mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
104 lines
3.3 KiB
JavaScript
104 lines
3.3 KiB
JavaScript
// Bundle the files Orca ships for components panels into resources/plugins/declarative/:
|
|
// the guest `orca` module, the `orca/testing` kit, and the Node hooks `orca plugin test` runs with.
|
|
// `--check` fails when a checked-in file is stale instead of rewriting it.
|
|
import { readFileSync, writeFileSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { build } from 'esbuild'
|
|
|
|
const ROOT = path.resolve(import.meta.dirname, '../../..', '..')
|
|
const OUTPUT_DIR = path.join(ROOT, 'resources', 'plugins', 'declarative')
|
|
const DECLARATIVE = path.join(ROOT, 'src', 'shared', 'plugins', 'declarative')
|
|
const TESTING = path.join(ROOT, 'src', 'main', 'plugins', 'testing')
|
|
|
|
export const DECLARATIVE_RUNTIME_OUTPUT = path.join(OUTPUT_DIR, 'orca-runtime.mjs')
|
|
|
|
/** The kit and the panel must share one runtime instance, so the kit imports the shipped file. */
|
|
const runtimeAsSibling = {
|
|
name: 'orca-runtime-as-sibling',
|
|
setup(builder) {
|
|
builder.onResolve({ filter: /runtime\/orca-module$/ }, () => ({
|
|
path: './orca-runtime.mjs',
|
|
external: true
|
|
}))
|
|
}
|
|
}
|
|
|
|
const BUNDLES = [
|
|
{
|
|
file: 'orca-runtime.mjs',
|
|
entry: path.join(DECLARATIVE, 'runtime', 'orca-module.ts'),
|
|
source: 'src/shared/plugins/declarative/runtime/',
|
|
platform: 'browser'
|
|
},
|
|
{
|
|
file: 'orca-testing.mjs',
|
|
entry: path.join(DECLARATIVE, 'testing', 'orca-testing.ts'),
|
|
source: 'src/shared/plugins/declarative/testing/',
|
|
platform: 'node',
|
|
plugins: [runtimeAsSibling]
|
|
},
|
|
{
|
|
file: 'orca-test-hooks.mjs',
|
|
entry: path.join(TESTING, 'plugin-test-hooks.ts'),
|
|
source: 'src/main/plugins/testing/',
|
|
platform: 'node'
|
|
},
|
|
{
|
|
file: 'orca-test-register.mjs',
|
|
entry: path.join(TESTING, 'plugin-test-register.ts'),
|
|
source: 'src/main/plugins/testing/',
|
|
platform: 'node'
|
|
}
|
|
]
|
|
|
|
async function bundle({ file, entry, source, platform, plugins = [] }) {
|
|
const result = await build({
|
|
entryPoints: [entry],
|
|
bundle: true,
|
|
format: 'esm',
|
|
platform,
|
|
target: platform === 'node' ? 'node20' : 'es2022',
|
|
charset: 'utf8',
|
|
legalComments: 'none',
|
|
// The Node files bundle zod and sucrase; minified they stay small in Git and on disk.
|
|
minify: platform === 'node',
|
|
plugins,
|
|
banner: {
|
|
js:
|
|
`// Generated by config/scripts/plugin-build/declarative-runtime/build-plugin-declarative-runtime.mjs from\n` +
|
|
`// ${source}. Do not edit.`
|
|
},
|
|
write: false,
|
|
logLevel: 'silent'
|
|
})
|
|
return { output: path.join(OUTPUT_DIR, file), text: result.outputFiles[0].text }
|
|
}
|
|
|
|
/** Every shipped bundle, as `{ output, text }`. */
|
|
export function bundleDeclarativeFiles() {
|
|
return Promise.all(BUNDLES.map(bundle))
|
|
}
|
|
|
|
export async function bundleDeclarativeRuntime() {
|
|
return (await bundle(BUNDLES[0])).text
|
|
}
|
|
|
|
async function main() {
|
|
const bundles = await bundleDeclarativeFiles()
|
|
const check = process.argv.includes('--check')
|
|
for (const { output, text } of bundles) {
|
|
const relativeOutput = path.relative(ROOT, output)
|
|
if (!check) {
|
|
writeFileSync(output, text)
|
|
console.log(`wrote ${relativeOutput}`)
|
|
} else if (readFileSync(output, 'utf8') !== text) {
|
|
console.error(`${relativeOutput} is stale; run pnpm generate:plugin-declarative-runtime`)
|
|
process.exitCode = 1
|
|
}
|
|
}
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === import.meta.filename) {
|
|
await main()
|
|
}
|