@tsparticles/cli 3.0.14 → 3.0.15
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 +4 -4
- 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
|
@@ -5,44 +5,42 @@ import { ESLint } from "eslint";
|
|
|
5
5
|
* @returns true if the linting was successful
|
|
6
6
|
*/
|
|
7
7
|
export async function lint(ci: boolean): Promise<boolean> {
|
|
8
|
-
|
|
8
|
+
console.log("ESLint - started on src");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
let res: boolean;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
try {
|
|
13
|
+
const eslint = new ESLint({
|
|
14
|
+
fix: !ci,
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const results = await eslint.lintFiles(["src"]),
|
|
18
|
+
errors = ESLint.getErrorResults(results);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
await ESLint.outputFixes(results);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const formatter = await eslint.loadFormatter("stylish"),
|
|
23
|
+
resultText = formatter.format(results),
|
|
24
|
+
minimumLength = 0;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.join("\n"),
|
|
31
|
-
);
|
|
26
|
+
if (errors.length > minimumLength) {
|
|
27
|
+
const messages = errors.map(t =>
|
|
28
|
+
t.messages.map(m => `${t.filePath} (${m.line.toString()},${m.column.toString()}): ${m.message}`).join("\n"),
|
|
29
|
+
);
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
throw new Error(messages.join("\n"));
|
|
32
|
+
}
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
console.log(resultText);
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
res = true;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(e);
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
res = false;
|
|
41
|
+
}
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
console.log("ESLint - done on src");
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
return res;
|
|
48
46
|
}
|
|
@@ -10,46 +10,46 @@ import prettier from "prettier";
|
|
|
10
10
|
* @returns true if the prettify src process was successful
|
|
11
11
|
*/
|
|
12
12
|
export async function prettifySrc(basePath: string, srcPath: string, ci: boolean): Promise<boolean> {
|
|
13
|
-
|
|
13
|
+
console.log("Prettier - started on src");
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
let res: boolean;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const contents = await fs.readFile(file.path, "utf8"),
|
|
24
|
-
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
17
|
+
try {
|
|
18
|
+
for await (const file of klaw(srcPath)) {
|
|
19
|
+
if (file.stats.isDirectory()) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
options.parser = "typescript";
|
|
29
|
-
options.tabWidth = 4;
|
|
30
|
-
options.arrowParens = "avoid" as const;
|
|
23
|
+
const contents = await fs.readFile(file.path, "utf8"),
|
|
24
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const formatted = await prettier.format(contents, options);
|
|
26
|
+
options.printWidth = 120;
|
|
27
|
+
options.endOfLine = "lf";
|
|
28
|
+
options.parser = "typescript";
|
|
29
|
+
options.tabWidth = 4;
|
|
30
|
+
options.arrowParens = "avoid" as const;
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
if (ci) {
|
|
33
|
+
if (!(await prettier.check(contents, options))) {
|
|
34
|
+
throw new Error(`${file.path} is not formatted correctly`);
|
|
41
35
|
}
|
|
36
|
+
} else {
|
|
37
|
+
const formatted = await prettier.format(contents, options);
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.error(e);
|
|
46
|
-
|
|
47
|
-
res = false;
|
|
39
|
+
await fs.writeFile(file.path, formatted, "utf8");
|
|
40
|
+
}
|
|
48
41
|
}
|
|
49
42
|
|
|
50
|
-
|
|
43
|
+
res = true;
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.error(e);
|
|
46
|
+
|
|
47
|
+
res = false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
console.log("Prettier - done on src");
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
return res;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -58,39 +58,39 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
58
58
|
* @returns true if the prettify package.json process was successful
|
|
59
59
|
*/
|
|
60
60
|
export async function prettifyPackageJson(basePath: string, ci: boolean): Promise<boolean> {
|
|
61
|
-
|
|
61
|
+
console.log("Prettier - started on package.json");
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
let res: boolean;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
try {
|
|
66
|
+
const contents = await fs.readFile("package.json", "utf8"),
|
|
67
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
options.tabWidth = 2;
|
|
70
|
+
options.printWidth = 120;
|
|
71
|
+
options.endOfLine = "lf";
|
|
72
|
+
options.parser = "json";
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
if (ci) {
|
|
75
|
+
if (!(await prettier.check(contents, options))) {
|
|
76
|
+
throw new Error(`package.json is not formatted correctly`);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
const formatted = await prettier.format(contents, options);
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
await fs.writeFile("package.json", formatted, "utf8");
|
|
82
|
+
}
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
res = true;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error(e);
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
res = false;
|
|
89
|
+
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
console.log("Prettier - done on package.json");
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
return res;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
@@ -99,41 +99,41 @@ export async function prettifyPackageJson(basePath: string, ci: boolean): Promis
|
|
|
99
99
|
* @returns true if the prettify package.dist.json process was successful
|
|
100
100
|
*/
|
|
101
101
|
export async function prettifyPackageDistJson(basePath: string, _ci: boolean): Promise<boolean> {
|
|
102
|
-
|
|
102
|
+
console.log("Prettier - started on package.dist.json");
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
let res: boolean;
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
try {
|
|
107
|
+
const contents = await fs.readFile("package.dist.json", "utf8"),
|
|
108
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
options.tabWidth = 2;
|
|
111
|
+
options.printWidth = 120;
|
|
112
|
+
options.endOfLine = "lf";
|
|
113
|
+
options.parser = "json";
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
// TODO: disabled this check until "prettier-plugin-multiline-arrays" package is compatible with Prettier 3.0.0
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
/* if (ci) {
|
|
118
118
|
if (!(await prettier.check(contents, options))) {
|
|
119
119
|
throw new Error(`package.dist.json is not formatted correctly`);
|
|
120
120
|
}
|
|
121
121
|
} else { */
|
|
122
|
-
|
|
122
|
+
const formatted = await prettier.format(contents, options);
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
await fs.writeFile("package.dist.json", formatted, "utf8");
|
|
125
|
+
// }
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
res = true;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.error(e);
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
res = false;
|
|
132
|
+
}
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
console.log("Prettier - done on package.dist.json");
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
return res;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -142,38 +142,38 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean): P
|
|
|
142
142
|
* @returns true if the prettify readme process was successful
|
|
143
143
|
*/
|
|
144
144
|
export async function prettifyReadme(basePath: string, ci: boolean): Promise<boolean> {
|
|
145
|
-
|
|
145
|
+
console.log("Prettier - started on README.md");
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
let res: boolean;
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
try {
|
|
150
|
+
const contents = await fs.readFile("README.md", "utf8"),
|
|
151
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
options.printWidth = 120;
|
|
154
|
+
options.endOfLine = "lf";
|
|
155
|
+
options.parser = "markdown";
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
if (ci) {
|
|
158
|
+
if (!(await prettier.check(contents, options))) {
|
|
159
|
+
throw new Error(`README.md is not formatted correctly`);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
const formatted = await prettier.format(contents, options);
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
await fs.writeFile("README.md", formatted, "utf8");
|
|
165
|
+
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
res = (await prettifyTraductions(basePath, ci)) && (await prettifyMarkdownTypeDocFiles(basePath, ci));
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error(e);
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
171
|
+
res = false;
|
|
172
|
+
}
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
console.log("Prettier - done on README.md");
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
return res;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
@@ -182,53 +182,53 @@ export async function prettifyReadme(basePath: string, ci: boolean): Promise<boo
|
|
|
182
182
|
* @returns true if the prettify traductions process was successful
|
|
183
183
|
*/
|
|
184
184
|
async function prettifyTraductions(basePath: string, ci: boolean): Promise<boolean> {
|
|
185
|
-
|
|
185
|
+
console.log("Prettier - started on traductions");
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
let res = false;
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
try {
|
|
190
|
+
const folder = "traduction",
|
|
191
|
+
folderPath = path.join(basePath, folder);
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (!res) {
|
|
198
|
-
for await (const file of klaw(folderPath)) {
|
|
199
|
-
if (file.stats.isDirectory()) {
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
193
|
+
if (!fs.existsSync(folderPath)) {
|
|
194
|
+
res = true;
|
|
195
|
+
}
|
|
202
196
|
|
|
203
|
-
|
|
204
|
-
|
|
197
|
+
if (!res) {
|
|
198
|
+
for await (const file of klaw(folderPath)) {
|
|
199
|
+
if (file.stats.isDirectory()) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
options.parser = "markdown";
|
|
203
|
+
const contents = await fs.readFile(file.path, "utf8"),
|
|
204
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
const formatted = await prettier.format(contents, options);
|
|
206
|
+
options.printWidth = 120;
|
|
207
|
+
options.endOfLine = "lf";
|
|
208
|
+
options.parser = "markdown";
|
|
216
209
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
210
|
+
if (ci) {
|
|
211
|
+
if (!(await prettier.check(contents, options))) {
|
|
212
|
+
throw new Error(`${file.path} is not formatted correctly`);
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
const formatted = await prettier.format(contents, options);
|
|
220
216
|
|
|
221
|
-
|
|
217
|
+
await fs.writeFile(file.path, formatted, "utf8");
|
|
222
218
|
}
|
|
223
|
-
|
|
224
|
-
console.error(e);
|
|
219
|
+
}
|
|
225
220
|
|
|
226
|
-
|
|
221
|
+
res = true;
|
|
227
222
|
}
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(e);
|
|
225
|
+
|
|
226
|
+
res = false;
|
|
227
|
+
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
console.log("Prettier - done on traductions");
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
return res;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
/**
|
|
@@ -237,51 +237,51 @@ async function prettifyTraductions(basePath: string, ci: boolean): Promise<boole
|
|
|
237
237
|
* @returns true if the prettify markdown typedoc files process was successful
|
|
238
238
|
*/
|
|
239
239
|
async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean): Promise<boolean> {
|
|
240
|
-
|
|
240
|
+
console.log("Prettier - started on markdown");
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
let res = false;
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (!fs.existsSync(folderPath)) {
|
|
249
|
-
res = true;
|
|
250
|
-
}
|
|
244
|
+
try {
|
|
245
|
+
const folder = "markdown",
|
|
246
|
+
folderPath = path.join(basePath, folder);
|
|
251
247
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
248
|
+
if (!fs.existsSync(folderPath)) {
|
|
249
|
+
res = true;
|
|
250
|
+
}
|
|
257
251
|
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
if (!res) {
|
|
253
|
+
for await (const file of klaw(folderPath)) {
|
|
254
|
+
if (file.stats.isDirectory()) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
260
257
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
options.parser = "markdown";
|
|
258
|
+
const contents = await fs.readFile(file.path, "utf8"),
|
|
259
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
264
260
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
const formatted = await prettier.format(contents, options);
|
|
261
|
+
options.printWidth = 120;
|
|
262
|
+
options.endOfLine = "lf";
|
|
263
|
+
options.parser = "markdown";
|
|
271
264
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
265
|
+
if (ci) {
|
|
266
|
+
if (!(await prettier.check(contents, options))) {
|
|
267
|
+
throw new Error(`${file.path} is not formatted correctly`);
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
const formatted = await prettier.format(contents, options);
|
|
275
271
|
|
|
276
|
-
|
|
272
|
+
await fs.writeFile(file.path, formatted, "utf8");
|
|
277
273
|
}
|
|
278
|
-
|
|
279
|
-
console.error(e);
|
|
274
|
+
}
|
|
280
275
|
|
|
281
|
-
|
|
276
|
+
res = true;
|
|
282
277
|
}
|
|
278
|
+
} catch (e) {
|
|
279
|
+
console.error(e);
|
|
280
|
+
|
|
281
|
+
res = false;
|
|
282
|
+
}
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
console.log("Prettier - done on markdown");
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
return res;
|
|
287
287
|
}
|