- Model | Graph switch on main.archify (Diagram | Graph on diagram pages, narrowed to that diagram) - union graph of every element and connection, registry and inline, built from the model index - query box: text, type:, diagram:, decision:, uses:, near:, from: to:, unused, shared, -shared - side panel per element and connection with diagrams, registry line and decisions one click away - legend chips, Fit, Layout, Labels, Export PNG; Cytoscape.js bundled as dist/graph.js - command Archify | Open Model Graph; integration check; unit tests for graph and queries
69 lines
2.0 KiB
JavaScript
69 lines
2.0 KiB
JavaScript
import * as esbuild from 'esbuild';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
const production = process.argv.includes('--production');
|
|
const watch = process.argv.includes('--watch');
|
|
const tests = process.argv.includes('--tests');
|
|
|
|
const common = {
|
|
bundle: true,
|
|
format: 'cjs',
|
|
platform: 'node',
|
|
target: 'node20',
|
|
sourcemap: !production,
|
|
minify: production,
|
|
logLevel: 'info',
|
|
// jsonc-parser's UMD entry uses dynamic requires esbuild cannot follow.
|
|
mainFields: ['module', 'main'],
|
|
};
|
|
|
|
if (tests) {
|
|
// Unit tests cover the modules that do not import 'vscode'; the
|
|
// integration suite runs inside VS Code, which provides it.
|
|
const entryPoints = fs.readdirSync('test')
|
|
.filter((file) => file.endsWith('.test.ts'))
|
|
.map((file) => path.join('test', file));
|
|
await esbuild.build({ ...common, entryPoints, outdir: 'out/test', sourcemap: true });
|
|
await esbuild.build({
|
|
...common,
|
|
entryPoints: ['test/integration/suite.ts'],
|
|
outfile: 'out/test/integration/suite.js',
|
|
external: ['vscode'],
|
|
sourcemap: true,
|
|
});
|
|
} else {
|
|
const contexts = await Promise.all([
|
|
esbuild.context({
|
|
...common,
|
|
entryPoints: ['src/extension.ts'],
|
|
outfile: 'dist/extension.js',
|
|
external: ['vscode'],
|
|
}),
|
|
// Runs inside the Archify page in the webview; three.js is bundled in.
|
|
esbuild.context({
|
|
...common,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: 'es2022',
|
|
entryPoints: ['src/viewer3d/index.ts'],
|
|
outfile: 'dist/viewer3d.js',
|
|
}),
|
|
// The Graph page of a model; Cytoscape.js is bundled in.
|
|
esbuild.context({
|
|
...common,
|
|
format: 'iife',
|
|
platform: 'browser',
|
|
target: 'es2022',
|
|
entryPoints: ['src/graph/index.ts'],
|
|
outfile: 'dist/graph.js',
|
|
}),
|
|
]);
|
|
if (watch) {
|
|
await Promise.all(contexts.map((ctx) => ctx.watch()));
|
|
} else {
|
|
await Promise.all(contexts.map((ctx) => ctx.rebuild()));
|
|
await Promise.all(contexts.map((ctx) => ctx.dispose()));
|
|
}
|
|
}
|