depflow 2.0.0-dev.2 → 2.0.0
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/build/cli/DepFLowCLI.js +10 -16
- package/build/cli/DepFLowCLI.js.map +1 -1
- package/build/cli/bin.js +0 -0
- package/build/config/schemas.d.ts +105 -56
- package/build/config/schemas.js +20 -20
- package/build/config/schemas.js.map +1 -1
- package/build/support/Async.d.ts +22 -0
- package/build/support/Async.js +62 -0
- package/build/support/Async.js.map +1 -0
- package/build/support/Dependency.d.ts +23 -41
- package/build/support/Dependency.js +65 -115
- package/build/support/Dependency.js.map +1 -1
- package/build/support/Git.d.ts +45 -28
- package/build/support/Git.js +81 -55
- package/build/support/Git.js.map +1 -1
- package/build/support/Task/Command.d.ts +49 -0
- package/build/support/Task/Command.js +100 -0
- package/build/support/Task/Command.js.map +1 -0
- package/build/support/Task/Task.d.ts +84 -0
- package/build/support/Task/Task.js +145 -0
- package/build/support/Task/Task.js.map +1 -0
- package/package.json +4 -4
- package/build/support/File.d.ts +0 -80
- package/build/support/File.js +0 -123
- package/build/support/File.js.map +0 -1
- package/build/support/PathFixer.d.ts +0 -36
- package/build/support/PathFixer.js +0 -161
- package/build/support/PathFixer.js.map +0 -1
- package/build/support/PathResolver.d.ts +0 -100
- package/build/support/PathResolver.js +0 -280
- package/build/support/PathResolver.js.map +0 -1
- package/build/support/Resolver/AliasCompiler.d.ts +0 -18
- package/build/support/Resolver/AliasCompiler.js +0 -32
- package/build/support/Resolver/AliasCompiler.js.map +0 -1
- package/build/support/Resolver/PathResolver.d.ts +0 -25
- package/build/support/Resolver/PathResolver.js +0 -79
- package/build/support/Resolver/PathResolver.js.map +0 -1
- package/build/support/Resolver/PathRewriter.d.ts +0 -10
- package/build/support/Resolver/PathRewriter.js +0 -39
- package/build/support/Resolver/PathRewriter.js.map +0 -1
- package/build/support/Resolver/Utils.d.ts +0 -36
- package/build/support/Resolver/Utils.js +0 -45
- package/build/support/Resolver/Utils.js.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export class Async {
|
|
2
|
+
static async delay(ms) {
|
|
3
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Asynchronously waits for a specific event to occur by executing the provided executor function.
|
|
7
|
+
* The executor function is expected to call a done callback when the event occurs, passing any relevant result.
|
|
8
|
+
* The method also supports an optional timeout parameter, which will reject the promise if the event does not occur within the specified time frame.
|
|
9
|
+
*
|
|
10
|
+
* @param executor - A function that executes the logic to wait for the event and calls the done callback when the event occurs.
|
|
11
|
+
* @param timeout - An optional timeout in milliseconds after which the promise will be rejected if the event has not occurred (default is -1, meaning no timeout).
|
|
12
|
+
* @returns A promise that resolves with the result passed to the done callback when the event occurs, or rejects if an error occurs or if the timeout is reached.
|
|
13
|
+
*/
|
|
14
|
+
static async awaitEvent(executor, timeout = -1) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
let timer = null;
|
|
17
|
+
let isSettled = false;
|
|
18
|
+
let cleanupHandler;
|
|
19
|
+
const cleanup = () => {
|
|
20
|
+
isSettled = true;
|
|
21
|
+
if (!timer)
|
|
22
|
+
return;
|
|
23
|
+
clearTimeout(timer);
|
|
24
|
+
timer = null;
|
|
25
|
+
if (typeof cleanupHandler === 'function') {
|
|
26
|
+
cleanupHandler();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const safeResolve = (result) => {
|
|
30
|
+
if (isSettled)
|
|
31
|
+
return;
|
|
32
|
+
cleanup();
|
|
33
|
+
resolve(result);
|
|
34
|
+
};
|
|
35
|
+
const safeReject = (err) => {
|
|
36
|
+
if (isSettled)
|
|
37
|
+
return;
|
|
38
|
+
cleanup();
|
|
39
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
40
|
+
};
|
|
41
|
+
if (timeout > 0) {
|
|
42
|
+
timer = setTimeout(() => {
|
|
43
|
+
safeReject(new Error(`Async event timed out after ${timeout}ms`));
|
|
44
|
+
}, timeout);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const result = executor(safeResolve, safeReject);
|
|
48
|
+
if (result instanceof Promise) {
|
|
49
|
+
result.then(h => { cleanupHandler = h; }).catch(safeReject);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
cleanupHandler = result;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
safeReject(error);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export default Async;
|
|
62
|
+
//# sourceMappingURL=Async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Async.js","sourceRoot":"","sources":["../../src/support/Async.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,KAAK;IACP,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAU;QAChC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAC1B,QAAkC,EAClC,UAAkB,CAAC,CAAC;QAEpB,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,IAAI,KAAK,GAA0B,IAAI,CAAC;YACxC,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAI,cAA6C,CAAC;YAElD,MAAM,OAAO,GAAG,GAAG,EAAE;gBACjB,SAAS,GAAG,IAAI,CAAC;gBACjB,IAAI,CAAC,KAAK;oBAAE,OAAO;gBACnB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,KAAK,GAAG,IAAI,CAAC;gBACb,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;oBACvC,cAAc,EAAE,CAAC;gBACrB,CAAC;YACL,CAAC,CAAC;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|
|
3
3
|
import Config from "../config/Config.js";
|
|
4
4
|
export declare class Dependency implements Dependency.Dependency {
|
|
5
5
|
protected readonly config: Config.Config;
|
|
6
|
+
protected logger: Logger;
|
|
6
7
|
static include: string[];
|
|
7
8
|
readonly name: string;
|
|
8
9
|
readonly repo: Dependency.repo;
|
|
9
|
-
readonly
|
|
10
|
+
readonly tag?: string;
|
|
10
11
|
readonly builder: Dependency.Builder[];
|
|
11
12
|
readonly resolver: Dependency.Resolver[];
|
|
12
|
-
constructor(config: Config.Config, dependency: Dependency.Dependency);
|
|
13
|
+
constructor(config: Config.Config, dependency: Dependency.Dependency, logger: Logger);
|
|
13
14
|
/** Get the folder of the dependency */
|
|
14
15
|
get folder(): string;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
-
* @returns A promise that resolves to a string message indicating the result of the clone or pull operation.
|
|
20
|
-
* @throws Will throw an error if the cloning or pulling process fails.
|
|
17
|
+
* Updates the local repository of the dependency by either cloning it if it does not exist or pulling the latest changes if it already exists. It checks for the existence of the dependency's folder and performs the appropriate Git operations, providing logging throughout the process to indicate the status of the operations. This method ensures that the local copy of the dependency is up-to-date with its remote repository, allowing for a smooth installation and build process when managing dependencies in a project.
|
|
18
|
+
* @returns A promise that resolves when the update process is complete, or rejects with an error if any step of the process fails, allowing callers to handle such scenarios appropriately.
|
|
19
|
+
* @throws Will throw an error if any issues occur during the cloning or pulling process, such as problems with Git commands or file system access.
|
|
21
20
|
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Pulls the latest changes from the dependency's repository to the local file system. It uses the Git utility to perform a pull operation on the existing local repository, ensuring that it is updated with any new commits or changes from the remote repository. This method is essential for keeping the local copy of the dependency in sync with its source, allowing for seamless updates without needing to reinstall the entire dependency.
|
|
25
|
-
* @returns A promise that resolves to a string message indicating the result of the pull operation.
|
|
26
|
-
* @throws Will throw an error if the pull process fails, such as if the local repository is not properly set up or if there are conflicts that cannot be automatically resolved.
|
|
27
|
-
*/
|
|
28
|
-
pull(): Promise<string>;
|
|
21
|
+
protected update(): Promise<void>;
|
|
29
22
|
/**
|
|
30
23
|
* Installs the dependency by first cloning its repository (or pulling updates if it already exists) and then executing any build steps defined in the builder property. It manages the entire installation process, including handling the cloning/pulling of the repository and running any necessary commands to set up the dependency according to its configuration. This method ensures that the dependency is properly installed and ready for use, providing feedback on each step of the process through returned messages.
|
|
31
24
|
* @returns A promise that resolves to an array of string messages indicating the results of the cloning/pulling and building processes.
|
|
32
25
|
* @throws Will throw an error if any step of the installation process fails, such as issues with cloning, pulling, or executing build commands.
|
|
33
26
|
*/
|
|
34
|
-
install(): Promise<
|
|
27
|
+
install(): Promise<void>;
|
|
35
28
|
/**
|
|
36
29
|
* Uninstalls the dependency by removing its local folder and any additional folders specified in the builder's move steps.
|
|
37
30
|
* It checks for the existence of each folder before attempting to remove it, ensuring that it only tries to delete valid paths.
|
|
@@ -39,7 +32,7 @@ export declare class Dependency implements Dependency.Dependency {
|
|
|
39
32
|
* @return A promise that resolves to an array of string messages indicating the results of the uninstallation process, such as which folders were removed.
|
|
40
33
|
* @throws Will throw an error if any issues occur during the uninstallation process, such as problems with file system access or if the specified folders cannot be removed.
|
|
41
34
|
*/
|
|
42
|
-
uninstall(): Promise<
|
|
35
|
+
uninstall(): Promise<void>;
|
|
43
36
|
/**
|
|
44
37
|
* Builds the dependency by executing the commands specified in the builder property.
|
|
45
38
|
* It iterates through each build step, running any defined commands and handling file movements as necessary.
|
|
@@ -48,7 +41,15 @@ export declare class Dependency implements Dependency.Dependency {
|
|
|
48
41
|
* @return A promise that resolves to an array of string messages indicating the results of the build process, including any command outputs and file movements.
|
|
49
42
|
* @throws Will throw an error if any issues occur during the build process, such as command execution failures or problems with file movements.
|
|
50
43
|
*/
|
|
51
|
-
protected build(): Promise<
|
|
44
|
+
protected build(): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Runs a series of shell commands as part of the build process, using a child process to execute the commands and capturing the output for logging. It handles the execution of the commands, providing feedback on the progress and any errors that occur during the process. This method is essential for executing the necessary setup commands defined in the builder configuration, allowing for a flexible and dynamic build process that can accommodate various requirements for different dependencies.
|
|
47
|
+
* @param commands An array of strings representing the shell commands to be executed as part of the build process.
|
|
48
|
+
* @param logger An optional Logger instance for logging the output and errors from the command execution.
|
|
49
|
+
* @returns A promise that resolves when the command execution is complete, or rejects with an error if any command fails, allowing callers to handle such scenarios appropriately.
|
|
50
|
+
* @throws Will throw an error if any issues occur during the execution of the commands, such as problems with spawning the child process or if any command returns a non-zero exit code.
|
|
51
|
+
*/
|
|
52
|
+
protected runTask(commands: string[], options?: Dependency.taskOptions): Promise<void>;
|
|
52
53
|
/**
|
|
53
54
|
* Handles the file movements defined in the builder's move steps.
|
|
54
55
|
* It supports various formats for specifying destinations, including strings, arrays, and objects with keys representing source paths.
|
|
@@ -59,29 +60,6 @@ export declare class Dependency implements Dependency.Dependency {
|
|
|
59
60
|
* @throws Will throw an error if any issues occur during the file movement process, such as missing source paths or problems with file system access.
|
|
60
61
|
*/
|
|
61
62
|
protected move(move: Dependency.Builder['move']): Promise<string[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Executes a series of shell commands in a child process, capturing the output and errors for each command.
|
|
64
|
-
* It writes each command to the child process's stdin and listens for output on stdout and stderr.
|
|
65
|
-
* The method uses a marker to determine when a command has finished executing, allowing it to capture the complete output for each command before proceeding to the next one.
|
|
66
|
-
* This function is crucial for running build commands defined in the dependency's configuration, providing feedback on the execution of each command and handling any errors that may arise during the process.
|
|
67
|
-
* @param commands An array of shell commands to execute.
|
|
68
|
-
* @param shell The child process in which to execute the commands.
|
|
69
|
-
* @returns A promise that resolves to an array of string messages indicating the results of the command executions, including any output or errors captured during the process.
|
|
70
|
-
* @throws Will throw an error if any command fails to execute properly, providing details about the failed command and the associated error message.
|
|
71
|
-
*/
|
|
72
|
-
protected executeCommands(commands: string[], shell: ChildProcessWithoutNullStreams): Promise<string[]>;
|
|
73
|
-
/**
|
|
74
|
-
* Executes a single shell command in the provided child process, capturing its output and handling errors.
|
|
75
|
-
* It writes the command to the child process's stdin and listens for output on stdout and stderr.
|
|
76
|
-
* The method uses a unique marker to determine when the command has finished executing, allowing it to capture the complete output before resolving.
|
|
77
|
-
* If an error occurs during execution, it captures the error message and rejects the promise with a descriptive error.
|
|
78
|
-
* This function is essential for running individual build commands as part of the dependency installation process, providing detailed feedback on the execution of each command and ensuring that any issues are properly handled and reported.
|
|
79
|
-
* @param shell The child process in which to execute the command.
|
|
80
|
-
* @param command The shell command to execute.
|
|
81
|
-
* @returns A promise that resolves to an array of string messages indicating the result of the command execution, including any output captured during the process.
|
|
82
|
-
* @throws Will throw an error if the command fails to execute properly, providing details about the failed command and the associated error message.
|
|
83
|
-
*/
|
|
84
|
-
protected executeCommand(shell: ChildProcessWithoutNullStreams, command: string): Promise<string[]>;
|
|
85
63
|
/**
|
|
86
64
|
* Handles the file movements for a specific source and destination.
|
|
87
65
|
* It checks for the existence of the source path and creates the destination folder if it does not exist.
|
|
@@ -123,5 +101,9 @@ export declare namespace Dependency {
|
|
|
123
101
|
interface manageOptions {
|
|
124
102
|
force?: boolean;
|
|
125
103
|
}
|
|
104
|
+
interface taskOptions {
|
|
105
|
+
logger?: Logger;
|
|
106
|
+
maxTimeMs?: number;
|
|
107
|
+
}
|
|
126
108
|
}
|
|
127
109
|
export default Dependency;
|
|
@@ -4,26 +4,29 @@
|
|
|
4
4
|
* @license Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { promises as FS } from "fs";
|
|
7
|
-
import { spawn } from "child_process";
|
|
8
7
|
import { File, Path } from '@netfeez/common-node';
|
|
9
|
-
import Git from "./Git.js";
|
|
10
8
|
import Validator from "./Validator.js";
|
|
9
|
+
import Git from "./Git.js";
|
|
10
|
+
import Async from "./Async.js";
|
|
11
|
+
import Task from "./Task/Task.js";
|
|
11
12
|
export class Dependency {
|
|
12
13
|
config;
|
|
14
|
+
logger;
|
|
13
15
|
static include = ['*'];
|
|
14
16
|
name;
|
|
15
17
|
repo;
|
|
16
|
-
|
|
18
|
+
tag;
|
|
17
19
|
builder;
|
|
18
20
|
resolver;
|
|
19
|
-
constructor(config, dependency) {
|
|
21
|
+
constructor(config, dependency, logger) {
|
|
20
22
|
this.config = config;
|
|
23
|
+
this.logger = logger;
|
|
21
24
|
Validator.validateRepo(dependency.repo);
|
|
22
25
|
this.name = dependency.name;
|
|
23
26
|
this.repo = dependency.repo;
|
|
24
|
-
this.
|
|
27
|
+
this.tag = dependency.tag;
|
|
25
28
|
this.builder = dependency.builder;
|
|
26
|
-
this.resolver = dependency.resolver;
|
|
29
|
+
this.resolver = dependency.resolver || [];
|
|
27
30
|
}
|
|
28
31
|
/** Get the folder of the dependency */
|
|
29
32
|
get folder() {
|
|
@@ -32,28 +35,21 @@ export class Dependency {
|
|
|
32
35
|
return path;
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
38
|
-
* @returns A promise that resolves to a string message indicating the result of the clone or pull operation.
|
|
39
|
-
* @throws Will throw an error if the cloning or pulling process fails.
|
|
38
|
+
* Updates the local repository of the dependency by either cloning it if it does not exist or pulling the latest changes if it already exists. It checks for the existence of the dependency's folder and performs the appropriate Git operations, providing logging throughout the process to indicate the status of the operations. This method ensures that the local copy of the dependency is up-to-date with its remote repository, allowing for a smooth installation and build process when managing dependencies in a project.
|
|
39
|
+
* @returns A promise that resolves when the update process is complete, or rejects with an error if any step of the process fails, allowing callers to handle such scenarios appropriately.
|
|
40
|
+
* @throws Will throw an error if any issues occur during the cloning or pulling process, such as problems with Git commands or file system access.
|
|
40
41
|
*/
|
|
41
|
-
async
|
|
42
|
+
async update() {
|
|
42
43
|
if (await File.exists(this.folder)) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
this.logger.log(`&R[${this.name}] &GRepository already exists, pulling latest changes...`);
|
|
45
|
+
await Git.pull(this.folder, { logger: this.logger });
|
|
46
|
+
this.logger.log(`&R[${this.name}] &GPull completed successfully.`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.logger.log(`&R[${this.name}] &GCloning repository from ${this.repo}...`);
|
|
50
|
+
await Git.clone(this.repo, this.folder, { tag: this.tag, logger: this.logger });
|
|
51
|
+
this.logger.log(`&R[${this.name}] &GClone completed successfully.`);
|
|
47
52
|
}
|
|
48
|
-
return await Git.clone(this.repo, this.folder, this.branch);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Pulls the latest changes from the dependency's repository to the local file system. It uses the Git utility to perform a pull operation on the existing local repository, ensuring that it is updated with any new commits or changes from the remote repository. This method is essential for keeping the local copy of the dependency in sync with its source, allowing for seamless updates without needing to reinstall the entire dependency.
|
|
52
|
-
* @returns A promise that resolves to a string message indicating the result of the pull operation.
|
|
53
|
-
* @throws Will throw an error if the pull process fails, such as if the local repository is not properly set up or if there are conflicts that cannot be automatically resolved.
|
|
54
|
-
*/
|
|
55
|
-
async pull() {
|
|
56
|
-
return await Git.pull(this.folder, this.branch);
|
|
57
53
|
}
|
|
58
54
|
/**
|
|
59
55
|
* Installs the dependency by first cloning its repository (or pulling updates if it already exists) and then executing any build steps defined in the builder property. It manages the entire installation process, including handling the cloning/pulling of the repository and running any necessary commands to set up the dependency according to its configuration. This method ensures that the dependency is properly installed and ready for use, providing feedback on each step of the process through returned messages.
|
|
@@ -61,13 +57,9 @@ export class Dependency {
|
|
|
61
57
|
* @throws Will throw an error if any step of the installation process fails, such as issues with cloning, pulling, or executing build commands.
|
|
62
58
|
*/
|
|
63
59
|
async install() {
|
|
64
|
-
const output = [];
|
|
65
60
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const buildResult = await this.build();
|
|
69
|
-
output.push(...buildResult);
|
|
70
|
-
return output;
|
|
61
|
+
await this.update();
|
|
62
|
+
await this.build();
|
|
71
63
|
}
|
|
72
64
|
catch (error) {
|
|
73
65
|
throw error;
|
|
@@ -82,7 +74,6 @@ export class Dependency {
|
|
|
82
74
|
*/
|
|
83
75
|
async uninstall() {
|
|
84
76
|
try {
|
|
85
|
-
const output = [];
|
|
86
77
|
const moves = this.builder
|
|
87
78
|
? this.builder
|
|
88
79
|
.map(step => step.move ? Dependency.getAllOutFolders(step.move) : [])
|
|
@@ -92,10 +83,10 @@ export class Dependency {
|
|
|
92
83
|
for (const folder of folders) {
|
|
93
84
|
if (!await File.exists(folder))
|
|
94
85
|
continue;
|
|
95
|
-
|
|
86
|
+
if (this.logger)
|
|
87
|
+
this.logger.log(`&R[${this.name}] &GRemoving folder: &C4${folder}`);
|
|
96
88
|
await FS.rm(folder, { recursive: true });
|
|
97
89
|
}
|
|
98
|
-
return output;
|
|
99
90
|
}
|
|
100
91
|
catch (error) {
|
|
101
92
|
throw error;
|
|
@@ -110,33 +101,46 @@ export class Dependency {
|
|
|
110
101
|
* @throws Will throw an error if any issues occur during the build process, such as command execution failures or problems with file movements.
|
|
111
102
|
*/
|
|
112
103
|
async build() {
|
|
113
|
-
const output = [];
|
|
114
104
|
if (!this.builder || this.builder.length === 0)
|
|
115
|
-
return
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
if (step.move) {
|
|
128
|
-
const moveResults = await this.move(step.move);
|
|
129
|
-
output.push(...moveResults);
|
|
130
|
-
}
|
|
105
|
+
return true;
|
|
106
|
+
for (const step of this.builder) {
|
|
107
|
+
if (step.run) {
|
|
108
|
+
const commands = Array.isArray(step.run) ? step.run : [step.run];
|
|
109
|
+
await this.runTask(commands, {
|
|
110
|
+
logger: this.logger,
|
|
111
|
+
maxTimeMs: step.maxTimeMs
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (step.move) {
|
|
115
|
+
await this.move(step.move);
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Runs a series of shell commands as part of the build process, using a child process to execute the commands and capturing the output for logging. It handles the execution of the commands, providing feedback on the progress and any errors that occur during the process. This method is essential for executing the necessary setup commands defined in the builder configuration, allowing for a flexible and dynamic build process that can accommodate various requirements for different dependencies.
|
|
122
|
+
* @param commands An array of strings representing the shell commands to be executed as part of the build process.
|
|
123
|
+
* @param logger An optional Logger instance for logging the output and errors from the command execution.
|
|
124
|
+
* @returns A promise that resolves when the command execution is complete, or rejects with an error if any command fails, allowing callers to handle such scenarios appropriately.
|
|
125
|
+
* @throws Will throw an error if any issues occur during the execution of the commands, such as problems with spawning the child process or if any command returns a non-zero exit code.
|
|
126
|
+
*/
|
|
127
|
+
runTask(commands, options = {}) {
|
|
128
|
+
const { logger, maxTimeMs } = options;
|
|
129
|
+
return Async.awaitEvent((done, fail) => {
|
|
130
|
+
const pollito = new Task(this.folder, commands);
|
|
131
|
+
if (logger) {
|
|
132
|
+
pollito.on('line', (line) => logger.info(`&R[${this.name} Build] &G${line}`));
|
|
133
|
+
pollito.on('error', (msg, step) => logger.error(`&R[${this.name} Build] &C1[Step ${step}] &C7: &C1${msg}`));
|
|
134
|
+
}
|
|
135
|
+
pollito.once('finish', (data) => {
|
|
136
|
+
if (data.fails > 0)
|
|
137
|
+
fail(new Error(`Build failed with ${data.fails} failed steps.`));
|
|
138
|
+
else
|
|
139
|
+
done();
|
|
140
|
+
});
|
|
141
|
+
pollito.start().catch(fail);
|
|
142
|
+
return () => { pollito.stop(); };
|
|
143
|
+
}, maxTimeMs);
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
146
|
* Handles the file movements defined in the builder's move steps.
|
|
@@ -170,63 +174,6 @@ export class Dependency {
|
|
|
170
174
|
}
|
|
171
175
|
return output;
|
|
172
176
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Executes a series of shell commands in a child process, capturing the output and errors for each command.
|
|
175
|
-
* It writes each command to the child process's stdin and listens for output on stdout and stderr.
|
|
176
|
-
* The method uses a marker to determine when a command has finished executing, allowing it to capture the complete output for each command before proceeding to the next one.
|
|
177
|
-
* This function is crucial for running build commands defined in the dependency's configuration, providing feedback on the execution of each command and handling any errors that may arise during the process.
|
|
178
|
-
* @param commands An array of shell commands to execute.
|
|
179
|
-
* @param shell The child process in which to execute the commands.
|
|
180
|
-
* @returns A promise that resolves to an array of string messages indicating the results of the command executions, including any output or errors captured during the process.
|
|
181
|
-
* @throws Will throw an error if any command fails to execute properly, providing details about the failed command and the associated error message.
|
|
182
|
-
*/
|
|
183
|
-
async executeCommands(commands, shell) {
|
|
184
|
-
const output = [];
|
|
185
|
-
shell.stderr.on('data', data => output.push(data.toString()));
|
|
186
|
-
for (const command of commands) {
|
|
187
|
-
const result = await this.executeCommand(shell, command);
|
|
188
|
-
output.push(...result);
|
|
189
|
-
}
|
|
190
|
-
shell.kill();
|
|
191
|
-
return output;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Executes a single shell command in the provided child process, capturing its output and handling errors.
|
|
195
|
-
* It writes the command to the child process's stdin and listens for output on stdout and stderr.
|
|
196
|
-
* The method uses a unique marker to determine when the command has finished executing, allowing it to capture the complete output before resolving.
|
|
197
|
-
* If an error occurs during execution, it captures the error message and rejects the promise with a descriptive error.
|
|
198
|
-
* This function is essential for running individual build commands as part of the dependency installation process, providing detailed feedback on the execution of each command and ensuring that any issues are properly handled and reported.
|
|
199
|
-
* @param shell The child process in which to execute the command.
|
|
200
|
-
* @param command The shell command to execute.
|
|
201
|
-
* @returns A promise that resolves to an array of string messages indicating the result of the command execution, including any output captured during the process.
|
|
202
|
-
* @throws Will throw an error if the command fails to execute properly, providing details about the failed command and the associated error message.
|
|
203
|
-
*/
|
|
204
|
-
async executeCommand(shell, command) {
|
|
205
|
-
const output = [];
|
|
206
|
-
output.push(`&RRunning command &C4${command}`);
|
|
207
|
-
await new Promise((resolve, reject) => {
|
|
208
|
-
shell.stdin.write(command + '\n');
|
|
209
|
-
const marker = `__END_${Date.now()}__`;
|
|
210
|
-
shell.stdin.write(`echo ${marker}\n`);
|
|
211
|
-
let out = '';
|
|
212
|
-
const listener = (data) => {
|
|
213
|
-
if (data.toString().includes(marker)) {
|
|
214
|
-
shell.stdout.off('data', listener);
|
|
215
|
-
output.push(out.trim());
|
|
216
|
-
resolve();
|
|
217
|
-
}
|
|
218
|
-
else
|
|
219
|
-
out += data.toString().trim();
|
|
220
|
-
};
|
|
221
|
-
shell.stdout.on('data', listener);
|
|
222
|
-
shell.stderr.once('data', data => {
|
|
223
|
-
shell.stdout.off('data', listener);
|
|
224
|
-
output.push(data.toString().trim());
|
|
225
|
-
reject(new Error(`Command "${command}" failed with error: ${data.toString().trim()}`));
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
return output;
|
|
229
|
-
}
|
|
230
177
|
/**
|
|
231
178
|
* Handles the file movements for a specific source and destination.
|
|
232
179
|
* It checks for the existence of the source path and creates the destination folder if it does not exist.
|
|
@@ -303,5 +250,8 @@ export class Dependency {
|
|
|
303
250
|
return folders;
|
|
304
251
|
}
|
|
305
252
|
}
|
|
253
|
+
(function (Dependency) {
|
|
254
|
+
;
|
|
255
|
+
})(Dependency || (Dependency = {}));
|
|
306
256
|
export default Dependency;
|
|
307
257
|
//# sourceMappingURL=Dependency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dependency.js","sourceRoot":"","sources":["../../src/support/Dependency.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Dependency.js","sourceRoot":"","sources":["../../src/support/Dependency.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,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ACN,CAAC,EAZgB,UAAU,KAAV,UAAU,QAY1B;AAED,eAAe,UAAU,CAAC"}
|
package/build/support/Git.d.ts
CHANGED
|
@@ -1,36 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import Task from "./Task/Task.js";
|
|
2
|
+
import Logger from "@netfeez/vterm";
|
|
3
|
+
export declare class Git {
|
|
4
|
+
protected path: string;
|
|
5
|
+
protected repo: string;
|
|
6
|
+
protected logger: Logger | null;
|
|
7
|
+
protected cwd: string;
|
|
8
|
+
constructor(path: string, repo: string, options: Git.RepoOptions);
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* Clones a Git repository from the specified URL to the target path, optionally checking out a specific tag after cloning.
|
|
11
|
+
* The method constructs the necessary commands to perform the clone operation and optionally check out a specified tag, then initiates a Task to execute these commands sequentially.
|
|
12
|
+
* It listens for 'line' events to log standard output and 'error' events to log any errors that occur during command execution, including the step at which the error occurred.
|
|
13
|
+
* Once all commands have been executed,
|
|
14
|
+
* it listens for the 'finish' event to determine the overall success of the operation, logging a summary of the results and resolving or rejecting the promise accordingly based on whether any steps failed.
|
|
15
|
+
* @param repo The URL of the Git repository to clone.
|
|
16
|
+
* @param path The file system path where the repository should be cloned to.
|
|
17
|
+
* @param options An object containing optional parameters for the clone operation, including:
|
|
18
|
+
* - tag: An optional Git tag to check out after cloning the repository.
|
|
19
|
+
* - logger: An optional Logger instance for real-time logging of command output and errors.
|
|
20
|
+
* - cwd: An optional current working directory to execute the commands from, defaulting to the process's current working directory if not provided.
|
|
11
21
|
*/
|
|
12
|
-
|
|
22
|
+
static clone(repo: string, path: string, options: Git.RepoOptions): Promise<void>;
|
|
13
23
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
24
|
+
* Performs a 'git pull' operation on the specified repository path, optionally checking out a specific tag after pulling the latest changes.
|
|
25
|
+
* The method constructs the necessary commands to navigate to the repository path, execute the pull operation, and optionally check out a specified tag.
|
|
26
|
+
* It then initiates a Task to execute these commands sequentially, providing real-time logging and error handling through the provided Logger instance.
|
|
27
|
+
* The method listens for 'line' events to log standard output and 'error' events to log any errors that occur during command execution, including the step at which the error occurred.
|
|
28
|
+
* Once all commands have been executed, it listens for the 'finish' event to determine the overall success of the operation, logging a summary of the results and resolving or rejecting the promise accordingly based on whether any steps failed.
|
|
29
|
+
* @param path The file system path to the local Git repository where the pull operation should be performed.
|
|
30
|
+
* @param options An object containing optional parameters for the pull operation, including:
|
|
31
|
+
* - tag: An optional Git tag to check out after pulling the latest changes.
|
|
32
|
+
* - logger: An optional Logger instance for real-time logging of command output and errors.
|
|
33
|
+
* - cwd: An optional current working directory to execute the commands from, defaulting to the process's current working directory if not provided.
|
|
19
34
|
*/
|
|
20
|
-
static
|
|
35
|
+
static pull(path: string, options: Git.RepoOptions): Promise<void>;
|
|
21
36
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
37
|
+
* Executes a series of Git commands as a Task, providing real-time logging and error handling through the provided Logger instance.
|
|
38
|
+
* The method constructs the necessary commands based on the provided repository URL, target path, and optional tag, then initiates a Task to execute these commands sequentially.
|
|
39
|
+
* It listens for 'line' events to log standard output and 'error' events to log any errors that occur during command execution, including the step at which the error occurred.
|
|
40
|
+
* Once all commands have been executed, it listens for the 'finish' event to determine the overall success of the operation, logging a summary of the results and resolving or rejecting the promise accordingly based on whether any steps failed.
|
|
26
41
|
*/
|
|
27
|
-
static
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
protected static runTask(commands: string[], options: Git.ShellOptions): Promise<Task.FinishData>;
|
|
43
|
+
}
|
|
44
|
+
export declare namespace Git {
|
|
45
|
+
interface ShellOptions {
|
|
46
|
+
cwd?: string;
|
|
47
|
+
logger?: Logger;
|
|
48
|
+
}
|
|
49
|
+
interface RepoOptions extends ShellOptions {
|
|
50
|
+
tag?: string;
|
|
51
|
+
}
|
|
35
52
|
}
|
|
36
53
|
export default Git;
|