@@ -39,13 +39,18 @@ function zipDirectory(sourceDir, outPath) {
39
39
}
40
40
41
41
mkdirSync ( join ( cwd , "dist" ) , { recursive : true } ) ;
42
- mkdirSync ( join ( cwd , "dist/build" ) , { recursive : true } ) ;
43
42
43
+ console . log ( `👉 Zipping TypeScript sources...` ) ;
44
44
await Promise . all ( steps . map ( ( step ) => {
45
45
return zipDirectory ( join ( cwd , "steps" , step ) , join ( cwd , "dist" , `ui5-typescript-walkthrough-step-${ step } .zip` ) )
46
46
} ) ) ;
47
+
48
+ mkdirSync ( join ( cwd , "dist/build" ) , { recursive : true } ) ;
49
+
50
+ console . log ( `👉 Building steps...` ) ;
47
51
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}`)}`);
49
54
await execute ( `npx ui5 build --dest ${ join ( cwd , "dist" , "build" , `${ step } ` ) } ` , {
50
55
cwd : join ( cwd , "steps" , step )
51
56
} ) ;
@@ -55,25 +60,46 @@ function zipDirectory(sourceDir, outPath) {
55
60
let content = `---\npermalink: ${ path ? `build/${ path . replace ( ".md" , ".html" ) } ` : "index.html" } \n---\n\n${ readFileSync ( file , { encoding : "utf8" } ) } ` ;
56
61
content = content . replace ( / s t e p s \/ ( \d { 2 } ) / g, "build/$1" ) ;
57
62
content = content . replace ( / \. \. \/ ( \d { 2 } ) / g, "../$1" ) ;
58
- content = content . replace ( / R E A D M E \. m d / g, "README .html" ) ;
63
+ content = content . replace ( / R E A D M E \. m d / g, "index .html" ) ;
59
64
writeFileSync ( file , content , { encoding : "utf8" } ) ;
60
65
}
61
66
67
+ console . log ( `👉 Copying README.md...` ) ;
62
68
copyFileSync ( join ( cwd , "README.md" ) , join ( cwd , "dist/index.md" ) ) ;
63
69
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 } ) ;
65
80
readmes . forEach ( ( readme ) => {
66
81
const [ , path , step ] = readme . match ( "steps/((.*)/README.md)" ) ;
67
82
mkdirSync ( join ( cwd , `dist/build/${ step } ` ) , { recursive : true } ) ;
68
83
copyFileSync ( join ( cwd , readme ) , join ( cwd , `dist/build/${ path } ` ) ) ;
69
84
rewriteLinks ( join ( cwd , `dist/build/${ path } ` ) , `${ path } ` ) ;
70
85
} ) ;
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
+ } ) ;
71
93
94
+
95
+ console . log ( `👉 Generate the JavaScript sources...` ) ;
72
96
await Promise . all ( steps . map ( ( step ) => {
73
97
const jsStepBaseDir = join ( cwd , "steps" , step ) ;
74
98
const buildOutputDir = join ( cwd , "dist" , "build" , `${ step } ` ) ;
75
99
const targetDir = join ( cwd , "dist" , "steps" , `${ step } ` ) ;
76
100
101
+ console . log ( ` 👉 Generate sources for step ${ step } ...` ) ;
102
+
77
103
// copy all files from buildOutputDir to targetDir except of TS files
78
104
const files = fg . sync ( [ "**/*" ] , { cwd : jsStepBaseDir , dot : true } ) ;
79
105
files . forEach ( ( file ) => {
@@ -107,7 +133,7 @@ function zipDirectory(sourceDir, outPath) {
107
133
}
108
134
} ) ;
109
135
110
- console . log ( `${ jsStepBaseDir } -> ${ buildOutputDir } ` ) ;
136
+ // console.log(`${jsStepBaseDir} -> ${buildOutputDir}`);
111
137
return zipDirectory ( join ( cwd , "dist" , "steps" , `${ step } ` ) , join ( cwd , "dist" , `ui5-typescript-walkthrough-step-${ step } -js.zip` ) )
112
138
} ) ) ;
113
139
0 commit comments