Skip to content

Commit 388cb7d

Browse files
committed
Fix GH pages script plus logging
1 parent 43fe390 commit 388cb7d

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

tools/builder/prepare-gh-pages.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ function zipDirectory(sourceDir, outPath) {
3939
}
4040

4141
mkdirSync(join(cwd, "dist"), { recursive: true });
42-
mkdirSync(join(cwd, "dist/build"), { recursive: true });
4342

43+
console.log(`👉 Zipping TypeScript sources...`);
4444
await Promise.all(steps.map((step) => {
4545
return zipDirectory(join(cwd, "steps", step), join(cwd, "dist", `ui5-typescript-walkthrough-step-${step}.zip`))
4646
}));
47+
48+
mkdirSync(join(cwd, "dist/build"), { recursive: true });
49+
50+
console.log(`👉 Building steps...`);
4751
for (const step of steps) {
48-
console.log(`npx ui5 build --dest ${join(cwd, "dist", "build", `${step}`)}`);
52+
console.log(` 👉 Building step ${step}...`);
53+
//console.log(`npx ui5 build --dest ${join(cwd, "dist", "build", `${step}`)}`);
4954
await execute(`npx ui5 build --dest ${join(cwd, "dist", "build", `${step}`)}`, {
5055
cwd: join(cwd, "steps", step)
5156
});
@@ -55,25 +60,46 @@ function zipDirectory(sourceDir, outPath) {
5560
let content = `---\npermalink: ${path ? `build/${path.replace(".md", ".html")}` : "index.html"}\n---\n\n${readFileSync(file, { encoding: "utf8"})}`;
5661
content = content.replace(/steps\/(\d{2})/g, "build/$1");
5762
content = content.replace(/\.\.\/(\d{2})/g, "../$1");
58-
content = content.replace(/README\.md/g, "README.html");
63+
content = content.replace(/README\.md/g, "index.html");
5964
writeFileSync(file, content, { encoding: "utf8" });
6065
}
6166

67+
console.log(`👉 Copying README.md...`);
6268
copyFileSync(join(cwd, "README.md"), join(cwd, "dist/index.md"));
6369
rewriteLinks(join(cwd, "dist/index.md"));
64-
const readmes = fg.globSync(["steps/**/README.md"], { cwd });
70+
71+
console.log(` 🌅 Copying root assets....`);
72+
const rootAssets = fg.globSync(["**/*"], { cwd: join(cwd, "assets") });
73+
rootAssets.forEach((asset) => {
74+
mkdirSync(dirname(join(cwd, `dist/assets/${asset}`)), { recursive: true });
75+
copyFileSync(join(cwd, "assets", asset), join(cwd, `dist/assets/${asset}`));
76+
});
77+
78+
console.log(`👉 Copying steps README.md files...`);
79+
const readmes = fg.globSync(["steps/*/README.md"], { cwd });
6580
readmes.forEach((readme) => {
6681
const [, path, step] = readme.match("steps/((.*)/README.md)");
6782
mkdirSync(join(cwd, `dist/build/${step}`), { recursive: true });
6883
copyFileSync(join(cwd, readme), join(cwd, `dist/build/${path}`));
6984
rewriteLinks(join(cwd, `dist/build/${path}`), `${path}`);
7085
});
86+
console.log(` 🌅 Copying steps assets....`);
87+
const assets = fg.globSync(["steps/*/assets/**/*"], { cwd });
88+
assets.forEach((asset) => {
89+
const [, step, assetFile] = asset.match("steps/(.*)/assets/(.*)");
90+
mkdirSync(dirname(join(cwd, "dist/build", step, "assets", assetFile)), { recursive: true });
91+
copyFileSync(join(cwd, "steps", step, "assets", assetFile), join(cwd, "dist/build", step, "assets", assetFile));
92+
});
7193

94+
95+
console.log(`👉 Generate the JavaScript sources...`);
7296
await Promise.all(steps.map((step) => {
7397
const jsStepBaseDir = join(cwd, "steps", step);
7498
const buildOutputDir = join(cwd, "dist", "build", `${step}`);
7599
const targetDir = join(cwd, "dist", "steps", `${step}`);
76100

101+
console.log(` 👉 Generate sources for step ${step}...`);
102+
77103
// copy all files from buildOutputDir to targetDir except of TS files
78104
const files = fg.sync(["**/*"], { cwd: jsStepBaseDir, dot: true });
79105
files.forEach((file) => {
@@ -107,7 +133,7 @@ function zipDirectory(sourceDir, outPath) {
107133
}
108134
});
109135

110-
console.log(`${jsStepBaseDir} -> ${buildOutputDir}`);
136+
//console.log(`${jsStepBaseDir} -> ${buildOutputDir}`);
111137
return zipDirectory(join(cwd, "dist", "steps", `${step}`), join(cwd, "dist", `ui5-typescript-walkthrough-step-${step}-js.zip`))
112138
}));
113139

0 commit comments

Comments
 (0)