@getkist/action-prettier 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.
Files changed (35) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/actions/PrettierAction/PrettierAction.d.ts +93 -0
  4. package/dist/actions/PrettierAction/PrettierAction.d.ts.map +1 -0
  5. package/dist/actions/PrettierAction/PrettierAction.js +205 -0
  6. package/dist/actions/PrettierAction/PrettierAction.js.map +1 -0
  7. package/dist/actions/PrettierAction/index.d.ts +3 -0
  8. package/dist/actions/PrettierAction/index.d.ts.map +1 -0
  9. package/dist/actions/PrettierAction/index.js +2 -0
  10. package/dist/actions/PrettierAction/index.js.map +1 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +14 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/src/actions/PrettierAction/PrettierAction.d.ts +93 -0
  16. package/dist/src/actions/PrettierAction/PrettierAction.d.ts.map +1 -0
  17. package/dist/src/actions/PrettierAction/PrettierAction.js +202 -0
  18. package/dist/src/actions/PrettierAction/PrettierAction.js.map +1 -0
  19. package/dist/src/actions/PrettierAction/index.d.ts +3 -0
  20. package/dist/src/actions/PrettierAction/index.d.ts.map +1 -0
  21. package/dist/src/actions/PrettierAction/index.js +2 -0
  22. package/dist/src/actions/PrettierAction/index.js.map +1 -0
  23. package/dist/src/index.d.ts +16 -0
  24. package/dist/src/index.d.ts.map +1 -0
  25. package/dist/src/index.js +14 -0
  26. package/dist/src/index.js.map +1 -0
  27. package/dist/src/types/Action.d.ts +48 -0
  28. package/dist/src/types/Action.d.ts.map +1 -0
  29. package/dist/src/types/Action.js +38 -0
  30. package/dist/src/types/Action.js.map +1 -0
  31. package/dist/types/Action.d.ts +48 -0
  32. package/dist/types/Action.d.ts.map +1 -0
  33. package/dist/types/Action.js +38 -0
  34. package/dist/types/Action.js.map +1 -0
  35. package/package.json +51 -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 @@
1
+ # kist-action-prettier
@@ -0,0 +1,93 @@
1
+ import { Action } from "../../types/Action.js";
2
+ /**
3
+ * Options for the PrettierAction
4
+ */
5
+ export interface PrettierActionOptions {
6
+ /**
7
+ * Files or glob patterns to format
8
+ */
9
+ targetFiles: string[];
10
+ /**
11
+ * Whether to write formatted files back to disk.
12
+ * If false, only checks formatting without modifying files.
13
+ */
14
+ write?: boolean;
15
+ /**
16
+ * Path to a custom Prettier config file
17
+ */
18
+ configPath?: string;
19
+ /**
20
+ * Tab width for indentation
21
+ */
22
+ tabWidth?: number;
23
+ /**
24
+ * Use tabs instead of spaces
25
+ */
26
+ useTabs?: boolean;
27
+ /**
28
+ * Print semicolons at the ends of statements
29
+ */
30
+ semi?: boolean;
31
+ /**
32
+ * Use single quotes instead of double quotes
33
+ */
34
+ singleQuote?: boolean;
35
+ /**
36
+ * Print trailing commas wherever possible
37
+ */
38
+ trailingComma?: "all" | "es5" | "none";
39
+ /**
40
+ * Print spaces between brackets in object literals
41
+ */
42
+ bracketSpacing?: boolean;
43
+ /**
44
+ * Put the closing bracket of a multi-line element on a new line
45
+ */
46
+ bracketSameLine?: boolean;
47
+ /**
48
+ * Include parentheses around a sole arrow function parameter
49
+ */
50
+ arrowParens?: "always" | "avoid";
51
+ /**
52
+ * Line width that the printer will wrap on
53
+ */
54
+ printWidth?: number;
55
+ /**
56
+ * How to handle whitespace in HTML, Vue, Angular, or JSX
57
+ */
58
+ htmlWhitespaceSensitivity?: "css" | "strict" | "ignore";
59
+ /**
60
+ * End of line style
61
+ */
62
+ endOfLine?: "lf" | "crlf" | "cr" | "auto";
63
+ /**
64
+ * Force parser to use (auto-detected by default)
65
+ */
66
+ parser?: string;
67
+ /**
68
+ * Ignore files matching patterns in .prettierignore
69
+ */
70
+ ignoreUnknown?: boolean;
71
+ }
72
+ /**
73
+ * Action for formatting code files using Prettier.
74
+ */
75
+ export declare class PrettierAction extends Action<PrettierActionOptions> {
76
+ readonly name = "PrettierAction";
77
+ describe(): string;
78
+ validateOptions(options: PrettierActionOptions): boolean;
79
+ execute(options: PrettierActionOptions): Promise<void>;
80
+ /**
81
+ * Build Prettier options from action options and config file
82
+ */
83
+ private buildPrettierOptions;
84
+ /**
85
+ * Resolve file patterns to actual file paths
86
+ */
87
+ private resolveFiles;
88
+ /**
89
+ * Process a single file with Prettier
90
+ */
91
+ private processFile;
92
+ }
93
+ //# sourceMappingURL=PrettierAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrettierAction.d.ts","sourceRoot":"","sources":["../../../src/actions/PrettierAction/PrettierAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAK/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;I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}
@@ -0,0 +1,205 @@
1
+ import { Action } from "../../types/Action.js";
2
+ import { promises as fs } from "fs";
3
+ import path from "path";
4
+ import * as prettier from "prettier";
5
+ /**
6
+ * Action for formatting code files using Prettier.
7
+ */
8
+ export class PrettierAction extends Action {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.name = "PrettierAction";
12
+ }
13
+ describe() {
14
+ return "Format code files using Prettier";
15
+ }
16
+ validateOptions(options) {
17
+ if (!options.targetFiles || !Array.isArray(options.targetFiles) || options.targetFiles.length === 0) {
18
+ this.logError("Invalid options: 'targetFiles' must be a non-empty array.");
19
+ return false;
20
+ }
21
+ if (options.trailingComma && !["all", "es5", "none"].includes(options.trailingComma)) {
22
+ this.logError("Invalid options: 'trailingComma' must be one of: all, es5, none");
23
+ return false;
24
+ }
25
+ if (options.arrowParens && !["always", "avoid"].includes(options.arrowParens)) {
26
+ this.logError("Invalid options: 'arrowParens' must be one of: always, avoid");
27
+ return false;
28
+ }
29
+ if (options.htmlWhitespaceSensitivity && !["css", "strict", "ignore"].includes(options.htmlWhitespaceSensitivity)) {
30
+ this.logError("Invalid options: 'htmlWhitespaceSensitivity' must be one of: css, strict, ignore");
31
+ return false;
32
+ }
33
+ if (options.endOfLine && !["lf", "crlf", "cr", "auto"].includes(options.endOfLine)) {
34
+ this.logError("Invalid options: 'endOfLine' must be one of: lf, crlf, cr, auto");
35
+ return false;
36
+ }
37
+ return true;
38
+ }
39
+ async execute(options) {
40
+ if (!this.validateOptions(options)) {
41
+ throw new Error("Invalid options provided to PrettierAction");
42
+ }
43
+ const write = options.write ?? true;
44
+ const mode = write ? "formatting" : "checking";
45
+ this.logInfo(`${write ? "Formatting" : "Checking"} ${options.targetFiles.length} file pattern(s)`);
46
+ try {
47
+ // Build Prettier options
48
+ const prettierOptions = await this.buildPrettierOptions(options);
49
+ // Resolve files from patterns
50
+ const files = await this.resolveFiles(options.targetFiles);
51
+ if (files.length === 0) {
52
+ this.logWarning("No files matched the provided patterns");
53
+ return;
54
+ }
55
+ this.logInfo(`Found ${files.length} file(s) to ${mode === "formatting" ? "format" : "check"}`);
56
+ let formattedCount = 0;
57
+ let unchangedCount = 0;
58
+ const errors = [];
59
+ for (const file of files) {
60
+ try {
61
+ const result = await this.processFile(file, prettierOptions, write, options.ignoreUnknown);
62
+ if (result === "formatted") {
63
+ formattedCount++;
64
+ }
65
+ else if (result === "unchanged") {
66
+ unchangedCount++;
67
+ }
68
+ }
69
+ catch (error) {
70
+ const errorMessage = error instanceof Error ? error.message : String(error);
71
+ errors.push(`${file}: ${errorMessage}`);
72
+ }
73
+ }
74
+ // Report results
75
+ if (write) {
76
+ this.logInfo(`Formatted ${formattedCount} file(s), ${unchangedCount} file(s) unchanged`);
77
+ }
78
+ else {
79
+ if (formattedCount > 0) {
80
+ throw new Error(`${formattedCount} file(s) need formatting`);
81
+ }
82
+ this.logInfo(`All ${unchangedCount} file(s) are properly formatted`);
83
+ }
84
+ if (errors.length > 0) {
85
+ this.logWarning(`${errors.length} file(s) had errors:`);
86
+ errors.forEach(e => this.logError(e));
87
+ }
88
+ }
89
+ catch (error) {
90
+ this.logError("Prettier formatting failed.", error);
91
+ throw error;
92
+ }
93
+ }
94
+ /**
95
+ * Build Prettier options from action options and config file
96
+ */
97
+ async buildPrettierOptions(options) {
98
+ let configOptions = {};
99
+ // Load config file if specified
100
+ if (options.configPath) {
101
+ const resolvedConfig = await prettier.resolveConfig(options.configPath);
102
+ if (resolvedConfig) {
103
+ configOptions = resolvedConfig;
104
+ }
105
+ }
106
+ // Build options from action configuration (these override config file)
107
+ const actionOptions = {};
108
+ if (options.tabWidth !== undefined)
109
+ actionOptions.tabWidth = options.tabWidth;
110
+ if (options.useTabs !== undefined)
111
+ actionOptions.useTabs = options.useTabs;
112
+ if (options.semi !== undefined)
113
+ actionOptions.semi = options.semi;
114
+ if (options.singleQuote !== undefined)
115
+ actionOptions.singleQuote = options.singleQuote;
116
+ if (options.trailingComma !== undefined)
117
+ actionOptions.trailingComma = options.trailingComma;
118
+ if (options.bracketSpacing !== undefined)
119
+ actionOptions.bracketSpacing = options.bracketSpacing;
120
+ if (options.bracketSameLine !== undefined)
121
+ actionOptions.bracketSameLine = options.bracketSameLine;
122
+ if (options.arrowParens !== undefined)
123
+ actionOptions.arrowParens = options.arrowParens;
124
+ if (options.printWidth !== undefined)
125
+ actionOptions.printWidth = options.printWidth;
126
+ if (options.htmlWhitespaceSensitivity !== undefined)
127
+ actionOptions.htmlWhitespaceSensitivity = options.htmlWhitespaceSensitivity;
128
+ if (options.endOfLine !== undefined)
129
+ actionOptions.endOfLine = options.endOfLine;
130
+ if (options.parser !== undefined)
131
+ actionOptions.parser = options.parser;
132
+ return { ...configOptions, ...actionOptions };
133
+ }
134
+ /**
135
+ * Resolve file patterns to actual file paths
136
+ */
137
+ async resolveFiles(patterns) {
138
+ const files = [];
139
+ for (const pattern of patterns) {
140
+ // Check if it's a direct file path
141
+ try {
142
+ const stat = await fs.stat(pattern);
143
+ if (stat.isFile()) {
144
+ files.push(path.resolve(pattern));
145
+ }
146
+ else if (stat.isDirectory()) {
147
+ // Skip directories in this simple implementation
148
+ this.logWarning(`Skipping directory: ${pattern} (use glob patterns for directories)`);
149
+ }
150
+ }
151
+ catch {
152
+ // File doesn't exist, might be a glob pattern
153
+ // For simplicity, we'll just skip non-existent files
154
+ this.logWarning(`File not found: ${pattern}`);
155
+ }
156
+ }
157
+ return [...new Set(files)]; // Remove duplicates
158
+ }
159
+ /**
160
+ * Process a single file with Prettier
161
+ */
162
+ async processFile(filePath, prettierOptions, write, ignoreUnknown) {
163
+ const content = await fs.readFile(filePath, "utf8");
164
+ // Get file info to determine parser
165
+ const fileInfo = await prettier.getFileInfo(filePath, {
166
+ ignorePath: ".prettierignore",
167
+ });
168
+ if (fileInfo.ignored) {
169
+ this.logDebug(`Ignored: ${filePath}`);
170
+ return "skipped";
171
+ }
172
+ if (fileInfo.inferredParser === null) {
173
+ if (ignoreUnknown) {
174
+ this.logDebug(`Unknown file type, skipping: ${filePath}`);
175
+ return "skipped";
176
+ }
177
+ throw new Error(`Could not determine parser for: ${filePath}`);
178
+ }
179
+ // Merge parser into options
180
+ const options = {
181
+ ...prettierOptions,
182
+ parser: prettierOptions.parser || fileInfo.inferredParser,
183
+ filepath: filePath,
184
+ };
185
+ // Check if file is already formatted
186
+ const isFormatted = await prettier.check(content, options);
187
+ if (isFormatted) {
188
+ this.logDebug(`Already formatted: ${filePath}`);
189
+ return "unchanged";
190
+ }
191
+ if (write) {
192
+ // Format and write
193
+ const formatted = await prettier.format(content, options);
194
+ await fs.writeFile(filePath, formatted, "utf8");
195
+ this.logInfo(`Formatted: ${filePath}`);
196
+ return "formatted";
197
+ }
198
+ else {
199
+ // Check mode - file needs formatting
200
+ this.logInfo(`Needs formatting: ${filePath}`);
201
+ return "formatted"; // Count as needing format
202
+ }
203
+ }
204
+ }
205
+ //# sourceMappingURL=PrettierAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrettierAction.js","sourceRoot":"","sources":["../../../src/actions/PrettierAction/PrettierAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAwFrC;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,MAA6B;IAAjE;;QACa,SAAI,GAAG,gBAAgB,CAAC;IAoNrC,CAAC;IAlNG,QAAQ;QACJ,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED,eAAe,CAAC,OAA8B;QAC1C,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClG,IAAI,CAAC,QAAQ,CAAC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ettierAction } from "./PrettierAction.js";
2
+ export type { PrettierActionOptions } from "./PrettierAction.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/PrettierAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { PrettierAction } from "./PrettierAction.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/PrettierAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { PrettierAction } from "./actions/PrettierAction/index.js";
2
+ export { PrettierAction } from "./actions/PrettierAction/index.js";
3
+ export type { PrettierActionOptions } from "./actions/PrettierAction/index.js";
4
+ export { Action } from "./types/Action.js";
5
+ /**
6
+ * Plugin definition for kist
7
+ */
8
+ declare const _default: {
9
+ name: string;
10
+ version: string;
11
+ actions: {
12
+ PrettierAction: PrettierAction;
13
+ };
14
+ };
15
+ export default _default;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;;;;;;;;AACH,wBAME"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import { PrettierAction } from "./actions/PrettierAction/index.js";
2
+ export { PrettierAction } from "./actions/PrettierAction/index.js";
3
+ export { Action } from "./types/Action.js";
4
+ /**
5
+ * Plugin definition for kist
6
+ */
7
+ export default {
8
+ name: "@getkist/action-prettier",
9
+ version: "1.0.0",
10
+ actions: {
11
+ PrettierAction: new PrettierAction(),
12
+ },
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,eAAe;IACX,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;QACL,cAAc,EAAE,IAAI,cAAc,EAAE;KACvC;CACJ,CAAC"}
@@ -0,0 +1,93 @@
1
+ import { Action } from "../../types/Action.js";
2
+ /**
3
+ * Options for the PrettierAction
4
+ */
5
+ export interface PrettierActionOptions {
6
+ /**
7
+ * Files or glob patterns to format
8
+ */
9
+ targetFiles: string[];
10
+ /**
11
+ * Whether to write formatted files back to disk.
12
+ * If false, only checks formatting without modifying files.
13
+ */
14
+ write?: boolean;
15
+ /**
16
+ * Path to a custom Prettier config file
17
+ */
18
+ configPath?: string;
19
+ /**
20
+ * Tab width for indentation
21
+ */
22
+ tabWidth?: number;
23
+ /**
24
+ * Use tabs instead of spaces
25
+ */
26
+ useTabs?: boolean;
27
+ /**
28
+ * Print semicolons at the ends of statements
29
+ */
30
+ semi?: boolean;
31
+ /**
32
+ * Use single quotes instead of double quotes
33
+ */
34
+ singleQuote?: boolean;
35
+ /**
36
+ * Print trailing commas wherever possible
37
+ */
38
+ trailingComma?: "all" | "es5" | "none";
39
+ /**
40
+ * Print spaces between brackets in object literals
41
+ */
42
+ bracketSpacing?: boolean;
43
+ /**
44
+ * Put the closing bracket of a multi-line element on a new line
45
+ */
46
+ bracketSameLine?: boolean;
47
+ /**
48
+ * Include parentheses around a sole arrow function parameter
49
+ */
50
+ arrowParens?: "always" | "avoid";
51
+ /**
52
+ * Line width that the printer will wrap on
53
+ */
54
+ printWidth?: number;
55
+ /**
56
+ * How to handle whitespace in HTML, Vue, Angular, or JSX
57
+ */
58
+ htmlWhitespaceSensitivity?: "css" | "strict" | "ignore";
59
+ /**
60
+ * End of line style
61
+ */
62
+ endOfLine?: "lf" | "crlf" | "cr" | "auto";
63
+ /**
64
+ * Force parser to use (auto-detected by default)
65
+ */
66
+ parser?: string;
67
+ /**
68
+ * Ignore files matching patterns in .prettierignore
69
+ */
70
+ ignoreUnknown?: boolean;
71
+ }
72
+ /**
73
+ * Action for formatting code files using Prettier.
74
+ */
75
+ export declare class PrettierAction extends Action<PrettierActionOptions> {
76
+ readonly name = "PrettierAction";
77
+ describe(): string;
78
+ validateOptions(options: PrettierActionOptions): boolean;
79
+ execute(options: PrettierActionOptions): Promise<void>;
80
+ /**
81
+ * Build Prettier options from action options and config file
82
+ */
83
+ private buildPrettierOptions;
84
+ /**
85
+ * Resolve file patterns to actual file paths
86
+ */
87
+ private resolveFiles;
88
+ /**
89
+ * Process a single file with Prettier
90
+ */
91
+ private processFile;
92
+ }
93
+ //# sourceMappingURL=PrettierAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrettierAction.d.ts","sourceRoot":"","sources":["../../../../src/actions/PrettierAction/PrettierAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAK/C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAEvC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAEjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,yBAAyB,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExD;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;IAE1C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,MAAM,CAAC,qBAAqB,CAAC;IAC7D,QAAQ,CAAC,IAAI,oBAAoB;IAEjC,QAAQ,IAAI,MAAM;IAIlB,eAAe,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO;IA6BlD,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8D5D;;OAEG;YACW,oBAAoB;IA8BlC;;OAEG;YACW,YAAY;IAuB1B;;OAEG;YACW,WAAW;CAqD5B"}
@@ -0,0 +1,202 @@
1
+ import { Action } from "../../types/Action.js";
2
+ import { promises as fs } from "fs";
3
+ import path from "path";
4
+ import * as prettier from "prettier";
5
+ /**
6
+ * Action for formatting code files using Prettier.
7
+ */
8
+ export class PrettierAction extends Action {
9
+ name = "PrettierAction";
10
+ describe() {
11
+ return "Format code files using Prettier";
12
+ }
13
+ validateOptions(options) {
14
+ if (!options.targetFiles || !Array.isArray(options.targetFiles) || options.targetFiles.length === 0) {
15
+ this.logError("Invalid options: 'targetFiles' must be a non-empty array.");
16
+ return false;
17
+ }
18
+ if (options.trailingComma && !["all", "es5", "none"].includes(options.trailingComma)) {
19
+ this.logError("Invalid options: 'trailingComma' must be one of: all, es5, none");
20
+ return false;
21
+ }
22
+ if (options.arrowParens && !["always", "avoid"].includes(options.arrowParens)) {
23
+ this.logError("Invalid options: 'arrowParens' must be one of: always, avoid");
24
+ return false;
25
+ }
26
+ if (options.htmlWhitespaceSensitivity && !["css", "strict", "ignore"].includes(options.htmlWhitespaceSensitivity)) {
27
+ this.logError("Invalid options: 'htmlWhitespaceSensitivity' must be one of: css, strict, ignore");
28
+ return false;
29
+ }
30
+ if (options.endOfLine && !["lf", "crlf", "cr", "auto"].includes(options.endOfLine)) {
31
+ this.logError("Invalid options: 'endOfLine' must be one of: lf, crlf, cr, auto");
32
+ return false;
33
+ }
34
+ return true;
35
+ }
36
+ async execute(options) {
37
+ if (!this.validateOptions(options)) {
38
+ throw new Error("Invalid options provided to PrettierAction");
39
+ }
40
+ const write = options.write ?? true;
41
+ const mode = write ? "formatting" : "checking";
42
+ this.logInfo(`${write ? "Formatting" : "Checking"} ${options.targetFiles.length} file pattern(s)`);
43
+ try {
44
+ // Build Prettier options
45
+ const prettierOptions = await this.buildPrettierOptions(options);
46
+ // Resolve files from patterns
47
+ const files = await this.resolveFiles(options.targetFiles);
48
+ if (files.length === 0) {
49
+ this.logWarning("No files matched the provided patterns");
50
+ return;
51
+ }
52
+ this.logInfo(`Found ${files.length} file(s) to ${mode === "formatting" ? "format" : "check"}`);
53
+ let formattedCount = 0;
54
+ let unchangedCount = 0;
55
+ const errors = [];
56
+ for (const file of files) {
57
+ try {
58
+ const result = await this.processFile(file, prettierOptions, write, options.ignoreUnknown);
59
+ if (result === "formatted") {
60
+ formattedCount++;
61
+ }
62
+ else if (result === "unchanged") {
63
+ unchangedCount++;
64
+ }
65
+ }
66
+ catch (error) {
67
+ const errorMessage = error instanceof Error ? error.message : String(error);
68
+ errors.push(`${file}: ${errorMessage}`);
69
+ }
70
+ }
71
+ // Report results
72
+ if (write) {
73
+ this.logInfo(`Formatted ${formattedCount} file(s), ${unchangedCount} file(s) unchanged`);
74
+ }
75
+ else {
76
+ if (formattedCount > 0) {
77
+ throw new Error(`${formattedCount} file(s) need formatting`);
78
+ }
79
+ this.logInfo(`All ${unchangedCount} file(s) are properly formatted`);
80
+ }
81
+ if (errors.length > 0) {
82
+ this.logWarning(`${errors.length} file(s) had errors:`);
83
+ errors.forEach(e => this.logError(e));
84
+ }
85
+ }
86
+ catch (error) {
87
+ this.logError("Prettier formatting failed.", error);
88
+ throw error;
89
+ }
90
+ }
91
+ /**
92
+ * Build Prettier options from action options and config file
93
+ */
94
+ async buildPrettierOptions(options) {
95
+ let configOptions = {};
96
+ // Load config file if specified
97
+ if (options.configPath) {
98
+ const resolvedConfig = await prettier.resolveConfig(options.configPath);
99
+ if (resolvedConfig) {
100
+ configOptions = resolvedConfig;
101
+ }
102
+ }
103
+ // Build options from action configuration (these override config file)
104
+ const actionOptions = {};
105
+ if (options.tabWidth !== undefined)
106
+ actionOptions.tabWidth = options.tabWidth;
107
+ if (options.useTabs !== undefined)
108
+ actionOptions.useTabs = options.useTabs;
109
+ if (options.semi !== undefined)
110
+ actionOptions.semi = options.semi;
111
+ if (options.singleQuote !== undefined)
112
+ actionOptions.singleQuote = options.singleQuote;
113
+ if (options.trailingComma !== undefined)
114
+ actionOptions.trailingComma = options.trailingComma;
115
+ if (options.bracketSpacing !== undefined)
116
+ actionOptions.bracketSpacing = options.bracketSpacing;
117
+ if (options.bracketSameLine !== undefined)
118
+ actionOptions.bracketSameLine = options.bracketSameLine;
119
+ if (options.arrowParens !== undefined)
120
+ actionOptions.arrowParens = options.arrowParens;
121
+ if (options.printWidth !== undefined)
122
+ actionOptions.printWidth = options.printWidth;
123
+ if (options.htmlWhitespaceSensitivity !== undefined)
124
+ actionOptions.htmlWhitespaceSensitivity = options.htmlWhitespaceSensitivity;
125
+ if (options.endOfLine !== undefined)
126
+ actionOptions.endOfLine = options.endOfLine;
127
+ if (options.parser !== undefined)
128
+ actionOptions.parser = options.parser;
129
+ return { ...configOptions, ...actionOptions };
130
+ }
131
+ /**
132
+ * Resolve file patterns to actual file paths
133
+ */
134
+ async resolveFiles(patterns) {
135
+ const files = [];
136
+ for (const pattern of patterns) {
137
+ // Check if it's a direct file path
138
+ try {
139
+ const stat = await fs.stat(pattern);
140
+ if (stat.isFile()) {
141
+ files.push(path.resolve(pattern));
142
+ }
143
+ else if (stat.isDirectory()) {
144
+ // Skip directories in this simple implementation
145
+ this.logWarning(`Skipping directory: ${pattern} (use glob patterns for directories)`);
146
+ }
147
+ }
148
+ catch {
149
+ // File doesn't exist, might be a glob pattern
150
+ // For simplicity, we'll just skip non-existent files
151
+ this.logWarning(`File not found: ${pattern}`);
152
+ }
153
+ }
154
+ return [...new Set(files)]; // Remove duplicates
155
+ }
156
+ /**
157
+ * Process a single file with Prettier
158
+ */
159
+ async processFile(filePath, prettierOptions, write, ignoreUnknown) {
160
+ const content = await fs.readFile(filePath, "utf8");
161
+ // Get file info to determine parser
162
+ const fileInfo = await prettier.getFileInfo(filePath, {
163
+ ignorePath: ".prettierignore",
164
+ });
165
+ if (fileInfo.ignored) {
166
+ this.logDebug(`Ignored: ${filePath}`);
167
+ return "skipped";
168
+ }
169
+ if (fileInfo.inferredParser === null) {
170
+ if (ignoreUnknown) {
171
+ this.logDebug(`Unknown file type, skipping: ${filePath}`);
172
+ return "skipped";
173
+ }
174
+ throw new Error(`Could not determine parser for: ${filePath}`);
175
+ }
176
+ // Merge parser into options
177
+ const options = {
178
+ ...prettierOptions,
179
+ parser: prettierOptions.parser || fileInfo.inferredParser,
180
+ filepath: filePath,
181
+ };
182
+ // Check if file is already formatted
183
+ const isFormatted = await prettier.check(content, options);
184
+ if (isFormatted) {
185
+ this.logDebug(`Already formatted: ${filePath}`);
186
+ return "unchanged";
187
+ }
188
+ if (write) {
189
+ // Format and write
190
+ const formatted = await prettier.format(content, options);
191
+ await fs.writeFile(filePath, formatted, "utf8");
192
+ this.logInfo(`Formatted: ${filePath}`);
193
+ return "formatted";
194
+ }
195
+ else {
196
+ // Check mode - file needs formatting
197
+ this.logInfo(`Needs formatting: ${filePath}`);
198
+ return "formatted"; // Count as needing format
199
+ }
200
+ }
201
+ }
202
+ //# sourceMappingURL=PrettierAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrettierAction.js","sourceRoot":"","sources":["../../../../src/actions/PrettierAction/PrettierAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAwFrC;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,MAA6B;IACpD,IAAI,GAAG,gBAAgB,CAAC;IAEjC,QAAQ;QACJ,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED,eAAe,CAAC,OAA8B;QAC1C,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClG,IAAI,CAAC,QAAQ,CAAC,2DAA2D,CAAC,CAAC;YAC3E,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,IAAI,OAAO,CAAC,aAAa,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACnF,IAAI,CAAC,QAAQ,CAAC,iEAAiE,CAAC,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AAO,SAAS,CAAC;YACrB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,QAAQ,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,4BAA4B;QAC5B,MAAM,OAAO,GAAqB;YAC9B,GAAG,eAAe;YAClB,MAAM,EAAE,eAAe,CAAC,MAAM,IAAI,QAAQ,CAAC,cAAc;YACzD,QAAQ,EAAE,QAAQ;SACrB,CAAC;QAEF,qCAAqC;QACrC,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAE3D,IAAI,WAAW,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;YAChD,OAAO,WAAW,CAAC;QACvB,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACR,mBAAmB;YACnB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1D,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAChD,IAAI,CAAC,OAAO,CAAC,cAAc,QAAQ,EAAE,CAAC,CAAC;YACvC,OAAO,WAAW,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,qCAAqC;YACrC,IAAI,CAAC,OAAO,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;YAC9C,OAAO,WAAW,CAAC,CAAC,0BAA0B;QAClD,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ export { PrettierAction } from "./PrettierAction.js";
2
+ export type { PrettierActionOptions } from "./PrettierAction.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/PrettierAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { PrettierAction } from "./PrettierAction.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/actions/PrettierAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { PrettierAction } from "./actions/PrettierAction/index.js";
2
+ export { PrettierAction } from "./actions/PrettierAction/index.js";
3
+ export type { PrettierActionOptions } from "./actions/PrettierAction/index.js";
4
+ export { Action } from "./types/Action.js";
5
+ /**
6
+ * Plugin definition for kist
7
+ */
8
+ declare const _default: {
9
+ name: string;
10
+ version: string;
11
+ actions: {
12
+ PrettierAction: PrettierAction;
13
+ };
14
+ };
15
+ export default _default;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;;;;;;;;AACH,wBAME"}
@@ -0,0 +1,14 @@
1
+ import { PrettierAction } from "./actions/PrettierAction/index.js";
2
+ export { PrettierAction } from "./actions/PrettierAction/index.js";
3
+ export { Action } from "./types/Action.js";
4
+ /**
5
+ * Plugin definition for kist
6
+ */
7
+ export default {
8
+ name: "@getkist/action-prettier",
9
+ version: "1.0.0",
10
+ actions: {
11
+ PrettierAction: new PrettierAction(),
12
+ },
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,eAAe;IACX,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE;QACL,cAAc,EAAE,IAAI,cAAc,EAAE;KACvC;CACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Base class for kist actions.
3
+ * Provides common functionality for all action implementations.
4
+ */
5
+ export declare abstract class Action<TOptions = Record<string, unknown>> {
6
+ /**
7
+ * The unique name of this action.
8
+ */
9
+ abstract readonly name: string;
10
+ /**
11
+ * Returns a human-readable description of what this action does.
12
+ */
13
+ abstract describe(): string;
14
+ /**
15
+ * Validates the provided options before execution.
16
+ * @param options - The options to validate
17
+ * @returns true if options are valid, false otherwise
18
+ */
19
+ abstract validateOptions(options: TOptions): boolean;
20
+ /**
21
+ * Executes the action with the provided options.
22
+ * @param options - The options for this action
23
+ * @returns A promise that resolves when the action completes
24
+ */
25
+ abstract execute(options: TOptions): Promise<void>;
26
+ /**
27
+ * Logs an informational message.
28
+ * @param message - The message to log
29
+ */
30
+ protected logInfo(message: string): void;
31
+ /**
32
+ * Logs a warning message.
33
+ * @param message - The message to log
34
+ */
35
+ protected logWarning(message: string): void;
36
+ /**
37
+ * Logs an error message.
38
+ * @param message - The message to log
39
+ * @param error - Optional error object
40
+ */
41
+ protected logError(message: string, error?: unknown): void;
42
+ /**
43
+ * Logs a debug message.
44
+ * @param message - The message to log
45
+ */
46
+ protected logDebug(message: string): void;
47
+ }
48
+ //# 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;AACH,8BAAsB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,MAAM;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAEpD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAElD;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC;;;OAGG;IACH,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAI1D;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAK5C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Base class for kist actions.
3
+ * Provides common functionality for all action implementations.
4
+ */
5
+ export class Action {
6
+ /**
7
+ * Logs an informational message.
8
+ * @param message - The message to log
9
+ */
10
+ logInfo(message) {
11
+ console.log(`[${this.name}] ${message}`);
12
+ }
13
+ /**
14
+ * Logs a warning message.
15
+ * @param message - The message to log
16
+ */
17
+ logWarning(message) {
18
+ console.warn(`[${this.name}] WARNING: ${message}`);
19
+ }
20
+ /**
21
+ * Logs an error message.
22
+ * @param message - The message to log
23
+ * @param error - Optional error object
24
+ */
25
+ logError(message, error) {
26
+ console.error(`[${this.name}] ERROR: ${message}`, error || "");
27
+ }
28
+ /**
29
+ * Logs a debug message.
30
+ * @param message - The message to log
31
+ */
32
+ logDebug(message) {
33
+ if (process.env.DEBUG) {
34
+ console.debug(`[${this.name}] DEBUG: ${message}`);
35
+ }
36
+ }
37
+ }
38
+ //# sourceMappingURL=Action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../../src/types/Action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAgB,MAAM;IAyBxB;;;OAGG;IACO,OAAO,CAAC,OAAe;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACO,UAAU,CAAC,OAAe;QAChC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,cAAc,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;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;;;OAGG;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;CACJ"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Base class for kist actions.
3
+ * Provides common functionality for all action implementations.
4
+ */
5
+ export declare abstract class Action<TOptions = Record<string, unknown>> {
6
+ /**
7
+ * The unique name of this action.
8
+ */
9
+ abstract readonly name: string;
10
+ /**
11
+ * Returns a human-readable description of what this action does.
12
+ */
13
+ abstract describe(): string;
14
+ /**
15
+ * Validates the provided options before execution.
16
+ * @param options - The options to validate
17
+ * @returns true if options are valid, false otherwise
18
+ */
19
+ abstract validateOptions(options: TOptions): boolean;
20
+ /**
21
+ * Executes the action with the provided options.
22
+ * @param options - The options for this action
23
+ * @returns A promise that resolves when the action completes
24
+ */
25
+ abstract execute(options: TOptions): Promise<void>;
26
+ /**
27
+ * Logs an informational message.
28
+ * @param message - The message to log
29
+ */
30
+ protected logInfo(message: string): void;
31
+ /**
32
+ * Logs a warning message.
33
+ * @param message - The message to log
34
+ */
35
+ protected logWarning(message: string): void;
36
+ /**
37
+ * Logs an error message.
38
+ * @param message - The message to log
39
+ * @param error - Optional error object
40
+ */
41
+ protected logError(message: string, error?: unknown): void;
42
+ /**
43
+ * Logs a debug message.
44
+ * @param message - The message to log
45
+ */
46
+ protected logDebug(message: string): void;
47
+ }
48
+ //# 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;AACH,8BAAsB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,IAAI,MAAM;IAE3B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO;IAEpD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAElD;;;OAGG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIxC;;;OAGG;IACH,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAI1D;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAK5C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Base class for kist actions.
3
+ * Provides common functionality for all action implementations.
4
+ */
5
+ export class Action {
6
+ /**
7
+ * Logs an informational message.
8
+ * @param message - The message to log
9
+ */
10
+ logInfo(message) {
11
+ console.log(`[${this.name}] ${message}`);
12
+ }
13
+ /**
14
+ * Logs a warning message.
15
+ * @param message - The message to log
16
+ */
17
+ logWarning(message) {
18
+ console.warn(`[${this.name}] WARNING: ${message}`);
19
+ }
20
+ /**
21
+ * Logs an error message.
22
+ * @param message - The message to log
23
+ * @param error - Optional error object
24
+ */
25
+ logError(message, error) {
26
+ console.error(`[${this.name}] ERROR: ${message}`, error || "");
27
+ }
28
+ /**
29
+ * Logs a debug message.
30
+ * @param message - The message to log
31
+ */
32
+ logDebug(message) {
33
+ if (process.env.DEBUG) {
34
+ console.debug(`[${this.name}] DEBUG: ${message}`);
35
+ }
36
+ }
37
+ }
38
+ //# sourceMappingURL=Action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Action.js","sourceRoot":"","sources":["../../src/types/Action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAgB,MAAM;IAyBxB;;;OAGG;IACO,OAAO,CAAC,OAAe;QAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACO,UAAU,CAAC,OAAe;QAChC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,cAAc,OAAO,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;;OAIG;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;;;OAGG;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;CACJ"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@getkist/action-prettier",
3
+ "version": "1.0.1",
4
+ "description": "Prettier code formatting action for kist",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "NODE_OPTIONS='--experimental-vm-modules' jest",
11
+ "lint": "eslint src/**/*.ts",
12
+ "prepublishOnly": "npm run build && npm test"
13
+ },
14
+ "keywords": [
15
+ "kist",
16
+ "prettier",
17
+ "format",
18
+ "code-formatting",
19
+ "plugin"
20
+ ],
21
+ "author": "kist",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/getkist/kist-action-prettier.git"
26
+ },
27
+ "engines": {
28
+ "node": ">=20.0.0",
29
+ "npm": ">=10.0.0"
30
+ },
31
+ "dependencies": {
32
+ "prettier": "^3.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/jest": "^29.5.12",
36
+ "@types/node": "^20.11.0",
37
+ "eslint": "^9.0.0",
38
+ "jest": "^29.7.0",
39
+ "ts-jest": "^29.1.2",
40
+ "typescript": "^5.3.0",
41
+ "typescript-eslint": "^8.0.0"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md",
46
+ "LICENSE"
47
+ ],
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }