Skip to content

Commit b40eaa1

Browse files
committed
refactor(provision-kit): move install source config
1 parent 544a804 commit b40eaa1

7 files changed

Lines changed: 94 additions & 2 deletions

File tree

‎packages/provision-kit/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
"types": "./src/install-source.ts",
2929
"default": "./src/install-source.ts"
3030
},
31+
"./install-source-config": {
32+
"types": "./src/install-source-config.ts",
33+
"default": "./src/install-source-config.ts"
34+
},
3135
"./install-source-network": {
3236
"types": "./src/install-source-network.ts",
3337
"default": "./src/install-source-network.ts"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import assert from 'node:assert/strict';
2+
import { test } from 'vitest';
3+
import { AppError } from '@agent-device/kernel/errors';
4+
import {
5+
parseGitHubActionsArtifactInstallSourceSpec,
6+
parseInstallSourceConfig,
7+
} from './install-source-config.ts';
8+
9+
test('parses GitHub Actions artifact specs into the exact install source shape', () => {
10+
assert.deepEqual(parseGitHubActionsArtifactInstallSourceSpec(' acme/mobile: 12345 '), {
11+
kind: 'github-actions-artifact',
12+
owner: 'acme',
13+
repo: 'mobile',
14+
artifactId: 12345,
15+
});
16+
assert.deepEqual(parseGitHubActionsArtifactInstallSourceSpec('acme/mobile: build-debug'), {
17+
kind: 'github-actions-artifact',
18+
owner: 'acme',
19+
repo: 'mobile',
20+
artifactName: 'build-debug',
21+
});
22+
});
23+
24+
test('parses config artifact names and numeric IDs with trimmed repository fields', () => {
25+
assert.deepEqual(
26+
parseInstallSourceConfig(
27+
{
28+
type: 'github-actions-artifact',
29+
repo: ' acme/mobile ',
30+
artifact: ' build-debug ',
31+
},
32+
'user config file',
33+
),
34+
{
35+
kind: 'github-actions-artifact',
36+
owner: 'acme',
37+
repo: 'mobile',
38+
artifactName: 'build-debug',
39+
},
40+
);
41+
assert.deepEqual(
42+
parseInstallSourceConfig(
43+
{ type: 'github-actions-artifact', repo: 'acme/mobile', artifact: '12345' },
44+
'project config file',
45+
),
46+
{
47+
kind: 'github-actions-artifact',
48+
owner: 'acme',
49+
repo: 'mobile',
50+
artifactId: 12345,
51+
},
52+
);
53+
});
54+
55+
test('rejects empty and malformed source values with typed INVALID_ARGS errors', () => {
56+
assertInvalidArgs(
57+
() => parseGitHubActionsArtifactInstallSourceSpec(''),
58+
'--github-actions-artifact must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232',
59+
);
60+
assertInvalidArgs(
61+
() => parseGitHubActionsArtifactInstallSourceSpec('acme/mobile:'),
62+
'--github-actions-artifact must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232',
63+
);
64+
assertInvalidArgs(
65+
() =>
66+
parseInstallSourceConfig(
67+
{ type: 'github-actions-artifact', repo: 'acme/mobile', artifact: ' ' },
68+
'config',
69+
),
70+
'config installSource.artifact must be a non-empty string.',
71+
);
72+
assertInvalidArgs(
73+
() => parseInstallSourceConfig({ type: 'github-actions-artifact', repo: 'acme' }, 'config'),
74+
'config installSource.repo must use owner/repo.',
75+
);
76+
});
77+
78+
function assertInvalidArgs(run: () => unknown, message: string): void {
79+
assert.throws(run, (error: unknown) => {
80+
assert.ok(error instanceof AppError);
81+
assert.equal(error.code, 'INVALID_ARGS');
82+
assert.equal(error.message, message);
83+
assert.equal(error.cause, undefined);
84+
return true;
85+
});
86+
}
File renamed without changes.

‎scripts/layering/package-boundaries.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ test('the real tree parses, declares, and passes R11', () => {
487487
'@agent-device/provision-kit/boot-diagnostics',
488488
'@agent-device/provision-kit/install-artifact-archive-context',
489489
'@agent-device/provision-kit/install-source',
490+
'@agent-device/provision-kit/install-source-config',
490491
'@agent-device/provision-kit/install-source-network',
491492
'@agent-device/provision-kit/install-source-network-transport',
492493
'@agent-device/provision-kit/toolchain-probe',

‎src/__tests__/eager-closure-budgets.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const FACADE_BUDGETS: Readonly<Record<string, number>> = Object.freeze({
159159
'packages/provision-kit/src/boot-diagnostics.ts': 3,
160160
'packages/provision-kit/src/install-artifact-archive-context.ts': 10,
161161
'packages/provision-kit/src/install-source.ts': 26,
162+
'packages/provision-kit/src/install-source-config.ts': 3,
162163
'packages/provision-kit/src/install-source-network.ts': 3,
163164
'packages/provision-kit/src/install-source-network-transport.ts': 1,
164165
'packages/provision-kit/src/toolchain-probe.ts': 8,

‎src/cli-schema/cli-config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
getOptionSpec,
1111
parseOptionValueFromSource,
1212
} from './option-schema.ts';
13-
import { parseInstallSourceConfig } from '../utils/install-source-config.ts';
13+
import { parseInstallSourceConfig } from '@agent-device/provision-kit/install-source-config';
1414
import { RETIRED_SCREENSHOT_MAX_SIZE } from '@agent-device/contracts/capture';
1515
import { type EnvMap } from '@agent-device/kernel/source-value';
1616

‎src/commands/management/install.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { DaemonInstallSource } from '@agent-device/kernel/contracts';
33
import type { CliFlags } from '@agent-device/contracts/command';
44
import type { CommandSchemaOverride } from '../../cli-schema/types.ts';
55
import { AppError } from '@agent-device/kernel/errors';
6-
import { parseGitHubActionsArtifactInstallSourceSpec } from '../../utils/install-source-config.ts';
6+
import { parseGitHubActionsArtifactInstallSourceSpec } from '@agent-device/provision-kit/install-source-config';
77
import {
88
booleanField,
99
jsonSchemaField,

0 commit comments

Comments
 (0)