@zgeoff/atc 2.17.0 → 2.19.0
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/package.json +1 -1
- package/src/client/build-workspace-destination.ts +38 -0
- package/src/client/pick-refusal-step.ts +29 -0
- package/src/client/resolve-workspace-root.ts +49 -0
- package/src/client/spawn-picker.ts +1655 -182
- package/src/shared/collect-workspaces-config.ts +25 -10
- package/src/shared/config.ts +17 -2
|
@@ -2,15 +2,21 @@ import { DEFAULT_GIT_TRANSPORTS } from './default-git-transports';
|
|
|
2
2
|
import { isRecord } from './report';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Where workspace sources come from
|
|
6
|
-
* the spawn picker lists by default, or
|
|
7
|
-
*
|
|
8
|
-
* default order;
|
|
5
|
+
* Where workspace sources come from and where their checkouts land: the
|
|
6
|
+
* GitHub owner whose repositories the spawn picker lists by default, or
|
|
7
|
+
* null to list the gh account's own; the ids of the sources the picker
|
|
8
|
+
* offers, in order, or null for the default order; the git transports the
|
|
9
|
+
* daemon fetches over; the root a checkout lands under on any target
|
|
10
|
+
* without its own, or null for the default; and each target's own root, by
|
|
11
|
+
* target id. A root is kept as written: whether it fits its target, such
|
|
12
|
+
* as `~` on a remote target, is checked where the target is known.
|
|
9
13
|
*/
|
|
10
14
|
export interface WorkspacesConfig {
|
|
11
15
|
readonly githubOwner: string | null;
|
|
12
16
|
readonly sources: readonly string[] | null;
|
|
13
17
|
readonly gitTransports: readonly string[] | InvalidGitTransports;
|
|
18
|
+
readonly root: string | null;
|
|
19
|
+
readonly targetRoots: ReadonlyMap<string, string>;
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
/**
|
|
@@ -34,17 +40,20 @@ const GITHUB_OWNER_PATTERN = /^[A-Za-z\d][A-Za-z\d-]{0,38}$/u;
|
|
|
34
40
|
/**
|
|
35
41
|
* Reads the `workspaces` section of config.json. An owner that is not a
|
|
36
42
|
* GitHub login is dropped, so a typo lists the gh account's own
|
|
37
|
-
* repositories instead of failing,
|
|
38
|
-
*
|
|
43
|
+
* repositories instead of failing, a source order that is not a list of
|
|
44
|
+
* ids falls back to the default order, and a root that is not a non-empty
|
|
45
|
+
* string is dropped. A transport list that is not a
|
|
39
46
|
* list of transports atc allows is a config error, and the list is then
|
|
40
47
|
* invalid, never the default, so the daemon runs no git until it is fixed.
|
|
41
48
|
* An empty list is valid and allows no transport.
|
|
42
49
|
*/
|
|
43
50
|
export function collectWorkspacesConfig(raw: unknown): CollectedWorkspacesConfig {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
51
|
+
const section = isRecord(raw) ? raw : {};
|
|
52
|
+
const owner = section['githubOwner'];
|
|
53
|
+
const sources = section['sources'];
|
|
54
|
+
const root = section['root'];
|
|
55
|
+
const targets = isRecord(section['targets']) ? section['targets'] : {};
|
|
56
|
+
const transports = collectGitTransports(section['gitTransports']);
|
|
48
57
|
|
|
49
58
|
return {
|
|
50
59
|
workspaces: {
|
|
@@ -55,6 +64,12 @@ export function collectWorkspacesConfig(raw: unknown): CollectedWorkspacesConfig
|
|
|
55
64
|
? sources
|
|
56
65
|
: null,
|
|
57
66
|
gitTransports: transports.transports,
|
|
67
|
+
root: typeof root === 'string' && root !== '' ? root : null,
|
|
68
|
+
targetRoots: new Map(
|
|
69
|
+
Object.entries(targets).flatMap(([id, dir]) =>
|
|
70
|
+
typeof dir === 'string' && dir !== '' ? [[id, dir] as const] : [],
|
|
71
|
+
),
|
|
72
|
+
),
|
|
58
73
|
},
|
|
59
74
|
errors: transports.errors,
|
|
60
75
|
};
|
package/src/shared/config.ts
CHANGED
|
@@ -70,7 +70,13 @@ const DEFAULTS: Config = {
|
|
|
70
70
|
codexBin: 'codex',
|
|
71
71
|
codexArgs: [],
|
|
72
72
|
dirs: { roots: [] },
|
|
73
|
-
workspaces: {
|
|
73
|
+
workspaces: {
|
|
74
|
+
githubOwner: null,
|
|
75
|
+
sources: null,
|
|
76
|
+
gitTransports: DEFAULT_GIT_TRANSPORTS,
|
|
77
|
+
root: null,
|
|
78
|
+
targetRoots: new Map(),
|
|
79
|
+
},
|
|
74
80
|
gateways: [],
|
|
75
81
|
hooks: {},
|
|
76
82
|
leader: { code: 0, label: '^Space' },
|
|
@@ -211,10 +217,19 @@ export function renderDefaultConfig(): string {
|
|
|
211
217
|
principals: _principals,
|
|
212
218
|
principalErrors: _principalErrors,
|
|
213
219
|
workspaceErrors: _workspaceErrors,
|
|
220
|
+
workspaces,
|
|
214
221
|
...written
|
|
215
222
|
} = DEFAULTS;
|
|
216
223
|
|
|
217
|
-
|
|
224
|
+
// The target roots are a map in memory and an object of target ids in
|
|
225
|
+
// the file.
|
|
226
|
+
const { targetRoots, ...rest } = workspaces;
|
|
227
|
+
|
|
228
|
+
return `${JSON.stringify(
|
|
229
|
+
{ ...written, workspaces: { ...rest, targets: Object.fromEntries(targetRoots) } },
|
|
230
|
+
null,
|
|
231
|
+
2,
|
|
232
|
+
)}\n`;
|
|
218
233
|
}
|
|
219
234
|
|
|
220
235
|
/**
|