@tsparticles/cli 3.0.14 → 3.0.16
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 +13 -7
- package/dist/build/build-bundle.d.ts +5 -0
- package/dist/build/build-circular-deps.d.ts +6 -0
- package/dist/build/build-clear.d.ts +5 -0
- package/dist/build/build-distfiles.d.ts +5 -0
- package/dist/build/build-distfiles.js +7 -8
- package/dist/build/build-diststats.d.ts +12 -0
- package/dist/build/build-eslint.d.ts +5 -0
- package/dist/build/build-eslint.js +1 -3
- package/dist/build/build-prettier.d.ts +25 -0
- package/dist/build/build-prettier.js +5 -5
- package/dist/build/build-tsc.d.ts +5 -0
- package/dist/build/build.d.ts +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/create/create.d.ts +3 -0
- package/dist/create/plugin/create-plugin.d.ts +8 -0
- package/dist/create/plugin/plugin.d.ts +3 -0
- package/dist/create/preset/create-preset.d.ts +8 -0
- package/dist/create/preset/preset.d.ts +3 -0
- package/dist/create/shape/create-shape.d.ts +8 -0
- package/dist/create/shape/shape.d.ts +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/file-utils.d.ts +28 -0
- package/dist/utils/string-utils.d.ts +20 -0
- package/dist/utils/template-utils.d.ts +47 -0
- package/files/create-plugin/src/PluginInstance.ts +4 -2
- package/files/create-plugin/src/index.ts +1 -1
- package/files/create-plugin/src/plugin.ts +6 -6
- package/files/empty-project/.browserslistrc +1 -1
- package/files/empty-project/package.dist.json +1 -1
- package/files/empty-project/package.json +9 -9
- package/files/empty-project/tsconfig.base.json +2 -1
- package/package.json +12 -12
- package/src/build/build-bundle.ts +34 -34
- package/src/build/build-circular-deps.ts +23 -23
- package/src/build/build-clear.ts +11 -11
- package/src/build/build-distfiles.ts +67 -70
- package/src/build/build-diststats.ts +41 -41
- package/src/build/build-eslint.ts +26 -28
- package/src/build/build-prettier.ts +166 -166
- package/src/build/build-tsc.ts +146 -149
- package/src/build/build.ts +116 -116
- package/src/cli.ts +3 -3
- package/src/create/plugin/create-plugin.ts +108 -111
- package/src/create/plugin/plugin.ts +31 -31
- package/src/create/preset/create-preset.ts +123 -126
- package/src/create/preset/preset.ts +31 -31
- package/src/create/shape/create-shape.ts +112 -115
- package/src/create/shape/shape.ts +31 -31
- package/src/tsconfig.json +7 -125
- package/src/utils/file-utils.ts +35 -35
- package/src/utils/string-utils.ts +13 -13
- package/src/utils/template-utils.ts +130 -130
- package/tests/create-plugin.test.ts +11 -3
- package/tests/create-preset.test.ts +10 -2
- package/tests/create-shape.test.ts +10 -2
- package/tests/tsconfig.json +3 -15
- package/tsconfig.json +53 -20
- package/.mocharc.json +0 -11
- package/tsconfig.eslint.json +0 -8
package/src/build/build-tsc.ts
CHANGED
|
@@ -2,11 +2,11 @@ import fs from "fs-extra";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
enum ExitCodes {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
OK = 0,
|
|
6
|
+
EmitErrors = 1,
|
|
7
|
+
NoDataOrOptions = 2,
|
|
8
|
+
NoOptions = 3,
|
|
9
|
+
ParseError = 4,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -15,15 +15,15 @@ enum ExitCodes {
|
|
|
15
15
|
* @returns the file content or undefined if the file doesn't exist
|
|
16
16
|
*/
|
|
17
17
|
async function readConfig(basePath: string, file: string): Promise<string | undefined> {
|
|
18
|
-
|
|
18
|
+
const tsconfigPath = path.join(basePath, file);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (await fs.pathExists(tsconfigPath)) {
|
|
21
|
+
const data = await fs.readFile(path.join(basePath, file));
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
return data.toString();
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
return undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -32,136 +32,133 @@ async function readConfig(basePath: string, file: string): Promise<string | unde
|
|
|
32
32
|
* @returns the exit code
|
|
33
33
|
*/
|
|
34
34
|
async function compile(basePath: string, type: "browser" | "cjs" | "esm" | "types" | "umd"): Promise<number> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
);
|
|
155
|
-
} else {
|
|
156
|
-
console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
157
|
-
}
|
|
35
|
+
let options: unknown, data: string | undefined;
|
|
36
|
+
|
|
37
|
+
switch (type) {
|
|
38
|
+
case "browser":
|
|
39
|
+
data = await readConfig(basePath, "tsconfig.browser.json");
|
|
40
|
+
|
|
41
|
+
if (!data) {
|
|
42
|
+
options = {
|
|
43
|
+
extends: "@tsparticles/tsconfig/tsconfig.browser.json",
|
|
44
|
+
compilerOptions: {
|
|
45
|
+
rootDir: "./src",
|
|
46
|
+
outDir: "./dist/browser",
|
|
47
|
+
},
|
|
48
|
+
include: ["./src"],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
break;
|
|
53
|
+
case "cjs":
|
|
54
|
+
data = await readConfig(basePath, "tsconfig.json");
|
|
55
|
+
|
|
56
|
+
if (!data) {
|
|
57
|
+
options = {
|
|
58
|
+
extends: "@tsparticles/tsconfig/tsconfig.json",
|
|
59
|
+
compilerOptions: {
|
|
60
|
+
rootDir: "./src",
|
|
61
|
+
outDir: "./dist/cjs",
|
|
62
|
+
},
|
|
63
|
+
include: ["./src"],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
break;
|
|
68
|
+
case "esm":
|
|
69
|
+
data = await readConfig(basePath, "tsconfig.module.json");
|
|
70
|
+
|
|
71
|
+
if (!data) {
|
|
72
|
+
options = {
|
|
73
|
+
extends: "@tsparticles/tsconfig/tsconfig.module.json",
|
|
74
|
+
compilerOptions: {
|
|
75
|
+
rootDir: "./src",
|
|
76
|
+
outDir: "./dist/esm",
|
|
77
|
+
},
|
|
78
|
+
include: ["./src"],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
break;
|
|
83
|
+
case "types":
|
|
84
|
+
data = await readConfig(basePath, "tsconfig.types.json");
|
|
85
|
+
|
|
86
|
+
if (!data) {
|
|
87
|
+
options = {
|
|
88
|
+
extends: "@tsparticles/tsconfig/tsconfig.types.json",
|
|
89
|
+
compilerOptions: {
|
|
90
|
+
rootDir: "./src",
|
|
91
|
+
outDir: "./dist/types",
|
|
92
|
+
},
|
|
93
|
+
include: ["./src"],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
break;
|
|
98
|
+
case "umd":
|
|
99
|
+
data = await readConfig(basePath, "tsconfig.umd.json");
|
|
100
|
+
|
|
101
|
+
if (!data) {
|
|
102
|
+
options = {
|
|
103
|
+
extends: "@tsparticles/tsconfig/tsconfig.umd.json",
|
|
104
|
+
compilerOptions: {
|
|
105
|
+
rootDir: "./src",
|
|
106
|
+
outDir: "./dist/umd",
|
|
107
|
+
},
|
|
108
|
+
include: ["./src"],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!data && !options) {
|
|
116
|
+
return ExitCodes.NoDataOrOptions;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!options && data) {
|
|
120
|
+
options = JSON.parse(data);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!options) {
|
|
124
|
+
return ExitCodes.NoOptions;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const ts = await import("typescript"),
|
|
128
|
+
parsed = ts.parseJsonConfigFileContent(options, ts.sys, basePath);
|
|
129
|
+
|
|
130
|
+
if (parsed.errors.length) {
|
|
131
|
+
return ExitCodes.ParseError;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const program = ts.createProgram(parsed.fileNames, parsed.options),
|
|
135
|
+
emitResult = program.emit(),
|
|
136
|
+
allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
137
|
+
|
|
138
|
+
let failed = false;
|
|
139
|
+
|
|
140
|
+
for (const diagnostic of allDiagnostics) {
|
|
141
|
+
failed = failed || diagnostic.category === ts.DiagnosticCategory.Error;
|
|
142
|
+
|
|
143
|
+
if (diagnostic.file) {
|
|
144
|
+
const startingPos = 0,
|
|
145
|
+
{ line, character } = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start ?? startingPos),
|
|
146
|
+
message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"),
|
|
147
|
+
increment = 1;
|
|
148
|
+
|
|
149
|
+
console.log(
|
|
150
|
+
`${diagnostic.file.fileName} (${(line + increment).toString()},${(character + increment).toString()}): ${message}`,
|
|
151
|
+
);
|
|
152
|
+
} else {
|
|
153
|
+
console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
158
154
|
}
|
|
155
|
+
}
|
|
159
156
|
|
|
160
|
-
|
|
157
|
+
const exitCode = emitResult.emitSkipped || failed ? ExitCodes.EmitErrors : ExitCodes.OK;
|
|
161
158
|
|
|
162
|
-
|
|
159
|
+
console.log(`TSC for ${type} done with exit code: '${exitCode.toLocaleString()}'.`);
|
|
163
160
|
|
|
164
|
-
|
|
161
|
+
return exitCode;
|
|
165
162
|
}
|
|
166
163
|
|
|
167
164
|
/**
|
|
@@ -169,25 +166,25 @@ async function compile(basePath: string, type: "browser" | "cjs" | "esm" | "type
|
|
|
169
166
|
* @returns true if the build was successful
|
|
170
167
|
*/
|
|
171
168
|
export async function buildTS(basePath: string): Promise<boolean> {
|
|
172
|
-
|
|
169
|
+
console.log("Building TS files");
|
|
173
170
|
|
|
174
|
-
|
|
171
|
+
let res = true;
|
|
175
172
|
|
|
176
|
-
|
|
173
|
+
const types: ("browser" | "cjs" | "esm" | "types" | "umd")[] = ["browser", "cjs", "esm", "types", "umd"];
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
for (const type of types) {
|
|
176
|
+
console.log(`Building TS files for ${type} configuration`);
|
|
180
177
|
|
|
181
|
-
|
|
178
|
+
const exitCode = await compile(basePath, type);
|
|
182
179
|
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
if (exitCode) {
|
|
181
|
+
res = false;
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
}
|
|
183
|
+
break;
|
|
188
184
|
}
|
|
185
|
+
}
|
|
189
186
|
|
|
190
|
-
|
|
187
|
+
console.log("Building TS files done");
|
|
191
188
|
|
|
192
|
-
|
|
189
|
+
return res;
|
|
193
190
|
}
|
package/src/build/build.ts
CHANGED
|
@@ -4,16 +4,16 @@ const buildCommand = new Command("build");
|
|
|
4
4
|
|
|
5
5
|
buildCommand.description("Build the tsParticles library using TypeScript");
|
|
6
6
|
buildCommand.option(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"-a, --all",
|
|
8
|
+
"Do all build steps (default if no flags are specified) (same as -b -c -d -l -p -t)",
|
|
9
|
+
false,
|
|
10
10
|
);
|
|
11
11
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
"--ci",
|
|
15
|
+
"Do all build steps for CI, no fixing files, only checking if they are formatted correctly",
|
|
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);
|
|
@@ -23,116 +23,116 @@ buildCommand.option("-t, --tsc", "Build the library using TypeScript", false);
|
|
|
23
23
|
|
|
24
24
|
buildCommand.argument("[path]", `Path to the project root folder, default is "src"`, "src");
|
|
25
25
|
buildCommand.action(async (argPath: string) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
26
|
+
const opts = buildCommand.opts(),
|
|
27
|
+
ci = !!opts["ci"],
|
|
28
|
+
all =
|
|
29
|
+
!!opts["all"] ||
|
|
30
|
+
(!opts["bundle"] && !opts["clean"] && !opts["dist"] && !opts["lint"] && !opts["prettify"] && !opts["tsc"]),
|
|
31
|
+
doBundle = all || !!opts["bundle"],
|
|
32
|
+
circularDeps = all || !!opts["circularDeps"],
|
|
33
|
+
clean = all || !!opts["clean"],
|
|
34
|
+
distfiles = all || !!opts["dist"],
|
|
35
|
+
doLint = all || !!opts["lint"],
|
|
36
|
+
prettier = all || !!opts["prettify"],
|
|
37
|
+
tsc = all || !!opts["tsc"];
|
|
38
|
+
|
|
39
|
+
const basePath = process.cwd(),
|
|
40
|
+
{ getDistStats } = await import("./build-diststats.js"),
|
|
41
|
+
oldStats = await getDistStats(basePath);
|
|
42
|
+
|
|
43
|
+
if (clean) {
|
|
44
|
+
const { clearDist } = await import("./build-clear.js");
|
|
45
|
+
|
|
46
|
+
await clearDist(basePath);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const path = await import("path"),
|
|
50
|
+
srcPath = path.join(basePath, argPath),
|
|
51
|
+
fs = await import("fs-extra");
|
|
52
|
+
|
|
53
|
+
if (!(await fs.pathExists(srcPath))) {
|
|
54
|
+
throw new Error("Provided path does not exist");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let canContinue = true;
|
|
58
|
+
|
|
59
|
+
if (prettier) {
|
|
60
|
+
const { prettifySrc } = await import("./build-prettier.js");
|
|
61
|
+
|
|
62
|
+
canContinue = await prettifySrc(basePath, srcPath, ci);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (canContinue && doLint) {
|
|
66
|
+
const { lint } = await import("./build-eslint.js");
|
|
67
|
+
|
|
68
|
+
canContinue = await lint(ci);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (canContinue && tsc) {
|
|
72
|
+
const { buildTS } = await import("./build-tsc.js");
|
|
73
|
+
|
|
74
|
+
canContinue = await buildTS(basePath);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (canContinue && circularDeps) {
|
|
78
|
+
const { buildCircularDeps } = await import("./build-circular-deps.js");
|
|
79
|
+
|
|
80
|
+
canContinue = await buildCircularDeps(basePath);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (canContinue && doBundle) {
|
|
84
|
+
const { bundle } = await import("./build-bundle.js");
|
|
85
|
+
|
|
86
|
+
canContinue = await bundle(basePath);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (canContinue && prettier) {
|
|
90
|
+
const { prettifyReadme, prettifyPackageJson, prettifyPackageDistJson } = await import("./build-prettier.js");
|
|
91
|
+
|
|
92
|
+
canContinue =
|
|
93
|
+
(await prettifyReadme(basePath, ci)) &&
|
|
94
|
+
(await prettifyPackageJson(basePath, ci)) &&
|
|
95
|
+
(await prettifyPackageDistJson(basePath, ci));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (canContinue && distfiles) {
|
|
99
|
+
const { buildDistFiles } = await import("./build-distfiles.js");
|
|
100
|
+
|
|
101
|
+
canContinue = await buildDistFiles(basePath);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (!canContinue) {
|
|
105
|
+
throw new Error("Build failed");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const newStats = await getDistStats(basePath),
|
|
109
|
+
diffSize = newStats.totalSize - oldStats.totalSize,
|
|
110
|
+
bundleDiffSize = newStats.bundleSize - oldStats.bundleSize,
|
|
111
|
+
minSize = 0,
|
|
112
|
+
bundleSizeIncreased = bundleDiffSize > minSize,
|
|
113
|
+
outputFunc = bundleSizeIncreased ? console.warn : console.info,
|
|
114
|
+
bundleSizeIncreasedText = bundleSizeIncreased ? "increased" : "decreased",
|
|
115
|
+
diffSizeIncreasedText = diffSize > minSize ? "increased" : "decreased",
|
|
116
|
+
texts = [
|
|
117
|
+
!bundleDiffSize
|
|
118
|
+
? "Bundle size unchanged"
|
|
119
|
+
: `Bundle size ${bundleSizeIncreasedText} from ${oldStats.bundleSize.toString()} to ${newStats.bundleSize.toString()} (${Math.abs(bundleDiffSize).toString()}B)`,
|
|
120
|
+
!diffSize
|
|
121
|
+
? "Size unchanged"
|
|
122
|
+
: `Size ${diffSizeIncreasedText} from ${oldStats.totalSize.toString()} to ${newStats.totalSize.toString()} (${Math.abs(diffSize).toString()}B)`,
|
|
123
|
+
`Files count changed from ${oldStats.totalFiles.toString()} to ${newStats.totalFiles.toString()} (${(
|
|
124
|
+
newStats.totalFiles - oldStats.totalFiles
|
|
125
|
+
).toString()})`,
|
|
126
|
+
`Folders count changed from ${oldStats.totalFolders.toString()} to ${newStats.totalFolders.toString()} (${(
|
|
127
|
+
newStats.totalFolders - oldStats.totalFolders
|
|
128
|
+
).toString()})`,
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
console.log("Build finished successfully!");
|
|
132
|
+
|
|
133
|
+
for (const text of texts) {
|
|
134
|
+
outputFunc(text);
|
|
135
|
+
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
export { buildCommand };
|
package/src/cli.ts
CHANGED
|
@@ -7,9 +7,9 @@ import path from "path";
|
|
|
7
7
|
import { program } from "commander";
|
|
8
8
|
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
__dirname = path.dirname(__filename),
|
|
11
|
+
rootPkgPath = path.join(__dirname, "..", "package.json"),
|
|
12
|
+
pkg = (await fs.readJson(rootPkgPath)) as { version: string };
|
|
13
13
|
|
|
14
14
|
program.name("tsparticles-cli");
|
|
15
15
|
program.description("tsParticles CLI");
|