@adea-ai/app-framework 0.0.0-stage → 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/LICENSE +201 -0
- package/NOTICE +30 -0
- package/README.md +1009 -2
- package/dist/app/application.d.ts +47 -0
- package/dist/app/application.js +115 -0
- package/dist/app/create-application.d.ts +13 -0
- package/dist/app/create-application.js +178 -0
- package/dist/app/service-registry.d.ts +44 -0
- package/dist/app/service-registry.js +116 -0
- package/dist/appearance/appearance-host.d.ts +62 -0
- package/dist/appearance/appearance-host.js +115 -0
- package/dist/appearance/appearance-preferences.d.ts +106 -0
- package/dist/appearance/appearance-preferences.js +175 -0
- package/dist/appearance/composition.d.ts +11 -0
- package/dist/appearance/composition.js +16 -0
- package/dist/appearance/custom-theme-import.d.ts +14 -0
- package/dist/appearance/custom-theme-import.js +315 -0
- package/dist/appearance/custom-theme-library.d.ts +146 -0
- package/dist/appearance/custom-theme-library.js +378 -0
- package/dist/appearance/editor.d.ts +20 -0
- package/dist/appearance/editor.js +47 -0
- package/dist/appearance/theme-file-importer.d.ts +23 -0
- package/dist/appearance/theme-file-importer.js +66 -0
- package/dist/appearance/theme-record-adapter.d.ts +26 -0
- package/dist/appearance/theme-record-adapter.js +64 -0
- package/dist/appearance/theme-registry.d.ts +10 -0
- package/dist/appearance/theme-registry.js +16 -0
- package/dist/appearance/window-surface.d.ts +5 -0
- package/dist/appearance/window-surface.js +9 -0
- package/dist/ci/toolchain-identity.d.ts +39 -0
- package/dist/ci/toolchain-identity.js +196 -0
- package/dist/cli/cef-helper-cli.d.ts +2 -0
- package/dist/cli/cef-helper-cli.js +18 -0
- package/dist/cli/cli-runner.d.ts +8 -0
- package/dist/cli/cli-runner.js +23 -0
- package/dist/cli/create-application-cli.d.ts +2 -0
- package/dist/cli/create-application-cli.js +40 -0
- package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
- package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
- package/dist/cli/framework-update-cli.d.ts +2 -0
- package/dist/cli/framework-update-cli.js +40 -0
- package/dist/cli/release-assets-plan-cli.d.ts +2 -0
- package/dist/cli/release-assets-plan-cli.js +14 -0
- package/dist/cli/release-cut-cli.d.ts +2 -0
- package/dist/cli/release-cut-cli.js +27 -0
- package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
- package/dist/cli/release-descriptor-staging-cli.js +45 -0
- package/dist/cli/release-finalize-cli.d.ts +1 -0
- package/dist/cli/release-finalize-cli.js +30 -0
- package/dist/cli/release-promote-cli.d.ts +2 -0
- package/dist/cli/release-promote-cli.js +32 -0
- package/dist/cli/release-publish-cli.d.ts +2 -0
- package/dist/cli/release-publish-cli.js +48 -0
- package/dist/cli/release-sign-cli.d.ts +2 -0
- package/dist/cli/release-sign-cli.js +13 -0
- package/dist/cli/release-step-cli.d.ts +2 -0
- package/dist/cli/release-step-cli.js +44 -0
- package/dist/cli/toolchain-identity-cli.d.ts +2 -0
- package/dist/cli/toolchain-identity-cli.js +10 -0
- package/dist/cli/update-helper-cli.d.ts +1 -0
- package/dist/cli/update-helper-cli.js +10 -0
- package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
- package/dist/cli/windows-runtime-patch-cli.js +17 -0
- package/dist/desktop/application-command-client.d.ts +15 -0
- package/dist/desktop/application-command-client.js +21 -0
- package/dist/desktop/channel-handshake.d.ts +32 -0
- package/dist/desktop/channel-handshake.js +111 -0
- package/dist/desktop/channel-proof.d.ts +43 -0
- package/dist/desktop/channel-proof.js +85 -0
- package/dist/desktop/client-assets.d.ts +7 -0
- package/dist/desktop/client-assets.js +59 -0
- package/dist/desktop/desktop-client.d.ts +23 -0
- package/dist/desktop/desktop-client.js +231 -0
- package/dist/desktop/desktop-gateway.d.ts +18 -0
- package/dist/desktop/desktop-gateway.js +146 -0
- package/dist/desktop/desktop-host.d.ts +48 -0
- package/dist/desktop/desktop-host.js +208 -0
- package/dist/desktop/desktop-stream.d.ts +36 -0
- package/dist/desktop/desktop-stream.js +231 -0
- package/dist/desktop/loopback-policy.d.ts +19 -0
- package/dist/desktop/loopback-policy.js +23 -0
- package/dist/desktop/open-url-channel.d.ts +15 -0
- package/dist/desktop/open-url-channel.js +55 -0
- package/dist/desktop/string-policy.d.ts +2 -0
- package/dist/desktop/string-policy.js +11 -0
- package/dist/framework-source.json +1 -0
- package/dist/installer/archive-entry.d.ts +6 -0
- package/dist/installer/archive-entry.js +14 -0
- package/dist/installer/command-artifact.d.ts +47 -0
- package/dist/installer/command-artifact.js +261 -0
- package/dist/installer/command-qualification-command.d.ts +12 -0
- package/dist/installer/command-qualification-command.js +71 -0
- package/dist/installer/hosted-runner.d.ts +4 -0
- package/dist/installer/hosted-runner.js +10 -0
- package/dist/installer/installed-payload.d.ts +29 -0
- package/dist/installer/installed-payload.js +312 -0
- package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
- package/dist/installer/installer-ci-bootstrap.js +160 -0
- package/dist/installer/installer-ci-preflight.d.ts +1 -0
- package/dist/installer/installer-ci-preflight.js +49 -0
- package/dist/installer/installer-ci-worker.d.ts +1 -0
- package/dist/installer/installer-ci-worker.js +105 -0
- package/dist/installer/installer-extraction.d.ts +14 -0
- package/dist/installer/installer-extraction.js +289 -0
- package/dist/installer/installer-fetch-guard.d.ts +15 -0
- package/dist/installer/installer-fetch-guard.js +50 -0
- package/dist/installer/installer-identity.d.ts +23 -0
- package/dist/installer/installer-identity.js +286 -0
- package/dist/installer/installer-layout.d.ts +21 -0
- package/dist/installer/installer-layout.js +89 -0
- package/dist/installer/installer-observation.d.ts +64 -0
- package/dist/installer/installer-observation.js +473 -0
- package/dist/installer/installer-process-cleanup.d.ts +18 -0
- package/dist/installer/installer-process-cleanup.js +158 -0
- package/dist/installer/installer-qualification-command.d.ts +11 -0
- package/dist/installer/installer-qualification-command.js +71 -0
- package/dist/installer/installer-renderer-evidence.d.ts +43 -0
- package/dist/installer/installer-renderer-evidence.js +136 -0
- package/dist/installer/installer-upgrade-command.d.ts +37 -0
- package/dist/installer/installer-upgrade-command.js +172 -0
- package/dist/installer/installer-worker-guard.d.ts +21 -0
- package/dist/installer/installer-worker-guard.js +72 -0
- package/dist/installer/native-executable.d.ts +5 -0
- package/dist/installer/native-executable.js +21 -0
- package/dist/installer/upgrade-asset-download.d.ts +13 -0
- package/dist/installer/upgrade-asset-download.js +41 -0
- package/dist/installer/write-all.d.ts +6 -0
- package/dist/installer/write-all.js +11 -0
- package/dist/native/app-bundle.d.ts +28 -0
- package/dist/native/app-bundle.js +60 -0
- package/dist/native/cef-helper.d.ts +28 -0
- package/dist/native/cef-helper.js +402 -0
- package/dist/native/desktop-build-hook.d.ts +7 -0
- package/dist/native/desktop-build-hook.js +20 -0
- package/dist/native/electrobun-source-patch.d.ts +25 -0
- package/dist/native/electrobun-source-patch.js +93 -0
- package/dist/native/linux-cef-links.d.ts +2 -0
- package/dist/native/linux-cef-links.js +15 -0
- package/dist/native/native-secret-store.d.ts +27 -0
- package/dist/native/native-secret-store.js +70 -0
- package/dist/native/native-utilities.d.ts +24 -0
- package/dist/native/native-utilities.js +85 -0
- package/dist/native/partitioned-window.d.ts +34 -0
- package/dist/native/partitioned-window.js +44 -0
- package/dist/native/renderer-profile.d.ts +53 -0
- package/dist/native/renderer-profile.js +30 -0
- package/dist/native/secure-window.d.ts +38 -0
- package/dist/native/secure-window.js +77 -0
- package/dist/native/sidecar-services.d.ts +23 -0
- package/dist/native/sidecar-services.js +46 -0
- package/dist/native/sidecar.d.ts +81 -0
- package/dist/native/sidecar.js +250 -0
- package/dist/native/window-bootstrap.d.ts +24 -0
- package/dist/native/window-bootstrap.js +63 -0
- package/dist/native/window-options.d.ts +32 -0
- package/dist/native/window-options.js +23 -0
- package/dist/native/windows-build-hook-internal.d.ts +2 -0
- package/dist/native/windows-build-hook-internal.js +32 -0
- package/dist/native/windows-build-hook.d.ts +2 -0
- package/dist/native/windows-build-hook.js +12 -0
- package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
- package/dist/native/windows-runtime-patch-internal.js +20 -0
- package/dist/native/windows-runtime-patch.d.ts +4 -0
- package/dist/native/windows-runtime-patch.js +12 -0
- package/dist/release/feed-release-cut.d.ts +23 -0
- package/dist/release/feed-release-cut.js +93 -0
- package/dist/release/feed-state.d.ts +25 -0
- package/dist/release/feed-state.js +81 -0
- package/dist/release/framework-package-publish.d.ts +21 -0
- package/dist/release/framework-package-publish.js +127 -0
- package/dist/release/framework-update.d.ts +30 -0
- package/dist/release/framework-update.js +139 -0
- package/dist/release/github-cli.d.ts +6 -0
- package/dist/release/github-cli.js +16 -0
- package/dist/release/github-release-assets.d.ts +3 -0
- package/dist/release/github-release-assets.js +24 -0
- package/dist/release/github-release-cut.d.ts +14 -0
- package/dist/release/github-release-cut.js +174 -0
- package/dist/release/github-release-lookup.d.ts +7 -0
- package/dist/release/github-release-lookup.js +29 -0
- package/dist/release/github-release-promotion.d.ts +10 -0
- package/dist/release/github-release-promotion.js +78 -0
- package/dist/release/github-release-provenance.d.ts +9 -0
- package/dist/release/github-release-provenance.js +27 -0
- package/dist/release/github-release-publisher.d.ts +9 -0
- package/dist/release/github-release-publisher.js +63 -0
- package/dist/release/github-release-qualification.d.ts +12 -0
- package/dist/release/github-release-qualification.js +80 -0
- package/dist/release/local-provenance.d.ts +24 -0
- package/dist/release/local-provenance.js +72 -0
- package/dist/release/local-release.d.ts +133 -0
- package/dist/release/local-release.js +387 -0
- package/dist/release/macos-dmg.d.ts +22 -0
- package/dist/release/macos-dmg.js +91 -0
- package/dist/release/release-artifact.d.ts +6 -0
- package/dist/release/release-artifact.js +38 -0
- package/dist/release/release-assets-plan.d.ts +14 -0
- package/dist/release/release-assets-plan.js +65 -0
- package/dist/release/release-config.d.ts +76 -0
- package/dist/release/release-config.js +180 -0
- package/dist/release/release-cut-command.d.ts +13 -0
- package/dist/release/release-cut-command.js +39 -0
- package/dist/release/release-cut.d.ts +54 -0
- package/dist/release/release-cut.js +76 -0
- package/dist/release/release-descriptor-staging.d.ts +34 -0
- package/dist/release/release-descriptor-staging.js +147 -0
- package/dist/release/release-finalize.d.ts +16 -0
- package/dist/release/release-finalize.js +104 -0
- package/dist/release/release-promotion-command.d.ts +12 -0
- package/dist/release/release-promotion-command.js +28 -0
- package/dist/release/release-promotion.d.ts +29 -0
- package/dist/release/release-promotion.js +57 -0
- package/dist/release/release-publication.d.ts +33 -0
- package/dist/release/release-publication.js +138 -0
- package/dist/release/release-publish-command.d.ts +7 -0
- package/dist/release/release-publish-command.js +91 -0
- package/dist/release/release-qualification.d.ts +106 -0
- package/dist/release/release-qualification.js +135 -0
- package/dist/release/release-staging.d.ts +9 -0
- package/dist/release/release-staging.js +61 -0
- package/dist/release/release-steps.d.ts +38 -0
- package/dist/release/release-steps.js +147 -0
- package/dist/release/retained-release-build.d.ts +19 -0
- package/dist/release/retained-release-build.js +122 -0
- package/dist/shell/app-shell.d.ts +61 -0
- package/dist/shell/app-shell.js +306 -0
- package/dist/shell/app-utilities.d.ts +122 -0
- package/dist/shell/app-utilities.js +334 -0
- package/dist/shell/application-menu-commands.d.ts +5 -0
- package/dist/shell/application-menu-commands.js +11 -0
- package/dist/shell/application-menu.d.ts +61 -0
- package/dist/shell/application-menu.js +208 -0
- package/dist/shell/help-shortcuts.d.ts +12 -0
- package/dist/shell/help-shortcuts.js +22 -0
- package/dist/shell/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -0
- package/dist/shell/settings-sections.d.ts +31 -0
- package/dist/shell/settings-sections.js +50 -0
- package/dist/shell/shortcut-platform.d.ts +17 -0
- package/dist/shell/shortcut-platform.js +25 -0
- package/dist/update-helper.bundle.js +260 -0
- package/dist/updates/channel-update-manager.d.ts +46 -0
- package/dist/updates/channel-update-manager.js +114 -0
- package/dist/updates/desktop-updater.d.ts +104 -0
- package/dist/updates/desktop-updater.js +345 -0
- package/dist/updates/release-feed.d.ts +61 -0
- package/dist/updates/release-feed.js +111 -0
- package/dist/updates/release-location.d.ts +9 -0
- package/dist/updates/release-location.js +80 -0
- package/dist/updates/release-version.d.ts +12 -0
- package/dist/updates/release-version.js +43 -0
- package/dist/updates/signed-release.d.ts +63 -0
- package/dist/updates/signed-release.js +162 -0
- package/dist/updates/stable-file.d.ts +10 -0
- package/dist/updates/stable-file.js +22 -0
- package/dist/updates/update-adapter.d.ts +57 -0
- package/dist/updates/update-adapter.js +72 -0
- package/dist/updates/update-arm.d.ts +24 -0
- package/dist/updates/update-arm.js +95 -0
- package/dist/updates/update-channel-store.d.ts +8 -0
- package/dist/updates/update-channel-store.js +72 -0
- package/dist/updates/update-discovery.d.ts +13 -0
- package/dist/updates/update-discovery.js +56 -0
- package/dist/updates/update-download.d.ts +14 -0
- package/dist/updates/update-download.js +67 -0
- package/dist/updates/update-exclusive-rename.d.ts +2 -0
- package/dist/updates/update-exclusive-rename.js +52 -0
- package/dist/updates/update-extraction.d.ts +18 -0
- package/dist/updates/update-extraction.js +183 -0
- package/dist/updates/update-handoff-plan.d.ts +22 -0
- package/dist/updates/update-handoff-plan.js +28 -0
- package/dist/updates/update-helper.d.ts +24 -0
- package/dist/updates/update-helper.js +56 -0
- package/dist/updates/update-launch.d.ts +5 -0
- package/dist/updates/update-launch.js +27 -0
- package/dist/updates/update-manager.d.ts +40 -0
- package/dist/updates/update-manager.js +83 -0
- package/dist/updates/update-process-fence.d.ts +10 -0
- package/dist/updates/update-process-fence.js +114 -0
- package/dist/updates/update-resume.d.ts +13 -0
- package/dist/updates/update-resume.js +34 -0
- package/dist/updates/update-shutdown.d.ts +15 -0
- package/dist/updates/update-shutdown.js +29 -0
- package/dist/updates/update-state.d.ts +30 -0
- package/dist/updates/update-state.js +18 -0
- package/dist/updates/update-swap-stage.d.ts +27 -0
- package/dist/updates/update-swap-stage.js +58 -0
- package/dist/updates/update-swap.d.ts +10 -0
- package/dist/updates/update-swap.js +30 -0
- package/dist/views/app-about.d.ts +22 -0
- package/dist/views/app-about.js +43 -0
- package/dist/views/app-appearance.d.ts +11 -0
- package/dist/views/app-appearance.js +42 -0
- package/dist/views/app-help.d.ts +17 -0
- package/dist/views/app-help.js +42 -0
- package/dist/views/app-settings.d.ts +26 -0
- package/dist/views/app-settings.js +97 -0
- package/dist/views/appearance-surface.d.ts +9 -0
- package/dist/views/appearance-surface.js +334 -0
- package/dist/views/update-surface.d.ts +34 -0
- package/dist/views/update-surface.js +64 -0
- package/package.json +374 -4
- package/src/app/application.tsx +138 -0
- package/src/appearance/appearance-host.tsx +205 -0
- package/src/appearance/appearance-preferences.ts +287 -0
- package/src/appearance/composition.ts +29 -0
- package/src/appearance/custom-theme-import.ts +424 -0
- package/src/appearance/custom-theme-library.ts +600 -0
- package/src/appearance/editor.ts +94 -0
- package/src/appearance/theme-file-importer.ts +103 -0
- package/src/appearance/theme-record-adapter.ts +106 -0
- package/src/appearance/theme-registry.ts +20 -0
- package/src/appearance/window-surface.ts +18 -0
- package/src/desktop/client-assets.ts +75 -0
- package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
- package/src/native/electrobun-windows-shortcut-com.patch +923 -0
- package/src/native/renderer-profile.ts +27 -0
- package/src/native/window-options.ts +24 -0
- package/src/shell/app-shell.tsx +294 -0
- package/src/shell/app-utilities.tsx +437 -0
- package/src/shell/help-shortcuts.ts +24 -0
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/shell/settings-sections.ts +74 -0
- package/src/shell/shortcut-platform.ts +35 -0
- package/src/updates/release-version.ts +57 -0
- package/src/updates/update-adapter.ts +129 -0
- package/src/updates/update-state.ts +34 -0
- package/src/views/app-about.tsx +44 -0
- package/src/views/app-appearance.tsx +32 -0
- package/src/views/app-help.tsx +43 -0
- package/src/views/app-settings.tsx +88 -0
- package/src/views/appearance-surface.tsx +427 -0
- package/src/views/update-surface.tsx +85 -0
- package/templates/application/.gitattributes +1 -0
- package/templates/application/.github/workflows/release-assets.yml +29 -0
- package/templates/application/.github/workflows/release-finalize.yml +29 -0
- package/templates/application/.github/workflows/release-please.yml +19 -0
- package/templates/application/.github/workflows/release.yml +29 -0
- package/templates/application/.github/workflows/validation.yml +28 -0
- package/templates/application/.oxfmtrc.json +6 -0
- package/templates/application/.oxlintrc.json +48 -0
- package/templates/application/.release-please-manifest.json +3 -0
- package/templates/application/README.md +47 -0
- package/templates/application/electrobun.config.ts +22 -0
- package/templates/application/release-please-config.json +12 -0
- package/templates/application/scripts/app-version.ts +9 -0
- package/templates/application/scripts/build-desktop.ts +34 -0
- package/templates/application/scripts/secure-build.ts +1 -0
- package/templates/application/scripts/stage-release.ts +21 -0
- package/templates/application/src/bun/index.ts +80 -0
- package/templates/application/src/electrobun.d.ts +27 -0
- package/templates/application/src/web/index.html +12 -0
- package/templates/application/src/web/main.tsx +97 -0
- package/templates/application/src/web/public/icon.svg +1 -0
- package/templates/application/src/web/style.css +3 -0
- package/templates/application/tests/app-config.test.ts +9 -0
- package/templates/application/tsconfig.json +15 -0
- package/templates/application/vite.config.ts +10 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { safeArchivePath } from "./archive-entry.js";
|
|
2
|
+
import { lstat, mkdir, mkdtemp, readdir, rm } from "node:fs/promises";
|
|
3
|
+
import { basename, join, relative, sep } from "node:path";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { c, t, x } from "tar";
|
|
6
|
+
// src/installer/command-artifact.ts
|
|
7
|
+
var MAX_ENTRIES = 1e5;
|
|
8
|
+
var MAX_EXPANDED_BYTES = 2147483648;
|
|
9
|
+
var MAX_ARCHIVE_BYTES = 1073741824;
|
|
10
|
+
var COMMAND_TIMEOUT_MS = 6e4;
|
|
11
|
+
var SERVICE_SETTLE_MS = 5e3;
|
|
12
|
+
var SERVICE_STOP_MS = 3e4;
|
|
13
|
+
/** The archive's one root directory: the asset name without `.tar.gz`. */
|
|
14
|
+
function commandArtifactRoot(asset) {
|
|
15
|
+
if (!asset.endsWith(".tar.gz") || asset.length <= 7) throw new Error("Command artifacts are .tar.gz archives");
|
|
16
|
+
return asset.slice(0, -7);
|
|
17
|
+
}
|
|
18
|
+
/** The launcher inside the root: `bin/<executable>`, or `bin/<executable>.cmd` on Windows. */
|
|
19
|
+
function commandLauncher(executable, platform) {
|
|
20
|
+
return `bin/${executable}${platform === "windows-x64" ? ".cmd" : ""}`;
|
|
21
|
+
}
|
|
22
|
+
async function collect(root, directory, entries) {
|
|
23
|
+
const children = await readdir(directory, { withFileTypes: true });
|
|
24
|
+
children.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0);
|
|
25
|
+
for (const child of children) {
|
|
26
|
+
const path = join(directory, child.name);
|
|
27
|
+
const info = await lstat(path);
|
|
28
|
+
const name = relative(root, path).split(sep).join("/");
|
|
29
|
+
if (info.isDirectory()) {
|
|
30
|
+
entries.push(name);
|
|
31
|
+
await collect(root, path, entries);
|
|
32
|
+
} else if (info.isFile()) entries.push(name);
|
|
33
|
+
else throw new Error("Command artifact holds an unsupported entry");
|
|
34
|
+
if (entries.length > MAX_ENTRIES) throw new Error("Command artifact has too many entries");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Pack the built payload directory into `archive` under its asset-named root. */
|
|
38
|
+
async function packCommandArtifact(options) {
|
|
39
|
+
const { source, archive, executable, platform } = options;
|
|
40
|
+
const root = commandArtifactRoot(basename(archive));
|
|
41
|
+
if (!(await lstat(source)).isDirectory()) throw new Error("Command artifact build is not a directory");
|
|
42
|
+
const launcher = await lstat(join(source, commandLauncher(executable, platform))).catch(() => void 0);
|
|
43
|
+
if (!launcher?.isFile() || launcher.size < 1 || platform !== "windows-x64" && !(launcher.mode & 64)) throw new Error("Command artifact build has no launcher");
|
|
44
|
+
const entries = [];
|
|
45
|
+
await collect(source, source, entries);
|
|
46
|
+
await c({
|
|
47
|
+
file: archive,
|
|
48
|
+
cwd: source,
|
|
49
|
+
gzip: true,
|
|
50
|
+
portable: true,
|
|
51
|
+
noDirRecurse: true,
|
|
52
|
+
mtime: /* @__PURE__ */ new Date(0),
|
|
53
|
+
prefix: root
|
|
54
|
+
}, entries);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read a command artifact archive: every entry is a regular file or directory under the
|
|
58
|
+
* asset-named root, within bounds, and the launcher is present (executable off Windows). With
|
|
59
|
+
* `destination`, also extract it there.
|
|
60
|
+
*/
|
|
61
|
+
async function readCommandArtifact(options) {
|
|
62
|
+
const { archive, executable, platform, destination } = options;
|
|
63
|
+
const info = await lstat(archive);
|
|
64
|
+
if (!info.isFile() || info.size < 1 || info.size > MAX_ARCHIVE_BYTES) throw new Error("Invalid command artifact archive");
|
|
65
|
+
const root = commandArtifactRoot(basename(archive));
|
|
66
|
+
const fold = platform === "windows-x64";
|
|
67
|
+
const launcher = `${root}/${commandLauncher(executable, platform)}`;
|
|
68
|
+
const seen = /* @__PURE__ */ new Set();
|
|
69
|
+
let invalid = false, bytes = 0, launcherFound = false;
|
|
70
|
+
const filter = (path, entry) => {
|
|
71
|
+
if (!("type" in entry)) {
|
|
72
|
+
invalid = true;
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const value = entry;
|
|
76
|
+
const normalized = safeArchivePath(path, fold);
|
|
77
|
+
const key = normalized && (fold ? normalized.toLowerCase() : normalized);
|
|
78
|
+
if (!normalized || !key || normalized !== root && !normalized.startsWith(`${root}/`) || value.type !== "File" && value.type !== "Directory" || seen.has(key) || seen.size >= MAX_ENTRIES) {
|
|
79
|
+
invalid = true;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
seen.add(key);
|
|
83
|
+
if (value.type === "File") {
|
|
84
|
+
bytes += value.size ?? 0;
|
|
85
|
+
if (!Number.isSafeInteger(bytes) || bytes > MAX_EXPANDED_BYTES) {
|
|
86
|
+
invalid = true;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (normalized === launcher) launcherFound = Boolean(value.size) && (fold || Boolean((value.mode ?? 0) & 64));
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
};
|
|
93
|
+
if (destination) await x({
|
|
94
|
+
file: archive,
|
|
95
|
+
cwd: destination,
|
|
96
|
+
strict: true,
|
|
97
|
+
preserveOwner: false,
|
|
98
|
+
umask: 18,
|
|
99
|
+
maxMetaEntrySize: 1048576,
|
|
100
|
+
filter
|
|
101
|
+
});
|
|
102
|
+
else await t({
|
|
103
|
+
file: archive,
|
|
104
|
+
strict: true,
|
|
105
|
+
maxMetaEntrySize: 1048576,
|
|
106
|
+
filter
|
|
107
|
+
});
|
|
108
|
+
if (invalid) throw new Error("Unsafe or unsupported command artifact entry");
|
|
109
|
+
if (!launcherFound) throw new Error("Command artifact has no launcher");
|
|
110
|
+
return {
|
|
111
|
+
entries: seen.size,
|
|
112
|
+
bytes
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function boundedText(stream, maximum) {
|
|
116
|
+
const chunks = [];
|
|
117
|
+
let size = 0;
|
|
118
|
+
for await (const chunk of stream) {
|
|
119
|
+
size += chunk.length;
|
|
120
|
+
if (size <= maximum) chunks.push(chunk);
|
|
121
|
+
}
|
|
122
|
+
return size > maximum ? void 0 : Buffer.concat(chunks).toString("utf8");
|
|
123
|
+
}
|
|
124
|
+
async function exitedWithin(child, milliseconds) {
|
|
125
|
+
let timer;
|
|
126
|
+
const timeout = new Promise((resolve) => {
|
|
127
|
+
timer = setTimeout(() => resolve(void 0), milliseconds);
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
return await Promise.race([child.exited, timeout]);
|
|
131
|
+
} finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Extract the archive into a new private location with its own home and data directories, then
|
|
137
|
+
* run `--version` (it must print `version`), each probe (each must exit 0), and the service
|
|
138
|
+
* (it must stay up through a settle window, then stop on SIGTERM with exit 0; on Windows, where
|
|
139
|
+
* no signal reaches a console process, its process tree is terminated).
|
|
140
|
+
*/
|
|
141
|
+
async function qualifyCommandArtifact(options) {
|
|
142
|
+
const { archive, platform, policy, version } = options;
|
|
143
|
+
const windows = platform === "windows-x64";
|
|
144
|
+
const location = await mkdtemp(join(tmpdir(), "framework-command-"));
|
|
145
|
+
let service;
|
|
146
|
+
try {
|
|
147
|
+
const install = join(location, "install"), home = join(location, "home"), temp = join(location, "tmp");
|
|
148
|
+
for (const path of [
|
|
149
|
+
install,
|
|
150
|
+
home,
|
|
151
|
+
temp
|
|
152
|
+
]) await mkdir(path, { mode: 448 });
|
|
153
|
+
await readCommandArtifact({
|
|
154
|
+
archive,
|
|
155
|
+
executable: policy.executable,
|
|
156
|
+
platform,
|
|
157
|
+
destination: install
|
|
158
|
+
});
|
|
159
|
+
const bin = join(install, commandArtifactRoot(basename(archive)), "bin");
|
|
160
|
+
const launcher = join(bin, basename(commandLauncher(policy.executable, platform)));
|
|
161
|
+
const installed = await lstat(launcher);
|
|
162
|
+
if (!installed.isFile() || installed.size < 1) throw new Error("Command artifact install failed");
|
|
163
|
+
const env = {};
|
|
164
|
+
for (const name of [
|
|
165
|
+
"PATH",
|
|
166
|
+
"SystemRoot",
|
|
167
|
+
"WINDIR",
|
|
168
|
+
"COMSPEC",
|
|
169
|
+
"PATHEXT",
|
|
170
|
+
"LANG"
|
|
171
|
+
]) if (options.env[name]) env[name] = options.env[name];
|
|
172
|
+
Object.assign(env, {
|
|
173
|
+
HOME: home,
|
|
174
|
+
USERPROFILE: home,
|
|
175
|
+
TMPDIR: temp,
|
|
176
|
+
TMP: temp,
|
|
177
|
+
TEMP: temp,
|
|
178
|
+
XDG_DATA_HOME: join(home, ".local", "share"),
|
|
179
|
+
XDG_CONFIG_HOME: join(home, ".config"),
|
|
180
|
+
XDG_STATE_HOME: join(home, ".local", "state"),
|
|
181
|
+
XDG_CACHE_HOME: join(home, ".cache"),
|
|
182
|
+
LOCALAPPDATA: join(home, "AppData", "Local"),
|
|
183
|
+
APPDATA: join(home, "AppData", "Roaming"),
|
|
184
|
+
...policy.qualification.env
|
|
185
|
+
});
|
|
186
|
+
const command = (args) => windows ? [
|
|
187
|
+
"cmd.exe",
|
|
188
|
+
"/d",
|
|
189
|
+
"/c",
|
|
190
|
+
basename(launcher),
|
|
191
|
+
...args
|
|
192
|
+
] : [launcher, ...args];
|
|
193
|
+
const spawn = (args, output) => Bun.spawn({
|
|
194
|
+
cmd: command(args),
|
|
195
|
+
cwd: windows ? bin : home,
|
|
196
|
+
env,
|
|
197
|
+
stdin: "ignore",
|
|
198
|
+
stdout: output,
|
|
199
|
+
stderr: output
|
|
200
|
+
});
|
|
201
|
+
const runOnce = async (args) => {
|
|
202
|
+
const child = spawn(args, "pipe");
|
|
203
|
+
const stdout = boundedText(child.stdout, 65536);
|
|
204
|
+
const stderr = boundedText(child.stderr, 65536);
|
|
205
|
+
const status = await exitedWithin(child, COMMAND_TIMEOUT_MS);
|
|
206
|
+
if (status === void 0) {
|
|
207
|
+
child.kill("SIGKILL");
|
|
208
|
+
await child.exited;
|
|
209
|
+
}
|
|
210
|
+
const [text] = await Promise.all([stdout, stderr]);
|
|
211
|
+
return {
|
|
212
|
+
status,
|
|
213
|
+
text
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
const reported = await runOnce(["--version"]);
|
|
217
|
+
if (reported.status !== 0 || reported.text?.trim() !== version) throw new Error("Command artifact version mismatch");
|
|
218
|
+
for (const probe of policy.qualification.probes) if ((await runOnce(probe)).status !== 0) throw new Error("Command artifact probe failed");
|
|
219
|
+
service = spawn(policy.qualification.service, "ignore");
|
|
220
|
+
if (await exitedWithin(service, options.settleMs ?? SERVICE_SETTLE_MS) !== void 0) throw new Error("Command artifact service exited early");
|
|
221
|
+
if (windows) {
|
|
222
|
+
if (await exitedWithin(Bun.spawn({
|
|
223
|
+
cmd: [
|
|
224
|
+
"taskkill.exe",
|
|
225
|
+
"/PID",
|
|
226
|
+
String(service.pid),
|
|
227
|
+
"/T",
|
|
228
|
+
"/F"
|
|
229
|
+
],
|
|
230
|
+
env,
|
|
231
|
+
stdin: "ignore",
|
|
232
|
+
stdout: "ignore",
|
|
233
|
+
stderr: "ignore"
|
|
234
|
+
}), COMMAND_TIMEOUT_MS) !== 0) throw new Error("Command artifact service did not stop");
|
|
235
|
+
if (await exitedWithin(service, SERVICE_STOP_MS) === void 0) throw new Error("Command artifact service did not stop");
|
|
236
|
+
} else {
|
|
237
|
+
service.kill("SIGTERM");
|
|
238
|
+
if (await exitedWithin(service, SERVICE_STOP_MS) !== 0) throw new Error("Command artifact service did not stop cleanly");
|
|
239
|
+
}
|
|
240
|
+
service = void 0;
|
|
241
|
+
return {
|
|
242
|
+
installed: true,
|
|
243
|
+
versionMatched: true,
|
|
244
|
+
probesPassed: true,
|
|
245
|
+
serviceStarted: true,
|
|
246
|
+
serviceStopped: windows ? "process-tree" : "sigterm"
|
|
247
|
+
};
|
|
248
|
+
} finally {
|
|
249
|
+
if (service) {
|
|
250
|
+
service.kill("SIGKILL");
|
|
251
|
+
await exitedWithin(service, SERVICE_STOP_MS);
|
|
252
|
+
}
|
|
253
|
+
await rm(location, {
|
|
254
|
+
recursive: true,
|
|
255
|
+
force: true,
|
|
256
|
+
maxRetries: 5,
|
|
257
|
+
retryDelay: 200
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
export { commandArtifactRoot, packCommandArtifact, qualifyCommandArtifact, readCommandArtifact };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type InstallerPlatform } from './installer-layout';
|
|
2
|
+
import { type CommandReceipt } from '../release/release-qualification';
|
|
3
|
+
/** The receipt a command artifact's qualification stages beside the payloads. */
|
|
4
|
+
export declare const commandReceiptName: (kind: string, platform: string) => string;
|
|
5
|
+
/** Qualify every command artifact of one platform in the trusted release-assets workflow. */
|
|
6
|
+
export declare function qualifyCommandArtifactsCommand(options: {
|
|
7
|
+
env: Record<string, string | undefined>;
|
|
8
|
+
config: unknown;
|
|
9
|
+
tag: string;
|
|
10
|
+
platform: InstallerPlatform;
|
|
11
|
+
directory: string;
|
|
12
|
+
}): Promise<CommandReceipt[]>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { assertInstallerContext } from "./installer-layout.js";
|
|
2
|
+
import { validateCommandReceipt } from "../release/release-qualification.js";
|
|
3
|
+
import { parseReleaseConfig } from "../release/release-config.js";
|
|
4
|
+
import { planReleaseAssets } from "../release/release-assets-plan.js";
|
|
5
|
+
import { qualifyCommandArtifact } from "./command-artifact.js";
|
|
6
|
+
import { fileIdentity } from "../release/release-publication.js";
|
|
7
|
+
import { lstat, writeFile } from "node:fs/promises";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
// src/installer/command-qualification-command.ts
|
|
10
|
+
/** The receipt a command artifact's qualification stages beside the payloads. */
|
|
11
|
+
var commandReceiptName = (kind, platform) => `command-test-${kind}-${platform}.json`;
|
|
12
|
+
/** Qualify every command artifact of one platform in the trusted release-assets workflow. */
|
|
13
|
+
async function qualifyCommandArtifactsCommand(options) {
|
|
14
|
+
const { env, config, tag, platform } = options;
|
|
15
|
+
const parsed = parseReleaseConfig(config);
|
|
16
|
+
if (!parsed.commandArtifacts.length) return [];
|
|
17
|
+
assertInstallerContext(env, platform, process.platform, process.arch);
|
|
18
|
+
if (env.RELEASE_TAG !== tag) throw new Error("Command artifact release tag mismatch");
|
|
19
|
+
const plan = await planReleaseAssets({
|
|
20
|
+
env,
|
|
21
|
+
config,
|
|
22
|
+
tag
|
|
23
|
+
});
|
|
24
|
+
if (env.SOURCE_SHA !== plan.sourceSha) throw new Error("Command artifact source mismatch");
|
|
25
|
+
const requirements = parsed.requirements(tag);
|
|
26
|
+
const directory = resolve(options.directory);
|
|
27
|
+
const identity = {
|
|
28
|
+
tag,
|
|
29
|
+
sourceSha: plan.sourceSha,
|
|
30
|
+
workflowSha: plan.workflowSha,
|
|
31
|
+
runId: env.GITHUB_RUN_ID,
|
|
32
|
+
runAttempt: Number(env.GITHUB_RUN_ATTEMPT)
|
|
33
|
+
};
|
|
34
|
+
const receipts = [];
|
|
35
|
+
for (const policy of parsed.commandArtifacts) {
|
|
36
|
+
const name = requirements.commandArtifacts[policy.kind][platform];
|
|
37
|
+
const destination = join(directory, commandReceiptName(policy.kind, platform));
|
|
38
|
+
try {
|
|
39
|
+
await lstat(destination);
|
|
40
|
+
throw new Error("Command artifact receipt already exists");
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error.code !== "ENOENT") throw error;
|
|
43
|
+
}
|
|
44
|
+
const path = join(directory, name);
|
|
45
|
+
const asset = await fileIdentity(path, name);
|
|
46
|
+
const result = await qualifyCommandArtifact({
|
|
47
|
+
archive: path,
|
|
48
|
+
platform,
|
|
49
|
+
policy,
|
|
50
|
+
version: plan.version,
|
|
51
|
+
env
|
|
52
|
+
});
|
|
53
|
+
if (JSON.stringify(await fileIdentity(path, name)) !== JSON.stringify(asset)) throw new Error("Staged command artifact changed");
|
|
54
|
+
const receipt = {
|
|
55
|
+
schema: 1,
|
|
56
|
+
...identity,
|
|
57
|
+
kind: policy.kind,
|
|
58
|
+
platform,
|
|
59
|
+
...result,
|
|
60
|
+
asset
|
|
61
|
+
};
|
|
62
|
+
validateCommandReceipt(identity, receipt, policy.kind, platform, name, [asset]);
|
|
63
|
+
await writeFile(destination, JSON.stringify(receipt, null, 2) + "\n", {
|
|
64
|
+
flag: "wx",
|
|
65
|
+
mode: 384
|
|
66
|
+
});
|
|
67
|
+
receipts.push(receipt);
|
|
68
|
+
}
|
|
69
|
+
return receipts;
|
|
70
|
+
}
|
|
71
|
+
export { commandReceiptName, qualifyCommandArtifactsCommand };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** True only on a disposable GitHub-hosted Actions runner. */
|
|
2
|
+
export declare function isHostedRunner(env: Record<string, string | undefined>): boolean;
|
|
3
|
+
/** Refuse `subject` anywhere but a disposable GitHub-hosted runner. */
|
|
4
|
+
export declare function assertHostedRunner(env: Record<string, string | undefined>, subject: string): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/installer/hosted-runner.ts
|
|
2
|
+
/** True only on a disposable GitHub-hosted Actions runner. */
|
|
3
|
+
function isHostedRunner(env) {
|
|
4
|
+
return env.CI === "true" && env.GITHUB_ACTIONS === "true" && env.RUNNER_ENVIRONMENT === "github-hosted";
|
|
5
|
+
}
|
|
6
|
+
/** Refuse `subject` anywhere but a disposable GitHub-hosted runner. */
|
|
7
|
+
function assertHostedRunner(env, subject) {
|
|
8
|
+
if (!isHostedRunner(env)) throw new Error(`${subject} requires a disposable GitHub-hosted runner`);
|
|
9
|
+
}
|
|
10
|
+
export { assertHostedRunner, isHostedRunner };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type InstallerPlatform, type InstallerRenderer } from './installer-layout';
|
|
2
|
+
/** Compare critical installed files to the staged archive before allowing app startup. */
|
|
3
|
+
export declare function verifyInstalledPayload(options: {
|
|
4
|
+
platform: InstallerPlatform;
|
|
5
|
+
renderer: InstallerRenderer;
|
|
6
|
+
appName: string;
|
|
7
|
+
version: string;
|
|
8
|
+
archive: string;
|
|
9
|
+
profile: string;
|
|
10
|
+
installedRoot: string;
|
|
11
|
+
/** Sidecar executables the app bundles; each is compared like the runtime. */
|
|
12
|
+
sidecars?: readonly string[];
|
|
13
|
+
env?: Record<string, string | undefined>;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
files: string[];
|
|
16
|
+
}>;
|
|
17
|
+
/** Extract only the candidate Bun executable to an isolated profile for guard preflight. */
|
|
18
|
+
export declare function extractCandidateRuntime(options: {
|
|
19
|
+
platform: InstallerPlatform;
|
|
20
|
+
renderer: InstallerRenderer;
|
|
21
|
+
appName: string;
|
|
22
|
+
archive: string;
|
|
23
|
+
profile: string;
|
|
24
|
+
env?: Record<string, string | undefined>;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
path: string;
|
|
27
|
+
size: number;
|
|
28
|
+
digest: string;
|
|
29
|
+
}>;
|