@bakers-build/conductor 0.5.1-next.850 → 0.5.1-next.852
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/dist/src/cli/config-plan.d.ts +2 -2
- package/dist/src/cli/config-plan.js +22 -503
- package/dist/src/cli/config-schema.d.ts +4 -78
- package/dist/src/cli/config-schema.js +5 -144
- package/dist/src/cli/config-templates.d.ts +1 -12
- package/dist/src/cli/config-templates.js +11 -52
- package/dist/src/cli/config-validation.js +22 -39
- package/dist/src/cli/project-context.js +1 -1
- package/dist/src/commands/conductor.d.ts +9 -1
- package/dist/src/commands/conductor.js +103 -21
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +31 -37
- package/dist/src/contract.d.ts +1 -0
- package/dist/src/contract.js +1 -0
- package/dist/src/core/conductor.d.ts +11 -18
- package/dist/src/core/conductor.js +33 -37
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.js +0 -7
- package/dist/src/plugins/remote.d.ts +19 -1
- package/dist/src/plugins/remote.js +13 -1
- package/dist/src/types.d.ts +9 -14
- package/package.json +4 -4
- package/dist/src/cli/migrate-addon-names.d.ts +0 -82
- package/dist/src/cli/migrate-addon-names.js +0 -334
- package/dist/src/core/host-key.d.ts +0 -19
- package/dist/src/core/host-key.js +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/conductor",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.852",
|
|
4
4
|
"description": "bakers.build conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@dropsh/plugin-jsonapi-schema": "^0.8.2",
|
|
34
34
|
"@dropsh/plugin-oauth2": "^0.8.2",
|
|
35
|
-
"@bakers-build/core": "^0.5.1-next.
|
|
36
|
-
"@bakers-build/message": "^0.5.1-next.
|
|
35
|
+
"@bakers-build/core": "^0.5.1-next.852",
|
|
36
|
+
"@bakers-build/message": "^0.5.1-next.852",
|
|
37
37
|
"commander": "^12.1.0",
|
|
38
38
|
"dropsh": "^0.8.2"
|
|
39
39
|
},
|
|
40
40
|
"bakersBuild": {
|
|
41
|
-
"commit": "
|
|
41
|
+
"commit": "11ac39f9f194501ed439fbc34b2f8d3f4f6addca",
|
|
42
42
|
"channel": "next"
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/** Suffix of the pre-rewrite backup a real (non-dry) rewrite leaves behind. */
|
|
2
|
-
export declare const ADDON_RENAME_BAK_SUFFIX = ".pre-addon-rename.bak";
|
|
3
|
-
/**
|
|
4
|
-
* The 14 addon packages renamed by BB-224 (spec v3 decision 14), including
|
|
5
|
-
* the BB-220 `pi` agent addon merged in from develop. A CLOSED
|
|
6
|
-
* set — the pass rewrites only these exact specifiers, so an unknown
|
|
7
|
-
* `@bakers-build/plugin-something` is left alone rather than silently retargeted at a
|
|
8
|
-
* package that does not exist.
|
|
9
|
-
*/
|
|
10
|
-
export declare const RENAMED_ADDONS: readonly ["auth-basic", "claude", "codex", "deployment", "dropsh", "essentials", "fake", "bakers-ui", "herdr", "kimi", "opencode", "pi", "remote-drupal", "workspace-git"];
|
|
11
|
-
/**
|
|
12
|
-
* Where each export of the host barrels lives now — the DELETED
|
|
13
|
-
* `@bakers-build/core/plugins` and (BB-230) the meta package's
|
|
14
|
-
* `@bakers-build/bakers/plugins`, which is unresolvable from a dev-clone install.
|
|
15
|
-
*
|
|
16
|
-
* The key set is the barrel's own export list — `core/src/plugins/registry-exports.ts`
|
|
17
|
-
* as of the commit that deleted it — re-pointed at the addon that owns each
|
|
18
|
-
* factory today. `defaultExport` records whether the target package
|
|
19
|
-
* DEFAULT-exports exactly that factory; when it does, the descriptor's `export:`
|
|
20
|
-
* becomes redundant and is dropped.
|
|
21
|
-
*
|
|
22
|
-
* Deliberately absent, so they are left untouched:
|
|
23
|
-
* - `selectRemote`/`selectWorkspace`/`selectExecutor`/`selectAgent(s)` — moved
|
|
24
|
-
* to `@bakers-build/conductor/contract`, but they are config-shape SELECTORS, not
|
|
25
|
-
* plugin factories, so no descriptor can legitimately name them;
|
|
26
|
-
* - any other/unknown export name — a config naming one is reported by the
|
|
27
|
-
* loader rather than silently retargeted at a package that may not have it.
|
|
28
|
-
*/
|
|
29
|
-
export declare const CORE_PLUGINS_BARREL_EXPORTS: Readonly<Record<string, {
|
|
30
|
-
target: string;
|
|
31
|
-
defaultExport: boolean;
|
|
32
|
-
}>>;
|
|
33
|
-
/**
|
|
34
|
-
* The host-barrel specifiers a descriptor may name. Both map through
|
|
35
|
-
* `CORE_PLUGINS_BARREL_EXPORTS`: `@bakers-build/core/plugins` is DELETED, and
|
|
36
|
-
* `@bakers-build/bakers/plugins` (BB-230) is unresolvable from a dev-clone install
|
|
37
|
-
* because the meta package that exports it is the workspace's leaf sink.
|
|
38
|
-
*/
|
|
39
|
-
export declare const HOST_BARREL_PATHS: readonly ["@bakers-build/core/plugins", "@bakers-build/bakers/plugins"];
|
|
40
|
-
/** Which surface a config file speaks — decides the ambiguous builtins mapping. */
|
|
41
|
-
export type ConfigSurface = 'connection' | 'engine';
|
|
42
|
-
/**
|
|
43
|
-
* Rewrite the legacy specifiers in one config's SOURCE TEXT — all of them: the
|
|
44
|
-
* renamed `@bakers-build/plugin-*` packages, the deleted `@bakers-build/core/builtins`
|
|
45
|
-
* preset, and the host-barrel descriptors naming either `@bakers-build/core/plugins`
|
|
46
|
-
* (deleted) or `@bakers-build/bakers/plugins` (BB-230). Pure; line
|
|
47
|
-
* count is preserved (every replacement is line-local), which is what lets the
|
|
48
|
-
* reported diff be a plain index-aligned line diff.
|
|
49
|
-
*/
|
|
50
|
-
export declare function migrateAddonNames(text: string, surface: ConfigSurface): {
|
|
51
|
-
text: string;
|
|
52
|
-
count: number;
|
|
53
|
-
};
|
|
54
|
-
/** The outcome of the rename pass over a single config file. */
|
|
55
|
-
export interface AddonRenameResult {
|
|
56
|
-
/** Report line, in the shape of the other upgrade steps. */
|
|
57
|
-
action: string;
|
|
58
|
-
/** `- old` / `+ new` lines for the rewritten specifiers. */
|
|
59
|
-
diff: string[];
|
|
60
|
-
/** Number of rewritten specifiers. */
|
|
61
|
-
count: number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Rename pass over ONE config file. Returns `undefined` when the file is absent
|
|
65
|
-
* or already on the new names (idempotency: no write, no backup, no report
|
|
66
|
-
* line — the file stays byte-identical).
|
|
67
|
-
*/
|
|
68
|
-
export declare function migrateAddonNamesInFile(path: string, surface: ConfigSurface, opts?: {
|
|
69
|
-
dryRun?: boolean;
|
|
70
|
-
}): AddonRenameResult | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Rename pass over every recognised config in the given `.bakers/` dirs (project
|
|
73
|
-
* + home). Emits report lines ONLY for files it actually rewrites, so an install
|
|
74
|
-
* already on `addon-*` adds no noise to the upgrade report.
|
|
75
|
-
*/
|
|
76
|
-
export declare function runAddonRenameMigration(opts?: {
|
|
77
|
-
bakersDirs: string[];
|
|
78
|
-
dryRun?: boolean;
|
|
79
|
-
}): {
|
|
80
|
-
actions: string[];
|
|
81
|
-
changed: boolean;
|
|
82
|
-
};
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { inspectConfigSource } from '@bakers-build/core';
|
|
4
|
-
import { listConductorConfigFiles } from '../config.js';
|
|
5
|
-
import { ConfigSourceEditor } from './config-source-edit.js';
|
|
6
|
-
// BB-224 (Finding 8b, spec v3 decision 17): the `bakers config upgrade` RENAME pass.
|
|
7
|
-
//
|
|
8
|
-
// The addon packages were renamed `@bakers-build/plugin-<name>` → `@bakers-build/addon-<name>`
|
|
9
|
-
// (decision 14) and the core barrels `@bakers-build/core/{builtins,plugins}` were
|
|
10
|
-
// deleted (Finding 6). Both are npm-breaking for an existing install, whose
|
|
11
|
-
// `.bakers/` configs still name the old packages — so `bakers config upgrade` rewrites them
|
|
12
|
-
// in the user's PROJECT `./.bakers/` and HOME `~/.bakers/` configs.
|
|
13
|
-
//
|
|
14
|
-
// All THREE deleted/renamed specifiers are covered, and — BB-230 — so is the
|
|
15
|
-
// FOURTH: the `@bakers-build/bakers/plugins` host barrel.
|
|
16
|
-
//
|
|
17
|
-
// BB-224 excluded that barrel on the premise that it "still exists as a
|
|
18
|
-
// back-compat aggregator", so a config naming it keeps resolving. That premise is
|
|
19
|
-
// INSTALL-DEPENDENT and false for a dev-clone install: `@bakers-build/bakers` is the
|
|
20
|
-
// workspace's leaf SINK, so nothing depends on it and it is absent from
|
|
21
|
-
// `bakers-cli/node_modules/@bakers-build/`; it is also the only package exporting
|
|
22
|
-
// `./plugins` (`@bakers-build/core`'s export map has no such subpath). The `bakers` shim
|
|
23
|
-
// prefers a checkout's own build over the global install by design, so exactly
|
|
24
|
-
// there the barrel is unresolvable and that one config line dies while its
|
|
25
|
-
// sibling `addon-*` slots resolve fine.
|
|
26
|
-
//
|
|
27
|
-
// The barrel itself keeps existing — this is not repairing a dead reference, it is
|
|
28
|
-
// making configs stop NAMING a barrel the project docs already tell them not to
|
|
29
|
-
// name. Both barrels are therefore migrated the same closed-set way, over the same
|
|
30
|
-
// `CORE_PLUGINS_BARREL_EXPORTS` table. Two deliberate consequences:
|
|
31
|
-
// - the table is a SUPERSET of what `@bakers-build/bakers/plugins` actually re-exports
|
|
32
|
-
// (`host/src/plugins-barrel.ts` omits the fakes on purpose — they are
|
|
33
|
-
// workspace-only and must not be a published package's dependency). Mapping
|
|
34
|
-
// them anyway is right: such a descriptor is broken today, and retargeting it
|
|
35
|
-
// at `@bakers-build/addon-fake` fixes it.
|
|
36
|
-
// - `loadInstructions` IS a barrel export but is not a plugin factory and is
|
|
37
|
-
// absent from the table, so it stays untouched — as does any other unmapped
|
|
38
|
-
// `export:`.
|
|
39
|
-
//
|
|
40
|
-
// Covered per config dir:
|
|
41
|
-
// - the connection config `bakers.config.js` (its `plugins[]` / `addons[]`);
|
|
42
|
-
// - EVERY engine config the loader itself recognises — the default
|
|
43
|
-
// `conductor.config.js` AND each `<variant>.conductor.config.js`
|
|
44
|
-
// (BB-137 naming convention, enumerated via `listConductorConfigFiles` so
|
|
45
|
-
// the pass and the loader can never disagree). A legacy `conductor.config.js`
|
|
46
|
-
// still carrying `site`/`plugins` (the back-compat connection source) is
|
|
47
|
-
// therefore covered too, and its `plugins[]` entries are mapped on the
|
|
48
|
-
// CONNECTION surface — see `builtinsTargetFor`.
|
|
49
|
-
//
|
|
50
|
-
// Safety (decision 18 + the v3 risk register):
|
|
51
|
-
// - Replacement is anchored on a CLOSED set of 14 known package names inside
|
|
52
|
-
// a matched quote pair — never a broad `@bakers-build/plugin-.*` sweep. A
|
|
53
|
-
// hand-written config's comments, formatting and unrelated code survive.
|
|
54
|
-
// The `@bakers-build/core/plugins` rewrite is likewise closed-set: it is driven by
|
|
55
|
-
// the barrel's OWN export list, and an export name outside that list is left
|
|
56
|
-
// untouched rather than retargeted at a guess.
|
|
57
|
-
// - `*Plugin` interface identifiers (`RemotePlugin`, `herdrExecutorPlugin`, …)
|
|
58
|
-
// and the `plugins:`/`addons:` config KEYS are excluded BY CONSTRUCTION: a
|
|
59
|
-
// replacement only ever fires on a full quoted specifier, and none of those
|
|
60
|
-
// is one.
|
|
61
|
-
// - Idempotent: a config already on `addon-*` produces zero matches and is
|
|
62
|
-
// left BYTE-unchanged (no rewrite, no backup, no report line).
|
|
63
|
-
// - `--dry-run` prints the line diff and writes nothing.
|
|
64
|
-
// - A real rewrite backs the original up next to the file, like the
|
|
65
|
-
// schema-migration path does.
|
|
66
|
-
/** Suffix of the pre-rewrite backup a real (non-dry) rewrite leaves behind. */
|
|
67
|
-
export const ADDON_RENAME_BAK_SUFFIX = '.pre-addon-rename.bak';
|
|
68
|
-
const AUTH_BASIC = '@bakers-build/addon-auth-basic';
|
|
69
|
-
const REMOTE_DRUPAL = '@bakers-build/addon-remote-drupal';
|
|
70
|
-
const WORKSPACE_GIT = '@bakers-build/addon-workspace-git';
|
|
71
|
-
const FAKE = '@bakers-build/addon-fake';
|
|
72
|
-
/**
|
|
73
|
-
* The 14 addon packages renamed by BB-224 (spec v3 decision 14), including
|
|
74
|
-
* the BB-220 `pi` agent addon merged in from develop. A CLOSED
|
|
75
|
-
* set — the pass rewrites only these exact specifiers, so an unknown
|
|
76
|
-
* `@bakers-build/plugin-something` is left alone rather than silently retargeted at a
|
|
77
|
-
* package that does not exist.
|
|
78
|
-
*/
|
|
79
|
-
export const RENAMED_ADDONS = [
|
|
80
|
-
'auth-basic',
|
|
81
|
-
'claude',
|
|
82
|
-
'codex',
|
|
83
|
-
'deployment',
|
|
84
|
-
'dropsh',
|
|
85
|
-
'essentials',
|
|
86
|
-
'fake',
|
|
87
|
-
'bakers-ui',
|
|
88
|
-
'herdr',
|
|
89
|
-
'kimi',
|
|
90
|
-
'opencode',
|
|
91
|
-
'pi',
|
|
92
|
-
'remote-drupal',
|
|
93
|
-
'workspace-git',
|
|
94
|
-
];
|
|
95
|
-
/**
|
|
96
|
-
* `'@bakers-build/plugin-<known>'` (or `"…"` / `` `…` ``), with an optional subpath
|
|
97
|
-
* (`/preset`), inside a MATCHED quote pair. The quote pair + the closing anchor
|
|
98
|
-
* are what make this an exact-specifier match: `@bakers-build/plugin-herdr-x` cannot
|
|
99
|
-
* match `herdr`, and a bare `RemotePlugin` identifier cannot match at all.
|
|
100
|
-
* Longest name first so a longer name always wins the alternation.
|
|
101
|
-
*/
|
|
102
|
-
const QUOTED_LEGACY_ADDON = new RegExp(`(['"\`])@bakers-build/plugin-(${[...RENAMED_ADDONS]
|
|
103
|
-
.sort((a, b) => b.length - a.length)
|
|
104
|
-
.join('|')})((?:/[^'"\`]*)?)\\1`, 'g');
|
|
105
|
-
/** `'@bakers-build/core/builtins'` inside a matched quote pair (the deleted preset). */
|
|
106
|
-
const QUOTED_LEGACY_BUILTINS = /(['"`])@bakers-build\/core\/builtins\1/g;
|
|
107
|
-
/**
|
|
108
|
-
* Where each export of the host barrels lives now — the DELETED
|
|
109
|
-
* `@bakers-build/core/plugins` and (BB-230) the meta package's
|
|
110
|
-
* `@bakers-build/bakers/plugins`, which is unresolvable from a dev-clone install.
|
|
111
|
-
*
|
|
112
|
-
* The key set is the barrel's own export list — `core/src/plugins/registry-exports.ts`
|
|
113
|
-
* as of the commit that deleted it — re-pointed at the addon that owns each
|
|
114
|
-
* factory today. `defaultExport` records whether the target package
|
|
115
|
-
* DEFAULT-exports exactly that factory; when it does, the descriptor's `export:`
|
|
116
|
-
* becomes redundant and is dropped.
|
|
117
|
-
*
|
|
118
|
-
* Deliberately absent, so they are left untouched:
|
|
119
|
-
* - `selectRemote`/`selectWorkspace`/`selectExecutor`/`selectAgent(s)` — moved
|
|
120
|
-
* to `@bakers-build/conductor/contract`, but they are config-shape SELECTORS, not
|
|
121
|
-
* plugin factories, so no descriptor can legitimately name them;
|
|
122
|
-
* - any other/unknown export name — a config naming one is reported by the
|
|
123
|
-
* loader rather than silently retargeted at a package that may not have it.
|
|
124
|
-
*/
|
|
125
|
-
export const CORE_PLUGINS_BARREL_EXPORTS = {
|
|
126
|
-
DrupalBbRemote: { target: REMOTE_DRUPAL, defaultExport: false },
|
|
127
|
-
FakeBbRemote: { target: FAKE, defaultExport: false },
|
|
128
|
-
FakeWorkspace: { target: FAKE, defaultExport: false },
|
|
129
|
-
GitWorkspace: { target: WORKSPACE_GIT, defaultExport: false },
|
|
130
|
-
basicAuthProvider: { target: AUTH_BASIC, defaultExport: true },
|
|
131
|
-
drupalRemote: { target: REMOTE_DRUPAL, defaultExport: true },
|
|
132
|
-
// @bakers-build/addon-fake ships the whole deterministic triple as NAMED exports
|
|
133
|
-
// (no default), so these keep their `export:`.
|
|
134
|
-
fakeRemote: { target: FAKE, defaultExport: false },
|
|
135
|
-
fakeWorkspace: { target: FAKE, defaultExport: false },
|
|
136
|
-
gitWorkspace: { target: WORKSPACE_GIT, defaultExport: true },
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* The host-barrel specifiers a descriptor may name. Both map through
|
|
140
|
-
* `CORE_PLUGINS_BARREL_EXPORTS`: `@bakers-build/core/plugins` is DELETED, and
|
|
141
|
-
* `@bakers-build/bakers/plugins` (BB-230) is unresolvable from a dev-clone install
|
|
142
|
-
* because the meta package that exports it is the workspace's leaf sink.
|
|
143
|
-
*/
|
|
144
|
-
export const HOST_BARREL_PATHS = [
|
|
145
|
-
'@bakers-build/core/plugins',
|
|
146
|
-
'@bakers-build/bakers/plugins',
|
|
147
|
-
];
|
|
148
|
-
/**
|
|
149
|
-
* The object-literal entry that encloses `at`, e.g.
|
|
150
|
-
* `{ use: '@bakers-build/core/builtins', with: { basic: token } }`. Empty string when
|
|
151
|
-
* the occurrence is a BARE string entry (`addons: ['@bakers-build/core/builtins']`) —
|
|
152
|
-
* the backward scan then hits the array/argument boundary first.
|
|
153
|
-
*/
|
|
154
|
-
function enclosingEntry(text, at) {
|
|
155
|
-
let depth = 0;
|
|
156
|
-
let start = -1;
|
|
157
|
-
for (let i = at; i >= 0; i--) {
|
|
158
|
-
const c = text[i];
|
|
159
|
-
if (c === '}')
|
|
160
|
-
depth++;
|
|
161
|
-
else if (c === '{') {
|
|
162
|
-
if (depth === 0) {
|
|
163
|
-
start = i;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
depth--;
|
|
167
|
-
}
|
|
168
|
-
else if (depth === 0 && (c === '[' || c === '(' || c === ';')) {
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (start < 0)
|
|
173
|
-
return '';
|
|
174
|
-
let d = 0;
|
|
175
|
-
for (let i = start; i < text.length; i++) {
|
|
176
|
-
const c = text[i];
|
|
177
|
-
if (c === '{')
|
|
178
|
-
d++;
|
|
179
|
-
else if (c === '}') {
|
|
180
|
-
d--;
|
|
181
|
-
if (d === 0)
|
|
182
|
-
return text.slice(start, i + 1);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return text.slice(start);
|
|
186
|
-
}
|
|
187
|
-
/** The nearest `plugins:` / `addons:` array key BEFORE `at`, if any. */
|
|
188
|
-
function nearestArrayKey(text, at) {
|
|
189
|
-
const re = /\b(plugins|addons)\s*:/g;
|
|
190
|
-
let last;
|
|
191
|
-
for (let m = re.exec(text); m !== null && m.index < at; m = re.exec(text)) {
|
|
192
|
-
last = m[1];
|
|
193
|
-
}
|
|
194
|
-
return last;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* `@bakers-build/core/builtins` was ONE preset contributing to BOTH surfaces, so its
|
|
198
|
-
* replacement is per-occurrence (spec v3 decision 17, the Finding 6/8 interplay):
|
|
199
|
-
*
|
|
200
|
-
* | signal (first that applies) | target |
|
|
201
|
-
* | the entry carries a `basic` token | `@bakers-build/addon-auth-basic` |
|
|
202
|
-
* | the nearest array key is `plugins:` | `@bakers-build/addon-auth-basic` |
|
|
203
|
-
* | the file is a connection config | `@bakers-build/addon-auth-basic` |
|
|
204
|
-
* | otherwise (engine `addons:` / a slot) | `@bakers-build/addon-remote-drupal` |
|
|
205
|
-
*
|
|
206
|
-
* The `plugins:` rule is what makes a LEGACY `conductor.config.js` (engine file
|
|
207
|
-
* name, but still carrying a connection `site`/`plugins`) come out right.
|
|
208
|
-
*/
|
|
209
|
-
function builtinsTargetFor(text, at, surface) {
|
|
210
|
-
if (/basic/i.test(enclosingEntry(text, at)))
|
|
211
|
-
return AUTH_BASIC;
|
|
212
|
-
if (nearestArrayKey(text, at) === 'plugins')
|
|
213
|
-
return AUTH_BASIC;
|
|
214
|
-
return surface === 'connection' ? AUTH_BASIC : REMOTE_DRUPAL;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Rewrite the legacy specifiers in one config's SOURCE TEXT — all of them: the
|
|
218
|
-
* renamed `@bakers-build/plugin-*` packages, the deleted `@bakers-build/core/builtins`
|
|
219
|
-
* preset, and the host-barrel descriptors naming either `@bakers-build/core/plugins`
|
|
220
|
-
* (deleted) or `@bakers-build/bakers/plugins` (BB-230). Pure; line
|
|
221
|
-
* count is preserved (every replacement is line-local), which is what lets the
|
|
222
|
-
* reported diff be a plain index-aligned line diff.
|
|
223
|
-
*/
|
|
224
|
-
export function migrateAddonNames(text, surface) {
|
|
225
|
-
const source = inspectConfigSource(text);
|
|
226
|
-
if (source.syntax !== 'valid')
|
|
227
|
-
return { text, count: 0 };
|
|
228
|
-
const e = new ConfigSourceEditor(text);
|
|
229
|
-
let count = 0;
|
|
230
|
-
const keys = [...source.properties.keys()].filter((key) => /(?:\.plugin|\.use|^plugins\[\d+\]$|^addons\[\d+\]$)$/.test(key));
|
|
231
|
-
for (const key of keys) {
|
|
232
|
-
const p = e.property(key);
|
|
233
|
-
if (!p?.staticallyDetermined || typeof p.value !== 'string')
|
|
234
|
-
continue;
|
|
235
|
-
let value = e.expression(key);
|
|
236
|
-
value = value.replace(QUOTED_LEGACY_ADDON, (_match, quote, name, subpath) => `${quote}@bakers-build/addon-${name}${subpath}${quote}`);
|
|
237
|
-
value = value.replace(QUOTED_LEGACY_BUILTINS, (_match, quote) => `${quote}${builtinsTargetFor(e.text, p.valueStart, surface)}${quote}`);
|
|
238
|
-
if (HOST_BARREL_PATHS.includes(p.value)) {
|
|
239
|
-
const parent = key.replace(/\.(plugin|use)$/, '');
|
|
240
|
-
const name = e.property(`${parent}.export`);
|
|
241
|
-
const target = typeof name?.value === 'string'
|
|
242
|
-
? CORE_PLUGINS_BARREL_EXPORTS[name.value]
|
|
243
|
-
: undefined;
|
|
244
|
-
if (target) {
|
|
245
|
-
value = `${value[0]}${target.target}${value[0]}`;
|
|
246
|
-
if (target.defaultExport && !e.expression(parent)?.includes('\n'))
|
|
247
|
-
e.remove(`${parent}.export`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (value !== e.expression(key)) {
|
|
251
|
-
e.set(key, value);
|
|
252
|
-
count++;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
for (const span of [...e.source.moduleSpecifiers].reverse()) {
|
|
256
|
-
const before = e.text.slice(span.start, span.end);
|
|
257
|
-
const after = before.replace(QUOTED_LEGACY_ADDON, (_match, quote, name, subpath) => `${quote}@bakers-build/addon-${name}${subpath}${quote}`);
|
|
258
|
-
if (before !== after) {
|
|
259
|
-
e.replace(span.start, span.end, after);
|
|
260
|
-
count++;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return { text: e.text, count };
|
|
264
|
-
}
|
|
265
|
-
/** An index-aligned `- old` / `+ new` line diff (line count is preserved). */
|
|
266
|
-
function lineDiff(before, after) {
|
|
267
|
-
const a = before.split('\n');
|
|
268
|
-
const b = after.split('\n');
|
|
269
|
-
const out = [];
|
|
270
|
-
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
271
|
-
if (a[i] === b[i])
|
|
272
|
-
continue;
|
|
273
|
-
if (a[i] !== undefined)
|
|
274
|
-
out.push(` - ${a[i]}`);
|
|
275
|
-
if (b[i] !== undefined)
|
|
276
|
-
out.push(` + ${b[i]}`);
|
|
277
|
-
}
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Rename pass over ONE config file. Returns `undefined` when the file is absent
|
|
282
|
-
* or already on the new names (idempotency: no write, no backup, no report
|
|
283
|
-
* line — the file stays byte-identical).
|
|
284
|
-
*/
|
|
285
|
-
export function migrateAddonNamesInFile(path, surface, opts = {}) {
|
|
286
|
-
if (!existsSync(path))
|
|
287
|
-
return undefined;
|
|
288
|
-
const before = readFileSync(path, 'utf8');
|
|
289
|
-
const { text: after, count } = migrateAddonNames(before, surface);
|
|
290
|
-
if (count === 0 || after === before)
|
|
291
|
-
return undefined;
|
|
292
|
-
const diff = lineDiff(before, after);
|
|
293
|
-
const what = `${count} legacy addon reference(s) → @bakers-build/addon-*`;
|
|
294
|
-
if (opts.dryRun ?? false) {
|
|
295
|
-
return { action: `would rewrite ${path} (${what})`, diff, count };
|
|
296
|
-
}
|
|
297
|
-
const bak = `${path}${ADDON_RENAME_BAK_SUFFIX}`;
|
|
298
|
-
writeFileSync(bak, before, 'utf8');
|
|
299
|
-
writeFileSync(path, after, 'utf8');
|
|
300
|
-
return {
|
|
301
|
-
action: `rewrote ${path} (${what}; backup ${bak})`,
|
|
302
|
-
diff,
|
|
303
|
-
count,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Rename pass over every recognised config in the given `.bakers/` dirs (project
|
|
308
|
-
* + home). Emits report lines ONLY for files it actually rewrites, so an install
|
|
309
|
-
* already on `addon-*` adds no noise to the upgrade report.
|
|
310
|
-
*/
|
|
311
|
-
export function runAddonRenameMigration(opts = { bakersDirs: [] }) {
|
|
312
|
-
const actions = [];
|
|
313
|
-
let changed = false;
|
|
314
|
-
const seen = new Set();
|
|
315
|
-
for (const dir of opts.bakersDirs) {
|
|
316
|
-
if (seen.has(dir) || !existsSync(dir))
|
|
317
|
-
continue;
|
|
318
|
-
seen.add(dir);
|
|
319
|
-
const files = [
|
|
320
|
-
[join(dir, 'bakers.config.js'), 'connection'],
|
|
321
|
-
...listConductorConfigFiles(dir).map((f) => [join(dir, f), 'engine']),
|
|
322
|
-
];
|
|
323
|
-
for (const [path, surface] of files) {
|
|
324
|
-
const res = migrateAddonNamesInFile(path, surface, {
|
|
325
|
-
dryRun: opts.dryRun ?? false,
|
|
326
|
-
});
|
|
327
|
-
if (res === undefined)
|
|
328
|
-
continue;
|
|
329
|
-
actions.push(res.action, ...res.diff);
|
|
330
|
-
changed = true;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return { actions, changed };
|
|
334
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host stem for `bb_machine.host_key` — the one entity that carries the
|
|
3
|
-
* field. `bb_conductor` has none, and reading one off it is precisely what
|
|
4
|
-
* left the host gate with no input at all (BB-450 review B7). Prefer
|
|
5
|
-
* `config.host_key` from MachineContext.machine_id; fall back to a
|
|
6
|
-
* best-effort parse of the composed `conductor_id` only when the loader could
|
|
7
|
-
* not supply the stem.
|
|
8
|
-
*
|
|
9
|
-
* Shared by the `Conductor` registration payload and the lifecycle commands
|
|
10
|
-
* (`stop`/`start`), so both agree on "this machine's" host_key — the input
|
|
11
|
-
* `signalVerifiedProcess()` compares a record's `host_key` against (BB-450
|
|
12
|
-
* AC-4). Two callers computing this independently is exactly how a gate can
|
|
13
|
-
* end up with no input on one side and a different answer on the other.
|
|
14
|
-
*/
|
|
15
|
-
export declare function hostKeyOf(config: {
|
|
16
|
-
host_key?: string;
|
|
17
|
-
conductor_id?: string;
|
|
18
|
-
machine_id?: string;
|
|
19
|
-
}): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host stem for `bb_machine.host_key` — the one entity that carries the
|
|
3
|
-
* field. `bb_conductor` has none, and reading one off it is precisely what
|
|
4
|
-
* left the host gate with no input at all (BB-450 review B7). Prefer
|
|
5
|
-
* `config.host_key` from MachineContext.machine_id; fall back to a
|
|
6
|
-
* best-effort parse of the composed `conductor_id` only when the loader could
|
|
7
|
-
* not supply the stem.
|
|
8
|
-
*
|
|
9
|
-
* Shared by the `Conductor` registration payload and the lifecycle commands
|
|
10
|
-
* (`stop`/`start`), so both agree on "this machine's" host_key — the input
|
|
11
|
-
* `signalVerifiedProcess()` compares a record's `host_key` against (BB-450
|
|
12
|
-
* AC-4). Two callers computing this independently is exactly how a gate can
|
|
13
|
-
* end up with no input on one side and a different answer on the other.
|
|
14
|
-
*/
|
|
15
|
-
export function hostKeyOf(config) {
|
|
16
|
-
const fromConfig = config.host_key?.trim();
|
|
17
|
-
if (fromConfig)
|
|
18
|
-
return fromConfig;
|
|
19
|
-
const id = config.conductor_id ?? config.machine_id ?? '';
|
|
20
|
-
const parts = id.split('-');
|
|
21
|
-
if (parts.length >= 3 && parts[0] && parts[1]) {
|
|
22
|
-
const middle = parts.slice(1, -1).join('-');
|
|
23
|
-
if (middle)
|
|
24
|
-
return middle;
|
|
25
|
-
}
|
|
26
|
-
return id;
|
|
27
|
-
}
|