Skip to content

Commit ad5ba74

Browse files
committed
Copy multiple sources
1 parent 6855e7d commit ad5ba74

1 file changed

Lines changed: 31 additions & 25 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -102,43 +102,49 @@ jobs:
102102
description = meta.get("description", "")
103103
screenshot_rel = meta.get("screenshot")
104104
105-
# Allow distDirs list, fallback to single distDir
106-
dist_dirs_rel = []
107-
if isinstance(meta.get("distDirs"), list):
108-
dist_dirs_rel = meta["distDirs"]
109-
elif isinstance(meta.get("distDir"), str):
110-
dist_dirs_rel = [meta["distDir"]]
105+
# Only support multi dist directories; ignore legacy single distDir
106+
dist_dirs_rel = meta.get("distDirs", []) if isinstance(meta.get("distDirs"), list) else []
111107
112108
if not app_id:
113109
print(f"[WARN] {meta_path} missing 'id', skipping.")
114110
continue
115111
112+
# If no distDirs provided, just register app for index but skip copy
116113
if not dist_dirs_rel:
117-
print(f"[WARN] {meta_path} missing 'distDirs'/'distDir', skipping.")
118-
continue
114+
print(f"[INFO] {meta_path} has no 'distDirs'; will only list app on index (no files copied).")
119115
120116
project_root = dirpath
121117
122-
# Choose first distDir that contains index.html
123-
chosen_dist_dir = None
124-
for rel in dist_dirs_rel:
125-
cand_dist = os.path.join(project_root, rel)
126-
cand_index = os.path.join(cand_dist, "index.html")
127-
if os.path.exists(cand_index):
128-
chosen_dist_dir = cand_dist
129-
break
130-
131-
if not chosen_dist_dir:
132-
print(f"[INFO] No index.html in any distDir for {app_id}, skipping.")
133-
continue
134-
135-
print(f"[OK] Using dist dir {chosen_dist_dir} for app {app_id}")
136-
137-
# Copy dist folder into site/<id>/
118+
# Helper: merge-copy contents of src into dst (overwrite on conflicts)
119+
def merge_copy(src: str, dst: str):
120+
if not os.path.exists(src):
121+
return
122+
os.makedirs(dst, exist_ok=True)
123+
for name in os.listdir(src):
124+
s = os.path.join(src, name)
125+
d = os.path.join(dst, name)
126+
if os.path.isdir(s):
127+
merge_copy(s, d)
128+
else:
129+
os.makedirs(os.path.dirname(d), exist_ok=True)
130+
try:
131+
shutil.copy2(s, d)
132+
except Exception as e:
133+
print(f"[WARN] Failed to copy {s} -> {d}: {e}")
134+
135+
# Copy contents of every configured distDir into site/<id>/ (no validation)
138136
target_app_dir = os.path.join(SITE_DIR, app_id)
139137
if os.path.exists(target_app_dir):
140138
shutil.rmtree(target_app_dir)
141-
shutil.copytree(chosen_dist_dir, target_app_dir)
139+
os.makedirs(target_app_dir, exist_ok=True)
140+
141+
for rel in dist_dirs_rel:
142+
src_dir = os.path.join(project_root, rel)
143+
if not os.path.exists(src_dir):
144+
print(f"[INFO] distDir does not exist (skipped): {src_dir}")
145+
continue
146+
print(f"[OK] Merging distDir for {app_id}: {src_dir} -> {target_app_dir}")
147+
merge_copy(src_dir, target_app_dir)
142148
143149
screenshot_target = None
144150
if screenshot_rel:

0 commit comments

Comments
 (0)