codify-plugin-lib 1.0.23 → 1.0.25
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/entities/resource.js +3 -1
- package/dist/utils/utils.d.ts +3 -1
- package/dist/utils/utils.js +8 -2
- package/package.json +1 -1
- package/src/entities/resource.ts +3 -1
- package/src/utils/utils.ts +24 -3
|
@@ -29,7 +29,9 @@ class Resource {
|
|
|
29
29
|
const resourceOperation = parameterChangeSet
|
|
30
30
|
.filter((change) => change.operation !== codify_schemas_1.ParameterOperation.NOOP)
|
|
31
31
|
.reduce((operation, curr) => {
|
|
32
|
-
const newOperation = this.
|
|
32
|
+
const newOperation = !this.statefulParameters.has(curr.name)
|
|
33
|
+
? this.calculateOperation(curr)
|
|
34
|
+
: codify_schemas_1.ResourceOperation.MODIFY;
|
|
33
35
|
return change_set_1.ChangeSet.combineResourceOperations(operation, newOperation);
|
|
34
36
|
}, codify_schemas_1.ResourceOperation.NOOP);
|
|
35
37
|
return plan_1.Plan.create(new change_set_1.ChangeSet(resourceOperation, parameterChangeSet), desiredConfig);
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ type CodifySpawnOptions = {
|
|
|
12
12
|
cwd?: string;
|
|
13
13
|
stdioString?: boolean;
|
|
14
14
|
} & SpawnOptions;
|
|
15
|
-
export declare function codifySpawn(cmd: string, args?: string[], opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'
|
|
15
|
+
export declare function codifySpawn(cmd: string, args?: string[], opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'> & {
|
|
16
|
+
throws?: boolean;
|
|
17
|
+
}, extras?: Record<any, any>): Promise<SpawnResult>;
|
|
16
18
|
export declare function isDebug(): boolean;
|
|
17
19
|
export {};
|
package/dist/utils/utils.js
CHANGED
|
@@ -25,10 +25,16 @@ async function codifySpawn(cmd, args, opts, extras) {
|
|
|
25
25
|
data: status === SpawnStatus.SUCCESS ? result.stdout : result.stderr
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
catch (
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (opts?.throws ?? true) {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
if (isDebug()) {
|
|
33
|
+
console.error(`CodifySpawn Error for command ${cmd} ${args}`, error);
|
|
34
|
+
}
|
|
29
35
|
return {
|
|
30
36
|
status: SpawnStatus.ERROR,
|
|
31
|
-
data:
|
|
37
|
+
data: error,
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
40
|
}
|
package/package.json
CHANGED
package/src/entities/resource.ts
CHANGED
|
@@ -45,7 +45,9 @@ export abstract class Resource<T extends ResourceConfig> {
|
|
|
45
45
|
const resourceOperation = parameterChangeSet
|
|
46
46
|
.filter((change) => change.operation !== ParameterOperation.NOOP)
|
|
47
47
|
.reduce((operation: ResourceOperation, curr: ParameterChange) => {
|
|
48
|
-
const newOperation = this.
|
|
48
|
+
const newOperation = !this.statefulParameters.has(curr.name)
|
|
49
|
+
? this.calculateOperation(curr)
|
|
50
|
+
: ResourceOperation.MODIFY; // All stateful parameters are modify only
|
|
49
51
|
return ChangeSet.combineResourceOperations(operation, newOperation);
|
|
50
52
|
}, ResourceOperation.NOOP);
|
|
51
53
|
|
package/src/utils/utils.ts
CHANGED
|
@@ -16,10 +16,23 @@ type CodifySpawnOptions = {
|
|
|
16
16
|
stdioString?: boolean;
|
|
17
17
|
} & SpawnOptions
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param cmd Command to run. Ex: `rm -rf`
|
|
22
|
+
* @param args Optional additional arguments to append
|
|
23
|
+
* @param opts Standard options for node spawn. Additional argument:
|
|
24
|
+
* throws determines if a shell will throw a JS error. Defaults to true
|
|
25
|
+
* @param extras From PromiseSpawn
|
|
26
|
+
*
|
|
27
|
+
* @see promiseSpawn
|
|
28
|
+
* @see spawn
|
|
29
|
+
*
|
|
30
|
+
* @returns SpawnResult { status: SUCCESS | ERROR; data: string }
|
|
31
|
+
*/
|
|
19
32
|
export async function codifySpawn(
|
|
20
33
|
cmd: string,
|
|
21
34
|
args?: string[],
|
|
22
|
-
opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'
|
|
35
|
+
opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'> & { throws?: boolean },
|
|
23
36
|
extras?: Record<any, any>,
|
|
24
37
|
): Promise<SpawnResult> {
|
|
25
38
|
try {
|
|
@@ -43,10 +56,18 @@ export async function codifySpawn(
|
|
|
43
56
|
status,
|
|
44
57
|
data: status === SpawnStatus.SUCCESS ? result.stdout : result.stderr
|
|
45
58
|
}
|
|
46
|
-
} catch (
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (opts?.throws ?? true) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isDebug()) {
|
|
65
|
+
console.error(`CodifySpawn Error for command ${cmd} ${args}`, error);
|
|
66
|
+
}
|
|
67
|
+
|
|
47
68
|
return {
|
|
48
69
|
status: SpawnStatus.ERROR,
|
|
49
|
-
data:
|
|
70
|
+
data: error as string,
|
|
50
71
|
}
|
|
51
72
|
}
|
|
52
73
|
}
|