@tsparticles/cli 3.0.9 → 3.0.11

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.
@@ -9,7 +9,7 @@ export async function buildDistFiles(basePath) {
9
9
  console.log("Build - started on dist files");
10
10
  let res;
11
11
  try {
12
- const pkgInfo = (await import(path.join(basePath, "package.json"))), libPackage = path.join(basePath, "package.dist.json"), distPath = path.join(basePath, pkgInfo.publishConfig?.directory ?? "dist");
12
+ const pkgInfo = JSON.parse((await fs.readFile(path.join(basePath, "package.json"))).toString()), libPackage = path.join(basePath, "package.dist.json"), distPath = path.join(basePath, pkgInfo.publishConfig?.directory ?? "dist");
13
13
  const data = await fs.readFile(libPackage), text = data.toString(), libObj = JSON.parse(text);
14
14
  libObj.version = pkgInfo.version;
15
15
  if (pkgInfo.dependencies) {
@@ -41,7 +41,7 @@ async function getFolderStats(folderPath, bundlePath) {
41
41
  */
42
42
  export async function getDistStats(basePath) {
43
43
  const path = await import("path"), distFolder = path.join(basePath, "dist"), pkgInfo = (await fs.exists(path.join(distFolder, "package.json")))
44
- ? (await import(path.join(distFolder, "package.json")))
44
+ ? JSON.parse((await fs.readFile(path.join(distFolder, "package.json"))).toString())
45
45
  : {}, bundlePath = (await fs.exists(distFolder)) && pkgInfo.jsdelivr ? path.join(distFolder, pkgInfo.jsdelivr) : undefined;
46
46
  return await getFolderStats(distFolder, bundlePath);
47
47
  }
@@ -1,6 +1,4 @@
1
1
  import { ESLint } from "eslint";
2
- import { defineConfig } from "eslint/config";
3
- import tsParticlesESLintConfig from "@tsparticles/eslint-config";
4
2
  /**
5
3
  * @param ci -
6
4
  * @returns true if the linting was successful
@@ -9,7 +7,9 @@ export async function lint(ci) {
9
7
  console.log("ESLint - started on src");
10
8
  let res;
11
9
  try {
12
- const eslint = new ESLint({ baseConfig: defineConfig([tsParticlesESLintConfig]), fix: !ci });
10
+ const eslint = new ESLint({
11
+ fix: !ci,
12
+ });
13
13
  const results = await eslint.lintFiles(["src"]), errors = ESLint.getErrorResults(results);
14
14
  await ESLint.outputFixes(results);
15
15
  const formatter = await eslint.loadFormatter("stylish"), resultText = formatter.format(results), minimumLength = 0;
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
5
5
  import fs from "fs-extra";
6
6
  import path from "path";
7
7
  import { program } from "commander";
8
- const __filename = fileURLToPath(import.meta.url), __dirname = path.dirname(__filename), rootPkgPath = path.join(__dirname, "package.json"), pkg = (await fs.readJson(rootPkgPath));
8
+ const __filename = fileURLToPath(import.meta.url), __dirname = path.dirname(__filename), rootPkgPath = path.join(__dirname, "..", "package.json"), pkg = (await fs.readJson(rootPkgPath));
9
9
  program.name("tsparticles-cli");
10
10
  program.description("tsParticles CLI");
11
11
  program.version(pkg.version, "-v, --version", "output the current version");
@@ -17,6 +17,11 @@ async function updateIndexFile(destPath, name) {
17
17
  from: /loadTemplateShape/g,
18
18
  to: `load${capitalizedName}Shape`,
19
19
  },
20
+ ],
21
+ });
22
+ await replaceTokensInFile({
23
+ path: path.join(destPath, "src", "ShapeDrawer.ts"),
24
+ tokens: [
20
25
  {
21
26
  from: /"#template#"/g,
22
27
  to: `"${camelizedName}"`,
@@ -1,6 +1,8 @@
1
1
  import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
2
2
 
3
3
  export class ShapeDrawer implements IShapeDrawer {
4
+ readonly validTypes = ["#template#"] as const;
5
+
4
6
  draw(_data: IShapeDrawData): void {
5
7
  // draw the particle using the context
6
8
  // which is already centered in the particle position
@@ -6,5 +6,5 @@ import type { Engine } from "@tsparticles/engine";
6
6
  export async function loadTemplateShape(engine: Engine): Promise<void> {
7
7
  const { ShapeDrawer } = await import("./ShapeDrawer.js");
8
8
 
9
- await engine.addShape("#template#", new ShapeDrawer());
9
+ await engine.addShape(new ShapeDrawer());
10
10
  }
@@ -84,7 +84,7 @@
84
84
  "prettier": "@tsparticles/prettier-config",
85
85
  "devDependencies": {
86
86
  "@babel/core": "^7.28.3",
87
- "@tsparticles/cli": "^3.0.9",
87
+ "@tsparticles/cli": "^3.0.11",
88
88
  "@tsparticles/eslint-config": "^3.0.5",
89
89
  "@tsparticles/prettier-config": "^3.0.1",
90
90
  "@tsparticles/tsconfig": "^3.0.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/cli",
3
- "version": "3.0.9",
3
+ "version": "3.0.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -11,49 +11,49 @@
11
11
  },
12
12
  "prettier": "@tsparticles/prettier-config",
13
13
  "dependencies": {
14
- "@tsparticles/eslint-config": "^3.0.5",
15
- "@tsparticles/prettier-config": "^3.0.1",
16
- "@tsparticles/tsconfig": "^3.0.5",
17
- "@tsparticles/webpack-plugin": "^3.0.5",
18
- "commander": "^14.0.0",
19
- "eslint": "^9.34.0",
14
+ "@tsparticles/eslint-config": "^3.0.6",
15
+ "@tsparticles/prettier-config": "^3.0.6",
16
+ "@tsparticles/tsconfig": "^3.0.6",
17
+ "@tsparticles/webpack-plugin": "^3.0.6",
18
+ "commander": "^14.0.2",
19
+ "eslint": "^9.39.2",
20
20
  "eslint-config-prettier": "^10.1.8",
21
- "eslint-plugin-jsdoc": "^54.1.1",
21
+ "eslint-plugin-jsdoc": "^61.5.0",
22
22
  "eslint-plugin-prettier": "^5.5.4",
23
- "eslint-plugin-tsdoc": "^0.4.0",
24
- "fs-extra": "^11.3.1",
23
+ "eslint-plugin-tsdoc": "^0.5.0",
24
+ "fs-extra": "^11.3.3",
25
25
  "klaw": "^4.1.0",
26
26
  "lookpath": "^1.2.3",
27
27
  "madge": "^8.0.0",
28
- "path-scurry": "^2.0.0",
29
- "prettier": "^3.6.2",
30
- "prettier-plugin-multiline-arrays": "^4.0.3",
28
+ "path-scurry": "^2.0.1",
29
+ "prettier": "^3.7.4",
30
+ "prettier-plugin-multiline-arrays": "4.1.1",
31
31
  "prompts": "^2.4.2",
32
- "rimraf": "^6.0.1",
33
- "typescript": "^5.9.2",
34
- "typescript-eslint": "^8.41.0",
35
- "webpack": "^5.101.3"
32
+ "rimraf": "^6.1.2",
33
+ "typescript": "^5.9.3",
34
+ "typescript-eslint": "^8.50.0",
35
+ "webpack": "^5.104.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/core": "^7.28.3",
39
- "@tsparticles/cli": "^2.3.3",
38
+ "@babel/core": "^7.28.5",
39
+ "@tsparticles/cli": "^3.0.10",
40
40
  "@tsparticles/engine": "^3.9.1",
41
41
  "@types/eslint": "^9.6.1",
42
42
  "@types/estree": "^1.0.8",
43
43
  "@types/fs-extra": "^11.0.4",
44
44
  "@types/klaw": "^3.0.7",
45
45
  "@types/madge": "^5.0.3",
46
- "@types/node": "^24.3.0",
46
+ "@types/node": "^25.0.3",
47
47
  "@types/prompts": "^2.4.9",
48
48
  "@types/webpack-env": "^1.18.8",
49
49
  "babel-loader": "^10.0.0",
50
- "browserslist": "^4.25.4",
50
+ "browserslist": "^4.28.1",
51
51
  "copyfiles": "^2.4.1",
52
- "cross-env": "^10.0.0",
53
- "terser-webpack-plugin": "^5.3.14",
52
+ "cross-env": "^10.1.0",
53
+ "terser-webpack-plugin": "^5.3.16",
54
54
  "ts-node": "^10.9.2",
55
- "vitest": "^1.5.6",
56
- "webpack-bundle-analyzer": "^4.10.2",
55
+ "vitest": "^4.0.16",
56
+ "webpack-bundle-analyzer": "^5.1.0",
57
57
  "webpack-cli": "^6.0.1"
58
58
  },
59
59
  "description": "tsParticles CLI",
@@ -71,7 +71,7 @@
71
71
  "compile:ci": "pnpm run build:ts",
72
72
  "build:ts": "pnpm run build:ts:cjs",
73
73
  "build:ts:cjs": "tsc -p src",
74
- "test": "vitest run --silent=false",
74
+ "test": "vitest run",
75
75
  "build": "pnpm run clear:dist && pnpm run prettify:src && pnpm run lint && pnpm run compile && pnpm run circular-deps && pnpm run prettify:readme && chmod +x dist/cli.js && chmod +x dist/build/build.js && chmod +x dist/create/create.js && chmod +x dist/create/preset/preset.js",
76
76
  "build:ci": "pnpm run clear:dist && pnpm run prettify:ci:src && pnpm run lint:ci && pnpm run compile:ci && pnpm run prettify:ci:readme",
77
77
  "clear:dist": "rimraf ./dist",
@@ -12,7 +12,7 @@ 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"))) as {
15
+ const pkgInfo = JSON.parse((await fs.readFile(path.join(basePath, "package.json"))).toString()) as {
16
16
  dependencies?: Record<string, string>;
17
17
  peerDependencies?: Record<string, string>;
18
18
  publishConfig?: { directory?: string };
@@ -60,7 +60,9 @@ export async function getDistStats(basePath: string): Promise<IDistStats> {
60
60
  const path = await import("path"),
61
61
  distFolder = path.join(basePath, "dist"),
62
62
  pkgInfo = (await fs.exists(path.join(distFolder, "package.json")))
63
- ? ((await import(path.join(distFolder, "package.json"))) as { jsdelivr?: string })
63
+ ? (JSON.parse((await fs.readFile(path.join(distFolder, "package.json"))).toString()) as {
64
+ jsdelivr?: string;
65
+ })
64
66
  : {},
65
67
  bundlePath =
66
68
  (await fs.exists(distFolder)) && pkgInfo.jsdelivr ? path.join(distFolder, pkgInfo.jsdelivr) : undefined;
@@ -1,6 +1,4 @@
1
1
  import { ESLint } from "eslint";
2
- import { defineConfig } from "eslint/config";
3
- import tsParticlesESLintConfig from "@tsparticles/eslint-config";
4
2
 
5
3
  /**
6
4
  * @param ci -
@@ -12,7 +10,9 @@ export async function lint(ci: boolean): Promise<boolean> {
12
10
  let res: boolean;
13
11
 
14
12
  try {
15
- const eslint = new ESLint({ baseConfig: defineConfig([tsParticlesESLintConfig]), fix: !ci });
13
+ const eslint = new ESLint({
14
+ fix: !ci,
15
+ });
16
16
 
17
17
  const results = await eslint.lintFiles(["src"]),
18
18
  errors = ESLint.getErrorResults(results);
@@ -27,8 +27,7 @@ export async function lint(ci: boolean): Promise<boolean> {
27
27
  const messages = errors.map(t =>
28
28
  t.messages
29
29
  .map(m => `${t.filePath} (${m.line.toString()},${m.column.toString()}): ${m.message}`)
30
- .join("\n"),
31
- );
30
+ .join("\n"));
32
31
 
33
32
  throw new Error(messages.join("\n"));
34
33
  }
package/src/cli.ts CHANGED
@@ -8,7 +8,7 @@ import { program } from "commander";
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url),
10
10
  __dirname = path.dirname(__filename),
11
- rootPkgPath = path.join(__dirname, "package.json"),
11
+ rootPkgPath = path.join(__dirname, "..", "package.json"),
12
12
  pkg = (await fs.readJson(rootPkgPath)) as { version: string };
13
13
 
14
14
  program.name("tsparticles-cli");
@@ -179,7 +179,6 @@ export async function createPluginTemplate(
179
179
  await updatePluginPackageDistFile(destPath, name, description, repoUrl);
180
180
  await updateReadmeFile(destPath, name, description, repoUrl);
181
181
  await updatePluginWebpackFile(destPath, name, description);
182
-
183
182
  await runInstall(destPath);
184
183
  await runBuild(destPath);
185
184
  }
@@ -28,6 +28,12 @@ async function updateIndexFile(destPath: string, name: string): Promise<void> {
28
28
  from: /loadTemplateShape/g,
29
29
  to: `load${capitalizedName}Shape`,
30
30
  },
31
+ ],
32
+ });
33
+
34
+ await replaceTokensInFile({
35
+ path: path.join(destPath, "src", "ShapeDrawer.ts"),
36
+ tokens: [
31
37
  {
32
38
  from: /"#template#"/g,
33
39
  to: `"${camelizedName}"`,
@@ -8,8 +8,6 @@ describe("create-plugin", () => {
8
8
  const destDir = path.join(__dirname, "tmp-files", "foo-plugin"),
9
9
  pkgPath = path.join(destDir, "package.json");
10
10
 
11
- console.log("pkgPath - plugin", pkgPath);
12
-
13
11
  await createPluginTemplate("foo", "Foo", "", destDir);
14
12
 
15
13
  const pkgInfo = await fs.readJSON(pkgPath);
@@ -24,11 +22,8 @@ describe("create-plugin", () => {
24
22
 
25
23
  await createPluginTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
26
24
 
27
- const pkgPath = path.join(destDir, "package.json");
28
-
29
- console.log(pkgPath);
30
-
31
- const pkgInfo = await fs.readJSON(pkgPath);
25
+ const pkgPath = path.join(destDir, "package.json"),
26
+ pkgInfo = await fs.readJSON(pkgPath);
32
27
 
33
28
  expect(pkgInfo.name).toBe("tsparticles-plugin-bar");
34
29
 
@@ -9,11 +9,8 @@ describe("create-preset", () => {
9
9
 
10
10
  await createPresetTemplate("foo", "Foo", "", destDir);
11
11
 
12
- const pkgPath = path.join(destDir, "package.json");
13
-
14
- console.log(pkgPath);
15
-
16
- const pkgInfo = await fs.readJSON(pkgPath);
12
+ const pkgPath = path.join(destDir, "package.json"),
13
+ pkgInfo = await fs.readJSON(pkgPath);
17
14
 
18
15
  expect(pkgInfo.name).toBe("tsparticles-preset-foo");
19
16
 
@@ -25,11 +22,8 @@ describe("create-preset", () => {
25
22
 
26
23
  await createPresetTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
27
24
 
28
- const pkgPath = path.join(destDir, "package.json");
29
-
30
- console.log(pkgPath);
31
-
32
- const pkgInfo = await fs.readJSON(pkgPath);
25
+ const pkgPath = path.join(destDir, "package.json"),
26
+ pkgInfo = await fs.readJSON(pkgPath);
33
27
 
34
28
  expect(pkgInfo.name).toBe("tsparticles-preset-bar");
35
29
 
@@ -9,11 +9,8 @@ describe("create-shape", () => {
9
9
 
10
10
  await createShapeTemplate("foo", "Foo", "", destDir);
11
11
 
12
- const pkgPath = path.join(destDir, "package.json");
13
-
14
- console.log(pkgPath);
15
-
16
- const pkgInfo = await fs.readJSON(pkgPath);
12
+ const pkgPath = path.join(destDir, "package.json"),
13
+ pkgInfo = await fs.readJSON(pkgPath);
17
14
 
18
15
  expect(pkgInfo.name).toBe("tsparticles-shape-foo");
19
16
 
@@ -25,11 +22,8 @@ describe("create-shape", () => {
25
22
 
26
23
  await createShapeTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
27
24
 
28
- const pkgPath = path.join(destDir, "package.json");
29
-
30
- console.log(pkgPath);
31
-
32
- const pkgInfo = await fs.readJSON(pkgPath);
25
+ const pkgPath = path.join(destDir, "package.json"),
26
+ pkgInfo = await fs.readJSON(pkgPath);
33
27
 
34
28
  expect(pkgInfo.name).toBe("tsparticles-shape-bar");
35
29