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,62 @@
1
+ import { AbstractProcess } from "../core/abstract/AbstractProcess";
2
+ import { OptionsInterface } from "../interface/OptionsInterface";
3
+ /**
4
+ * ArgumentParser handles parsing and validating command-line arguments
5
+ * against the structure defined in OptionsInterface.
6
+ * Extends AbstractProcess for consistent logging.
7
+ */
8
+ export declare class ArgumentParser extends AbstractProcess {
9
+ /**
10
+ * Command-line arguments to parse, excluding the Node.js and script path.
11
+ */
12
+ private args;
13
+ /**
14
+ * Instance of OptionsValidator for validating parsed arguments.
15
+ */
16
+ private validator;
17
+ /**
18
+ * Initializes the ArgumentParser with command-line arguments and an
19
+ * instance of OptionsValidator for validation.
20
+ *
21
+ * @param args - Command-line arguments. Defaults to `process.argv.slice(2)`.
22
+ */
23
+ constructor();
24
+ /**
25
+ * Retrieves the value of a specific option from the CLI arguments, with
26
+ * validation.
27
+ *
28
+ * @param key - The name of the option (matches keys in OptionsInterface).
29
+ * @param options - Additional options:
30
+ * - `default`: The default value to return if the option is not found.
31
+ * @returns The value of the option or the default value if not found.
32
+ * @throws Error if the value is invalid based on the validation rules.
33
+ */
34
+ getOption<K extends keyof OptionsInterface>(key: K, options?: {
35
+ default?: OptionsInterface[K];
36
+ }): OptionsInterface[K] | undefined;
37
+ /**
38
+ * Checks if a specific flag exists in the CLI arguments.
39
+ *
40
+ * @param key - The name of the flag to check (e.g., "dryRun").
41
+ * @returns `true` if the flag is present, otherwise `false`.
42
+ */
43
+ hasFlag(key: keyof OptionsInterface): boolean;
44
+ /**
45
+ * Parses all CLI arguments into a key-value object.
46
+ * Flags are treated as boolean if not followed by a value.
47
+ *
48
+ * Example:
49
+ * --live --mode development => { live: true, mode: "development" }
50
+ *
51
+ * @returns A key-value object of all parsed CLI arguments.
52
+ */
53
+ getAllFlags(): Record<string, string | boolean>;
54
+ /**
55
+ * Retrieves a specific flag value.
56
+ *
57
+ * @param key - The flag name to retrieve.
58
+ * @param defaultValue - The default value if the flag is not present.
59
+ * @returns The value of the flag or the default value.
60
+ */
61
+ getFlag(key: string, defaultValue?: string | boolean): string | boolean;
62
+ }
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ArgumentParser = void 0;
7
+ const AbstractProcess_1 = require("../core/abstract/AbstractProcess");
8
+ const OptionsValidator_1 = require("../core/validation/OptionsValidator");
9
+ // ============================================================================
10
+ // Class
11
+ // ============================================================================
12
+ /**
13
+ * ArgumentParser handles parsing and validating command-line arguments
14
+ * against the structure defined in OptionsInterface.
15
+ * Extends AbstractProcess for consistent logging.
16
+ */
17
+ class ArgumentParser extends AbstractProcess_1.AbstractProcess {
18
+ // Constructor
19
+ // ========================================================================
20
+ /**
21
+ * Initializes the ArgumentParser with command-line arguments and an
22
+ * instance of OptionsValidator for validation.
23
+ *
24
+ * @param args - Command-line arguments. Defaults to `process.argv.slice(2)`.
25
+ */
26
+ constructor() {
27
+ super();
28
+ // Skip Node.js and script path
29
+ this.args = process.argv.slice(2);
30
+ // console.log(process.argv.slice(2))
31
+ // this.args = args;
32
+ this.validator = new OptionsValidator_1.OptionsValidator();
33
+ this.logDebug("ArgumentParser initialized with arguments.");
34
+ }
35
+ // Methods
36
+ // ========================================================================
37
+ /**
38
+ * Retrieves the value of a specific option from the CLI arguments, with
39
+ * validation.
40
+ *
41
+ * @param key - The name of the option (matches keys in OptionsInterface).
42
+ * @param options - Additional options:
43
+ * - `default`: The default value to return if the option is not found.
44
+ * @returns The value of the option or the default value if not found.
45
+ * @throws Error if the value is invalid based on the validation rules.
46
+ */
47
+ getOption(key, options) {
48
+ const flag = `--${key}`;
49
+ const flagIndex = this.args.findIndex((arg) => arg === flag);
50
+ const value = flagIndex !== -1 && this.args[flagIndex + 1]
51
+ ? this.args[flagIndex + 1]
52
+ : options === null || options === void 0 ? void 0 : options.default;
53
+ if (value !== undefined) {
54
+ // Create a partial object to validate the specific key-value pair
55
+ const partialOption = {
56
+ [key]: value,
57
+ };
58
+ // Validate the key-value pair
59
+ this.validator.validate(partialOption);
60
+ }
61
+ this.logInfo(`Retrieved option "${key}" with value: ${value}`);
62
+ return value;
63
+ }
64
+ /**
65
+ * Checks if a specific flag exists in the CLI arguments.
66
+ *
67
+ * @param key - The name of the flag to check (e.g., "dryRun").
68
+ * @returns `true` if the flag is present, otherwise `false`.
69
+ */
70
+ hasFlag(key) {
71
+ const flag = `--${key}`;
72
+ const exists = this.args.includes(flag);
73
+ this.logInfo(`Flag "${flag}" is ${exists ? "present" : "not present"}.`);
74
+ return exists;
75
+ }
76
+ /**
77
+ * Parses all CLI arguments into a key-value object.
78
+ * Flags are treated as boolean if not followed by a value.
79
+ *
80
+ * Example:
81
+ * --live --mode development => { live: true, mode: "development" }
82
+ *
83
+ * @returns A key-value object of all parsed CLI arguments.
84
+ */
85
+ getAllFlags() {
86
+ const flags = {};
87
+ for (let i = 0; i < this.args.length; i++) {
88
+ const arg = this.args[i];
89
+ if (arg.startsWith("--")) {
90
+ const key = arg.slice(2);
91
+ const nextArg = this.args[i + 1];
92
+ if (nextArg && !nextArg.startsWith("--")) {
93
+ flags[key] = nextArg;
94
+ // Skip the next argument since it's a value
95
+ i++;
96
+ }
97
+ else {
98
+ // Flag with no value is treated as boolean true
99
+ flags[key] = true;
100
+ }
101
+ }
102
+ }
103
+ return flags;
104
+ }
105
+ /**
106
+ * Retrieves a specific flag value.
107
+ *
108
+ * @param key - The flag name to retrieve.
109
+ * @param defaultValue - The default value if the flag is not present.
110
+ * @returns The value of the flag or the default value.
111
+ */
112
+ getFlag(key, defaultValue = false) {
113
+ var _a;
114
+ const flags = this.getAllFlags();
115
+ return (_a = flags[key]) !== null && _a !== void 0 ? _a : defaultValue;
116
+ }
117
+ }
118
+ exports.ArgumentParser = ArgumentParser;
package/js/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ /**
4
+ * Note: The `#!/usr/bin/env node` shebang ensures that the script can be executed
5
+ * directly as a Node.js script on compatible systems.
6
+ */
package/js/cli.js ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // ============================================================================
4
+ // Imports
5
+ // ============================================================================
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const ArgumentParser_1 = require("./cli/ArgumentParser");
17
+ const ConfigLoader_1 = require("./core/config/ConfigLoader");
18
+ const ConfigStore_1 = require("./core/config/ConfigStore");
19
+ const kist_1 = require("./kist");
20
+ // ============================================================================
21
+ // Main Entry Point
22
+ // ============================================================================
23
+ /**
24
+ * The entry point for the Kist CLI application. Sets up the runtime
25
+ * environment, loads configuration, and invokes the Kist class.
26
+ */
27
+ (() => __awaiter(void 0, void 0, void 0, function* () {
28
+ try {
29
+ // console.log("Raw arguments:", process.argv);
30
+ // Initialize CLI argument parser
31
+ const parser = new ArgumentParser_1.ArgumentParser();
32
+ const cliOptions = parser.getAllFlags();
33
+ // console.log(cliOptions)
34
+ // Initialize ConfigStore
35
+ const configStore = ConfigStore_1.ConfigStore.getInstance();
36
+ // Initialize ConfigStore and load configuration
37
+ const configLoader = new ConfigLoader_1.ConfigLoader();
38
+ yield configLoader.initialize();
39
+ const fileConfig = yield configLoader.loadConfig();
40
+ // Merge Configs
41
+ // configStore.print()
42
+ configStore.merge(fileConfig); // Merge file-based config
43
+ // configStore.print()
44
+ configStore.merge({ options: cliOptions }); // Merge CLI options
45
+ // configStore.print()
46
+ // Create a Kist instance and execute the workflow
47
+ const kist = new kist_1.Kist();
48
+ yield kist.run();
49
+ }
50
+ catch (error) {
51
+ console.error(`[CLI] An unexpected error occurred:`, error);
52
+ process.exit(1);
53
+ }
54
+ }))();
55
+ /**
56
+ * Note: The `#!/usr/bin/env node` shebang ensures that the script can be executed
57
+ * directly as a Node.js script on compatible systems.
58
+ */
@@ -0,0 +1,62 @@
1
+ import { Logger } from "../../logger/Logger";
2
+ /**
3
+ * AbstractProcess provides consistent logging functionality to its subclasses.
4
+ * It leverages a centralized logger to manage different log levels and
5
+ * ensures logging consistency across the application.
6
+ */
7
+ export declare abstract class AbstractProcess {
8
+ /**
9
+ * Logger instance for handling log messages.
10
+ */
11
+ protected readonly logger: Logger;
12
+ /**
13
+ * Constructs an AbstractProcess instance.
14
+ * Initializes the logger to ensure logging capabilities are available to
15
+ * subclasses.
16
+ */
17
+ constructor();
18
+ /**
19
+ * Logs an informational message with the originating class name as context.
20
+ * Use this for standard informational messages.
21
+ * @param message - The message to log.
22
+ */
23
+ protected logInfo(message: string): void;
24
+ /**
25
+ * Logs a debug message with the originating class name as context.
26
+ * @param message - The debug message to log.
27
+ */
28
+ protected logDebug(message: string): void;
29
+ /**
30
+ * Logs a warning message with the originating class name as context.
31
+ * Use this to highlight potential issues that are non-critical.
32
+ * @param message - The warning message to log.
33
+ */
34
+ protected logWarn(message: string): void;
35
+ /**
36
+ * Logs an error message with the originating class name as context.
37
+ * Handles any type of error and ensures consistent error reporting.
38
+ * Use this for logging critical issues or exceptions.
39
+ *
40
+ * @param message - A custom message providing additional context for
41
+ * the error.
42
+ * @param error - (Optional) The error to log. Can be a string, an Error
43
+ * object, or other types.
44
+ */
45
+ protected logError(message: string, error?: unknown): void;
46
+ /**
47
+ * Formats an error message for logging.
48
+ * Combines a custom message with additional error details if available.
49
+ *
50
+ * @param message - The base error message.
51
+ * @param error - Additional error information, such as an Error object.
52
+ * @returns A formatted string combining the message and error details.
53
+ */
54
+ private formatError;
55
+ /**
56
+ * Logs a success message with the originating class name as context.
57
+ * Use this to indicate successful completion of a process or step.
58
+ *
59
+ * @param message - The success message to log.
60
+ */
61
+ protected logSuccess(message: string): void;
62
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AbstractProcess = void 0;
7
+ const Logger_1 = require("../../logger/Logger");
8
+ // ============================================================================
9
+ // Class
10
+ // ============================================================================
11
+ /**
12
+ * AbstractProcess provides consistent logging functionality to its subclasses.
13
+ * It leverages a centralized logger to manage different log levels and
14
+ * ensures logging consistency across the application.
15
+ */
16
+ class AbstractProcess {
17
+ // Constructor
18
+ // ========================================================================
19
+ /**
20
+ * Constructs an AbstractProcess instance.
21
+ * Initializes the logger to ensure logging capabilities are available to
22
+ * subclasses.
23
+ */
24
+ constructor() {
25
+ this.logger = Logger_1.Logger.getInstance();
26
+ }
27
+ // Logging Methods
28
+ // ========================================================================
29
+ /**
30
+ * Logs an informational message with the originating class name as context.
31
+ * Use this for standard informational messages.
32
+ * @param message - The message to log.
33
+ */
34
+ logInfo(message) {
35
+ this.logger.logInfo(this.constructor.name, message);
36
+ }
37
+ /**
38
+ * Logs a debug message with the originating class name as context.
39
+ * @param message - The debug message to log.
40
+ */
41
+ logDebug(message) {
42
+ this.logger.logDebug(this.constructor.name, message);
43
+ }
44
+ /**
45
+ * Logs a warning message with the originating class name as context.
46
+ * Use this to highlight potential issues that are non-critical.
47
+ * @param message - The warning message to log.
48
+ */
49
+ logWarn(message) {
50
+ this.logger.logWarn(this.constructor.name, message);
51
+ }
52
+ /**
53
+ * Logs an error message with the originating class name as context.
54
+ * Handles any type of error and ensures consistent error reporting.
55
+ * Use this for logging critical issues or exceptions.
56
+ *
57
+ * @param message - A custom message providing additional context for
58
+ * the error.
59
+ * @param error - (Optional) The error to log. Can be a string, an Error
60
+ * object, or other types.
61
+ */
62
+ logError(message, error) {
63
+ const errorMessage = this.formatError(message, error);
64
+ this.logger.logError(this.constructor.name, errorMessage);
65
+ }
66
+ /**
67
+ * Formats an error message for logging.
68
+ * Combines a custom message with additional error details if available.
69
+ *
70
+ * @param message - The base error message.
71
+ * @param error - Additional error information, such as an Error object.
72
+ * @returns A formatted string combining the message and error details.
73
+ */
74
+ formatError(message, error) {
75
+ if (error instanceof Error) {
76
+ return `${message}: ${error.message}`;
77
+ }
78
+ else if (typeof error === "string") {
79
+ return `${message}: ${error}`;
80
+ }
81
+ else if (error) {
82
+ return `${message}: ${JSON.stringify(error)}`;
83
+ }
84
+ return message;
85
+ }
86
+ /**
87
+ * Logs a success message with the originating class name as context.
88
+ * Use this to indicate successful completion of a process or step.
89
+ *
90
+ * @param message - The success message to log.
91
+ */
92
+ logSuccess(message) {
93
+ this.logger.logInfo(this.constructor.name, message);
94
+ }
95
+ }
96
+ exports.AbstractProcess = AbstractProcess;
@@ -0,0 +1,72 @@
1
+ import { AbstractProcess } from "../abstract/AbstractProcess";
2
+ /**
3
+ * AbstractValidator provides a base class for validation.
4
+ * Extends AbstractProcess for consistent logging and validation utility
5
+ * methods.
6
+ * Subclasses should implement the specific `validateProperty` method for
7
+ * custom validation logic.
8
+ */
9
+ export declare abstract class AbstractValidator<T> extends AbstractProcess {
10
+ constructor();
11
+ /**
12
+ * Validates an entire object.
13
+ * @param target - The object to validate.
14
+ * @throws Error if validation fails for any property.
15
+ */
16
+ validate(target: T): void;
17
+ /**
18
+ * Validates a specific property of the object.
19
+ * Subclasses must implement this method to provide specific validation logic.
20
+ *
21
+ * @param key - The key of the property being validated.
22
+ * @param value - The value of the property being validated.
23
+ */
24
+ protected abstract validateProperty<K extends keyof T>(key: K, value: T[K]): void;
25
+ /**
26
+ * Validates a numeric value.
27
+ *
28
+ * @param key - The key being validated.
29
+ * @param value - The numeric value to validate.
30
+ * @throws Error if the value is not a non-negative number.
31
+ */
32
+ protected validateNumber<K extends keyof T>(key: K, value: T[K]): void;
33
+ /**
34
+ * Validates a boolean value.
35
+ *
36
+ * @param key - The key being validated.
37
+ * @param value - The boolean value to validate.
38
+ * @throws Error if the value is not a boolean.
39
+ */
40
+ protected validateBoolean<K extends keyof T>(key: K, value: T[K]): void;
41
+ /**
42
+ * Validates a string value.
43
+ *
44
+ * @param key - The key being validated.
45
+ * @param value - The string value to validate.
46
+ * @throws Error if the value is not a non-empty string.
47
+ */
48
+ protected validateString<K extends keyof T>(key: K, value: T[K]): void;
49
+ /**
50
+ * Validates an object value.
51
+ *
52
+ * @param key - The key being validated.
53
+ * @param value - The object value to validate.
54
+ * @throws Error if the value is not a valid object.
55
+ */
56
+ protected validateObject<K extends keyof T>(key: K, value: T[K]): void;
57
+ /**
58
+ * Logs validation success for a property.
59
+ * @param key - The property key.
60
+ * @param value - The value of the property.
61
+ */
62
+ protected logValidationSuccess(key: keyof T, value: T[keyof T]): void;
63
+ /**
64
+ * Throws a standardized validation error.
65
+ *
66
+ * @param key - The key being validated.
67
+ * @param value - The invalid value.
68
+ * @param message - Additional error message.
69
+ * @throws Error with a formatted message.
70
+ */
71
+ protected throwValidationError<K extends keyof T>(key: K, value: T[K], message: string): void;
72
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AbstractValidator = void 0;
7
+ const AbstractProcess_1 = require("../abstract/AbstractProcess");
8
+ // ============================================================================
9
+ // Class
10
+ // ============================================================================
11
+ /**
12
+ * AbstractValidator provides a base class for validation.
13
+ * Extends AbstractProcess for consistent logging and validation utility
14
+ * methods.
15
+ * Subclasses should implement the specific `validateProperty` method for
16
+ * custom validation logic.
17
+ */
18
+ class AbstractValidator extends AbstractProcess_1.AbstractProcess {
19
+ // Parameters
20
+ // ========================================================================
21
+ // Constructor
22
+ // ========================================================================
23
+ constructor() {
24
+ super();
25
+ }
26
+ // Abstract Methods
27
+ // ========================================================================
28
+ /**
29
+ * Validates an entire object.
30
+ * @param target - The object to validate.
31
+ * @throws Error if validation fails for any property.
32
+ */
33
+ validate(target) {
34
+ if (!target || typeof target !== "object") {
35
+ throw new Error("Target must be a valid object.");
36
+ }
37
+ for (const key in target) {
38
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
39
+ this.validateProperty(key, target[key]);
40
+ }
41
+ }
42
+ this.logInfo("Validation completed successfully.");
43
+ }
44
+ // Validation Methods
45
+ // ========================================================================
46
+ /**
47
+ * Validates a numeric value.
48
+ *
49
+ * @param key - The key being validated.
50
+ * @param value - The numeric value to validate.
51
+ * @throws Error if the value is not a non-negative number.
52
+ */
53
+ validateNumber(key, value) {
54
+ if (typeof value !== "number" || value < 0) {
55
+ this.throwValidationError(key, value, "Must be a non-negative number.");
56
+ }
57
+ }
58
+ /**
59
+ * Validates a boolean value.
60
+ *
61
+ * @param key - The key being validated.
62
+ * @param value - The boolean value to validate.
63
+ * @throws Error if the value is not a boolean.
64
+ */
65
+ validateBoolean(key, value) {
66
+ if (typeof value !== "boolean") {
67
+ this.throwValidationError(key, value, "Must be a boolean.");
68
+ }
69
+ }
70
+ /**
71
+ * Validates a string value.
72
+ *
73
+ * @param key - The key being validated.
74
+ * @param value - The string value to validate.
75
+ * @throws Error if the value is not a non-empty string.
76
+ */
77
+ validateString(key, value) {
78
+ if (typeof value !== "string" || value.trim() === "") {
79
+ this.throwValidationError(key, value, "Must be a non-empty string.");
80
+ }
81
+ }
82
+ /**
83
+ * Validates an object value.
84
+ *
85
+ * @param key - The key being validated.
86
+ * @param value - The object value to validate.
87
+ * @throws Error if the value is not a valid object.
88
+ */
89
+ validateObject(key, value) {
90
+ if (typeof value !== "object" ||
91
+ value === null ||
92
+ Array.isArray(value)) {
93
+ this.throwValidationError(key, value, "Must be a valid object.");
94
+ }
95
+ }
96
+ // Utility Methods
97
+ // ========================================================================
98
+ /**
99
+ * Logs validation success for a property.
100
+ * @param key - The property key.
101
+ * @param value - The value of the property.
102
+ */
103
+ logValidationSuccess(key, value) {
104
+ const message = `
105
+ Validation successful for property "${String(key)}"
106
+ with value: ${JSON.stringify(value)}
107
+ `;
108
+ this.logSuccess(message);
109
+ }
110
+ /**
111
+ * Throws a standardized validation error.
112
+ *
113
+ * @param key - The key being validated.
114
+ * @param value - The invalid value.
115
+ * @param message - Additional error message.
116
+ * @throws Error with a formatted message.
117
+ */
118
+ throwValidationError(key, value, message) {
119
+ const errorMessage = `
120
+ Validation failed for "${String(key)}"
121
+ with value "${JSON.stringify(value)}".
122
+ ${message}
123
+ `;
124
+ this.logError(errorMessage);
125
+ throw new Error(errorMessage);
126
+ }
127
+ }
128
+ exports.AbstractValidator = AbstractValidator;
@@ -0,0 +1,47 @@
1
+ import { ConfigInterface } from "../../interface/ConfigInterface";
2
+ import { AbstractProcess } from "../abstract/AbstractProcess";
3
+ /**
4
+ * ConfigLoader is responsible for loading and parsing configuration files
5
+ * (`kist.yaml` or `kist.yml` by default). It validates the configuration
6
+ * structure and provides it in a usable format for the pipeline.
7
+ * Extends `AbstractProcess` for consistent logging.
8
+ */
9
+ export declare class ConfigLoader extends AbstractProcess {
10
+ /**
11
+ * Resolved path to the configuration file, if found.
12
+ */
13
+ private configPath;
14
+ /**
15
+ * Default filenames to search for configuration files.
16
+ */
17
+ private readonly defaultFilenames;
18
+ /**
19
+ * Constructs a ConfigLoader instance.
20
+ * Searches for `kist.yaml` or `kist.yml` in the working directory
21
+ * unless a custom path is provided.
22
+ *
23
+ * @param configPath - Optional custom configuration file path.
24
+ */
25
+ constructor(configPath?: string);
26
+ /**
27
+ * Initializes the loader by locating the configuration file.
28
+ * Searches for `kist.yaml` or `kist.yml` by default.
29
+ *
30
+ * @param configPath - Optional custom configuration file path.
31
+ */
32
+ initialize(configPath?: string): Promise<void>;
33
+ /**
34
+ * Loads and validates the configuration file.
35
+ *
36
+ * @returns Parsed and validated configuration object.
37
+ * @throws Error if the configuration file cannot be read or validated.
38
+ */
39
+ loadConfig(): Promise<ConfigInterface>;
40
+ /**
41
+ * Validates the structure of the configuration.
42
+ *
43
+ * @param config - The configuration object to validate.
44
+ * @throws Error if validation fails.
45
+ */
46
+ private validateConfig;
47
+ }