feat(installer): migrate shims to runtime-managed targets

This commit is contained in:
ZenchantLive 2026-03-02 20:42:35 -08:00
parent 205f9500ec
commit 7945ee8d3c
6 changed files with 271 additions and 1 deletions

View file

@ -0,0 +1,45 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
test('installer migrates legacy repo-bound shim to runtime-managed shim', async () => {
if (process.platform === 'win32') {
return;
}
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'bb-install-migrate-'));
const installHome = path.join(root, 'home').replace(/\\/g, '/');
try {
const shimDir = path.join(installHome, '.beadboard', 'bin');
await fs.mkdir(shimDir, { recursive: true });
await fs.writeFile(
path.join(shimDir, 'beadboard'),
'#!/usr/bin/env bash\nexec node "/legacy/repo/install/beadboard.mjs" "$@"\n',
'utf8',
);
await execFileAsync('bash', ['install/install.sh'], {
env: { ...process.env, BB_INSTALL_HOME: installHome },
});
const shimRaw = await fs.readFile(path.join(shimDir, 'beadboard'), 'utf8');
const metadataRaw = await fs.readFile(
path.join(installHome, '.beadboard', 'runtime', 'current.json'),
'utf8',
);
assert.doesNotMatch(shimRaw, /\/legacy\/repo\/install\/beadboard\.mjs/);
assert.match(shimRaw, /runtime\/current\.json/);
assert.match(shimRaw, /RUNTIME_ROOT/);
assert.match(metadataRaw, /"runtimeRoot"/);
} finally {
await fs.rm(root, { recursive: true, force: true });
}
});

View file

@ -0,0 +1,41 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
const scriptPath = 'install/install.sh';
test('install.sh supports install and reinstall into BB_INSTALL_HOME', { skip: os.platform() === 'win32' ? 'Bash pathing issues on Windows' : false }, async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'bb-install-smoke-'));
const installHome = path.join(root, 'home').replace(/\\/g, '/');
try {
await execFileAsync('bash', [scriptPath], {
env: { ...process.env, BB_INSTALL_HOME: installHome },
});
await execFileAsync('bash', [scriptPath], {
env: { ...process.env, BB_INSTALL_HOME: installHome },
});
const beadboardShim = path.join(installHome, '.beadboard', 'bin', 'beadboard');
const bbShim = path.join(installHome, '.beadboard', 'bin', 'bb');
const runtimeMetadata = path.join(installHome, '.beadboard', 'runtime', 'current.json');
const [beadboardRaw, bbRaw, metadataRaw] = await Promise.all([
fs.readFile(beadboardShim, 'utf8'),
fs.readFile(bbShim, 'utf8'),
fs.readFile(runtimeMetadata, 'utf8'),
]);
assert.match(beadboardRaw, /runtime\/current\.json/);
assert.match(bbRaw, /runtime\/current\.json/);
assert.match(metadataRaw, /"runtimeRoot"/);
assert.match(metadataRaw, /"installMode"/);
} finally {
await fs.rm(root, { recursive: true, force: true });
}
});

View file

@ -0,0 +1,39 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import path from 'node:path';
async function read(relativePath: string): Promise<string> {
return fs.readFile(path.resolve(relativePath), 'utf8');
}
test('install wrapper scripts exist with canonical filenames', async () => {
const [ps1, sh] = await Promise.all([
read('install/install.ps1'),
read('install/install.sh'),
]);
assert.match(ps1, /beadboard/i);
assert.match(sh, /beadboard/i);
});
test('install wrappers provision both bb and beadboard shims', async () => {
const [ps1, sh] = await Promise.all([
read('install/install.ps1'),
read('install/install.sh'),
]);
assert.match(ps1, /\bbb\b/i);
assert.match(ps1, /\bbeadboard\b/i);
assert.match(sh, /\bbb\b/i);
assert.match(sh, /\bbeadboard\b/i);
});
test('install wrappers write runtime metadata and resolve runtime targets first', async () => {
const [ps1, sh] = await Promise.all([
read('install/install.ps1'),
read('install/install.sh'),
]);
assert.match(ps1, /runtime\\current\.json/i);
assert.match(ps1, /RUNTIME_ROOT/i);
assert.match(sh, /runtime\/current\.json/i);
assert.match(sh, /RUNTIME_ROOT/i);
});