Skip to content

Commit d6e90b2

Browse files
committed
feat: Added os support
1 parent a970a4b commit d6e90b2

3 files changed

Lines changed: 38 additions & 9 deletions

File tree

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-plugin-test",
3-
"version": "0.0.53",
3+
"version": "0.0.53-beta11",
44
"description": "",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
@@ -16,12 +16,14 @@
1616
"dependencies": {
1717
"ajv": "^8.12.0",
1818
"ajv-formats": "^3.0.1",
19-
"codify-schemas": "1.0.77",
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",
2323
"nanoid": "^5.0.9",
24-
"chalk": "^5.4.1"
24+
"chalk": "^5.4.1",
25+
"@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
26+
"strip-ansi": "^7.1.2"
2527
},
2628
"devDependencies": {
2729
"@oclif/prettier-config": "^0.2.1",
@@ -37,7 +39,7 @@
3739
"tsx": "^4.7.3",
3840
"typescript": "5.3.3",
3941
"vitest": "^1.4.0",
40-
"codify-plugin-lib": "1.0.171"
42+
"codify-plugin-lib": "1.0.182-beta9"
4143
},
4244
"engines": {
4345
"node": ">=18.0.0"

src/plugin-tester.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import unionBy from 'lodash.unionby';
99

1010
import { PluginProcess } from './plugin-process.js';
11-
import { splitUserConfig } from './utils.js';
11+
import { getResourceOs, splitUserConfig } from './utils.js';
1212

1313
export class PluginTester {
1414
static async fullTest(
@@ -26,8 +26,12 @@ export class PluginTester {
2626
validateModify?: (plans: PlanResponseData[]) => Promise<void> | void,
2727
}
2828
}): Promise<void> {
29-
const ids = configs.map((c) => c.name ? `${c.type}.${c.name}` : c.type).join(', ')
30-
console.info(chalk.cyan(`Starting full test of [ ${ids} ]...`))
29+
configs = configs.filter((c) => !c.os || c.os.includes(getResourceOs()));
30+
const ids = configs
31+
.map((c) => `${c.type}${c.name ? `.${c.name}` : ''}`)
32+
.join(', ')
33+
console.info(chalk.cyan(`Starting full test of [ ${ids} ]...`));
34+
3135

3236
const {
3337
skipUninstall = false,

src/utils.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ResourceConfig, StringIndexedObject } from 'codify-schemas';
1+
import { ResourceConfig, ResourceOs, StringIndexedObject } from 'codify-schemas';
2+
import os from 'node:os';
23

34
export function splitUserConfig<T extends StringIndexedObject>(
45
config: ResourceConfig & T
@@ -7,13 +8,35 @@ export function splitUserConfig<T extends StringIndexedObject>(
78
type: config.type,
89
...(config.name ? { name: config.name } : {}),
910
...(config.dependsOn ? { dependsOn: config.dependsOn } : {}),
11+
...(config.os ? { os: config.os } : {}),
1012
};
1113

1214
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13-
const { type, name, dependsOn, ...parameters } = config;
15+
const { type, name, dependsOn, os, ...parameters } = config;
1416

1517
return {
1618
parameters: parameters as T,
1719
coreParameters,
1820
};
1921
}
22+
23+
export function getResourceOs(): ResourceOs{
24+
const currOs = os.platform();
25+
switch (currOs) {
26+
case 'darwin': {
27+
return ResourceOs.MACOS;
28+
}
29+
30+
case 'linux': {
31+
return ResourceOs.LINUX;
32+
}
33+
34+
case 'win32': {
35+
return ResourceOs.WINDOWS;
36+
}
37+
38+
default: {
39+
throw new Error(`Unsupported OS: ${currOs}`);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)