@tsparticles/cli 3.3.1 → 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 (40) hide show
  1. package/.github/dependabot.yml +7 -0
  2. package/.planning/codebase/ARCHITECTURE.md +83 -51
  3. package/.planning/codebase/CONCERNS.md +61 -58
  4. package/.planning/codebase/CONVENTIONS.md +47 -52
  5. package/.planning/codebase/INTEGRATIONS.md +26 -17
  6. package/.planning/codebase/STACK.md +37 -31
  7. package/.planning/codebase/STRUCTURE.md +87 -53
  8. package/.planning/codebase/TESTING.md +80 -62
  9. package/dist/build/build-distfiles.js +14 -13
  10. package/dist/build/build-diststats.js +8 -7
  11. package/dist/build/build-prettier.js +16 -15
  12. package/dist/build/build-tsc.js +4 -3
  13. package/dist/build/build.js +10 -8
  14. package/dist/cli.js +3 -3
  15. package/dist/create/plugin/create-plugin.js +4 -3
  16. package/dist/create/preset/create-preset.js +4 -3
  17. package/dist/create/shape/create-shape.js +4 -3
  18. package/dist/tsconfig.tsbuildinfo +1 -1
  19. package/dist/utils/file-utils.js +7 -6
  20. package/dist/utils/template-utils.js +4 -3
  21. package/files/empty-project/package.json +7 -7
  22. package/files/empty-project/webpack.config.js +11 -11
  23. package/package.json +9 -11
  24. package/src/build/build-distfiles.ts +15 -14
  25. package/src/build/build-diststats.ts +8 -8
  26. package/src/build/build-prettier.ts +16 -15
  27. package/src/build/build-tsc.ts +4 -3
  28. package/src/build/build.ts +10 -10
  29. package/src/cli.ts +3 -3
  30. package/src/create/plugin/create-plugin.ts +4 -3
  31. package/src/create/preset/create-preset.ts +4 -3
  32. package/src/create/shape/create-shape.ts +4 -3
  33. package/src/utils/file-utils.ts +7 -6
  34. package/src/utils/template-utils.ts +4 -3
  35. package/tests/create-plugin.test.ts +25 -25
  36. package/tests/create-preset.test.ts +25 -25
  37. package/tests/create-shape.test.ts +25 -25
  38. package/tests/file-utils.test.ts +87 -78
  39. package/tests/tsconfig.json +12 -11
  40. package/tsconfig.json +52 -53
@@ -1,40 +1,40 @@
1
1
  import { describe, it, expect } from "vitest";
2
+ import { readFile, rm } from "node:fs/promises";
2
3
  import { createPresetTemplate } from "../src/create/preset/create-preset.js";
3
4
  import path from "node:path";
4
- import fs from "fs-extra";
5
5
 
6
6
  describe("create-preset", () => {
7
- it("should have created the preset project", async () => {
8
- const destDir = path.join(__dirname, "tmp-files", "foo-preset");
7
+ it("should have created the preset project", async () => {
8
+ const destDir = path.join(__dirname, "tmp-files", "foo-preset");
9
9
 
10
- try {
11
- await createPresetTemplate("foo", "Foo", "", destDir);
12
- } catch (e) {
13
- console.error(e);
14
- }
10
+ try {
11
+ await createPresetTemplate("foo", "Foo", "", destDir);
12
+ } catch (e) {
13
+ console.error(e);
14
+ }
15
15
 
16
- const pkgPath = path.join(destDir, "package.json"),
17
- pkgInfo = await fs.readJSON(pkgPath);
16
+ const pkgPath = path.join(destDir, "package.json"),
17
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
18
18
 
19
- expect(pkgInfo.name).toBe("tsparticles-preset-foo");
19
+ expect(pkgInfo.name).toBe("tsparticles-preset-foo");
20
20
 
21
- await fs.remove(destDir);
22
- });
21
+ await rm(destDir, { recursive: true });
22
+ });
23
23
 
24
- it("should have created the preset project, w/ repo", async () => {
25
- const destDir = path.join(__dirname, "tmp-files", "bar-preset");
24
+ it("should have created the preset project, w/ repo", async () => {
25
+ const destDir = path.join(__dirname, "tmp-files", "bar-preset");
26
26
 
27
- try {
28
- await createPresetTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
- } catch (e) {
30
- console.error(e);
31
- }
27
+ try {
28
+ await createPresetTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
32
 
33
- const pkgPath = path.join(destDir, "package.json"),
34
- pkgInfo = await fs.readJSON(pkgPath);
33
+ const pkgPath = path.join(destDir, "package.json"),
34
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
35
35
 
36
- expect(pkgInfo.name).toBe("tsparticles-preset-bar");
36
+ expect(pkgInfo.name).toBe("tsparticles-preset-bar");
37
37
 
38
- await fs.remove(destDir);
39
- });
38
+ await rm(destDir, { recursive: true });
39
+ });
40
40
  });
@@ -1,40 +1,40 @@
1
1
  import { describe, it, expect } from "vitest";
2
+ import { readFile, rm } from "node:fs/promises";
2
3
  import { createShapeTemplate } from "../src/create/shape/create-shape.js";
3
4
  import path from "node:path";
4
- import fs from "fs-extra";
5
5
 
6
6
  describe("create-shape", () => {
7
- it("should have created the shape project", async () => {
8
- const destDir = path.join(__dirname, "tmp-files", "foo-shape");
7
+ it("should have created the shape project", async () => {
8
+ const destDir = path.join(__dirname, "tmp-files", "foo-shape");
9
9
 
10
- try {
11
- await createShapeTemplate("foo", "Foo", "", destDir);
12
- } catch (e) {
13
- console.error(e);
14
- }
10
+ try {
11
+ await createShapeTemplate("foo", "Foo", "", destDir);
12
+ } catch (e) {
13
+ console.error(e);
14
+ }
15
15
 
16
- const pkgPath = path.join(destDir, "package.json"),
17
- pkgInfo = await fs.readJSON(pkgPath);
16
+ const pkgPath = path.join(destDir, "package.json"),
17
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
18
18
 
19
- expect(pkgInfo.name).toBe("tsparticles-shape-foo");
19
+ expect(pkgInfo.name).toBe("tsparticles-shape-foo");
20
20
 
21
- await fs.remove(destDir);
22
- });
21
+ await rm(destDir, { recursive: true });
22
+ });
23
23
 
24
- it("should have created the shape project, w/ repo", async () => {
25
- const destDir = path.join(__dirname, "tmp-files", "bar-shape");
24
+ it("should have created the shape project, w/ repo", async () => {
25
+ const destDir = path.join(__dirname, "tmp-files", "bar-shape");
26
26
 
27
- try {
28
- await createShapeTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
- } catch (e) {
30
- console.error(e);
31
- }
27
+ try {
28
+ await createShapeTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
32
 
33
- const pkgPath = path.join(destDir, "package.json"),
34
- pkgInfo = await fs.readJSON(pkgPath);
33
+ const pkgPath = path.join(destDir, "package.json"),
34
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
35
35
 
36
- expect(pkgInfo.name).toBe("tsparticles-shape-bar");
36
+ expect(pkgInfo.name).toBe("tsparticles-shape-bar");
37
37
 
38
- await fs.remove(destDir);
39
- });
38
+ await rm(destDir, { recursive: true });
39
+ });
40
40
  });
@@ -1,100 +1,109 @@
1
- import {afterAll, describe, it, expect} from "vitest";
2
- import fs from "fs-extra";
3
- import path from "node:path";
1
+ import { afterAll, describe, it, expect } from "vitest";
4
2
  import {
5
- getDestinationDir,
6
- getRepositoryUrl,
7
- replaceTokensInFile,
8
- replaceTokensInFiles,
3
+ getDestinationDir,
4
+ getRepositoryUrl,
5
+ replaceTokensInFile,
6
+ replaceTokensInFiles,
9
7
  } from "../src/utils/file-utils.js";
8
+ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
9
+ import path from "node:path";
10
10
 
11
11
  describe("file-utils", async () => {
12
- const baseDir = path.resolve("tmp-files");
13
-
14
- await fs.ensureDir(baseDir);
15
-
16
- describe("replace tokens in files", async () => {
17
- fs.writeFileSync(path.join(baseDir, "files1.txt"), "test");
18
- fs.writeFileSync(path.join(baseDir, "files2.txt"), "test");
19
-
20
- await replaceTokensInFiles([{
21
- path: path.join(baseDir, "files1.txt"),
22
- tokens: [{
23
- from: "test",
24
- to: "test1",
25
- }],
26
- }, {
27
- path: path.join(baseDir, "files2.txt"),
28
- tokens: [{
29
- from: "test",
30
- to: "test2",
31
- }],
32
- }]);
33
-
34
- it("should replace tokens in files", async () => {
35
- const data1 = await fs.readFile(path.join(baseDir, "files1.txt"), "utf8"),
36
- data2 = await fs.readFile(path.join(baseDir, "files2.txt"), "utf8");
37
-
38
- expect(data1).toBe("test1");
39
- expect(data2).toBe("test2");
40
- });
12
+ const baseDir = path.resolve("tmp-files");
13
+
14
+ await mkdir(baseDir);
15
+
16
+ describe("replace tokens in files", async () => {
17
+ await writeFile(path.join(baseDir, "files1.txt"), "test");
18
+ await writeFile(path.join(baseDir, "files2.txt"), "test");
19
+
20
+ await replaceTokensInFiles([
21
+ {
22
+ path: path.join(baseDir, "files1.txt"),
23
+ tokens: [
24
+ {
25
+ from: "test",
26
+ to: "test1",
27
+ },
28
+ ],
29
+ },
30
+ {
31
+ path: path.join(baseDir, "files2.txt"),
32
+ tokens: [
33
+ {
34
+ from: "test",
35
+ to: "test2",
36
+ },
37
+ ],
38
+ },
39
+ ]);
40
+
41
+ it("should replace tokens in files", async () => {
42
+ const data1 = await readFile(path.join(baseDir, "files1.txt"), "utf8"),
43
+ data2 = await readFile(path.join(baseDir, "files2.txt"), "utf8");
44
+
45
+ expect(data1).toBe("test1");
46
+ expect(data2).toBe("test2");
47
+ });
48
+ });
49
+
50
+ describe("replace tokens in file", async () => {
51
+ await writeFile(path.join(baseDir, "file1.txt"), "test");
52
+
53
+ await replaceTokensInFile({
54
+ path: path.join(baseDir, "file1.txt"),
55
+ tokens: [
56
+ {
57
+ from: "test",
58
+ to: "test1",
59
+ },
60
+ ],
41
61
  });
42
62
 
43
- describe("replace tokens in file", async () => {
44
- fs.writeFileSync(path.join(baseDir, "file1.txt"), "test");
45
-
46
- await replaceTokensInFile({
47
- path: path.join(baseDir, "file1.txt"),
48
- tokens: [{
49
- from: "test",
50
- to: "test1",
51
- }],
52
- });
53
-
54
- it("should replace tokens in files", async () => {
55
- const data = await fs.readFile(path.join(baseDir, "file1.txt"), "utf8");
63
+ it("should replace tokens in files", async () => {
64
+ const data = await readFile(path.join(baseDir, "file1.txt"), "utf8");
56
65
 
57
- expect(data).toBe("test1");
58
- });
66
+ expect(data).toBe("test1");
59
67
  });
68
+ });
60
69
 
61
- describe("get destination dir", async () => {
62
- const destDir = await getDestinationDir(path.join("tmp-files", "baz"));
70
+ describe("get destination dir", async () => {
71
+ const destDir = await getDestinationDir(path.join("tmp-files", "baz"));
63
72
 
64
- it("should return the destination dir", () => {
65
- expect(destDir).toBe(path.join(baseDir, "baz"));
66
- });
73
+ it("should return the destination dir", () => {
74
+ expect(destDir).toBe(path.join(baseDir, "baz"));
75
+ });
67
76
 
68
- it("should return the destination dir", async () => {
69
- const destDir2 = await getDestinationDir(path.join("tmp-files", "baz"));
77
+ it("should return the destination dir", async () => {
78
+ const destDir2 = await getDestinationDir(path.join("tmp-files", "baz"));
70
79
 
71
- expect(destDir2).toBe(path.join(baseDir, "baz"));
72
- });
80
+ expect(destDir2).toBe(path.join(baseDir, "baz"));
81
+ });
73
82
 
74
- it("should throw exception", async () => {
75
- await fs.writeFile(path.join(baseDir, "baz", "tmp.txt"), "");
83
+ it("should throw exception", async () => {
84
+ await writeFile(path.join(baseDir, "baz", "tmp.txt"), "");
76
85
 
77
- let ex = false;
86
+ let ex = false;
78
87
 
79
- try {
80
- await getDestinationDir(path.join("tmp-files", "baz"));
88
+ try {
89
+ await getDestinationDir(path.join("tmp-files", "baz"));
81
90
 
82
- console.log("never");
83
- } catch {
84
- ex = true;
85
- }
91
+ console.log("never");
92
+ } catch {
93
+ ex = true;
94
+ }
86
95
 
87
- expect(ex).toBe(true);
88
- });
96
+ expect(ex).toBe(true);
89
97
  });
98
+ });
90
99
 
91
- describe("get repository url", () => {
92
- it("should return the repository url", async () => {
93
- expect(await getRepositoryUrl()).not.toBe("");
94
- });
100
+ describe("get repository url", () => {
101
+ it("should return the repository url", async () => {
102
+ expect(await getRepositoryUrl()).not.toBe("");
95
103
  });
104
+ });
96
105
 
97
- afterAll(async () => {
98
- await fs.remove(baseDir);
99
- });
106
+ afterAll(async () => {
107
+ await rm(baseDir, { recursive: true });
108
+ });
100
109
  });
@@ -1,13 +1,14 @@
1
1
  {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": ".",
5
- "target": "ES2021",
6
- "allowJs": true,
7
- "declaration": false,
8
- "removeComments": true,
9
- "importHelpers": false
10
- },
11
- "references": [{ "path": "../src" }],
12
- "include": ["**/*.ts"]
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "target": "ES2021",
6
+ "allowJs": true,
7
+ "declaration": false,
8
+ "removeComments": true,
9
+ "importHelpers": false,
10
+ "esModuleInterop": true
11
+ },
12
+ "references": [{ "path": "../src" }],
13
+ "include": ["**/*.ts"]
13
14
  }
package/tsconfig.json CHANGED
@@ -1,55 +1,54 @@
1
1
  {
2
- "compilerOptions": {
3
- "rootDir": ".",
4
- "outDir": ".",
5
- "resolveJsonModule": true,
6
- "composite": true,
7
- "target": "ESNext",
8
- "module": "NodeNext",
9
- "moduleResolution": "NodeNext",
10
- "lib": [
11
- "ESNext",
12
- "ES2024",
13
- "ES2023",
14
- "ES2022",
15
- "ES2021",
16
- "ES2020",
17
- "ES2019",
18
- "ES2018",
19
- "ES2017",
20
- "ES2016",
21
- "ES2015"
22
- ],
23
- "types": [
24
- "node",
25
- "fs-extra",
26
- "klaw",
27
- "prompts",
28
- "eslint",
29
- "vitest"
30
- ],
31
- "strict": true,
32
- "noImplicitAny": true,
33
- "strictNullChecks": true,
34
- "strictFunctionTypes": true,
35
- "strictBindCallApply": true,
36
- "strictPropertyInitialization": true,
37
- "noImplicitThis": true,
38
- "useUnknownInCatchVariables": true,
39
- "alwaysStrict": true,
40
- "noUnusedLocals": true,
41
- "noUnusedParameters": true,
42
- "exactOptionalPropertyTypes": true,
43
- "noImplicitReturns": true,
44
- "noFallthroughCasesInSwitch": true,
45
- "noUncheckedIndexedAccess": true,
46
- "noImplicitOverride": true,
47
- "noPropertyAccessFromIndexSignature": true,
48
- "esModuleInterop": true,
49
- "forceConsistentCasingInFileNames": true,
50
- "allowSyntheticDefaultImports": true
51
- },
52
- "include": [
53
- "src/**/*"
54
- ]
2
+ "compilerOptions": {
3
+ "rootDir": ".",
4
+ "outDir": ".",
5
+ "resolveJsonModule": true,
6
+ "composite": true,
7
+ "target": "ESNext",
8
+ "module": "NodeNext",
9
+ "moduleResolution": "NodeNext",
10
+ "lib": [
11
+ "ESNext",
12
+ "ES2024",
13
+ "ES2023",
14
+ "ES2022",
15
+ "ES2021",
16
+ "ES2020",
17
+ "ES2019",
18
+ "ES2018",
19
+ "ES2017",
20
+ "ES2016",
21
+ "ES2015"
22
+ ],
23
+ "types": [
24
+ "node",
25
+ "klaw",
26
+ "prompts",
27
+ "eslint",
28
+ "vitest"
29
+ ],
30
+ "strict": true,
31
+ "noImplicitAny": true,
32
+ "strictNullChecks": true,
33
+ "strictFunctionTypes": true,
34
+ "strictBindCallApply": true,
35
+ "strictPropertyInitialization": true,
36
+ "noImplicitThis": true,
37
+ "useUnknownInCatchVariables": true,
38
+ "alwaysStrict": true,
39
+ "noUnusedLocals": true,
40
+ "noUnusedParameters": true,
41
+ "exactOptionalPropertyTypes": true,
42
+ "noImplicitReturns": true,
43
+ "noFallthroughCasesInSwitch": true,
44
+ "noUncheckedIndexedAccess": true,
45
+ "noImplicitOverride": true,
46
+ "noPropertyAccessFromIndexSignature": true,
47
+ "esModuleInterop": true,
48
+ "forceConsistentCasingInFileNames": true,
49
+ "allowSyntheticDefaultImports": true
50
+ },
51
+ "include": [
52
+ "src/**/*"
53
+ ]
55
54
  }