Skip to content

Commit a26f393

Browse files
♻️ refactor(template-resolve): remove implicit default template fallback
- Require explicit "template" in JSON, error if missing - diff module resolves template from JSON instead of hardcoded path - package_zip.sh: update template filenames
1 parent 5d9197b commit a26f393

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎skill/scripts/package_zip.sh‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/bash
2-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
# SPDX-License-Identifier: MIT-0
4-
# spec-driven-presentation-maker配布用zipを作成してDesktopに配置する
2+
# pptx-maker配布用zipを作成してDesktopに配置する
53
set -euo pipefail
64

75
SRC="$(cd "$(dirname "$0")/.." && pwd)"
8-
OUT=~/Desktop/spec-driven-presentation-maker.zip
6+
OUT=~/Desktop/pptx-maker.zip
97

108
cd "$SRC"
119
rm -f "$OUT"
@@ -28,7 +26,7 @@ zip -r "$OUT" . \
2826
-x 'tests/*'
2927

3028
# テンプレートだけ追加
31-
zip "$OUT" templates/default-dark.pptx templates/default-light.pptx
29+
zip "$OUT" templates/aws-brand-dark.pptx templates/aws-brand-light.pptx
3230

3331
echo ""
3432
echo "Created: $OUT"

‎skill/scripts/pptx_builder.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272

7373
def _resolve_template(data, input_path):
74-
"""Resolve template path: presentation.json "template" → templates/default-dark.pptx → repo fallback."""
74+
"""Resolve template path: presentation.json "template" → templates/ lookup → error."""
7575
templates_dir = Path(__file__).parent.parent / "templates"
7676

7777
if data.get("template"):
@@ -85,11 +85,7 @@ def _resolve_template(data, input_path):
8585
if named.exists():
8686
return named, True
8787

88-
default = templates_dir / "default-dark.pptx"
89-
if default.exists():
90-
return default, False
91-
92-
print(f"Error: No template found. Place a template in {templates_dir}/ or set \"template\" in presentation JSON", file=sys.stderr)
88+
print("Error: No template specified. Set \"template\" in presentation JSON.", file=sys.stderr)
9389
sys.exit(1)
9490

9591

‎skill/sdpm/diff/__init__.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,17 @@ def load_slides_json_or_pptx(path):
165165
with tempfile.TemporaryDirectory() as tmpdir:
166166
tmp_pptx = Path(tmpdir) / "tmp.pptx"
167167
from sdpm.builder import PPTXBuilder, resolve_override
168-
template = Path(__file__).resolve().parent.parent.parent / "templates" / "default-dark.pptx"
168+
templates_dir = Path(__file__).resolve().parent.parent.parent / "templates"
169+
tpl_name = data.get("template")
170+
if not tpl_name:
171+
raise ValueError("No \"template\" specified in JSON. Cannot build for diff.")
172+
template = Path(path).parent / tpl_name
173+
if not template.exists():
174+
named = templates_dir / (tpl_name if tpl_name.endswith(".pptx") else tpl_name + ".pptx")
175+
if named.exists():
176+
template = named
177+
else:
178+
raise FileNotFoundError(f"Template not found: {tpl_name}")
169179
builder = PPTXBuilder(template, fonts=data.get("fonts"), base_dir=Path(path).parent,
170180
default_text_color=data.get("defaultTextColor", "#FFFFFF"))
171181
id_map = {s["id"]: s for s in data.get("slides", []) if "id" in s}

0 commit comments

Comments
 (0)