kist 0.0.0 → 0.1.31

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 (237) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +298 -3
  3. package/js/actions/CoreActions.d.ts +6 -0
  4. package/js/actions/CoreActions.js +47 -0
  5. package/js/actions/DirectoryCleanAction/DirectoryCleanAction.d.ts +36 -0
  6. package/js/actions/DirectoryCleanAction/DirectoryCleanAction.js +123 -0
  7. package/js/actions/DirectoryCleanAction/index.d.ts +2 -0
  8. package/js/actions/DirectoryCleanAction/index.js +8 -0
  9. package/js/actions/DirectoryCopyAction/DirectoryCopyAction.d.ts +42 -0
  10. package/js/actions/DirectoryCopyAction/DirectoryCopyAction.js +118 -0
  11. package/js/actions/DirectoryCopyAction/index.d.ts +2 -0
  12. package/js/actions/DirectoryCopyAction/index.js +8 -0
  13. package/js/actions/DirectoryCreateAction/DirectoryCreateAction.d.ts +30 -0
  14. package/js/actions/DirectoryCreateAction/DirectoryCreateAction.js +85 -0
  15. package/js/actions/DirectoryCreateAction/index.d.ts +2 -0
  16. package/js/actions/DirectoryCreateAction/index.js +8 -0
  17. package/js/actions/DocumentationAction/DocumentationAction.d.ts +23 -0
  18. package/js/actions/DocumentationAction/DocumentationAction.js +88 -0
  19. package/js/actions/DocumentationAction/index.d.ts +2 -0
  20. package/js/actions/DocumentationAction/index.js +8 -0
  21. package/js/actions/FileCopyAction/FileCopyAction.d.ts +42 -0
  22. package/js/actions/FileCopyAction/FileCopyAction.js +127 -0
  23. package/js/actions/FileCopyAction/index.d.ts +2 -0
  24. package/js/actions/FileCopyAction/index.js +8 -0
  25. package/js/actions/FileRenameAction/FileRenameAction.d.ts +30 -0
  26. package/js/actions/FileRenameAction/FileRenameAction.js +84 -0
  27. package/js/actions/FileRenameAction/index.d.ts +2 -0
  28. package/js/actions/FileRenameAction/index.js +8 -0
  29. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.d.ts +31 -0
  30. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.js +98 -0
  31. package/js/actions/JavaScriptMinifyAction/index.d.ts +2 -0
  32. package/js/actions/JavaScriptMinifyAction/index.js +8 -0
  33. package/js/actions/JavaScriptMinifyAction/terser.config.d.ts +27 -0
  34. package/js/actions/JavaScriptMinifyAction/terser.config.js +119 -0
  35. package/js/actions/LintAction/LintAction.d.ts +17 -0
  36. package/js/actions/LintAction/LintAction.js +63 -0
  37. package/js/actions/LintAction/index.d.ts +2 -0
  38. package/js/actions/LintAction/index.js +8 -0
  39. package/js/actions/PackageManagerAction/PackageManagerAction.d.ts +57 -0
  40. package/js/actions/PackageManagerAction/PackageManagerAction.js +161 -0
  41. package/js/actions/PackageManagerAction/index.d.ts +2 -0
  42. package/js/actions/PackageManagerAction/index.js +8 -0
  43. package/js/actions/PackageManagerAction/package.config.d.ts +16 -0
  44. package/js/actions/PackageManagerAction/package.config.js +91 -0
  45. package/js/actions/StyleProcessingAction/StyleProcessingAction.d.ts +34 -0
  46. package/js/actions/StyleProcessingAction/StyleProcessingAction.js +164 -0
  47. package/js/actions/StyleProcessingAction/index.d.ts +2 -0
  48. package/js/actions/StyleProcessingAction/index.js +8 -0
  49. package/js/actions/StyleProcessingAction/postcss.config.compressed.d.ts +10 -0
  50. package/js/actions/StyleProcessingAction/postcss.config.compressed.js +31 -0
  51. package/js/actions/StyleProcessingAction/postcss.config.expanded.d.ts +16 -0
  52. package/js/actions/StyleProcessingAction/postcss.config.expanded.js +45 -0
  53. package/js/actions/SvgPackagerAction/SvgPackagerAction.d.ts +68 -0
  54. package/js/actions/SvgPackagerAction/SvgPackagerAction.js +186 -0
  55. package/js/actions/SvgPackagerAction/index.d.ts +2 -0
  56. package/js/actions/SvgPackagerAction/index.js +8 -0
  57. package/js/actions/SvgReaderAction/SvgReaderAction.d.ts +32 -0
  58. package/js/actions/SvgReaderAction/SvgReaderAction.js +87 -0
  59. package/js/actions/SvgReaderAction/index.d.ts +2 -0
  60. package/js/actions/SvgReaderAction/index.js +8 -0
  61. package/js/actions/SvgSpriteAction/SvgSpriteAction.d.ts +37 -0
  62. package/js/actions/SvgSpriteAction/SvgSpriteAction.js +114 -0
  63. package/js/actions/SvgSpriteAction/index.d.ts +2 -0
  64. package/js/actions/SvgSpriteAction/index.js +8 -0
  65. package/js/actions/SvgSpriteAction/svgsprite.config.d.ts +3 -0
  66. package/js/actions/SvgSpriteAction/svgsprite.config.js +117 -0
  67. package/js/actions/SvgToPngAction/SvgToPngAction.d.ts +28 -0
  68. package/js/actions/SvgToPngAction/SvgToPngAction.js +108 -0
  69. package/js/actions/SvgToPngAction/index.d.ts +2 -0
  70. package/js/actions/SvgToPngAction/index.js +8 -0
  71. package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.d.ts +28 -0
  72. package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.js +96 -0
  73. package/js/actions/TypeScriptCompilerAction/index.d.ts +2 -0
  74. package/js/actions/TypeScriptCompilerAction/index.js +8 -0
  75. package/js/actions/VersionWriteAction/VersionWriteAction.d.ts +45 -0
  76. package/js/actions/VersionWriteAction/VersionWriteAction.js +147 -0
  77. package/js/actions/VersionWriteAction/index.d.ts +2 -0
  78. package/js/actions/VersionWriteAction/index.js +8 -0
  79. package/js/cli/ArgumentParser.d.ts +62 -0
  80. package/js/cli/ArgumentParser.js +118 -0
  81. package/js/cli.d.ts +6 -0
  82. package/js/cli.js +58 -0
  83. package/js/core/abstract/AbstractProcess.d.ts +62 -0
  84. package/js/core/abstract/AbstractProcess.js +96 -0
  85. package/js/core/abstract/AbstractValidator.d.ts +72 -0
  86. package/js/core/abstract/AbstractValidator.js +128 -0
  87. package/js/core/config/ConfigLoader.d.ts +47 -0
  88. package/js/core/config/ConfigLoader.js +130 -0
  89. package/js/core/config/ConfigStore.d.ts +53 -0
  90. package/js/core/config/ConfigStore.js +136 -0
  91. package/js/core/config/defaultConfig.d.ts +5 -0
  92. package/js/core/config/defaultConfig.js +131 -0
  93. package/js/core/pipeline/Action.d.ts +60 -0
  94. package/js/core/pipeline/Action.js +77 -0
  95. package/js/core/pipeline/ActionRegistry.d.ts +80 -0
  96. package/js/core/pipeline/ActionRegistry.js +180 -0
  97. package/js/core/pipeline/Pipeline.d.ts +42 -0
  98. package/js/core/pipeline/Pipeline.js +107 -0
  99. package/js/core/pipeline/PipelineManager.d.ts +55 -0
  100. package/js/core/pipeline/PipelineManager.js +164 -0
  101. package/js/core/pipeline/Stage.d.ts +45 -0
  102. package/js/core/pipeline/Stage.js +110 -0
  103. package/js/core/pipeline/Step.d.ts +26 -0
  104. package/js/core/pipeline/Step.js +85 -0
  105. package/js/core/validation/OptionsValidator.d.ts +43 -0
  106. package/js/core/validation/OptionsValidator.js +123 -0
  107. package/js/index.d.ts +3 -0
  108. package/js/index.js +36 -0
  109. package/js/interface/ActionInterface.d.ts +57 -0
  110. package/js/interface/ActionInterface.js +5 -0
  111. package/js/interface/ActionPlugin.d.ts +4 -0
  112. package/js/interface/ActionPlugin.js +5 -0
  113. package/js/interface/ConfigInterface.d.ts +43 -0
  114. package/js/interface/ConfigInterface.js +5 -0
  115. package/js/interface/LiveOptionsInterface.d.ts +42 -0
  116. package/js/interface/LiveOptionsInterface.js +2 -0
  117. package/js/interface/MetadataInterface.d.ts +95 -0
  118. package/js/interface/MetadataInterface.js +2 -0
  119. package/js/interface/OptionsInterface.d.ts +45 -0
  120. package/js/interface/OptionsInterface.js +5 -0
  121. package/js/interface/PipelineOptionsInterface.d.ts +66 -0
  122. package/js/interface/PipelineOptionsInterface.js +5 -0
  123. package/js/interface/StageInterface.d.ts +79 -0
  124. package/js/interface/StageInterface.js +5 -0
  125. package/js/interface/StepInterface.d.ts +66 -0
  126. package/js/interface/StepInterface.js +5 -0
  127. package/js/interface/StepOptionsInterface.d.ts +38 -0
  128. package/js/interface/StepOptionsInterface.js +21 -0
  129. package/js/interface/index.d.ts +7 -0
  130. package/js/interface/index.js +3 -0
  131. package/js/kist.d.ts +58 -0
  132. package/js/kist.js +145 -0
  133. package/js/live/LiveServer.d.ts +95 -0
  134. package/js/live/LiveServer.js +233 -0
  135. package/js/live/LiveWatcher.d.ts +45 -0
  136. package/js/live/LiveWatcher.js +140 -0
  137. package/js/logger/Logger.d.ts +94 -0
  138. package/js/logger/Logger.js +151 -0
  139. package/js/logger/LoggerStyles.d.ts +23 -0
  140. package/js/logger/LoggerStyles.js +30 -0
  141. package/js/types/ActionOptionsType.d.ts +8 -0
  142. package/js/types/ActionOptionsType.js +2 -0
  143. package/js/types/index.d.ts +1 -0
  144. package/js/types/index.js +3 -0
  145. package/package.json +93 -7
  146. package/ts/actions/CoreActions.ts +64 -0
  147. package/ts/actions/DirectoryCleanAction/DirectoryCleanAction.ts +121 -0
  148. package/ts/actions/DirectoryCleanAction/index.ts +11 -0
  149. package/ts/actions/DirectoryCopyAction/DirectoryCopyAction.ts +118 -0
  150. package/ts/actions/DirectoryCopyAction/index.ts +11 -0
  151. package/ts/actions/DirectoryCreateAction/DirectoryCreateAction.ts +81 -0
  152. package/ts/actions/DirectoryCreateAction/index.ts +11 -0
  153. package/ts/actions/DocumentationAction/DocumentationAction.ts +100 -0
  154. package/ts/actions/DocumentationAction/index.ts +11 -0
  155. package/ts/actions/FileCopyAction/FileCopyAction.ts +125 -0
  156. package/ts/actions/FileCopyAction/index.ts +11 -0
  157. package/ts/actions/FileRenameAction/FileRenameAction.ts +82 -0
  158. package/ts/actions/FileRenameAction/index.ts +11 -0
  159. package/ts/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.ts +109 -0
  160. package/ts/actions/JavaScriptMinifyAction/index.ts +11 -0
  161. package/ts/actions/JavaScriptMinifyAction/terser.config.ts +177 -0
  162. package/ts/actions/LintAction/LintAction.ts +67 -0
  163. package/ts/actions/LintAction/index.ts +11 -0
  164. package/ts/actions/PackageManagerAction/PackageManagerAction.ts +176 -0
  165. package/ts/actions/PackageManagerAction/index.ts +11 -0
  166. package/ts/actions/PackageManagerAction/package.config.ts +94 -0
  167. package/ts/actions/SassDocAction/SassDocAction.ts +66 -0
  168. package/ts/actions/SassDocAction/index.ts +11 -0
  169. package/ts/actions/StyleProcessingAction/StyleProcessingAction.ts +142 -0
  170. package/ts/actions/StyleProcessingAction/index.ts +11 -0
  171. package/ts/actions/StyleProcessingAction/postcss.config.compressed.ts +31 -0
  172. package/ts/actions/StyleProcessingAction/postcss.config.expanded.ts +47 -0
  173. package/ts/actions/SvgPackagerAction/SvgPackagerAction.ts +187 -0
  174. package/ts/actions/SvgPackagerAction/index.ts +11 -0
  175. package/ts/actions/SvgReaderAction/SvgReaderAction.ts +77 -0
  176. package/ts/actions/SvgReaderAction/index.ts +11 -0
  177. package/ts/actions/SvgSpriteAction/SvgSpriteAction.ts +127 -0
  178. package/ts/actions/SvgSpriteAction/index.ts +11 -0
  179. package/ts/actions/SvgSpriteAction/svgsprite.config.ts +123 -0
  180. package/ts/actions/SvgToPngAction/SvgToPngAction.ts +113 -0
  181. package/ts/actions/SvgToPngAction/index.ts +11 -0
  182. package/ts/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.ts +117 -0
  183. package/ts/actions/TypeScriptCompilerAction/index.ts +11 -0
  184. package/ts/actions/VersionWriteAction/VersionWriteAction.ts +174 -0
  185. package/ts/actions/VersionWriteAction/index.ts +11 -0
  186. package/ts/actions/index.ts +0 -0
  187. package/ts/cli/ArgumentParser.ts +150 -0
  188. package/ts/cli/index.ts +1 -0
  189. package/ts/cli.ts +56 -0
  190. package/ts/core/abstract/AbstractProcess.ts +109 -0
  191. package/ts/core/abstract/AbstractSingleton.ts +46 -0
  192. package/ts/core/abstract/AbstractValidator.ts +167 -0
  193. package/ts/core/abstract/index.ts +0 -0
  194. package/ts/core/config/ConfigLoader.ts +141 -0
  195. package/ts/core/config/ConfigStore copy.ts +201 -0
  196. package/ts/core/config/ConfigStore.ts +157 -0
  197. package/ts/core/config/defaultConfig.ts +154 -0
  198. package/ts/core/config/index.ts +0 -0
  199. package/ts/core/index.ts +34 -0
  200. package/ts/core/pipeline/Action.ts +101 -0
  201. package/ts/core/pipeline/ActionRegistry.ts +216 -0
  202. package/ts/core/pipeline/Pipeline.ts +121 -0
  203. package/ts/core/pipeline/PipelineManager.ts +170 -0
  204. package/ts/core/pipeline/Stage.ts +131 -0
  205. package/ts/core/pipeline/Step.ts +96 -0
  206. package/ts/core/pipeline/index.ts +0 -0
  207. package/ts/core/validation/ActionValidator.ts +97 -0
  208. package/ts/core/validation/ConfigValidator.ts +103 -0
  209. package/ts/core/validation/OptionsValidator.ts +179 -0
  210. package/ts/core/validation/StageValidator.ts +175 -0
  211. package/ts/core/validation/StepValidator.ts +203 -0
  212. package/ts/core/validation/index.ts +0 -0
  213. package/ts/index.ts +26 -0
  214. package/ts/interface/ActionInterface.ts +70 -0
  215. package/ts/interface/ActionPlugin.ts +14 -0
  216. package/ts/interface/ConfigInterface.ts +55 -0
  217. package/ts/interface/File.ts +24 -0
  218. package/ts/interface/LiveOptionsInterface.ts +46 -0
  219. package/ts/interface/MetadataInterface.ts +105 -0
  220. package/ts/interface/OptionsInterface.ts +58 -0
  221. package/ts/interface/PackageJson.ts +171 -0
  222. package/ts/interface/PipelineOptionsInterface.ts +74 -0
  223. package/ts/interface/SVG.ts +84 -0
  224. package/ts/interface/StageInterface.ts +96 -0
  225. package/ts/interface/StepInterface.ts +83 -0
  226. package/ts/interface/StepOptionsInterface.ts +57 -0
  227. package/ts/interface/index.ts +9 -0
  228. package/ts/kist.ts +161 -0
  229. package/ts/live/LiveServer.ts +311 -0
  230. package/ts/live/LiveWatcher.ts +150 -0
  231. package/ts/live/index.ts +11 -0
  232. package/ts/logger/Logger.ts +187 -0
  233. package/ts/logger/LoggerStyles.ts +28 -0
  234. package/ts/logger/index.ts +0 -0
  235. package/ts/types/ActionOptionsType.ts +10 -0
  236. package/ts/types/index.ts +3 -0
  237. package/index.js +0 -3
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.FileRenameAction = void 0;
19
+ const fs_1 = require("fs");
20
+ const path_1 = __importDefault(require("path"));
21
+ const Action_1 = require("../../core/pipeline/Action");
22
+ // ============================================================================
23
+ // Classes
24
+ // ============================================================================
25
+ /**
26
+ * FileRenameAction handles renaming files within the file system.
27
+ * Ensures that file renaming operations are handled efficiently and safely.
28
+ */
29
+ class FileRenameAction extends Action_1.Action {
30
+ /**
31
+ * Executes the file renaming action.
32
+ *
33
+ * @param options - The options specifying the source and target file paths.
34
+ * @returns A Promise that resolves when the file has been successfully renamed.
35
+ * @throws {Error} If the source file does not exist or cannot be renamed.
36
+ */
37
+ execute(options) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ const { srcPath, targetPath } = options;
40
+ if (!srcPath || !targetPath) {
41
+ throw new Error("Invalid options: 'srcPath' and 'targetPath' are required.");
42
+ }
43
+ this.logInfo(`Renaming file: ${srcPath} → ${targetPath}`);
44
+ try {
45
+ yield this.renameFile(srcPath, targetPath);
46
+ this.logInfo(`File successfully renamed to ${targetPath}`);
47
+ }
48
+ catch (error) {
49
+ this.logError("Failed to rename file.", error);
50
+ throw error;
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * Renames a file from its current path to a new path.
56
+ *
57
+ * @param srcPath - The current file path.
58
+ * @param targetPath - The new file path.
59
+ * @returns A Promise that resolves once the file is successfully renamed.
60
+ */
61
+ renameFile(srcPath, targetPath) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ try {
64
+ const resolvedSrcPath = path_1.default.resolve(srcPath);
65
+ const resolvedTargetPath = path_1.default.resolve(targetPath);
66
+ yield fs_1.promises.rename(resolvedSrcPath, resolvedTargetPath);
67
+ this.logDebug(`File renamed: ${resolvedSrcPath} → ${resolvedTargetPath}`);
68
+ }
69
+ catch (error) {
70
+ this.logError(`Error renaming file: ${srcPath} → ${targetPath}`, error);
71
+ throw error;
72
+ }
73
+ });
74
+ }
75
+ /**
76
+ * Provides a description of the action.
77
+ *
78
+ * @returns A string description of the action.
79
+ */
80
+ describe() {
81
+ return "Renames a file from a specified source path to a target path.";
82
+ }
83
+ }
84
+ exports.FileRenameAction = FileRenameAction;
@@ -0,0 +1,2 @@
1
+ import { FileRenameAction } from "./FileRenameAction";
2
+ export { FileRenameAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FileRenameAction = void 0;
7
+ const FileRenameAction_1 = require("./FileRenameAction");
8
+ Object.defineProperty(exports, "FileRenameAction", { enumerable: true, get: function () { return FileRenameAction_1.FileRenameAction; } });
@@ -0,0 +1,31 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
3
+ /**
4
+ * JavaScriptMinifyAction handles the minification of JavaScript files.
5
+ * Uses Terser to reduce file size and optimize performance.
6
+ */
7
+ export declare class JavaScriptMinifyAction extends Action {
8
+ /**
9
+ * Executes the JavaScript minification action.
10
+ *
11
+ * @param options - The options containing input and output file paths.
12
+ * @returns A Promise that resolves when the minification process completes.
13
+ * @throws {Error} If input file is missing, minification fails, or output cannot be written.
14
+ */
15
+ execute(options: ActionOptionsType): Promise<void>;
16
+ /**
17
+ * Minifies a JavaScript file using Terser.
18
+ *
19
+ * @param inputPath - Path to the input JavaScript file.
20
+ * @param outputPath - Path where the minified file will be saved.
21
+ * @param customConfig - Custom Terser configuration.
22
+ * @returns A Promise that resolves when the minification is complete.
23
+ */
24
+ private minifyFile;
25
+ /**
26
+ * Provides a description of the action.
27
+ *
28
+ * @returns A string description of the action.
29
+ */
30
+ describe(): string;
31
+ }
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.JavaScriptMinifyAction = void 0;
19
+ const fs_1 = require("fs");
20
+ const path_1 = __importDefault(require("path"));
21
+ const terser_1 = require("terser");
22
+ const Action_1 = require("../../core/pipeline/Action");
23
+ const terser_config_js_1 = __importDefault(require("./terser.config.js"));
24
+ // ============================================================================
25
+ // Classes
26
+ // ============================================================================
27
+ /**
28
+ * JavaScriptMinifyAction handles the minification of JavaScript files.
29
+ * Uses Terser to reduce file size and optimize performance.
30
+ */
31
+ class JavaScriptMinifyAction extends Action_1.Action {
32
+ /**
33
+ * Executes the JavaScript minification action.
34
+ *
35
+ * @param options - The options containing input and output file paths.
36
+ * @returns A Promise that resolves when the minification process completes.
37
+ * @throws {Error} If input file is missing, minification fails, or output cannot be written.
38
+ */
39
+ execute(options) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { inputPath, outputPath, customConfig = {} } = options;
42
+ if (!inputPath || !outputPath) {
43
+ throw new Error("Invalid options: 'inputPath' and 'outputPath' are required.");
44
+ }
45
+ this.logInfo(`Minifying JavaScript file: ${inputPath} → ${outputPath}`);
46
+ try {
47
+ yield this.minifyFile(inputPath, outputPath, customConfig);
48
+ this.logInfo(`JavaScript minification completed: ${outputPath}`);
49
+ }
50
+ catch (error) {
51
+ this.logError("JavaScript minification failed.", error);
52
+ throw error;
53
+ }
54
+ });
55
+ }
56
+ /**
57
+ * Minifies a JavaScript file using Terser.
58
+ *
59
+ * @param inputPath - Path to the input JavaScript file.
60
+ * @param outputPath - Path where the minified file will be saved.
61
+ * @param customConfig - Custom Terser configuration.
62
+ * @returns A Promise that resolves when the minification is complete.
63
+ */
64
+ minifyFile(inputPath, outputPath, customConfig) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ var _a;
67
+ try {
68
+ const resolvedInputPath = path_1.default.resolve(inputPath);
69
+ const resolvedOutputPath = path_1.default.resolve(outputPath);
70
+ // Read JavaScript file
71
+ const inputCode = yield fs_1.promises.readFile(resolvedInputPath, "utf8");
72
+ // Merge Terser configuration with explicit type casting
73
+ const terserOptions = Object.assign(Object.assign(Object.assign({}, terser_config_js_1.default), customConfig), { ecma: terser_config_js_1.default.ecma, nameCache: (_a = terser_config_js_1.default.nameCache) !== null && _a !== void 0 ? _a : undefined });
74
+ // Minify using Terser
75
+ const result = yield (0, terser_1.minify)(inputCode, terserOptions);
76
+ if (!result.code) {
77
+ throw new Error("Minification resulted in empty output.");
78
+ }
79
+ // Write minified file
80
+ yield fs_1.promises.writeFile(resolvedOutputPath, result.code, "utf8");
81
+ this.logDebug(`Minified JavaScript file saved to ${resolvedOutputPath}`);
82
+ }
83
+ catch (error) {
84
+ this.logError(`Error minifying JavaScript file: ${inputPath}`, error);
85
+ throw error;
86
+ }
87
+ });
88
+ }
89
+ /**
90
+ * Provides a description of the action.
91
+ *
92
+ * @returns A string description of the action.
93
+ */
94
+ describe() {
95
+ return "Minifies JavaScript files using Terser to reduce size and optimize performance.";
96
+ }
97
+ }
98
+ exports.JavaScriptMinifyAction = JavaScriptMinifyAction;
@@ -0,0 +1,2 @@
1
+ import { JavaScriptMinifyAction } from "./JavaScriptMinifyAction";
2
+ export { JavaScriptMinifyAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JavaScriptMinifyAction = void 0;
7
+ const JavaScriptMinifyAction_1 = require("./JavaScriptMinifyAction");
8
+ Object.defineProperty(exports, "JavaScriptMinifyAction", { enumerable: true, get: function () { return JavaScriptMinifyAction_1.JavaScriptMinifyAction; } });
@@ -0,0 +1,27 @@
1
+ declare const terserConfig: {
2
+ parse: {};
3
+ compress: {
4
+ drop_console: boolean;
5
+ drop_debugger: boolean;
6
+ pure_funcs: string[];
7
+ arrows: boolean;
8
+ };
9
+ mangle: {
10
+ properties: boolean;
11
+ };
12
+ format: {
13
+ comments: boolean;
14
+ beautify: boolean;
15
+ };
16
+ sourceMap: {};
17
+ ecma: number;
18
+ enclose: boolean;
19
+ keep_classnames: boolean;
20
+ keep_fnames: boolean;
21
+ ie8: boolean;
22
+ module: boolean;
23
+ nameCache: null;
24
+ safari10: boolean;
25
+ toplevel: boolean;
26
+ };
27
+ export default terserConfig;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // ============================================================================
7
+ // Constants
8
+ // ============================================================================
9
+ // https://terser.org/docs/api-reference/
10
+ const terserConfig = {
11
+ parse: {
12
+ // parse options
13
+ },
14
+ compress: {
15
+ // compress options
16
+ drop_console: true, // Remove console.log statements
17
+ drop_debugger: true, // Remove debugger statements
18
+ pure_funcs: ["console.info", "console.debug", "console.warn"], // Remove specific console functions
19
+ // defaults (default: true) -- Pass false to disable most default enabled compress transforms. Useful when you only want to enable a few compress options while disabling the rest.
20
+ // Class and object literal methods are converted will also be
21
+ // converted to arrow expressions if the resultant code is shorter:
22
+ // m(){return x} becomes m:()=>x. To do this to regular ES5 functions
23
+ // which don't use this or arguments, see unsafe_arrows.
24
+ arrows: true, // (default: true)
25
+ // arguments (default: false) -- replace arguments[index] with function parameter name whenever possible.
26
+ // booleans (default: true) -- various optimizations for boolean context, for example !!a ? b : c → a ? b : c
27
+ // booleans_as_integers (default: false) -- Turn booleans into 0 and 1, also makes comparisons with booleans use == and != instead of === and !==.
28
+ // collapse_vars (default: true) -- Collapse single-use non-constant variables, side effects permitting.
29
+ // comparisons (default: true) -- apply certain optimizations to binary nodes, e.g. !(a <= b) → a > b (only when unsafe_comps), attempts to negate binary nodes, e.g. a = !b && !c && !d && !e → a=!(b||c||d||e) etc. Note: comparisons works best with lhs_constants enabled.
30
+ // computed_props (default: true) -- Transforms constant computed properties into regular ones: {["computed"]: 1} is converted to {computed: 1}.
31
+ // conditionals (default: true) -- apply optimizations for if-s and conditional expressions
32
+ // dead_code (default: true) -- remove unreachable code
33
+ // directives (default: true) -- remove redundant or non-standard directives
34
+ // drop_console (default: false) -- Pass true to discard calls to console.* functions. If you only want to discard a portion of console, you can pass an array like this ['log', 'info'], which will only discard console.log、 console.info.
35
+ // drop_debugger (default: true) -- remove debugger; statements
36
+ // ecma (default: 5) -- Pass 2015 or greater to enable compress options that will transform ES5 code into smaller ES6+ equivalent forms.
37
+ // evaluate (default: true) -- attempt to evaluate constant expressions
38
+ // expression (default: false) -- Pass true to preserve completion values from terminal statements without return, e.g. in bookmarklets.
39
+ // global_defs (default: {}) -- see conditional compilation
40
+ // hoist_funs (default: false) -- hoist function declarations
41
+ // hoist_props (default: true) -- hoist properties from constant object and array literals into regular variables subject to a set of constraints. For example: var o={p:1, q:2}; f(o.p, o.q); is converted to f(1, 2);. Note: hoist_props works best with mangle enabled, the compress option passes set to 2 or higher, and the compress option toplevel enabled.
42
+ // hoist_vars (default: false) -- hoist var declarations (this is false by default because it seems to increase the size of the output in general)
43
+ // if_return (default: true) -- optimizations for if/return and if/continue
44
+ // inline (default: true) -- inline calls to function with simple/return statement:
45
+ // false -- same as 0
46
+ // 0 -- disabled inlining
47
+ // 1 -- inline simple functions
48
+ // 2 -- inline functions with arguments
49
+ // 3 -- inline functions with arguments and variables
50
+ // true -- same as 3
51
+ // join_vars (default: true) -- join consecutive var, let and const statements
52
+ // keep_classnames (default: false) -- Pass true to prevent the compressor from discarding class names. Pass a regular expression to only keep class names matching that regex. See also: the keep_classnames mangle option.
53
+ // keep_fargs (default: true) -- Prevents the compressor from discarding unused function arguments. You need this for code which relies on Function.length.
54
+ // keep_fnames (default: false) -- Pass true to prevent the compressor from discarding function names. Pass a regular expression to only keep function names matching that regex. Useful for code relying on Function.prototype.name. See also: the keep_fnames mangle option.
55
+ // keep_infinity (default: false) -- Pass true to prevent Infinity from being compressed into 1/0, which may cause performance issues on Chrome.
56
+ // lhs_constants (default: true) -- Moves constant values to the left-hand side of binary nodes. foo == 42 → 42 == foo
57
+ // loops (default: true) -- optimizations for do, while and for loops when we can statically determine the condition.
58
+ // module (default false) -- Pass true when compressing an ES6 module. Strict mode is implied and the toplevel option as well.
59
+ // negate_iife (default: true) -- negate "Immediately-Called Function Expressions" where the return value is discarded, to avoid the parens that the code generator would insert.
60
+ // passes (default: 1) -- The maximum number of times to run compress. In some cases more than one pass leads to further compressed code. Keep in mind more passes will take more time.
61
+ // properties (default: true) -- rewrite property access using the dot notation, for example foo["bar"] → foo.bar
62
+ // pure_funcs (default: null) -- You can pass an array of names and Terser will assume that those functions do not produce side effects. DANGER: will not check if the name is redefined in scope. An example case here, for instance var q = Math.floor(a/b). If variable q is not used elsewhere, Terser will drop it, but will still keep the Math.floor(a/b), not knowing what it does. You can pass pure_funcs: [ 'Math.floor' ] to let it know that this function won't produce any side effect, in which case the whole statement would get discarded. The current implementation adds some overhead (compression will be slower).
63
+ // pure_getters (default: "strict") -- If you pass true for this, Terser will assume that object property access (e.g. foo.bar or foo["bar"]) doesn't have any side effects. Specify "strict" to treat foo.bar as side-effect-free only when foo is certain to not throw, i.e. not null or undefined.
64
+ // pure_new (default: false) -- Set to true to assume new X() never has side effects.
65
+ // reduce_vars (default: true) -- Improve optimization on variables assigned with and used as constant values.
66
+ // reduce_funcs (default: true) -- Inline single-use functions when possible. Depends on reduce_vars being enabled. Disabling this option sometimes improves performance of the output code.
67
+ // sequences (default: true) -- join consecutive simple statements using the comma operator. May be set to a positive integer to specify the maximum number of consecutive comma sequences that will be generated. If this option is set to true then the default sequences limit is 200. Set option to false or 0 to disable. The smallest sequences length is 2. A sequences value of 1 is grandfathered to be equivalent to true and as such means 200. On rare occasions the default sequences limit leads to very slow compress times in which case a value of 20 or less is recommended.
68
+ // side_effects (default: true) -- Remove expressions which have no side effects and whose results aren't used.
69
+ // switches (default: true) -- de-duplicate and remove unreachable switch branches
70
+ // toplevel (default: false) -- drop unreferenced functions ("funcs") and/or variables ("vars") in the top level scope (false by default, true to drop both unreferenced functions and variables)
71
+ // top_retain (default: null) -- prevent specific toplevel functions and variables from unused removal (can be array, comma-separated, RegExp or function. Implies toplevel)
72
+ // typeofs (default: true) -- Transforms typeof foo == "undefined" into foo === void 0. Note: recommend to set this value to false for IE10 and earlier versions due to known issues.
73
+ // unsafe (default: false) -- apply "unsafe" transformations (details).
74
+ // unsafe_arrows (default: false) -- Convert ES5 style anonymous function expressions to arrow functions if the function body does not reference this. Note: it is not always safe to perform this conversion if code relies on the the function having a prototype, which arrow functions lack. This transform requires that the ecma compress option is set to 2015 or greater.
75
+ // unsafe_comps (default: false) -- Reverse < and <= to > and >= to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like get, or valueOf. This could cause change in execution order after operands in the comparison are switching. Compression only works if both comparisons and unsafe_comps are both set to true.
76
+ // unsafe_Function (default: false) -- compress and mangle Function(args, code) when both args and code are string literals.
77
+ // unsafe_math (default: false) -- optimize numerical expressions like 2 * x * 3 into 6 * x, which may give imprecise floating point results.
78
+ // unsafe_symbols (default: false) -- removes keys from native Symbol declarations, e.g Symbol("kDog") becomes Symbol().
79
+ // unsafe_methods (default: false) -- Converts { m: function(){} } to { m(){} }. ecma must be set to 6 or greater to enable this transform. If unsafe_methods is a RegExp then key/value pairs with keys matching the RegExp will be converted to concise methods. Note: if enabled there is a risk of getting a "<method name> is not a constructor" TypeError should any code try to new the former function.
80
+ // unsafe_proto (default: false) -- optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)
81
+ // unsafe_regexp (default: false) -- enable substitutions of variables with RegExp values the same way as if they are constants.
82
+ // unsafe_undefined (default: false) -- substitute void 0 if there is a variable named undefined in scope (variable name will be mangled, typically reduced to a single character)
83
+ // unused (default: true) -- drop unreferenced functions and variables (simple direct variable assignments do not count as references unless set to "keep_assign")
84
+ },
85
+ mangle: {
86
+ // mangle options
87
+ // Mangle names for obfuscation and size reduction
88
+ properties: true, // Mangle property names
89
+ // properties: {
90
+ // // mangle property options // gives error messages
91
+ // // bare_returns: false, //support top level return statements
92
+ // html5_comments: true, // (default true)
93
+ // shebang: true, //(default true) -- support #!command as the first line
94
+ // spidermonkey: false, // (default false) -- accept a Spidermonkey (Mozilla) AST
95
+ // }
96
+ },
97
+ format: {
98
+ // format options (can also use `output` for backwards compatibility)
99
+ comments: false, // Remove comments to reduce file size
100
+ beautify: false, // Disable beautification for smaller file size
101
+ },
102
+ sourceMap: {
103
+ // source map options
104
+ },
105
+ // Define ECMAScript target version
106
+ ecma: 5, // specify one of: 5, 2015, 2016, etc.
107
+ enclose: false, // or specify true, or "args:values"
108
+ keep_classnames: false, // Remove class names
109
+ keep_fnames: false, // Remove function names
110
+ ie8: false,
111
+ module: false,
112
+ nameCache: null, // or specify a name cache object
113
+ safari10: false,
114
+ toplevel: true, // Enable top-level variable and function name mangling
115
+ };
116
+ // ============================================================================
117
+ // Export
118
+ // ============================================================================
119
+ exports.default = terserConfig;
@@ -0,0 +1,17 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
3
+ /**
4
+ * LintAction handles linting TypeScript and JavaScript files using ESLint.
5
+ * This action can be configured to run in strict mode or automatically fix issues.
6
+ */
7
+ export declare class LintAction extends Action {
8
+ private eslint;
9
+ constructor();
10
+ execute(options: ActionOptionsType): Promise<void>;
11
+ /**
12
+ * Provides a description of the action.
13
+ *
14
+ * @returns A string description of the action.
15
+ */
16
+ describe(): string;
17
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LintAction = void 0;
16
+ const eslint_1 = require("eslint");
17
+ const Action_1 = require("../../core/pipeline/Action");
18
+ // ============================================================================
19
+ // Classes
20
+ // ============================================================================
21
+ /**
22
+ * LintAction handles linting TypeScript and JavaScript files using ESLint.
23
+ * This action can be configured to run in strict mode or automatically fix issues.
24
+ */
25
+ class LintAction extends Action_1.Action {
26
+ constructor() {
27
+ super(); // Call the parent class constructor
28
+ this.eslint = new eslint_1.ESLint({}); // Initialize ESLint with default config
29
+ }
30
+ execute(options) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { targetFiles = ["src/**/*.ts"], fix = false, configPath = ".eslintrc.js", } = options;
33
+ if (!targetFiles || targetFiles.length === 0) {
34
+ throw new Error("Invalid options: 'targetFiles' is required and must contain at least one file or directory.");
35
+ }
36
+ this.logInfo(`Starting ESLint on: ${targetFiles.join(", ")}`);
37
+ try {
38
+ // Update ESLint instance with correct configuration
39
+ this.eslint = new eslint_1.ESLint({ fix, overrideConfigFile: configPath });
40
+ const results = yield this.eslint.lintFiles(targetFiles);
41
+ if (fix) {
42
+ yield eslint_1.ESLint.outputFixes(results);
43
+ }
44
+ const formatter = yield this.eslint.loadFormatter("stylish");
45
+ console.log(formatter.format(results));
46
+ this.logInfo("ESLint linting completed successfully.");
47
+ }
48
+ catch (error) {
49
+ this.logError("ESLint encountered an error.", error);
50
+ throw error;
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * Provides a description of the action.
56
+ *
57
+ * @returns A string description of the action.
58
+ */
59
+ describe() {
60
+ return "Runs ESLint on specified files and directories, with optional auto-fixing.";
61
+ }
62
+ }
63
+ exports.LintAction = LintAction;
@@ -0,0 +1,2 @@
1
+ import { LintAction } from "./LintAction";
2
+ export { LintAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LintAction = void 0;
7
+ const LintAction_1 = require("./LintAction");
8
+ Object.defineProperty(exports, "LintAction", { enumerable: true, get: function () { return LintAction_1.LintAction; } });
@@ -0,0 +1,57 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType.js";
3
+ /**
4
+ * PackageManagerAction handles reading, validating, and creating `package.json`
5
+ * files, supporting custom configurations and merging with selected fields.
6
+ */
7
+ export declare class PackageManagerAction extends Action {
8
+ /**
9
+ * Executes the package management action.
10
+ * Reads an existing `package.json`, extracts selected fields, and writes a new one.
11
+ *
12
+ * @param options - Options specifying input path, output directory, and fields to export.
13
+ * @returns A Promise that resolves when the action is completed successfully.
14
+ * @throws {Error} Throws an error if neither `packageJsonPath` nor `outputDir` is provided.
15
+ */
16
+ execute(options: ActionOptionsType): Promise<void>;
17
+ /**
18
+ * Reads and parses an existing `package.json`.
19
+ *
20
+ * @param packageJsonPath - Path to the `package.json` file.
21
+ * @returns Parsed JSON object.
22
+ * @throws {Error} If the file does not exist or contains invalid JSON.
23
+ */
24
+ private readPackageJson;
25
+ /**
26
+ * Filters specified fields from a `package.json` object.
27
+ *
28
+ * @param config - The original package.json object.
29
+ * @param fields - List of fields to extract.
30
+ * @returns A new object containing only the selected fields.
31
+ */
32
+ private filterFields;
33
+ /**
34
+ * Creates a `package.json` file with selected fields and custom overrides.
35
+ *
36
+ * @param outputDir - Directory where the new `package.json` will be created.
37
+ * @param filteredConfig - The filtered package.json fields.
38
+ * @param customConfig - Custom overrides to apply.
39
+ * @returns A Promise that resolves when the file has been successfully created.
40
+ * @throws {Error} If the file cannot be written.
41
+ */
42
+ private createPackageJson;
43
+ /**
44
+ * Ensures that the specified directory exists, creating it if it does not.
45
+ *
46
+ * @param dirPath - The path of the directory to verify or create.
47
+ * @returns A Promise that resolves once the directory is verified or created.
48
+ * @throws {Error} If the directory cannot be created.
49
+ */
50
+ private ensureDirectoryExists;
51
+ /**
52
+ * Provides a description of the action.
53
+ *
54
+ * @returns A string description of the action.
55
+ */
56
+ describe(): string;
57
+ }