kist 0.0.0 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +298 -3
  3. package/js/actions/CoreActions.d.ts +6 -0
  4. package/js/actions/CoreActions.js +47 -0
  5. package/js/actions/DirectoryCleanAction/DirectoryCleanAction.d.ts +36 -0
  6. package/js/actions/DirectoryCleanAction/DirectoryCleanAction.js +123 -0
  7. package/js/actions/DirectoryCleanAction/index.d.ts +2 -0
  8. package/js/actions/DirectoryCleanAction/index.js +8 -0
  9. package/js/actions/DirectoryCopyAction/DirectoryCopyAction.d.ts +42 -0
  10. package/js/actions/DirectoryCopyAction/DirectoryCopyAction.js +118 -0
  11. package/js/actions/DirectoryCopyAction/index.d.ts +2 -0
  12. package/js/actions/DirectoryCopyAction/index.js +8 -0
  13. package/js/actions/DirectoryCreateAction/DirectoryCreateAction.d.ts +30 -0
  14. package/js/actions/DirectoryCreateAction/DirectoryCreateAction.js +85 -0
  15. package/js/actions/DirectoryCreateAction/index.d.ts +2 -0
  16. package/js/actions/DirectoryCreateAction/index.js +8 -0
  17. package/js/actions/DocumentationAction/DocumentationAction.d.ts +23 -0
  18. package/js/actions/DocumentationAction/DocumentationAction.js +88 -0
  19. package/js/actions/DocumentationAction/index.d.ts +2 -0
  20. package/js/actions/DocumentationAction/index.js +8 -0
  21. package/js/actions/FileCopyAction/FileCopyAction.d.ts +42 -0
  22. package/js/actions/FileCopyAction/FileCopyAction.js +127 -0
  23. package/js/actions/FileCopyAction/index.d.ts +2 -0
  24. package/js/actions/FileCopyAction/index.js +8 -0
  25. package/js/actions/FileRenameAction/FileRenameAction.d.ts +30 -0
  26. package/js/actions/FileRenameAction/FileRenameAction.js +84 -0
  27. package/js/actions/FileRenameAction/index.d.ts +2 -0
  28. package/js/actions/FileRenameAction/index.js +8 -0
  29. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.d.ts +31 -0
  30. package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.js +98 -0
  31. package/js/actions/JavaScriptMinifyAction/index.d.ts +2 -0
  32. package/js/actions/JavaScriptMinifyAction/index.js +8 -0
  33. package/js/actions/JavaScriptMinifyAction/terser.config.d.ts +27 -0
  34. package/js/actions/JavaScriptMinifyAction/terser.config.js +119 -0
  35. package/js/actions/LintAction/LintAction.d.ts +17 -0
  36. package/js/actions/LintAction/LintAction.js +63 -0
  37. package/js/actions/LintAction/index.d.ts +2 -0
  38. package/js/actions/LintAction/index.js +8 -0
  39. package/js/actions/PackageManagerAction/PackageManagerAction.d.ts +57 -0
  40. package/js/actions/PackageManagerAction/PackageManagerAction.js +161 -0
  41. package/js/actions/PackageManagerAction/index.d.ts +2 -0
  42. package/js/actions/PackageManagerAction/index.js +8 -0
  43. package/js/actions/PackageManagerAction/package.config.d.ts +16 -0
  44. package/js/actions/PackageManagerAction/package.config.js +91 -0
  45. package/js/actions/StyleProcessingAction/StyleProcessingAction.d.ts +34 -0
  46. package/js/actions/StyleProcessingAction/StyleProcessingAction.js +164 -0
  47. package/js/actions/StyleProcessingAction/index.d.ts +2 -0
  48. package/js/actions/StyleProcessingAction/index.js +8 -0
  49. package/js/actions/StyleProcessingAction/postcss.config.compressed.d.ts +10 -0
  50. package/js/actions/StyleProcessingAction/postcss.config.compressed.js +31 -0
  51. package/js/actions/StyleProcessingAction/postcss.config.expanded.d.ts +16 -0
  52. package/js/actions/StyleProcessingAction/postcss.config.expanded.js +45 -0
  53. package/js/actions/SvgPackagerAction/SvgPackagerAction.d.ts +68 -0
  54. package/js/actions/SvgPackagerAction/SvgPackagerAction.js +186 -0
  55. package/js/actions/SvgPackagerAction/index.d.ts +2 -0
  56. package/js/actions/SvgPackagerAction/index.js +8 -0
  57. package/js/actions/SvgReaderAction/SvgReaderAction.d.ts +32 -0
  58. package/js/actions/SvgReaderAction/SvgReaderAction.js +87 -0
  59. package/js/actions/SvgReaderAction/index.d.ts +2 -0
  60. package/js/actions/SvgReaderAction/index.js +8 -0
  61. package/js/actions/SvgSpriteAction/SvgSpriteAction.d.ts +37 -0
  62. package/js/actions/SvgSpriteAction/SvgSpriteAction.js +114 -0
  63. package/js/actions/SvgSpriteAction/index.d.ts +2 -0
  64. package/js/actions/SvgSpriteAction/index.js +8 -0
  65. package/js/actions/SvgSpriteAction/svgsprite.config.d.ts +3 -0
  66. package/js/actions/SvgSpriteAction/svgsprite.config.js +117 -0
  67. package/js/actions/SvgToPngAction/SvgToPngAction.d.ts +28 -0
  68. package/js/actions/SvgToPngAction/SvgToPngAction.js +108 -0
  69. package/js/actions/SvgToPngAction/index.d.ts +2 -0
  70. package/js/actions/SvgToPngAction/index.js +8 -0
  71. package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.d.ts +28 -0
  72. package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.js +96 -0
  73. package/js/actions/TypeScriptCompilerAction/index.d.ts +2 -0
  74. package/js/actions/TypeScriptCompilerAction/index.js +8 -0
  75. package/js/actions/VersionWriteAction/VersionWriteAction.d.ts +45 -0
  76. package/js/actions/VersionWriteAction/VersionWriteAction.js +147 -0
  77. package/js/actions/VersionWriteAction/index.d.ts +2 -0
  78. package/js/actions/VersionWriteAction/index.js +8 -0
  79. package/js/cli/ArgumentParser.d.ts +62 -0
  80. package/js/cli/ArgumentParser.js +118 -0
  81. package/js/cli.d.ts +6 -0
  82. package/js/cli.js +58 -0
  83. package/js/core/abstract/AbstractProcess.d.ts +62 -0
  84. package/js/core/abstract/AbstractProcess.js +96 -0
  85. package/js/core/abstract/AbstractValidator.d.ts +72 -0
  86. package/js/core/abstract/AbstractValidator.js +128 -0
  87. package/js/core/config/ConfigLoader.d.ts +47 -0
  88. package/js/core/config/ConfigLoader.js +130 -0
  89. package/js/core/config/ConfigStore.d.ts +69 -0
  90. package/js/core/config/ConfigStore.js +168 -0
  91. package/js/core/config/defaultConfig.d.ts +5 -0
  92. package/js/core/config/defaultConfig.js +131 -0
  93. package/js/core/pipeline/Action.d.ts +60 -0
  94. package/js/core/pipeline/Action.js +77 -0
  95. package/js/core/pipeline/ActionRegistry.d.ts +80 -0
  96. package/js/core/pipeline/ActionRegistry.js +180 -0
  97. package/js/core/pipeline/Pipeline.d.ts +42 -0
  98. package/js/core/pipeline/Pipeline.js +107 -0
  99. package/js/core/pipeline/PipelineManager.d.ts +55 -0
  100. package/js/core/pipeline/PipelineManager.js +164 -0
  101. package/js/core/pipeline/Stage.d.ts +45 -0
  102. package/js/core/pipeline/Stage.js +110 -0
  103. package/js/core/pipeline/Step.d.ts +26 -0
  104. package/js/core/pipeline/Step.js +85 -0
  105. package/js/core/validation/OptionsValidator.d.ts +43 -0
  106. package/js/core/validation/OptionsValidator.js +123 -0
  107. package/js/index.d.ts +3 -0
  108. package/js/index.js +36 -0
  109. package/js/interface/ActionInterface.d.ts +57 -0
  110. package/js/interface/ActionInterface.js +5 -0
  111. package/js/interface/ActionPlugin.d.ts +4 -0
  112. package/js/interface/ActionPlugin.js +5 -0
  113. package/js/interface/ConfigInterface.d.ts +43 -0
  114. package/js/interface/ConfigInterface.js +5 -0
  115. package/js/interface/LiveOptionsInterface.d.ts +42 -0
  116. package/js/interface/LiveOptionsInterface.js +2 -0
  117. package/js/interface/MetadataInterface.d.ts +95 -0
  118. package/js/interface/MetadataInterface.js +2 -0
  119. package/js/interface/OptionsInterface.d.ts +45 -0
  120. package/js/interface/OptionsInterface.js +5 -0
  121. package/js/interface/PipelineOptionsInterface.d.ts +66 -0
  122. package/js/interface/PipelineOptionsInterface.js +5 -0
  123. package/js/interface/StageInterface.d.ts +79 -0
  124. package/js/interface/StageInterface.js +5 -0
  125. package/js/interface/StepInterface.d.ts +66 -0
  126. package/js/interface/StepInterface.js +5 -0
  127. package/js/interface/StepOptionsInterface.d.ts +38 -0
  128. package/js/interface/StepOptionsInterface.js +21 -0
  129. package/js/interface/index.d.ts +7 -0
  130. package/js/interface/index.js +3 -0
  131. package/js/kist.d.ts +58 -0
  132. package/js/kist.js +145 -0
  133. package/js/live/LiveServer.d.ts +95 -0
  134. package/js/live/LiveServer.js +233 -0
  135. package/js/live/LiveWatcher.d.ts +45 -0
  136. package/js/live/LiveWatcher.js +140 -0
  137. package/js/logger/Logger.d.ts +94 -0
  138. package/js/logger/Logger.js +151 -0
  139. package/js/logger/LoggerStyles.d.ts +23 -0
  140. package/js/logger/LoggerStyles.js +30 -0
  141. package/js/types/ActionOptionsType.d.ts +8 -0
  142. package/js/types/ActionOptionsType.js +2 -0
  143. package/js/types/index.d.ts +1 -0
  144. package/js/types/index.js +3 -0
  145. package/package.json +93 -7
  146. package/ts/actions/CoreActions.ts +64 -0
  147. package/ts/actions/DirectoryCleanAction/DirectoryCleanAction.ts +121 -0
  148. package/ts/actions/DirectoryCleanAction/index.ts +11 -0
  149. package/ts/actions/DirectoryCopyAction/DirectoryCopyAction.ts +118 -0
  150. package/ts/actions/DirectoryCopyAction/index.ts +11 -0
  151. package/ts/actions/DirectoryCreateAction/DirectoryCreateAction.ts +81 -0
  152. package/ts/actions/DirectoryCreateAction/index.ts +11 -0
  153. package/ts/actions/DocumentationAction/DocumentationAction.ts +100 -0
  154. package/ts/actions/DocumentationAction/index.ts +11 -0
  155. package/ts/actions/FileCopyAction/FileCopyAction.ts +125 -0
  156. package/ts/actions/FileCopyAction/index.ts +11 -0
  157. package/ts/actions/FileRenameAction/FileRenameAction.ts +82 -0
  158. package/ts/actions/FileRenameAction/index.ts +11 -0
  159. package/ts/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.ts +109 -0
  160. package/ts/actions/JavaScriptMinifyAction/index.ts +11 -0
  161. package/ts/actions/JavaScriptMinifyAction/terser.config.ts +177 -0
  162. package/ts/actions/LintAction/LintAction.ts +67 -0
  163. package/ts/actions/LintAction/index.ts +11 -0
  164. package/ts/actions/PackageManagerAction/PackageManagerAction.ts +176 -0
  165. package/ts/actions/PackageManagerAction/index.ts +11 -0
  166. package/ts/actions/PackageManagerAction/package.config.ts +94 -0
  167. package/ts/actions/SassDocAction/SassDocAction.ts +66 -0
  168. package/ts/actions/SassDocAction/index.ts +11 -0
  169. package/ts/actions/StyleProcessingAction/StyleProcessingAction.ts +142 -0
  170. package/ts/actions/StyleProcessingAction/index.ts +11 -0
  171. package/ts/actions/StyleProcessingAction/postcss.config.compressed.ts +31 -0
  172. package/ts/actions/StyleProcessingAction/postcss.config.expanded.ts +47 -0
  173. package/ts/actions/SvgPackagerAction/SvgPackagerAction.ts +187 -0
  174. package/ts/actions/SvgPackagerAction/index.ts +11 -0
  175. package/ts/actions/SvgReaderAction/SvgReaderAction.ts +77 -0
  176. package/ts/actions/SvgReaderAction/index.ts +11 -0
  177. package/ts/actions/SvgSpriteAction/SvgSpriteAction.ts +127 -0
  178. package/ts/actions/SvgSpriteAction/index.ts +11 -0
  179. package/ts/actions/SvgSpriteAction/svgsprite.config.ts +123 -0
  180. package/ts/actions/SvgToPngAction/SvgToPngAction.ts +113 -0
  181. package/ts/actions/SvgToPngAction/index.ts +11 -0
  182. package/ts/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.ts +117 -0
  183. package/ts/actions/TypeScriptCompilerAction/index.ts +11 -0
  184. package/ts/actions/VersionWriteAction/VersionWriteAction.ts +174 -0
  185. package/ts/actions/VersionWriteAction/index.ts +11 -0
  186. package/ts/actions/index.ts +0 -0
  187. package/ts/cli/ArgumentParser.ts +150 -0
  188. package/ts/cli/index.ts +1 -0
  189. package/ts/cli.ts +56 -0
  190. package/ts/core/abstract/AbstractProcess.ts +109 -0
  191. package/ts/core/abstract/AbstractSingleton.ts +46 -0
  192. package/ts/core/abstract/AbstractValidator.ts +167 -0
  193. package/ts/core/abstract/index.ts +0 -0
  194. package/ts/core/config/ConfigLoader.ts +141 -0
  195. package/ts/core/config/ConfigStore.ts +201 -0
  196. package/ts/core/config/defaultConfig.ts +154 -0
  197. package/ts/core/config/index.ts +0 -0
  198. package/ts/core/index.ts +34 -0
  199. package/ts/core/pipeline/Action.ts +101 -0
  200. package/ts/core/pipeline/ActionRegistry.ts +216 -0
  201. package/ts/core/pipeline/Pipeline.ts +121 -0
  202. package/ts/core/pipeline/PipelineManager.ts +170 -0
  203. package/ts/core/pipeline/Stage.ts +131 -0
  204. package/ts/core/pipeline/Step.ts +96 -0
  205. package/ts/core/pipeline/index.ts +0 -0
  206. package/ts/core/validation/ActionValidator.ts +97 -0
  207. package/ts/core/validation/ConfigValidator.ts +103 -0
  208. package/ts/core/validation/OptionsValidator.ts +179 -0
  209. package/ts/core/validation/StageValidator.ts +175 -0
  210. package/ts/core/validation/StepValidator.ts +203 -0
  211. package/ts/core/validation/index.ts +0 -0
  212. package/ts/index.ts +26 -0
  213. package/ts/interface/ActionInterface.ts +70 -0
  214. package/ts/interface/ActionPlugin.ts +14 -0
  215. package/ts/interface/ConfigInterface.ts +55 -0
  216. package/ts/interface/File.ts +24 -0
  217. package/ts/interface/LiveOptionsInterface.ts +46 -0
  218. package/ts/interface/MetadataInterface.ts +105 -0
  219. package/ts/interface/OptionsInterface.ts +58 -0
  220. package/ts/interface/PackageJson.ts +171 -0
  221. package/ts/interface/PipelineOptionsInterface.ts +74 -0
  222. package/ts/interface/SVG.ts +84 -0
  223. package/ts/interface/StageInterface.ts +96 -0
  224. package/ts/interface/StepInterface.ts +83 -0
  225. package/ts/interface/StepOptionsInterface.ts +57 -0
  226. package/ts/interface/index.ts +9 -0
  227. package/ts/kist.ts +161 -0
  228. package/ts/live/LiveServer.ts +311 -0
  229. package/ts/live/LiveWatcher.ts +150 -0
  230. package/ts/live/index.ts +11 -0
  231. package/ts/logger/Logger.ts +187 -0
  232. package/ts/logger/LoggerStyles.ts +28 -0
  233. package/ts/logger/index.ts +0 -0
  234. package/ts/types/ActionOptionsType.ts +10 -0
  235. package/ts/types/index.ts +3 -0
  236. package/index.js +0 -3
@@ -0,0 +1,161 @@
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.PackageManagerAction = void 0;
19
+ const promises_1 = __importDefault(require("fs/promises"));
20
+ const path_1 = __importDefault(require("path"));
21
+ const Action_1 = require("../../core/pipeline/Action");
22
+ const package_config_js_1 = __importDefault(require("./package.config.js"));
23
+ // ============================================================================
24
+ // Classes
25
+ // ============================================================================
26
+ /**
27
+ * PackageManagerAction handles reading, validating, and creating `package.json`
28
+ * files, supporting custom configurations and merging with selected fields.
29
+ */
30
+ class PackageManagerAction extends Action_1.Action {
31
+ /**
32
+ * Executes the package management action.
33
+ * Reads an existing `package.json`, extracts selected fields, and writes a new one.
34
+ *
35
+ * @param options - Options specifying input path, output directory, and fields to export.
36
+ * @returns A Promise that resolves when the action is completed successfully.
37
+ * @throws {Error} Throws an error if neither `packageJsonPath` nor `outputDir` is provided.
38
+ */
39
+ execute(options) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { packageJsonPath, outputDir, fields = [], // Specify which fields to copy
42
+ customConfig = {}, } = options;
43
+ if (!packageJsonPath) {
44
+ throw new Error("The 'packageJsonPath' option is required.");
45
+ }
46
+ if (!outputDir) {
47
+ throw new Error("The 'outputDir' option is required.");
48
+ }
49
+ const existingConfig = yield this.readPackageJson(packageJsonPath);
50
+ const filteredConfig = this.filterFields(existingConfig, fields);
51
+ yield this.createPackageJson(outputDir, filteredConfig, customConfig);
52
+ });
53
+ }
54
+ /**
55
+ * Reads and parses an existing `package.json`.
56
+ *
57
+ * @param packageJsonPath - Path to the `package.json` file.
58
+ * @returns Parsed JSON object.
59
+ * @throws {Error} If the file does not exist or contains invalid JSON.
60
+ */
61
+ readPackageJson(packageJsonPath) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const fullPath = path_1.default.resolve(packageJsonPath);
64
+ try {
65
+ const fileContent = yield promises_1.default.readFile(fullPath, "utf-8");
66
+ const parsedContent = JSON.parse(fileContent);
67
+ this.logInfo(`Successfully read package.json from ${fullPath}`);
68
+ return parsedContent;
69
+ }
70
+ catch (error) {
71
+ if (error.code === "ENOENT") {
72
+ throw new Error(`File not found at ${fullPath}. Please ensure the path is correct.`);
73
+ }
74
+ else if (error.name === "SyntaxError") {
75
+ throw new Error(`Invalid JSON in ${fullPath}: ${error.message}`);
76
+ }
77
+ else {
78
+ throw new Error(`Unexpected error while reading ${fullPath}: ${error.message}`);
79
+ }
80
+ }
81
+ });
82
+ }
83
+ /**
84
+ * Filters specified fields from a `package.json` object.
85
+ *
86
+ * @param config - The original package.json object.
87
+ * @param fields - List of fields to extract.
88
+ * @returns A new object containing only the selected fields.
89
+ */
90
+ filterFields(config, fields) {
91
+ if (!fields.length) {
92
+ return config; // If no fields are specified, return the full config.
93
+ }
94
+ const filteredConfig = {};
95
+ for (const field of fields) {
96
+ if (config[field] !== undefined) {
97
+ filteredConfig[field] = config[field];
98
+ }
99
+ }
100
+ this.logInfo(`Filtered package.json fields: ${JSON.stringify(filteredConfig, null, 2)}`);
101
+ return filteredConfig;
102
+ }
103
+ /**
104
+ * Creates a `package.json` file with selected fields and custom overrides.
105
+ *
106
+ * @param outputDir - Directory where the new `package.json` will be created.
107
+ * @param filteredConfig - The filtered package.json fields.
108
+ * @param customConfig - Custom overrides to apply.
109
+ * @returns A Promise that resolves when the file has been successfully created.
110
+ * @throws {Error} If the file cannot be written.
111
+ */
112
+ createPackageJson(outputDir, filteredConfig, customConfig) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const filePath = path_1.default.join(outputDir, "package.json");
115
+ // Merge default settings with filtered config and custom overrides
116
+ const finalConfig = Object.assign(Object.assign(Object.assign({}, package_config_js_1.default), filteredConfig), customConfig);
117
+ const data = JSON.stringify(finalConfig, null, 2);
118
+ try {
119
+ yield this.ensureDirectoryExists(outputDir);
120
+ yield promises_1.default.writeFile(filePath, data, "utf-8");
121
+ this.logInfo(`package.json successfully created at ${filePath}`);
122
+ }
123
+ catch (error) {
124
+ this.logError("Error creating package.json", error);
125
+ throw error;
126
+ }
127
+ });
128
+ }
129
+ /**
130
+ * Ensures that the specified directory exists, creating it if it does not.
131
+ *
132
+ * @param dirPath - The path of the directory to verify or create.
133
+ * @returns A Promise that resolves once the directory is verified or created.
134
+ * @throws {Error} If the directory cannot be created.
135
+ */
136
+ ensureDirectoryExists(dirPath) {
137
+ return __awaiter(this, void 0, void 0, function* () {
138
+ try {
139
+ yield promises_1.default.mkdir(dirPath, { recursive: true });
140
+ }
141
+ catch (error) {
142
+ if (error.code !== "EEXIST") {
143
+ throw error;
144
+ }
145
+ }
146
+ });
147
+ }
148
+ /**
149
+ * Provides a description of the action.
150
+ *
151
+ * @returns A string description of the action.
152
+ */
153
+ describe() {
154
+ return "Reads an existing package.json, extracts selected fields, and creates a new one.";
155
+ }
156
+ }
157
+ exports.PackageManagerAction = PackageManagerAction;
158
+ // ============================================================================
159
+ // Export
160
+ // ============================================================================
161
+ // export default PackageManagerAction;
@@ -0,0 +1,2 @@
1
+ import { PackageManagerAction } from "./PackageManagerAction";
2
+ export { PackageManagerAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PackageManagerAction = void 0;
7
+ const PackageManagerAction_1 = require("./PackageManagerAction");
8
+ Object.defineProperty(exports, "PackageManagerAction", { enumerable: true, get: function () { return PackageManagerAction_1.PackageManagerAction; } });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Configuration object for package.json properties, used to define metadata,
3
+ * file inclusions, and other necessary project configurations.
4
+ */
5
+ declare const packageConfig: {
6
+ name: string;
7
+ version: string;
8
+ description: string;
9
+ keywords: string;
10
+ license: string;
11
+ homepage: string;
12
+ main: string;
13
+ types: string;
14
+ files: string[];
15
+ };
16
+ export default packageConfig;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Constants
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /**
7
+ * Configuration object for package.json properties, used to define metadata,
8
+ * file inclusions, and other necessary project configurations.
9
+ */
10
+ const packageConfig = {
11
+ name: "example-project",
12
+ version: "0.1.0",
13
+ description: "",
14
+ keywords: "",
15
+ license: "MIT",
16
+ homepage: "https://www.example.com",
17
+ // funding: [
18
+ // {
19
+ // "type": "github",
20
+ // "url": "https://github.com/sponsors/scape-foundation"
21
+ // }
22
+ // ],
23
+ // type: "module",
24
+ // main: "js/index",
25
+ main: "js/index.js",
26
+ // types: "js/index",
27
+ types: "js/index.d.ts",
28
+ // "module": "dist/js/unit.gl.js",
29
+ // "style": "dist/css/unit.gl.css",
30
+ // "sass": "src/scss/index.scss",
31
+ // main: 'index.js',
32
+ files: [
33
+ "code-snippets/**/*.code-snippets",
34
+ "css/**/*.{css,map}",
35
+ "font/**/*.{eot,otf,ttf,woff,woff2}",
36
+ "inkscape/**/*.inkscape",
37
+ "jinja/**/*.jinja",
38
+ "js/**/*.d.ts",
39
+ "js/**/*.{js,map}",
40
+ "less/**/*.less",
41
+ "md/**/*.md",
42
+ "oco/**/*.oco",
43
+ "png/**/*.png",
44
+ "py/**/*.py",
45
+ "rcpx/**/*.rcpx",
46
+ "scss/**/*.scss",
47
+ "sketchpalette/**/*.sketchpalette",
48
+ "styl/**/*.styl",
49
+ "svg/**/*.svg",
50
+ "tex/**/*.tex",
51
+ "ts/**/*.ts",
52
+ "!.DS_Store",
53
+ ],
54
+ // exports: {
55
+ // ".": {
56
+ // // "sass": "./src/scss/index.scss",
57
+ // // "import": "./dist/js/index.mjs",
58
+ // // "default": "./dist/js/index.js"
59
+ // "sass": "./scss/index.scss",
60
+ // "scss": "./scss/index.scss",
61
+ // "typescript": "./ts/index.ts",
62
+ // "default": "./js/index.js"
63
+ // }
64
+ // }
65
+ // repository: {
66
+ // type: pack.repository.type,
67
+ // url: pack.repository.url,
68
+ // },
69
+ // author?: string | {
70
+ // name: string;
71
+ // email?: string;
72
+ // url?: string;
73
+ // };
74
+ // bugs?: {
75
+ // url?: string;
76
+ // email?: string;
77
+ // };
78
+ // contributors?: Array<string | {
79
+ // name: string;
80
+ // email?: string;
81
+ // url?: string;
82
+ // }>;
83
+ // funding?: string | {
84
+ // type: string;
85
+ // url: string;
86
+ // };
87
+ };
88
+ // ============================================================================
89
+ // Export
90
+ // ============================================================================
91
+ exports.default = packageConfig;
@@ -0,0 +1,34 @@
1
+ import { Action } from "../../core/pipeline/Action.js";
2
+ import { ActionOptionsType } from "../../types/ActionOptionsType.js";
3
+ /**
4
+ * StyleProcessingAction is a step action responsible for processing styles,
5
+ * including compiling SCSS and applying PostCSS transformations. It supports
6
+ * expanded and compressed output styles based on the provided configuration.
7
+ */
8
+ export declare class StyleProcessingAction extends Action {
9
+ /**
10
+ * Executes the style processing action.
11
+ * @param options - The options specific to style processing, including
12
+ * input/output file paths and style format.
13
+ * @returns A Promise that resolves when the styles are processed
14
+ * successfully, or rejects with an error if the action fails.
15
+ */
16
+ execute(options: ActionOptionsType): Promise<void>;
17
+ /**
18
+ * Processes the given CSS with PostCSS based on the provided style option.
19
+ * @param css - The CSS string to process.
20
+ * @param styleOption - The style option, either "expanded" or "compressed".
21
+ * @returns Processed CSS string.
22
+ */
23
+ private processPostCSS;
24
+ /**
25
+ * Ensures that the given directory exists, creating it if it does not.
26
+ * @param dirPath - The path of the directory to check and create.
27
+ */
28
+ private ensureDirectoryExists;
29
+ /**
30
+ * Provides a description of the action.
31
+ * @returns A string description of the action.
32
+ */
33
+ describe(): string;
34
+ }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.StyleProcessingAction = void 0;
52
+ const fs_1 = require("fs");
53
+ const path_1 = __importDefault(require("path"));
54
+ const postcss_1 = __importDefault(require("postcss"));
55
+ const sass = __importStar(require("sass"));
56
+ const Action_js_1 = require("../../core/pipeline/Action.js");
57
+ // Assuming the PostCSS configurations are available at the given paths
58
+ const postcss_config_compressed_js_1 = __importDefault(require("./postcss.config.compressed.js"));
59
+ const postcss_config_expanded_js_1 = __importDefault(require("./postcss.config.expanded.js"));
60
+ // ============================================================================
61
+ // Classes
62
+ // ============================================================================
63
+ /**
64
+ * StyleProcessingAction is a step action responsible for processing styles,
65
+ * including compiling SCSS and applying PostCSS transformations. It supports
66
+ * expanded and compressed output styles based on the provided configuration.
67
+ */
68
+ class StyleProcessingAction extends Action_js_1.Action {
69
+ // Parameters
70
+ // ========================================================================
71
+ // Constructor
72
+ // ========================================================================
73
+ // Methods
74
+ // ========================================================================
75
+ /**
76
+ * Executes the style processing action.
77
+ * @param options - The options specific to style processing, including
78
+ * input/output file paths and style format.
79
+ * @returns A Promise that resolves when the styles are processed
80
+ * successfully, or rejects with an error if the action fails.
81
+ */
82
+ execute(options) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ const inputFile = options.inputFile;
85
+ const outputFile = options.outputFile;
86
+ const styleOption = options.styleOption;
87
+ if (!inputFile || !outputFile || !styleOption) {
88
+ throw new Error("Missing required options: inputFile, outputFile, or styleOption.");
89
+ }
90
+ this.logInfo(`Processing styles from ${inputFile} to ${outputFile} with ${styleOption} style.`);
91
+ try {
92
+ // Ensure the output directory exists
93
+ const outputDir = path_1.default.dirname(outputFile);
94
+ yield this.ensureDirectoryExists(outputDir);
95
+ // Compile SCSS to CSS
96
+ const result = yield sass.compileAsync(inputFile, {
97
+ style: styleOption,
98
+ importers: [new sass.NodePackageImporter()],
99
+ });
100
+ // Process the compiled CSS with PostCSS
101
+ const processedCss = yield this.processPostCSS(result.css, styleOption);
102
+ // Write the processed CSS to a file
103
+ yield fs_1.promises.writeFile(outputFile, processedCss, "utf-8");
104
+ this.logInfo(`Styles processed successfully from ${inputFile} to ${outputFile}.`);
105
+ }
106
+ catch (error) {
107
+ this.logError(`Error processing styles from ${inputFile}: ${error}`);
108
+ throw error;
109
+ }
110
+ });
111
+ }
112
+ /**
113
+ * Processes the given CSS with PostCSS based on the provided style option.
114
+ * @param css - The CSS string to process.
115
+ * @param styleOption - The style option, either "expanded" or "compressed".
116
+ * @returns Processed CSS string.
117
+ */
118
+ processPostCSS(css, styleOption) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ const config = styleOption === "expanded"
121
+ ? postcss_config_expanded_js_1.default
122
+ : postcss_config_compressed_js_1.default;
123
+ const result = yield (0, postcss_1.default)(config.plugins).process(css, {
124
+ from: undefined,
125
+ map: { inline: false },
126
+ });
127
+ return result.css;
128
+ });
129
+ }
130
+ /**
131
+ * Ensures that the given directory exists, creating it if it does not.
132
+ * @param dirPath - The path of the directory to check and create.
133
+ */
134
+ ensureDirectoryExists(dirPath) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ try {
137
+ yield fs_1.promises.mkdir(dirPath, { recursive: true });
138
+ }
139
+ catch (error) {
140
+ if (error instanceof Error) {
141
+ const nodeError = error;
142
+ if (nodeError.code !== "EEXIST") {
143
+ throw nodeError;
144
+ }
145
+ }
146
+ else {
147
+ throw error;
148
+ }
149
+ }
150
+ });
151
+ }
152
+ /**
153
+ * Provides a description of the action.
154
+ * @returns A string description of the action.
155
+ */
156
+ describe() {
157
+ return "Processes SCSS files into CSS, applying PostCSS transformations for expanded or compressed outputs.";
158
+ }
159
+ }
160
+ exports.StyleProcessingAction = StyleProcessingAction;
161
+ // ============================================================================
162
+ // Export
163
+ // ============================================================================
164
+ // export default StyleProcessingAction;
@@ -0,0 +1,2 @@
1
+ import { StyleProcessingAction } from "./StyleProcessingAction";
2
+ export { StyleProcessingAction };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StyleProcessingAction = void 0;
7
+ const StyleProcessingAction_1 = require("./StyleProcessingAction");
8
+ Object.defineProperty(exports, "StyleProcessingAction", { enumerable: true, get: function () { return StyleProcessingAction_1.StyleProcessingAction; } });
@@ -0,0 +1,10 @@
1
+ import autoprefixer from "autoprefixer";
2
+ /**
3
+ * Configuration object for PostCSS that includes plugins for optimization and compression
4
+ * of CSS. This setup is typically used for production builds where minimized CSS is preferred
5
+ * to reduce file size and improve loading times.
6
+ */
7
+ declare const postcssConfigCompressed: {
8
+ plugins: (typeof autoprefixer | import("postcss").Processor)[];
9
+ };
10
+ export default postcssConfigCompressed;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const autoprefixer_1 = __importDefault(require("autoprefixer")); // Handles CSS vendor prefixing automatically
10
+ const cssnano_1 = __importDefault(require("cssnano")); // A PostCSS plugin for CSS minimization
11
+ // ============================================================================
12
+ // Constants
13
+ // ============================================================================
14
+ /**
15
+ * Configuration object for PostCSS that includes plugins for optimization and compression
16
+ * of CSS. This setup is typically used for production builds where minimized CSS is preferred
17
+ * to reduce file size and improve loading times.
18
+ */
19
+ const postcssConfigCompressed = {
20
+ plugins: [
21
+ autoprefixer_1.default, // Automatically adds vendor prefixes to CSS rules
22
+ (0, cssnano_1.default)({
23
+ // Compresses CSS output
24
+ preset: "default", // Uses the default settings for compression
25
+ }),
26
+ ],
27
+ };
28
+ // ============================================================================
29
+ // Export
30
+ // ============================================================================
31
+ exports.default = postcssConfigCompressed;
@@ -0,0 +1,16 @@
1
+ import autoprefixer from "autoprefixer";
2
+ /**
3
+ * Configuration object for PostCSS that focuses on generating expanded, readable CSS
4
+ * for development environments. Includes plugins that enhance CSS handling like nesting,
5
+ * variable support, and import inlining, alongside autoprefixer for browser compatibility.
6
+ */
7
+ declare const postcssConfigExpanded: {
8
+ plugins: (typeof autoprefixer)[];
9
+ };
10
+ export default postcssConfigExpanded;
11
+ /**
12
+ * Note: This configuration is intended for development use where extended readability
13
+ * and ease of debugging are critical. The cssnano plugin is commented out by default
14
+ * to keep the output CSS as clean and readable as possible; it can be enabled for
15
+ * environments that require slightly more optimized output without full minification.
16
+ */
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // Import
4
+ // ============================================================================
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const autoprefixer_1 = __importDefault(require("autoprefixer")); // Automatically adds vendor prefixes to CSS rules
10
+ // import postcssSimpleVars from 'postcss-simple-vars'; // Plugin to handle CSS variables
11
+ // import postcssNested from 'postcss-nested'; // Plugin to allow nesting of CSS rules
12
+ // import postcssImport from 'postcss-import'; // Plugin to inline import CSS files into a single CSS
13
+ // ============================================================================
14
+ // Constants
15
+ // ============================================================================
16
+ /**
17
+ * Configuration object for PostCSS that focuses on generating expanded, readable CSS
18
+ * for development environments. Includes plugins that enhance CSS handling like nesting,
19
+ * variable support, and import inlining, alongside autoprefixer for browser compatibility.
20
+ */
21
+ const postcssConfigExpanded = {
22
+ plugins: [
23
+ autoprefixer_1.default,
24
+ // Include other plugins suited for the expanded output
25
+ ],
26
+ // plugins: [
27
+ // postcssImport(), // Allows importing of other CSS files within a CSS file
28
+ // autoprefixer(), // Adds vendor prefixes to CSS, using data from Can I Use
29
+ // postcssSimpleVars(), // Enables the use of Sass-like variables in CSS
30
+ // postcssNested(), // Process nested rules, which is similar to how Sass handles nesting
31
+ // // cssnano({
32
+ // // preset: 'default', // Optionally include for light compression or reformatting
33
+ // // }),
34
+ // ]
35
+ };
36
+ // ============================================================================
37
+ // Export
38
+ // ============================================================================
39
+ exports.default = postcssConfigExpanded;
40
+ /**
41
+ * Note: This configuration is intended for development use where extended readability
42
+ * and ease of debugging are critical. The cssnano plugin is commented out by default
43
+ * to keep the output CSS as clean and readable as possible; it can be enabled for
44
+ * environments that require slightly more optimized output without full minification.
45
+ */