Initial team BPM workspace with managed connections, scanning and mail templates
This commit is contained in:
commit
34770ed338
101 files changed
+6499
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// Regression/import entry point for offline captures. Never contacts BPM.
|
||||
const fs = require('node:fs/promises');
|
||||
const path = require('node:path');
|
||||
const { renderSnapshot } = require('../src/exporter.cjs');
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const value = flag => { const index=args.indexOf(flag); return index < 0 ? undefined : args[index+1]; };
|
||||
const input = value('--snapshot');
|
||||
if (!input) throw new Error('用法:node scripts/export-snapshot.cjs --snapshot <snapshot.json> [--assets <assets.json>] [--output <directory>]');
|
||||
const captured = JSON.parse(await fs.readFile(input,'utf8'));
|
||||
const snapshot = { ...captured, metadata: captured.metadata || { order:captured.order,project:captured.project,model:captured.model,serial:captured.serial }, images:[], warnings:[] };
|
||||
if (value('--assets')) {
|
||||
const assets = JSON.parse(await fs.readFile(value('--assets'),'utf8'));
|
||||
const external = [];
|
||||
for (const asset of assets.assets || []) {
|
||||
if (asset.kind === 'stylesheet') external.push(await fs.readFile(asset.path,'utf8'));
|
||||
if (asset.kind === 'image') {
|
||||
const bytes = await fs.readFile(asset.path);
|
||||
const data = `data:${asset.contentType || 'image/gif'};base64,${bytes.toString('base64')}`;
|
||||
snapshot.images.push({url:asset.url,data});
|
||||
const url = new URL(asset.url);
|
||||
snapshot.images.push({url:url.pathname+url.search,data});
|
||||
}
|
||||
}
|
||||
snapshot.styles = [...external,...(snapshot.styles || [])];
|
||||
}
|
||||
// Legacy capture used by the original probe already contains visible-value spans.
|
||||
const result = await renderSnapshot(snapshot,{outputDir:value('--output') && path.resolve(value('--output'))});
|
||||
console.log(JSON.stringify(result,null,2));
|
||||
}
|
||||
main().catch(error=>{console.error(error.message);process.exitCode=1;});
|
||||
Reference in new issue
Block a user