kist 0.1.39 → 0.1.41
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/README.md +2 -2
- package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.js +14 -2
- package/js/cli/ArgumentParser.js +1 -0
- package/js/core/config/ConfigLoader.js +33 -0
- package/js/core/config/ConfigStore.js +7 -3
- package/package.json +1 -2
- package/ts/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.ts +27 -3
- package/ts/cli/ArgumentParser.ts +2 -1
- package/ts/core/config/ConfigLoader.ts +41 -0
- package/ts/core/config/ConfigStore.ts +23 -6
- package/ts/index.ts +0 -2
- package/ts/actions/SassDocAction/SassDocAction.ts +0 -66
- package/ts/actions/SassDocAction/index.ts +0 -11
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/getkist/brand/master/src/logo/kist.png" width="20%"
|
|
2
|
+
<img src="https://raw.githubusercontent.com/getkist/brand/master/src/logo/kist.png" width="20%" alt="kist logo"></p>
|
|
3
3
|
<h1 align="center" style='border-bottom: none;'>kist</h1>
|
|
4
4
|
<h3 align="center">Package Pipeline Processor</h3>
|
|
5
5
|
|
|
@@ -286,7 +286,7 @@ Contributions are welcome! Follow these steps to contribute:
|
|
|
286
286
|
|
|
287
287
|
#### Copyright
|
|
288
288
|
|
|
289
|
-
Copyright ©
|
|
289
|
+
Copyright © 2025 [Scape Agency BV](https://www.scape.agency/ "Scape Agency website"). All Rights Reserved.
|
|
290
290
|
|
|
291
291
|
#### License
|
|
292
292
|
|
|
@@ -35,14 +35,26 @@ class TypeScriptCompilerAction extends Action_1.Action {
|
|
|
35
35
|
*/
|
|
36
36
|
execute(options) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const { tsconfigPath = "tsconfig.json" } = options;
|
|
38
|
+
// const { tsconfigPath = "tsconfig.json" } = options;
|
|
39
|
+
const { tsconfigPath = "tsconfig.json", filePaths, outputDir, compilerOptions = {}, } = options;
|
|
39
40
|
const resolvedTsconfigPath = path_1.default.resolve(tsconfigPath);
|
|
40
41
|
this.logInfo(`Compiling TypeScript using configuration: ${resolvedTsconfigPath}`);
|
|
41
42
|
try {
|
|
42
43
|
// **Properly Parse tsconfig.json**
|
|
43
44
|
const parsedConfig = this.loadAndParseTsConfig(resolvedTsconfigPath);
|
|
45
|
+
// Merge custom compiler options
|
|
46
|
+
const mergedCompilerOptions = Object.assign(Object.assign({}, parsedConfig.options), compilerOptions);
|
|
47
|
+
// Set output directory if specified
|
|
48
|
+
if (outputDir) {
|
|
49
|
+
mergedCompilerOptions.outDir = outputDir;
|
|
50
|
+
}
|
|
51
|
+
// **Create a TypeScript Program**
|
|
52
|
+
const program = typescript_1.default.createProgram(filePaths !== null && filePaths !== void 0 ? filePaths : parsedConfig.fileNames, mergedCompilerOptions);
|
|
44
53
|
// **Create a TypeScript Program**
|
|
45
|
-
const program =
|
|
54
|
+
// const program = ts.createProgram(
|
|
55
|
+
// parsedConfig.fileNames,
|
|
56
|
+
// parsedConfig.options,
|
|
57
|
+
// );
|
|
46
58
|
const emitResult = program.emit();
|
|
47
59
|
// **Collect Diagnostics**
|
|
48
60
|
const allDiagnostics = typescript_1.default
|
package/js/cli/ArgumentParser.js
CHANGED
|
@@ -24,6 +24,7 @@ class ArgumentParser extends AbstractProcess_1.AbstractProcess {
|
|
|
24
24
|
* @param args - Command-line arguments. Defaults to `process.argv.slice(2)`.
|
|
25
25
|
*/
|
|
26
26
|
constructor() {
|
|
27
|
+
// args: string[] = process.argv.slice(2)
|
|
27
28
|
super();
|
|
28
29
|
// Skip Node.js and script path
|
|
29
30
|
this.args = process.argv.slice(2);
|
|
@@ -70,11 +70,44 @@ class ConfigLoader extends AbstractProcess_1.AbstractProcess {
|
|
|
70
70
|
}
|
|
71
71
|
catch (error) {
|
|
72
72
|
this.logDebug(`File not accessible: ${resolvedPath}`);
|
|
73
|
+
// ❗ If user explicitly provided --config and it fails, stop immediately
|
|
74
|
+
if (cliPath) {
|
|
75
|
+
throw new Error(`Configuration file not found or not accessible: ${resolvedPath}`);
|
|
76
|
+
}
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
this.logWarn("No configuration file found. Proceeding with default settings.");
|
|
76
80
|
});
|
|
77
81
|
}
|
|
82
|
+
// public async initialize(): Promise<void> {
|
|
83
|
+
// const parser = new ArgumentParser();
|
|
84
|
+
// const cliFlags = parser.getAllFlags();
|
|
85
|
+
// const cliPath =
|
|
86
|
+
// typeof cliFlags.config === "string" ? cliFlags.config : undefined;
|
|
87
|
+
// const searchPaths = cliPath ? [cliPath] : this.defaultFilenames;
|
|
88
|
+
// this.logDebug(`Current working directory: ${process.cwd()}`);
|
|
89
|
+
// this.logDebug(
|
|
90
|
+
// `Searching for config file${cliPath ? ` from --config=${cliPath}` : ""}...`,
|
|
91
|
+
// );
|
|
92
|
+
// for (const fileName of searchPaths) {
|
|
93
|
+
// const resolvedPath = path.resolve(process.cwd(), fileName);
|
|
94
|
+
// this.logDebug(`Checking: ${resolvedPath}`);
|
|
95
|
+
// try {
|
|
96
|
+
// await fs.promises.access(
|
|
97
|
+
// resolvedPath,
|
|
98
|
+
// fs.constants.F_OK | fs.constants.R_OK,
|
|
99
|
+
// );
|
|
100
|
+
// this.configPath = resolvedPath;
|
|
101
|
+
// this.logDebug(`Configuration file found: ${resolvedPath}`);
|
|
102
|
+
// return;
|
|
103
|
+
// } catch (error) {
|
|
104
|
+
// this.logDebug(`File not accessible: ${resolvedPath}`);
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// this.logWarn(
|
|
108
|
+
// "No configuration file found. Proceeding with default settings.",
|
|
109
|
+
// );
|
|
110
|
+
// }
|
|
78
111
|
/**
|
|
79
112
|
* Loads and validates the configuration file.
|
|
80
113
|
*
|
|
@@ -65,7 +65,8 @@ class ConfigStore extends AbstractProcess_1.AbstractProcess {
|
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
// Ensure property exists and is an object
|
|
68
|
-
if (!Object.prototype.hasOwnProperty.call(current, k) ||
|
|
68
|
+
if (!Object.prototype.hasOwnProperty.call(current, k) ||
|
|
69
|
+
typeof current[k] !== "object") {
|
|
69
70
|
current[k] = Object.create(null); // Use a null prototype object
|
|
70
71
|
}
|
|
71
72
|
current = current[k];
|
|
@@ -118,8 +119,11 @@ class ConfigStore extends AbstractProcess_1.AbstractProcess {
|
|
|
118
119
|
this.logWarn(`Skipping unsafe key during merge: "${key}"`);
|
|
119
120
|
continue;
|
|
120
121
|
}
|
|
121
|
-
if (source[key] &&
|
|
122
|
-
|
|
122
|
+
if (source[key] &&
|
|
123
|
+
typeof source[key] === "object" &&
|
|
124
|
+
!Array.isArray(source[key])) {
|
|
125
|
+
if (!Object.prototype.hasOwnProperty.call(target, key) ||
|
|
126
|
+
typeof target[key] !== "object") {
|
|
123
127
|
target[key] = Object.create(null);
|
|
124
128
|
}
|
|
125
129
|
target[key] = this.deepMerge(target[key], source[key]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kist",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "Package Pipeline Processor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kist",
|
|
@@ -86,7 +86,6 @@
|
|
|
86
86
|
"postcss-preset-env": "^10.0.0",
|
|
87
87
|
"prettier": "^3.0.3",
|
|
88
88
|
"sass": "^1.69.7",
|
|
89
|
-
"sassdoc": "^2.7.4",
|
|
90
89
|
"semver": "^7.5.4",
|
|
91
90
|
"svg-sprite": "^2.0.2",
|
|
92
91
|
"svgo": "^3.1.0",
|
|
@@ -23,7 +23,14 @@ export class TypeScriptCompilerAction extends Action {
|
|
|
23
23
|
* @throws {Error} Throws an error if compilation fails.
|
|
24
24
|
*/
|
|
25
25
|
async execute(options: ActionOptionsType): Promise<void> {
|
|
26
|
-
const { tsconfigPath = "tsconfig.json" } = options;
|
|
26
|
+
// const { tsconfigPath = "tsconfig.json" } = options;
|
|
27
|
+
const {
|
|
28
|
+
tsconfigPath = "tsconfig.json",
|
|
29
|
+
filePaths,
|
|
30
|
+
outputDir,
|
|
31
|
+
compilerOptions = {},
|
|
32
|
+
} = options;
|
|
33
|
+
|
|
27
34
|
const resolvedTsconfigPath = path.resolve(tsconfigPath);
|
|
28
35
|
|
|
29
36
|
this.logInfo(
|
|
@@ -36,11 +43,28 @@ export class TypeScriptCompilerAction extends Action {
|
|
|
36
43
|
resolvedTsconfigPath,
|
|
37
44
|
);
|
|
38
45
|
|
|
46
|
+
// Merge custom compiler options
|
|
47
|
+
const mergedCompilerOptions = {
|
|
48
|
+
...parsedConfig.options,
|
|
49
|
+
...compilerOptions,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Set output directory if specified
|
|
53
|
+
if (outputDir) {
|
|
54
|
+
mergedCompilerOptions.outDir = outputDir;
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
// **Create a TypeScript Program**
|
|
40
58
|
const program = ts.createProgram(
|
|
41
|
-
parsedConfig.fileNames,
|
|
42
|
-
|
|
59
|
+
filePaths ?? parsedConfig.fileNames,
|
|
60
|
+
mergedCompilerOptions,
|
|
43
61
|
);
|
|
62
|
+
|
|
63
|
+
// **Create a TypeScript Program**
|
|
64
|
+
// const program = ts.createProgram(
|
|
65
|
+
// parsedConfig.fileNames,
|
|
66
|
+
// parsedConfig.options,
|
|
67
|
+
// );
|
|
44
68
|
const emitResult = program.emit();
|
|
45
69
|
|
|
46
70
|
// **Collect Diagnostics**
|
package/ts/cli/ArgumentParser.ts
CHANGED
|
@@ -38,7 +38,8 @@ export class ArgumentParser extends AbstractProcess {
|
|
|
38
38
|
*
|
|
39
39
|
* @param args - Command-line arguments. Defaults to `process.argv.slice(2)`.
|
|
40
40
|
*/
|
|
41
|
-
constructor() {
|
|
41
|
+
constructor() {
|
|
42
|
+
// args: string[] = process.argv.slice(2)
|
|
42
43
|
super();
|
|
43
44
|
// Skip Node.js and script path
|
|
44
45
|
this.args = process.argv.slice(2);
|
|
@@ -73,6 +73,13 @@ export class ConfigLoader extends AbstractProcess {
|
|
|
73
73
|
return;
|
|
74
74
|
} catch (error) {
|
|
75
75
|
this.logDebug(`File not accessible: ${resolvedPath}`);
|
|
76
|
+
|
|
77
|
+
// ❗ If user explicitly provided --config and it fails, stop immediately
|
|
78
|
+
if (cliPath) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Configuration file not found or not accessible: ${resolvedPath}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -80,6 +87,40 @@ export class ConfigLoader extends AbstractProcess {
|
|
|
80
87
|
"No configuration file found. Proceeding with default settings.",
|
|
81
88
|
);
|
|
82
89
|
}
|
|
90
|
+
// public async initialize(): Promise<void> {
|
|
91
|
+
// const parser = new ArgumentParser();
|
|
92
|
+
// const cliFlags = parser.getAllFlags();
|
|
93
|
+
// const cliPath =
|
|
94
|
+
// typeof cliFlags.config === "string" ? cliFlags.config : undefined;
|
|
95
|
+
|
|
96
|
+
// const searchPaths = cliPath ? [cliPath] : this.defaultFilenames;
|
|
97
|
+
|
|
98
|
+
// this.logDebug(`Current working directory: ${process.cwd()}`);
|
|
99
|
+
// this.logDebug(
|
|
100
|
+
// `Searching for config file${cliPath ? ` from --config=${cliPath}` : ""}...`,
|
|
101
|
+
// );
|
|
102
|
+
|
|
103
|
+
// for (const fileName of searchPaths) {
|
|
104
|
+
// const resolvedPath = path.resolve(process.cwd(), fileName);
|
|
105
|
+
// this.logDebug(`Checking: ${resolvedPath}`);
|
|
106
|
+
|
|
107
|
+
// try {
|
|
108
|
+
// await fs.promises.access(
|
|
109
|
+
// resolvedPath,
|
|
110
|
+
// fs.constants.F_OK | fs.constants.R_OK,
|
|
111
|
+
// );
|
|
112
|
+
// this.configPath = resolvedPath;
|
|
113
|
+
// this.logDebug(`Configuration file found: ${resolvedPath}`);
|
|
114
|
+
// return;
|
|
115
|
+
// } catch (error) {
|
|
116
|
+
// this.logDebug(`File not accessible: ${resolvedPath}`);
|
|
117
|
+
// }
|
|
118
|
+
// }
|
|
119
|
+
|
|
120
|
+
// this.logWarn(
|
|
121
|
+
// "No configuration file found. Proceeding with default settings.",
|
|
122
|
+
// );
|
|
123
|
+
// }
|
|
83
124
|
|
|
84
125
|
/**
|
|
85
126
|
* Loads and validates the configuration file.
|
|
@@ -80,7 +80,10 @@ export class ConfigStore extends AbstractProcess {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Ensure property exists and is an object
|
|
83
|
-
if (
|
|
83
|
+
if (
|
|
84
|
+
!Object.prototype.hasOwnProperty.call(current, k) ||
|
|
85
|
+
typeof current[k] !== "object"
|
|
86
|
+
) {
|
|
84
87
|
current[k] = Object.create(null); // Use a null prototype object
|
|
85
88
|
}
|
|
86
89
|
current = current[k];
|
|
@@ -90,12 +93,16 @@ export class ConfigStore extends AbstractProcess {
|
|
|
90
93
|
|
|
91
94
|
// Prevent prototype pollution at the final assignment
|
|
92
95
|
if (["__proto__", "constructor", "prototype"].includes(finalKey)) {
|
|
93
|
-
this.logWarn(
|
|
96
|
+
this.logWarn(
|
|
97
|
+
`Attempted prototype pollution detected: "${finalKey}"`,
|
|
98
|
+
);
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
current[finalKey] = value;
|
|
98
|
-
this.logDebug(
|
|
103
|
+
this.logDebug(
|
|
104
|
+
`Set configuration key "${key}" to: ${JSON.stringify(value)}`,
|
|
105
|
+
);
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
/**
|
|
@@ -120,7 +127,10 @@ export class ConfigStore extends AbstractProcess {
|
|
|
120
127
|
* Prints the current configuration to the console.
|
|
121
128
|
*/
|
|
122
129
|
public print(): void {
|
|
123
|
-
console.log(
|
|
130
|
+
console.log(
|
|
131
|
+
"Current Configuration:",
|
|
132
|
+
JSON.stringify(this.config, null, 2),
|
|
133
|
+
);
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
/**
|
|
@@ -142,8 +152,15 @@ export class ConfigStore extends AbstractProcess {
|
|
|
142
152
|
continue;
|
|
143
153
|
}
|
|
144
154
|
|
|
145
|
-
if (
|
|
146
|
-
|
|
155
|
+
if (
|
|
156
|
+
source[key] &&
|
|
157
|
+
typeof source[key] === "object" &&
|
|
158
|
+
!Array.isArray(source[key])
|
|
159
|
+
) {
|
|
160
|
+
if (
|
|
161
|
+
!Object.prototype.hasOwnProperty.call(target, key) ||
|
|
162
|
+
typeof target[key] !== "object"
|
|
163
|
+
) {
|
|
147
164
|
target[key] = Object.create(null);
|
|
148
165
|
}
|
|
149
166
|
target[key] = this.deepMerge(target[key], source[key]);
|
package/ts/index.ts
CHANGED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// // ============================================================================
|
|
2
|
-
// // Imports
|
|
3
|
-
// // ============================================================================
|
|
4
|
-
|
|
5
|
-
// // @ts-ignore: Implicit any type for sassdoc module
|
|
6
|
-
// import path from "path";
|
|
7
|
-
// import sassdoc from "sassdoc";
|
|
8
|
-
// import { Action } from "../../core/pipeline/Action";
|
|
9
|
-
// import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
10
|
-
|
|
11
|
-
// // ============================================================================
|
|
12
|
-
// // Classes
|
|
13
|
-
// // ============================================================================
|
|
14
|
-
|
|
15
|
-
// /**
|
|
16
|
-
// * SassDocAction generates SASS documentation using SassDoc.
|
|
17
|
-
// * This action allows specifying source directories, destination paths, and additional options.
|
|
18
|
-
// */
|
|
19
|
-
// export class SassDocAction extends Action {
|
|
20
|
-
// /**
|
|
21
|
-
// * Executes the SASS documentation generation process.
|
|
22
|
-
// *
|
|
23
|
-
// * @param options - The options specifying source directories, output path, and SassDoc configurations.
|
|
24
|
-
// * @returns A Promise that resolves when the documentation generation is completed successfully.
|
|
25
|
-
// * @throws {Error} Throws an error if the documentation process fails.
|
|
26
|
-
// */
|
|
27
|
-
// async execute(options: ActionOptionsType): Promise<void> {
|
|
28
|
-
// const {
|
|
29
|
-
// sourcePaths = ["src/styles"],
|
|
30
|
-
// outputPath = "docs/sass",
|
|
31
|
-
// sassdocOptions = {},
|
|
32
|
-
// } = options;
|
|
33
|
-
|
|
34
|
-
// if (!Array.isArray(sourcePaths) || sourcePaths.length === 0) {
|
|
35
|
-
// throw new Error("Invalid options: 'sourcePaths' must be a non-empty array.");
|
|
36
|
-
// }
|
|
37
|
-
|
|
38
|
-
// this.logInfo(`Generating SASS documentation in ${outputPath}...`);
|
|
39
|
-
|
|
40
|
-
// try {
|
|
41
|
-
// // Merge custom options with default options
|
|
42
|
-
// const config: sassdoc.Options = {
|
|
43
|
-
// dest: path.resolve(outputPath),
|
|
44
|
-
// verbose: true,
|
|
45
|
-
// ...sassdocOptions,
|
|
46
|
-
// };
|
|
47
|
-
|
|
48
|
-
// // Run SassDoc to generate documentation
|
|
49
|
-
// await sassdoc(sourcePaths, config);
|
|
50
|
-
|
|
51
|
-
// this.logInfo(`SASS documentation successfully generated at: ${config.dest}`);
|
|
52
|
-
// } catch (error) {
|
|
53
|
-
// this.logError("An error occurred while generating SASS documentation.", error);
|
|
54
|
-
// throw error;
|
|
55
|
-
// }
|
|
56
|
-
// }
|
|
57
|
-
|
|
58
|
-
// /**
|
|
59
|
-
// * Provides a description of the action.
|
|
60
|
-
// *
|
|
61
|
-
// * @returns A string description of the action.
|
|
62
|
-
// */
|
|
63
|
-
// describe(): string {
|
|
64
|
-
// return "Generates SASS documentation using SassDoc.";
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Import
|
|
3
|
-
// ============================================================================
|
|
4
|
-
|
|
5
|
-
// import { SassDocAction } from "./SassDocAction";
|
|
6
|
-
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// Export
|
|
9
|
-
// ============================================================================
|
|
10
|
-
|
|
11
|
-
// export { SassDocAction };
|