@tsparticles/cli 1.7.0 → 1.8.0
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-eslint.js +1 -1
- package/dist/build/build-prettier.js +10 -10
- package/dist/utils/template-utils.js +1 -4
- package/files/empty-project/package.json +8 -8
- package/files/empty-project/webpack.config.js +1 -1
- package/package.json +9 -10
- package/src/build/build-eslint.ts +2 -2
- package/src/build/build-prettier.ts +10 -10
- package/src/build/build.ts +2 -2
- package/src/create/plugin/create-plugin.ts +11 -11
- package/src/create/preset/create-preset.ts +11 -11
- package/src/create/shape/create-shape.ts +10 -10
- package/src/utils/template-utils.ts +4 -8
|
@@ -16,7 +16,7 @@ const prettier_1 = __importDefault(require("prettier"));
|
|
|
16
16
|
*/
|
|
17
17
|
async function prettifySrc(basePath, srcPath, ci) {
|
|
18
18
|
console.log("Prettier - started on src");
|
|
19
|
-
let res
|
|
19
|
+
let res;
|
|
20
20
|
try {
|
|
21
21
|
for await (const file of (0, klaw_1.default)(srcPath)) {
|
|
22
22
|
if (file.stats.isDirectory()) {
|
|
@@ -28,12 +28,12 @@ async function prettifySrc(basePath, srcPath, ci) {
|
|
|
28
28
|
options.parser = "typescript";
|
|
29
29
|
options.tabWidth = 4;
|
|
30
30
|
if (ci) {
|
|
31
|
-
if (!prettier_1.default.check(contents, options)) {
|
|
31
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
32
32
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
const formatted = prettier_1.default.format(contents, options);
|
|
36
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
37
37
|
await fs_extra_1.default.writeFile(file.path, formatted, "utf8");
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -54,19 +54,19 @@ exports.prettifySrc = prettifySrc;
|
|
|
54
54
|
*/
|
|
55
55
|
async function prettifyReadme(basePath, ci) {
|
|
56
56
|
console.log("Prettier - started on README.md");
|
|
57
|
-
let res
|
|
57
|
+
let res;
|
|
58
58
|
try {
|
|
59
59
|
const contents = await fs_extra_1.default.readFile("README.md", "utf8"), options = (await prettier_1.default.resolveConfig(basePath)) ?? {};
|
|
60
60
|
options.printWidth = 120;
|
|
61
61
|
options.endOfLine = "lf";
|
|
62
62
|
options.parser = "markdown";
|
|
63
63
|
if (ci) {
|
|
64
|
-
if (!prettier_1.default.check(contents, options)) {
|
|
64
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
65
65
|
throw new Error(`README.md is not formatted correctly`);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
|
-
const formatted = prettier_1.default.format(contents, options);
|
|
69
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
70
70
|
await fs_extra_1.default.writeFile("README.md", formatted, "utf8");
|
|
71
71
|
}
|
|
72
72
|
res = (await prettifyTraductions(basePath, ci)) && (await prettifyMarkdownTypeDocFiles(basePath, ci));
|
|
@@ -102,12 +102,12 @@ async function prettifyTraductions(basePath, ci) {
|
|
|
102
102
|
options.endOfLine = "lf";
|
|
103
103
|
options.parser = "markdown";
|
|
104
104
|
if (ci) {
|
|
105
|
-
if (!prettier_1.default.check(contents, options)) {
|
|
105
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
106
106
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
|
-
const formatted = prettier_1.default.format(contents, options);
|
|
110
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
111
111
|
await fs_extra_1.default.writeFile(file.path, formatted, "utf8");
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -144,12 +144,12 @@ async function prettifyMarkdownTypeDocFiles(basePath, ci) {
|
|
|
144
144
|
options.endOfLine = "lf";
|
|
145
145
|
options.parser = "markdown";
|
|
146
146
|
if (ci) {
|
|
147
|
-
if (!prettier_1.default.check(contents, options)) {
|
|
147
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
148
148
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
|
-
const formatted = prettier_1.default.format(contents, options);
|
|
152
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
153
153
|
await fs_extra_1.default.writeFile(file.path, formatted, "utf8");
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -63,10 +63,7 @@ exports.copyEmptyTemplateFiles = copyEmptyTemplateFiles;
|
|
|
63
63
|
* @returns true if the file should be copied
|
|
64
64
|
*/
|
|
65
65
|
function copyFilter(src) {
|
|
66
|
-
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
66
|
+
return !(src.endsWith("node_modules") || src.endsWith("dist"));
|
|
70
67
|
}
|
|
71
68
|
exports.copyFilter = copyFilter;
|
|
72
69
|
/**
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"prettier": "@tsparticles/prettier-config",
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/core": "^7.22.5",
|
|
86
|
-
"@tsparticles/cli": "1.
|
|
87
|
-
"@tsparticles/eslint-config": "^1.
|
|
86
|
+
"@tsparticles/cli": "1.8.0",
|
|
87
|
+
"@tsparticles/eslint-config": "^1.14.0",
|
|
88
88
|
"@tsparticles/prettier-config": "^1.10.0",
|
|
89
|
-
"@tsparticles/tsconfig": "^1.
|
|
90
|
-
"@tsparticles/webpack-plugin": "^1.
|
|
89
|
+
"@tsparticles/tsconfig": "^1.14.0",
|
|
90
|
+
"@tsparticles/webpack-plugin": "^1.16.0",
|
|
91
91
|
"@types/webpack-env": "^1.18.1",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^5.60.
|
|
93
|
-
"@typescript-eslint/parser": "^5.60.
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^5.60.1",
|
|
93
|
+
"@typescript-eslint/parser": "^5.60.1",
|
|
94
94
|
"babel-loader": "^9.1.2",
|
|
95
95
|
"browserslist": "^4.21.9",
|
|
96
96
|
"copyfiles": "^2.4.1",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"prettier": "^2.8.8",
|
|
100
100
|
"rimraf": "^5.0.1",
|
|
101
101
|
"terser-webpack-plugin": "^5.3.9",
|
|
102
|
-
"typescript": "^5.1.
|
|
103
|
-
"webpack": "^5.
|
|
102
|
+
"typescript": "^5.1.6",
|
|
103
|
+
"webpack": "^5.88.1",
|
|
104
104
|
"webpack-bundle-analyzer": "^4.9.0",
|
|
105
105
|
"webpack-cli": "^5.1.4"
|
|
106
106
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
const { loadParticlesTemplate } = require("@tsparticles/webpack-plugin"),
|
|
2
2
|
version = require("./package.json").version;
|
|
3
3
|
|
|
4
|
-
module.exports = loadParticlesTemplate("empty", "Empty", version, __dirname);
|
|
4
|
+
module.exports = 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": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsparticles-cli": "dist/cli.js"
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
},
|
|
11
11
|
"prettier": "@tsparticles/prettier-config",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tsparticles/eslint-config": "^1.
|
|
14
|
-
"@tsparticles/prettier-config": "^1.
|
|
13
|
+
"@tsparticles/eslint-config": "^1.15.0",
|
|
14
|
+
"@tsparticles/prettier-config": "^1.11.0",
|
|
15
15
|
"@tsparticles/tsconfig": "^1.14.0",
|
|
16
|
-
"@tsparticles/webpack-plugin": "^1.
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
18
|
-
"@typescript-eslint/parser": "^5.
|
|
16
|
+
"@tsparticles/webpack-plugin": "^1.17.1",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
18
|
+
"@typescript-eslint/parser": "^5.61.0",
|
|
19
19
|
"commander": "^11.0.0",
|
|
20
|
-
"eslint": "^8.
|
|
20
|
+
"eslint": "^8.44.0",
|
|
21
21
|
"eslint-config-prettier": "^8.8.0",
|
|
22
|
-
"eslint-plugin-jsdoc": "^46.4.
|
|
22
|
+
"eslint-plugin-jsdoc": "^46.4.3",
|
|
23
23
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
24
24
|
"fs-extra": "^11.1.1",
|
|
25
25
|
"klaw": "^4.1.0",
|
|
26
26
|
"path-scurry": "^1.10.0",
|
|
27
|
-
"prettier": "^
|
|
27
|
+
"prettier": "^3.0.0",
|
|
28
28
|
"prompts": "^2.4.2",
|
|
29
29
|
"rimraf": "^5.0.1",
|
|
30
30
|
"typescript": "^5.1.6",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"@types/fs-extra": "^11.0.1",
|
|
36
36
|
"@types/klaw": "^3.0.3",
|
|
37
37
|
"@types/node": "^20.3.2",
|
|
38
|
-
"@types/prettier": "^2.7.3",
|
|
39
38
|
"@types/prompts": "^2.4.4"
|
|
40
39
|
},
|
|
41
40
|
"description": "tsParticles CLI",
|
|
@@ -7,7 +7,7 @@ import { ESLint } from "eslint";
|
|
|
7
7
|
export async function lint(ci: boolean): Promise<boolean> {
|
|
8
8
|
console.log("ESLint - started on src");
|
|
9
9
|
|
|
10
|
-
let res
|
|
10
|
+
let res: boolean;
|
|
11
11
|
|
|
12
12
|
try {
|
|
13
13
|
const eslint = new ESLint({
|
|
@@ -28,7 +28,7 @@ export async function lint(ci: boolean): Promise<boolean> {
|
|
|
28
28
|
|
|
29
29
|
if (errors.length > 0) {
|
|
30
30
|
const messages = errors.map(t =>
|
|
31
|
-
t.messages.map(m => `${t.filePath} (${m.line},${m.column}): ${m.message}`).join("\n")
|
|
31
|
+
t.messages.map(m => `${t.filePath} (${m.line},${m.column}): ${m.message}`).join("\n"),
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
throw new Error(messages.join("\n"));
|
|
@@ -12,7 +12,7 @@ import prettier from "prettier";
|
|
|
12
12
|
export async function prettifySrc(basePath: string, srcPath: string, ci: boolean): Promise<boolean> {
|
|
13
13
|
console.log("Prettier - started on src");
|
|
14
14
|
|
|
15
|
-
let res
|
|
15
|
+
let res: boolean;
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
18
|
for await (const file of klaw(srcPath)) {
|
|
@@ -29,11 +29,11 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
29
29
|
options.tabWidth = 4;
|
|
30
30
|
|
|
31
31
|
if (ci) {
|
|
32
|
-
if (!prettier.check(contents, options)) {
|
|
32
|
+
if (!(await prettier.check(contents, options))) {
|
|
33
33
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
34
34
|
}
|
|
35
35
|
} else {
|
|
36
|
-
const formatted = prettier.format(contents, options);
|
|
36
|
+
const formatted = await prettier.format(contents, options);
|
|
37
37
|
|
|
38
38
|
await fs.writeFile(file.path, formatted, "utf8");
|
|
39
39
|
}
|
|
@@ -59,7 +59,7 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
59
59
|
export async function prettifyReadme(basePath: string, ci: boolean): Promise<boolean> {
|
|
60
60
|
console.log("Prettier - started on README.md");
|
|
61
61
|
|
|
62
|
-
let res
|
|
62
|
+
let res: boolean;
|
|
63
63
|
|
|
64
64
|
try {
|
|
65
65
|
const contents = await fs.readFile("README.md", "utf8"),
|
|
@@ -70,11 +70,11 @@ export async function prettifyReadme(basePath: string, ci: boolean): Promise<boo
|
|
|
70
70
|
options.parser = "markdown";
|
|
71
71
|
|
|
72
72
|
if (ci) {
|
|
73
|
-
if (!prettier.check(contents, options)) {
|
|
73
|
+
if (!(await prettier.check(contents, options))) {
|
|
74
74
|
throw new Error(`README.md is not formatted correctly`);
|
|
75
75
|
}
|
|
76
76
|
} else {
|
|
77
|
-
const formatted = prettier.format(contents, options);
|
|
77
|
+
const formatted = await prettier.format(contents, options);
|
|
78
78
|
|
|
79
79
|
await fs.writeFile("README.md", formatted, "utf8");
|
|
80
80
|
}
|
|
@@ -123,11 +123,11 @@ async function prettifyTraductions(basePath: string, ci: boolean): Promise<boole
|
|
|
123
123
|
options.parser = "markdown";
|
|
124
124
|
|
|
125
125
|
if (ci) {
|
|
126
|
-
if (!prettier.check(contents, options)) {
|
|
126
|
+
if (!(await prettier.check(contents, options))) {
|
|
127
127
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
128
128
|
}
|
|
129
129
|
} else {
|
|
130
|
-
const formatted = prettier.format(contents, options);
|
|
130
|
+
const formatted = await prettier.format(contents, options);
|
|
131
131
|
|
|
132
132
|
await fs.writeFile(file.path, formatted, "utf8");
|
|
133
133
|
}
|
|
@@ -178,11 +178,11 @@ async function prettifyMarkdownTypeDocFiles(basePath: string, ci: boolean): Prom
|
|
|
178
178
|
options.parser = "markdown";
|
|
179
179
|
|
|
180
180
|
if (ci) {
|
|
181
|
-
if (!prettier.check(contents, options)) {
|
|
181
|
+
if (!(await prettier.check(contents, options))) {
|
|
182
182
|
throw new Error(`${file.path} is not formatted correctly`);
|
|
183
183
|
}
|
|
184
184
|
} else {
|
|
185
|
-
const formatted = prettier.format(contents, options);
|
|
185
|
+
const formatted = await prettier.format(contents, options);
|
|
186
186
|
|
|
187
187
|
await fs.writeFile(file.path, formatted, "utf8");
|
|
188
188
|
}
|
package/src/build/build.ts
CHANGED
|
@@ -15,14 +15,14 @@ buildCommand.description("Build the library using TypeScript");
|
|
|
15
15
|
buildCommand.option(
|
|
16
16
|
"-a, --all",
|
|
17
17
|
"Do all build steps (default if no flags are specified) (same as -b -c -d -l -p -t)",
|
|
18
|
-
true
|
|
18
|
+
true,
|
|
19
19
|
);
|
|
20
20
|
buildCommand.option("-b, --bundle", "Bundle the library using Webpack", false);
|
|
21
21
|
buildCommand.option("-c, --clean", "Clean the dist folder", false);
|
|
22
22
|
buildCommand.option(
|
|
23
23
|
"--ci",
|
|
24
24
|
"Do all build steps for CI, no fixing files, only checking if they are formatted correctly",
|
|
25
|
-
false
|
|
25
|
+
false,
|
|
26
26
|
);
|
|
27
27
|
buildCommand.option("-d, --dist", "Build the dist files", false);
|
|
28
28
|
buildCommand.option("-l, --lint", "Lint the source files", false);
|
|
@@ -40,7 +40,7 @@ async function updatePluginPackageFile(
|
|
|
40
40
|
destPath: string,
|
|
41
41
|
name: string,
|
|
42
42
|
description: string,
|
|
43
|
-
repoUrl: string
|
|
43
|
+
repoUrl: string,
|
|
44
44
|
): Promise<void> {
|
|
45
45
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
46
46
|
dashedName = dash(camelizedName);
|
|
@@ -50,7 +50,7 @@ async function updatePluginPackageFile(
|
|
|
50
50
|
`"tsparticles-plugin-${dashedName}"`,
|
|
51
51
|
description,
|
|
52
52
|
`"tsparticles.plugin.${camelizedName}.min.js"`,
|
|
53
|
-
repoUrl
|
|
53
|
+
repoUrl,
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -65,7 +65,7 @@ async function updatePluginPackageDistFile(
|
|
|
65
65
|
destPath: string,
|
|
66
66
|
name: string,
|
|
67
67
|
description: string,
|
|
68
|
-
repoUrl: string
|
|
68
|
+
repoUrl: string,
|
|
69
69
|
): Promise<void> {
|
|
70
70
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
71
71
|
dashedName = dash(camelizedName);
|
|
@@ -75,7 +75,7 @@ async function updatePluginPackageDistFile(
|
|
|
75
75
|
`"tsparticles-plugin-${dashedName}"`,
|
|
76
76
|
description,
|
|
77
77
|
`"tsparticles.plugin.${camelizedName}.min.js"`,
|
|
78
|
-
repoUrl
|
|
78
|
+
repoUrl,
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -97,23 +97,23 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
97
97
|
readmePackageNameRegex = /tsparticles-plugin-template/g,
|
|
98
98
|
replacedPackageNameText = replacedDescriptionText.replace(
|
|
99
99
|
readmePackageNameRegex,
|
|
100
|
-
`tsparticles-plugin-${dashedName}
|
|
100
|
+
`tsparticles-plugin-${dashedName}`,
|
|
101
101
|
),
|
|
102
102
|
readmeFileNameRegex = /tsparticles\.plugin\.template(\.bundle)?\.min\.js/g,
|
|
103
103
|
replacedFileNameText = replacedPackageNameText.replace(
|
|
104
104
|
readmeFileNameRegex,
|
|
105
|
-
`tsparticles.plugin.${camelizedName}$1.min.js
|
|
105
|
+
`tsparticles.plugin.${camelizedName}$1.min.js`,
|
|
106
106
|
),
|
|
107
107
|
readmeFunctionNameRegex = /loadTemplatePlugin/g,
|
|
108
108
|
replacedFunctionNameText = replacedFileNameText.replace(
|
|
109
109
|
readmeFunctionNameRegex,
|
|
110
|
-
`load${capitalizedName}Plugin
|
|
110
|
+
`load${capitalizedName}Plugin`,
|
|
111
111
|
),
|
|
112
112
|
readmeMiniDescriptionRegex =
|
|
113
113
|
/\[tsParticles]\(https:\/\/github.com\/matteobruni\/tsparticles\) additional template plugin\./g,
|
|
114
114
|
replacedMiniDescriptionText = replacedFunctionNameText.replace(
|
|
115
115
|
readmeMiniDescriptionRegex,
|
|
116
|
-
`[tsParticles](https://github.com/matteobruni/tsparticles) additional ${name} plugin
|
|
116
|
+
`[tsParticles](https://github.com/matteobruni/tsparticles) additional ${name} plugin.`,
|
|
117
117
|
),
|
|
118
118
|
readmeUsageRegex = /plugin\.type: "template"/g,
|
|
119
119
|
replacedUsageText = replacedMiniDescriptionText.replace(readmeUsageRegex, `plugin.type: "${camelizedName}`),
|
|
@@ -124,7 +124,7 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
124
124
|
: "tsparticles/plugin-template",
|
|
125
125
|
replacedText = replacedUsageText.replace(
|
|
126
126
|
sampleImageRegex,
|
|
127
|
-
`
|
|
127
|
+
``,
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
await fs.writeFile(readmePath, replacedText);
|
|
@@ -141,7 +141,7 @@ async function updatePluginWebpackFile(destPath: string, name: string, descripti
|
|
|
141
141
|
destPath,
|
|
142
142
|
camelize(capitalize(capitalize(name, "-"), " ")),
|
|
143
143
|
`tsParticles ${description} Plugin`,
|
|
144
|
-
"loadParticlesPlugin"
|
|
144
|
+
"loadParticlesPlugin",
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -156,7 +156,7 @@ export async function createPluginTemplate(
|
|
|
156
156
|
name: string,
|
|
157
157
|
description: string,
|
|
158
158
|
repoUrl: string,
|
|
159
|
-
destPath: string
|
|
159
|
+
destPath: string,
|
|
160
160
|
): Promise<void> {
|
|
161
161
|
const sourcePath = path.resolve(__dirname, "..", "..", "..", "files", "create-plugin");
|
|
162
162
|
|
|
@@ -55,7 +55,7 @@ async function updatePresetPackageFile(
|
|
|
55
55
|
destPath: string,
|
|
56
56
|
name: string,
|
|
57
57
|
description: string,
|
|
58
|
-
repoUrl: string
|
|
58
|
+
repoUrl: string,
|
|
59
59
|
): Promise<void> {
|
|
60
60
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
61
61
|
dashedName = dash(camelizedName);
|
|
@@ -65,7 +65,7 @@ async function updatePresetPackageFile(
|
|
|
65
65
|
`"tsparticles-preset-${dashedName}"`,
|
|
66
66
|
description,
|
|
67
67
|
`"tsparticles.preset.${camelizedName}.min.js"`,
|
|
68
|
-
repoUrl
|
|
68
|
+
repoUrl,
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -80,7 +80,7 @@ async function updatePresetPackageDistFile(
|
|
|
80
80
|
destPath: string,
|
|
81
81
|
name: string,
|
|
82
82
|
description: string,
|
|
83
|
-
repoUrl: string
|
|
83
|
+
repoUrl: string,
|
|
84
84
|
): Promise<void> {
|
|
85
85
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
86
86
|
dashedName = dash(camelizedName);
|
|
@@ -90,7 +90,7 @@ async function updatePresetPackageDistFile(
|
|
|
90
90
|
`"tsparticles-preset-${dashedName}"`,
|
|
91
91
|
description,
|
|
92
92
|
`"tsparticles.preset.${camelizedName}.min.js"`,
|
|
93
|
-
repoUrl
|
|
93
|
+
repoUrl,
|
|
94
94
|
);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -112,23 +112,23 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
112
112
|
readmePackageNameRegex = /tsparticles-preset-template/g,
|
|
113
113
|
replacedPackageNameText = replacedDescriptionText.replace(
|
|
114
114
|
readmePackageNameRegex,
|
|
115
|
-
`tsparticles-preset-${dashedName}
|
|
115
|
+
`tsparticles-preset-${dashedName}`,
|
|
116
116
|
),
|
|
117
117
|
readmeFileNameRegex = /tsparticles\.preset\.template(\.bundle)?\.min\.js/g,
|
|
118
118
|
replacedFileNameText = replacedPackageNameText.replace(
|
|
119
119
|
readmeFileNameRegex,
|
|
120
|
-
`tsparticles.preset.${camelizedName}$1.min.js
|
|
120
|
+
`tsparticles.preset.${camelizedName}$1.min.js`,
|
|
121
121
|
),
|
|
122
122
|
readmeFunctionNameRegex = /loadTemplatePreset/g,
|
|
123
123
|
replacedFunctionNameText = replacedFileNameText.replace(
|
|
124
124
|
readmeFunctionNameRegex,
|
|
125
|
-
`load${capitalizedName}Preset
|
|
125
|
+
`load${capitalizedName}Preset`,
|
|
126
126
|
),
|
|
127
127
|
readmeMiniDescriptionRegex =
|
|
128
128
|
/\[tsParticles]\(https:\/\/github.com\/matteobruni\/tsparticles\) preset template\./g,
|
|
129
129
|
replacedMiniDescriptionText = replacedFunctionNameText.replace(
|
|
130
130
|
readmeMiniDescriptionRegex,
|
|
131
|
-
`[tsParticles](https://github.com/matteobruni/tsparticles) preset ${name}
|
|
131
|
+
`[tsParticles](https://github.com/matteobruni/tsparticles) preset ${name}.`,
|
|
132
132
|
),
|
|
133
133
|
readmeUsageRegex = /preset: "template"/g,
|
|
134
134
|
replacedUsageText = replacedMiniDescriptionText.replace(readmeUsageRegex, `preset: "${camelizedName}`),
|
|
@@ -139,7 +139,7 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
139
139
|
: "tsparticles/preset-template",
|
|
140
140
|
replacedText = replacedUsageText.replace(
|
|
141
141
|
sampleImageRegex,
|
|
142
|
-
`
|
|
142
|
+
``,
|
|
143
143
|
);
|
|
144
144
|
|
|
145
145
|
await fs.writeFile(readmePath, replacedText);
|
|
@@ -156,7 +156,7 @@ async function updatePresetWebpackFile(destPath: string, name: string, descripti
|
|
|
156
156
|
destPath,
|
|
157
157
|
camelize(capitalize(capitalize(name, "-"), " ")),
|
|
158
158
|
`tsParticles ${description} Preset`,
|
|
159
|
-
"loadParticlesPreset"
|
|
159
|
+
"loadParticlesPreset",
|
|
160
160
|
);
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -171,7 +171,7 @@ export async function createPresetTemplate(
|
|
|
171
171
|
name: string,
|
|
172
172
|
description: string,
|
|
173
173
|
repoUrl: string,
|
|
174
|
-
destPath: string
|
|
174
|
+
destPath: string,
|
|
175
175
|
): Promise<void> {
|
|
176
176
|
const sourcePath = path.resolve(__dirname, "..", "..", "..", "files", "create-preset");
|
|
177
177
|
|
|
@@ -40,7 +40,7 @@ async function updateShapePackageFile(
|
|
|
40
40
|
destPath: string,
|
|
41
41
|
name: string,
|
|
42
42
|
description: string,
|
|
43
|
-
repoUrl: string
|
|
43
|
+
repoUrl: string,
|
|
44
44
|
): Promise<void> {
|
|
45
45
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
46
46
|
dashedName = dash(camelizedName);
|
|
@@ -50,7 +50,7 @@ async function updateShapePackageFile(
|
|
|
50
50
|
`"tsparticles-shape-${dashedName}"`,
|
|
51
51
|
description,
|
|
52
52
|
`"tsparticles.shape.${camelizedName}.min.js"`,
|
|
53
|
-
repoUrl
|
|
53
|
+
repoUrl,
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -65,7 +65,7 @@ async function updateShapePackageDistFile(
|
|
|
65
65
|
destPath: string,
|
|
66
66
|
name: string,
|
|
67
67
|
description: string,
|
|
68
|
-
repoUrl: string
|
|
68
|
+
repoUrl: string,
|
|
69
69
|
): Promise<void> {
|
|
70
70
|
const camelizedName = camelize(camelize(name, "-"), " "),
|
|
71
71
|
dashedName = dash(camelizedName);
|
|
@@ -75,7 +75,7 @@ async function updateShapePackageDistFile(
|
|
|
75
75
|
`"tsparticles-shape-${dashedName}"`,
|
|
76
76
|
description,
|
|
77
77
|
`"tsparticles.shape.${camelizedName}.min.js"`,
|
|
78
|
-
repoUrl
|
|
78
|
+
repoUrl,
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -97,12 +97,12 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
97
97
|
readmePackageNameRegex = /tsparticles-shape-template/g,
|
|
98
98
|
replacedPackageNameText = replacedDescriptionText.replace(
|
|
99
99
|
readmePackageNameRegex,
|
|
100
|
-
`tsparticles-shape-${dashedName}
|
|
100
|
+
`tsparticles-shape-${dashedName}`,
|
|
101
101
|
),
|
|
102
102
|
readmeFileNameRegex = /tsparticles\.shape\.template(\.bundle)?\.min\.js/g,
|
|
103
103
|
replacedFileNameText = replacedPackageNameText.replace(
|
|
104
104
|
readmeFileNameRegex,
|
|
105
|
-
`tsparticles.shape.${camelizedName}$1.min.js
|
|
105
|
+
`tsparticles.shape.${camelizedName}$1.min.js`,
|
|
106
106
|
),
|
|
107
107
|
readmeFunctionNameRegex = /loadTemplateShape/g,
|
|
108
108
|
replacedFunctionNameText = replacedFileNameText.replace(readmeFunctionNameRegex, `load${capitalizedName}Shape`),
|
|
@@ -110,7 +110,7 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
110
110
|
/\[tsParticles]\(https:\/\/github.com\/matteobruni\/tsparticles\) additional template shape\./g,
|
|
111
111
|
replacedMiniDescriptionText = replacedFunctionNameText.replace(
|
|
112
112
|
readmeMiniDescriptionRegex,
|
|
113
|
-
`[tsParticles](https://github.com/matteobruni/tsparticles) additional ${name} shape
|
|
113
|
+
`[tsParticles](https://github.com/matteobruni/tsparticles) additional ${name} shape.`,
|
|
114
114
|
),
|
|
115
115
|
readmeUsageRegex = /shape\.type: "template"/g,
|
|
116
116
|
replacedUsageText = replacedMiniDescriptionText.replace(readmeUsageRegex, `shape.type: "${camelizedName}`),
|
|
@@ -121,7 +121,7 @@ async function updateReadmeFile(destPath: string, name: string, description: str
|
|
|
121
121
|
: "tsparticles/shape-template",
|
|
122
122
|
replacedText = replacedUsageText.replace(
|
|
123
123
|
sampleImageRegex,
|
|
124
|
-
`
|
|
124
|
+
``,
|
|
125
125
|
);
|
|
126
126
|
|
|
127
127
|
await fs.writeFile(readmePath, replacedText);
|
|
@@ -138,7 +138,7 @@ async function updateShapeWebpackFile(destPath: string, name: string, descriptio
|
|
|
138
138
|
destPath,
|
|
139
139
|
camelize(capitalize(capitalize(name, "-"), " ")),
|
|
140
140
|
`tsParticles ${description} Shape`,
|
|
141
|
-
"loadParticlesShape"
|
|
141
|
+
"loadParticlesShape",
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -153,7 +153,7 @@ export async function createShapeTemplate(
|
|
|
153
153
|
name: string,
|
|
154
154
|
description: string,
|
|
155
155
|
repoUrl: string,
|
|
156
|
-
destPath: string
|
|
156
|
+
destPath: string,
|
|
157
157
|
): Promise<void> {
|
|
158
158
|
const sourcePath = path.resolve(__dirname, "..", "..", "..", "files", "create-shape");
|
|
159
159
|
|
|
@@ -15,7 +15,7 @@ export async function updatePackageFile(
|
|
|
15
15
|
packageName: string,
|
|
16
16
|
description: string,
|
|
17
17
|
fileName: string,
|
|
18
|
-
repoUrl: string
|
|
18
|
+
repoUrl: string,
|
|
19
19
|
): Promise<void> {
|
|
20
20
|
const packagePath = path.resolve(destPath, "package.json"),
|
|
21
21
|
packageContents = await fs.readFile(packagePath, "utf-8"),
|
|
@@ -48,7 +48,7 @@ export async function updatePackageDistFile(
|
|
|
48
48
|
packageName: string,
|
|
49
49
|
description: string,
|
|
50
50
|
fileName: string,
|
|
51
|
-
repoUrl: string
|
|
51
|
+
repoUrl: string,
|
|
52
52
|
): Promise<void> {
|
|
53
53
|
const packagePath = path.resolve(destPath, "package.dist.json"),
|
|
54
54
|
packageContents = await fs.readFile(packagePath, "utf-8"),
|
|
@@ -79,7 +79,7 @@ export async function updateWebpackFile(
|
|
|
79
79
|
destPath: string,
|
|
80
80
|
name: string,
|
|
81
81
|
description: string,
|
|
82
|
-
fnName: string
|
|
82
|
+
fnName: string,
|
|
83
83
|
): Promise<void> {
|
|
84
84
|
const webpackPath = path.resolve(destPath, "webpack.config.js"),
|
|
85
85
|
webpack = await fs.readFile(webpackPath, "utf-8"),
|
|
@@ -112,11 +112,7 @@ export async function copyEmptyTemplateFiles(destPath: string): Promise<void> {
|
|
|
112
112
|
* @returns true if the file should be copied
|
|
113
113
|
*/
|
|
114
114
|
export function copyFilter(src: string): boolean {
|
|
115
|
-
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return true;
|
|
115
|
+
return !(src.endsWith("node_modules") || src.endsWith("dist"));
|
|
120
116
|
}
|
|
121
117
|
|
|
122
118
|
/**
|