@capgo/cli 8.98.0 → 8.98.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/dist/src/sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as wA0}from"node:module";var module={exports:{}};var KA0=Object.create;var{getPrototypeOf:OA0,defineProperty:ZE,getOwnPropertyNames:zA0}=Object;var VA0=Object.prototype.hasOwnProperty;function LA0($){return this[$]}var NA0,MA0,n$=($,D,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=D?NA0??=new WeakMap:MA0??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?KA0(OA0($)):{};let F=D||!$||!$.__esModule?ZE(J,"default",{value:$,enumerable:!0}):J;for(let Z of zA0($))if(!VA0.call(F,Z))ZE(F,Z,{get:LA0.bind($,Z),enumerable:!0});if(Q)X.set($,F);return F};var A=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var BA0=($)=>$;function EA0($,D){this[$]=BA0.bind(null,D)}var a6=($,D)=>{for(var J in D)ZE($,J,{get:D[J],enumerable:!0,configurable:!0,set:EA0.bind(D,J)})};var p=($,D)=>()=>($&&(D=$($=0)),D);var Q0=wA0(import.meta.url);var N1;var QD=p(()=>{N1={name:"@capgo/cli",type:"module",version:"8.98.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"https://github.com/Cap-go/capgo.app",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",typecheck:"tsc --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:notify-app-ready-background":"bun test ./test/test-notify-app-ready-background.mjs ./test/test-background-check-shutdown.mjs","test:bundle":"bun test/test-bundle.mjs","test:bundle-validation":"bun test test/bundle/","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs && bun test/test-get-remote-dependencies.mjs","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-export":"bun test/test-credentials-export.mjs","test:key-create-mode":"bun test/test-key-create-mode.mjs","test:asc-key-protocol":"bun test/test-asc-key-protocol.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:android-service-account-validation":"bun test/test-android-service-account-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:offline-packers":"bun test/test-offline-packers.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:build-needed":"bun test/test-build-needed.mjs","test:cli-help":"bun test/test-cli-help.mjs","test:build-cache-payload":"bun test/test-build-cache-payload.mjs","test:build-cancellation":"bun test/test-build-cancellation.mjs","test:ci-prompts":"bun test/test-ci-prompts.mjs","test:capgo-app-id-prompt":"bun test/test-capgo-app-id-prompt.mjs","test:bundle-soft-delete":"bun test/test-bundle-soft-delete.mjs","test:ci-secrets":"bun test/test-ci-secrets.mjs","test:android-onboarding-progress":"bun test/test-android-onboarding-progress.mjs && bun test/test-android-select-guard.mjs","test:android-keystore-action":"bun test/test-android-keystore-action.mjs","test:android-google-play-action":"bun test/test-android-google-play-action.mjs","test:onboarding-telemetry":"bun test/test-onboarding-telemetry.mjs","test:v2-event-migration":"bun test/test-v2-event-migration.mjs","test:analytics":"bun test/test-analytics.mjs","test:cli-headers":"bun test/test-cli-headers.mjs","test:min-cli-version":"bun test/test-min-cli-version.mjs","test:authenticated-command-invocation":"bun test/test-authenticated-command-invocation.mjs","test:analytics-error-category":"bun test/test-analytics-error-category.mjs","test:analytics-org-resolver":"bun test/test-analytics-org-resolver.mjs","test:api-perf":"bun test/test-api-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:bundle-pages":"bun test test/test-bundle-pages.test.ts","test:bundle-single-requests":"bun test test/test-bundle-single-requests.test.ts","test:mcp-analytics":"bun test/test-mcp-analytics.mjs","test:mcp-instructions":"bun test/test-mcp-instructions.mjs","test:mcp-stdout-guard":"bun test/test-mcp-stdout-guard.mjs","test:mcp-host-fields":"bun test/test-mcp-host-fields.mjs","test:mcp-platform-select":"bun test/test-mcp-platform-select.mjs","test:mcp-explain-scopes":"bun test/test-mcp-explain-scopes.mjs","test:mcp-oauth-reopen":"bun test/test-mcp-oauth-reopen.mjs","test:mcp-broker-oauth":"bun test/test-mcp-broker-oauth.mjs","test:mcp-broker-session":"bun test/test-mcp-broker-session.mjs","test:mcp-credentials-manage":"bun test/test-mcp-credentials-manage.mjs","test:mcp-resume-prompt":"bun test/test-mcp-resume-prompt.mjs","test:mcp-build-job":"bun test/test-mcp-build-job.mjs","test:mcp-build-tools":"bun test/test-mcp-build-tools.mjs","test:app-created-source":"bun test/test-app-created-source.mjs","test:app-add-exists":"bun test/test-app-add-exists.mjs","test:app-add-getting-started":"bun test/test-app-add-getting-started.mjs","test:app-list":"bun test/test-app-list.mjs","test:app-todo":"bun test/test-app-todo.mjs && bun test/test-builder-only-checklist.mjs && bun test/test-builder-only-setup.mjs && bun test/test-app-todo-lists.mjs && bun test/test-app-todo-tabs.mjs && bun test/test-app-todo-command.mjs && node test/test-app-todo-interactive.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:cli-recovery":"bun test/test-cli-recovery.mjs","test:create-capgo-client":"bun test/test-create-capgo-client.mjs","test:no-supabase-sdk":"bun test/test-no-supabase-sdk.mjs","test:onboarding-recovery":"bun test/test-onboarding-recovery.mjs","test:onboarding-progress":"bun test/test-onboarding-progress.mjs","test:onboarding-run-targets":"bun test/test-onboarding-run-targets.mjs","test:run-device-command":"bun test/test-run-device-command.mjs","test:init-app-conflict":"bun test/test-init-app-conflict.mjs","test:channel-add-exists":"bun test/test-channel-add-exists.mjs","test:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-command-execution":"bun test/test-init-command-execution.mjs","test:init-upload-recovery":"bun test/test-init-upload-monorepo-recovery.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:init-ota-checklist":"bun test/test-init-ota-checklist.mjs","test:init-telemetry":"bun test/test-init-telemetry.mjs","test:capacitor-config-target":"bun test/test-capacitor-config-target.mjs","test:builder-app-id-config":"bun test/test-builder-app-id-config.mjs","test:capacitor-config-typescript7":"bun test/test-capacitor-config-typescript7.mjs","test:capacitor-config-native-import":"bun test/test-capacitor-config-native-import.mjs","test:cli-user-error-config":"bun test/test-cli-user-error-config.mjs","test:cordova-upload-mode":"bun test/test-cordova-upload-mode.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun run test:builder-app-id-config && bun run test:capacitor-config-typescript7 && bun run test:capacitor-config-native-import && bun run test:cli-user-error-config && bun test/test-init-monorepo-targeting.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs && bun test/test-auth-session-bad-key.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs && bun test/test-build-env.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-certificate-action":"bun test/test-ios-certificate-action.mjs","test:ios-profile-action":"bun test/test-ios-profile-action.mjs","test:ios-credential-action":"bun test/test-ios-credential-action.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:ios-marketing-version":"bun test/test-ios-marketing-version.mjs","test:android-version":"bun test/test-android-version.mjs","test:platform-flow-contract":"bun test/test-platform-flow-contract.mjs","test:tail-engine-shared":"bun test/test-tail-engine-shared.mjs",test:"bun run build && bun scripts/run-test-suite.ts","test:run":"bun scripts/run-test-suite.ts","test:serial":"bun run build && bun scripts/run-test-suite.ts --serial","test:suite":"bun run test:helper-dce && bun run test:version-detection:setup && bun run test:bundle && bun run test:notify-app-ready-background && bun run test:bundle-validation && bun run test:functional && bun run test:semver && bun run test:auto-bump-version && bun run test:auto-bump-ai-diff && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:cordova-upload-mode && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:package-json-guard && bun run test:credentials && bun run test:credentials-export && bun run test:key-create-mode && bun run test:ios-provisioning-map && bun run test:ios-provisioning-command && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:offline-packers && bun run test:checksum && bun run test:build-needed && bun run test:cli-help && bun run test:build-cache-payload && bun run test:build-cancellation && bun run test:ci-prompts && bun run test:capgo-app-id-prompt && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:android-keystore-action && bun run test:android-google-play-action && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:cli-headers && bun run test:min-cli-version && bun run test:authenticated-command-invocation && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:api-perf && bun run test:preview-qr && bun run test:bundle-pages && bun run test:bundle-single-requests && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-host-fields && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:app-add-exists && bun run test:app-add-getting-started && bun run test:app-list && bun run test:app-todo && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-capgo-client && bun run test:bundle-soft-delete && bun run test:no-supabase-sdk && bun run test:build-platform-selection && bun run test:builder-project-discovery && bun run test:builder-app-selection && bun run test:builder-login-gate && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-monorepo-targeting && bun run test:init-app-conflict && bun run test:channel-list && bun run test:channel-add-exists && bun run test:wait-log && bun run test:init-guardrails && bun run test:init-command-execution && bun run test:init-upload-recovery && bun run test:init-replay && bun run test:init-telemetry && bun run test:init-ota-checklist && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:support && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-certificate-action && bun run test:ios-profile-action && bun run test:ios-credential-action && bun run test:ios-e2e && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run test:p8-error && bun run test:ios-tui-routing && bun run test:ios-updater-sync-validation && bun run test:ios-verify-app && bun run test:ios-marketing-version && bun run test:android-version && bun run test:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && bun run test:android-gcp && bun run test:android-app-verification && bun run test:android-rename && bun run test:appflow-auth && bun run test:appflow-api-map && bun run test:appflow-validate && bun run test:appflow-flow && bun run test:appflow-gapfill && bun run test:appflow-engine && bun run test:appflow-tail && bun run test:appflow-fetch && bun run test:appflow-sa-decode && bun run test:app-permission-helper && bun run test:2fa-compliance-network && bun run test:retryable-capgo-api-error && bun run test:organization-set-api-host && bun run test:plan-validation && bun run test:setup-notices && bun run test:settings-parity && bun run test:init-browser-login && bun run test:android-onboarding-units && bun run test:build-credentials-units && bun run test:onboarding-generators && bun run test:mcp-onboarding","test:build-platform-selection":"bun test/test-build-platform-selection.mjs","test:builder-project-discovery":"bun test/test-builder-project-discovery.mjs","test:builder-app-selection":"bun test/test-builder-app-selection.mjs","test:builder-login-gate":"bun test/test-builder-login-gate.mjs","test:ai-log-capture":"bun test/test-ai-log-capture.mjs","test:ai-analyze-flow":"bun test/test-ai-analyze-flow.mjs","test:cicd-failure-help":"bun test/test-cicd-failure-help.mjs","test:ai-sse-parser":"bun test/test-ai-sse-parser.mjs","test:ai-render-markdown":"bun test/test-ai-render-markdown.mjs","test:ai-onboarding-mode":"bun test/test-ai-onboarding-mode.mjs","test:ai-fit":"bun test/test-ai-fit.mjs","test:platform-layout":"bun test/test-platform-layout.mjs","test:frame-fit":"bun test/run-frame-fit.mjs","test:onboarding-min-size":"bun test/test-onboarding-min-size.mjs","test:min-size-gate":"bun test/test-min-size-gate.mjs","test:shell-size-gate":"bun test/test-shell-size-gate.mjs","test:build-log-sanitize":"bun test/test-build-log-sanitize.mjs","test:build-output-viewport":"bun test/test-build-output-viewport.mjs","test:diff-viewer-viewport":"bun test/test-diff-viewer-viewport.mjs","test:build-complete-exit":"bun test/test-build-complete-exit.mjs","test:ai-stream-markdown":"bun test/test-ai-stream-markdown.mjs","test:support":"bun test/test-support.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.mjs","test:app-set-options":"bun test/test-app-set-options.mjs","test:settings-parity":"bun test/test-settings-parity.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-gcp":"bun test/test-android-gcp.mjs","test:android-app-verification":"bun test/test-android-app-verification.mjs","test:android-rename":"bun test/test-android-rename.mjs","test:appflow-auth":"bun test/test-appflow-auth.mjs","test:appflow-api-map":"bun test/test-appflow-api-map.mjs","test:appflow-validate":"bun test/test-appflow-validate.mjs","test:appflow-flow":"bun test/test-appflow-flow.mjs","test:appflow-gapfill":"bun test/test-appflow-gapfill.mjs","test:appflow-engine":"bun test/test-appflow-engine.mjs","test:appflow-tail":"bun test/test-appflow-tail.mjs","test:appflow-fetch":"bun test/test-appflow-fetch.mjs","test:appflow-sa-decode":"bun test/test-appflow-sa-decode.mjs","test:app-permission-helper":"bun test/test-app-permission-helper.mjs","test:2fa-compliance-network":"bun test/test-2fa-compliance-network.mjs","test:retryable-capgo-api-error":"bun test/test-retryable-capgo-api-error.mjs","test:organization-set-api-host":"bun test/test-organization-set-api-host.mjs","test:plan-validation":"bun test/test-plan-validation.mjs && bun test ./test/test-direct-offer-plan.mjs","test:auto-bump-version":"bun test/test-auto-bump-version.mjs","test:auto-bump-ai-diff":"bun test/test-auto-bump-ai-diff.mjs","test:ios-provisioning-map":"bun test/test-ios-provisioning-map.mjs","test:ios-provisioning-command":"bun test/test-ios-provisioning-command.mjs","test:channel-list":"bun test/test-channel-list.mjs","test:init-browser-login":"bun test test/init/","test:android-onboarding-units":"bun test/test-android-gradle.mjs && bun test/test-android-keystore.mjs && bun test/test-android-oauth.mjs && bun test/test-android-play.mjs && bun test/test-android-tui-sequencing.mjs","test:build-credentials-units":"bun test/test-credentials-migration.mjs && bun test/test-provisioning-map-validation.mjs && bun test/test-mobileprovision-parser.mjs","test:onboarding-generators":"bun test/test-diff-utils.mjs && bun test/test-workflow-generator.mjs","test:mcp-onboarding":"bun test/test-mcp-onboarding.mjs","test:setup-notices":"bun test ./test/test-setup-notices.mjs ./test/test-setup-progress-request.mjs ./test/test-setup-notice-background.mjs ./test/test-init-completion-notice.mjs && bun test ./test/test-builder-setup-notice.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@manypkg/tools":"^2.1.2","@rrweb/types":"^2.1.1","@standard-schema/spec":"^1.1.0","@xmldom/xmldom":"^0.9.10","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","agent-cli-detector":"^0.1.6","happy-dom":"^20.11.0",ink:"^7.1.1","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.8","rrweb-snapshot":"^2.1.1","string-width":"^8.2.2",typescript:"6.0.3",zod:"^4.5.4"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1","node-pty":"^1.1.0"},devDependencies:{"@antfu/eslint-config":"^9.2.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.4.2","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.7.0","@modelcontextprotocol/client":"^2.0.0-beta.5","@modelcontextprotocol/server":"^2.0.0-beta.5","@sauber/table":"npm:@jsr/sauber__table","@sinonjs/fake-timers":"15.4.0","@std/semver":"npm:@jsr/std__semver@1.0.8","@tanstack/intent":"^0.3.6","@types/adm-zip":"^0.5.8","@types/cross-spawn":"^6.0.6","@types/jsonwebtoken":"^9.0.10","@types/node":"^26.1.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.17","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native":"npm:typescript@7.1.0-beta","@vercel/ncc":"^0.44.1","@vue/compiler-dom":"3.5.40","@xterm/headless":"^6.0.0","adm-zip":"^0.6.0","ci-info":"^4.4.0",commander:"^15.0.0","cross-spawn":"^7.0.6",eslint:"^10.7.0","git-format-staged":"4.0.2",husky:"^9.1.7","is-wsl":"^3.1.1",micromatch:"^4.0.8",open:"^11.0.0",oxlint:"^1.75.0",partysocket:"^1.3.0",prettyjson:"^1.2.5",tmp:"^0.2.7","tus-js-client":"^4.3.1",ws:"^8.21.1"}}});var J0;var W$=p(()=>{J0=class J0 extends Error{context;constructor($,D,J){super($,J!==void 0?{cause:J}:void 0);this.name="CliUserError",this.context=D}}});import{platform as jA0}from"node:os";import{version as AA0}from"node:process";function SA0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function rh($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token is missing. Re-run the build command or pass a valid log token.";return"Capgo API key is missing. Run `npx -y @capgo/cli@latest login` or pass `--apikey`."}function PA0($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token contains invalid characters (only ASCII is allowed). Re-run the build command to get a fresh token.";if($.toLowerCase()==="authorization")return"Authorization header contains invalid characters (only ASCII is allowed). Check your Capgo API key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function qE($,D){if(D===void 0||D===null){if(GE.has($.toLowerCase()))throw new J0(rh($));throw new J0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(GE.has($.toLowerCase()))throw new J0(rh($));throw new J0(`HTTP header "${$}" is missing or invalid.`)}if(!SA0(D)){if(GE.has($.toLowerCase()))throw new J0(PA0($));throw new J0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function i$($){let D={capgo_api:TA0,"x-cli-version":N1.version,"x-cli-command":IA0,"x-cli-node":AA0,"x-cli-os":jA0()};if($)for(let[J,Q]of Object.entries($))D[J]=qE(J,Q);return D}var TA0="2025-10-01",IA0="",GE;var XD=p(()=>{QD();W$();GE=new Set(["authorization","capgkey","x-capgo-log-token"])});var oh,th=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},ah=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var sh=p(()=>{oh=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let J=0;$.lastIndex=0;while($.test(D))J+=1;return D.length-J}})()});var CA0,_A0,eh,vA0,$g,xA0,kA0,uA0,Dg=($,D={},J={})=>{let Q=D.limit??1/0,X=D.ellipsis??"",Y=D?.ellipsisWidth??(X?Dg(X,uA0,J).width:0),F=0,Z=J.controlWidth??0,G=J.tabWidth??8,q=J.emojiWidth??2,U=2,W=J.regularWidth??1,H=J.wideWidth??2,K=[[xA0,W],[CA0,0],[_A0,Z],[vA0,G],[$g,q],[eh,H]],O=0,z=0,V=$.length,M=0,E=!1,L=V,N=Math.max(0,Q-Y),B=0,w=0,_=0,x=0;$:while(!0){if(w>B||z>=V&&z>O){let R=$.slice(B,w)||$.slice(O,z);M=0;for(let k of R.replaceAll(kA0,"")){let v=k.codePointAt(0)||0;if(th(v))x=2;else if(ah(v))x=H;else x=W;if(_+x>N)L=Math.min(L,Math.max(B,O)+M);if(_+x>Q){E=!0;break $}M+=k.length,_+=x}B=w=0}if(z>=V)break $;for(let R=0,k=K.length;R<k;R++){let[v,d]=K[R];if(v.lastIndex=z,v.test($)){if(M=v===eh?oh($.slice(z,v.lastIndex)):v===$g?1:v.lastIndex-z,x=M*d,_+x>N)L=Math.min(L,z+Math.floor((N-_)/d));if(_+x>Q){E=!0;break $}_+=x,B=O,w=z,z=O=v.lastIndex;continue $}}z+=1}return{width:E?N:_,index:E?L:V,truncated:E,ellipsed:E&&Q>=Y}},Jg;var Qg=p(()=>{sh();CA0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,_A0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,eh=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,vA0=/\t{1,1000}/y,$g=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,xA0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,kA0=/\p{M}+/gu,uA0={limit:1/0,ellipsis:""},Jg=Dg});var fA0,yA0=($,D={})=>{return Jg($,fA0,D).width},y8;var UE=p(()=>{Qg();fA0={limit:1/0,ellipsis:"",ellipsisWidth:0},y8=yA0});function I5($,D,J){return String($).normalize().split(dA0).map((Q)=>mA0(Q,D,J)).join(`
|
|
1
|
+
import{createRequire as wA0}from"node:module";var module={exports:{}};var KA0=Object.create;var{getPrototypeOf:OA0,defineProperty:ZE,getOwnPropertyNames:zA0}=Object;var VA0=Object.prototype.hasOwnProperty;function LA0($){return this[$]}var NA0,MA0,n$=($,D,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=D?NA0??=new WeakMap:MA0??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?KA0(OA0($)):{};let F=D||!$||!$.__esModule?ZE(J,"default",{value:$,enumerable:!0}):J;for(let Z of zA0($))if(!VA0.call(F,Z))ZE(F,Z,{get:LA0.bind($,Z),enumerable:!0});if(Q)X.set($,F);return F};var A=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var BA0=($)=>$;function EA0($,D){this[$]=BA0.bind(null,D)}var a6=($,D)=>{for(var J in D)ZE($,J,{get:D[J],enumerable:!0,configurable:!0,set:EA0.bind(D,J)})};var p=($,D)=>()=>($&&(D=$($=0)),D);var Q0=wA0(import.meta.url);var N1;var QD=p(()=>{N1={name:"@capgo/cli",type:"module",version:"8.98.1",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"https://github.com/Cap-go/capgo.app",directory:"cli"},bugs:{url:"https://github.com/Cap-go/capgo/issues"},keywords:["appflow alternative","ionic","capacitor","auto update","live update","capgo","cli","upload","capgo-cli","sdk","tanstack-intent"],exports:{".":{import:"./dist/index.js",require:"./dist/index.js"},"./sdk":{types:"./dist/src/sdk.d.ts",import:"./dist/src/sdk.js"}},main:"dist/index.js",types:"dist/src/index.d.ts",bin:{capgo:"dist/index.js"},files:["!skills/_artifacts","dist","skills"],engines:{npm:">=8.0.0",node:">=20.0.0"},scripts:{build:"tsc && bun build.mjs",dev:"NODE_ENV=development ncc build","no-debug":"node dist/index.js","dev-build":"SUPA_DB=development ncc build",pack:"pkg",typecheck:"tsc --noEmit",lint:"bun run lint:ox","lint:ox":"oxlint --config ../.oxlintrc.json src","lint:fix":"oxlint --config ../.oxlintrc.json --fix src","check-posix-paths":"node test/check-posix-paths.js","generate-docs":"node dist/index.js generate-docs README.md","test:notify-app-ready-background":"bun test ./test/test-notify-app-ready-background.mjs ./test/test-background-check-shutdown.mjs","test:bundle":"bun test/test-bundle.mjs","test:bundle-validation":"bun test test/bundle/","test:prescan":"bun test test/prescan/","test:functional":"bun test/test-functional.mjs","test:semver":"bun test/test-semver-validation.mjs","test:version-edge-cases":"bun test/test-version-validation.mjs","test:regex":"bun test/test-regex-validation.mjs","test:upload":"bun test/test-upload-validation.mjs","test:fail-on-incompatible":"bun test/test-fail-on-incompatible.mjs","test:native-dependencies":"bun test/test-native-dependencies.mjs && bun test/test-get-remote-dependencies.mjs","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.mjs","test:credentials-export":"bun test/test-credentials-export.mjs","test:key-create-mode":"bun test/test-key-create-mode.mjs","test:asc-key-protocol":"bun test/test-asc-key-protocol.mjs","test:credentials-validation":"bun test/test-credentials-validation.mjs","test:android-service-account-validation":"bun test/test-android-service-account-validation.mjs","test:build-zip-filter":"bun test/test-build-zip-filter.mjs","test:offline-packers":"bun test/test-offline-packers.mjs","test:checksum":"bun test/test-checksum-algorithm.mjs","test:build-needed":"bun test/test-build-needed.mjs","test:cli-help":"bun test/test-cli-help.mjs","test:build-cache-payload":"bun test/test-build-cache-payload.mjs","test:build-cancellation":"bun test/test-build-cancellation.mjs","test:ci-prompts":"bun test/test-ci-prompts.mjs","test:capgo-app-id-prompt":"bun test/test-capgo-app-id-prompt.mjs","test:bundle-soft-delete":"bun test/test-bundle-soft-delete.mjs","test:ci-secrets":"bun test/test-ci-secrets.mjs","test:android-onboarding-progress":"bun test/test-android-onboarding-progress.mjs && bun test/test-android-select-guard.mjs","test:android-keystore-action":"bun test/test-android-keystore-action.mjs","test:android-google-play-action":"bun test/test-android-google-play-action.mjs","test:onboarding-telemetry":"bun test/test-onboarding-telemetry.mjs","test:v2-event-migration":"bun test/test-v2-event-migration.mjs","test:analytics":"bun test/test-analytics.mjs","test:cli-headers":"bun test/test-cli-headers.mjs","test:min-cli-version":"bun test/test-min-cli-version.mjs","test:authenticated-command-invocation":"bun test/test-authenticated-command-invocation.mjs","test:analytics-error-category":"bun test/test-analytics-error-category.mjs","test:analytics-org-resolver":"bun test/test-analytics-org-resolver.mjs","test:api-perf":"bun test/test-api-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:bundle-pages":"bun test test/test-bundle-pages.test.ts","test:bundle-single-requests":"bun test test/test-bundle-single-requests.test.ts","test:mcp-analytics":"bun test/test-mcp-analytics.mjs","test:mcp-instructions":"bun test/test-mcp-instructions.mjs","test:mcp-stdout-guard":"bun test/test-mcp-stdout-guard.mjs","test:mcp-host-fields":"bun test/test-mcp-host-fields.mjs","test:mcp-platform-select":"bun test/test-mcp-platform-select.mjs","test:mcp-explain-scopes":"bun test/test-mcp-explain-scopes.mjs","test:mcp-oauth-reopen":"bun test/test-mcp-oauth-reopen.mjs","test:mcp-broker-oauth":"bun test/test-mcp-broker-oauth.mjs","test:mcp-broker-session":"bun test/test-mcp-broker-session.mjs","test:mcp-credentials-manage":"bun test/test-mcp-credentials-manage.mjs","test:mcp-resume-prompt":"bun test/test-mcp-resume-prompt.mjs","test:mcp-build-job":"bun test/test-mcp-build-job.mjs","test:mcp-build-tools":"bun test/test-mcp-build-tools.mjs","test:app-created-source":"bun test/test-app-created-source.mjs","test:app-add-exists":"bun test/test-app-add-exists.mjs","test:app-add-getting-started":"bun test/test-app-add-getting-started.mjs","test:app-list":"bun test/test-app-list.mjs","test:app-todo":"bun test/test-app-todo.mjs && bun test/test-builder-only-checklist.mjs && bun test/test-builder-only-setup.mjs && bun test/test-app-todo-lists.mjs && bun test/test-app-todo-tabs.mjs && bun test/test-app-todo-command.mjs && node test/test-app-todo-interactive.mjs","test:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.mjs","test:cli-recovery":"bun test/test-cli-recovery.mjs","test:create-capgo-client":"bun test/test-create-capgo-client.mjs","test:no-supabase-sdk":"bun test/test-no-supabase-sdk.mjs","test:no-redirect-error":"bun test/test-no-redirect-error.mjs","test:onboarding-recovery":"bun test/test-onboarding-recovery.mjs","test:onboarding-progress":"bun test/test-onboarding-progress.mjs","test:onboarding-run-targets":"bun test/test-onboarding-run-targets.mjs","test:run-device-command":"bun test/test-run-device-command.mjs","test:init-app-conflict":"bun test/test-init-app-conflict.mjs","test:channel-add-exists":"bun test/test-channel-add-exists.mjs","test:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.mjs","test:init-command-execution":"bun test/test-init-command-execution.mjs","test:init-upload-recovery":"bun test/test-init-upload-monorepo-recovery.mjs","test:init-replay":"bun test/test-init-replay.mjs","test:init-ota-checklist":"bun test/test-init-ota-checklist.mjs","test:init-telemetry":"bun test/test-init-telemetry.mjs","test:capacitor-config-target":"bun test/test-capacitor-config-target.mjs","test:builder-app-id-config":"bun test/test-builder-app-id-config.mjs","test:capacitor-config-typescript7":"bun test/test-capacitor-config-typescript7.mjs","test:capacitor-config-native-import":"bun test/test-capacitor-config-native-import.mjs","test:cli-user-error-config":"bun test/test-cli-user-error-config.mjs","test:cordova-upload-mode":"bun test/test-cordova-upload-mode.mjs","test:init-monorepo-targeting":"bun run test:capacitor-config-target && bun run test:builder-app-id-config && bun run test:capacitor-config-typescript7 && bun run test:capacitor-config-native-import && bun run test:cli-user-error-config && bun test/test-init-monorepo-targeting.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:auth-session":"bun test/test-auth-session.mjs && bun test/test-auth-session-bad-key.mjs","test:mcp":"node test/test-mcp.mjs","test:mcp-no-key-handshake":"node test/test-mcp-no-key-handshake.mjs","test:version-detection":"node test/test-get-installed-version.mjs","test:version-detection:setup":"./test/fixtures/setup-test-projects.sh","test:platform-paths":"bun test/test-platform-paths.mjs","test:project-type-detection":"bun test/test-project-type-detection.mjs","test:payload-split":"bun test/test-payload-split.mjs && bun test/test-build-env.mjs","test:macos-signing":"bun test/test-macos-signing.mjs","test:helper-dce":"bash scripts/check-helper-dce.sh","test:apple-api-import-helpers":"bun test/test-apple-api-import-helpers.mjs","test:apple-api-verify-key":"bun test/test-apple-api-verify-key.mjs","test:bundle-id-detector":"bun test/test-bundle-id-detector.mjs","test:apple-api-app-list":"bun test/test-apple-api-app-list.mjs","test:apple-api-cert-create":"bun test/test-apple-api-cert-create.mjs","test:app-verification":"bun test/test-app-verification.mjs","test:pbxproj-parser":"bun test/test-pbxproj-parser.mjs","test:self-update":"bun test/test-self-update.mjs","test:update-prompt":"bun test/test-update-prompt.mjs","test:android-tail-engine":"bun test/test-android-tail-engine.mjs","test:android-tail-render":"bun test/test-android-tail-render.mjs","test:android-tail-routing":"bun test/test-android-tail-routing.mjs","test:dev-gate-stripped":"bun test/test-dev-gate-stripped.mjs","test:ios-confirm-app-id":"bun test/test-ios-confirm-app-id.mjs","test:ios-create-new":"bun test/test-ios-create-new.mjs","test:ios-certificate-action":"bun test/test-ios-certificate-action.mjs","test:ios-profile-action":"bun test/test-ios-profile-action.mjs","test:ios-credential-action":"bun test/test-ios-credential-action.mjs","test:ios-e2e":"bun test/test-ios-e2e.mjs","test:ios-import-discovery":"bun test/test-ios-import-discovery.mjs","test:ios-import-export":"bun test/test-ios-import-export.mjs","test:ios-import-pickers":"bun test/test-ios-import-pickers.mjs","test:ios-import-recovery":"bun test/test-ios-import-recovery.mjs","test:ios-recovery":"bun test/test-ios-recovery.mjs","test:ios-resume":"bun test/test-ios-resume.mjs","test:ios-tail-handoff":"bun test/test-ios-tail-handoff.mjs","test:ios-tui-render":"bun test/test-ios-tui-render.mjs","test:p8-error":"bun test/test-p8-error.mjs","test:ios-tui-routing":"bun test/test-ios-tui-routing.mjs","test:ios-updater-sync-validation":"bun test/test-ios-updater-sync-validation.mjs","test:ios-verify-app":"bun test/test-ios-verify-app.mjs","test:ios-marketing-version":"bun test/test-ios-marketing-version.mjs","test:android-version":"bun test/test-android-version.mjs","test:platform-flow-contract":"bun test/test-platform-flow-contract.mjs","test:tail-engine-shared":"bun test/test-tail-engine-shared.mjs",test:"bun run build && bun scripts/run-test-suite.ts","test:run":"bun scripts/run-test-suite.ts","test:serial":"bun run build && bun scripts/run-test-suite.ts --serial","test:suite":"bun run test:helper-dce && bun run test:version-detection:setup && bun run test:bundle && bun run test:notify-app-ready-background && bun run test:bundle-validation && bun run test:functional && bun run test:semver && bun run test:auto-bump-version && bun run test:auto-bump-ai-diff && bun run test:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:cordova-upload-mode && bun run test:fail-on-incompatible && bun run test:native-dependencies && bun run test:package-json-guard && bun run test:credentials && bun run test:credentials-export && bun run test:key-create-mode && bun run test:ios-provisioning-map && bun run test:ios-provisioning-command && bun run test:credentials-validation && bun run test:android-service-account-validation && bun run test:build-zip-filter && bun run test:offline-packers && bun run test:checksum && bun run test:build-needed && bun run test:cli-help && bun run test:build-cache-payload && bun run test:build-cancellation && bun run test:ci-prompts && bun run test:capgo-app-id-prompt && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:android-keystore-action && bun run test:android-google-play-action && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && bun run test:cli-headers && bun run test:min-cli-version && bun run test:authenticated-command-invocation && bun run test:analytics-error-category && bun run test:analytics-org-resolver && bun run test:api-perf && bun run test:preview-qr && bun run test:bundle-pages && bun run test:bundle-single-requests && bun run test:app-set-options && bun run test:mcp-analytics && bun run test:mcp-instructions && bun run test:mcp-live-update-onboarding && bun run test:mcp-stdout-guard && bun run test:mcp-host-fields && bun run test:mcp-platform-select && bun run test:mcp-explain-scopes && bun run test:mcp-oauth-reopen && bun run test:mcp-broker-oauth && bun run test:mcp-broker-session && bun run test:mcp-credentials-manage && bun run test:mcp-resume-prompt && bun run test:mcp-build-job && bun run test:mcp-build-tools && bun run test:app-created-source && bun run test:app-add-exists && bun run test:app-add-getting-started && bun run test:app-list && bun run test:app-todo && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-capgo-client && bun run test:bundle-soft-delete && bun run test:no-supabase-sdk && bun run test:no-redirect-error && bun run test:build-platform-selection && bun run test:builder-project-discovery && bun run test:builder-app-selection && bun run test:builder-login-gate && bun run test:onboarding-recovery && bun run test:onboarding-progress && bun run test:onboarding-run-targets && bun run test:run-device-command && bun run test:init-monorepo-targeting && bun run test:init-app-conflict && bun run test:channel-list && bun run test:channel-add-exists && bun run test:wait-log && bun run test:init-guardrails && bun run test:init-command-execution && bun run test:init-upload-recovery && bun run test:init-replay && bun run test:init-telemetry && bun run test:init-ota-checklist && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:mcp-no-key-handshake && bun run test:auth-session && bun run test:version-detection && bun run test:platform-paths && bun run test:project-type-detection && bun run test:payload-split && bun run test:macos-signing && bun run test:asc-key-protocol && bun run test:apple-api-import-helpers && bun run test:apple-api-verify-key && bun run test:bundle-id-detector && bun run test:apple-api-app-list && bun run test:app-verification && bun run test:pbxproj-parser && bun run test:ai-log-capture && bun run test:ai-analyze-flow && bun run test:cicd-failure-help && bun run test:ai-sse-parser && bun run test:ai-render-markdown && bun run test:ai-stream-markdown && bun run test:ai-onboarding-mode && bun run test:ai-fit && bun run test:platform-layout && bun run test:frame-fit && bun run test:onboarding-min-size && bun run test:min-size-gate && bun run test:shell-size-gate && bun run test:build-log-sanitize && bun run test:build-output-viewport && bun run test:diff-viewer-viewport && bun run test:build-complete-exit && bun run test:support && bun run test:self-update && bun run test:update-prompt && bun run test:apple-api-cert-create && bun run test:android-tail-engine && bun run test:android-tail-render && bun run test:android-tail-routing && bun run test:dev-gate-stripped && bun run test:ios-confirm-app-id && bun run test:ios-create-new && bun run test:ios-certificate-action && bun run test:ios-profile-action && bun run test:ios-credential-action && bun run test:ios-e2e && bun run test:ios-import-discovery && bun run test:ios-import-export && bun run test:ios-import-pickers && bun run test:ios-import-recovery && bun run test:ios-recovery && bun run test:ios-resume && bun run test:ios-tail-handoff && bun run test:ios-tui-render && bun run test:p8-error && bun run test:ios-tui-routing && bun run test:ios-updater-sync-validation && bun run test:ios-verify-app && bun run test:ios-marketing-version && bun run test:android-version && bun run test:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && bun run test:android-gcp && bun run test:android-app-verification && bun run test:android-rename && bun run test:appflow-auth && bun run test:appflow-api-map && bun run test:appflow-validate && bun run test:appflow-flow && bun run test:appflow-gapfill && bun run test:appflow-engine && bun run test:appflow-tail && bun run test:appflow-fetch && bun run test:appflow-sa-decode && bun run test:app-permission-helper && bun run test:2fa-compliance-network && bun run test:retryable-capgo-api-error && bun run test:organization-set-api-host && bun run test:plan-validation && bun run test:setup-notices && bun run test:settings-parity && bun run test:init-browser-login && bun run test:android-onboarding-units && bun run test:build-credentials-units && bun run test:onboarding-generators && bun run test:mcp-onboarding","test:build-platform-selection":"bun test/test-build-platform-selection.mjs","test:builder-project-discovery":"bun test/test-builder-project-discovery.mjs","test:builder-app-selection":"bun test/test-builder-app-selection.mjs","test:builder-login-gate":"bun test/test-builder-login-gate.mjs","test:ai-log-capture":"bun test/test-ai-log-capture.mjs","test:ai-analyze-flow":"bun test/test-ai-analyze-flow.mjs","test:cicd-failure-help":"bun test/test-cicd-failure-help.mjs","test:ai-sse-parser":"bun test/test-ai-sse-parser.mjs","test:ai-render-markdown":"bun test/test-ai-render-markdown.mjs","test:ai-onboarding-mode":"bun test/test-ai-onboarding-mode.mjs","test:ai-fit":"bun test/test-ai-fit.mjs","test:platform-layout":"bun test/test-platform-layout.mjs","test:frame-fit":"bun test/run-frame-fit.mjs","test:onboarding-min-size":"bun test/test-onboarding-min-size.mjs","test:min-size-gate":"bun test/test-min-size-gate.mjs","test:shell-size-gate":"bun test/test-shell-size-gate.mjs","test:build-log-sanitize":"bun test/test-build-log-sanitize.mjs","test:build-output-viewport":"bun test/test-build-output-viewport.mjs","test:diff-viewer-viewport":"bun test/test-diff-viewer-viewport.mjs","test:build-complete-exit":"bun test/test-build-complete-exit.mjs","test:ai-stream-markdown":"bun test/test-ai-stream-markdown.mjs","test:support":"bun test/test-support.mjs","test:mcp-live-update-onboarding":"bun test/test-mcp-live-update-onboarding.mjs","test:app-set-options":"bun test/test-app-set-options.mjs","test:settings-parity":"bun test/test-settings-parity.mjs","test:android-reporting-api":"bun test/test-android-reporting-api.mjs","test:android-gcp":"bun test/test-android-gcp.mjs","test:android-app-verification":"bun test/test-android-app-verification.mjs","test:android-rename":"bun test/test-android-rename.mjs","test:appflow-auth":"bun test/test-appflow-auth.mjs","test:appflow-api-map":"bun test/test-appflow-api-map.mjs","test:appflow-validate":"bun test/test-appflow-validate.mjs","test:appflow-flow":"bun test/test-appflow-flow.mjs","test:appflow-gapfill":"bun test/test-appflow-gapfill.mjs","test:appflow-engine":"bun test/test-appflow-engine.mjs","test:appflow-tail":"bun test/test-appflow-tail.mjs","test:appflow-fetch":"bun test/test-appflow-fetch.mjs","test:appflow-sa-decode":"bun test/test-appflow-sa-decode.mjs","test:app-permission-helper":"bun test/test-app-permission-helper.mjs","test:2fa-compliance-network":"bun test/test-2fa-compliance-network.mjs","test:retryable-capgo-api-error":"bun test/test-retryable-capgo-api-error.mjs","test:organization-set-api-host":"bun test/test-organization-set-api-host.mjs","test:plan-validation":"bun test/test-plan-validation.mjs && bun test ./test/test-direct-offer-plan.mjs","test:auto-bump-version":"bun test/test-auto-bump-version.mjs","test:auto-bump-ai-diff":"bun test/test-auto-bump-ai-diff.mjs","test:ios-provisioning-map":"bun test/test-ios-provisioning-map.mjs","test:ios-provisioning-command":"bun test/test-ios-provisioning-command.mjs","test:channel-list":"bun test/test-channel-list.mjs","test:init-browser-login":"bun test test/init/","test:android-onboarding-units":"bun test/test-android-gradle.mjs && bun test/test-android-keystore.mjs && bun test/test-android-oauth.mjs && bun test/test-android-play.mjs && bun test/test-android-tui-sequencing.mjs","test:build-credentials-units":"bun test/test-credentials-migration.mjs && bun test/test-provisioning-map-validation.mjs && bun test/test-mobileprovision-parser.mjs","test:onboarding-generators":"bun test/test-diff-utils.mjs && bun test/test-workflow-generator.mjs","test:mcp-onboarding":"bun test/test-mcp-onboarding.mjs","test:setup-notices":"bun test ./test/test-setup-notices.mjs ./test/test-setup-progress-request.mjs ./test/test-setup-notice-background.mjs ./test/test-init-completion-notice.mjs && bun test ./test/test-builder-setup-notice.mjs"},dependencies:{"@inkjs/ui":"^2.0.0","@manypkg/tools":"^2.1.2","@rrweb/types":"^2.1.1","@standard-schema/spec":"^1.1.0","@xmldom/xmldom":"^0.9.10","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","agent-cli-detector":"^0.1.6","happy-dom":"^20.11.0",ink:"^7.1.1","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.8","rrweb-snapshot":"^2.1.1","string-width":"^8.2.2",typescript:"6.0.3",zod:"^4.5.4"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1","node-pty":"^1.1.0"},devDependencies:{"@antfu/eslint-config":"^9.2.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.4.2","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.7.0","@modelcontextprotocol/client":"^2.0.0-beta.5","@modelcontextprotocol/server":"^2.0.0-beta.5","@sauber/table":"npm:@jsr/sauber__table","@sinonjs/fake-timers":"15.4.0","@std/semver":"npm:@jsr/std__semver@1.0.8","@tanstack/intent":"^0.3.6","@types/adm-zip":"^0.5.8","@types/cross-spawn":"^6.0.6","@types/jsonwebtoken":"^9.0.10","@types/node":"^26.1.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.17","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native":"npm:typescript@7.1.0-beta","@vercel/ncc":"^0.44.1","@vue/compiler-dom":"3.5.40","@xterm/headless":"^6.0.0","adm-zip":"^0.6.0","ci-info":"^4.4.0",commander:"^15.0.0","cross-spawn":"^7.0.6",eslint:"^10.7.0","git-format-staged":"4.0.2",husky:"^9.1.7","is-wsl":"^3.1.1",micromatch:"^4.0.8",open:"^11.0.0",oxlint:"^1.75.0",partysocket:"^1.3.0",prettyjson:"^1.2.5",tmp:"^0.2.7","tus-js-client":"^4.3.1",ws:"^8.21.1"}}});var J0;var W$=p(()=>{J0=class J0 extends Error{context;constructor($,D,J){super($,J!==void 0?{cause:J}:void 0);this.name="CliUserError",this.context=D}}});import{platform as jA0}from"node:os";import{version as AA0}from"node:process";function SA0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function rh($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token is missing. Re-run the build command or pass a valid log token.";return"Capgo API key is missing. Run `npx -y @capgo/cli@latest login` or pass `--apikey`."}function PA0($){if($.toLowerCase()==="x-capgo-log-token")return"Build log token contains invalid characters (only ASCII is allowed). Re-run the build command to get a fresh token.";if($.toLowerCase()==="authorization")return"Authorization header contains invalid characters (only ASCII is allowed). Check your Capgo API key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function qE($,D){if(D===void 0||D===null){if(GE.has($.toLowerCase()))throw new J0(rh($));throw new J0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(GE.has($.toLowerCase()))throw new J0(rh($));throw new J0(`HTTP header "${$}" is missing or invalid.`)}if(!SA0(D)){if(GE.has($.toLowerCase()))throw new J0(PA0($));throw new J0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function i$($){let D={capgo_api:TA0,"x-cli-version":N1.version,"x-cli-command":IA0,"x-cli-node":AA0,"x-cli-os":jA0()};if($)for(let[J,Q]of Object.entries($))D[J]=qE(J,Q);return D}var TA0="2025-10-01",IA0="",GE;var XD=p(()=>{QD();W$();GE=new Set(["authorization","capgkey","x-capgo-log-token"])});var oh,th=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},ah=($)=>{return $===8987||$===9001||$>=12272&&$<=12287||$>=12289&&$<=12350||$>=12441&&$<=12543||$>=12549&&$<=12591||$>=12593&&$<=12686||$>=12688&&$<=12771||$>=12783&&$<=12830||$>=12832&&$<=12871||$>=12880&&$<=19903||$>=65040&&$<=65049||$>=65072&&$<=65106||$>=65108&&$<=65126||$>=65128&&$<=65131||$>=127488&&$<=127490||$>=127504&&$<=127547||$>=127552&&$<=127560||$>=131072&&$<=196605||$>=196608&&$<=262141};var sh=p(()=>{oh=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let J=0;$.lastIndex=0;while($.test(D))J+=1;return D.length-J}})()});var CA0,_A0,eh,vA0,$g,xA0,kA0,uA0,Dg=($,D={},J={})=>{let Q=D.limit??1/0,X=D.ellipsis??"",Y=D?.ellipsisWidth??(X?Dg(X,uA0,J).width:0),F=0,Z=J.controlWidth??0,G=J.tabWidth??8,q=J.emojiWidth??2,U=2,W=J.regularWidth??1,H=J.wideWidth??2,K=[[xA0,W],[CA0,0],[_A0,Z],[vA0,G],[$g,q],[eh,H]],O=0,z=0,V=$.length,M=0,E=!1,L=V,N=Math.max(0,Q-Y),B=0,w=0,_=0,x=0;$:while(!0){if(w>B||z>=V&&z>O){let R=$.slice(B,w)||$.slice(O,z);M=0;for(let k of R.replaceAll(kA0,"")){let v=k.codePointAt(0)||0;if(th(v))x=2;else if(ah(v))x=H;else x=W;if(_+x>N)L=Math.min(L,Math.max(B,O)+M);if(_+x>Q){E=!0;break $}M+=k.length,_+=x}B=w=0}if(z>=V)break $;for(let R=0,k=K.length;R<k;R++){let[v,d]=K[R];if(v.lastIndex=z,v.test($)){if(M=v===eh?oh($.slice(z,v.lastIndex)):v===$g?1:v.lastIndex-z,x=M*d,_+x>N)L=Math.min(L,z+Math.floor((N-_)/d));if(_+x>Q){E=!0;break $}_+=x,B=O,w=z,z=O=v.lastIndex;continue $}}z+=1}return{width:E?N:_,index:E?L:V,truncated:E,ellipsed:E&&Q>=Y}},Jg;var Qg=p(()=>{sh();CA0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,_A0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,eh=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,vA0=/\t{1,1000}/y,$g=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,xA0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,kA0=/\p{M}+/gu,uA0={limit:1/0,ellipsis:""},Jg=Dg});var fA0,yA0=($,D={})=>{return Jg($,fA0,D).width},y8;var UE=p(()=>{Qg();fA0={limit:1/0,ellipsis:"",ellipsisWidth:0},y8=yA0});function I5($,D,J){return String($).normalize().split(dA0).map((Q)=>mA0(Q,D,J)).join(`
|
|
2
2
|
`)}var AH="\x1B",Gg="",bA0=39,HE="\x07",qg="[",hA0="]",Ug="m",KE,Xg,Yg=($)=>{if($>=30&&$<=37)return 39;if($>=90&&$<=97)return 39;if($>=40&&$<=47)return 49;if($>=100&&$<=107)return 49;if($===1||$===2)return 22;if($===3)return 23;if($===4)return 24;if($===7)return 27;if($===8)return 28;if($===9)return 29;if($===0)return 0;return},Fg=($)=>`${AH}${qg}${$}${Ug}`,Zg=($)=>`${AH}${KE}${$}${HE}`,WE=($,D,J)=>{let Q=D[Symbol.iterator](),X=!1,Y=!1,F=$.at(-1),Z=F===void 0?0:y8(F),G=Q.next(),q=Q.next(),U=0;while(!G.done){let W=G.value,H=y8(W);if(Z+H<=J)$[$.length-1]+=W;else $.push(W),Z=0;if(W===AH||W===Gg)X=!0,Y=D.startsWith(KE,U+1);if(X){if(Y){if(W===HE)X=!1,Y=!1}else if(W===Ug)X=!1}else if(Z+=H,Z===J&&!q.done)$.push(""),Z=0;G=q,q=Q.next(),U+=W.length}if(F=$.at(-1),!Z&&F!==void 0&&F.length&&$.length>1)$[$.length-2]+=$.pop()},gA0=($)=>{let D=$.split(" "),J=D.length;while(J){if(y8(D[J-1]))break;J--}if(J===D.length)return $;return D.slice(0,J).join(" ")+D.slice(J).join("")},mA0=($,D,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Q="",X,Y,F=$.split(" "),Z=[""],G=0;for(let W=0;W<F.length;W++){let H=F[W];if(J.trim!==!1){let O=Z.at(-1)??"",z=O.trimStart();if(O.length!==z.length)Z[Z.length-1]=z,G=y8(z)}if(W!==0){if(G>=D&&(J.wordWrap===!1||J.trim===!1))Z.push(""),G=0;if(G||J.trim===!1)Z[Z.length-1]+=" ",G++}let K=y8(H);if(J.hard&&K>D){let O=D-G,z=1+Math.floor((K-O-1)/D);if(Math.floor((K-1)/D)<z)Z.push("");WE(Z,H,D),G=y8(Z.at(-1)??"");continue}if(G+K>D&&G&&K){if(J.wordWrap===!1&&G<D){WE(Z,H,D),G=y8(Z.at(-1)??"");continue}Z.push(""),G=0}if(G+K>D&&J.wordWrap===!1){WE(Z,H,D),G=y8(Z.at(-1)??"");continue}Z[Z.length-1]+=H,G+=K}if(J.trim!==!1)Z=Z.map((W)=>gA0(W));let q=Z.join(`
|
|
3
3
|
`),U=!1;for(let W=0;W<q.length;W++){let H=q[W];if(Q+=H,!U){if(U=H>="\uD800"&&H<="\uDBFF",U)continue}else U=!1;if(H===AH||H===Gg){Xg.lastIndex=W+1;let O=Xg.exec(q)?.groups;if(O?.code!==void 0){let z=Number.parseFloat(O.code);X=z===bA0?void 0:z}else if(O?.uri!==void 0)Y=O.uri.length===0?void 0:O.uri}if(q[W+1]===`
|
|
4
4
|
`){if(Y)Q+=Zg("");let K=X?Yg(X):void 0;if(X&&K)Q+=Fg(K)}else if(H===`
|
|
@@ -370,8 +370,8 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
370
370
|
`)}function PF0($){return[`Bundle upload timed out after ${Math.round($/1000)}s.`,"The standard upload has to finish the whole transfer within this window and does not retry, so a large bundle or a slow connection can trip it.","What you can do:","1. Retry with the resumable upload, which uploads in chunks and retries automatically: npx @capgo/cli@latest bundle upload --tus","2. Or raise the limit for the standard upload: npx @capgo/cli@latest bundle upload --timeout <milliseconds>"].join(`
|
|
371
371
|
`)}function F0($){if(!$)return"Unknown error";if(NF($).isSecurityPolicyError)return tv($);let J=$;if(typeof $==="string")return $;if($ instanceof Error){let Q=J.message||J.cause?.message||J.stack||$.name,X=J.cause?.name,Y=Q.toLowerCase();if(Y.includes("fetch failed")||Y.includes("failed to fetch")||Y.includes("connect timeout")||Y.includes("network")||X?.startsWith("UND_ERR"))return`Network error: ${Q}${J.code?` (code ${J.code})`:""}. Check your network connection and API endpoint availability.`;let F=J.status||J.statusCode;return[Q,J.code?`Code: ${J.code}`:void 0,F?`Status: ${F}`:void 0].filter(Boolean).join(" | ")||$.name}if(J.message){let Q=[J.message,J.code?`Code: ${J.code}`:void 0,J.status||J.statusCode?`Status: ${J.status||J.statusCode}`:void 0].filter(Boolean).join(" | "),X=J.message.toLowerCase();if(X.includes("fetch failed")||X.includes("failed to fetch")||J.error==="Failed to fetch")return`Network error: ${Q}. Check your network connection and API endpoint availability.`;if(J.details||J.hint||J.error)return`${Q}${Q?" | ":""}${J.error?typeof J.error==="string"?J.error:J.error.message??"":""}${J.details?`Details: ${J.details}`:""}${J.hint?`Hint: ${J.hint}`:""}`.trim();return Q}if(typeof J.error==="string"&&J.error.length>0)return J.error;if(J.error&&typeof J.error==="object"&&typeof J.error.message==="string"&&J.error.message.length>0)return J.error.message;return`
|
|
372
372
|
${IF0.default.render($)}`}function Cx($){if(typeof $!=="string"&&typeof $!=="number")return;return Z9(String($)).slice(0,CF0)}function J8$($){if(typeof $==="string")return Z9($).slice(0,CF0);if(!$||typeof $!=="object")return String($);let D=$,J=Cx(D.name),Q=Cx(D.message),X=J&&Q?`${J}: ${Q}`:Q||J||Object.prototype.toString.call($),Y=[["code",D.code],["errno",D.errno],["syscall",D.syscall],["address",D.address],["port",D.port]].map(([F,Z])=>{let G=Cx(Z);return G?`${F}=${G}`:void 0}).filter(Boolean);return`${X}${Y.length>0?` (${Y.join(", ")})`:""}`}function VL($){let D=[],J=new Set,Q=0,X=(Y,F,Z)=>{if(Q>=D8$)return;if(Y&&typeof Y==="object"){if(J.has(Y))return;J.add(Y)}Q++;let G=" ".repeat(Z);if(D.push(`${G}${F}${J8$(Y)}`),!Y||typeof Y!=="object")return;let q=Y,U=[q.causingError,q.cause].filter((W,H,K)=>W!==void 0&&W!==null&&K.indexOf(W)===H);for(let W of U)X(W,"Caused by: ",Z+1);if(Array.isArray(q.errors))q.errors.forEach((W,H)=>{X(W,`Contained error ${H+1}: `,Z+1)})};return X($,"",0),Z9(D.join(`
|
|
373
|
-
`))}function d6({silent:$=!1,stdinIsTTY:D=!!AF0.isTTY,stdoutIsTTY:J=!!TF0.isTTY,ci:Q=yx.isCI}={}){return!$&&D&&J&&!Q}function Q8$($={}){let D=$.ci??yx.isCI,J=$.stdinIsTTY??!!AF0.isTTY,Q=$.stdoutIsTTY??!!TF0.isTTY,X=$.platform??wF0(),Y="display"in $?$.display:wJ.DISPLAY;if(D||!J||!Q)return!1;if(X==="linux"&&!Y)return!1;return!0}async function _F0($){if(!Q8$())return;try{await(await Promise.resolve().then(() => (BF(),HU))).default($)}catch(D){if(D?.code==="ENOENT")return}}function J1($){if(ZJ0($))return YJ0($);else if(GJ0($))return FJ0($);return $}function X8$($=J1(OD()),D=void 0){let J=D?.split(",")[0],Q=J??A$($,zD);if(!U1(Q)){let Y=J?`Package.json at ${Q} does not exist`:`No package.json found at ${Q}. Run this command from your project root (the folder that contains package.json), or pass --package-json <path> to point at it (for example in a monorepo).`;throw n0.error(Y),Error(Y)}let X=Y6(Q);return JSON.parse(X)}function RJ($=J1(OD()),D=void 0){return X8$($,D).version??""}function Y8$($){let D=$.replace("^","").replace("~","");if(_3(D))try{let J=o$(D);return b9(J)}catch{return D}return D}async function E4($,D=OD(),J){let Q=J?J.split(",").map((F)=>F.trim()).filter(Boolean):[],X=[],Y=(F)=>{let Z=EJ(F);if(!X.includes(Z))X.push(Z)};for(let F of Q){let Z=EJ(D,F);if(U1(Z))Y(AF(Z))}Y(EJ(D)),Y(OD());for(let F of X)try{let Z=`${$}/package.json`,{createRequire:G}=await import("node:module"),U=G(A$(F,"package.json")).resolve(Z),W=JSON.parse(Y6(U,"utf-8"));if(W.version)return W.version}catch{}for(let F of X){let Z=F,G=IF.parse(Z).root;while(Z!==G){let q=A$(Z,"node_modules",$,zD);if(U1(q))try{let W=JSON.parse(Y6(q,"utf-8"));if(W.version)return W.version}catch{}let U=AF(Z);if(U===Z)break;Z=U}}if($==="@capgo/capacitor-updater"){let F=null,Z=A$(D,"ios","App","Podfile");if(U1(Z))try{let q=Y6(Z,"utf-8").match(/pod\s+['"]CapgoCapacitorUpdater['"],\s*:path\s*=>\s*['"]([^'"]+)['"]/);if(q?.[1])F=EJ(A$(D,"ios","App",q[1]))}catch{}if(!F){let G=A$(D,"android","capacitor.settings.gradle");if(U1(G))try{let U=Y6(G,"utf-8").match(/project\(':capgo-capacitor-updater'\)\.projectDir\s*=\s*new\s+File\(['"]([^'"]+)['"]/);if(U?.[1])F=EJ(A$(D,"android",U[1])).replace(/\/android$/,"")}catch{}}if(F){let G=A$(F,zD);if(U1(G))try{let q=JSON.parse(Y6(G,"utf-8"));if(q.version)return q.version}catch{}}}try{let F=J?J.split(",").map((q)=>q.trim()).filter(Boolean).join(","):J,G=(await LL(D,F)).get($);if(G)return G}catch{}return null}async function LL($=J1(OD()),D=void 0){let J=D?.split(",").map((Y)=>Y.trim()).filter(Boolean);if(J??=[A$($,zD)],J){for(let Y of J)if(!U1(Y)){let F=`Package.json at ${Y} does not exist`;throw n0.error(F),Error(F)}}let Q=new Map,{createRequire:X}=await import("node:module");for(let Y of J){let F=Y6(Y),Z=JSON.parse(F),G=AF(Y),q=(U,W)=>{try{let z=X(A$(G,"package.json")).resolve(`${U}/package.json`),V=JSON.parse(Y6(z,"utf-8"));if(V.version)return V.version}catch{}let H=G,K=IF.parse(H).root;while(H!==K){let O=A$(H,"node_modules",U,zD);if(U1(O))try{let V=JSON.parse(Y6(O,"utf-8"));if(V.version)return V.version}catch{}let z=AF(H);if(z===H)break;H=z}return Y8$(W)};for(let U in Z.dependencies)Q.set(U,q(U,Z.dependencies[U]));for(let U in Z.devDependencies)Q.set(U,q(U,Z.devDependencies[U]))}return Q}async function F8$($=J1(OD()),D=void 0){let J=D?.split(",").map((X)=>X.trim()).filter(Boolean);if(J??=[A$($,zD)],J){for(let X of J)if(!U1(X)){let Y=`Package.json at ${X} does not exist`;throw n0.error(Y),Error(Y)}}let Q=new Map;for(let X of J){let Y=Y6(X),F=JSON.parse(Y);for(let Z in F.dependencies??{})if(typeof F.dependencies[Z]==="string")Q.set(Z,F.dependencies[Z]);for(let Z in F.devDependencies??{})if(typeof F.devDependencies[Z]==="string")Q.set(Z,F.devDependencies[Z])}return Q}function Z8$($){if(!$)return!1;if($.config&&Object.keys($.config).length>0)return!0;return!!$.path&&U1($.path)}async function vF0($,D=!1){let J=NL;try{let Q=await $();if(!Z8$(Q)){if(!D)n0.error(J);throw new J0(J)}return Q}catch(Q){if(Q instanceof J0)throw Q;let X=F0(Q);if(!D)n0.error(`${J}: ${X}`);throw new J0(J,{cause:X})}}function q$($=!1){return vF0(XT,$)}function V6($=!1){return vF0(YT,$)}async function G8$($,D){let J=await V6();if(J?.config)J.config.plugins??={},J.config.plugins.extConfig??={},J.config.plugins[$]??={},J.config.plugins[$]={...J.config.plugins[$],...D},await FT($,J);return J}async function xF0($){return G8$("CapacitorUpdater",$)}function zF0($,D){if(typeof D!=="string"||!D.trim())return;try{return wQ(D)}catch(J){throw new J0(`Invalid ${$} in capacitor config: ${J instanceof Error?J.message:String(J)}`)}}async function ZD($=!1){let D;try{D=await q$($)}catch{return VF0({host:OF0,hostWeb:hD,hostFilesApi:xx,hostApi:zU})}let J=zF0("localApi",D?.config?.plugins?.CapacitorUpdater?.localApi),Q=zF0("localApiFiles",D?.config?.plugins?.CapacitorUpdater?.localApiFiles),X={host:D?.config?.plugins?.CapacitorUpdater?.localHost||OF0,hostWeb:D?.config?.plugins?.CapacitorUpdater?.localWebHost||hD,hostFilesApi:Q??J??xx,hostApi:J??zU};if(!J&&D?.config?.plugins?.CapacitorUpdater?.localSupa&&!hx().apiHost&&!kx("CAPGO_API_HOST"))throw new J0("`localSupa` in capacitor.config is no longer supported. Set `localApi` to your Capgo API URL instead.");return VF0(X)}function U8$($){return{apiHost:$.apiHost?wQ($.apiHost):void 0,filesHost:$.filesHost?wQ($.filesHost):void 0}}function hx(){return kF0.getStore()??q8$}function ML($,D){return kF0.run(U8$($),D)}function kx($){let D=wJ[$]?.trim();return D?wQ(D):void 0}function VF0($){let D=hx(),J=D.apiHost??kx("CAPGO_API_HOST"),Q=D.filesHost??(D.apiHost?void 0:kx("CAPGO_FILES_HOST"));if(J)$.hostApi=J,$.hostFilesApi=J;if(Q)$.hostFilesApi=Q;return $}function LF0($){return typeof $==="object"&&$!==null}function W8$($){if(!LF0($))return!1;let D=$.capacitor;if(LF0(D)&&(D.ios!==void 0||D.android!==void 0))return!0;return!1}function H8$($){if(U1(A$($,"plugin.xml")))return!0;let D=A$($,zD);if(!U1(D))return!1;try{return W8$(JSON.parse(Y6(D,"utf-8")))}catch{return!1}}function fF0($,D){if(D)return D;return $===zU||$===xx?F5():void 0}async function CF($=!1,D,J){let Q=(q)=>{let U={...q};return Ri(U,void 0,$),U},X=await ZD($),Y=X.hostApi,F=NF0.get(Y);if(F)return Q(F);let Z=_x.get(Y);if(!D&&Z)return Z.then(Q);let G=(async()=>{try{let q=fF0(Y,J),U=await fetch(`${Y}/private/config`,{...D?{signal:D}:{},redirect:"
|
|
374
|
-
`)[0].trim()}async function EL($){let D=await b1($);if(D?.error==="channel_zip_required"||D?.error==="channel_delta_required")return D.message||D.error;let J=$ instanceof Error?$.message:String($??"");if(J.includes("CHANNEL_ZIP_REQUIRED"))return MF0(J,"CHANNEL_ZIP_REQUIRED");if(J.includes("CHANNEL_DELTA_REQUIRED"))return MF0(J,"CHANNEL_DELTA_REQUIRED");return null}function wQ($){let D=new URL($);if(!["http:","https:"].includes(D.protocol))throw new J0("Capgo API host must use HTTPS");let J=D.hostname==="localhost"||D.hostname==="127.0.0.1"||D.hostname==="[::1]";if(D.protocol==="http:"&&!J)throw new J0("Capgo API host must use HTTPS (HTTP is only allowed for localhost)");if(D.username||D.password)throw new J0("Capgo API host must not include credentials");if(D.search||D.hash)throw new J0("Capgo API host must not include query parameters or fragments");return`${D.origin}${b8(D.pathname)}`}async function gx($,D=!0,J){let Q=await ZD(D),X=$?wQ($):Q.hostApi,Y=J?wQ(J):$&&X!==Q.hostApi?X:Q.hostFilesApi;return{apiHost:X,filesHost:Y}}async function v1($){let D=await b1($);if(D){let J=BL(D);if(J)return J}return F0($)}async function I0($,D){let J=(D.method??"POST").toUpperCase(),Q=await gx(D.apiHost),X=D.useFilesHost?Q.filesHost:Q.apiHost,Y=`${b8(X)}/${$.replace(/^\//,"")}`,F=D.instrument!==!1&&Vi()?Ei($.replace(/^\//,"")):fetch;try{let Z=await F(Y,{method:J,redirect:"
|
|
373
|
+
`))}function d6({silent:$=!1,stdinIsTTY:D=!!AF0.isTTY,stdoutIsTTY:J=!!TF0.isTTY,ci:Q=yx.isCI}={}){return!$&&D&&J&&!Q}function Q8$($={}){let D=$.ci??yx.isCI,J=$.stdinIsTTY??!!AF0.isTTY,Q=$.stdoutIsTTY??!!TF0.isTTY,X=$.platform??wF0(),Y="display"in $?$.display:wJ.DISPLAY;if(D||!J||!Q)return!1;if(X==="linux"&&!Y)return!1;return!0}async function _F0($){if(!Q8$())return;try{await(await Promise.resolve().then(() => (BF(),HU))).default($)}catch(D){if(D?.code==="ENOENT")return}}function J1($){if(ZJ0($))return YJ0($);else if(GJ0($))return FJ0($);return $}function X8$($=J1(OD()),D=void 0){let J=D?.split(",")[0],Q=J??A$($,zD);if(!U1(Q)){let Y=J?`Package.json at ${Q} does not exist`:`No package.json found at ${Q}. Run this command from your project root (the folder that contains package.json), or pass --package-json <path> to point at it (for example in a monorepo).`;throw n0.error(Y),Error(Y)}let X=Y6(Q);return JSON.parse(X)}function RJ($=J1(OD()),D=void 0){return X8$($,D).version??""}function Y8$($){let D=$.replace("^","").replace("~","");if(_3(D))try{let J=o$(D);return b9(J)}catch{return D}return D}async function E4($,D=OD(),J){let Q=J?J.split(",").map((F)=>F.trim()).filter(Boolean):[],X=[],Y=(F)=>{let Z=EJ(F);if(!X.includes(Z))X.push(Z)};for(let F of Q){let Z=EJ(D,F);if(U1(Z))Y(AF(Z))}Y(EJ(D)),Y(OD());for(let F of X)try{let Z=`${$}/package.json`,{createRequire:G}=await import("node:module"),U=G(A$(F,"package.json")).resolve(Z),W=JSON.parse(Y6(U,"utf-8"));if(W.version)return W.version}catch{}for(let F of X){let Z=F,G=IF.parse(Z).root;while(Z!==G){let q=A$(Z,"node_modules",$,zD);if(U1(q))try{let W=JSON.parse(Y6(q,"utf-8"));if(W.version)return W.version}catch{}let U=AF(Z);if(U===Z)break;Z=U}}if($==="@capgo/capacitor-updater"){let F=null,Z=A$(D,"ios","App","Podfile");if(U1(Z))try{let q=Y6(Z,"utf-8").match(/pod\s+['"]CapgoCapacitorUpdater['"],\s*:path\s*=>\s*['"]([^'"]+)['"]/);if(q?.[1])F=EJ(A$(D,"ios","App",q[1]))}catch{}if(!F){let G=A$(D,"android","capacitor.settings.gradle");if(U1(G))try{let U=Y6(G,"utf-8").match(/project\(':capgo-capacitor-updater'\)\.projectDir\s*=\s*new\s+File\(['"]([^'"]+)['"]/);if(U?.[1])F=EJ(A$(D,"android",U[1])).replace(/\/android$/,"")}catch{}}if(F){let G=A$(F,zD);if(U1(G))try{let q=JSON.parse(Y6(G,"utf-8"));if(q.version)return q.version}catch{}}}try{let F=J?J.split(",").map((q)=>q.trim()).filter(Boolean).join(","):J,G=(await LL(D,F)).get($);if(G)return G}catch{}return null}async function LL($=J1(OD()),D=void 0){let J=D?.split(",").map((Y)=>Y.trim()).filter(Boolean);if(J??=[A$($,zD)],J){for(let Y of J)if(!U1(Y)){let F=`Package.json at ${Y} does not exist`;throw n0.error(F),Error(F)}}let Q=new Map,{createRequire:X}=await import("node:module");for(let Y of J){let F=Y6(Y),Z=JSON.parse(F),G=AF(Y),q=(U,W)=>{try{let z=X(A$(G,"package.json")).resolve(`${U}/package.json`),V=JSON.parse(Y6(z,"utf-8"));if(V.version)return V.version}catch{}let H=G,K=IF.parse(H).root;while(H!==K){let O=A$(H,"node_modules",U,zD);if(U1(O))try{let V=JSON.parse(Y6(O,"utf-8"));if(V.version)return V.version}catch{}let z=AF(H);if(z===H)break;H=z}return Y8$(W)};for(let U in Z.dependencies)Q.set(U,q(U,Z.dependencies[U]));for(let U in Z.devDependencies)Q.set(U,q(U,Z.devDependencies[U]))}return Q}async function F8$($=J1(OD()),D=void 0){let J=D?.split(",").map((X)=>X.trim()).filter(Boolean);if(J??=[A$($,zD)],J){for(let X of J)if(!U1(X)){let Y=`Package.json at ${X} does not exist`;throw n0.error(Y),Error(Y)}}let Q=new Map;for(let X of J){let Y=Y6(X),F=JSON.parse(Y);for(let Z in F.dependencies??{})if(typeof F.dependencies[Z]==="string")Q.set(Z,F.dependencies[Z]);for(let Z in F.devDependencies??{})if(typeof F.devDependencies[Z]==="string")Q.set(Z,F.devDependencies[Z])}return Q}function Z8$($){if(!$)return!1;if($.config&&Object.keys($.config).length>0)return!0;return!!$.path&&U1($.path)}async function vF0($,D=!1){let J=NL;try{let Q=await $();if(!Z8$(Q)){if(!D)n0.error(J);throw new J0(J)}return Q}catch(Q){if(Q instanceof J0)throw Q;let X=F0(Q);if(!D)n0.error(`${J}: ${X}`);throw new J0(J,{cause:X})}}function q$($=!1){return vF0(XT,$)}function V6($=!1){return vF0(YT,$)}async function G8$($,D){let J=await V6();if(J?.config)J.config.plugins??={},J.config.plugins.extConfig??={},J.config.plugins[$]??={},J.config.plugins[$]={...J.config.plugins[$],...D},await FT($,J);return J}async function xF0($){return G8$("CapacitorUpdater",$)}function zF0($,D){if(typeof D!=="string"||!D.trim())return;try{return wQ(D)}catch(J){throw new J0(`Invalid ${$} in capacitor config: ${J instanceof Error?J.message:String(J)}`)}}async function ZD($=!1){let D;try{D=await q$($)}catch{return VF0({host:OF0,hostWeb:hD,hostFilesApi:xx,hostApi:zU})}let J=zF0("localApi",D?.config?.plugins?.CapacitorUpdater?.localApi),Q=zF0("localApiFiles",D?.config?.plugins?.CapacitorUpdater?.localApiFiles),X={host:D?.config?.plugins?.CapacitorUpdater?.localHost||OF0,hostWeb:D?.config?.plugins?.CapacitorUpdater?.localWebHost||hD,hostFilesApi:Q??J??xx,hostApi:J??zU};if(!J&&D?.config?.plugins?.CapacitorUpdater?.localSupa&&!hx().apiHost&&!kx("CAPGO_API_HOST"))throw new J0("`localSupa` in capacitor.config is no longer supported. Set `localApi` to your Capgo API URL instead.");return VF0(X)}function U8$($){return{apiHost:$.apiHost?wQ($.apiHost):void 0,filesHost:$.filesHost?wQ($.filesHost):void 0}}function hx(){return kF0.getStore()??q8$}function ML($,D){return kF0.run(U8$($),D)}function kx($){let D=wJ[$]?.trim();return D?wQ(D):void 0}function VF0($){let D=hx(),J=D.apiHost??kx("CAPGO_API_HOST"),Q=D.filesHost??(D.apiHost?void 0:kx("CAPGO_FILES_HOST"));if(J)$.hostApi=J,$.hostFilesApi=J;if(Q)$.hostFilesApi=Q;return $}function LF0($){return typeof $==="object"&&$!==null}function W8$($){if(!LF0($))return!1;let D=$.capacitor;if(LF0(D)&&(D.ios!==void 0||D.android!==void 0))return!0;return!1}function H8$($){if(U1(A$($,"plugin.xml")))return!0;let D=A$($,zD);if(!U1(D))return!1;try{return W8$(JSON.parse(Y6(D,"utf-8")))}catch{return!1}}function fF0($,D){if(D)return D;return $===zU||$===xx?F5():void 0}async function CF($=!1,D,J){let Q=(q)=>{let U={...q};return Ri(U,void 0,$),U},X=await ZD($),Y=X.hostApi,F=NF0.get(Y);if(F)return Q(F);let Z=_x.get(Y);if(!D&&Z)return Z.then(Q);let G=(async()=>{try{let q=fF0(Y,J),U=await fetch(`${Y}/private/config`,{...D?{signal:D}:{},redirect:"manual",headers:i$(q?{capgkey:q}:void 0)});if(!U.ok)throw Error(`HTTP error! status: ${U.status}`);let H={...await U.json(),...X};return NF0.set(Y,H),{...H}}catch{if(!$)n0.info(`Local config ${F0(X)}`);return{...X}}finally{if(!D)_x.delete(Y)}})();if(!D)_x.set(Y,G);return G.then(Q)}async function yF0($){let D=await ZD();try{let J=fF0(D.hostFilesApi,$),Q=await fetch(`${D.hostFilesApi}/files/config`,{redirect:"manual",headers:i$(J?{capgkey:J}:void 0)});if(!Q.ok)throw Error(`HTTP error! status: ${Q.status}`);return await Q.json()}catch{return{partialUpload:!1,TUSUpload:!1,partialUploadForced:!1,TUSUploadForced:!1,maxUploadLength:eD$,maxChunkSize:$8$,alertUploadSize:sD$}}}function BL($){if(!$||typeof $!=="object")return"";let D=$;return[D.error,D.message,D.status].filter(Boolean).join(" | ")}function MF0($,D){let J=$.indexOf(D);if(J<0)return $;return $.slice(J+D.length).replace(/^:\s*/,"").split(`
|
|
374
|
+
`)[0].trim()}async function EL($){let D=await b1($);if(D?.error==="channel_zip_required"||D?.error==="channel_delta_required")return D.message||D.error;let J=$ instanceof Error?$.message:String($??"");if(J.includes("CHANNEL_ZIP_REQUIRED"))return MF0(J,"CHANNEL_ZIP_REQUIRED");if(J.includes("CHANNEL_DELTA_REQUIRED"))return MF0(J,"CHANNEL_DELTA_REQUIRED");return null}function wQ($){let D=new URL($);if(!["http:","https:"].includes(D.protocol))throw new J0("Capgo API host must use HTTPS");let J=D.hostname==="localhost"||D.hostname==="127.0.0.1"||D.hostname==="[::1]";if(D.protocol==="http:"&&!J)throw new J0("Capgo API host must use HTTPS (HTTP is only allowed for localhost)");if(D.username||D.password)throw new J0("Capgo API host must not include credentials");if(D.search||D.hash)throw new J0("Capgo API host must not include query parameters or fragments");return`${D.origin}${b8(D.pathname)}`}async function gx($,D=!0,J){let Q=await ZD(D),X=$?wQ($):Q.hostApi,Y=J?wQ(J):$&&X!==Q.hostApi?X:Q.hostFilesApi;return{apiHost:X,filesHost:Y}}async function v1($){let D=await b1($);if(D){let J=BL(D);if(J)return J}return F0($)}async function I0($,D){let J=(D.method??"POST").toUpperCase(),Q=await gx(D.apiHost),X=D.useFilesHost?Q.filesHost:Q.apiHost,Y=`${b8(X)}/${$.replace(/^\//,"")}`,F=D.instrument!==!1&&Vi()?Ei($.replace(/^\//,"")):fetch;try{let Z=await F(Y,{method:J,redirect:"manual",headers:i$({"Content-Type":"application/json",Authorization:D.apikey,capgkey:D.apikey,...D.apiVersion?{capgo_api:D.apiVersion}:{}}),body:J==="GET"||J==="HEAD"?void 0:typeof D.body==="string"?D.body:JSON.stringify(D.body??{}),signal:D.signal});if(!Z.ok)return{data:null,error:new tX(Z)};return{data:(Z.headers.get("content-type")??"").includes("application/json")?await Z.json().catch(()=>null):await Z.text().catch(()=>null),error:null}}catch(Z){return{data:null,error:Z instanceof Error?Z:Error(String(Z))}}}async function LU($,D=!0){return(await gx($?.apiHost,D)).apiHost}async function F$($,D,J=!1,Q,X){let Y=qE("capgkey",$),F=async()=>{await CF(J,Q,Y);let q=await gx(void 0,J);if(D&&!J)n0.info(`Using custom Capgo API ${q.apiHost}`);return{apikey:Y,...q}};if(!D&&!X)return F();let Z=hx(),G=D?wQ(D):Z.apiHost;return ML({apiHost:G,filesHost:X??(G===Z.apiHost?Z.filesHost:void 0)},F)}async function wL($,D,J={}){let{data:Q,error:X}=await I0(`private/cli/members/2fa-status?org_id=${encodeURIComponent(D)}`,{apikey:$,method:"GET",body:void 0,apiHost:J.apiHost});if(X)throw X;return Q??[]}async function RL($,D,J={}){let{data:Q,error:X}=await I0(`private/cli/members/password-policy?org_id=${encodeURIComponent(D)}`,{apikey:$,method:"GET",body:void 0,apiHost:J.apiHost});if(X)throw X;return Q??[]}function WL($){try{if(!U1($))return;return Y6($,"utf8").trim()||void 0}catch{return}}function F5(){let $=wJ.CAPGO_TOKEN?.trim();if($)return $;let D=WL(`${EF0()}/.capgo`);if(D)return D;return WL(".capgo")}function A0($=!1,D=(J)=>n0.info(J)){let J=wJ.CAPGO_TOKEN?.trim();if(J){if(!$)D("Use CAPGO_TOKEN environment variable");return J}let X=`${EF0()}/.capgo`,Y=WL(X);if(Y){if(!$)D(`Use global API key ${X}`)}else if(X=".capgo",Y=WL(X),Y&&!$)D(`Use local API key ${X}`);if(!Y){let Z=`No Capgo API key found. Run \`${NJ0()}\` first, then retry this command.`;throw n0.error(Z),new J0(Z)}return Y}async function*bF0($){let D=await TF($,{withFileTypes:!0});for(let J of D){let Q=EJ($,J.name);if(J.isDirectory()&&!J.name.startsWith(".")&&!J.name.startsWith("node_modules")&&!J.name.startsWith("dist"))yield*bF0(Q);else yield Q}}function AQ($){let J=($.endsWith(".br")?$.slice(0,-3):$).split(".").pop()?.toLowerCase()||"";return{html:"text/html",htm:"text/html",js:"application/javascript",mjs:"application/javascript",cjs:"application/javascript",css:"text/css",json:"application/json",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",bmp:"image/bmp",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",mp4:"video/mp4",webm:"video/webm",xml:"application/xml",txt:"text/plain",md:"text/markdown",pdf:"application/pdf",wasm:"application/wasm",map:"application/json"}[J]||"application/octet-stream"}async function hF0($=!1,D=OD()){let J=/(main|index)\.(ts|tsx|js|jsx)$/,Q="",X=EJ(D),Y=X.split("/").length;for await(let F of bF0(X))if(F.split("/").length-Y<=2&&J.test(F)){if(Q=F,!$)n0.info(`Found main file here ${F}`);break}return Q}async function gF0($,D,J,Q){let X={app_id:D,name:J,version:0};try{let Y=await I0("files/upload_link",{apikey:$,body:X,useFilesHost:!0,apiHost:Q?.apiHost});if(Y.error){if(Y.error instanceof tX){let F=await Y.error.context.json().catch(()=>({}));n0.error(`Upload URL error: ${F.status||JSON.stringify(F)}`)}else n0.error(`Cannot get upload url: ${Y.error.message}`);return""}return Y.data?.url??""}catch(Y){n0.error(`Cannot get upload url ${F0(Y)}`)}return""}async function*mF0($){let D=TF($,{withFileTypes:!0});for(let J of D){let Q=A$($,J.name);if(J.isDirectory())yield*mF0(Q);else yield Q}}function gD($,D="5.10.0",J="6.25.0",Q="7.25.0"){if($.major===5&&U7($,o$(D)))return!0;if($.major===6&&U7($,o$(J)))return!0;if($.major===7&&U7($,o$(Q)))return!0;return!1}async function TL($){let D=[],J=[".DS_Store",".git",".gitignore","node_modules","package-lock.json","tsconfig.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json","tsconfig.app.json","tsconfig.spec.json"];for await(let Q of mF0($)){if(J.some((Z)=>Q.includes(Z))){n0.info(`Ignoring file ${Q}, please ensure you have only required files in your dist folder`);continue}let X=Y6(Q);if(X.length===0){n0.info(`Ignoring empty file ${Q}, please ensure you have only required files in your dist folder`);continue}let Y=await XJ(X,"sha256"),F=RF0($,Q);if(F.startsWith("/"))F=F.substring(1);D.push({file:F,hash:Y})}return D}async function IL($){if(wF0()==="win32")return O8$($);else return K8$($)}function K8$($){let D=new fx.default;return D.addLocalFolder($),D.toBuffer()}async function O8$($){n0.info("Zipping file windows mode");let D=new fx.default,J=(Q,X)=>{let Y=TF(Q);for(let F of Y){let Z=A$(Q,F),G=aD$(Z);if(G.isFile()){let q=Y6(Z);D.addFile(A$(X,F).split(jF0).join("/"),q)}else if(G.isDirectory())J(Z,A$(X,F))}};return J($,""),D.toBuffer()}function MU($){let D=RQ();return`App ${$} does not exist, run first \`${D.runner} @capgo/cli app add ${$}\` to create it`}function mx($){let J=$?.originalResponse?.getBody?.(),Q=$ instanceof Error?$.message:String($??"");return`${J??""} ${Q}`.includes("app_not_found")}async function dF0($,D,J,Q,X,Y,F,Z){return new Promise((G,q)=>{e0($,{channel:"app",event:"App TUS upload",org_id:J,tracking_version:2,tags:{"app-id":Q}}),new HL.Upload(D,{endpoint:`${F.hostFilesApi}/files/upload/attachments/`,chunkSize:Z,retryDelays:[...PF],metadataForPartialUploads:{filename:`orgs/${J}/apps/${Q}/${X}.zip`,filetype:"application/gzip"},metadata:{filename:`orgs/${J}/apps/${Q}/${X}.zip`,filetype:"application/zip"},headers:i$({Authorization:$}),onError(W){if(n0.error(`Error uploading bundle: ${W.message}`),mx(W)){q(Error(MU(Q)));return}if(W instanceof HL.DetailedError){let H=W.originalResponse?.getBody(),K=W.originalResponse?.getStatus(),O=W.originalRequest?.getURL(),z=(()=>{try{let V=JSON.parse(H||'{"error": "unknown error"}');return V.status||V.error||V.message||"unknown error"}catch{return H||W.message}})();q(Error(`TUS upload failed (status ${K??"unknown"}, url ${O??"unknown"}): ${z}`))}else q(Error(`TUS upload failed: ${W.message||W.toString()}`))},onProgress(W,H){let K=(W/H*100).toFixed(2);Y.message(`Uploaded ${K}%`)},async onSuccess(){await e0($,{channel:"app",event:"App TUS done",org_id:J,tracking_version:2,tags:{"app-id":Q}}).catch(),G(!0)}}).start()})}async function _F($,D,J,Q){let Y=await I0("private/delete_failed_version",{apikey:$,method:"DELETE",body:{app_id:D,name:J},apiHost:Q?.apiHost});if(Y.error){if(Y.error instanceof tX){let F=await Y.error.context.json().catch(()=>({}));throw Error(F.status||F.message||JSON.stringify(F))}throw Error(Y.error.message)}}async function cF0($,D,J,Q,X){let Y={app_id:D,name:J,manifest:Q},F=await _5(()=>I0("private/set_manifest",{apikey:$,body:Y,apiHost:X?.apiHost}));if(F.error){if(F.error instanceof tX){let Z=await F.error.context.json().catch(()=>({}));throw Error(Z.error||Z.status||Z.message||JSON.stringify(Z))}throw Error(F.error.message)}}async function e0($,D,J,Q,X,Y){let F=Date.now();if((C5(wJ.CAPGO_DISABLE_TELEMETRY)||C5(wJ.CAPGO_DISABLE_POSTHOG))&&!D.notifyConsole)return;try{let G={};try{G=qR()}catch(O){if(J)n0.error(`Failed to enrich event tags, sending caller tags only: ${F0(O)}`)}let q={...D,nonPersonTags:{...G,...D.nonPersonTags??{}}};if(J)n0.info(`Get remove config: for ${D.event}`);let U=X??(await CF(!0,Q)).hostApi;if(J)n0.info(`Sending analytics event: ${JSON.stringify(q)}`);let W=new AbortController,H=setTimeout(()=>W.abort(),1e4),K=Q?typeof AbortSignal.any==="function"?AbortSignal.any([W.signal,Q]):Q:W.signal;try{zX("telemetry request started");let O=await fetch(`${b8(U)}/private/events`,{method:"POST",body:JSON.stringify(q),headers:i$({"Content-Type":"application/json",capgkey:$}),signal:K,redirect:Y});if(zX("telemetry response received",{duration_ms:Date.now()-F,status:O.status}),clearTimeout(H),!O.ok)throw Error(`HTTP error! status: ${O.status}`);let z=await O.json();if(z.error&&J)n0.error(`Failed to send analytics event: ${z.error}`)}finally{clearTimeout(H)}}catch(G){if(zX("telemetry request failed",{duration_ms:Date.now()-F,error:Ig(G)}),J)n0.error("Failed to send Stats event details:"),n0.error(F0(G))}}function dx($){if(n0.error(`
|
|
375
375
|
\uD83D\uDD10 Access Denied: Two-Factor Authentication Required`),n0.error("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"),$)n0.error(`
|
|
376
376
|
The organization "${$}" requires all members to have 2FA enabled.`);else n0.error(`
|
|
377
377
|
This organization requires all members to have 2FA enabled.`);throw n0.error(`
|
|
@@ -675,7 +675,7 @@ ${fj$}
|
|
|
675
675
|
|
|
676
676
|
Docs: ${tb}`);let F=await C$({message:"Have you added notifyAppReady() and rebuilt your app?"});if(i0(F)||!F)continue;if(U8(D,"notifyAppReady"))return $$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"manual"}}),"recovered";T.warn("notifyAppReady() is still missing in the build folder. Rebuild, or choose another option.");continue}if(Y==="skip"){T.warn("Skipping notifyAppReady check. Without this call, Capgo may roll back downloaded updates."),T.warn(`Learn more: ${tb}`);let F=await C$({message:"Continue without notifyAppReady()?",initialValue:!1});if(i0(F)||!F)continue;return $$({channel:"bundle",event:"CLI Skipped NotifyAppReady Check",tags:{}}),"skipped"}if(Y==="patch-build"){let F=lj$(D);if(!F){T.warn("Could not patch the build folder automatically. The app bundle must already include CapacitorUpdater, or patch the source and rebuild.");continue}if(!U8(D,"notifyAppReady")){T.warn(`Patched ${F}, but notifyAppReady() is still missing. Try another option.`);continue}return T.success(`Added notifyAppReady() to ${F}`),$$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"patch-build"}}),"recovered"}if(Y==="patch-source")try{let F=await nj$(J1(sb()));if(!F){T.warn("Could not find your app entry file automatically.");continue}T.success(`Added notifyAppReady() to ${F}`),T.info("Rebuild your web assets, then retry zip/upload.");let Z=await C$({message:"Have you rebuilt your app into the build folder?"});if(i0(Z)||!Z)continue;if(U8(D,"notifyAppReady"))return $$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"patch-source"}}),"recovered";T.warn("notifyAppReady() is still missing in the build folder after rebuild.")}catch(F){T.error(F0(F))}}}r0();import Yw0 from"node:process";var ij$={info:($)=>T.info($),spinner:y1},pj$=[{code:"aws:eu-central-1",label:"EU (Frankfurt)"},{code:"gcp:me-central1",label:"Middle East (Riyadh)"},{code:"gcp:asia-east2",label:"Hong Kong"},{code:"aws:ap-northeast-1",label:"Japan (Tokyo)"},{code:"aws:ap-south-1",label:"India (Mumbai)"},{code:"aws:us-east-1",label:"North America (Virginia)"},{code:"gcp:africa-south1",label:"Africa (South Africa)"},{code:"aws:ap-southeast-2",label:"Oceania (Sydney)"},{code:"aws:sa-east-1",label:"South America (São Paulo)"}],rj$=60000,oj$=1000,Fw0=20;function tj$(){if(typeof Intl>"u")return null;return Intl.DateTimeFormat().resolvedOptions().timeZone||null}function aj$(){let $=tj$();if(!$)return null;if(/^America\//.test($))return"aws:us-east-1";if(/^Europe\//.test($)||/^Atlantic\//.test($))return"aws:eu-central-1";if(/^Africa\//.test($))return"gcp:africa-south1";if(/^Asia\//.test($)){let D=($.split("/")[1]??"").toLowerCase();if(["tokyo","osaka","seoul","pyongyang"].includes(D))return"aws:ap-northeast-1";if(["kolkata","mumbai","calcutta","chennai","bangalore","hyderabad","delhi","dhaka","colombo","karachi"].includes(D))return"aws:ap-south-1";if(["hong_kong","singapore","manila","jakarta","kuala_lumpur","beijing","shanghai","hongkong","taipei"].includes(D))return"gcp:asia-east2";if(["sydney","melbourne","canberra","perth","brisbane","darwin","adelaide"].includes(D))return"aws:ap-southeast-2";return"gcp:asia-east2"}if(/^Pacific\//.test($)||/^Australia\//.test($))return"aws:ap-southeast-2";return null}function sj$(){let $=[...pj$],D=aj$();if(!D)return $;let J=$.findIndex((X)=>X.code===D);if(J<0)return $;let[Q]=$.splice(J,1);return $.push(Q),$}function ej$($,D,J){let Q=Math.min(Math.max($,0),J);return Math.floor(Q/J*D)}function $A$($){let D=Math.min(Math.max($,0),100),J=Math.round(D/100*Fw0);return`${"█".repeat(J)}${"░".repeat(Fw0-J)}`}function DA$($){return`${Math.max(0,$)}s`}function Zw0({interactive:$=Yw0.stdout.isTTY&&Yw0.stderr.isTTY,totalMs:D=rj$,updateIntervalMs:J=oj$,title:Q="Replicating your bundle in all regions...",completeMessage:X="Your update is now available worldwide.",reporter:Y}={}){if(!$||D<=0)return Promise.resolve();let F=sj$();if(!F.length)return Promise.resolve();let Z=Y??ij$;Z.info(Q),Z.info(`Regions: ${F.map((H)=>H.label).join(" • ")}`);let G=Z.spinner(),q=Date.now(),U=F.length,W=null;return new Promise((H)=>{let K=()=>{let O=Date.now()-q,z=Math.max(0,D-O),V=ej$(O,U,D),M=Math.min(100,Math.round(O/D*100)),E=$A$(M),L=V<U?F[V]?.label||"Finalizing":"Complete",N=`${V}/${U} regions updated • ${DA$(Math.ceil(z/1000))} left • ${E} • Next: ${L}`;G.message(N)};G.start(Q),K(),W=setInterval(K,J),setTimeout(()=>{if(W)clearInterval(W);G.stop(X),H()},D)})}W$();wF();function Gw0($){let D=$?.autoUpdate;if(D==="always")return!0;if(typeof D==="string"||D===!1)return!1;let J=$?.directUpdate;return J===!0||J==="always"}f0();r0();H8();var JA$=new Set(["major","minor","patch","metadata"]);function HH($){if($===void 0||$===null||$===!1)return;if($===!0)return"minor";let D=String($).trim().toLowerCase();if(D==="fix")return"patch";if(D==="ai")return"ai";if(JA$.has(D))return D;return}function QA$($){if($==="metadata"||$==="prerelease")return"prerelease";return $}function XA$($,D){let J=$.match(/^(\d+)\.(\d+)\.(\d+)(.*)?$/);if(!J){if(D==="major")return"1.0.0";if(D==="minor")return"0.1.0";if(D==="prerelease")return"1.0.1-0";return"1.0.1"}let Q=Number.parseInt(J[1],10),X=Number.parseInt(J[2],10),Y=Number.parseInt(J[3],10),F=J[4]??"";if(D==="major")return`${Q+1}.0.0`;if(D==="minor")return`${Q}.${X+1}.0`;if(D==="patch")return`${Q}.${X}.${Y+1}`;let Z=F.match(/^-([A-Za-z0-9.-]*?)(\d+)?$/);if(Z){let G=Z[1]??"",q=Z[2]!==void 0?Number.parseInt(Z[2],10)+1:0;if(G.endsWith(".")||G==="")return`${Q}.${X}.${Y}-${G}${q}`;return`${Q}.${X}.${Y}-${G}${G?".":""}${q}`}return`${Q}.${X}.${Y+1}-0`}function fB($,D="minor"){let J=QA$(D);try{let Q=o$($);return b9(P3(Q,J))}catch{return XA$($,J)}}function qw0($){return fB($,"patch")}async function Uw0($,D){let J=qw0($),Q=D?` for ${D}`:"",X=await z1({message:`How do you want to handle the version${Q}?`,options:[{value:"auto",label:`Auto: Bump patch version (${$} → ${J})`},{value:"manual",label:"Manual: I'll provide the version number"}]});if(i0(X))return null;if(X==="auto")return T.info(`\uD83D\uDD22 Auto-bumped version from ${$} to ${J}`),J;let Y=await F4({message:`Current version is ${$}. Enter new version:`,validate:(F)=>{if(!F)return"Version is required";if(!/^\d+\.\d+\.\d+/.test(F))return"Please enter a valid version (x.y.z)"}});if(i0(Y))return null;return Y}function Ww0($){let D=qw0($);try{let J=o$($);return[D,b9(P3(J,"minor")),`${$}-beta.1`,`${$}.1`]}catch{return[D,`${$}.1`,`${$}-beta.1`,`${$}-rc.1`]}}r0();Y5();f0();var $h=100;function YA$($,D){let J=new Map(D.map((Z)=>[Z.file,Z.hash])),Q=new Map($.map((Z)=>[Z.file,Z.hash])),X=[],Y=[],F=[];for(let[Z,G]of Q){let q=J.get(Z);if(q===void 0)X.push(Z);else if(q!==G)F.push(Z)}for(let[Z]of J)if(!Q.has(Z))Y.push(Z);return{added:X,removed:Y,changed:F,counts:{added:X.length,removed:Y.length,changed:F.length}}}function FA$($){return{added:$.added.slice(0,$h),removed:$.removed.slice(0,$h),changed:$.changed.slice(0,$h),counts:$.counts}}async function ZA$($,D){let J;try{J=await FF0($,D)}catch(Q){throw Error(`Cannot fetch remote manifest: ${F0(Q)}`)}return J.filter((Q)=>Q.file_name&&Q.file_hash).map((Q)=>({file:Q.file_name,hash:Q.file_hash}))}async function GA$($,D,J){let Q=J[0];if(Q){let Y=(await G9($,D,Q).catch(()=>[]))[0]?.version_info;if(Y&&!Y.deleted&&Y.id&&Y.name)return{name:Y.name,id:Y.id}}try{return await JL($,D)}catch(X){return T.warn(`Cannot fetch latest remote version for AI auto-bump: ${F0(X)}`),null}}async function qA$($){let{data:D,error:J}=await I0("bundle/ai_bump_level",{apikey:$.apikey,body:{appId:$.appId,baseVersion:$.baseVersion,manifestDiff:FA$($.manifestDiff),nativeCompatibility:$.nativeCompatibility},apiHost:$.apiHost});if(J)throw J;let Q=typeof D?.level==="string"?D.level.trim().toLowerCase():"",X=typeof D?.reason==="string"?D.reason.trim():"";if(!["major","minor","patch","metadata"].includes(Q)||!X)throw Error("AI bump endpoint returned an invalid response");return{level:Q,reason:X}}async function Hw0($){let D=await GA$($.client,$.appid,$.channels);if(!D)return{level:"patch",reason:"No previous Capgo version; defaulting to patch bump without AI."};try{let J=await TL($.path),Q=await ZA$($.client,D.id),X=YA$(J,Q);return await qA$({apikey:$.apikey,appId:$.appid,baseVersion:D.name,manifestDiff:X,apiHost:$.options?.apiHost})}catch(J){return{level:"minor",reason:`AI unavailable (${J instanceof Error?J.message:String(J)}); falling back to minor.`}}}r0();BF();m1();function UA$($){if(!$.incompatible)return"skip";if(!$.interactive)return"ci-ad";return $.hasCredentials?"prompt-build":"prompt-onboarding"}function Kw0($){if(!$.incompatible||!$.failOnIncompatible)return!1;if(!$.interactive)return!0;return $.builderAction==="continue"}var WA$="https://capgo.app/docs/cli/cloud-build/",Dh="https://capgo.app/native-build/",Ow0="This update includes native changes. An app store update may be required for these changes to take effect. Capgo Builder can help you build and publish the required native update.";function HA$($){let D=$?"run a native build (npx @capgo/cli build request --platform <ios|android>)":"set up Capgo Builder (npx @capgo/cli build onboarding)";T.warn(`${Ow0} To ${D} — learn more: ${Dh} · docs: ${WA$}`)}async function zw0($){try{return await KA$($)}catch{return"continue"}}async function KA$($){let{hasCredentials:D}=$,J=UA$({incompatible:$.incompatible,interactive:$.interactive,hasCredentials:D});if(J==="skip")return"continue";let Q=D?"build":"onboarding";if($$({channel:"bundle",event:"Builder CTA Shown",apikey:$.apikey,appId:$.appId,orgId:$.orgId,tags:{surface:J==="ci-ad"?"ci":"interactive",mode:Q,incompatible_count:$.incompatibleCount}}),J==="ci-ad")return HA$(D),"continue";T.info(Ow0);let X=$.select??((Z)=>z1(Z)),Y=$.openUrl??zx,F=Q==="build"?"Start a native build with Capgo Builder now?":"Would you like to configure Capgo Builder now?";while(!0){let Z=await X({message:F,initialValue:"yes",options:[{value:"yes",label:"✅ Yes"},{value:"no",label:"❌ No"},{value:"learn",label:"\uD83D\uDCD6 Learn what Capgo Builder is"}]});if(i0(Z))return"abort";if(Z==="learn"){$$({channel:"bundle",event:"Builder CTA Learn Selected",apikey:$.apikey,appId:$.appId,orgId:$.orgId,tags:{mode:Q}});try{await Y(Dh)}catch{T.warn(`Could not open your browser automatically. Visit: ${Dh}`)}continue}if(Z==="yes")return $$({channel:"bundle",event:"Builder CTA Accepted",apikey:$.apikey,appId:$.appId,orgId:$.orgId,tags:{mode:Q}}),Q==="build"?"launch-build":"launch-onboarding";return $$({channel:"bundle",event:"Builder CTA Declined",apikey:$.apikey,appId:$.appId,orgId:$.orgId,tags:{mode:Q}}),"continue"}}W$();A3();f0();v7();var bB=1;function hB($,D){return $?D?"rsa_v3_hex":"rsa_v2_base64":"sha256_hex"}function Nw0($,D){return!$&&D}var OA$=/^[!#$%&'*+\-.^\w`|~]+$/,Vw0=new Set(["upload_if_doesnt_exist","reuse","upload"]),zA$=2048;function Mw0($){for(let D=0;D<$.length;D++){let J=$.charCodeAt(D);if(J<=31||J===127)return!0}return!1}function Bw0($){for(let D=0;D<$.length;D++){let J=$.charCodeAt(D);if(J<=31||J===127||J>255)return!0}return!1}function yB($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function P$($){throw new J0(`Invalid manifest upload authorization response: ${$}`)}function Lw0($,D,J=!1){if(typeof $!=="string")P$(`${D} must be a URL`);let Q;try{Q=new URL($)}catch{P$(`${D} must be a valid absolute URL`)}let X=Q.protocol==="http:"&&(Q.hostname==="localhost"||Q.hostname==="127.0.0.1"||Q.hostname==="[::1]");if(Q.protocol!=="https:"&&!X)P$(`${D} must use HTTPS`);if(Q.username||Q.password||Q.hash)P$(`${D} contains unsupported URL components`);if(J&&!$.endsWith("/"))P$(`${D} must end with /`);return $}function VA$($){if(!$||$.length>zA$||$.startsWith("/")||$.includes("\\")||Mw0($))return!1;let D=$.split("/");return D.length>=5&&D[0]==="orgs"&&!!D[1]&&D[2]==="apps"&&!!D[3]&&D.slice(4).every((J)=>!!J&&J!=="."&&J!=="..")}function LA$($,D){if(!yB($))P$(`upload_targets[${D}] must be an object`);if(typeof $.id!=="string"||!$.id||Mw0($.id))P$(`upload_targets[${D}].id must be a nonempty string`);if($.protocol!=="tus")P$(`upload target ${$.id} uses an unsupported protocol`);if(!yB($.authorization)||$.authorization.type!=="header")P$(`upload target ${$.id} uses unsupported authorization`);let J=$.authorization.header_name,Q=$.authorization.token_prefix,X=$.authorization.expires_at;if(typeof J!=="string"||!OA$.test(J))P$(`upload target ${$.id} has an invalid authorization header name`);if(typeof Q!=="string"||Bw0(Q))P$(`upload target ${$.id} has an invalid authorization token prefix`);if(typeof X!=="number"||!Number.isSafeInteger(X)||X<=0)P$(`upload target ${$.id} has an invalid expiration`);return{id:$.id,protocol:"tus",upload_url:Lw0($.upload_url,`upload target ${$.id} upload_url`),existence_check_url_prefix:Lw0($.existence_check_url_prefix,`upload target ${$.id} existence_check_url_prefix`,!0),authorization:{type:"header",header_name:J,token_prefix:Q,expires_at:X}}}function NA$($,D){if(!yB(D))P$("body must be an object");if(D.protocol_version!==$.protocol_version)P$("protocol_version does not match the request");if(D.version_id!==$.version_id)P$("version_id does not match the request");if(!Vw0.has(D.default_action))P$("default_action is invalid");if(D.default_s3_path_prefix!==void 0&&typeof D.default_s3_path_prefix!=="string")P$("default_s3_path_prefix must be a string");if(D.default_upload_target!==void 0&&typeof D.default_upload_target!=="string")P$("default_upload_target must be a string");if(!Array.isArray(D.upload_targets))P$("upload_targets must be an array");if(!Array.isArray(D.entries))P$("entries must be an array");let J=new Map;for(let[G,q]of D.upload_targets.entries()){let U=LA$(q,G);if(J.has(U.id))P$(`upload target ${U.id} is duplicated`);J.set(U.id,U)}if(typeof D.default_upload_target==="string"&&!J.has(D.default_upload_target))P$("default_upload_target references an unknown upload target");let Q=new Map($.entries.map((G)=>[G.id,G]));if(Q.size!==$.entries.length)P$("request contains duplicate entry ids");let X=new Set,Y=new Set,F=new Map;for(let[G,q]of D.entries.entries()){if(!yB(q))P$(`entries[${G}] must be an object`);let U=q.id;if(typeof U!=="number"||!Number.isSafeInteger(U)||!Q.has(U))P$(`entries[${G}].id is unknown`);if(X.has(U))P$(`entry id ${U} is duplicated`);X.add(U);let W=q.action??D.default_action;if(!Vw0.has(W))P$(`entry id ${U} has an invalid action`);if(q.s3_path!==void 0&&typeof q.s3_path!=="string")P$(`entry id ${U} has an invalid s3_path`);if(q.s3_path_suffix!==void 0&&typeof q.s3_path_suffix!=="string")P$(`entry id ${U} has an invalid s3_path_suffix`);let H=typeof q.s3_path==="string",K=typeof q.s3_path_suffix==="string";if(H===K)P$(`entry id ${U} must contain exactly one path representation`);if(K&&typeof D.default_s3_path_prefix!=="string")P$(`entry id ${U} requires default_s3_path_prefix`);let O=H?q.s3_path:`${D.default_s3_path_prefix}${q.s3_path_suffix}`;if(!VA$(O))P$(`entry id ${U} has an invalid s3 path`);if(Y.has(O))P$(`entry id ${U} duplicates another s3 path`);Y.add(O);let z,V;if(q.upload_target!==void 0&&(typeof q.upload_target!=="string"||!J.has(q.upload_target)))P$(`entry id ${U} references an unknown upload target`);if(W!=="reuse"){let E=q.upload_target??D.default_upload_target;if(typeof E!=="string"||!(z=J.get(E)))P$(`entry id ${U} references an unknown upload target`);if(typeof q.upload_token!=="string")P$(`entry id ${U} is missing upload_token`);let L=`${z.authorization.token_prefix}${q.upload_token}`;if(!L||Bw0(L))P$(`entry id ${U} has an invalid upload token`);V={headerName:z.authorization.header_name,value:L}}let M;if(W==="reuse"){if(typeof q.file_size_receipt!=="string"||!q.file_size_receipt)P$(`entry id ${U} is missing file_size_receipt`);M=q.file_size_receipt}F.set(U,{request:Q.get(U),action:W,s3Path:O,uploadTarget:z,uploadAuthorization:V,fileSizeReceipt:M})}if(X.size!==$.entries.length)P$("response does not contain exactly one entry for every request entry");return{response:{...D,upload_targets:[...J.values()],entries:D.entries},entries:$.entries.map((G)=>F.get(G.id))}}async function Ew0($,D,J={},Q=I0,X=(Y)=>new Promise((F)=>setTimeout(F,Y))){let Y,F=setTimeout(()=>{Y=E1().spinner(),Y.start("Requesting delta upload authorization")},500);try{let{data:Z,error:G}=await _5(async()=>Q("private/request_manifest_upload",{apikey:$,body:D,apiHost:J.apiHost}),X);if(G)throw new J0(`Cannot request manifest upload: ${await v1(G)}`);let q=NA$(D,Z);return Y?.stop("Delta upload authorized"),q}catch(Z){throw Y?.error("Cannot authorize delta upload"),Z}finally{clearTimeout(F)}}H8();XD();var kR0=n$(SR0(),1),uR0=n$(nK(),1);import{createHash as rT$}from"node:crypto";import{createReadStream as Bh,statSync as oT$}from"node:fs";import{platform as tT$}from"node:os";import{join as aT$,posix as sT$,win32 as vR0}from"node:path";import{cwd as eT$}from"node:process";import{buffer as Eh}from"node:stream/consumers";import{createBrotliCompress as $I$}from"node:zlib";W$();j3();f0();v7();W$();function PR0($){return Array.from($).filter((D)=>{let J=D.codePointAt(0)??0;return J===9||J===10||J>=32&&!(J>=127&&J<=159)}).join("")}class F7 extends J0{backendMessage;requestId;scope;constructor($,D,J){let Q=PR0(D),X=J===void 0?void 0:PR0(J),Y=X?`
|
|
677
677
|
|
|
678
|
-
Request ID: ${X}`:"";super(`Abandoning manifest upload. The following error occurred: ${Q}${Y}`);this.name="ManifestUploadAbandonError",this.backendMessage=Q,this.requestId=X,this.scope=$}}function Nh($){if($===void 0)return;let D;try{D=JSON.parse($)}catch{return}if(!D||typeof D!=="object"||Array.isArray(D))return;let J=D,Q=J.moreInfo&&typeof J.moreInfo==="object"&&!Array.isArray(J.moreInfo)?J.moreInfo:void 0,X=typeof Q?.requestId==="string"?Q.requestId:typeof J.requestId==="string"?J.requestId:void 0;if(typeof J.abandon_explicit_error==="string")return new F7("all",J.abandon_explicit_error,X);if(typeof J.abandon_manifest_only_explicit_error==="string")return new F7("manifest",J.abandon_manifest_only_explicit_error,X);return}function CR0($){return Nh($?.originalResponse?.getBody?.())}function _R0($,D){return $.scope==="manifest"&&D?"manifest":"all"}class Mh{abandonError;abandonPromise;activeUploads=new Map;register($,D){if(this.abandonError)return D(this.abandonError),!1;return this.activeUploads.set($,D),!0}unregister($){this.activeUploads.delete($)}throwIfAbandoned(){if(this.abandonError)throw this.abandonError}async abandon($){if(!this.abandonError)this.abandonError=$;if(!this.abandonPromise){let D=[...this.activeUploads.entries()];this.activeUploads.clear(),this.abandonPromise=(async()=>{await Promise.allSettled(D.map(async([J])=>{await J.abort()}));for(let[,J]of D)J(this.abandonError)})()}await this.abandonPromise}}var T5={info:($)=>E1().info($),warn:($)=>E1().warn($),error:($)=>E1().error($)},DI$=new Set([429,502,503,504]),JI$=30000;function QI$($){return DI$.has($)}function xR0($){return Math.min($,JI$)}function XI$($,D,J){let Q=D[J];if(Q===void 0)return;if($.status!==429)return Q;let X=$.headers.get("Retry-After")?.trim();if(!X)return Q;if(/^\d+$/.test(X)){let F=Number(X),Z=F*1000;if(Number.isSafeInteger(F)&&Number.isFinite(Z))return xR0(Z)}let Y=Date.parse(X);if(Number.isFinite(Y)){let F=Y-Date.now();if(F>=0)return xR0(F)}return Q}function YI$($){return new J0(`Cannot check whether manifest file exists (HTTP ${$})`,{status:$})}async function FI$($,D){let J=new URL(`${$}${encodeURIComponent(D)}`),Q=PF.slice(0,3);for(let X=0;;X++){J.searchParams.set("nocache",`${Date.now()}`);try{let Y=await fetch(J.toString(),{method:"GET",redirect:"error",headers:i$({"cache-control":"no-cache"})});if(Y.status===404)return{exists:!1};if(!Y.ok){let F=QI$(Y.status)?XI$(Y,Q,X):void 0;if(F!==void 0){if(await Y.body?.cancel(),F>0)await new Promise((Z)=>setTimeout(Z,F));continue}throw YI$(Y.status)}return{exists:!0,receipt:Y.headers.get("X-Capgo-Manifest-Size-Receipt")??void 0}}catch(Y){let F=Q[X];if(!f9(Y)||F===void 0)throw Y;if(F>0)await new Promise((Z)=>setTimeout(Z,F))}}}var ZI$=8192;async function GI$($){let D=J1(eT$()),J=await E4("@capgo/capacitor-updater",D,$.packageJson),Q;try{Q=J?o$(J):void 0}catch{Q=void 0}if(!J||!Q)return{version:null,supportsBrotliV2:!1};let X=!gD(Q,void 0,void 0,NU);return{version:`${Q.major}.${Q.minor}.${Q.patch}`,supportsBrotliV2:X}}function qI$($,D){if(!D)return!1;let J=D.split(",").map((Q)=>Q.trim()).filter((Q)=>!!Q);if(J.length===0)return!1;return kR0.isMatch($,J)}async function UI$($,D,J){let X=oT$($).size,Y=await Eh(Bh($));if(X===0)return{buffer:Y,useBrotli:!1};if(qI$(D,J.noBrotliPatterns))return{buffer:Y,useBrotli:!1};if(X<ZI$)return{buffer:Y,useBrotli:!1};try{let F=await Eh(Bh($).pipe($I$({})));if(F.length>=X-10)return{buffer:Y,useBrotli:!1};return{buffer:F,useBrotli:!0}}catch(F){return T5.warn(`Brotli compression failed for ${$}: ${F}, using original file`),{buffer:Y,useBrotli:!1}}}async function wh($,D,J,Q=!1){let X=E1().spinner();X.start(D!=="v2"?"Generating the update manifest":`Generating the update manifest with ${Q?"V3":"V2"} encryption`);let Y=await TL($);if(D==="v2")for(let F of Y)F.hash=Q?J3(F.hash,J):D3(F.hash,J);return X.stop("Manifest generated successfully"),Y}async function fR0($,D,J,Q,X,Y,F=!1){let Z=await wh($,X,Y,F);return await e0(D,{channel:"partial-update",event:"Generate manifest",org_id:J,tracking_version:2,tags:{"app-id":Q}}),Z}function yR0($){if(tT$()!=="win32")return $;return vR0.normalize($).split(vR0.sep).join(sT$.sep)}class K3 extends J0{constructor($){super($);this.name="PartialUploadValidationError"}}async function WI$($,D){let{version:J,supportsBrotliV2:Q}=await GI$(D);if(!Q)throw new K3(`Your project is using an older version of @capgo/capacitor-updater (${J||"unknown"}). To use Delta updates, please upgrade to version ${jL} (v5), ${AL} (v6) or ${NU} (v7) or higher.`);if(D.disableBrotli)T5.info("Brotli compression disabled by user request");else if(D.noBrotliPatterns)T5.info(`Files matching patterns (${D.noBrotliPatterns}) will be excluded from brotli compression`);let X=$.filter((Y)=>Y.file.includes(" "));if(X.length>0)throw new K3(`Files with spaces in their names (${X.map((Y)=>Y.file).join(", ")}). Please rename the files.`);if($.length>VU)throw new K3(zL($.length))}async function bR0($,D,J,Q){let X=aT$(D,$.file),Y=yR0($.file),F=Q.disableBrotli?{buffer:await Eh(Bh(X)),useBrotli:!1}:await UI$(X,Y,Q),Z=J?$3(F.buffer,J.sessionKey,J.ivSessionKey):F.buffer,G=F.useBrotli?`${Y}.br`:Y;return{buffer:Z,fileName:G,compression:F.useBrotli?"brotli":"none",uploadedBytesSha256:rT$("sha256").update(Z).digest("hex"),uploadedBytesSize:Z.byteLength}}async function nB($,D,J,Q,X){if(await WI$($,Q),$.length===0)throw new J0("Cannot request a manifest upload for an empty manifest");let Y=[];for(let[F,Z]of $.entries()){let G=await bR0(Z,D,J,Q),q={id:F,file_name:G.fileName,compression:G.compression,file_hash:Z.hash,uploaded_bytes_sha256:G.uploadedBytesSha256,uploaded_bytes_size:G.uploadedBytesSize};if(Y.push(q),X)await X(q,G.buffer)}return Y}function HI$($,D){if($.request.file_name!==D.fileName||$.request.compression!==D.compression||$.request.uploaded_bytes_sha256!==D.uploadedBytesSha256||$.request.uploaded_bytes_size!==D.uploadedBytesSize)throw new J0(`Manifest file changed while preparing the upload: ${$.request.file_name}`)}function KI$($){return i$({[$.uploadAuthorization.headerName]:$.uploadAuthorization.value})}async function hR0($,D,J,Q,X,Y,F,Z){let G=E1().spinner();G.start("Preparing delta update with TUS protocol");let q=performance.now(),U=!!F.userRequestedDelta;if(Z.entries.length!==D.length)throw new J0("Manifest upload authorization does not match the local manifest");let W=0,H=D.length,K=Z.entries.filter((z)=>z.request.compression==="brotli").length,O=new Mh;try{G.message(`Uploading ${H} files using TUS protocol`);let z=async(N,B)=>{O.throwIfAbandoned();let w=yR0(N.file),_=await bR0(N,J,Y,F),x=_.buffer;O.throwIfAbandoned();let R=Z.entries[B];if(R.request.file_hash!==N.hash)throw new J0(`Manifest upload authorization does not match the local manifest entry ${B}`);HI$(R,_);let k=_.fileName,v=R.s3Path;if(R.action==="reuse")return W++,{file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:R.fileSizeReceipt};let d={exists:!1};if(R.action==="upload_if_doesnt_exist")try{d=await FI$(R.uploadTarget.existence_check_url_prefix,v)}catch(l){let a=l instanceof Error?l.message:String(l);throw Error(`Cannot check whether delta file exists: ${w}: ${a}`,{cause:l})}if(O.throwIfAbandoned(),d.exists)return W++,Promise.resolve({file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:d.receipt});return new Promise((l,a)=>{G.message(`Prepare upload delta file: ${w}`);let g=AQ(k),I=KI$(R),S=new uR0.Upload(x,{endpoint:R.uploadTarget.upload_url,chunkSize:F.tusChunkSize,retryDelays:[...PF],removeFingerprintOnSuccess:!0,metadata:{filename:v,filetype:g},headers:I,onAfterResponse(u,h){let c=Nh(h.getBody());if(c)return O.abandon(c)},onError:(u)=>{let h=CR0(u);if(h){O.abandon(h);return}O.unregister(S);let c=F.verbose?VL(u):u.toString();if(mx(u)){T5.error(`Failed to upload ${w}: ${c}`),a(Error(MU(Q)));return}let m;try{let o=c.match(/response text: (\{.*?\})/);if(o&&o[1])m=JSON.parse(o[1]).moreInfo?.requestId}catch{}let Y0=m?` [requestId: ${m}]`:"";T5.error(`Failed to upload ${w}: ${c}${Y0}`),a(u)},onProgress(){let u=(W/H*100).toFixed(2);G.message(`Uploading delta update: ${u}%`)},onSuccess({lastResponse:u}){O.unregister(S),W++,l({file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:u.getHeader("X-Capgo-Manifest-Size-Receipt")??void 0})}});if(O.register(S,a))S.start()})},V=F.deltaUploadConcurrency??50,M=[];for(let N=0;N<D.length;N+=V){O.throwIfAbandoned();let B=D.slice(N,N+V),w=Math.floor(N/V)+1,_=Math.ceil(D.length/V);if(_>1)G.message(`Processing batch ${w}/${_} (${B.length} files)`);let x=await Promise.all(B.map((R,k)=>z(R,N+k)));M.push(...x)}if(M.some((N)=>!N.file_size_receipt))throw new J0("Manifest upload did not return a size receipt for every file");let L=((performance.now()-q)/1000).toFixed(2);if(G.stop(`Delta update uploaded successfully \uD83D\uDCAA in (${L} seconds)`),K>0)T5.info(`${K} of ${H} files were compressed with brotli and use .br extension`);return await e0($,{channel:"app",event:`App Partial TUS done${K>0?" with .br extension":""}`,org_id:X,tracking_version:2,tags:{"app-id":Q}}),await e0($,{channel:"performance",event:"Partial upload performance",org_id:X,tracking_version:2,tags:{"app-id":Q,time:L}}),M}catch(z){let M=((performance.now()-q)/1000).toFixed(2);if(G.error(`Failed to upload delta update (after ${M} seconds)`),z instanceof F7)throw z;let E=F.verbose?VL(z):String(z);if(U)throw T5.error(`Error uploading delta update: ${E}`),T5.error("Delta upload was explicitly requested but failed. Upload aborted."),z;else return T5.info(`Error uploading delta update: ${E}, This is not a critical error, the bundle has been uploaded without the delta files`),null}}v7();function Rh($){if(!$)return[];let D=$.split(",").map((J)=>J.trim()).filter(Boolean);return Array.from(new Set(D))}function O3($){return $.join(", ")}function gR0($,D,J){let Q=[],X=[];for(let Y of $){if(J.get(Y)===D){Q.push(Y);continue}X.push(Y)}return{channelsAlreadyCurrent:Q,channelsToAssign:X}}H8();import{existsSync as jh,readFileSync as OI$}from"node:fs";import{cwd as Ah}from"node:process";Jq();W$();f0();v7();var x9={info:($)=>E1().info($),warn:($)=>E1().warn($),error:($)=>E1().error($)};function Th($){throw x9.error($),new J0($)}var zI$="5.30.0",VI$="6.30.0",LI$="7.30.0",mR0=["@capgo/cordova-updater","cordova-plugin-capgo"];function NI$($){return mR0.includes($)}async function MI$($,D){if(!f8($.mode)){let J=await E4("@capgo/capacitor-updater",D,$.packageJson);return J?{packageName:"@capgo/capacitor-updater",version:J}:null}for(let J of mR0){let Q=await E4(J,D,$.packageJson);if(Q)return{packageName:J,version:Q}}return null}async function iB($,D,J,Q={}){let X,Y,F="",Z=null,G="none",q="",U="",W,H=D.keyV2,K=D.key===!1,O=E1().spinner();O.start(`Zipping bundle from ${$}`),Z=await IL($),O.message("Calculating checksum");let z=J1(Ah()),V=await MI$(D,z),M=V?.version,E=V?.packageName,L=!1,N;try{N=M?o$(M):void 0}catch{N=void 0}if(!V)if(f8(D.mode))x9.warn("Cannot find a Capgo updater plugin in node_modules. Using SHA256 checksum for this Cordova upload."),L=!0;else Th("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");else if(E&&NI$(E))L=!0;else if(N)L=!gD(N,jL,AL,NU);else if(M==="link:@capgo/capacitor-updater"||M==="file:.."||M==="file:../")x9.warn(`Using local ${E??"@capgo/capacitor-updater"}. Assuming latest version for checksum calculation.`),L=!0;let B=D.forceCrc32Checksum===!0,w=!B&&((H||D.keyDataV2||jh(z6))&&!K||L),_=w?"sha256":"crc32";if(F=await XJ(Z,_),O.stop(`Checksum ${w?"SHA256":"CRC32"}${B?" (forced)":""}: ${F}`),K)x9.info("Encryption ignored");else if((H||jh(z6)||D.keyDataV2)&&!D.oldEncryption){let x=typeof H==="string"?H:z6,R=D.keyDataV2||"";if(!R&&!jh(x))Th(`Cannot find private key ${x}`);if(await Q.onEncryptV2?.(),!R)R=OI$(x).toString();let k=N&&!gD(N,"5.30.0","6.30.0","7.30.0");x9.info(`Encrypting your bundle with ${k?"V3":"V2"}`);let{sessionKey:v,ivSessionKey:d}=NB(R),l=$3(Z,v,d);if(F=k?J3(F,R):D3(F,R),X=d,W=k?"v3":"v2",Y=v,G="v2",q=R,J){if(U=oB0(J),D.verbose)x9.info(`[Verbose] Encryption key_id: ${U}`)}if(D.displayIvSession)x9.info(`Your Iv Session key is ${X},
|
|
678
|
+
Request ID: ${X}`:"";super(`Abandoning manifest upload. The following error occurred: ${Q}${Y}`);this.name="ManifestUploadAbandonError",this.backendMessage=Q,this.requestId=X,this.scope=$}}function Nh($){if($===void 0)return;let D;try{D=JSON.parse($)}catch{return}if(!D||typeof D!=="object"||Array.isArray(D))return;let J=D,Q=J.moreInfo&&typeof J.moreInfo==="object"&&!Array.isArray(J.moreInfo)?J.moreInfo:void 0,X=typeof Q?.requestId==="string"?Q.requestId:typeof J.requestId==="string"?J.requestId:void 0;if(typeof J.abandon_explicit_error==="string")return new F7("all",J.abandon_explicit_error,X);if(typeof J.abandon_manifest_only_explicit_error==="string")return new F7("manifest",J.abandon_manifest_only_explicit_error,X);return}function CR0($){return Nh($?.originalResponse?.getBody?.())}function _R0($,D){return $.scope==="manifest"&&D?"manifest":"all"}class Mh{abandonError;abandonPromise;activeUploads=new Map;register($,D){if(this.abandonError)return D(this.abandonError),!1;return this.activeUploads.set($,D),!0}unregister($){this.activeUploads.delete($)}throwIfAbandoned(){if(this.abandonError)throw this.abandonError}async abandon($){if(!this.abandonError)this.abandonError=$;if(!this.abandonPromise){let D=[...this.activeUploads.entries()];this.activeUploads.clear(),this.abandonPromise=(async()=>{await Promise.allSettled(D.map(async([J])=>{await J.abort()}));for(let[,J]of D)J(this.abandonError)})()}await this.abandonPromise}}var T5={info:($)=>E1().info($),warn:($)=>E1().warn($),error:($)=>E1().error($)},DI$=new Set([429,502,503,504]),JI$=30000;function QI$($){return DI$.has($)}function xR0($){return Math.min($,JI$)}function XI$($,D,J){let Q=D[J];if(Q===void 0)return;if($.status!==429)return Q;let X=$.headers.get("Retry-After")?.trim();if(!X)return Q;if(/^\d+$/.test(X)){let F=Number(X),Z=F*1000;if(Number.isSafeInteger(F)&&Number.isFinite(Z))return xR0(Z)}let Y=Date.parse(X);if(Number.isFinite(Y)){let F=Y-Date.now();if(F>=0)return xR0(F)}return Q}function YI$($){return new J0(`Cannot check whether manifest file exists (HTTP ${$})`,{status:$})}async function FI$($,D){let J=new URL(`${$}${encodeURIComponent(D)}`),Q=PF.slice(0,3);for(let X=0;;X++){J.searchParams.set("nocache",`${Date.now()}`);try{let Y=await fetch(J.toString(),{method:"GET",redirect:"manual",headers:i$({"cache-control":"no-cache"})});if(Y.status===404)return{exists:!1};if(!Y.ok){let F=QI$(Y.status)?XI$(Y,Q,X):void 0;if(F!==void 0){if(await Y.body?.cancel(),F>0)await new Promise((Z)=>setTimeout(Z,F));continue}throw YI$(Y.status)}return{exists:!0,receipt:Y.headers.get("X-Capgo-Manifest-Size-Receipt")??void 0}}catch(Y){let F=Q[X];if(!f9(Y)||F===void 0)throw Y;if(F>0)await new Promise((Z)=>setTimeout(Z,F))}}}var ZI$=8192;async function GI$($){let D=J1(eT$()),J=await E4("@capgo/capacitor-updater",D,$.packageJson),Q;try{Q=J?o$(J):void 0}catch{Q=void 0}if(!J||!Q)return{version:null,supportsBrotliV2:!1};let X=!gD(Q,void 0,void 0,NU);return{version:`${Q.major}.${Q.minor}.${Q.patch}`,supportsBrotliV2:X}}function qI$($,D){if(!D)return!1;let J=D.split(",").map((Q)=>Q.trim()).filter((Q)=>!!Q);if(J.length===0)return!1;return kR0.isMatch($,J)}async function UI$($,D,J){let X=oT$($).size,Y=await Eh(Bh($));if(X===0)return{buffer:Y,useBrotli:!1};if(qI$(D,J.noBrotliPatterns))return{buffer:Y,useBrotli:!1};if(X<ZI$)return{buffer:Y,useBrotli:!1};try{let F=await Eh(Bh($).pipe($I$({})));if(F.length>=X-10)return{buffer:Y,useBrotli:!1};return{buffer:F,useBrotli:!0}}catch(F){return T5.warn(`Brotli compression failed for ${$}: ${F}, using original file`),{buffer:Y,useBrotli:!1}}}async function wh($,D,J,Q=!1){let X=E1().spinner();X.start(D!=="v2"?"Generating the update manifest":`Generating the update manifest with ${Q?"V3":"V2"} encryption`);let Y=await TL($);if(D==="v2")for(let F of Y)F.hash=Q?J3(F.hash,J):D3(F.hash,J);return X.stop("Manifest generated successfully"),Y}async function fR0($,D,J,Q,X,Y,F=!1){let Z=await wh($,X,Y,F);return await e0(D,{channel:"partial-update",event:"Generate manifest",org_id:J,tracking_version:2,tags:{"app-id":Q}}),Z}function yR0($){if(tT$()!=="win32")return $;return vR0.normalize($).split(vR0.sep).join(sT$.sep)}class K3 extends J0{constructor($){super($);this.name="PartialUploadValidationError"}}async function WI$($,D){let{version:J,supportsBrotliV2:Q}=await GI$(D);if(!Q)throw new K3(`Your project is using an older version of @capgo/capacitor-updater (${J||"unknown"}). To use Delta updates, please upgrade to version ${jL} (v5), ${AL} (v6) or ${NU} (v7) or higher.`);if(D.disableBrotli)T5.info("Brotli compression disabled by user request");else if(D.noBrotliPatterns)T5.info(`Files matching patterns (${D.noBrotliPatterns}) will be excluded from brotli compression`);let X=$.filter((Y)=>Y.file.includes(" "));if(X.length>0)throw new K3(`Files with spaces in their names (${X.map((Y)=>Y.file).join(", ")}). Please rename the files.`);if($.length>VU)throw new K3(zL($.length))}async function bR0($,D,J,Q){let X=aT$(D,$.file),Y=yR0($.file),F=Q.disableBrotli?{buffer:await Eh(Bh(X)),useBrotli:!1}:await UI$(X,Y,Q),Z=J?$3(F.buffer,J.sessionKey,J.ivSessionKey):F.buffer,G=F.useBrotli?`${Y}.br`:Y;return{buffer:Z,fileName:G,compression:F.useBrotli?"brotli":"none",uploadedBytesSha256:rT$("sha256").update(Z).digest("hex"),uploadedBytesSize:Z.byteLength}}async function nB($,D,J,Q,X){if(await WI$($,Q),$.length===0)throw new J0("Cannot request a manifest upload for an empty manifest");let Y=[];for(let[F,Z]of $.entries()){let G=await bR0(Z,D,J,Q),q={id:F,file_name:G.fileName,compression:G.compression,file_hash:Z.hash,uploaded_bytes_sha256:G.uploadedBytesSha256,uploaded_bytes_size:G.uploadedBytesSize};if(Y.push(q),X)await X(q,G.buffer)}return Y}function HI$($,D){if($.request.file_name!==D.fileName||$.request.compression!==D.compression||$.request.uploaded_bytes_sha256!==D.uploadedBytesSha256||$.request.uploaded_bytes_size!==D.uploadedBytesSize)throw new J0(`Manifest file changed while preparing the upload: ${$.request.file_name}`)}function KI$($){return i$({[$.uploadAuthorization.headerName]:$.uploadAuthorization.value})}async function hR0($,D,J,Q,X,Y,F,Z){let G=E1().spinner();G.start("Preparing delta update with TUS protocol");let q=performance.now(),U=!!F.userRequestedDelta;if(Z.entries.length!==D.length)throw new J0("Manifest upload authorization does not match the local manifest");let W=0,H=D.length,K=Z.entries.filter((z)=>z.request.compression==="brotli").length,O=new Mh;try{G.message(`Uploading ${H} files using TUS protocol`);let z=async(N,B)=>{O.throwIfAbandoned();let w=yR0(N.file),_=await bR0(N,J,Y,F),x=_.buffer;O.throwIfAbandoned();let R=Z.entries[B];if(R.request.file_hash!==N.hash)throw new J0(`Manifest upload authorization does not match the local manifest entry ${B}`);HI$(R,_);let k=_.fileName,v=R.s3Path;if(R.action==="reuse")return W++,{file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:R.fileSizeReceipt};let d={exists:!1};if(R.action==="upload_if_doesnt_exist")try{d=await FI$(R.uploadTarget.existence_check_url_prefix,v)}catch(l){let a=l instanceof Error?l.message:String(l);throw Error(`Cannot check whether delta file exists: ${w}: ${a}`,{cause:l})}if(O.throwIfAbandoned(),d.exists)return W++,Promise.resolve({file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:d.receipt});return new Promise((l,a)=>{G.message(`Prepare upload delta file: ${w}`);let g=AQ(k),I=KI$(R),S=new uR0.Upload(x,{endpoint:R.uploadTarget.upload_url,chunkSize:F.tusChunkSize,retryDelays:[...PF],removeFingerprintOnSuccess:!0,metadata:{filename:v,filetype:g},headers:I,onAfterResponse(u,h){let c=Nh(h.getBody());if(c)return O.abandon(c)},onError:(u)=>{let h=CR0(u);if(h){O.abandon(h);return}O.unregister(S);let c=F.verbose?VL(u):u.toString();if(mx(u)){T5.error(`Failed to upload ${w}: ${c}`),a(Error(MU(Q)));return}let m;try{let o=c.match(/response text: (\{.*?\})/);if(o&&o[1])m=JSON.parse(o[1]).moreInfo?.requestId}catch{}let Y0=m?` [requestId: ${m}]`:"";T5.error(`Failed to upload ${w}: ${c}${Y0}`),a(u)},onProgress(){let u=(W/H*100).toFixed(2);G.message(`Uploading delta update: ${u}%`)},onSuccess({lastResponse:u}){O.unregister(S),W++,l({file_name:k,s3_path:v,file_hash:N.hash,file_size_receipt:u.getHeader("X-Capgo-Manifest-Size-Receipt")??void 0})}});if(O.register(S,a))S.start()})},V=F.deltaUploadConcurrency??50,M=[];for(let N=0;N<D.length;N+=V){O.throwIfAbandoned();let B=D.slice(N,N+V),w=Math.floor(N/V)+1,_=Math.ceil(D.length/V);if(_>1)G.message(`Processing batch ${w}/${_} (${B.length} files)`);let x=await Promise.all(B.map((R,k)=>z(R,N+k)));M.push(...x)}if(M.some((N)=>!N.file_size_receipt))throw new J0("Manifest upload did not return a size receipt for every file");let L=((performance.now()-q)/1000).toFixed(2);if(G.stop(`Delta update uploaded successfully \uD83D\uDCAA in (${L} seconds)`),K>0)T5.info(`${K} of ${H} files were compressed with brotli and use .br extension`);return await e0($,{channel:"app",event:`App Partial TUS done${K>0?" with .br extension":""}`,org_id:X,tracking_version:2,tags:{"app-id":Q}}),await e0($,{channel:"performance",event:"Partial upload performance",org_id:X,tracking_version:2,tags:{"app-id":Q,time:L}}),M}catch(z){let M=((performance.now()-q)/1000).toFixed(2);if(G.error(`Failed to upload delta update (after ${M} seconds)`),z instanceof F7)throw z;let E=F.verbose?VL(z):String(z);if(U)throw T5.error(`Error uploading delta update: ${E}`),T5.error("Delta upload was explicitly requested but failed. Upload aborted."),z;else return T5.info(`Error uploading delta update: ${E}, This is not a critical error, the bundle has been uploaded without the delta files`),null}}v7();function Rh($){if(!$)return[];let D=$.split(",").map((J)=>J.trim()).filter(Boolean);return Array.from(new Set(D))}function O3($){return $.join(", ")}function gR0($,D,J){let Q=[],X=[];for(let Y of $){if(J.get(Y)===D){Q.push(Y);continue}X.push(Y)}return{channelsAlreadyCurrent:Q,channelsToAssign:X}}H8();import{existsSync as jh,readFileSync as OI$}from"node:fs";import{cwd as Ah}from"node:process";Jq();W$();f0();v7();var x9={info:($)=>E1().info($),warn:($)=>E1().warn($),error:($)=>E1().error($)};function Th($){throw x9.error($),new J0($)}var zI$="5.30.0",VI$="6.30.0",LI$="7.30.0",mR0=["@capgo/cordova-updater","cordova-plugin-capgo"];function NI$($){return mR0.includes($)}async function MI$($,D){if(!f8($.mode)){let J=await E4("@capgo/capacitor-updater",D,$.packageJson);return J?{packageName:"@capgo/capacitor-updater",version:J}:null}for(let J of mR0){let Q=await E4(J,D,$.packageJson);if(Q)return{packageName:J,version:Q}}return null}async function iB($,D,J,Q={}){let X,Y,F="",Z=null,G="none",q="",U="",W,H=D.keyV2,K=D.key===!1,O=E1().spinner();O.start(`Zipping bundle from ${$}`),Z=await IL($),O.message("Calculating checksum");let z=J1(Ah()),V=await MI$(D,z),M=V?.version,E=V?.packageName,L=!1,N;try{N=M?o$(M):void 0}catch{N=void 0}if(!V)if(f8(D.mode))x9.warn("Cannot find a Capgo updater plugin in node_modules. Using SHA256 checksum for this Cordova upload."),L=!0;else Th("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");else if(E&&NI$(E))L=!0;else if(N)L=!gD(N,jL,AL,NU);else if(M==="link:@capgo/capacitor-updater"||M==="file:.."||M==="file:../")x9.warn(`Using local ${E??"@capgo/capacitor-updater"}. Assuming latest version for checksum calculation.`),L=!0;let B=D.forceCrc32Checksum===!0,w=!B&&((H||D.keyDataV2||jh(z6))&&!K||L),_=w?"sha256":"crc32";if(F=await XJ(Z,_),O.stop(`Checksum ${w?"SHA256":"CRC32"}${B?" (forced)":""}: ${F}`),K)x9.info("Encryption ignored");else if((H||jh(z6)||D.keyDataV2)&&!D.oldEncryption){let x=typeof H==="string"?H:z6,R=D.keyDataV2||"";if(!R&&!jh(x))Th(`Cannot find private key ${x}`);if(await Q.onEncryptV2?.(),!R)R=OI$(x).toString();let k=N&&!gD(N,"5.30.0","6.30.0","7.30.0");x9.info(`Encrypting your bundle with ${k?"V3":"V2"}`);let{sessionKey:v,ivSessionKey:d}=NB(R),l=$3(Z,v,d);if(F=k?J3(F,R):D3(F,R),X=d,W=k?"v3":"v2",Y=v,G="v2",q=R,J){if(U=oB0(J),D.verbose)x9.info(`[Verbose] Encryption key_id: ${U}`)}if(D.displayIvSession)x9.info(`Your Iv Session key is ${X},
|
|
679
679
|
keep it safe, you will need it to decrypt your bundle.
|
|
680
680
|
It will be also visible in your dashboard
|
|
681
681
|
`);Z=l}return{zipped:Z,ivSessionKey:X,sessionKey:Y,checksum:F,checksumAlgorithm:_,checksumEncryption:W,encryptionMethod:G,finalKeyData:q,keyId:U,updaterVersion:M,updaterPackageName:E}}function pB($,D){let J=$?new Map($.filter((X)=>!!X.native&&X.native!==void 0).map((X)=>[X.name,X])):new Map;return J.size>0||!D?Array.from(J,([X,Y])=>({name:X,version:Y.version,requested_version:Y.requested_version,...Y.ios_checksum&&{ios_checksum:Y.ios_checksum},...Y.android_checksum&&{android_checksum:Y.android_checksum}})):void 0}async function rB($,D){if($.encryptDelta=$.encryptDelta||$.encryptPartial,$.encryptDelta&&D!=="v2")Th("You cannot encrypt the delta update if you are not using the v2 encryption method");let J=!1;if($.delta&&D==="v2"&&!$.encryptDelta){let Q=J1(Ah()),X=await E4("@capgo/capacitor-updater",Q,$.packageJson),Y;try{Y=X?o$(X):void 0}catch{Y=void 0}if(X&&Y&&pH(Y,o$("6.14.4"))){if(x9.info(`Auto-enabling delta update encryption for updater version ${Y} (>= 6.14.4)`),$.verbose)x9.info("[Verbose] Delta encryption auto-enabled for updater >= 6.14.4");$.encryptDelta=!0}}if($.delta&&($.encryptDelta||D==="v2")){let Q=J1(Ah()),X=await E4("@capgo/capacitor-updater",Q,$.packageJson),Y;try{Y=X?o$(X):void 0}catch{Y=void 0}if(X&&Y){if(J=!gD(Y,zI$,VI$,LI$),$.verbose&&J)x9.info(`[Verbose] Using hex checksum format for updater version ${Y}`)}}return{supportsHexChecksum:J}}W$();f0();function BI$($){let D=$.appId?.trim()||"<appId>",J=$.path?.trim()||"www",Q=$.channel?.trim()||"<channel>";return`npx @capgo/cli@latest bundle upload ${D} --mode cordova --path ${J} --channel ${Q}`}function EI$($){return[NL,"If this is a Cordova project (config.xml / plugin.xml and a www folder), retry with:",BI$($)].join(`
|