@getkist/action-sass 1.0.5 → 1.0.9

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 (29) hide show
  1. package/dist/index.cjs +311 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/{actions/StyleProcessingAction/StyleProcessingAction.d.ts → index.d.cts} +77 -5
  4. package/dist/index.d.ts +153 -7
  5. package/dist/index.mjs +279 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +21 -13
  8. package/dist/actions/StyleProcessingAction/StyleProcessingAction.d.ts.map +0 -1
  9. package/dist/actions/StyleProcessingAction/StyleProcessingAction.js +0 -215
  10. package/dist/actions/StyleProcessingAction/StyleProcessingAction.js.map +0 -1
  11. package/dist/actions/StyleProcessingAction/index.d.ts +0 -3
  12. package/dist/actions/StyleProcessingAction/index.d.ts.map +0 -1
  13. package/dist/actions/StyleProcessingAction/index.js +0 -5
  14. package/dist/actions/StyleProcessingAction/index.js.map +0 -1
  15. package/dist/actions/StyleProcessingAction/postcss.config.compressed.d.ts +0 -11
  16. package/dist/actions/StyleProcessingAction/postcss.config.compressed.d.ts.map +0 -1
  17. package/dist/actions/StyleProcessingAction/postcss.config.compressed.js +0 -26
  18. package/dist/actions/StyleProcessingAction/postcss.config.compressed.js.map +0 -1
  19. package/dist/actions/StyleProcessingAction/postcss.config.expanded.d.ts +0 -11
  20. package/dist/actions/StyleProcessingAction/postcss.config.expanded.d.ts.map +0 -1
  21. package/dist/actions/StyleProcessingAction/postcss.config.expanded.js +0 -20
  22. package/dist/actions/StyleProcessingAction/postcss.config.expanded.js.map +0 -1
  23. package/dist/index.d.ts.map +0 -1
  24. package/dist/index.js +0 -20
  25. package/dist/index.js.map +0 -1
  26. package/dist/types/Action.d.ts +0 -70
  27. package/dist/types/Action.d.ts.map +0 -1
  28. package/dist/types/Action.js +0 -56
  29. package/dist/types/Action.js.map +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,311 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+ var postcss = require('postcss');
8
+ var sass = require('sass');
9
+ var autoprefixer = require('autoprefixer');
10
+ var cssnano = require('cssnano');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ function _interopNamespace(e) {
15
+ if (e && e.__esModule) return e;
16
+ var n = Object.create(null);
17
+ if (e) {
18
+ Object.keys(e).forEach(function (k) {
19
+ if (k !== 'default') {
20
+ var d = Object.getOwnPropertyDescriptor(e, k);
21
+ Object.defineProperty(n, k, d.get ? d : {
22
+ enumerable: true,
23
+ get: function () { return e[k]; }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n.default = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var path__default = /*#__PURE__*/_interopDefault(path);
33
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
34
+ var sass__namespace = /*#__PURE__*/_interopNamespace(sass);
35
+ var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
36
+ var cssnano__default = /*#__PURE__*/_interopDefault(cssnano);
37
+
38
+ // src/actions/StyleProcessingAction/StyleProcessingAction.ts
39
+
40
+ // src/types/Action.ts
41
+ var Action = class {
42
+ /**
43
+ * Gets the unique name of the action.
44
+ */
45
+ get name() {
46
+ return this.constructor.name;
47
+ }
48
+ /**
49
+ * Validates options before execution
50
+ * Override in subclasses for specific validation
51
+ */
52
+ validateOptions(_options) {
53
+ return true;
54
+ }
55
+ /**
56
+ * Provides a description of the action
57
+ */
58
+ describe() {
59
+ return `${this.name} action`;
60
+ }
61
+ /**
62
+ * Log an info message
63
+ */
64
+ logInfo(message) {
65
+ console.log(`[${this.name}] ${message}`);
66
+ }
67
+ /**
68
+ * Log an error message
69
+ */
70
+ logError(message, error) {
71
+ console.error(`[${this.name}] ERROR: ${message}`, error || "");
72
+ }
73
+ /**
74
+ * Log a debug message
75
+ */
76
+ logDebug(message) {
77
+ if (process.env.DEBUG) {
78
+ console.debug(`[${this.name}] DEBUG: ${message}`);
79
+ }
80
+ }
81
+ /**
82
+ * Log a warning message
83
+ */
84
+ logWarning(message) {
85
+ console.warn(`[${this.name}] WARNING: ${message}`);
86
+ }
87
+ };
88
+ var postcssConfigCompressed = {
89
+ plugins: [
90
+ autoprefixer__default.default,
91
+ cssnano__default.default({
92
+ preset: "default"
93
+ })
94
+ ]
95
+ };
96
+ var postcss_config_compressed_default = postcssConfigCompressed;
97
+ var postcssConfigExpanded = {
98
+ plugins: [autoprefixer__default.default]
99
+ };
100
+ var postcss_config_expanded_default = postcssConfigExpanded;
101
+
102
+ // src/actions/StyleProcessingAction/StyleProcessingAction.ts
103
+ var StyleProcessingAction = class extends Action {
104
+ // Parameters
105
+ // ========================================================================
106
+ // Constructor
107
+ // ========================================================================
108
+ // Methods
109
+ // ========================================================================
110
+ /**
111
+ * Executes the style processing action.
112
+ * @param options - The options specific to style processing, including
113
+ * input/output file paths and style format.
114
+ * @returns A Promise that resolves when the styles are processed
115
+ * successfully, or rejects with an error if the action fails.
116
+ */
117
+ async execute(options) {
118
+ const inputFile = options.inputFile;
119
+ if (!inputFile) {
120
+ throw new Error("Missing required option: inputFile.");
121
+ }
122
+ if (options.outputs && options.outputs.length > 0) {
123
+ await this.executeMultiOutput(inputFile, options.outputs, options.sourceMapIncludeSources ?? true);
124
+ return;
125
+ }
126
+ await this.executeSingleOutput(options);
127
+ }
128
+ /**
129
+ * Executes multi-output mode: compiles SCSS for each unique style,
130
+ * then generates all specified output files.
131
+ */
132
+ async executeMultiOutput(inputFile, outputs, sourceMapIncludeSources) {
133
+ this.logInfo(
134
+ `Processing styles from ${inputFile} to ${outputs.length} outputs`
135
+ );
136
+ const expandedOutputs = outputs.filter((o) => o.style === "expanded");
137
+ const compressedOutputs = outputs.filter((o) => o.style === "compressed");
138
+ const compiledCache = /* @__PURE__ */ new Map();
139
+ for (const style of ["expanded", "compressed"]) {
140
+ const outputsForStyle = style === "expanded" ? expandedOutputs : compressedOutputs;
141
+ if (outputsForStyle.length === 0) continue;
142
+ const needsSourceMap = outputsForStyle.some((o) => o.sourceMap);
143
+ const result = await sass__namespace.compileAsync(inputFile, {
144
+ style,
145
+ importers: [new sass__namespace.NodePackageImporter()],
146
+ sourceMap: needsSourceMap,
147
+ sourceMapIncludeSources: needsSourceMap && sourceMapIncludeSources
148
+ });
149
+ compiledCache.set(style, {
150
+ css: result.css,
151
+ sourceMap: result.sourceMap
152
+ });
153
+ }
154
+ for (const output of outputs) {
155
+ const compiled = compiledCache.get(output.style);
156
+ const sourceMap = output.sourceMap ?? false;
157
+ try {
158
+ const outputDir = path__default.default.dirname(output.file);
159
+ await this.ensureDirectoryExists(outputDir);
160
+ const { css: processedCss, map: processedMap } = await this.processPostCSS(
161
+ compiled.css,
162
+ output.style,
163
+ sourceMap ? {
164
+ inputFile,
165
+ outputFile: output.file,
166
+ sassSourceMap: compiled.sourceMap
167
+ } : void 0
168
+ );
169
+ await fs.promises.writeFile(output.file, processedCss, "utf-8");
170
+ if (sourceMap && processedMap) {
171
+ const mapFile = `${output.file}.map`;
172
+ await fs.promises.writeFile(mapFile, processedMap.toString(), "utf-8");
173
+ this.logInfo(` \u2192 ${output.file} (${output.style} + sourcemap)`);
174
+ } else {
175
+ this.logInfo(` \u2192 ${output.file} (${output.style})`);
176
+ }
177
+ } catch (error) {
178
+ this.logError(`Error processing ${output.file}: ${error}`);
179
+ throw error;
180
+ }
181
+ }
182
+ this.logInfo(`Multi-output style processing complete`);
183
+ }
184
+ /**
185
+ * Executes single-output mode (legacy behavior).
186
+ */
187
+ async executeSingleOutput(options) {
188
+ const inputFile = options.inputFile;
189
+ const outputFile = options.outputFile;
190
+ const styleOption = options.styleOption;
191
+ const sourceMap = options.sourceMap ?? false;
192
+ const sourceMapIncludeSources = options.sourceMapIncludeSources ?? true;
193
+ if (!outputFile || !styleOption) {
194
+ throw new Error(
195
+ "Missing required options: outputFile or styleOption (or use 'outputs' for multi-output mode)."
196
+ );
197
+ }
198
+ this.logInfo(
199
+ `Processing styles from ${inputFile} to ${outputFile} with ${styleOption} style${sourceMap ? " + sourcemap" : ""}.`
200
+ );
201
+ try {
202
+ const outputDir = path__default.default.dirname(outputFile);
203
+ await this.ensureDirectoryExists(outputDir);
204
+ const result = await sass__namespace.compileAsync(inputFile, {
205
+ style: styleOption,
206
+ importers: [new sass__namespace.NodePackageImporter()],
207
+ sourceMap,
208
+ sourceMapIncludeSources: sourceMap && sourceMapIncludeSources
209
+ });
210
+ const { css: processedCss, map: processedMap } = await this.processPostCSS(
211
+ result.css,
212
+ styleOption,
213
+ sourceMap ? {
214
+ inputFile,
215
+ outputFile,
216
+ sassSourceMap: result.sourceMap
217
+ } : void 0
218
+ );
219
+ await fs.promises.writeFile(outputFile, processedCss, "utf-8");
220
+ if (sourceMap && processedMap) {
221
+ const mapFile = `${outputFile}.map`;
222
+ await fs.promises.writeFile(
223
+ mapFile,
224
+ processedMap.toString(),
225
+ "utf-8"
226
+ );
227
+ this.logInfo(`Sourcemap written to ${mapFile}`);
228
+ }
229
+ this.logInfo(
230
+ `Styles processed successfully from ${inputFile} to ${outputFile}.`
231
+ );
232
+ } catch (error) {
233
+ this.logError(
234
+ `Error processing styles from ${inputFile}: ${error}`
235
+ );
236
+ throw error;
237
+ }
238
+ }
239
+ /**
240
+ * Processes the given CSS with PostCSS based on the provided style option.
241
+ * @param css - The CSS string to process.
242
+ * @param styleOption - The style option, either "expanded" or "compressed".
243
+ * @param sourceMapOptions - Optional sourcemap configuration.
244
+ * @returns Object containing processed CSS string and optional sourcemap.
245
+ */
246
+ async processPostCSS(css, styleOption, sourceMapOptions) {
247
+ const config = styleOption === "expanded" ? postcss_config_expanded_default : postcss_config_compressed_default;
248
+ const postcssOptions = {
249
+ from: sourceMapOptions?.inputFile,
250
+ to: sourceMapOptions?.outputFile
251
+ };
252
+ if (sourceMapOptions) {
253
+ postcssOptions.map = {
254
+ inline: false,
255
+ annotation: `${path__default.default.basename(sourceMapOptions.outputFile)}.map`,
256
+ prev: sourceMapOptions.sassSourceMap ? JSON.stringify(sourceMapOptions.sassSourceMap) : false,
257
+ sourcesContent: true
258
+ };
259
+ } else {
260
+ postcssOptions.map = false;
261
+ }
262
+ const result = await postcss__default.default(config.plugins).process(css, postcssOptions);
263
+ return { css: result.css, map: result.map };
264
+ }
265
+ /**
266
+ * Ensures that the given directory exists, creating it if it does not.
267
+ * @param dirPath - The path of the directory to check and create.
268
+ */
269
+ async ensureDirectoryExists(dirPath) {
270
+ try {
271
+ await fs.promises.mkdir(dirPath, { recursive: true });
272
+ } catch (error) {
273
+ if (error instanceof Error) {
274
+ const nodeError = error;
275
+ if (nodeError.code !== "EEXIST") {
276
+ throw nodeError;
277
+ }
278
+ } else {
279
+ throw error;
280
+ }
281
+ }
282
+ }
283
+ /**
284
+ * Provides a description of the action.
285
+ * @returns A string description of the action.
286
+ */
287
+ describe() {
288
+ return "Processes SCSS files into CSS, applying PostCSS transformations for expanded or compressed outputs.";
289
+ }
290
+ };
291
+
292
+ // src/index.ts
293
+ var plugin = {
294
+ version: "1.0.4",
295
+ description: "SASS/SCSS compilation with PostCSS processing for kist",
296
+ author: "kist",
297
+ repository: "https://github.com/getkist/kist-action-sass",
298
+ keywords: ["kist", "kist-action", "sass", "scss", "postcss", "css"],
299
+ registerActions() {
300
+ return {
301
+ StyleProcessingAction
302
+ };
303
+ }
304
+ };
305
+ var src_default = plugin;
306
+
307
+ exports.Action = Action;
308
+ exports.StyleProcessingAction = StyleProcessingAction;
309
+ exports.default = src_default;
310
+ //# sourceMappingURL=index.cjs.map
311
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/Action.ts","../src/actions/StyleProcessingAction/postcss.config.compressed.ts","../src/actions/StyleProcessingAction/postcss.config.expanded.ts","../src/actions/StyleProcessingAction/StyleProcessingAction.ts","../src/index.ts"],"names":["autoprefixer","cssnano","sass","path","fs","postcss"],"mappings":";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A,EAAK,MAAA,CAAO,GAAA,EAAK,GAAA,EAAK,OAAO,GAAA,EAAI;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAc,sBAAsB,OAAA,EAAgC;AAChE,IAAA,IAAI;AACA,MAAA,MAAMD,YAAG,KAAA,CAAM,OAAA,EAAS,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA,IAC/C,SAAS,KAAA,EAAO;AACZ,MAAA,IAAI,iBAAiB,KAAA,EAAO;AACxB,QAAA,MAAM,SAAA,GAAY,KAAA;AAClB,QAAA,IAAI,SAAA,CAAU,SAAS,QAAA,EAAU;AAC7B,UAAA,MAAM,SAAA;AAAA,QACV;AAAA,MACJ,CAAA,MAAO;AACH,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,QAAA,GAAmB;AACf,IAAA,OAAO,qGAAA;AAAA,EACX;AACJ;;;ACzTA,IAAM,MAAA,GAAuB;AAAA,EACzB,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,wDAAA;AAAA,EACb,MAAA,EAAQ,MAAA;AAAA,EACR,UAAA,EAAY,6CAAA;AAAA,EACZ,UAAU,CAAC,MAAA,EAAQ,eAAe,MAAA,EAAQ,MAAA,EAAQ,WAAW,KAAK,CAAA;AAAA,EAClE,eAAA,GAAkB;AACd,IAAA,OAAO;AAAA,MACH;AAAA,KACJ;AAAA,EACJ;AACJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Base Action types for kist action plugins\n * These types match the kist Action interface for compatibility\n */\n\n/**\n * Action options type - a generic record of key-value pairs\n */\nexport type ActionOptionsType = Record<string, unknown>;\n\n/**\n * Abstract base class for all kist actions\n * Provides logging and execution interface\n */\nexport abstract class Action<T extends ActionOptionsType = ActionOptionsType> {\n /**\n * Gets the unique name of the action.\n */\n get name(): string {\n return this.constructor.name;\n }\n\n /**\n * Validates options before execution\n * Override in subclasses for specific validation\n */\n validateOptions(_options: T): boolean {\n return true;\n }\n\n /**\n * Execute the action with given options\n * Must be implemented by subclasses\n */\n abstract execute(options: T): Promise<void>;\n\n /**\n * Provides a description of the action\n */\n describe(): string {\n return `${this.name} action`;\n }\n\n /**\n * Log an info message\n */\n protected logInfo(message: string): void {\n console.log(`[${this.name}] ${message}`);\n }\n\n /**\n * Log an error message\n */\n protected logError(message: string, error?: unknown): void {\n console.error(`[${this.name}] ERROR: ${message}`, error || \"\");\n }\n\n /**\n * Log a debug message\n */\n protected logDebug(message: string): void {\n if (process.env.DEBUG) {\n console.debug(`[${this.name}] DEBUG: ${message}`);\n }\n }\n\n /**\n * Log a warning message\n */\n protected logWarning(message: string): void {\n console.warn(`[${this.name}] WARNING: ${message}`);\n }\n}\n\n/**\n * Plugin interface for kist action packages\n */\nexport interface ActionPlugin {\n /** Plugin name */\n name?: string;\n /** Plugin version */\n version: string;\n /** Plugin description */\n description?: string;\n /** Plugin author */\n author?: string;\n /** Repository URL */\n repository?: string;\n /** Keywords */\n keywords?: string[];\n /** Map of action names to action classes */\n actions?: Record<string, new () => Action>;\n /** Register actions method */\n registerActions?: () => Record<string, new () => Action>;\n}\n","// ============================================================================\n// Import\n// ============================================================================\n\nimport autoprefixer from \"autoprefixer\";\nimport cssnano from \"cssnano\";\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Configuration object for PostCSS that includes plugins for optimization and compression\n * of CSS. This setup is typically used for production builds where minimized CSS is preferred\n * to reduce file size and improve loading times.\n */\nconst postcssConfigCompressed = {\n plugins: [\n autoprefixer,\n cssnano({\n preset: \"default\",\n }),\n ],\n};\n\n// ============================================================================\n// Export\n// ============================================================================\n\nexport default postcssConfigCompressed;\n","// ============================================================================\n// Import\n// ============================================================================\n\nimport autoprefixer from \"autoprefixer\";\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Configuration object for PostCSS that focuses on generating expanded, readable CSS\n * for development environments. Includes plugins that enhance CSS handling like nesting,\n * variable support, and import inlining, alongside autoprefixer for browser compatibility.\n */\nconst postcssConfigExpanded = {\n plugins: [autoprefixer],\n};\n\n// ============================================================================\n// Export\n// ============================================================================\n\nexport default postcssConfigExpanded;\n","// ============================================================================\n// Import\n// ============================================================================\n\nimport { promises as fs } from \"fs\";\nimport path from \"path\";\nimport postcss from \"postcss\";\nimport * as sass from \"sass\";\n\nimport { Action, ActionOptionsType } from \"../../types/Action.js\";\n\n// Assuming the PostCSS configurations are available at the given paths\nimport postcssConfigCompressed from \"./postcss.config.compressed.js\";\nimport postcssConfigExpanded from \"./postcss.config.expanded.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Single output configuration for multi-output mode.\n */\nexport interface StyleOutputConfig {\n /** Output file path */\n file: string;\n /** CSS style: expanded or compressed */\n style: \"expanded\" | \"compressed\";\n /** Enable sourcemap for this output (default: false) */\n sourceMap?: boolean;\n}\n\nexport interface StyleProcessingActionOptions extends ActionOptionsType {\n /** Input SCSS/CSS file path */\n inputFile: string;\n\n /** Single output file path (mutually exclusive with outputs) */\n outputFile?: string;\n /** Single output style option (mutually exclusive with outputs) */\n styleOption?: \"expanded\" | \"compressed\";\n\n /**\n * Multiple outputs from single input (mutually exclusive with outputFile/styleOption).\n * Allows generating both expanded and compressed CSS from one source.\n *\n * @example\n * ```yaml\n * outputs:\n * - file: \"./dist/css/app.css\"\n * style: expanded\n * sourceMap: true\n * - file: \"./dist/css/app.min.css\"\n * style: compressed\n * ```\n */\n outputs?: StyleOutputConfig[];\n\n /** Enable sourcemap generation for single output mode (default: false) */\n sourceMap?: boolean;\n /** Include original source content in sourcemap (default: true when sourceMap enabled) */\n sourceMapIncludeSources?: boolean;\n}\n\n// ============================================================================\n// Classes\n// ============================================================================\n\n/**\n * StyleProcessingAction is a step action responsible for processing styles,\n * including compiling SCSS and applying PostCSS transformations. It supports\n * expanded and compressed output styles based on the provided configuration.\n */\nexport class StyleProcessingAction extends Action {\n // Parameters\n // ========================================================================\n\n // Constructor\n // ========================================================================\n\n // Methods\n // ========================================================================\n\n /**\n * Executes the style processing action.\n * @param options - The options specific to style processing, including\n * input/output file paths and style format.\n * @returns A Promise that resolves when the styles are processed\n * successfully, or rejects with an error if the action fails.\n */\n async execute(options: StyleProcessingActionOptions): Promise<void> {\n const inputFile = options.inputFile;\n\n if (!inputFile) {\n throw new Error(\"Missing required option: inputFile.\");\n }\n\n // Multi-output mode\n if (options.outputs && options.outputs.length > 0) {\n await this.executeMultiOutput(inputFile, options.outputs, options.sourceMapIncludeSources ?? true);\n return;\n }\n\n // Single output mode (legacy)\n await this.executeSingleOutput(options);\n }\n\n /**\n * Executes multi-output mode: compiles SCSS for each unique style,\n * then generates all specified output files.\n */\n private async executeMultiOutput(\n inputFile: string,\n outputs: StyleOutputConfig[],\n sourceMapIncludeSources: boolean,\n ): Promise<void> {\n this.logInfo(\n `Processing styles from ${inputFile} to ${outputs.length} outputs`,\n );\n\n // Group outputs by style to avoid redundant SCSS compilation\n const expandedOutputs = outputs.filter((o) => o.style === \"expanded\");\n const compressedOutputs = outputs.filter((o) => o.style === \"compressed\");\n\n // Compile SCSS for each style variant needed\n const compiledCache = new Map<\"expanded\" | \"compressed\", { css: string; sourceMap?: object }>();\n\n for (const style of [\"expanded\", \"compressed\"] as const) {\n const outputsForStyle = style === \"expanded\" ? expandedOutputs : compressedOutputs;\n if (outputsForStyle.length === 0) continue;\n\n const needsSourceMap = outputsForStyle.some((o) => o.sourceMap);\n const result = await sass.compileAsync(inputFile, {\n style,\n importers: [new sass.NodePackageImporter()],\n sourceMap: needsSourceMap,\n sourceMapIncludeSources: needsSourceMap && sourceMapIncludeSources,\n });\n compiledCache.set(style, {\n css: result.css,\n sourceMap: result.sourceMap,\n });\n }\n\n // Process each output\n for (const output of outputs) {\n const compiled = compiledCache.get(output.style)!;\n const sourceMap = output.sourceMap ?? false;\n\n try {\n // Ensure output directory exists\n const outputDir = path.dirname(output.file);\n await this.ensureDirectoryExists(outputDir);\n\n // Process with PostCSS\n const { css: processedCss, map: processedMap } =\n await this.processPostCSS(\n compiled.css,\n output.style,\n sourceMap\n ? {\n inputFile,\n outputFile: output.file,\n sassSourceMap: compiled.sourceMap,\n }\n : undefined,\n );\n\n // Write CSS\n await fs.writeFile(output.file, processedCss, \"utf-8\");\n\n // Write sourcemap if enabled\n if (sourceMap && processedMap) {\n const mapFile = `${output.file}.map`;\n await fs.writeFile(mapFile, processedMap.toString(), \"utf-8\");\n this.logInfo(` → ${output.file} (${output.style} + sourcemap)`);\n } else {\n this.logInfo(` → ${output.file} (${output.style})`);\n }\n } catch (error) {\n this.logError(`Error processing ${output.file}: ${error}`);\n throw error;\n }\n }\n\n this.logInfo(`Multi-output style processing complete`);\n }\n\n /**\n * Executes single-output mode (legacy behavior).\n */\n private async executeSingleOutput(\n options: StyleProcessingActionOptions,\n ): Promise<void> {\n const inputFile = options.inputFile;\n const outputFile = options.outputFile;\n const styleOption = options.styleOption;\n const sourceMap = options.sourceMap ?? false;\n const sourceMapIncludeSources = options.sourceMapIncludeSources ?? true;\n\n if (!outputFile || !styleOption) {\n throw new Error(\n \"Missing required options: outputFile or styleOption (or use 'outputs' for multi-output mode).\",\n );\n }\n\n this.logInfo(\n `Processing styles from ${inputFile} to ${outputFile} with ${styleOption} style${sourceMap ? \" + sourcemap\" : \"\"}.`,\n );\n\n try {\n // Ensure the output directory exists\n const outputDir = path.dirname(outputFile);\n await this.ensureDirectoryExists(outputDir);\n\n // Compile SCSS to CSS\n const result = await sass.compileAsync(inputFile, {\n style: styleOption,\n importers: [new sass.NodePackageImporter()],\n sourceMap: sourceMap,\n sourceMapIncludeSources: sourceMap && sourceMapIncludeSources,\n });\n\n // Process the compiled CSS with PostCSS\n const { css: processedCss, map: processedMap } =\n await this.processPostCSS(\n result.css,\n styleOption,\n sourceMap\n ? {\n inputFile,\n outputFile,\n sassSourceMap: result.sourceMap,\n }\n : undefined,\n );\n\n // Write the processed CSS to a file\n await fs.writeFile(outputFile, processedCss, \"utf-8\");\n\n // Write sourcemap if enabled\n if (sourceMap && processedMap) {\n const mapFile = `${outputFile}.map`;\n await fs.writeFile(\n mapFile,\n processedMap.toString(),\n \"utf-8\",\n );\n this.logInfo(`Sourcemap written to ${mapFile}`);\n }\n\n this.logInfo(\n `Styles processed successfully from ${inputFile} to ${outputFile}.`,\n );\n } catch (error) {\n this.logError(\n `Error processing styles from ${inputFile}: ${error}`,\n );\n throw error;\n }\n }\n\n /**\n * Processes the given CSS with PostCSS based on the provided style option.\n * @param css - The CSS string to process.\n * @param styleOption - The style option, either \"expanded\" or \"compressed\".\n * @param sourceMapOptions - Optional sourcemap configuration.\n * @returns Object containing processed CSS string and optional sourcemap.\n */\n private async processPostCSS(\n css: string,\n styleOption: \"expanded\" | \"compressed\",\n sourceMapOptions?: {\n inputFile: string;\n outputFile: string;\n sassSourceMap?: unknown;\n },\n ): Promise<{ css: string; map?: postcss.SourceMap }> {\n const config =\n styleOption === \"expanded\"\n ? postcssConfigExpanded\n : postcssConfigCompressed;\n\n const postcssOptions: postcss.ProcessOptions = {\n from: sourceMapOptions?.inputFile,\n to: sourceMapOptions?.outputFile,\n };\n\n if (sourceMapOptions) {\n postcssOptions.map = {\n inline: false,\n annotation: `${path.basename(sourceMapOptions.outputFile)}.map`,\n prev: sourceMapOptions.sassSourceMap\n ? JSON.stringify(sourceMapOptions.sassSourceMap)\n : false,\n sourcesContent: true,\n };\n } else {\n postcssOptions.map = false;\n }\n\n const result = await postcss(config.plugins).process(css, postcssOptions);\n return { css: result.css, map: result.map };\n }\n\n /**\n * Ensures that the given directory exists, creating it if it does not.\n * @param dirPath - The path of the directory to check and create.\n */\n private async ensureDirectoryExists(dirPath: string): Promise<void> {\n try {\n await fs.mkdir(dirPath, { recursive: true });\n } catch (error) {\n if (error instanceof Error) {\n const nodeError = error as NodeJS.ErrnoException;\n if (nodeError.code !== \"EEXIST\") {\n throw nodeError;\n }\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Provides a description of the action.\n * @returns A string description of the action.\n */\n describe(): string {\n return \"Processes SCSS files into CSS, applying PostCSS transformations for expanded or compressed outputs.\";\n }\n}\n","// ============================================================================\n// Export\n// ============================================================================\n\nexport { StyleProcessingAction } from \"./actions/StyleProcessingAction/index.js\";\nexport type { StyleProcessingActionOptions } from \"./actions/StyleProcessingAction/index.js\";\nexport { Action, ActionPlugin } from \"./types/Action.js\";\nexport type { ActionOptionsType } from \"./types/Action.js\";\n\n// ============================================================================\n// Plugin Definition\n// ============================================================================\n\nimport { ActionPlugin } from \"./types/Action.js\";\nimport { StyleProcessingAction } from \"./actions/StyleProcessingAction/index.js\";\n\nconst plugin: ActionPlugin = {\n version: \"1.0.4\",\n description: \"SASS/SCSS compilation with PostCSS processing for kist\",\n author: \"kist\",\n repository: \"https://github.com/getkist/kist-action-sass\",\n keywords: [\"kist\", \"kist-action\", \"sass\", \"scss\", \"postcss\", \"css\"],\n registerActions() {\n return {\n StyleProcessingAction,\n };\n },\n};\n\nexport default plugin;\n"]}
@@ -1,8 +1,77 @@
1
- import { Action, ActionOptionsType } from "../../types/Action.js";
1
+ /**
2
+ * Base Action types for kist action plugins
3
+ * These types match the kist Action interface for compatibility
4
+ */
5
+ /**
6
+ * Action options type - a generic record of key-value pairs
7
+ */
8
+ type ActionOptionsType = Record<string, unknown>;
9
+ /**
10
+ * Abstract base class for all kist actions
11
+ * Provides logging and execution interface
12
+ */
13
+ declare abstract class Action<T extends ActionOptionsType = ActionOptionsType> {
14
+ /**
15
+ * Gets the unique name of the action.
16
+ */
17
+ get name(): string;
18
+ /**
19
+ * Validates options before execution
20
+ * Override in subclasses for specific validation
21
+ */
22
+ validateOptions(_options: T): boolean;
23
+ /**
24
+ * Execute the action with given options
25
+ * Must be implemented by subclasses
26
+ */
27
+ abstract execute(options: T): Promise<void>;
28
+ /**
29
+ * Provides a description of the action
30
+ */
31
+ describe(): string;
32
+ /**
33
+ * Log an info message
34
+ */
35
+ protected logInfo(message: string): void;
36
+ /**
37
+ * Log an error message
38
+ */
39
+ protected logError(message: string, error?: unknown): void;
40
+ /**
41
+ * Log a debug message
42
+ */
43
+ protected logDebug(message: string): void;
44
+ /**
45
+ * Log a warning message
46
+ */
47
+ protected logWarning(message: string): void;
48
+ }
49
+ /**
50
+ * Plugin interface for kist action packages
51
+ */
52
+ interface ActionPlugin {
53
+ /** Plugin name */
54
+ name?: string;
55
+ /** Plugin version */
56
+ version: string;
57
+ /** Plugin description */
58
+ description?: string;
59
+ /** Plugin author */
60
+ author?: string;
61
+ /** Repository URL */
62
+ repository?: string;
63
+ /** Keywords */
64
+ keywords?: string[];
65
+ /** Map of action names to action classes */
66
+ actions?: Record<string, new () => Action>;
67
+ /** Register actions method */
68
+ registerActions?: () => Record<string, new () => Action>;
69
+ }
70
+
2
71
  /**
3
72
  * Single output configuration for multi-output mode.
4
73
  */
5
- export interface StyleOutputConfig {
74
+ interface StyleOutputConfig {
6
75
  /** Output file path */
7
76
  file: string;
8
77
  /** CSS style: expanded or compressed */
@@ -10,7 +79,7 @@ export interface StyleOutputConfig {
10
79
  /** Enable sourcemap for this output (default: false) */
11
80
  sourceMap?: boolean;
12
81
  }
13
- export interface StyleProcessingActionOptions extends ActionOptionsType {
82
+ interface StyleProcessingActionOptions extends ActionOptionsType {
14
83
  /** Input SCSS/CSS file path */
15
84
  inputFile: string;
16
85
  /** Single output file path (mutually exclusive with outputs) */
@@ -42,7 +111,7 @@ export interface StyleProcessingActionOptions extends ActionOptionsType {
42
111
  * including compiling SCSS and applying PostCSS transformations. It supports
43
112
  * expanded and compressed output styles based on the provided configuration.
44
113
  */
45
- export declare class StyleProcessingAction extends Action {
114
+ declare class StyleProcessingAction extends Action {
46
115
  /**
47
116
  * Executes the style processing action.
48
117
  * @param options - The options specific to style processing, including
@@ -79,4 +148,7 @@ export declare class StyleProcessingAction extends Action {
79
148
  */
80
149
  describe(): string;
81
150
  }
82
- //# sourceMappingURL=StyleProcessingAction.d.ts.map
151
+
152
+ declare const plugin: ActionPlugin;
153
+
154
+ export { Action, type ActionOptionsType, type ActionPlugin, StyleProcessingAction, type StyleProcessingActionOptions, plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,154 @@
1
- export { StyleProcessingAction } from "./actions/StyleProcessingAction/index.js";
2
- export type { StyleProcessingActionOptions } from "./actions/StyleProcessingAction/index.js";
3
- export { Action, ActionPlugin } from "./types/Action.js";
4
- export type { ActionOptionsType } from "./types/Action.js";
5
- import { ActionPlugin } from "./types/Action.js";
1
+ /**
2
+ * Base Action types for kist action plugins
3
+ * These types match the kist Action interface for compatibility
4
+ */
5
+ /**
6
+ * Action options type - a generic record of key-value pairs
7
+ */
8
+ type ActionOptionsType = Record<string, unknown>;
9
+ /**
10
+ * Abstract base class for all kist actions
11
+ * Provides logging and execution interface
12
+ */
13
+ declare abstract class Action<T extends ActionOptionsType = ActionOptionsType> {
14
+ /**
15
+ * Gets the unique name of the action.
16
+ */
17
+ get name(): string;
18
+ /**
19
+ * Validates options before execution
20
+ * Override in subclasses for specific validation
21
+ */
22
+ validateOptions(_options: T): boolean;
23
+ /**
24
+ * Execute the action with given options
25
+ * Must be implemented by subclasses
26
+ */
27
+ abstract execute(options: T): Promise<void>;
28
+ /**
29
+ * Provides a description of the action
30
+ */
31
+ describe(): string;
32
+ /**
33
+ * Log an info message
34
+ */
35
+ protected logInfo(message: string): void;
36
+ /**
37
+ * Log an error message
38
+ */
39
+ protected logError(message: string, error?: unknown): void;
40
+ /**
41
+ * Log a debug message
42
+ */
43
+ protected logDebug(message: string): void;
44
+ /**
45
+ * Log a warning message
46
+ */
47
+ protected logWarning(message: string): void;
48
+ }
49
+ /**
50
+ * Plugin interface for kist action packages
51
+ */
52
+ interface ActionPlugin {
53
+ /** Plugin name */
54
+ name?: string;
55
+ /** Plugin version */
56
+ version: string;
57
+ /** Plugin description */
58
+ description?: string;
59
+ /** Plugin author */
60
+ author?: string;
61
+ /** Repository URL */
62
+ repository?: string;
63
+ /** Keywords */
64
+ keywords?: string[];
65
+ /** Map of action names to action classes */
66
+ actions?: Record<string, new () => Action>;
67
+ /** Register actions method */
68
+ registerActions?: () => Record<string, new () => Action>;
69
+ }
70
+
71
+ /**
72
+ * Single output configuration for multi-output mode.
73
+ */
74
+ interface StyleOutputConfig {
75
+ /** Output file path */
76
+ file: string;
77
+ /** CSS style: expanded or compressed */
78
+ style: "expanded" | "compressed";
79
+ /** Enable sourcemap for this output (default: false) */
80
+ sourceMap?: boolean;
81
+ }
82
+ interface StyleProcessingActionOptions extends ActionOptionsType {
83
+ /** Input SCSS/CSS file path */
84
+ inputFile: string;
85
+ /** Single output file path (mutually exclusive with outputs) */
86
+ outputFile?: string;
87
+ /** Single output style option (mutually exclusive with outputs) */
88
+ styleOption?: "expanded" | "compressed";
89
+ /**
90
+ * Multiple outputs from single input (mutually exclusive with outputFile/styleOption).
91
+ * Allows generating both expanded and compressed CSS from one source.
92
+ *
93
+ * @example
94
+ * ```yaml
95
+ * outputs:
96
+ * - file: "./dist/css/app.css"
97
+ * style: expanded
98
+ * sourceMap: true
99
+ * - file: "./dist/css/app.min.css"
100
+ * style: compressed
101
+ * ```
102
+ */
103
+ outputs?: StyleOutputConfig[];
104
+ /** Enable sourcemap generation for single output mode (default: false) */
105
+ sourceMap?: boolean;
106
+ /** Include original source content in sourcemap (default: true when sourceMap enabled) */
107
+ sourceMapIncludeSources?: boolean;
108
+ }
109
+ /**
110
+ * StyleProcessingAction is a step action responsible for processing styles,
111
+ * including compiling SCSS and applying PostCSS transformations. It supports
112
+ * expanded and compressed output styles based on the provided configuration.
113
+ */
114
+ declare class StyleProcessingAction extends Action {
115
+ /**
116
+ * Executes the style processing action.
117
+ * @param options - The options specific to style processing, including
118
+ * input/output file paths and style format.
119
+ * @returns A Promise that resolves when the styles are processed
120
+ * successfully, or rejects with an error if the action fails.
121
+ */
122
+ execute(options: StyleProcessingActionOptions): Promise<void>;
123
+ /**
124
+ * Executes multi-output mode: compiles SCSS for each unique style,
125
+ * then generates all specified output files.
126
+ */
127
+ private executeMultiOutput;
128
+ /**
129
+ * Executes single-output mode (legacy behavior).
130
+ */
131
+ private executeSingleOutput;
132
+ /**
133
+ * Processes the given CSS with PostCSS based on the provided style option.
134
+ * @param css - The CSS string to process.
135
+ * @param styleOption - The style option, either "expanded" or "compressed".
136
+ * @param sourceMapOptions - Optional sourcemap configuration.
137
+ * @returns Object containing processed CSS string and optional sourcemap.
138
+ */
139
+ private processPostCSS;
140
+ /**
141
+ * Ensures that the given directory exists, creating it if it does not.
142
+ * @param dirPath - The path of the directory to check and create.
143
+ */
144
+ private ensureDirectoryExists;
145
+ /**
146
+ * Provides a description of the action.
147
+ * @returns A string description of the action.
148
+ */
149
+ describe(): string;
150
+ }
151
+
6
152
  declare const plugin: ActionPlugin;
7
- export default plugin;
8
- //# sourceMappingURL=index.d.ts.map
153
+
154
+ export { Action, type ActionOptionsType, type ActionPlugin, StyleProcessingAction, type StyleProcessingActionOptions, plugin as default };