@capgo/cli 8.68.1 → 8.68.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.js +4 -4
- package/dist/notify-app-ready-worker.js +1 -1
- package/dist/onboarding-worker.js +1 -1
- package/dist/package.json +1 -1
- package/dist/src/schemas/bundle.d.ts +1 -0
- package/dist/src/sdk.js +3 -3
- package/dist/updater-installed-worker.js +1 -1
- package/package.json +1 -1
- package/skills/release-management/SKILL.md +2 -2
package/dist/src/sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as DC0}from"node:module";var module={exports:{}};var oT0=Object.create;var{getPrototypeOf:tT0,defineProperty:bG,getOwnPropertyNames:gg}=Object;var rw=Object.prototype.hasOwnProperty;function ow($){return this[$]}var z0=($,D,X)=>{var Q=gg(D);for(let J of Q)if(!rw.call($,J)&&J!=="default")bG($,J,{get:ow.bind(D,J),enumerable:!0});if(X){for(let J of Q)if(!rw.call(X,J)&&J!=="default")bG(X,J,{get:ow.bind(D,J),enumerable:!0});return X}},aT0,sT0,x$=($,D,X)=>{var Q=$!=null&&typeof $==="object";if(Q){var J=D?aT0??=new WeakMap:sT0??=new WeakMap,Y=J.get($);if(Y)return Y}X=$!=null?oT0(tT0($)):{};let Z=D||!$||!$.__esModule?bG(X,"default",{value:$,enumerable:!0}):X;for(let F of gg($))if(!rw.call(Z,F))bG(Z,F,{get:ow.bind($,F),enumerable:!0});if(Q)J.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var eT0=($)=>$;function $C0($,D){this[$]=eT0.bind(null,D)}var K6=($,D)=>{for(var X in D)bG($,X,{get:D[X],enumerable:!0,configurable:!0,set:$C0.bind(D,X)})};var o=($,D)=>()=>($&&(D=$($=0)),D);var Q0=DC0(import.meta.url);var $D;var L8=o(()=>{$D={name:"@capgo/cli",type:"module",version:"8.68.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",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --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: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: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: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:supabase-perf":"bun test/test-supabase-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:bundle-pages":"bun test test/test-bundle-pages.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-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-output-text":"bun test/test-app-list-output-text.mjs","test:app-todo":"bun test/test-app-todo.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-supabase-client":"bun test/test-create-supabase-client.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-upload-recovery":"bun test/test-init-upload-error-gate.mjs && bun test/test-init-upload-monorepo-recovery.mjs","test:init-replay":"bun test/test-init-replay.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","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","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:manifest-path-encoding":"bun test/test-manifest-path-encoding.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:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.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-flow-contract":"bun test/test-ios-flow-contract.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 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: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: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: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:supabase-perf && bun run test:preview-qr && bun run test:bundle-pages && 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-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-output-text && bun run test:app-todo && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-supabase-client && 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-upload-recovery && bun run test:init-replay && bun run test:init-telemetry && 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:manifest-path-encoding && 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:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && 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:frame-fit-ios-shared && 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-flow-contract && 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:organization-set-api-host && bun run test:trial-warning && bun run test:plan-validation","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-analyze-stream":"bun test/test-ai-analyze-stream.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-mailto":"bun test/test-support-mailto.mjs","test:support-redact":"bun test/test-support-redact.mjs","test:support-internal-log":"bun test/test-support-internal-log.mjs","test:support-help-menu":"bun test/test-support-help-menu.mjs","test:support-contact":"bun test/test-support-contact.mjs","test:support-upload-prompt":"bun test/test-support-upload-prompt.mjs","test:support-bundle-files":"bun test/test-support-bundle-files.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 && bun test/test-app-list-options.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:organization-set-api-host":"bun test/test-organization-set-api-host.mjs","test:trial-warning":"bun test/test-trial-warning.mjs","test:plan-validation":"bun test/test-plan-validation.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"},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","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.110.8","@tanstack/intent":"^0.3.6","@types/adm-zip":"^0.5.8","@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-preview":"7.0.0-dev.20260707.2","@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",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 G0;var _$=o(()=>{G0=class G0 extends Error{context;constructor($,D){super($);this.name="CliUserError",this.context=D}}});import{platform as QC0}from"node:os";import{version as JC0}from"node:process";function FC0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function mg($){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 GC0($){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 or Supabase anon key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function aw($,D){if(D===void 0||D===null){if(tw.has($.toLowerCase()))throw new G0(mg($));throw new G0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(tw.has($.toLowerCase()))throw new G0(mg($));throw new G0(`HTTP header "${$}" is missing or invalid.`)}if(!FC0(D)){if(tw.has($.toLowerCase()))throw new G0(GC0($));throw new G0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function i$($){let D={capgo_api:YC0,"x-cli-version":$D.version,"x-cli-command":ZC0,"x-cli-node":JC0,"x-cli-os":QC0()};if($)for(let[X,Q]of Object.entries($))D[X]=aw(X,Q);return D}var YC0="2025-10-01",ZC0="",tw;var q4=o(()=>{L8();_$();tw=new Set(["authorization","capgkey","x-capgo-log-token"])});var dg,cg=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},lg=($)=>{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 ng=o(()=>{dg=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let X=0;$.lastIndex=0;while($.test(D))X+=1;return D.length-X}})()});var WC0,qC0,pg,UC0,ig,HC0,KC0,OC0,rg=($,D={},X={})=>{let Q=D.limit??1/0,J=D.ellipsis??"",Y=D?.ellipsisWidth??(J?rg(J,OC0,X).width:0),Z=0,F=X.controlWidth??0,G=X.tabWidth??8,W=X.emojiWidth??2,q=2,U=X.regularWidth??1,H=X.wideWidth??2,K=[[HC0,U],[WC0,0],[qC0,F],[UC0,G],[ig,W],[pg,H]],O=0,V=0,z=$.length,N=0,w=!1,L=z,M=Math.max(0,Q-Y),B=0,R=0,P=0,v=0;$:while(!0){if(R>B||V>=z&&V>O){let j=$.slice(B,R)||$.slice(O,V);N=0;for(let k of j.replaceAll(KC0,"")){let x=k.codePointAt(0)||0;if(cg(x))v=2;else if(lg(x))v=H;else v=U;if(P+v>M)L=Math.min(L,Math.max(B,O)+N);if(P+v>Q){w=!0;break $}N+=k.length,P+=v}B=R=0}if(V>=z)break $;for(let j=0,k=K.length;j<k;j++){let[x,g]=K[j];if(x.lastIndex=V,x.test($)){if(N=x===pg?dg($.slice(V,x.lastIndex)):x===ig?1:x.lastIndex-V,v=N*g,P+v>M)L=Math.min(L,V+Math.floor((M-P)/g));if(P+v>Q){w=!0;break $}P+=v,B=O,R=V,V=O=x.lastIndex;continue $}}V+=1}return{width:w?M:P,index:w?L:z,truncated:w,ellipsed:w&&Q>=Y}},og;var tg=o(()=>{ng();WC0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,qC0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pg=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,UC0=/\t{1,1000}/y,ig=/[\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,HC0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,KC0=/\p{M}+/gu,OC0={limit:1/0,ellipsis:""},og=rg});var VC0,zC0=($,D={})=>{return og($,VC0,D).width},n8;var sw=o(()=>{tg();VC0={limit:1/0,ellipsis:"",ellipsisWidth:0},n8=zC0});function m7($,D,X){return String($).normalize().split(wC0).map((Q)=>BC0(Q,D,X)).join(`
|
|
1
|
+
import{createRequire as DC0}from"node:module";var module={exports:{}};var oT0=Object.create;var{getPrototypeOf:tT0,defineProperty:bG,getOwnPropertyNames:gg}=Object;var rw=Object.prototype.hasOwnProperty;function ow($){return this[$]}var z0=($,D,X)=>{var Q=gg(D);for(let J of Q)if(!rw.call($,J)&&J!=="default")bG($,J,{get:ow.bind(D,J),enumerable:!0});if(X){for(let J of Q)if(!rw.call(X,J)&&J!=="default")bG(X,J,{get:ow.bind(D,J),enumerable:!0});return X}},aT0,sT0,x$=($,D,X)=>{var Q=$!=null&&typeof $==="object";if(Q){var J=D?aT0??=new WeakMap:sT0??=new WeakMap,Y=J.get($);if(Y)return Y}X=$!=null?oT0(tT0($)):{};let Z=D||!$||!$.__esModule?bG(X,"default",{value:$,enumerable:!0}):X;for(let F of gg($))if(!rw.call(Z,F))bG(Z,F,{get:ow.bind($,F),enumerable:!0});if(Q)J.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var eT0=($)=>$;function $C0($,D){this[$]=eT0.bind(null,D)}var K6=($,D)=>{for(var X in D)bG($,X,{get:D[X],enumerable:!0,configurable:!0,set:$C0.bind(D,X)})};var o=($,D)=>()=>($&&(D=$($=0)),D);var Q0=DC0(import.meta.url);var $D;var L8=o(()=>{$D={name:"@capgo/cli",type:"module",version:"8.68.2",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",types:"bunx --bun supabase gen types typescript --project-id=xvwzpoazmxkqosrdewyv > src/types/supabase.types.ts",typecheck:"tsgo --project tsconfig.tsgo.json --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: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: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: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:supabase-perf":"bun test/test-supabase-perf.mjs","test:preview-qr":"bun test/test-preview-qr.mjs","test:bundle-pages":"bun test test/test-bundle-pages.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-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-output-text":"bun test/test-app-list-output-text.mjs","test:app-todo":"bun test/test-app-todo.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-supabase-client":"bun test/test-create-supabase-client.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-upload-recovery":"bun test/test-init-upload-error-gate.mjs && bun test/test-init-upload-monorepo-recovery.mjs","test:init-replay":"bun test/test-init-replay.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","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","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:manifest-path-encoding":"bun test/test-manifest-path-encoding.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:frame-fit-ios-shared":"bun test/test-frame-fit-ios-shared.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-flow-contract":"bun test/test-ios-flow-contract.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 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: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: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: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:supabase-perf && bun run test:preview-qr && bun run test:bundle-pages && 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-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-output-text && bun run test:app-todo && bun run test:doctor-analytics && bun run test:posthog-exception && bun run test:cli-recovery && bun run test:create-supabase-client && 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-upload-recovery && bun run test:init-replay && bun run test:init-telemetry && 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:manifest-path-encoding && 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:ai-analyze-stream && bun run test:support-mailto && bun run test:support-redact && bun run test:support-internal-log && bun run test:support-help-menu && bun run test:support-contact && bun run test:support-upload-prompt && bun run test:support-bundle-files && 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:frame-fit-ios-shared && 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-flow-contract && 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:organization-set-api-host && bun run test:trial-warning && bun run test:plan-validation","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-analyze-stream":"bun test/test-ai-analyze-stream.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-mailto":"bun test/test-support-mailto.mjs","test:support-redact":"bun test/test-support-redact.mjs","test:support-internal-log":"bun test/test-support-internal-log.mjs","test:support-help-menu":"bun test/test-support-help-menu.mjs","test:support-contact":"bun test/test-support-contact.mjs","test:support-upload-prompt":"bun test/test-support-upload-prompt.mjs","test:support-bundle-files":"bun test/test-support-bundle-files.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 && bun test/test-app-list-options.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:organization-set-api-host":"bun test/test-organization-set-api-host.mjs","test:trial-warning":"bun test/test-trial-warning.mjs","test:plan-validation":"bun test/test-plan-validation.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"},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","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.110.8","@tanstack/intent":"^0.3.6","@types/adm-zip":"^0.5.8","@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-preview":"7.0.0-dev.20260707.2","@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",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 G0;var _$=o(()=>{G0=class G0 extends Error{context;constructor($,D){super($);this.name="CliUserError",this.context=D}}});import{platform as QC0}from"node:os";import{version as JC0}from"node:process";function FC0($){for(let D=0;D<$.length;D++)if($.charCodeAt(D)>255)return!1;return!0}function mg($){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 GC0($){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 or Supabase anon key configuration.";return"Capgo API key contains invalid characters (only ASCII is allowed). Copy the key from the Capgo dashboard."}function aw($,D){if(D===void 0||D===null){if(tw.has($.toLowerCase()))throw new G0(mg($));throw new G0(`HTTP header "${$}" is missing or invalid.`)}if(typeof D!=="string"){if(tw.has($.toLowerCase()))throw new G0(mg($));throw new G0(`HTTP header "${$}" is missing or invalid.`)}if(!FC0(D)){if(tw.has($.toLowerCase()))throw new G0(GC0($));throw new G0(`HTTP header "${$}" contains invalid characters (only ASCII is allowed).`)}return D}function i$($){let D={capgo_api:YC0,"x-cli-version":$D.version,"x-cli-command":ZC0,"x-cli-node":JC0,"x-cli-os":QC0()};if($)for(let[X,Q]of Object.entries($))D[X]=aw(X,Q);return D}var YC0="2025-10-01",ZC0="",tw;var q4=o(()=>{L8();_$();tw=new Set(["authorization","capgkey","x-capgo-log-token"])});var dg,cg=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},lg=($)=>{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 ng=o(()=>{dg=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let X=0;$.lastIndex=0;while($.test(D))X+=1;return D.length-X}})()});var WC0,qC0,pg,UC0,ig,HC0,KC0,OC0,rg=($,D={},X={})=>{let Q=D.limit??1/0,J=D.ellipsis??"",Y=D?.ellipsisWidth??(J?rg(J,OC0,X).width:0),Z=0,F=X.controlWidth??0,G=X.tabWidth??8,W=X.emojiWidth??2,q=2,U=X.regularWidth??1,H=X.wideWidth??2,K=[[HC0,U],[WC0,0],[qC0,F],[UC0,G],[ig,W],[pg,H]],O=0,V=0,z=$.length,N=0,w=!1,L=z,M=Math.max(0,Q-Y),B=0,R=0,P=0,v=0;$:while(!0){if(R>B||V>=z&&V>O){let j=$.slice(B,R)||$.slice(O,V);N=0;for(let k of j.replaceAll(KC0,"")){let x=k.codePointAt(0)||0;if(cg(x))v=2;else if(lg(x))v=H;else v=U;if(P+v>M)L=Math.min(L,Math.max(B,O)+N);if(P+v>Q){w=!0;break $}N+=k.length,P+=v}B=R=0}if(V>=z)break $;for(let j=0,k=K.length;j<k;j++){let[x,g]=K[j];if(x.lastIndex=V,x.test($)){if(N=x===pg?dg($.slice(V,x.lastIndex)):x===ig?1:x.lastIndex-V,v=N*g,P+v>M)L=Math.min(L,V+Math.floor((M-P)/g));if(P+v>Q){w=!0;break $}P+=v,B=O,R=V,V=O=x.lastIndex;continue $}}V+=1}return{width:w?M:P,index:w?L:z,truncated:w,ellipsed:w&&Q>=Y}},og;var tg=o(()=>{ng();WC0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,qC0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pg=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,UC0=/\t{1,1000}/y,ig=/[\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,HC0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,KC0=/\p{M}+/gu,OC0={limit:1/0,ellipsis:""},og=rg});var VC0,zC0=($,D={})=>{return og($,VC0,D).width},n8;var sw=o(()=>{tg();VC0={limit:1/0,ellipsis:"",ellipsisWidth:0},n8=zC0});function m7($,D,X){return String($).normalize().split(wC0).map((Q)=>BC0(Q,D,X)).join(`
|
|
2
2
|
`)}var GK="\x1B",Dm="",LC0=39,$R="\x07",Xm="[",MC0="]",Qm="m",DR,ag,sg=($)=>{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},eg=($)=>`${GK}${Xm}${$}${Qm}`,$m=($)=>`${GK}${DR}${$}${$R}`,ew=($,D,X)=>{let Q=D[Symbol.iterator](),J=!1,Y=!1,Z=$.at(-1),F=Z===void 0?0:n8(Z),G=Q.next(),W=Q.next(),q=0;while(!G.done){let U=G.value,H=n8(U);if(F+H<=X)$[$.length-1]+=U;else $.push(U),F=0;if(U===GK||U===Dm)J=!0,Y=D.startsWith(DR,q+1);if(J){if(Y){if(U===$R)J=!1,Y=!1}else if(U===Qm)J=!1}else if(F+=H,F===X&&!W.done)$.push(""),F=0;G=W,W=Q.next(),q+=U.length}if(Z=$.at(-1),!F&&Z!==void 0&&Z.length&&$.length>1)$[$.length-2]+=$.pop()},NC0=($)=>{let D=$.split(" "),X=D.length;while(X){if(n8(D[X-1]))break;X--}if(X===D.length)return $;return D.slice(0,X).join(" ")+D.slice(X).join("")},BC0=($,D,X={})=>{if(X.trim!==!1&&$.trim()==="")return"";let Q="",J,Y,Z=$.split(" "),F=[""],G=0;for(let U=0;U<Z.length;U++){let H=Z[U];if(X.trim!==!1){let O=F.at(-1)??"",V=O.trimStart();if(O.length!==V.length)F[F.length-1]=V,G=n8(V)}if(U!==0){if(G>=D&&(X.wordWrap===!1||X.trim===!1))F.push(""),G=0;if(G||X.trim===!1)F[F.length-1]+=" ",G++}let K=n8(H);if(X.hard&&K>D){let O=D-G,V=1+Math.floor((K-O-1)/D);if(Math.floor((K-1)/D)<V)F.push("");ew(F,H,D),G=n8(F.at(-1)??"");continue}if(G+K>D&&G&&K){if(X.wordWrap===!1&&G<D){ew(F,H,D),G=n8(F.at(-1)??"");continue}F.push(""),G=0}if(G+K>D&&X.wordWrap===!1){ew(F,H,D),G=n8(F.at(-1)??"");continue}F[F.length-1]+=H,G+=K}if(X.trim!==!1)F=F.map((U)=>NC0(U));let W=F.join(`
|
|
3
3
|
`),q=!1;for(let U=0;U<W.length;U++){let H=W[U];if(Q+=H,!q){if(q=H>="\uD800"&&H<="\uDBFF",q)continue}else q=!1;if(H===GK||H===Dm){ag.lastIndex=U+1;let O=ag.exec(W)?.groups;if(O?.code!==void 0){let V=Number.parseFloat(O.code);J=V===LC0?void 0:V}else if(O?.uri!==void 0)Y=O.uri.length===0?void 0:O.uri}if(W[U+1]===`
|
|
4
4
|
`){if(Y)Q+=$m("");let K=J?sg(J):void 0;if(J&&K)Q+=eg(K)}else if(H===`
|
|
@@ -694,7 +694,7 @@ ${sh(D)};
|
|
|
694
694
|
${Bx$}
|
|
695
695
|
|
|
696
696
|
Docs: ${ah}`);let Z=await g$({message:"Have you added notifyAppReady() and rebuilt your app?"});if(r0(Z)||!Z)continue;if(z8(D,"notifyAppReady"))return F$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"manual"}}),"recovered";C.warn("notifyAppReady() is still missing in the build folder. Rebuild, or choose another option.");continue}if(Y==="skip"){C.warn("Skipping notifyAppReady check. Without this call, Capgo may roll back downloaded updates."),C.warn(`Learn more: ${ah}`);let Z=await g$({message:"Continue without notifyAppReady()?",initialValue:!1});if(r0(Z)||!Z)continue;return F$({channel:"bundle",event:"CLI Skipped NotifyAppReady Check",tags:{}}),"skipped"}if(Y==="patch-build"){let Z=Cx$(D);if(!Z){C.warn("Could not patch the build folder automatically. The app bundle must already include CapacitorUpdater, or patch the source and rebuild.");continue}if(!z8(D,"notifyAppReady")){C.warn(`Patched ${Z}, but notifyAppReady() is still missing. Try another option.`);continue}return C.success(`Added notifyAppReady() to ${Z}`),F$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"patch-build"}}),"recovered"}if(Y==="patch-source")try{let Z=await Px$(Y1(eh()));if(!Z){C.warn("Could not find your app entry file automatically.");continue}C.success(`Added notifyAppReady() to ${Z}`),C.info("Rebuild your web assets, then retry zip/upload.");let F=await g$({message:"Have you rebuilt your app into the build folder?"});if(r0(F)||!F)continue;if(z8(D,"notifyAppReady"))return F$({channel:"bundle",event:"CLI Recovered Missing NotifyAppReady",tags:{recovery:"patch-source"}}),"recovered";C.warn("notifyAppReady() is still missing in the build folder after rebuild.")}catch(Z){C.error(F0(Z))}}}_$();p0();var Sx$={invoke:async($,D)=>G$($,D),formatError:B9};async function SA0($,D,X=Sx$){let{data:Q,error:J}=await X.invoke("private/config",{apikey:$.apikey,method:"GET",supaHost:$.supaHost,supaAnon:$.supaAnon});if(J||!Q?.useNewFinalizeBundleUpload){await D();return}let Y=$.reporter.spinner();Y.start("Finalizing bundle upload...");let{error:Z}=await X.invoke("private/finalize_bundle_upload",{apikey:$.apikey,body:{app_id:$.appId,name:$.bundle},supaHost:$.supaHost,supaAnon:$.supaAnon});if(Z){let F=`Cannot finalize bundle upload: ${await X.formatError(Z)}`;throw Y.error(F),new G0(F)}Y.stop("Bundle upload finalized")}_$();p0();function _x$($){let D=$.appId?.trim()||"<appId>",X=$.path?.trim()||"www",Q=$.channel?.trim()||"<channel>";return`npx @capgo/cli@latest bundle upload ${D} --mode cordova --path ${X} --channel ${Q}`}function vx$($){return[LN,"If this is a Cordova project (config.xml / plugin.xml and a www folder), retry with:",_x$($)].join(`
|
|
697
|
-
`)}function xx$($,D){if($ instanceof G0&&$.message===LN)throw new G0(vx$({appId:D.appId,path:D.path,channel:D.channel}));throw $}async function _A0($,D={}){if(l9($.mode))return RA0({path:$.path,appId:D.appId});try{return await z$()}catch(X){xx$(X,{appId:D.appId,path:$.path,channel:$.channel})}}r8();q4();var gI0=x$(bI0(),1),mI0=x$(eO(),1);import{Buffer as Wy$}from"node:buffer";import{createHash as qy$}from"node:crypto";import{createReadStream as Lg,statSync as Uy$}from"node:fs";import{platform as Hy$}from"node:os";import{join as Ky$,posix as Oy$,win32 as hI0}from"node:path";import{cwd as Vy$}from"node:process";import{buffer as Mg}from"node:stream/consumers";import{createBrotliCompress as zy$}from"node:zlib";_$();p0();YV();var g7={info:($)=>UD().info($),warn:($)=>UD().warn($),error:($)=>UD().error($)};async function Ly$($,D){try{let X=new URL(`${$.hostFilesApi}/files/read/attachments/${encodeURIComponent(D)}`);X.searchParams.set("nocache",`${Date.now()}`);let Q=await fetch(X.toString(),{method:"GET",headers:i$({range:"bytes=0-0","cache-control":"no-cache"})});return{exists:Q.ok,receipt:Q.headers.get("X-Capgo-Manifest-Size-Receipt")??void 0}}catch{return{exists:!1}}}var My$=8192;async function Ny$($){let D=Y1(Vy$()),X=await _6("@capgo/capacitor-updater",D,$.packageJson),Q;try{Q=X?a$(X):void 0}catch{Q=void 0}if(!X||!Q)return{version:null,supportsBrotliV2:!1};let J=!r4(Q,void 0,void 0,ZU);return{version:`${Q.major}.${Q.minor}.${Q.patch}`,supportsBrotliV2:J}}function By$($,D){if(!D)return!1;let X=D.split(",").map((Q)=>Q.trim()).filter((Q)=>!!Q);if(X.length===0)return!1;return gI0.isMatch($,X)}async function wy$($,D,X){let J=Uy$($).size,Y=await Mg(Lg($));if(J===0)return{buffer:Y,useBrotli:!1};if(By$(D,X.noBrotliPatterns))return{buffer:Y,useBrotli:!1};if(J<My$)return{buffer:Y,useBrotli:!1};try{let Z=await Mg(Lg($).pipe(zy$({})));if(Z.length>=J-10)return{buffer:Y,useBrotli:!1};return{buffer:Z,useBrotli:!0}}catch(Z){return g7.warn(`Brotli compression failed for ${$}: ${Z}, using original file`),{buffer:Y,useBrotli:!1}}}async function dI0($,D,X,Q,J,Y,Z=!1){let F=UD().spinner();F.start(J!=="v2"?"Generating the update manifest":`Generating the update manifest with ${Z?"V3":"V2"} encryption`);let G=await wN($);if(J==="v2")for(let W of G)W.hash=Z?wG(W.hash,Y):BG(W.hash,Y);return F.stop("Manifest generated successfully"),await e0(D,{channel:"partial-update",event:"Generate manifest",org_id:X,tracking_version:2,tags:{"app-id":Q}}),G}function Ry$($){if(Hy$()!=="win32")return $;return hI0.normalize($).split(hI0.sep).join(Oy$.sep)}function Ey$($){return $.split("/").map((D)=>encodeURIComponent(D)).join("/")}function jy$($,D,X,Q,J){let Y=qy$("sha256").update(X).digest("hex"),Z=Ey$(Q);if(J){let F=Wy$.from(J.ivSessionKey).toString("hex");return`orgs/${$}/apps/${D}/delta/${F}/${Y}_${Z}`}return`orgs/${$}/apps/${D}/delta/${Y}_${Z}`}async function cI0($,D,X,Q,J,Y,Z){let F=UD().spinner();F.start("Preparing
|
|
697
|
+
`)}function xx$($,D){if($ instanceof G0&&$.message===LN)throw new G0(vx$({appId:D.appId,path:D.path,channel:D.channel}));throw $}async function _A0($,D={}){if(l9($.mode))return RA0({path:$.path,appId:D.appId});try{return await z$()}catch(X){xx$(X,{appId:D.appId,path:$.path,channel:$.channel})}}r8();q4();var gI0=x$(bI0(),1),mI0=x$(eO(),1);import{Buffer as Wy$}from"node:buffer";import{createHash as qy$}from"node:crypto";import{createReadStream as Lg,statSync as Uy$}from"node:fs";import{platform as Hy$}from"node:os";import{join as Ky$,posix as Oy$,win32 as hI0}from"node:path";import{cwd as Vy$}from"node:process";import{buffer as Mg}from"node:stream/consumers";import{createBrotliCompress as zy$}from"node:zlib";_$();p0();YV();var g7={info:($)=>UD().info($),warn:($)=>UD().warn($),error:($)=>UD().error($)};async function Ly$($,D){try{let X=new URL(`${$.hostFilesApi}/files/read/attachments/${encodeURIComponent(D)}`);X.searchParams.set("nocache",`${Date.now()}`);let Q=await fetch(X.toString(),{method:"GET",headers:i$({range:"bytes=0-0","cache-control":"no-cache"})});return{exists:Q.ok,receipt:Q.headers.get("X-Capgo-Manifest-Size-Receipt")??void 0}}catch{return{exists:!1}}}var My$=8192;async function Ny$($){let D=Y1(Vy$()),X=await _6("@capgo/capacitor-updater",D,$.packageJson),Q;try{Q=X?a$(X):void 0}catch{Q=void 0}if(!X||!Q)return{version:null,supportsBrotliV2:!1};let J=!r4(Q,void 0,void 0,ZU);return{version:`${Q.major}.${Q.minor}.${Q.patch}`,supportsBrotliV2:J}}function By$($,D){if(!D)return!1;let X=D.split(",").map((Q)=>Q.trim()).filter((Q)=>!!Q);if(X.length===0)return!1;return gI0.isMatch($,X)}async function wy$($,D,X){let J=Uy$($).size,Y=await Mg(Lg($));if(J===0)return{buffer:Y,useBrotli:!1};if(By$(D,X.noBrotliPatterns))return{buffer:Y,useBrotli:!1};if(J<My$)return{buffer:Y,useBrotli:!1};try{let Z=await Mg(Lg($).pipe(zy$({})));if(Z.length>=J-10)return{buffer:Y,useBrotli:!1};return{buffer:Z,useBrotli:!0}}catch(Z){return g7.warn(`Brotli compression failed for ${$}: ${Z}, using original file`),{buffer:Y,useBrotli:!1}}}async function dI0($,D,X,Q,J,Y,Z=!1){let F=UD().spinner();F.start(J!=="v2"?"Generating the update manifest":`Generating the update manifest with ${Z?"V3":"V2"} encryption`);let G=await wN($);if(J==="v2")for(let W of G)W.hash=Z?wG(W.hash,Y):BG(W.hash,Y);return F.stop("Manifest generated successfully"),await e0(D,{channel:"partial-update",event:"Generate manifest",org_id:X,tracking_version:2,tags:{"app-id":Q}}),G}function Ry$($){if(Hy$()!=="win32")return $;return hI0.normalize($).split(hI0.sep).join(Oy$.sep)}function Ey$($){return $.split("/").map((D)=>encodeURIComponent(D)).join("/")}function jy$($,D,X,Q,J){let Y=qy$("sha256").update(X).digest("hex"),Z=Ey$(Q);if(J){let F=Wy$.from(J.ivSessionKey).toString("hex");return`orgs/${$}/apps/${D}/delta/${F}/${Y}_${Z}`}return`orgs/${$}/apps/${D}/delta/${Y}_${Z}`}async function cI0($,D,X,Q,J,Y,Z){let F=UD().spinner();F.start("Preparing delta update with TUS protocol");let G=performance.now(),W=await J6(),q=!!Z.userRequestedDelta,{version:U,supportsBrotliV2:H}=await Ny$(Z);if(!H)throw new G0(`Your project is using an older version of @capgo/capacitor-updater (${U||"unknown"}). To use Delta updates, please upgrade to version ${NN} (v5), ${BN} (v6) or ${ZU} (v7) or higher.`);else if(Z.disableBrotli)g7.info("Brotli compression disabled by user request");else if(Z.noBrotliPatterns)g7.info(`Files matching patterns (${Z.noBrotliPatterns}) will be excluded from brotli compression`);let K=D.filter((N)=>N.file.includes(" "));if(K.length>0)throw new G0(`Files with spaces in their names (${K.map((N)=>N.file).join(", ")}). Please rename the files.`);if(D.length>QU)throw new G0(ON(D.length));let O=0,V=D.length,z=0;try{F.message(`Uploading ${V} files using TUS protocol`);let N=async(R)=>{let P=Ky$(X,R.file),v=Ry$(R.file),j,k=!1;if(Z.disableBrotli)j=await Mg(Lg(P)),k=!1;else{let h=await wy$(P,v,Z);j=h.buffer,k=h.useBrotli}let x=j;if(Y)x=NG(j,Y.sessionKey,Y.ivSessionKey);let g=v;if(k)g=`${v}.br`,z++;let d=jy$(J,Q,R.hash,g,Y),D0=!Y?await Ly$(W,d):{exists:!1};if(D0.exists)return O++,Promise.resolve({file_name:g,s3_path:d,file_hash:R.hash,file_size_receipt:D0.receipt});return new Promise((h,A)=>{F.message(`Prepare upload delta file: ${v}`);let T=dQ(g);new mI0.Upload(x,{endpoint:`${W.hostFilesApi}/files/upload/attachments/`,chunkSize:Z.tusChunkSize,retryDelays:[...XU],removeFingerprintOnSuccess:!0,metadata:{filename:d,filetype:T},headers:i$({Authorization:$}),onError:(m)=>{let c=m.toString();if(nk(m)){g7.error(`Failed to upload ${v}: ${c}`),A(Error(FU(Q)));return}let l;try{let n=c.match(/response text: (\{.*?\})/);if(n&&n[1])l=JSON.parse(n[1]).moreInfo?.requestId}catch{}let Z0=l?` [requestId: ${l}]`:"";g7.error(`Failed to upload ${v}: ${c}${Z0}`),A(m)},onProgress(){let m=(O/V*100).toFixed(2);F.message(`Uploading delta update: ${m}%`)},onSuccess({lastResponse:m}){O++,h({file_name:g,s3_path:d,file_hash:R.hash,file_size_receipt:m.getHeader("X-Capgo-Manifest-Size-Receipt")??void 0})}}).start()})},w=500,L=[];for(let R=0;R<D.length;R+=w){let P=D.slice(R,R+w),v=Math.floor(R/w)+1,j=Math.ceil(D.length/w);if(j>1)F.message(`Processing batch ${v}/${j} (${P.length} files)`);let k=await Promise.all(P.map((x)=>N(x)));L.push(...k)}if(L.some((R)=>!R.file_size_receipt))L.forEach((R)=>delete R.file_size_receipt);let B=((performance.now()-G)/1000).toFixed(2);if(F.stop(`Delta update uploaded successfully \uD83D\uDCAA in (${B} seconds)`),z>0)g7.info(`${z} of ${V} files were compressed with brotli and use .br extension`);return await e0($,{channel:"app",event:`App Partial TUS done${z>0?" with .br extension":""}`,org_id:J,tracking_version:2,tags:{"app-id":Q}}),await e0($,{channel:"performance",event:"Partial upload performance",org_id:J,tracking_version:2,tags:{"app-id":Q,time:B}}),L}catch(N){let L=((performance.now()-G)/1000).toFixed(2);if(F.error(`Failed to upload delta update (after ${L} seconds)`),q)throw g7.error(`Error uploading delta update: ${N}`),g7.error("Delta upload was explicitly requested but failed. Upload aborted."),N;else return g7.info(`Error uploading delta update: ${N}, This is not a critical error, the bundle has been uploaded without the delta files`),null}}YV();function Ng($){if(!$)return[];let D=$.split(",").map((X)=>X.trim()).filter(Boolean);return Array.from(new Set(D))}function vG($){return $.join(", ")}function lI0($,D,X){let Q=[],J=[];for(let Y of $){if(X.get(Y)===D){Q.push(Y);continue}J.push(Y)}return{channelsAlreadyCurrent:Q,channelsToAssign:J}}var nI0="Upload cancelled by user",r={info:($)=>UD().info($),warn:($)=>UD().warn($),error:($)=>UD().error($),success:($)=>UD().success($)};function H$($){throw r.error($),new G0($)}async function gw($,D){let X=await JU($);H$(X||await D())}function Rg(){throw r.warn(nI0),new G0(nI0)}class oI0 extends G0{}async function Bg($,D,X){let{error:Q}=await XW0($,D);if(Q)H$(`Cannot ${X} bundle ${F0(Q)}`)}function Ty$($){let D=$.map((X)=>{let Q=g5(X);return[X.name,X.localVersion||"-",X.remoteVersion||"-",Q.compatible?"✅":"❌",Q.message]});r.info(B7({headers:["Package","Local","Remote","Status","Details"],rows:D}))}async function Cy$($,D){let X=b5("",D.packageJson),Q=D.bundle||$?.plugins?.CapacitorUpdater?.version||X||`0.0.1-beta.local-${Ay$().split("-")[0]}`;if(!hQ.test(Q))H$(`Your bundle name ${Q}, is not valid it should follow semver convention : https://semver.org/`);return Q}function Py$($){let D=$.apikey||u0();if(!D)H$("Missing API key, you need to provide an API key to upload your bundle");return D}async function Sy$($,D,X,Q){let J=await Cw({explicitAppId:$,config:X,apikey:D.apikey||u0(!0),packageJsonPaths:TG(D.packageJson),interactive:Q,supaHost:D.supaHost,supaAnon:D.supaAnon}),Y=D.path||X?.webDir||(l9(D.mode)?Sw:void 0);if(!J)H$(l9(D.mode)?"Missing appId. Pass it on the command line or set id in config.xml / plugin.xml":"Missing argument, you need to provide a appid or be in a capacitor project");if(!Y)H$(l9(D.mode)?`Missing upload path. Pass --path or use the default Cordova web dir (${Sw})`:"Missing argument, you need to provide a path (--path), or be in a capacitor project");if(!hw(Y))H$(`Path ${Y} does not exist, build your app first, or provide a valid path`);return{appid:J,path:Y}}async function _y$($,D,X){if($.codeCheck===!1||$.ignoreNotifyAppReady)return;if(!z8(D,"notifyAppReady")){if(await xw({webDir:D,interactive:X})==="skipped")return}if(!z8(D,"notifyAppReady"))throw r.error(`notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugins/updater/notifyappready
|
|
698
698
|
If you are sure your app has this code, you can use the --no-code-check or --ignore-notify-app-ready option`),Error(`notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugins/updater/notifyappready
|
|
699
699
|
If you are sure your app has this code, you can use the --no-code-check or --ignore-notify-app-ready option`.trim());if(!AG(D))H$(`index.html is missing in the root folder of ${D}`)}async function vy$($,D,X,Q,J,Y,Z){let{ignoreMetadataCheck:F,autoMinUpdateVersion:G,minUpdateVersion:W}=X,{data:q,error:U}=await $.from("channels").select("disable_auto_update, version ( id, name, min_update_version, native_packages )").eq("name",Q).eq("app_id",J).maybeSingle();if(U)H$(`Cannot load channel ${Q} for compatibility checks ${F0(U)}`);let H=q?.version??void 0,K=!!q&&q.disable_auto_update==="version_number",O,V;if(!U&&q&&q.version&&q.version.native_packages&&!F){let M=UD().spinner();M.start(`Checking bundle compatibility with channel ${Q}`);let{finalCompatibility:B,localDependencies:R}=await IN($,J,Q,X.packageJson,X.nodeModules);if(V=B,O=R,V.filter((v)=>!o4(v)).length>0){if(M.error(`Bundle NOT compatible with ${Q} channel`),r.warn(""),Ty$(V),r.warn(""),r.warn("An app store update may be required for these changes to take effect."),G)W=Y,r.info(`Auto set min-update-version to ${W}`)}else if(G)try{let{min_update_version:v}=q.version;if(!v||!hQ.test(v))H$("Invalid remote min update version, skipping auto setting compatibility");W=v,M.stop(`Auto set min-update-version to ${W}`)}catch{H$(`Cannot auto set compatibility, invalid data ${q}`)}else M.stop(`Bundle compatible with ${Q} channel`)}else if(!F){if(r.warn(`Channel ${Q} is new or it's your first upload with compatibility check, it will be ignored this time`),O=await ik(X.packageJson,X.nodeModules),G)W=Y,r.info(`Auto set min-update-version to ${W}`)}let z=V?void 0:F?"ignore_metadata_check":"no_remote_metadata",N=Jj0(V);if(F$({channel:"bundle",event:"Bundle Upload Compatibility Checked",apikey:X.apikey,appId:J,orgId:Z,tags:{result:N.result,incompatible_count:N.incompatibleCount,channel:Q,channel_name:Q,...N.reasons.length>0?{reasons:N.reasons.join(",")}:{},...z?{skip_reason:z}:{}}}),K&&!W&&!F)H$("You need to provide a min-update-version to upload a bundle to this channel");if(W){if(!hQ.test(W))H$(`Your minimal version update ${W}, is not valid it should follow semver convention : https://semver.org/`)}let w=O?new Map(O.filter((M)=>!!M.native&&M.native!==void 0).map((M)=>[M.name,M])):new Map;return{nativePackages:w.size>0||!X.ignoreMetadataCheck?Array.from(w,([M,B])=>({name:M,version:B.version,requested_version:B.requested_version,...B.ios_checksum&&{ios_checksum:B.ios_checksum},...B.android_checksum&&{android_checksum:B.android_checksum}})):void 0,minUpdateVersion:W,incompatibleCount:N.incompatibleCount,compatibility:{result:N.result,versionOldId:H?.id!=null?String(H.id):void 0,versionOldName:H?.name}}}async function xy$($,D,X,Q=!1,J=!1){let{data:Y,error:Z}=await $.rpc("exist_app_versions",{appid:D,name_version:X}).single();if(Z)H$(`Cannot check if version ${X} already exists ${F0(Z)}`);if(Y){if(Q)return r.warn(`Version ${X} already exists - exiting gracefully due to --version-exists-ok option`),UD().outro("Bundle version already exists - exiting gracefully \uD83C\uDF89"),!0;if(J){r.error(`❌ Version ${X} already exists`);let F=YA0(X);r.info("\uD83D\uDCA1 Here are some suggestions:"),F.forEach((q,U)=>{r.info(` ${U+1}. ${q}`)});let G=await y1({message:"What would you like to do?",options:[{value:"suggest1",label:`Use ${F[0]}`},{value:"suggest2",label:`Use ${F[1]}`},{value:"suggest3",label:`Use ${F[2]}`},{value:"suggest4",label:`Use ${F[3]}`},{value:"custom",label:"Enter a custom version"},{value:"cancel",label:"Cancel upload"}]});if(r0(G)||typeof G!=="string"||G==="cancel")Rg();let W;if(G==="custom"){let q=await JA0(X,"upload");if(!q)Rg();W=q}else{let q=Number.parseInt(G.replace("suggest",""))-1;W=F[q]}return r.info(`\uD83D\uDD04 Retrying with new version: ${W}`),W}H$(`Version ${X} already exists`)}return!1}function ky$($){let D;for(let{minUpdateVersion:X}of $){if(!X)continue;if(!D||xR(a$(X),a$(D)))D=X}return D}async function yy$($,D,X,Q){let J=new Map;for(let F of X){let G=UD().spinner();G.start(`Checking bundle checksum compatibility with channel ${F}`);let W=await qW0($,D,F);if(J.set(F,W),!W){G.stop(`No checksum found for channel ${F}, the bundle will be uploaded`);continue}if(W===Q){G.stop(`Channel ${F} already has this bundle checksum`);continue}G.stop(`Checksum compatible with ${F} channel`)}let{channelsAlreadyCurrent:Y,channelsToAssign:Z}=lI0(X,Q,J);if(Z.length===0){let F=vG(X);throw r.error(`Cannot upload the same bundle content.
|
|
700
700
|
Current bundle checksum matches remote bundle for channel${X.length>1?"s":""} ${F}
|
|
@@ -706,7 +706,7 @@ PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upl
|
|
|
706
706
|
The bundle size is ${k} Mb, this may take a while to download for users
|
|
707
707
|
`),r.info(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
|
|
708
708
|
`),D.verbose)r.info("[Verbose] Bundle size details:"),r.info(` - Actual size: ${k} MB (${U?.byteLength} bytes)`),r.info(` - Alert threshold: ${Math.floor(Z/1024/1024)} MB`),r.info(` - Maximum allowed: ${x} MB`),r.info("[Verbose] Sending 'App Too Large' event to analytics...");if(await e0(X,{channel:"app-error",event:"App Too Large",org_id:Q,tracking_version:2,tags:{"app-id":J,size_mb:k}},D.verbose),D.verbose)r.info("[Verbose] Event sent successfully")}else if(D.verbose)r.info(`[Verbose] Bundle size OK: ${k} MB (under ${Math.floor(Z/1024/1024)} MB alert threshold)`);if(D.verbose)r.info("[Verbose] Bundle preparation complete, returning bundle data");return{zipped:U,ivSessionKey:G,sessionKey:W,checksum:q,encryptionMethod:H,finalKeyData:K,keyId:O}}async function dy$($,D,X,Q,J,Y,Z,F){let G=UD().spinner();G.start("Uploading Bundle");let W=performance.now(),q=!1;if(Z.verbose)r.info("[Verbose] uploadBundleToCapgoCloud called:"),r.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),r.info(` - App ID: ${X}`),r.info(` - Bundle version: ${Q}`),r.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(Z.dryUpload){if(G.stop(`Dry run, bundle not uploaded
|
|
709
|
-
Bundle uploaded \uD83D\uDCAA in 0 seconds`),Z.verbose)r.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let K=await J6();if(Z.verbose)r.info("[Verbose] Local config retrieved for upload");if(Z.multipart!==void 0&&Z.multipart||Z.tus!==void 0&&Z.tus){if(Z.multipart)r.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else r.info("Uploading bundle with TUS protocol");if(Z.verbose)r.info("[Verbose] Starting TUS resumable upload..."),r.info(` - Host: ${K.hostWeb}`),r.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(await YW0($,Y,J,X,Q,G,K,F),q=!0,Z.verbose)r.info("[Verbose] TUS upload completed, updating database with R2 path...");let O=`orgs/${J}/apps/${X}/${Q}.zip`,{error:V}=await D.from("app_versions").update({r2_path:O}).eq("name",Q).eq("app_id",X);if(V){if(r.error(`Cannot finish TUS upload ${F0(V)}`),Z.verbose)r.info(`[Verbose] Database update failed: ${F0(V)}`);throw Error("Cannot finish TUS upload")}if(Z.verbose)r.info(`[Verbose] Database updated with R2 path: ${O}`)}else{if(Z.verbose)r.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let O=await QW0($,X,Q,Z);if(!O){if(r.error("Cannot get upload url"),Z.verbose)r.info("[Verbose] Failed to retrieve presigned upload URL from database");throw Error("Cannot get upload url")}let V=Z.timeout||n30;if(Z.verbose)r.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),r.info(` - Timeout: ${V}ms`),r.info(" - Retry attempts: 0 (standard upload does not retry, use --tus for resumable retries)"),r.info(" - Content-Type: application/zip");let z=new AbortController,N=setTimeout(()=>z.abort(),V);try{let w=await fetch(O,{method:"PUT",body:Y,headers:{"Content-Type":"application/zip"},signal:z.signal});if(!w.ok)throw Error(`HTTP error! status: ${w.status}`)}catch(w){if(z.signal.aborted||w?.name==="AbortError"){let L=Error(p30(V));throw L.name=lk,L}throw w}finally{clearTimeout(N)}if(Z.verbose)r.info("[Verbose] HTTP PUT upload completed successfully")}}catch(K){let V=((performance.now()-W)/1000).toFixed(2);if(G.error(`Failed to upload bundle ( after ${V} seconds)`),Z.verbose)r.info(`[Verbose] Upload failed after ${V} seconds`),r.info(`[Verbose] Error type: ${K instanceof Error?"Error":typeof K}`);if(K instanceof Error&&K.name===lk)r.error(K.message);else if(K instanceof Error&&K.message.includes("HTTP error"))try{let z=K.message.match(/status: (\d+)/),N=z?z[1]:"unknown";r.error(`Upload failed with status ${N}: ${K.message}`)}catch{r.error(`Upload failed: ${K.message}`)}else{if(Z.verbose)r.info(`[Verbose] Non-HTTP error: ${F0(K)}`);if(!Z.tus)r.error(`Cannot upload bundle ( try again with --tus option) ${F0(K)}`);else r.error(`Cannot upload bundle please contact support if the issue persists ${F0(K)}`)}if(Z.verbose)r.info("[Verbose] Cleaning up failed version from database...");try{if(await EN($,X,Q,Z),Z.verbose)r.info("[Verbose] Failed version cleaned up")}catch(z){r.error(`Cleanup of the incomplete version failed (${F0(z)}); delete bundle ${Q} manually before retrying.`)}throw K instanceof Error?K:Error(String(K))}let H=((performance.now()-W)/1000).toFixed(2);if(G.stop(`Bundle uploaded \uD83D\uDCAA in (${H} seconds)`),Z.verbose)r.info("[Verbose] Upload successful:"),r.info(` - Upload time: ${H} seconds`),r.info(` - Upload method: ${q?"TUS (resumable)":"Standard HTTP PUT"}`),r.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),r.info("[Verbose] Sending performance event...");if(await e0($,{channel:"performance",event:q?"TUS upload zip performance":"Upload zip performance",org_id:J,tracking_version:2,tags:{"app-id":X,time:H}},Z.verbose),Z.verbose)r.info("[Verbose] Performance event sent successfully")}function cy$($){if($.rollout==null&&$.rolloutPercentageBps==null)return;if($.rolloutPercentageBps!=null)return $.rolloutPercentageBps;return Math.round(($.rollout??0)*100)}function pI0($){return`${Number(($/100).toFixed(2))}%`}async function sI0($,D,X,Q){let{data:J}=await $.rpc("get_app_versions",{apikey:D,name_version:Q,appid:X}).single();if(!J)H$("Cannot get version id, cannot set channel");return J}async function ly$($,D,X){let{data:Q,error:J}=await $.rpc("exist_app_versions",{appid:D,name_version:X}).single();if(J)H$(`Cannot check if version ${X} already exists ${F0(J)}`);return!!Q}async function ny$($,D){let{data:X,error:Q}=await $.from("app_versions").select("name").eq("app_id",D).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(Q)return r.warn(`Cannot fetch latest remote version ${F0(Q)}`),null;return X?.name??null}async function iI0($,D,X,Q,J){let Y=X;for(let Z=0;Z<100;Z++){if(!await ly$($,D,Y)){if(Y!==J)r.info(`\uD83D\uDD22 Auto-bumped (${Q}) version from ${J} to ${Y}`);return Y}Y=Tw(Y,Q)}H$(`Could not find a free ${Q}-bumped version after 100 attempts (started from ${J})`)}async function py$($,D,X,Q,J){let Y=X[0],F=(await eI0($,D,Y))?.name??null;if(F)r.info(`\uD83D\uDCE6 Auto-bump base from channel ${Y}: ${F}`);else if(F=await ny$($,D),F)r.info(`\uD83D\uDCE6 Auto-bump base from latest remote app version: ${F}`);if(!F)return r.info(`ℹ️ No remote versions found for auto-bump, keeping local version ${Q}`),iI0($,D,Q,J,Q);let G=Tw(F,J);return iI0($,D,G,J,F)}async function eI0($,D,X){let{data:Q,error:J}=await $.from("channels").select("version:app_versions!channels_version_fkey( id, name, deleted )").eq("app_id",D).eq("name",X);if(J)return r.error(`Cannot delete linked bundle on upload ${F0(J)}`),null;if(Q.length===0)return r.warn("No linked bundle found in the channel you are trying to upload to"),null;let Y=Q[0].version;if(!Y)return r.warn("No linked bundle found in the channel you are trying to upload to"),null;if(Y.deleted)return r.warn("The linked bundle is already deleted"),null;return Y}async function iy$($,D){if(!D)return;let{error:X}=await $.from("app_versions").update({deleted:!0}).eq("id",D.id);if(X){r.error(`Cannot delete linked bundle on upload ${F0(X)}`);return}r.info(`Linked bundle ${D.name} deleted`)}async function Eg($,D,X,Q=!0){let{data:J,error:Y}=await $.from("channels").select("id, public, version, rollout_version, rollout_enabled, rollout_percentage_bps").eq("app_id",D).eq("name",X).maybeSingle();if(Y&&Q)H$(`Cannot check channel ${X}: ${F0(Y)}`);return J}async function ry$($,D,X,Q,J=!1,Y,Z=!1){let F=new Map,G=Y!=null||Z;for(let W of new Set(Q)){let q=await Eg($,X,W);if(q){if(F.set(W,q),!await xD($,D,"channel.promote_bundle",{appId:X,channelId:q.id}))H$("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");if(J||G){if(!await xD($,D,"channel.update_settings",{appId:X,channelId:q.id}))H$(J?"Cannot enable device self-assign because this API key lacks channel.update_settings":"Cannot set rollout because this API key lacks channel.update_settings for the target channel")}if(G&&!q.version)H$(`Cannot set rollout, channel ${W} needs a stable bundle before using progressive rollout`);if(Z&&q.rollout_version==null)H$(`Cannot advance rollout, channel ${W} has no rollout target to promote to stable`);if(Z&&Y==null&&!((q.rollout_percentage_bps??0)>0))H$(`Cannot advance rollout, channel ${W} has no rollout percentage to reuse. Pass --rollout or --rollout-percentage-bps`);continue}if(G)H$(`Cannot set rollout, channel ${W} must already exist with a stable bundle`);if(!await xD($,D,"app.create_channel",{appId:X}))H$("Cannot create target channel because this API key lacks app.create_channel");F.set(W,null)}return F}async function jg($){let D=$?.context;if(D?.json)try{return JSON.stringify(await D.json())}catch{}return F0($)}async function rI0($,D,X,Q,J,Y,Z){let{error:F}=await G$("bundle",{apikey:$,method:"PUT",body:{app_id:D,version_id:X,channel_id:Q.id},supaHost:Z?.supaHost,supaAnon:Z?.supaAnon});if(F)await gw(F,async()=>`Cannot set channel because this API key does not have the required RBAC permission. ${await jg(F)}`);let G=`${J.hostWeb}/app/${D}/channel/${Q.id}`;if(Q.rollout_enabled&&Q.rollout_version!=null)r.warn("This channel has an active progressive rollout. Linking this bundle as the stable version resets that rollout, so devices receive the new bundle instead of the previous rollout target.");else if(Q.public)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${G}`);if(Y)r.info(`Bundle url: ${G}`);return!0}async function oy$($,D,X,Q,J,Y,Z,F,G,W,q=!1,U,H){let K=W!==null&&await xD($,D,"channel.promote_bundle",{appId:F,channelId:W.id}),O=W===null&&await xD($,D,"app.create_channel",{appId:F});if(W&&!K){if(q)H$("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");return r.warn("Cannot set channel because this API key lacks channel.promote_bundle for the target channel"),!1}if(W&&K){let z=await sI0($,D,F,Q);if(U){if(!await xD($,D,"channel.update_settings",{appId:F,channelId:W.id}))return r.warn("Cannot enable device self-assign because this API key lacks channel.update_settings"),rI0(D,F,z,W,G,X,H)}if(!U)return rI0(D,F,z,W,G,X,H);let{error:N,data:w}=await FW0($,{name:J,app_id:F,created_by:Y,version:z,owner_org:Z,...U?{allow_device_self_set:!0}:{}});if(N)await gw(N,()=>`Cannot set channel because this API key does not have the required RBAC permission. ${F0(N)}`);if(w?.id){let L=`${G.hostWeb}/app/${F}/channel/${w.id}`;if(W.rollout_enabled&&W.rollout_version!=null)r.warn("This channel has an active progressive rollout. Linking this bundle as the stable version resets that rollout, so devices receive the new bundle instead of the previous rollout target.");else if(w.public)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${L}`);if(X)r.info(`Bundle url: ${L}`)}return!0}if(O){let{error:z,data:N}=await G$("channel",{apikey:D,method:"POST",body:{app_id:F,channel:J,version:Q,...U?{allow_device_self_set:!0}:{}},supaHost:H?.supaHost,supaAnon:H?.supaAnon});if(z)await gw(z,async()=>`Cannot create channel and set its bundle because this API key does not have the required RBAC permission. ${await jg(z)}`);let w=N,L=Number(w?.id),M=w?.public===!0;if(!Number.isSafeInteger(L)||typeof w?.public!=="boolean"){let R=await Eg($,F,J,!1),P=Number(R?.id);if(!Number.isSafeInteger(P)){if(!Number.isSafeInteger(L))return r.info("Your update is now available \uD83C\uDF89"),!0}else L=P,M=R?.public===!0}let B=`${G.hostWeb}/app/${F}/channel/${L}`;if(M)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${B}`);if(X)r.info(`Bundle url: ${B}`);return!0}let V="Cannot create target channel because this API key lacks app.create_channel";if(q)H$(V);return r.warn(V),!1}async function ty$($,D,X,Q,J,Y,Z,F,G,W,q,U,H=!1){if(!F)H$(`Cannot set rollout, channel ${J} must already exist with a stable bundle`);if(!F.version)H$(`Cannot set rollout, channel ${J} needs a stable bundle before using progressive rollout`);if(H&&F.rollout_version==null)H$(`Cannot advance rollout, channel ${J} has no rollout target to promote to stable`);let K=await sI0($,D,Y,Q),[O,V]=await Promise.all([xD($,D,"channel.promote_bundle",{appId:Y,channelId:F.id}),xD($,D,"channel.update_settings",{appId:Y,channelId:F.id})]);if(!O)H$("Cannot set rollout because this API key lacks channel.promote_bundle for the target channel");if(!V)H$("Cannot set rollout because this API key lacks channel.update_settings for the target channel");let z=F.rollout_version===K&&G>0,{error:N}=await G$("channel",{apikey:D,method:"POST",body:{app_id:Y,channel:J,rolloutVersion:Q,rolloutPercentageBps:G,rolloutEnabled:G>0,...H?{advanceRollout:!0}:{},...z?{rolloutPaused:!1}:{},...W!=null?{rolloutCacheTtlSeconds:W}:{},...q?{allow_device_self_set:!0}:{}},supaHost:U?.supaHost,supaAnon:U?.supaAnon});if(N)await gw(N,async()=>`Cannot set rollout in channel ${await jg(N)}`);let w=`${Z.hostWeb}/app/${Y}/channel/${F.id}`;if(H)r.info(`Promoted the previous rollout to stable on ${J} and set @${Q} as the new rollout target (${pI0(G)})`);else r.info(`Set ${Y} channel ${J} rollout target to @${Q} (${pI0(G)})`);if(X)r.info(`Bundle url: ${w}`);return!0}async function ay$($,D,X){let{error:Q,data:J}=await D.from("apps").select("default_upload_channel").eq("app_id",$).single();if(Q)throw Error(`Cannot find default upload channel: ${F0(Q)}. You can set it here: ${X}/app/${$}/info`);return J.default_upload_channel}async function Ag($,D,X=!1,Q){return bt(Q,()=>sy$($,D,X))}async function sy$($,D,X){if(!X)UD().intro(`Uploading with CLI version ${$D.version}`);let Q,J=bQ();await C1(UD());let{s3Region:Y,s3Apikey:Z,s3Apisecret:F,s3BucketName:G,s3Endpoint:W,s3Port:q,s3SSL:U}=D;if(D.verbose)r.info("[Verbose] Starting upload process with options:"),r.info(` - API key: ${D.apikey?"provided":"from saved key"}`),r.info(` - Path: ${D.path||"from capacitor config"}`),r.info(` - Channel: ${D.channel||"from default upload channel"}`),r.info(` - Bundle: ${D.bundle||"auto-detected"}`),r.info(` - External: ${D.external||"false"}`),r.info(` - Encryption: ${D.keyV2||D.keyDataV2?"v2":D.key===!1?"disabled":"auto"}`),r.info(` - Upload method: ${D.tus?"TUS":D.zip?"ZIP":"auto"}`),r.info(` - Delta updates: ${D.delta||D.partial?"enabled":"disabled"}`);let H=Py$(D);if(D.verbose)r.info("[Verbose] API key retrieved successfully");let K=await _A0(D,{appId:$});if(D.verbose)r.info(l9(D.mode)?`[Verbose] Cordova project config resolved (webDir: ${K.config.webDir})`:"[Verbose] Capacitor config loaded successfully");D.userRequestedDelta=!!(D.partial||D.delta||D.partialOnly||D.deltaOnly);let O=XA0(K?.config?.plugins?.CapacitorUpdater),V=E4({silent:X});if(O&&D.delta===void 0){if(V){r.info("\uD83D\uDCA1 Instant updates are enabled in your config"),r.info(" Delta updates send only changed files instead of the full bundle");let _0=await g$({message:"Enable delta updates for this upload? (Recommended with instant updates)",initialValue:!0});if(!r0(_0)&&_0){if(D.delta=!0,D.verbose)r.info("[Verbose] Delta updates auto-enabled due to instant update configuration")}}else if(!X){if(D.delta!==!1){if(D.delta=!0,D.verbose)r.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to instant update configuration")}}}let z=await t30();if(D.verbose)r.info("[Verbose] Remote file config retrieved:"),r.info(` - Max upload length: ${Math.floor(z.maxUploadLength/1024/1024)} MB`),r.info(` - Alert upload size: ${Math.floor(z.alertUploadSize/1024/1024)} MB`),r.info(` - TUS upload: ${z.TUSUpload?"enabled":"disabled"}`),r.info(` - TUS upload forced: ${z.TUSUploadForced?"yes":"no"}`),r.info(` - Partial upload: ${z.partialUpload?"enabled":"disabled"}`),r.info(` - Max chunk size: ${Math.floor(z.maxChunkSize/1024/1024)} MB`);let{appid:N,path:w}=await Sy$($,D,K.config,V);if(D.verbose)r.info(`[Verbose] App ID: ${N}, Build path: ${w}`);if(tH(D.autoBump)&&D.bundle)H$("Cannot use --bundle (-b) and --auto-bump together. Omit --bundle to auto-increment from the latest remote version.");let L=await Cy$(K.config,D);if(D.verbose)r.info(`[Verbose] Bundle version: ${L}`);let M=D.external?"external":"r2-direct",B="none";if(await _y$(D,w,V),D.verbose)r.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");let R=await J6();if(D.verbose)r.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if(D.supaHost&&D.supaAnon){if(r.info("Using custom supabase instance from provided options"),R.supaHost=D.supaHost,R.supaKey=D.supaAnon,D.verbose)r.info(`[Verbose] Custom Supabase host: ${D.supaHost}`)}let P=await U$(H,D.supaHost,D.supaAnon);if(D.verbose)r.info("[Verbose] Supabase client created successfully");if(await MD(P,N,X),await n1(P,H,N,"app.upload_bundle",X,!0),D.verbose)r.info("[Verbose] App exists and API key has app.upload_bundle permission");let v=await M1(P,H);if(D.verbose)r.info(`[Verbose] User verified successfully, user_id: ${v}`);let j=Ng(D.channel);if(D.channel!==void 0&&j.length===0)H$("Missing channel name, pass one channel or a comma-separated list with --channel");let k=j.length>0?null:await ay$(N,P,R.hostWeb),x=j.length>0?j:Ng(k||"production");if(x.length===0)H$("Cannot resolve target channel");let g=vG(x),d=x,D0=cy$(D);if(D.verbose)r.info(`[Verbose] Target channel${x.length>1?"s":""}: ${g}`);let h=await PD(H,N,{supaHost:D.supaHost,supaAnon:D.supaAnon});if(D.verbose)r.info(`[Verbose] Organization ID: ${h}`);if(await s30(P,h,$D.version),D.verbose)r.info("[Verbose] Remote CLI messages checked");if(await e30(P,h,N,!0),D.verbose)r.info("[Verbose] Plan validation passed");if(D.verbose)r.info("[Verbose] Trial check completed");let A=tH(D.autoBump);if(A){let _0;if(A==="ai"){let i0=await ZA0({supabase:P,appid:N,channels:x,path:w,apikey:H,options:{supaHost:D.supaHost,supaAnon:D.supaAnon}});r.info(`\uD83E\uDD16 AI auto-bump chose ${i0.level}: ${i0.reason}`),_0=i0.level}else _0=A;if(D.verbose)r.info(`[Verbose] Resolving auto-bump (${_0}) version from channel/app remote versions...`);if(L=await py$(P,N,x,L,_0),D.verbose)r.info(`[Verbose] Bundle version after auto-bump: ${L}`)}if(D.autoSetBundle){if(l9(D.mode))r.warn("--auto-set-bundle is not supported in Cordova mode (no capacitor.config to update)");else if(await r30({version:L}),D.verbose)r.info(`[Verbose] Auto-set bundle version in ${K.path}`)}if(r.info(`Upload ${N}@${L} started from path "${w}" to Capgo cloud`),D.verbose)r.info(`[Verbose] Checking if version ${L} already exists...`);let T=await xy$(P,N,L,D.versionExistsOk,V);if(D.verbose)r.info(`[Verbose] Version exists check: ${T?typeof T==="string"?`retry with ${T}`:"yes (skipping)":"no (continuing)"}`);if(T===!0)return{success:!0,appId:N,skipped:!0,reason:"VERSION_EXISTS",bundle:L,checksum:null,encryptionMethod:B,storageProvider:M};if(typeof T==="string")return r.info(`Retrying upload with new version: ${T}`),Ag($,{...D,bundle:T,autoBump:void 0},X);if(D.external&&!D.external.startsWith("https://"))H$(`External link should should start with "https://" current is "${D.external}"`);let y=null,m="",c;if(!D.external){if(D.verbose)r.info(`[Verbose] Preparing bundle file from path: ${w}`);let _0=K.config?.plugins?.CapacitorUpdater?.publicKey;if(c=await my$(w,D,H,h,N,z.maxUploadLength,z.alertUploadSize,_0),Q=c.sessionKey,y=c.zipped,B=c.encryptionMethod,m=c.finalKeyData,D.verbose)r.info("[Verbose] Bundle prepared:"),r.info(` - Size: ${Math.floor((c.zipped?.byteLength??0)/1024)} KB`),r.info(` - Checksum: ${c.checksum}`),r.info(` - Encryption: ${c.encryptionMethod}`),r.info(` - IV Session Key: ${c.ivSessionKey?"present":"none"}`),r.info(` - Key ID: ${c.keyId||"none"}`);if(!D.ignoreChecksumCheck&&D0==null&&!D.rolloutAdvance){if(D.verbose)r.info("[Verbose] Checking for duplicate checksum...");if(d=await yy$(P,N,x,c.checksum),D.verbose)r.info("[Verbose] Checksum is unique or already satisfied across target channels")}}let l=vG(d);if(D.verbose)r.info(`[Verbose] Checking compatibility with channel${d.length>1?"s":""} ${l}...`);let Z0=[];for(let _0 of d){let i0=await vy$(P,J,D,_0,N,L,h);Z0.push({channel:_0,...i0})}let n=Z0.find((_0)=>_0.nativePackages)?.nativePackages,Y0=ky$(Z0),M0=Z0.filter((_0)=>_0.compatibility.result==="incompatible"),O0=M0.length>0,S0=M0.reduce((_0,i0)=>Math.max(_0,i0.incompatibleCount),0),O$=vG(M0.map((_0)=>_0.channel)),K0=()=>{let _0=O$||l;F$({channel:"bundle",event:"Bundle Upload Blocked",apikey:D.apikey,appId:N,orgId:h,tags:{reason:"incompatible",channel:_0,channel_name:_0,channel_names:_0,channel_count:M0.length||d.length,incompatible_count:S0,interactive:V}});let B1=`Upload aborted: bundle is incompatible with ${M0.length===1?"channel":"channels"} "${_0}" (${S0} native package(s) changed). A native build / app-store update is required. Run a native build with Capgo Builder (https://capgo.app/docs/cli/cloud-build/), or remove --fail-on-incompatible to upload anyway.`;throw r.error(B1),new oI0(B1)};if(O0&&!X&&!D.acceptIncompatible){if(D.failOnIncompatible&&!V)K0();let _0=await Z2(N)!==null,i0=await WA0({incompatible:O0,interactive:V,hasCredentials:_0,appId:N,orgId:h,apikey:H,incompatibleCount:S0});if(i0==="abort")Rg();if(i0!=="continue")return{success:!0,appId:N,skipped:!0,reason:"NATIVE_BUILD",builderAction:i0,bundle:L,checksum:null,encryptionMethod:B,storageProvider:M};if(FA0({incompatible:O0,failOnIncompatible:!!D.failOnIncompatible,interactive:V,builderAction:i0}))K0()}else if(O0&&D.acceptIncompatible&&!X)r.warn("Proceeding because --accept-incompatible was set. The incompatible-bundle crash warning will not be emailed.");if(D.verbose)r.info("[Verbose] Compatibility check completed:"),r.info(` - Native packages: ${n?n.length:0}`),r.info(` - Min update version: ${Y0||"none"}`);if(D.deleteLinkedBundleOnUpload)r.warn(`Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the target channel${d.length>1?"s":""}: ${l}.`),r.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let b0=d.length>0,S=b0?await ry$(P,H,N,d,!!D.selfAssign,D0,!!D.rolloutAdvance):new Map,I={name:L,app_id:N,session_key:D.external?D.ivSessionKey:c?.ivSessionKey,external_url:D.external,storage_provider:M,min_update_version:Y0,native_packages:n,owner_org:h,user_id:v,checksum:D.external?D.encryptedChecksum:c?.checksum,link:D.link||null,comment:D.comment||null,key_id:c?.keyId||void 0,cli_version:$D.version};if(D.external){if(D.verbose)r.info(`[Verbose] Using external URL: ${D.external}`);if(await e0(H,{channel:"app",event:"App external",org_id:h,tracking_version:2,tags:{"app-id":N}},D.verbose),D.verbose)r.info("[Verbose] External bundle configured:"),r.info(` - URL: ${D.external}`),r.info(` - IV Session Key: ${D.ivSessionKey?"provided":"none"}`),r.info(` - Encrypted Checksum: ${D.encryptedChecksum?"provided":"none"}`)}if(D.zip){if(D.tus=!1,D.verbose)r.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!z.TUSUpload||D.external){if(D.tus=!1,D.verbose)r.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if(D.tus=D.tus||z.TUSUploadForced,D.verbose)r.info(`[Verbose] Upload method: ${D.tus?"TUS (resumable)":"Standard"}`);if(!z.partialUpload||D.external){if(D.delta=!1,D.verbose&&D.external)r.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if(D.delta=D.delta||D.partial||D.deltaOnly||D.partialOnly||z.partialUploadForced,D.verbose)r.info(`[Verbose] Delta updates: ${D.delta?"enabled":"disabled"}`);if(D.encryptPartial&&B==="v1")H$("You cannot encrypt the partial update if you are not using the v2 encryption method");let a="5.30.0",p="6.30.0",e="7.30.0",R$=!1;if(D.delta&&B==="v2"&&!D.encryptPartial){let _0=Y1(wg()),i0=await _6("@capgo/capacitor-updater",_0,D.packageJson),B1;try{B1=i0?a$(i0):void 0}catch{B1=void 0}if(i0&&B1&&xR(B1,a$("6.14.4"))){if(r.info(`Auto-enabling partial update encryption for updater version ${B1} (> 6.14.4)`),D.verbose)r.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");D.encryptPartial=!0}}if(D.delta&&(D.encryptPartial||B==="v2")){let _0=Y1(wg()),i0=await _6("@capgo/capacitor-updater",_0,D.packageJson),B1;try{B1=i0?a$(i0):void 0}catch{B1=void 0}if(i0&&B1){if(R$=!r4(B1,a,p,e),D.verbose&&R$)r.info(`[Verbose] Using hex checksum format for updater version ${B1}`)}}if(D.verbose&&D.delta)r.info("[Verbose] Preparing delta/partial update manifest...");let C0=D.delta?await dI0(w,H,h,N,D.encryptPartial?B:"none",m,R$):[];if(D.verbose&&D.delta)r.info(`[Verbose] Delta manifest prepared with ${C0.length} files`);if(D.delta&&C0.length>QU)H$(ON(C0.length));if(D.verbose)r.info("[Verbose] Creating version record in database...");if(await Bg(P,I,"add"),D.verbose)r.info("[Verbose] Version record created successfully");if(D.dryUpload){if(D.verbose)r.info("[Verbose] Dry upload mode: skipping bundle publishing and channel assignment");if(!X)UD().outro("Dry upload saved bundle metadata without uploading files or updating channels");return{success:!0,appId:N,bundle:L,checksum:I.checksum??null,encryptionMethod:B,sessionKey:Q?Q.toString("base64"):void 0,ivSessionKey:typeof I.session_key==="string"?I.session_key:void 0,storageProvider:I.storage_provider,reason:"DRY_UPLOAD"}}if(D.tusChunkSize&&D.tusChunkSize>z.maxChunkSize)r.error(`Chunk size ${D.tusChunkSize} is greater than the maximum chunk size ${z.maxChunkSize}, using the maximum chunk size`),D.tusChunkSize=z.maxChunkSize;else if(!D.tusChunkSize)D.tusChunkSize=z.maxChunkSize;if(D.verbose)r.info(`[Verbose] TUS chunk size: ${Math.floor(D.tusChunkSize/1024/1024)} MB`);if(y&&fy$(D)){if(!G||!W||!Y||!Z||!F||!q)H$("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(r.info("Uploading to S3"),D.verbose)r.info("[Verbose] S3 configuration:"),r.info(` - Endpoint: ${W}`),r.info(` - Region: ${Y}`),r.info(` - Bucket: ${G}`),r.info(` - Port: ${q}`),r.info(` - SSL: ${U?"enabled":"disabled"}`);let _0=`${U?"https":"http"}://${W}${q?`:${q}`:""}`,i0=new Rw({endPoint:W,region:Y,port:q,pathStyle:!0,bucket:G,accessKey:Z,secretKey:F}),B1=`${N}-${L}`,j$=encodeURIComponent(B1);if(D.verbose)r.info(`[Verbose] Uploading to S3 as: ${B1}`);try{await i0.putObject(B1,Uint8Array.from(y)),I.external_url=`${_0}/${j$}`,I.storage_provider="external",await Bg(P,I,"update")}catch(j1){try{await EN(H,N,L,D)}catch(zD){H$(`Cannot upload bundle to S3 ${F0(j1)}. Cleanup of the incomplete version also failed (${F0(zD)}); delete bundle ${L} manually before retrying.`)}H$(`Cannot upload bundle to S3 ${F0(j1)}`)}if(D.verbose)r.info(`[Verbose] S3 upload complete, external URL: ${I.external_url}`)}else if(y){if(tI0(D)){if(D.verbose)r.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await dy$(H,P,N,L,h,y,D,D.tusChunkSize)}else if(D.verbose)r.info("[Verbose] Skipping full bundle upload (delta-only mode)");let _0=null;try{if(D.dryUpload){if(D.delta=!1,D.verbose)r.info("[Verbose] Dry upload mode: skipping delta upload")}let i0=I.session_key&&D.encryptPartial&&Q?{sessionKey:Q,ivSessionKey:I.session_key}:void 0;if(D.verbose&&D.delta)r.info("[Verbose] Starting delta/partial file upload..."),r.info(` - Manifest entries: ${C0.length}`),r.info(` - Encryption: ${i0?"enabled":"disabled"}`);if(_0=D.delta?await cI0(H,C0,w,N,h,i0,D):null,D.verbose&&_0)r.info(`[Verbose] Delta upload complete with ${_0.length} files`)}catch(i0){if(D.userRequestedDelta)throw i0;if(r.info(`Failed to upload partial files to capgo cloud. Error: ${F0(i0)}. This is not a critical error, the bundle has been uploaded without the partial files`),D.verbose)r.info(`[Verbose] Delta upload error details: ${F0(i0)}`)}if(_0?.length){if(D.verbose)r.info(`[Verbose] Writing ${_0.length} manifest rows via set_manifest...`);try{await ZW0(H,N,L,_0,D)}catch(i0){try{await EN(H,N,L,D)}catch(B1){H$(`Cannot set bundle manifest ${F0(i0)}. Cleanup of the incomplete version also failed (${F0(B1)}); delete bundle ${L} manually before retrying.`)}H$(`Cannot set bundle manifest ${F0(i0)}`)}if(D.verbose)r.info("[Verbose] Manifest rows written (sizes filled by backend from R2)")}if(I.storage_provider="r2",I.manifest=null,D.verbose)r.info("[Verbose] Updating version record with storage provider...");if(await SA0({apikey:H,appId:N,bundle:L,supaHost:D.supaHost,supaAnon:D.supaAnon,reporter:UD()},async()=>{await Bg(P,I,"update")}),D.verbose)r.info("[Verbose] Version record updated successfully")}let h$=await xD(P,H,"bundle.delete",{appId:N});if(D.verbose)r.info("[Verbose] Permissions:"),r.info(" - app.upload_bundle: yes"),r.info(` - bundle.delete: ${h$?"yes":"no"}`),r.info(" - channel permissions: checked per target channel");let j0=D.deleteLinkedBundleOnUpload&&h$,s0=j0?await Promise.all(d.map(async(_0)=>({channel:_0,version:await eI0(P,N,_0)}))):[];if(D.deleteLinkedBundleOnUpload&&!j0)r.warn("Cannot delete linked bundle on upload because this API key lacks bundle.delete");let X$=new Set(d).size,E$=new Set;for(let _0 of d){if(D.verbose)r.info(`[Verbose] Setting bundle ${L} to channel ${_0}...`);let i0=S.has(_0)?S.get(_0)??null:await Eg(P,N,_0),B1=D.rolloutAdvance||D0!=null,j$=i0?.rollout_percentage_bps,j1=D0??j$??0;if(D.rolloutAdvance&&D0==null&&!((j$??0)>0))H$(`Cannot advance rollout, channel ${_0} has no rollout percentage to reuse. Pass --rollout or --rollout-percentage-bps`);let zD=B1?await ty$(P,H,!!D.bundleUrl,L,_0,N,R,i0,j1,D.rolloutCacheTtlSeconds,D.selfAssign,D,!!D.rolloutAdvance):await oy$(P,H,!!D.bundleUrl,L,_0,v,h,N,R,i0,b0,D.selfAssign,D);if(zD)E$.add(_0);if(D.verbose)r.info(`[Verbose] Channel ${_0} ${zD?"updated successfully":"was not updated"}`)}if(j0){let _0=new Set;for(let i0 of s0){if(!E$.has(i0.channel))continue;if(!i0.version||_0.has(i0.version.id))continue;if(D.verbose)r.info(`[Verbose] Deleting previously linked bundle in channel ${i0.channel}...`);await iy$(P,i0.version),_0.add(i0.version.id)}}if(E$.size===0)r.warn("Cannot set channel because this API key lacks the required RBAC permission");if(b0&&E$.size!==X$)H$("Cannot complete upload because one or more target channels were not updated");if(D.verbose)r.info("[Verbose] Sending upload event...");await e0(H,{channel:"app",event:"App Uploaded",org_id:h,tracking_version:2,tags:{"app-id":N,bundle:L}},D.verbose),await e0(H,{channel:"app",event:"Bundle Uploaded",org_id:h,tracking_version:2,tags:{"app-id":N,bundle:L},notifyConsole:!0}).catch(()=>{});for(let _0 of Z0){if(_0.compatibility.result!=="incompatible")continue;F$({channel:"bundle",event:"Bundle Incompatible",apikey:H,appId:N,orgId:h,tags:{source:"upload",channel:_0.channel,channel_name:_0.channel,channel_overwritten:E$.has(_0.channel),version_new_name:L,..._0.compatibility.versionOldId?{version_old_id:_0.compatibility.versionOldId}:{},..._0.compatibility.versionOldName?{version_old_name:_0.compatibility.versionOldName}:{},...D.acceptIncompatible?{incompatibility_accepted:!0}:{}}})}let G1={success:!0,appId:N,bundle:L,updatedChannels:Array.from(E$),checksum:I.checksum??null,encryptionMethod:B,sessionKey:Q?Q.toString("base64"):void 0,ivSessionKey:typeof I.session_key==="string"?I.session_key:void 0,storageProvider:I.storage_provider};if(D.verbose)r.info("[Verbose] Upload completed successfully:"),r.info(` - Bundle: ${G1.bundle}`),r.info(` - Checksum: ${G1.checksum}`),r.info(` - Encryption: ${G1.encryptionMethod}`),r.info(` - Storage: ${G1.storageProvider}`);if(V&&!G1.skipped){let _0=D.showReplicationProgress;if(_0===void 0)_0=await sj0({preferenceKey:"uploadShowReplicationProgress",message:"Show Capgo global replication progress for this upload so you can confirm rollout in all regions?",initialValue:!1,rememberMessage:"Remember this replication progress preference for future uploads on this machine?"});if(_0)await DA0({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:V})}if(!X&&!G1.skipped)UD().outro("Time to share your update to the world \uD83C\uDF0D");return G1}Q$();r8();FD();M6();mW();p0();import{randomUUID as Hf$}from"node:crypto";import{existsSync as Kf$,writeFileSync as Of$}from"node:fs";import{cwd as Vf$}from"node:process";import{existsSync as $T0,readFileSync as Ig}from"node:fs";import{createRequire as ey$}from"node:module";import{dirname as Tg,join as $f$}from"node:path";import Df$ from"node:process";var QK="@capgo/capacitor-updater";function Xf$($){if(!$T0($))return null;try{return JSON.parse(Ig($,"utf-8"))}catch{return null}}function Qf$($,D){let X=Xf$($);if(!X)return{version:null,section:null};let Q=["dependencies","devDependencies","optionalDependencies"];for(let J of Q){let Y=X[J];if(!Y||!Object.hasOwn(Y,D))continue;let Z=Y[D];return{version:typeof Z==="string"?Z:String(Z),section:J}}return{version:null,section:null}}function Jf$($,D){let Q=Tg($);while(!0){let J=$f$(Q,"node_modules",D,"package.json");if($T0(J))try{let Z=JSON.parse(Ig(J,"utf-8"));if(typeof Z.version==="string")return Z.version}catch{return null}let Y=Tg(Q);if(Y===Q)break;Q=Y}if(!Df$.versions.pnp)return null;try{let Y=ey$($).resolve(`${D}/package.json`),Z=JSON.parse(Ig(Y,"utf-8"));if(typeof Z.version==="string")return Z.version}catch{return null}return null}function Yf$($,D){let X=Tg($),Q=Qf$($,D),J=Jf$($,D),Y=[];if(!Q.version)Y.push(`Missing ${D} in ${$}`);if(!J)Y.push(`Cannot resolve ${D} from ${X}/node_modules`);return{packageJsonPath:$,projectDir:X,declaredVersion:Q.version,declaredIn:Q.section,installedVersion:J,ready:Y.length===0,details:Y}}function xG($){return Yf$($,QK)}Q$();import{spawnSync as Zf$}from"node:child_process";import{existsSync as XT0,statSync as Ff$}from"node:fs";import{dirname as Gf$,join as Wf$,resolve as QT0}from"node:path";import{cwd as DT0}from"node:process";p0();function Cg($){return`0.0.1-beta.local-${$}`}function Pg($){let D=Y1(DT0()),X=TG($);if(X?.length)for(let Q of X)for(let J of[DT0(),D]){let Y=QT0(J,Q);if(XT0(Y))return Y}return Wf$(D,"package.json")}function qf$($){return $?.trim()||"latest"}function Uf$($,D,X){let Q=`${QK}@${D}`,J=$.installCommand.split(/\s+/).filter(Boolean),Y=J[0];if(!Y)return null;if(!X?.trim())switch($.pm){case"yarn":return{command:"yarn",args:["add",Q]};case"bun":return{command:"bun",args:["add",Q]};case"pnpm":return{command:"pnpm",args:["add",Q]};default:return{command:Y,args:[...J.slice(1),Q]}}if($.pm==="yarn"||$.pm==="bun")return{command:Y,args:J.slice(1)};return{command:Y,args:[...J.slice(1),"--force",Q]}}async function JT0($,D){C.warn(`Bundle version "${$}" is not valid semver (https://semver.org/).`);let X=await g$({message:`Use local fallback version ${D} instead?`,initialValue:!0});if(r0(X)||!X)return null;return C.info(`Using bundle version ${D}`),D}async function YT0($){let D=await U4({message:$,validate:(X)=>{let Q=X?.trim();if(!Q)return"Value is required";let J=QT0(Q);if(!XT0(J))return`Path does not exist: ${J}`;if(!Ff$(J).isDirectory())return`Path is not a directory: ${J}`}});if(r0(D))return null;return D.trim()}async function ZT0($){let D=Pg($),X=xG(D);if(X.ready)return!0;C.warn(`Cannot find ${QK} in node_modules.`);let Q=await g$({message:`Install ${QK} now?`,initialValue:!0});if(r0(Q)||!Q)return!1;let J=bQ(),Y=qf$(X.declaredVersion),Z=Uf$(J,Y,X.declaredVersion);if(!Z)return!1;if(Zf$(Z.command,Z.args,{cwd:Gf$(D),stdio:"inherit",shell:!1}).status!==0)return!1;return xG(D).ready}_$();var zf$=20;function Lf$($){console.log(JSON.stringify($,null,2))}function kG($){console.error(F0($))}function Mf$($){if($.context?.message)kG({error:$.message,message:$.context.message});else kG({error:$.message})}async function FT0($,D,X=!1){let{json:Q}=D,{bundle:J,path:Y}=D,Z=!Q&&!X;try{if(Z)await C1();let F=await z$(),G=E4({silent:Q||X}),W=await Cw({explicitAppId:$,config:F?.config,packageJsonPaths:TG(D.packageJson),interactive:G,json:Q}),q=Hf$().split("-")[0],U=b5("",D.packageJson);if(J=J||U||Cg(q),Z)o0(`Zipping ${W??"app"}@${J}`);if(J&&!hQ.test(J)){if(G){let j=await JT0(J,Cg(q));if(j)J=j}if(!hQ.test(J)){let j=`Your bundle name ${J}, is not valid it should follow semver convention : https://semver.org/`;if(!X)if(Q)kG({error:"invalid_semver"});else C.error(j);throw Error("Invalid bundle version format")}}if(Y=Y||F?.config?.webDir,!Y&&G){let j=await YT0("Enter the path to your built web assets (webDir):");if(j)Y=j}if(!W||!J||!Y){if(!X)if(Q)kG({error:"missing_argument"});else C.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project");throw Error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project")}if(Z)C.info(`Started from path "${Y}"`);if(D.codeCheck!==!1&&!D.ignoreNotifyAppReady){if(!z8(Y,"notifyAppReady"))if(G){if(await xw({webDir:Y,interactive:G,json:Q})!=="skipped"&&!z8(Y,"notifyAppReady"))throw new G0("notifyAppReady() is missing in build folder")}else throw Q?new G0("notifyAppReady_not_in_source_code",{message:vw(Y)}):new G0(vw(Y));if(!AG(Y)){if(!X)if(Q)kG({error:"index_html_not_found"});else C.error(`index.html is missing in the root folder of ${Y}`);throw Error("index.html is missing in root folder")}}let K=await RN(Y);if(Z)C.info(`Zipped ${K.byteLength} bytes`);let O=Z?d1():null;if(O)O.start("Calculating checksum");let V=Y1(Vf$()),z=Pg(D.packageJson),N=xG(z);if(!N.ready&&G&&await ZT0(D.packageJson))N=xG(z);if(!N.ready){if(!X)C.warn("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");throw Error("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager")}let w=await _6("@capgo/capacitor-updater",V,D.packageJson),L=!1,M;try{M=w?a$(w):void 0}catch{M=void 0}if(M)L=!r4(M,void 0,void 0,"7.0.0");else if(w==="link:@capgo/capacitor-updater"){if(!X)C.warn("Using local @capgo/capacitor-updater. Assuming v7");L=!0}let B=await w5(K,D.keyV2||Kf$(W6)||L?"sha256":"crc32");if(O)O.stop(`Checksum ${L?"SHA256":"CRC32"}: ${B}`);let R=Math.floor(K.byteLength/1024/1024);if(R>zf$&&Z)C.warn(`WARNING !!
|
|
709
|
+
Bundle uploaded \uD83D\uDCAA in 0 seconds`),Z.verbose)r.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let K=await J6();if(Z.verbose)r.info("[Verbose] Local config retrieved for upload");if(Z.multipart!==void 0&&Z.multipart||Z.tus!==void 0&&Z.tus){if(Z.multipart)r.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else r.info("Uploading bundle with TUS protocol");if(Z.verbose)r.info("[Verbose] Starting TUS resumable upload..."),r.info(` - Host: ${K.hostWeb}`),r.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(await YW0($,Y,J,X,Q,G,K,F),q=!0,Z.verbose)r.info("[Verbose] TUS upload completed, updating database with R2 path...");let O=`orgs/${J}/apps/${X}/${Q}.zip`,{error:V}=await D.from("app_versions").update({r2_path:O}).eq("name",Q).eq("app_id",X);if(V){if(r.error(`Cannot finish TUS upload ${F0(V)}`),Z.verbose)r.info(`[Verbose] Database update failed: ${F0(V)}`);throw Error("Cannot finish TUS upload")}if(Z.verbose)r.info(`[Verbose] Database updated with R2 path: ${O}`)}else{if(Z.verbose)r.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let O=await QW0($,X,Q,Z);if(!O){if(r.error("Cannot get upload url"),Z.verbose)r.info("[Verbose] Failed to retrieve presigned upload URL from database");throw Error("Cannot get upload url")}let V=Z.timeout||n30;if(Z.verbose)r.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),r.info(` - Timeout: ${V}ms`),r.info(" - Retry attempts: 0 (standard upload does not retry, use --tus for resumable retries)"),r.info(" - Content-Type: application/zip");let z=new AbortController,N=setTimeout(()=>z.abort(),V);try{let w=await fetch(O,{method:"PUT",body:Y,headers:{"Content-Type":"application/zip"},signal:z.signal});if(!w.ok)throw Error(`HTTP error! status: ${w.status}`)}catch(w){if(z.signal.aborted||w?.name==="AbortError"){let L=Error(p30(V));throw L.name=lk,L}throw w}finally{clearTimeout(N)}if(Z.verbose)r.info("[Verbose] HTTP PUT upload completed successfully")}}catch(K){let V=((performance.now()-W)/1000).toFixed(2);if(G.error(`Failed to upload bundle ( after ${V} seconds)`),Z.verbose)r.info(`[Verbose] Upload failed after ${V} seconds`),r.info(`[Verbose] Error type: ${K instanceof Error?"Error":typeof K}`);if(K instanceof Error&&K.name===lk)r.error(K.message);else if(K instanceof Error&&K.message.includes("HTTP error"))try{let z=K.message.match(/status: (\d+)/),N=z?z[1]:"unknown";r.error(`Upload failed with status ${N}: ${K.message}`)}catch{r.error(`Upload failed: ${K.message}`)}else{if(Z.verbose)r.info(`[Verbose] Non-HTTP error: ${F0(K)}`);if(!Z.tus)r.error(`Cannot upload bundle ( try again with --tus option) ${F0(K)}`);else r.error(`Cannot upload bundle please contact support if the issue persists ${F0(K)}`)}if(Z.verbose)r.info("[Verbose] Cleaning up failed version from database...");try{if(await EN($,X,Q,Z),Z.verbose)r.info("[Verbose] Failed version cleaned up")}catch(z){r.error(`Cleanup of the incomplete version failed (${F0(z)}); delete bundle ${Q} manually before retrying.`)}throw K instanceof Error?K:Error(String(K))}let H=((performance.now()-W)/1000).toFixed(2);if(G.stop(`Bundle uploaded \uD83D\uDCAA in (${H} seconds)`),Z.verbose)r.info("[Verbose] Upload successful:"),r.info(` - Upload time: ${H} seconds`),r.info(` - Upload method: ${q?"TUS (resumable)":"Standard HTTP PUT"}`),r.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),r.info("[Verbose] Sending performance event...");if(await e0($,{channel:"performance",event:q?"TUS upload zip performance":"Upload zip performance",org_id:J,tracking_version:2,tags:{"app-id":X,time:H}},Z.verbose),Z.verbose)r.info("[Verbose] Performance event sent successfully")}function cy$($){if($.rollout==null&&$.rolloutPercentageBps==null)return;if($.rolloutPercentageBps!=null)return $.rolloutPercentageBps;return Math.round(($.rollout??0)*100)}function pI0($){return`${Number(($/100).toFixed(2))}%`}async function sI0($,D,X,Q){let{data:J}=await $.rpc("get_app_versions",{apikey:D,name_version:Q,appid:X}).single();if(!J)H$("Cannot get version id, cannot set channel");return J}async function ly$($,D,X){let{data:Q,error:J}=await $.rpc("exist_app_versions",{appid:D,name_version:X}).single();if(J)H$(`Cannot check if version ${X} already exists ${F0(J)}`);return!!Q}async function ny$($,D){let{data:X,error:Q}=await $.from("app_versions").select("name").eq("app_id",D).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(Q)return r.warn(`Cannot fetch latest remote version ${F0(Q)}`),null;return X?.name??null}async function iI0($,D,X,Q,J){let Y=X;for(let Z=0;Z<100;Z++){if(!await ly$($,D,Y)){if(Y!==J)r.info(`\uD83D\uDD22 Auto-bumped (${Q}) version from ${J} to ${Y}`);return Y}Y=Tw(Y,Q)}H$(`Could not find a free ${Q}-bumped version after 100 attempts (started from ${J})`)}async function py$($,D,X,Q,J){let Y=X[0],F=(await eI0($,D,Y))?.name??null;if(F)r.info(`\uD83D\uDCE6 Auto-bump base from channel ${Y}: ${F}`);else if(F=await ny$($,D),F)r.info(`\uD83D\uDCE6 Auto-bump base from latest remote app version: ${F}`);if(!F)return r.info(`ℹ️ No remote versions found for auto-bump, keeping local version ${Q}`),iI0($,D,Q,J,Q);let G=Tw(F,J);return iI0($,D,G,J,F)}async function eI0($,D,X){let{data:Q,error:J}=await $.from("channels").select("version:app_versions!channels_version_fkey( id, name, deleted )").eq("app_id",D).eq("name",X);if(J)return r.error(`Cannot delete linked bundle on upload ${F0(J)}`),null;if(Q.length===0)return r.warn("No linked bundle found in the channel you are trying to upload to"),null;let Y=Q[0].version;if(!Y)return r.warn("No linked bundle found in the channel you are trying to upload to"),null;if(Y.deleted)return r.warn("The linked bundle is already deleted"),null;return Y}async function iy$($,D){if(!D)return;let{error:X}=await $.from("app_versions").update({deleted:!0}).eq("id",D.id);if(X){r.error(`Cannot delete linked bundle on upload ${F0(X)}`);return}r.info(`Linked bundle ${D.name} deleted`)}async function Eg($,D,X,Q=!0){let{data:J,error:Y}=await $.from("channels").select("id, public, version, rollout_version, rollout_enabled, rollout_percentage_bps").eq("app_id",D).eq("name",X).maybeSingle();if(Y&&Q)H$(`Cannot check channel ${X}: ${F0(Y)}`);return J}async function ry$($,D,X,Q,J=!1,Y,Z=!1){let F=new Map,G=Y!=null||Z;for(let W of new Set(Q)){let q=await Eg($,X,W);if(q){if(F.set(W,q),!await xD($,D,"channel.promote_bundle",{appId:X,channelId:q.id}))H$("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");if(J||G){if(!await xD($,D,"channel.update_settings",{appId:X,channelId:q.id}))H$(J?"Cannot enable device self-assign because this API key lacks channel.update_settings":"Cannot set rollout because this API key lacks channel.update_settings for the target channel")}if(G&&!q.version)H$(`Cannot set rollout, channel ${W} needs a stable bundle before using progressive rollout`);if(Z&&q.rollout_version==null)H$(`Cannot advance rollout, channel ${W} has no rollout target to promote to stable`);if(Z&&Y==null&&!((q.rollout_percentage_bps??0)>0))H$(`Cannot advance rollout, channel ${W} has no rollout percentage to reuse. Pass --rollout or --rollout-percentage-bps`);continue}if(G)H$(`Cannot set rollout, channel ${W} must already exist with a stable bundle`);if(!await xD($,D,"app.create_channel",{appId:X}))H$("Cannot create target channel because this API key lacks app.create_channel");F.set(W,null)}return F}async function jg($){let D=$?.context;if(D?.json)try{return JSON.stringify(await D.json())}catch{}return F0($)}async function rI0($,D,X,Q,J,Y,Z){let{error:F}=await G$("bundle",{apikey:$,method:"PUT",body:{app_id:D,version_id:X,channel_id:Q.id},supaHost:Z?.supaHost,supaAnon:Z?.supaAnon});if(F)await gw(F,async()=>`Cannot set channel because this API key does not have the required RBAC permission. ${await jg(F)}`);let G=`${J.hostWeb}/app/${D}/channel/${Q.id}`;if(Q.rollout_enabled&&Q.rollout_version!=null)r.warn("This channel has an active progressive rollout. Linking this bundle as the stable version resets that rollout, so devices receive the new bundle instead of the previous rollout target.");else if(Q.public)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${G}`);if(Y)r.info(`Bundle url: ${G}`);return!0}async function oy$($,D,X,Q,J,Y,Z,F,G,W,q=!1,U,H){let K=W!==null&&await xD($,D,"channel.promote_bundle",{appId:F,channelId:W.id}),O=W===null&&await xD($,D,"app.create_channel",{appId:F});if(W&&!K){if(q)H$("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");return r.warn("Cannot set channel because this API key lacks channel.promote_bundle for the target channel"),!1}if(W&&K){let z=await sI0($,D,F,Q);if(U){if(!await xD($,D,"channel.update_settings",{appId:F,channelId:W.id}))return r.warn("Cannot enable device self-assign because this API key lacks channel.update_settings"),rI0(D,F,z,W,G,X,H)}if(!U)return rI0(D,F,z,W,G,X,H);let{error:N,data:w}=await FW0($,{name:J,app_id:F,created_by:Y,version:z,owner_org:Z,...U?{allow_device_self_set:!0}:{}});if(N)await gw(N,()=>`Cannot set channel because this API key does not have the required RBAC permission. ${F0(N)}`);if(w?.id){let L=`${G.hostWeb}/app/${F}/channel/${w.id}`;if(W.rollout_enabled&&W.rollout_version!=null)r.warn("This channel has an active progressive rollout. Linking this bundle as the stable version resets that rollout, so devices receive the new bundle instead of the previous rollout target.");else if(w.public)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${L}`);if(X)r.info(`Bundle url: ${L}`)}return!0}if(O){let{error:z,data:N}=await G$("channel",{apikey:D,method:"POST",body:{app_id:F,channel:J,version:Q,...U?{allow_device_self_set:!0}:{}},supaHost:H?.supaHost,supaAnon:H?.supaAnon});if(z)await gw(z,async()=>`Cannot create channel and set its bundle because this API key does not have the required RBAC permission. ${await jg(z)}`);let w=N,L=Number(w?.id),M=w?.public===!0;if(!Number.isSafeInteger(L)||typeof w?.public!=="boolean"){let R=await Eg($,F,J,!1),P=Number(R?.id);if(!Number.isSafeInteger(P)){if(!Number.isSafeInteger(L))return r.info("Your update is now available \uD83C\uDF89"),!0}else L=P,M=R?.public===!0}let B=`${G.hostWeb}/app/${F}/channel/${L}`;if(M)r.info("Your update is now available in your public channel \uD83C\uDF89");else r.info(`Link device to this bundle to try it: ${B}`);if(X)r.info(`Bundle url: ${B}`);return!0}let V="Cannot create target channel because this API key lacks app.create_channel";if(q)H$(V);return r.warn(V),!1}async function ty$($,D,X,Q,J,Y,Z,F,G,W,q,U,H=!1){if(!F)H$(`Cannot set rollout, channel ${J} must already exist with a stable bundle`);if(!F.version)H$(`Cannot set rollout, channel ${J} needs a stable bundle before using progressive rollout`);if(H&&F.rollout_version==null)H$(`Cannot advance rollout, channel ${J} has no rollout target to promote to stable`);let K=await sI0($,D,Y,Q),[O,V]=await Promise.all([xD($,D,"channel.promote_bundle",{appId:Y,channelId:F.id}),xD($,D,"channel.update_settings",{appId:Y,channelId:F.id})]);if(!O)H$("Cannot set rollout because this API key lacks channel.promote_bundle for the target channel");if(!V)H$("Cannot set rollout because this API key lacks channel.update_settings for the target channel");let z=F.rollout_version===K&&G>0,{error:N}=await G$("channel",{apikey:D,method:"POST",body:{app_id:Y,channel:J,rolloutVersion:Q,rolloutPercentageBps:G,rolloutEnabled:G>0,...H?{advanceRollout:!0}:{},...z?{rolloutPaused:!1}:{},...W!=null?{rolloutCacheTtlSeconds:W}:{},...q?{allow_device_self_set:!0}:{}},supaHost:U?.supaHost,supaAnon:U?.supaAnon});if(N)await gw(N,async()=>`Cannot set rollout in channel ${await jg(N)}`);let w=`${Z.hostWeb}/app/${Y}/channel/${F.id}`;if(H)r.info(`Promoted the previous rollout to stable on ${J} and set @${Q} as the new rollout target (${pI0(G)})`);else r.info(`Set ${Y} channel ${J} rollout target to @${Q} (${pI0(G)})`);if(X)r.info(`Bundle url: ${w}`);return!0}async function ay$($,D,X){let{error:Q,data:J}=await D.from("apps").select("default_upload_channel").eq("app_id",$).single();if(Q)throw Error(`Cannot find default upload channel: ${F0(Q)}. You can set it here: ${X}/app/${$}/info`);return J.default_upload_channel}async function Ag($,D,X=!1,Q){return bt(Q,()=>sy$($,D,X))}async function sy$($,D,X){if(!X)UD().intro(`Uploading with CLI version ${$D.version}`);let Q,J=bQ();await C1(UD());let{s3Region:Y,s3Apikey:Z,s3Apisecret:F,s3BucketName:G,s3Endpoint:W,s3Port:q,s3SSL:U}=D;if(D.verbose)r.info("[Verbose] Starting upload process with options:"),r.info(` - API key: ${D.apikey?"provided":"from saved key"}`),r.info(` - Path: ${D.path||"from capacitor config"}`),r.info(` - Channel: ${D.channel||"from default upload channel"}`),r.info(` - Bundle: ${D.bundle||"auto-detected"}`),r.info(` - External: ${D.external||"false"}`),r.info(` - Encryption: ${D.keyV2||D.keyDataV2?"v2":D.key===!1?"disabled":"auto"}`),r.info(` - Upload method: ${D.tus?"TUS":D.zip?"ZIP":"auto"}`),r.info(` - Delta updates: ${D.delta||D.partial?"enabled":"disabled"}`);let H=Py$(D);if(D.verbose)r.info("[Verbose] API key retrieved successfully");let K=await _A0(D,{appId:$});if(D.verbose)r.info(l9(D.mode)?`[Verbose] Cordova project config resolved (webDir: ${K.config.webDir})`:"[Verbose] Capacitor config loaded successfully");D.userRequestedDelta=!!(D.partial||D.delta||D.partialOnly||D.deltaOnly);let O=XA0(K?.config?.plugins?.CapacitorUpdater),V=E4({silent:X});if(O&&D.delta===void 0){if(V){r.info("\uD83D\uDCA1 Instant updates are enabled in your config"),r.info(" Delta updates send only changed files instead of the full bundle");let _0=await g$({message:"Enable delta updates for this upload? (Recommended with instant updates)",initialValue:!0});if(!r0(_0)&&_0){if(D.delta=!0,D.verbose)r.info("[Verbose] Delta updates auto-enabled due to instant update configuration")}}else if(!X){if(D.delta!==!1){if(D.delta=!0,D.verbose)r.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to instant update configuration")}}}let z=await t30();if(D.verbose)r.info("[Verbose] Remote file config retrieved:"),r.info(` - Max upload length: ${Math.floor(z.maxUploadLength/1024/1024)} MB`),r.info(` - Alert upload size: ${Math.floor(z.alertUploadSize/1024/1024)} MB`),r.info(` - TUS upload: ${z.TUSUpload?"enabled":"disabled"}`),r.info(` - TUS upload forced: ${z.TUSUploadForced?"yes":"no"}`),r.info(` - Delta upload: ${z.partialUpload?"enabled":"disabled"}`),r.info(` - Max chunk size: ${Math.floor(z.maxChunkSize/1024/1024)} MB`);let{appid:N,path:w}=await Sy$($,D,K.config,V);if(D.verbose)r.info(`[Verbose] App ID: ${N}, Build path: ${w}`);if(tH(D.autoBump)&&D.bundle)H$("Cannot use --bundle (-b) and --auto-bump together. Omit --bundle to auto-increment from the latest remote version.");let L=await Cy$(K.config,D);if(D.verbose)r.info(`[Verbose] Bundle version: ${L}`);let M=D.external?"external":"r2-direct",B="none";if(await _y$(D,w,V),D.verbose)r.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");let R=await J6();if(D.verbose)r.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if(D.supaHost&&D.supaAnon){if(r.info("Using custom supabase instance from provided options"),R.supaHost=D.supaHost,R.supaKey=D.supaAnon,D.verbose)r.info(`[Verbose] Custom Supabase host: ${D.supaHost}`)}let P=await U$(H,D.supaHost,D.supaAnon);if(D.verbose)r.info("[Verbose] Supabase client created successfully");if(await MD(P,N,X),await n1(P,H,N,"app.upload_bundle",X,!0),D.verbose)r.info("[Verbose] App exists and API key has app.upload_bundle permission");let v=await M1(P,H);if(D.verbose)r.info(`[Verbose] User verified successfully, user_id: ${v}`);let j=Ng(D.channel);if(D.channel!==void 0&&j.length===0)H$("Missing channel name, pass one channel or a comma-separated list with --channel");let k=j.length>0?null:await ay$(N,P,R.hostWeb),x=j.length>0?j:Ng(k||"production");if(x.length===0)H$("Cannot resolve target channel");let g=vG(x),d=x,D0=cy$(D);if(D.verbose)r.info(`[Verbose] Target channel${x.length>1?"s":""}: ${g}`);let h=await PD(H,N,{supaHost:D.supaHost,supaAnon:D.supaAnon});if(D.verbose)r.info(`[Verbose] Organization ID: ${h}`);if(await s30(P,h,$D.version),D.verbose)r.info("[Verbose] Remote CLI messages checked");if(await e30(P,h,N,!0),D.verbose)r.info("[Verbose] Plan validation passed");if(D.verbose)r.info("[Verbose] Trial check completed");let A=tH(D.autoBump);if(A){let _0;if(A==="ai"){let i0=await ZA0({supabase:P,appid:N,channels:x,path:w,apikey:H,options:{supaHost:D.supaHost,supaAnon:D.supaAnon}});r.info(`\uD83E\uDD16 AI auto-bump chose ${i0.level}: ${i0.reason}`),_0=i0.level}else _0=A;if(D.verbose)r.info(`[Verbose] Resolving auto-bump (${_0}) version from channel/app remote versions...`);if(L=await py$(P,N,x,L,_0),D.verbose)r.info(`[Verbose] Bundle version after auto-bump: ${L}`)}if(D.autoSetBundle){if(l9(D.mode))r.warn("--auto-set-bundle is not supported in Cordova mode (no capacitor.config to update)");else if(await r30({version:L}),D.verbose)r.info(`[Verbose] Auto-set bundle version in ${K.path}`)}if(r.info(`Upload ${N}@${L} started from path "${w}" to Capgo cloud`),D.verbose)r.info(`[Verbose] Checking if version ${L} already exists...`);let T=await xy$(P,N,L,D.versionExistsOk,V);if(D.verbose)r.info(`[Verbose] Version exists check: ${T?typeof T==="string"?`retry with ${T}`:"yes (skipping)":"no (continuing)"}`);if(T===!0)return{success:!0,appId:N,skipped:!0,reason:"VERSION_EXISTS",bundle:L,checksum:null,encryptionMethod:B,storageProvider:M};if(typeof T==="string")return r.info(`Retrying upload with new version: ${T}`),Ag($,{...D,bundle:T,autoBump:void 0},X);if(D.external&&!D.external.startsWith("https://"))H$(`External link should should start with "https://" current is "${D.external}"`);let y=null,m="",c;if(!D.external){if(D.verbose)r.info(`[Verbose] Preparing bundle file from path: ${w}`);let _0=K.config?.plugins?.CapacitorUpdater?.publicKey;if(c=await my$(w,D,H,h,N,z.maxUploadLength,z.alertUploadSize,_0),Q=c.sessionKey,y=c.zipped,B=c.encryptionMethod,m=c.finalKeyData,D.verbose)r.info("[Verbose] Bundle prepared:"),r.info(` - Size: ${Math.floor((c.zipped?.byteLength??0)/1024)} KB`),r.info(` - Checksum: ${c.checksum}`),r.info(` - Encryption: ${c.encryptionMethod}`),r.info(` - IV Session Key: ${c.ivSessionKey?"present":"none"}`),r.info(` - Key ID: ${c.keyId||"none"}`);if(!D.ignoreChecksumCheck&&D0==null&&!D.rolloutAdvance){if(D.verbose)r.info("[Verbose] Checking for duplicate checksum...");if(d=await yy$(P,N,x,c.checksum),D.verbose)r.info("[Verbose] Checksum is unique or already satisfied across target channels")}}let l=vG(d);if(D.verbose)r.info(`[Verbose] Checking compatibility with channel${d.length>1?"s":""} ${l}...`);let Z0=[];for(let _0 of d){let i0=await vy$(P,J,D,_0,N,L,h);Z0.push({channel:_0,...i0})}let n=Z0.find((_0)=>_0.nativePackages)?.nativePackages,Y0=ky$(Z0),M0=Z0.filter((_0)=>_0.compatibility.result==="incompatible"),O0=M0.length>0,S0=M0.reduce((_0,i0)=>Math.max(_0,i0.incompatibleCount),0),O$=vG(M0.map((_0)=>_0.channel)),K0=()=>{let _0=O$||l;F$({channel:"bundle",event:"Bundle Upload Blocked",apikey:D.apikey,appId:N,orgId:h,tags:{reason:"incompatible",channel:_0,channel_name:_0,channel_names:_0,channel_count:M0.length||d.length,incompatible_count:S0,interactive:V}});let B1=`Upload aborted: bundle is incompatible with ${M0.length===1?"channel":"channels"} "${_0}" (${S0} native package(s) changed). A native build / app-store update is required. Run a native build with Capgo Builder (https://capgo.app/docs/cli/cloud-build/), or remove --fail-on-incompatible to upload anyway.`;throw r.error(B1),new oI0(B1)};if(O0&&!X&&!D.acceptIncompatible){if(D.failOnIncompatible&&!V)K0();let _0=await Z2(N)!==null,i0=await WA0({incompatible:O0,interactive:V,hasCredentials:_0,appId:N,orgId:h,apikey:H,incompatibleCount:S0});if(i0==="abort")Rg();if(i0!=="continue")return{success:!0,appId:N,skipped:!0,reason:"NATIVE_BUILD",builderAction:i0,bundle:L,checksum:null,encryptionMethod:B,storageProvider:M};if(FA0({incompatible:O0,failOnIncompatible:!!D.failOnIncompatible,interactive:V,builderAction:i0}))K0()}else if(O0&&D.acceptIncompatible&&!X)r.warn("Proceeding because --accept-incompatible was set. The incompatible-bundle crash warning will not be emailed.");if(D.verbose)r.info("[Verbose] Compatibility check completed:"),r.info(` - Native packages: ${n?n.length:0}`),r.info(` - Min update version: ${Y0||"none"}`);if(D.deleteLinkedBundleOnUpload)r.warn(`Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the target channel${d.length>1?"s":""}: ${l}.`),r.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let b0=d.length>0,S=b0?await ry$(P,H,N,d,!!D.selfAssign,D0,!!D.rolloutAdvance):new Map,I={name:L,app_id:N,session_key:D.external?D.ivSessionKey:c?.ivSessionKey,external_url:D.external,storage_provider:M,min_update_version:Y0,native_packages:n,owner_org:h,user_id:v,checksum:D.external?D.encryptedChecksum:c?.checksum,link:D.link||null,comment:D.comment||null,key_id:c?.keyId||void 0,cli_version:$D.version};if(D.external){if(D.verbose)r.info(`[Verbose] Using external URL: ${D.external}`);if(await e0(H,{channel:"app",event:"App external",org_id:h,tracking_version:2,tags:{"app-id":N}},D.verbose),D.verbose)r.info("[Verbose] External bundle configured:"),r.info(` - URL: ${D.external}`),r.info(` - IV Session Key: ${D.ivSessionKey?"provided":"none"}`),r.info(` - Encrypted Checksum: ${D.encryptedChecksum?"provided":"none"}`)}if(D.zip){if(D.tus=!1,D.verbose)r.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!z.TUSUpload||D.external){if(D.tus=!1,D.verbose)r.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if(D.tus=D.tus||z.TUSUploadForced,D.verbose)r.info(`[Verbose] Upload method: ${D.tus?"TUS (resumable)":"Standard"}`);if(!z.partialUpload||D.external){if(D.delta=!1,D.verbose&&D.external)r.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if(D.delta=D.delta||D.partial||D.deltaOnly||D.partialOnly||z.partialUploadForced,D.verbose)r.info(`[Verbose] Delta updates: ${D.delta?"enabled":"disabled"}`);if(D.encryptDelta=D.encryptDelta||D.encryptPartial,D.encryptDelta&&B!=="v2")H$("You cannot encrypt the delta update if you are not using the v2 encryption method");let a="5.30.0",p="6.30.0",e="7.30.0",R$=!1;if(D.delta&&B==="v2"&&!D.encryptDelta){let _0=Y1(wg()),i0=await _6("@capgo/capacitor-updater",_0,D.packageJson),B1;try{B1=i0?a$(i0):void 0}catch{B1=void 0}if(i0&&B1&&xR(B1,a$("6.14.4"))){if(r.info(`Auto-enabling delta update encryption for updater version ${B1} (>= 6.14.4)`),D.verbose)r.info("[Verbose] Delta encryption auto-enabled for updater >= 6.14.4");D.encryptDelta=!0}}if(D.delta&&(D.encryptDelta||B==="v2")){let _0=Y1(wg()),i0=await _6("@capgo/capacitor-updater",_0,D.packageJson),B1;try{B1=i0?a$(i0):void 0}catch{B1=void 0}if(i0&&B1){if(R$=!r4(B1,a,p,e),D.verbose&&R$)r.info(`[Verbose] Using hex checksum format for updater version ${B1}`)}}if(D.verbose&&D.delta)r.info("[Verbose] Preparing delta update manifest...");let C0=D.delta?await dI0(w,H,h,N,D.encryptDelta?B:"none",m,R$):[];if(D.verbose&&D.delta)r.info(`[Verbose] Delta manifest prepared with ${C0.length} files`);if(D.delta&&C0.length>QU)H$(ON(C0.length));if(D.verbose)r.info("[Verbose] Creating version record in database...");if(await Bg(P,I,"add"),D.verbose)r.info("[Verbose] Version record created successfully");if(D.dryUpload){if(D.verbose)r.info("[Verbose] Dry upload mode: skipping bundle publishing and channel assignment");if(!X)UD().outro("Dry upload saved bundle metadata without uploading files or updating channels");return{success:!0,appId:N,bundle:L,checksum:I.checksum??null,encryptionMethod:B,sessionKey:Q?Q.toString("base64"):void 0,ivSessionKey:typeof I.session_key==="string"?I.session_key:void 0,storageProvider:I.storage_provider,reason:"DRY_UPLOAD"}}if(D.tusChunkSize&&D.tusChunkSize>z.maxChunkSize)r.error(`Chunk size ${D.tusChunkSize} is greater than the maximum chunk size ${z.maxChunkSize}, using the maximum chunk size`),D.tusChunkSize=z.maxChunkSize;else if(!D.tusChunkSize)D.tusChunkSize=z.maxChunkSize;if(D.verbose)r.info(`[Verbose] TUS chunk size: ${Math.floor(D.tusChunkSize/1024/1024)} MB`);if(y&&fy$(D)){if(!G||!W||!Y||!Z||!F||!q)H$("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(r.info("Uploading to S3"),D.verbose)r.info("[Verbose] S3 configuration:"),r.info(` - Endpoint: ${W}`),r.info(` - Region: ${Y}`),r.info(` - Bucket: ${G}`),r.info(` - Port: ${q}`),r.info(` - SSL: ${U?"enabled":"disabled"}`);let _0=`${U?"https":"http"}://${W}${q?`:${q}`:""}`,i0=new Rw({endPoint:W,region:Y,port:q,pathStyle:!0,bucket:G,accessKey:Z,secretKey:F}),B1=`${N}-${L}`,j$=encodeURIComponent(B1);if(D.verbose)r.info(`[Verbose] Uploading to S3 as: ${B1}`);try{await i0.putObject(B1,Uint8Array.from(y)),I.external_url=`${_0}/${j$}`,I.storage_provider="external",await Bg(P,I,"update")}catch(j1){try{await EN(H,N,L,D)}catch(zD){H$(`Cannot upload bundle to S3 ${F0(j1)}. Cleanup of the incomplete version also failed (${F0(zD)}); delete bundle ${L} manually before retrying.`)}H$(`Cannot upload bundle to S3 ${F0(j1)}`)}if(D.verbose)r.info(`[Verbose] S3 upload complete, external URL: ${I.external_url}`)}else if(y){if(tI0(D)){if(D.verbose)r.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await dy$(H,P,N,L,h,y,D,D.tusChunkSize)}else if(D.verbose)r.info("[Verbose] Skipping full bundle upload (delta-only mode)");let _0=null;try{if(D.dryUpload){if(D.delta=!1,D.verbose)r.info("[Verbose] Dry upload mode: skipping delta upload")}let i0=I.session_key&&D.encryptDelta&&Q?{sessionKey:Q,ivSessionKey:I.session_key}:void 0;if(D.verbose&&D.delta)r.info("[Verbose] Starting delta file upload..."),r.info(` - Manifest entries: ${C0.length}`),r.info(` - Encryption: ${i0?"enabled":"disabled"}`);if(_0=D.delta?await cI0(H,C0,w,N,h,i0,D):null,D.verbose&&_0)r.info(`[Verbose] Delta upload complete with ${_0.length} files`)}catch(i0){if(D.userRequestedDelta)throw i0;if(r.info(`Failed to upload delta files to capgo cloud. Error: ${F0(i0)}. This is not a critical error, the bundle has been uploaded without the delta files`),D.verbose)r.info(`[Verbose] Delta upload error details: ${F0(i0)}`)}if(_0?.length){if(D.verbose)r.info(`[Verbose] Writing ${_0.length} manifest rows via set_manifest...`);try{await ZW0(H,N,L,_0,D)}catch(i0){try{await EN(H,N,L,D)}catch(B1){H$(`Cannot set bundle manifest ${F0(i0)}. Cleanup of the incomplete version also failed (${F0(B1)}); delete bundle ${L} manually before retrying.`)}H$(`Cannot set bundle manifest ${F0(i0)}`)}if(D.verbose)r.info("[Verbose] Manifest rows written (sizes filled by backend from R2)")}if(I.storage_provider="r2",I.manifest=null,D.verbose)r.info("[Verbose] Updating version record with storage provider...");if(await SA0({apikey:H,appId:N,bundle:L,supaHost:D.supaHost,supaAnon:D.supaAnon,reporter:UD()},async()=>{await Bg(P,I,"update")}),D.verbose)r.info("[Verbose] Version record updated successfully")}let h$=await xD(P,H,"bundle.delete",{appId:N});if(D.verbose)r.info("[Verbose] Permissions:"),r.info(" - app.upload_bundle: yes"),r.info(` - bundle.delete: ${h$?"yes":"no"}`),r.info(" - channel permissions: checked per target channel");let j0=D.deleteLinkedBundleOnUpload&&h$,s0=j0?await Promise.all(d.map(async(_0)=>({channel:_0,version:await eI0(P,N,_0)}))):[];if(D.deleteLinkedBundleOnUpload&&!j0)r.warn("Cannot delete linked bundle on upload because this API key lacks bundle.delete");let X$=new Set(d).size,E$=new Set;for(let _0 of d){if(D.verbose)r.info(`[Verbose] Setting bundle ${L} to channel ${_0}...`);let i0=S.has(_0)?S.get(_0)??null:await Eg(P,N,_0),B1=D.rolloutAdvance||D0!=null,j$=i0?.rollout_percentage_bps,j1=D0??j$??0;if(D.rolloutAdvance&&D0==null&&!((j$??0)>0))H$(`Cannot advance rollout, channel ${_0} has no rollout percentage to reuse. Pass --rollout or --rollout-percentage-bps`);let zD=B1?await ty$(P,H,!!D.bundleUrl,L,_0,N,R,i0,j1,D.rolloutCacheTtlSeconds,D.selfAssign,D,!!D.rolloutAdvance):await oy$(P,H,!!D.bundleUrl,L,_0,v,h,N,R,i0,b0,D.selfAssign,D);if(zD)E$.add(_0);if(D.verbose)r.info(`[Verbose] Channel ${_0} ${zD?"updated successfully":"was not updated"}`)}if(j0){let _0=new Set;for(let i0 of s0){if(!E$.has(i0.channel))continue;if(!i0.version||_0.has(i0.version.id))continue;if(D.verbose)r.info(`[Verbose] Deleting previously linked bundle in channel ${i0.channel}...`);await iy$(P,i0.version),_0.add(i0.version.id)}}if(E$.size===0)r.warn("Cannot set channel because this API key lacks the required RBAC permission");if(b0&&E$.size!==X$)H$("Cannot complete upload because one or more target channels were not updated");if(D.verbose)r.info("[Verbose] Sending upload event...");await e0(H,{channel:"app",event:"App Uploaded",org_id:h,tracking_version:2,tags:{"app-id":N,bundle:L}},D.verbose),await e0(H,{channel:"app",event:"Bundle Uploaded",org_id:h,tracking_version:2,tags:{"app-id":N,bundle:L},notifyConsole:!0}).catch(()=>{});for(let _0 of Z0){if(_0.compatibility.result!=="incompatible")continue;F$({channel:"bundle",event:"Bundle Incompatible",apikey:H,appId:N,orgId:h,tags:{source:"upload",channel:_0.channel,channel_name:_0.channel,channel_overwritten:E$.has(_0.channel),version_new_name:L,..._0.compatibility.versionOldId?{version_old_id:_0.compatibility.versionOldId}:{},..._0.compatibility.versionOldName?{version_old_name:_0.compatibility.versionOldName}:{},...D.acceptIncompatible?{incompatibility_accepted:!0}:{}}})}let G1={success:!0,appId:N,bundle:L,updatedChannels:Array.from(E$),checksum:I.checksum??null,encryptionMethod:B,sessionKey:Q?Q.toString("base64"):void 0,ivSessionKey:typeof I.session_key==="string"?I.session_key:void 0,storageProvider:I.storage_provider};if(D.verbose)r.info("[Verbose] Upload completed successfully:"),r.info(` - Bundle: ${G1.bundle}`),r.info(` - Checksum: ${G1.checksum}`),r.info(` - Encryption: ${G1.encryptionMethod}`),r.info(` - Storage: ${G1.storageProvider}`);if(V&&!G1.skipped){let _0=D.showReplicationProgress;if(_0===void 0)_0=await sj0({preferenceKey:"uploadShowReplicationProgress",message:"Show Capgo global replication progress for this upload so you can confirm rollout in all regions?",initialValue:!1,rememberMessage:"Remember this replication progress preference for future uploads on this machine?"});if(_0)await DA0({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:V})}if(!X&&!G1.skipped)UD().outro("Time to share your update to the world \uD83C\uDF0D");return G1}Q$();r8();FD();M6();mW();p0();import{randomUUID as Hf$}from"node:crypto";import{existsSync as Kf$,writeFileSync as Of$}from"node:fs";import{cwd as Vf$}from"node:process";import{existsSync as $T0,readFileSync as Ig}from"node:fs";import{createRequire as ey$}from"node:module";import{dirname as Tg,join as $f$}from"node:path";import Df$ from"node:process";var QK="@capgo/capacitor-updater";function Xf$($){if(!$T0($))return null;try{return JSON.parse(Ig($,"utf-8"))}catch{return null}}function Qf$($,D){let X=Xf$($);if(!X)return{version:null,section:null};let Q=["dependencies","devDependencies","optionalDependencies"];for(let J of Q){let Y=X[J];if(!Y||!Object.hasOwn(Y,D))continue;let Z=Y[D];return{version:typeof Z==="string"?Z:String(Z),section:J}}return{version:null,section:null}}function Jf$($,D){let Q=Tg($);while(!0){let J=$f$(Q,"node_modules",D,"package.json");if($T0(J))try{let Z=JSON.parse(Ig(J,"utf-8"));if(typeof Z.version==="string")return Z.version}catch{return null}let Y=Tg(Q);if(Y===Q)break;Q=Y}if(!Df$.versions.pnp)return null;try{let Y=ey$($).resolve(`${D}/package.json`),Z=JSON.parse(Ig(Y,"utf-8"));if(typeof Z.version==="string")return Z.version}catch{return null}return null}function Yf$($,D){let X=Tg($),Q=Qf$($,D),J=Jf$($,D),Y=[];if(!Q.version)Y.push(`Missing ${D} in ${$}`);if(!J)Y.push(`Cannot resolve ${D} from ${X}/node_modules`);return{packageJsonPath:$,projectDir:X,declaredVersion:Q.version,declaredIn:Q.section,installedVersion:J,ready:Y.length===0,details:Y}}function xG($){return Yf$($,QK)}Q$();import{spawnSync as Zf$}from"node:child_process";import{existsSync as XT0,statSync as Ff$}from"node:fs";import{dirname as Gf$,join as Wf$,resolve as QT0}from"node:path";import{cwd as DT0}from"node:process";p0();function Cg($){return`0.0.1-beta.local-${$}`}function Pg($){let D=Y1(DT0()),X=TG($);if(X?.length)for(let Q of X)for(let J of[DT0(),D]){let Y=QT0(J,Q);if(XT0(Y))return Y}return Wf$(D,"package.json")}function qf$($){return $?.trim()||"latest"}function Uf$($,D,X){let Q=`${QK}@${D}`,J=$.installCommand.split(/\s+/).filter(Boolean),Y=J[0];if(!Y)return null;if(!X?.trim())switch($.pm){case"yarn":return{command:"yarn",args:["add",Q]};case"bun":return{command:"bun",args:["add",Q]};case"pnpm":return{command:"pnpm",args:["add",Q]};default:return{command:Y,args:[...J.slice(1),Q]}}if($.pm==="yarn"||$.pm==="bun")return{command:Y,args:J.slice(1)};return{command:Y,args:[...J.slice(1),"--force",Q]}}async function JT0($,D){C.warn(`Bundle version "${$}" is not valid semver (https://semver.org/).`);let X=await g$({message:`Use local fallback version ${D} instead?`,initialValue:!0});if(r0(X)||!X)return null;return C.info(`Using bundle version ${D}`),D}async function YT0($){let D=await U4({message:$,validate:(X)=>{let Q=X?.trim();if(!Q)return"Value is required";let J=QT0(Q);if(!XT0(J))return`Path does not exist: ${J}`;if(!Ff$(J).isDirectory())return`Path is not a directory: ${J}`}});if(r0(D))return null;return D.trim()}async function ZT0($){let D=Pg($),X=xG(D);if(X.ready)return!0;C.warn(`Cannot find ${QK} in node_modules.`);let Q=await g$({message:`Install ${QK} now?`,initialValue:!0});if(r0(Q)||!Q)return!1;let J=bQ(),Y=qf$(X.declaredVersion),Z=Uf$(J,Y,X.declaredVersion);if(!Z)return!1;if(Zf$(Z.command,Z.args,{cwd:Gf$(D),stdio:"inherit",shell:!1}).status!==0)return!1;return xG(D).ready}_$();var zf$=20;function Lf$($){console.log(JSON.stringify($,null,2))}function kG($){console.error(F0($))}function Mf$($){if($.context?.message)kG({error:$.message,message:$.context.message});else kG({error:$.message})}async function FT0($,D,X=!1){let{json:Q}=D,{bundle:J,path:Y}=D,Z=!Q&&!X;try{if(Z)await C1();let F=await z$(),G=E4({silent:Q||X}),W=await Cw({explicitAppId:$,config:F?.config,packageJsonPaths:TG(D.packageJson),interactive:G,json:Q}),q=Hf$().split("-")[0],U=b5("",D.packageJson);if(J=J||U||Cg(q),Z)o0(`Zipping ${W??"app"}@${J}`);if(J&&!hQ.test(J)){if(G){let j=await JT0(J,Cg(q));if(j)J=j}if(!hQ.test(J)){let j=`Your bundle name ${J}, is not valid it should follow semver convention : https://semver.org/`;if(!X)if(Q)kG({error:"invalid_semver"});else C.error(j);throw Error("Invalid bundle version format")}}if(Y=Y||F?.config?.webDir,!Y&&G){let j=await YT0("Enter the path to your built web assets (webDir):");if(j)Y=j}if(!W||!J||!Y){if(!X)if(Q)kG({error:"missing_argument"});else C.error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project");throw Error("Missing argument, you need to provide a appId and a bundle and a path, or be in a capacitor project")}if(Z)C.info(`Started from path "${Y}"`);if(D.codeCheck!==!1&&!D.ignoreNotifyAppReady){if(!z8(Y,"notifyAppReady"))if(G){if(await xw({webDir:Y,interactive:G,json:Q})!=="skipped"&&!z8(Y,"notifyAppReady"))throw new G0("notifyAppReady() is missing in build folder")}else throw Q?new G0("notifyAppReady_not_in_source_code",{message:vw(Y)}):new G0(vw(Y));if(!AG(Y)){if(!X)if(Q)kG({error:"index_html_not_found"});else C.error(`index.html is missing in the root folder of ${Y}`);throw Error("index.html is missing in root folder")}}let K=await RN(Y);if(Z)C.info(`Zipped ${K.byteLength} bytes`);let O=Z?d1():null;if(O)O.start("Calculating checksum");let V=Y1(Vf$()),z=Pg(D.packageJson),N=xG(z);if(!N.ready&&G&&await ZT0(D.packageJson))N=xG(z);if(!N.ready){if(!X)C.warn("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager");throw Error("Cannot find @capgo/capacitor-updater in node_modules, please install it first with your package manager")}let w=await _6("@capgo/capacitor-updater",V,D.packageJson),L=!1,M;try{M=w?a$(w):void 0}catch{M=void 0}if(M)L=!r4(M,void 0,void 0,"7.0.0");else if(w==="link:@capgo/capacitor-updater"){if(!X)C.warn("Using local @capgo/capacitor-updater. Assuming v7");L=!0}let B=await w5(K,D.keyV2||Kf$(W6)||L?"sha256":"crc32");if(O)O.stop(`Checksum ${L?"SHA256":"CRC32"}: ${B}`);let R=Math.floor(K.byteLength/1024/1024);if(R>zf$&&Z)C.warn(`WARNING !!
|
|
710
710
|
The bundle size is ${R} Mb, this may take a while to download for users
|
|
711
711
|
`),C.warn(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
|
|
712
712
|
`);let P=Z?d1():null,v=D.name||`${W}_${J}.zip`;if(P)P.start(`Saving to ${v}`);if(Of$(v,K),P)P.stop(`Saved to ${v}`);if(F$({channel:"bundle",event:"Bundle Zipped",tags:{zip_size_bytes:K.byteLength}}),Z)$$("Done ✅");if(!X&&Q)Lf$({bundle:J,filename:v,checksum:B});return{bundle:J,filename:v,checksum:B}}catch(F){if(!X)if(Q)if(F instanceof G0)Mf$(F);else kG(F);else C.error(F0(F));throw F instanceof Error?F:Error(String(F))}}Q$();FD();function GT0($){return(()=>{if($ instanceof Error)return $.message;if($&&typeof $==="object"){let X=$;return[X.message,X.details,X.hint,X.code].filter((Q)=>typeof Q==="string"||typeof Q==="number").join(" ")}return String($)})().toLowerCase().includes("unique_name_app_id")}_$();p0();async function Nf$($,D,X){let{data:Q,error:J}=await DF($,D,X);if(!J&&Q)return!0;if(J?.code==="PGRST116")return!1;return null}async function Bf$($,D={}){if(!GT0($.createError))return"not_duplicate";let X=await(D.isChannelReadableByCaller??Nf$)($.supabase,$.appId,$.channelName);if(X===!0)return"duplicate_readable";if(X===!1)return"duplicate_inaccessible";throw Error("Cannot verify channel access for this API key. Grant app.read_channels or channel.read, then retry.")}async function WT0($,D,X,Q=!1){if(!Q)o0("Create channel");X.apikey=X.apikey||u0();let J=await z$(Q).catch(()=>{return});if(D=s$(D,J?.config),!X.apikey){if(!Q)C.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!Q)C.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw new G0("Missing appId")}let Y=await U$(X.apikey,X.supaHost,X.supaAnon,Q);if(await MD(Y,D,Q),await M1(Y,X.apikey),await n1(Y,X.apikey,D,"app.create_channel",Q,!0),!Q)C.info(`Creating channel ${D}#${$} to Capgo`);let Z=await PD(X.apikey,D,{supaHost:X.supaHost,supaAnon:X.supaAnon}),F=await LW0({apikey:X.apikey,silent:Q,supaHost:X.supaHost,supaAnon:X.supaAnon},{channel:$,app_id:D,version:null,allow_device_self_set:X.selfAssign??!1,public:X.default??!1});if(F.error){let W=await B9(F.error),q;try{q=await Bf$({createError:W,supabase:Y,appId:D,channelName:$})}catch(H){let K=F0(H);if(!Q)C.error(`Cannot create Channel \uD83D\uDE40
|