@tsparticles/cli 3.3.0 → 3.3.2

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.
Files changed (42) hide show
  1. package/.github/dependabot.yml +7 -0
  2. package/.planning/codebase/ARCHITECTURE.md +132 -3
  3. package/.planning/codebase/CONCERNS.md +105 -3
  4. package/.planning/codebase/CONVENTIONS.md +91 -3
  5. package/.planning/codebase/INTEGRATIONS.md +82 -3
  6. package/.planning/codebase/STACK.md +88 -8
  7. package/.planning/codebase/STRUCTURE.md +138 -3
  8. package/.planning/codebase/TESTING.md +156 -3
  9. package/dist/build/build-distfiles.js +14 -13
  10. package/dist/build/build-diststats.js +8 -7
  11. package/dist/build/build-prettier.d.ts +2 -2
  12. package/dist/build/build-prettier.js +26 -25
  13. package/dist/build/build-tsc.js +4 -3
  14. package/dist/build/build.js +10 -8
  15. package/dist/cli.js +3 -3
  16. package/dist/create/plugin/create-plugin.js +4 -3
  17. package/dist/create/preset/create-preset.js +4 -3
  18. package/dist/create/shape/create-shape.js +4 -3
  19. package/dist/tsconfig.tsbuildinfo +1 -1
  20. package/dist/utils/file-utils.js +7 -6
  21. package/dist/utils/template-utils.js +4 -3
  22. package/files/empty-project/package.json +7 -7
  23. package/files/empty-project/webpack.config.js +11 -11
  24. package/package.json +9 -11
  25. package/renovate.json +3 -0
  26. package/src/build/build-distfiles.ts +15 -14
  27. package/src/build/build-diststats.ts +8 -8
  28. package/src/build/build-prettier.ts +25 -26
  29. package/src/build/build-tsc.ts +4 -3
  30. package/src/build/build.ts +10 -10
  31. package/src/cli.ts +3 -3
  32. package/src/create/plugin/create-plugin.ts +4 -3
  33. package/src/create/preset/create-preset.ts +4 -3
  34. package/src/create/shape/create-shape.ts +4 -3
  35. package/src/utils/file-utils.ts +7 -6
  36. package/src/utils/template-utils.ts +4 -3
  37. package/tests/create-plugin.test.ts +25 -25
  38. package/tests/create-preset.test.ts +25 -25
  39. package/tests/create-shape.test.ts +25 -25
  40. package/tests/file-utils.test.ts +87 -78
  41. package/tests/tsconfig.json +12 -11
  42. package/tsconfig.json +52 -53
@@ -85,11 +85,11 @@
85
85
  "devDependencies": {
86
86
  "@swc/core": "^1.15.18",
87
87
  "@tsparticles/cli": "latest",
88
- "@tsparticles/depcruise-config": "^3.3.0",
89
- "@tsparticles/eslint-config": "^3.3.0",
90
- "@tsparticles/prettier-config": "^3.3.0",
91
- "@tsparticles/tsconfig": "^3.3.0",
92
- "@tsparticles/webpack-plugin": "^3.3.0",
88
+ "@tsparticles/depcruise-config": "^3.3.1",
89
+ "@tsparticles/eslint-config": "^3.3.1",
90
+ "@tsparticles/prettier-config": "^3.3.1",
91
+ "@tsparticles/tsconfig": "^3.3.1",
92
+ "@tsparticles/webpack-plugin": "^3.3.1",
93
93
  "@types/webpack-env": "^1.18.8",
94
94
  "browserslist": "^4.28.1",
95
95
  "copyfiles": "^2.4.1",
@@ -98,9 +98,9 @@
98
98
  "prettier": "^3.8.1",
99
99
  "rimraf": "^6.1.3",
100
100
  "swc-loader": "^0.2.7",
101
- "terser-webpack-plugin": "^5.3.17",
101
+ "terser-webpack-plugin": "^5.4.0",
102
102
  "typescript": "^5.9.3",
103
- "typescript-eslint": "^8.56.1",
103
+ "typescript-eslint": "^8.57.0",
104
104
  "webpack": "^5.105.4",
105
105
  "webpack-bundle-analyzer": "^5.2.0",
106
106
  "webpack-cli": "^6.0.1"
@@ -1,16 +1,16 @@
1
- import {loadParticlesTemplate} from "@tsparticles/webpack-plugin";
2
- import {fileURLToPath} from "url";
3
- import fs from "fs-extra";
4
- import path from "path";
1
+ import { loadParticlesTemplate } from "@tsparticles/webpack-plugin";
2
+ import { fileURLToPath } from "node:url";
3
+ import { readFile } from "node:fs/promises";
4
+ import path from "node:path";
5
5
 
6
6
  const __filename = fileURLToPath(import.meta.url),
7
- __dirname = path.dirname(__filename),
8
- rootPkgPath = path.join(__dirname, "package.json"),
9
- pkg = await fs.readJson(rootPkgPath);
7
+ __dirname = path.dirname(__filename),
8
+ rootPkgPath = path.join(__dirname, "package.json"),
9
+ pkg = JSON.parse(await readFile(rootPkgPath, "utf-8"));
10
10
 
11
11
  export default loadParticlesTemplate({
12
- moduleName: "empty",
13
- templateName: "Empty",
14
- version: pkg.version,
15
- dir: __dirname
12
+ moduleName: "empty",
13
+ templateName: "Empty",
14
+ version: pkg.version,
15
+ dir: __dirname,
16
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/cli",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,18 +17,17 @@
17
17
  "prettier": "@tsparticles/prettier-config",
18
18
  "dependencies": {
19
19
  "@swc/core": "^1.15.18",
20
- "@tsparticles/depcruise-config": "^3.3.0",
21
- "@tsparticles/eslint-config": "^3.3.0",
22
- "@tsparticles/prettier-config": "^3.3.0",
23
- "@tsparticles/tsconfig": "^3.3.0",
24
- "@tsparticles/webpack-plugin": "^3.3.0",
20
+ "@tsparticles/depcruise-config": "^3.3.1",
21
+ "@tsparticles/eslint-config": "^3.3.1",
22
+ "@tsparticles/prettier-config": "^3.3.1",
23
+ "@tsparticles/tsconfig": "^3.3.1",
24
+ "@tsparticles/webpack-plugin": "^3.3.1",
25
25
  "commander": "^14.0.3",
26
26
  "eslint": "^10.0.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
30
  "eslint-plugin-tsdoc": "^0.5.2",
31
- "fs-extra": "^11.3.4",
32
31
  "klaw": "^4.1.0",
33
32
  "lookpath": "^1.2.3",
34
33
  "dependency-cruiser": "^17.3.8",
@@ -39,22 +38,21 @@
39
38
  "rimraf": "^6.1.3",
40
39
  "swc-loader": "^0.2.7",
41
40
  "typescript": "^5.9.3",
42
- "typescript-eslint": "^8.56.1",
41
+ "typescript-eslint": "^8.57.0",
43
42
  "webpack": "^5.105.4"
44
43
  },
45
44
  "devDependencies": {
46
45
  "@tsparticles/cli": "latest",
47
46
  "@tsparticles/engine": "^3.9.1",
48
47
  "@types/estree": "^1.0.8",
49
- "@types/fs-extra": "^11.0.4",
50
48
  "@types/klaw": "^3.0.7",
51
- "@types/node": "^25.3.5",
49
+ "@types/node": "^25.4.0",
52
50
  "@types/prompts": "^2.4.9",
53
51
  "@types/webpack-env": "^1.18.8",
54
52
  "browserslist": "^4.28.1",
55
53
  "copyfiles": "^2.4.1",
56
54
  "cross-env": "^10.1.0",
57
- "terser-webpack-plugin": "^5.3.17",
55
+ "terser-webpack-plugin": "^5.4.0",
58
56
  "ts-node": "^10.9.2",
59
57
  "vitest": "^4.0.18",
60
58
  "webpack-bundle-analyzer": "^5.2.0",
package/renovate.json CHANGED
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "baseBranches": [
4
+ "dev"
5
+ ],
3
6
  "extends": [
4
7
  "config:base"
5
8
  ]
@@ -1,4 +1,5 @@
1
- import fs from "fs-extra";
1
+ import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
2
3
  import klaw from "klaw";
3
4
  import path from "node:path";
4
5
 
@@ -15,7 +16,7 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
15
16
  let res: boolean;
16
17
 
17
18
  try {
18
- const pkgInfo = JSON.parse((await fs.readFile(path.join(basePath, "package.json"))).toString()) as {
19
+ const pkgInfo = JSON.parse((await readFile(path.join(basePath, "package.json"))).toString()) as {
19
20
  dependencies?: Record<string, string>;
20
21
  peerDependencies?: Record<string, string>;
21
22
  publishConfig?: { directory?: string };
@@ -23,7 +24,7 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
23
24
  },
24
25
  libPackage = path.join(basePath, "package.dist.json"),
25
26
  distPath = path.join(basePath, pkgInfo.publishConfig?.directory ?? "dist"),
26
- data = await fs.readFile(libPackage),
27
+ data = await readFile(libPackage),
27
28
  text = data.toString(),
28
29
  libObj = JSON.parse(text) as Record<string, unknown>;
29
30
 
@@ -37,7 +38,7 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
37
38
 
38
39
  const jsonIndent = 2;
39
40
 
40
- await fs.writeFile(libPackage, `${JSON.stringify(libObj, undefined, jsonIndent)}\n`, "utf8");
41
+ await writeFile(libPackage, `${JSON.stringify(libObj, undefined, jsonIndent)}\n`, "utf8");
41
42
 
42
43
  if (!silent) {
43
44
  console.log(`package.dist.json updated successfully to version ${pkgInfo.version}`);
@@ -56,19 +57,19 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
56
57
  const src = path.join(basePath, typeof file === "string" ? file : file.source),
57
58
  dest = path.join(distPath, typeof file === "string" ? file : file.destination);
58
59
 
59
- await fs.copyFile(src, dest);
60
+ await copyFile(src, dest);
60
61
  }
61
62
 
62
63
  const scriptsPath = path.join(basePath, "scripts"),
63
64
  distScriptsPath = path.join(distPath, "scripts");
64
65
 
65
- if ((await fs.exists(scriptsPath)) && !(await fs.exists(distScriptsPath))) {
66
- await fs.mkdir(distScriptsPath);
66
+ if (existsSync(scriptsPath) && !existsSync(distScriptsPath)) {
67
+ await mkdir(distScriptsPath);
67
68
 
68
69
  const installPath = path.join(scriptsPath, "install.js");
69
70
 
70
- if (await fs.exists(installPath)) {
71
- await fs.copyFile(installPath, path.join(distScriptsPath, "install.js"));
71
+ if (existsSync(installPath)) {
72
+ await copyFile(installPath, path.join(distScriptsPath, "install.js"));
72
73
  }
73
74
  }
74
75
 
@@ -77,9 +78,9 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
77
78
  continue;
78
79
  }
79
80
 
80
- const contents = await fs.readFile(file.path, "utf8");
81
+ const contents = await readFile(file.path, "utf8");
81
82
 
82
- await fs.writeFile(file.path, contents.replaceAll("__VERSION__", `"${pkgInfo.version}"`), "utf8");
83
+ await writeFile(file.path, contents.replaceAll("__VERSION__", `"${pkgInfo.version}"`), "utf8");
83
84
  }
84
85
 
85
86
  /* for await (const file of klaw(path.join(distPath, "cjs"))) {
@@ -90,9 +91,9 @@ export async function buildDistFiles(basePath: string, silent: boolean): Promise
90
91
  await fs.rename(file.path, file.path.replace(/\.js$/, ".mjs"));
91
92
  } */
92
93
 
93
- await fs.writeFile(path.join(distPath, "cjs", "package.json"), `{ "type": "commonjs" }`);
94
- await fs.writeFile(path.join(distPath, "esm", "package.json"), `{ "type": "module" }`);
95
- await fs.writeFile(path.join(distPath, "browser", "package.json"), `{ "type": "module" }`);
94
+ await writeFile(path.join(distPath, "cjs", "package.json"), `{ "type": "commonjs" }`);
95
+ await writeFile(path.join(distPath, "esm", "package.json"), `{ "type": "module" }`);
96
+ await writeFile(path.join(distPath, "browser", "package.json"), `{ "type": "module" }`);
96
97
 
97
98
  res = true;
98
99
  } catch (e) {
@@ -1,4 +1,5 @@
1
- import fs from "fs-extra";
1
+ import { opendir, readFile, stat } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
2
3
 
3
4
  export interface IDistStats {
4
5
  bundleSize: number;
@@ -20,11 +21,11 @@ async function getFolderStats(folderPath: string, bundlePath?: string): Promise<
20
21
  totalSize: 0,
21
22
  };
22
23
 
23
- if (!(await fs.pathExists(folderPath))) {
24
+ if (!existsSync(folderPath)) {
24
25
  return stats;
25
26
  }
26
27
 
27
- const dir = await fs.promises.opendir(folderPath),
28
+ const dir = await opendir(folderPath),
28
29
  path = await import("path");
29
30
 
30
31
  for await (const dirent of dir) {
@@ -37,7 +38,7 @@ async function getFolderStats(folderPath: string, bundlePath?: string): Promise<
37
38
  stats.totalFiles += subDirStats.totalFiles;
38
39
  stats.totalSize += subDirStats.totalSize;
39
40
  } else {
40
- const fileStats = await fs.stat(path.join(folderPath, dirent.name));
41
+ const fileStats = await stat(path.join(folderPath, dirent.name));
41
42
 
42
43
  stats.totalFiles++;
43
44
  stats.totalSize += fileStats.size;
@@ -59,13 +60,12 @@ async function getFolderStats(folderPath: string, bundlePath?: string): Promise<
59
60
  export async function getDistStats(basePath: string): Promise<IDistStats> {
60
61
  const path = await import("path"),
61
62
  distFolder = path.join(basePath, "dist"),
62
- pkgInfo = (await fs.exists(path.join(distFolder, "package.json")))
63
- ? (JSON.parse((await fs.readFile(path.join(distFolder, "package.json"))).toString()) as {
63
+ pkgInfo = existsSync(path.join(distFolder, "package.json"))
64
+ ? (JSON.parse((await readFile(path.join(distFolder, "package.json"))).toString()) as {
64
65
  jsdelivr?: string;
65
66
  })
66
67
  : {},
67
- bundlePath =
68
- (await fs.exists(distFolder)) && pkgInfo.jsdelivr ? path.join(distFolder, pkgInfo.jsdelivr) : undefined;
68
+ bundlePath = existsSync(distFolder) && pkgInfo.jsdelivr ? path.join(distFolder, pkgInfo.jsdelivr) : undefined;
69
69
 
70
70
  return await getFolderStats(distFolder, bundlePath);
71
71
  }
@@ -1,4 +1,5 @@
1
- import fs from "fs-extra";
1
+ import { readFile, writeFile } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
2
3
  import klaw from "klaw";
3
4
  import path from "node:path";
4
5
  import prettier from "prettier";
@@ -23,7 +24,7 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
23
24
  continue;
24
25
  }
25
26
 
26
- const contents = await fs.readFile(file.path, "utf8"),
27
+ const contents = await readFile(file.path, "utf8"),
27
28
  options = (await prettier.resolveConfig(basePath)) ?? {};
28
29
 
29
30
  options.printWidth = 120;
@@ -39,7 +40,7 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
39
40
  } else {
40
41
  const formatted = await prettier.format(contents, options);
41
42
 
42
- await fs.writeFile(file.path, formatted, "utf8");
43
+ await writeFile(file.path, formatted, "utf8");
43
44
  }
44
45
  }
45
46
 
@@ -71,7 +72,7 @@ export async function prettifyPackageJson(basePath: string, ci: boolean, silent:
71
72
  let res: boolean;
72
73
 
73
74
  try {
74
- const contents = await fs.readFile("package.json", "utf8"),
75
+ const contents = await readFile("package.json", "utf8"),
75
76
  options = (await prettier.resolveConfig(basePath)) ?? {};
76
77
 
77
78
  options.tabWidth = 2;
@@ -86,7 +87,7 @@ export async function prettifyPackageJson(basePath: string, ci: boolean, silent:
86
87
  } else {
87
88
  const formatted = await prettier.format(contents, options);
88
89
 
89
- await fs.writeFile("package.json", formatted, "utf8");
90
+ await writeFile("package.json", formatted, "utf8");
90
91
  }
91
92
 
92
93
  res = true;
@@ -105,11 +106,11 @@ export async function prettifyPackageJson(basePath: string, ci: boolean, silent:
105
106
 
106
107
  /**
107
108
  * @param basePath -
108
- * @param _ci -
109
+ * @param ci -
109
110
  * @param silent -
110
111
  * @returns true if the prettify package.dist.json process was successful
111
112
  */
112
- export async function prettifyPackageDistJson(basePath: string, _ci: boolean, silent: boolean): Promise<boolean> {
113
+ export async function prettifyPackageDistJson(basePath: string, ci: boolean, silent: boolean): Promise<boolean> {
113
114
  if (!silent) {
114
115
  console.log("Prettier - started on package.dist.json");
115
116
  }
@@ -117,7 +118,7 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean, si
117
118
  let res: boolean;
118
119
 
119
120
  try {
120
- const contents = await fs.readFile("package.dist.json", "utf8"),
121
+ const contents = await readFile("package.dist.json", "utf8"),
121
122
  options = (await prettier.resolveConfig(basePath)) ?? {};
122
123
 
123
124
  options.tabWidth = 2;
@@ -125,17 +126,15 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean, si
125
126
  options.endOfLine = "lf";
126
127
  options.parser = "json";
127
128
 
128
- // TODO: disabled this check until "prettier-plugin-multiline-arrays" package is compatible with Prettier 3.0.0
129
-
130
- /* if (ci) {
131
- if (!(await prettier.check(contents, options))) {
132
- throw new Error(`package.dist.json is not formatted correctly`);
133
- }
134
- } else { */
135
- const formatted = await prettier.format(contents, options);
129
+ if (ci) {
130
+ if (!(await prettier.check(contents, options))) {
131
+ throw new Error(`package.dist.json is not formatted correctly`);
132
+ }
133
+ } else {
134
+ const formatted = await prettier.format(contents, options);
136
135
 
137
- await fs.writeFile("package.dist.json", formatted, "utf8");
138
- // }
136
+ await writeFile("package.dist.json", formatted, "utf8");
137
+ }
139
138
 
140
139
  res = true;
141
140
  } catch (e) {
@@ -165,7 +164,7 @@ export async function prettifyReadme(basePath: string, ci: boolean, silent: bool
165
164
  let res: boolean;
166
165
 
167
166
  try {
168
- const contents = await fs.readFile("README.md", "utf8"),
167
+ const contents = await readFile("README.md", "utf8"),
169
168
  options = (await prettier.resolveConfig(basePath)) ?? {};
170
169
 
171
170
  options.printWidth = 120;
@@ -179,7 +178,7 @@ export async function prettifyReadme(basePath: string, ci: boolean, silent: bool
179
178
  } else {
180
179
  const formatted = await prettier.format(contents, options);
181
180
 
182
- await fs.writeFile("README.md", formatted, "utf8");
181
+ await writeFile("README.md", formatted, "utf8");
183
182
  }
184
183
 
185
184
  res =
@@ -214,7 +213,7 @@ async function prettifyTraductions(basePath: string, ci: boolean, silent: boolea
214
213
  const folder = "traduction",
215
214
  folderPath = path.join(basePath, folder);
216
215
 
217
- if (!fs.existsSync(folderPath)) {
216
+ if (!existsSync(folderPath)) {
218
217
  res = true;
219
218
  }
220
219
 
@@ -224,7 +223,7 @@ async function prettifyTraductions(basePath: string, ci: boolean, silent: boolea
224
223
  continue;
225
224
  }
226
225
 
227
- const contents = await fs.readFile(file.path, "utf8"),
226
+ const contents = await readFile(file.path, "utf8"),
228
227
  options = (await prettier.resolveConfig(basePath)) ?? {};
229
228
 
230
229
  options.printWidth = 120;
@@ -238,7 +237,7 @@ async function prettifyTraductions(basePath: string, ci: boolean, silent: boolea
238
237
  } else {
239
238
  const formatted = await prettier.format(contents, options);
240
239
 
241
- await fs.writeFile(file.path, formatted, "utf8");
240
+ await writeFile(file.path, formatted, "utf8");
242
241
  }
243
242
  }
244
243
 
@@ -274,7 +273,7 @@ async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean, silen
274
273
  const folder = "markdown",
275
274
  folderPath = path.join(basePath, folder);
276
275
 
277
- if (!fs.existsSync(folderPath)) {
276
+ if (!existsSync(folderPath)) {
278
277
  res = true;
279
278
  }
280
279
 
@@ -284,7 +283,7 @@ async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean, silen
284
283
  continue;
285
284
  }
286
285
 
287
- const contents = await fs.readFile(file.path, "utf8"),
286
+ const contents = await readFile(file.path, "utf8"),
288
287
  options = (await prettier.resolveConfig(basePath)) ?? {};
289
288
 
290
289
  options.printWidth = 120;
@@ -298,7 +297,7 @@ async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean, silen
298
297
  } else {
299
298
  const formatted = await prettier.format(contents, options);
300
299
 
301
- await fs.writeFile(file.path, formatted, "utf8");
300
+ await writeFile(file.path, formatted, "utf8");
302
301
  }
303
302
  }
304
303
 
@@ -1,5 +1,6 @@
1
- import fs from "fs-extra";
1
+ import { existsSync } from "node:fs";
2
2
  import path from "node:path";
3
+ import { readFile } from "node:fs/promises";
3
4
 
4
5
  enum ExitCodes {
5
6
  OK = 0,
@@ -17,8 +18,8 @@ enum ExitCodes {
17
18
  async function readConfig(basePath: string, file: string): Promise<string | undefined> {
18
19
  const tsconfigPath = path.join(basePath, file);
19
20
 
20
- if (await fs.pathExists(tsconfigPath)) {
21
- const data = await fs.readFile(path.join(basePath, file));
21
+ if (existsSync(tsconfigPath)) {
22
+ const data = await readFile(path.join(basePath, file));
22
23
 
23
24
  return data.toString();
24
25
  }
@@ -1,4 +1,6 @@
1
1
  import { Command } from "commander";
2
+ import { existsSync } from "node:fs";
3
+ import path from "node:path";
2
4
 
3
5
  const buildCommand = new Command("build");
4
6
 
@@ -52,11 +54,9 @@ buildCommand.action(async (argPath: string) => {
52
54
  await clearDist(basePath, silent);
53
55
  }
54
56
 
55
- const path = await import("path"),
56
- srcPath = path.join(basePath, argPath),
57
- fs = await import("fs-extra");
57
+ const srcPath = path.join(basePath, argPath);
58
58
 
59
- if (!(await fs.pathExists(srcPath))) {
59
+ if (!existsSync(srcPath)) {
60
60
  throw new Error("Provided path does not exist");
61
61
  }
62
62
 
@@ -126,12 +126,12 @@ buildCommand.action(async (argPath: string) => {
126
126
  outputFunc = bundleSizeIncreased ? console.warn : console.info;
127
127
 
128
128
  texts = [
129
- !bundleDiffSize
130
- ? "Bundle size unchanged"
131
- : `Bundle size ${bundleSizeIncreasedText} from ${oldStats.bundleSize.toString()} to ${newStats.bundleSize.toString()} (${Math.abs(bundleDiffSize).toString()}B)`,
132
- !diffSize
133
- ? "Size unchanged"
134
- : `Size ${diffSizeIncreasedText} from ${oldStats.totalSize.toString()} to ${newStats.totalSize.toString()} (${Math.abs(diffSize).toString()}B)`,
129
+ bundleDiffSize
130
+ ? `Bundle size ${bundleSizeIncreasedText} from ${oldStats.bundleSize.toString()} to ${newStats.bundleSize.toString()} (${Math.abs(bundleDiffSize).toString()}B)`
131
+ : "Bundle size unchanged",
132
+ diffSize
133
+ ? `Size ${diffSizeIncreasedText} from ${oldStats.totalSize.toString()} to ${newStats.totalSize.toString()} (${Math.abs(diffSize).toString()}B)`
134
+ : "Size unchanged",
135
135
  `Files count changed from ${oldStats.totalFiles.toString()} to ${newStats.totalFiles.toString()} (${(
136
136
  newStats.totalFiles - oldStats.totalFiles
137
137
  ).toString()})`,
package/src/cli.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { buildCommand } from "./build/build.js";
3
3
  import { createCommand } from "./create/create.js";
4
- import { fileURLToPath } from "url";
5
- import fs from "fs-extra";
4
+ import { fileURLToPath } from "node:url";
6
5
  import path from "node:path";
7
6
  import { program } from "commander";
7
+ import { readFile } from "node:fs/promises";
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url),
10
10
  __dirname = path.dirname(__filename),
11
11
  rootPkgPath = path.join(__dirname, "..", "package.json"),
12
- pkg = (await fs.readJson(rootPkgPath)) as { version: string };
12
+ pkg = JSON.parse(await readFile(rootPkgPath, "utf-8")) as { version: string };
13
13
 
14
14
  program.name("tsparticles-cli");
15
15
  program.description("tsParticles CLI");
@@ -8,7 +8,7 @@ import {
8
8
  updatePackageFile,
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
- import fs from "fs-extra";
11
+ import { cp } from "node:fs/promises";
12
12
  import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
@@ -166,8 +166,9 @@ export async function createPluginTemplate(
166
166
 
167
167
  await copyEmptyTemplateFiles(destPath);
168
168
 
169
- await fs.copy(sourcePath, destPath, {
170
- overwrite: true,
169
+ await cp(sourcePath, destPath, {
170
+ recursive: true,
171
+ force: true,
171
172
  filter: copyFilter,
172
173
  });
173
174
 
@@ -8,7 +8,7 @@ import {
8
8
  updatePackageFile,
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
- import fs from "fs-extra";
11
+ import { cp } from "node:fs/promises";
12
12
  import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
@@ -184,8 +184,9 @@ export async function createPresetTemplate(
184
184
 
185
185
  await copyEmptyTemplateFiles(destPath);
186
186
 
187
- await fs.copy(sourcePath, destPath, {
188
- overwrite: true,
187
+ await cp(sourcePath, destPath, {
188
+ recursive: true,
189
+ force: true,
189
190
  filter: copyFilter,
190
191
  });
191
192
 
@@ -8,7 +8,7 @@ import {
8
8
  updatePackageFile,
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
- import fs from "fs-extra";
11
+ import { cp } from "node:fs/promises";
12
12
  import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
@@ -171,8 +171,9 @@ export async function createShapeTemplate(
171
171
 
172
172
  await copyEmptyTemplateFiles(destPath);
173
173
 
174
- await fs.copy(sourcePath, destPath, {
175
- overwrite: true,
174
+ await cp(sourcePath, destPath, {
175
+ recursive: true,
176
+ force: true,
176
177
  filter: copyFilter,
177
178
  });
178
179
 
@@ -1,5 +1,6 @@
1
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
1
2
  import { exec } from "node:child_process";
2
- import fs from "fs-extra";
3
+ import { existsSync } from "node:fs";
3
4
  import { lookpath } from "lookpath";
4
5
  import path from "node:path";
5
6
 
@@ -21,7 +22,7 @@ export async function replaceTokensInFiles(options: ReplaceTokensOptions[]): Pro
21
22
  for (const item of options) {
22
23
  const filePath = item.path;
23
24
 
24
- let data = await fs.readFile(filePath, "utf-8");
25
+ let data = await readFile(filePath, "utf-8");
25
26
 
26
27
  for (const token of item.tokens) {
27
28
  const regex = new RegExp(token.from, "g");
@@ -29,7 +30,7 @@ export async function replaceTokensInFiles(options: ReplaceTokensOptions[]): Pro
29
30
  data = data.replace(regex, token.to);
30
31
  }
31
32
 
32
- await fs.writeFile(filePath, data);
33
+ await writeFile(filePath, data);
33
34
  }
34
35
  }
35
36
 
@@ -48,10 +49,10 @@ export async function replaceTokensInFile(options: ReplaceTokensOptions): Promis
48
49
  */
49
50
  export async function getDestinationDir(destination: string): Promise<string> {
50
51
  const destPath = path.join(process.cwd(), destination),
51
- destExists = await fs.pathExists(destPath);
52
+ destExists = existsSync(destPath);
52
53
 
53
54
  if (destExists) {
54
- const destContents = await fs.readdir(destPath),
55
+ const destContents = await readdir(destPath),
55
56
  destContentsNoGit = destContents.filter(t => t !== ".git" && t !== ".gitignore");
56
57
 
57
58
  if (destContentsNoGit.length) {
@@ -59,7 +60,7 @@ export async function getDestinationDir(destination: string): Promise<string> {
59
60
  }
60
61
  }
61
62
 
62
- await fs.ensureDir(destPath);
63
+ await mkdir(destPath);
63
64
 
64
65
  return destPath;
65
66
  }
@@ -1,5 +1,5 @@
1
+ import { cp } from "node:fs/promises";
1
2
  import { exec } from "node:child_process";
2
- import fs from "fs-extra";
3
3
  import { lookpath } from "lookpath";
4
4
  import path from "node:path";
5
5
  import { replaceTokensInFile } from "./file-utils.js";
@@ -133,8 +133,9 @@ export async function updateWebpackFile(
133
133
  * @param destPath - The path where the project will be created
134
134
  */
135
135
  export async function copyEmptyTemplateFiles(destPath: string): Promise<void> {
136
- await fs.copy(path.join(__dirname, "..", "..", "files", "empty-project"), destPath, {
137
- overwrite: true,
136
+ await cp(path.join(__dirname, "..", "..", "files", "empty-project"), destPath, {
137
+ recursive: true,
138
+ force: true,
138
139
  filter: copyFilter,
139
140
  });
140
141
  }