codify-plugin-lib 1.0.11 → 1.0.13

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.
@@ -1,5 +1,5 @@
1
1
  import { ResourceConfig, ResourceOperation } from 'codify-schemas';
2
- import { ChangeSet, ParameterChange } from './change-set';
2
+ import { ParameterChange } from './change-set';
3
3
  import { Plan } from './plan';
4
4
  export declare abstract class Resource<T extends ResourceConfig> {
5
5
  private dependencies;
@@ -11,8 +11,8 @@ export declare abstract class Resource<T extends ResourceConfig> {
11
11
  abstract validate(config: ResourceConfig): Promise<boolean>;
12
12
  abstract getCurrentConfig(): Promise<T | null>;
13
13
  abstract calculateOperation(change: ParameterChange): ResourceOperation.MODIFY | ResourceOperation.RECREATE;
14
- abstract applyCreate(changeSet: ChangeSet): Promise<void>;
15
- abstract applyModify(changeSet: ChangeSet): Promise<void>;
16
- abstract applyRecreate(changeSet: ChangeSet): Promise<void>;
17
- abstract applyDestroy(changeSet: ChangeSet): Promise<void>;
14
+ abstract applyCreate(plan: Plan): Promise<void>;
15
+ abstract applyModify(plan: Plan): Promise<void>;
16
+ abstract applyRecreate(plan: Plan): Promise<void>;
17
+ abstract applyDestroy(plan: Plan): Promise<void>;
18
18
  }
@@ -29,12 +29,11 @@ class Resource {
29
29
  if (plan.getResourceType() !== this.getTypeId()) {
30
30
  throw new Error(`Internal error: Plan set to wrong resource during apply. Expected ${this.getTypeId()} but got: ${plan.getResourceType()}`);
31
31
  }
32
- const changeSet = plan.changeSet;
33
32
  switch (plan.changeSet.operation) {
34
- case codify_schemas_1.ResourceOperation.CREATE: return this.applyCreate(changeSet);
35
- case codify_schemas_1.ResourceOperation.MODIFY: return this.applyModify(changeSet);
36
- case codify_schemas_1.ResourceOperation.RECREATE: return this.applyRecreate(changeSet);
37
- case codify_schemas_1.ResourceOperation.DESTROY: return this.applyDestroy(changeSet);
33
+ case codify_schemas_1.ResourceOperation.CREATE: return this.applyCreate(plan);
34
+ case codify_schemas_1.ResourceOperation.MODIFY: return this.applyModify(plan);
35
+ case codify_schemas_1.ResourceOperation.RECREATE: return this.applyRecreate(plan);
36
+ case codify_schemas_1.ResourceOperation.DESTROY: return this.applyDestroy(plan);
38
37
  }
39
38
  }
40
39
  }
@@ -12,6 +12,6 @@ type CodifySpawnOptions = {
12
12
  cwd?: string;
13
13
  stdioString?: boolean;
14
14
  } & SpawnOptions;
15
- export declare function codifySpawn(cmd: string, args: string[], opts?: CodifySpawnOptions, extras?: Record<any, any>): Promise<SpawnResult>;
15
+ export declare function codifySpawn(cmd: string, args?: string[], opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'>, extras?: Record<any, any>): Promise<SpawnResult>;
16
16
  export declare function isDebug(): boolean;
17
17
  export {};
@@ -13,7 +13,7 @@ var SpawnStatus;
13
13
  async function codifySpawn(cmd, args, opts, extras) {
14
14
  try {
15
15
  const stdio = isDebug() ? 'inherit' : 'pipe';
16
- const result = await (0, promise_spawn_1.default)(cmd, args, { ...opts, stdio, stdioString: true, shell: true }, extras);
16
+ const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio, stdioString: true, shell: true }, extras);
17
17
  const status = (result.code === 0 && !result.stderr)
18
18
  ? SpawnStatus.SUCCESS
19
19
  : SpawnStatus.ERROR;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -7,19 +7,19 @@ import { expect } from 'chai';
7
7
  import { Plan } from './plan';
8
8
 
9
9
  class TestResource extends Resource<TestConfig> {
10
- applyCreate(changeSet: ChangeSet): Promise<void> {
10
+ applyCreate(plan: Plan): Promise<void> {
11
11
  return Promise.resolve(undefined);
12
12
  }
13
13
 
14
- applyDestroy(changeSet: ChangeSet): Promise<void> {
14
+ applyDestroy(plan: Plan): Promise<void> {
15
15
  return Promise.resolve(undefined);
16
16
  }
17
17
 
18
- applyModify(changeSet: ChangeSet): Promise<void> {
18
+ applyModify(plan: Plan): Promise<void> {
19
19
  return Promise.resolve(undefined);
20
20
  }
21
21
 
22
- applyRecreate(changeSet: ChangeSet): Promise<void> {
22
+ applyRecreate(plan: Plan): Promise<void> {
23
23
  return Promise.resolve(undefined);
24
24
  }
25
25
 
@@ -47,12 +47,11 @@ export abstract class Resource<T extends ResourceConfig> {
47
47
  throw new Error(`Internal error: Plan set to wrong resource during apply. Expected ${this.getTypeId()} but got: ${plan.getResourceType()}`);
48
48
  }
49
49
 
50
- const changeSet = plan.changeSet;
51
50
  switch (plan.changeSet.operation) {
52
- case ResourceOperation.CREATE: return this.applyCreate(changeSet);
53
- case ResourceOperation.MODIFY: return this.applyModify(changeSet);
54
- case ResourceOperation.RECREATE: return this.applyRecreate(changeSet);
55
- case ResourceOperation.DESTROY: return this.applyDestroy(changeSet);
51
+ case ResourceOperation.CREATE: return this.applyCreate(plan);
52
+ case ResourceOperation.MODIFY: return this.applyModify(plan);
53
+ case ResourceOperation.RECREATE: return this.applyRecreate(plan);
54
+ case ResourceOperation.DESTROY: return this.applyDestroy(plan);
56
55
  }
57
56
  }
58
57
 
@@ -62,11 +61,11 @@ export abstract class Resource<T extends ResourceConfig> {
62
61
 
63
62
  abstract calculateOperation(change: ParameterChange): ResourceOperation.MODIFY | ResourceOperation.RECREATE;
64
63
 
65
- abstract applyCreate(changeSet: ChangeSet): Promise<void>;
64
+ abstract applyCreate(plan: Plan): Promise<void>;
66
65
 
67
- abstract applyModify(changeSet: ChangeSet): Promise<void>;
66
+ abstract applyModify(plan: Plan): Promise<void>;
68
67
 
69
- abstract applyRecreate(changeSet: ChangeSet): Promise<void>;
68
+ abstract applyRecreate(plan: Plan): Promise<void>;
70
69
 
71
- abstract applyDestroy(changeSet: ChangeSet): Promise<void>;
70
+ abstract applyDestroy(plan:Plan): Promise<void>;
72
71
  }
@@ -18,15 +18,15 @@ type CodifySpawnOptions = {
18
18
 
19
19
  export async function codifySpawn(
20
20
  cmd: string,
21
- args: string[],
22
- opts?: CodifySpawnOptions,
21
+ args?: string[],
22
+ opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString' | 'shell'>,
23
23
  extras?: Record<any, any>,
24
24
  ): Promise<SpawnResult> {
25
25
  try {
26
26
  const stdio = isDebug() ? 'inherit' : 'pipe';
27
27
  const result = await promiseSpawn(
28
28
  cmd,
29
- args,
29
+ args ?? [],
30
30
  { ...opts, stdio, stdioString: true, shell: true },
31
31
  extras
32
32
  );