@tsparticles/cli 3.1.7 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js-ci.yml +0 -2
- package/.planning/PROJECT.md +43 -0
- package/.planning/REQUIREMENTS.md +41 -0
- package/.planning/ROADMAP.md +41 -0
- package/.planning/STATE.md +6 -0
- package/.planning/codebase/ARCHITECTURE.md +3 -0
- package/.planning/codebase/CONCERNS.md +3 -0
- package/.planning/codebase/CONVENTIONS.md +3 -0
- package/.planning/codebase/INTEGRATIONS.md +3 -0
- package/.planning/codebase/STACK.md +11 -0
- package/.planning/codebase/STRUCTURE.md +3 -0
- package/.planning/codebase/TESTING.md +3 -0
- package/.planning/config.json +1 -0
- package/.planning/research/ARCHITECTURE.md +1 -0
- package/.planning/research/FEATURES.md +1 -0
- package/.planning/research/PITFALLS.md +1 -0
- package/.planning/research/STACK.md +1 -0
- package/.planning/research/SUMMARY.md +9 -0
- package/dist/build/build-bundle.d.ts +2 -1
- package/dist/build/build-bundle.js +8 -3
- package/dist/build/build-circular-deps.d.ts +2 -1
- package/dist/build/build-circular-deps.js +8 -3
- package/dist/build/build-clear.d.ts +2 -1
- package/dist/build/build-clear.js +8 -3
- package/dist/build/build-distfiles.d.ts +2 -1
- package/dist/build/build-distfiles.js +11 -4
- package/dist/build/build-eslint.d.ts +2 -1
- package/dist/build/build-eslint.js +8 -3
- package/dist/build/build-prettier.d.ts +8 -4
- package/dist/build/build-prettier.js +50 -19
- package/dist/build/build-tsc.d.ts +2 -1
- package/dist/build/build-tsc.js +17 -7
- package/dist/build/build.js +32 -24
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/files/empty-project/package.json +8 -8
- package/package.json +10 -10
- package/src/build/build-bundle.ts +8 -3
- package/src/build/build-circular-deps.ts +8 -3
- package/src/build/build-clear.ts +8 -3
- package/src/build/build-distfiles.ts +11 -4
- package/src/build/build-eslint.ts +8 -3
- package/src/build/build-prettier.ts +50 -19
- package/src/build/build-tsc.ts +21 -7
- package/src/build/build.ts +36 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/cli",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,18 +16,18 @@
|
|
|
16
16
|
},
|
|
17
17
|
"prettier": "@tsparticles/prettier-config",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@swc/core": "^1.15.
|
|
20
|
-
"@tsparticles/depcruise-config": "^3.
|
|
21
|
-
"@tsparticles/eslint-config": "^3.
|
|
22
|
-
"@tsparticles/prettier-config": "^3.
|
|
23
|
-
"@tsparticles/tsconfig": "^3.
|
|
24
|
-
"@tsparticles/webpack-plugin": "^3.
|
|
19
|
+
"@swc/core": "^1.15.18",
|
|
20
|
+
"@tsparticles/depcruise-config": "^3.2.0",
|
|
21
|
+
"@tsparticles/eslint-config": "^3.2.0",
|
|
22
|
+
"@tsparticles/prettier-config": "^3.2.0",
|
|
23
|
+
"@tsparticles/tsconfig": "^3.2.0",
|
|
24
|
+
"@tsparticles/webpack-plugin": "^3.2.0",
|
|
25
25
|
"commander": "^14.0.3",
|
|
26
26
|
"eslint": "^9.39.3",
|
|
27
27
|
"eslint-config-prettier": "^10.1.8",
|
|
28
28
|
"eslint-plugin-jsdoc": "^62.7.1",
|
|
29
29
|
"eslint-plugin-prettier": "^5.5.5",
|
|
30
|
-
"eslint-plugin-tsdoc": "^0.5.
|
|
30
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
31
31
|
"fs-extra": "^11.3.3",
|
|
32
32
|
"klaw": "^4.1.0",
|
|
33
33
|
"lookpath": "^1.2.3",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"swc-loader": "^0.2.7",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
42
|
"typescript-eslint": "^8.56.1",
|
|
43
|
-
"webpack": "^5.105.
|
|
43
|
+
"webpack": "^5.105.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@tsparticles/cli": "latest",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/estree": "^1.0.8",
|
|
50
50
|
"@types/fs-extra": "^11.0.4",
|
|
51
51
|
"@types/klaw": "^3.0.7",
|
|
52
|
-
"@types/node": "^25.3.
|
|
52
|
+
"@types/node": "^25.3.3",
|
|
53
53
|
"@types/prompts": "^2.4.9",
|
|
54
54
|
"@types/webpack-env": "^1.18.8",
|
|
55
55
|
"browserslist": "^4.28.1",
|
|
@@ -3,10 +3,13 @@ import webpack from "webpack";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @param basePath -
|
|
6
|
+
* @param silent -
|
|
6
7
|
* @returns true if the bundle was created
|
|
7
8
|
*/
|
|
8
|
-
export async function bundle(basePath: string): Promise<boolean> {
|
|
9
|
-
|
|
9
|
+
export async function bundle(basePath: string, silent: boolean): Promise<boolean> {
|
|
10
|
+
if (!silent) {
|
|
11
|
+
console.log("Bundling started");
|
|
12
|
+
}
|
|
10
13
|
|
|
11
14
|
let res = false;
|
|
12
15
|
|
|
@@ -54,7 +57,9 @@ export async function bundle(basePath: string): Promise<boolean> {
|
|
|
54
57
|
res = false;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
if (!silent) {
|
|
61
|
+
console.log("Bundling done");
|
|
62
|
+
}
|
|
58
63
|
|
|
59
64
|
return res;
|
|
60
65
|
}
|
|
@@ -7,9 +7,10 @@ const ZERO_VIOLATIONS = 0;
|
|
|
7
7
|
/**
|
|
8
8
|
* Checks for circular dependencies using dependency-cruiser
|
|
9
9
|
* @param basePath - The project root path
|
|
10
|
+
* @param silent - If true, reduces the amount of output during the check
|
|
10
11
|
* @returns true if no circular dependencies are found, false otherwise
|
|
11
12
|
*/
|
|
12
|
-
export async function buildCircularDeps(basePath: string): Promise<boolean> {
|
|
13
|
+
export async function buildCircularDeps(basePath: string, silent: boolean): Promise<boolean> {
|
|
13
14
|
const srcPath = path.join(basePath, "src"),
|
|
14
15
|
cruiseOptions = await loadDependencyCruiserConfig(basePath);
|
|
15
16
|
|
|
@@ -35,7 +36,9 @@ export async function buildCircularDeps(basePath: string): Promise<boolean> {
|
|
|
35
36
|
return false;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
if (!silent) {
|
|
40
|
+
console.log("✅ No circular dependencies found.");
|
|
41
|
+
}
|
|
39
42
|
|
|
40
43
|
return true;
|
|
41
44
|
} catch (e) {
|
|
@@ -43,6 +46,8 @@ export async function buildCircularDeps(basePath: string): Promise<boolean> {
|
|
|
43
46
|
|
|
44
47
|
return false;
|
|
45
48
|
} finally {
|
|
46
|
-
|
|
49
|
+
if (!silent) {
|
|
50
|
+
console.log("Finished checking circular dependencies.");
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
}
|
package/src/build/build-clear.ts
CHANGED
|
@@ -3,10 +3,13 @@ import { rimraf } from "rimraf";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @param basePath -
|
|
6
|
+
* @param silent -
|
|
6
7
|
* @returns true if the dist folder was cleared
|
|
7
8
|
*/
|
|
8
|
-
export async function clearDist(basePath: string): Promise<boolean> {
|
|
9
|
-
|
|
9
|
+
export async function clearDist(basePath: string, silent: boolean): Promise<boolean> {
|
|
10
|
+
if (!silent) {
|
|
11
|
+
console.log("Clearing dist folder");
|
|
12
|
+
}
|
|
10
13
|
|
|
11
14
|
let res = false;
|
|
12
15
|
|
|
@@ -20,7 +23,9 @@ export async function clearDist(basePath: string): Promise<boolean> {
|
|
|
20
23
|
res = false;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
if (!silent) {
|
|
27
|
+
console.log("Clearing dist folder done");
|
|
28
|
+
}
|
|
24
29
|
|
|
25
30
|
return res;
|
|
26
31
|
}
|
|
@@ -4,10 +4,13 @@ import path from "node:path";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param basePath -
|
|
7
|
+
* @param silent -
|
|
7
8
|
* @returns true if the dist files process was successful
|
|
8
9
|
*/
|
|
9
|
-
export async function buildDistFiles(basePath: string): Promise<boolean> {
|
|
10
|
-
|
|
10
|
+
export async function buildDistFiles(basePath: string, silent: boolean): Promise<boolean> {
|
|
11
|
+
if (!silent) {
|
|
12
|
+
console.log("Build - started on dist files");
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
let res: boolean;
|
|
13
16
|
|
|
@@ -36,7 +39,9 @@ export async function buildDistFiles(basePath: string): Promise<boolean> {
|
|
|
36
39
|
|
|
37
40
|
await fs.writeFile(libPackage, `${JSON.stringify(libObj, undefined, jsonIndent)}\n`, "utf8");
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
if (!silent) {
|
|
43
|
+
console.log(`package.dist.json updated successfully to version ${pkgInfo.version}`);
|
|
44
|
+
}
|
|
40
45
|
|
|
41
46
|
const rootFilesToCopy = [
|
|
42
47
|
"LICENSE",
|
|
@@ -96,7 +101,9 @@ export async function buildDistFiles(basePath: string): Promise<boolean> {
|
|
|
96
101
|
res = false;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
|
|
104
|
+
if (!silent) {
|
|
105
|
+
console.log("Build - done on dist files");
|
|
106
|
+
}
|
|
100
107
|
|
|
101
108
|
return res;
|
|
102
109
|
}
|
|
@@ -2,10 +2,13 @@ import { ESLint } from "eslint";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param ci -
|
|
5
|
+
* @param silent -
|
|
5
6
|
* @returns true if the linting was successful
|
|
6
7
|
*/
|
|
7
|
-
export async function lint(ci: boolean): Promise<boolean> {
|
|
8
|
-
|
|
8
|
+
export async function lint(ci: boolean, silent: boolean): Promise<boolean> {
|
|
9
|
+
if (!silent) {
|
|
10
|
+
console.log("ESLint - started on src");
|
|
11
|
+
}
|
|
9
12
|
|
|
10
13
|
let res: boolean;
|
|
11
14
|
|
|
@@ -39,7 +42,9 @@ export async function lint(ci: boolean): Promise<boolean> {
|
|
|
39
42
|
res = false;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
if (!silent) {
|
|
46
|
+
console.log("ESLint - done on src");
|
|
47
|
+
}
|
|
43
48
|
|
|
44
49
|
return res;
|
|
45
50
|
}
|
|
@@ -7,10 +7,13 @@ import prettier from "prettier";
|
|
|
7
7
|
* @param basePath -
|
|
8
8
|
* @param srcPath -
|
|
9
9
|
* @param ci -
|
|
10
|
+
* @param silent -
|
|
10
11
|
* @returns true if the prettify src process was successful
|
|
11
12
|
*/
|
|
12
|
-
export async function prettifySrc(basePath: string, srcPath: string, ci: boolean): Promise<boolean> {
|
|
13
|
-
|
|
13
|
+
export async function prettifySrc(basePath: string, srcPath: string, ci: boolean, silent: boolean): Promise<boolean> {
|
|
14
|
+
if (!silent) {
|
|
15
|
+
console.log("Prettier - started on src");
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
let res: boolean;
|
|
16
19
|
|
|
@@ -47,7 +50,9 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
47
50
|
res = false;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
if (!silent) {
|
|
54
|
+
console.log("Prettier - done on src");
|
|
55
|
+
}
|
|
51
56
|
|
|
52
57
|
return res;
|
|
53
58
|
}
|
|
@@ -55,10 +60,13 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
55
60
|
/**
|
|
56
61
|
* @param basePath -
|
|
57
62
|
* @param ci -
|
|
63
|
+
* @param silent -
|
|
58
64
|
* @returns true if the prettify package.json process was successful
|
|
59
65
|
*/
|
|
60
|
-
export async function prettifyPackageJson(basePath: string, ci: boolean): Promise<boolean> {
|
|
61
|
-
|
|
66
|
+
export async function prettifyPackageJson(basePath: string, ci: boolean, silent: boolean): Promise<boolean> {
|
|
67
|
+
if (!silent) {
|
|
68
|
+
console.log("Prettier - started on package.json");
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
let res: boolean;
|
|
64
72
|
|
|
@@ -88,7 +96,9 @@ export async function prettifyPackageJson(basePath: string, ci: boolean): Promis
|
|
|
88
96
|
res = false;
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
|
|
99
|
+
if (!silent) {
|
|
100
|
+
console.log("Prettier - done on package.json");
|
|
101
|
+
}
|
|
92
102
|
|
|
93
103
|
return res;
|
|
94
104
|
}
|
|
@@ -96,10 +106,13 @@ export async function prettifyPackageJson(basePath: string, ci: boolean): Promis
|
|
|
96
106
|
/**
|
|
97
107
|
* @param basePath -
|
|
98
108
|
* @param _ci -
|
|
109
|
+
* @param silent -
|
|
99
110
|
* @returns true if the prettify package.dist.json process was successful
|
|
100
111
|
*/
|
|
101
|
-
export async function prettifyPackageDistJson(basePath: string, _ci: boolean): Promise<boolean> {
|
|
102
|
-
|
|
112
|
+
export async function prettifyPackageDistJson(basePath: string, _ci: boolean, silent: boolean): Promise<boolean> {
|
|
113
|
+
if (!silent) {
|
|
114
|
+
console.log("Prettier - started on package.dist.json");
|
|
115
|
+
}
|
|
103
116
|
|
|
104
117
|
let res: boolean;
|
|
105
118
|
|
|
@@ -131,7 +144,9 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean): P
|
|
|
131
144
|
res = false;
|
|
132
145
|
}
|
|
133
146
|
|
|
134
|
-
|
|
147
|
+
if (!silent) {
|
|
148
|
+
console.log("Prettier - done on package.dist.json");
|
|
149
|
+
}
|
|
135
150
|
|
|
136
151
|
return res;
|
|
137
152
|
}
|
|
@@ -139,10 +154,13 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean): P
|
|
|
139
154
|
/**
|
|
140
155
|
* @param basePath -
|
|
141
156
|
* @param ci -
|
|
157
|
+
* @param silent -
|
|
142
158
|
* @returns true if the prettify readme process was successful
|
|
143
159
|
*/
|
|
144
|
-
export async function prettifyReadme(basePath: string, ci: boolean): Promise<boolean> {
|
|
145
|
-
|
|
160
|
+
export async function prettifyReadme(basePath: string, ci: boolean, silent: boolean): Promise<boolean> {
|
|
161
|
+
if (!silent) {
|
|
162
|
+
console.log("Prettier - started on README.md");
|
|
163
|
+
}
|
|
146
164
|
|
|
147
165
|
let res: boolean;
|
|
148
166
|
|
|
@@ -164,14 +182,17 @@ export async function prettifyReadme(basePath: string, ci: boolean): Promise<boo
|
|
|
164
182
|
await fs.writeFile("README.md", formatted, "utf8");
|
|
165
183
|
}
|
|
166
184
|
|
|
167
|
-
res =
|
|
185
|
+
res =
|
|
186
|
+
(await prettifyTraductions(basePath, ci, silent)) && (await prettifyMarkdownTypeDocFiles(basePath, ci, silent));
|
|
168
187
|
} catch (e) {
|
|
169
188
|
console.error(e);
|
|
170
189
|
|
|
171
190
|
res = false;
|
|
172
191
|
}
|
|
173
192
|
|
|
174
|
-
|
|
193
|
+
if (!silent) {
|
|
194
|
+
console.log("Prettier - done on README.md");
|
|
195
|
+
}
|
|
175
196
|
|
|
176
197
|
return res;
|
|
177
198
|
}
|
|
@@ -179,10 +200,13 @@ export async function prettifyReadme(basePath: string, ci: boolean): Promise<boo
|
|
|
179
200
|
/**
|
|
180
201
|
* @param basePath -
|
|
181
202
|
* @param ci -
|
|
203
|
+
* @param silent -
|
|
182
204
|
* @returns true if the prettify traductions process was successful
|
|
183
205
|
*/
|
|
184
|
-
async function prettifyTraductions(basePath: string, ci: boolean): Promise<boolean> {
|
|
185
|
-
|
|
206
|
+
async function prettifyTraductions(basePath: string, ci: boolean, silent: boolean): Promise<boolean> {
|
|
207
|
+
if (!silent) {
|
|
208
|
+
console.log("Prettier - started on traductions");
|
|
209
|
+
}
|
|
186
210
|
|
|
187
211
|
let res = false;
|
|
188
212
|
|
|
@@ -226,7 +250,9 @@ async function prettifyTraductions(basePath: string, ci: boolean): Promise<boole
|
|
|
226
250
|
res = false;
|
|
227
251
|
}
|
|
228
252
|
|
|
229
|
-
|
|
253
|
+
if (!silent) {
|
|
254
|
+
console.log("Prettier - done on traductions");
|
|
255
|
+
}
|
|
230
256
|
|
|
231
257
|
return res;
|
|
232
258
|
}
|
|
@@ -234,10 +260,13 @@ async function prettifyTraductions(basePath: string, ci: boolean): Promise<boole
|
|
|
234
260
|
/**
|
|
235
261
|
* @param basePath -
|
|
236
262
|
* @param ci -
|
|
263
|
+
* @param silent -
|
|
237
264
|
* @returns true if the prettify markdown typedoc files process was successful
|
|
238
265
|
*/
|
|
239
|
-
async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean): Promise<boolean> {
|
|
240
|
-
|
|
266
|
+
async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean, silent: boolean): Promise<boolean> {
|
|
267
|
+
if (!silent) {
|
|
268
|
+
console.log("Prettier - started on markdown");
|
|
269
|
+
}
|
|
241
270
|
|
|
242
271
|
let res = false;
|
|
243
272
|
|
|
@@ -281,7 +310,9 @@ async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean): Prom
|
|
|
281
310
|
res = false;
|
|
282
311
|
}
|
|
283
312
|
|
|
284
|
-
|
|
313
|
+
if (!silent) {
|
|
314
|
+
console.log("Prettier - done on markdown");
|
|
315
|
+
}
|
|
285
316
|
|
|
286
317
|
return res;
|
|
287
318
|
}
|
package/src/build/build-tsc.ts
CHANGED
|
@@ -29,9 +29,14 @@ async function readConfig(basePath: string, file: string): Promise<string | unde
|
|
|
29
29
|
/**
|
|
30
30
|
* @param basePath -
|
|
31
31
|
* @param type -
|
|
32
|
+
* @param silent -
|
|
32
33
|
* @returns the exit code
|
|
33
34
|
*/
|
|
34
|
-
async function compile(
|
|
35
|
+
async function compile(
|
|
36
|
+
basePath: string,
|
|
37
|
+
type: "browser" | "cjs" | "esm" | "types" | "umd",
|
|
38
|
+
silent: boolean,
|
|
39
|
+
): Promise<number> {
|
|
35
40
|
let options: unknown, data: string | undefined;
|
|
36
41
|
|
|
37
42
|
switch (type) {
|
|
@@ -156,26 +161,33 @@ async function compile(basePath: string, type: "browser" | "cjs" | "esm" | "type
|
|
|
156
161
|
|
|
157
162
|
const exitCode = emitResult.emitSkipped || failed ? ExitCodes.EmitErrors : ExitCodes.OK;
|
|
158
163
|
|
|
159
|
-
|
|
164
|
+
if (!silent || exitCode) {
|
|
165
|
+
console.log(`TSC for ${type} done with exit code: '${exitCode.toLocaleString()}'.`);
|
|
166
|
+
}
|
|
160
167
|
|
|
161
168
|
return exitCode;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
/**
|
|
165
172
|
* @param basePath -
|
|
173
|
+
* @param silent -
|
|
166
174
|
* @returns true if the build was successful
|
|
167
175
|
*/
|
|
168
|
-
export async function buildTS(basePath: string): Promise<boolean> {
|
|
169
|
-
|
|
176
|
+
export async function buildTS(basePath: string, silent: boolean): Promise<boolean> {
|
|
177
|
+
if (!silent) {
|
|
178
|
+
console.log("Building TS files");
|
|
179
|
+
}
|
|
170
180
|
|
|
171
181
|
let res = true;
|
|
172
182
|
|
|
173
183
|
const types: ("browser" | "cjs" | "esm" | "types" | "umd")[] = ["browser", "cjs", "esm", "types", "umd"];
|
|
174
184
|
|
|
175
185
|
for (const type of types) {
|
|
176
|
-
|
|
186
|
+
if (!silent) {
|
|
187
|
+
console.log(`Building TS files for ${type} configuration`);
|
|
188
|
+
}
|
|
177
189
|
|
|
178
|
-
const exitCode = await compile(basePath, type);
|
|
190
|
+
const exitCode = await compile(basePath, type, silent);
|
|
179
191
|
|
|
180
192
|
if (exitCode) {
|
|
181
193
|
res = false;
|
|
@@ -184,7 +196,9 @@ export async function buildTS(basePath: string): Promise<boolean> {
|
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
198
|
|
|
187
|
-
|
|
199
|
+
if (!silent) {
|
|
200
|
+
console.log("Building TS files done");
|
|
201
|
+
}
|
|
188
202
|
|
|
189
203
|
return res;
|
|
190
204
|
}
|
package/src/build/build.ts
CHANGED
|
@@ -12,13 +12,18 @@ buildCommand.option("-b, --bundle", "Bundle the library using Webpack", false);
|
|
|
12
12
|
buildCommand.option("-c, --clean", "Clean the dist folder", false);
|
|
13
13
|
buildCommand.option(
|
|
14
14
|
"--ci",
|
|
15
|
-
"Do all build steps for CI, no fixing files, only checking if they are formatted correctly",
|
|
15
|
+
"Do all build steps for CI, no fixing files, only checking if they are formatted correctly, sets silent to true by default",
|
|
16
16
|
false,
|
|
17
17
|
);
|
|
18
18
|
buildCommand.option("-r, --circular-deps", "Check for circular dependencies", false);
|
|
19
19
|
buildCommand.option("-d, --dist", "Build the dist files", false);
|
|
20
20
|
buildCommand.option("-l, --lint", "Lint the source files", false);
|
|
21
21
|
buildCommand.option("-p, --prettify", "Prettify the source files", false);
|
|
22
|
+
buildCommand.option(
|
|
23
|
+
"-s, --silent <boolean>",
|
|
24
|
+
"Reduce the amount of output during the build, defaults to false, except when --ci is set",
|
|
25
|
+
false,
|
|
26
|
+
);
|
|
22
27
|
buildCommand.option("-t, --tsc", "Build the library using TypeScript", false);
|
|
23
28
|
|
|
24
29
|
buildCommand.argument("[path]", `Path to the project root folder, default is "src"`, "src");
|
|
@@ -35,6 +40,7 @@ buildCommand.action(async (argPath: string) => {
|
|
|
35
40
|
doLint = all || !!opts["lint"],
|
|
36
41
|
prettier = all || !!opts["prettify"],
|
|
37
42
|
tsc = all || !!opts["tsc"],
|
|
43
|
+
silent = !!opts["silent"] || ci,
|
|
38
44
|
basePath = process.cwd(),
|
|
39
45
|
{ getDistStats } = await import("./build-diststats.js"),
|
|
40
46
|
oldStats = await getDistStats(basePath);
|
|
@@ -42,7 +48,7 @@ buildCommand.action(async (argPath: string) => {
|
|
|
42
48
|
if (clean) {
|
|
43
49
|
const { clearDist } = await import("./build-clear.js");
|
|
44
50
|
|
|
45
|
-
await clearDist(basePath);
|
|
51
|
+
await clearDist(basePath, silent);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
const path = await import("path"),
|
|
@@ -58,60 +64,66 @@ buildCommand.action(async (argPath: string) => {
|
|
|
58
64
|
if (prettier) {
|
|
59
65
|
const { prettifySrc } = await import("./build-prettier.js");
|
|
60
66
|
|
|
61
|
-
canContinue = await prettifySrc(basePath, srcPath, ci);
|
|
67
|
+
canContinue = await prettifySrc(basePath, srcPath, ci, silent);
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
if (canContinue && doLint) {
|
|
65
71
|
const { lint } = await import("./build-eslint.js");
|
|
66
72
|
|
|
67
|
-
canContinue = await lint(ci);
|
|
73
|
+
canContinue = await lint(ci, silent);
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
if (canContinue && tsc) {
|
|
71
77
|
const { buildTS } = await import("./build-tsc.js");
|
|
72
78
|
|
|
73
|
-
canContinue = await buildTS(basePath);
|
|
79
|
+
canContinue = await buildTS(basePath, silent);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
if (canContinue && circularDeps) {
|
|
77
83
|
const { buildCircularDeps } = await import("./build-circular-deps.js");
|
|
78
84
|
|
|
79
|
-
canContinue = await buildCircularDeps(basePath);
|
|
85
|
+
canContinue = await buildCircularDeps(basePath, silent);
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
if (canContinue && doBundle) {
|
|
83
89
|
const { bundle } = await import("./build-bundle.js");
|
|
84
90
|
|
|
85
|
-
canContinue = await bundle(basePath);
|
|
91
|
+
canContinue = await bundle(basePath, silent);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
if (canContinue && prettier) {
|
|
89
95
|
const { prettifyReadme, prettifyPackageJson, prettifyPackageDistJson } = await import("./build-prettier.js");
|
|
90
96
|
|
|
91
97
|
canContinue =
|
|
92
|
-
(await prettifyReadme(basePath, ci)) &&
|
|
93
|
-
(await prettifyPackageJson(basePath, ci)) &&
|
|
94
|
-
(await prettifyPackageDistJson(basePath, ci));
|
|
98
|
+
(await prettifyReadme(basePath, ci, silent)) &&
|
|
99
|
+
(await prettifyPackageJson(basePath, ci, silent)) &&
|
|
100
|
+
(await prettifyPackageDistJson(basePath, ci, silent));
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
if (canContinue && distfiles) {
|
|
98
104
|
const { buildDistFiles } = await import("./build-distfiles.js");
|
|
99
105
|
|
|
100
|
-
canContinue = await buildDistFiles(basePath);
|
|
106
|
+
canContinue = await buildDistFiles(basePath, silent);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
if (!canContinue) {
|
|
104
110
|
throw new Error("Build failed");
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
let texts: string[] = [],
|
|
114
|
+
outputFunc = console.info;
|
|
115
|
+
|
|
116
|
+
if (!silent) {
|
|
117
|
+
const newStats = await getDistStats(basePath),
|
|
118
|
+
diffSize = newStats.totalSize - oldStats.totalSize,
|
|
119
|
+
bundleDiffSize = newStats.bundleSize - oldStats.bundleSize,
|
|
120
|
+
minSize = 0,
|
|
121
|
+
bundleSizeIncreased = bundleDiffSize > minSize,
|
|
122
|
+
bundleSizeIncreasedText = bundleSizeIncreased ? "increased" : "decreased",
|
|
123
|
+
diffSizeIncreasedText = diffSize > minSize ? "increased" : "decreased";
|
|
124
|
+
|
|
125
|
+
outputFunc = bundleSizeIncreased ? console.warn : console.info;
|
|
126
|
+
|
|
115
127
|
texts = [
|
|
116
128
|
!bundleDiffSize
|
|
117
129
|
? "Bundle size unchanged"
|
|
@@ -126,11 +138,14 @@ buildCommand.action(async (argPath: string) => {
|
|
|
126
138
|
newStats.totalFolders - oldStats.totalFolders
|
|
127
139
|
).toString()})`,
|
|
128
140
|
];
|
|
141
|
+
}
|
|
129
142
|
|
|
130
143
|
console.log("Build finished successfully!");
|
|
131
144
|
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
if (!silent) {
|
|
146
|
+
for (const text of texts) {
|
|
147
|
+
outputFunc(text);
|
|
148
|
+
}
|
|
134
149
|
}
|
|
135
150
|
});
|
|
136
151
|
|