@codifycli/plugin-core 1.1.0-beta15 → 1.1.0-beta17
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/plugin/plugin.d.ts
CHANGED
|
@@ -8,8 +8,13 @@ export declare class Plugin {
|
|
|
8
8
|
resourceControllers: Map<string, ResourceController<ResourceConfig>>;
|
|
9
9
|
planStorage: Map<string, Plan<any>>;
|
|
10
10
|
planPty: BackgroundPty;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
minSupportedCliVersion: string | undefined;
|
|
12
|
+
constructor(name: string, resourceControllers: Map<string, ResourceController<ResourceConfig>>, options?: {
|
|
13
|
+
minSupportedCliVersion?: string;
|
|
14
|
+
});
|
|
15
|
+
static create(name: string, resources: Resource<any>[], options?: {
|
|
16
|
+
minSupportedCliVersion?: string;
|
|
17
|
+
}): Plugin;
|
|
13
18
|
initialize(data: InitializeRequestData): Promise<InitializeResponseData>;
|
|
14
19
|
getResourceInfo(data: GetResourceInfoRequestData): GetResourceInfoResponseData;
|
|
15
20
|
match(data: MatchRequestData): Promise<MatchResponseData>;
|
package/dist/plugin/plugin.js
CHANGED
|
@@ -11,16 +11,18 @@ export class Plugin {
|
|
|
11
11
|
resourceControllers;
|
|
12
12
|
planStorage;
|
|
13
13
|
planPty = new BackgroundPty();
|
|
14
|
-
|
|
14
|
+
minSupportedCliVersion;
|
|
15
|
+
constructor(name, resourceControllers, options) {
|
|
15
16
|
this.name = name;
|
|
16
17
|
this.resourceControllers = resourceControllers;
|
|
17
18
|
this.planStorage = new Map();
|
|
19
|
+
this.minSupportedCliVersion = options?.minSupportedCliVersion;
|
|
18
20
|
}
|
|
19
|
-
static create(name, resources) {
|
|
21
|
+
static create(name, resources, options) {
|
|
20
22
|
const controllers = resources
|
|
21
23
|
.map((resource) => new ResourceController(resource));
|
|
22
24
|
const controllersMap = new Map(controllers.map((r) => [r.typeId, r]));
|
|
23
|
-
return new Plugin(name, controllersMap);
|
|
25
|
+
return new Plugin(name, controllersMap, options);
|
|
24
26
|
}
|
|
25
27
|
async initialize(data) {
|
|
26
28
|
if (data.verbosityLevel) {
|
|
@@ -30,6 +32,7 @@ export class Plugin {
|
|
|
30
32
|
await controller.initialize();
|
|
31
33
|
}
|
|
32
34
|
return {
|
|
35
|
+
minSupportedCliVersion: this.minSupportedCliVersion,
|
|
33
36
|
resourceDefinitions: [...this.resourceControllers.values()]
|
|
34
37
|
.map((r) => {
|
|
35
38
|
const sensitiveParameters = Object.entries(r.settings.parameterSettings ?? {})
|
|
@@ -28,7 +28,7 @@ export class ParsedResourceSettings {
|
|
|
28
28
|
if (ctx.path.length === 0) {
|
|
29
29
|
ctx.jsonSchema.title = settings.id;
|
|
30
30
|
ctx.jsonSchema.description = schema.description ?? settings.description ?? `${settings.id} resource. Can be used to manage ${settings.id}`;
|
|
31
|
-
ctx.jsonSchema.$comment = schema.meta()
|
|
31
|
+
ctx.jsonSchema.$comment = schema.meta()?.$comment;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
})
|
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-beta17",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "ISC",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@codifycli/schemas": "1.1.0-
|
|
38
|
+
"@codifycli/schemas": "1.1.0-beta6",
|
|
39
39
|
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
|
|
40
40
|
"ajv": "^8.18.0",
|
|
41
41
|
"ajv-formats": "^2.1.1",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"lodash.isequal": "^4.5.0",
|
|
44
44
|
"nanoid": "^5.0.9",
|
|
45
45
|
"strip-ansi": "^7.1.0",
|
|
46
|
-
"uuid": "^
|
|
46
|
+
"uuid": "^14.0.0",
|
|
47
47
|
"zod": "4.1.13"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -107,6 +107,7 @@ describe('Change set tests', () => {
|
|
|
107
107
|
|
|
108
108
|
const parameterSettings = new ParsedResourceSettings({
|
|
109
109
|
id: 'type',
|
|
110
|
+
operatingSystems: [],
|
|
110
111
|
parameterSettings: {
|
|
111
112
|
propA: { type: 'array' }
|
|
112
113
|
}
|
|
@@ -129,6 +130,7 @@ describe('Change set tests', () => {
|
|
|
129
130
|
|
|
130
131
|
const parameterSettings = new ParsedResourceSettings({
|
|
131
132
|
id: 'type',
|
|
133
|
+
operatingSystems: [],
|
|
132
134
|
parameterSettings: {
|
|
133
135
|
propA: { type: 'array' }
|
|
134
136
|
}
|
|
@@ -152,6 +154,7 @@ describe('Change set tests', () => {
|
|
|
152
154
|
|
|
153
155
|
const parameterSettings = new ParsedResourceSettings({
|
|
154
156
|
id: 'type',
|
|
157
|
+
operatingSystems: [],
|
|
155
158
|
parameterSettings: {
|
|
156
159
|
propA: { canModify: true }
|
|
157
160
|
}
|
|
@@ -176,6 +179,7 @@ describe('Change set tests', () => {
|
|
|
176
179
|
|
|
177
180
|
const parameterSettings = new ParsedResourceSettings({
|
|
178
181
|
id: 'type',
|
|
182
|
+
operatingSystems: [],
|
|
179
183
|
parameterSettings: {
|
|
180
184
|
propA: { canModify: true },
|
|
181
185
|
propB: { canModify: true }
|
|
@@ -196,6 +200,7 @@ describe('Change set tests', () => {
|
|
|
196
200
|
|
|
197
201
|
const parameterSettings = new ParsedResourceSettings({
|
|
198
202
|
id: 'type',
|
|
203
|
+
operatingSystems: [],
|
|
199
204
|
parameterSettings: {
|
|
200
205
|
propA: { type: 'array' }
|
|
201
206
|
},
|
|
@@ -213,6 +218,7 @@ describe('Change set tests', () => {
|
|
|
213
218
|
|
|
214
219
|
const parameterSettings = new ParsedResourceSettings({
|
|
215
220
|
id: 'type',
|
|
221
|
+
operatingSystems: [],
|
|
216
222
|
parameterSettings: {
|
|
217
223
|
propA: { type: 'array' }
|
|
218
224
|
},
|
|
@@ -229,6 +235,7 @@ describe('Change set tests', () => {
|
|
|
229
235
|
|
|
230
236
|
const parameterSettings = new ParsedResourceSettings({
|
|
231
237
|
id: 'type',
|
|
238
|
+
operatingSystems: [],
|
|
232
239
|
parameterSettings: {
|
|
233
240
|
propA: { type: 'array' }
|
|
234
241
|
},
|
|
@@ -245,6 +252,7 @@ describe('Change set tests', () => {
|
|
|
245
252
|
|
|
246
253
|
const parameterSettings = new ParsedResourceSettings({
|
|
247
254
|
id: 'type',
|
|
255
|
+
operatingSystems: [],
|
|
248
256
|
parameterSettings: {
|
|
249
257
|
propA: {
|
|
250
258
|
type: 'array',
|
|
@@ -259,12 +267,50 @@ describe('Change set tests', () => {
|
|
|
259
267
|
expect(result.parameterChanges[0].operation).to.eq(ParameterOperation.MODIFY);
|
|
260
268
|
})
|
|
261
269
|
|
|
270
|
+
it('excludes setting parameters from destroy change set', () => {
|
|
271
|
+
const settings = {
|
|
272
|
+
id: 'type',
|
|
273
|
+
operatingSystems: [],
|
|
274
|
+
parameterSettings: {
|
|
275
|
+
propA: {},
|
|
276
|
+
propB: { setting: true },
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const cs = ChangeSet.destroy({ propA: 'val', propB: true }, settings as any);
|
|
281
|
+
expect(cs.parameterChanges.length).to.eq(1);
|
|
282
|
+
expect(cs.parameterChanges[0].name).to.eq('propA');
|
|
283
|
+
expect(cs.parameterChanges[0].operation).to.eq(ParameterOperation.REMOVE);
|
|
284
|
+
expect(cs.operation).to.eq(ResourceOperation.DESTROY);
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
it('excludes multiple setting parameters from destroy change set', () => {
|
|
288
|
+
const settings = {
|
|
289
|
+
id: 'type',
|
|
290
|
+
operatingSystems: [],
|
|
291
|
+
parameterSettings: {
|
|
292
|
+
skipAlreadyInstalledCasks: { type: 'boolean', default: true, setting: true },
|
|
293
|
+
onlyPlanUserInstalled: { type: 'boolean', default: true, setting: true },
|
|
294
|
+
directory: { type: 'directory' },
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const cs = ChangeSet.destroy(
|
|
299
|
+
{ skipAlreadyInstalledCasks: true, onlyPlanUserInstalled: true, directory: '/opt/homebrew' },
|
|
300
|
+
settings as any
|
|
301
|
+
);
|
|
302
|
+
expect(cs.parameterChanges.length).to.eq(1);
|
|
303
|
+
expect(cs.parameterChanges[0].name).to.eq('directory');
|
|
304
|
+
expect(cs.operation).to.eq(ResourceOperation.DESTROY);
|
|
305
|
+
})
|
|
306
|
+
|
|
262
307
|
it('correctly determines array equality 5', () => {
|
|
263
308
|
const arrA = [{ key1: 'b' }, { key1: 'a' }, { key1: 'a' }];
|
|
264
309
|
const arrB = [{ key1: 'a' }, { key1: 'a' }, { key1: 'b' }];
|
|
265
310
|
|
|
266
311
|
const parameterSettings = new ParsedResourceSettings({
|
|
267
312
|
id: 'type',
|
|
313
|
+
operatingSystems: [],
|
|
268
314
|
parameterSettings: {
|
|
269
315
|
propA: {
|
|
270
316
|
type: 'array',
|
package/src/plugin/plugin.ts
CHANGED
|
@@ -31,15 +31,22 @@ import { VerbosityLevel } from '../utils/verbosity-level.js';
|
|
|
31
31
|
export class Plugin {
|
|
32
32
|
planStorage: Map<string, Plan<any>>;
|
|
33
33
|
planPty = new BackgroundPty();
|
|
34
|
+
minSupportedCliVersion: string | undefined;
|
|
34
35
|
|
|
35
36
|
constructor(
|
|
36
37
|
public name: string,
|
|
37
|
-
public resourceControllers: Map<string, ResourceController<ResourceConfig
|
|
38
|
+
public resourceControllers: Map<string, ResourceController<ResourceConfig>>,
|
|
39
|
+
options?: { minSupportedCliVersion?: string }
|
|
38
40
|
) {
|
|
39
41
|
this.planStorage = new Map();
|
|
42
|
+
this.minSupportedCliVersion = options?.minSupportedCliVersion;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
static create(
|
|
45
|
+
static create(
|
|
46
|
+
name: string,
|
|
47
|
+
resources: Resource<any>[],
|
|
48
|
+
options?: { minSupportedCliVersion?: string }
|
|
49
|
+
) {
|
|
43
50
|
const controllers = resources
|
|
44
51
|
.map((resource) => new ResourceController(resource))
|
|
45
52
|
|
|
@@ -47,7 +54,7 @@ export class Plugin {
|
|
|
47
54
|
controllers.map((r) => [r.typeId, r] as const)
|
|
48
55
|
);
|
|
49
56
|
|
|
50
|
-
return new Plugin(name, controllersMap);
|
|
57
|
+
return new Plugin(name, controllersMap, options);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
async initialize(data: InitializeRequestData): Promise<InitializeResponseData> {
|
|
@@ -60,6 +67,7 @@ export class Plugin {
|
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
return {
|
|
70
|
+
minSupportedCliVersion: this.minSupportedCliVersion,
|
|
63
71
|
resourceDefinitions: [...this.resourceControllers.values()]
|
|
64
72
|
.map((r) => {
|
|
65
73
|
const sensitiveParameters = Object.entries(r.settings.parameterSettings ?? {})
|
|
@@ -76,7 +76,7 @@ export class ParsedResourceSettings<T extends StringIndexedObject> implements Re
|
|
|
76
76
|
if (ctx.path.length === 0) {
|
|
77
77
|
ctx.jsonSchema.title = settings.id;
|
|
78
78
|
ctx.jsonSchema.description = schema.description ?? settings.description ?? `${settings.id} resource. Can be used to manage ${settings.id}`;
|
|
79
|
-
ctx.jsonSchema.$comment = (schema.meta() as Record<string, string | undefined>)
|
|
79
|
+
ctx.jsonSchema.$comment = (schema.meta() as Record<string, string | undefined> | undefined)?.$comment;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}) as JSONSchemaType<T>
|