kist 0.0.0 → 0.1.31
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 +298 -3
- package/js/actions/CoreActions.d.ts +6 -0
- package/js/actions/CoreActions.js +47 -0
- package/js/actions/DirectoryCleanAction/DirectoryCleanAction.d.ts +36 -0
- package/js/actions/DirectoryCleanAction/DirectoryCleanAction.js +123 -0
- package/js/actions/DirectoryCleanAction/index.d.ts +2 -0
- package/js/actions/DirectoryCleanAction/index.js +8 -0
- package/js/actions/DirectoryCopyAction/DirectoryCopyAction.d.ts +42 -0
- package/js/actions/DirectoryCopyAction/DirectoryCopyAction.js +118 -0
- package/js/actions/DirectoryCopyAction/index.d.ts +2 -0
- package/js/actions/DirectoryCopyAction/index.js +8 -0
- package/js/actions/DirectoryCreateAction/DirectoryCreateAction.d.ts +30 -0
- package/js/actions/DirectoryCreateAction/DirectoryCreateAction.js +85 -0
- package/js/actions/DirectoryCreateAction/index.d.ts +2 -0
- package/js/actions/DirectoryCreateAction/index.js +8 -0
- package/js/actions/DocumentationAction/DocumentationAction.d.ts +23 -0
- package/js/actions/DocumentationAction/DocumentationAction.js +88 -0
- package/js/actions/DocumentationAction/index.d.ts +2 -0
- package/js/actions/DocumentationAction/index.js +8 -0
- package/js/actions/FileCopyAction/FileCopyAction.d.ts +42 -0
- package/js/actions/FileCopyAction/FileCopyAction.js +127 -0
- package/js/actions/FileCopyAction/index.d.ts +2 -0
- package/js/actions/FileCopyAction/index.js +8 -0
- package/js/actions/FileRenameAction/FileRenameAction.d.ts +30 -0
- package/js/actions/FileRenameAction/FileRenameAction.js +84 -0
- package/js/actions/FileRenameAction/index.d.ts +2 -0
- package/js/actions/FileRenameAction/index.js +8 -0
- package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.d.ts +31 -0
- package/js/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.js +98 -0
- package/js/actions/JavaScriptMinifyAction/index.d.ts +2 -0
- package/js/actions/JavaScriptMinifyAction/index.js +8 -0
- package/js/actions/JavaScriptMinifyAction/terser.config.d.ts +27 -0
- package/js/actions/JavaScriptMinifyAction/terser.config.js +119 -0
- package/js/actions/LintAction/LintAction.d.ts +17 -0
- package/js/actions/LintAction/LintAction.js +63 -0
- package/js/actions/LintAction/index.d.ts +2 -0
- package/js/actions/LintAction/index.js +8 -0
- package/js/actions/PackageManagerAction/PackageManagerAction.d.ts +57 -0
- package/js/actions/PackageManagerAction/PackageManagerAction.js +161 -0
- package/js/actions/PackageManagerAction/index.d.ts +2 -0
- package/js/actions/PackageManagerAction/index.js +8 -0
- package/js/actions/PackageManagerAction/package.config.d.ts +16 -0
- package/js/actions/PackageManagerAction/package.config.js +91 -0
- package/js/actions/StyleProcessingAction/StyleProcessingAction.d.ts +34 -0
- package/js/actions/StyleProcessingAction/StyleProcessingAction.js +164 -0
- package/js/actions/StyleProcessingAction/index.d.ts +2 -0
- package/js/actions/StyleProcessingAction/index.js +8 -0
- package/js/actions/StyleProcessingAction/postcss.config.compressed.d.ts +10 -0
- package/js/actions/StyleProcessingAction/postcss.config.compressed.js +31 -0
- package/js/actions/StyleProcessingAction/postcss.config.expanded.d.ts +16 -0
- package/js/actions/StyleProcessingAction/postcss.config.expanded.js +45 -0
- package/js/actions/SvgPackagerAction/SvgPackagerAction.d.ts +68 -0
- package/js/actions/SvgPackagerAction/SvgPackagerAction.js +186 -0
- package/js/actions/SvgPackagerAction/index.d.ts +2 -0
- package/js/actions/SvgPackagerAction/index.js +8 -0
- package/js/actions/SvgReaderAction/SvgReaderAction.d.ts +32 -0
- package/js/actions/SvgReaderAction/SvgReaderAction.js +87 -0
- package/js/actions/SvgReaderAction/index.d.ts +2 -0
- package/js/actions/SvgReaderAction/index.js +8 -0
- package/js/actions/SvgSpriteAction/SvgSpriteAction.d.ts +37 -0
- package/js/actions/SvgSpriteAction/SvgSpriteAction.js +114 -0
- package/js/actions/SvgSpriteAction/index.d.ts +2 -0
- package/js/actions/SvgSpriteAction/index.js +8 -0
- package/js/actions/SvgSpriteAction/svgsprite.config.d.ts +3 -0
- package/js/actions/SvgSpriteAction/svgsprite.config.js +117 -0
- package/js/actions/SvgToPngAction/SvgToPngAction.d.ts +28 -0
- package/js/actions/SvgToPngAction/SvgToPngAction.js +108 -0
- package/js/actions/SvgToPngAction/index.d.ts +2 -0
- package/js/actions/SvgToPngAction/index.js +8 -0
- package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.d.ts +28 -0
- package/js/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.js +96 -0
- package/js/actions/TypeScriptCompilerAction/index.d.ts +2 -0
- package/js/actions/TypeScriptCompilerAction/index.js +8 -0
- package/js/actions/VersionWriteAction/VersionWriteAction.d.ts +45 -0
- package/js/actions/VersionWriteAction/VersionWriteAction.js +147 -0
- package/js/actions/VersionWriteAction/index.d.ts +2 -0
- package/js/actions/VersionWriteAction/index.js +8 -0
- package/js/cli/ArgumentParser.d.ts +62 -0
- package/js/cli/ArgumentParser.js +118 -0
- package/js/cli.d.ts +6 -0
- package/js/cli.js +58 -0
- package/js/core/abstract/AbstractProcess.d.ts +62 -0
- package/js/core/abstract/AbstractProcess.js +96 -0
- package/js/core/abstract/AbstractValidator.d.ts +72 -0
- package/js/core/abstract/AbstractValidator.js +128 -0
- package/js/core/config/ConfigLoader.d.ts +47 -0
- package/js/core/config/ConfigLoader.js +130 -0
- package/js/core/config/ConfigStore.d.ts +53 -0
- package/js/core/config/ConfigStore.js +136 -0
- package/js/core/config/defaultConfig.d.ts +5 -0
- package/js/core/config/defaultConfig.js +131 -0
- package/js/core/pipeline/Action.d.ts +60 -0
- package/js/core/pipeline/Action.js +77 -0
- package/js/core/pipeline/ActionRegistry.d.ts +80 -0
- package/js/core/pipeline/ActionRegistry.js +180 -0
- package/js/core/pipeline/Pipeline.d.ts +42 -0
- package/js/core/pipeline/Pipeline.js +107 -0
- package/js/core/pipeline/PipelineManager.d.ts +55 -0
- package/js/core/pipeline/PipelineManager.js +164 -0
- package/js/core/pipeline/Stage.d.ts +45 -0
- package/js/core/pipeline/Stage.js +110 -0
- package/js/core/pipeline/Step.d.ts +26 -0
- package/js/core/pipeline/Step.js +85 -0
- package/js/core/validation/OptionsValidator.d.ts +43 -0
- package/js/core/validation/OptionsValidator.js +123 -0
- package/js/index.d.ts +3 -0
- package/js/index.js +36 -0
- package/js/interface/ActionInterface.d.ts +57 -0
- package/js/interface/ActionInterface.js +5 -0
- package/js/interface/ActionPlugin.d.ts +4 -0
- package/js/interface/ActionPlugin.js +5 -0
- package/js/interface/ConfigInterface.d.ts +43 -0
- package/js/interface/ConfigInterface.js +5 -0
- package/js/interface/LiveOptionsInterface.d.ts +42 -0
- package/js/interface/LiveOptionsInterface.js +2 -0
- package/js/interface/MetadataInterface.d.ts +95 -0
- package/js/interface/MetadataInterface.js +2 -0
- package/js/interface/OptionsInterface.d.ts +45 -0
- package/js/interface/OptionsInterface.js +5 -0
- package/js/interface/PipelineOptionsInterface.d.ts +66 -0
- package/js/interface/PipelineOptionsInterface.js +5 -0
- package/js/interface/StageInterface.d.ts +79 -0
- package/js/interface/StageInterface.js +5 -0
- package/js/interface/StepInterface.d.ts +66 -0
- package/js/interface/StepInterface.js +5 -0
- package/js/interface/StepOptionsInterface.d.ts +38 -0
- package/js/interface/StepOptionsInterface.js +21 -0
- package/js/interface/index.d.ts +7 -0
- package/js/interface/index.js +3 -0
- package/js/kist.d.ts +58 -0
- package/js/kist.js +145 -0
- package/js/live/LiveServer.d.ts +95 -0
- package/js/live/LiveServer.js +233 -0
- package/js/live/LiveWatcher.d.ts +45 -0
- package/js/live/LiveWatcher.js +140 -0
- package/js/logger/Logger.d.ts +94 -0
- package/js/logger/Logger.js +151 -0
- package/js/logger/LoggerStyles.d.ts +23 -0
- package/js/logger/LoggerStyles.js +30 -0
- package/js/types/ActionOptionsType.d.ts +8 -0
- package/js/types/ActionOptionsType.js +2 -0
- package/js/types/index.d.ts +1 -0
- package/js/types/index.js +3 -0
- package/package.json +93 -7
- package/ts/actions/CoreActions.ts +64 -0
- package/ts/actions/DirectoryCleanAction/DirectoryCleanAction.ts +121 -0
- package/ts/actions/DirectoryCleanAction/index.ts +11 -0
- package/ts/actions/DirectoryCopyAction/DirectoryCopyAction.ts +118 -0
- package/ts/actions/DirectoryCopyAction/index.ts +11 -0
- package/ts/actions/DirectoryCreateAction/DirectoryCreateAction.ts +81 -0
- package/ts/actions/DirectoryCreateAction/index.ts +11 -0
- package/ts/actions/DocumentationAction/DocumentationAction.ts +100 -0
- package/ts/actions/DocumentationAction/index.ts +11 -0
- package/ts/actions/FileCopyAction/FileCopyAction.ts +125 -0
- package/ts/actions/FileCopyAction/index.ts +11 -0
- package/ts/actions/FileRenameAction/FileRenameAction.ts +82 -0
- package/ts/actions/FileRenameAction/index.ts +11 -0
- package/ts/actions/JavaScriptMinifyAction/JavaScriptMinifyAction.ts +109 -0
- package/ts/actions/JavaScriptMinifyAction/index.ts +11 -0
- package/ts/actions/JavaScriptMinifyAction/terser.config.ts +177 -0
- package/ts/actions/LintAction/LintAction.ts +67 -0
- package/ts/actions/LintAction/index.ts +11 -0
- package/ts/actions/PackageManagerAction/PackageManagerAction.ts +176 -0
- package/ts/actions/PackageManagerAction/index.ts +11 -0
- package/ts/actions/PackageManagerAction/package.config.ts +94 -0
- package/ts/actions/SassDocAction/SassDocAction.ts +66 -0
- package/ts/actions/SassDocAction/index.ts +11 -0
- package/ts/actions/StyleProcessingAction/StyleProcessingAction.ts +142 -0
- package/ts/actions/StyleProcessingAction/index.ts +11 -0
- package/ts/actions/StyleProcessingAction/postcss.config.compressed.ts +31 -0
- package/ts/actions/StyleProcessingAction/postcss.config.expanded.ts +47 -0
- package/ts/actions/SvgPackagerAction/SvgPackagerAction.ts +187 -0
- package/ts/actions/SvgPackagerAction/index.ts +11 -0
- package/ts/actions/SvgReaderAction/SvgReaderAction.ts +77 -0
- package/ts/actions/SvgReaderAction/index.ts +11 -0
- package/ts/actions/SvgSpriteAction/SvgSpriteAction.ts +127 -0
- package/ts/actions/SvgSpriteAction/index.ts +11 -0
- package/ts/actions/SvgSpriteAction/svgsprite.config.ts +123 -0
- package/ts/actions/SvgToPngAction/SvgToPngAction.ts +113 -0
- package/ts/actions/SvgToPngAction/index.ts +11 -0
- package/ts/actions/TypeScriptCompilerAction/TypeScriptCompilerAction.ts +117 -0
- package/ts/actions/TypeScriptCompilerAction/index.ts +11 -0
- package/ts/actions/VersionWriteAction/VersionWriteAction.ts +174 -0
- package/ts/actions/VersionWriteAction/index.ts +11 -0
- package/ts/actions/index.ts +0 -0
- package/ts/cli/ArgumentParser.ts +150 -0
- package/ts/cli/index.ts +1 -0
- package/ts/cli.ts +56 -0
- package/ts/core/abstract/AbstractProcess.ts +109 -0
- package/ts/core/abstract/AbstractSingleton.ts +46 -0
- package/ts/core/abstract/AbstractValidator.ts +167 -0
- package/ts/core/abstract/index.ts +0 -0
- package/ts/core/config/ConfigLoader.ts +141 -0
- package/ts/core/config/ConfigStore copy.ts +201 -0
- package/ts/core/config/ConfigStore.ts +157 -0
- package/ts/core/config/defaultConfig.ts +154 -0
- package/ts/core/config/index.ts +0 -0
- package/ts/core/index.ts +34 -0
- package/ts/core/pipeline/Action.ts +101 -0
- package/ts/core/pipeline/ActionRegistry.ts +216 -0
- package/ts/core/pipeline/Pipeline.ts +121 -0
- package/ts/core/pipeline/PipelineManager.ts +170 -0
- package/ts/core/pipeline/Stage.ts +131 -0
- package/ts/core/pipeline/Step.ts +96 -0
- package/ts/core/pipeline/index.ts +0 -0
- package/ts/core/validation/ActionValidator.ts +97 -0
- package/ts/core/validation/ConfigValidator.ts +103 -0
- package/ts/core/validation/OptionsValidator.ts +179 -0
- package/ts/core/validation/StageValidator.ts +175 -0
- package/ts/core/validation/StepValidator.ts +203 -0
- package/ts/core/validation/index.ts +0 -0
- package/ts/index.ts +26 -0
- package/ts/interface/ActionInterface.ts +70 -0
- package/ts/interface/ActionPlugin.ts +14 -0
- package/ts/interface/ConfigInterface.ts +55 -0
- package/ts/interface/File.ts +24 -0
- package/ts/interface/LiveOptionsInterface.ts +46 -0
- package/ts/interface/MetadataInterface.ts +105 -0
- package/ts/interface/OptionsInterface.ts +58 -0
- package/ts/interface/PackageJson.ts +171 -0
- package/ts/interface/PipelineOptionsInterface.ts +74 -0
- package/ts/interface/SVG.ts +84 -0
- package/ts/interface/StageInterface.ts +96 -0
- package/ts/interface/StepInterface.ts +83 -0
- package/ts/interface/StepOptionsInterface.ts +57 -0
- package/ts/interface/index.ts +9 -0
- package/ts/kist.ts +161 -0
- package/ts/live/LiveServer.ts +311 -0
- package/ts/live/LiveWatcher.ts +150 -0
- package/ts/live/index.ts +11 -0
- package/ts/logger/Logger.ts +187 -0
- package/ts/logger/LoggerStyles.ts +28 -0
- package/ts/logger/index.ts +0 -0
- package/ts/types/ActionOptionsType.ts +10 -0
- package/ts/types/index.ts +3 -0
- package/index.js +0 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { promises as fsPromises } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { Action } from "../../core/pipeline/Action";
|
|
8
|
+
import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Classes
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* DirectoryCreatorAction ensures that specified directory structures
|
|
16
|
+
* exist within a base path. It creates missing directories recursively.
|
|
17
|
+
*/
|
|
18
|
+
export class DirectoryCreateAction extends Action {
|
|
19
|
+
/**
|
|
20
|
+
* Executes the directory creation action.
|
|
21
|
+
*
|
|
22
|
+
* @param options - The options specifying the base directory and
|
|
23
|
+
* the list of directories to create.
|
|
24
|
+
* @returns A Promise that resolves when all directories are created.
|
|
25
|
+
*/
|
|
26
|
+
async execute(options: ActionOptionsType): Promise<void> {
|
|
27
|
+
const { basePath, directories } = options;
|
|
28
|
+
|
|
29
|
+
if (!basePath || !directories || !Array.isArray(directories)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Invalid options: 'basePath' (string) and 'directories' (array) are required.",
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.logInfo(
|
|
36
|
+
`Ensuring directory structure under base path: ${basePath}`,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await this.createDirectories(basePath, directories);
|
|
41
|
+
this.logInfo(
|
|
42
|
+
"All specified directories have been created successfully.",
|
|
43
|
+
);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.logError("Failed to create directories.", error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Ensures that directories exist under the specified base path.
|
|
52
|
+
*
|
|
53
|
+
* @param basePath - The base directory where subdirectories should be created.
|
|
54
|
+
* @param directories - An array of relative paths for directories to create.
|
|
55
|
+
* @returns A Promise that resolves when all directories exist.
|
|
56
|
+
*/
|
|
57
|
+
private async createDirectories(
|
|
58
|
+
basePath: string,
|
|
59
|
+
directories: string[],
|
|
60
|
+
): Promise<void> {
|
|
61
|
+
for (const dir of directories) {
|
|
62
|
+
const dirPath = path.join(basePath, dir);
|
|
63
|
+
try {
|
|
64
|
+
await fsPromises.mkdir(dirPath, { recursive: true });
|
|
65
|
+
this.logDebug(`Directory ensured: ${dirPath}`);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
this.logError(`Error creating directory: ${dirPath}`, error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Provides a description of the action.
|
|
75
|
+
*
|
|
76
|
+
* @returns A string description of the action.
|
|
77
|
+
*/
|
|
78
|
+
describe(): string {
|
|
79
|
+
return "Creates specified directory structures under a given base path.";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { DirectoryCreateAction } from "./DirectoryCreateAction";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Export
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export { DirectoryCreateAction };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Imports
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import util from "util";
|
|
8
|
+
import { Action } from "../../core/pipeline/Action";
|
|
9
|
+
import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
10
|
+
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Constants
|
|
13
|
+
// ============================================================================
|
|
14
|
+
|
|
15
|
+
const execFileAsync = util.promisify(execFile);
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Classes
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* DocumentationAction automates the generation of documentation for software
|
|
23
|
+
* projects. This action allows specifying a documentation generator, source
|
|
24
|
+
* paths, and output locations.
|
|
25
|
+
*/
|
|
26
|
+
export class DocumentationAction extends Action {
|
|
27
|
+
/**
|
|
28
|
+
* Executes the documentation generation process using the specified command-line tool.
|
|
29
|
+
*
|
|
30
|
+
* @param options - The options specifying the generator tool, source path, and output path.
|
|
31
|
+
* @returns A Promise that resolves when documentation generation completes successfully.
|
|
32
|
+
* @throws {Error} Throws an error if the documentation process fails.
|
|
33
|
+
*/
|
|
34
|
+
async execute(options: ActionOptionsType): Promise<void> {
|
|
35
|
+
const {
|
|
36
|
+
generatorCommand = "jsdoc",
|
|
37
|
+
sourcePath = "./src",
|
|
38
|
+
outputPath = "./docs",
|
|
39
|
+
configPath = "",
|
|
40
|
+
} = options;
|
|
41
|
+
|
|
42
|
+
if (!generatorCommand) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"Invalid options: 'generatorCommand' must be specified.",
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const resolvedSourcePath = path.resolve(sourcePath);
|
|
49
|
+
const resolvedOutputPath = path.resolve(outputPath);
|
|
50
|
+
const resolvedConfigPath = configPath
|
|
51
|
+
? path.resolve(configPath)
|
|
52
|
+
: null;
|
|
53
|
+
|
|
54
|
+
this.logInfo(`Generating documentation with ${generatorCommand}...`);
|
|
55
|
+
this.logDebug(`Source Path: ${resolvedSourcePath}`);
|
|
56
|
+
this.logDebug(`Output Path: ${resolvedOutputPath}`);
|
|
57
|
+
if (resolvedConfigPath)
|
|
58
|
+
this.logDebug(`Config Path: ${resolvedConfigPath}`);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
// Construct command arguments
|
|
62
|
+
const args = resolvedConfigPath
|
|
63
|
+
? ["-c", resolvedConfigPath, "-d", resolvedOutputPath]
|
|
64
|
+
: [resolvedSourcePath, "-d", resolvedOutputPath];
|
|
65
|
+
|
|
66
|
+
// Execute documentation generation command safely
|
|
67
|
+
const { stdout, stderr } = await execFileAsync(
|
|
68
|
+
generatorCommand,
|
|
69
|
+
args,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (stderr) {
|
|
73
|
+
this.logError(`Documentation generation failed: ${stderr}`);
|
|
74
|
+
throw new Error(stderr);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.logInfo(stdout);
|
|
78
|
+
this.logInfo(
|
|
79
|
+
`Documentation successfully generated at: ${resolvedOutputPath}`,
|
|
80
|
+
);
|
|
81
|
+
} catch (error: any) {
|
|
82
|
+
this.logError(
|
|
83
|
+
"Error occurred while generating documentation.",
|
|
84
|
+
error,
|
|
85
|
+
);
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Documentation generation failed: ${error.message}`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Provides a description of the action.
|
|
94
|
+
*
|
|
95
|
+
* @returns A string description of the action.
|
|
96
|
+
*/
|
|
97
|
+
describe(): string {
|
|
98
|
+
return "Generates project documentation using a specified tool (e.g., JSDoc, TypeDoc).";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { DocumentationAction } from "./DocumentationAction";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Export
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export { DocumentationAction };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { Action } from "../../core/pipeline/Action";
|
|
8
|
+
import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Classes
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* FileCopyAction is a step action responsible for copying files from a source
|
|
16
|
+
* location to a destination directory. This action handles file path
|
|
17
|
+
* resolution and ensures that existing files in the destination can be
|
|
18
|
+
* replaced if necessary.
|
|
19
|
+
*/
|
|
20
|
+
export class FileCopyAction extends Action {
|
|
21
|
+
// Parameters
|
|
22
|
+
// ========================================================================
|
|
23
|
+
|
|
24
|
+
// Constructor
|
|
25
|
+
// ========================================================================
|
|
26
|
+
|
|
27
|
+
// Methods
|
|
28
|
+
// ========================================================================
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Executes the file copy action.
|
|
32
|
+
* @param options - The options specific to file copying, including source
|
|
33
|
+
* file and destination directory.
|
|
34
|
+
* @returns A Promise that resolves when the file has been successfully
|
|
35
|
+
* copied, or rejects with an error if the action fails.
|
|
36
|
+
*/
|
|
37
|
+
async execute(options: ActionOptionsType): Promise<void> {
|
|
38
|
+
const srcFile = options.srcFile as string;
|
|
39
|
+
const destDir = options.destDir as string;
|
|
40
|
+
|
|
41
|
+
if (!srcFile || !destDir) {
|
|
42
|
+
throw new Error("Missing required options: srcFile or destDir.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.logInfo(`Copying file from ${srcFile} to ${destDir}.`);
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
await this.copyFileToDirectory(srcFile, destDir);
|
|
49
|
+
this.logInfo(
|
|
50
|
+
`File copied successfully from ${srcFile} to ${destDir}.`,
|
|
51
|
+
);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
this.logError(
|
|
54
|
+
`Error copying file from ${srcFile} to ${destDir}: ${error}`,
|
|
55
|
+
);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Copies a file from a specified source to a destination directory.
|
|
62
|
+
* Handles file path resolution and ensures the destination directory
|
|
63
|
+
* exists.
|
|
64
|
+
*
|
|
65
|
+
* @param srcFile - The path of the source file to be copied.
|
|
66
|
+
* @param destDir - The destination directory where the file should
|
|
67
|
+
* be placed.
|
|
68
|
+
* @returns A Promise that resolves when the file has been successfully
|
|
69
|
+
* copied.
|
|
70
|
+
* @throws {Error} If the file cannot be copied, including due to
|
|
71
|
+
* permission errors or the source file not existing.
|
|
72
|
+
*/
|
|
73
|
+
private async copyFileToDirectory(
|
|
74
|
+
srcFile: string,
|
|
75
|
+
destDir: string,
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
try {
|
|
78
|
+
// Ensure the destination directory exists
|
|
79
|
+
await this.ensureDirectoryExists(destDir);
|
|
80
|
+
|
|
81
|
+
// Resolve the destination file path
|
|
82
|
+
const fileName = path.basename(srcFile);
|
|
83
|
+
const destFilePath = path.join(destDir, fileName);
|
|
84
|
+
|
|
85
|
+
// Copy the file
|
|
86
|
+
await fs.promises.copyFile(srcFile, destFilePath);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
this.logError(`Error copying file: ${error}`);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Ensures that the given directory exists, creating it if it does not.
|
|
95
|
+
* @param dirPath - The path of the directory to check and create.
|
|
96
|
+
*/
|
|
97
|
+
private async ensureDirectoryExists(dirPath: string): Promise<void> {
|
|
98
|
+
try {
|
|
99
|
+
await fs.promises.mkdir(dirPath, { recursive: true });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
const nodeError = error as NodeJS.ErrnoException;
|
|
103
|
+
if (nodeError.code !== "EEXIST") {
|
|
104
|
+
throw nodeError;
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Provides a description of the action.
|
|
114
|
+
* @returns A string description of the action.
|
|
115
|
+
*/
|
|
116
|
+
describe(): string {
|
|
117
|
+
return "Copies a file from a source location to a destination directory, ensuring directories exist and handling errors gracefully.";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ============================================================================
|
|
122
|
+
// Export
|
|
123
|
+
// ============================================================================
|
|
124
|
+
|
|
125
|
+
// export default FileCopyAction;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { FileCopyAction } from "./FileCopyAction";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Export
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export { FileCopyAction };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { promises as fsPromises } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { Action } from "../../core/pipeline/Action";
|
|
8
|
+
import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Classes
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* FileRenameAction handles renaming files within the file system.
|
|
16
|
+
* Ensures that file renaming operations are handled efficiently and safely.
|
|
17
|
+
*/
|
|
18
|
+
export class FileRenameAction extends Action {
|
|
19
|
+
/**
|
|
20
|
+
* Executes the file renaming action.
|
|
21
|
+
*
|
|
22
|
+
* @param options - The options specifying the source and target file paths.
|
|
23
|
+
* @returns A Promise that resolves when the file has been successfully renamed.
|
|
24
|
+
* @throws {Error} If the source file does not exist or cannot be renamed.
|
|
25
|
+
*/
|
|
26
|
+
async execute(options: ActionOptionsType): Promise<void> {
|
|
27
|
+
const { srcPath, targetPath } = options;
|
|
28
|
+
|
|
29
|
+
if (!srcPath || !targetPath) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
"Invalid options: 'srcPath' and 'targetPath' are required.",
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.logInfo(`Renaming file: ${srcPath} → ${targetPath}`);
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await this.renameFile(srcPath, targetPath);
|
|
39
|
+
this.logInfo(`File successfully renamed to ${targetPath}`);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
this.logError("Failed to rename file.", error);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Renames a file from its current path to a new path.
|
|
48
|
+
*
|
|
49
|
+
* @param srcPath - The current file path.
|
|
50
|
+
* @param targetPath - The new file path.
|
|
51
|
+
* @returns A Promise that resolves once the file is successfully renamed.
|
|
52
|
+
*/
|
|
53
|
+
private async renameFile(
|
|
54
|
+
srcPath: string,
|
|
55
|
+
targetPath: string,
|
|
56
|
+
): Promise<void> {
|
|
57
|
+
try {
|
|
58
|
+
const resolvedSrcPath = path.resolve(srcPath);
|
|
59
|
+
const resolvedTargetPath = path.resolve(targetPath);
|
|
60
|
+
|
|
61
|
+
await fsPromises.rename(resolvedSrcPath, resolvedTargetPath);
|
|
62
|
+
this.logDebug(
|
|
63
|
+
`File renamed: ${resolvedSrcPath} → ${resolvedTargetPath}`,
|
|
64
|
+
);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
this.logError(
|
|
67
|
+
`Error renaming file: ${srcPath} → ${targetPath}`,
|
|
68
|
+
error,
|
|
69
|
+
);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Provides a description of the action.
|
|
76
|
+
*
|
|
77
|
+
* @returns A string description of the action.
|
|
78
|
+
*/
|
|
79
|
+
describe(): string {
|
|
80
|
+
return "Renames a file from a specified source path to a target path.";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { FileRenameAction } from "./FileRenameAction";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Export
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export { FileRenameAction };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { promises as fs } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { minify, MinifyOptions } from "terser";
|
|
8
|
+
import { Action } from "../../core/pipeline/Action";
|
|
9
|
+
import { ActionOptionsType } from "../../types/ActionOptionsType";
|
|
10
|
+
import terserConfig from "./terser.config.js";
|
|
11
|
+
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Classes
|
|
14
|
+
// ============================================================================
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* JavaScriptMinifyAction handles the minification of JavaScript files.
|
|
18
|
+
* Uses Terser to reduce file size and optimize performance.
|
|
19
|
+
*/
|
|
20
|
+
export class JavaScriptMinifyAction extends Action {
|
|
21
|
+
/**
|
|
22
|
+
* Executes the JavaScript minification action.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The options containing input and output file paths.
|
|
25
|
+
* @returns A Promise that resolves when the minification process completes.
|
|
26
|
+
* @throws {Error} If input file is missing, minification fails, or output cannot be written.
|
|
27
|
+
*/
|
|
28
|
+
async execute(options: ActionOptionsType): Promise<void> {
|
|
29
|
+
const { inputPath, outputPath, customConfig = {} } = options;
|
|
30
|
+
|
|
31
|
+
if (!inputPath || !outputPath) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"Invalid options: 'inputPath' and 'outputPath' are required.",
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.logInfo(
|
|
38
|
+
`Minifying JavaScript file: ${inputPath} → ${outputPath}`,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
await this.minifyFile(inputPath, outputPath, customConfig);
|
|
43
|
+
this.logInfo(`JavaScript minification completed: ${outputPath}`);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.logError("JavaScript minification failed.", error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Minifies a JavaScript file using Terser.
|
|
52
|
+
*
|
|
53
|
+
* @param inputPath - Path to the input JavaScript file.
|
|
54
|
+
* @param outputPath - Path where the minified file will be saved.
|
|
55
|
+
* @param customConfig - Custom Terser configuration.
|
|
56
|
+
* @returns A Promise that resolves when the minification is complete.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
private async minifyFile(
|
|
60
|
+
inputPath: string,
|
|
61
|
+
outputPath: string,
|
|
62
|
+
customConfig: Record<string, any>,
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
try {
|
|
65
|
+
const resolvedInputPath = path.resolve(inputPath);
|
|
66
|
+
const resolvedOutputPath = path.resolve(outputPath);
|
|
67
|
+
|
|
68
|
+
// Read JavaScript file
|
|
69
|
+
const inputCode = await fs.readFile(resolvedInputPath, "utf8");
|
|
70
|
+
|
|
71
|
+
// Merge Terser configuration with explicit type casting
|
|
72
|
+
const terserOptions: MinifyOptions = {
|
|
73
|
+
...terserConfig,
|
|
74
|
+
...customConfig,
|
|
75
|
+
ecma: terserConfig.ecma as MinifyOptions["ecma"], // Ensure ecma is correctly typed
|
|
76
|
+
nameCache: terserConfig.nameCache ?? undefined, // Ensure nameCache is undefined if null
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Minify using Terser
|
|
80
|
+
const result = await minify(inputCode, terserOptions);
|
|
81
|
+
|
|
82
|
+
if (!result.code) {
|
|
83
|
+
throw new Error("Minification resulted in empty output.");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Write minified file
|
|
87
|
+
await fs.writeFile(resolvedOutputPath, result.code, "utf8");
|
|
88
|
+
|
|
89
|
+
this.logDebug(
|
|
90
|
+
`Minified JavaScript file saved to ${resolvedOutputPath}`,
|
|
91
|
+
);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.logError(
|
|
94
|
+
`Error minifying JavaScript file: ${inputPath}`,
|
|
95
|
+
error,
|
|
96
|
+
);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Provides a description of the action.
|
|
103
|
+
*
|
|
104
|
+
* @returns A string description of the action.
|
|
105
|
+
*/
|
|
106
|
+
describe(): string {
|
|
107
|
+
return "Minifies JavaScript files using Terser to reduce size and optimize performance.";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Import
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
import { JavaScriptMinifyAction } from "./JavaScriptMinifyAction";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Export
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export { JavaScriptMinifyAction };
|