Archify Diagram Viewer 0.1.0
VS Code extension that previews Archify diagrams from their JSON sources (live, as you type) and opens rendered Archify HTML in a viewer tab. Bundles the Archify 3.0.1 renderer and runs it on VS Code's Node runtime. Adds validation diagnostics, JSON schema help, source-link navigation, export saving, render-to-file and open-in-browser commands. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env node
|
||||
// Copies the Archify renderer runtime into vendor/archify and writes
|
||||
// VS Code-friendly copies of its JSON schemas into schemas/.
|
||||
//
|
||||
// Usage: node scripts/sync-archify.mjs [path-to-archify-checkout]
|
||||
// Default source: ../../ws-storm/archify (or $ARCHIFY_SRC).
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const source = path.resolve(
|
||||
process.argv[2] || process.env.ARCHIFY_SRC || path.join(root, '..', '..', 'ws-storm', 'archify'),
|
||||
);
|
||||
const skill = path.join(source, 'archify');
|
||||
|
||||
// Runtime pieces the CLI reads at render/validate time. test/ and examples/
|
||||
// are development-only and large, so they are left out.
|
||||
const RUNTIME = [
|
||||
'LICENSE',
|
||||
'THIRD_PARTY_NOTICES.md',
|
||||
'package.json',
|
||||
'skill-release.json',
|
||||
'assets',
|
||||
'bin',
|
||||
'brand-marks',
|
||||
'delta',
|
||||
'migrations',
|
||||
'recipes',
|
||||
'references',
|
||||
'renderers',
|
||||
'schemas',
|
||||
'scripts',
|
||||
];
|
||||
|
||||
if (!fs.existsSync(path.join(skill, 'bin', 'archify.mjs'))) {
|
||||
console.error(`Archify checkout not found at ${source}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const vendor = path.join(root, 'vendor', 'archify');
|
||||
fs.rmSync(vendor, { recursive: true, force: true });
|
||||
fs.mkdirSync(vendor, { recursive: true });
|
||||
for (const entry of RUNTIME) {
|
||||
fs.cpSync(path.join(skill, entry), path.join(vendor, entry), { recursive: true });
|
||||
}
|
||||
|
||||
// The upstream schemas carry absolute GitHub $ids, which would make VS Code
|
||||
// resolve "common.schema.json" refs over the network. Dropping $id lets refs
|
||||
// resolve next to the bundled file instead.
|
||||
const schemaOut = path.join(root, 'schemas');
|
||||
fs.rmSync(schemaOut, { recursive: true, force: true });
|
||||
fs.mkdirSync(schemaOut, { recursive: true });
|
||||
for (const file of fs.readdirSync(path.join(skill, 'schemas'))) {
|
||||
if (!file.endsWith('.schema.json')) continue;
|
||||
const schema = JSON.parse(fs.readFileSync(path.join(skill, 'schemas', file), 'utf8'));
|
||||
delete schema.$id;
|
||||
fs.writeFileSync(path.join(schemaOut, file), `${JSON.stringify(schema, null, 2)}\n`);
|
||||
}
|
||||
|
||||
let revision = 'unknown';
|
||||
try {
|
||||
revision = execFileSync('git', ['-C', source, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
|
||||
} catch {}
|
||||
const { version } = JSON.parse(fs.readFileSync(path.join(skill, 'package.json'), 'utf8'));
|
||||
fs.writeFileSync(
|
||||
path.join(root, 'vendor', 'archify.json'),
|
||||
`${JSON.stringify({ upstream: 'https://github.com/tt-a1i/archify', version, revision }, null, 2)}\n`,
|
||||
);
|
||||
console.log(`Synced archify ${version} (${revision.slice(0, 12)}) from ${source}`);
|
||||
Reference in New Issue
Block a user