@tsparticles/cli 3.1.7 → 3.2.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.
Files changed (44) hide show
  1. package/.github/workflows/node.js-ci.yml +0 -2
  2. package/.planning/PROJECT.md +43 -0
  3. package/.planning/REQUIREMENTS.md +41 -0
  4. package/.planning/ROADMAP.md +41 -0
  5. package/.planning/STATE.md +6 -0
  6. package/.planning/codebase/ARCHITECTURE.md +3 -0
  7. package/.planning/codebase/CONCERNS.md +3 -0
  8. package/.planning/codebase/CONVENTIONS.md +3 -0
  9. package/.planning/codebase/INTEGRATIONS.md +3 -0
  10. package/.planning/codebase/STACK.md +11 -0
  11. package/.planning/codebase/STRUCTURE.md +3 -0
  12. package/.planning/codebase/TESTING.md +3 -0
  13. package/.planning/config.json +1 -0
  14. package/.planning/research/ARCHITECTURE.md +1 -0
  15. package/.planning/research/FEATURES.md +1 -0
  16. package/.planning/research/PITFALLS.md +1 -0
  17. package/.planning/research/STACK.md +1 -0
  18. package/.planning/research/SUMMARY.md +9 -0
  19. package/dist/build/build-bundle.d.ts +2 -1
  20. package/dist/build/build-bundle.js +8 -3
  21. package/dist/build/build-circular-deps.d.ts +2 -1
  22. package/dist/build/build-circular-deps.js +8 -3
  23. package/dist/build/build-clear.d.ts +2 -1
  24. package/dist/build/build-clear.js +8 -3
  25. package/dist/build/build-distfiles.d.ts +2 -1
  26. package/dist/build/build-distfiles.js +11 -4
  27. package/dist/build/build-eslint.d.ts +2 -1
  28. package/dist/build/build-eslint.js +8 -3
  29. package/dist/build/build-prettier.d.ts +8 -4
  30. package/dist/build/build-prettier.js +50 -19
  31. package/dist/build/build-tsc.d.ts +2 -1
  32. package/dist/build/build-tsc.js +17 -7
  33. package/dist/build/build.js +32 -24
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/files/empty-project/package.json +3 -3
  36. package/package.json +5 -5
  37. package/src/build/build-bundle.ts +8 -3
  38. package/src/build/build-circular-deps.ts +8 -3
  39. package/src/build/build-clear.ts +8 -3
  40. package/src/build/build-distfiles.ts +11 -4
  41. package/src/build/build-eslint.ts +8 -3
  42. package/src/build/build-prettier.ts +50 -19
  43. package/src/build/build-tsc.ts +21 -7
  44. package/src/build/build.ts +36 -21
@@ -24,9 +24,10 @@ async function readConfig(basePath, file) {
24
24
  /**
25
25
  * @param basePath -
26
26
  * @param type -
27
+ * @param silent -
27
28
  * @returns the exit code
28
29
  */
29
- async function compile(basePath, type) {
30
+ async function compile(basePath, type, silent) {
30
31
  let options, data;
31
32
  switch (type) {
32
33
  case "browser":
@@ -121,25 +122,34 @@ async function compile(basePath, type) {
121
122
  }
122
123
  }
123
124
  const exitCode = emitResult.emitSkipped || failed ? ExitCodes.EmitErrors : ExitCodes.OK;
124
- console.log(`TSC for ${type} done with exit code: '${exitCode.toLocaleString()}'.`);
125
+ if (!silent || exitCode) {
126
+ console.log(`TSC for ${type} done with exit code: '${exitCode.toLocaleString()}'.`);
127
+ }
125
128
  return exitCode;
126
129
  }
127
130
  /**
128
131
  * @param basePath -
132
+ * @param silent -
129
133
  * @returns true if the build was successful
130
134
  */
131
- export async function buildTS(basePath) {
132
- console.log("Building TS files");
135
+ export async function buildTS(basePath, silent) {
136
+ if (!silent) {
137
+ console.log("Building TS files");
138
+ }
133
139
  let res = true;
134
140
  const types = ["browser", "cjs", "esm", "types", "umd"];
135
141
  for (const type of types) {
136
- console.log(`Building TS files for ${type} configuration`);
137
- const exitCode = await compile(basePath, type);
142
+ if (!silent) {
143
+ console.log(`Building TS files for ${type} configuration`);
144
+ }
145
+ const exitCode = await compile(basePath, type, silent);
138
146
  if (exitCode) {
139
147
  res = false;
140
148
  break;
141
149
  }
142
150
  }
143
- console.log("Building TS files done");
151
+ if (!silent) {
152
+ console.log("Building TS files done");
153
+ }
144
154
  return res;
145
155
  }
@@ -4,19 +4,20 @@ buildCommand.description("Build the tsParticles library using TypeScript");
4
4
  buildCommand.option("-a, --all", "Do all build steps (default if no flags are specified) (same as -b -c -d -l -p -t)", false);
5
5
  buildCommand.option("-b, --bundle", "Bundle the library using Webpack", false);
6
6
  buildCommand.option("-c, --clean", "Clean the dist folder", false);
7
- buildCommand.option("--ci", "Do all build steps for CI, no fixing files, only checking if they are formatted correctly", false);
7
+ buildCommand.option("--ci", "Do all build steps for CI, no fixing files, only checking if they are formatted correctly, sets silent to true by default", false);
8
8
  buildCommand.option("-r, --circular-deps", "Check for circular dependencies", false);
9
9
  buildCommand.option("-d, --dist", "Build the dist files", false);
10
10
  buildCommand.option("-l, --lint", "Lint the source files", false);
11
11
  buildCommand.option("-p, --prettify", "Prettify the source files", false);
12
+ buildCommand.option("-s, --silent <boolean>", "Reduce the amount of output during the build, defaults to false, except when --ci is set", false);
12
13
  buildCommand.option("-t, --tsc", "Build the library using TypeScript", false);
13
14
  buildCommand.argument("[path]", `Path to the project root folder, default is "src"`, "src");
14
15
  buildCommand.action(async (argPath) => {
15
16
  const opts = buildCommand.opts(), ci = !!opts["ci"], all = !!opts["all"] ||
16
- (!opts["bundle"] && !opts["clean"] && !opts["dist"] && !opts["lint"] && !opts["prettify"] && !opts["tsc"]), doBundle = all || !!opts["bundle"], circularDeps = all || !!opts["circularDeps"], clean = all || !!opts["clean"], distfiles = all || !!opts["dist"], doLint = all || !!opts["lint"], prettier = all || !!opts["prettify"], tsc = all || !!opts["tsc"], basePath = process.cwd(), { getDistStats } = await import("./build-diststats.js"), oldStats = await getDistStats(basePath);
17
+ (!opts["bundle"] && !opts["clean"] && !opts["dist"] && !opts["lint"] && !opts["prettify"] && !opts["tsc"]), doBundle = all || !!opts["bundle"], circularDeps = all || !!opts["circularDeps"], clean = all || !!opts["clean"], distfiles = all || !!opts["dist"], doLint = all || !!opts["lint"], prettier = all || !!opts["prettify"], tsc = all || !!opts["tsc"], silent = !!opts["silent"] || ci, basePath = process.cwd(), { getDistStats } = await import("./build-diststats.js"), oldStats = await getDistStats(basePath);
17
18
  if (clean) {
18
19
  const { clearDist } = await import("./build-clear.js");
19
- await clearDist(basePath);
20
+ await clearDist(basePath, silent);
20
21
  }
21
22
  const path = await import("path"), srcPath = path.join(basePath, argPath), fs = await import("fs-extra");
22
23
  if (!(await fs.pathExists(srcPath))) {
@@ -25,51 +26,58 @@ buildCommand.action(async (argPath) => {
25
26
  let canContinue = true;
26
27
  if (prettier) {
27
28
  const { prettifySrc } = await import("./build-prettier.js");
28
- canContinue = await prettifySrc(basePath, srcPath, ci);
29
+ canContinue = await prettifySrc(basePath, srcPath, ci, silent);
29
30
  }
30
31
  if (canContinue && doLint) {
31
32
  const { lint } = await import("./build-eslint.js");
32
- canContinue = await lint(ci);
33
+ canContinue = await lint(ci, silent);
33
34
  }
34
35
  if (canContinue && tsc) {
35
36
  const { buildTS } = await import("./build-tsc.js");
36
- canContinue = await buildTS(basePath);
37
+ canContinue = await buildTS(basePath, silent);
37
38
  }
38
39
  if (canContinue && circularDeps) {
39
40
  const { buildCircularDeps } = await import("./build-circular-deps.js");
40
- canContinue = await buildCircularDeps(basePath);
41
+ canContinue = await buildCircularDeps(basePath, silent);
41
42
  }
42
43
  if (canContinue && doBundle) {
43
44
  const { bundle } = await import("./build-bundle.js");
44
- canContinue = await bundle(basePath);
45
+ canContinue = await bundle(basePath, silent);
45
46
  }
46
47
  if (canContinue && prettier) {
47
48
  const { prettifyReadme, prettifyPackageJson, prettifyPackageDistJson } = await import("./build-prettier.js");
48
49
  canContinue =
49
- (await prettifyReadme(basePath, ci)) &&
50
- (await prettifyPackageJson(basePath, ci)) &&
51
- (await prettifyPackageDistJson(basePath, ci));
50
+ (await prettifyReadme(basePath, ci, silent)) &&
51
+ (await prettifyPackageJson(basePath, ci, silent)) &&
52
+ (await prettifyPackageDistJson(basePath, ci, silent));
52
53
  }
53
54
  if (canContinue && distfiles) {
54
55
  const { buildDistFiles } = await import("./build-distfiles.js");
55
- canContinue = await buildDistFiles(basePath);
56
+ canContinue = await buildDistFiles(basePath, silent);
56
57
  }
57
58
  if (!canContinue) {
58
59
  throw new Error("Build failed");
59
60
  }
60
- const newStats = await getDistStats(basePath), diffSize = newStats.totalSize - oldStats.totalSize, bundleDiffSize = newStats.bundleSize - oldStats.bundleSize, minSize = 0, bundleSizeIncreased = bundleDiffSize > minSize, outputFunc = bundleSizeIncreased ? console.warn : console.info, bundleSizeIncreasedText = bundleSizeIncreased ? "increased" : "decreased", diffSizeIncreasedText = diffSize > minSize ? "increased" : "decreased", texts = [
61
- !bundleDiffSize
62
- ? "Bundle size unchanged"
63
- : `Bundle size ${bundleSizeIncreasedText} from ${oldStats.bundleSize.toString()} to ${newStats.bundleSize.toString()} (${Math.abs(bundleDiffSize).toString()}B)`,
64
- !diffSize
65
- ? "Size unchanged"
66
- : `Size ${diffSizeIncreasedText} from ${oldStats.totalSize.toString()} to ${newStats.totalSize.toString()} (${Math.abs(diffSize).toString()}B)`,
67
- `Files count changed from ${oldStats.totalFiles.toString()} to ${newStats.totalFiles.toString()} (${(newStats.totalFiles - oldStats.totalFiles).toString()})`,
68
- `Folders count changed from ${oldStats.totalFolders.toString()} to ${newStats.totalFolders.toString()} (${(newStats.totalFolders - oldStats.totalFolders).toString()})`,
69
- ];
61
+ let texts = [], outputFunc = console.info;
62
+ if (!silent) {
63
+ const newStats = await getDistStats(basePath), diffSize = newStats.totalSize - oldStats.totalSize, bundleDiffSize = newStats.bundleSize - oldStats.bundleSize, minSize = 0, bundleSizeIncreased = bundleDiffSize > minSize, bundleSizeIncreasedText = bundleSizeIncreased ? "increased" : "decreased", diffSizeIncreasedText = diffSize > minSize ? "increased" : "decreased";
64
+ outputFunc = bundleSizeIncreased ? console.warn : console.info;
65
+ texts = [
66
+ !bundleDiffSize
67
+ ? "Bundle size unchanged"
68
+ : `Bundle size ${bundleSizeIncreasedText} from ${oldStats.bundleSize.toString()} to ${newStats.bundleSize.toString()} (${Math.abs(bundleDiffSize).toString()}B)`,
69
+ !diffSize
70
+ ? "Size unchanged"
71
+ : `Size ${diffSizeIncreasedText} from ${oldStats.totalSize.toString()} to ${newStats.totalSize.toString()} (${Math.abs(diffSize).toString()}B)`,
72
+ `Files count changed from ${oldStats.totalFiles.toString()} to ${newStats.totalFiles.toString()} (${(newStats.totalFiles - oldStats.totalFiles).toString()})`,
73
+ `Folders count changed from ${oldStats.totalFolders.toString()} to ${newStats.totalFolders.toString()} (${(newStats.totalFolders - oldStats.totalFolders).toString()})`,
74
+ ];
75
+ }
70
76
  console.log("Build finished successfully!");
71
- for (const text of texts) {
72
- outputFunc(text);
77
+ if (!silent) {
78
+ for (const text of texts) {
79
+ outputFunc(text);
80
+ }
73
81
  }
74
82
  });
75
83
  export { buildCommand };