@getkist/action-sass 1.0.1
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/LICENSE +21 -0
- package/README.md +171 -0
- package/dist/actions/StyleProcessingAction/StyleProcessingAction.d.ts +82 -0
- package/dist/actions/StyleProcessingAction/StyleProcessingAction.d.ts.map +1 -0
- package/dist/actions/StyleProcessingAction/StyleProcessingAction.js +215 -0
- package/dist/actions/StyleProcessingAction/StyleProcessingAction.js.map +1 -0
- package/dist/actions/StyleProcessingAction/index.d.ts +3 -0
- package/dist/actions/StyleProcessingAction/index.d.ts.map +1 -0
- package/dist/actions/StyleProcessingAction/index.js +5 -0
- package/dist/actions/StyleProcessingAction/index.js.map +1 -0
- package/dist/actions/StyleProcessingAction/postcss.config.compressed.d.ts +11 -0
- package/dist/actions/StyleProcessingAction/postcss.config.compressed.d.ts.map +1 -0
- package/dist/actions/StyleProcessingAction/postcss.config.compressed.js +26 -0
- package/dist/actions/StyleProcessingAction/postcss.config.compressed.js.map +1 -0
- package/dist/actions/StyleProcessingAction/postcss.config.expanded.d.ts +11 -0
- package/dist/actions/StyleProcessingAction/postcss.config.expanded.d.ts.map +1 -0
- package/dist/actions/StyleProcessingAction/postcss.config.expanded.js +20 -0
- package/dist/actions/StyleProcessingAction/postcss.config.expanded.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/types/Action.d.ts +70 -0
- package/dist/types/Action.d.ts.map +1 -0
- package/dist/types/Action.js +56 -0
- package/dist/types/Action.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kist
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# @getkist/action-sass
|
|
2
|
+
|
|
3
|
+
SASS/SCSS compilation with PostCSS processing for [kist](https://github.com/getkist/kist) build tool.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@getkist/action-sass)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **SASS/SCSS Compilation** - Modern SASS compilation using Dart Sass
|
|
11
|
+
- **PostCSS Integration** - Automatic PostCSS processing with autoprefixer
|
|
12
|
+
- **Compression Support** - Expanded and compressed output styles
|
|
13
|
+
- **CSS Optimization** - Built-in cssnano for minification
|
|
14
|
+
- **Node Package Importer** - Import from node_modules directly
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev @getkist/action-sass
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic Style Compilation
|
|
25
|
+
|
|
26
|
+
Add to your `kist.yml`:
|
|
27
|
+
|
|
28
|
+
```yaml
|
|
29
|
+
pipeline:
|
|
30
|
+
stages:
|
|
31
|
+
- name: styles
|
|
32
|
+
steps:
|
|
33
|
+
- name: compile-styles
|
|
34
|
+
action: StyleProcessingAction
|
|
35
|
+
options:
|
|
36
|
+
inputFile: ./src/styles/main.scss
|
|
37
|
+
outputFile: ./dist/styles/main.css
|
|
38
|
+
styleOption: compressed
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Expanded Output
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
pipeline:
|
|
45
|
+
stages:
|
|
46
|
+
- name: dev-styles
|
|
47
|
+
steps:
|
|
48
|
+
- name: compile-dev-styles
|
|
49
|
+
action: StyleProcessingAction
|
|
50
|
+
options:
|
|
51
|
+
inputFile: ./src/styles/app.scss
|
|
52
|
+
outputFile: ./dist/styles/app.css
|
|
53
|
+
styleOption: expanded
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Action: StyleProcessingAction
|
|
57
|
+
|
|
58
|
+
Compiles SCSS files to CSS with PostCSS transformations.
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
| Option | Type | Required | Description |
|
|
63
|
+
| ------------- | ------ | -------- | ---------------------------------------- |
|
|
64
|
+
| `inputFile` | string | Yes | Path to the input SCSS file |
|
|
65
|
+
| `outputFile` | string | Yes | Path for the output CSS file |
|
|
66
|
+
| `styleOption` | string | Yes | Output style: 'expanded' or 'compressed' |
|
|
67
|
+
|
|
68
|
+
### Features
|
|
69
|
+
|
|
70
|
+
**Expanded Mode:**
|
|
71
|
+
|
|
72
|
+
- Readable, formatted CSS output
|
|
73
|
+
- Autoprefixer for browser compatibility
|
|
74
|
+
- Ideal for development
|
|
75
|
+
|
|
76
|
+
**Compressed Mode:**
|
|
77
|
+
|
|
78
|
+
- Minified CSS with cssnano
|
|
79
|
+
- Autoprefixer for browser compatibility
|
|
80
|
+
- Optimized for production
|
|
81
|
+
|
|
82
|
+
### PostCSS Plugins
|
|
83
|
+
|
|
84
|
+
- **autoprefixer** - Automatically adds vendor prefixes
|
|
85
|
+
- **cssnano** - CSS minification (compressed mode only)
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
### Multiple Style Files
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
pipeline:
|
|
93
|
+
stages:
|
|
94
|
+
- name: compile-all-styles
|
|
95
|
+
steps:
|
|
96
|
+
- name: main-styles
|
|
97
|
+
action: StyleProcessingAction
|
|
98
|
+
options:
|
|
99
|
+
inputFile: ./src/styles/main.scss
|
|
100
|
+
outputFile: ./dist/styles/main.css
|
|
101
|
+
styleOption: compressed
|
|
102
|
+
|
|
103
|
+
- name: admin-styles
|
|
104
|
+
action: StyleProcessingAction
|
|
105
|
+
options:
|
|
106
|
+
inputFile: ./src/styles/admin.scss
|
|
107
|
+
outputFile: ./dist/styles/admin.css
|
|
108
|
+
styleOption: compressed
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Development vs Production
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
pipeline:
|
|
115
|
+
stages:
|
|
116
|
+
- name: dev-build
|
|
117
|
+
steps:
|
|
118
|
+
- name: dev-styles
|
|
119
|
+
action: StyleProcessingAction
|
|
120
|
+
options:
|
|
121
|
+
inputFile: ./src/styles/app.scss
|
|
122
|
+
outputFile: ./dist/dev/app.css
|
|
123
|
+
styleOption: expanded
|
|
124
|
+
|
|
125
|
+
- name: prod-build
|
|
126
|
+
steps:
|
|
127
|
+
- name: prod-styles
|
|
128
|
+
action: StyleProcessingAction
|
|
129
|
+
options:
|
|
130
|
+
inputFile: ./src/styles/app.scss
|
|
131
|
+
outputFile: ./dist/prod/app.css
|
|
132
|
+
styleOption: compressed
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## TypeScript Types
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { StyleProcessingAction } from "@getkist/action-sass";
|
|
139
|
+
|
|
140
|
+
const action = new StyleProcessingAction();
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### StyleProcessingActionOptions
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
interface StyleProcessingActionOptions {
|
|
147
|
+
inputFile: string;
|
|
148
|
+
outputFile: string;
|
|
149
|
+
styleOption: "expanded" | "compressed";
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Requirements
|
|
154
|
+
|
|
155
|
+
- Node.js >= 18.0.0
|
|
156
|
+
- kist >= 0.1.0
|
|
157
|
+
|
|
158
|
+
## Contributing
|
|
159
|
+
|
|
160
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT © kist
|
|
165
|
+
|
|
166
|
+
## Links
|
|
167
|
+
|
|
168
|
+
- [GitHub Repository](https://github.com/getkist/kist-action-sass)
|
|
169
|
+
- [npm Package](https://www.npmjs.com/package/@getkist/action-sass)
|
|
170
|
+
- [kist Build Tool](https://github.com/getkist/kist)
|
|
171
|
+
- [Issue Tracker](https://github.com/getkist/kist-action-sass/issues)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Action, ActionOptionsType } from "../../types/Action.js";
|
|
2
|
+
/**
|
|
3
|
+
* Single output configuration for multi-output mode.
|
|
4
|
+
*/
|
|
5
|
+
export interface StyleOutputConfig {
|
|
6
|
+
/** Output file path */
|
|
7
|
+
file: string;
|
|
8
|
+
/** CSS style: expanded or compressed */
|
|
9
|
+
style: "expanded" | "compressed";
|
|
10
|
+
/** Enable sourcemap for this output (default: false) */
|
|
11
|
+
sourceMap?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface StyleProcessingActionOptions extends ActionOptionsType {
|
|
14
|
+
/** Input SCSS/CSS file path */
|
|
15
|
+
inputFile: string;
|
|
16
|
+
/** Single output file path (mutually exclusive with outputs) */
|
|
17
|
+
outputFile?: string;
|
|
18
|
+
/** Single output style option (mutually exclusive with outputs) */
|
|
19
|
+
styleOption?: "expanded" | "compressed";
|
|
20
|
+
/**
|
|
21
|
+
* Multiple outputs from single input (mutually exclusive with outputFile/styleOption).
|
|
22
|
+
* Allows generating both expanded and compressed CSS from one source.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```yaml
|
|
26
|
+
* outputs:
|
|
27
|
+
* - file: "./dist/css/app.css"
|
|
28
|
+
* style: expanded
|
|
29
|
+
* sourceMap: true
|
|
30
|
+
* - file: "./dist/css/app.min.css"
|
|
31
|
+
* style: compressed
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
outputs?: StyleOutputConfig[];
|
|
35
|
+
/** Enable sourcemap generation for single output mode (default: false) */
|
|
36
|
+
sourceMap?: boolean;
|
|
37
|
+
/** Include original source content in sourcemap (default: true when sourceMap enabled) */
|
|
38
|
+
sourceMapIncludeSources?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* StyleProcessingAction is a step action responsible for processing styles,
|
|
42
|
+
* including compiling SCSS and applying PostCSS transformations. It supports
|
|
43
|
+
* expanded and compressed output styles based on the provided configuration.
|
|
44
|
+
*/
|
|
45
|
+
export declare class StyleProcessingAction extends Action {
|
|
46
|
+
/**
|
|
47
|
+
* Executes the style processing action.
|
|
48
|
+
* @param options - The options specific to style processing, including
|
|
49
|
+
* input/output file paths and style format.
|
|
50
|
+
* @returns A Promise that resolves when the styles are processed
|
|
51
|
+
* successfully, or rejects with an error if the action fails.
|
|
52
|
+
*/
|
|
53
|
+
execute(options: StyleProcessingActionOptions): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Executes multi-output mode: compiles SCSS for each unique style,
|
|
56
|
+
* then generates all specified output files.
|
|
57
|
+
*/
|
|
58
|
+
private executeMultiOutput;
|
|
59
|
+
/**
|
|
60
|
+
* Executes single-output mode (legacy behavior).
|
|
61
|
+
*/
|
|
62
|
+
private executeSingleOutput;
|
|
63
|
+
/**
|
|
64
|
+
* Processes the given CSS with PostCSS based on the provided style option.
|
|
65
|
+
* @param css - The CSS string to process.
|
|
66
|
+
* @param styleOption - The style option, either "expanded" or "compressed".
|
|
67
|
+
* @param sourceMapOptions - Optional sourcemap configuration.
|
|
68
|
+
* @returns Object containing processed CSS string and optional sourcemap.
|
|
69
|
+
*/
|
|
70
|
+
private processPostCSS;
|
|
71
|
+
/**
|
|
72
|
+
* Ensures that the given directory exists, creating it if it does not.
|
|
73
|
+
* @param dirPath - The path of the directory to check and create.
|
|
74
|
+
*/
|
|
75
|
+
private ensureDirectoryExists;
|
|
76
|
+
/**
|
|
77
|
+
* Provides a description of the action.
|
|
78
|
+
* @returns A string description of the action.
|
|
79
|
+
*/
|
|
80
|
+
describe(): string;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=StyleProcessingAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleProcessingAction.d.ts","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/StyleProcessingAction.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAUlE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,KAAK,EAAE,UAAU,GAAG,YAAY,CAAC;IACjC,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACnE,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAElB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC;IAExC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAE9B,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0FAA0F;IAC1F,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACrC;AAMD;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,MAAM;IAU7C;;;;;;OAMG;IACG,OAAO,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBnE;;;OAGG;YACW,kBAAkB;IA6EhC;;OAEG;YACW,mBAAmB;IAuEjC;;;;;;OAMG;YACW,cAAc;IAoC5B;;;OAGG;YACW,qBAAqB;IAenC;;;OAGG;IACH,QAAQ,IAAI,MAAM;CAGrB"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import { promises as fs } from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import postcss from "postcss";
|
|
7
|
+
import * as sass from "sass";
|
|
8
|
+
import { Action } from "../../types/Action.js";
|
|
9
|
+
// Assuming the PostCSS configurations are available at the given paths
|
|
10
|
+
import postcssConfigCompressed from "./postcss.config.compressed.js";
|
|
11
|
+
import postcssConfigExpanded from "./postcss.config.expanded.js";
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Classes
|
|
14
|
+
// ============================================================================
|
|
15
|
+
/**
|
|
16
|
+
* StyleProcessingAction is a step action responsible for processing styles,
|
|
17
|
+
* including compiling SCSS and applying PostCSS transformations. It supports
|
|
18
|
+
* expanded and compressed output styles based on the provided configuration.
|
|
19
|
+
*/
|
|
20
|
+
export class StyleProcessingAction extends Action {
|
|
21
|
+
// Parameters
|
|
22
|
+
// ========================================================================
|
|
23
|
+
// Constructor
|
|
24
|
+
// ========================================================================
|
|
25
|
+
// Methods
|
|
26
|
+
// ========================================================================
|
|
27
|
+
/**
|
|
28
|
+
* Executes the style processing action.
|
|
29
|
+
* @param options - The options specific to style processing, including
|
|
30
|
+
* input/output file paths and style format.
|
|
31
|
+
* @returns A Promise that resolves when the styles are processed
|
|
32
|
+
* successfully, or rejects with an error if the action fails.
|
|
33
|
+
*/
|
|
34
|
+
async execute(options) {
|
|
35
|
+
const inputFile = options.inputFile;
|
|
36
|
+
if (!inputFile) {
|
|
37
|
+
throw new Error("Missing required option: inputFile.");
|
|
38
|
+
}
|
|
39
|
+
// Multi-output mode
|
|
40
|
+
if (options.outputs && options.outputs.length > 0) {
|
|
41
|
+
await this.executeMultiOutput(inputFile, options.outputs, options.sourceMapIncludeSources ?? true);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Single output mode (legacy)
|
|
45
|
+
await this.executeSingleOutput(options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Executes multi-output mode: compiles SCSS for each unique style,
|
|
49
|
+
* then generates all specified output files.
|
|
50
|
+
*/
|
|
51
|
+
async executeMultiOutput(inputFile, outputs, sourceMapIncludeSources) {
|
|
52
|
+
this.logInfo(`Processing styles from ${inputFile} to ${outputs.length} outputs`);
|
|
53
|
+
// Group outputs by style to avoid redundant SCSS compilation
|
|
54
|
+
const expandedOutputs = outputs.filter((o) => o.style === "expanded");
|
|
55
|
+
const compressedOutputs = outputs.filter((o) => o.style === "compressed");
|
|
56
|
+
// Compile SCSS for each style variant needed
|
|
57
|
+
const compiledCache = new Map();
|
|
58
|
+
for (const style of ["expanded", "compressed"]) {
|
|
59
|
+
const outputsForStyle = style === "expanded" ? expandedOutputs : compressedOutputs;
|
|
60
|
+
if (outputsForStyle.length === 0)
|
|
61
|
+
continue;
|
|
62
|
+
const needsSourceMap = outputsForStyle.some((o) => o.sourceMap);
|
|
63
|
+
const result = await sass.compileAsync(inputFile, {
|
|
64
|
+
style,
|
|
65
|
+
importers: [new sass.NodePackageImporter()],
|
|
66
|
+
sourceMap: needsSourceMap,
|
|
67
|
+
sourceMapIncludeSources: needsSourceMap && sourceMapIncludeSources,
|
|
68
|
+
});
|
|
69
|
+
compiledCache.set(style, {
|
|
70
|
+
css: result.css,
|
|
71
|
+
sourceMap: result.sourceMap,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Process each output
|
|
75
|
+
for (const output of outputs) {
|
|
76
|
+
const compiled = compiledCache.get(output.style);
|
|
77
|
+
const sourceMap = output.sourceMap ?? false;
|
|
78
|
+
try {
|
|
79
|
+
// Ensure output directory exists
|
|
80
|
+
const outputDir = path.dirname(output.file);
|
|
81
|
+
await this.ensureDirectoryExists(outputDir);
|
|
82
|
+
// Process with PostCSS
|
|
83
|
+
const { css: processedCss, map: processedMap } = await this.processPostCSS(compiled.css, output.style, sourceMap
|
|
84
|
+
? {
|
|
85
|
+
inputFile,
|
|
86
|
+
outputFile: output.file,
|
|
87
|
+
sassSourceMap: compiled.sourceMap,
|
|
88
|
+
}
|
|
89
|
+
: undefined);
|
|
90
|
+
// Write CSS
|
|
91
|
+
await fs.writeFile(output.file, processedCss, "utf-8");
|
|
92
|
+
// Write sourcemap if enabled
|
|
93
|
+
if (sourceMap && processedMap) {
|
|
94
|
+
const mapFile = `${output.file}.map`;
|
|
95
|
+
await fs.writeFile(mapFile, processedMap.toString(), "utf-8");
|
|
96
|
+
this.logInfo(` → ${output.file} (${output.style} + sourcemap)`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this.logInfo(` → ${output.file} (${output.style})`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.logError(`Error processing ${output.file}: ${error}`);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
this.logInfo(`Multi-output style processing complete`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Executes single-output mode (legacy behavior).
|
|
111
|
+
*/
|
|
112
|
+
async executeSingleOutput(options) {
|
|
113
|
+
const inputFile = options.inputFile;
|
|
114
|
+
const outputFile = options.outputFile;
|
|
115
|
+
const styleOption = options.styleOption;
|
|
116
|
+
const sourceMap = options.sourceMap ?? false;
|
|
117
|
+
const sourceMapIncludeSources = options.sourceMapIncludeSources ?? true;
|
|
118
|
+
if (!outputFile || !styleOption) {
|
|
119
|
+
throw new Error("Missing required options: outputFile or styleOption (or use 'outputs' for multi-output mode).");
|
|
120
|
+
}
|
|
121
|
+
this.logInfo(`Processing styles from ${inputFile} to ${outputFile} with ${styleOption} style${sourceMap ? " + sourcemap" : ""}.`);
|
|
122
|
+
try {
|
|
123
|
+
// Ensure the output directory exists
|
|
124
|
+
const outputDir = path.dirname(outputFile);
|
|
125
|
+
await this.ensureDirectoryExists(outputDir);
|
|
126
|
+
// Compile SCSS to CSS
|
|
127
|
+
const result = await sass.compileAsync(inputFile, {
|
|
128
|
+
style: styleOption,
|
|
129
|
+
importers: [new sass.NodePackageImporter()],
|
|
130
|
+
sourceMap: sourceMap,
|
|
131
|
+
sourceMapIncludeSources: sourceMap && sourceMapIncludeSources,
|
|
132
|
+
});
|
|
133
|
+
// Process the compiled CSS with PostCSS
|
|
134
|
+
const { css: processedCss, map: processedMap } = await this.processPostCSS(result.css, styleOption, sourceMap
|
|
135
|
+
? {
|
|
136
|
+
inputFile,
|
|
137
|
+
outputFile,
|
|
138
|
+
sassSourceMap: result.sourceMap,
|
|
139
|
+
}
|
|
140
|
+
: undefined);
|
|
141
|
+
// Write the processed CSS to a file
|
|
142
|
+
await fs.writeFile(outputFile, processedCss, "utf-8");
|
|
143
|
+
// Write sourcemap if enabled
|
|
144
|
+
if (sourceMap && processedMap) {
|
|
145
|
+
const mapFile = `${outputFile}.map`;
|
|
146
|
+
await fs.writeFile(mapFile, processedMap.toString(), "utf-8");
|
|
147
|
+
this.logInfo(`Sourcemap written to ${mapFile}`);
|
|
148
|
+
}
|
|
149
|
+
this.logInfo(`Styles processed successfully from ${inputFile} to ${outputFile}.`);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
this.logError(`Error processing styles from ${inputFile}: ${error}`);
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Processes the given CSS with PostCSS based on the provided style option.
|
|
158
|
+
* @param css - The CSS string to process.
|
|
159
|
+
* @param styleOption - The style option, either "expanded" or "compressed".
|
|
160
|
+
* @param sourceMapOptions - Optional sourcemap configuration.
|
|
161
|
+
* @returns Object containing processed CSS string and optional sourcemap.
|
|
162
|
+
*/
|
|
163
|
+
async processPostCSS(css, styleOption, sourceMapOptions) {
|
|
164
|
+
const config = styleOption === "expanded"
|
|
165
|
+
? postcssConfigExpanded
|
|
166
|
+
: postcssConfigCompressed;
|
|
167
|
+
const postcssOptions = {
|
|
168
|
+
from: sourceMapOptions?.inputFile,
|
|
169
|
+
to: sourceMapOptions?.outputFile,
|
|
170
|
+
};
|
|
171
|
+
if (sourceMapOptions) {
|
|
172
|
+
postcssOptions.map = {
|
|
173
|
+
inline: false,
|
|
174
|
+
annotation: `${path.basename(sourceMapOptions.outputFile)}.map`,
|
|
175
|
+
prev: sourceMapOptions.sassSourceMap
|
|
176
|
+
? JSON.stringify(sourceMapOptions.sassSourceMap)
|
|
177
|
+
: false,
|
|
178
|
+
sourcesContent: true,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
postcssOptions.map = false;
|
|
183
|
+
}
|
|
184
|
+
const result = await postcss(config.plugins).process(css, postcssOptions);
|
|
185
|
+
return { css: result.css, map: result.map };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Ensures that the given directory exists, creating it if it does not.
|
|
189
|
+
* @param dirPath - The path of the directory to check and create.
|
|
190
|
+
*/
|
|
191
|
+
async ensureDirectoryExists(dirPath) {
|
|
192
|
+
try {
|
|
193
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (error instanceof Error) {
|
|
197
|
+
const nodeError = error;
|
|
198
|
+
if (nodeError.code !== "EEXIST") {
|
|
199
|
+
throw nodeError;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Provides a description of the action.
|
|
209
|
+
* @returns A string description of the action.
|
|
210
|
+
*/
|
|
211
|
+
describe() {
|
|
212
|
+
return "Processes SCSS files into CSS, applying PostCSS transformations for expanded or compressed outputs.";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=StyleProcessingAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleProcessingAction.js","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/StyleProcessingAction.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAqB,MAAM,uBAAuB,CAAC;AAElE,uEAAuE;AACvE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AACrE,OAAO,qBAAqB,MAAM,8BAA8B,CAAC;AAiDjE,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,MAAM;IAC7C,aAAa;IACb,2EAA2E;IAE3E,cAAc;IACd,2EAA2E;IAE3E,UAAU;IACV,2EAA2E;IAE3E;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,CAAC,OAAqC;QAC/C,MAAM,SAA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AAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBACzB,MAAM,SAAS,GAAG,KAA8B,CAAC;gBACjD,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAC9B,MAAM,SAAS,CAAC;gBACpB,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,QAAQ;QACJ,OAAO,qGAAqG,CAAC;IACjH,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Export
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { StyleProcessingAction } from "./StyleProcessingAction.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import autoprefixer from "autoprefixer";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration object for PostCSS that includes plugins for optimization and compression
|
|
4
|
+
* of CSS. This setup is typically used for production builds where minimized CSS is preferred
|
|
5
|
+
* to reduce file size and improve loading times.
|
|
6
|
+
*/
|
|
7
|
+
declare const postcssConfigCompressed: {
|
|
8
|
+
plugins: (typeof autoprefixer | import("postcss").Processor)[];
|
|
9
|
+
};
|
|
10
|
+
export default postcssConfigCompressed;
|
|
11
|
+
//# sourceMappingURL=postcss.config.compressed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcss.config.compressed.d.ts","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/postcss.config.compressed.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,MAAM,cAAc,CAAC;AAOxC;;;;GAIG;AACH,QAAA,MAAM,uBAAuB;;CAO5B,CAAC;AAMF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import autoprefixer from "autoprefixer";
|
|
5
|
+
import cssnano from "cssnano";
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Constants
|
|
8
|
+
// ============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Configuration object for PostCSS that includes plugins for optimization and compression
|
|
11
|
+
* of CSS. This setup is typically used for production builds where minimized CSS is preferred
|
|
12
|
+
* to reduce file size and improve loading times.
|
|
13
|
+
*/
|
|
14
|
+
const postcssConfigCompressed = {
|
|
15
|
+
plugins: [
|
|
16
|
+
autoprefixer,
|
|
17
|
+
cssnano({
|
|
18
|
+
preset: "default",
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Export
|
|
24
|
+
// ============================================================================
|
|
25
|
+
export default postcssConfigCompressed;
|
|
26
|
+
//# sourceMappingURL=postcss.config.compressed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcss.config.compressed.js","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/postcss.config.compressed.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,YAAY,MAAM,cAAc,CAAC;AACxC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,uBAAuB,GAAG;IAC5B,OAAO,EAAE;QACL,YAAY;QACZ,OAAO,CAAC;YACJ,MAAM,EAAE,SAAS;SACpB,CAAC;KACL;CACJ,CAAC;AAEF,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import autoprefixer from "autoprefixer";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration object for PostCSS that focuses on generating expanded, readable CSS
|
|
4
|
+
* for development environments. Includes plugins that enhance CSS handling like nesting,
|
|
5
|
+
* variable support, and import inlining, alongside autoprefixer for browser compatibility.
|
|
6
|
+
*/
|
|
7
|
+
declare const postcssConfigExpanded: {
|
|
8
|
+
plugins: (typeof autoprefixer)[];
|
|
9
|
+
};
|
|
10
|
+
export default postcssConfigExpanded;
|
|
11
|
+
//# sourceMappingURL=postcss.config.expanded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcss.config.expanded.d.ts","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/postcss.config.expanded.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,MAAM,cAAc,CAAC;AAMxC;;;;GAIG;AACH,QAAA,MAAM,qBAAqB;;CAE1B,CAAC;AAMF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import autoprefixer from "autoprefixer";
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Constants
|
|
7
|
+
// ============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Configuration object for PostCSS that focuses on generating expanded, readable CSS
|
|
10
|
+
* for development environments. Includes plugins that enhance CSS handling like nesting,
|
|
11
|
+
* variable support, and import inlining, alongside autoprefixer for browser compatibility.
|
|
12
|
+
*/
|
|
13
|
+
const postcssConfigExpanded = {
|
|
14
|
+
plugins: [autoprefixer],
|
|
15
|
+
};
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Export
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export default postcssConfigExpanded;
|
|
20
|
+
//# sourceMappingURL=postcss.config.expanded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postcss.config.expanded.js","sourceRoot":"","sources":["../../../src/actions/StyleProcessingAction/postcss.config.expanded.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,qBAAqB,GAAG;IAC1B,OAAO,EAAE,CAAC,YAAY,CAAC;CAC1B,CAAC;AAEF,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,eAAe,qBAAqB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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";
|
|
6
|
+
declare const plugin: ActionPlugin;
|
|
7
|
+
export default plugin;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,YAAY,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAC7F,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,YASb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Export
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { StyleProcessingAction } from "./actions/StyleProcessingAction/index.js";
|
|
5
|
+
export { Action } from "./types/Action.js";
|
|
6
|
+
import { StyleProcessingAction } from "./actions/StyleProcessingAction/index.js";
|
|
7
|
+
const plugin = {
|
|
8
|
+
version: "1.0.0",
|
|
9
|
+
description: "SASS/SCSS compilation with PostCSS processing for kist",
|
|
10
|
+
author: "kist",
|
|
11
|
+
repository: "https://github.com/getkist/kist-action-sass",
|
|
12
|
+
keywords: ["kist", "kist-action", "sass", "scss", "postcss", "css"],
|
|
13
|
+
actions: {
|
|
14
|
+
StyleProcessingAction,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default plugin;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAgB,MAAM,mBAAmB,CAAC;AAQzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,MAAM,MAAM,GAAiB;IACzB,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,wDAAwD;IACrE,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,6CAA6C;IACzD,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;IACnE,OAAO,EAAE;QACL,qBAAqB;KACxB;CACJ,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getkist/action-sass",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SASS/SCSS compilation with PostCSS processing actions for kist build tool",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"kist",
|
|
10
|
+
"kist-action",
|
|
11
|
+
"sass",
|
|
12
|
+
"scss",
|
|
13
|
+
"postcss",
|
|
14
|
+
"css",
|
|
15
|
+
"compilation",
|
|
16
|
+
"autoprefixer",
|
|
17
|
+
"cssnano"
|
|
18
|
+
],
|
|
19
|
+
"author": "kist",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/getkist/kist-action-sass.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/getkist/kist-action-sass/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/getkist/kist-action-sass#readme",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0",
|
|
31
|
+
"npm": ">=9.0.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"build:watch": "tsc --watch",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"test:watch": "jest --watch",
|
|
38
|
+
"test:coverage": "jest --coverage",
|
|
39
|
+
"test:unit": "jest --testPathPatterns=\\.test\\.ts$",
|
|
40
|
+
"test:integration": "jest --testPathPatterns=\\.integration\\.test\\.ts$",
|
|
41
|
+
"test:e2e": "jest --testPathPatterns=e2e\\.test\\.ts$",
|
|
42
|
+
"test:coverage:enforce": "jest --coverage && jest --listTests | grep -E '\\.(test|integration|e2e)\\.ts$' | wc -l && echo 'Coverage thresholds enforced'",
|
|
43
|
+
"benchmark": "npx ts-node src/tests/benchmark.ts",
|
|
44
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
45
|
+
"lint:fix": "eslint 'src/**/*.ts' --fix",
|
|
46
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
47
|
+
"clean": "rm -rf dist",
|
|
48
|
+
"prepublishOnly": "npm run clean && npm run build && npm test"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"kist": "^0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"sass": "^1.97.3",
|
|
55
|
+
"postcss": "^8.5.6",
|
|
56
|
+
"autoprefixer": "^10.4.24",
|
|
57
|
+
"cssnano": "^7.1.2"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/jest": "30.0.0",
|
|
61
|
+
"@types/node": "25.2.2",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "8.54.0",
|
|
63
|
+
"@typescript-eslint/parser": "8.54.0",
|
|
64
|
+
"eslint": "10.0.0",
|
|
65
|
+
"jest": "30.2.0",
|
|
66
|
+
"kist": "^0.1.58",
|
|
67
|
+
"prettier": "^3.8.1",
|
|
68
|
+
"ts-jest": "^29.4.6",
|
|
69
|
+
"typescript": "^5.9.3"
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist",
|
|
73
|
+
"README.md",
|
|
74
|
+
"LICENSE"
|
|
75
|
+
]
|
|
76
|
+
}
|