kist 0.1.58 → 0.1.60

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 (104) hide show
  1. package/js/actions/CoreActions.d.ts +12 -0
  2. package/js/actions/CoreActions.js +12 -16
  3. package/js/actions/FileCopyAction/FileCopyAction.d.ts +24 -2
  4. package/js/actions/FileCopyAction/FileCopyAction.js +131 -8
  5. package/js/config/actions.config.d.ts +14 -15
  6. package/js/config/actions.config.js +27 -46
  7. package/js/core/cache/BuildCache.d.ts +159 -0
  8. package/js/core/cache/BuildCache.js +418 -0
  9. package/js/core/cache/FileCache.d.ts +149 -0
  10. package/js/core/cache/FileCache.js +339 -0
  11. package/js/core/config/ConfigLoader.d.ts +42 -0
  12. package/js/core/config/ConfigLoader.js +140 -3
  13. package/js/core/pipeline/Pipeline.d.ts +34 -2
  14. package/js/core/pipeline/Pipeline.js +111 -8
  15. package/js/core/pipeline/Stage.d.ts +30 -4
  16. package/js/core/pipeline/Stage.js +94 -13
  17. package/js/core/progress/ProgressReporter.d.ts +137 -0
  18. package/js/core/progress/ProgressReporter.js +221 -0
  19. package/js/index.d.ts +1 -1
  20. package/js/index.js +3 -3
  21. package/js/interface/ConfigInterface.d.ts +19 -0
  22. package/js/interface/OptionsInterface.d.ts +85 -0
  23. package/js/interface/StageInterface.d.ts +20 -0
  24. package/package.json +29 -27
  25. package/ts/actions/CoreActions.ts +12 -21
  26. package/ts/actions/FileCopyAction/FileCopyAction.ts +159 -13
  27. package/ts/config/actions.config.ts +28 -50
  28. package/ts/core/cache/BuildCache.ts +504 -0
  29. package/ts/core/cache/FileCache.ts +395 -0
  30. package/ts/core/cache/index.ts +6 -0
  31. package/ts/core/config/ConfigLoader.ts +176 -7
  32. package/ts/core/index.ts +7 -0
  33. package/ts/core/pipeline/Pipeline.ts +131 -6
  34. package/ts/core/pipeline/Stage.ts +102 -14
  35. package/ts/core/progress/ProgressReporter.ts +297 -0
  36. package/ts/core/progress/index.ts +9 -0
  37. package/ts/core/validation/ConfigValidator.ts +11 -1
  38. package/ts/index.ts +3 -3
  39. package/ts/interface/ConfigInterface.ts +20 -0
  40. package/ts/interface/OptionsInterface.ts +100 -0
  41. package/ts/interface/StageInterface.ts +23 -0
  42. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.d.ts +0 -31
  43. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.js +0 -98
  44. package/js/actions/JavaScriptMinifyAction/index.d.ts +0 -2
  45. package/js/actions/JavaScriptMinifyAction/index.js +0 -8
  46. package/js/actions/JavaScriptMinifyAction/terser.config.d.ts +0 -27
  47. package/js/actions/JavaScriptMinifyAction/terser.config.js +0 -119
  48. package/js/actions/LintAction/LintAction.d.ts +0 -17
  49. package/js/actions/LintAction/LintAction.js +0 -63
  50. package/js/actions/LintAction/index.d.ts +0 -2
  51. package/js/actions/LintAction/index.js +0 -8
  52. package/js/actions/StyleProcessingAction/StyleProcessingAction.d.ts +0 -34
  53. package/js/actions/StyleProcessingAction/StyleProcessingAction.js +0 -164
  54. package/js/actions/StyleProcessingAction/index.d.ts +0 -2
  55. package/js/actions/StyleProcessingAction/index.js +0 -8
  56. package/js/actions/StyleProcessingAction/postcss.config.compressed.d.ts +0 -10
  57. package/js/actions/StyleProcessingAction/postcss.config.compressed.js +0 -31
  58. package/js/actions/StyleProcessingAction/postcss.config.expanded.d.ts +0 -16
  59. package/js/actions/StyleProcessingAction/postcss.config.expanded.js +0 -45
  60. package/js/actions/SvgPackagerAction/SvgPackagerAction.d.ts +0 -68
  61. package/js/actions/SvgPackagerAction/SvgPackagerAction.js +0 -186
  62. package/js/actions/SvgPackagerAction/index.d.ts +0 -2
  63. package/js/actions/SvgPackagerAction/index.js +0 -8
  64. package/js/actions/SvgReaderAction/SvgReaderAction.d.ts +0 -32
  65. package/js/actions/SvgReaderAction/SvgReaderAction.js +0 -87
  66. package/js/actions/SvgReaderAction/index.d.ts +0 -2
  67. package/js/actions/SvgReaderAction/index.js +0 -8
  68. package/js/actions/SvgSpriteAction/SvgSpriteAction.d.ts +0 -37
  69. package/js/actions/SvgSpriteAction/SvgSpriteAction.js +0 -114
  70. package/js/actions/SvgSpriteAction/index.d.ts +0 -2
  71. package/js/actions/SvgSpriteAction/index.js +0 -8
  72. package/js/actions/SvgSpriteAction/svgsprite.config.d.ts +0 -3
  73. package/js/actions/SvgSpriteAction/svgsprite.config.js +0 -117
  74. package/js/actions/SvgToPngAction/SvgToPngAction.d.ts +0 -28
  75. package/js/actions/SvgToPngAction/SvgToPngAction.js +0 -111
  76. package/js/actions/SvgToPngAction/index.d.ts +0 -2
  77. package/js/actions/SvgToPngAction/index.js +0 -8
  78. package/js/actions/TemplateRenderAction/TemplateRenderAction.d.ts +0 -9
  79. package/js/actions/TemplateRenderAction/TemplateRenderAction.js +0 -95
  80. package/js/actions/TemplateRenderAction/index.d.ts +0 -2
  81. package/js/actions/TemplateRenderAction/index.js +0 -8
  82. package/js/actions/TemplateRenderAction/nunjucks.config.d.ts +0 -14
  83. package/js/actions/TemplateRenderAction/nunjucks.config.js +0 -33
  84. package/ts/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.ts +0 -109
  85. package/ts/actions/JavaScriptMinifyAction/index.ts +0 -11
  86. package/ts/actions/JavaScriptMinifyAction/terser.config.ts +0 -177
  87. package/ts/actions/LintAction/LintAction.ts +0 -67
  88. package/ts/actions/LintAction/index.ts +0 -11
  89. package/ts/actions/StyleProcessingAction/StyleProcessingAction.ts +0 -142
  90. package/ts/actions/StyleProcessingAction/index.ts +0 -11
  91. package/ts/actions/StyleProcessingAction/postcss.config.compressed.ts +0 -31
  92. package/ts/actions/StyleProcessingAction/postcss.config.expanded.ts +0 -46
  93. package/ts/actions/SvgPackagerAction/SvgPackagerAction.ts +0 -187
  94. package/ts/actions/SvgPackagerAction/index.ts +0 -11
  95. package/ts/actions/SvgReaderAction/SvgReaderAction.ts +0 -77
  96. package/ts/actions/SvgReaderAction/index.ts +0 -11
  97. package/ts/actions/SvgSpriteAction/SvgSpriteAction.ts +0 -127
  98. package/ts/actions/SvgSpriteAction/index.ts +0 -11
  99. package/ts/actions/SvgSpriteAction/svgsprite.config.ts +0 -123
  100. package/ts/actions/SvgToPngAction/SvgToPngAction.ts +0 -121
  101. package/ts/actions/SvgToPngAction/index.ts +0 -11
  102. package/ts/actions/TemplateRenderAction/TemplateRenderAction.ts +0 -124
  103. package/ts/actions/TemplateRenderAction/index.ts +0 -11
  104. package/ts/actions/TemplateRenderAction/nunjucks.config.ts +0 -37
@@ -2,5 +2,17 @@ import { ActionInterface } from "../interface/ActionInterface";
2
2
  /**
3
3
  * A record of core actions, mapped by their unique `name` property.
4
4
  * Automatically derives names from the action classes.
5
+ *
6
+ * Note: Additional actions are available in separate @getkist/action-* packages:
7
+ * - @getkist/action-eslint - ESLint linting
8
+ * - @getkist/action-jest - Jest test runner
9
+ * - @getkist/action-nunjucks - Nunjucks/Jinja templating
10
+ * - @getkist/action-postcss - PostCSS processing
11
+ * - @getkist/action-prettier - Prettier formatting
12
+ * - @getkist/action-sass - SASS/SCSS compilation
13
+ * - @getkist/action-svg - SVG sprite generation and optimization
14
+ * - @getkist/action-terser - JavaScript minification
15
+ * - @getkist/action-tsdown - tsdown bundling
16
+ * - @getkist/action-tsup - tsup bundling
5
17
  */
6
18
  export declare const coreActions: Record<string, new () => ActionInterface>;
@@ -10,16 +10,8 @@ const DirectoryCreateAction_1 = require("../actions/DirectoryCreateAction");
10
10
  const DocumentationAction_1 = require("../actions/DocumentationAction");
11
11
  const FileCopyAction_1 = require("../actions/FileCopyAction");
12
12
  const FileRenameAction_1 = require("../actions/FileRenameAction");
13
- const JavaScriptMinifyAction_1 = require("../actions/JavaScriptMinifyAction");
14
- const LintAction_1 = require("../actions/LintAction");
15
13
  const PackageManagerAction_1 = require("../actions/PackageManagerAction");
16
14
  const RunScriptAction_1 = require("../actions/RunScriptAction");
17
- const StyleProcessingAction_1 = require("../actions/StyleProcessingAction");
18
- const SvgPackagerAction_1 = require("../actions/SvgPackagerAction");
19
- const SvgReaderAction_1 = require("../actions/SvgReaderAction");
20
- const SvgSpriteAction_1 = require("../actions/SvgSpriteAction");
21
- const SvgToPngAction_1 = require("../actions/SvgToPngAction");
22
- const TemplateRenderAction_1 = require("../actions/TemplateRenderAction");
23
15
  const TypeScriptCompilerAction_1 = require("../actions/TypeScriptCompilerAction");
24
16
  const VersionWriteAction_1 = require("../actions/VersionWriteAction");
25
17
  // ============================================================================
@@ -28,6 +20,18 @@ const VersionWriteAction_1 = require("../actions/VersionWriteAction");
28
20
  /**
29
21
  * A record of core actions, mapped by their unique `name` property.
30
22
  * Automatically derives names from the action classes.
23
+ *
24
+ * Note: Additional actions are available in separate @getkist/action-* packages:
25
+ * - @getkist/action-eslint - ESLint linting
26
+ * - @getkist/action-jest - Jest test runner
27
+ * - @getkist/action-nunjucks - Nunjucks/Jinja templating
28
+ * - @getkist/action-postcss - PostCSS processing
29
+ * - @getkist/action-prettier - Prettier formatting
30
+ * - @getkist/action-sass - SASS/SCSS compilation
31
+ * - @getkist/action-svg - SVG sprite generation and optimization
32
+ * - @getkist/action-terser - JavaScript minification
33
+ * - @getkist/action-tsdown - tsdown bundling
34
+ * - @getkist/action-tsup - tsup bundling
31
35
  */
32
36
  exports.coreActions = {
33
37
  [new DirectoryCleanAction_1.DirectoryCleanAction().name]: DirectoryCleanAction_1.DirectoryCleanAction,
@@ -36,16 +40,8 @@ exports.coreActions = {
36
40
  [new DocumentationAction_1.DocumentationAction().name]: DocumentationAction_1.DocumentationAction,
37
41
  [new FileCopyAction_1.FileCopyAction().name]: FileCopyAction_1.FileCopyAction,
38
42
  [new FileRenameAction_1.FileRenameAction().name]: FileRenameAction_1.FileRenameAction,
39
- [new JavaScriptMinifyAction_1.JavaScriptMinifyAction().name]: JavaScriptMinifyAction_1.JavaScriptMinifyAction,
40
- [new LintAction_1.LintAction().name]: LintAction_1.LintAction,
41
43
  [new PackageManagerAction_1.PackageManagerAction().name]: PackageManagerAction_1.PackageManagerAction,
42
44
  [new RunScriptAction_1.RunScriptAction().name]: RunScriptAction_1.RunScriptAction,
43
- [new StyleProcessingAction_1.StyleProcessingAction().name]: StyleProcessingAction_1.StyleProcessingAction,
44
- [new SvgPackagerAction_1.SvgPackagerAction().name]: SvgPackagerAction_1.SvgPackagerAction,
45
- [new SvgReaderAction_1.SvgReaderAction().name]: SvgReaderAction_1.SvgReaderAction,
46
- [new SvgSpriteAction_1.SvgSpriteAction().name]: SvgSpriteAction_1.SvgSpriteAction,
47
- [new SvgToPngAction_1.SvgToPngAction().name]: SvgToPngAction_1.SvgToPngAction,
48
- [new TemplateRenderAction_1.TemplateRenderAction().name]: TemplateRenderAction_1.TemplateRenderAction,
49
45
  [new TypeScriptCompilerAction_1.TypeScriptCompilerAction().name]: TypeScriptCompilerAction_1.TypeScriptCompilerAction,
50
46
  [new VersionWriteAction_1.VersionWriteAction().name]: VersionWriteAction_1.VersionWriteAction,
51
47
  };
@@ -5,8 +5,15 @@ import { ActionOptionsType } from "../../types/ActionOptionsType";
5
5
  * location to a destination directory. This action handles file path
6
6
  * resolution and ensures that existing files in the destination can be
7
7
  * replaced if necessary.
8
+ *
9
+ * Performance features:
10
+ * - Uses streaming for large files to reduce memory usage
11
+ * - Supports file caching to skip unchanged files
12
+ * - Parallel batch copy support
8
13
  */
9
14
  export declare class FileCopyAction extends Action {
15
+ private fileCache;
16
+ constructor();
10
17
  /**
11
18
  * Executes the file copy action.
12
19
  * @param options - The options specific to file copying, including source
@@ -15,10 +22,21 @@ export declare class FileCopyAction extends Action {
15
22
  * copied, or rejects with an error if the action fails.
16
23
  */
17
24
  execute(options: ActionOptionsType): Promise<void>;
25
+ /**
26
+ * Copies a single file with optional caching.
27
+ */
28
+ private copySingleFile;
29
+ /**
30
+ * Copies multiple files with optional parallel execution.
31
+ */
32
+ private copyMultipleFiles;
33
+ /**
34
+ * Copies files in parallel with concurrency control.
35
+ */
36
+ private copyFilesInParallel;
18
37
  /**
19
38
  * Copies a file from a specified source to a destination directory.
20
- * Handles file path resolution and ensures the destination directory
21
- * exists.
39
+ * Uses streaming for large files to reduce memory usage.
22
40
  *
23
41
  * @param srcFile - The path of the source file to be copied.
24
42
  * @param destDir - The destination directory where the file should
@@ -29,6 +47,10 @@ export declare class FileCopyAction extends Action {
29
47
  * permission errors or the source file not existing.
30
48
  */
31
49
  private copyFileToDirectory;
50
+ /**
51
+ * Copies a file using streams for memory-efficient handling of large files.
52
+ */
53
+ private streamCopyFile;
32
54
  /**
33
55
  * Ensures that the given directory exists, creating it if it does not.
34
56
  * @param dirPath - The path of the directory to check and create.
@@ -18,7 +18,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.FileCopyAction = void 0;
19
19
  const fs_1 = __importDefault(require("fs"));
20
20
  const path_1 = __importDefault(require("path"));
21
+ const promises_1 = require("stream/promises");
21
22
  const Action_1 = require("../../core/pipeline/Action");
23
+ const FileCache_1 = require("../../core/cache/FileCache");
24
+ // ============================================================================
25
+ // Constants
26
+ // ============================================================================
27
+ /** Threshold for using streaming copy (5MB) */
28
+ const STREAMING_THRESHOLD = 5 * 1024 * 1024;
22
29
  // ============================================================================
23
30
  // Classes
24
31
  // ============================================================================
@@ -27,12 +34,19 @@ const Action_1 = require("../../core/pipeline/Action");
27
34
  * location to a destination directory. This action handles file path
28
35
  * resolution and ensures that existing files in the destination can be
29
36
  * replaced if necessary.
37
+ *
38
+ * Performance features:
39
+ * - Uses streaming for large files to reduce memory usage
40
+ * - Supports file caching to skip unchanged files
41
+ * - Parallel batch copy support
30
42
  */
31
43
  class FileCopyAction extends Action_1.Action {
32
- // Parameters
33
- // ========================================================================
34
44
  // Constructor
35
45
  // ========================================================================
46
+ constructor() {
47
+ super();
48
+ this.fileCache = FileCache_1.FileCache.getInstance();
49
+ }
36
50
  // Methods
37
51
  // ========================================================================
38
52
  /**
@@ -45,13 +59,44 @@ class FileCopyAction extends Action_1.Action {
45
59
  execute(options) {
46
60
  return __awaiter(this, void 0, void 0, function* () {
47
61
  const srcFile = options.srcFile;
62
+ const srcFiles = options.srcFiles;
48
63
  const destDir = options.destDir;
49
- if (!srcFile || !destDir) {
50
- throw new Error("Missing required options: srcFile or destDir.");
64
+ const useCache = options.useCache;
65
+ const parallel = options.parallel;
66
+ if ((!srcFile && !srcFiles) || !destDir) {
67
+ throw new Error("Missing required options: srcFile/srcFiles or destDir.");
68
+ }
69
+ // Handle batch copy
70
+ if (srcFiles && srcFiles.length > 0) {
71
+ yield this.copyMultipleFiles(srcFiles, destDir, { useCache, parallel });
72
+ return;
73
+ }
74
+ // Handle single file copy
75
+ if (srcFile) {
76
+ yield this.copySingleFile(srcFile, destDir, { useCache });
77
+ }
78
+ });
79
+ }
80
+ /**
81
+ * Copies a single file with optional caching.
82
+ */
83
+ copySingleFile(srcFile_1, destDir_1) {
84
+ return __awaiter(this, arguments, void 0, function* (srcFile, destDir, options = {}) {
85
+ // Check cache if enabled
86
+ if (options.useCache) {
87
+ const hasChanged = yield this.fileCache.hasFileChanged(srcFile);
88
+ if (!hasChanged) {
89
+ this.logDebug(`Skipping unchanged file: ${srcFile}`);
90
+ return;
91
+ }
51
92
  }
52
93
  this.logInfo(`Copying file from ${srcFile} to ${destDir}.`);
53
94
  try {
54
95
  yield this.copyFileToDirectory(srcFile, destDir);
96
+ // Update cache
97
+ if (options.useCache) {
98
+ yield this.fileCache.updateFileEntry(srcFile);
99
+ }
55
100
  this.logInfo(`File copied successfully from ${srcFile} to ${destDir}.`);
56
101
  }
57
102
  catch (error) {
@@ -60,10 +105,70 @@ class FileCopyAction extends Action_1.Action {
60
105
  }
61
106
  });
62
107
  }
108
+ /**
109
+ * Copies multiple files with optional parallel execution.
110
+ */
111
+ copyMultipleFiles(srcFiles_1, destDir_1) {
112
+ return __awaiter(this, arguments, void 0, function* (srcFiles, destDir, options = {}) {
113
+ const startTime = performance.now();
114
+ let filesToCopy = srcFiles;
115
+ // Filter unchanged files if caching is enabled
116
+ if (options.useCache) {
117
+ filesToCopy = yield this.fileCache.getChangedFiles(srcFiles);
118
+ const skipped = srcFiles.length - filesToCopy.length;
119
+ if (skipped > 0) {
120
+ this.logInfo(`Skipping ${skipped} unchanged files.`);
121
+ }
122
+ }
123
+ if (filesToCopy.length === 0) {
124
+ this.logInfo("All files are up to date, nothing to copy.");
125
+ return;
126
+ }
127
+ this.logInfo(`Copying ${filesToCopy.length} files to ${destDir}.`);
128
+ try {
129
+ if (options.parallel) {
130
+ // Parallel copy with concurrency limit
131
+ yield this.copyFilesInParallel(filesToCopy, destDir, 10);
132
+ }
133
+ else {
134
+ // Sequential copy
135
+ for (const file of filesToCopy) {
136
+ yield this.copyFileToDirectory(file, destDir);
137
+ }
138
+ }
139
+ // Update cache for all copied files
140
+ if (options.useCache) {
141
+ yield this.fileCache.updateFileEntries(filesToCopy);
142
+ }
143
+ const duration = performance.now() - startTime;
144
+ this.logInfo(`Copied ${filesToCopy.length} files in ${duration.toFixed(2)}ms.`);
145
+ }
146
+ catch (error) {
147
+ this.logError(`Error copying files: ${error}`);
148
+ throw error;
149
+ }
150
+ });
151
+ }
152
+ /**
153
+ * Copies files in parallel with concurrency control.
154
+ */
155
+ copyFilesInParallel(srcFiles_1, destDir_1) {
156
+ return __awaiter(this, arguments, void 0, function* (srcFiles, destDir, maxConcurrent = 10) {
157
+ const executing = new Set();
158
+ for (const srcFile of srcFiles) {
159
+ const copyPromise = this.copyFileToDirectory(srcFile, destDir)
160
+ .finally(() => executing.delete(copyPromise));
161
+ executing.add(copyPromise);
162
+ if (executing.size >= maxConcurrent) {
163
+ yield Promise.race(executing);
164
+ }
165
+ }
166
+ yield Promise.all(executing);
167
+ });
168
+ }
63
169
  /**
64
170
  * Copies a file from a specified source to a destination directory.
65
- * Handles file path resolution and ensures the destination directory
66
- * exists.
171
+ * Uses streaming for large files to reduce memory usage.
67
172
  *
68
173
  * @param srcFile - The path of the source file to be copied.
69
174
  * @param destDir - The destination directory where the file should
@@ -81,8 +186,16 @@ class FileCopyAction extends Action_1.Action {
81
186
  // Resolve the destination file path
82
187
  const fileName = path_1.default.basename(srcFile);
83
188
  const destFilePath = path_1.default.join(destDir, fileName);
84
- // Copy the file
85
- yield fs_1.default.promises.copyFile(srcFile, destFilePath);
189
+ // Check file size to determine copy method
190
+ const stat = yield fs_1.default.promises.stat(srcFile);
191
+ if (stat.size > STREAMING_THRESHOLD) {
192
+ // Use streaming for large files
193
+ yield this.streamCopyFile(srcFile, destFilePath);
194
+ }
195
+ else {
196
+ // Use standard copy for smaller files
197
+ yield fs_1.default.promises.copyFile(srcFile, destFilePath);
198
+ }
86
199
  }
87
200
  catch (error) {
88
201
  this.logError(`Error copying file: ${error}`);
@@ -90,6 +203,16 @@ class FileCopyAction extends Action_1.Action {
90
203
  }
91
204
  });
92
205
  }
206
+ /**
207
+ * Copies a file using streams for memory-efficient handling of large files.
208
+ */
209
+ streamCopyFile(srcFile, destFile) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const readStream = fs_1.default.createReadStream(srcFile);
212
+ const writeStream = fs_1.default.createWriteStream(destFile);
213
+ yield (0, promises_1.pipeline)(readStream, writeStream);
214
+ });
215
+ }
93
216
  /**
94
217
  * Ensures that the given directory exists, creating it if it does not.
95
218
  * @param dirPath - The path of the directory to check and create.
@@ -1,34 +1,33 @@
1
1
  /**
2
- * Defines which actions are considered "core" and will remain in the main
3
- * kist package. All other actions should be moved to separate plugin packages.
2
+ * Defines which actions are in the main kist package vs. separate plugins.
4
3
  *
5
- * Core Actions (Lightweight essentials):
4
+ * Core Actions (in main kist package):
6
5
  * - Directory operations (create, copy, clean)
7
6
  * - File operations (copy, rename)
8
7
  * - Version management
9
- * - Template rendering (lightweight)
8
+ * - TypeScript compilation
9
+ * - Documentation generation
10
+ * - Package management
11
+ * - Script running
10
12
  *
11
- * Plugin Actions (Move to separate repos):
13
+ * Migrated to Plugin Packages:
12
14
  * - StyleProcessingAction -> @getkist/action-sass
13
- * - TypeScriptCompilerAction -> @getkist/action-typescript
14
15
  * - JavaScriptMinifyAction -> @getkist/action-terser
15
16
  * - SvgPackagerAction -> @getkist/action-svg
16
17
  * - SvgSpriteAction -> @getkist/action-svg
17
18
  * - SvgToPngAction -> @getkist/action-svg
18
19
  * - SvgReaderAction -> @getkist/action-svg
19
- * - LintAction -> @getkist/action-lint
20
- * - DocumentationAction -> @getkist/action-docs
21
- * - PackageManagerAction -> @getkist/action-package-manager
22
- * - RunScriptAction -> @getkist/action-scripts
20
+ * - LintAction -> @getkist/action-eslint
21
+ * - TemplateRenderAction -> @getkist/action-nunjucks
23
22
  */
24
- export declare const CORE_ACTIONS: readonly ["DirectoryCleanAction", "DirectoryCopyAction", "DirectoryCreateAction", "FileCopyAction", "FileRenameAction", "TemplateRenderAction", "VersionWriteAction"];
25
- export declare const PLUGIN_ACTIONS: readonly ["StyleProcessingAction", "TypeScriptCompilerAction", "JavaScriptMinifyAction", "SvgPackagerAction", "SvgReaderAction", "SvgSpriteAction", "SvgToPngAction", "LintAction", "DocumentationAction", "PackageManagerAction", "RunScriptAction"];
23
+ export declare const CORE_ACTIONS: readonly ["DirectoryCleanAction", "DirectoryCopyAction", "DirectoryCreateAction", "DocumentationAction", "FileCopyAction", "FileRenameAction", "PackageManagerAction", "RunScriptAction", "TypeScriptCompilerAction", "VersionWriteAction"];
24
+ export declare const MIGRATED_ACTIONS: readonly ["StyleProcessingAction", "JavaScriptMinifyAction", "SvgPackagerAction", "SvgReaderAction", "SvgSpriteAction", "SvgToPngAction", "LintAction", "TemplateRenderAction"];
26
25
  export type CoreActionName = (typeof CORE_ACTIONS)[number];
27
- export type PluginActionName = (typeof PLUGIN_ACTIONS)[number];
26
+ export type MigratedActionName = (typeof MIGRATED_ACTIONS)[number];
28
27
  /**
29
- * Plugin package mappings for migration guide
28
+ * Plugin package mappings - use these packages for the migrated actions
30
29
  */
31
- export declare const PLUGIN_PACKAGES: Record<PluginActionName, {
30
+ export declare const MIGRATED_PACKAGES: Record<MigratedActionName, {
32
31
  package: string;
33
32
  npm: string;
34
33
  github: string;
@@ -3,44 +3,44 @@
3
3
  // Core Actions Configuration
4
4
  // ============================================================================
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PLUGIN_PACKAGES = exports.PLUGIN_ACTIONS = exports.CORE_ACTIONS = void 0;
6
+ exports.MIGRATED_PACKAGES = exports.MIGRATED_ACTIONS = exports.CORE_ACTIONS = void 0;
7
7
  /**
8
- * Defines which actions are considered "core" and will remain in the main
9
- * kist package. All other actions should be moved to separate plugin packages.
8
+ * Defines which actions are in the main kist package vs. separate plugins.
10
9
  *
11
- * Core Actions (Lightweight essentials):
10
+ * Core Actions (in main kist package):
12
11
  * - Directory operations (create, copy, clean)
13
12
  * - File operations (copy, rename)
14
13
  * - Version management
15
- * - Template rendering (lightweight)
14
+ * - TypeScript compilation
15
+ * - Documentation generation
16
+ * - Package management
17
+ * - Script running
16
18
  *
17
- * Plugin Actions (Move to separate repos):
19
+ * Migrated to Plugin Packages:
18
20
  * - StyleProcessingAction -> @getkist/action-sass
19
- * - TypeScriptCompilerAction -> @getkist/action-typescript
20
21
  * - JavaScriptMinifyAction -> @getkist/action-terser
21
22
  * - SvgPackagerAction -> @getkist/action-svg
22
23
  * - SvgSpriteAction -> @getkist/action-svg
23
24
  * - SvgToPngAction -> @getkist/action-svg
24
25
  * - SvgReaderAction -> @getkist/action-svg
25
- * - LintAction -> @getkist/action-lint
26
- * - DocumentationAction -> @getkist/action-docs
27
- * - PackageManagerAction -> @getkist/action-package-manager
28
- * - RunScriptAction -> @getkist/action-scripts
26
+ * - LintAction -> @getkist/action-eslint
27
+ * - TemplateRenderAction -> @getkist/action-nunjucks
29
28
  */
30
29
  exports.CORE_ACTIONS = [
31
30
  "DirectoryCleanAction",
32
31
  "DirectoryCopyAction",
33
32
  "DirectoryCreateAction",
33
+ "DocumentationAction",
34
34
  "FileCopyAction",
35
35
  "FileRenameAction",
36
- "TemplateRenderAction",
36
+ "PackageManagerAction",
37
+ "RunScriptAction",
38
+ "TypeScriptCompilerAction",
37
39
  "VersionWriteAction",
38
40
  ];
39
- exports.PLUGIN_ACTIONS = [
41
+ exports.MIGRATED_ACTIONS = [
40
42
  // @getkist/action-sass
41
43
  "StyleProcessingAction",
42
- // @getkist/action-typescript
43
- "TypeScriptCompilerAction",
44
44
  // @getkist/action-terser
45
45
  "JavaScriptMinifyAction",
46
46
  // @getkist/action-svg
@@ -48,29 +48,20 @@ exports.PLUGIN_ACTIONS = [
48
48
  "SvgReaderAction",
49
49
  "SvgSpriteAction",
50
50
  "SvgToPngAction",
51
- // @getkist/action-lint
51
+ // @getkist/action-eslint
52
52
  "LintAction",
53
- // @getkist/action-docs
54
- "DocumentationAction",
55
- // @getkist/action-package-manager
56
- "PackageManagerAction",
57
- // @getkist/action-scripts
58
- "RunScriptAction",
53
+ // @getkist/action-nunjucks
54
+ "TemplateRenderAction",
59
55
  ];
60
56
  /**
61
- * Plugin package mappings for migration guide
57
+ * Plugin package mappings - use these packages for the migrated actions
62
58
  */
63
- exports.PLUGIN_PACKAGES = {
59
+ exports.MIGRATED_PACKAGES = {
64
60
  StyleProcessingAction: {
65
61
  package: "@getkist/action-sass",
66
62
  npm: "npm install --save-dev @getkist/action-sass",
67
63
  github: "https://github.com/getkist/kist-action-sass",
68
64
  },
69
- TypeScriptCompilerAction: {
70
- package: "@getkist/action-typescript",
71
- npm: "npm install --save-dev @getkist/action-typescript",
72
- github: "https://github.com/getkist/kist-action-typescript",
73
- },
74
65
  JavaScriptMinifyAction: {
75
66
  package: "@getkist/action-terser",
76
67
  npm: "npm install --save-dev @getkist/action-terser",
@@ -97,23 +88,13 @@ exports.PLUGIN_PACKAGES = {
97
88
  github: "https://github.com/getkist/kist-action-svg",
98
89
  },
99
90
  LintAction: {
100
- package: "@getkist/action-lint",
101
- npm: "npm install --save-dev @getkist/action-lint",
102
- github: "https://github.com/getkist/kist-action-lint",
103
- },
104
- DocumentationAction: {
105
- package: "@getkist/action-docs",
106
- npm: "npm install --save-dev @getkist/action-docs",
107
- github: "https://github.com/getkist/kist-action-docs",
108
- },
109
- PackageManagerAction: {
110
- package: "@getkist/action-package-manager",
111
- npm: "npm install --save-dev @getkist/action-package-manager",
112
- github: "https://github.com/getkist/kist-action-package-manager",
91
+ package: "@getkist/action-eslint",
92
+ npm: "npm install --save-dev @getkist/action-eslint",
93
+ github: "https://github.com/getkist/kist-action-eslint",
113
94
  },
114
- RunScriptAction: {
115
- package: "@getkist/action-scripts",
116
- npm: "npm install --save-dev @getkist/action-scripts",
117
- github: "https://github.com/getkist/kist-action-scripts",
95
+ TemplateRenderAction: {
96
+ package: "@getkist/action-nunjucks",
97
+ npm: "npm install --save-dev @getkist/action-nunjucks",
98
+ github: "https://github.com/getkist/kist-action-nunjucks",
118
99
  },
119
100
  };
@@ -0,0 +1,159 @@
1
+ import { AbstractProcess } from "../abstract/AbstractProcess";
2
+ /**
3
+ * Options for the BuildCache constructor.
4
+ */
5
+ interface BuildCacheOptions {
6
+ /** Directory to store cached build artifacts */
7
+ cacheDir?: string;
8
+ /** Maximum cache size in bytes (default: 1GB) */
9
+ maxCacheSize?: number;
10
+ /** Cache time-to-live in milliseconds (default: 7 days) */
11
+ ttl?: number;
12
+ }
13
+ /**
14
+ * Result from a cache lookup.
15
+ */
16
+ interface CacheLookupResult {
17
+ /** Whether a valid cache entry was found */
18
+ found: boolean;
19
+ /** Cached output files if found */
20
+ outputFiles?: string[];
21
+ /** Whether cache was restored from artifacts */
22
+ restored?: boolean;
23
+ }
24
+ /**
25
+ * BuildCache provides a mechanism for caching build outputs based on input
26
+ * file hashes. This enables incremental builds by skipping steps whose inputs
27
+ * haven't changed.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const buildCache = BuildCache.getInstance();
32
+ *
33
+ * // Check for cached output
34
+ * const cacheResult = await buildCache.lookup('typescript', inputFiles, config);
35
+ * if (cacheResult.found) {
36
+ * console.log('Using cached build output');
37
+ * return cacheResult.outputFiles;
38
+ * }
39
+ *
40
+ * // Build and cache the result
41
+ * const outputFiles = await compile(inputFiles);
42
+ * await buildCache.store('typescript', inputFiles, outputFiles, config);
43
+ * ```
44
+ */
45
+ export declare class BuildCache extends AbstractProcess {
46
+ /** Singleton instance */
47
+ private static instance;
48
+ /** In-memory cache index */
49
+ private cacheIndex;
50
+ /** Directory for storing cached artifacts */
51
+ private cacheDir;
52
+ /** Maximum cache size in bytes */
53
+ private maxCacheSize;
54
+ /** Time-to-live in milliseconds */
55
+ private ttl;
56
+ /** Path to the cache index file */
57
+ private indexPath;
58
+ /** Flag indicating initialization status */
59
+ private initialized;
60
+ /** Reference to FileCache for input hashing */
61
+ private fileCache;
62
+ /** Statistics */
63
+ private stats;
64
+ /**
65
+ * Private constructor for singleton pattern.
66
+ */
67
+ private constructor();
68
+ /**
69
+ * Gets the singleton instance of BuildCache.
70
+ */
71
+ static getInstance(options?: BuildCacheOptions): BuildCache;
72
+ /**
73
+ * Resets the singleton instance (useful for testing).
74
+ */
75
+ static resetInstance(): void;
76
+ /**
77
+ * Initializes the build cache.
78
+ */
79
+ initialize(): Promise<void>;
80
+ /**
81
+ * Looks up a cached build result.
82
+ *
83
+ * @param actionName - Name of the action (e.g., 'typescript', 'sass')
84
+ * @param inputFiles - Array of input file paths
85
+ * @param config - Build configuration object
86
+ * @returns Cache lookup result
87
+ */
88
+ lookup(actionName: string, inputFiles: string[], config?: Record<string, any>): Promise<CacheLookupResult>;
89
+ /**
90
+ * Stores a build result in the cache.
91
+ *
92
+ * @param actionName - Name of the action
93
+ * @param inputFiles - Array of input file paths
94
+ * @param outputFiles - Array of output file paths
95
+ * @param config - Build configuration object
96
+ * @param buildDuration - Optional build duration in milliseconds
97
+ */
98
+ store(actionName: string, inputFiles: string[], outputFiles: string[], config?: Record<string, any>, buildDuration?: number): Promise<void>;
99
+ /**
100
+ * Invalidates cache entries for a specific action.
101
+ */
102
+ invalidateAction(actionName: string): void;
103
+ /**
104
+ * Clears the entire build cache.
105
+ */
106
+ clear(): Promise<void>;
107
+ /**
108
+ * Saves the cache index to disk.
109
+ */
110
+ save(): Promise<void>;
111
+ /**
112
+ * Gets cache statistics.
113
+ */
114
+ getStats(): typeof this.stats & {
115
+ size: number;
116
+ hitRate: string;
117
+ };
118
+ /**
119
+ * Computes a unique cache key for a build.
120
+ */
121
+ private computeCacheKey;
122
+ /**
123
+ * Computes a combined hash of all input files.
124
+ */
125
+ private computeInputHash;
126
+ /**
127
+ * Computes a hash of the configuration object.
128
+ */
129
+ private computeConfigHash;
130
+ /**
131
+ * Verifies that all output files exist.
132
+ */
133
+ private verifyOutputFiles;
134
+ /**
135
+ * Stores output files as cached artifacts.
136
+ */
137
+ private storeArtifacts;
138
+ /**
139
+ * Restores output files from cached artifacts.
140
+ */
141
+ private restoreFromArtifacts;
142
+ /**
143
+ * Loads the cache index from disk.
144
+ */
145
+ private loadIndex;
146
+ /**
147
+ * Cleans up old cache entries if cache exceeds size limits.
148
+ */
149
+ private cleanupIfNeeded;
150
+ /**
151
+ * Evicts a single cache entry.
152
+ */
153
+ private evictEntry;
154
+ /**
155
+ * Gets the total size of a directory in bytes.
156
+ */
157
+ private getDirectorySize;
158
+ }
159
+ export {};