@bakers-build/bakers 0.9.1-next.5 → 0.9.1-next.6

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.
Files changed (2) hide show
  1. package/dist/src/config.js +68 -61
  2. package/package.json +37 -37
@@ -1,8 +1,8 @@
1
1
  import { hostname } from 'node:os';
2
- import { dirname, join } from 'node:path';
2
+ import { dirname, join, resolve } from 'node:path';
3
3
  import { createInterface } from 'node:readline';
4
4
  import { pathToFileURL } from 'node:url';
5
- import { homeBbDir, readConfigAddons, reportLoadedBbConfigFields, resolveBbConnectionSelection, scopeAddons, } from '@bakers-build/core';
5
+ import { finalizeConfigReport, homeBbDir, inventoryConfig, readAddonCapabilities, reportLoadedBbConfigFields, resolveBbConnectionSelection, } from '@bakers-build/core';
6
6
  import { Option } from 'commander';
7
7
  /** Terminal-only input. Secret characters are never echoed. */
8
8
  async function promptInput(label, secret = false) {
@@ -36,63 +36,40 @@ const SCOPE_FILE = {
36
36
  machine: '~/.bakers/machine.config.js',
37
37
  project: '.bakers/project.config.js',
38
38
  };
39
- /**
40
- * Report each machine/project `addons[]` entry listed in a scope its addon
41
- * does not declare. Resolving an addon imports its preset, so an offline
42
- * check (which never imports source) only notes that it skipped this.
43
- */
44
- async function checkAddonScopes(report, online, cwd) {
45
- const files = report.files.filter((f) => f.selected &&
46
- f.state !== 'absent' &&
47
- (f.kind === 'machine' || f.kind === 'project'));
48
- if (files.length === 0)
49
- return;
50
- const base = {
51
- stage: 'schema',
52
- key: 'addons',
53
- related: [],
54
- statically_determined: false,
55
- recheck: 'bakers config check --scope all --online',
56
- };
57
- if (!online) {
58
- report.findings.push({
59
- ...base,
60
- code: 'addon_scope_skipped',
61
- severity: 'info',
62
- path: files[0].path,
63
- expected: 'Each addon is listed only in a scope it declares.',
64
- observed: null,
65
- owner: files[0].layer,
66
- remediation: 'Addon scopes are not checked offline; run bakers config check --online to resolve each addons[] entry.',
67
- });
68
- return;
69
- }
70
- const hostBases = [import.meta.url];
71
- const { findings } = await scopeAddons(await Promise.all(files.map(async (f) => ({
72
- scope: f.kind === 'machine' ? 'machine' : 'project',
73
- path: f.path,
74
- entries: await readConfigAddons(f.path),
75
- bases: [
76
- pathToFileURL(`${dirname(f.path)}/`).href,
77
- ...(f.kind === 'machine' ? [] : [pathToFileURL(`${cwd}/`).href]),
78
- ...hostBases,
79
- ],
80
- }))), { unresolved: 'skip', logger: { warn: () => { } } });
81
- for (const finding of findings) {
82
- const allowed = finding.allowed.map((s) => SCOPE_FILE[s]).join(' or ');
83
- report.findings.push({
84
- ...base,
85
- code: 'addon_scope_not_allowed',
86
- severity: 'error',
87
- path: finding.path,
88
- expected: `'${finding.spec}' may be configured only in ${allowed}.`,
89
- observed: finding.spec,
90
- owner: finding.scope,
91
- remediation: `Move '${finding.spec}' from addons[] of ${finding.path} to addons[] of ${allowed}.`,
92
- });
39
+ /** Check declared scopes without evaluating the user's configuration. */
40
+ function checkAddonScopes(report, planning) {
41
+ const inventory = inventoryConfig(planning);
42
+ for (const file of report.files.filter((f) => f.selected && (f.kind === 'machine' || f.kind === 'project'))) {
43
+ const source = inventory.sources.get(file.path);
44
+ if (!source)
45
+ continue;
46
+ for (const [key, property] of source.properties) {
47
+ if (!/^addons\[\d+\](?:\.use)?$/.test(key) ||
48
+ typeof property.value !== 'string')
49
+ continue;
50
+ const spec = property.value;
51
+ const allowed = planning.capabilities?.[spec]?.scopes;
52
+ const scope = file.kind === 'machine' ? 'machine' : 'project';
53
+ if (!allowed || allowed.includes(scope))
54
+ continue;
55
+ const target = allowed.map((s) => SCOPE_FILE[s]).join(' or ');
56
+ report.findings.push({
57
+ stage: 'schema',
58
+ key: 'addons',
59
+ related: [],
60
+ statically_determined: true,
61
+ recheck: 'bakers config check --scope all',
62
+ code: 'addon_scope_not_allowed',
63
+ severity: 'error',
64
+ path: file.path,
65
+ expected: `'${spec}' may be configured only in ${target}.`,
66
+ observed: spec,
67
+ owner: scope,
68
+ remediation: `Move '${spec}' from addons[] of ${file.path} to addons[] of ${target}.`,
69
+ });
70
+ finalizeConfigReport(report);
71
+ }
93
72
  }
94
- if (findings.length > 0 && report.result !== 'failed')
95
- report.result = 'blocked';
96
73
  }
97
74
  /** `, N values not checked`: a passing result never hides what it skipped. */
98
75
  function notCheckedSummary(report) {
@@ -113,6 +90,8 @@ export function renderConfigReport(report, dryRun = false) {
113
90
  const { tunnel, source } = report.machine_policy;
114
91
  lines.push(`Machine tunnel: ${tunnel === null ? 'unresolved' : tunnel} (from ${source})`);
115
92
  }
93
+ for (const [slot, origin] of Object.entries(report.slot_sources ?? {}))
94
+ lines.push(`${slot[0]?.toUpperCase()}${slot.slice(1)}: ${origin}`);
116
95
  if (report.executor_source)
117
96
  lines.push(`Executor: from ${report.executor_source}`);
118
97
  if (report.connection_resolution) {
@@ -163,9 +142,12 @@ function buildConfigCommand(parent, operation, deps, hiddenScope, description) {
163
142
  .option('--connection <id>', 'named connection from ~/.bakers/connections')
164
143
  .option('--yes', 'disable prompts and automatic selections')
165
144
  .option('--online', 'authenticate and verify each selected workspace (project scopes); resolve addons[] entries to check their scopes');
145
+ if (operation === 'init')
146
+ for (const slot of ['server', 'executor', 'worktree'])
147
+ command.option(`--${slot} <package>`, `project ${slot} addon`);
166
148
  if (operation !== 'check')
167
149
  command
168
- .option('--dry-run', 'report planned changes without imports, network or writes')
150
+ .option('--dry-run', 'report planned changes without config evaluation, network or writes')
169
151
  .addOption(new Option('--project-connection <choice>', 'retired; use --connection'))
170
152
  .option('--label <name>', 'machine display label (default: the short hostname)')
171
153
  .option('--base-url <url>', 'connection server URL')
@@ -179,7 +161,7 @@ function buildConfigCommand(parent, operation, deps, hiddenScope, description) {
179
161
  command.action(async (options) => {
180
162
  if (hiddenScope !== undefined && options.scope === undefined)
181
163
  options.scope = hiddenScope;
182
- const { applyConfigPlan, planConfig } = await import('@bakers-build/conductor/config');
164
+ const { applyConfigPlan, planConfig, DEFAULT_SLOT_ADDON } = await import('@bakers-build/conductor/config');
183
165
  if (options.projectConnection !== undefined)
184
166
  throw new Error('--project-connection is retired; use --connection <id> or BAKERS_CONNECTION.');
185
167
  const cwd = deps.cwd ?? process.cwd();
@@ -272,6 +254,28 @@ function buildConfigCommand(parent, operation, deps, hiddenScope, description) {
272
254
  });
273
255
  planning.connectionPath = selectedConnection.path;
274
256
  }
257
+ planning.slots = {};
258
+ for (const slot of ['server', 'executor', 'worktree'])
259
+ if (options[slot] !== undefined)
260
+ planning.slots[slot] = options[slot];
261
+ // Static inventory supplies package names; only preset modules are imported.
262
+ const sources = inventoryConfig(planning).sources;
263
+ const projectBases = [
264
+ pathToFileURL(`${resolve(cwd, options.path ?? '.')}/`).href,
265
+ import.meta.url,
266
+ ];
267
+ planning.capabilities = {};
268
+ for (const [path, source] of sources) {
269
+ const specs = [...source.properties]
270
+ .filter(([key, property]) => /^addons\[\d+\](?:\.use)?$/.test(key) &&
271
+ typeof property.value === 'string')
272
+ .map(([, property]) => property.value);
273
+ Object.assign(planning.capabilities, await readAddonCapabilities(specs, [
274
+ pathToFileURL(`${dirname(path)}/`).href,
275
+ ...projectBases,
276
+ ]));
277
+ }
278
+ Object.assign(planning.capabilities, await readAddonCapabilities([...Object.values(planning.slots), DEFAULT_SLOT_ADDON], projectBases));
275
279
  let plan = planConfig(planning);
276
280
  if (operation === 'init' &&
277
281
  options.project &&
@@ -371,15 +375,18 @@ function buildConfigCommand(parent, operation, deps, hiddenScope, description) {
371
375
  const current = planConfig({
372
376
  ...planning,
373
377
  operation: 'check',
378
+ slots: {},
374
379
  }).report;
375
380
  report.files = current.files;
376
381
  report.findings = current.findings;
377
382
  report.result = current.result;
378
383
  report.verification = current.verification;
384
+ if (current.slot_sources)
385
+ report.slot_sources = current.slot_sources;
379
386
  }
380
387
  }
381
388
  if (!cancelled && operation === 'check')
382
- await checkAddonScopes(report, options.online === true, cwd);
389
+ checkAddonScopes(report, planning);
383
390
  // A device-code connection authenticates from a session that sign-in
384
391
  // creates, and nothing has signed in yet when `init` has only just
385
392
  // written the file. Verifying here therefore reports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/bakers",
3
- "version": "0.9.1-next.5",
3
+ "version": "0.9.1-next.6",
4
4
  "description": "bakers.build meta package: the `bakers` plugin-host CLI + all runtime plugins. Global install target.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,45 +38,45 @@
38
38
  "jsonapi"
39
39
  ],
40
40
  "dependencies": {
41
- "@bakers-build/addon-agents": "^0.9.1-next.5",
42
- "@bakers-build/addon-auth-basic": "^0.9.1-next.5",
43
- "@bakers-build/addon-claude": "^0.9.1-next.5",
44
- "@bakers-build/addon-codex": "^0.9.1-next.5",
45
- "@bakers-build/addon-ddev": "^0.9.1-next.5",
46
- "@bakers-build/addon-deployment": "^0.9.1-next.5",
47
- "@bakers-build/addon-dropsh": "^0.9.1-next.5",
48
- "@bakers-build/addon-essentials": "^0.9.1-next.5",
49
- "@bakers-build/addon-bakers-ui": "^0.9.1-next.5",
50
- "@bakers-build/addon-bakers-ui-artifacts": "^0.9.1-next.5",
51
- "@bakers-build/addon-forge": "^0.9.1-next.5",
52
- "@bakers-build/addon-forge-github": "^0.9.1-next.5",
53
- "@bakers-build/addon-forge-gitlab": "^0.9.1-next.5",
54
- "@bakers-build/addon-grok": "^0.9.1-next.5",
55
- "@bakers-build/addon-herdr": "^0.9.1-next.5",
56
- "@bakers-build/addon-herdr-core": "^0.9.1-next.5",
57
- "@bakers-build/addon-info": "^0.9.1-next.5",
58
- "@bakers-build/addon-kimi": "^0.9.1-next.5",
59
- "@bakers-build/addon-opencode": "^0.9.1-next.5",
60
- "@bakers-build/addon-orca": "^0.9.1-next.5",
61
- "@bakers-build/addon-pi": "^0.9.1-next.5",
62
- "@bakers-build/addon-ports": "^0.9.1-next.5",
63
- "@bakers-build/addon-ports-cloudflare": "^0.9.1-next.5",
64
- "@bakers-build/addon-ports-cloudflare-quick": "^0.9.1-next.5",
65
- "@bakers-build/addon-ports-frp": "^0.9.1-next.5",
66
- "@bakers-build/addon-remote-drupal": "^0.9.1-next.5",
67
- "@bakers-build/addon-runtime-docker": "^0.9.1-next.5",
68
- "@bakers-build/addon-runtime-bwrap": "^0.9.1-next.5",
69
- "@bakers-build/addon-tailscale": "^0.9.1-next.5",
70
- "@bakers-build/addon-track": "^0.9.1-next.5",
71
- "@bakers-build/addon-workspace": "^0.9.1-next.5",
72
- "@bakers-build/addon-workspace-git": "^0.9.1-next.5",
73
- "@bakers-build/conductor": "^0.9.1-next.5",
74
- "@bakers-build/core": "^0.9.1-next.5",
75
- "@bakers-build/ui": "^0.9.1-next.5",
41
+ "@bakers-build/addon-agents": "^0.9.1-next.6",
42
+ "@bakers-build/addon-auth-basic": "^0.9.1-next.6",
43
+ "@bakers-build/addon-claude": "^0.9.1-next.6",
44
+ "@bakers-build/addon-codex": "^0.9.1-next.6",
45
+ "@bakers-build/addon-ddev": "^0.9.1-next.6",
46
+ "@bakers-build/addon-deployment": "^0.9.1-next.6",
47
+ "@bakers-build/addon-dropsh": "^0.9.1-next.6",
48
+ "@bakers-build/addon-essentials": "^0.9.1-next.6",
49
+ "@bakers-build/addon-bakers-ui": "^0.9.1-next.6",
50
+ "@bakers-build/addon-bakers-ui-artifacts": "^0.9.1-next.6",
51
+ "@bakers-build/addon-forge": "^0.9.1-next.6",
52
+ "@bakers-build/addon-forge-github": "^0.9.1-next.6",
53
+ "@bakers-build/addon-forge-gitlab": "^0.9.1-next.6",
54
+ "@bakers-build/addon-grok": "^0.9.1-next.6",
55
+ "@bakers-build/addon-herdr": "^0.9.1-next.6",
56
+ "@bakers-build/addon-herdr-core": "^0.9.1-next.6",
57
+ "@bakers-build/addon-info": "^0.9.1-next.6",
58
+ "@bakers-build/addon-kimi": "^0.9.1-next.6",
59
+ "@bakers-build/addon-opencode": "^0.9.1-next.6",
60
+ "@bakers-build/addon-orca": "^0.9.1-next.6",
61
+ "@bakers-build/addon-pi": "^0.9.1-next.6",
62
+ "@bakers-build/addon-ports": "^0.9.1-next.6",
63
+ "@bakers-build/addon-ports-cloudflare": "^0.9.1-next.6",
64
+ "@bakers-build/addon-ports-cloudflare-quick": "^0.9.1-next.6",
65
+ "@bakers-build/addon-ports-frp": "^0.9.1-next.6",
66
+ "@bakers-build/addon-remote-drupal": "^0.9.1-next.6",
67
+ "@bakers-build/addon-runtime-docker": "^0.9.1-next.6",
68
+ "@bakers-build/addon-runtime-bwrap": "^0.9.1-next.6",
69
+ "@bakers-build/addon-tailscale": "^0.9.1-next.6",
70
+ "@bakers-build/addon-track": "^0.9.1-next.6",
71
+ "@bakers-build/addon-workspace": "^0.9.1-next.6",
72
+ "@bakers-build/addon-workspace-git": "^0.9.1-next.6",
73
+ "@bakers-build/conductor": "^0.9.1-next.6",
74
+ "@bakers-build/core": "^0.9.1-next.6",
75
+ "@bakers-build/ui": "^0.9.1-next.6",
76
76
  "commander": "^12.1.0"
77
77
  },
78
78
  "bakersBuild": {
79
- "commit": "d9242cad6cabee1faf010b5d46ac1bac33f6e0a1",
79
+ "commit": "e7d9921d51d5c045f29ca7e35d1e6a348e6ddf08",
80
80
  "channel": "next"
81
81
  }
82
82
  }