@adea-ai/app-framework 0.24.0 → 0.24.1
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 +43 -1
- package/dist/framework-source.json +1 -1
- package/dist/release/framework-package-publish.js +4 -2
- package/dist/shell/app-shell.js +21 -33
- package/dist/shell/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -0
- package/package.json +13 -2
- package/src/shell/app-shell.tsx +29 -20
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/app/create-application.ts +0 -245
- package/src/app/service-registry.ts +0 -124
- package/src/ci/toolchain-identity.ts +0 -244
- package/src/cli/cef-helper-cli.ts +0 -21
- package/src/cli/cli-runner.ts +0 -29
- package/src/cli/create-application-cli.ts +0 -62
- package/src/cli/electrobun-shortcut-patch-cli.ts +0 -24
- package/src/cli/framework-update-cli.ts +0 -41
- package/src/cli/release-assets-plan-cli.ts +0 -14
- package/src/cli/release-cut-cli.ts +0 -41
- package/src/cli/release-descriptor-staging-cli.ts +0 -57
- package/src/cli/release-finalize-cli.ts +0 -34
- package/src/cli/release-promote-cli.ts +0 -31
- package/src/cli/release-publish-cli.ts +0 -46
- package/src/cli/release-sign-cli.ts +0 -24
- package/src/cli/release-step-cli.ts +0 -71
- package/src/cli/toolchain-identity-cli.ts +0 -12
- package/src/cli/update-helper-cli.ts +0 -12
- package/src/cli/windows-runtime-patch-cli.ts +0 -17
- package/src/desktop/application-command-client.ts +0 -43
- package/src/desktop/channel-handshake.ts +0 -136
- package/src/desktop/channel-proof.ts +0 -122
- package/src/desktop/desktop-client.ts +0 -303
- package/src/desktop/desktop-gateway.ts +0 -189
- package/src/desktop/desktop-host.ts +0 -335
- package/src/desktop/desktop-stream.ts +0 -324
- package/src/desktop/loopback-policy.ts +0 -41
- package/src/desktop/open-url-channel.ts +0 -79
- package/src/desktop/string-policy.ts +0 -9
- package/src/installer/archive-entry.ts +0 -32
- package/src/installer/command-artifact.ts +0 -307
- package/src/installer/command-qualification-command.ts +0 -75
- package/src/installer/hosted-runner.ts +0 -11
- package/src/installer/installed-payload.ts +0 -408
- package/src/installer/installer-ci-bootstrap.ts +0 -199
- package/src/installer/installer-ci-preflight.ts +0 -61
- package/src/installer/installer-ci-worker.ts +0 -105
- package/src/installer/installer-extraction.ts +0 -367
- package/src/installer/installer-fetch-guard.ts +0 -75
- package/src/installer/installer-identity.ts +0 -331
- package/src/installer/installer-layout.ts +0 -167
- package/src/installer/installer-observation.ts +0 -671
- package/src/installer/installer-process-cleanup.ts +0 -167
- package/src/installer/installer-qualification-command.ts +0 -81
- package/src/installer/installer-renderer-evidence.ts +0 -268
- package/src/installer/installer-upgrade-command.ts +0 -226
- package/src/installer/installer-worker-guard.ts +0 -112
- package/src/installer/native-executable.ts +0 -37
- package/src/installer/upgrade-asset-download.ts +0 -72
- package/src/installer/write-all.ts +0 -19
- package/src/native/app-bundle.ts +0 -86
- package/src/native/cef-helper.ts +0 -471
- package/src/native/desktop-build-hook.ts +0 -21
- package/src/native/electrobun-source-patch.ts +0 -107
- package/src/native/linux-cef-links.ts +0 -14
- package/src/native/native-secret-store.ts +0 -99
- package/src/native/native-utilities.ts +0 -166
- package/src/native/partitioned-window.ts +0 -62
- package/src/native/secure-window.ts +0 -115
- package/src/native/sidecar-services.ts +0 -71
- package/src/native/sidecar.ts +0 -387
- package/src/native/window-bootstrap.ts +0 -77
- package/src/native/windows-build-hook-internal.ts +0 -49
- package/src/native/windows-build-hook.ts +0 -12
- package/src/native/windows-runtime-patch-internal.ts +0 -48
- package/src/native/windows-runtime-patch.ts +0 -15
- package/src/release/feed-release-cut.ts +0 -110
- package/src/release/feed-state.ts +0 -135
- package/src/release/framework-package-publish.ts +0 -163
- package/src/release/framework-update.ts +0 -196
- package/src/release/github-cli.ts +0 -27
- package/src/release/github-release-assets.ts +0 -36
- package/src/release/github-release-cut.ts +0 -237
- package/src/release/github-release-lookup.ts +0 -39
- package/src/release/github-release-promotion.ts +0 -112
- package/src/release/github-release-provenance.ts +0 -65
- package/src/release/github-release-publisher.ts +0 -90
- package/src/release/github-release-qualification.ts +0 -144
- package/src/release/local-provenance.ts +0 -92
- package/src/release/local-release.ts +0 -525
- package/src/release/macos-dmg.ts +0 -113
- package/src/release/release-artifact.ts +0 -53
- package/src/release/release-assets-plan.ts +0 -118
- package/src/release/release-config.ts +0 -420
- package/src/release/release-cut-command.ts +0 -80
- package/src/release/release-cut.ts +0 -133
- package/src/release/release-descriptor-staging.ts +0 -242
- package/src/release/release-finalize.ts +0 -191
- package/src/release/release-promotion-command.ts +0 -36
- package/src/release/release-promotion.ts +0 -132
- package/src/release/release-publication.ts +0 -213
- package/src/release/release-publish-command.ts +0 -163
- package/src/release/release-qualification.ts +0 -397
- package/src/release/release-staging.ts +0 -87
- package/src/release/release-steps.ts +0 -173
- package/src/release/retained-release-build.ts +0 -217
- package/src/shell/application-menu-commands.ts +0 -6
- package/src/shell/application-menu.ts +0 -250
- package/src/updates/channel-update-manager.ts +0 -127
- package/src/updates/desktop-updater.ts +0 -440
- package/src/updates/release-feed.ts +0 -187
- package/src/updates/release-location.ts +0 -101
- package/src/updates/signed-release.ts +0 -311
- package/src/updates/stable-file.ts +0 -32
- package/src/updates/update-arm.ts +0 -107
- package/src/updates/update-channel-store.ts +0 -86
- package/src/updates/update-discovery.ts +0 -113
- package/src/updates/update-download.ts +0 -82
- package/src/updates/update-exclusive-rename.ts +0 -58
- package/src/updates/update-extraction.ts +0 -261
- package/src/updates/update-handoff-plan.ts +0 -75
- package/src/updates/update-helper.ts +0 -87
- package/src/updates/update-launch.ts +0 -33
- package/src/updates/update-manager.ts +0 -130
- package/src/updates/update-process-fence.ts +0 -125
- package/src/updates/update-resume.ts +0 -34
- package/src/updates/update-shutdown.ts +0 -37
- package/src/updates/update-swap-stage.ts +0 -75
- package/src/updates/update-swap.ts +0 -30
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/** The transport supplies a verified principal; this registry does not authenticate it. */
|
|
2
|
-
export type ServiceDefinition<Principal, Input, Output> = Readonly<{
|
|
3
|
-
parse(value: unknown): Input
|
|
4
|
-
authorize(principal: Principal, input: Input): boolean | Promise<boolean>
|
|
5
|
-
run(principal: Principal, input: Input): Output | Promise<Output>
|
|
6
|
-
/** Largest invoke body the transport accepts for this service. Default 256 KiB, at most 16 MiB. */
|
|
7
|
-
maxBodyBytes?: number
|
|
8
|
-
}>
|
|
9
|
-
export type ServiceResult =
|
|
10
|
-
| { ok: true; value: unknown }
|
|
11
|
-
| { ok: false; code: 'unknown_service' | 'invalid_input' | 'unauthorized' | 'service_failed' }
|
|
12
|
-
| { ok: false; code: 'service_error'; error: { code: string; message: string } }
|
|
13
|
-
|
|
14
|
-
const MAX_ERROR_MESSAGE = 2048
|
|
15
|
-
export const DEFAULT_SERVICE_BODY_BYTES = 256 * 1024
|
|
16
|
-
export const MAX_SERVICE_BODY_BYTES = 16 * 1024 * 1024
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* An error a service means its caller to read. Throw it from `run` and the caller
|
|
20
|
-
* receives `{ok: false, code: 'service_error', error: {code, message}}`; any other
|
|
21
|
-
* thrown value stays a bare `service_failed` so implementation detail never leaks.
|
|
22
|
-
*/
|
|
23
|
-
export class ServiceError extends Error {
|
|
24
|
-
readonly code: string
|
|
25
|
-
constructor(code: string, message: string) {
|
|
26
|
-
if (typeof code !== 'string' || !/^[a-z][a-z0-9_]*$/.test(code) || code.length > 64)
|
|
27
|
-
throw new Error('Invalid service error code')
|
|
28
|
-
if (typeof message !== 'string') throw new Error('Invalid service error message')
|
|
29
|
-
super(message.length > MAX_ERROR_MESSAGE ? message.slice(0, MAX_ERROR_MESSAGE) : message)
|
|
30
|
-
this.name = 'ServiceError'
|
|
31
|
-
this.code = code
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** In-process dispatch boundary for app services. Never expose it without an authenticated transport. */
|
|
36
|
-
export function createServiceRegistry<Principal>() {
|
|
37
|
-
type Entry = {
|
|
38
|
-
maxBodyBytes: number
|
|
39
|
-
invoke(value: unknown, principal: Principal, current?: () => boolean): Promise<ServiceResult>
|
|
40
|
-
}
|
|
41
|
-
const entries = new Map<string, Entry>()
|
|
42
|
-
return {
|
|
43
|
-
register<Input, Output>(
|
|
44
|
-
name: string,
|
|
45
|
-
definition: ServiceDefinition<Principal, Input, Output>
|
|
46
|
-
): () => void {
|
|
47
|
-
if (!/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(name) || name.length > 128)
|
|
48
|
-
throw new Error('Invalid service name')
|
|
49
|
-
if (entries.has(name)) throw new Error('Service already registered')
|
|
50
|
-
const { parse, authorize, run } = definition
|
|
51
|
-
if (
|
|
52
|
-
typeof parse !== 'function' ||
|
|
53
|
-
typeof authorize !== 'function' ||
|
|
54
|
-
typeof run !== 'function'
|
|
55
|
-
)
|
|
56
|
-
throw new Error('Invalid service definition')
|
|
57
|
-
const maxBodyBytes = definition.maxBodyBytes ?? DEFAULT_SERVICE_BODY_BYTES
|
|
58
|
-
if (
|
|
59
|
-
!Number.isSafeInteger(maxBodyBytes) ||
|
|
60
|
-
maxBodyBytes < 1 ||
|
|
61
|
-
maxBodyBytes > MAX_SERVICE_BODY_BYTES
|
|
62
|
-
)
|
|
63
|
-
throw new Error('Invalid service body limit')
|
|
64
|
-
const entry: Entry = {
|
|
65
|
-
maxBodyBytes,
|
|
66
|
-
async invoke(value, principal, current) {
|
|
67
|
-
let input: Input
|
|
68
|
-
try {
|
|
69
|
-
input = parse(value)
|
|
70
|
-
} catch {
|
|
71
|
-
return { ok: false, code: 'invalid_input' }
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
if ((await authorize(principal, input)) !== true)
|
|
75
|
-
return { ok: false, code: 'unauthorized' }
|
|
76
|
-
} catch {
|
|
77
|
-
return { ok: false, code: 'unauthorized' }
|
|
78
|
-
}
|
|
79
|
-
if (entries.get(name) !== entry) return { ok: false, code: 'unknown_service' }
|
|
80
|
-
try {
|
|
81
|
-
if (current && current() !== true) return { ok: false, code: 'unauthorized' }
|
|
82
|
-
} catch {
|
|
83
|
-
return { ok: false, code: 'unauthorized' }
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
return { ok: true, value: await run(principal, input) }
|
|
87
|
-
} catch (error) {
|
|
88
|
-
if (!(error instanceof ServiceError)) return { ok: false, code: 'service_failed' }
|
|
89
|
-
return {
|
|
90
|
-
ok: false,
|
|
91
|
-
code: 'service_error',
|
|
92
|
-
error: { code: error.code, message: error.message },
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
}
|
|
97
|
-
entries.set(name, entry)
|
|
98
|
-
return () => {
|
|
99
|
-
if (entries.get(name) === entry) entries.delete(name)
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* The invoke body limit for `name` (the default for an unknown service), or with no
|
|
104
|
-
* name the largest limit any registered service accepts, for reading before the name is known.
|
|
105
|
-
*/
|
|
106
|
-
maxBodyBytes(name?: string): number {
|
|
107
|
-
if (name !== undefined) return entries.get(name)?.maxBodyBytes ?? DEFAULT_SERVICE_BODY_BYTES
|
|
108
|
-
let largest = DEFAULT_SERVICE_BODY_BYTES
|
|
109
|
-
for (const entry of entries.values()) largest = Math.max(largest, entry.maxBodyBytes)
|
|
110
|
-
return largest
|
|
111
|
-
},
|
|
112
|
-
/** `current` must synchronously recheck channel and scope immediately before the handler starts. */
|
|
113
|
-
async dispatch(
|
|
114
|
-
name: string,
|
|
115
|
-
value: unknown,
|
|
116
|
-
principal: Principal,
|
|
117
|
-
current?: () => boolean
|
|
118
|
-
): Promise<ServiceResult> {
|
|
119
|
-
const entry = entries.get(name)
|
|
120
|
-
if (!entry) return { ok: false, code: 'unknown_service' }
|
|
121
|
-
return entry.invoke(value, principal, current)
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identifies the toolchain cached `vp` tasks run on, so every cache key covers
|
|
3
|
-
* it without anyone setting a label.
|
|
4
|
-
*
|
|
5
|
-
* Vite Task fingerprints a task's command text, declared environment variables
|
|
6
|
-
* and the files it reads, but not the `node` or `bun` binary or the platform.
|
|
7
|
-
* An app's `vite.config.ts` calls `expectedId()` every time `vp` loads it and
|
|
8
|
-
* writes the result into the text of each cached command, so a different Node,
|
|
9
|
-
* Bun or platform is a different key. The id lives in the invocation's own task
|
|
10
|
-
* graph, not in a file, so two `vp` invocations in one checkout with different
|
|
11
|
-
* toolchains cannot see each other's.
|
|
12
|
-
*
|
|
13
|
-
* The config process cannot be trusted to see what the tasks will, so every
|
|
14
|
-
* invocation also runs an uncached task first
|
|
15
|
-
* (`adea-toolchain-identity --expect <id>`) with the PATH the tasks really get.
|
|
16
|
-
* It recomputes the id and exits non-zero unless it equals the one written into
|
|
17
|
-
* the commands; the dependent tasks then do not run and nothing is read from or
|
|
18
|
-
* stored in the cache.
|
|
19
|
-
*
|
|
20
|
-
* The id holds each binary's version and a hash of its bytes, the platform and
|
|
21
|
-
* the libc, never a path: the same bytes at another path (another checkout, a CI
|
|
22
|
-
* runner) keep their entries.
|
|
23
|
-
*/
|
|
24
|
-
import { execFileSync } from 'node:child_process'
|
|
25
|
-
import { createHash } from 'node:crypto'
|
|
26
|
-
import {
|
|
27
|
-
accessSync,
|
|
28
|
-
closeSync,
|
|
29
|
-
constants,
|
|
30
|
-
mkdirSync,
|
|
31
|
-
openSync,
|
|
32
|
-
readFileSync,
|
|
33
|
-
readSync,
|
|
34
|
-
realpathSync,
|
|
35
|
-
renameSync,
|
|
36
|
-
statSync,
|
|
37
|
-
writeFileSync,
|
|
38
|
-
} from 'node:fs'
|
|
39
|
-
import { delimiter, join } from 'node:path'
|
|
40
|
-
|
|
41
|
-
/** The marker written into commands when the toolchain could not be identified. It never matches. */
|
|
42
|
-
export const UNIDENTIFIED = 'unidentified'
|
|
43
|
-
|
|
44
|
-
type Memo = Record<string, string>
|
|
45
|
-
type Binary = { version: string; sha256: string }
|
|
46
|
-
export type ToolchainIdentity = { platform: string; libc: string; node: Binary; bun: Binary }
|
|
47
|
-
|
|
48
|
-
const errorCode = (error: unknown) => (error as NodeJS.ErrnoException | null)?.code
|
|
49
|
-
const message = (error: unknown) => (error instanceof Error ? error.message : String(error))
|
|
50
|
-
|
|
51
|
-
/** The executable `name` resolves to on `searchPath`, never a CWD lookup. */
|
|
52
|
-
export function onPath(
|
|
53
|
-
name: string,
|
|
54
|
-
searchPath: string,
|
|
55
|
-
platform: NodeJS.Platform = process.platform
|
|
56
|
-
): string | undefined {
|
|
57
|
-
for (const dir of searchPath.split(delimiter)) {
|
|
58
|
-
if (!dir) continue
|
|
59
|
-
// Windows' native Node and Bun distributions use .exe; keep checking an
|
|
60
|
-
// extensionless launcher first so an ambiguous wrapper cannot be skipped.
|
|
61
|
-
const executable = (filename: string) => {
|
|
62
|
-
const candidate = join(dir, filename)
|
|
63
|
-
try {
|
|
64
|
-
accessSync(candidate, constants.X_OK)
|
|
65
|
-
if (statSync(candidate).isFile()) return realpathSync(candidate)
|
|
66
|
-
} catch {
|
|
67
|
-
// not in this directory
|
|
68
|
-
}
|
|
69
|
-
return undefined
|
|
70
|
-
}
|
|
71
|
-
const exact = executable(name)
|
|
72
|
-
if (exact) return exact
|
|
73
|
-
// Batch and COM launchers may be selected by a Windows shell but cannot
|
|
74
|
-
// be fingerprinted safely with execFileSync. Refuse rather than skip one
|
|
75
|
-
// and accidentally hash a different binary later in PATH.
|
|
76
|
-
if (platform === 'win32') {
|
|
77
|
-
for (const ext of ['.cmd', '.bat', '.com']) {
|
|
78
|
-
try {
|
|
79
|
-
if (statSync(join(dir, name + ext)).isFile())
|
|
80
|
-
throw new Error(`Cannot identify Windows launcher for ${name}`)
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (errorCode(error) !== 'ENOENT' && errorCode(error) !== 'ENOTDIR') throw error
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const native = executable(`${name}.exe`)
|
|
86
|
-
if (native) return native
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return undefined
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const memoFile = (root: string) => join(root, 'node_modules', '.cache', 'orch-toolchain-memo.json')
|
|
93
|
-
|
|
94
|
-
function readMemo(root: string): Memo {
|
|
95
|
-
try {
|
|
96
|
-
return JSON.parse(readFileSync(memoFile(root), 'utf8')) as Memo
|
|
97
|
-
} catch {
|
|
98
|
-
return {}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** sha256 of a file, remembered by path, size and modification time (a hash cache, not an identity). */
|
|
103
|
-
function sha256(file: string, memo: Memo, root: string): string {
|
|
104
|
-
const before = statSync(file)
|
|
105
|
-
const key = `${file}:${before.size}:${before.mtimeMs}`
|
|
106
|
-
if (memo[key]) return memo[key]
|
|
107
|
-
const hash = createHash('sha256')
|
|
108
|
-
const buffer = Buffer.allocUnsafe(1 << 20)
|
|
109
|
-
const fd = openSync(file, 'r')
|
|
110
|
-
try {
|
|
111
|
-
for (;;) {
|
|
112
|
-
const read = readSync(fd, buffer, 0, buffer.length, null)
|
|
113
|
-
if (read === 0) break
|
|
114
|
-
hash.update(buffer.subarray(0, read))
|
|
115
|
-
}
|
|
116
|
-
} finally {
|
|
117
|
-
closeSync(fd)
|
|
118
|
-
}
|
|
119
|
-
const digest = hash.digest('hex')
|
|
120
|
-
const after = statSync(file)
|
|
121
|
-
// A file replaced while it was read is not remembered.
|
|
122
|
-
if (after.size === before.size && after.mtimeMs === before.mtimeMs) {
|
|
123
|
-
for (const old of Object.keys(memo)) if (old.startsWith(`${file}:`)) delete memo[old]
|
|
124
|
-
memo[key] = digest
|
|
125
|
-
try {
|
|
126
|
-
mkdirSync(join(root, 'node_modules', '.cache'), { recursive: true })
|
|
127
|
-
// Atomic, so a concurrent invocation never reads a torn memo. Last writer
|
|
128
|
-
// wins; a lost entry only costs a rehash.
|
|
129
|
-
const staged = `${memoFile(root)}.${process.pid}`
|
|
130
|
-
writeFileSync(staged, JSON.stringify(memo))
|
|
131
|
-
renameSync(staged, memoFile(root))
|
|
132
|
-
} catch {
|
|
133
|
-
// the memo is an optimisation
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return digest
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* The real executable behind `name` on `searchPath`. A launcher (Vite+ may
|
|
141
|
-
* prepend one only when a task starts) is followed to the binary it runs.
|
|
142
|
-
*/
|
|
143
|
-
export function runtimeExecutable(
|
|
144
|
-
name: string,
|
|
145
|
-
searchPath: string = process.env.PATH ?? ''
|
|
146
|
-
): string {
|
|
147
|
-
const file = onPath(name, searchPath)
|
|
148
|
-
if (!file) throw new Error(`\`${name}\` is not on PATH, so the toolchain cannot be identified`)
|
|
149
|
-
try {
|
|
150
|
-
const executable = execFileSync(file, ['-p', 'process.execPath'], {
|
|
151
|
-
encoding: 'utf8',
|
|
152
|
-
// Cached launchers inherit PATH; avoid enumerating unrelated variables.
|
|
153
|
-
...(searchPath === process.env.PATH ? {} : { env: { ...process.env, PATH: searchPath } }),
|
|
154
|
-
}).trim()
|
|
155
|
-
if (!executable || !statSync(executable).isFile()) throw new Error('invalid executable path')
|
|
156
|
-
return realpathSync(executable)
|
|
157
|
-
} catch (error) {
|
|
158
|
-
throw new Error(`\`${name}\` executable probe failed: ${message(error)}`, { cause: error })
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function describe(name: string, searchPath: string, memo: Memo, root: string): Binary {
|
|
163
|
-
const file = onPath(name, searchPath)
|
|
164
|
-
if (!file) throw new Error(`\`${name}\` is not on PATH, so the toolchain cannot be identified`)
|
|
165
|
-
let version: string
|
|
166
|
-
try {
|
|
167
|
-
version = execFileSync(file, ['--version'], { encoding: 'utf8' }).trim()
|
|
168
|
-
} catch (error) {
|
|
169
|
-
throw new Error(`\`${name} --version\` failed: ${message(error)}`, { cause: error })
|
|
170
|
-
}
|
|
171
|
-
if (!version) throw new Error(`\`${name} --version\` printed nothing`)
|
|
172
|
-
return { version, sha256: sha256(runtimeExecutable(name, searchPath), memo, root) }
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* The identity of the `node` and `bun` found on `searchPath`, and of the
|
|
177
|
-
* platform. Throws when it cannot be established.
|
|
178
|
-
*/
|
|
179
|
-
export function identity({
|
|
180
|
-
root = process.cwd(),
|
|
181
|
-
searchPath = process.env.PATH ?? '',
|
|
182
|
-
}: { root?: string; searchPath?: string } = {}): ToolchainIdentity {
|
|
183
|
-
const memo = readMemo(root)
|
|
184
|
-
const report = process.report?.getReport?.() as { header?: { glibcVersionRuntime?: string } }
|
|
185
|
-
const libc = report?.header?.glibcVersionRuntime
|
|
186
|
-
return {
|
|
187
|
-
platform: `${process.platform}-${process.arch}`,
|
|
188
|
-
libc: libc ? `glibc${libc}` : process.platform === 'linux' ? 'non-glibc' : 'na',
|
|
189
|
-
node: describe('node', searchPath, memo, root),
|
|
190
|
-
bun: describe('bun', searchPath, memo, root),
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const clean = (text: string) => text.replace(/^v/, '').replace(/[^A-Za-z0-9.]+/g, '_')
|
|
195
|
-
|
|
196
|
-
/** A short, shell-safe id that goes into command text. */
|
|
197
|
-
export function idOf(found: ToolchainIdentity): string {
|
|
198
|
-
return [
|
|
199
|
-
found.platform,
|
|
200
|
-
found.libc,
|
|
201
|
-
`node${clean(found.node.version)}-${found.node.sha256.slice(0, 12)}`,
|
|
202
|
-
`bun${clean(found.bun.version)}-${found.bun.sha256.slice(0, 12)}`,
|
|
203
|
-
].join('.')
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The id the tasks of the invocation that is loading `vite.config.ts` are
|
|
208
|
-
* expected to run on. `vp` runs tasks with `node_modules/.bin` first and the
|
|
209
|
-
* package-manager `bun` ahead of the shell's, and gives the config process the
|
|
210
|
-
* latter already, so the workspace `.bin` is the one directory added here.
|
|
211
|
-
*/
|
|
212
|
-
export function expectedId(root: string = process.cwd()): string {
|
|
213
|
-
try {
|
|
214
|
-
const searchPath = [join(root, 'node_modules', '.bin'), process.env.PATH ?? ''].join(delimiter)
|
|
215
|
-
return idOf(identity({ root, searchPath }))
|
|
216
|
-
} catch {
|
|
217
|
-
return UNIDENTIFIED
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/** Exit status for `--expect <id>`: 0 only when the tasks run on the toolchain their keys name. */
|
|
222
|
-
export function verifyToolchain(expected: string, root: string = process.cwd()): number {
|
|
223
|
-
let actual: string
|
|
224
|
-
try {
|
|
225
|
-
actual = idOf(identity({ root }))
|
|
226
|
-
} catch (error) {
|
|
227
|
-
console.error(`toolchain-identity: ${message(error)}`)
|
|
228
|
-
return 1
|
|
229
|
-
}
|
|
230
|
-
if (expected === UNIDENTIFIED) {
|
|
231
|
-
console.error(
|
|
232
|
-
'toolchain-identity: the toolchain could not be identified when the tasks were loaded'
|
|
233
|
-
)
|
|
234
|
-
return 1
|
|
235
|
-
}
|
|
236
|
-
if (actual !== expected) {
|
|
237
|
-
console.error(
|
|
238
|
-
`toolchain-identity: the tasks run on ${actual}, but their cache keys were written for ${expected}`
|
|
239
|
-
)
|
|
240
|
-
return 1
|
|
241
|
-
}
|
|
242
|
-
console.log(`toolchain ${actual}`)
|
|
243
|
-
return 0
|
|
244
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { cefHelperCacheKey, cefHelperFailure, ensurePatchedCefHelper } from '../native/cef-helper'
|
|
3
|
-
import { runCli } from './cli-runner'
|
|
4
|
-
|
|
5
|
-
// `key` prints this platform's patched CEF helper cache key, for CI caches of
|
|
6
|
-
// ADEA_CEF_HELPER_CACHE; it changes with the pinned source, patch and CEF SDK.
|
|
7
|
-
// `build` fills that cache ahead of an Electrobun build.
|
|
8
|
-
await runCli(
|
|
9
|
-
(error) => `Unable to prepare the patched CEF helper: ${cefHelperFailure(error)}`,
|
|
10
|
-
async () => {
|
|
11
|
-
const [command, ...extra] = process.argv.slice(2)
|
|
12
|
-
if (extra.length || (command !== 'key' && command !== 'build'))
|
|
13
|
-
throw new Error('Unexpected arguments')
|
|
14
|
-
const os = { darwin: 'macos', linux: 'linux', win32: 'win' }[process.platform as string] ?? ''
|
|
15
|
-
if (command === 'key') process.stdout.write(`${cefHelperCacheKey(os, process.arch)}\n`)
|
|
16
|
-
else {
|
|
17
|
-
await ensurePatchedCefHelper(process.env, os, process.arch)
|
|
18
|
-
process.stdout.write('Patched CEF helper is cached\n')
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
)
|
package/src/cli/cli-runner.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { lstat, readFile } from 'node:fs/promises'
|
|
2
|
-
|
|
3
|
-
/** Run a command-line entry point. Any failure prints `failure` and sets exit code 1. A
|
|
4
|
-
* string never shows the error itself, which may carry paths or key material; pass a
|
|
5
|
-
* function only for commands whose errors are safe to print. */
|
|
6
|
-
export async function runCli(
|
|
7
|
-
failure: string | ((error: unknown) => string),
|
|
8
|
-
main: () => unknown,
|
|
9
|
-
options: { requireGitHubActions?: boolean } = {}
|
|
10
|
-
): Promise<void> {
|
|
11
|
-
try {
|
|
12
|
-
if (options.requireGitHubActions && process.env.GITHUB_ACTIONS !== 'true')
|
|
13
|
-
throw new Error('Invalid workflow invocation')
|
|
14
|
-
await main()
|
|
15
|
-
} catch (error) {
|
|
16
|
-
process.stderr.write(`${typeof failure === 'string' ? failure : failure(error)}\n`)
|
|
17
|
-
process.exitCode = 1
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Parse a JSON file that is a regular file, not a link, of 1 to `maxBytes` bytes. */
|
|
22
|
-
export async function readJsonFile(path: string, maxBytes: number): Promise<unknown> {
|
|
23
|
-
const info = await lstat(path)
|
|
24
|
-
if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > maxBytes)
|
|
25
|
-
throw new Error('Invalid configuration file')
|
|
26
|
-
const bytes = await readFile(path)
|
|
27
|
-
if (bytes.length !== info.size) throw new Error('Configuration file changed')
|
|
28
|
-
return JSON.parse(bytes.toString('utf8'))
|
|
29
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { createApplication } from '../app/create-application'
|
|
3
|
-
import { runCli } from './cli-runner'
|
|
4
|
-
|
|
5
|
-
const usage =
|
|
6
|
-
'Usage: create-adea-app --directory PATH --slug SLUG --name NAME --identifier REVERSE_DNS --source-url HTTPS_URL --framework SPECIFIER [--renderer native|cef]'
|
|
7
|
-
const allowed = new Set([
|
|
8
|
-
'directory',
|
|
9
|
-
'slug',
|
|
10
|
-
'name',
|
|
11
|
-
'identifier',
|
|
12
|
-
'source-url',
|
|
13
|
-
'framework',
|
|
14
|
-
'renderer',
|
|
15
|
-
])
|
|
16
|
-
await runCli(
|
|
17
|
-
(error) => (error instanceof Error ? error.message : 'Could not create application'),
|
|
18
|
-
async () => {
|
|
19
|
-
const args = process.argv.slice(2)
|
|
20
|
-
if (args.length === 1 && args[0] === '--help') {
|
|
21
|
-
console.log(usage)
|
|
22
|
-
process.exit(0)
|
|
23
|
-
}
|
|
24
|
-
const values: Record<string, string> = {}
|
|
25
|
-
for (let i = 0; i < args.length; i += 2) {
|
|
26
|
-
const key = args[i]?.startsWith('--') ? args[i]!.slice(2) : ''
|
|
27
|
-
const value = args[i + 1]
|
|
28
|
-
if (!allowed.has(key) || values[key] !== undefined || !value || value.startsWith('--'))
|
|
29
|
-
throw new Error(usage)
|
|
30
|
-
values[key] = value
|
|
31
|
-
}
|
|
32
|
-
const {
|
|
33
|
-
directory,
|
|
34
|
-
slug,
|
|
35
|
-
name,
|
|
36
|
-
identifier,
|
|
37
|
-
'source-url': sourceUrl,
|
|
38
|
-
framework,
|
|
39
|
-
renderer,
|
|
40
|
-
} = values
|
|
41
|
-
if (
|
|
42
|
-
!directory ||
|
|
43
|
-
!slug ||
|
|
44
|
-
!name ||
|
|
45
|
-
!identifier ||
|
|
46
|
-
!sourceUrl ||
|
|
47
|
-
!framework ||
|
|
48
|
-
(renderer && renderer !== 'native' && renderer !== 'cef')
|
|
49
|
-
)
|
|
50
|
-
throw new Error(usage)
|
|
51
|
-
const result = await createApplication({
|
|
52
|
-
directory,
|
|
53
|
-
slug,
|
|
54
|
-
name,
|
|
55
|
-
identifier,
|
|
56
|
-
sourceUrl,
|
|
57
|
-
frameworkSpecifier: framework,
|
|
58
|
-
renderer: renderer as 'native' | 'cef' | undefined,
|
|
59
|
-
})
|
|
60
|
-
console.log(`Created application at ${result.directory}`)
|
|
61
|
-
}
|
|
62
|
-
)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { execFileSync } from 'node:child_process'
|
|
3
|
-
import { resolve } from 'node:path'
|
|
4
|
-
import {
|
|
5
|
-
applyElectrobunPatch,
|
|
6
|
-
ELECTROBUN_COMMIT,
|
|
7
|
-
PINNED_SHORTCUT_PATCH,
|
|
8
|
-
SHORTCUT_PATCH_PATH,
|
|
9
|
-
} from '../native/electrobun-source-patch'
|
|
10
|
-
import { runCli } from './cli-runner'
|
|
11
|
-
|
|
12
|
-
await runCli(
|
|
13
|
-
(error) =>
|
|
14
|
-
`Unable to apply the pinned Electrobun shortcut patch: ${error instanceof Error ? error.message : 'unknown error'}`,
|
|
15
|
-
() => {
|
|
16
|
-
const [checkout, ...extra] = process.argv.slice(2)
|
|
17
|
-
if (!checkout || extra.length) throw new Error('Expected an Electrobun checkout')
|
|
18
|
-
const root = resolve(checkout)
|
|
19
|
-
const head = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim()
|
|
20
|
-
if (head !== ELECTROBUN_COMMIT) throw new Error('Unexpected Electrobun commit')
|
|
21
|
-
applyElectrobunPatch(root, SHORTCUT_PATCH_PATH, PINNED_SHORTCUT_PATCH)
|
|
22
|
-
process.stdout.write('Prepared pinned Electrobun extractor with bounded Shell Link shortcuts\n')
|
|
23
|
-
}
|
|
24
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { applyFrameworkUpdate, resolveFrameworkRelease } from '../release/framework-update'
|
|
3
|
-
import { runCli } from './cli-runner'
|
|
4
|
-
|
|
5
|
-
// Usage: adea-update-app-framework [version]. Run from the consumer's repository root.
|
|
6
|
-
await runCli(
|
|
7
|
-
(error) => `App-framework update failed; nothing was changed. ${(error as Error).message}`,
|
|
8
|
-
async () => {
|
|
9
|
-
const [requested, ...extra] = process.argv.slice(2)
|
|
10
|
-
if (extra.length) throw new Error('Usage: adea-update-app-framework [version]')
|
|
11
|
-
const release = await resolveFrameworkRelease(
|
|
12
|
-
{
|
|
13
|
-
async registry(path) {
|
|
14
|
-
const response = await fetch(`https://registry.npmjs.org/${path}`, {
|
|
15
|
-
headers: { accept: 'application/json' },
|
|
16
|
-
})
|
|
17
|
-
if (!response.ok) throw new Error(`npm answered ${response.status} for ${path}`)
|
|
18
|
-
return response.json()
|
|
19
|
-
},
|
|
20
|
-
async download(url) {
|
|
21
|
-
const response = await fetch(url)
|
|
22
|
-
if (!response.ok) throw new Error(`Download answered ${response.status}`)
|
|
23
|
-
return new Uint8Array(await response.arrayBuffer())
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
requested
|
|
27
|
-
)
|
|
28
|
-
const root = process.cwd()
|
|
29
|
-
const result = await applyFrameworkUpdate(root, release, {
|
|
30
|
-
async run(command, cwd) {
|
|
31
|
-
return Bun.spawn(command, { cwd, stdout: 'inherit', stderr: 'inherit' }).exited
|
|
32
|
-
},
|
|
33
|
-
async files(cwd) {
|
|
34
|
-
const listing = Bun.spawnSync(['git', 'ls-files', '-z'], { cwd })
|
|
35
|
-
if (listing.exitCode !== 0) throw new Error('git ls-files failed')
|
|
36
|
-
return listing.stdout.toString().split('\0').filter(Boolean)
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
process.stdout.write(JSON.stringify(result) + '\n')
|
|
40
|
-
}
|
|
41
|
-
)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { planReleaseAssets } from '../release/release-assets-plan'
|
|
3
|
-
import { readJsonFile, runCli } from './cli-runner'
|
|
4
|
-
|
|
5
|
-
await runCli(
|
|
6
|
-
'Unable to plan release assets; check release provenance and the trusted workflow.',
|
|
7
|
-
async () => {
|
|
8
|
-
const [tag, path, ...extra] = process.argv.slice(2)
|
|
9
|
-
if (!tag || !path || extra.length)
|
|
10
|
-
throw new Error('Expected release tag and configuration file')
|
|
11
|
-
const config = await readJsonFile(path, 262144)
|
|
12
|
-
console.log(JSON.stringify(await planReleaseAssets({ env: process.env, config, tag })))
|
|
13
|
-
}
|
|
14
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { runReleaseCutCommand } from '../release/release-cut-command'
|
|
3
|
-
import { gitCli } from '../release/local-provenance'
|
|
4
|
-
import { hostReleasePlatform, runLocalReleaseCut } from '../release/local-release'
|
|
5
|
-
import { readJsonFile, runCli } from './cli-runner'
|
|
6
|
-
|
|
7
|
-
// `release-cut-cli.js <dev|daily> <config>` in the trusted control workflow, or
|
|
8
|
-
// `release-cut-cli.js --local <dev|daily> <config> <source-sha>` from a clean checkout.
|
|
9
|
-
const local = process.argv[2] === '--local'
|
|
10
|
-
await runCli(
|
|
11
|
-
'Unable to cut the release; check the trusted workflow or local checkout and release configuration.',
|
|
12
|
-
async () => {
|
|
13
|
-
const [kind, path, sourceSha, ...extra] = process.argv.slice(local ? 3 : 2)
|
|
14
|
-
if ((kind !== 'daily' && kind !== 'dev') || !path || extra.length || !sourceSha !== !local)
|
|
15
|
-
throw new Error('Invalid workflow invocation')
|
|
16
|
-
const config = await readJsonFile(path, 65536)
|
|
17
|
-
if (
|
|
18
|
-
typeof config !== 'object' ||
|
|
19
|
-
config === null ||
|
|
20
|
-
typeof (config as { appName?: unknown }).appName !== 'string'
|
|
21
|
-
)
|
|
22
|
-
throw new Error('Missing app name')
|
|
23
|
-
const result = local
|
|
24
|
-
? await runLocalReleaseCut({
|
|
25
|
-
kind,
|
|
26
|
-
config,
|
|
27
|
-
sourceSha: sourceSha!,
|
|
28
|
-
platform: hostReleasePlatform(),
|
|
29
|
-
git: gitCli(),
|
|
30
|
-
fetch,
|
|
31
|
-
})
|
|
32
|
-
: await runReleaseCutCommand({
|
|
33
|
-
env: process.env,
|
|
34
|
-
kind,
|
|
35
|
-
appName: (config as { appName: string }).appName,
|
|
36
|
-
config,
|
|
37
|
-
})
|
|
38
|
-
process.stdout.write(JSON.stringify(result) + '\n')
|
|
39
|
-
},
|
|
40
|
-
{ requireGitHubActions: !local }
|
|
41
|
-
)
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { createPrivateKey } from 'node:crypto'
|
|
3
|
-
import { gitCli } from '../release/local-provenance'
|
|
4
|
-
import {
|
|
5
|
-
hostReleasePlatform,
|
|
6
|
-
localTagProvenance,
|
|
7
|
-
stageLocalDescriptors,
|
|
8
|
-
} from '../release/local-release'
|
|
9
|
-
import { stageReleaseDescriptors } from '../release/release-descriptor-staging'
|
|
10
|
-
import { readJsonFile, runCli } from './cli-runner'
|
|
11
|
-
|
|
12
|
-
// `release-descriptor-staging-cli.js [--local] <directory> <config>` with RELEASE_TAG and the
|
|
13
|
-
// signing key in the environment. Locally it signs this machine's platform only, with
|
|
14
|
-
// SOURCE_SHA and the local run number RELEASE_RUN_ID as provenance.
|
|
15
|
-
const local = process.argv[2] === '--local'
|
|
16
|
-
await runCli(
|
|
17
|
-
'Unable to stage signed descriptors; check the trusted release, installer receipts and signing configuration.',
|
|
18
|
-
async () => {
|
|
19
|
-
const [directory, configPath, ...extra] = process.argv.slice(local ? 3 : 2)
|
|
20
|
-
const {
|
|
21
|
-
RELEASE_TAG: tag,
|
|
22
|
-
ADEA_RELEASE_SIGNING_KEY: pem,
|
|
23
|
-
ADEA_RELEASE_SIGNING_KEY_ID: keyId,
|
|
24
|
-
SOURCE_SHA: sourceSha,
|
|
25
|
-
RELEASE_RUN_ID: runId,
|
|
26
|
-
} = process.env
|
|
27
|
-
if (!directory || !configPath || extra.length || !tag || !pem || !keyId)
|
|
28
|
-
throw new Error('Missing signing context')
|
|
29
|
-
const config = await readJsonFile(configPath, 262144)
|
|
30
|
-
if (!local) {
|
|
31
|
-
const names = await stageReleaseDescriptors({
|
|
32
|
-
env: process.env,
|
|
33
|
-
config,
|
|
34
|
-
directory,
|
|
35
|
-
tag,
|
|
36
|
-
keyId,
|
|
37
|
-
privateKey: createPrivateKey(pem),
|
|
38
|
-
})
|
|
39
|
-
console.log(JSON.stringify(names))
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
if (!sourceSha || !runId) throw new Error('Missing local release identity')
|
|
43
|
-
const { repository } = await localTagProvenance({ config, tag, sourceSha, git: gitCli() })
|
|
44
|
-
const names = await stageLocalDescriptors({
|
|
45
|
-
config,
|
|
46
|
-
directory,
|
|
47
|
-
tag,
|
|
48
|
-
sourceSha,
|
|
49
|
-
repository,
|
|
50
|
-
runId,
|
|
51
|
-
platform: hostReleasePlatform(),
|
|
52
|
-
keyId,
|
|
53
|
-
privateKey: createPrivateKey(pem),
|
|
54
|
-
})
|
|
55
|
-
console.log(JSON.stringify(names))
|
|
56
|
-
}
|
|
57
|
-
)
|