kist 0.0.0 → 0.1.30

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 (236) 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 +69 -0
  90. package/js/core/config/ConfigStore.js +168 -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.ts +201 -0
  196. package/ts/core/config/defaultConfig.ts +154 -0
  197. package/ts/core/config/index.ts +0 -0
  198. package/ts/core/index.ts +34 -0
  199. package/ts/core/pipeline/Action.ts +101 -0
  200. package/ts/core/pipeline/ActionRegistry.ts +216 -0
  201. package/ts/core/pipeline/Pipeline.ts +121 -0
  202. package/ts/core/pipeline/PipelineManager.ts +170 -0
  203. package/ts/core/pipeline/Stage.ts +131 -0
  204. package/ts/core/pipeline/Step.ts +96 -0
  205. package/ts/core/pipeline/index.ts +0 -0
  206. package/ts/core/validation/ActionValidator.ts +97 -0
  207. package/ts/core/validation/ConfigValidator.ts +103 -0
  208. package/ts/core/validation/OptionsValidator.ts +179 -0
  209. package/ts/core/validation/StageValidator.ts +175 -0
  210. package/ts/core/validation/StepValidator.ts +203 -0
  211. package/ts/core/validation/index.ts +0 -0
  212. package/ts/index.ts +26 -0
  213. package/ts/interface/ActionInterface.ts +70 -0
  214. package/ts/interface/ActionPlugin.ts +14 -0
  215. package/ts/interface/ConfigInterface.ts +55 -0
  216. package/ts/interface/File.ts +24 -0
  217. package/ts/interface/LiveOptionsInterface.ts +46 -0
  218. package/ts/interface/MetadataInterface.ts +105 -0
  219. package/ts/interface/OptionsInterface.ts +58 -0
  220. package/ts/interface/PackageJson.ts +171 -0
  221. package/ts/interface/PipelineOptionsInterface.ts +74 -0
  222. package/ts/interface/SVG.ts +84 -0
  223. package/ts/interface/StageInterface.ts +96 -0
  224. package/ts/interface/StepInterface.ts +83 -0
  225. package/ts/interface/StepOptionsInterface.ts +57 -0
  226. package/ts/interface/index.ts +9 -0
  227. package/ts/kist.ts +161 -0
  228. package/ts/live/LiveServer.ts +311 -0
  229. package/ts/live/LiveWatcher.ts +150 -0
  230. package/ts/live/index.ts +11 -0
  231. package/ts/logger/Logger.ts +187 -0
  232. package/ts/logger/LoggerStyles.ts +28 -0
  233. package/ts/logger/index.ts +0 -0
  234. package/ts/types/ActionOptionsType.ts +10 -0
  235. package/ts/types/index.ts +3 -0
  236. package/index.js +0 -3
@@ -0,0 +1,130 @@
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.ConfigLoader = void 0;
19
+ const fs_1 = __importDefault(require("fs"));
20
+ const js_yaml_1 = __importDefault(require("js-yaml"));
21
+ const path_1 = __importDefault(require("path"));
22
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
23
+ // ============================================================================
24
+ // Class
25
+ // ============================================================================
26
+ /**
27
+ * ConfigLoader is responsible for loading and parsing configuration files
28
+ * (`kist.yaml` or `kist.yml` by default). It validates the configuration
29
+ * structure and provides it in a usable format for the pipeline.
30
+ * Extends `AbstractProcess` for consistent logging.
31
+ */
32
+ class ConfigLoader extends AbstractProcess_1.AbstractProcess {
33
+ // Constructor
34
+ // ========================================================================
35
+ /**
36
+ * Constructs a ConfigLoader instance.
37
+ * Searches for `kist.yaml` or `kist.yml` in the working directory
38
+ * unless a custom path is provided.
39
+ *
40
+ * @param configPath - Optional custom configuration file path.
41
+ */
42
+ constructor(configPath) {
43
+ super();
44
+ // Parameters
45
+ // ========================================================================
46
+ /**
47
+ * Resolved path to the configuration file, if found.
48
+ */
49
+ this.configPath = null;
50
+ /**
51
+ * Default filenames to search for configuration files.
52
+ */
53
+ this.defaultFilenames = ["kist.yaml", "kist.yml"];
54
+ if (configPath) {
55
+ this.configPath = path_1.default.resolve(process.cwd(), configPath);
56
+ this.logDebug(`Custom configuration path set: ${this.configPath}`);
57
+ }
58
+ else {
59
+ this.logDebug("ConfigLoader initialized without custom path.");
60
+ }
61
+ }
62
+ // Methods
63
+ // ========================================================================
64
+ /**
65
+ * Initializes the loader by locating the configuration file.
66
+ * Searches for `kist.yaml` or `kist.yml` by default.
67
+ *
68
+ * @param configPath - Optional custom configuration file path.
69
+ */
70
+ initialize(configPath) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const searchPaths = configPath ? [configPath] : this.defaultFilenames;
73
+ this.logDebug(`Current working directory: ${process.cwd()}`);
74
+ this.logDebug("Searching for configuration files...");
75
+ for (const fileName of searchPaths) {
76
+ const resolvedPath = path_1.default.resolve(process.cwd(), fileName);
77
+ this.logDebug(`Checking: ${resolvedPath}`);
78
+ try {
79
+ yield fs_1.default.promises.access(resolvedPath, fs_1.default.constants.F_OK | fs_1.default.constants.R_OK);
80
+ this.configPath = resolvedPath;
81
+ this.logDebug(`Configuration file found: ${resolvedPath}`);
82
+ return;
83
+ }
84
+ catch (error) {
85
+ this.logDebug(`File not accessible: ${resolvedPath}`);
86
+ }
87
+ }
88
+ this.logWarn("No configuration file found. Proceeding with default settings.");
89
+ });
90
+ }
91
+ /**
92
+ * Loads and validates the configuration file.
93
+ *
94
+ * @returns Parsed and validated configuration object.
95
+ * @throws Error if the configuration file cannot be read or validated.
96
+ */
97
+ loadConfig() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ if (!this.configPath) {
100
+ this.logWarn("No configuration file found. Using default configuration.");
101
+ return { stages: [] };
102
+ }
103
+ try {
104
+ this.logDebug(`Loading configuration from: ${this.configPath}`);
105
+ const fileContents = yield fs_1.default.promises.readFile(this.configPath, "utf8");
106
+ const config = js_yaml_1.default.load(fileContents);
107
+ this.validateConfig(config);
108
+ this.logDebug(`Successfully loaded configuration from: ${this.configPath}`);
109
+ return config;
110
+ }
111
+ catch (error) {
112
+ this.logError("Failed to load configuration.", error);
113
+ throw new Error(`Failed to load configuration: ${error.message}`);
114
+ }
115
+ });
116
+ }
117
+ /**
118
+ * Validates the structure of the configuration.
119
+ *
120
+ * @param config - The configuration object to validate.
121
+ * @throws Error if validation fails.
122
+ */
123
+ validateConfig(config) {
124
+ if (!Array.isArray(config.stages)) {
125
+ throw new Error("Invalid configuration: 'stages' must be an array.");
126
+ }
127
+ this.logDebug("Configuration structure validated successfully.");
128
+ }
129
+ }
130
+ exports.ConfigLoader = ConfigLoader;
@@ -0,0 +1,69 @@
1
+ import { ConfigInterface } from "../../interface/ConfigInterface";
2
+ import { AbstractProcess } from "../abstract/AbstractProcess";
3
+ /**
4
+ * ConfigStore is a singleton that loads and manages the application's
5
+ * configuration.
6
+ * It prioritizes CLI arguments over configuration file values.
7
+ */
8
+ export declare class ConfigStore extends AbstractProcess {
9
+ /**
10
+ * Singleton instance of the ConfigStore.
11
+ */
12
+ private static instance;
13
+ /**
14
+ * The current configuration stored in the ConfigStore.
15
+ */
16
+ private config;
17
+ /**
18
+ * Private constructor to enforce the singleton pattern.
19
+ * Initializes the store with the default configuration.
20
+ */
21
+ private constructor();
22
+ /**
23
+ * Retrieves the singleton instance of ConfigStore, initializing it if
24
+ * necessary.
25
+ * @returns The singleton instance of ConfigStore.
26
+ */
27
+ static getInstance(): ConfigStore;
28
+ /**
29
+ * Retrieves a value from the configuration by key.
30
+ * Supports nested keys using dot notation (e.g., "options.logLevel").
31
+ *
32
+ * @param key - The key of the configuration to retrieve.
33
+ * @returns The configuration value or undefined if not found.
34
+ */
35
+ get<T>(key: string): T | undefined;
36
+ /**
37
+ * Sets a value in the configuration by key.
38
+ * Supports nested keys using dot notation (e.g., "options.logLevel").
39
+ *
40
+ * @param key - The key of the configuration to set.
41
+ * @param value - The value to set.
42
+ */
43
+ set(key: string, value: unknown): void;
44
+ /**
45
+ * Merges the provided configuration into the existing configuration.
46
+ * Uses a deep merge strategy to combine objects and overwrite primitives.
47
+ *
48
+ * @param newConfig - The new configuration to merge.
49
+ */
50
+ merge(newConfig: Partial<ConfigInterface>): void;
51
+ /**
52
+ * Retrieves the current configuration.
53
+ *
54
+ * @returns The current configuration object.
55
+ */
56
+ getConfig(): ConfigInterface;
57
+ /**
58
+ * Prints the current configuration to the console in a readable format.
59
+ */
60
+ print(): void;
61
+ /**
62
+ * Deeply merges two objects.
63
+ *
64
+ * @param target - The target object to merge into.
65
+ * @param source - The source object to merge from.
66
+ * @returns The merged object.
67
+ */
68
+ private deepMerge;
69
+ }
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConfigStore = void 0;
7
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
8
+ const defaultConfig_1 = require("./defaultConfig");
9
+ // ============================================================================
10
+ // Class
11
+ // ============================================================================
12
+ /**
13
+ * ConfigStore is a singleton that loads and manages the application's
14
+ * configuration.
15
+ * It prioritizes CLI arguments over configuration file values.
16
+ */
17
+ class ConfigStore extends AbstractProcess_1.AbstractProcess {
18
+ // Constructor
19
+ // ========================================================================
20
+ /**
21
+ * Private constructor to enforce the singleton pattern.
22
+ * Initializes the store with the default configuration.
23
+ */
24
+ constructor() {
25
+ super();
26
+ this.config = defaultConfig_1.defaultConfig;
27
+ this.logDebug("ConfigStore initialized with default configuration.");
28
+ }
29
+ // Static Methods
30
+ // ========================================================================
31
+ /**
32
+ * Retrieves the singleton instance of ConfigStore, initializing it if
33
+ * necessary.
34
+ * @returns The singleton instance of ConfigStore.
35
+ */
36
+ static getInstance() {
37
+ if (!ConfigStore.instance) {
38
+ ConfigStore.instance = new ConfigStore();
39
+ }
40
+ return ConfigStore.instance;
41
+ }
42
+ // Instance Methods
43
+ // ========================================================================
44
+ /**
45
+ * Retrieves a value from the configuration by key.
46
+ * Supports nested keys using dot notation (e.g., "options.logLevel").
47
+ *
48
+ * @param key - The key of the configuration to retrieve.
49
+ * @returns The configuration value or undefined if not found.
50
+ */
51
+ get(key) {
52
+ const keys = key.split(".");
53
+ let current = this.config;
54
+ for (const k of keys) {
55
+ if (current[k] === undefined) {
56
+ return undefined;
57
+ }
58
+ current = current[k];
59
+ }
60
+ this.logDebug(`Configuration key "${key}" retrieved with value: ${JSON.stringify(current)}`);
61
+ return current;
62
+ }
63
+ /**
64
+ * Sets a value in the configuration by key.
65
+ * Supports nested keys using dot notation (e.g., "options.logLevel").
66
+ *
67
+ * @param key - The key of the configuration to set.
68
+ * @param value - The value to set.
69
+ */
70
+ set(key, value) {
71
+ const keys = key.split(".");
72
+ let current = this.config;
73
+ for (let i = 0; i < keys.length - 1; i++) {
74
+ const k = keys[i];
75
+ if (!current[k] || typeof current[k] !== "object") {
76
+ current[k] = {};
77
+ }
78
+ current = current[k];
79
+ }
80
+ current[keys[keys.length - 1]] = value;
81
+ this.logDebug(`Set configuration key "${key}" to: ${JSON.stringify(value)}`);
82
+ }
83
+ /**
84
+ * Merges the provided configuration into the existing configuration.
85
+ * Uses a deep merge strategy to combine objects and overwrite primitives.
86
+ *
87
+ * @param newConfig - The new configuration to merge.
88
+ */
89
+ merge(newConfig) {
90
+ this.config = this.deepMerge(this.config, newConfig);
91
+ this.logDebug("Configuration successfully merged.");
92
+ }
93
+ /**
94
+ * Retrieves the current configuration.
95
+ *
96
+ * @returns The current configuration object.
97
+ */
98
+ getConfig() {
99
+ return this.config;
100
+ }
101
+ /**
102
+ * Prints the current configuration to the console in a readable format.
103
+ */
104
+ print() {
105
+ console.log("Current Configuration:");
106
+ console.log(JSON.stringify(this.config, null, 2));
107
+ }
108
+ /**
109
+ * Deeply merges two objects.
110
+ *
111
+ * @param target - The target object to merge into.
112
+ * @param source - The source object to merge from.
113
+ * @returns The merged object.
114
+ */
115
+ // private deepMerge(target: any, source: any): any {
116
+ // if (typeof target !== "object" || target === null) {
117
+ // return source;
118
+ // }
119
+ // for (const key of Object.keys(source)) {
120
+ // if (
121
+ // source[key] &&
122
+ // typeof source[key] === "object" &&
123
+ // !Array.isArray(source[key])
124
+ // ) {
125
+ // if (!target[key] || typeof target[key] !== "object") {
126
+ // target[key] = {};
127
+ // }
128
+ // target[key] = this.deepMerge(target[key], source[key]);
129
+ // } else {
130
+ // target[key] = source[key];
131
+ // }
132
+ // }
133
+ // return target;
134
+ // }
135
+ deepMerge(target, source) {
136
+ if (typeof target !== "object" || target === null) {
137
+ return source;
138
+ }
139
+ for (const key of Object.keys(source)) {
140
+ // Prevent prototype pollution
141
+ if (key === "__proto__" ||
142
+ key === "constructor" ||
143
+ key === "prototype") {
144
+ this.logWarn(`Skipping potentially unsafe key: "${key}"`);
145
+ continue;
146
+ }
147
+ if (source[key] &&
148
+ typeof source[key] === "object" &&
149
+ !Array.isArray(source[key])) {
150
+ if (!target[key] || typeof target[key] !== "object") {
151
+ target[key] = {};
152
+ }
153
+ target[key] = this.deepMerge(target[key], source[key]);
154
+ }
155
+ else {
156
+ target[key] = source[key];
157
+ }
158
+ }
159
+ return target;
160
+ }
161
+ }
162
+ exports.ConfigStore = ConfigStore;
163
+ // Parameters
164
+ // ========================================================================
165
+ /**
166
+ * Singleton instance of the ConfigStore.
167
+ */
168
+ ConfigStore.instance = null;
@@ -0,0 +1,5 @@
1
+ import { ConfigInterface } from "../../interface/ConfigInterface";
2
+ /**
3
+ * Default configuration for the kist pipeline.
4
+ */
5
+ export declare const defaultConfig: ConfigInterface;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.defaultConfig = void 0;
7
+ // ============================================================================
8
+ // Constants
9
+ // ============================================================================
10
+ /**
11
+ * Default configuration for the kist pipeline.
12
+ */
13
+ exports.defaultConfig = {
14
+ metadata: {
15
+ /**
16
+ * The name of the pipeline for identification and reporting.
17
+ */
18
+ name: "kist pipeline",
19
+ /**
20
+ * Semantic version of the pipeline configuration for tracking changes.
21
+ */
22
+ version: "1.0.0",
23
+ /**
24
+ * Detailed description outlining the purpose of the pipeline.
25
+ */
26
+ description: "A generic pipeline configuration for kist.",
27
+ /**
28
+ * The author or owner of the pipeline configuration.
29
+ */
30
+ author: "Anonymous",
31
+ /**
32
+ * Arbitrary key-value pairs to describe the pipeline.
33
+ */
34
+ tags: {
35
+ category: "generic",
36
+ environment: "development",
37
+ },
38
+ /**
39
+ * Timestamp indicating when the configuration was created or last updated.
40
+ * Automatically set to the current date/time.
41
+ */
42
+ timestamp: new Date().toISOString(),
43
+ /**
44
+ * License under which the pipeline configuration is shared or used.
45
+ */
46
+ license: "MIT",
47
+ /**
48
+ * URL pointing to documentation or additional resources for the pipeline.
49
+ */
50
+ documentation: "https://example.com/documentation",
51
+ /**
52
+ * Contact information for questions or support.
53
+ */
54
+ contact: "support@example.com",
55
+ /**
56
+ * Dependencies or related systems required by the pipeline configuration.
57
+ */
58
+ dependencies: ["Node.js >=14.0", "Docker >=20.10"],
59
+ /**
60
+ * Environments where the pipeline is intended to run.
61
+ */
62
+ environments: ["local", "CI/CD", "staging", "production"],
63
+ },
64
+ options: {
65
+ /**
66
+ * Configuration settings for live reload functionality.
67
+ */
68
+ live: {
69
+ /**
70
+ * Indicates whether live reload is enabled.
71
+ */
72
+ enabled: false,
73
+ /**
74
+ * Port on which the live reload server listens.
75
+ */
76
+ port: 3000,
77
+ /**
78
+ * Root directory for serving static files.
79
+ */
80
+ root: "public",
81
+ /**
82
+ * Paths to watch for changes.
83
+ */
84
+ watchPaths: ["src/**/*", "config/**/*", "kist.yaml"],
85
+ /**
86
+ * Paths or patterns to ignore while watching.
87
+ */
88
+ ignoredPaths: ["node_modules/*"],
89
+ },
90
+ /**
91
+ * Configuration options for pipeline execution.
92
+ */
93
+ pipeline: {
94
+ /**
95
+ * Default timeout in milliseconds for each step in the pipeline.
96
+ */
97
+ stepTimeout: 30000,
98
+ /**
99
+ * Whether to halt the pipeline if a step fails.
100
+ */
101
+ haltOnFailure: true,
102
+ /**
103
+ * Maximum number of concurrent stages allowed to run in parallel.
104
+ * Set to 0 for no limit.
105
+ */
106
+ maxConcurrentStages: 0,
107
+ /**
108
+ * Retry strategy for steps that fail.
109
+ */
110
+ retryStrategy: {
111
+ /**
112
+ * Number of retry attempts before marking a step as failed.
113
+ */
114
+ retries: 3,
115
+ /**
116
+ * Delay in milliseconds between retry attempts.
117
+ */
118
+ delay: 1000,
119
+ },
120
+ },
121
+ /**
122
+ * Logging level for the pipeline.
123
+ */
124
+ logLevel: "info",
125
+ },
126
+ /**
127
+ * Default stages for the pipeline. Initially set to an empty array.
128
+ * Users can define and add their own stages.
129
+ */
130
+ stages: [],
131
+ };
@@ -0,0 +1,60 @@
1
+ import { ActionInterface } from "../../interface/ActionInterface";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
3
+ import { AbstractProcess } from "../abstract/AbstractProcess";
4
+ /**
5
+ * Action is an abstract base class that serves as a foundation for all step
6
+ * actions in the pipeline. It provides a consistent structure and utility
7
+ * methods for derived action classes, making it easier to implement and
8
+ * integrate custom behaviors like `BuildAction`, `LintAction`, and more.
9
+ */
10
+ export declare abstract class Action extends AbstractProcess implements ActionInterface {
11
+ /**
12
+ * Gets the unique name of the action.
13
+ * The name is derived from the class name of the concrete action.
14
+ */
15
+ get name(): string;
16
+ /**
17
+ * Constructs a new Action instance.
18
+ * Inherits the logger from the AbstractProcess base class.
19
+ */
20
+ constructor();
21
+ /**
22
+ * Provides a basic validation mechanism for action options.
23
+ * Derived classes can override this method to implement specific
24
+ * validation logic.
25
+ *
26
+ * @param options - The options to validate, ensuring they meet the
27
+ * action"s specific requirements.
28
+ * @returns A boolean indicating whether the options are valid. Default
29
+ * implementation always returns true.
30
+ */
31
+ validateOptions(options: ActionOptionsType): boolean;
32
+ /**
33
+ * Abstract method that must be implemented by derived classes to perform
34
+ * the action"s main logic.
35
+ * This method is invoked during the step execution process.
36
+ *
37
+ * @param options - A structured set of options specific to the action's
38
+ * configuration.
39
+ * @returns A Promise that resolves when the action completes successfully,
40
+ * or rejects with an error if the action fails.
41
+ */
42
+ abstract execute(options: ActionOptionsType): Promise<void>;
43
+ /**
44
+ * Provides a summary or description of the action.
45
+ * This method can be overridden by derived classes to provide more
46
+ * specific details about the action.
47
+ *
48
+ * @returns A string description of the action.
49
+ */
50
+ describe(): string;
51
+ /**
52
+ * Logs a message indicating the start of the action's execution.
53
+ * Useful for tracking progress in pipelines with multiple steps.
54
+ */
55
+ protected logStart(): void;
56
+ /**
57
+ * Logs a message indicating the successful completion of the action.
58
+ */
59
+ protected logSuccess(): void;
60
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Action = void 0;
7
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
8
+ // ============================================================================
9
+ // Class
10
+ // ============================================================================
11
+ /**
12
+ * Action is an abstract base class that serves as a foundation for all step
13
+ * actions in the pipeline. It provides a consistent structure and utility
14
+ * methods for derived action classes, making it easier to implement and
15
+ * integrate custom behaviors like `BuildAction`, `LintAction`, and more.
16
+ */
17
+ class Action extends AbstractProcess_1.AbstractProcess {
18
+ // Parameters
19
+ // ========================================================================
20
+ /**
21
+ * Gets the unique name of the action.
22
+ * The name is derived from the class name of the concrete action.
23
+ */
24
+ get name() {
25
+ return this.constructor.name;
26
+ }
27
+ // Constructor
28
+ // ========================================================================
29
+ /**
30
+ * Constructs a new Action instance.
31
+ * Inherits the logger from the AbstractProcess base class.
32
+ */
33
+ constructor() {
34
+ super();
35
+ }
36
+ // Methods
37
+ // ========================================================================
38
+ /**
39
+ * Provides a basic validation mechanism for action options.
40
+ * Derived classes can override this method to implement specific
41
+ * validation logic.
42
+ *
43
+ * @param options - The options to validate, ensuring they meet the
44
+ * action"s specific requirements.
45
+ * @returns A boolean indicating whether the options are valid. Default
46
+ * implementation always returns true.
47
+ */
48
+ validateOptions(options) {
49
+ // Default validation: always returns true, can be overridden in
50
+ // derived classes
51
+ return true;
52
+ }
53
+ /**
54
+ * Provides a summary or description of the action.
55
+ * This method can be overridden by derived classes to provide more
56
+ * specific details about the action.
57
+ *
58
+ * @returns A string description of the action.
59
+ */
60
+ describe() {
61
+ return "Base action for executing steps in the pipeline.";
62
+ }
63
+ /**
64
+ * Logs a message indicating the start of the action's execution.
65
+ * Useful for tracking progress in pipelines with multiple steps.
66
+ */
67
+ logStart() {
68
+ this.logInfo(`Starting action: ${this.name}`);
69
+ }
70
+ /**
71
+ * Logs a message indicating the successful completion of the action.
72
+ */
73
+ logSuccess() {
74
+ this.logInfo(`Successfully completed action: ${this.name}`);
75
+ }
76
+ }
77
+ exports.Action = Action;