@adea-ai/app-framework 0.24.0 → 0.25.0

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.
Files changed (137) hide show
  1. package/README.md +49 -1
  2. package/dist/cli/macos-signing-cli.d.ts +2 -0
  3. package/dist/cli/macos-signing-cli.js +14 -0
  4. package/dist/desktop/channel-proof.js +7 -1
  5. package/dist/framework-source.json +1 -1
  6. package/dist/release/framework-package-publish.js +4 -2
  7. package/dist/release/local-release.d.ts +2 -0
  8. package/dist/release/local-release.js +25 -2
  9. package/dist/release/macos-signing.d.ts +27 -0
  10. package/dist/release/macos-signing.js +101 -0
  11. package/dist/shell/app-shell.js +21 -33
  12. package/dist/shell/navigation-drawer.d.ts +12 -0
  13. package/dist/shell/navigation-drawer.js +42 -0
  14. package/dist/updates/release-feed.d.ts +2 -0
  15. package/dist/updates/release-feed.js +11 -2
  16. package/package.json +16 -4
  17. package/src/shell/app-shell.tsx +29 -20
  18. package/src/shell/navigation-drawer.tsx +36 -0
  19. package/src/app/create-application.ts +0 -245
  20. package/src/app/service-registry.ts +0 -124
  21. package/src/ci/toolchain-identity.ts +0 -244
  22. package/src/cli/cef-helper-cli.ts +0 -21
  23. package/src/cli/cli-runner.ts +0 -29
  24. package/src/cli/create-application-cli.ts +0 -62
  25. package/src/cli/electrobun-shortcut-patch-cli.ts +0 -24
  26. package/src/cli/framework-update-cli.ts +0 -41
  27. package/src/cli/release-assets-plan-cli.ts +0 -14
  28. package/src/cli/release-cut-cli.ts +0 -41
  29. package/src/cli/release-descriptor-staging-cli.ts +0 -57
  30. package/src/cli/release-finalize-cli.ts +0 -34
  31. package/src/cli/release-promote-cli.ts +0 -31
  32. package/src/cli/release-publish-cli.ts +0 -46
  33. package/src/cli/release-sign-cli.ts +0 -24
  34. package/src/cli/release-step-cli.ts +0 -71
  35. package/src/cli/toolchain-identity-cli.ts +0 -12
  36. package/src/cli/update-helper-cli.ts +0 -12
  37. package/src/cli/windows-runtime-patch-cli.ts +0 -17
  38. package/src/desktop/application-command-client.ts +0 -43
  39. package/src/desktop/channel-handshake.ts +0 -136
  40. package/src/desktop/channel-proof.ts +0 -122
  41. package/src/desktop/desktop-client.ts +0 -303
  42. package/src/desktop/desktop-gateway.ts +0 -189
  43. package/src/desktop/desktop-host.ts +0 -335
  44. package/src/desktop/desktop-stream.ts +0 -324
  45. package/src/desktop/loopback-policy.ts +0 -41
  46. package/src/desktop/open-url-channel.ts +0 -79
  47. package/src/desktop/string-policy.ts +0 -9
  48. package/src/installer/archive-entry.ts +0 -32
  49. package/src/installer/command-artifact.ts +0 -307
  50. package/src/installer/command-qualification-command.ts +0 -75
  51. package/src/installer/hosted-runner.ts +0 -11
  52. package/src/installer/installed-payload.ts +0 -408
  53. package/src/installer/installer-ci-bootstrap.ts +0 -199
  54. package/src/installer/installer-ci-preflight.ts +0 -61
  55. package/src/installer/installer-ci-worker.ts +0 -105
  56. package/src/installer/installer-extraction.ts +0 -367
  57. package/src/installer/installer-fetch-guard.ts +0 -75
  58. package/src/installer/installer-identity.ts +0 -331
  59. package/src/installer/installer-layout.ts +0 -167
  60. package/src/installer/installer-observation.ts +0 -671
  61. package/src/installer/installer-process-cleanup.ts +0 -167
  62. package/src/installer/installer-qualification-command.ts +0 -81
  63. package/src/installer/installer-renderer-evidence.ts +0 -268
  64. package/src/installer/installer-upgrade-command.ts +0 -226
  65. package/src/installer/installer-worker-guard.ts +0 -112
  66. package/src/installer/native-executable.ts +0 -37
  67. package/src/installer/upgrade-asset-download.ts +0 -72
  68. package/src/installer/write-all.ts +0 -19
  69. package/src/native/app-bundle.ts +0 -86
  70. package/src/native/cef-helper.ts +0 -471
  71. package/src/native/desktop-build-hook.ts +0 -21
  72. package/src/native/electrobun-source-patch.ts +0 -107
  73. package/src/native/linux-cef-links.ts +0 -14
  74. package/src/native/native-secret-store.ts +0 -99
  75. package/src/native/native-utilities.ts +0 -166
  76. package/src/native/partitioned-window.ts +0 -62
  77. package/src/native/secure-window.ts +0 -115
  78. package/src/native/sidecar-services.ts +0 -71
  79. package/src/native/sidecar.ts +0 -387
  80. package/src/native/window-bootstrap.ts +0 -77
  81. package/src/native/windows-build-hook-internal.ts +0 -49
  82. package/src/native/windows-build-hook.ts +0 -12
  83. package/src/native/windows-runtime-patch-internal.ts +0 -48
  84. package/src/native/windows-runtime-patch.ts +0 -15
  85. package/src/release/feed-release-cut.ts +0 -110
  86. package/src/release/feed-state.ts +0 -135
  87. package/src/release/framework-package-publish.ts +0 -163
  88. package/src/release/framework-update.ts +0 -196
  89. package/src/release/github-cli.ts +0 -27
  90. package/src/release/github-release-assets.ts +0 -36
  91. package/src/release/github-release-cut.ts +0 -237
  92. package/src/release/github-release-lookup.ts +0 -39
  93. package/src/release/github-release-promotion.ts +0 -112
  94. package/src/release/github-release-provenance.ts +0 -65
  95. package/src/release/github-release-publisher.ts +0 -90
  96. package/src/release/github-release-qualification.ts +0 -144
  97. package/src/release/local-provenance.ts +0 -92
  98. package/src/release/local-release.ts +0 -525
  99. package/src/release/macos-dmg.ts +0 -113
  100. package/src/release/release-artifact.ts +0 -53
  101. package/src/release/release-assets-plan.ts +0 -118
  102. package/src/release/release-config.ts +0 -420
  103. package/src/release/release-cut-command.ts +0 -80
  104. package/src/release/release-cut.ts +0 -133
  105. package/src/release/release-descriptor-staging.ts +0 -242
  106. package/src/release/release-finalize.ts +0 -191
  107. package/src/release/release-promotion-command.ts +0 -36
  108. package/src/release/release-promotion.ts +0 -132
  109. package/src/release/release-publication.ts +0 -213
  110. package/src/release/release-publish-command.ts +0 -163
  111. package/src/release/release-qualification.ts +0 -397
  112. package/src/release/release-staging.ts +0 -87
  113. package/src/release/release-steps.ts +0 -173
  114. package/src/release/retained-release-build.ts +0 -217
  115. package/src/shell/application-menu-commands.ts +0 -6
  116. package/src/shell/application-menu.ts +0 -250
  117. package/src/updates/channel-update-manager.ts +0 -127
  118. package/src/updates/desktop-updater.ts +0 -440
  119. package/src/updates/release-feed.ts +0 -187
  120. package/src/updates/release-location.ts +0 -101
  121. package/src/updates/signed-release.ts +0 -311
  122. package/src/updates/stable-file.ts +0 -32
  123. package/src/updates/update-arm.ts +0 -107
  124. package/src/updates/update-channel-store.ts +0 -86
  125. package/src/updates/update-discovery.ts +0 -113
  126. package/src/updates/update-download.ts +0 -82
  127. package/src/updates/update-exclusive-rename.ts +0 -58
  128. package/src/updates/update-extraction.ts +0 -261
  129. package/src/updates/update-handoff-plan.ts +0 -75
  130. package/src/updates/update-helper.ts +0 -87
  131. package/src/updates/update-launch.ts +0 -33
  132. package/src/updates/update-manager.ts +0 -130
  133. package/src/updates/update-process-fence.ts +0 -125
  134. package/src/updates/update-resume.ts +0 -34
  135. package/src/updates/update-shutdown.ts +0 -37
  136. package/src/updates/update-swap-stage.ts +0 -75
  137. package/src/updates/update-swap.ts +0 -30
@@ -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
- )
@@ -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
- )
@@ -1,34 +0,0 @@
1
- import { readFile } from 'node:fs/promises'
2
- import { gitCli, originRepository } from '../release/local-provenance'
3
- import { verifyLocalRelease } from '../release/local-release'
4
- import { finalizeReleasePleaseDraft, parseFinalizationEvent } from '../release/release-finalize'
5
-
6
- // A local release has no draft to finalize: `--local <config> <tag>` verifies what the feed
7
- // publishes for the tag instead, after an upload.
8
- if (process.argv[2] === '--local') {
9
- const [configPath, tag, ...extra] = process.argv.slice(3)
10
- if (!configPath || !tag || extra.length) throw new Error('Expected release configuration and tag')
11
- const config: unknown = JSON.parse(await readFile(configPath, 'utf8'))
12
- const result = await verifyLocalRelease({
13
- config,
14
- tag,
15
- repository: await originRepository(gitCli()),
16
- fetch,
17
- })
18
- console.log(JSON.stringify(result))
19
- } else {
20
- const configPath = process.argv[2]
21
- if (!configPath || process.argv.length !== 3 || !process.env.GITHUB_EVENT_PATH)
22
- throw new Error('Expected release configuration and workflow event')
23
- const config: unknown = JSON.parse(await readFile(configPath, 'utf8'))
24
- if (typeof config !== 'object' || config === null || Array.isArray(config))
25
- throw new Error('Invalid release configuration')
26
- const event: unknown = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH, 'utf8'))
27
- const identity = parseFinalizationEvent(
28
- event,
29
- process.env.GITHUB_REPOSITORY ?? '',
30
- process.env.GITHUB_EVENT_NAME
31
- )
32
- await finalizeReleasePleaseDraft({ env: process.env, config, ...identity })
33
- console.log('Qualified draft published as a prerelease')
34
- }
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { gitCli, originRepository } from '../release/local-provenance'
3
- import { runLocalPromotion } from '../release/local-release'
4
- import { runPromotionCommand } from '../release/release-promotion-command'
5
- import { readJsonFile, runCli } from './cli-runner'
6
-
7
- // `release-promote-cli.js <config>` in the trusted workflow, or
8
- // `release-promote-cli.js --local <config> <out>`, which stages the feed update under <out>.
9
- const local = process.argv[2] === '--local'
10
- await runCli(
11
- 'Unable to promote the release; check the trusted workflow or feed and release configuration.',
12
- async () => {
13
- const [path, out, ...extra] = process.argv.slice(local ? 3 : 2)
14
- const held = process.env.STABLE_PROMOTION_HELD
15
- if (!path || extra.length || !out !== !local || !['true', 'false', undefined].includes(held))
16
- throw new Error('Invalid workflow invocation')
17
- const config = await readJsonFile(path, 65536)
18
- const result = local
19
- ? await runLocalPromotion({
20
- config,
21
- out: out!,
22
- now: new Date().toISOString(),
23
- held: held === 'true',
24
- repository: await originRepository(gitCli()),
25
- fetch,
26
- })
27
- : await runPromotionCommand({ env: process.env, config })
28
- process.stdout.write(JSON.stringify(local ? { ...result, plan: undefined } : result) + '\n')
29
- },
30
- { requireGitHubActions: !local }
31
- )
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { gitCli } from '../release/local-provenance'
3
- import {
4
- hostReleasePlatform,
5
- localTagProvenance,
6
- stageLocalRelease,
7
- } from '../release/local-release'
8
- import { runReleasePublishCommand } from '../release/release-publish-command'
9
- import { readJsonFile, runCli } from './cli-runner'
10
-
11
- // `release-publish-cli.js <directory> <config>` in the trusted assets workflow, or
12
- // `release-publish-cli.js --local <directory> <config> <out>` with RELEASE_TAG and SOURCE_SHA,
13
- // which stages the feed upload under <out> instead of publishing.
14
- const local = process.argv[2] === '--local'
15
- await runCli(
16
- 'Unable to publish release artifacts; check the trusted workflow or local checkout, receipts, signing configuration and staged bytes.',
17
- async () => {
18
- const [directory, configPath, out, ...extra] = process.argv.slice(local ? 3 : 2)
19
- if (!directory || !configPath || extra.length || !out !== !local)
20
- throw new Error('Invalid workflow invocation')
21
- const config = await readJsonFile(configPath, 65536)
22
- if (local) {
23
- const { RELEASE_TAG: tag, SOURCE_SHA: sourceSha } = process.env
24
- if (!tag || !sourceSha) throw new Error('Missing local release identity')
25
- const { repository } = await localTagProvenance({ config, tag, sourceSha, git: gitCli() })
26
- const plan = await stageLocalRelease({
27
- config,
28
- directory,
29
- out: out!,
30
- tag,
31
- sourceSha,
32
- repository,
33
- platform: hostReleasePlatform(),
34
- now: new Date().toISOString(),
35
- fetch,
36
- })
37
- process.stdout.write(JSON.stringify({ tag, objects: plan.objects.length }) + '\n')
38
- return
39
- }
40
- const result = await runReleasePublishCommand({ env: process.env, config, directory })
41
- process.stdout.write(
42
- JSON.stringify({ tag: result.tag, runId: result.runId, runAttempt: result.runAttempt }) + '\n'
43
- )
44
- },
45
- { requireGitHubActions: !local }
46
- )
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { createPrivateKey } from 'node:crypto'
3
- import { signReleaseArtifact, type ReleaseArtifactIdentity } from '../release/release-artifact'
4
- import { readJsonFile, runCli } from './cli-runner'
5
-
6
- // The signing key is passed in the environment, never in command arguments or output.
7
- await runCli(
8
- 'Unable to sign release artifact; check the identity, archive and signing key.',
9
- async () => {
10
- const [identityPath, artifactPath, feed, ...extra] = process.argv.slice(2)
11
- if (
12
- !identityPath ||
13
- !artifactPath ||
14
- !feed ||
15
- extra.length ||
16
- !process.env.ADEA_RELEASE_SIGNING_KEY
17
- )
18
- throw new Error('usage')
19
- const identity = (await readJsonFile(identityPath, 16384)) as ReleaseArtifactIdentity
20
- const key = createPrivateKey(process.env.ADEA_RELEASE_SIGNING_KEY)
21
- const result = await signReleaseArtifact(artifactPath, identity, key, feed)
22
- process.stdout.write(JSON.stringify(result) + '\n')
23
- }
24
- )