codify-plugin-lib 1.0.170 → 1.0.172
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/messages/sender.d.ts +10 -0
- package/dist/messages/sender.js +41 -0
- package/dist/resource/resource-settings.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/messages/sender.ts +54 -0
- package/src/resource/resource-settings.ts +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send requests to the Codify CLI
|
|
3
|
+
*/
|
|
4
|
+
declare class CodifyCliSenderImpl {
|
|
5
|
+
private readonly validateIpcMessageV2;
|
|
6
|
+
requestPressKeyToContinuePrompt(message?: string): Promise<void>;
|
|
7
|
+
private sendAndWaitForResponse;
|
|
8
|
+
}
|
|
9
|
+
export declare const CodifyCliSender: CodifyCliSenderImpl;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { IpcMessageV2Schema, MessageCmd } from 'codify-schemas';
|
|
3
|
+
import { nanoid } from 'nanoid';
|
|
4
|
+
const ajv = new Ajv({
|
|
5
|
+
strict: true,
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Send requests to the Codify CLI
|
|
9
|
+
*/
|
|
10
|
+
class CodifyCliSenderImpl {
|
|
11
|
+
validateIpcMessageV2 = ajv.compile(IpcMessageV2Schema);
|
|
12
|
+
async requestPressKeyToContinuePrompt(message) {
|
|
13
|
+
await this.sendAndWaitForResponse({
|
|
14
|
+
cmd: MessageCmd.PRESS_KEY_TO_CONTINUE_REQUEST,
|
|
15
|
+
data: {
|
|
16
|
+
promptMessage: message,
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async sendAndWaitForResponse(message) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const requestId = nanoid(8);
|
|
23
|
+
const listener = (data) => {
|
|
24
|
+
if (data.requestId === requestId) {
|
|
25
|
+
process.removeListener('message', listener);
|
|
26
|
+
if (!this.validateIpcMessageV2(data.data)) {
|
|
27
|
+
throw new Error(`Invalid response for request:
|
|
28
|
+
|
|
29
|
+
${message}
|
|
30
|
+
|
|
31
|
+
${JSON.stringify(this.validateIpcMessageV2.errors, null, 2)}`);
|
|
32
|
+
}
|
|
33
|
+
resolve(data);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
process.on('message', listener);
|
|
37
|
+
process.send(message);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const CodifyCliSender = new CodifyCliSenderImpl();
|
|
@@ -63,7 +63,7 @@ export function resolveFnFromEqualsFnOrString(fnOrString) {
|
|
|
63
63
|
}
|
|
64
64
|
const ParameterTransformationDefaults = {
|
|
65
65
|
'directory': {
|
|
66
|
-
to: (a) =>
|
|
66
|
+
to: (a) => resolvePathWithVariables((untildify(String(a)))),
|
|
67
67
|
from: (a, original) => {
|
|
68
68
|
if (ParameterEqualsDefaults.directory(a, original)) {
|
|
69
69
|
return original;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codify-plugin-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.172",
|
|
4
4
|
"description": "Library plugin library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"ajv": "^8.12.0",
|
|
18
18
|
"ajv-formats": "^2.1.1",
|
|
19
|
-
"codify-schemas": "1.0.
|
|
19
|
+
"codify-schemas": "1.0.76",
|
|
20
20
|
"@npmcli/promise-spawn": "^7.0.1",
|
|
21
21
|
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
|
|
22
22
|
"uuid": "^10.0.0",
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { MessageHandler } from './messages/handlers.js';
|
|
|
2
2
|
import { Plugin } from './plugin/plugin.js';
|
|
3
3
|
|
|
4
4
|
export * from './errors.js'
|
|
5
|
+
export * from './messages/sender.js'
|
|
5
6
|
export * from './plan/change-set.js'
|
|
6
7
|
export * from './plan/plan.js'
|
|
7
8
|
export * from './plan/plan-types.js'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import {
|
|
3
|
+
IpcMessageV2,
|
|
4
|
+
IpcMessageV2Schema,
|
|
5
|
+
MessageCmd, PressKeyToContinueRequestData
|
|
6
|
+
} from 'codify-schemas';
|
|
7
|
+
import { nanoid } from 'nanoid';
|
|
8
|
+
|
|
9
|
+
const ajv = new Ajv({
|
|
10
|
+
strict: true,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Send requests to the Codify CLI
|
|
15
|
+
*/
|
|
16
|
+
class CodifyCliSenderImpl {
|
|
17
|
+
private readonly validateIpcMessageV2 = ajv.compile(IpcMessageV2Schema);
|
|
18
|
+
|
|
19
|
+
async requestPressKeyToContinuePrompt(message?: string): Promise<void> {
|
|
20
|
+
await this.sendAndWaitForResponse(<IpcMessageV2>{
|
|
21
|
+
cmd: MessageCmd.PRESS_KEY_TO_CONTINUE_REQUEST,
|
|
22
|
+
data: <PressKeyToContinueRequestData>{
|
|
23
|
+
promptMessage: message,
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private async sendAndWaitForResponse(message: IpcMessageV2): Promise<IpcMessageV2> {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const requestId = nanoid(8);
|
|
31
|
+
const listener = (data: IpcMessageV2)=> {
|
|
32
|
+
if (data.requestId === requestId) {
|
|
33
|
+
process.removeListener('message', listener);
|
|
34
|
+
|
|
35
|
+
if (!this.validateIpcMessageV2(data.data)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Invalid response for request:
|
|
38
|
+
|
|
39
|
+
${message}
|
|
40
|
+
|
|
41
|
+
${JSON.stringify(this.validateIpcMessageV2.errors, null, 2)}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resolve(data);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
process.on('message', listener);
|
|
49
|
+
process.send!(message)
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const CodifyCliSender = new CodifyCliSenderImpl();
|
|
@@ -398,7 +398,7 @@ export function resolveFnFromEqualsFnOrString(
|
|
|
398
398
|
|
|
399
399
|
const ParameterTransformationDefaults: Partial<Record<ParameterSettingType, InputTransformation>> = {
|
|
400
400
|
'directory': {
|
|
401
|
-
to: (a: unknown) =>
|
|
401
|
+
to: (a: unknown) => resolvePathWithVariables((untildify(String(a)))),
|
|
402
402
|
from: (a: unknown, original) => {
|
|
403
403
|
if (ParameterEqualsDefaults.directory!(a, original)) {
|
|
404
404
|
return original;
|