brustjs 0.1.10-alpha → 0.1.11-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +7 -7
- package/runtime/cli/build.ts +128 -18
- package/runtime/cli/help.ts +125 -0
- package/runtime/cli/index.ts +57 -22
- package/runtime/index.js +52 -52
- package/runtime/index.ts +15 -4
- package/runtime/islands/native-render.ts +23 -6
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ route apiece.
|
|
|
73
73
|
```
|
|
74
74
|
brustjs dev <entry> # dev mode: watcher + WS reload + browser auto-reload
|
|
75
75
|
brustjs build <entry> --out-dir D # prebuilt ./dist/ — run from the project (bun run dist/index.js)
|
|
76
|
+
--target <auto|all|TARGET[,…]> # which native binary to bundle (default: auto = host platform)
|
|
76
77
|
brustjs new <name> # scaffold a project (partial — see Status)
|
|
77
78
|
```
|
|
78
79
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brustjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11-alpha",
|
|
4
4
|
"description": "Bun + Rust SSR framework — React on the server, Rust everywhere else (napi cdylib + per-worker SharedArrayBuffer).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"typescript": "^6.0.3"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"brustjs-darwin-x64": "0.1.
|
|
44
|
-
"brustjs-darwin-arm64": "0.1.
|
|
45
|
-
"brustjs-linux-x64-gnu": "0.1.
|
|
46
|
-
"brustjs-linux-arm64-gnu": "0.1.
|
|
47
|
-
"brustjs-linux-x64-musl": "0.1.
|
|
48
|
-
"brustjs-linux-arm64-musl": "0.1.
|
|
43
|
+
"brustjs-darwin-x64": "0.1.11-alpha",
|
|
44
|
+
"brustjs-darwin-arm64": "0.1.11-alpha",
|
|
45
|
+
"brustjs-linux-x64-gnu": "0.1.11-alpha",
|
|
46
|
+
"brustjs-linux-arm64-gnu": "0.1.11-alpha",
|
|
47
|
+
"brustjs-linux-x64-musl": "0.1.11-alpha",
|
|
48
|
+
"brustjs-linux-arm64-musl": "0.1.11-alpha"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^19.2.6",
|
package/runtime/cli/build.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
|
-
import { copyFile, mkdir, readdir, rm } from 'node:fs/promises'
|
|
2
|
+
import { copyFile, cp, mkdir, readdir, rm } from 'node:fs/promises'
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import path, { isAbsolute, resolve } from 'node:path'
|
|
5
5
|
import {
|
|
@@ -59,14 +59,98 @@ async function collectNativeBinaries(): Promise<string[]> {
|
|
|
59
59
|
return out
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/** The 6 published platform targets (root package.json optionalDependencies),
|
|
63
|
+
* keyed by the napi binary infix `<platform>-<arch>[-<libc>]`. */
|
|
64
|
+
export const VALID_TARGETS = [
|
|
65
|
+
'darwin-x64',
|
|
66
|
+
'darwin-arm64',
|
|
67
|
+
'linux-x64-gnu',
|
|
68
|
+
'linux-arm64-gnu',
|
|
69
|
+
'linux-x64-musl',
|
|
70
|
+
'linux-arm64-musl',
|
|
71
|
+
] as const
|
|
72
|
+
|
|
73
|
+
/** Host target infix — reuses the same detection as platformPackageName by
|
|
74
|
+
* stripping the `brustjs-` prefix. */
|
|
75
|
+
export function hostTargetInfix(): string {
|
|
76
|
+
return platformPackageName().replace(/^brustjs-/, '')
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function basenameTarget(absPath: string): string | null {
|
|
80
|
+
const b = absPath.replace(/^.*[/\\]/, '') // basename
|
|
81
|
+
const m = /^brust\.(.+)\.node$/.exec(b)
|
|
82
|
+
return m ? m[1] : null
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Select which collected `brust.*.node` paths to copy for `target`.
|
|
86
|
+
* Pure: takes the collected absolute paths, returns selected paths + errors. */
|
|
87
|
+
export function selectNativeBinaries(
|
|
88
|
+
collected: string[],
|
|
89
|
+
target: string,
|
|
90
|
+
): { selected: string[]; errors: string[] } {
|
|
91
|
+
// Dedupe tokens here so `selected` never contains duplicate paths — the
|
|
92
|
+
// function's contract is a clean selection, independent of any caller-side
|
|
93
|
+
// copy-dedup (`--target darwin-arm64,darwin-arm64` must select once).
|
|
94
|
+
const tokens = [
|
|
95
|
+
...new Set(
|
|
96
|
+
target
|
|
97
|
+
.split(',')
|
|
98
|
+
.map((t) => t.trim().toLowerCase())
|
|
99
|
+
.filter(Boolean),
|
|
100
|
+
),
|
|
101
|
+
]
|
|
102
|
+
const byTarget = new Map<string, string>() // infix → first abs path (dedupe)
|
|
103
|
+
for (const p of collected) {
|
|
104
|
+
const t = basenameTarget(p)
|
|
105
|
+
if (t && !byTarget.has(t)) byTarget.set(t, p)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (tokens.length === 0) return { selected: [], errors: ['brust build: empty --target'] }
|
|
109
|
+
|
|
110
|
+
const hasAuto = tokens.includes('auto')
|
|
111
|
+
const hasAll = tokens.includes('all')
|
|
112
|
+
if ((hasAuto || hasAll) && tokens.length > 1) {
|
|
113
|
+
return {
|
|
114
|
+
selected: [],
|
|
115
|
+
errors: [
|
|
116
|
+
`brust build: --target "${target}" — auto/all cannot be combined with other targets`,
|
|
117
|
+
],
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (hasAll) return { selected: [...byTarget.values()], errors: [] }
|
|
121
|
+
|
|
122
|
+
const wanted = hasAuto ? [hostTargetInfix()] : tokens
|
|
123
|
+
const selected: string[] = []
|
|
124
|
+
const errors: string[] = []
|
|
125
|
+
for (const t of wanted) {
|
|
126
|
+
if (!hasAuto && !VALID_TARGETS.includes(t as (typeof VALID_TARGETS)[number])) {
|
|
127
|
+
errors.push(
|
|
128
|
+
`brust build: unknown target "${t}" (valid: ${VALID_TARGETS.join(', ')}, or auto/all)`,
|
|
129
|
+
)
|
|
130
|
+
continue
|
|
131
|
+
}
|
|
132
|
+
const p = byTarget.get(t)
|
|
133
|
+
if (!p) {
|
|
134
|
+
errors.push(
|
|
135
|
+
`brust build: no native binary for target "${t}" — install brustjs-${t} or build it (bun --filter runtime run build)`,
|
|
136
|
+
)
|
|
137
|
+
continue
|
|
138
|
+
}
|
|
139
|
+
selected.push(p)
|
|
140
|
+
}
|
|
141
|
+
return { selected, errors }
|
|
142
|
+
}
|
|
143
|
+
|
|
62
144
|
interface ParsedArgs {
|
|
63
145
|
entry: string // absolute path to the entry file
|
|
64
146
|
outDir: string // absolute path to the output dir
|
|
147
|
+
target: string // --target value (default 'auto')
|
|
65
148
|
}
|
|
66
149
|
|
|
67
150
|
function parseArgs(args: string[]): ParsedArgs {
|
|
68
151
|
let entry: string | undefined
|
|
69
152
|
let outDir: string | undefined
|
|
153
|
+
let target = 'auto'
|
|
70
154
|
|
|
71
155
|
for (let i = 0; i < args.length; i++) {
|
|
72
156
|
const a = args[i]
|
|
@@ -78,6 +162,18 @@ function parseArgs(args: string[]): ParsedArgs {
|
|
|
78
162
|
}
|
|
79
163
|
} else if (a.startsWith('--out-dir=')) {
|
|
80
164
|
outDir = a.slice('--out-dir='.length)
|
|
165
|
+
} else if (a === '--target') {
|
|
166
|
+
target = args[++i]
|
|
167
|
+
if (!target) {
|
|
168
|
+
console.error('brust build: --target requires a value')
|
|
169
|
+
process.exit(1)
|
|
170
|
+
}
|
|
171
|
+
} else if (a.startsWith('--target=')) {
|
|
172
|
+
target = a.slice('--target='.length)
|
|
173
|
+
if (!target) {
|
|
174
|
+
console.error('brust build: --target= requires a value')
|
|
175
|
+
process.exit(1)
|
|
176
|
+
}
|
|
81
177
|
} else if (a.startsWith('-')) {
|
|
82
178
|
console.error(`brust build: unknown flag "${a}"`)
|
|
83
179
|
process.exit(1)
|
|
@@ -107,11 +203,11 @@ function parseArgs(args: string[]): ParsedArgs {
|
|
|
107
203
|
: resolve(cwd, outDir)
|
|
108
204
|
: resolve(cwd, 'dist')
|
|
109
205
|
|
|
110
|
-
return { entry: entryPath, outDir: outPath }
|
|
206
|
+
return { entry: entryPath, outDir: outPath, target }
|
|
111
207
|
}
|
|
112
208
|
|
|
113
209
|
export async function runBuild(args: string[]): Promise<void> {
|
|
114
|
-
const { entry, outDir } = parseArgs(args)
|
|
210
|
+
const { entry, outDir, target } = parseArgs(args)
|
|
115
211
|
const entryDir = path.dirname(entry)
|
|
116
212
|
|
|
117
213
|
console.log(`[brust build] entry: ${entry}`)
|
|
@@ -177,12 +273,11 @@ export async function runBuild(args: string[]): Promise<void> {
|
|
|
177
273
|
// native: true route. Pipeline runs even if no native routes exist (writes
|
|
178
274
|
// an empty manifest) so consumers can rely on the output dir's presence.
|
|
179
275
|
{
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
const jinjaDir = path.join(process.cwd(), '.brust/jinja')
|
|
276
|
+
// Emit jinja templates INTO the build output dir (`<outDir>/jinja`), next to
|
|
277
|
+
// the other pre-built artifacts (islands, css, mcp-manifest), so a dist-only
|
|
278
|
+
// deploy ships the templates. The prebuilt runtime reads them from
|
|
279
|
+
// `<BRUST_DIST_DIR>/jinja` (see index.ts loadJinjaOnce / configureJinjaDir).
|
|
280
|
+
const jinjaDir = path.join(outDir, 'jinja')
|
|
186
281
|
// Spec §7 Component-source resolution: scan the routes module's source for
|
|
187
282
|
// ImportDeclarations, NOT the app entry's. The app entry only imports the
|
|
188
283
|
// routes module + brust; the page components are imported by routes.tsx.
|
|
@@ -197,6 +292,17 @@ export async function runBuild(args: string[]): Promise<void> {
|
|
|
197
292
|
})
|
|
198
293
|
const nativeCount = (loadedRoutes ?? []).filter((r: any) => r?.nativeTemplate).length
|
|
199
294
|
console.log(`[brust build] jinja: ${nativeCount} template(s) → ${jinjaDir}`)
|
|
295
|
+
|
|
296
|
+
// Also mirror into cwd/.brust/jinja so the NON-prebuilt source runtime
|
|
297
|
+
// (`bun run <entry>` directly, and `bun run dev`) — which reads
|
|
298
|
+
// cwd/.brust/jinja — finds the same templates after a build. The prebuilt
|
|
299
|
+
// dist reads <distDir>/jinja (above); this keeps the dev/source path working
|
|
300
|
+
// without a separate compile step. `.brust/` is a gitignored cache dir.
|
|
301
|
+
const localJinjaDir = path.join(process.cwd(), '.brust', 'jinja')
|
|
302
|
+
if (path.resolve(localJinjaDir) !== path.resolve(jinjaDir)) {
|
|
303
|
+
await rm(localJinjaDir, { recursive: true, force: true })
|
|
304
|
+
await cp(jinjaDir, localJinjaDir, { recursive: true })
|
|
305
|
+
}
|
|
200
306
|
}
|
|
201
307
|
|
|
202
308
|
// 4.5. CSS — Tailwind v4 if app.css is present.
|
|
@@ -284,26 +390,30 @@ export async function runBuild(args: string[]): Promise<void> {
|
|
|
284
390
|
}
|
|
285
391
|
console.log(`[brust build] bundle: ${path.join(outDir, 'index.js')}`)
|
|
286
392
|
|
|
287
|
-
// 7. Copy the
|
|
393
|
+
// 7. Copy the selected-platform native binary(ies).
|
|
288
394
|
const nativeDir = path.join(outDir, 'native')
|
|
289
395
|
await mkdir(nativeDir, { recursive: true })
|
|
290
396
|
|
|
291
397
|
// napi-rs names the binary `brust.<platform>-<arch>[-libc].node` (binaryName
|
|
292
398
|
// "brust", from the root napi config). Source/CI builds leave it in runtime/;
|
|
293
|
-
// an installed project carries it in the brustjs-<platform> package.
|
|
294
|
-
//
|
|
295
|
-
// (local/installed) layouts both Just Work.
|
|
399
|
+
// an installed project carries it in the brustjs-<platform> package. The
|
|
400
|
+
// --target flag (default "auto" = host platform) selects which to copy.
|
|
296
401
|
const nativeBinaries = await collectNativeBinaries()
|
|
297
|
-
|
|
402
|
+
const { selected, errors } = selectNativeBinaries(nativeBinaries, target)
|
|
403
|
+
if (errors.length > 0) {
|
|
404
|
+
for (const e of errors) console.error(e)
|
|
405
|
+
process.exit(1)
|
|
406
|
+
}
|
|
407
|
+
if (selected.length === 0) {
|
|
298
408
|
console.error(
|
|
299
|
-
`brust build: no native binary found
|
|
300
|
-
|
|
301
|
-
`
|
|
409
|
+
`brust build: no native binary found for target "${target}". Looked in ` +
|
|
410
|
+
`${path.join(REPO_ROOT, 'runtime')} and the ${platformPackageName()} package. ` +
|
|
411
|
+
`From source run \`bun --filter runtime run build\` first.`,
|
|
302
412
|
)
|
|
303
413
|
process.exit(1)
|
|
304
414
|
}
|
|
305
415
|
const seen = new Set<string>()
|
|
306
|
-
for (const src of
|
|
416
|
+
for (const src of selected) {
|
|
307
417
|
const name = path.basename(src)
|
|
308
418
|
if (seen.has(name)) continue
|
|
309
419
|
seen.add(name)
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Dep-free CLI help/version rendering + a tiny ANSI color util. All functions
|
|
2
|
+
// return strings (no console writes) so they're unit-testable. index.ts owns
|
|
3
|
+
// the actual stdout/stderr + exit codes.
|
|
4
|
+
import { readFileSync } from 'node:fs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
|
|
7
|
+
/** Read the brustjs package.json version. `help.ts` lives at
|
|
8
|
+
* <root>/runtime/cli/, so ../../package.json is <root>/package.json in both the
|
|
9
|
+
* source tree and an installed node_modules/brustjs layout. Never throws —
|
|
10
|
+
* returns "unknown" on any failure (version must not crash the CLI). */
|
|
11
|
+
export function readVersion(): string {
|
|
12
|
+
try {
|
|
13
|
+
const p = path.join(import.meta.dir, '..', '..', 'package.json')
|
|
14
|
+
const pkg = JSON.parse(readFileSync(p, 'utf8')) as { version?: string }
|
|
15
|
+
return pkg.version ?? 'unknown'
|
|
16
|
+
} catch {
|
|
17
|
+
return 'unknown'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function useColor(): boolean {
|
|
22
|
+
return Boolean(process.stdout.isTTY) && !process.env.NO_COLOR
|
|
23
|
+
}
|
|
24
|
+
function wrap(open: string, s: string): string {
|
|
25
|
+
return useColor() ? `\x1b[${open}m${s}\x1b[0m` : s
|
|
26
|
+
}
|
|
27
|
+
export const style = {
|
|
28
|
+
bold: (s: string) => wrap('1', s),
|
|
29
|
+
dim: (s: string) => wrap('2', s),
|
|
30
|
+
cyan: (s: string) => wrap('36', s),
|
|
31
|
+
green: (s: string) => wrap('32', s),
|
|
32
|
+
red: (s: string) => wrap('31', s),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface CommandDef {
|
|
36
|
+
name: string
|
|
37
|
+
summary: string
|
|
38
|
+
usage: string
|
|
39
|
+
flags: { flag: string; desc: string }[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const COMMANDS: CommandDef[] = [
|
|
43
|
+
{
|
|
44
|
+
name: 'build',
|
|
45
|
+
summary: 'Compile a brust app to a self-contained dist/',
|
|
46
|
+
usage: 'brust build [entry] [options]',
|
|
47
|
+
flags: [
|
|
48
|
+
{ flag: '[entry]', desc: 'Entry file (default ./index.ts)' },
|
|
49
|
+
{ flag: '--out-dir <dir>', desc: 'Output directory (default ./dist)' },
|
|
50
|
+
{
|
|
51
|
+
flag: '--target <t>',
|
|
52
|
+
desc: 'Native target(s): auto | all | <platform>-<arch>[-<libc>][,…] (default auto)',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'dev',
|
|
58
|
+
summary: 'Run the dev server with hot reload',
|
|
59
|
+
usage: 'brust dev [entry] [options]',
|
|
60
|
+
flags: [
|
|
61
|
+
{ flag: '[entry]', desc: 'Entry file (default ./index.ts)' },
|
|
62
|
+
{ flag: '--port <n>', desc: 'Port to listen on' },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'new',
|
|
67
|
+
summary: 'Scaffold a new brust project',
|
|
68
|
+
usage: 'brust new <name> [options]',
|
|
69
|
+
flags: [
|
|
70
|
+
{ flag: '<name>', desc: 'Project name (lowercase letters, digits, - _)' },
|
|
71
|
+
{ flag: '--dir <path>', desc: 'Target directory (default ./<name>)' },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
function pad(s: string, w: number): string {
|
|
77
|
+
return s + ' '.repeat(Math.max(0, w - s.length))
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function renderVersion(): string {
|
|
81
|
+
return `brustjs ${readVersion()}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function renderRootHelp(): string {
|
|
85
|
+
const lines: string[] = []
|
|
86
|
+
lines.push(`${style.bold('brust')} ${style.dim(readVersion())} — the brust framework CLI`)
|
|
87
|
+
lines.push('')
|
|
88
|
+
lines.push(`${style.bold('Usage:')} brust <command> [options]`)
|
|
89
|
+
lines.push('')
|
|
90
|
+
const globals = [
|
|
91
|
+
{ label: '-h, --help', desc: 'Show help (brust help <command> for details)' },
|
|
92
|
+
{ label: '-v, --version', desc: 'Show the brustjs version' },
|
|
93
|
+
]
|
|
94
|
+
// One shared column width across commands AND global flags so every
|
|
95
|
+
// description lines up in a single column.
|
|
96
|
+
const w = Math.max(...COMMANDS.map((c) => c.name.length), ...globals.map((g) => g.label.length))
|
|
97
|
+
lines.push(style.bold('Commands:'))
|
|
98
|
+
for (const c of COMMANDS) {
|
|
99
|
+
lines.push(` ${style.cyan(pad(c.name, w))} ${c.summary}`)
|
|
100
|
+
}
|
|
101
|
+
lines.push('')
|
|
102
|
+
lines.push(style.bold('Global:'))
|
|
103
|
+
for (const g of globals) {
|
|
104
|
+
lines.push(` ${style.cyan(pad(g.label, w))} ${g.desc}`)
|
|
105
|
+
}
|
|
106
|
+
lines.push('')
|
|
107
|
+
lines.push(style.dim('Run `brust help <command>` for command-specific options.'))
|
|
108
|
+
return lines.join('\n')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function renderCommandHelp(name: string): string | null {
|
|
112
|
+
const c = COMMANDS.find((x) => x.name === name)
|
|
113
|
+
if (!c) return null
|
|
114
|
+
const lines: string[] = []
|
|
115
|
+
lines.push(`${style.bold('Usage:')} ${c.usage}`)
|
|
116
|
+
lines.push('')
|
|
117
|
+
lines.push(c.summary)
|
|
118
|
+
lines.push('')
|
|
119
|
+
lines.push(style.bold('Options:'))
|
|
120
|
+
const w = Math.max(...c.flags.map((f) => f.flag.length))
|
|
121
|
+
for (const f of c.flags) {
|
|
122
|
+
lines.push(` ${style.cyan(pad(f.flag, w))} ${f.desc}`)
|
|
123
|
+
}
|
|
124
|
+
return lines.join('\n')
|
|
125
|
+
}
|
package/runtime/cli/index.ts
CHANGED
|
@@ -1,30 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
|
|
2
|
+
import { COMMANDS, renderCommandHelp, renderRootHelp, renderVersion } from './help.ts'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const argv = process.argv.slice(2)
|
|
5
|
+
const first = argv[0]
|
|
6
|
+
const second = argv[1]
|
|
7
|
+
|
|
8
|
+
// Derive from COMMANDS so the dispatch set and the help registry can never
|
|
9
|
+
// drift (a name in KNOWN but absent from COMMANDS would print `null` as help).
|
|
10
|
+
const KNOWN = new Set(COMMANDS.map((c) => c.name))
|
|
11
|
+
|
|
12
|
+
function hasHelpFlag(args: string[]): boolean {
|
|
13
|
+
return args.includes('--help') || args.includes('-h')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (first === '--version' || first === '-v' || first === 'version') {
|
|
17
|
+
console.log(renderVersion())
|
|
18
|
+
process.exit(0)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (first === '--help' || first === '-h' || first === 'help') {
|
|
22
|
+
if (second && KNOWN.has(second)) {
|
|
23
|
+
console.log(renderCommandHelp(second))
|
|
24
|
+
process.exit(0)
|
|
9
25
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
if (second) {
|
|
27
|
+
console.error(`brust: unknown command "${second}".`)
|
|
28
|
+
console.error(renderRootHelp())
|
|
29
|
+
process.exit(1)
|
|
14
30
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
console.log(renderRootHelp())
|
|
32
|
+
process.exit(0)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (first && KNOWN.has(first)) {
|
|
36
|
+
const rest = argv.slice(1)
|
|
37
|
+
if (hasHelpFlag(rest)) {
|
|
38
|
+
console.log(renderCommandHelp(first))
|
|
39
|
+
process.exit(0)
|
|
19
40
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
switch (first) {
|
|
42
|
+
case 'build': {
|
|
43
|
+
const { runBuild } = await import('./build.ts')
|
|
44
|
+
await runBuild(rest)
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
case 'dev': {
|
|
48
|
+
const { runDev } = await import('./dev.ts')
|
|
49
|
+
await runDev(rest)
|
|
50
|
+
break
|
|
51
|
+
}
|
|
52
|
+
case 'new': {
|
|
53
|
+
const { runNew } = await import('./new.ts')
|
|
54
|
+
await runNew(rest)
|
|
55
|
+
break
|
|
27
56
|
}
|
|
28
|
-
process.exit(1)
|
|
29
57
|
}
|
|
58
|
+
} else if (!first) {
|
|
59
|
+
console.error(renderRootHelp())
|
|
60
|
+
process.exit(1)
|
|
61
|
+
} else {
|
|
62
|
+
console.error(`brust: unknown command "${first}".`)
|
|
63
|
+
console.error('Run `brust --help` to see available commands.')
|
|
64
|
+
process.exit(1)
|
|
30
65
|
}
|
package/runtime/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('brustjs-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('brustjs-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.1.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
80
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('brustjs-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('brustjs-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.1.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
96
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('brustjs-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('brustjs-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.1.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
117
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('brustjs-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('brustjs-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.1.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
133
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('brustjs-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('brustjs-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.1.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
150
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('brustjs-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('brustjs-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.1.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
166
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('brustjs-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('brustjs-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.1.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
185
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('brustjs-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('brustjs-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.1.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
201
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('brustjs-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('brustjs-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.1.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
217
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('brustjs-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('brustjs-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.1.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
237
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('brustjs-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('brustjs-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.1.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
253
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('brustjs-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('brustjs-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.1.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
274
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('brustjs-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('brustjs-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.1.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
290
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('brustjs-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('brustjs-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.1.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
308
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('brustjs-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('brustjs-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.1.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
324
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('brustjs-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('brustjs-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.1.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
342
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('brustjs-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('brustjs-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.1.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
358
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('brustjs-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('brustjs-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.1.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
376
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('brustjs-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('brustjs-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.1.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
392
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('brustjs-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('brustjs-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.1.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
410
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('brustjs-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('brustjs-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.1.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
426
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('brustjs-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('brustjs-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.1.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
443
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('brustjs-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('brustjs-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.1.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
459
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('brustjs-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('brustjs-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.1.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
479
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('brustjs-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('brustjs-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.1.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
495
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('brustjs-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('brustjs-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.1.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
511
|
+
if (bindingPackageVersion !== '0.1.11-alpha' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.1.11-alpha but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/runtime/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ActionDef } from './actions.ts'
|
|
|
3
3
|
import { isValidActionId } from './actions.ts'
|
|
4
4
|
import { loadConfig } from './config.ts'
|
|
5
5
|
import { configureCssEnabled, configureCssHrefsForRoute } from './css.ts'
|
|
6
|
+
import { configureJinjaDir } from './islands/native-render.ts'
|
|
6
7
|
|
|
7
8
|
export interface ServeOptions {
|
|
8
9
|
/** Host/address to bind on. A hostname (e.g. `localhost`, resolved Rust-side)
|
|
@@ -419,10 +420,20 @@ export const brust = {
|
|
|
419
420
|
}
|
|
420
421
|
}
|
|
421
422
|
|
|
422
|
-
// Sub-project J — load
|
|
423
|
-
// the startup-validation warning in registerRoutes can compare
|
|
424
|
-
// a populated registry. Loads once at startup; dev hot reload
|
|
425
|
-
|
|
423
|
+
// Sub-project J — load the compiled `*.jinja` templates into the minijinja
|
|
424
|
+
// env so the startup-validation warning in registerRoutes can compare
|
|
425
|
+
// against a populated registry. Loads once at startup; dev hot reload
|
|
426
|
+
// reloads it. The templates ship INSIDE the build output, so a pre-built
|
|
427
|
+
// run reads them (and their islands/components sidecars) from
|
|
428
|
+
// `<distDir>/jinja`; dev compiles them to `cwd/.brust/jinja`.
|
|
429
|
+
const jinjaDir = prebuilt
|
|
430
|
+
? path.join(distDir!, 'jinja')
|
|
431
|
+
: path.resolve(process.cwd(), '.brust/jinja')
|
|
432
|
+
configureJinjaDir(jinjaDir)
|
|
433
|
+
loadJinjaOnce(jinjaDir)
|
|
434
|
+
if (prebuilt && existsSync(jinjaDir)) {
|
|
435
|
+
console.log(`[brust] main: using pre-built jinja at ${jinjaDir}`)
|
|
436
|
+
}
|
|
426
437
|
|
|
427
438
|
this.registerRoutes(routes)
|
|
428
439
|
const ssePaths = routes
|
|
@@ -20,6 +20,23 @@ import path from 'node:path'
|
|
|
20
20
|
import { renderToString } from 'react-dom/server.node'
|
|
21
21
|
import { createElement } from 'react'
|
|
22
22
|
|
|
23
|
+
// Sub-project J — the directory holding the compiled `<Name>.jinja` templates
|
|
24
|
+
// and their `.islands.json` / `.components.json` sidecars. Configured ONCE at
|
|
25
|
+
// boot (`configureJinjaDir`) so it tracks the same location `loadJinjaOnce`
|
|
26
|
+
// loads from: `<BRUST_DIST_DIR>/jinja` for a pre-built run, `cwd/.brust/jinja`
|
|
27
|
+
// in dev. Falls back to the dev location when unset (tests pass an explicit dir).
|
|
28
|
+
let _configuredJinjaDir: string | null = null
|
|
29
|
+
|
|
30
|
+
/** Set the directory the sidecar-manifest readers resolve against. Called once
|
|
31
|
+
* at boot from `index.ts`, mirroring `configureIslandsDir`/`configureCssDir`. */
|
|
32
|
+
export function configureJinjaDir(dir: string): void {
|
|
33
|
+
_configuredJinjaDir = dir
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function defaultJinjaDir(): string {
|
|
37
|
+
return _configuredJinjaDir ?? path.resolve(process.cwd(), '.brust/jinja')
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
/** One entry of a `<template>.islands.json` manifest (enriched by T6). */
|
|
24
41
|
export interface NativeIslandEntry {
|
|
25
42
|
component: string
|
|
@@ -90,14 +107,14 @@ export function entityEncode(s: string): string {
|
|
|
90
107
|
const manifestCache = new Map<string, NativeIslandEntry[] | null>()
|
|
91
108
|
|
|
92
109
|
/** Read `<jinjaDir>/<templateName>.islands.json` and return the parsed entry
|
|
93
|
-
* array, or `null` if the file doesn't exist. `jinjaDir` defaults to
|
|
94
|
-
* `
|
|
95
|
-
* are cached by absolute path. */
|
|
110
|
+
* array, or `null` if the file doesn't exist. `jinjaDir` defaults to the
|
|
111
|
+
* boot-configured jinja dir (`configureJinjaDir`), or `cwd/.brust/jinja` when
|
|
112
|
+
* unset; tests pass a temp dir. Both hits and misses are cached by absolute path. */
|
|
96
113
|
export function loadIslandManifest(
|
|
97
114
|
templateName: string,
|
|
98
115
|
jinjaDir?: string,
|
|
99
116
|
): NativeIslandEntry[] | null {
|
|
100
|
-
const dir = jinjaDir ??
|
|
117
|
+
const dir = jinjaDir ?? defaultJinjaDir()
|
|
101
118
|
const abs = path.resolve(dir, `${templateName}.islands.json`)
|
|
102
119
|
if (manifestCache.has(abs)) return manifestCache.get(abs)!
|
|
103
120
|
let parsed: NativeIslandEntry[] | null
|
|
@@ -251,7 +268,7 @@ export function loadComponentManifest(
|
|
|
251
268
|
templateName: string,
|
|
252
269
|
jinjaDir?: string,
|
|
253
270
|
): NativeComponentEntry[] | null {
|
|
254
|
-
const dir = jinjaDir ??
|
|
271
|
+
const dir = jinjaDir ?? defaultJinjaDir()
|
|
255
272
|
const abs = path.resolve(dir, `${templateName}.components.json`)
|
|
256
273
|
if (componentManifestCache.has(abs)) return componentManifestCache.get(abs)!
|
|
257
274
|
let parsed: NativeComponentEntry[] | null
|
|
@@ -282,7 +299,7 @@ export async function resolveComponentContext(
|
|
|
282
299
|
const out: Record<string, string> = {}
|
|
283
300
|
if (!manifest.length) return out
|
|
284
301
|
|
|
285
|
-
const dir = jinjaDir ??
|
|
302
|
+
const dir = jinjaDir ?? defaultJinjaDir()
|
|
286
303
|
const factoryPath = path.resolve(dir, `${templateName}.factory.ts`)
|
|
287
304
|
|
|
288
305
|
let factoryMod = factoryCache.get(factoryPath)
|