@getkist/action-postcss 1.0.5 → 1.0.7

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.
package/dist/index.cjs ADDED
@@ -0,0 +1,192 @@
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 autoprefixer = require('autoprefixer');
9
+ var cssnano = require('cssnano');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var path__default = /*#__PURE__*/_interopDefault(path);
14
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
15
+ var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
16
+ var cssnano__default = /*#__PURE__*/_interopDefault(cssnano);
17
+
18
+ // src/actions/PostCssAction/PostCssAction.ts
19
+
20
+ // src/types/Action.ts
21
+ var Action = class {
22
+ /**
23
+ * Gets the unique name of the action.
24
+ */
25
+ get name() {
26
+ return this.constructor.name;
27
+ }
28
+ /**
29
+ * Validates options before execution
30
+ * Override in subclasses for specific validation
31
+ */
32
+ validateOptions(_options) {
33
+ return true;
34
+ }
35
+ /**
36
+ * Provides a description of the action
37
+ */
38
+ describe() {
39
+ return `${this.name} action`;
40
+ }
41
+ /**
42
+ * Log an info message
43
+ */
44
+ logInfo(message) {
45
+ console.log(`[${this.name}] ${message}`);
46
+ }
47
+ /**
48
+ * Log an error message
49
+ */
50
+ logError(message, error) {
51
+ console.error(`[${this.name}] ERROR: ${message}`, error || "");
52
+ }
53
+ /**
54
+ * Log a debug message
55
+ */
56
+ logDebug(message) {
57
+ if (process.env.DEBUG) {
58
+ console.debug(`[${this.name}] DEBUG: ${message}`);
59
+ }
60
+ }
61
+ /**
62
+ * Log a warning message
63
+ */
64
+ logWarning(message) {
65
+ console.warn(`[${this.name}] WARNING: ${message}`);
66
+ }
67
+ };
68
+
69
+ // src/actions/PostCssAction/PostCssAction.ts
70
+ var PostCssAction = class extends Action {
71
+ /**
72
+ * Validates the action options.
73
+ *
74
+ * @param options - The options to validate.
75
+ * @returns True if options are valid.
76
+ */
77
+ validateOptions(options) {
78
+ if (!options.inputPath || typeof options.inputPath !== "string") {
79
+ this.logError("Invalid options: 'inputPath' is required and must be a string.");
80
+ return false;
81
+ }
82
+ if (!options.outputPath || typeof options.outputPath !== "string") {
83
+ this.logError("Invalid options: 'outputPath' is required and must be a string.");
84
+ return false;
85
+ }
86
+ if (options.autoprefixer !== void 0 && typeof options.autoprefixer !== "boolean") {
87
+ this.logError("Invalid options: 'autoprefixer' must be a boolean.");
88
+ return false;
89
+ }
90
+ if (options.minify !== void 0 && typeof options.minify !== "boolean") {
91
+ this.logError("Invalid options: 'minify' must be a boolean.");
92
+ return false;
93
+ }
94
+ if (options.cssnanoPreset !== void 0) {
95
+ const validPresets = ["default", "lite", "advanced"];
96
+ if (!validPresets.includes(options.cssnanoPreset)) {
97
+ this.logError(`Invalid options: 'cssnanoPreset' must be one of: ${validPresets.join(", ")}`);
98
+ return false;
99
+ }
100
+ }
101
+ return true;
102
+ }
103
+ /**
104
+ * Executes the PostCSS processing action.
105
+ *
106
+ * @param options - The options for CSS processing.
107
+ * @returns A Promise that resolves when processing completes.
108
+ * @throws {Error} If processing encounters an error.
109
+ */
110
+ async execute(options) {
111
+ if (!this.validateOptions(options)) {
112
+ throw new Error("Invalid options provided to PostCssAction.");
113
+ }
114
+ const {
115
+ inputPath,
116
+ outputPath,
117
+ autoprefixer: useAutoprefixer = true,
118
+ browsers = ["> 1%", "last 2 versions", "not dead"],
119
+ minify = false,
120
+ cssnanoPreset = "default",
121
+ sourcemap = false,
122
+ inlineSourcemap = false,
123
+ plugins: customPlugins = []
124
+ } = options;
125
+ this.logInfo(`Processing CSS: ${inputPath} \u2192 ${outputPath}`);
126
+ try {
127
+ const resolvedInputPath = path__default.default.resolve(inputPath);
128
+ const resolvedOutputPath = path__default.default.resolve(outputPath);
129
+ const inputCss = await fs.promises.readFile(resolvedInputPath, "utf8");
130
+ const plugins = [];
131
+ if (useAutoprefixer) {
132
+ plugins.push(autoprefixer__default.default({ overrideBrowserslist: browsers }));
133
+ }
134
+ if (minify) {
135
+ plugins.push(cssnano__default.default({ preset: cssnanoPreset }));
136
+ }
137
+ plugins.push(...customPlugins);
138
+ const result = await postcss__default.default(plugins).process(inputCss, {
139
+ from: resolvedInputPath,
140
+ to: resolvedOutputPath,
141
+ map: sourcemap ? { inline: inlineSourcemap } : false
142
+ });
143
+ const outputDir = path__default.default.dirname(resolvedOutputPath);
144
+ await fs.promises.mkdir(outputDir, { recursive: true });
145
+ await fs.promises.writeFile(resolvedOutputPath, result.css, "utf8");
146
+ if (sourcemap && !inlineSourcemap && result.map) {
147
+ await fs.promises.writeFile(`${resolvedOutputPath}.map`, result.map.toString(), "utf8");
148
+ this.logDebug(`Sourcemap written to ${resolvedOutputPath}.map`);
149
+ }
150
+ for (const warning of result.warnings()) {
151
+ this.logWarning(`${warning.plugin}: ${warning.text}`);
152
+ }
153
+ const features = [];
154
+ if (useAutoprefixer) features.push("autoprefixer");
155
+ if (minify) features.push("minify");
156
+ if (sourcemap) features.push("sourcemap");
157
+ this.logInfo(`CSS processing completed: ${outputPath} (${features.join(", ") || "no transforms"})`);
158
+ } catch (error) {
159
+ this.logError("PostCSS processing failed.", error);
160
+ throw error;
161
+ }
162
+ }
163
+ /**
164
+ * Provides a description of the action.
165
+ *
166
+ * @returns A string description of the action.
167
+ */
168
+ describe() {
169
+ return "Processes CSS files using PostCSS with autoprefixer and cssnano support.";
170
+ }
171
+ };
172
+
173
+ // src/index.ts
174
+ var plugin = {
175
+ version: "1.0.0",
176
+ description: "PostCSS processing for kist",
177
+ author: "kist",
178
+ repository: "https://github.com/getkist/kist-action-postcss",
179
+ keywords: ["kist", "kist-action", "postcss", "css"],
180
+ registerActions() {
181
+ return {
182
+ PostCssAction
183
+ };
184
+ }
185
+ };
186
+ var src_default = plugin;
187
+
188
+ exports.Action = Action;
189
+ exports.PostCssAction = PostCssAction;
190
+ exports.default = src_default;
191
+ //# sourceMappingURL=index.cjs.map
192
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/Action.ts","../src/actions/PostCssAction/PostCssAction.ts","../src/index.ts"],"names":["path","fs","autoprefixer","cssnano","postcss"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcO,IAAe,SAAf,MAAuE;AAAA;AAAA;AAAA;AAAA,EAI1E,IAAI,IAAA,GAAe;AACf,IAAA,OAAO,KAAK,WAAA,CAAY,IAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,QAAA,EAAsB;AAClC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAWA,QAAA,GAAmB;AACf,IAAA,OAAO,CAAA,EAAG,KAAK,IAAI,CAAA,OAAA,CAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKU,QAAQ,OAAA,EAAuB;AACrC,IAAA,OAAA,CAAQ,IAAI,CAAA,CAAA,EAAI,IAAA,CAAK,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKU,QAAA,CAAS,SAAiB,KAAA,EAAuB;AACvD,IAAA,OAAA,CAAQ,KAAA,CAAM,IAAI,IAAA,CAAK,IAAI,YAAY,OAAO,CAAA,CAAA,EAAI,SAAS,EAAE,CAAA;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKU,SAAS,OAAA,EAAuB;AACtC,IAAA,IAAI,OAAA,CAAQ,IAAI,KAAA,EAAO;AACnB,MAAA,OAAA,CAAQ,MAAM,CAAA,CAAA,EAAI,IAAA,CAAK,IAAI,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAA;AAAA,IACpD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAKU,WAAW,OAAA,EAAuB;A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AA,IAAI,SAAA,EAAW,QAAA,CAAS,IAAA,CAAK,WAAW,CAAA;AAExC,MAAA,IAAA,CAAK,OAAA,CAAQ,6BAA6B,UAAU,CAAA,EAAA,EAAK,SAAS,IAAA,CAAK,IAAI,CAAA,IAAK,eAAe,CAAA,CAAA,CAAG,CAAA;AAAA,IACtG,SAAS,KAAA,EAAO;AACZ,MAAA,IAAA,CAAK,QAAA,CAAS,8BAA8B,KAAK,CAAA;AACjD,MAAA,MAAM,KAAA;AAAA,IACV;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,QAAA,GAAmB;AACf,IAAA,OAAO,0EAAA;AAAA,EACX;AACJ;;;AC7JA,IAAM,MAAA,GAAuB;AAAA,EACzB,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,6BAAA;AAAA,EACb,MAAA,EAAQ,MAAA;AAAA,EACR,UAAA,EAAY,gDAAA;AAAA,EACZ,QAAA,EAAU,CAAC,MAAA,EAAQ,aAAA,EAAe,WAAW,KAAK,CAAA;AAAA,EAClD,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 { promises as fs } from \"fs\";\nimport path from \"path\";\nimport postcss, { AcceptedPlugin } from \"postcss\";\nimport autoprefixer from \"autoprefixer\";\nimport cssnano from \"cssnano\";\nimport { Action, ActionOptionsType } from \"../../types/Action.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Options for the PostCssAction\n */\nexport interface PostCssActionOptions extends ActionOptionsType {\n /** Path to the input CSS file */\n inputPath: string;\n /** Path where the processed CSS will be saved */\n outputPath: string;\n /** Enable autoprefixer (default: true) */\n autoprefixer?: boolean;\n /** Autoprefixer browser targets */\n browsers?: string[];\n /** Enable minification with cssnano (default: false) */\n minify?: boolean;\n /** cssnano preset (default: default) */\n cssnanoPreset?: \"default\" | \"lite\" | \"advanced\";\n /** Generate sourcemap (default: false) */\n sourcemap?: boolean;\n /** Inline sourcemap instead of external file (default: false) */\n inlineSourcemap?: boolean;\n /** Additional PostCSS plugins */\n plugins?: AcceptedPlugin[];\n}\n\n// ============================================================================\n// Classes\n// ============================================================================\n\n/**\n * PostCssAction handles CSS processing using PostCSS.\n * Supports autoprefixer, cssnano minification, and custom plugins.\n */\nexport class PostCssAction extends Action<PostCssActionOptions> {\n /**\n * Validates the action options.\n *\n * @param options - The options to validate.\n * @returns True if options are valid.\n */\n validateOptions(options: PostCssActionOptions): boolean {\n if (!options.inputPath || typeof options.inputPath !== \"string\") {\n this.logError(\"Invalid options: 'inputPath' is required and must be a string.\");\n return false;\n }\n if (!options.outputPath || typeof options.outputPath !== \"string\") {\n this.logError(\"Invalid options: 'outputPath' is required and must be a string.\");\n return false;\n }\n if (options.autoprefixer !== undefined && typeof options.autoprefixer !== \"boolean\") {\n this.logError(\"Invalid options: 'autoprefixer' must be a boolean.\");\n return false;\n }\n if (options.minify !== undefined && typeof options.minify !== \"boolean\") {\n this.logError(\"Invalid options: 'minify' must be a boolean.\");\n return false;\n }\n if (options.cssnanoPreset !== undefined) {\n const validPresets = [\"default\", \"lite\", \"advanced\"];\n if (!validPresets.includes(options.cssnanoPreset)) {\n this.logError(`Invalid options: 'cssnanoPreset' must be one of: ${validPresets.join(\", \")}`);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Executes the PostCSS processing action.\n *\n * @param options - The options for CSS processing.\n * @returns A Promise that resolves when processing completes.\n * @throws {Error} If processing encounters an error.\n */\n async execute(options: PostCssActionOptions): Promise<void> {\n if (!this.validateOptions(options)) {\n throw new Error(\"Invalid options provided to PostCssAction.\");\n }\n\n const {\n inputPath,\n outputPath,\n autoprefixer: useAutoprefixer = true,\n browsers = [\"> 1%\", \"last 2 versions\", \"not dead\"],\n minify = false,\n cssnanoPreset = \"default\",\n sourcemap = false,\n inlineSourcemap = false,\n plugins: customPlugins = [],\n } = options;\n\n this.logInfo(`Processing CSS: ${inputPath} → ${outputPath}`);\n\n try {\n const resolvedInputPath = path.resolve(inputPath);\n const resolvedOutputPath = path.resolve(outputPath);\n\n // Read input CSS\n const inputCss = await fs.readFile(resolvedInputPath, \"utf8\");\n\n // Build plugin list\n const plugins: AcceptedPlugin[] = [];\n\n if (useAutoprefixer) {\n plugins.push(autoprefixer({ overrideBrowserslist: browsers }));\n }\n\n if (minify) {\n plugins.push(cssnano({ preset: cssnanoPreset }));\n }\n\n // Add custom plugins\n plugins.push(...customPlugins);\n\n // Process with PostCSS\n const result = await postcss(plugins).process(inputCss, {\n from: resolvedInputPath,\n to: resolvedOutputPath,\n map: sourcemap ? { inline: inlineSourcemap } : false,\n });\n\n // Ensure output directory exists\n const outputDir = path.dirname(resolvedOutputPath);\n await fs.mkdir(outputDir, { recursive: true });\n\n // Write output CSS\n await fs.writeFile(resolvedOutputPath, result.css, \"utf8\");\n\n // Write sourcemap if external\n if (sourcemap && !inlineSourcemap && result.map) {\n await fs.writeFile(`${resolvedOutputPath}.map`, result.map.toString(), \"utf8\");\n this.logDebug(`Sourcemap written to ${resolvedOutputPath}.map`);\n }\n\n // Log warnings\n for (const warning of result.warnings()) {\n this.logWarning(`${warning.plugin}: ${warning.text}`);\n }\n\n const features = [];\n if (useAutoprefixer) features.push(\"autoprefixer\");\n if (minify) features.push(\"minify\");\n if (sourcemap) features.push(\"sourcemap\");\n\n this.logInfo(`CSS processing completed: ${outputPath} (${features.join(\", \") || \"no transforms\"})`);\n } catch (error) {\n this.logError(\"PostCSS processing failed.\", error);\n throw error;\n }\n }\n\n /**\n * Provides a description of the action.\n *\n * @returns A string description of the action.\n */\n describe(): string {\n return \"Processes CSS files using PostCSS with autoprefixer and cssnano support.\";\n }\n}\n","// ============================================================================\n// Export\n// ============================================================================\n\nexport { PostCssAction } from \"./actions/PostCssAction/index.js\";\nexport type { PostCssActionOptions } from \"./actions/PostCssAction/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 { PostCssAction } from \"./actions/PostCssAction/index.js\";\n\nconst plugin: ActionPlugin = {\n version: \"1.0.0\",\n description: \"PostCSS processing for kist\",\n author: \"kist\",\n repository: \"https://github.com/getkist/kist-action-postcss\",\n keywords: [\"kist\", \"kist-action\", \"postcss\", \"css\"],\n registerActions() {\n return {\n PostCssAction,\n };\n },\n};\n\nexport default plugin;\n"]}
@@ -0,0 +1,126 @@
1
+ import { AcceptedPlugin } from 'postcss';
2
+
3
+ /**
4
+ * Base Action types for kist action plugins
5
+ * These types match the kist Action interface for compatibility
6
+ */
7
+ /**
8
+ * Action options type - a generic record of key-value pairs
9
+ */
10
+ type ActionOptionsType = Record<string, unknown>;
11
+ /**
12
+ * Abstract base class for all kist actions
13
+ * Provides logging and execution interface
14
+ */
15
+ declare abstract class Action<T extends ActionOptionsType = ActionOptionsType> {
16
+ /**
17
+ * Gets the unique name of the action.
18
+ */
19
+ get name(): string;
20
+ /**
21
+ * Validates options before execution
22
+ * Override in subclasses for specific validation
23
+ */
24
+ validateOptions(_options: T): boolean;
25
+ /**
26
+ * Execute the action with given options
27
+ * Must be implemented by subclasses
28
+ */
29
+ abstract execute(options: T): Promise<void>;
30
+ /**
31
+ * Provides a description of the action
32
+ */
33
+ describe(): string;
34
+ /**
35
+ * Log an info message
36
+ */
37
+ protected logInfo(message: string): void;
38
+ /**
39
+ * Log an error message
40
+ */
41
+ protected logError(message: string, error?: unknown): void;
42
+ /**
43
+ * Log a debug message
44
+ */
45
+ protected logDebug(message: string): void;
46
+ /**
47
+ * Log a warning message
48
+ */
49
+ protected logWarning(message: string): void;
50
+ }
51
+ /**
52
+ * Plugin interface for kist action packages
53
+ */
54
+ interface ActionPlugin {
55
+ /** Plugin name */
56
+ name?: string;
57
+ /** Plugin version */
58
+ version: string;
59
+ /** Plugin description */
60
+ description?: string;
61
+ /** Plugin author */
62
+ author?: string;
63
+ /** Repository URL */
64
+ repository?: string;
65
+ /** Keywords */
66
+ keywords?: string[];
67
+ /** Map of action names to action classes */
68
+ actions?: Record<string, new () => Action>;
69
+ /** Register actions method */
70
+ registerActions?: () => Record<string, new () => Action>;
71
+ }
72
+
73
+ /**
74
+ * Options for the PostCssAction
75
+ */
76
+ interface PostCssActionOptions extends ActionOptionsType {
77
+ /** Path to the input CSS file */
78
+ inputPath: string;
79
+ /** Path where the processed CSS will be saved */
80
+ outputPath: string;
81
+ /** Enable autoprefixer (default: true) */
82
+ autoprefixer?: boolean;
83
+ /** Autoprefixer browser targets */
84
+ browsers?: string[];
85
+ /** Enable minification with cssnano (default: false) */
86
+ minify?: boolean;
87
+ /** cssnano preset (default: default) */
88
+ cssnanoPreset?: "default" | "lite" | "advanced";
89
+ /** Generate sourcemap (default: false) */
90
+ sourcemap?: boolean;
91
+ /** Inline sourcemap instead of external file (default: false) */
92
+ inlineSourcemap?: boolean;
93
+ /** Additional PostCSS plugins */
94
+ plugins?: AcceptedPlugin[];
95
+ }
96
+ /**
97
+ * PostCssAction handles CSS processing using PostCSS.
98
+ * Supports autoprefixer, cssnano minification, and custom plugins.
99
+ */
100
+ declare class PostCssAction extends Action<PostCssActionOptions> {
101
+ /**
102
+ * Validates the action options.
103
+ *
104
+ * @param options - The options to validate.
105
+ * @returns True if options are valid.
106
+ */
107
+ validateOptions(options: PostCssActionOptions): boolean;
108
+ /**
109
+ * Executes the PostCSS processing action.
110
+ *
111
+ * @param options - The options for CSS processing.
112
+ * @returns A Promise that resolves when processing completes.
113
+ * @throws {Error} If processing encounters an error.
114
+ */
115
+ execute(options: PostCssActionOptions): Promise<void>;
116
+ /**
117
+ * Provides a description of the action.
118
+ *
119
+ * @returns A string description of the action.
120
+ */
121
+ describe(): string;
122
+ }
123
+
124
+ declare const plugin: ActionPlugin;
125
+
126
+ export { Action, type ActionOptionsType, type ActionPlugin, PostCssAction, type PostCssActionOptions, plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,126 @@
1
- export { PostCssAction } from "./actions/PostCssAction/index.js";
2
- export type { PostCssActionOptions } from "./actions/PostCssAction/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
+ import { AcceptedPlugin } from 'postcss';
2
+
3
+ /**
4
+ * Base Action types for kist action plugins
5
+ * These types match the kist Action interface for compatibility
6
+ */
7
+ /**
8
+ * Action options type - a generic record of key-value pairs
9
+ */
10
+ type ActionOptionsType = Record<string, unknown>;
11
+ /**
12
+ * Abstract base class for all kist actions
13
+ * Provides logging and execution interface
14
+ */
15
+ declare abstract class Action<T extends ActionOptionsType = ActionOptionsType> {
16
+ /**
17
+ * Gets the unique name of the action.
18
+ */
19
+ get name(): string;
20
+ /**
21
+ * Validates options before execution
22
+ * Override in subclasses for specific validation
23
+ */
24
+ validateOptions(_options: T): boolean;
25
+ /**
26
+ * Execute the action with given options
27
+ * Must be implemented by subclasses
28
+ */
29
+ abstract execute(options: T): Promise<void>;
30
+ /**
31
+ * Provides a description of the action
32
+ */
33
+ describe(): string;
34
+ /**
35
+ * Log an info message
36
+ */
37
+ protected logInfo(message: string): void;
38
+ /**
39
+ * Log an error message
40
+ */
41
+ protected logError(message: string, error?: unknown): void;
42
+ /**
43
+ * Log a debug message
44
+ */
45
+ protected logDebug(message: string): void;
46
+ /**
47
+ * Log a warning message
48
+ */
49
+ protected logWarning(message: string): void;
50
+ }
51
+ /**
52
+ * Plugin interface for kist action packages
53
+ */
54
+ interface ActionPlugin {
55
+ /** Plugin name */
56
+ name?: string;
57
+ /** Plugin version */
58
+ version: string;
59
+ /** Plugin description */
60
+ description?: string;
61
+ /** Plugin author */
62
+ author?: string;
63
+ /** Repository URL */
64
+ repository?: string;
65
+ /** Keywords */
66
+ keywords?: string[];
67
+ /** Map of action names to action classes */
68
+ actions?: Record<string, new () => Action>;
69
+ /** Register actions method */
70
+ registerActions?: () => Record<string, new () => Action>;
71
+ }
72
+
73
+ /**
74
+ * Options for the PostCssAction
75
+ */
76
+ interface PostCssActionOptions extends ActionOptionsType {
77
+ /** Path to the input CSS file */
78
+ inputPath: string;
79
+ /** Path where the processed CSS will be saved */
80
+ outputPath: string;
81
+ /** Enable autoprefixer (default: true) */
82
+ autoprefixer?: boolean;
83
+ /** Autoprefixer browser targets */
84
+ browsers?: string[];
85
+ /** Enable minification with cssnano (default: false) */
86
+ minify?: boolean;
87
+ /** cssnano preset (default: default) */
88
+ cssnanoPreset?: "default" | "lite" | "advanced";
89
+ /** Generate sourcemap (default: false) */
90
+ sourcemap?: boolean;
91
+ /** Inline sourcemap instead of external file (default: false) */
92
+ inlineSourcemap?: boolean;
93
+ /** Additional PostCSS plugins */
94
+ plugins?: AcceptedPlugin[];
95
+ }
96
+ /**
97
+ * PostCssAction handles CSS processing using PostCSS.
98
+ * Supports autoprefixer, cssnano minification, and custom plugins.
99
+ */
100
+ declare class PostCssAction extends Action<PostCssActionOptions> {
101
+ /**
102
+ * Validates the action options.
103
+ *
104
+ * @param options - The options to validate.
105
+ * @returns True if options are valid.
106
+ */
107
+ validateOptions(options: PostCssActionOptions): boolean;
108
+ /**
109
+ * Executes the PostCSS processing action.
110
+ *
111
+ * @param options - The options for CSS processing.
112
+ * @returns A Promise that resolves when processing completes.
113
+ * @throws {Error} If processing encounters an error.
114
+ */
115
+ execute(options: PostCssActionOptions): Promise<void>;
116
+ /**
117
+ * Provides a description of the action.
118
+ *
119
+ * @returns A string description of the action.
120
+ */
121
+ describe(): string;
122
+ }
123
+
6
124
  declare const plugin: ActionPlugin;
7
- export default plugin;
8
- //# sourceMappingURL=index.d.ts.map
125
+
126
+ export { Action, type ActionOptionsType, type ActionPlugin, PostCssAction, type PostCssActionOptions, plugin as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,179 @@
1
+ import { promises } from 'fs';
2
+ import path from 'path';
3
+ import postcss from 'postcss';
4
+ import autoprefixer from 'autoprefixer';
5
+ import cssnano from 'cssnano';
6
+
7
+ // src/actions/PostCssAction/PostCssAction.ts
8
+
9
+ // src/types/Action.ts
10
+ var Action = class {
11
+ /**
12
+ * Gets the unique name of the action.
13
+ */
14
+ get name() {
15
+ return this.constructor.name;
16
+ }
17
+ /**
18
+ * Validates options before execution
19
+ * Override in subclasses for specific validation
20
+ */
21
+ validateOptions(_options) {
22
+ return true;
23
+ }
24
+ /**
25
+ * Provides a description of the action
26
+ */
27
+ describe() {
28
+ return `${this.name} action`;
29
+ }
30
+ /**
31
+ * Log an info message
32
+ */
33
+ logInfo(message) {
34
+ console.log(`[${this.name}] ${message}`);
35
+ }
36
+ /**
37
+ * Log an error message
38
+ */
39
+ logError(message, error) {
40
+ console.error(`[${this.name}] ERROR: ${message}`, error || "");
41
+ }
42
+ /**
43
+ * Log a debug message
44
+ */
45
+ logDebug(message) {
46
+ if (process.env.DEBUG) {
47
+ console.debug(`[${this.name}] DEBUG: ${message}`);
48
+ }
49
+ }
50
+ /**
51
+ * Log a warning message
52
+ */
53
+ logWarning(message) {
54
+ console.warn(`[${this.name}] WARNING: ${message}`);
55
+ }
56
+ };
57
+
58
+ // src/actions/PostCssAction/PostCssAction.ts
59
+ var PostCssAction = class extends Action {
60
+ /**
61
+ * Validates the action options.
62
+ *
63
+ * @param options - The options to validate.
64
+ * @returns True if options are valid.
65
+ */
66
+ validateOptions(options) {
67
+ if (!options.inputPath || typeof options.inputPath !== "string") {
68
+ this.logError("Invalid options: 'inputPath' is required and must be a string.");
69
+ return false;
70
+ }
71
+ if (!options.outputPath || typeof options.outputPath !== "string") {
72
+ this.logError("Invalid options: 'outputPath' is required and must be a string.");
73
+ return false;
74
+ }
75
+ if (options.autoprefixer !== void 0 && typeof options.autoprefixer !== "boolean") {
76
+ this.logError("Invalid options: 'autoprefixer' must be a boolean.");
77
+ return false;
78
+ }
79
+ if (options.minify !== void 0 && typeof options.minify !== "boolean") {
80
+ this.logError("Invalid options: 'minify' must be a boolean.");
81
+ return false;
82
+ }
83
+ if (options.cssnanoPreset !== void 0) {
84
+ const validPresets = ["default", "lite", "advanced"];
85
+ if (!validPresets.includes(options.cssnanoPreset)) {
86
+ this.logError(`Invalid options: 'cssnanoPreset' must be one of: ${validPresets.join(", ")}`);
87
+ return false;
88
+ }
89
+ }
90
+ return true;
91
+ }
92
+ /**
93
+ * Executes the PostCSS processing action.
94
+ *
95
+ * @param options - The options for CSS processing.
96
+ * @returns A Promise that resolves when processing completes.
97
+ * @throws {Error} If processing encounters an error.
98
+ */
99
+ async execute(options) {
100
+ if (!this.validateOptions(options)) {
101
+ throw new Error("Invalid options provided to PostCssAction.");
102
+ }
103
+ const {
104
+ inputPath,
105
+ outputPath,
106
+ autoprefixer: useAutoprefixer = true,
107
+ browsers = ["> 1%", "last 2 versions", "not dead"],
108
+ minify = false,
109
+ cssnanoPreset = "default",
110
+ sourcemap = false,
111
+ inlineSourcemap = false,
112
+ plugins: customPlugins = []
113
+ } = options;
114
+ this.logInfo(`Processing CSS: ${inputPath} \u2192 ${outputPath}`);
115
+ try {
116
+ const resolvedInputPath = path.resolve(inputPath);
117
+ const resolvedOutputPath = path.resolve(outputPath);
118
+ const inputCss = await promises.readFile(resolvedInputPath, "utf8");
119
+ const plugins = [];
120
+ if (useAutoprefixer) {
121
+ plugins.push(autoprefixer({ overrideBrowserslist: browsers }));
122
+ }
123
+ if (minify) {
124
+ plugins.push(cssnano({ preset: cssnanoPreset }));
125
+ }
126
+ plugins.push(...customPlugins);
127
+ const result = await postcss(plugins).process(inputCss, {
128
+ from: resolvedInputPath,
129
+ to: resolvedOutputPath,
130
+ map: sourcemap ? { inline: inlineSourcemap } : false
131
+ });
132
+ const outputDir = path.dirname(resolvedOutputPath);
133
+ await promises.mkdir(outputDir, { recursive: true });
134
+ await promises.writeFile(resolvedOutputPath, result.css, "utf8");
135
+ if (sourcemap && !inlineSourcemap && result.map) {
136
+ await promises.writeFile(`${resolvedOutputPath}.map`, result.map.toString(), "utf8");
137
+ this.logDebug(`Sourcemap written to ${resolvedOutputPath}.map`);
138
+ }
139
+ for (const warning of result.warnings()) {
140
+ this.logWarning(`${warning.plugin}: ${warning.text}`);
141
+ }
142
+ const features = [];
143
+ if (useAutoprefixer) features.push("autoprefixer");
144
+ if (minify) features.push("minify");
145
+ if (sourcemap) features.push("sourcemap");
146
+ this.logInfo(`CSS processing completed: ${outputPath} (${features.join(", ") || "no transforms"})`);
147
+ } catch (error) {
148
+ this.logError("PostCSS processing failed.", error);
149
+ throw error;
150
+ }
151
+ }
152
+ /**
153
+ * Provides a description of the action.
154
+ *
155
+ * @returns A string description of the action.
156
+ */
157
+ describe() {
158
+ return "Processes CSS files using PostCSS with autoprefixer and cssnano support.";
159
+ }
160
+ };
161
+
162
+ // src/index.ts
163
+ var plugin = {
164
+ version: "1.0.0",
165
+ description: "PostCSS processing for kist",
166
+ author: "kist",
167
+ repository: "https://github.com/getkist/kist-action-postcss",
168
+ keywords: ["kist", "kist-action", "postcss", "css"],
169
+ registerActions() {
170
+ return {
171
+ PostCssAction
172
+ };
173
+ }
174
+ };
175
+ var src_default = plugin;
176
+
177
+ export { Action, PostCssAction, src_default as default };
178
+ //# sourceMappingURL=index.mjs.map
179
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/Action.ts","../src/actions/PostCssAction/PostCssAction.ts","../src/index.ts"],"names":["fs"],"mappings":";;;;;;;;;AAcO,IAAe,SAAf,MAAuE;AAAA;AAAA;AAAA;AAAA,EAI1E,IAAI,IAAA,GAAe;AACf,IAAA,OAAO,KAAK,WAAA,CAAY,IAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,QAAA,EAAsB;AAClC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAWA,QAAA,GAAmB;AACf,IAAA,OAAO,CAAA,EAAG,KAAK,IAAI,CAAA,OAAA,CAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKU,QAAQ,OAAA,EAAuB;AACrC,IAAA,OAAA,CAAQ,IAAI,CAAA,CAAA,EAAI,IAAA,CAAK,IAAI,CAAA,EAAA,EAAK,OAAO,CAAA,CAAE,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,E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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 { promises as fs } from \"fs\";\nimport path from \"path\";\nimport postcss, { AcceptedPlugin } from \"postcss\";\nimport autoprefixer from \"autoprefixer\";\nimport cssnano from \"cssnano\";\nimport { Action, ActionOptionsType } from \"../../types/Action.js\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Options for the PostCssAction\n */\nexport interface PostCssActionOptions extends ActionOptionsType {\n /** Path to the input CSS file */\n inputPath: string;\n /** Path where the processed CSS will be saved */\n outputPath: string;\n /** Enable autoprefixer (default: true) */\n autoprefixer?: boolean;\n /** Autoprefixer browser targets */\n browsers?: string[];\n /** Enable minification with cssnano (default: false) */\n minify?: boolean;\n /** cssnano preset (default: default) */\n cssnanoPreset?: \"default\" | \"lite\" | \"advanced\";\n /** Generate sourcemap (default: false) */\n sourcemap?: boolean;\n /** Inline sourcemap instead of external file (default: false) */\n inlineSourcemap?: boolean;\n /** Additional PostCSS plugins */\n plugins?: AcceptedPlugin[];\n}\n\n// ============================================================================\n// Classes\n// ============================================================================\n\n/**\n * PostCssAction handles CSS processing using PostCSS.\n * Supports autoprefixer, cssnano minification, and custom plugins.\n */\nexport class PostCssAction extends Action<PostCssActionOptions> {\n /**\n * Validates the action options.\n *\n * @param options - The options to validate.\n * @returns True if options are valid.\n */\n validateOptions(options: PostCssActionOptions): boolean {\n if (!options.inputPath || typeof options.inputPath !== \"string\") {\n this.logError(\"Invalid options: 'inputPath' is required and must be a string.\");\n return false;\n }\n if (!options.outputPath || typeof options.outputPath !== \"string\") {\n this.logError(\"Invalid options: 'outputPath' is required and must be a string.\");\n return false;\n }\n if (options.autoprefixer !== undefined && typeof options.autoprefixer !== \"boolean\") {\n this.logError(\"Invalid options: 'autoprefixer' must be a boolean.\");\n return false;\n }\n if (options.minify !== undefined && typeof options.minify !== \"boolean\") {\n this.logError(\"Invalid options: 'minify' must be a boolean.\");\n return false;\n }\n if (options.cssnanoPreset !== undefined) {\n const validPresets = [\"default\", \"lite\", \"advanced\"];\n if (!validPresets.includes(options.cssnanoPreset)) {\n this.logError(`Invalid options: 'cssnanoPreset' must be one of: ${validPresets.join(\", \")}`);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Executes the PostCSS processing action.\n *\n * @param options - The options for CSS processing.\n * @returns A Promise that resolves when processing completes.\n * @throws {Error} If processing encounters an error.\n */\n async execute(options: PostCssActionOptions): Promise<void> {\n if (!this.validateOptions(options)) {\n throw new Error(\"Invalid options provided to PostCssAction.\");\n }\n\n const {\n inputPath,\n outputPath,\n autoprefixer: useAutoprefixer = true,\n browsers = [\"> 1%\", \"last 2 versions\", \"not dead\"],\n minify = false,\n cssnanoPreset = \"default\",\n sourcemap = false,\n inlineSourcemap = false,\n plugins: customPlugins = [],\n } = options;\n\n this.logInfo(`Processing CSS: ${inputPath} → ${outputPath}`);\n\n try {\n const resolvedInputPath = path.resolve(inputPath);\n const resolvedOutputPath = path.resolve(outputPath);\n\n // Read input CSS\n const inputCss = await fs.readFile(resolvedInputPath, \"utf8\");\n\n // Build plugin list\n const plugins: AcceptedPlugin[] = [];\n\n if (useAutoprefixer) {\n plugins.push(autoprefixer({ overrideBrowserslist: browsers }));\n }\n\n if (minify) {\n plugins.push(cssnano({ preset: cssnanoPreset }));\n }\n\n // Add custom plugins\n plugins.push(...customPlugins);\n\n // Process with PostCSS\n const result = await postcss(plugins).process(inputCss, {\n from: resolvedInputPath,\n to: resolvedOutputPath,\n map: sourcemap ? { inline: inlineSourcemap } : false,\n });\n\n // Ensure output directory exists\n const outputDir = path.dirname(resolvedOutputPath);\n await fs.mkdir(outputDir, { recursive: true });\n\n // Write output CSS\n await fs.writeFile(resolvedOutputPath, result.css, \"utf8\");\n\n // Write sourcemap if external\n if (sourcemap && !inlineSourcemap && result.map) {\n await fs.writeFile(`${resolvedOutputPath}.map`, result.map.toString(), \"utf8\");\n this.logDebug(`Sourcemap written to ${resolvedOutputPath}.map`);\n }\n\n // Log warnings\n for (const warning of result.warnings()) {\n this.logWarning(`${warning.plugin}: ${warning.text}`);\n }\n\n const features = [];\n if (useAutoprefixer) features.push(\"autoprefixer\");\n if (minify) features.push(\"minify\");\n if (sourcemap) features.push(\"sourcemap\");\n\n this.logInfo(`CSS processing completed: ${outputPath} (${features.join(\", \") || \"no transforms\"})`);\n } catch (error) {\n this.logError(\"PostCSS processing failed.\", error);\n throw error;\n }\n }\n\n /**\n * Provides a description of the action.\n *\n * @returns A string description of the action.\n */\n describe(): string {\n return \"Processes CSS files using PostCSS with autoprefixer and cssnano support.\";\n }\n}\n","// ============================================================================\n// Export\n// ============================================================================\n\nexport { PostCssAction } from \"./actions/PostCssAction/index.js\";\nexport type { PostCssActionOptions } from \"./actions/PostCssAction/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 { PostCssAction } from \"./actions/PostCssAction/index.js\";\n\nconst plugin: ActionPlugin = {\n version: \"1.0.0\",\n description: \"PostCSS processing for kist\",\n author: \"kist\",\n repository: \"https://github.com/getkist/kist-action-postcss\",\n keywords: [\"kist\", \"kist-action\", \"postcss\", \"css\"],\n registerActions() {\n return {\n PostCssAction,\n };\n },\n};\n\nexport default plugin;\n"]}
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "@getkist/action-postcss",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "PostCSS processing actions for kist",
5
- "main": "dist/index.js",
5
+ "main": "./dist/index.cjs",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.cjs"
17
+ }
12
18
  },
13
19
  "./package.json": "./package.json"
14
20
  },
@@ -36,8 +42,8 @@
36
42
  "npm": ">=10.0.0"
37
43
  },
38
44
  "scripts": {
39
- "build": "tsc",
40
- "build:watch": "tsc --watch",
45
+ "build": "tsup",
46
+ "build:watch": "tsup --watch",
41
47
  "test": "NODE_OPTIONS='--experimental-vm-modules' jest",
42
48
  "test:watch": "NODE_OPTIONS='--experimental-vm-modules' jest --watch",
43
49
  "test:coverage": "NODE_OPTIONS='--experimental-vm-modules' jest --coverage",
@@ -69,12 +75,14 @@
69
75
  "ts-jest": "^29.4.6",
70
76
  "typedoc": "^0.28.0",
71
77
  "typedoc-plugin-markdown": "^4.10.0",
72
- "typescript": "^5.9.3"
78
+ "typescript": "^5.9.3",
79
+ "tsup": "^8.5.1"
73
80
  },
74
81
  "files": [
75
82
  "dist",
76
83
  "README.md",
77
84
  "LICENSE"
78
85
  ],
79
- "sideEffects": false
86
+ "sideEffects": false,
87
+ "module": "./dist/index.mjs"
80
88
  }
@@ -1,53 +0,0 @@
1
- import { AcceptedPlugin } from "postcss";
2
- import { Action, ActionOptionsType } from "../../types/Action.js";
3
- /**
4
- * Options for the PostCssAction
5
- */
6
- export interface PostCssActionOptions extends ActionOptionsType {
7
- /** Path to the input CSS file */
8
- inputPath: string;
9
- /** Path where the processed CSS will be saved */
10
- outputPath: string;
11
- /** Enable autoprefixer (default: true) */
12
- autoprefixer?: boolean;
13
- /** Autoprefixer browser targets */
14
- browsers?: string[];
15
- /** Enable minification with cssnano (default: false) */
16
- minify?: boolean;
17
- /** cssnano preset (default: default) */
18
- cssnanoPreset?: "default" | "lite" | "advanced";
19
- /** Generate sourcemap (default: false) */
20
- sourcemap?: boolean;
21
- /** Inline sourcemap instead of external file (default: false) */
22
- inlineSourcemap?: boolean;
23
- /** Additional PostCSS plugins */
24
- plugins?: AcceptedPlugin[];
25
- }
26
- /**
27
- * PostCssAction handles CSS processing using PostCSS.
28
- * Supports autoprefixer, cssnano minification, and custom plugins.
29
- */
30
- export declare class PostCssAction extends Action<PostCssActionOptions> {
31
- /**
32
- * Validates the action options.
33
- *
34
- * @param options - The options to validate.
35
- * @returns True if options are valid.
36
- */
37
- validateOptions(options: PostCssActionOptions): boolean;
38
- /**
39
- * Executes the PostCSS processing action.
40
- *
41
- * @param options - The options for CSS processing.
42
- * @returns A Promise that resolves when processing completes.
43
- * @throws {Error} If processing encounters an error.
44
- */
45
- execute(options: PostCssActionOptions): Promise<void>;
46
- /**
47
- * Provides a description of the action.
48
- *
49
- * @returns A string description of the action.
50
- */
51
- describe(): string;
52
- }
53
- //# sourceMappingURL=PostCssAction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostCssAction.d.ts","sourceRoot":"","sources":["../../../src/actions/PostCssAction/PostCssAction.ts"],"names":[],"mappings":"AAMA,OAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAMlE;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC3D,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,wDAAwD;IACxD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,aAAa,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;IAChD,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iEAAiE;IACjE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iCAAiC;IACjC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAMD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,MAAM,CAAC,oBAAoB,CAAC;IAC3D;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO;IA2BvD;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6E3D;;;;OAIG;IACH,QAAQ,IAAI,MAAM;CAGrB"}
@@ -1,121 +0,0 @@
1
- // ============================================================================
2
- // Import
3
- // ============================================================================
4
- import { promises as fs } from "fs";
5
- import path from "path";
6
- import postcss from "postcss";
7
- import autoprefixer from "autoprefixer";
8
- import cssnano from "cssnano";
9
- import { Action } from "../../types/Action.js";
10
- // ============================================================================
11
- // Classes
12
- // ============================================================================
13
- /**
14
- * PostCssAction handles CSS processing using PostCSS.
15
- * Supports autoprefixer, cssnano minification, and custom plugins.
16
- */
17
- export class PostCssAction extends Action {
18
- /**
19
- * Validates the action options.
20
- *
21
- * @param options - The options to validate.
22
- * @returns True if options are valid.
23
- */
24
- validateOptions(options) {
25
- if (!options.inputPath || typeof options.inputPath !== "string") {
26
- this.logError("Invalid options: 'inputPath' is required and must be a string.");
27
- return false;
28
- }
29
- if (!options.outputPath || typeof options.outputPath !== "string") {
30
- this.logError("Invalid options: 'outputPath' is required and must be a string.");
31
- return false;
32
- }
33
- if (options.autoprefixer !== undefined && typeof options.autoprefixer !== "boolean") {
34
- this.logError("Invalid options: 'autoprefixer' must be a boolean.");
35
- return false;
36
- }
37
- if (options.minify !== undefined && typeof options.minify !== "boolean") {
38
- this.logError("Invalid options: 'minify' must be a boolean.");
39
- return false;
40
- }
41
- if (options.cssnanoPreset !== undefined) {
42
- const validPresets = ["default", "lite", "advanced"];
43
- if (!validPresets.includes(options.cssnanoPreset)) {
44
- this.logError(`Invalid options: 'cssnanoPreset' must be one of: ${validPresets.join(", ")}`);
45
- return false;
46
- }
47
- }
48
- return true;
49
- }
50
- /**
51
- * Executes the PostCSS processing action.
52
- *
53
- * @param options - The options for CSS processing.
54
- * @returns A Promise that resolves when processing completes.
55
- * @throws {Error} If processing encounters an error.
56
- */
57
- async execute(options) {
58
- if (!this.validateOptions(options)) {
59
- throw new Error("Invalid options provided to PostCssAction.");
60
- }
61
- const { inputPath, outputPath, autoprefixer: useAutoprefixer = true, browsers = ["> 1%", "last 2 versions", "not dead"], minify = false, cssnanoPreset = "default", sourcemap = false, inlineSourcemap = false, plugins: customPlugins = [], } = options;
62
- this.logInfo(`Processing CSS: ${inputPath} → ${outputPath}`);
63
- try {
64
- const resolvedInputPath = path.resolve(inputPath);
65
- const resolvedOutputPath = path.resolve(outputPath);
66
- // Read input CSS
67
- const inputCss = await fs.readFile(resolvedInputPath, "utf8");
68
- // Build plugin list
69
- const plugins = [];
70
- if (useAutoprefixer) {
71
- plugins.push(autoprefixer({ overrideBrowserslist: browsers }));
72
- }
73
- if (minify) {
74
- plugins.push(cssnano({ preset: cssnanoPreset }));
75
- }
76
- // Add custom plugins
77
- plugins.push(...customPlugins);
78
- // Process with PostCSS
79
- const result = await postcss(plugins).process(inputCss, {
80
- from: resolvedInputPath,
81
- to: resolvedOutputPath,
82
- map: sourcemap ? { inline: inlineSourcemap } : false,
83
- });
84
- // Ensure output directory exists
85
- const outputDir = path.dirname(resolvedOutputPath);
86
- await fs.mkdir(outputDir, { recursive: true });
87
- // Write output CSS
88
- await fs.writeFile(resolvedOutputPath, result.css, "utf8");
89
- // Write sourcemap if external
90
- if (sourcemap && !inlineSourcemap && result.map) {
91
- await fs.writeFile(`${resolvedOutputPath}.map`, result.map.toString(), "utf8");
92
- this.logDebug(`Sourcemap written to ${resolvedOutputPath}.map`);
93
- }
94
- // Log warnings
95
- for (const warning of result.warnings()) {
96
- this.logWarning(`${warning.plugin}: ${warning.text}`);
97
- }
98
- const features = [];
99
- if (useAutoprefixer)
100
- features.push("autoprefixer");
101
- if (minify)
102
- features.push("minify");
103
- if (sourcemap)
104
- features.push("sourcemap");
105
- this.logInfo(`CSS processing completed: ${outputPath} (${features.join(", ") || "no transforms"})`);
106
- }
107
- catch (error) {
108
- this.logError("PostCSS processing failed.", error);
109
- throw error;
110
- }
111
- }
112
- /**
113
- * Provides a description of the action.
114
- *
115
- * @returns A string description of the action.
116
- */
117
- describe() {
118
- return "Processes CSS files using PostCSS with autoprefixer and cssnano support.";
119
- }
120
- }
121
- //# sourceMappingURL=PostCssAction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostCssAction.js","sourceRoot":"","sources":["../../../src/actions/PostCss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AC;gBACtC,IAAI,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1D,CAAC;YAED,MAAM,QAAQ,GAAG,EAAE,CAAC;YACpB,IAAI,eAAe;gBAAE,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YACnD,IAAI,MAAM;gBAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpC,IAAI,SAAS;gBAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAE1C,IAAI,CAAC,OAAO,CAAC,6BAA6B,UAAU,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe,GAAG,CAAC,CAAC;QACxG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;YACnD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACJ,OAAO,0EAA0E,CAAC;IACtF,CAAC;CACJ"}
@@ -1,3 +0,0 @@
1
- import { PostCssAction, PostCssActionOptions } from "./PostCssAction.js";
2
- export { PostCssAction, PostCssActionOptions };
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/PostCssAction/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAMzE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- // ============================================================================
2
- // Import
3
- // ============================================================================
4
- import { PostCssAction } from "./PostCssAction.js";
5
- // ============================================================================
6
- // Export
7
- // ============================================================================
8
- export { PostCssAction };
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/PostCssAction/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,aAAa,EAAwB,MAAM,oBAAoB,CAAC;AAEzE,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,aAAa,EAAwB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAM3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,QAAA,MAAM,MAAM,EAAE,YAWb,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js DELETED
@@ -1,20 +0,0 @@
1
- // ============================================================================
2
- // Export
3
- // ============================================================================
4
- export { PostCssAction } from "./actions/PostCssAction/index.js";
5
- export { Action } from "./types/Action.js";
6
- import { PostCssAction } from "./actions/PostCssAction/index.js";
7
- const plugin = {
8
- version: "1.0.0",
9
- description: "PostCSS processing for kist",
10
- author: "kist",
11
- repository: "https://github.com/getkist/kist-action-postcss",
12
- keywords: ["kist", "kist-action", "postcss", "css"],
13
- registerActions() {
14
- return {
15
- PostCssAction,
16
- };
17
- },
18
- };
19
- export default plugin;
20
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAgB,MAAM,mBAAmB,CAAC;AAQzD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,MAAM,MAAM,GAAiB;IACzB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,6BAA6B;IAC1C,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,gDAAgD;IAC5D,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,CAAC;IACnD,eAAe;QACX,OAAO;YACH,aAAa;SAChB,CAAC;IACN,CAAC;CACJ,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,70 +0,0 @@
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
- export type ActionOptionsType = Record<string, unknown>;
9
- /**
10
- * Abstract base class for all kist actions
11
- * Provides logging and execution interface
12
- */
13
- export 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
- export 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
- //# sourceMappingURL=Action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../src/types/Action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD;;;GAGG;AACH,8BAAsB,MAAM,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB;IACxE;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;IACH,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO;IAIrC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAI1D;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMzC;;OAEG;IACH,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG9C;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,MAAM,CAAC,CAAC;IAC3C,8BAA8B;IAC9B,eAAe,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,UAAU,MAAM,CAAC,CAAC;CAC5D"}
@@ -1,56 +0,0 @@
1
- /**
2
- * Base Action types for kist action plugins
3
- * These types match the kist Action interface for compatibility
4
- */
5
- /**
6
- * Abstract base class for all kist actions
7
- * Provides logging and execution interface
8
- */
9
- export class Action {
10
- /**
11
- * Gets the unique name of the action.
12
- */
13
- get name() {
14
- return this.constructor.name;
15
- }
16
- /**
17
- * Validates options before execution
18
- * Override in subclasses for specific validation
19
- */
20
- validateOptions(_options) {
21
- return true;
22
- }
23
- /**
24
- * Provides a description of the action
25
- */
26
- describe() {
27
- return `${this.name} action`;
28
- }
29
- /**
30
- * Log an info message
31
- */
32
- logInfo(message) {
33
- console.log(`[${this.name}] ${message}`);
34
- }
35
- /**
36
- * Log an error message
37
- */
38
- logError(message, error) {
39
- console.error(`[${this.name}] ERROR: ${message}`, error || "");
40
- }
41
- /**
42
- * Log a debug message
43
- */
44
- logDebug(message) {
45
- if (process.env.DEBUG) {
46
- console.debug(`[${this.name}] DEBUG: ${message}`);
47
- }
48
- }
49
- /**
50
- * Log a warning message
51
- */
52
- logWarning(message) {
53
- console.warn(`[${this.name}] WARNING: ${message}`);
54
- }
55
- }
56
- //# sourceMappingURL=Action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../src/types/Action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;GAGG;AACH,MAAM,OAAgB,MAAM;IACxB;;OAEG;IACH,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,QAAW;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAQD;;OAEG;IACH,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,IAAI,SAAS,CAAC;IACjC,CAAC;IAED;;OAEG;IACO,OAAO,CAAC,OAAe;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAe,EAAE,KAAe;QAC/C,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,YAAY,OAAO,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACO,QAAQ,CAAC,OAAe;QAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,YAAY,OAAO,EAAE,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;IAED;;OAEG;IACO,UAAU,CAAC,OAAe;QAChC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,cAAc,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;CACJ"}