@codifycli/plugin-test 1.0.0-beta1
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/.eslintignore +1 -0
- package/.eslintrc.json +30 -0
- package/.github/workflows/unit-test-ci.yaml +24 -0
- package/.prettierrc.json +1 -0
- package/CLAUDE.md +126 -0
- package/README.md +315 -0
- package/codify.json +9 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-process.d.ts +19 -0
- package/dist/plugin-process.js +119 -0
- package/dist/plugin-process.js.map +1 -0
- package/dist/plugin-tester.d.ts +20 -0
- package/dist/plugin-tester.js +210 -0
- package/dist/plugin-tester.js.map +1 -0
- package/dist/shell.d.ts +12 -0
- package/dist/shell.js +37 -0
- package/dist/shell.js.map +1 -0
- package/dist/spawn.d.ts +16 -0
- package/dist/spawn.js +71 -0
- package/dist/spawn.js.map +1 -0
- package/dist/test-utils.d.ts +44 -0
- package/dist/test-utils.js +123 -0
- package/dist/test-utils.js.map +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +34 -0
- package/dist/utils.js.map +1 -0
- package/package.json +56 -0
- package/src/index.ts +3 -0
- package/src/plugin-process.ts +161 -0
- package/src/plugin-tester.ts +281 -0
- package/src/shell.ts +45 -0
- package/src/spawn.ts +101 -0
- package/src/test-utils.test.ts +83 -0
- package/src/test-utils.ts +147 -0
- package/src/utils.ts +42 -0
- package/test/plugin-tester.test.ts +350 -0
- package/test/test-plugin.ts +215 -0
- package/tsconfig.json +24 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ImportResponseData, PlanResponseData, ResourceConfig } from '@codifycli/schemas';
|
|
2
|
+
export declare class PluginTester {
|
|
3
|
+
static fullTest(pluginPath: string, configs: ResourceConfig[], options?: {
|
|
4
|
+
skipUninstall?: boolean;
|
|
5
|
+
skipImport?: boolean;
|
|
6
|
+
validatePlan?: (plans: PlanResponseData[]) => Promise<void> | void;
|
|
7
|
+
validateApply?: (plans: PlanResponseData[]) => Promise<void> | void;
|
|
8
|
+
validateDestroy?: (plans: PlanResponseData[]) => Promise<void> | void;
|
|
9
|
+
validateImport?: (importResults: (ImportResponseData['result'][0])[]) => Promise<void> | void;
|
|
10
|
+
testModify?: {
|
|
11
|
+
modifiedConfigs: ResourceConfig[];
|
|
12
|
+
validateModify?: (plans: PlanResponseData[]) => Promise<void> | void;
|
|
13
|
+
};
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
static install(pluginPath: string, configs: ResourceConfig[]): Promise<void>;
|
|
16
|
+
static uninstall(pluginPath: string, configs: ResourceConfig[], options?: {
|
|
17
|
+
validateDestroy?: (plans: PlanResponseData[]) => Promise<void> | void;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
private static addNamesToConfigs;
|
|
20
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { ResourceOperation, } from '@codifycli/schemas';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import unionBy from 'lodash.unionby';
|
|
4
|
+
import { PluginProcess } from './plugin-process.js';
|
|
5
|
+
import { getPlatformOs, splitUserConfig } from './utils.js';
|
|
6
|
+
export class PluginTester {
|
|
7
|
+
static async fullTest(pluginPath, configs, options) {
|
|
8
|
+
configs = configs.filter((c) => !c.os || c.os.includes(getPlatformOs()));
|
|
9
|
+
const ids = configs
|
|
10
|
+
.map((c) => `${c.type}${c.name ? `.${c.name}` : ''}`)
|
|
11
|
+
.join(', ');
|
|
12
|
+
console.info(chalk.cyan(`Starting full test of [ ${ids} ]...`));
|
|
13
|
+
const { skipUninstall = false, } = options ?? {};
|
|
14
|
+
const plugin = new PluginProcess(pluginPath);
|
|
15
|
+
try {
|
|
16
|
+
console.info(chalk.cyan('Testing initialization...'));
|
|
17
|
+
const initializeResult = await plugin.initialize();
|
|
18
|
+
const unsupportedConfigs = configs.filter((c) => !initializeResult.resourceDefinitions.some((rd) => rd.type === c.type));
|
|
19
|
+
if (unsupportedConfigs.length > 0) {
|
|
20
|
+
throw new Error(`The plugin does not support the following configs supplied:\n ${JSON.stringify(unsupportedConfigs, null, 2)}\n Initialize result: ${JSON.stringify(initializeResult)}`);
|
|
21
|
+
}
|
|
22
|
+
// configs = configs.filter((c) => initializeResult.resourceDefinitions.find((rd) => rd.type === c.type)?.operatingSystems?.includes(os.platform() as OS));
|
|
23
|
+
console.info(chalk.cyan('Testing validate...'));
|
|
24
|
+
const validate = await plugin.validate({
|
|
25
|
+
configs: configs.map((c) => {
|
|
26
|
+
const { coreParameters, parameters } = splitUserConfig(c);
|
|
27
|
+
return { core: coreParameters, parameters };
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
const invalidConfigs = validate.resourceValidations.filter((v) => !v.isValid);
|
|
31
|
+
if (invalidConfigs.length > 0) {
|
|
32
|
+
throw new Error(`The following configs did not validate:\n ${JSON.stringify(invalidConfigs, null, 2)}`);
|
|
33
|
+
}
|
|
34
|
+
console.info(chalk.cyan('Testing plan...'));
|
|
35
|
+
const plans = [];
|
|
36
|
+
for (const config of configs) {
|
|
37
|
+
const { coreParameters, parameters } = splitUserConfig(config);
|
|
38
|
+
plans.push(await plugin.plan({
|
|
39
|
+
core: coreParameters,
|
|
40
|
+
desired: parameters,
|
|
41
|
+
isStateful: false,
|
|
42
|
+
state: undefined,
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
if (options?.validatePlan) {
|
|
46
|
+
await options.validatePlan(plans);
|
|
47
|
+
}
|
|
48
|
+
console.info(chalk.cyan('Testing apply...'));
|
|
49
|
+
for (const plan of plans) {
|
|
50
|
+
await plugin.apply({
|
|
51
|
+
planId: plan.planId
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (options?.validateApply) {
|
|
55
|
+
await options.validateApply(plans);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
plugin.kill();
|
|
60
|
+
}
|
|
61
|
+
if (!options?.skipImport) {
|
|
62
|
+
const importPlugin = new PluginProcess(pluginPath);
|
|
63
|
+
try {
|
|
64
|
+
await importPlugin.initialize();
|
|
65
|
+
console.info(chalk.cyan('Testing import...'));
|
|
66
|
+
const importResults = [];
|
|
67
|
+
for (const config of configs) {
|
|
68
|
+
const { coreParameters, parameters } = splitUserConfig(config);
|
|
69
|
+
const importResult = await importPlugin.import({ core: coreParameters, parameters });
|
|
70
|
+
importResults.push(importResult);
|
|
71
|
+
}
|
|
72
|
+
if (options?.validateImport) {
|
|
73
|
+
await options.validateImport(importResults.map((r) => r.result[0]));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
importPlugin.kill();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (options?.testModify) {
|
|
81
|
+
const modifyPlugin = new PluginProcess(pluginPath);
|
|
82
|
+
try {
|
|
83
|
+
await modifyPlugin.initialize();
|
|
84
|
+
console.info(chalk.cyan('Testing modify...'));
|
|
85
|
+
const modifyPlans = [];
|
|
86
|
+
for (const config of options.testModify.modifiedConfigs) {
|
|
87
|
+
const { coreParameters, parameters } = splitUserConfig(config);
|
|
88
|
+
modifyPlans.push(await modifyPlugin.plan({
|
|
89
|
+
core: coreParameters,
|
|
90
|
+
desired: parameters,
|
|
91
|
+
isStateful: false,
|
|
92
|
+
state: undefined,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
if (modifyPlans.some((p) => p.operation !== ResourceOperation.MODIFY)) {
|
|
96
|
+
throw new Error(`Error while testing modify. Non-modify results were found in the plan:
|
|
97
|
+
${JSON.stringify(modifyPlans, null, 2)}`);
|
|
98
|
+
}
|
|
99
|
+
for (const plan of modifyPlans) {
|
|
100
|
+
await modifyPlugin.apply({
|
|
101
|
+
planId: plan.planId
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (options.testModify.validateModify) {
|
|
105
|
+
await options.testModify.validateModify(modifyPlans);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
modifyPlugin.kill();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!skipUninstall) {
|
|
113
|
+
// We need to add unique names to multiple configs with the same type or else it breaks the unionBy below.
|
|
114
|
+
const configsWithNames = this.addNamesToConfigs(configs);
|
|
115
|
+
const modifiedConfigs = this.addNamesToConfigs(options?.testModify?.modifiedConfigs ?? []);
|
|
116
|
+
const id = (config) => config.type + (config.name ? `.${config.name}` : '');
|
|
117
|
+
const configsToDestroy = unionBy(modifiedConfigs, configsWithNames, id);
|
|
118
|
+
await this.uninstall(pluginPath, configsToDestroy.toReversed(), options);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
static async install(pluginPath, configs) {
|
|
122
|
+
const plugin = new PluginProcess(pluginPath);
|
|
123
|
+
try {
|
|
124
|
+
console.info(chalk.cyan('Testing initialization...'));
|
|
125
|
+
const initializeResult = await plugin.initialize();
|
|
126
|
+
const unsupportedConfigs = configs.filter((c) => !initializeResult.resourceDefinitions.some((rd) => rd.type === c.type));
|
|
127
|
+
if (unsupportedConfigs.length > 0) {
|
|
128
|
+
throw new Error(`The plugin does not support the following configs supplied:\n ${JSON.stringify(unsupportedConfigs, null, 2)}\n Initialize result: ${JSON.stringify(initializeResult)}`);
|
|
129
|
+
}
|
|
130
|
+
// configs = configs.filter((c) => initializeResult.resourceDefinitions.find((rd) => rd.type === c.type)?.operatingSystems?.includes(os.platform() as OS));
|
|
131
|
+
console.info(chalk.cyan('Testing validate...'));
|
|
132
|
+
const validate = await plugin.validate({
|
|
133
|
+
configs: configs.map((c) => {
|
|
134
|
+
const { coreParameters, parameters } = splitUserConfig(c);
|
|
135
|
+
return { core: coreParameters, parameters };
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
const invalidConfigs = validate.resourceValidations.filter((v) => !v.isValid);
|
|
139
|
+
if (invalidConfigs.length > 0) {
|
|
140
|
+
throw new Error(`The following configs did not validate:\n ${JSON.stringify(invalidConfigs, null, 2)}`);
|
|
141
|
+
}
|
|
142
|
+
console.info(chalk.cyan('Testing plan...'));
|
|
143
|
+
const plans = [];
|
|
144
|
+
for (const config of configs) {
|
|
145
|
+
const { coreParameters, parameters } = splitUserConfig(config);
|
|
146
|
+
plans.push(await plugin.plan({
|
|
147
|
+
core: coreParameters,
|
|
148
|
+
desired: parameters,
|
|
149
|
+
isStateful: false,
|
|
150
|
+
state: undefined,
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
console.info(chalk.cyan('Testing apply...'));
|
|
154
|
+
for (const plan of plans) {
|
|
155
|
+
await plugin.apply({
|
|
156
|
+
planId: plan.planId
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
plugin.kill();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
static async uninstall(pluginPath, configs, options) {
|
|
165
|
+
const destroyPlugin = new PluginProcess(pluginPath);
|
|
166
|
+
try {
|
|
167
|
+
await destroyPlugin.initialize();
|
|
168
|
+
console.info(chalk.cyan('Testing destroy...'));
|
|
169
|
+
const plans = [];
|
|
170
|
+
for (const config of configs) {
|
|
171
|
+
const { coreParameters, parameters } = splitUserConfig(config);
|
|
172
|
+
plans.push(await destroyPlugin.plan({
|
|
173
|
+
core: coreParameters,
|
|
174
|
+
isStateful: true,
|
|
175
|
+
state: parameters,
|
|
176
|
+
desired: undefined
|
|
177
|
+
}));
|
|
178
|
+
}
|
|
179
|
+
for (const plan of plans) {
|
|
180
|
+
if (plan.operation !== ResourceOperation.DESTROY && plan.operation !== ResourceOperation.NOOP) {
|
|
181
|
+
throw new Error(`Expect resource operation to be 'destroy' but instead received plan: \n ${JSON.stringify(plans, null, 2)}`);
|
|
182
|
+
}
|
|
183
|
+
await destroyPlugin.apply({
|
|
184
|
+
planId: plan.planId
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (options?.validateDestroy) {
|
|
188
|
+
await options.validateDestroy(plans);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
destroyPlugin.kill();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
static addNamesToConfigs(configs) {
|
|
196
|
+
const configsWithNames = new Array();
|
|
197
|
+
const typeSet = new Set(configs.map((c) => c.type));
|
|
198
|
+
for (const type of typeSet) {
|
|
199
|
+
const sameTypeConfigs = configs.filter((c) => c.type === type);
|
|
200
|
+
if (sameTypeConfigs.length > 1) {
|
|
201
|
+
sameTypeConfigs.forEach((c, idx) => {
|
|
202
|
+
c.name = c.name ?? idx.toString();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
configsWithNames.push(...sameTypeConfigs);
|
|
206
|
+
}
|
|
207
|
+
return configsWithNames;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=plugin-tester.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-tester.js","sourceRoot":"","sources":["../src/plugin-tester.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,KAAK,CAAC,QAAQ,CACnB,UAAkB,EAClB,OAAyB,EACzB,OAWC;QACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,GAAG,GAAG,OAAO;aAChB,GAAG,CAAC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ASH"] = "bash";
|
|
5
|
+
Shell["SH"] = "sh";
|
|
6
|
+
Shell["KSH"] = "ksh";
|
|
7
|
+
Shell["CSH"] = "csh";
|
|
8
|
+
Shell["FISH"] = "fish";
|
|
9
|
+
})(Shell || (Shell = {}));
|
|
10
|
+
export const ShellUtils = {
|
|
11
|
+
getShell() {
|
|
12
|
+
const shell = process.env.SHELL || '';
|
|
13
|
+
if (shell.endsWith('bash')) {
|
|
14
|
+
return Shell.BASH;
|
|
15
|
+
}
|
|
16
|
+
if (shell.endsWith('zsh')) {
|
|
17
|
+
return Shell.ZSH;
|
|
18
|
+
}
|
|
19
|
+
if (shell.endsWith('sh')) {
|
|
20
|
+
return Shell.SH;
|
|
21
|
+
}
|
|
22
|
+
if (shell.endsWith('csh')) {
|
|
23
|
+
return Shell.CSH;
|
|
24
|
+
}
|
|
25
|
+
if (shell.endsWith('ksh')) {
|
|
26
|
+
return Shell.KSH;
|
|
27
|
+
}
|
|
28
|
+
if (shell.endsWith('fish')) {
|
|
29
|
+
return Shell.FISH;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
},
|
|
33
|
+
getDefaultShell() {
|
|
34
|
+
return process.env.SHELL;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,KAOX;AAPD,WAAY,KAAK;IACf,oBAAW,CAAA;IACX,sBAAa,CAAA;IACb,kBAAS,CAAA;IACT,oBAAW,CAAA;IACX,oBAAW,CAAA;IACX,sBAAa,CAAA;AACf,CAAC,EAPW,KAAK,KAAL,KAAK,QAOhB;AAGD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ;QACN,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;QAEtC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,IAAI,CAAA;QACnB,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC,GAAG,CAAA;QAClB,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,EAAE,CAAA;QACjB,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC,GAAG,CAAA;QAClB,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC,GAAG,CAAA;QAClB,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,IAAI,CAAA;QACnB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,eAAe;QACb,OAAO,OAAO,CAAC,GAAG,CAAC,KAAM,CAAC;IAC5B,CAAC;CACF,CAAA"}
|
package/dist/spawn.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SpawnStatus } from '@codifycli/schemas';
|
|
2
|
+
export interface SpawnResult {
|
|
3
|
+
status: SpawnStatus;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
data: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SpawnOptions {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
env?: Record<string, unknown>;
|
|
10
|
+
interactive?: boolean;
|
|
11
|
+
requiresRoot?: boolean;
|
|
12
|
+
stdin?: boolean;
|
|
13
|
+
throws?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function testSpawn(cmd: string, options?: SpawnOptions): Promise<SpawnResult>;
|
|
16
|
+
export declare function spawnSafe(cmd: string, options?: SpawnOptions): Promise<SpawnResult>;
|
package/dist/spawn.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SpawnStatus } from '@codifycli/schemas';
|
|
2
|
+
import * as pty from '@homebridge/node-pty-prebuilt-multiarch';
|
|
3
|
+
import stripAnsi from 'strip-ansi';
|
|
4
|
+
import { Shell, ShellUtils } from './shell.js';
|
|
5
|
+
export function testSpawn(cmd, options) {
|
|
6
|
+
return spawnSafe(cmd, { interactive: true, ...options, });
|
|
7
|
+
}
|
|
8
|
+
export function spawnSafe(cmd, options) {
|
|
9
|
+
if (cmd.toLowerCase().includes('sudo')) {
|
|
10
|
+
throw new Error('Command must not include sudo');
|
|
11
|
+
}
|
|
12
|
+
console.log(`Running command: ${options?.requiresRoot ? 'sudo' : ''} ${cmd}` + (options?.cwd ? `(${options?.cwd})` : ''));
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
const output = [];
|
|
15
|
+
const historyIgnore = ShellUtils.getShell() === Shell.ZSH ? { HISTORY_IGNORE: '*' } : { HISTIGNORE: '*' };
|
|
16
|
+
// If TERM_PROGRAM=Apple_Terminal is set then ANSI escape characters may be included
|
|
17
|
+
// in the response.
|
|
18
|
+
const env = {
|
|
19
|
+
...process.env, ...options?.env,
|
|
20
|
+
TERM_PROGRAM: 'codify',
|
|
21
|
+
COMMAND_MODE: 'unix2003',
|
|
22
|
+
COLORTERM: 'truecolor',
|
|
23
|
+
...historyIgnore
|
|
24
|
+
};
|
|
25
|
+
// Initial terminal dimensions
|
|
26
|
+
const initialCols = 10000; // Set to a large value to prevent wrapping
|
|
27
|
+
const initialRows = process.stdout.rows ?? 24;
|
|
28
|
+
const command = options?.requiresRoot ? `sudo ${cmd}` : cmd;
|
|
29
|
+
const args = options?.interactive ? ['-i', '-c', command] : ['-c', command];
|
|
30
|
+
// Run the command in a pty for interactivity
|
|
31
|
+
const mPty = pty.spawn(ShellUtils.getDefaultShell(), args, {
|
|
32
|
+
...options,
|
|
33
|
+
cols: initialCols,
|
|
34
|
+
rows: initialRows,
|
|
35
|
+
env
|
|
36
|
+
});
|
|
37
|
+
mPty.onData((data) => {
|
|
38
|
+
process.stdout.write(data);
|
|
39
|
+
output.push(data.toString());
|
|
40
|
+
});
|
|
41
|
+
const resizeListener = () => {
|
|
42
|
+
const { columns, rows } = process.stdout;
|
|
43
|
+
mPty.resize(columns, rows);
|
|
44
|
+
};
|
|
45
|
+
const stdinListener = (data) => {
|
|
46
|
+
// console.log('stdinListener', data);
|
|
47
|
+
mPty.write(data.toString());
|
|
48
|
+
};
|
|
49
|
+
// Listen to resize events for the terminal window;
|
|
50
|
+
process.stdout.on('resize', resizeListener);
|
|
51
|
+
if (options?.stdin) {
|
|
52
|
+
process.stdin.on('data', stdinListener);
|
|
53
|
+
}
|
|
54
|
+
mPty.onExit((result) => {
|
|
55
|
+
process.stdout.off('resize', resizeListener);
|
|
56
|
+
if (options?.stdin) {
|
|
57
|
+
process.stdin.off('data', stdinListener);
|
|
58
|
+
}
|
|
59
|
+
if (options?.throws && result.exitCode !== 0) {
|
|
60
|
+
reject(new Error(stripAnsi(output.join('\n').trim())));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
resolve({
|
|
64
|
+
status: result.exitCode === 0 ? SpawnStatus.SUCCESS : SpawnStatus.ERROR,
|
|
65
|
+
exitCode: result.exitCode,
|
|
66
|
+
data: stripAnsi(output.join('\n').trim()),
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=spawn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../src/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,yCAAyC,CAAC;AAC/D,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,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M,EAAE,aAAa,CAAC,CAAA;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YACrB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;YAC7C,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;YAC3C,CAAC;YAED,IAAI,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;gBAC7C,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACvD,OAAO;YACT,CAAC;YAED,OAAO,CAAC;gBACN,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK;gBACvE,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;aAC1C,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { IpcMessageV2 } from '@codifycli/schemas';
|
|
3
|
+
import { ChildProcess } from 'node:child_process';
|
|
4
|
+
export declare const TestUtils: {
|
|
5
|
+
sendMessageAndAwaitResponse(process: ChildProcess, message: IpcMessageV2): Promise<any>;
|
|
6
|
+
ensureHomebrewInstalledOnMacOs(pluginPath: string): Promise<void>;
|
|
7
|
+
ensureXcodeInstalledOnMacOs(pluginPath: string): Promise<void>;
|
|
8
|
+
getShell(): 'bash' | 'zsh';
|
|
9
|
+
/**
|
|
10
|
+
* Get the primary shell rc file path
|
|
11
|
+
*/
|
|
12
|
+
getPrimaryShellRc(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get the source command for the shell rc file
|
|
15
|
+
* Usage: execSync(TestUtils.getSourceCommand())
|
|
16
|
+
*/
|
|
17
|
+
getSourceCommand(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Get shell-specific command to run with sourced environment
|
|
20
|
+
* Usage: execSync(TestUtils.getShellCommand('which brew'))
|
|
21
|
+
*/
|
|
22
|
+
getShellCommand(command: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get shell name for execSync shell option
|
|
25
|
+
*/
|
|
26
|
+
getShellName(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get interactive shell command
|
|
29
|
+
* Usage: execSync(TestUtils.getInteractiveCommand('my-alias'))
|
|
30
|
+
*/
|
|
31
|
+
getInteractiveCommand(command: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get which command output format based on shell
|
|
34
|
+
*/
|
|
35
|
+
getAliasWhichCommand(aliasName: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Check if running on macOS
|
|
38
|
+
*/
|
|
39
|
+
isMacOS(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Check if running on Linux
|
|
42
|
+
*/
|
|
43
|
+
isLinux(): boolean;
|
|
44
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
import { IpcMessageSchema, MessageStatus, ResourceOs, SpawnStatus } from '@codifycli/schemas';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { PluginTester } from './plugin-tester.js';
|
|
6
|
+
import { testSpawn } from './spawn.js';
|
|
7
|
+
const ajv = new Ajv.default({
|
|
8
|
+
strict: true
|
|
9
|
+
});
|
|
10
|
+
const ipcMessageValidator = ajv.compile(IpcMessageSchema);
|
|
11
|
+
export const TestUtils = {
|
|
12
|
+
sendMessageAndAwaitResponse(process, message) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
process.on('message', (response) => {
|
|
15
|
+
if (!ipcMessageValidator(response)) {
|
|
16
|
+
throw new Error(`Invalid message from plugin. ${JSON.stringify(message, null, 2)}`);
|
|
17
|
+
}
|
|
18
|
+
// Wait for the message response. Other messages such as sudoRequest may be sent before the response returns
|
|
19
|
+
if (response.requestId === message.requestId) {
|
|
20
|
+
if (response.status === MessageStatus.SUCCESS) {
|
|
21
|
+
resolve(response.data);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
reject(new Error(String(response.data)));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// Send message last to ensure listeners are all registered
|
|
29
|
+
process.send(message);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
async ensureHomebrewInstalledOnMacOs(pluginPath) {
|
|
33
|
+
const homebrewQuery = await testSpawn('which brew');
|
|
34
|
+
if (homebrewQuery.status !== SpawnStatus.SUCCESS) {
|
|
35
|
+
await PluginTester.install(pluginPath, [{ type: 'homebrew', os: [ResourceOs.MACOS] }]);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async ensureXcodeInstalledOnMacOs(pluginPath) {
|
|
39
|
+
const xcodeQuery = await testSpawn('xcode-select -p');
|
|
40
|
+
if (xcodeQuery.status !== SpawnStatus.SUCCESS) {
|
|
41
|
+
await PluginTester.install(pluginPath, [{ type: 'xcode-tools', os: [ResourceOs.MACOS] }]);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
getShell() {
|
|
45
|
+
const shell = process.env.SHELL || '';
|
|
46
|
+
if (shell.includes('bash')) {
|
|
47
|
+
return 'bash';
|
|
48
|
+
}
|
|
49
|
+
if (shell.includes('zsh')) {
|
|
50
|
+
return 'zsh';
|
|
51
|
+
}
|
|
52
|
+
// Default to bash for tests
|
|
53
|
+
return 'bash';
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Get the primary shell rc file path
|
|
57
|
+
*/
|
|
58
|
+
getPrimaryShellRc() {
|
|
59
|
+
const shell = TestUtils.getShell();
|
|
60
|
+
const homeDir = os.homedir();
|
|
61
|
+
if (shell === 'bash') {
|
|
62
|
+
return path.join(homeDir, '.bashrc');
|
|
63
|
+
}
|
|
64
|
+
if (shell === 'zsh') {
|
|
65
|
+
return path.join(homeDir, '.zshrc');
|
|
66
|
+
}
|
|
67
|
+
throw new Error('Unsupported shell');
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Get the source command for the shell rc file
|
|
71
|
+
* Usage: execSync(TestUtils.getSourceCommand())
|
|
72
|
+
*/
|
|
73
|
+
getSourceCommand() {
|
|
74
|
+
return `source ${TestUtils.getPrimaryShellRc()}`;
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* Get shell-specific command to run with sourced environment
|
|
78
|
+
* Usage: execSync(TestUtils.getShellCommand('which brew'))
|
|
79
|
+
*/
|
|
80
|
+
getShellCommand(command) {
|
|
81
|
+
return `${TestUtils.getSourceCommand()}; ${command}`;
|
|
82
|
+
},
|
|
83
|
+
/**
|
|
84
|
+
* Get shell name for execSync shell option
|
|
85
|
+
*/
|
|
86
|
+
getShellName() {
|
|
87
|
+
return TestUtils.getShell();
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Get interactive shell command
|
|
91
|
+
* Usage: execSync(TestUtils.getInteractiveCommand('my-alias'))
|
|
92
|
+
*/
|
|
93
|
+
getInteractiveCommand(command) {
|
|
94
|
+
const shell = TestUtils.getShell();
|
|
95
|
+
return shell === 'bash'
|
|
96
|
+
? `bash -i -c "${command}"`
|
|
97
|
+
: `zsh -i -c "${command}"`;
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Get which command output format based on shell
|
|
101
|
+
*/
|
|
102
|
+
getAliasWhichCommand(aliasName) {
|
|
103
|
+
const shell = TestUtils.getShell();
|
|
104
|
+
// zsh outputs: "alias_name: aliased to command"
|
|
105
|
+
// bash outputs: "alias alias_name='command'"
|
|
106
|
+
return shell === 'bash'
|
|
107
|
+
? `${TestUtils.getShellCommand(`alias ${aliasName}`)}`
|
|
108
|
+
: `${TestUtils.getShellCommand(`which ${aliasName}`)}`;
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Check if running on macOS
|
|
112
|
+
*/
|
|
113
|
+
isMacOS() {
|
|
114
|
+
return os.platform() === 'darwin';
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Check if running on Linux
|
|
118
|
+
*/
|
|
119
|
+
isLinux() {
|
|
120
|
+
return os.platform() === 'linux';
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAgB,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC;IAC1B,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,2BAA2B,CAAC,OAAqB,EAAE,OAAqB;QACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,OAAO,CAAC,EAAE,CAA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qB,CAAC,OAAe;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QAEnC,OAAO,KAAK,KAAK,MAAM;YACrB,CAAC,CAAC,eAAe,OAAO,GAAG;YAC3B,CAAC,CAAC,cAAc,OAAO,GAAG,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,SAAiB;QACpC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QAEnC,gDAAgD;QAChD,6CAA6C;QAC7C,OAAO,KAAK,KAAK,MAAM;YACrB,CAAC,CAAC,GAAG,SAAS,CAAC,eAAe,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE;YACtD,CAAC,CAAC,GAAG,SAAS,CAAC,eAAe,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC;IACnC,CAAC;CACF,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ResourceConfig, ResourceOs, StringIndexedObject } from '@codifycli/schemas';
|
|
2
|
+
export declare function splitUserConfig<T extends StringIndexedObject>(config: ResourceConfig & T): {
|
|
3
|
+
parameters: T;
|
|
4
|
+
coreParameters: ResourceConfig;
|
|
5
|
+
};
|
|
6
|
+
export declare function getPlatformOs(): ResourceOs;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ResourceOs } from '@codifycli/schemas';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
export function splitUserConfig(config) {
|
|
4
|
+
const coreParameters = {
|
|
5
|
+
type: config.type,
|
|
6
|
+
...(config.name ? { name: config.name } : {}),
|
|
7
|
+
...(config.dependsOn ? { dependsOn: config.dependsOn } : {}),
|
|
8
|
+
...(config.os ? { os: config.os } : {}),
|
|
9
|
+
};
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
const { type, name, dependsOn, os, ...parameters } = config;
|
|
12
|
+
return {
|
|
13
|
+
parameters: parameters,
|
|
14
|
+
coreParameters,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function getPlatformOs() {
|
|
18
|
+
const currOs = os.platform();
|
|
19
|
+
switch (currOs) {
|
|
20
|
+
case 'darwin': {
|
|
21
|
+
return ResourceOs.MACOS;
|
|
22
|
+
}
|
|
23
|
+
case 'linux': {
|
|
24
|
+
return ResourceOs.LINUX;
|
|
25
|
+
}
|
|
26
|
+
case 'win32': {
|
|
27
|
+
return ResourceOs.WINDOWS;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
throw new Error(`Unsupported OS: ${currOs}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAuB,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,UAAU,eAAe,CAC7B,MAA0B;IAE1B,MAAM,cAAc,GAAG;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,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