@tsparticles/cli 3.3.1 → 3.3.3
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.
- package/.github/dependabot.yml +7 -0
- package/.planning/codebase/ARCHITECTURE.md +83 -51
- package/.planning/codebase/CONCERNS.md +61 -58
- package/.planning/codebase/CONVENTIONS.md +47 -52
- package/.planning/codebase/INTEGRATIONS.md +26 -17
- package/.planning/codebase/STACK.md +37 -31
- package/.planning/codebase/STRUCTURE.md +87 -53
- package/.planning/codebase/TESTING.md +80 -62
- package/dist/build/build-distfiles.js +14 -13
- package/dist/build/build-diststats.js +8 -7
- package/dist/build/build-prettier.js +16 -15
- package/dist/build/build-tsc.js +4 -3
- package/dist/build/build.js +10 -8
- package/dist/cli.js +3 -3
- package/dist/create/plugin/create-plugin.js +4 -3
- package/dist/create/preset/create-preset.js +4 -3
- package/dist/create/shape/create-shape.js +4 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/file-utils.js +8 -7
- package/dist/utils/template-utils.js +4 -3
- package/files/empty-project/package.json +7 -7
- package/files/empty-project/webpack.config.js +11 -11
- package/package.json +9 -11
- package/src/build/build-distfiles.ts +15 -14
- package/src/build/build-diststats.ts +8 -8
- package/src/build/build-prettier.ts +16 -15
- package/src/build/build-tsc.ts +4 -3
- package/src/build/build.ts +10 -10
- package/src/cli.ts +3 -3
- package/src/create/plugin/create-plugin.ts +4 -3
- package/src/create/preset/create-preset.ts +4 -3
- package/src/create/shape/create-shape.ts +4 -3
- package/src/utils/file-utils.ts +8 -7
- package/src/utils/template-utils.ts +4 -3
- package/tests/create-plugin.test.ts +25 -25
- package/tests/create-preset.test.ts +25 -25
- package/tests/create-shape.test.ts +25 -25
- package/tests/file-utils.test.ts +87 -78
- package/tests/tsconfig.json +12 -11
- 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
|
-
|
|
8
|
-
|
|
7
|
+
it("should have created the preset project", async () => {
|
|
8
|
+
const destDir = path.join(__dirname, "tmp-files", "foo-preset");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
try {
|
|
11
|
+
await createPresetTemplate("foo", "Foo", "", destDir);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error(e);
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const pkgPath = path.join(destDir, "package.json"),
|
|
17
|
+
pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
expect(pkgInfo.name).toBe("tsparticles-preset-foo");
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
await rm(destDir, { recursive: true, force: true });
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
it("should have created the preset project, w/ repo", async () => {
|
|
25
|
+
const destDir = path.join(__dirname, "tmp-files", "bar-preset");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
33
|
+
const pkgPath = path.join(destDir, "package.json"),
|
|
34
|
+
pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
expect(pkgInfo.name).toBe("tsparticles-preset-bar");
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
await rm(destDir, { recursive: true, force: 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
|
-
|
|
8
|
-
|
|
7
|
+
it("should have created the shape project", async () => {
|
|
8
|
+
const destDir = path.join(__dirname, "tmp-files", "foo-shape");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
try {
|
|
11
|
+
await createShapeTemplate("foo", "Foo", "", destDir);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error(e);
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const pkgPath = path.join(destDir, "package.json"),
|
|
17
|
+
pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
expect(pkgInfo.name).toBe("tsparticles-shape-foo");
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
await rm(destDir, { recursive: true, force: true });
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
it("should have created the shape project, w/ repo", async () => {
|
|
25
|
+
const destDir = path.join(__dirname, "tmp-files", "bar-shape");
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
33
|
+
const pkgPath = path.join(destDir, "package.json"),
|
|
34
|
+
pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
expect(pkgInfo.name).toBe("tsparticles-shape-bar");
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
await rm(destDir, { recursive: true, force: true });
|
|
39
|
+
});
|
|
40
40
|
});
|
package/tests/file-utils.test.ts
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
58
|
-
});
|
|
66
|
+
expect(data).toBe("test1");
|
|
59
67
|
});
|
|
68
|
+
});
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
describe("get destination dir", async () => {
|
|
71
|
+
const destDir = await getDestinationDir(path.join("tmp-files", "baz"));
|
|
63
72
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
it("should return the destination dir", () => {
|
|
74
|
+
expect(destDir).toBe(path.join(baseDir, "baz"));
|
|
75
|
+
});
|
|
67
76
|
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
it("should return the destination dir", async () => {
|
|
78
|
+
const destDir2 = await getDestinationDir(path.join("tmp-files", "baz"));
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
expect(destDir2).toBe(path.join(baseDir, "baz"));
|
|
81
|
+
});
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
it("should throw exception", async () => {
|
|
84
|
+
await writeFile(path.join(baseDir, "baz", "tmp.txt"), "");
|
|
76
85
|
|
|
77
|
-
|
|
86
|
+
let ex = false;
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
try {
|
|
89
|
+
await getDestinationDir(path.join("tmp-files", "baz"));
|
|
81
90
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
console.log("never");
|
|
92
|
+
} catch {
|
|
93
|
+
ex = true;
|
|
94
|
+
}
|
|
86
95
|
|
|
87
|
-
|
|
88
|
-
});
|
|
96
|
+
expect(ex).toBe(true);
|
|
89
97
|
});
|
|
98
|
+
});
|
|
90
99
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
afterAll(async () => {
|
|
107
|
+
await rm(baseDir, { recursive: true, force: true });
|
|
108
|
+
});
|
|
100
109
|
});
|
package/tests/tsconfig.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
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
|
}
|