@tsparticles/cli 2.0.0 → 2.0.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.
@@ -37,11 +37,11 @@ async function bundle(basePath) {
37
37
  console.log("Bundling started");
38
38
  let res = false;
39
39
  try {
40
- const options = await Promise.resolve(`${path_1.default.join(basePath, "webpack.config.js")}`).then(s => __importStar(require(s)));
40
+ const options = (await Promise.resolve(`${path_1.default.join(basePath, "webpack.config.js")}`).then(s => __importStar(require(s))));
41
41
  res = await new Promise((resolve, reject) => {
42
42
  (0, webpack_1.default)(options.default, (err, stats) => {
43
43
  if (err) {
44
- console.error(err.stack || err);
44
+ console.error(err.stack ?? err);
45
45
  reject(err);
46
46
  return;
47
47
  }
@@ -38,7 +38,7 @@ async function buildDistFiles(basePath) {
38
38
  console.log("Build - started on dist files");
39
39
  let res;
40
40
  try {
41
- const pkgInfo = await Promise.resolve(`${path_1.default.join(basePath, "package.json")}`).then(s => __importStar(require(s))), libPackage = path_1.default.join(basePath, "package.dist.json"), distPath = path_1.default.join(basePath, pkgInfo.publishConfig?.directory || "dist");
41
+ const pkgInfo = (await Promise.resolve(`${path_1.default.join(basePath, "package.json")}`).then(s => __importStar(require(s)))), libPackage = path_1.default.join(basePath, "package.dist.json"), distPath = path_1.default.join(basePath, pkgInfo.publishConfig?.directory ?? "dist");
42
42
  const data = await fs_extra_1.default.readFile(libPackage), text = data.toString(), libObj = JSON.parse(text);
43
43
  libObj.version = pkgInfo.version;
44
44
  if (pkgInfo.dependencies) {
@@ -76,13 +76,13 @@ async function buildDistFiles(basePath) {
76
76
  const contents = await fs_extra_1.default.readFile(file.path, "utf8");
77
77
  await fs_extra_1.default.writeFile(file.path, contents.replaceAll("__VERSION__", `"${pkgInfo.version}"`), "utf8");
78
78
  }
79
- /*for await (const file of klaw(path.join(distPath, "cjs"))) {
79
+ /* for await (const file of klaw(path.join(distPath, "cjs"))) {
80
80
  await fs.rename(file.path, file.path.replace(/\.js$/, ".cjs"));
81
81
  }
82
82
 
83
83
  for await (const file of klaw(path.join(distPath, "esm"))) {
84
84
  await fs.rename(file.path, file.path.replace(/\.js$/, ".mjs"));
85
- }*/
85
+ } */
86
86
  await fs_extra_1.default.writeFile(path_1.default.join(distPath, "cjs", "package.json"), `{ "type": "commonjs" }`);
87
87
  await fs_extra_1.default.writeFile(path_1.default.join(distPath, "esm", "package.json"), `{ "type": "module" }`);
88
88
  await fs_extra_1.default.writeFile(path_1.default.join(distPath, "browser", "package.json"), `{ "type": "module" }`);
@@ -70,7 +70,7 @@ async function getFolderStats(folderPath, bundlePath) {
70
70
  */
71
71
  async function getDistStats(basePath) {
72
72
  const distFolder = path_1.default.join(basePath, "dist"), pkgInfo = (await fs_extra_1.default.exists(path_1.default.join(distFolder, "package.json")))
73
- ? await Promise.resolve(`${path_1.default.join(distFolder, "package.json")}`).then(s => __importStar(require(s)))
73
+ ? (await Promise.resolve(`${path_1.default.join(distFolder, "package.json")}`).then(s => __importStar(require(s))))
74
74
  : {}, bundlePath = (await fs_extra_1.default.exists(distFolder)) && pkgInfo.jsdelivr
75
75
  ? path_1.default.resolve(path_1.default.join(distFolder, pkgInfo.jsdelivr))
76
76
  : undefined;
@@ -95,14 +95,14 @@ async function prettifyPackageDistJson(basePath, _ci) {
95
95
  options.endOfLine = "lf";
96
96
  options.parser = "json";
97
97
  // TODO: disabled this check until "prettier-plugin-multiline-arrays" package is compatible with Prettier 3.0.0
98
- /*if (ci) {
98
+ /* if (ci) {
99
99
  if (!(await prettier.check(contents, options))) {
100
100
  throw new Error(`package.dist.json is not formatted correctly`);
101
101
  }
102
- } else {*/
102
+ } else { */
103
103
  const formatted = await prettier_1.default.format(contents, options);
104
104
  await fs_extra_1.default.writeFile("package.dist.json", formatted, "utf8");
105
- //}
105
+ // }
106
106
  res = true;
107
107
  }
108
108
  catch (e) {
@@ -18,7 +18,6 @@ async function readConfig(basePath, file) {
18
18
  const data = await fs_extra_1.default.readFile(path_1.default.join(basePath, file));
19
19
  return data.toString();
20
20
  }
21
- return;
22
21
  }
23
22
  /**
24
23
  * @param basePath -
@@ -29,7 +29,7 @@ pluginCommand.action(async (destination) => {
29
29
  name: "description",
30
30
  message: "What is the description of the plugin?",
31
31
  validate: (value) => (value ? true : "The description can't be empty"),
32
- initial: (0, string_utils_1.capitalize)(initialName || ""),
32
+ initial: (0, string_utils_1.capitalize)(initialName ?? ""),
33
33
  },
34
34
  {
35
35
  type: "text",
@@ -38,6 +38,6 @@ pluginCommand.action(async (destination) => {
38
38
  initial: repoUrl.trim(),
39
39
  },
40
40
  ];
41
- const { name, description, repositoryUrl } = await (0, prompts_1.default)(questions);
41
+ const { name, description, repositoryUrl } = (await (0, prompts_1.default)(questions));
42
42
  await (0, create_plugin_1.createPluginTemplate)(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
43
  });
@@ -29,7 +29,7 @@ presetCommand.action(async (destination) => {
29
29
  name: "description",
30
30
  message: "What is the description of the preset?",
31
31
  validate: (value) => (value ? true : "The description can't be empty"),
32
- initial: (0, string_utils_1.capitalize)(initialName || ""),
32
+ initial: (0, string_utils_1.capitalize)(initialName ?? ""),
33
33
  },
34
34
  {
35
35
  type: "text",
@@ -38,6 +38,6 @@ presetCommand.action(async (destination) => {
38
38
  initial: repoUrl.trim(),
39
39
  },
40
40
  ];
41
- const { name, description, repositoryUrl } = await (0, prompts_1.default)(questions);
41
+ const { name, description, repositoryUrl } = (await (0, prompts_1.default)(questions));
42
42
  await (0, create_preset_1.createPresetTemplate)(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
43
  });
@@ -29,7 +29,7 @@ shapeCommand.action(async (destination) => {
29
29
  name: "description",
30
30
  message: "What is the description of the shape?",
31
31
  validate: (value) => (value ? true : "The description can't be empty"),
32
- initial: (0, string_utils_1.capitalize)(initialName || ""),
32
+ initial: (0, string_utils_1.capitalize)(initialName ?? ""),
33
33
  },
34
34
  {
35
35
  type: "text",
@@ -38,6 +38,6 @@ shapeCommand.action(async (destination) => {
38
38
  initial: repoUrl.trim(),
39
39
  },
40
40
  ];
41
- const { name, description, repositoryUrl } = await (0, prompts_1.default)(questions);
41
+ const { name, description, repositoryUrl } = (await (0, prompts_1.default)(questions));
42
42
  await (0, create_shape_1.createShapeTemplate)(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
43
  });
@@ -72,6 +72,6 @@
72
72
  "module": "index.js",
73
73
  "types": "index.d.ts",
74
74
  "dependencies": {
75
- "@tsparticles/engine": "^3.0.0-beta.3"
75
+ "@tsparticles/engine": "^3.0.2"
76
76
  }
77
77
  }
@@ -82,29 +82,29 @@
82
82
  "types": "dist/types/index.d.ts",
83
83
  "prettier": "@tsparticles/prettier-config",
84
84
  "devDependencies": {
85
- "@babel/core": "^7.23.3",
86
- "@tsparticles/cli": "^2.0.0",
87
- "@tsparticles/eslint-config": "^2.0.0-beta.7",
88
- "@tsparticles/prettier-config": "^2.0.0-beta.4",
89
- "@tsparticles/tsconfig": "^2.0.0-beta.1",
90
- "@tsparticles/webpack-plugin": "^2.0.0-beta.11",
85
+ "@babel/core": "^7.23.6",
86
+ "@tsparticles/cli": "^2.0.2",
87
+ "@tsparticles/eslint-config": "^2.0.2",
88
+ "@tsparticles/prettier-config": "^2.0.1",
89
+ "@tsparticles/tsconfig": "^2.0.1",
90
+ "@tsparticles/webpack-plugin": "^2.0.2",
91
91
  "@types/webpack-env": "^1.18.4",
92
- "@typescript-eslint/eslint-plugin": "^6.11.0",
93
- "@typescript-eslint/parser": "^6.11.0",
92
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
93
+ "@typescript-eslint/parser": "^6.14.0",
94
94
  "babel-loader": "^9.1.3",
95
95
  "browserslist": "^4.22.1",
96
96
  "copyfiles": "^2.4.1",
97
- "eslint": "^8.53.0",
98
- "eslint-config-prettier": "^9.0.0",
99
- "prettier": "^3.1.0",
97
+ "eslint": "^8.55.0",
98
+ "eslint-config-prettier": "^9.1.0",
99
+ "prettier": "^3.1.1",
100
100
  "rimraf": "^5.0.5",
101
101
  "terser-webpack-plugin": "^5.3.9",
102
- "typescript": "^5.2.2",
102
+ "typescript": "^5.3.3",
103
103
  "webpack": "^5.89.0",
104
104
  "webpack-bundle-analyzer": "^4.10.0",
105
105
  "webpack-cli": "^5.1.4"
106
106
  },
107
107
  "dependencies": {
108
- "@tsparticles/engine": "^3.0.0-beta.3"
108
+ "@tsparticles/engine": "^3.0.2"
109
109
  }
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "tsparticles-cli": "dist/cli.js"
@@ -10,40 +10,40 @@
10
10
  },
11
11
  "prettier": "@tsparticles/prettier-config",
12
12
  "dependencies": {
13
- "@tsparticles/eslint-config": "^2.0.0",
14
- "@tsparticles/prettier-config": "^2.0.0",
15
- "@tsparticles/tsconfig": "^2.0.0",
16
- "@tsparticles/webpack-plugin": "^2.0.0",
17
- "@typescript-eslint/eslint-plugin": "^6.12.0",
18
- "@typescript-eslint/parser": "^6.12.0",
13
+ "@tsparticles/eslint-config": "^2.0.2",
14
+ "@tsparticles/prettier-config": "^2.0.1",
15
+ "@tsparticles/tsconfig": "^2.0.1",
16
+ "@tsparticles/webpack-plugin": "^2.0.2",
17
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
18
+ "@typescript-eslint/parser": "^6.14.0",
19
19
  "commander": "^11.1.0",
20
- "eslint": "^8.54.0",
21
- "eslint-config-prettier": "^9.0.0",
20
+ "eslint": "^8.55.0",
21
+ "eslint-config-prettier": "^9.1.0",
22
22
  "eslint-plugin-jsdoc": "^46.9.0",
23
23
  "eslint-plugin-tsdoc": "^0.2.17",
24
- "fs-extra": "^11.1.1",
24
+ "fs-extra": "^11.2.0",
25
25
  "klaw": "^4.1.0",
26
26
  "lookpath": "^1.2.2",
27
27
  "path-scurry": "^1.10.1",
28
- "prettier": "^3.1.0",
28
+ "prettier": "^3.1.1",
29
29
  "prettier-plugin-multiline-arrays": "^3.0.1",
30
30
  "prompts": "^2.4.2",
31
31
  "rimraf": "^5.0.5",
32
- "typescript": "^5.3.2",
32
+ "typescript": "^5.3.3",
33
33
  "webpack": "^5.89.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^4.3.11",
37
37
  "@types/fs-extra": "^11.0.4",
38
38
  "@types/klaw": "^3.0.6",
39
- "@types/mocha": "^10.0.5",
40
- "@types/node": "^20.9.3",
39
+ "@types/mocha": "^10.0.6",
40
+ "@types/node": "^20.10.4",
41
41
  "@types/prompts": "^2.4.9",
42
42
  "chai": "^4.3.10",
43
43
  "cross-env": "^7.0.3",
44
44
  "mocha": "^10.2.0",
45
45
  "nyc": "^15.1.0",
46
- "ts-node": "^10.9.1"
46
+ "ts-node": "^10.9.2"
47
47
  },
48
48
  "description": "tsParticles CLI",
49
49
  "main": ".eslintrc.js",
@@ -11,12 +11,12 @@ export async function bundle(basePath: string): Promise<boolean> {
11
11
  let res = false;
12
12
 
13
13
  try {
14
- const options = await import(path.join(basePath, "webpack.config.js"));
14
+ const options = (await import(path.join(basePath, "webpack.config.js"))) as { default: webpack.Configuration };
15
15
 
16
16
  res = await new Promise<boolean>((resolve, reject) => {
17
17
  webpack(options.default, (err, stats) => {
18
18
  if (err) {
19
- console.error(err.stack || err);
19
+ console.error(err.stack ?? err);
20
20
 
21
21
  reject(err);
22
22
 
@@ -12,13 +12,18 @@ export async function buildDistFiles(basePath: string): Promise<boolean> {
12
12
  let res: boolean;
13
13
 
14
14
  try {
15
- const pkgInfo = await import(path.join(basePath, "package.json")),
15
+ const pkgInfo = (await import(path.join(basePath, "package.json"))) as {
16
+ dependencies?: Record<string, string>;
17
+ peerDependencies?: Record<string, string>;
18
+ publishConfig?: { directory?: string };
19
+ version: string;
20
+ },
16
21
  libPackage = path.join(basePath, "package.dist.json"),
17
- distPath = path.join(basePath, pkgInfo.publishConfig?.directory || "dist");
22
+ distPath = path.join(basePath, pkgInfo.publishConfig?.directory ?? "dist");
18
23
 
19
24
  const data = await fs.readFile(libPackage),
20
25
  text = data.toString(),
21
- libObj = JSON.parse(text);
26
+ libObj = JSON.parse(text) as Record<string, unknown>;
22
27
 
23
28
  libObj.version = pkgInfo.version;
24
29
 
@@ -71,13 +76,13 @@ export async function buildDistFiles(basePath: string): Promise<boolean> {
71
76
  await fs.writeFile(file.path, contents.replaceAll("__VERSION__", `"${pkgInfo.version}"`), "utf8");
72
77
  }
73
78
 
74
- /*for await (const file of klaw(path.join(distPath, "cjs"))) {
79
+ /* for await (const file of klaw(path.join(distPath, "cjs"))) {
75
80
  await fs.rename(file.path, file.path.replace(/\.js$/, ".cjs"));
76
81
  }
77
82
 
78
83
  for await (const file of klaw(path.join(distPath, "esm"))) {
79
84
  await fs.rename(file.path, file.path.replace(/\.js$/, ".mjs"));
80
- }*/
85
+ } */
81
86
 
82
87
  await fs.writeFile(path.join(distPath, "cjs", "package.json"), `{ "type": "commonjs" }`);
83
88
  await fs.writeFile(path.join(distPath, "esm", "package.json"), `{ "type": "module" }`);
@@ -57,7 +57,7 @@ async function getFolderStats(folderPath: string, bundlePath?: string): Promise<
57
57
  export async function getDistStats(basePath: string): Promise<IDistStats> {
58
58
  const distFolder = path.join(basePath, "dist"),
59
59
  pkgInfo = (await fs.exists(path.join(distFolder, "package.json")))
60
- ? await import(path.join(distFolder, "package.json"))
60
+ ? ((await import(path.join(distFolder, "package.json"))) as { jsdelivr?: string })
61
61
  : {},
62
62
  bundlePath =
63
63
  (await fs.exists(distFolder)) && pkgInfo.jsdelivr
@@ -113,15 +113,15 @@ export async function prettifyPackageDistJson(basePath: string, _ci: boolean): P
113
113
 
114
114
  // TODO: disabled this check until "prettier-plugin-multiline-arrays" package is compatible with Prettier 3.0.0
115
115
 
116
- /*if (ci) {
116
+ /* if (ci) {
117
117
  if (!(await prettier.check(contents, options))) {
118
118
  throw new Error(`package.dist.json is not formatted correctly`);
119
119
  }
120
- } else {*/
120
+ } else { */
121
121
  const formatted = await prettier.format(contents, options);
122
122
 
123
123
  await fs.writeFile("package.dist.json", formatted, "utf8");
124
- //}
124
+ // }
125
125
 
126
126
  res = true;
127
127
  } catch (e) {
@@ -15,8 +15,6 @@ async function readConfig(basePath: string, file: string): Promise<string | unde
15
15
 
16
16
  return data.toString();
17
17
  }
18
-
19
- return;
20
18
  }
21
19
 
22
20
  /**
@@ -27,7 +27,7 @@ pluginCommand.action(async (destination: string) => {
27
27
  name: "description",
28
28
  message: "What is the description of the plugin?",
29
29
  validate: (value: string) => (value ? true : "The description can't be empty"),
30
- initial: capitalize(initialName || ""),
30
+ initial: capitalize(initialName ?? ""),
31
31
  },
32
32
  {
33
33
  type: "text",
@@ -37,7 +37,11 @@ pluginCommand.action(async (destination: string) => {
37
37
  },
38
38
  ];
39
39
 
40
- const { name, description, repositoryUrl } = await prompts(questions);
40
+ const { name, description, repositoryUrl } = (await prompts(questions)) as {
41
+ description: string;
42
+ name: string;
43
+ repositoryUrl: string;
44
+ };
41
45
 
42
46
  await createPluginTemplate(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
47
  });
@@ -27,7 +27,7 @@ presetCommand.action(async (destination: string) => {
27
27
  name: "description",
28
28
  message: "What is the description of the preset?",
29
29
  validate: (value: string) => (value ? true : "The description can't be empty"),
30
- initial: capitalize(initialName || ""),
30
+ initial: capitalize(initialName ?? ""),
31
31
  },
32
32
  {
33
33
  type: "text",
@@ -37,7 +37,11 @@ presetCommand.action(async (destination: string) => {
37
37
  },
38
38
  ];
39
39
 
40
- const { name, description, repositoryUrl } = await prompts(questions);
40
+ const { name, description, repositoryUrl } = (await prompts(questions)) as {
41
+ description: string;
42
+ name: string;
43
+ repositoryUrl: string;
44
+ };
41
45
 
42
46
  await createPresetTemplate(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
47
  });
@@ -27,7 +27,7 @@ shapeCommand.action(async (destination: string) => {
27
27
  name: "description",
28
28
  message: "What is the description of the shape?",
29
29
  validate: (value: string) => (value ? true : "The description can't be empty"),
30
- initial: capitalize(initialName || ""),
30
+ initial: capitalize(initialName ?? ""),
31
31
  },
32
32
  {
33
33
  type: "text",
@@ -37,7 +37,11 @@ shapeCommand.action(async (destination: string) => {
37
37
  },
38
38
  ];
39
39
 
40
- const { name, description, repositoryUrl } = await prompts(questions);
40
+ const { name, description, repositoryUrl } = (await prompts(questions)) as {
41
+ description: string;
42
+ name: string;
43
+ repositoryUrl: string;
44
+ };
41
45
 
42
46
  await createShapeTemplate(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
43
47
  });
@@ -3,15 +3,15 @@ import fs from "fs-extra";
3
3
  import { lookpath } from "lookpath";
4
4
  import path from "path";
5
5
 
6
- export type ReplaceTokensOptions = {
6
+ export interface ReplaceTokensOptions {
7
7
  path: string;
8
8
  tokens: ReplaceTokensData[];
9
- };
9
+ }
10
10
 
11
- export type ReplaceTokensData = {
11
+ export interface ReplaceTokensData {
12
12
  from: string | RegExp;
13
13
  to: string;
14
- };
14
+ }
15
15
 
16
16
  /**
17
17
  *