@tsparticles/cli 1.6.3 → 1.6.4
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.js +16 -16
- package/dist/cli.js +4 -4
- package/dist/create/create.js +2 -2
- package/dist/create/preset/create-preset.js +14 -14
- package/dist/create/preset/preset.js +4 -4
- package/files/empty-project/package.json +1 -1
- package/package.json +3 -4
- package/src/build/build.ts +7 -7
- package/src/cli.ts +2 -2
- package/src/create/create.ts +1 -1
- package/src/create/preset/create-preset.ts +2 -2
- package/src/create/preset/preset.ts +2 -2
package/dist/build/build.js
CHANGED
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildCommand = void 0;
|
|
7
|
-
const
|
|
7
|
+
const build_prettier_1 = require("./build-prettier");
|
|
8
8
|
const commander_1 = require("commander");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
9
|
+
const build_distfiles_1 = require("./build-distfiles");
|
|
10
|
+
const build_tsc_1 = require("./build-tsc");
|
|
11
|
+
const build_bundle_1 = require("./build-bundle");
|
|
12
|
+
const build_clear_1 = require("./build-clear");
|
|
13
13
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const build_diststats_1 = require("./build-diststats");
|
|
15
|
+
const build_eslint_1 = require("./build-eslint");
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const buildCommand = new commander_1.Command("build");
|
|
18
18
|
exports.buildCommand = buildCommand;
|
|
@@ -28,9 +28,9 @@ buildCommand.option("-t, --tsc", "Build the library using TypeScript", false);
|
|
|
28
28
|
buildCommand.argument("[path]", `Path to the project root folder, default is "src"`, "src");
|
|
29
29
|
buildCommand.action(async (argPath) => {
|
|
30
30
|
const opts = buildCommand.opts(), ci = !!opts.ci, all = !!opts.all, doBundle = all || !!opts.bundle, clean = all || !!opts.clean, distfiles = all || !!opts.dist, doLint = all || !!opts.lint, prettier = all || !!opts.prettify, tsc = all || !!opts.tsc;
|
|
31
|
-
const basePath = process.cwd(), oldStats = await (0,
|
|
31
|
+
const basePath = process.cwd(), oldStats = await (0, build_diststats_1.getDistStats)(basePath);
|
|
32
32
|
if (clean) {
|
|
33
|
-
await (0,
|
|
33
|
+
await (0, build_clear_1.clearDist)(basePath);
|
|
34
34
|
}
|
|
35
35
|
const srcPath = path_1.default.join(basePath, argPath);
|
|
36
36
|
if (!(await fs_extra_1.default.pathExists(srcPath))) {
|
|
@@ -38,27 +38,27 @@ buildCommand.action(async (argPath) => {
|
|
|
38
38
|
}
|
|
39
39
|
let canContinue = true;
|
|
40
40
|
if (canContinue && prettier) {
|
|
41
|
-
canContinue = await (0,
|
|
41
|
+
canContinue = await (0, build_prettier_1.prettifySrc)(basePath, srcPath, ci);
|
|
42
42
|
}
|
|
43
43
|
if (canContinue && doLint) {
|
|
44
|
-
canContinue = await (0,
|
|
44
|
+
canContinue = await (0, build_eslint_1.lint)(ci);
|
|
45
45
|
}
|
|
46
46
|
if (canContinue && tsc) {
|
|
47
|
-
canContinue = await (0,
|
|
47
|
+
canContinue = await (0, build_tsc_1.buildTS)(basePath);
|
|
48
48
|
}
|
|
49
49
|
if (canContinue && doBundle) {
|
|
50
|
-
canContinue = await (0,
|
|
50
|
+
canContinue = await (0, build_bundle_1.bundle)(basePath);
|
|
51
51
|
}
|
|
52
52
|
if (canContinue && prettier) {
|
|
53
|
-
canContinue = await (0,
|
|
53
|
+
canContinue = await (0, build_prettier_1.prettifyReadme)(basePath, ci);
|
|
54
54
|
}
|
|
55
55
|
if (canContinue && distfiles) {
|
|
56
|
-
canContinue = await (0,
|
|
56
|
+
canContinue = await (0, build_distfiles_1.buildDistFiles)(basePath);
|
|
57
57
|
}
|
|
58
58
|
if (!canContinue) {
|
|
59
59
|
throw new Error("Build failed");
|
|
60
60
|
}
|
|
61
|
-
const newStats = await (0,
|
|
61
|
+
const newStats = await (0, build_diststats_1.getDistStats)(basePath), diffSize = newStats.totalSize - oldStats.totalSize, bundleDiffSize = newStats.bundleSize - oldStats.bundleSize, bundleSizeIncreased = bundleDiffSize > 0, outputFunc = bundleSizeIncreased ? console.warn : console.info, texts = [
|
|
62
62
|
!bundleDiffSize
|
|
63
63
|
? "Bundle size unchanged"
|
|
64
64
|
: `Bundle size ${bundleSizeIncreased ? "increased" : "decreased"} from ${oldStats.bundleSize} to ${newStats.bundleSize} (${Math.abs(bundleDiffSize)}B)`,
|
package/dist/cli.js
CHANGED
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const build_1 = require("./build/build");
|
|
8
|
+
const create_1 = require("./create/create");
|
|
9
9
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
10
10
|
const commander_1 = require("commander");
|
|
11
11
|
commander_1.program.name("tsparticles-cli build");
|
|
12
12
|
commander_1.program.description("tsParticles Builder");
|
|
13
13
|
commander_1.program.version(package_json_1.default.version, "-v, --version", "output the current version");
|
|
14
|
-
commander_1.program.addCommand(
|
|
15
|
-
commander_1.program.addCommand(
|
|
14
|
+
commander_1.program.addCommand(build_1.buildCommand);
|
|
15
|
+
commander_1.program.addCommand(create_1.createCommand);
|
|
16
16
|
commander_1.program.parse(process.argv);
|
package/dist/create/create.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCommand = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
|
-
const
|
|
5
|
+
const preset_1 = require("./preset/preset");
|
|
6
6
|
const createCommand = new commander_1.Command("create");
|
|
7
7
|
exports.createCommand = createCommand;
|
|
8
8
|
createCommand.description("Create a new tsParticles project");
|
|
9
|
-
createCommand.addCommand(
|
|
9
|
+
createCommand.addCommand(preset_1.presetCommand);
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createPresetTemplate = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const string_utils_1 = require("../../utils/string-utils");
|
|
8
|
+
const template_utils_1 = require("../../utils/template-utils");
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
/**
|
|
@@ -14,7 +14,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
14
14
|
* @param name - The name of the project
|
|
15
15
|
*/
|
|
16
16
|
async function updateBundleFile(destPath, name) {
|
|
17
|
-
const bundlePath = path_1.default.resolve(destPath, "src", "bundle.ts"), bundle = await fs_extra_1.default.readFile(bundlePath, "utf-8"), capitalizedName = (0,
|
|
17
|
+
const bundlePath = path_1.default.resolve(destPath, "src", "bundle.ts"), bundle = await fs_extra_1.default.readFile(bundlePath, "utf-8"), capitalizedName = (0, string_utils_1.capitalize)((0, string_utils_1.capitalize)(name, "-"), " "), bundleRegex = /loadTemplatePreset/g, replacedText = bundle.replace(bundleRegex, `load${capitalizedName}Preset`);
|
|
18
18
|
await fs_extra_1.default.writeFile(bundlePath, replacedText);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -23,7 +23,7 @@ async function updateBundleFile(destPath, name) {
|
|
|
23
23
|
* @param name - The name of the project
|
|
24
24
|
*/
|
|
25
25
|
async function updateIndexFile(destPath, name) {
|
|
26
|
-
const indexPath = path_1.default.resolve(destPath, "src", "index.ts"), index = await fs_extra_1.default.readFile(indexPath, "utf-8"), capitalizedName = (0,
|
|
26
|
+
const indexPath = path_1.default.resolve(destPath, "src", "index.ts"), index = await fs_extra_1.default.readFile(indexPath, "utf-8"), capitalizedName = (0, string_utils_1.capitalize)((0, string_utils_1.capitalize)(name, "-"), " "), camelizedName = (0, string_utils_1.camelize)(capitalizedName), indexFunctionRegex = /loadTemplatePreset/g, replacedFuncText = index.replace(indexFunctionRegex, `load${capitalizedName}Preset`), indexNameRegex = /"#template#"/g, replacedNameText = replacedFuncText.replace(indexNameRegex, `"${camelizedName}"`);
|
|
27
27
|
await fs_extra_1.default.writeFile(indexPath, replacedNameText);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -34,8 +34,8 @@ async function updateIndexFile(destPath, name) {
|
|
|
34
34
|
* @param repoUrl - The repository url
|
|
35
35
|
*/
|
|
36
36
|
async function updatePresetPackageFile(destPath, name, description, repoUrl) {
|
|
37
|
-
const camelizedName = (0,
|
|
38
|
-
(0,
|
|
37
|
+
const camelizedName = (0, string_utils_1.camelize)((0, string_utils_1.camelize)(name, "-"), " "), dashedName = (0, string_utils_1.dash)(camelizedName);
|
|
38
|
+
(0, template_utils_1.updatePackageFile)(destPath, `"tsparticles-preset-${dashedName}"`, description, `"tsparticles.preset.${camelizedName}.min.js"`, repoUrl);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Updates the preset package dist file
|
|
@@ -45,8 +45,8 @@ async function updatePresetPackageFile(destPath, name, description, repoUrl) {
|
|
|
45
45
|
* @param repoUrl - The repository url
|
|
46
46
|
*/
|
|
47
47
|
async function updatePresetPackageDistFile(destPath, name, description, repoUrl) {
|
|
48
|
-
const camelizedName = (0,
|
|
49
|
-
(0,
|
|
48
|
+
const camelizedName = (0, string_utils_1.camelize)((0, string_utils_1.camelize)(name, "-"), " "), dashedName = (0, string_utils_1.dash)(camelizedName);
|
|
49
|
+
(0, template_utils_1.updatePackageDistFile)(destPath, `"tsparticles-preset-${dashedName}"`, description, `"tsparticles.preset.${camelizedName}.min.js"`, repoUrl);
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
52
|
* Updates the preset readme file
|
|
@@ -56,7 +56,7 @@ async function updatePresetPackageDistFile(destPath, name, description, repoUrl)
|
|
|
56
56
|
* @param repoUrl - The repository url
|
|
57
57
|
*/
|
|
58
58
|
async function updateReadmeFile(destPath, name, description, repoUrl) {
|
|
59
|
-
const readmePath = path_1.default.resolve(destPath, "README.md"), readme = await fs_extra_1.default.readFile(readmePath, "utf-8"), capitalizedName = (0,
|
|
59
|
+
const readmePath = path_1.default.resolve(destPath, "README.md"), readme = await fs_extra_1.default.readFile(readmePath, "utf-8"), capitalizedName = (0, string_utils_1.capitalize)((0, string_utils_1.capitalize)(name, "-"), " "), camelizedName = (0, string_utils_1.camelize)(capitalizedName), dashedName = (0, string_utils_1.dash)(camelizedName), readmeDescriptionRegex = /tsParticles Template Preset/g, replacedDescriptionText = readme.replace(readmeDescriptionRegex, `tsParticles ${description} Preset`), readmePackageNameRegex = /tsparticles-preset-template/g, replacedPackageNameText = replacedDescriptionText.replace(readmePackageNameRegex, `tsparticles-preset-${dashedName}`), readmeFileNameRegex = /tsparticles\.preset\.template(\.bundle)?\.min\.js/g, replacedFileNameText = replacedPackageNameText.replace(readmeFileNameRegex, `tsparticles.preset.${camelizedName}$1.min.js`), readmeFunctionNameRegex = /loadTemplatePreset/g, replacedFunctionNameText = replacedFileNameText.replace(readmeFunctionNameRegex, `load${capitalizedName}Preset`), readmeMiniDescriptionRegex = /\[tsParticles]\(https:\/\/github.com\/matteobruni\/tsparticles\) preset template\./g, replacedMiniDescriptionText = replacedFunctionNameText.replace(readmeMiniDescriptionRegex, `[tsParticles](https://github.com/matteobruni/tsparticles) preset ${name}.`), readmeUsageRegex = /preset: "template"/g, replacedUsageText = replacedMiniDescriptionText.replace(readmeUsageRegex, `preset: "${camelizedName}`), sampleImageRegex = /!\[demo]\(https:\/\/raw.githubusercontent.com\/tsparticles\/preset-template\/main\/images\/sample.png\)/g, repoPath = repoUrl.includes("github.com")
|
|
60
60
|
? repoUrl.substring(repoUrl.indexOf("github.com/") + 11, repoUrl.indexOf(".git"))
|
|
61
61
|
: "tsparticles/preset-template", replacedText = replacedUsageText.replace(sampleImageRegex, ``);
|
|
62
62
|
await fs_extra_1.default.writeFile(readmePath, replacedText);
|
|
@@ -68,7 +68,7 @@ async function updateReadmeFile(destPath, name, description, repoUrl) {
|
|
|
68
68
|
* @param description - The description of the project
|
|
69
69
|
*/
|
|
70
70
|
async function updatePresetWebpackFile(destPath, name, description) {
|
|
71
|
-
await (0,
|
|
71
|
+
await (0, template_utils_1.updateWebpackFile)(destPath, (0, string_utils_1.camelize)((0, string_utils_1.capitalize)((0, string_utils_1.capitalize)(name, "-"), " ")), `tsParticles ${description} Preset`, "loadParticlesPreset");
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Creates the preset project
|
|
@@ -79,10 +79,10 @@ async function updatePresetWebpackFile(destPath, name, description) {
|
|
|
79
79
|
*/
|
|
80
80
|
async function createPresetTemplate(name, description, repoUrl, destPath) {
|
|
81
81
|
const sourcePath = path_1.default.resolve(__dirname, "..", "..", "..", "files", "create-preset");
|
|
82
|
-
await (0,
|
|
82
|
+
await (0, template_utils_1.copyEmptyTemplateFiles)(destPath);
|
|
83
83
|
await fs_extra_1.default.copy(sourcePath, destPath, {
|
|
84
84
|
overwrite: true,
|
|
85
|
-
filter:
|
|
85
|
+
filter: template_utils_1.copyFilter,
|
|
86
86
|
});
|
|
87
87
|
await updateBundleFile(destPath, name);
|
|
88
88
|
await updateIndexFile(destPath, name);
|
|
@@ -90,7 +90,7 @@ async function createPresetTemplate(name, description, repoUrl, destPath) {
|
|
|
90
90
|
await updatePresetPackageDistFile(destPath, name, description, repoUrl);
|
|
91
91
|
await updateReadmeFile(destPath, name, description, repoUrl);
|
|
92
92
|
await updatePresetWebpackFile(destPath, name, description);
|
|
93
|
-
(0,
|
|
94
|
-
(0,
|
|
93
|
+
(0, template_utils_1.runInstall)(destPath);
|
|
94
|
+
(0, template_utils_1.runBuild)(destPath);
|
|
95
95
|
}
|
|
96
96
|
exports.createPresetTemplate = createPresetTemplate;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.presetCommand = void 0;
|
|
7
7
|
const prompts_1 = __importDefault(require("prompts"));
|
|
8
8
|
const commander_1 = require("commander");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const string_utils_1 = require("../../utils/string-utils");
|
|
10
|
+
const create_preset_1 = require("./create-preset");
|
|
11
11
|
const child_process_1 = require("child_process");
|
|
12
12
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
13
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -44,7 +44,7 @@ presetCommand.action(async (destination) => {
|
|
|
44
44
|
name: "description",
|
|
45
45
|
message: "What is the description of the preset?",
|
|
46
46
|
validate: (value) => (value ? true : "The description can't be empty"),
|
|
47
|
-
initial: (0,
|
|
47
|
+
initial: (0, string_utils_1.capitalize)(initialName || ""),
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
type: "text",
|
|
@@ -54,5 +54,5 @@ presetCommand.action(async (destination) => {
|
|
|
54
54
|
},
|
|
55
55
|
];
|
|
56
56
|
const { name, description, repositoryUrl } = await (0, prompts_1.default)(questions);
|
|
57
|
-
(0,
|
|
57
|
+
(0, create_preset_1.createPresetTemplate)(name.trim(), description.trim(), repositoryUrl.trim(), destPath);
|
|
58
58
|
});
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"prettier": "@tsparticles/prettier-config",
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/core": "^7.22.5",
|
|
86
|
-
"@tsparticles/cli": "1.6.
|
|
86
|
+
"@tsparticles/cli": "1.6.4",
|
|
87
87
|
"@tsparticles/eslint-config": "^1.13.0",
|
|
88
88
|
"@tsparticles/prettier-config": "^1.10.0",
|
|
89
89
|
"@tsparticles/tsconfig": "^1.13.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/cli",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsparticles-cli": "dist/cli.js"
|
|
@@ -10,16 +10,15 @@
|
|
|
10
10
|
},
|
|
11
11
|
"prettier": "@tsparticles/prettier-config",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tsparticles/eslint-config": "^1.13.
|
|
13
|
+
"@tsparticles/eslint-config": "^1.13.3",
|
|
14
14
|
"@tsparticles/prettier-config": "^1.10.0",
|
|
15
15
|
"@tsparticles/tsconfig": "^1.13.0",
|
|
16
|
-
"@tsparticles/webpack-plugin": "^1.15.
|
|
16
|
+
"@tsparticles/webpack-plugin": "^1.15.5",
|
|
17
17
|
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
18
18
|
"@typescript-eslint/parser": "^5.60.0",
|
|
19
19
|
"commander": "^11.0.0",
|
|
20
20
|
"eslint": "^8.43.0",
|
|
21
21
|
"eslint-config-prettier": "^8.8.0",
|
|
22
|
-
"eslint-plugin-import": "^2.27.5",
|
|
23
22
|
"eslint-plugin-jsdoc": "^46.2.6",
|
|
24
23
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
25
24
|
"fs-extra": "^11.1.1",
|
package/src/build/build.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { prettifyReadme, prettifySrc } from "./build-prettier
|
|
1
|
+
import { prettifyReadme, prettifySrc } from "./build-prettier";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { buildDistFiles } from "./build-distfiles
|
|
4
|
-
import { buildTS } from "./build-tsc
|
|
5
|
-
import { bundle } from "./build-bundle
|
|
6
|
-
import { clearDist } from "./build-clear
|
|
3
|
+
import { buildDistFiles } from "./build-distfiles";
|
|
4
|
+
import { buildTS } from "./build-tsc";
|
|
5
|
+
import { bundle } from "./build-bundle";
|
|
6
|
+
import { clearDist } from "./build-clear";
|
|
7
7
|
import fs from "fs-extra";
|
|
8
|
-
import { getDistStats } from "./build-diststats
|
|
9
|
-
import { lint } from "./build-eslint
|
|
8
|
+
import { getDistStats } from "./build-diststats";
|
|
9
|
+
import { lint } from "./build-eslint";
|
|
10
10
|
import path from "path";
|
|
11
11
|
|
|
12
12
|
const buildCommand = new Command("build");
|
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { buildCommand } from "./build/build
|
|
3
|
-
import { createCommand } from "./create/create
|
|
2
|
+
import { buildCommand } from "./build/build";
|
|
3
|
+
import { createCommand } from "./create/create";
|
|
4
4
|
import pkgInfo from "../package.json";
|
|
5
5
|
import { program } from "commander";
|
|
6
6
|
|
package/src/create/create.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelize, capitalize, dash } from "../../utils/string-utils
|
|
1
|
+
import { camelize, capitalize, dash } from "../../utils/string-utils";
|
|
2
2
|
import {
|
|
3
3
|
copyEmptyTemplateFiles,
|
|
4
4
|
copyFilter,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
updatePackageDistFile,
|
|
8
8
|
updatePackageFile,
|
|
9
9
|
updateWebpackFile,
|
|
10
|
-
} from "../../utils/template-utils
|
|
10
|
+
} from "../../utils/template-utils";
|
|
11
11
|
import fs from "fs-extra";
|
|
12
12
|
import path from "path";
|
|
13
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import prompts, { type PromptObject } from "prompts";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { capitalize } from "../../utils/string-utils
|
|
4
|
-
import { createPresetTemplate } from "./create-preset
|
|
3
|
+
import { capitalize } from "../../utils/string-utils";
|
|
4
|
+
import { createPresetTemplate } from "./create-preset";
|
|
5
5
|
import { execSync } from "child_process";
|
|
6
6
|
import fs from "fs-extra";
|
|
7
7
|
import path from "path";
|