@tsparticles/cli-command-create 4.0.0-beta.12

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 (54) hide show
  1. package/.cache/eslint/.eslintcache +1 -0
  2. package/.dependency-cruiser.cjs +382 -0
  3. package/LICENSE +21 -0
  4. package/README.md +51 -0
  5. package/dist/create.d.ts +3 -0
  6. package/dist/create.js +10 -0
  7. package/dist/plugin/create-plugin.d.ts +8 -0
  8. package/dist/plugin/create-plugin.js +136 -0
  9. package/dist/plugin/plugin.d.ts +3 -0
  10. package/dist/plugin/plugin.js +34 -0
  11. package/dist/preset/create-preset.d.ts +8 -0
  12. package/dist/preset/create-preset.js +154 -0
  13. package/dist/preset/preset.d.ts +3 -0
  14. package/dist/preset/preset.js +34 -0
  15. package/dist/shape/create-shape.d.ts +8 -0
  16. package/dist/shape/create-shape.js +137 -0
  17. package/dist/shape/shape.d.ts +3 -0
  18. package/dist/shape/shape.js +34 -0
  19. package/dist/tsconfig.tsbuildinfo +1 -0
  20. package/eslint.config.js +22 -0
  21. package/files/create-plugin/README.md +74 -0
  22. package/files/create-plugin/src/PluginInstance.ts +18 -0
  23. package/files/create-plugin/src/browser.ts +10 -0
  24. package/files/create-plugin/src/index.lazy.ts +10 -0
  25. package/files/create-plugin/src/index.ts +9 -0
  26. package/files/create-plugin/src/plugin.ts +36 -0
  27. package/files/create-preset/README.md +144 -0
  28. package/files/create-preset/images/sample.png +0 -0
  29. package/files/create-preset/src/browser.ts +10 -0
  30. package/files/create-preset/src/bundle.ts +17 -0
  31. package/files/create-preset/src/index.lazy.ts +14 -0
  32. package/files/create-preset/src/index.ts +13 -0
  33. package/files/create-preset/src/options.ts +6 -0
  34. package/files/create-shape/README.md +75 -0
  35. package/files/create-shape/src/ShapeDrawer.ts +16 -0
  36. package/files/create-shape/src/browser.ts +10 -0
  37. package/files/create-shape/src/index.lazy.ts +10 -0
  38. package/files/create-shape/src/index.ts +9 -0
  39. package/package.json +81 -0
  40. package/renovate.json +9 -0
  41. package/src/create.ts +14 -0
  42. package/src/plugin/create-plugin.ts +198 -0
  43. package/src/plugin/plugin.ts +46 -0
  44. package/src/preset/create-preset.ts +218 -0
  45. package/src/preset/preset.ts +46 -0
  46. package/src/shape/create-shape.ts +200 -0
  47. package/src/shape/shape.ts +46 -0
  48. package/src/tsconfig.json +9 -0
  49. package/tests/create-plugin.test.ts +40 -0
  50. package/tests/create-preset.test.ts +40 -0
  51. package/tests/create-shape.test.ts +40 -0
  52. package/tests/tsconfig.json +15 -0
  53. package/tsconfig.json +53 -0
  54. package/vitest.config.ts +11 -0
@@ -0,0 +1,46 @@
1
+ import { capitalize, getDestinationDir, getRepositoryUrl } from "@tsparticles/cli-create-utils";
2
+ import prompts, { type PromptObject } from "prompts";
3
+ import { Command } from "commander";
4
+ import { createShapeTemplate } from "./create-shape.js";
5
+ import path from "node:path";
6
+
7
+ const shapeCommand = new Command("shape");
8
+
9
+ shapeCommand.description("Create a new tsParticles shape");
10
+ shapeCommand.argument("<destination>", "Destination folder");
11
+ shapeCommand.action(async (destination: string) => {
12
+ const destPath = await getDestinationDir(destination),
13
+ repoUrl = await getRepositoryUrl(),
14
+ initialName = destPath.split(path.sep).pop(),
15
+ questions: PromptObject[] = [
16
+ {
17
+ type: "text",
18
+ name: "name",
19
+ message: "What is the name of the shape?",
20
+ validate: (value: string) => (value ? true : "The name can't be empty"),
21
+ initial: initialName,
22
+ },
23
+ {
24
+ type: "text",
25
+ name: "description",
26
+ message: "What is the description of the shape?",
27
+ validate: (value: string) => (value ? true : "The description can't be empty"),
28
+ initial: capitalize(initialName ?? ""),
29
+ },
30
+ {
31
+ type: "text",
32
+ name: "repositoryUrl",
33
+ message: "What is the repository URL? (optional)",
34
+ initial: repoUrl.trim(),
35
+ },
36
+ ],
37
+ { name, description, repositoryUrl } = (await prompts(questions)) as {
38
+ description: string;
39
+ name: string;
40
+ repositoryUrl: string;
41
+ };
42
+
43
+ await createShapeTemplate(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
44
+ });
45
+
46
+ export { shapeCommand };
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "../dist"
6
+ },
7
+ "references": [{ "path": "../" }],
8
+ "include": ["**/*"]
9
+ }
@@ -0,0 +1,40 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { createPluginTemplate } from "../src/plugin/create-plugin.js";
3
+ import { readFile, rm } from "node:fs/promises";
4
+ import path from "node:path";
5
+
6
+ describe("create-plugin", () => {
7
+ it("should have created the plugin project", async () => {
8
+ const destDir = path.join(__dirname, "tmp-files", "foo-plugin"),
9
+ pkgPath = path.join(destDir, "package.json");
10
+
11
+ try {
12
+ await createPluginTemplate("foo", "Foo", "", destDir);
13
+ } catch (e) {
14
+ console.error(e);
15
+ }
16
+
17
+ const pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
18
+
19
+ expect(pkgInfo.name).toBe("tsparticles-plugin-foo");
20
+
21
+ await rm(destDir, { recursive: true, force: true });
22
+ });
23
+
24
+ it("should have created the plugin project, w/ repo", async () => {
25
+ const destDir = path.join(__dirname, "tmp-files", "bar-plugin");
26
+
27
+ try {
28
+ await createPluginTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
+
33
+ const pkgPath = path.join(destDir, "package.json"),
34
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
35
+
36
+ expect(pkgInfo.name).toBe("tsparticles-plugin-bar");
37
+
38
+ await rm(destDir, { recursive: true, force: true });
39
+ });
40
+ });
@@ -0,0 +1,40 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { readFile, rm } from "node:fs/promises";
3
+ import { createPresetTemplate } from "../src/preset/create-preset.js";
4
+ import path from "node:path";
5
+
6
+ describe("create-preset", () => {
7
+ it("should have created the preset project", async () => {
8
+ const destDir = path.join(__dirname, "tmp-files", "foo-preset");
9
+
10
+ try {
11
+ await createPresetTemplate("foo", "Foo", "", destDir);
12
+ } catch (e) {
13
+ console.error(e);
14
+ }
15
+
16
+ const pkgPath = path.join(destDir, "package.json"),
17
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
18
+
19
+ expect(pkgInfo.name).toBe("tsparticles-preset-foo");
20
+
21
+ await rm(destDir, { recursive: true, force: true });
22
+ });
23
+
24
+ it("should have created the preset project, w/ repo", async () => {
25
+ const destDir = path.join(__dirname, "tmp-files", "bar-preset");
26
+
27
+ try {
28
+ await createPresetTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
+
33
+ const pkgPath = path.join(destDir, "package.json"),
34
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
35
+
36
+ expect(pkgInfo.name).toBe("tsparticles-preset-bar");
37
+
38
+ await rm(destDir, { recursive: true, force: true });
39
+ });
40
+ });
@@ -0,0 +1,40 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { readFile, rm } from "node:fs/promises";
3
+ import { createShapeTemplate } from "../src/shape/create-shape.js";
4
+ import path from "node:path";
5
+
6
+ describe("create-shape", () => {
7
+ it("should have created the shape project", async () => {
8
+ const destDir = path.join(__dirname, "tmp-files", "foo-shape");
9
+
10
+ try {
11
+ await createShapeTemplate("foo", "Foo", "", destDir);
12
+ } catch (e) {
13
+ console.error(e);
14
+ }
15
+
16
+ const pkgPath = path.join(destDir, "package.json"),
17
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
18
+
19
+ expect(pkgInfo.name).toBe("tsparticles-shape-foo");
20
+
21
+ await rm(destDir, { recursive: true, force: true });
22
+ });
23
+
24
+ it("should have created the shape project, w/ repo", async () => {
25
+ const destDir = path.join(__dirname, "tmp-files", "bar-shape");
26
+
27
+ try {
28
+ await createShapeTemplate("bar", "Bar", "https://github.com/matteobruni/tsparticles", destDir);
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
+
33
+ const pkgPath = path.join(destDir, "package.json"),
34
+ pkgInfo = JSON.parse(await readFile(pkgPath, "utf-8"));
35
+
36
+ expect(pkgInfo.name).toBe("tsparticles-shape-bar");
37
+
38
+ await rm(destDir, { recursive: true, force: true });
39
+ });
40
+ });
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "target": "ES2021",
6
+ "types": ["node", "vitest"],
7
+ "allowJs": true,
8
+ "declaration": false,
9
+ "removeComments": true,
10
+ "importHelpers": false,
11
+ "esModuleInterop": true
12
+ },
13
+ "references": [{ "path": "../src" }],
14
+ "include": ["**/*.ts"]
15
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,53 @@
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
+ "klaw",
26
+ "prompts",
27
+ "eslint"
28
+ ],
29
+ "strict": true,
30
+ "noImplicitAny": true,
31
+ "strictNullChecks": true,
32
+ "strictFunctionTypes": true,
33
+ "strictBindCallApply": true,
34
+ "strictPropertyInitialization": true,
35
+ "noImplicitThis": true,
36
+ "useUnknownInCatchVariables": true,
37
+ "alwaysStrict": true,
38
+ "noUnusedLocals": true,
39
+ "noUnusedParameters": true,
40
+ "exactOptionalPropertyTypes": true,
41
+ "noImplicitReturns": true,
42
+ "noFallthroughCasesInSwitch": true,
43
+ "noUncheckedIndexedAccess": true,
44
+ "noImplicitOverride": true,
45
+ "noPropertyAccessFromIndexSignature": true,
46
+ "esModuleInterop": true,
47
+ "forceConsistentCasingInFileNames": true,
48
+ "allowSyntheticDefaultImports": true
49
+ },
50
+ "include": [
51
+ "src/**/*"
52
+ ]
53
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: "node",
7
+ include: ["tests/**/*.test.ts"],
8
+ testTimeout: 5 * 60 * 1000
9
+ }
10
+ });
11
+