@tsparticles/cli 3.0.9 → 3.0.10
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/dist/build/build-distfiles.js +1 -1
- package/dist/build/build-diststats.js +1 -1
- package/dist/build/build-eslint.js +3 -3
- package/dist/cli.js +1 -1
- package/dist/create/shape/create-shape.js +5 -0
- package/files/create-shape/src/ShapeDrawer.ts +2 -0
- package/files/create-shape/src/index.ts +1 -1
- package/files/empty-project/package.json +1 -1
- package/package.json +2 -2
- package/src/build/build-distfiles.ts +1 -1
- package/src/build/build-diststats.ts +3 -1
- package/src/build/build-eslint.ts +3 -3
- package/src/cli.ts +1 -1
- package/src/create/plugin/create-plugin.ts +0 -1
- package/src/create/shape/create-shape.ts +6 -0
- package/tests/create-plugin.test.ts +2 -7
- package/tests/create-preset.test.ts +4 -10
- package/tests/create-shape.test.ts +4 -10
|
@@ -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
|
|
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
|
|
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({
|
|
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(
|
|
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.
|
|
87
|
+
"@tsparticles/cli": "^3.0.10",
|
|
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.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -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
|
|
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
|
|
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
|
|
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({
|
|
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);
|
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
|
|