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,151 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Logger = void 0;
7
+ const LoggerStyles_1 = require("./LoggerStyles");
8
+ // ============================================================================
9
+ // Class
10
+ // ============================================================================
11
+ /**
12
+ * Logger class for handling console messages.
13
+ * Singleton instance ensures consistent logging behavior throughout the
14
+ * application.
15
+ */
16
+ class Logger {
17
+ // Constructor
18
+ // ========================================================================
19
+ /**
20
+ * Private constructor to enforce singleton pattern.
21
+ * @param logLevel - The log level for controlling log output.
22
+ */
23
+ constructor(logLevel = "info") {
24
+ this.logLevel = logLevel;
25
+ }
26
+ // Singleton Methods
27
+ // ========================================================================
28
+ /**
29
+ * Retrieves the singleton instance of Logger.
30
+ * Initializes a non-verbose Logger instance if it hasn't been explicitly
31
+ * initialized.
32
+ *
33
+ * @returns The Logger instance.
34
+ */
35
+ static getInstance(logLevel = "info") {
36
+ if (!Logger.instance) {
37
+ // Default to "info" level if not initialized explicitly
38
+ Logger.instance = new Logger(logLevel);
39
+ }
40
+ return Logger.instance;
41
+ }
42
+ /**
43
+ * Resets the Logger instance.
44
+ * Useful for testing or reinitializing the Logger during runtime.
45
+ */
46
+ static resetInstance() {
47
+ Logger.instance = null;
48
+ }
49
+ // Logging Methods
50
+ // ========================================================================
51
+ /**
52
+ * Logs a message with a specific level if it meets the current log level.
53
+ *
54
+ * @param level - The log level (e.g., "INFO", "WARN", "ERROR").
55
+ * @param context - The context or class name where the log originates.
56
+ * @param message - The message content to log.
57
+ * @param fgStyle - The foreground color style to apply to the log level.
58
+ * @param bgStyle - The background color style to apply to the log level (default is reset).
59
+ */
60
+ log(level, context, message, fgStyle, bgStyle = LoggerStyles_1.LoggerStyles.Reset) {
61
+ if (this.shouldLog(level)) {
62
+ const formattedMessage = `${fgStyle}${bgStyle}[${level.toUpperCase()}]${LoggerStyles_1.LoggerStyles.Reset} [${LoggerStyles_1.LoggerStyles.Cyan}${context}${LoggerStyles_1.LoggerStyles.Reset}] ${message}`;
63
+ console[level === "error" ? "error" : level === "warn" ? "warn" : "log"](formattedMessage);
64
+ }
65
+ }
66
+ /**
67
+ * Determines if a log should be displayed based on the current log level.
68
+ *
69
+ * @param level - The level of the log being checked.
70
+ * @returns True if the log should be displayed, otherwise false.
71
+ */
72
+ shouldLog(level) {
73
+ const levels = ["debug", "info", "warn", "error"];
74
+ return levels.indexOf(level) >= levels.indexOf(this.logLevel);
75
+ }
76
+ /**
77
+ * Logs an informational message.
78
+ *
79
+ * @param context - The originating class or module.
80
+ * @param message - The informational message to log.
81
+ */
82
+ logInfo(context, message) {
83
+ this.log("info", context, message, LoggerStyles_1.LoggerStyles.Blue);
84
+ }
85
+ /**
86
+ * Logs a warning message.
87
+ *
88
+ * @param context - The originating class or module.
89
+ * @param message - The warning message to log.
90
+ */
91
+ logWarn(context, message) {
92
+ this.log("warn", context, message, LoggerStyles_1.LoggerStyles.Yellow);
93
+ }
94
+ /**
95
+ * Logs an error message.
96
+ *
97
+ * @param context - The originating class or module.
98
+ * @param message - The error message to log.
99
+ * @param error - (Optional) Additional error details.
100
+ */
101
+ logError(context, message, error) {
102
+ const formattedMessage = this.formatError(message, error);
103
+ this.log("error", context, formattedMessage, LoggerStyles_1.LoggerStyles.Red, LoggerStyles_1.LoggerStyles.BgYellow);
104
+ }
105
+ /**
106
+ * Logs a debug message.
107
+ *
108
+ * @param context - The originating class or module.
109
+ * @param message - The debug message to log.
110
+ */
111
+ logDebug(context, message) {
112
+ this.log("debug", context, message, LoggerStyles_1.LoggerStyles.Magenta);
113
+ }
114
+ // Utility Methods
115
+ // ========================================================================
116
+ /**
117
+ * Sets the log level dynamically.
118
+ *
119
+ * @param level - The log level to set (e.g., "debug", "info").
120
+ */
121
+ setLogLevel(level) {
122
+ this.logLevel = level;
123
+ }
124
+ /**
125
+ * Formats an error message for logging.
126
+ * Combines a base message with additional error details if available.
127
+ *
128
+ * @param message - The base error message.
129
+ * @param error - Additional error information, such as an Error object.
130
+ * @returns A formatted string combining the message and error details.
131
+ */
132
+ formatError(message, error) {
133
+ if (error instanceof Error) {
134
+ return `${message}: ${error.message}`;
135
+ }
136
+ else if (typeof error === "string") {
137
+ return `${message}: ${error}`;
138
+ }
139
+ else if (error) {
140
+ return `${message}: ${JSON.stringify(error)}`;
141
+ }
142
+ return message;
143
+ }
144
+ }
145
+ exports.Logger = Logger;
146
+ // Parameters
147
+ // ========================================================================
148
+ /**
149
+ * Singleton instance
150
+ */
151
+ Logger.instance = null;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * LoggerStyles defines terminal color codes for text and background styling.
3
+ * These styles are used to format log messages with colors and effects.
4
+ */
5
+ export declare enum LoggerStyles {
6
+ Reset = "\u001B[0m",
7
+ Bold = "\u001B[1m",
8
+ Dim = "\u001B[2m",
9
+ Red = "\u001B[31m",
10
+ Green = "\u001B[32m",
11
+ Yellow = "\u001B[33m",
12
+ Blue = "\u001B[34m",
13
+ Magenta = "\u001B[35m",
14
+ Cyan = "\u001B[36m",
15
+ Gray = "\u001B[90m",
16
+ BgRed = "\u001B[41m",
17
+ BgGreen = "\u001B[42m",
18
+ BgYellow = "\u001B[43m",
19
+ BgBlue = "\u001B[44m",
20
+ BgMagenta = "\u001B[45m",
21
+ BgCyan = "\u001B[46m",
22
+ BgGray = "\u001B[100m"
23
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerStyles = void 0;
4
+ /**
5
+ * LoggerStyles defines terminal color codes for text and background styling.
6
+ * These styles are used to format log messages with colors and effects.
7
+ */
8
+ var LoggerStyles;
9
+ (function (LoggerStyles) {
10
+ // Reset and Effects
11
+ LoggerStyles["Reset"] = "\u001B[0m";
12
+ LoggerStyles["Bold"] = "\u001B[1m";
13
+ LoggerStyles["Dim"] = "\u001B[2m";
14
+ // Foreground Colors
15
+ LoggerStyles["Red"] = "\u001B[31m";
16
+ LoggerStyles["Green"] = "\u001B[32m";
17
+ LoggerStyles["Yellow"] = "\u001B[33m";
18
+ LoggerStyles["Blue"] = "\u001B[34m";
19
+ LoggerStyles["Magenta"] = "\u001B[35m";
20
+ LoggerStyles["Cyan"] = "\u001B[36m";
21
+ LoggerStyles["Gray"] = "\u001B[90m";
22
+ // Background Colors
23
+ LoggerStyles["BgRed"] = "\u001B[41m";
24
+ LoggerStyles["BgGreen"] = "\u001B[42m";
25
+ LoggerStyles["BgYellow"] = "\u001B[43m";
26
+ LoggerStyles["BgBlue"] = "\u001B[44m";
27
+ LoggerStyles["BgMagenta"] = "\u001B[45m";
28
+ LoggerStyles["BgCyan"] = "\u001B[46m";
29
+ LoggerStyles["BgGray"] = "\u001B[100m";
30
+ })(LoggerStyles || (exports.LoggerStyles = LoggerStyles = {}));
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Defines the structure of options passed to step actions.
3
+ * This type provides a flexible, yet type-safe, way to manage action-specific settings.
4
+ */
5
+ export interface ActionOptionsType {
6
+ [key: string]: any;
7
+ optionalField?: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { ActionOptionsType } from "./ActionOptionsType";
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // src/types/index.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,11 +1,97 @@
1
1
  {
2
2
  "name": "kist",
3
- "version": "0.0.0",
3
+ "version": "0.1.31",
4
4
  "description": "Package Pipeline Processor",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
5
+ "keywords": [
6
+ "kist",
7
+ "package",
8
+ "packager",
9
+ "build",
10
+ "builder",
11
+ "compile",
12
+ "compiler",
13
+ "framework",
14
+ "web"
15
+ ],
16
+ "license": "MIT",
17
+ "homepage": "https://www.getkist.com/",
18
+ "main": "js/index.js",
19
+ "types": "js/index.d.ts",
20
+ "files": [
21
+ "code-snippets/**/*.code-snippets",
22
+ "css/**/*.{css,map}",
23
+ "font/**/*.{eot,otf,ttf,woff,woff2}",
24
+ "inkscape/**/*.inkscape",
25
+ "jinja/**/*.jinja",
26
+ "js/**/*.d.ts",
27
+ "js/**/*.{js,map}",
28
+ "less/**/*.less",
29
+ "md/**/*.md",
30
+ "oco/**/*.oco",
31
+ "png/**/*.png",
32
+ "py/**/*.py",
33
+ "rcpx/**/*.rcpx",
34
+ "scss/**/*.scss",
35
+ "sketchpalette/**/*.sketchpalette",
36
+ "styl/**/*.styl",
37
+ "svg/**/*.svg",
38
+ "tex/**/*.tex",
39
+ "ts/**/*.ts",
40
+ "!.DS_Store"
41
+ ],
42
+ "author": "Lars van Vianen <lars@vianen.com> (https://vianen.com)",
43
+ "contributors": [
44
+ "Scape Agency <info@scape.agency>"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/getkist/kist.git"
8
49
  },
9
- "author": "",
10
- "license": "ISC"
11
- }
50
+ "funding": [
51
+ {
52
+ "type": "github",
53
+ "url": "https://github.com/sponsors/scape-foundation"
54
+ }
55
+ ],
56
+ "bin": {
57
+ "kist": "js/cli.js"
58
+ },
59
+ "dependencies": {
60
+ "@babel/core": "^7.23.6",
61
+ "@babel/preset-env": "^7.23.6",
62
+ "@babel/preset-typescript": "^7.23.3",
63
+ "@types/fs-extra": "^11.0.4",
64
+ "@types/glob": "^8.1.0",
65
+ "@types/jsdom": "^21.1.6",
66
+ "@types/micromatch": "^4.0.9",
67
+ "@types/node": "^22.13.0",
68
+ "@types/nunjucks": "^3.2.6",
69
+ "@types/svg-sprite": "^0.0.39",
70
+ "autoprefixer": "^10.4.16",
71
+ "chokidar": "^4.0.0",
72
+ "cssnano": "^7.0.4",
73
+ "del": "^8.0.0",
74
+ "eslint": "^9.9.0",
75
+ "eslint-config-prettier": "^10.0.1",
76
+ "express": "^4.21.0",
77
+ "express-rate-limit": "^7.5.0",
78
+ "fantasticon": "^3.0.0",
79
+ "fs-extra": "^11.2.0",
80
+ "glob": "^11.0.0",
81
+ "js-yaml": "^4.1.0",
82
+ "jsdom": "^26.0.0",
83
+ "lodash": "^4.17.21",
84
+ "nunjucks": "^3.2.4",
85
+ "postcss": "^8.4.32",
86
+ "postcss-preset-env": "^10.0.0",
87
+ "prettier": "^3.0.3",
88
+ "sass": "^1.69.7",
89
+ "sassdoc": "^2.7.4",
90
+ "semver": "^7.5.4",
91
+ "sharp": "^0.33.1",
92
+ "svg-sprite": "^2.0.2",
93
+ "svgo": "^3.1.0",
94
+ "terser": "^5.26.0",
95
+ "ws": "^8.18.0"
96
+ }
97
+ }
@@ -0,0 +1,64 @@
1
+ // ============================================================================
2
+ // Import
3
+ // ============================================================================
4
+
5
+ import { DirectoryCleanAction } from "../actions/DirectoryCleanAction";
6
+ import { DirectoryCopyAction } from "../actions/DirectoryCopyAction";
7
+ import { DirectoryCreateAction } from "../actions/DirectoryCreateAction";
8
+
9
+ import { DocumentationAction } from "../actions/DocumentationAction";
10
+
11
+ import { FileCopyAction } from "../actions/FileCopyAction";
12
+ import { FileRenameAction } from "../actions/FileRenameAction";
13
+
14
+ import { JavaScriptMinifyAction } from "../actions/JavaScriptMinifyAction";
15
+ import { LintAction } from "../actions/LintAction";
16
+
17
+ import { PackageManagerAction } from "../actions/PackageManagerAction";
18
+
19
+ import { StyleProcessingAction } from "../actions/StyleProcessingAction";
20
+
21
+ import { SvgPackagerAction } from "../actions/SvgPackagerAction";
22
+ import { SvgReaderAction } from "../actions/SvgReaderAction";
23
+ import { SvgSpriteAction } from "../actions/SvgSpriteAction";
24
+ import { SvgToPngAction } from "../actions/SvgToPngAction";
25
+
26
+ import { TypeScriptCompilerAction } from "../actions/TypeScriptCompilerAction";
27
+
28
+ import { VersionWriteAction } from "../actions/VersionWriteAction";
29
+
30
+ import { ActionInterface } from "../interface/ActionInterface";
31
+
32
+ // ============================================================================
33
+ // Core Actions
34
+ // ============================================================================
35
+
36
+ /**
37
+ * A record of core actions, mapped by their unique `name` property.
38
+ * Automatically derives names from the action classes.
39
+ */
40
+ export const coreActions: Record<string, new () => ActionInterface> = {
41
+ [new DirectoryCleanAction().name]: DirectoryCleanAction,
42
+ [new DirectoryCopyAction().name]: DirectoryCopyAction,
43
+ [new DirectoryCreateAction().name]: DirectoryCreateAction,
44
+
45
+ [new DocumentationAction().name]: DocumentationAction,
46
+
47
+ [new FileCopyAction().name]: FileCopyAction,
48
+ [new FileRenameAction().name]: FileRenameAction,
49
+
50
+ [new JavaScriptMinifyAction().name]: JavaScriptMinifyAction,
51
+ [new LintAction().name]: LintAction,
52
+
53
+ [new PackageManagerAction().name]: PackageManagerAction,
54
+ [new StyleProcessingAction().name]: StyleProcessingAction,
55
+
56
+ [new SvgPackagerAction().name]: SvgPackagerAction,
57
+ [new SvgReaderAction().name]: SvgReaderAction,
58
+ [new SvgSpriteAction().name]: SvgSpriteAction,
59
+ [new SvgToPngAction().name]: SvgToPngAction,
60
+
61
+ [new TypeScriptCompilerAction().name]: TypeScriptCompilerAction,
62
+
63
+ [new VersionWriteAction().name]: VersionWriteAction,
64
+ };
@@ -0,0 +1,121 @@
1
+ // ============================================================================
2
+ // Import
3
+ // ============================================================================
4
+
5
+ import fs from "fs";
6
+ import micromatch from "micromatch"; // For glob pattern matching
7
+ import path from "path";
8
+ import { Action } from "../../core/pipeline/Action";
9
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
10
+
11
+ // ============================================================================
12
+ // Classes
13
+ // ============================================================================
14
+
15
+ /**
16
+ * DirectoryCleanAction is a step action responsible for cleaning a directory
17
+ * by deleting all its contents while optionally retaining files and
18
+ * directories that match specified glob patterns.
19
+ */
20
+ export class DirectoryCleanAction extends Action {
21
+ // Methods
22
+ // ========================================================================
23
+
24
+ /**
25
+ * Executes the directory cleaning action.
26
+ *
27
+ * @param options - The options specific to directory cleaning, including
28
+ * the directory path and glob patterns to retain.
29
+ * @returns A Promise that resolves when the directory has been
30
+ * successfully cleaned, or silently resolves if the directory does not
31
+ * exist.
32
+ */
33
+ async execute(options: ActionOptionsType): Promise<void> {
34
+ const dirPath = options.dirPath as string;
35
+ const keepPatterns = options.keep as string[] | undefined;
36
+
37
+ if (!dirPath) {
38
+ throw new Error("Missing required option: dirPath.");
39
+ }
40
+
41
+ if (!fs.existsSync(dirPath)) {
42
+ this.logWarn(`Directory does not exist, skipping: ${dirPath}`);
43
+ return; // Exit gracefully if directory does not exist
44
+ }
45
+
46
+ this.logInfo(`Cleaning directory: ${dirPath}`);
47
+
48
+ try {
49
+ await this.cleanDirectoryContents(dirPath, keepPatterns);
50
+ this.logInfo(`Directory cleaned successfully: ${dirPath}`);
51
+ } catch (error) {
52
+ this.logError(`Error cleaning directory "${dirPath}":`, error);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Deletes all contents of a specified directory, excluding files and
58
+ * directories that match specified glob patterns.
59
+ *
60
+ * @param dirPath - The path to the directory to be cleaned.
61
+ * @param keepPatterns - An optional array of glob patterns for files
62
+ * and directories to retain.
63
+ * @returns A Promise that resolves when the directory has been
64
+ * successfully cleaned.
65
+ * @throws {Error} Throws an error if deleting any file or directory fails.
66
+ */
67
+ private async cleanDirectoryContents(
68
+ dirPath: string,
69
+ keepPatterns?: string[],
70
+ ): Promise<void> {
71
+ const files = await fs.promises.readdir(dirPath);
72
+
73
+ for (const file of files) {
74
+ const curPath = path.join(dirPath, file);
75
+ const relativePath = path.relative(dirPath, curPath);
76
+
77
+ // Skip files/directories matching keep patterns
78
+ if (
79
+ keepPatterns &&
80
+ micromatch.isMatch(relativePath, keepPatterns)
81
+ ) {
82
+ this.logInfo(`Skipping: ${relativePath}`);
83
+ continue;
84
+ }
85
+
86
+ try {
87
+ const stat = await fs.promises.lstat(curPath);
88
+ if (stat.isDirectory()) {
89
+ // Recursively clean subdirectory
90
+ await fs.promises.rmdir(curPath, { recursive: true });
91
+ this.logInfo(`Deleted directory: ${relativePath}`);
92
+ } else {
93
+ // Delete file
94
+ await fs.promises.unlink(curPath);
95
+ this.logInfo(`Deleted file: ${relativePath}`);
96
+ }
97
+ } catch (error) {
98
+ this.logError(`Error deleting: ${relativePath}`, error);
99
+ }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Provides a description of the action.
105
+ * @returns A string description of the action.
106
+ */
107
+ describe(): string {
108
+ let description = `
109
+ Cleans a directory by deleting all its contents while retaining
110
+ files and directories matching specified glob patterns. If the
111
+ directory does not exist, the action will skip gracefully.
112
+ `;
113
+ return description;
114
+ }
115
+ }
116
+
117
+ // ============================================================================
118
+ // Export
119
+ // ============================================================================
120
+
121
+ // export default DirectoryCleanAction;
@@ -0,0 +1,11 @@
1
+ // ============================================================================
2
+ // Import
3
+ // ============================================================================
4
+
5
+ import { DirectoryCleanAction } from "./DirectoryCleanAction";
6
+
7
+ // ============================================================================
8
+ // Export
9
+ // ============================================================================
10
+
11
+ export { DirectoryCleanAction };
@@ -0,0 +1,118 @@
1
+ // ============================================================================
2
+ // Import
3
+ // ============================================================================
4
+
5
+ import { promises as fs } from "fs";
6
+ import path from "path";
7
+ import { Action } from "../../core/pipeline/Action";
8
+ import { ActionOptionsType } from "../../types";
9
+
10
+ // ============================================================================
11
+ // Classes
12
+ // ============================================================================
13
+
14
+ /**
15
+ * DirectoryCopyAction is a step action responsible for copying all files and
16
+ * subdirectories from one directory to another, using asynchronous operations
17
+ * for efficient handling.
18
+ */
19
+ export class DirectoryCopyAction extends Action {
20
+ // Methods
21
+ // ========================================================================
22
+
23
+ /**
24
+ * Executes the directory copy action.
25
+ * @param options - The options specific to directory copying, including
26
+ * the source and destination paths.
27
+ * @returns A Promise that resolves when the directory contents have been
28
+ * successfully copied, or rejects with an error if the action fails.
29
+ */
30
+ async execute(options: ActionOptionsType): Promise<void> {
31
+ const srcDir = options.srcDir as string;
32
+ const destDir = options.destDir as string;
33
+
34
+ if (!srcDir || !destDir) {
35
+ throw new Error("Missing required options: srcDir or destDir.");
36
+ }
37
+
38
+ this.logInfo(`Copying files from ${srcDir} to ${destDir}`);
39
+
40
+ try {
41
+ await this.copyFiles(srcDir, destDir);
42
+ this.logInfo(
43
+ `Files copied successfully from ${srcDir} to ${destDir}`,
44
+ );
45
+ } catch (error) {
46
+ this.logError(
47
+ `Error copying files from ${srcDir} to ${destDir}: ${error}`,
48
+ );
49
+ throw error;
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Asynchronously copies all files and subdirectories from the source
55
+ * directory to the destination directory. If the destination directory
56
+ * does not exist, it will be created.
57
+ *
58
+ * @param srcDir - The path of the source directory.
59
+ * @param destDir - The path of the destination directory.
60
+ * @throws {Error} If any file or directory could not be copied.
61
+ */
62
+ private async copyFiles(srcDir: string, destDir: string): Promise<void> {
63
+ const resolvedSrcDir: string = path.resolve(srcDir);
64
+ const resolvedDestDir: string = path.resolve(destDir);
65
+
66
+ try {
67
+ await this.recursiveCopy(resolvedSrcDir, resolvedDestDir);
68
+ } catch (error) {
69
+ throw new Error(
70
+ `Failed to copy from ${resolvedSrcDir} to ${resolvedDestDir}: ${error}`,
71
+ );
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Recursively copies files and directories from the source to the
77
+ * destination directory.
78
+ * This method creates the destination directory if it does not exist and
79
+ * recursively copies all nested files and directories.
80
+ *
81
+ * @param srcDir - Source directory.
82
+ * @param destDir - Destination directory.
83
+ */
84
+ private async recursiveCopy(
85
+ srcDir: string,
86
+ destDir: string,
87
+ ): Promise<void> {
88
+ await fs.mkdir(destDir, { recursive: true });
89
+ const entries = await fs.readdir(srcDir, { withFileTypes: true });
90
+
91
+ for (const entry of entries) {
92
+ const srcPath = path.join(srcDir, entry.name);
93
+ const destPath = path.join(destDir, entry.name);
94
+
95
+ if (entry.isDirectory()) {
96
+ // Recursively copy subdirectory
97
+ await this.recursiveCopy(srcPath, destPath);
98
+ } else {
99
+ // Copy file
100
+ await fs.copyFile(srcPath, destPath);
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Provides a description of the action.
107
+ * @returns A string description of the action.
108
+ */
109
+ describe(): string {
110
+ return "Copies all files and subdirectories from one directory to another, including handling of nested directories.";
111
+ }
112
+ }
113
+
114
+ // ============================================================================
115
+ // Export
116
+ // ============================================================================
117
+
118
+ // export default DirectoryCopyAction;
@@ -0,0 +1,11 @@
1
+ // ============================================================================
2
+ // Import
3
+ // ============================================================================
4
+
5
+ import { DirectoryCopyAction } from "./DirectoryCopyAction";
6
+
7
+ // ============================================================================
8
+ // Export
9
+ // ============================================================================
10
+
11
+ export { DirectoryCopyAction };