Skip to content

Commit 3912a6a

Browse files
committed
chore: Update to the latest @codifycli packages.
1 parent 6377346 commit 3912a6a

9 files changed

Lines changed: 29 additions & 26 deletions

File tree

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "codify-plugin-test",
3-
"version": "0.0.53-beta23",
2+
"name": "@codifycli/plugin-test",
3+
"version": "1.0.0-beta1",
44
"description": "",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
@@ -9,14 +9,14 @@
99
"author": "",
1010
"license": "ISC",
1111
"scripts": {
12-
"test": "echo \"Error: no test specified\" && exit 1",
12+
"test": "vitest",
1313
"start": "tsx ./src/index.ts",
1414
"prepublishOnly": "tsc"
1515
},
1616
"dependencies": {
17-
"ajv": "^8.12.0",
17+
"@codifycli/schemas": "1.0.0",
18+
"ajv": "^8.18.0",
1819
"ajv-formats": "^3.0.1",
19-
"codify-schemas": "1.0.86-beta7",
2020
"lodash.matches": "^4.6.0",
2121
"lodash.differencewith": "4.5.0",
2222
"lodash.unionby": "^4.8.0",
@@ -26,9 +26,10 @@
2626
"strip-ansi": "^7.1.2"
2727
},
2828
"devDependencies": {
29+
"@codifycli/plugin-core": "1.0.0-beta2",
2930
"@oclif/prettier-config": "^0.2.1",
3031
"@types/debug": "^4.1.12",
31-
"@types/node": "^18",
32+
"@types/node": "^22",
3233
"@types/lodash.matches": "^4.6.9",
3334
"@types/lodash.differencewith": "^4.5.9",
3435
"@types/lodash.unionby": "^4.8.9",
@@ -38,8 +39,7 @@
3839
"eslint-config-prettier": "^9.0.0",
3940
"tsx": "^4.7.3",
4041
"typescript": "5.3.3",
41-
"vitest": "^1.4.0",
42-
"codify-plugin-lib": "1.0.182-beta9"
42+
"vitest": "^4.0.18"
4343
},
4444
"engines": {
4545
"node": ">=18.0.0"

src/plugin-process.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Ajv from 'ajv';
21
import {
32
ApplyRequestData,
43
CommandRequestData,
@@ -13,11 +12,10 @@ import {
1312
PlanResponseData,
1413
ValidateRequestData,
1514
ValidateResponseData
16-
} from 'codify-schemas';
15+
} from '@codifycli/schemas';
16+
import Ajv from 'ajv';
1717
import { nanoid } from 'nanoid';
1818
import { ChildProcess, fork } from 'node:child_process';
19-
import fs from 'node:fs/promises';
20-
import * as os from 'node:os';
2119
import path from 'node:path';
2220

2321
import { spawnSafe } from './spawn.js';

src/plugin-tester.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import chalk from 'chalk';
21
import {
3-
ImportResponseData, OS,
2+
ImportResponseData,
43
PlanResponseData,
54
ResourceConfig,
65
ResourceOperation,
7-
} from 'codify-schemas';
6+
} from '@codifycli/schemas';
7+
import chalk from 'chalk';
88
import unionBy from 'lodash.unionby';
99

1010
import { PluginProcess } from './plugin-process.js';
1111
import { getPlatformOs, splitUserConfig } from './utils.js';
12-
import os from 'node:os';
1312

1413
export class PluginTester {
1514
static async fullTest(

src/spawn.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { SpawnStatus } from '@codifycli/schemas';
12
import * as pty from '@homebridge/node-pty-prebuilt-multiarch';
2-
import { SpawnStatus } from 'codify-schemas';
33
import stripAnsi from 'strip-ansi';
44

55
import { Shell, ShellUtils } from './shell.js';
@@ -16,6 +16,7 @@ export interface SpawnOptions {
1616
interactive?: boolean,
1717
requiresRoot?: boolean,
1818
stdin?: boolean,
19+
throws?: boolean,
1920
}
2021

2122
export function testSpawn(cmd: string, options?: SpawnOptions): Promise<SpawnResult> {
@@ -29,7 +30,7 @@ export function spawnSafe(cmd: string, options?: SpawnOptions): Promise<SpawnRes
2930

3031
console.log(`Running command: ${options?.requiresRoot ? 'sudo' : ''} ${cmd}` + (options?.cwd ? `(${options?.cwd})` : ''))
3132

32-
return new Promise((resolve) => {
33+
return new Promise((resolve, reject) => {
3334
const output: string[] = [];
3435
const historyIgnore = ShellUtils.getShell() === Shell.ZSH ? { HISTORY_IGNORE: '*' } : { HISTIGNORE: '*' };
3536

@@ -85,6 +86,11 @@ export function spawnSafe(cmd: string, options?: SpawnOptions): Promise<SpawnRes
8586
process.stdin.off('data', stdinListener);
8687
}
8788

89+
if (options?.throws && result.exitCode !== 0) {
90+
reject(new Error(stripAnsi(output.join('\n').trim())));
91+
return;
92+
}
93+
8894
resolve({
8995
status: result.exitCode === 0 ? SpawnStatus.SUCCESS : SpawnStatus.ERROR,
9096
exitCode: result.exitCode,

src/test-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ChildProcess } from 'node:child_process';
33
import { Readable } from 'stream';
44
import { TestUtils } from './test-utils.js';
55
import { describe, expect, it, vi } from 'vitest';
6-
import { MessageStatus } from 'codify-schemas';
6+
import { MessageStatus } from '@codifycli/schemas';
77
import { nanoid } from 'nanoid';
88

99
describe('Test Utils tests', async () => {

src/test-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Ajv from 'ajv';
2-
import { IpcMessageSchema, IpcMessageV2, MessageStatus, ResourceOs, SpawnStatus } from 'codify-schemas';
2+
import { IpcMessageSchema, IpcMessageV2, MessageStatus, ResourceOs, SpawnStatus } from '@codifycli/schemas';
33
import { ChildProcess } from 'node:child_process';
44
import os from 'node:os';
55
import path from 'node:path';

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResourceConfig, ResourceOs, StringIndexedObject } from 'codify-schemas';
1+
import { ResourceConfig, ResourceOs, StringIndexedObject } from '@codifycli/schemas';
22
import os from 'node:os';
33

44
export function splitUserConfig<T extends StringIndexedObject>(

test/plugin-tester.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
22
import { PluginTester } from '../src/index.js';
33
import path from 'node:path';
4-
import { ResourceOperation } from 'codify-schemas/src/types/index.js';
4+
import { ResourceOperation } from '@codifycli/schemas';
55
import deepMatches from 'lodash.matches';
66
import differenceWith from 'lodash.differencewith';
77
import { PluginProcess } from '../src/plugin-process';
88
import * as fs from 'node:fs';
9+
import { ResourceOs } from '@codifycli/schemas';
910

1011
const pluginPath = path.join(__dirname, './test-plugin.ts');
1112

@@ -316,15 +317,14 @@ describe('Plugin tester integration tests', () => {
316317
it('Can filter out unsupported configs based on OS', { timeout: 300000 }, async () => {
317318
await PluginTester.fullTest(pluginPath, [{
318319
type: 'windows-only',
320+
os: [ResourceOs.Windows],
319321
}], {
320322
validatePlan(plan) {
321323
expect(plan.length).to.eq(0);
322324
}
323325
});
324326
});
325327

326-
327-
328328
// it('Can uninstall two resources with the same type', async () => {
329329
// await plugin.fullTest([{
330330
// type: 'test-destroy',

test/test-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
Resource,
88
ResourceSettings,
99
runPlugin
10-
} from 'codify-plugin-lib';
11-
import { OS, StringIndexedObject } from 'codify-schemas';
10+
} from '@codifycli/plugin-core';
11+
import { OS, StringIndexedObject } from '@codifycli/schemas';
1212
import * as fs from 'node:fs';
1313

1414
export interface TestConfig extends StringIndexedObject {

0 commit comments

Comments
 (0)