@tsparticles/cli 2.0.0-beta.3 → 2.0.0-beta.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.
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prettifyReadme = exports.prettifySrc = void 0;
|
|
6
|
+
exports.prettifyReadme = exports.prettifyPackageDistJson = exports.prettifyPackageJson = exports.prettifySrc = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const klaw_1 = __importDefault(require("klaw"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -47,6 +47,72 @@ async function prettifySrc(basePath, srcPath, ci) {
|
|
|
47
47
|
return res;
|
|
48
48
|
}
|
|
49
49
|
exports.prettifySrc = prettifySrc;
|
|
50
|
+
/**
|
|
51
|
+
* @param basePath -
|
|
52
|
+
* @param ci -
|
|
53
|
+
* @returns true if the prettify package.json process was successful
|
|
54
|
+
*/
|
|
55
|
+
async function prettifyPackageJson(basePath, ci) {
|
|
56
|
+
console.log("Prettier - started on package.json");
|
|
57
|
+
let res;
|
|
58
|
+
try {
|
|
59
|
+
const contents = await fs_extra_1.default.readFile("package.json", "utf8"), options = (await prettier_1.default.resolveConfig(basePath)) ?? {};
|
|
60
|
+
options.tabWidth = 2;
|
|
61
|
+
options.printWidth = 120;
|
|
62
|
+
options.endOfLine = "lf";
|
|
63
|
+
options.parser = "json";
|
|
64
|
+
if (ci) {
|
|
65
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
66
|
+
throw new Error(`pacakge.json is not formatted correctly`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
71
|
+
await fs_extra_1.default.writeFile("pacakge.json", formatted, "utf8");
|
|
72
|
+
}
|
|
73
|
+
res = true;
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.error(e);
|
|
77
|
+
res = false;
|
|
78
|
+
}
|
|
79
|
+
console.log("Prettier - done on pacakge.json");
|
|
80
|
+
return res;
|
|
81
|
+
}
|
|
82
|
+
exports.prettifyPackageJson = prettifyPackageJson;
|
|
83
|
+
/**
|
|
84
|
+
* @param basePath -
|
|
85
|
+
* @param ci -
|
|
86
|
+
* @returns true if the prettify package.dist.json process was successful
|
|
87
|
+
*/
|
|
88
|
+
async function prettifyPackageDistJson(basePath, ci) {
|
|
89
|
+
console.log("Prettier - started on package.dist.json");
|
|
90
|
+
let res;
|
|
91
|
+
try {
|
|
92
|
+
const contents = await fs_extra_1.default.readFile("package.dist.json", "utf8"), options = (await prettier_1.default.resolveConfig(basePath)) ?? {};
|
|
93
|
+
options.tabWidth = 2;
|
|
94
|
+
options.printWidth = 120;
|
|
95
|
+
options.endOfLine = "lf";
|
|
96
|
+
options.parser = "json";
|
|
97
|
+
if (ci) {
|
|
98
|
+
if (!(await prettier_1.default.check(contents, options))) {
|
|
99
|
+
throw new Error(`package.dist.json is not formatted correctly`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const formatted = await prettier_1.default.format(contents, options);
|
|
104
|
+
await fs_extra_1.default.writeFile("pacakge.dist.json", formatted, "utf8");
|
|
105
|
+
}
|
|
106
|
+
res = true;
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
console.error(e);
|
|
110
|
+
res = false;
|
|
111
|
+
}
|
|
112
|
+
console.log("Prettier - done on pacakge.dist.json");
|
|
113
|
+
return res;
|
|
114
|
+
}
|
|
115
|
+
exports.prettifyPackageDistJson = prettifyPackageDistJson;
|
|
50
116
|
/**
|
|
51
117
|
* @param basePath -
|
|
52
118
|
* @param ci -
|
package/dist/build/build.js
CHANGED
|
@@ -51,6 +51,8 @@ buildCommand.action(async (argPath) => {
|
|
|
51
51
|
}
|
|
52
52
|
if (canContinue && prettier) {
|
|
53
53
|
canContinue = await (0, build_prettier_1.prettifyReadme)(basePath, ci);
|
|
54
|
+
canContinue = await (0, build_prettier_1.prettifyPackageJson)(basePath, ci);
|
|
55
|
+
canContinue = await (0, build_prettier_1.prettifyPackageDistJson)(basePath, ci);
|
|
54
56
|
}
|
|
55
57
|
if (canContinue && distfiles) {
|
|
56
58
|
canContinue = await (0, build_distfiles_1.buildDistFiles)(basePath);
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"prettier": "@tsparticles/prettier-config",
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/core": "^7.22.9",
|
|
86
|
-
"@tsparticles/cli": "^2.0.0-beta.
|
|
86
|
+
"@tsparticles/cli": "^2.0.0-beta.4",
|
|
87
87
|
"@tsparticles/eslint-config": "^1.19.0",
|
|
88
88
|
"@tsparticles/prettier-config": "^1.12.0",
|
|
89
89
|
"@tsparticles/tsconfig": "^1.14.0",
|
package/package.json
CHANGED
|
@@ -51,6 +51,88 @@ export async function prettifySrc(basePath: string, srcPath: string, ci: boolean
|
|
|
51
51
|
return res;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @param basePath -
|
|
56
|
+
* @param ci -
|
|
57
|
+
* @returns true if the prettify package.json process was successful
|
|
58
|
+
*/
|
|
59
|
+
export async function prettifyPackageJson(basePath: string, ci: boolean): Promise<boolean> {
|
|
60
|
+
console.log("Prettier - started on package.json");
|
|
61
|
+
|
|
62
|
+
let res: boolean;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const contents = await fs.readFile("package.json", "utf8"),
|
|
66
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
67
|
+
|
|
68
|
+
options.tabWidth = 2;
|
|
69
|
+
options.printWidth = 120;
|
|
70
|
+
options.endOfLine = "lf";
|
|
71
|
+
options.parser = "json";
|
|
72
|
+
|
|
73
|
+
if (ci) {
|
|
74
|
+
if (!(await prettier.check(contents, options))) {
|
|
75
|
+
throw new Error(`pacakge.json is not formatted correctly`);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
const formatted = await prettier.format(contents, options);
|
|
79
|
+
|
|
80
|
+
await fs.writeFile("pacakge.json", formatted, "utf8");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
res = true;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.error(e);
|
|
86
|
+
|
|
87
|
+
res = false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log("Prettier - done on pacakge.json");
|
|
91
|
+
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param basePath -
|
|
97
|
+
* @param ci -
|
|
98
|
+
* @returns true if the prettify package.dist.json process was successful
|
|
99
|
+
*/
|
|
100
|
+
export async function prettifyPackageDistJson(basePath: string, ci: boolean): Promise<boolean> {
|
|
101
|
+
console.log("Prettier - started on package.dist.json");
|
|
102
|
+
|
|
103
|
+
let res: boolean;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const contents = await fs.readFile("package.dist.json", "utf8"),
|
|
107
|
+
options = (await prettier.resolveConfig(basePath)) ?? {};
|
|
108
|
+
|
|
109
|
+
options.tabWidth = 2;
|
|
110
|
+
options.printWidth = 120;
|
|
111
|
+
options.endOfLine = "lf";
|
|
112
|
+
options.parser = "json";
|
|
113
|
+
|
|
114
|
+
if (ci) {
|
|
115
|
+
if (!(await prettier.check(contents, options))) {
|
|
116
|
+
throw new Error(`package.dist.json is not formatted correctly`);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
const formatted = await prettier.format(contents, options);
|
|
120
|
+
|
|
121
|
+
await fs.writeFile("pacakge.dist.json", formatted, "utf8");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
res = true;
|
|
125
|
+
} catch (e) {
|
|
126
|
+
console.error(e);
|
|
127
|
+
|
|
128
|
+
res = false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log("Prettier - done on pacakge.dist.json");
|
|
132
|
+
|
|
133
|
+
return res;
|
|
134
|
+
}
|
|
135
|
+
|
|
54
136
|
/**
|
|
55
137
|
* @param basePath -
|
|
56
138
|
* @param ci -
|
package/src/build/build.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prettifyReadme, prettifySrc } from "./build-prettier";
|
|
1
|
+
import { prettifyPackageDistJson, prettifyPackageJson, prettifyReadme, prettifySrc } from "./build-prettier";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { buildDistFiles } from "./build-distfiles";
|
|
4
4
|
import { buildTS } from "./build-tsc";
|
|
@@ -74,6 +74,8 @@ buildCommand.action(async (argPath: string) => {
|
|
|
74
74
|
|
|
75
75
|
if (canContinue && prettier) {
|
|
76
76
|
canContinue = await prettifyReadme(basePath, ci);
|
|
77
|
+
canContinue = await prettifyPackageJson(basePath, ci);
|
|
78
|
+
canContinue = await prettifyPackageDistJson(basePath, ci);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
if (canContinue && distfiles) {
|