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,110 @@
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.Stage = void 0;
16
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
17
+ const Step_1 = require("./Step");
18
+ // ============================================================================
19
+ // Class
20
+ // ============================================================================
21
+ /**
22
+ * Represents a stage in the pipeline, encapsulating its execution logic and
23
+ * dependencies. Each stage consists of multiple steps that are executed
24
+ * consecutively, and stages can have dependencies on other stages which are
25
+ * managed before execution.
26
+ */
27
+ class Stage extends AbstractProcess_1.AbstractProcess {
28
+ // Constructor
29
+ // ========================================================================
30
+ /**
31
+ * Constructs a Stage instance with the given stage definition.
32
+ * @param stage - The stage definition containing name, steps, and
33
+ * dependencies.
34
+ */
35
+ constructor(stage) {
36
+ super(); // Initialize logging
37
+ this.name = stage.name;
38
+ this.steps = stage.steps.map((step) => new Step_1.Step(step));
39
+ this.dependsOn = stage.dependsOn;
40
+ this.logInfo(`Stage "${this.name}" initialized with ${this.steps.length} steps.`);
41
+ }
42
+ // Methods
43
+ // ========================================================================
44
+ // Methods
45
+ // ========================================================================
46
+ /**
47
+ * Executes the stage by running its steps consecutively.
48
+ * Manages dependencies by waiting for dependent stages to complete
49
+ * before execution.
50
+ * @param completedStages - A set of completed stage names used for
51
+ * dependency tracking.
52
+ * @throws Error if any step within the stage fails.
53
+ */
54
+ execute(completedStages) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ // Handle dependencies before executing the stage
57
+ if (this.dependsOn) {
58
+ yield this.resolveDependencies(completedStages);
59
+ }
60
+ this.logInfo(`Executing stage: ${this.name}`);
61
+ // Execute all steps within the stage consecutively
62
+ try {
63
+ for (const step of this.steps) {
64
+ yield step.execute();
65
+ }
66
+ this.logInfo(`Stage "${this.name}" completed successfully.`);
67
+ completedStages.add(this.name);
68
+ }
69
+ catch (error) {
70
+ this.logError(`Error executing stage "${this.name}": ${error}`, error);
71
+ // Propagate the error to halt pipeline or manage based on
72
+ // global settings
73
+ throw error;
74
+ }
75
+ });
76
+ }
77
+ /**
78
+ * Resolves dependencies by ensuring all required stages have completed.
79
+ * @param completedStages - A set of completed stage names used for
80
+ * dependency tracking.
81
+ * @returns A promise that resolves once all dependencies are met.
82
+ */
83
+ resolveDependencies(completedStages) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ if (!this.dependsOn)
86
+ return;
87
+ this.logInfo(`Stage "${this.name}" is waiting for
88
+ dependencies:${this.dependsOn.join(", ")}`);
89
+ yield Promise.all(this.dependsOn.map((dep) => this.waitForStageCompletion(dep, completedStages)));
90
+ this.logInfo(`All dependencies resolved for stage: "${this.name}"`);
91
+ });
92
+ }
93
+ /**
94
+ * Waits for a specified stage to complete by monitoring the completed
95
+ * stages set.
96
+ * @param stageName - The name of the stage to wait for.
97
+ * @param completedStages - A set of completed stage names used for
98
+ * dependency tracking.
99
+ * @returns A promise that resolves when the specified stage is marked
100
+ * as completed.
101
+ */
102
+ waitForStageCompletion(stageName, completedStages) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ while (!completedStages.has(stageName)) {
105
+ yield new Promise((resolve) => setTimeout(resolve, 100));
106
+ }
107
+ });
108
+ }
109
+ }
110
+ exports.Stage = Stage;
@@ -0,0 +1,26 @@
1
+ import { StepInterface } from "../../interface/StepInterface";
2
+ import { AbstractProcess } from "../abstract/AbstractProcess";
3
+ /**
4
+ * Represents a single step in a stage, encapsulating its execution logic.
5
+ * This class manages the resolution and execution of actions associated
6
+ * with each step.
7
+ */
8
+ export declare class Step extends AbstractProcess {
9
+ private name;
10
+ private action;
11
+ private options?;
12
+ /**
13
+ * Constructs a Step instance based on the provided step definition.
14
+ * Dynamically resolves the action class from the registry.
15
+ *
16
+ * @param step - The step definition containing the step name, action name,
17
+ * and options.
18
+ * @throws Error if the specified action is not registered in the action
19
+ * registry.
20
+ */
21
+ constructor(step: StepInterface);
22
+ /**
23
+ * Executes the step by invoking its action's execute method.
24
+ */
25
+ execute(): Promise<void>;
26
+ }
@@ -0,0 +1,85 @@
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.Step = void 0;
16
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
17
+ const ActionRegistry_1 = require("./ActionRegistry");
18
+ // ============================================================================
19
+ // Class
20
+ // ============================================================================
21
+ /**
22
+ * Represents a single step in a stage, encapsulating its execution logic.
23
+ * This class manages the resolution and execution of actions associated
24
+ * with each step.
25
+ */
26
+ class Step extends AbstractProcess_1.AbstractProcess {
27
+ // Constructor
28
+ // ========================================================================
29
+ /**
30
+ * Constructs a Step instance based on the provided step definition.
31
+ * Dynamically resolves the action class from the registry.
32
+ *
33
+ * @param step - The step definition containing the step name, action name,
34
+ * and options.
35
+ * @throws Error if the specified action is not registered in the action
36
+ * registry.
37
+ */
38
+ constructor(step) {
39
+ super();
40
+ this.name = step.name;
41
+ // Resolve the action class from the registry using the action name
42
+ const actionRegistry = ActionRegistry_1.ActionRegistry.getInstance();
43
+ // console.log(step.action)
44
+ // const ActionClass = actionRegistry.getAction(step.action.name);
45
+ const ActionClass = actionRegistry.getAction(String(step.action));
46
+ if (!ActionClass) {
47
+ let msg = `
48
+ Unknown action "${step.action}" for step "${this.name}".
49
+ Ensure the action is registered in the registry.
50
+ `;
51
+ this.logError(msg);
52
+ throw new Error(msg);
53
+ }
54
+ // Initialize the action with the specific class from the registry
55
+ this.action = new ActionClass();
56
+ this.options = step.options;
57
+ this.logInfo(`Step "${this.name}" initialized with action "${step.action.constructor.name}".`);
58
+ }
59
+ // Methods
60
+ // ========================================================================
61
+ /**
62
+ * Executes the step by invoking its action's execute method.
63
+ */
64
+ execute() {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ this.logInfo(`Executing step: ${this.name}`);
67
+ try {
68
+ // Validate options if the action provides a validation method
69
+ if (typeof this.action.validateOptions === "function") {
70
+ const isValid = this.action.validateOptions(this.options || {});
71
+ if (!isValid) {
72
+ throw new Error(`Invalid options for step: ${this.name}`);
73
+ }
74
+ }
75
+ // Execute the action with the provided options
76
+ yield this.action.execute(this.options || {});
77
+ this.logInfo(`Step "${this.name}" completed successfully.`);
78
+ }
79
+ catch (error) {
80
+ this.logError(`Error executing step "${this.name}": ${error}`, error);
81
+ }
82
+ });
83
+ }
84
+ }
85
+ exports.Step = Step;
@@ -0,0 +1,43 @@
1
+ import { OptionsInterface } from "../../interface/OptionsInterface";
2
+ import { AbstractValidator } from "../abstract/AbstractValidator";
3
+ /**
4
+ * OptionsValidator provides centralized validation logic for pipeline options.
5
+ * Extends AbstractValidator for consistent validation and logging.
6
+ */
7
+ export declare class OptionsValidator extends AbstractValidator<OptionsInterface> {
8
+ /**
9
+ * A runtime mapping of enumerated options for validation.
10
+ */
11
+ private static allowedValues;
12
+ constructor();
13
+ /**
14
+ * Validates a specific property of the options object.
15
+ *
16
+ * @param key - The key of the option to validate.
17
+ * @param value - The value of the option to validate.
18
+ * @throws Error if validation fails.
19
+ */
20
+ protected validateProperty<K extends keyof OptionsInterface>(key: K, value: OptionsInterface[K]): void;
21
+ /**
22
+ * Validates a property based on its type when it does not have predefined
23
+ * allowed values.
24
+ *
25
+ * @param key - The key to validate.
26
+ * @param value - The value to validate.
27
+ */
28
+ private validateByType;
29
+ /**
30
+ * Validates the `live` configuration, ensuring all nested properties
31
+ * conform to their expected types and ranges.
32
+ *
33
+ * @param value - The live reload configuration to validate.
34
+ */
35
+ private validateLiveOptions;
36
+ /**
37
+ * Checks if the given value is a valid object.
38
+ *
39
+ * @param value - The value to check.
40
+ * @returns True if the value is an object and not null or an array.
41
+ */
42
+ private isValidObject;
43
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OptionsValidator = void 0;
7
+ const AbstractValidator_1 = require("../abstract/AbstractValidator");
8
+ // ============================================================================
9
+ // Class
10
+ // ============================================================================
11
+ /**
12
+ * OptionsValidator provides centralized validation logic for pipeline options.
13
+ * Extends AbstractValidator for consistent validation and logging.
14
+ */
15
+ class OptionsValidator extends AbstractValidator_1.AbstractValidator {
16
+ // Constructor
17
+ // ========================================================================
18
+ constructor() {
19
+ super();
20
+ this.logDebug("OptionsValidator initialized.");
21
+ }
22
+ // Methods
23
+ // ========================================================================
24
+ /**
25
+ * Validates a specific property of the options object.
26
+ *
27
+ * @param key - The key of the option to validate.
28
+ * @param value - The value of the option to validate.
29
+ * @throws Error if validation fails.
30
+ */
31
+ validateProperty(key, value) {
32
+ if (value === undefined) {
33
+ this.throwValidationError(key, value, `Option "${String(key)}" cannot be undefined.`);
34
+ return;
35
+ }
36
+ const allowedValues = OptionsValidator.allowedValues[key];
37
+ if (allowedValues && !allowedValues.includes(value)) {
38
+ this.throwValidationError(key, value, `Invalid value "${value}" for option "${String(key)}". Allowed values are: ${allowedValues.join(", ")}.`);
39
+ return;
40
+ }
41
+ this.validateByType(key, value);
42
+ this.logValidationSuccess(key, value);
43
+ }
44
+ /**
45
+ * Validates a property based on its type when it does not have predefined
46
+ * allowed values.
47
+ *
48
+ * @param key - The key to validate.
49
+ * @param value - The value to validate.
50
+ */
51
+ validateByType(key, value) {
52
+ switch (key) {
53
+ case "stepTimeout":
54
+ case "maxConcurrentStages":
55
+ if (typeof value === "number" && value >= 0) {
56
+ this.validateNumber(key, value);
57
+ }
58
+ else {
59
+ this.throwValidationError(key, value, "Must be a non-negative number.");
60
+ }
61
+ break;
62
+ case "haltOnFailure":
63
+ case "tags":
64
+ if (this.isValidObject(value)) {
65
+ this.validateObject(key, value);
66
+ }
67
+ else {
68
+ this.throwValidationError(key, value, "Must be a valid object.");
69
+ }
70
+ break;
71
+ case "live":
72
+ this.validateLiveOptions(value);
73
+ break;
74
+ default:
75
+ if (typeof value === "string" && value.trim() !== "") {
76
+ this.validateString(key, value);
77
+ }
78
+ else {
79
+ this.throwValidationError(key, value, "Must be a non-empty string.");
80
+ }
81
+ }
82
+ }
83
+ /**
84
+ * Validates the `live` configuration, ensuring all nested properties
85
+ * conform to their expected types and ranges.
86
+ *
87
+ * @param value - The live reload configuration to validate.
88
+ */
89
+ validateLiveOptions(value) {
90
+ if ((value === null || value === void 0 ? void 0 : value.port) && (value.port < 1 || value.port > 65535)) {
91
+ this.throwValidationError("live.port", value.port, "Port must be a number between 1 and 65535.");
92
+ }
93
+ if ((value === null || value === void 0 ? void 0 : value.root) && typeof value.root !== "string") {
94
+ this.throwValidationError("live.root", value.root, "Root must be a valid string path.");
95
+ }
96
+ if ((value === null || value === void 0 ? void 0 : value.watchPaths) && !Array.isArray(value.watchPaths)) {
97
+ this.throwValidationError("live.watchPaths", value.watchPaths, "Must be an array of paths.");
98
+ }
99
+ if ((value === null || value === void 0 ? void 0 : value.ignoredPaths) && !Array.isArray(value.ignoredPaths)) {
100
+ this.throwValidationError("live.ignoredPaths", value.ignoredPaths, "Must be an array of paths.");
101
+ }
102
+ }
103
+ /**
104
+ * Checks if the given value is a valid object.
105
+ *
106
+ * @param value - The value to check.
107
+ * @returns True if the value is an object and not null or an array.
108
+ */
109
+ isValidObject(value) {
110
+ return (typeof value === "object" &&
111
+ value !== null &&
112
+ !Array.isArray(value));
113
+ }
114
+ }
115
+ exports.OptionsValidator = OptionsValidator;
116
+ // Parameters
117
+ // ========================================================================
118
+ /**
119
+ * A runtime mapping of enumerated options for validation.
120
+ */
121
+ OptionsValidator.allowedValues = {
122
+ logLevel: ["debug", "info", "warn", "error"],
123
+ };
package/js/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { Kist } from "./kist";
2
+ export * from "./types";
3
+ export * from "./cli.js";
package/js/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Kist = void 0;
21
+ // Core Modules
22
+ // export { Pipeline } from "./core/Pipeline";
23
+ // export { ConfigLoader } from "./core/ConfigLoader";
24
+ // export { PipelineManager } from "./core/PipelineManager";
25
+ // Live Modules
26
+ // export { LiveReloadServer } from "./live/LiveReloadServer";
27
+ // export { FileWatcher } from "./live/FileWatcher";
28
+ // Actions and Other Utilities
29
+ // export { Action } from "./core/Action";
30
+ // Main Function
31
+ var kist_1 = require("./kist");
32
+ Object.defineProperty(exports, "Kist", { enumerable: true, get: function () { return kist_1.Kist; } });
33
+ // Additional Types
34
+ __exportStar(require("./types"), exports);
35
+ // CLI Functions (if required programmatically)
36
+ __exportStar(require("./cli.js"), exports);
@@ -0,0 +1,57 @@
1
+ import { ActionOptionsType } from "../types/ActionOptionsType";
2
+ /**
3
+ * ActionInterface defines the contract for step action classes in pack.gl.
4
+ * Implementing this interface allows actions to be dynamically integrated into
5
+ * the pipeline, offering a flexible and extensible system for defining custom
6
+ * behaviors within different stages.
7
+ */
8
+ export interface ActionInterface {
9
+ /**
10
+ * A unique name identifying the action.
11
+ * This property is used for logging, registration in the ActionRegistry,
12
+ * and debugging purposes.
13
+ */
14
+ name: string;
15
+ /**
16
+ * Executes the action with the provided options.
17
+ * Implementations of this method should perform the main logic of the
18
+ * action, such as building, testing, linting, packaging, or other
19
+ * custom-defined processes.
20
+ *
21
+ * @param options - A structured set of options specific to the action's
22
+ * configuration. Implementations are responsible for validating and
23
+ * applying these options. Example configurations might include:
24
+ * - For 'build': { minify: boolean, sourceMap: boolean, target: string }
25
+ * - For 'lint': { fix: boolean, formatter: string }
26
+ * @returns A Promise that resolves when the action completes successfully,
27
+ * or rejects with an error if the action fails.
28
+ */
29
+ execute(options: ActionOptionsType): Promise<void>;
30
+ /**
31
+ * Validates the provided options before execution.
32
+ * This method can be used to check the integrity and correctness of the
33
+ * options object, ensuring that required fields are present and valid.
34
+ *
35
+ * @param options - The options to validate, ensuring they meet the
36
+ * action's specific requirements.
37
+ * @returns A boolean indicating whether the options are valid. Throws an
38
+ * error or returns false if validation fails.
39
+ */
40
+ validateOptions?(options: ActionOptionsType): boolean;
41
+ /**
42
+ * Provides a summary or description of the action.
43
+ * This can be used for logging, debugging, or documentation purposes to
44
+ * describe what the action does.
45
+ *
46
+ * @returns A string description of the action.
47
+ */
48
+ describe?(): string;
49
+ /**
50
+ * Optional cleanup logic to execute after the main action completes.
51
+ * Implementations can use this for teardown tasks, like removing
52
+ * temporary files or restoring the state altered during execution.
53
+ *
54
+ * @returns A promise that resolves after cleanup is complete.
55
+ */
56
+ cleanup?(): Promise<void>;
57
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { ActionInterface } from "./ActionInterface";
2
+ export interface ActionPlugin {
3
+ registerActions(): Record<string, new () => ActionInterface>;
4
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ import { MetadataInterface } from "./MetadataInterface";
2
+ import { OptionsInterface } from "./OptionsInterface";
3
+ import { StageInterface } from "./StageInterface";
4
+ /**
5
+ * ConfigInterface defines the overall configuration for the packaging
6
+ * pipeline. This configuration determines the structure, behavior, and
7
+ * execution flow of the entire pipeline, including stages, global settings,
8
+ * and optional metadata.
9
+ */
10
+ export interface ConfigInterface {
11
+ /**
12
+ * Optional metadata that provides additional context or descriptive
13
+ * information about the pipeline configuration. This can include the
14
+ * pipeline name, version, author, or any other relevant details. Useful
15
+ * for documentation, tracking, and integration with external systems.
16
+ */
17
+ metadata?: MetadataInterface;
18
+ /**
19
+ * Optional global options that apply universally across the entire
20
+ * pipeline. These options can control aspects like logging levels, step
21
+ * timeouts, error handling, concurrency limits, and other settings that
22
+ * affect the overall pipeline behavior.
23
+ */
24
+ options?: OptionsInterface;
25
+ /**
26
+ * A list of stages to be executed in the pipeline. Stages run in parallel
27
+ * by default, but dependencies specified in each stage can enforce a
28
+ * specific execution order. Stages should be defined in the logical
29
+ * sequence that aligns with the pipeline's objectives.
30
+ */
31
+ stages: StageInterface[];
32
+ /**
33
+ * An optional function or set of rules for validating the configuration
34
+ * before execution. This can be used to ensure that the pipeline meets
35
+ * certain criteria or standards before running, catching potential
36
+ * configuration errors early.
37
+ *
38
+ * @param config - The full configuration object to validate.
39
+ * @returns A boolean indicating whether the configuration is valid, or
40
+ * throws an error if validation fails.
41
+ */
42
+ validateConfig?(config: ConfigInterface): boolean;
43
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * LiveOptionsInterface defines the configuration settings for live reload
3
+ * functionality, which enables dynamic updates to the application during
4
+ * development.
5
+ */
6
+ export interface LiveOptionsInterface {
7
+ /**
8
+ * Enables or disables the live reload feature.
9
+ * - `true`: Live reload is enabled, and the server will listen for changes.
10
+ * - `false`: Live reload is disabled.
11
+ *
12
+ * @default false
13
+ */
14
+ enabled?: boolean;
15
+ /**
16
+ * The port number on which the live reload server will listen.
17
+ * If not specified, a default port (e.g., 3000) may be used.
18
+ *
19
+ * @example 3000
20
+ * @default 3000
21
+ */
22
+ port?: number;
23
+ /**
24
+ * The root directory for serving static files during live reload.
25
+ * This path is relative to the project root and is used to serve public
26
+ * assets.
27
+ *
28
+ * @example "public"
29
+ * @default "public"
30
+ */
31
+ root?: string;
32
+ /**
33
+ * An array of paths to monitor for file changes. These paths can use glob
34
+ * patterns for flexibility
35
+ */
36
+ watchPaths?: string[];
37
+ /**
38
+ * An array of paths or patterns to exclude from monitoring. Use this to
39
+ * ignore directories or files that do not need to trigger reloads
40
+ */
41
+ ignoredPaths?: string[];
42
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });