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,117 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // ============================================================================
7
+ // Constants
8
+ // ============================================================================
9
+ const svgspriteConfig = {
10
+ dest: "./dist/sprite", // Main output directory
11
+ // log: null, // Logging verbosity (default: no logging)
12
+ shape: {
13
+ // SVG shape related options
14
+ id: {
15
+ separator: "--", // Separator for directory name traversal
16
+ generator: "icon-%s",
17
+ // generator: function () { /*...*/ }, // SVG shape ID generator callback
18
+ pseudo: "~", // File name separator for shape states (e.g. ':hover')
19
+ },
20
+ dimension: {
21
+ // Dimension related options
22
+ maxWidth: 2000, // Max. shape width
23
+ maxHeight: 2000, // Max. shape height
24
+ precision: 2, // Floating point precision
25
+ attributes: false, // Width and height attributes on embedded shapes
26
+ },
27
+ spacing: {
28
+ // Spacing related options
29
+ padding: 0, // Padding around all shapes
30
+ box: "content", // Padding strategy (similar to CSS `box-sizing`)
31
+ },
32
+ transform: ["svgo"], // List of transformations / optimizations
33
+ // meta: null, // Path to YAML file with meta / accessibility data
34
+ // align: null, // Path to YAML file with extended alignment data
35
+ // dest: null // Output directory for optimized intermediate SVG shapes
36
+ },
37
+ svg: {
38
+ // General options for created SVG files
39
+ xmlDeclaration: false, // Add XML declaration to SVG sprite
40
+ // xmlDeclaration: true, // Add XML declaration to SVG sprite
41
+ doctypeDeclaration: true, // Add DOCTYPE declaration to SVG sprite
42
+ namespaceIDs: true, // Add namespace token to all IDs in SVG shapes
43
+ // namespaceIDPrefix: '', // Add a prefix to the automatically generated namespaceIDs
44
+ // namespaceClassnames: true, // Add namespace token to all CSS class names in SVG shapes
45
+ namespaceClassnames: false, // Add namespace token to all CSS class names in SVG shapes
46
+ dimensionAttributes: true, // Width and height attributes on the sprite
47
+ },
48
+ variables: {}, // Custom Mustache templating variables and functions
49
+ mode: {
50
+ css: {
51
+ // CSS sprite mode
52
+ render: {
53
+ css: true, // Render CSS stylesheet
54
+ },
55
+ },
56
+ view: true, // Create a «view» sprite
57
+ defs: true, // Create a «defs» sprite
58
+ // symbol: true, // Create a «symbol» sprite
59
+ symbol: {
60
+ // Create a «symbol» sprite
61
+ // dest: ".",
62
+ // inline: true, // Prepare for inline embedding
63
+ sprite: "icon.gl.svg",
64
+ },
65
+ stack: true, // Create a «stack» sprite
66
+ // symbol: true // Symbol sprite mode
67
+ },
68
+ };
69
+ // ============================================================================
70
+ // Export
71
+ // ============================================================================
72
+ exports.default = svgspriteConfig;
73
+ // "svgo": {
74
+ // "multipass": true,
75
+ // "plugins": [
76
+ // {
77
+ // "name": "preset-default",
78
+ // "params": {
79
+ // "overrides": {
80
+ // "removeUnknownsAndDefaults": {
81
+ // "keepDataAttrs": false,
82
+ // "keepRoleAttr": true
83
+ // },
84
+ // "removeViewBox": false
85
+ // }
86
+ // }
87
+ // },
88
+ // "cleanupListOfValues",
89
+ // "removeXMLNS",
90
+ // {
91
+ // "name": "removeAttrs",
92
+ // "params": {
93
+ // "attrs": [
94
+ // "clip-rule",
95
+ // "fill"
96
+ // ]
97
+ // }
98
+ // }
99
+ // ]
100
+ // }
101
+ // <mode>: {
102
+ // dest: "<mode>", // Mode specific output directory
103
+ // prefix: "svg-%s", // Prefix for CSS selectors
104
+ // dimensions: "-dims", // Suffix for dimension CSS selectors
105
+ // sprite: "svg/sprite.<mode>.svg", // Sprite path and name
106
+ // bust: true || false, // Cache busting (mode dependent default value)
107
+ // render: { // Stylesheet rendering definitions
108
+ // /* -------------------------------------------
109
+ // css: false, // CSS stylesheet options
110
+ // scss: false, // Sass stylesheet options
111
+ // less: false, // LESS stylesheet options
112
+ // styl: false, // Stylus stylesheet options
113
+ // <custom>: ... // Custom stylesheet options
114
+ // ------------------------------------------- */
115
+ // },
116
+ // example: false // Create an HTML example document
117
+ // }
@@ -0,0 +1,28 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
3
+ /**
4
+ * SvgToPngAction converts SVG content to PNG format.
5
+ * Uses `sharp` for conversion and `jsdom` for SVG element manipulation.
6
+ */
7
+ export declare class SvgToPngAction extends Action {
8
+ /**
9
+ * Executes the SVG-to-PNG conversion process.
10
+ * @param options - Options including SVG content, output path, width,
11
+ * and height.
12
+ */
13
+ execute(options: ActionOptionsType): Promise<void>;
14
+ /**
15
+ * Converts SVG content to a PNG file, optionally resizing the output.
16
+ * @param svgContent - The SVG content to be converted.
17
+ * @param outputPath - The filesystem path where the PNG should be saved.
18
+ * @param width - Optional width for resizing.
19
+ * @param height - Optional height for resizing.
20
+ */
21
+ private convert;
22
+ /**
23
+ * Provides a description of the action.
24
+ * @returns A string description of the action.
25
+ */
26
+ describe(): string;
27
+ }
28
+ export default SvgToPngAction;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Imports
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.SvgToPngAction = void 0;
19
+ const fs_1 = __importDefault(require("fs"));
20
+ const jsdom_1 = require("jsdom");
21
+ const path_1 = __importDefault(require("path"));
22
+ const sharp_1 = __importDefault(require("sharp"));
23
+ const Action_1 = require("../../core/pipeline/Action");
24
+ // ============================================================================
25
+ // Classes
26
+ // ============================================================================
27
+ /**
28
+ * SvgToPngAction converts SVG content to PNG format.
29
+ * Uses `sharp` for conversion and `jsdom` for SVG element manipulation.
30
+ */
31
+ class SvgToPngAction extends Action_1.Action {
32
+ // Methods
33
+ // ========================================================================
34
+ /**
35
+ * Executes the SVG-to-PNG conversion process.
36
+ * @param options - Options including SVG content, output path, width,
37
+ * and height.
38
+ */
39
+ execute(options) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { svgContent, outputPath, width, height } = options;
42
+ if (!svgContent || !outputPath) {
43
+ throw new Error("Both 'svgContent' and 'outputPath' must be provided.");
44
+ }
45
+ this.logInfo(`Converting SVG to PNG: ${outputPath}`);
46
+ try {
47
+ yield this.convert(svgContent, outputPath, width, height);
48
+ this.logInfo(`SVG successfully converted to PNG: ${outputPath}`);
49
+ }
50
+ catch (error) {
51
+ this.logError("Error converting SVG to PNG:", error);
52
+ throw error;
53
+ }
54
+ });
55
+ }
56
+ /**
57
+ * Converts SVG content to a PNG file, optionally resizing the output.
58
+ * @param svgContent - The SVG content to be converted.
59
+ * @param outputPath - The filesystem path where the PNG should be saved.
60
+ * @param width - Optional width for resizing.
61
+ * @param height - Optional height for resizing.
62
+ */
63
+ convert(svgContent, outputPath, width, height) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ // Ensure the output directory exists
67
+ const outputDir = path_1.default.dirname(outputPath);
68
+ if (!fs_1.default.existsSync(outputDir)) {
69
+ fs_1.default.mkdirSync(outputDir, { recursive: true });
70
+ }
71
+ // Create a JSDOM instance to parse the SVG
72
+ const dom = new jsdom_1.JSDOM(svgContent);
73
+ const svgElement = dom.window.document.querySelector("svg");
74
+ if (!svgElement) {
75
+ throw new Error("Invalid SVG content");
76
+ }
77
+ if (width) {
78
+ svgElement.setAttribute("width", width.toString());
79
+ }
80
+ if (height) {
81
+ svgElement.setAttribute("height", height.toString());
82
+ }
83
+ // Serialize the updated SVG content
84
+ const updatedSvgContent = svgElement.outerHTML;
85
+ // Convert SVG to PNG using Sharp
86
+ const pngBuffer = yield (0, sharp_1.default)(Buffer.from(updatedSvgContent))
87
+ .png()
88
+ .toBuffer();
89
+ yield (0, sharp_1.default)(pngBuffer).toFile(outputPath);
90
+ }
91
+ catch (error) {
92
+ throw new Error(`Error converting SVG to PNG: ${error.message}`);
93
+ }
94
+ });
95
+ }
96
+ /**
97
+ * Provides a description of the action.
98
+ * @returns A string description of the action.
99
+ */
100
+ describe() {
101
+ return "Converts SVG content to PNG format with optional resizing.";
102
+ }
103
+ }
104
+ exports.SvgToPngAction = SvgToPngAction;
105
+ // ============================================================================
106
+ // Export
107
+ // ============================================================================
108
+ exports.default = SvgToPngAction;
@@ -0,0 +1,2 @@
1
+ import { SvgToPngAction } from "./SvgToPngAction";
2
+ export { SvgToPngAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SvgToPngAction = void 0;
7
+ const SvgToPngAction_1 = require("./SvgToPngAction");
8
+ Object.defineProperty(exports, "SvgToPngAction", { enumerable: true, get: function () { return SvgToPngAction_1.SvgToPngAction; } });
@@ -0,0 +1,28 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType";
3
+ /**
4
+ * TypeScriptCompilerAction compiles TypeScript files into JavaScript.
5
+ */
6
+ export declare class TypeScriptCompilerAction extends Action {
7
+ /**
8
+ * Executes the TypeScript compilation process.
9
+ *
10
+ * @param options - The options specifying the tsconfig path and additional compiler options.
11
+ * @returns A Promise that resolves when compilation is completed successfully.
12
+ * @throws {Error} Throws an error if compilation fails.
13
+ */
14
+ execute(options: ActionOptionsType): Promise<void>;
15
+ /**
16
+ * Loads and parses `tsconfig.json` properly before passing it to the compiler.
17
+ *
18
+ * @param tsconfigPath - The path to the tsconfig.json file.
19
+ * @returns Parsed TypeScript compiler options and source files.
20
+ */
21
+ private loadAndParseTsConfig;
22
+ /**
23
+ * Provides a description of the action.
24
+ *
25
+ * @returns A string description of the action.
26
+ */
27
+ describe(): string;
28
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Imports
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.TypeScriptCompilerAction = void 0;
19
+ const path_1 = __importDefault(require("path"));
20
+ const typescript_1 = __importDefault(require("typescript"));
21
+ const Action_1 = require("../../core/pipeline/Action");
22
+ // ============================================================================
23
+ // Classes
24
+ // ============================================================================
25
+ /**
26
+ * TypeScriptCompilerAction compiles TypeScript files into JavaScript.
27
+ */
28
+ class TypeScriptCompilerAction extends Action_1.Action {
29
+ /**
30
+ * Executes the TypeScript compilation process.
31
+ *
32
+ * @param options - The options specifying the tsconfig path and additional compiler options.
33
+ * @returns A Promise that resolves when compilation is completed successfully.
34
+ * @throws {Error} Throws an error if compilation fails.
35
+ */
36
+ execute(options) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { tsconfigPath = "tsconfig.json" } = options;
39
+ const resolvedTsconfigPath = path_1.default.resolve(tsconfigPath);
40
+ this.logInfo(`Compiling TypeScript using configuration: ${resolvedTsconfigPath}`);
41
+ try {
42
+ // **Properly Parse tsconfig.json**
43
+ const parsedConfig = this.loadAndParseTsConfig(resolvedTsconfigPath);
44
+ // **Create a TypeScript Program**
45
+ const program = typescript_1.default.createProgram(parsedConfig.fileNames, parsedConfig.options);
46
+ const emitResult = program.emit();
47
+ // **Collect Diagnostics**
48
+ const allDiagnostics = typescript_1.default
49
+ .getPreEmitDiagnostics(program)
50
+ .concat(emitResult.diagnostics);
51
+ if (allDiagnostics.length > 0) {
52
+ allDiagnostics.forEach((diagnostic) => {
53
+ const message = typescript_1.default.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
54
+ this.logError(`TypeScript Error: ${message}`);
55
+ });
56
+ throw new Error("TypeScript compilation failed due to errors.");
57
+ }
58
+ this.logInfo("TypeScript compilation completed successfully.");
59
+ }
60
+ catch (error) {
61
+ this.logError("Error during TypeScript compilation:", error);
62
+ throw new Error(`TypeScript compilation failed: ${error.message}`);
63
+ }
64
+ });
65
+ }
66
+ /**
67
+ * Loads and parses `tsconfig.json` properly before passing it to the compiler.
68
+ *
69
+ * @param tsconfigPath - The path to the tsconfig.json file.
70
+ * @returns Parsed TypeScript compiler options and source files.
71
+ */
72
+ loadAndParseTsConfig(tsconfigPath) {
73
+ // **Read and Parse tsconfig.json**
74
+ const configFile = typescript_1.default.readConfigFile(tsconfigPath, typescript_1.default.sys.readFile);
75
+ if (configFile.error) {
76
+ throw new Error(`Error reading tsconfig.json: ${typescript_1.default.flattenDiagnosticMessageText(configFile.error.messageText, "\n")}`);
77
+ }
78
+ // **Parse the configuration content**
79
+ const parsedConfig = typescript_1.default.parseJsonConfigFileContent(configFile.config, typescript_1.default.sys, path_1.default.dirname(tsconfigPath));
80
+ if (parsedConfig.errors.length > 0) {
81
+ throw new Error(`Error parsing tsconfig.json: ${parsedConfig.errors
82
+ .map((diag) => typescript_1.default.flattenDiagnosticMessageText(diag.messageText, "\n"))
83
+ .join("\n")}`);
84
+ }
85
+ return parsedConfig;
86
+ }
87
+ /**
88
+ * Provides a description of the action.
89
+ *
90
+ * @returns A string description of the action.
91
+ */
92
+ describe() {
93
+ return "Compiles TypeScript files using a given tsconfig.json configuration.";
94
+ }
95
+ }
96
+ exports.TypeScriptCompilerAction = TypeScriptCompilerAction;
@@ -0,0 +1,2 @@
1
+ import { TypeScriptCompilerAction } from "./TypeScriptCompilerAction";
2
+ export { TypeScriptCompilerAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TypeScriptCompilerAction = void 0;
7
+ const TypeScriptCompilerAction_1 = require("./TypeScriptCompilerAction");
8
+ Object.defineProperty(exports, "TypeScriptCompilerAction", { enumerable: true, get: function () { return TypeScriptCompilerAction_1.TypeScriptCompilerAction; } });
@@ -0,0 +1,45 @@
1
+ import { Action } from "../../core/pipeline/Action";
2
+ import { ActionOptionsType } from "../../types";
3
+ /**
4
+ * VersionWriteAction is a step action responsible for replacing a version
5
+ * string in one or more specified files. The version is located and replaced
6
+ * based on a specified key and pattern.
7
+ */
8
+ export declare class VersionWriteAction extends Action {
9
+ /**
10
+ * Executes the version writing action.
11
+ * @param options - The options specific to version writing, including the
12
+ * files, key, and version string or a flag to retrieve it from
13
+ * `package.json`.
14
+ * @returns A Promise that resolves when the version has been successfully
15
+ * replaced in all specified files, or rejects with an error if the
16
+ * action fails.
17
+ */
18
+ execute(options: ActionOptionsType): Promise<void>;
19
+ /**
20
+ * Retrieves the version string from the `package.json` file.
21
+ * @returns A promise that resolves to the version string or `undefined`
22
+ * if not found.
23
+ * @throws {Error} Throws an error if `package.json` cannot be read.
24
+ */
25
+ private getVersionFromPackageJson;
26
+ /**
27
+ * Replaces a version string in a file for a specific key.
28
+ * This method reads the file, replaces the version for the key, and
29
+ * writes the updated content back to the file.
30
+ *
31
+ * @param filePath - The file path where the version should be replaced.
32
+ * @param version - The new version string to replace in the file.
33
+ * @param key - The key prefix that identifies the version line (e.g.,
34
+ * `version:`).
35
+ * @returns A promise that resolves when the version has been successfully
36
+ * replaced.
37
+ * @throws {Error} Throws an error if reading or writing the file fails.
38
+ */
39
+ private replaceVersionInFile;
40
+ /**
41
+ * Provides a description of the action.
42
+ * @returns A string description of the action.
43
+ */
44
+ describe(): string;
45
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
+ return new (P || (P = Promise))(function (resolve, reject) {
8
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
12
+ });
13
+ };
14
+ var __importDefault = (this && this.__importDefault) || function (mod) {
15
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.VersionWriteAction = void 0;
19
+ const fs_1 = require("fs");
20
+ const path_1 = __importDefault(require("path"));
21
+ const Action_1 = require("../../core/pipeline/Action");
22
+ // ============================================================================
23
+ // Classes
24
+ // ============================================================================
25
+ /**
26
+ * VersionWriteAction is a step action responsible for replacing a version
27
+ * string in one or more specified files. The version is located and replaced
28
+ * based on a specified key and pattern.
29
+ */
30
+ class VersionWriteAction extends Action_1.Action {
31
+ // Methods
32
+ // ========================================================================
33
+ /**
34
+ * Executes the version writing action.
35
+ * @param options - The options specific to version writing, including the
36
+ * files, key, and version string or a flag to retrieve it from
37
+ * `package.json`.
38
+ * @returns A Promise that resolves when the version has been successfully
39
+ * replaced in all specified files, or rejects with an error if the
40
+ * action fails.
41
+ */
42
+ execute(options) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const files = options.files;
45
+ let version = options.version;
46
+ if (!files) {
47
+ throw new Error(`Missing required option: files.`);
48
+ }
49
+ // Retrieve version from package.json if not explicitly provided
50
+ if (!version) {
51
+ version = yield this.getVersionFromPackageJson();
52
+ if (!version) {
53
+ throw new Error(`Version is not provided in options and could not be retrieved from package.json.`);
54
+ }
55
+ }
56
+ this.logInfo(`Replacing version "${version}" in specified files.`);
57
+ try {
58
+ // Replace the version in each file
59
+ yield Promise.all(files.map(({ path: filePath, key }) => this.replaceVersionInFile(filePath, version, key || "version:")));
60
+ this.logInfo(`Version "${version}" replaced successfully in all specified files.`);
61
+ }
62
+ catch (error) {
63
+ this.logError(`Failed to replace version in one or more files.`, error);
64
+ throw error;
65
+ }
66
+ });
67
+ }
68
+ /**
69
+ * Retrieves the version string from the `package.json` file.
70
+ * @returns A promise that resolves to the version string or `undefined`
71
+ * if not found.
72
+ * @throws {Error} Throws an error if `package.json` cannot be read.
73
+ */
74
+ getVersionFromPackageJson() {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ try {
77
+ const packageJsonPath = path_1.default.resolve(process.cwd(), "package.json");
78
+ const packageJsonContent = yield fs_1.promises.readFile(packageJsonPath, "utf8");
79
+ const packageJson = JSON.parse(packageJsonContent);
80
+ const version = packageJson.version;
81
+ if (version && /^\d+\.\d+\.\d+$/.test(version)) {
82
+ this.logInfo(`Version "${version}" retrieved from package.json.`);
83
+ return version;
84
+ }
85
+ else {
86
+ this.logWarn(`Invalid or missing version in package.json.`);
87
+ return undefined;
88
+ }
89
+ }
90
+ catch (error) {
91
+ this.logError(`Error reading package.json for version retrieval.`, error);
92
+ return undefined;
93
+ }
94
+ });
95
+ }
96
+ /**
97
+ * Replaces a version string in a file for a specific key.
98
+ * This method reads the file, replaces the version for the key, and
99
+ * writes the updated content back to the file.
100
+ *
101
+ * @param filePath - The file path where the version should be replaced.
102
+ * @param version - The new version string to replace in the file.
103
+ * @param key - The key prefix that identifies the version line (e.g.,
104
+ * `version:`).
105
+ * @returns A promise that resolves when the version has been successfully
106
+ * replaced.
107
+ * @throws {Error} Throws an error if reading or writing the file fails.
108
+ */
109
+ replaceVersionInFile(filePath, version, key) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ try {
112
+ const content = yield fs_1.promises.readFile(filePath, "utf8");
113
+ const lines = content.split("\n");
114
+ const updatedLines = lines.map((line) => {
115
+ const regex = new RegExp(`^\\s*${key}\\s*\\d+\\.\\d+\\.\\d+`);
116
+ if (regex.test(line)) {
117
+ return line.replace(/\d+\.\d+\.\d+$/, version);
118
+ }
119
+ return line;
120
+ });
121
+ yield fs_1.promises.writeFile(filePath, updatedLines.join("\n"), "utf8");
122
+ this.logInfo(`Version replaced in file "${filePath}" for key "${key}".`);
123
+ }
124
+ catch (error) {
125
+ throw new Error(`Error replacing version in file "${filePath}":
126
+ ${error.message}`);
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Provides a description of the action.
132
+ * @returns A string description of the action.
133
+ */
134
+ describe() {
135
+ let description = `
136
+ Replaces a version string in one or more specified files based on
137
+ a key and pattern. Can retrieve the version from package.json or
138
+ set it manually.
139
+ `;
140
+ return description;
141
+ }
142
+ }
143
+ exports.VersionWriteAction = VersionWriteAction;
144
+ // ============================================================================
145
+ // Export
146
+ // ============================================================================
147
+ // export default VersionWriteAction;
@@ -0,0 +1,2 @@
1
+ import { VersionWriteAction } from "./VersionWriteAction";
2
+ export { VersionWriteAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VersionWriteAction = void 0;
7
+ const VersionWriteAction_1 = require("./VersionWriteAction");
8
+ Object.defineProperty(exports, "VersionWriteAction", { enumerable: true, get: function () { return VersionWriteAction_1.VersionWriteAction; } });