mindspace: version runtime contracts and audit packages
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.join(__dirname, '..');
|
||||
@@ -9,6 +11,7 @@ const runtimeRoot = path.join(root, '.runtime', 'mindspace-service');
|
||||
const serviceSourceRoot = path.join(root, 'mindspace-service');
|
||||
const nodeModulesDir = path.join(root, 'node_modules');
|
||||
const skipNodeModules = process.argv.includes('--skip-node-modules');
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
const excludeTopLevel = new Set([
|
||||
'.git',
|
||||
@@ -167,6 +170,14 @@ async function copyNodeModules() {
|
||||
|
||||
async function writeMetadata() {
|
||||
const head = await fs.readFile(path.join(root, '.git', 'HEAD'), 'utf8').catch(() => 'unknown');
|
||||
const gitSha = await execFileAsync('git', ['-C', root, 'rev-parse', 'HEAD'])
|
||||
.then(({ stdout }) => stdout.trim())
|
||||
.catch(() => null);
|
||||
const gitBranch = await execFileAsync('git', ['-C', root, 'branch', '--show-current'])
|
||||
.then(({ stdout }) => stdout.trim())
|
||||
.catch(() => null);
|
||||
const builtAt = new Date().toISOString();
|
||||
const buildId = gitSha ? `mindspace-${gitSha.slice(0, 12)}` : `mindspace-${Date.now()}`;
|
||||
const runbook = [
|
||||
'MindSpace service runtime artifact',
|
||||
'',
|
||||
@@ -197,8 +208,22 @@ async function writeMetadata() {
|
||||
'but standalone MindSpace data paths must stay under /Users/john/MindSpace.',
|
||||
'',
|
||||
`Git head ref: ${head.trim()}`,
|
||||
`Git sha: ${gitSha ?? 'unknown'}`,
|
||||
`Git branch: ${gitBranch ?? 'unknown'}`,
|
||||
`Build id: ${buildId}`,
|
||||
`Built at: ${builtAt}`,
|
||||
].join('\n');
|
||||
await fs.writeFile(path.join(runtimeRoot, 'RUNBOOK.txt'), runbook, 'utf8');
|
||||
await fs.writeFile(
|
||||
path.join(runtimeRoot, 'build-info.json'),
|
||||
`${JSON.stringify({
|
||||
buildId,
|
||||
gitSha,
|
||||
gitBranch,
|
||||
builtAt,
|
||||
}, null, 2)}\n`,
|
||||
'utf8',
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in New Issue
Block a user