codify-plugin-lib 1.0.181 → 1.0.182-beta2

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.
Files changed (34) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/plugin/plugin.js +5 -2
  4. package/dist/pty/background-pty.js +12 -4
  5. package/dist/pty/index.d.ts +17 -1
  6. package/dist/pty/seqeuntial-pty.d.ts +16 -0
  7. package/dist/pty/seqeuntial-pty.js +84 -0
  8. package/dist/resource/parsed-resource-settings.d.ts +3 -1
  9. package/dist/resource/parsed-resource-settings.js +4 -6
  10. package/dist/resource/resource-settings.d.ts +5 -1
  11. package/dist/resource/resource-settings.js +1 -1
  12. package/dist/utils/index.d.ts +25 -0
  13. package/dist/utils/index.js +108 -0
  14. package/dist/utils/internal-utils.d.ts +18 -0
  15. package/dist/utils/internal-utils.js +86 -0
  16. package/package.json +2 -2
  17. package/src/index.ts +1 -1
  18. package/src/plan/plan.test.ts +6 -1
  19. package/src/plugin/plugin.test.ts +11 -2
  20. package/src/plugin/plugin.ts +5 -2
  21. package/src/pty/background-pty.ts +14 -4
  22. package/src/pty/index.test.ts +7 -4
  23. package/src/pty/index.ts +17 -1
  24. package/src/pty/seqeuntial-pty.ts +105 -0
  25. package/src/pty/sequential-pty.test.ts +61 -0
  26. package/src/resource/parsed-resource-settings.ts +8 -7
  27. package/src/resource/resource-controller-stateful-mode.test.ts +2 -1
  28. package/src/resource/resource-controller.test.ts +22 -4
  29. package/src/resource/resource-settings.test.ts +29 -2
  30. package/src/resource/resource-settings.ts +13 -2
  31. package/src/utils/index.ts +140 -0
  32. package/src/utils/{utils.test.ts → internal-utils.test.ts} +1 -1
  33. package/src/utils/test-utils.test.ts +5 -2
  34. /package/src/utils/{utils.ts → internal-utils.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { Plugin } from './plugin.js';
3
- import { ApplyRequestData, ParameterOperation, ResourceOperation, StringIndexedObject } from 'codify-schemas';
3
+ import { ApplyRequestData, OS, ParameterOperation, ResourceOperation, StringIndexedObject } from 'codify-schemas';
4
4
  import { Resource } from '../resource/resource.js';
5
5
  import { Plan } from '../plan/plan.js';
6
6
  import { spy } from 'sinon';
@@ -17,7 +17,8 @@ interface TestConfig extends StringIndexedObject {
17
17
  class TestResource extends Resource<TestConfig> {
18
18
  getSettings(): ResourceSettings<TestConfig> {
19
19
  return {
20
- id: 'testResource'
20
+ id: 'testResource',
21
+ operatingSystems: [OS.Darwin],
21
22
  };
22
23
  }
23
24
 
@@ -154,6 +155,7 @@ describe('Plugin tests', () => {
154
155
  getSettings(): ResourceSettings<TestConfig> {
155
156
  return {
156
157
  id: 'typeId',
158
+ operatingSystems: [OS.Darwin],
157
159
  schema,
158
160
  }
159
161
  }
@@ -192,6 +194,7 @@ describe('Plugin tests', () => {
192
194
  getSettings(): ResourceSettings<TestConfig> {
193
195
  return {
194
196
  id: 'typeId',
197
+ operatingSystems: [OS.Darwin],
195
198
  schema,
196
199
  importAndDestroy: {
197
200
  requiredParameters: []
@@ -285,6 +288,7 @@ describe('Plugin tests', () => {
285
288
  getSettings(): ResourceSettings<TestConfig> {
286
289
  return {
287
290
  id: 'type',
291
+ operatingSystems: [OS.Darwin],
288
292
  schema: {
289
293
  '$schema': 'http://json-schema.org/draft-07/schema',
290
294
  '$id': 'https://www.codifycli.com/ssh-config.json',
@@ -330,6 +334,7 @@ describe('Plugin tests', () => {
330
334
  getSettings(): ResourceSettings<TestConfig> {
331
335
  return {
332
336
  ...super.getSettings(),
337
+ operatingSystems: [OS.Darwin],
333
338
  allowMultiple: {
334
339
  identifyingParameters: ['path', 'paths']
335
340
  }
@@ -351,6 +356,7 @@ describe('Plugin tests', () => {
351
356
  getSettings(): ResourceSettings<TestConfig> {
352
357
  return {
353
358
  ...super.getSettings(),
359
+ operatingSystems: [OS.Darwin],
354
360
  parameterSettings: {
355
361
  path: { type: 'directory' },
356
362
  paths: { type: 'array', itemType: 'directory' }
@@ -407,6 +413,7 @@ describe('Plugin tests', () => {
407
413
  getSettings(): ResourceSettings<TestConfig> {
408
414
  return {
409
415
  id: 'ssh-config',
416
+ operatingSystems: [OS.Darwin],
410
417
  parameterSettings: {
411
418
  hosts: { type: 'stateful', definition: new TestStatefulParameter() }
412
419
  },
@@ -454,6 +461,7 @@ describe('Plugin tests', () => {
454
461
  getSettings(): ResourceSettings<TestConfig> {
455
462
  return {
456
463
  id: 'ssh-config',
464
+ operatingSystems: [OS.Darwin],
457
465
  allowMultiple: true
458
466
  }
459
467
  }
@@ -476,6 +484,7 @@ describe('Plugin tests', () => {
476
484
  getSettings(): ResourceSettings<TestConfig> {
477
485
  return {
478
486
  id: 'ssh-config',
487
+ operatingSystems: [OS.Darwin],
479
488
  }
480
489
  }
481
490
  })
@@ -21,10 +21,11 @@ import { ApplyValidationError } from '../common/errors.js';
21
21
  import { Plan } from '../plan/plan.js';
22
22
  import { BackgroundPty } from '../pty/background-pty.js';
23
23
  import { getPty } from '../pty/index.js';
24
+ import { SequentialPty } from '../pty/seqeuntial-pty.js';
24
25
  import { Resource } from '../resource/resource.js';
25
26
  import { ResourceController } from '../resource/resource-controller.js';
27
+ import { VerbosityLevel } from '../utils/internal-utils.js';
26
28
  import { ptyLocalStorage } from '../utils/pty-local-storage.js';
27
- import { VerbosityLevel } from '../utils/utils.js';
28
29
 
29
30
  export class Plugin {
30
31
  planStorage: Map<string, Plan<any>>;
@@ -75,6 +76,7 @@ export class Plugin {
75
76
  dependencies: r.dependencies,
76
77
  type: r.typeId,
77
78
  sensitiveParameters,
79
+ operatingSystems: r.settings.operatingSystems,
78
80
  }
79
81
  })
80
82
  }
@@ -121,6 +123,7 @@ export class Plugin {
121
123
  import: {
122
124
  requiredParameters: requiredPropertyNames,
123
125
  },
126
+ operatingSystems: resource.settings.operatingSystems,
124
127
  sensitiveParameters,
125
128
  allowMultiple
126
129
  }
@@ -232,7 +235,7 @@ export class Plugin {
232
235
  throw new Error('Malformed plan with resource that cannot be found');
233
236
  }
234
237
 
235
- await resource.apply(plan);
238
+ await ptyLocalStorage.run(new SequentialPty(), async () => resource.apply(plan))
236
239
 
237
240
  // Validate using desired/desired. If the apply was successful, no changes should be reported back.
238
241
  // Default back desired back to current if it is not defined (for destroys only)
@@ -6,7 +6,8 @@ import * as fs from 'node:fs/promises';
6
6
  import stripAnsi from 'strip-ansi';
7
7
 
8
8
  import { debugLog } from '../utils/debug.js';
9
- import { VerbosityLevel } from '../utils/utils.js';
9
+ import { Shell, Utils } from '../utils/index.js';
10
+ import { VerbosityLevel } from '../utils/internal-utils.js';
10
11
  import { IPty, SpawnError, SpawnOptions, SpawnResult } from './index.js';
11
12
  import { PromiseQueue } from './promise-queue.js';
12
13
 
@@ -128,9 +129,18 @@ export class BackgroundPty implements IPty {
128
129
 
129
130
  return new Promise(resolve => {
130
131
  // zsh-specific commands
131
- if (this.getDefaultShell() === 'zsh') {
132
- this.basePty.write('setopt hist_ignore_space;\n');
132
+ switch (Utils.getShell()) {
133
+ case Shell.ZSH: {
134
+ this.basePty.write('setopt HIST_NO_STORE;\n');
135
+ break;
136
+ }
137
+
138
+ default: {
139
+ this.basePty.write('export HISTIGNORE=\'history*\';\n');
140
+ break;
141
+ }
133
142
  }
143
+
134
144
  this.basePty.write(' unset PS1;\n');
135
145
  this.basePty.write(' unset PS0;\n')
136
146
  this.basePty.write(' echo setup complete\\"\n')
@@ -147,6 +157,6 @@ export class BackgroundPty implements IPty {
147
157
  }
148
158
 
149
159
  private getDefaultShell(): string {
150
- return process.platform === 'darwin' ? 'zsh' : 'bash';
160
+ return process.env.SHELL!;
151
161
  }
152
162
  }
@@ -3,8 +3,9 @@ import { TestConfig, TestResource } from '../utils/test-utils.test.js';
3
3
  import { getPty, IPty } from './index.js';
4
4
  import { Plugin } from '../plugin/plugin.js'
5
5
  import { CreatePlan } from '../plan/plan-types.js';
6
- import { ResourceOperation } from 'codify-schemas';
6
+ import { OS, ResourceOperation } from 'codify-schemas';
7
7
  import { ResourceSettings } from '../resource/resource-settings.js';
8
+ import { SequentialPty } from './seqeuntial-pty.js';
8
9
 
9
10
  describe('General tests for PTYs', () => {
10
11
  it('Can get pty within refresh', async () => {
@@ -45,7 +46,8 @@ describe('General tests for PTYs', () => {
45
46
  const testResource1 = new class extends TestResource {
46
47
  getSettings(): ResourceSettings<TestConfig> {
47
48
  return {
48
- id: 'type1'
49
+ id: 'type1',
50
+ operatingSystems: [OS.Darwin],
49
51
  }
50
52
  }
51
53
 
@@ -64,6 +66,7 @@ describe('General tests for PTYs', () => {
64
66
  getSettings(): ResourceSettings<TestConfig> {
65
67
  return {
66
68
  id: 'type2',
69
+ operatingSystems: [OS.Darwin],
67
70
  }
68
71
  }
69
72
 
@@ -103,11 +106,11 @@ describe('General tests for PTYs', () => {
103
106
  expect(pty1).to.eq(pty2);
104
107
  })
105
108
 
106
- it('Currently pty not available for apply', async () => {
109
+ it('Sequential pty should be available for applies', async () => {
107
110
  const testResource = new class extends TestResource {
108
111
  create(plan: CreatePlan<TestConfig>): Promise<void> {
109
112
  const $ = getPty();
110
- expect($).to.be.undefined;
113
+ expect($).to.instanceof(SequentialPty)
111
114
  }
112
115
  }
113
116
 
package/src/pty/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ptyLocalStorage } from '../utils/pty-local-storage.js';
2
2
 
3
3
  export interface SpawnResult {
4
- status: 'success' | 'error';
4
+ status: 'error' | 'success';
5
5
  exitCode: number;
6
6
  data: string;
7
7
  }
@@ -11,9 +11,25 @@ export enum SpawnStatus {
11
11
  ERROR = 'error',
12
12
  }
13
13
 
14
+ /**
15
+ * Represents the configuration options for spawning a child process.
16
+ *
17
+ * @interface SpawnOptions
18
+ *
19
+ * @property {string} [cwd] - Specifies the working directory of the child process.
20
+ * If not provided, the current working directory of the parent process is used.
21
+ *
22
+ * @property {Record<string, unknown>} [env] - Defines environment key-value pairs
23
+ * that will be available to the child process. If not specified, the child process
24
+ * will inherit the environment variables of the parent process.
25
+ *
26
+ * @property {boolean} [interactive] - Indicates whether the spawned process needs
27
+ * to be interactive. Only works within apply (not plan). Defaults to true.
28
+ */
14
29
  export interface SpawnOptions {
15
30
  cwd?: string;
16
31
  env?: Record<string, unknown>,
32
+ interactive?: boolean,
17
33
  }
18
34
 
19
35
  export class SpawnError extends Error {
@@ -0,0 +1,105 @@
1
+ import pty from '@homebridge/node-pty-prebuilt-multiarch';
2
+ import { EventEmitter } from 'node:events';
3
+ import stripAnsi from 'strip-ansi';
4
+
5
+ import { Shell, Utils } from '../utils/index.js';
6
+ import { VerbosityLevel } from '../utils/internal-utils.js';
7
+ import { IPty, SpawnError, SpawnOptions, SpawnResult, SpawnStatus } from './index.js';
8
+
9
+ EventEmitter.defaultMaxListeners = 1000;
10
+
11
+ /**
12
+ * The background pty is a specialized pty designed for speed. It can launch multiple tasks
13
+ * in parallel by moving them to the background. It attaches unix FIFO pipes to each process
14
+ * to listen to stdout and stderr. One limitation of the BackgroundPty is that the tasks run
15
+ * without a tty (or even a stdin) attached so interactive commands will not work.
16
+ */
17
+ export class SequentialPty implements IPty {
18
+ async spawn(cmd: string, options?: SpawnOptions): Promise<SpawnResult> {
19
+ const spawnResult = await this.spawnSafe(cmd, options);
20
+
21
+ if (spawnResult.status !== 'success') {
22
+ throw new SpawnError(cmd, spawnResult.exitCode, spawnResult.data);
23
+ }
24
+
25
+ return spawnResult;
26
+ }
27
+
28
+ async spawnSafe(cmd: string, options?: SpawnOptions): Promise<SpawnResult> {
29
+ console.log(`Running command: ${cmd}` + (options?.cwd ? `(${options?.cwd})` : ''))
30
+
31
+ return new Promise((resolve) => {
32
+ const output: string[] = [];
33
+
34
+ const historyIgnore = Utils.getShell() === Shell.ZSH ? { HISTORY_IGNORE: '*' } : { HISTIGNORE: '*' };
35
+
36
+ // If TERM_PROGRAM=Apple_Terminal is set then ANSI escape characters may be included
37
+ // in the response.
38
+ const env = {
39
+ ...process.env, ...options?.env,
40
+ TERM_PROGRAM: 'codify',
41
+ COMMAND_MODE: 'unix2003',
42
+ COLORTERM: 'truecolor', ...historyIgnore
43
+ }
44
+
45
+ // Initial terminal dimensions
46
+ const initialCols = process.stdout.columns ?? 80;
47
+ const initialRows = process.stdout.rows ?? 24;
48
+
49
+ const args = (options?.interactive ?? false) ? ['-i', '-c', `"${cmd}"`] : ['-c', `"${cmd}"`]
50
+
51
+ // Run the command in a pty for interactivity
52
+ const mPty = pty.spawn(this.getDefaultShell(), args, {
53
+ ...options,
54
+ cols: initialCols,
55
+ rows: initialRows,
56
+ env
57
+ });
58
+
59
+ mPty.onData((data) => {
60
+ if (VerbosityLevel.get() > 0) {
61
+ process.stdout.write(data);
62
+ }
63
+
64
+ output.push(data.toString());
65
+ })
66
+
67
+ const stdinListener = (data: any) => {
68
+ mPty.write(data.toString());
69
+ };
70
+
71
+ const resizeListener = () => {
72
+ const { columns, rows } = process.stdout;
73
+ mPty.resize(columns, rows);
74
+ }
75
+
76
+ // Listen to resize events for the terminal window;
77
+ process.stdout.on('resize', resizeListener);
78
+ // Listen for user input
79
+ process.stdin.on('data', stdinListener);
80
+
81
+ mPty.onExit((result) => {
82
+ process.stdout.off('resize', resizeListener);
83
+ process.stdin.off('data', stdinListener);
84
+
85
+ resolve({
86
+ status: result.exitCode === 0 ? SpawnStatus.SUCCESS : SpawnStatus.ERROR,
87
+ exitCode: result.exitCode,
88
+ data: stripAnsi(output.join('\n').trim()),
89
+ })
90
+ })
91
+ })
92
+ }
93
+
94
+ async kill(): Promise<{ exitCode: number, signal?: number | undefined }> {
95
+ // No-op here. Each pty instance is stand alone and tied to the parent process. Everything should be killed as expected.
96
+ return {
97
+ exitCode: 0,
98
+ signal: 0,
99
+ }
100
+ }
101
+
102
+ private getDefaultShell(): string {
103
+ return process.env.SHELL!;
104
+ }
105
+ }
@@ -0,0 +1,61 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { SequentialPty } from './seqeuntial-pty.js';
3
+ import { VerbosityLevel } from '../utils/internal-utils.js';
4
+
5
+ describe('SequentialPty tests', () => {
6
+ it('Can launch a simple command', async () => {
7
+ const pty = new SequentialPty();
8
+
9
+ VerbosityLevel.set(1);
10
+
11
+ const result = await pty.spawnSafe('ls');
12
+ expect(result).toMatchObject({
13
+ status: 'success',
14
+ exitCode: 0,
15
+ data: expect.any(String),
16
+ })
17
+
18
+ const exitCode = await pty.kill();
19
+ expect(exitCode).toMatchObject({
20
+ exitCode: 0,
21
+ });
22
+ })
23
+
24
+ it('Reports back the correct exit code and status', async () => {
25
+ const pty = new SequentialPty();
26
+
27
+ const resultSuccess = await pty.spawnSafe('ls');
28
+ expect(resultSuccess).toMatchObject({
29
+ status: 'success',
30
+ exitCode: 0,
31
+ })
32
+
33
+ const resultFailed = await pty.spawnSafe('which sjkdhsakjdhjkash');
34
+ expect(resultFailed).toMatchObject({
35
+ status: 'error',
36
+ exitCode: 127,
37
+ data: 'zsh:1: command not found: which sjkdhsakjdhjkash' // This might change on different os or shells. Keep for now.
38
+ })
39
+ });
40
+
41
+ it('Can use a different cwd', async () => {
42
+ const pty = new SequentialPty();
43
+
44
+ const resultSuccess = await pty.spawnSafe('pwd', { cwd: '/tmp' });
45
+ expect(resultSuccess).toMatchObject({
46
+ status: 'success',
47
+ exitCode: 0,
48
+ data: '/tmp'
49
+ })
50
+ });
51
+
52
+ it('It can launch a command in interactive mode', async () => {
53
+ const pty = new SequentialPty();
54
+
55
+ const resultSuccess = await pty.spawnSafe('ls', { interactive: false });
56
+ expect(resultSuccess).toMatchObject({
57
+ status: 'success',
58
+ exitCode: 0,
59
+ })
60
+ });
61
+ })
@@ -1,5 +1,5 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
- import { StringIndexedObject } from 'codify-schemas';
2
+ import { OS, StringIndexedObject } from 'codify-schemas';
3
3
 
4
4
  import { StatefulParameterController } from '../stateful-parameter/stateful-parameter-controller.js';
5
5
  import {
@@ -46,16 +46,17 @@ export class ParsedResourceSettings<T extends StringIndexedObject> implements Re
46
46
  removeStatefulParametersBeforeDestroy?: boolean | undefined;
47
47
  dependencies?: string[] | undefined;
48
48
  transformation?: InputTransformation;
49
+
50
+ operatingSystems!: Array<OS>;
51
+ isSensitive?: boolean;
52
+
49
53
  private settings: ResourceSettings<T>;
50
54
 
51
55
  constructor(settings: ResourceSettings<T>) {
52
56
  this.settings = settings;
53
- this.id = settings.id;
54
- this.schema = settings.schema;
55
- this.allowMultiple = settings.allowMultiple;
56
- this.removeStatefulParametersBeforeDestroy = settings.removeStatefulParametersBeforeDestroy;
57
- this.dependencies = settings.dependencies;
58
- this.transformation = settings.transformation;
57
+
58
+ const { parameterSettings, ...rest } = settings;
59
+ Object.assign(this, rest);
59
60
 
60
61
  this.validateSettings();
61
62
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { ParameterOperation, ResourceOperation } from 'codify-schemas';
2
+ import { OS, ParameterOperation, ResourceOperation } from 'codify-schemas';
3
3
  import { TestConfig, TestResource, TestStatefulParameter } from '../utils/test-utils.test.js';
4
4
  import { ResourceSettings } from './resource-settings.js';
5
5
  import { ResourceController } from './resource-controller.js';
@@ -179,6 +179,7 @@ describe('Resource tests for stateful plans', () => {
179
179
  getSettings(): ResourceSettings<TestConfig> {
180
180
  return {
181
181
  id: 'type',
182
+ operatingSystems: [OS.Darwin],
182
183
  parameterSettings: {
183
184
  propD: { type: 'stateful', definition: statefulParameter },
184
185
  }
@@ -1,5 +1,5 @@
1
1
  import { Resource } from './resource.js';
2
- import { ResourceOperation } from 'codify-schemas';
2
+ import { OS, ResourceOperation } from 'codify-schemas';
3
3
  import { spy } from 'sinon';
4
4
  import { describe, expect, it } from 'vitest'
5
5
  import { ArrayParameterSetting, ParameterSetting, ResourceSettings } from './resource-settings.js';
@@ -7,7 +7,7 @@ import { CreatePlan, DestroyPlan, ModifyPlan } from '../plan/plan-types.js';
7
7
  import { ParameterChange } from '../plan/change-set.js';
8
8
  import { ResourceController } from './resource-controller.js';
9
9
  import { TestConfig, testPlan, TestResource, TestStatefulParameter } from '../utils/test-utils.test.js';
10
- import { tildify, untildify } from '../utils/utils.js';
10
+ import { tildify, untildify } from '../utils/internal-utils.js';
11
11
  import { ArrayStatefulParameter, StatefulParameter } from '../stateful-parameter/stateful-parameter.js';
12
12
  import { Plan } from '../plan/plan.js';
13
13
  import os from 'node:os';
@@ -19,6 +19,7 @@ describe('Resource tests', () => {
19
19
  getSettings(): ResourceSettings<TestConfig> {
20
20
  return {
21
21
  id: 'type',
22
+ operatingSystems: [OS.Darwin],
22
23
  dependencies: ['homebrew', 'python'],
23
24
  parameterSettings: {
24
25
  propA: {
@@ -197,6 +198,7 @@ describe('Resource tests', () => {
197
198
  getSettings(): ResourceSettings<TestConfig> {
198
199
  return {
199
200
  id: 'resource',
201
+ operatingSystems: [OS.Darwin],
200
202
  parameterSettings: {
201
203
  propA: { canModify: true },
202
204
  propB: { canModify: true },
@@ -232,6 +234,7 @@ describe('Resource tests', () => {
232
234
  getSettings(): ResourceSettings<TestConfig> {
233
235
  return {
234
236
  id: 'type',
237
+ operatingSystems: [OS.Darwin],
235
238
  dependencies: ['homebrew', 'python'],
236
239
  parameterSettings: {
237
240
  propA: { canModify: true },
@@ -254,6 +257,7 @@ describe('Resource tests', () => {
254
257
  getSettings(): ResourceSettings<TestConfig> {
255
258
  return {
256
259
  id: 'type',
260
+ operatingSystems: [OS.Darwin],
257
261
  dependencies: ['homebrew', 'python'],
258
262
  parameterSettings: {
259
263
  propA: { canModify: true },
@@ -270,6 +274,7 @@ describe('Resource tests', () => {
270
274
  getSettings(): ResourceSettings<TestConfig> {
271
275
  return {
272
276
  id: 'type',
277
+ operatingSystems: [OS.Darwin],
273
278
  parameterSettings: {
274
279
  propA: { default: 'propADefault' }
275
280
  }
@@ -298,6 +303,7 @@ describe('Resource tests', () => {
298
303
  getSettings(): ResourceSettings<TestConfig> {
299
304
  return {
300
305
  id: 'type',
306
+ operatingSystems: [OS.Darwin],
301
307
  parameterSettings: {
302
308
  propE: { default: 'propEDefault' }
303
309
  }
@@ -325,6 +331,7 @@ describe('Resource tests', () => {
325
331
  getSettings(): ResourceSettings<TestConfig> {
326
332
  return {
327
333
  id: 'type',
334
+ operatingSystems: [OS.Darwin],
328
335
  parameterSettings: {
329
336
  propE: { default: 'propEDefault' }
330
337
  }
@@ -348,6 +355,7 @@ describe('Resource tests', () => {
348
355
  getSettings(): ResourceSettings<TestConfig> {
349
356
  return {
350
357
  id: 'type',
358
+ operatingSystems: [OS.Darwin],
351
359
  parameterSettings: {
352
360
  propA: { default: 'propADefault' }
353
361
  }
@@ -376,6 +384,7 @@ describe('Resource tests', () => {
376
384
  getSettings(): ResourceSettings<TestConfig> {
377
385
  return {
378
386
  id: 'type',
387
+ operatingSystems: [OS.Darwin],
379
388
  parameterSettings: {
380
389
  propA: { default: 'propADefault' }
381
390
  }
@@ -392,7 +401,7 @@ describe('Resource tests', () => {
392
401
  it('Has the correct typing for applys', () => {
393
402
  const resource = new class extends Resource<TestConfig> {
394
403
  getSettings(): ResourceSettings<TestConfig> {
395
- return { id: 'type' }
404
+ return { id: 'type', operatingSystems: [OS.Darwin], }
396
405
  }
397
406
 
398
407
  async refresh(): Promise<Partial<TestConfig> | null> {
@@ -418,7 +427,8 @@ describe('Resource tests', () => {
418
427
  const parameter1 = new class extends StatefulParameter<any, any> {
419
428
  getSettings(): ParameterSetting {
420
429
  return {
421
- type: 'version'
430
+ type: 'version',
431
+ operatingSystems: [OS.Darwin],
422
432
  }
423
433
  }
424
434
 
@@ -462,6 +472,7 @@ describe('Resource tests', () => {
462
472
  getSettings(): ResourceSettings<TestConfig> {
463
473
  return {
464
474
  id: 'nvm',
475
+ operatingSystems: [OS.Darwin],
465
476
  parameterSettings: {
466
477
  global: { type: 'stateful', definition: parameter1, order: 2 },
467
478
  nodeVersions: { type: 'stateful', definition: parameter2, order: 1 },
@@ -514,6 +525,7 @@ describe('Resource tests', () => {
514
525
  getSettings(): ResourceSettings<TestConfig> {
515
526
  return {
516
527
  id: 'nvm',
528
+ operatingSystems: [OS.Darwin],
517
529
  parameterSettings: {
518
530
  global: { type: 'stateful', definition: parameter1, order: 2 },
519
531
  nodeVersions: { type: 'stateful', definition: parameter2, order: 1 },
@@ -546,6 +558,7 @@ describe('Resource tests', () => {
546
558
  getSettings(): ResourceSettings<TestConfig> {
547
559
  return {
548
560
  id: 'resourceType',
561
+ operatingSystems: [OS.Darwin],
549
562
  parameterSettings: {
550
563
  propD: {
551
564
  type: 'array',
@@ -630,6 +643,7 @@ describe('Resource tests', () => {
630
643
  getSettings(): ResourceSettings<TestConfig> {
631
644
  return {
632
645
  id: 'resourceType',
646
+ operatingSystems: [OS.Darwin],
633
647
  parameterSettings: {
634
648
  propD: {
635
649
  type: 'array',
@@ -720,6 +734,7 @@ describe('Resource tests', () => {
720
734
  getSettings(): ResourceSettings<TestConfig> {
721
735
  return {
722
736
  id: 'resourceType',
737
+ operatingSystems: [OS.Darwin],
723
738
  parameterSettings: {
724
739
  propA: { type: 'string', default: 'defaultValue' },
725
740
  propB: { type: 'boolean', default: true }
@@ -755,6 +770,7 @@ describe('Resource tests', () => {
755
770
  getSettings(): ResourceSettings<any> {
756
771
  return {
757
772
  id: 'path',
773
+ operatingSystems: [OS.Darwin],
758
774
  parameterSettings: {
759
775
  path: { type: 'string', isEqual: 'directory' },
760
776
  paths: { canModify: true, type: 'array', isElementEqual: 'directory' },
@@ -797,6 +813,7 @@ describe('Resource tests', () => {
797
813
  getSettings(): ResourceSettings<any> {
798
814
  return {
799
815
  id: 'path',
816
+ operatingSystems: [OS.Darwin],
800
817
  parameterSettings: {
801
818
  path: { type: 'string', isEqual: 'directory' },
802
819
  paths: { canModify: true, type: 'array', isElementEqual: 'directory' },
@@ -840,6 +857,7 @@ describe('Resource tests', () => {
840
857
  getSettings(): ResourceSettings<any> {
841
858
  return {
842
859
  id: 'path',
860
+ operatingSystems: [OS.Darwin],
843
861
  parameterSettings: {
844
862
  path: { type: 'directory' },
845
863
  paths: { canModify: true, type: 'array', itemType: 'directory' },