@tsparticles/cli 3.0.0 → 3.0.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.
- package/.github/workflows/node.js-ci.yml +8 -8
- package/dist/build/build-bundle.js +5 -44
- package/dist/build/build-circular-deps.js +4 -10
- package/dist/build/build-clear.js +4 -10
- package/dist/build/build-distfiles.js +21 -60
- package/dist/build/build-diststats.js +8 -47
- package/dist/build/build-eslint.js +7 -8
- package/dist/build/build-prettier.js +38 -47
- package/dist/build/build-tsc.js +7 -46
- package/dist/build/build.js +13 -49
- package/dist/cli.js +10 -15
- package/dist/create/create.js +9 -12
- package/dist/create/plugin/create-plugin.js +22 -28
- package/dist/create/plugin/plugin.js +12 -18
- package/dist/create/preset/create-preset.js +26 -32
- package/dist/create/preset/preset.js +12 -18
- package/dist/create/shape/create-shape.js +23 -29
- package/dist/create/shape/shape.js +12 -18
- package/dist/utils/file-utils.js +16 -25
- package/dist/utils/string-utils.js +3 -8
- package/dist/utils/template-utils.js +23 -35
- package/eslint.config.js +0 -1
- package/files/empty-project/eslint.config.js +6 -0
- package/files/empty-project/package.dist.json +1 -0
- package/files/empty-project/package.json +2 -1
- package/files/empty-project/webpack.config.js +10 -3
- package/package.json +7 -11
- package/pnpm-workspace.yaml +1 -0
- package/src/build/build-eslint.ts +3 -1
- package/src/tsconfig.json +1 -1
- package/tests/create-plugin.test.ts +4 -5
- package/tests/create-preset.test.ts +4 -5
- package/tests/create-shape.test.ts +4 -5
- package/tests/file-utils.test.ts +8 -9
- package/tests/string-utils.test.ts +24 -25
- package/tests/tsconfig.json +2 -1
- package/vitest.config.ts +11 -0
- package/files/empty-project/.eslintignore +0 -2
- package/files/empty-project/.eslintrc.js +0 -5
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.createShapeTemplate = createShapeTemplate;
|
|
7
|
-
const string_utils_1 = require("../../utils/string-utils");
|
|
8
|
-
const template_utils_1 = require("../../utils/template-utils");
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const file_utils_1 = require("../../utils/file-utils");
|
|
1
|
+
import { camelize, capitalize, dash } from "../../utils/string-utils";
|
|
2
|
+
import { copyEmptyTemplateFiles, copyFilter, runBuild, runInstall, updatePackageDistFile, updatePackageFile, updateWebpackFile, } from "../../utils/template-utils";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { replaceTokensInFile } from "../../utils/file-utils";
|
|
12
6
|
/**
|
|
13
7
|
* Updates the index file with the correct function name
|
|
14
8
|
* @param destPath - The path where the project is located
|
|
15
9
|
* @param name - The name of the project
|
|
16
10
|
*/
|
|
17
11
|
async function updateIndexFile(destPath, name) {
|
|
18
|
-
const capitalizedName =
|
|
19
|
-
await
|
|
20
|
-
path:
|
|
12
|
+
const capitalizedName = capitalize(name, "-", " "), camelizedName = camelize(capitalizedName);
|
|
13
|
+
await replaceTokensInFile({
|
|
14
|
+
path: path.resolve(destPath, "src", "index.ts"),
|
|
21
15
|
tokens: [
|
|
22
16
|
{
|
|
23
17
|
from: /loadTemplateShape/g,
|
|
@@ -38,8 +32,8 @@ async function updateIndexFile(destPath, name) {
|
|
|
38
32
|
* @param repoUrl - The repository url
|
|
39
33
|
*/
|
|
40
34
|
async function updateShapePackageFile(destPath, name, description, repoUrl) {
|
|
41
|
-
const camelizedName =
|
|
42
|
-
await
|
|
35
|
+
const camelizedName = camelize(camelize(name, "-"), " "), dashedName = dash(camelizedName);
|
|
36
|
+
await updatePackageFile(destPath, `tsparticles-shape-${dashedName}`, description, `tsparticles.shape.${camelizedName}.min.js`, repoUrl);
|
|
43
37
|
}
|
|
44
38
|
/**
|
|
45
39
|
* Updates the shape package dist file
|
|
@@ -49,8 +43,8 @@ async function updateShapePackageFile(destPath, name, description, repoUrl) {
|
|
|
49
43
|
* @param repoUrl - The repository url
|
|
50
44
|
*/
|
|
51
45
|
async function updateShapePackageDistFile(destPath, name, description, repoUrl) {
|
|
52
|
-
const camelizedName =
|
|
53
|
-
await
|
|
46
|
+
const camelizedName = camelize(camelize(name, "-"), " "), dashedName = dash(camelizedName);
|
|
47
|
+
await updatePackageDistFile(destPath, `tsparticles-shape-${dashedName}`, description, `tsparticles.shape.${camelizedName}.min.js`, repoUrl);
|
|
54
48
|
}
|
|
55
49
|
/**
|
|
56
50
|
* Updates the shape readme file
|
|
@@ -60,11 +54,11 @@ async function updateShapePackageDistFile(destPath, name, description, repoUrl)
|
|
|
60
54
|
* @param repoUrl - The repository url
|
|
61
55
|
*/
|
|
62
56
|
async function updateReadmeFile(destPath, name, description, repoUrl) {
|
|
63
|
-
const capitalizedName =
|
|
57
|
+
const capitalizedName = capitalize(name, "-", " "), camelizedName = camelize(capitalizedName), dashedName = dash(camelizedName), stringSearch = "github.com", trailingSlashSearch = "github.com/", repoPath = repoUrl.includes(stringSearch)
|
|
64
58
|
? repoUrl.substring(repoUrl.indexOf(trailingSlashSearch) + trailingSlashSearch.length, repoUrl.indexOf(".git"))
|
|
65
59
|
: "tsparticles/shape-template";
|
|
66
|
-
await
|
|
67
|
-
path:
|
|
60
|
+
await replaceTokensInFile({
|
|
61
|
+
path: path.resolve(destPath, "README.md"),
|
|
68
62
|
tokens: [
|
|
69
63
|
{
|
|
70
64
|
from: /tsParticles Template Shape/g,
|
|
@@ -104,7 +98,7 @@ async function updateReadmeFile(destPath, name, description, repoUrl) {
|
|
|
104
98
|
* @param description - The description of the project
|
|
105
99
|
*/
|
|
106
100
|
async function updateShapeWebpackFile(destPath, name, description) {
|
|
107
|
-
await
|
|
101
|
+
await updateWebpackFile(destPath, camelize(capitalize(name, "-", " ")), description, "loadParticlesShape");
|
|
108
102
|
}
|
|
109
103
|
/**
|
|
110
104
|
* Creates the shape project
|
|
@@ -113,18 +107,18 @@ async function updateShapeWebpackFile(destPath, name, description) {
|
|
|
113
107
|
* @param repoUrl - The repository url
|
|
114
108
|
* @param destPath - The path where the project is located
|
|
115
109
|
*/
|
|
116
|
-
async function createShapeTemplate(name, description, repoUrl, destPath) {
|
|
117
|
-
const sourcePath =
|
|
118
|
-
await
|
|
119
|
-
await
|
|
110
|
+
export async function createShapeTemplate(name, description, repoUrl, destPath) {
|
|
111
|
+
const sourcePath = path.resolve(__dirname, "..", "..", "..", "files", "create-shape");
|
|
112
|
+
await copyEmptyTemplateFiles(destPath);
|
|
113
|
+
await fs.copy(sourcePath, destPath, {
|
|
120
114
|
overwrite: true,
|
|
121
|
-
filter:
|
|
115
|
+
filter: copyFilter,
|
|
122
116
|
});
|
|
123
117
|
await updateIndexFile(destPath, name);
|
|
124
118
|
await updateShapePackageFile(destPath, name, description, repoUrl);
|
|
125
119
|
await updateShapePackageDistFile(destPath, name, description, repoUrl);
|
|
126
120
|
await updateReadmeFile(destPath, name, description, repoUrl);
|
|
127
121
|
await updateShapeWebpackFile(destPath, name, description);
|
|
128
|
-
await
|
|
129
|
-
await
|
|
122
|
+
await runInstall(destPath);
|
|
123
|
+
await runBuild(destPath);
|
|
130
124
|
}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
9
|
-
const commander_1 = require("commander");
|
|
10
|
-
const string_utils_1 = require("../../utils/string-utils");
|
|
11
|
-
const create_shape_1 = require("./create-shape");
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const shapeCommand = new commander_1.Command("shape");
|
|
14
|
-
exports.shapeCommand = shapeCommand;
|
|
1
|
+
import { getDestinationDir, getRepositoryUrl } from "../../utils/file-utils";
|
|
2
|
+
import prompts from "prompts";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { capitalize } from "../../utils/string-utils";
|
|
5
|
+
import { createShapeTemplate } from "./create-shape";
|
|
6
|
+
import path from "path";
|
|
7
|
+
const shapeCommand = new Command("shape");
|
|
15
8
|
shapeCommand.description("Create a new tsParticles shape");
|
|
16
9
|
shapeCommand.argument("<destination>", "Destination folder");
|
|
17
10
|
shapeCommand.action(async (destination) => {
|
|
18
|
-
const destPath = await
|
|
11
|
+
const destPath = await getDestinationDir(destination), repoUrl = await getRepositoryUrl(), initialName = destPath.split(path.sep).pop(), questions = [
|
|
19
12
|
{
|
|
20
13
|
type: "text",
|
|
21
14
|
name: "name",
|
|
@@ -28,7 +21,7 @@ shapeCommand.action(async (destination) => {
|
|
|
28
21
|
name: "description",
|
|
29
22
|
message: "What is the description of the shape?",
|
|
30
23
|
validate: (value) => (value ? true : "The description can't be empty"),
|
|
31
|
-
initial:
|
|
24
|
+
initial: capitalize(initialName ?? ""),
|
|
32
25
|
},
|
|
33
26
|
{
|
|
34
27
|
type: "text",
|
|
@@ -36,6 +29,7 @@ shapeCommand.action(async (destination) => {
|
|
|
36
29
|
message: "What is the repository URL? (optional)",
|
|
37
30
|
initial: repoUrl.trim(),
|
|
38
31
|
},
|
|
39
|
-
], { name, description, repositoryUrl } = (await (
|
|
40
|
-
await
|
|
32
|
+
], { name, description, repositoryUrl } = (await prompts(questions));
|
|
33
|
+
await createShapeTemplate(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
|
|
41
34
|
});
|
|
35
|
+
export { shapeCommand };
|
package/dist/utils/file-utils.js
CHANGED
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.replaceTokensInFiles = replaceTokensInFiles;
|
|
7
|
-
exports.replaceTokensInFile = replaceTokensInFile;
|
|
8
|
-
exports.getDestinationDir = getDestinationDir;
|
|
9
|
-
exports.getRepositoryUrl = getRepositoryUrl;
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
12
|
-
const lookpath_1 = require("lookpath");
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { lookpath } from "lookpath";
|
|
4
|
+
import path from "path";
|
|
14
5
|
/**
|
|
15
6
|
*
|
|
16
7
|
* @param options -
|
|
17
8
|
*/
|
|
18
|
-
async function replaceTokensInFiles(options) {
|
|
9
|
+
export async function replaceTokensInFiles(options) {
|
|
19
10
|
for (const item of options) {
|
|
20
|
-
const filePath =
|
|
21
|
-
let data = await
|
|
11
|
+
const filePath = path.resolve(item.path);
|
|
12
|
+
let data = await fs.readFile(filePath, "utf-8");
|
|
22
13
|
for (const token of item.tokens) {
|
|
23
14
|
const regex = new RegExp(token.from, "g");
|
|
24
15
|
data = data.replace(regex, token.to);
|
|
25
16
|
}
|
|
26
|
-
await
|
|
17
|
+
await fs.writeFile(filePath, data);
|
|
27
18
|
}
|
|
28
19
|
}
|
|
29
20
|
/**
|
|
30
21
|
*
|
|
31
22
|
* @param options -
|
|
32
23
|
*/
|
|
33
|
-
async function replaceTokensInFile(options) {
|
|
24
|
+
export async function replaceTokensInFile(options) {
|
|
34
25
|
await replaceTokensInFiles([options]);
|
|
35
26
|
}
|
|
36
27
|
/**
|
|
@@ -38,26 +29,26 @@ async function replaceTokensInFile(options) {
|
|
|
38
29
|
* @param destination -
|
|
39
30
|
* @returns the destination directory path
|
|
40
31
|
*/
|
|
41
|
-
async function getDestinationDir(destination) {
|
|
42
|
-
const destPath =
|
|
32
|
+
export async function getDestinationDir(destination) {
|
|
33
|
+
const destPath = path.resolve(path.join(process.cwd(), destination)), destExists = await fs.pathExists(destPath);
|
|
43
34
|
if (destExists) {
|
|
44
|
-
const destContents = await
|
|
35
|
+
const destContents = await fs.readdir(destPath), destContentsNoGit = destContents.filter(t => t !== ".git" && t !== ".gitignore");
|
|
45
36
|
if (destContentsNoGit.length) {
|
|
46
37
|
throw new Error("Destination folder already exists and is not empty");
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
|
-
await
|
|
40
|
+
await fs.ensureDir(destPath);
|
|
50
41
|
return destPath;
|
|
51
42
|
}
|
|
52
43
|
/**
|
|
53
44
|
* @returns the repository URL
|
|
54
45
|
*/
|
|
55
|
-
async function getRepositoryUrl() {
|
|
56
|
-
if (!(await
|
|
46
|
+
export async function getRepositoryUrl() {
|
|
47
|
+
if (!(await lookpath("git"))) {
|
|
57
48
|
return "";
|
|
58
49
|
}
|
|
59
50
|
return new Promise((resolve, reject) => {
|
|
60
|
-
|
|
51
|
+
exec("git config --get remote.origin.url", (error, stdout) => {
|
|
61
52
|
if (error) {
|
|
62
53
|
reject(error);
|
|
63
54
|
return;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalize = capitalize;
|
|
4
|
-
exports.camelize = camelize;
|
|
5
|
-
exports.dash = dash;
|
|
6
1
|
/**
|
|
7
2
|
* This function is used to capitalize a string.
|
|
8
3
|
* @param str - the string to capitalize (e.g. "my-string" -\> "MyString")
|
|
9
4
|
* @param splits - the characters used to split the string, if not provided the string will be considered a single word
|
|
10
5
|
* @returns the capitalized string
|
|
11
6
|
*/
|
|
12
|
-
function capitalize(str, ...splits) {
|
|
7
|
+
export function capitalize(str, ...splits) {
|
|
13
8
|
let res = str.replace(/./, c => c.toUpperCase());
|
|
14
9
|
for (const split of splits) {
|
|
15
10
|
res = res
|
|
@@ -25,7 +20,7 @@ function capitalize(str, ...splits) {
|
|
|
25
20
|
* @param splits - the characters used to split the string, if not provided the string will be considered a single word
|
|
26
21
|
* @returns the camelized string
|
|
27
22
|
*/
|
|
28
|
-
function camelize(str, ...splits) {
|
|
23
|
+
export function camelize(str, ...splits) {
|
|
29
24
|
return capitalize(str, ...splits).replace(/./, c => c.toLowerCase());
|
|
30
25
|
}
|
|
31
26
|
/**
|
|
@@ -33,7 +28,7 @@ function camelize(str, ...splits) {
|
|
|
33
28
|
* @param str - the string to dash (e.g. "myString" -\> "my-string")
|
|
34
29
|
* @returns the dashed string
|
|
35
30
|
*/
|
|
36
|
-
function dash(str) {
|
|
31
|
+
export function dash(str) {
|
|
37
32
|
const index = 0, dashed = str.replace(/([A-Z])/g, g => `-${g[index].toLowerCase()}`), startPos = 1;
|
|
38
33
|
return dashed.startsWith("-") ? dashed.substring(startPos) : dashed;
|
|
39
34
|
}
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.updatePackageFile = updatePackageFile;
|
|
7
|
-
exports.updatePackageDistFile = updatePackageDistFile;
|
|
8
|
-
exports.updateWebpackFile = updateWebpackFile;
|
|
9
|
-
exports.copyEmptyTemplateFiles = copyEmptyTemplateFiles;
|
|
10
|
-
exports.copyFilter = copyFilter;
|
|
11
|
-
exports.runInstall = runInstall;
|
|
12
|
-
exports.runBuild = runBuild;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
15
|
-
const lookpath_1 = require("lookpath");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const file_utils_1 = require("./file-utils");
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { lookpath } from "lookpath";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { replaceTokensInFile } from "./file-utils";
|
|
18
6
|
/**
|
|
19
7
|
* Updates the package.json file
|
|
20
8
|
* @param destPath - The path where the package.json file is located
|
|
@@ -23,9 +11,9 @@ const file_utils_1 = require("./file-utils");
|
|
|
23
11
|
* @param fileName - The name of the output file
|
|
24
12
|
* @param repoUrl - The repository URL
|
|
25
13
|
*/
|
|
26
|
-
async function updatePackageFile(destPath, packageName, description, fileName, repoUrl) {
|
|
27
|
-
await
|
|
28
|
-
path:
|
|
14
|
+
export async function updatePackageFile(destPath, packageName, description, fileName, repoUrl) {
|
|
15
|
+
await replaceTokensInFile({
|
|
16
|
+
path: path.resolve(destPath, "package.json"),
|
|
29
17
|
tokens: [
|
|
30
18
|
{
|
|
31
19
|
from: /"tsParticles empty template"/g,
|
|
@@ -62,9 +50,9 @@ async function updatePackageFile(destPath, packageName, description, fileName, r
|
|
|
62
50
|
* @param fileName - The name of the output file
|
|
63
51
|
* @param repoUrl - The url of the repository
|
|
64
52
|
*/
|
|
65
|
-
async function updatePackageDistFile(destPath, packageName, description, fileName, repoUrl) {
|
|
66
|
-
await
|
|
67
|
-
path:
|
|
53
|
+
export async function updatePackageDistFile(destPath, packageName, description, fileName, repoUrl) {
|
|
54
|
+
await replaceTokensInFile({
|
|
55
|
+
path: path.resolve(destPath, "package.dist.json"),
|
|
68
56
|
tokens: [
|
|
69
57
|
{
|
|
70
58
|
from: /"tsParticles empty template"/g,
|
|
@@ -100,9 +88,9 @@ async function updatePackageDistFile(destPath, packageName, description, fileNam
|
|
|
100
88
|
* @param description - The description of the project
|
|
101
89
|
* @param fnName - The name of the function to load the template
|
|
102
90
|
*/
|
|
103
|
-
async function updateWebpackFile(destPath, name, description, fnName) {
|
|
104
|
-
await
|
|
105
|
-
path:
|
|
91
|
+
export async function updateWebpackFile(destPath, name, description, fnName) {
|
|
92
|
+
await replaceTokensInFile({
|
|
93
|
+
path: path.resolve(destPath, "webpack.config.js"),
|
|
106
94
|
tokens: [
|
|
107
95
|
{
|
|
108
96
|
from: /"Empty"/g,
|
|
@@ -123,8 +111,8 @@ async function updateWebpackFile(destPath, name, description, fnName) {
|
|
|
123
111
|
* Copies the empty template files to the destination path
|
|
124
112
|
* @param destPath - The path where the project will be created
|
|
125
113
|
*/
|
|
126
|
-
async function copyEmptyTemplateFiles(destPath) {
|
|
127
|
-
await
|
|
114
|
+
export async function copyEmptyTemplateFiles(destPath) {
|
|
115
|
+
await fs.copy(path.resolve(__dirname, "..", "..", "files", "empty-project"), destPath, {
|
|
128
116
|
overwrite: true,
|
|
129
117
|
filter: copyFilter,
|
|
130
118
|
});
|
|
@@ -134,19 +122,19 @@ async function copyEmptyTemplateFiles(destPath) {
|
|
|
134
122
|
* @param src - The source file path
|
|
135
123
|
* @returns true if the file should be copied
|
|
136
124
|
*/
|
|
137
|
-
function copyFilter(src) {
|
|
125
|
+
export function copyFilter(src) {
|
|
138
126
|
return !(src.endsWith("node_modules") || src.endsWith("dist"));
|
|
139
127
|
}
|
|
140
128
|
/**
|
|
141
129
|
* Runs npm install in the given path
|
|
142
130
|
* @param destPath - The path where the project will be created
|
|
143
131
|
*/
|
|
144
|
-
async function runInstall(destPath) {
|
|
145
|
-
if (!(await
|
|
132
|
+
export async function runInstall(destPath) {
|
|
133
|
+
if (!(await lookpath("npm"))) {
|
|
146
134
|
return;
|
|
147
135
|
}
|
|
148
136
|
return new Promise((resolve, reject) => {
|
|
149
|
-
|
|
137
|
+
exec("npm install", {
|
|
150
138
|
cwd: destPath,
|
|
151
139
|
}, error => {
|
|
152
140
|
if (error) {
|
|
@@ -161,12 +149,12 @@ async function runInstall(destPath) {
|
|
|
161
149
|
* Runs npm run build in the given path
|
|
162
150
|
* @param destPath - The path where the project will be build
|
|
163
151
|
*/
|
|
164
|
-
async function runBuild(destPath) {
|
|
165
|
-
if (!(await
|
|
152
|
+
export async function runBuild(destPath) {
|
|
153
|
+
if (!(await lookpath("npm"))) {
|
|
166
154
|
return;
|
|
167
155
|
}
|
|
168
156
|
return new Promise((resolve, reject) => {
|
|
169
|
-
|
|
157
|
+
exec("npm run build", {
|
|
170
158
|
cwd: destPath,
|
|
171
159
|
}, error => {
|
|
172
160
|
if (error) {
|
package/eslint.config.js
CHANGED
|
@@ -10,7 +10,6 @@ export default defineConfig([
|
|
|
10
10
|
{
|
|
11
11
|
languageOptions: {
|
|
12
12
|
parserOptions: {
|
|
13
|
-
// Usa il tsconfig nella cartella src che contiene i sorgenti effettivi
|
|
14
13
|
project: [path.resolve(__dirname, "src/tsconfig.json")],
|
|
15
14
|
tsconfigRootDir: __dirname,
|
|
16
15
|
sourceType: "module"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "@tsparticles/empty-template",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"private": true,
|
|
5
|
+
"type": "module",
|
|
5
6
|
"description": "tsParticles empty template",
|
|
6
7
|
"homepage": "https://particles.js.org",
|
|
7
8
|
"scripts": {
|
|
@@ -83,7 +84,7 @@
|
|
|
83
84
|
"prettier": "@tsparticles/prettier-config",
|
|
84
85
|
"devDependencies": {
|
|
85
86
|
"@babel/core": "^7.23.9",
|
|
86
|
-
"@tsparticles/cli": "^3.0.
|
|
87
|
+
"@tsparticles/cli": "^3.0.2",
|
|
87
88
|
"@tsparticles/eslint-config": "^2.2.1",
|
|
88
89
|
"@tsparticles/prettier-config": "^2.1.6",
|
|
89
90
|
"@tsparticles/tsconfig": "^2.1.7",
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {loadParticlesTemplate} from "@tsparticles/webpack-plugin";
|
|
2
|
+
import {fileURLToPath} from 'url';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url),
|
|
7
|
+
__dirname = path.dirname(__filename),
|
|
8
|
+
pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8')),
|
|
9
|
+
version = pkg.version;
|
|
10
|
+
|
|
11
|
+
export default loadParticlesTemplate({moduleName: "empty", templateName: "Empty", version, dir: __dirname});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/cli",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"prettier": "@tsparticles/prettier-config",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@tsparticles/eslint-config": "^3.0.
|
|
15
|
-
"@tsparticles/prettier-config": "^3.0.
|
|
16
|
-
"@tsparticles/tsconfig": "^3.0.
|
|
17
|
-
"@tsparticles/webpack-plugin": "^3.0.
|
|
14
|
+
"@tsparticles/eslint-config": "^3.0.3",
|
|
15
|
+
"@tsparticles/prettier-config": "^3.0.1",
|
|
16
|
+
"@tsparticles/tsconfig": "^3.0.1",
|
|
17
|
+
"@tsparticles/webpack-plugin": "^3.0.3",
|
|
18
18
|
"commander": "^14.0.0",
|
|
19
19
|
"eslint": "^9.34.0",
|
|
20
20
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -38,25 +38,21 @@
|
|
|
38
38
|
"@babel/core": "^7.28.3",
|
|
39
39
|
"@tsparticles/cli": "^2.3.3",
|
|
40
40
|
"@tsparticles/engine": "^3.9.1",
|
|
41
|
-
"@types/chai": "^5.2.2",
|
|
42
41
|
"@types/eslint": "^9.6.1",
|
|
43
42
|
"@types/estree": "^1.0.8",
|
|
44
43
|
"@types/fs-extra": "^11.0.4",
|
|
45
44
|
"@types/klaw": "^3.0.7",
|
|
46
45
|
"@types/madge": "^5.0.3",
|
|
47
|
-
"@types/mocha": "^10.0.10",
|
|
48
46
|
"@types/node": "^24.3.0",
|
|
49
47
|
"@types/prompts": "^2.4.9",
|
|
50
48
|
"@types/webpack-env": "^1.18.8",
|
|
51
49
|
"babel-loader": "^10.0.0",
|
|
52
50
|
"browserslist": "^4.25.4",
|
|
53
|
-
"chai": "^4.5.0",
|
|
54
51
|
"copyfiles": "^2.4.1",
|
|
55
52
|
"cross-env": "^10.0.0",
|
|
56
|
-
"mocha": "^10.8.2",
|
|
57
|
-
"nyc": "^17.1.0",
|
|
58
53
|
"terser-webpack-plugin": "^5.3.14",
|
|
59
54
|
"ts-node": "^10.9.2",
|
|
55
|
+
"vitest": "^1.5.6",
|
|
60
56
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
61
57
|
"webpack-cli": "^6.0.1"
|
|
62
58
|
},
|
|
@@ -75,7 +71,7 @@
|
|
|
75
71
|
"compile:ci": "pnpm run build:ts",
|
|
76
72
|
"build:ts": "pnpm run build:ts:cjs",
|
|
77
73
|
"build:ts:cjs": "tsc -p src",
|
|
78
|
-
"test": "
|
|
74
|
+
"test": "vitest run",
|
|
79
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",
|
|
80
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",
|
|
81
77
|
"clear:dist": "rimraf ./dist",
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ESLint } from "eslint";
|
|
2
|
+
import { defineConfig } from "eslint/config";
|
|
3
|
+
import tsParticlesESLintConfig from "@tsparticles/eslint-config";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @param ci -
|
|
@@ -10,7 +12,7 @@ export async function lint(ci: boolean): Promise<boolean> {
|
|
|
10
12
|
let res: boolean;
|
|
11
13
|
|
|
12
14
|
try {
|
|
13
|
-
const eslint = new ESLint({ fix: !ci });
|
|
15
|
+
const eslint = new ESLint({ baseConfig: defineConfig([tsParticlesESLintConfig]), fix: !ci });
|
|
14
16
|
|
|
15
17
|
const results = await eslint.lintFiles(["src"]),
|
|
16
18
|
errors = ESLint.getErrorResults(results);
|
package/src/tsconfig.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
28
28
|
|
|
29
29
|
/* Modules */
|
|
30
|
-
"module": "
|
|
30
|
+
"module": "es2020",
|
|
31
31
|
/* Specify what module code is generated. */
|
|
32
32
|
"rootDir": ".",
|
|
33
33
|
/* Specify the root folder within your source files. */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { describe, it } from "
|
|
2
|
-
import { expect } from "chai";
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
3
2
|
import { createPluginTemplate } from "../src/create/plugin/create-plugin";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import fs from "fs-extra";
|
|
6
5
|
|
|
7
|
-
describe("create-plugin",
|
|
6
|
+
describe("create-plugin", () => {
|
|
8
7
|
it("should have created the plugin project", async () => {
|
|
9
8
|
const destDir = path.resolve(path.join(__dirname, "tmp-files", "foo-plugin"));
|
|
10
9
|
|
|
@@ -12,7 +11,7 @@ describe("create-plugin", async () => {
|
|
|
12
11
|
|
|
13
12
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
14
13
|
|
|
15
|
-
expect(pkgInfo.name).
|
|
14
|
+
expect(pkgInfo.name).toBe("tsparticles-plugin-foo");
|
|
16
15
|
|
|
17
16
|
await fs.remove(destDir);
|
|
18
17
|
});
|
|
@@ -24,7 +23,7 @@ describe("create-plugin", async () => {
|
|
|
24
23
|
|
|
25
24
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
26
25
|
|
|
27
|
-
expect(pkgInfo.name).
|
|
26
|
+
expect(pkgInfo.name).toBe("tsparticles-plugin-bar");
|
|
28
27
|
|
|
29
28
|
await fs.remove(destDir);
|
|
30
29
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { describe, it } from "
|
|
2
|
-
import { expect } from "chai";
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
3
2
|
import { createPresetTemplate } from "../src/create/preset/create-preset";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import fs from "fs-extra";
|
|
6
5
|
|
|
7
|
-
describe("create-preset",
|
|
6
|
+
describe("create-preset", () => {
|
|
8
7
|
it("should have created the preset project", async () => {
|
|
9
8
|
const destDir = path.resolve(path.join(__dirname, "tmp-files", "foo-preset"));
|
|
10
9
|
|
|
@@ -12,7 +11,7 @@ describe("create-preset", async () => {
|
|
|
12
11
|
|
|
13
12
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
14
13
|
|
|
15
|
-
expect(pkgInfo.name).
|
|
14
|
+
expect(pkgInfo.name).toBe("tsparticles-preset-foo");
|
|
16
15
|
|
|
17
16
|
await fs.remove(destDir);
|
|
18
17
|
});
|
|
@@ -24,7 +23,7 @@ describe("create-preset", async () => {
|
|
|
24
23
|
|
|
25
24
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
26
25
|
|
|
27
|
-
expect(pkgInfo.name).
|
|
26
|
+
expect(pkgInfo.name).toBe("tsparticles-preset-bar");
|
|
28
27
|
|
|
29
28
|
await fs.remove(destDir);
|
|
30
29
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { describe, it } from "
|
|
2
|
-
import { expect } from "chai";
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
3
2
|
import { createShapeTemplate } from "../src/create/shape/create-shape";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import fs from "fs-extra";
|
|
6
5
|
|
|
7
|
-
describe("create-shape",
|
|
6
|
+
describe("create-shape", () => {
|
|
8
7
|
it("should have created the shape project", async () => {
|
|
9
8
|
const destDir = path.resolve(path.join(__dirname, "tmp-files", "foo-shape"));
|
|
10
9
|
|
|
@@ -12,7 +11,7 @@ describe("create-shape", async () => {
|
|
|
12
11
|
|
|
13
12
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
14
13
|
|
|
15
|
-
expect(pkgInfo.name).
|
|
14
|
+
expect(pkgInfo.name).toBe("tsparticles-shape-foo");
|
|
16
15
|
|
|
17
16
|
await fs.remove(destDir);
|
|
18
17
|
});
|
|
@@ -24,7 +23,7 @@ describe("create-shape", async () => {
|
|
|
24
23
|
|
|
25
24
|
const pkgInfo = await fs.readJSON(path.join(destDir, "package.json"));
|
|
26
25
|
|
|
27
|
-
expect(pkgInfo.name).
|
|
26
|
+
expect(pkgInfo.name).toBe("tsparticles-shape-bar");
|
|
28
27
|
|
|
29
28
|
await fs.remove(destDir);
|
|
30
29
|
});
|