@@ -2,6 +2,20 @@ const takeWhile = require("lodash/takeWhile");
2
2
const { execSync } = require ( "child_process" ) ;
3
3
const fs = require ( "fs" ) ;
4
4
const path = require ( "path" ) ;
5
+ const yargs = require ( "yargs" ) ;
6
+
7
+ const args = yargs ( process . argv . slice ( 2 ) )
8
+ . usage ( "$0 [--ci --docker keyed/framework1 ... non-keyed/frameworkN]" )
9
+ . help ( )
10
+ . boolean ( "ci" )
11
+ . default ( "ci" , false )
12
+ . describe ( "ci" , "Use npm ci or npm install?" )
13
+ . boolean ( "docker" )
14
+ . default ( "docker" , false )
15
+ . describe (
16
+ "docker" ,
17
+ "Copy package-lock back for docker build or build locally?"
18
+ ) . argv ;
5
19
6
20
/*
7
21
This script rebuilds all frameworks from scratch,
@@ -12,31 +26,46 @@ If building a framework fails you can resume building like
12
26
npm run rebuild-frameworks --restartWith keyed/react
13
27
*/
14
28
15
- const cliArgs = process . argv . slice ( 2 ) ;
16
-
17
- // Use npm ci or npm install ?
18
- const useCi = cliArgs . includes ( "--ci" ) ;
29
+ /**
30
+ * Use npm ci or npm install?
31
+ * @type {boolean }
32
+ */
33
+ const useCi = args . ci ;
19
34
20
- // Copy package-lock back for docker build or build locally?
21
- const useDocker = cliArgs . includes ( "--docker" ) ;
35
+ /**
36
+ * Copy package-lock back for docker build or build locally?
37
+ * @type {boolean }
38
+ */
39
+ const useDocker = args . docker ;
22
40
23
- const restartBuildingWith = cliArgs . find ( ( arg ) => ! arg . startsWith ( "--" ) ) ;
41
+ const restartBuildingWith = args . _ . find ( ( arg ) => ! arg . startsWith ( "--" ) ) ;
24
42
const restartWithFramework = restartBuildingWith || "" ;
25
43
26
44
console . log (
27
45
"ARGS" ,
46
+ args ,
28
47
"ci" ,
29
48
useCi ,
30
49
"docker" ,
31
50
useDocker ,
32
51
"restartWith" ,
33
- restartWithFramework ,
52
+ restartWithFramework
34
53
) ;
35
54
55
+ const filesToDelete = [
56
+ "yarn-lock" ,
57
+ "dist" ,
58
+ "elm-stuff" ,
59
+ "bower_components" ,
60
+ "node_modules" ,
61
+ "output" ,
62
+ useCi && "package-lock.json" ,
63
+ ] . filter ( Boolean ) ;
64
+
36
65
/**
37
66
* @typedef {Object } Framework
38
- * @property {string } type - Type of the framework (e.g., "keyed" or "non-keyed")
39
67
* @property {string } name - Name of the framework (e.g., "vue", "qwik", "svelte")
68
+ * @property {string } type - Type of the framework (e.g., "keyed" or "non-keyed")
40
69
*/
41
70
42
71
/**
@@ -45,13 +74,14 @@ console.log(
45
74
* @returns {Framework[] }
46
75
*/
47
76
function getFrameworks ( ) {
48
- const keyedFrameworks = fs
49
- . readdirSync ( "./frameworks/keyed" )
50
- . map ( ( framework ) => ( { type : "keyed" , name : framework } ) ) ;
51
- const nonKeyedFrameworks = fs
52
- . readdirSync ( "./frameworks/non-keyed" )
53
- . map ( ( framework ) => ( { type : "non-keyed" , name : framework } ) ) ;
54
- return [ ...keyedFrameworks , ...nonKeyedFrameworks ] ;
77
+ const keyedTypes = [ "keyed" , "non-keyed" ] ;
78
+ const framewokrs = keyedTypes . flatMap ( ( type ) =>
79
+ fs
80
+ . readdirSync ( path . join ( "frameworks" , type ) )
81
+ . map ( ( framework ) => ( { name : framework , type } ) )
82
+ ) ;
83
+
84
+ return framewokrs ;
55
85
}
56
86
57
87
/**
@@ -68,7 +98,7 @@ function shouldSkipFramework({ type, name }) {
68
98
}
69
99
70
100
/**
71
- * Run a command synchronously in the specified directory
101
+ * Run a command synchronously in the specified directory and log command
72
102
* @param {string } command - The command to run
73
103
* @param {string } cwd - The current working directory (optional)
74
104
*/
@@ -111,15 +141,6 @@ function buildFramework(framework) {
111
141
// execSync(`rm -r ${path}`);
112
142
// }
113
143
// rsync(keyed,name);
114
- const filesToDelete = [
115
- "yarn-lock" ,
116
- "dist" ,
117
- "elm-stuff" ,
118
- "bower_components" ,
119
- "node_modules" ,
120
- "output" ,
121
- useCi ? "" : "package-lock.json" ,
122
- ] ;
123
144
124
145
deleteFrameworkFiles ( frameworkPath , filesToDelete ) ;
125
146
@@ -141,7 +162,7 @@ function buildFrameworks() {
141
162
const skippableFrameworks = takeWhile ( frameworks , shouldSkipFramework ) ;
142
163
const buildableFrameworks = frameworks . slice ( skippableFrameworks . length ) ;
143
164
144
- console . log ( "Building frameworks:" , buildableFrameworks ) ;
165
+ // console.log("Building frameworks:", buildableFrameworks);
145
166
146
167
for ( const framework of buildableFrameworks ) {
147
168
buildFramework ( framework ) ;
0 commit comments