@tsparticles/cli 3.0.17 → 3.1.0

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 (41) hide show
  1. package/.dependency-cruiser.cjs +382 -0
  2. package/dist/build/build-bundle.js +1 -1
  3. package/dist/build/build-circular-deps.d.ts +2 -2
  4. package/dist/build/build-circular-deps.js +61 -21
  5. package/dist/build/build-clear.js +1 -1
  6. package/dist/build/build-distfiles.js +1 -1
  7. package/dist/build/build-prettier.js +1 -1
  8. package/dist/build/build-tsc.js +1 -1
  9. package/dist/cli.js +1 -1
  10. package/dist/create/plugin/create-plugin.js +1 -1
  11. package/dist/create/plugin/plugin.js +1 -1
  12. package/dist/create/preset/create-preset.js +1 -1
  13. package/dist/create/preset/preset.js +1 -1
  14. package/dist/create/shape/create-shape.js +1 -1
  15. package/dist/create/shape/shape.js +1 -1
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/dist/utils/file-utils.js +2 -2
  18. package/dist/utils/template-utils.js +2 -2
  19. package/files/empty-project/package.json +5 -7
  20. package/package.json +10 -13
  21. package/pnpm-workspace.yaml +1 -0
  22. package/src/build/build-bundle.ts +1 -1
  23. package/src/build/build-circular-deps.ts +92 -24
  24. package/src/build/build-clear.ts +1 -1
  25. package/src/build/build-distfiles.ts +1 -1
  26. package/src/build/build-prettier.ts +1 -1
  27. package/src/build/build-tsc.ts +1 -1
  28. package/src/cli.ts +1 -1
  29. package/src/create/plugin/create-plugin.ts +1 -1
  30. package/src/create/plugin/plugin.ts +1 -1
  31. package/src/create/preset/create-preset.ts +1 -1
  32. package/src/create/preset/preset.ts +1 -1
  33. package/src/create/shape/create-shape.ts +1 -1
  34. package/src/create/shape/shape.ts +1 -1
  35. package/src/utils/file-utils.ts +2 -2
  36. package/src/utils/template-utils.ts +2 -2
  37. package/tests/create-plugin.test.ts +1 -1
  38. package/tests/create-preset.test.ts +1 -1
  39. package/tests/create-shape.test.ts +1 -1
  40. package/tests/file-utils.test.ts +1 -1
  41. package/tsconfig.json +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/cli",
3
- "version": "3.0.17",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,20 +11,20 @@
11
11
  },
12
12
  "prettier": "@tsparticles/prettier-config",
13
13
  "dependencies": {
14
- "@tsparticles/eslint-config": "^3.0.12",
14
+ "@tsparticles/eslint-config": "^3.1.0",
15
15
  "@tsparticles/prettier-config": "^3.0.11",
16
- "@tsparticles/tsconfig": "^3.0.9",
17
- "@tsparticles/webpack-plugin": "^3.0.12",
18
- "commander": "^14.0.2",
16
+ "@tsparticles/tsconfig": "^3.1.0",
17
+ "@tsparticles/webpack-plugin": "^3.1.0",
18
+ "commander": "^14.0.3",
19
19
  "eslint": "^9.39.2",
20
20
  "eslint-config-prettier": "^10.1.8",
21
- "eslint-plugin-jsdoc": "^62.4.1",
21
+ "eslint-plugin-jsdoc": "^62.5.0",
22
22
  "eslint-plugin-prettier": "^5.5.5",
23
23
  "eslint-plugin-tsdoc": "^0.5.0",
24
24
  "fs-extra": "^11.3.3",
25
25
  "klaw": "^4.1.0",
26
26
  "lookpath": "^1.2.3",
27
- "madge": "^8.0.0",
27
+ "dependency-cruiser": "^17.3.7",
28
28
  "path-scurry": "^2.0.1",
29
29
  "prettier": "^3.8.1",
30
30
  "prettier-plugin-multiline-arrays": "^4.1.3",
@@ -35,18 +35,15 @@
35
35
  "webpack": "^5.104.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/core": "^7.28.6",
39
- "@tsparticles/cli": "^3.0.16",
38
+ "@tsparticles/cli": "^3.0.17",
40
39
  "@tsparticles/engine": "^3.9.1",
41
40
  "@types/eslint": "^9.6.1",
42
41
  "@types/estree": "^1.0.8",
43
42
  "@types/fs-extra": "^11.0.4",
44
43
  "@types/klaw": "^3.0.7",
45
- "@types/madge": "^5.0.3",
46
- "@types/node": "^25.0.10",
44
+ "@types/node": "^25.2.0",
47
45
  "@types/prompts": "^2.4.9",
48
46
  "@types/webpack-env": "^1.18.8",
49
- "babel-loader": "^10.0.0",
50
47
  "browserslist": "^4.28.1",
51
48
  "copyfiles": "^2.4.1",
52
49
  "cross-env": "^10.1.0",
@@ -66,7 +63,7 @@
66
63
  "prettify:readme": "prettier --write ./README.md",
67
64
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
68
65
  "lint:ci": "eslint src --ext .js,.jsx,.ts,.tsx",
69
- "circular-deps": "madge --circular --extensions ts src",
66
+ "circular-deps": "depcruise src --include-only '^src' --validate --output-type err-long",
70
67
  "compile": "pnpm run build:ts",
71
68
  "compile:ci": "pnpm run build:ts",
72
69
  "build:ts": "pnpm run build:ts:cjs",
@@ -1,3 +1,4 @@
1
1
  onlyBuiltDependencies:
2
+ - '@swc/core'
2
3
  - '@tsparticles/engine'
3
4
  - esbuild
@@ -1,4 +1,4 @@
1
- import path from "path";
1
+ import path from "node:path";
2
2
  import webpack from "webpack";
3
3
 
4
4
  /**
@@ -1,39 +1,107 @@
1
- import madge from "madge";
2
- import path from "path";
1
+ import {
2
+ type ICruiseOptions,
3
+ type ICruiseResult,
4
+ type IForbiddenRuleType,
5
+ type IViolation,
6
+ cruise,
7
+ } from "dependency-cruiser";
8
+ import fs from "fs-extra";
9
+ import path from "node:path";
10
+
11
+ const ZERO_VIOLATIONS = 0;
3
12
 
4
13
  /**
5
- *
6
- * @param basePath -
14
+ * Checks for circular dependencies using dependency-cruiser
15
+ * @param basePath - The project root path
7
16
  * @returns true if no circular dependencies are found, false otherwise
8
17
  */
9
18
  export async function buildCircularDeps(basePath: string): Promise<boolean> {
10
- let res = false;
19
+ const srcPath = path.join(basePath, "src"),
20
+ configPath = path.join(basePath, ".dependency-cruiser.js"),
21
+ configPathCjs = path.join(basePath, ".dependency-cruiser.cjs");
22
+
23
+ // Base options with explicit type
24
+ let cruiseOptions: ICruiseOptions = {
25
+ tsPreCompilationDeps: false,
26
+ tsConfig: {
27
+ fileName: path.join(srcPath, "tsconfig.json"),
28
+ },
29
+ };
11
30
 
12
31
  try {
13
- const madgeRes = await madge(path.join(basePath, "src"), {
14
- fileExtensions: ["ts"],
15
- detectiveOptions: {
16
- ts: {
17
- skipTypeImports: true,
18
- },
32
+ if (await fs.pathExists(configPath)) {
33
+ const configModule = (await import(configPath)) as {
34
+ default: {
35
+ forbidden?: IForbiddenRuleType[];
36
+ options?: ICruiseOptions;
37
+ };
19
38
  },
20
- }),
21
- circularDeps = madgeRes.circular();
39
+ extendedConfig = configModule.default;
22
40
 
23
- if (circularDeps.length) {
24
- console.error("Circular dependencies found!");
41
+ cruiseOptions = {
42
+ ...cruiseOptions,
43
+ ...extendedConfig.options,
44
+ ruleSet: {
45
+ forbidden: extendedConfig.forbidden ?? [],
46
+ },
47
+ };
48
+ } else if (await fs.pathExists(configPathCjs)) {
49
+ const configModule = (await import(configPathCjs)) as {
50
+ default: {
51
+ forbidden?: IForbiddenRuleType[];
52
+ options?: ICruiseOptions;
53
+ };
54
+ },
55
+ extendedConfig = configModule.default;
25
56
 
26
- for (const dep of circularDeps) {
27
- console.error(dep.join(" > "));
28
- }
57
+ cruiseOptions = {
58
+ ...cruiseOptions,
59
+ ...extendedConfig.options,
60
+ ruleSet: {
61
+ forbidden: extendedConfig.forbidden ?? [],
62
+ },
63
+ };
29
64
  } else {
30
- res = true;
65
+ console.log("No .dependency-cruiser.js found, applying default circular check.");
66
+
67
+ cruiseOptions.ruleSet = {
68
+ forbidden: [
69
+ {
70
+ name: "no-circular",
71
+ severity: "error",
72
+ from: {},
73
+ to: { circular: true },
74
+ },
75
+ ],
76
+ };
77
+ }
78
+
79
+ const result: unknown = await cruise([srcPath], cruiseOptions),
80
+ cruiseResult = result as ICruiseResult,
81
+ violations: IViolation[] = cruiseResult.summary.violations,
82
+ circularViolations = violations.filter((violation: IViolation) => violation.rule.name === "no-circular");
83
+
84
+ if (circularViolations.length > ZERO_VIOLATIONS) {
85
+ console.error("⚠️ Circular dependencies found!");
86
+
87
+ for (const violation of circularViolations) {
88
+ const cyclePath = (violation.cycle ?? []).map(step => {
89
+ return (step as { name: string }).name;
90
+ });
91
+
92
+ console.error(`Cycle detected: ${cyclePath.join(" -> ")}`);
93
+ }
94
+ return false;
31
95
  }
32
- } catch (e) {
33
- console.error(e);
34
- }
35
96
 
36
- console.log("Finished checking circular dependencies.");
97
+ console.log(" No circular dependencies found.");
37
98
 
38
- return res;
99
+ return true;
100
+ } catch (e) {
101
+ console.error("❌ Error while checking dependencies:", e);
102
+
103
+ return false;
104
+ } finally {
105
+ console.log("Finished checking circular dependencies.");
106
+ }
39
107
  }
@@ -1,4 +1,4 @@
1
- import path from "path";
1
+ import path from "node:path";
2
2
  import { rimraf } from "rimraf";
3
3
 
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import fs from "fs-extra";
2
2
  import klaw from "klaw";
3
- import path from "path";
3
+ import path from "node:path";
4
4
 
5
5
  /**
6
6
  * @param basePath -
@@ -1,6 +1,6 @@
1
1
  import fs from "fs-extra";
2
2
  import klaw from "klaw";
3
- import path from "path";
3
+ import path from "node:path";
4
4
  import prettier from "prettier";
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import fs from "fs-extra";
2
- import path from "path";
2
+ import path from "node:path";
3
3
 
4
4
  enum ExitCodes {
5
5
  OK = 0,
package/src/cli.ts CHANGED
@@ -3,7 +3,7 @@ import { buildCommand } from "./build/build.js";
3
3
  import { createCommand } from "./create/create.js";
4
4
  import { fileURLToPath } from "url";
5
5
  import fs from "fs-extra";
6
- import path from "path";
6
+ import path from "node:path";
7
7
  import { program } from "commander";
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url),
@@ -9,7 +9,7 @@ import {
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
11
  import fs from "fs-extra";
12
- import path from "path";
12
+ import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
15
15
  /**
@@ -3,7 +3,7 @@ import prompts, { type PromptObject } from "prompts";
3
3
  import { Command } from "commander";
4
4
  import { capitalize } from "../../utils/string-utils.js";
5
5
  import { createPluginTemplate } from "./create-plugin.js";
6
- import path from "path";
6
+ import path from "node:path";
7
7
 
8
8
  const pluginCommand = new Command("plugin");
9
9
 
@@ -9,7 +9,7 @@ import {
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
11
  import fs from "fs-extra";
12
- import path from "path";
12
+ import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
15
15
  /**
@@ -3,7 +3,7 @@ import prompts, { type PromptObject } from "prompts";
3
3
  import { Command } from "commander";
4
4
  import { capitalize } from "../../utils/string-utils.js";
5
5
  import { createPresetTemplate } from "./create-preset.js";
6
- import path from "path";
6
+ import path from "node:path";
7
7
 
8
8
  const presetCommand = new Command("preset");
9
9
 
@@ -9,7 +9,7 @@ import {
9
9
  updateWebpackFile,
10
10
  } from "../../utils/template-utils.js";
11
11
  import fs from "fs-extra";
12
- import path from "path";
12
+ import path from "node:path";
13
13
  import { replaceTokensInFile } from "../../utils/file-utils.js";
14
14
 
15
15
  /**
@@ -3,7 +3,7 @@ import prompts, { type PromptObject } from "prompts";
3
3
  import { Command } from "commander";
4
4
  import { capitalize } from "../../utils/string-utils.js";
5
5
  import { createShapeTemplate } from "./create-shape.js";
6
- import path from "path";
6
+ import path from "node:path";
7
7
 
8
8
  const shapeCommand = new Command("shape");
9
9
 
@@ -1,7 +1,7 @@
1
- import { exec } from "child_process";
1
+ import { exec } from "node:child_process";
2
2
  import fs from "fs-extra";
3
3
  import { lookpath } from "lookpath";
4
- import path from "path";
4
+ import path from "node:path";
5
5
 
6
6
  export interface ReplaceTokensOptions {
7
7
  path: string;
@@ -1,7 +1,7 @@
1
- import { exec } from "child_process";
1
+ import { exec } from "node:child_process";
2
2
  import fs from "fs-extra";
3
3
  import { lookpath } from "lookpath";
4
- import path from "path";
4
+ import path from "node:path";
5
5
  import { replaceTokensInFile } from "./file-utils.js";
6
6
 
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from "vitest";
2
2
  import { createPluginTemplate } from "../src/create/plugin/create-plugin.js";
3
- import path from "path";
3
+ import path from "node:path";
4
4
  import fs from "fs-extra";
5
5
 
6
6
  describe("create-plugin", () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from "vitest";
2
2
  import { createPresetTemplate } from "../src/create/preset/create-preset.js";
3
- import path from "path";
3
+ import path from "node:path";
4
4
  import fs from "fs-extra";
5
5
 
6
6
  describe("create-preset", () => {
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from "vitest";
2
2
  import { createShapeTemplate } from "../src/create/shape/create-shape.js";
3
- import path from "path";
3
+ import path from "node:path";
4
4
  import fs from "fs-extra";
5
5
 
6
6
  describe("create-shape", () => {
@@ -1,6 +1,6 @@
1
1
  import {afterAll, describe, it, expect} from "vitest";
2
2
  import fs from "fs-extra";
3
- import path from "path";
3
+ import path from "node:path";
4
4
  import {
5
5
  getDestinationDir,
6
6
  getRepositoryUrl,
package/tsconfig.json CHANGED
@@ -24,7 +24,6 @@
24
24
  "node",
25
25
  "fs-extra",
26
26
  "klaw",
27
- "madge",
28
27
  "prompts",
29
28
  "eslint",
30
29
  "vitest"