@codifycli/plugin-core 1.1.0-beta21 → 1.1.0-beta23
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/dist/pty/index.d.ts +1 -1
- package/dist/pty/index.js +5 -2
- package/dist/pty/seqeuntial-pty.js +2 -2
- package/package.json +1 -1
- package/src/pty/index.ts +5 -2
- package/src/pty/seqeuntial-pty.ts +2 -2
package/dist/pty/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class SpawnError extends Error {
|
|
|
38
38
|
data: string;
|
|
39
39
|
cmd: string;
|
|
40
40
|
exitCode: number;
|
|
41
|
-
constructor(cmd: string, exitCode: number, data: string);
|
|
41
|
+
constructor(cmd: string, exitCode: number, data: string, logs?: string[]);
|
|
42
42
|
}
|
|
43
43
|
export interface IPty {
|
|
44
44
|
spawn(cmd: string | string[], options?: SpawnOptions): Promise<SpawnResult>;
|
package/dist/pty/index.js
CHANGED
|
@@ -8,8 +8,11 @@ export class SpawnError extends Error {
|
|
|
8
8
|
data;
|
|
9
9
|
cmd;
|
|
10
10
|
exitCode;
|
|
11
|
-
constructor(cmd, exitCode, data) {
|
|
12
|
-
|
|
11
|
+
constructor(cmd, exitCode, data, logs) {
|
|
12
|
+
const logSection = logs?.length
|
|
13
|
+
? `\nLast logs:\n${logs.join('\n')}`
|
|
14
|
+
: '';
|
|
15
|
+
super(`Spawn Error: on command "${cmd}" with exit code: ${exitCode}\nOutput:\n${data}${logSection}`);
|
|
13
16
|
this.data = data;
|
|
14
17
|
this.cmd = cmd;
|
|
15
18
|
this.exitCode = exitCode;
|
|
@@ -20,7 +20,7 @@ const validateSudoRequestResponse = ajv.compile(CommandRequestResponseDataSchema
|
|
|
20
20
|
*/
|
|
21
21
|
export class SequentialPty {
|
|
22
22
|
logBuffer = [];
|
|
23
|
-
static MAX_LOG_LINES =
|
|
23
|
+
static MAX_LOG_LINES = 30;
|
|
24
24
|
getLogs() {
|
|
25
25
|
return [...this.logBuffer];
|
|
26
26
|
}
|
|
@@ -34,7 +34,7 @@ export class SequentialPty {
|
|
|
34
34
|
async spawn(cmd, options) {
|
|
35
35
|
const spawnResult = await this.spawnSafe(cmd, options);
|
|
36
36
|
if (spawnResult.status !== 'success') {
|
|
37
|
-
throw new SpawnError(Array.isArray(cmd) ? cmd.join('\n') : cmd, spawnResult.exitCode, spawnResult.data);
|
|
37
|
+
throw new SpawnError(Array.isArray(cmd) ? cmd.join('\n') : cmd, spawnResult.exitCode, spawnResult.data, this.logBuffer);
|
|
38
38
|
}
|
|
39
39
|
return spawnResult;
|
|
40
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codifycli/plugin-core",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-beta23",
|
|
4
4
|
"description": "TypeScript library for building Codify plugins to manage system resources (applications, CLI tools, settings) through infrastructure-as-code",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
package/src/pty/index.ts
CHANGED
|
@@ -44,8 +44,11 @@ export class SpawnError extends Error {
|
|
|
44
44
|
cmd: string;
|
|
45
45
|
exitCode: number;
|
|
46
46
|
|
|
47
|
-
constructor(cmd: string, exitCode: number, data: string) {
|
|
48
|
-
|
|
47
|
+
constructor(cmd: string, exitCode: number, data: string, logs?: string[]) {
|
|
48
|
+
const logSection = logs?.length
|
|
49
|
+
? `\nLast logs:\n${logs.join('\n')}`
|
|
50
|
+
: '';
|
|
51
|
+
super(`Spawn Error: on command "${cmd}" with exit code: ${exitCode}\nOutput:\n${data}${logSection}`);
|
|
49
52
|
|
|
50
53
|
this.data = data;
|
|
51
54
|
this.cmd = cmd;
|
|
@@ -29,7 +29,7 @@ const validateSudoRequestResponse = ajv.compile(CommandRequestResponseDataSchema
|
|
|
29
29
|
*/
|
|
30
30
|
export class SequentialPty implements IPty {
|
|
31
31
|
private logBuffer: string[] = [];
|
|
32
|
-
private static readonly MAX_LOG_LINES =
|
|
32
|
+
private static readonly MAX_LOG_LINES = 30;
|
|
33
33
|
|
|
34
34
|
getLogs(): string[] {
|
|
35
35
|
return [...this.logBuffer];
|
|
@@ -47,7 +47,7 @@ export class SequentialPty implements IPty {
|
|
|
47
47
|
const spawnResult = await this.spawnSafe(cmd, options);
|
|
48
48
|
|
|
49
49
|
if (spawnResult.status !== 'success') {
|
|
50
|
-
throw new SpawnError(Array.isArray(cmd) ? cmd.join('\n') : cmd, spawnResult.exitCode, spawnResult.data);
|
|
50
|
+
throw new SpawnError(Array.isArray(cmd) ? cmd.join('\n') : cmd, spawnResult.exitCode, spawnResult.data, this.logBuffer);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return spawnResult;
|