@capgo/cli 8.37.2 → 8.37.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "8.37.2",
4
+ "version": "8.37.3",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",
package/dist/src/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import{createRequire as PM0}from"node:module";var module={exports:{}};var EM0=Object.create;var{getPrototypeOf:AM0,defineProperty:PZ,getOwnPropertyNames:ik}=Object;var dL=Object.prototype.hasOwnProperty;function cL($){return this[$]}var W0=($,D,J)=>{var Q=ik(D);for(let X of Q)if(!dL.call($,X)&&X!=="default")PZ($,X,{get:cL.bind(D,X),enumerable:!0});if(J){for(let X of Q)if(!dL.call(J,X)&&X!=="default")PZ(J,X,{get:cL.bind(D,X),enumerable:!0});return J}},jM0,IM0,j1=($,D,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=D?jM0??=new WeakMap:IM0??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?EM0(AM0($)):{};let Z=D||!$||!$.__esModule?PZ(J,"default",{value:$,enumerable:!0}):J;for(let F of ik($))if(!dL.call(Z,F))PZ(Z,F,{get:cL.bind($,F),enumerable:!0});if(Q)X.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var TM0=($)=>$;function CM0($,D){this[$]=TM0.bind(null,D)}var mD=($,D)=>{for(var J in D)PZ($,J,{get:D[J],enumerable:!0,configurable:!0,set:CM0.bind(D,J)})};var s=($,D)=>()=>($&&(D=$($=0)),D);var $0=PM0(import.meta.url);var JD;var D8=s(()=>{JD={name:"@capgo/cli",type:"module",version:"8.37.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:"git+https://github.com/Cap-go/capgo.git",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:bundle":"bun test/test-bundle.mjs","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","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.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: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","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: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: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:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.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:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.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:init-monorepo-targeting":"bun run test:capacitor-config-target && 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-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: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: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:fail-on-incompatible && bun run test:native-dependencies && bun run test:package-json-guard && bun run test:credentials && 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:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && 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: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:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && 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:wait-log && bun run test:init-guardrails && 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-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:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && 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: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: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","test:android-reporting-api":"bun test/test-android-reporting-api.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: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"},dependencies:{"@inkjs/ui":"^2.0.0","@rrweb/types":"^2.1.1","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","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",zod:"^4.4.3","@standard-schema/spec":"^1.1.0"},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","@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.1",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",typescript:"6.0.3",ws:"^8.21.1"}}});import{platform as xM0}from"node:os";import{version as vM0}from"node:process";function u1($){return{capgo_api:_M0,"x-cli-version":JD.version,"x-cli-command":kM0,"x-cli-node":vM0,"x-cli-os":xM0(),...$}}var _M0="2025-10-01",kM0="";var _6=s(()=>{D8()});var rk,ok=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},ak=($)=>{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 tk=s(()=>{rk=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let J=0;$.lastIndex=0;while($.test(D))J+=1;return D.length-J}})()});var yM0,uM0,sk,fM0,ek,hM0,bM0,gM0,$y=($,D={},J={})=>{let Q=D.limit??1/0,X=D.ellipsis??"",Y=D?.ellipsisWidth??(X?$y(X,gM0,J).width:0),Z=0,F=J.controlWidth??0,G=J.tabWidth??8,U=J.emojiWidth??2,q=2,W=J.regularWidth??1,z=J.wideWidth??2,H=[[hM0,W],[yM0,0],[uM0,F],[fM0,G],[ek,U],[sk,z]],K=0,V=0,O=$.length,M=0,B=!1,N=O,L=Math.max(0,Q-Y),w=0,R=0,S=0,v=0;$:while(!0){if(R>w||V>=O&&V>K){let A=$.slice(w,R)||$.slice(K,V);M=0;for(let _ of A.replaceAll(bM0,"")){let x=_.codePointAt(0)||0;if(ok(x))v=2;else if(ak(x))v=z;else v=W;if(S+v>L)N=Math.min(N,Math.max(w,K)+M);if(S+v>Q){B=!0;break $}M+=_.length,S+=v}w=R=0}if(V>=O)break $;for(let A=0,_=H.length;A<_;A++){let[x,b]=H[A];if(x.lastIndex=V,x.test($)){if(M=x===sk?rk($.slice(V,x.lastIndex)):x===ek?1:x.lastIndex-V,v=M*b,S+v>L)N=Math.min(N,V+Math.floor((L-S)/b));if(S+v>Q){B=!0;break $}S+=v,w=K,R=V,V=K=x.lastIndex;continue $}}V+=1}return{width:B?L:S,index:B?N:O,truncated:B,ellipsed:B&&Q>=Y}},Dy;var Jy=s(()=>{tk();yM0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,uM0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,sk=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,fM0=/\t{1,1000}/y,ek=/[\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,hM0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,bM0=/\p{M}+/gu,gM0={limit:1/0,ellipsis:""},Dy=$y});var mM0,dM0=($,D={})=>{return Dy($,mM0,D).width},J8;var lL=s(()=>{Jy();mM0={limit:1/0,ellipsis:"",ellipsisWidth:0},J8=dM0});function m9($,D,J){return String($).normalize().split(iM0).map((Q)=>pM0(Q,D,J)).join(`
1
+ import{createRequire as PM0}from"node:module";var module={exports:{}};var EM0=Object.create;var{getPrototypeOf:AM0,defineProperty:PZ,getOwnPropertyNames:ik}=Object;var dL=Object.prototype.hasOwnProperty;function cL($){return this[$]}var W0=($,D,J)=>{var Q=ik(D);for(let X of Q)if(!dL.call($,X)&&X!=="default")PZ($,X,{get:cL.bind(D,X),enumerable:!0});if(J){for(let X of Q)if(!dL.call(J,X)&&X!=="default")PZ(J,X,{get:cL.bind(D,X),enumerable:!0});return J}},jM0,IM0,j1=($,D,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=D?jM0??=new WeakMap:IM0??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?EM0(AM0($)):{};let Z=D||!$||!$.__esModule?PZ(J,"default",{value:$,enumerable:!0}):J;for(let F of ik($))if(!dL.call(Z,F))PZ(Z,F,{get:cL.bind($,F),enumerable:!0});if(Q)X.set($,Z);return Z};var E=($,D)=>()=>(D||$((D={exports:{}}).exports,D),D.exports);var TM0=($)=>$;function CM0($,D){this[$]=TM0.bind(null,D)}var mD=($,D)=>{for(var J in D)PZ($,J,{get:D[J],enumerable:!0,configurable:!0,set:CM0.bind(D,J)})};var s=($,D)=>()=>($&&(D=$($=0)),D);var $0=PM0(import.meta.url);var JD;var D8=s(()=>{JD={name:"@capgo/cli",type:"module",version:"8.37.3",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:"git+https://github.com/Cap-go/capgo.git",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:bundle":"bun test/test-bundle.mjs","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","test:package-json-guard":"bun test/test-package-json-guard.mjs","test:credentials":"bun test/test-credentials.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: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","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: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: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:doctor-analytics":"bun test/test-doctor-analytics.mjs","test:posthog-exception":"bun test/test-posthog-exception.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:wait-log":"bun test/test-wait-log.mjs","test:init-guardrails":"bun test/test-init-guardrails.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:init-monorepo-targeting":"bun run test:capacitor-config-target && 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-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: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: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:fail-on-incompatible && bun run test:native-dependencies && bun run test:package-json-guard && bun run test:credentials && 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:ci-prompts && bun run test:ci-secrets && bun run test:android-onboarding-progress && bun run test:onboarding-telemetry && bun run test:v2-event-migration && bun run test:analytics && 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: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:doctor-analytics && bun run test:posthog-exception && bun run test:build-platform-selection && 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:wait-log && bun run test:init-guardrails && 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-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:platform-flow-contract && bun run test:tail-engine-shared && bun run test:prescan && bun run test:android-reporting-api && 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: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: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","test:android-reporting-api":"bun test/test-android-reporting-api.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: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"},dependencies:{"@inkjs/ui":"^2.0.0","@rrweb/types":"^2.1.1","@xterm/addon-serialize":"^0.14.0","@xterm/headless":"^6.0.0","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",zod:"^4.4.3","@standard-schema/spec":"^1.1.0"},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","@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.1",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",typescript:"6.0.3",ws:"^8.21.1"}}});import{platform as xM0}from"node:os";import{version as vM0}from"node:process";function u1($){return{capgo_api:_M0,"x-cli-version":JD.version,"x-cli-command":kM0,"x-cli-node":vM0,"x-cli-os":xM0(),...$}}var _M0="2025-10-01",kM0="";var _6=s(()=>{D8()});var rk,ok=($)=>{return $===12288||$>=65281&&$<=65376||$>=65504&&$<=65510},ak=($)=>{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 tk=s(()=>{rk=(()=>{let $=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(D)=>{let J=0;$.lastIndex=0;while($.test(D))J+=1;return D.length-J}})()});var yM0,uM0,sk,fM0,ek,hM0,bM0,gM0,$y=($,D={},J={})=>{let Q=D.limit??1/0,X=D.ellipsis??"",Y=D?.ellipsisWidth??(X?$y(X,gM0,J).width:0),Z=0,F=J.controlWidth??0,G=J.tabWidth??8,U=J.emojiWidth??2,q=2,W=J.regularWidth??1,z=J.wideWidth??2,H=[[hM0,W],[yM0,0],[uM0,F],[fM0,G],[ek,U],[sk,z]],K=0,V=0,O=$.length,M=0,B=!1,N=O,L=Math.max(0,Q-Y),w=0,R=0,S=0,v=0;$:while(!0){if(R>w||V>=O&&V>K){let A=$.slice(w,R)||$.slice(K,V);M=0;for(let _ of A.replaceAll(bM0,"")){let x=_.codePointAt(0)||0;if(ok(x))v=2;else if(ak(x))v=z;else v=W;if(S+v>L)N=Math.min(N,Math.max(w,K)+M);if(S+v>Q){B=!0;break $}M+=_.length,S+=v}w=R=0}if(V>=O)break $;for(let A=0,_=H.length;A<_;A++){let[x,b]=H[A];if(x.lastIndex=V,x.test($)){if(M=x===sk?rk($.slice(V,x.lastIndex)):x===ek?1:x.lastIndex-V,v=M*b,S+v>L)N=Math.min(N,V+Math.floor((L-S)/b));if(S+v>Q){B=!0;break $}S+=v,w=K,R=V,V=K=x.lastIndex;continue $}}V+=1}return{width:B?L:S,index:B?N:O,truncated:B,ellipsed:B&&Q>=Y}},Dy;var Jy=s(()=>{tk();yM0=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,uM0=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,sk=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,fM0=/\t{1,1000}/y,ek=/[\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,hM0=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,bM0=/\p{M}+/gu,gM0={limit:1/0,ellipsis:""},Dy=$y});var mM0,dM0=($,D={})=>{return Dy($,mM0,D).width},J8;var lL=s(()=>{Jy();mM0={limit:1/0,ellipsis:"",ellipsisWidth:0},J8=dM0});function m9($,D,J){return String($).normalize().split(iM0).map((Q)=>pM0(Q,D,J)).join(`
2
2
  `)}var Yq="\x1B",Fy="›",cM0=39,pL="\x07",Gy="[",lM0="]",Uy="m",iL,Qy,Xy=($)=>{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},Yy=($)=>`${Yq}${Gy}${$}${Uy}`,Zy=($)=>`${Yq}${iL}${$}${pL}`,nL=($,D,J)=>{let Q=D[Symbol.iterator](),X=!1,Y=!1,Z=$.at(-1),F=Z===void 0?0:J8(Z),G=Q.next(),U=Q.next(),q=0;while(!G.done){let W=G.value,z=J8(W);if(F+z<=J)$[$.length-1]+=W;else $.push(W),F=0;if(W===Yq||W===Fy)X=!0,Y=D.startsWith(iL,q+1);if(X){if(Y){if(W===pL)X=!1,Y=!1}else if(W===Uy)X=!1}else if(F+=z,F===J&&!U.done)$.push(""),F=0;G=U,U=Q.next(),q+=W.length}if(Z=$.at(-1),!F&&Z!==void 0&&Z.length&&$.length>1)$[$.length-2]+=$.pop()},nM0=($)=>{let D=$.split(" "),J=D.length;while(J){if(J8(D[J-1]))break;J--}if(J===D.length)return $;return D.slice(0,J).join(" ")+D.slice(J).join("")},pM0=($,D,J={})=>{if(J.trim!==!1&&$.trim()==="")return"";let Q="",X,Y,Z=$.split(" "),F=[""],G=0;for(let W=0;W<Z.length;W++){let z=Z[W];if(J.trim!==!1){let K=F.at(-1)??"",V=K.trimStart();if(K.length!==V.length)F[F.length-1]=V,G=J8(V)}if(W!==0){if(G>=D&&(J.wordWrap===!1||J.trim===!1))F.push(""),G=0;if(G||J.trim===!1)F[F.length-1]+=" ",G++}let H=J8(z);if(J.hard&&H>D){let K=D-G,V=1+Math.floor((H-K-1)/D);if(Math.floor((H-1)/D)<V)F.push("");nL(F,z,D),G=J8(F.at(-1)??"");continue}if(G+H>D&&G&&H){if(J.wordWrap===!1&&G<D){nL(F,z,D),G=J8(F.at(-1)??"");continue}F.push(""),G=0}if(G+H>D&&J.wordWrap===!1){nL(F,z,D),G=J8(F.at(-1)??"");continue}F[F.length-1]+=z,G+=H}if(J.trim!==!1)F=F.map((W)=>nM0(W));let U=F.join(`
3
3
  `),q=!1;for(let W=0;W<U.length;W++){let z=U[W];if(Q+=z,!q){if(q=z>="\uD800"&&z<="\uDBFF",q)continue}else q=!1;if(z===Yq||z===Fy){Qy.lastIndex=W+1;let K=Qy.exec(U)?.groups;if(K?.code!==void 0){let V=Number.parseFloat(K.code);X=V===cM0?void 0:V}else if(K?.uri!==void 0)Y=K.uri.length===0?void 0:K.uri}if(U[W+1]===`
4
4
  `){if(Y)Q+=Zy("");let H=X?Xy(X):void 0;if(X&&H)Q+=Yy(H)}else if(z===`
@@ -658,7 +658,7 @@ PS: You can ignore this check with "--ignore-checksum-check"`),Error("Cannot upl
658
658
  The bundle size is ${v} Mb, this may take a while to download for users
659
659
  `),i.info(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
660
660
  `),D.verbose)i.info("[Verbose] Bundle size details:"),i.info(` - Actual size: ${v} MB (${W?.byteLength} bytes)`),i.info(` - Alert threshold: ${Math.floor(Z/1024/1024)} MB`),i.info(` - Maximum allowed: ${A} MB`),i.info("[Verbose] Sending 'App Too Large' event to analytics...");if(await p0(J,{channel:"app-error",event:"App Too Large",icon:"\uD83D\uDE9B",org_id:Q,tracking_version:2,tags:{"app-id":X},notify:!1},D.verbose),D.verbose)i.info("[Verbose] Event sent successfully")}else if(D.verbose)i.info(`[Verbose] Bundle size OK: ${v} MB (under ${Math.floor(Z/1024/1024)} MB alert threshold)`);if(D.verbose)i.info("[Verbose] Bundle preparation complete, returning bundle data");return{zipped:W,ivSessionKey:G,sessionKey:U,checksum:q,encryptionMethod:z,finalKeyData:H,keyId:K}}async function HL1($,D,J,Q,X,Y,Z,F){let G=s$().spinner();G.start("Uploading Bundle");let U=performance.now(),q=!1;if(Z.verbose)i.info("[Verbose] uploadBundleToCapgoCloud called:"),i.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),i.info(` - App ID: ${J}`),i.info(` - Bundle version: ${Q}`),i.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(Z.dryUpload){if(G.stop(`Dry run, bundle not uploaded
661
- Bundle uploaded \uD83D\uDCAA in 0 seconds`),Z.verbose)i.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let H=await N6();if(Z.verbose)i.info("[Verbose] Local config retrieved for upload");if(Z.multipart!==void 0&&Z.multipart||Z.tus!==void 0&&Z.tus){if(Z.multipart)i.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else i.info("Uploading bundle with TUS protocol");if(Z.verbose)i.info("[Verbose] Starting TUS resumable upload..."),i.info(` - Host: ${H.hostWeb}`),i.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(await t50($,Y,X,J,Q,G,H,F),q=!0,Z.verbose)i.info("[Verbose] TUS upload completed, updating database with R2 path...");let K=`orgs/${X}/apps/${J}/${Q}.zip`,{error:V}=await D.from("app_versions").update({r2_path:K}).eq("name",Q).eq("app_id",J);if(V){if(i.error(`Cannot finish TUS upload ${Z0(V)}`),Z.verbose)i.info(`[Verbose] Database update failed: ${Z0(V)}`);throw Error("Cannot finish TUS upload")}if(Z.verbose)i.info(`[Verbose] Database updated with R2 path: ${K}`)}else{if(Z.verbose)i.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let K=await o50($,J,Q,Z);if(!K){if(i.error("Cannot get upload url"),Z.verbose)i.info("[Verbose] Failed to retrieve presigned upload URL from database");throw Error("Cannot get upload url")}let V=Z.timeout||v50;if(Z.verbose)i.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),i.info(` - Timeout: ${V}ms`),i.info(" - Retry attempts: 0 (standard upload does not retry, use --tus for resumable retries)"),i.info(" - Content-Type: application/zip");let O=new AbortController,M=setTimeout(()=>O.abort(),V);try{let B=await fetch(K,{method:"PUT",body:Y,headers:{"Content-Type":"application/zip"},signal:O.signal});if(!B.ok)throw Error(`HTTP error! status: ${B.status}`)}catch(B){if(O.signal.aborted||B?.name==="AbortError"){let N=Error(_50(V));throw N.name=lP,N}throw B}finally{clearTimeout(M)}if(Z.verbose)i.info("[Verbose] HTTP PUT upload completed successfully")}}catch(H){let V=((performance.now()-U)/1000).toFixed(2);if(G.error(`Failed to upload bundle ( after ${V} seconds)`),Z.verbose)i.info(`[Verbose] Upload failed after ${V} seconds`),i.info(`[Verbose] Error type: ${H instanceof Error?"Error":typeof H}`);if(H instanceof Error&&H.name===lP)i.error(H.message);else if(H instanceof Error&&H.message.includes("HTTP error"))try{let O=H.message.match(/status: (\d+)/),M=O?O[1]:"unknown";i.error(`Upload failed with status ${M}: ${H.message}`)}catch{i.error(`Upload failed: ${H.message}`)}else{if(Z.verbose)i.info(`[Verbose] Non-HTTP error: ${Z0(H)}`);if(!Z.tus)i.error(`Cannot upload bundle ( try again with --tus option) ${Z0(H)}`);else i.error(`Cannot upload bundle please contact support if the issue persists ${Z0(H)}`)}if(Z.verbose)i.info("[Verbose] Cleaning up failed version from database...");try{if(await pV($,J,Q,Z),Z.verbose)i.info("[Verbose] Failed version cleaned up")}catch(O){i.error(`Cleanup of the incomplete version failed (${Z0(O)}); delete bundle ${Q} manually before retrying.`)}throw H instanceof Error?H:Error(String(H))}let z=((performance.now()-U)/1000).toFixed(2);if(G.stop(`Bundle uploaded \uD83D\uDCAA in (${z} seconds)`),Z.verbose)i.info("[Verbose] Upload successful:"),i.info(` - Upload time: ${z} seconds`),i.info(` - Upload method: ${q?"TUS (resumable)":"Standard HTTP PUT"}`),i.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),i.info("[Verbose] Sending performance event...");if(await p0($,{channel:"performance",event:q?"TUS upload zip performance":"Upload zip performance",icon:"\uD83D\uDE84",org_id:X,tracking_version:2,tags:{"app-id":J,time:z},notify:!1},Z.verbose),Z.verbose)i.info("[Verbose] Performance event sent successfully")}function KL1($){if($.rollout==null&&$.rolloutPercentageBps==null)return;if($.rolloutPercentageBps!=null)return $.rolloutPercentageBps;return Math.round(($.rollout??0)*100)}function VL1($){return`${Number(($/100).toFixed(2))}%`}async function PL0($,D,J,Q){let{data:X}=await $.rpc("get_app_versions",{apikey:D,name_version:Q,appid:J}).single();if(!X)U1("Cannot get version id, cannot set channel");return X}async function OL1($,D,J){let{data:Q,error:X}=await $.rpc("exist_app_versions",{appid:D,name_version:J}).single();if(X)U1(`Cannot check if version ${J} already exists ${Z0(X)}`);return!!Q}async function NL1($,D){let{data:J,error:Q}=await $.from("app_versions").select("name").eq("app_id",D).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(Q)return i.warn(`Cannot fetch latest remote version ${Z0(Q)}`),null;return J?.name??null}async function IL0($,D,J,Q,X){let Y=J;for(let Z=0;Z<100;Z++){if(!await OL1($,D,Y)){if(Y!==X)i.info(`\uD83D\uDD22 Auto-bumped (${Q}) version from ${X} to ${Y}`);return Y}Y=TL(Y,Q)}U1(`Could not find a free ${Q}-bumped version after 100 attempts (started from ${X})`)}async function LL1($,D,J,Q,X){let Y=J[0],F=(await SL0($,D,Y))?.name??null;if(F)i.info(`\uD83D\uDCE6 Auto-bump base from channel ${Y}: ${F}`);else if(F=await NL1($,D),F)i.info(`\uD83D\uDCE6 Auto-bump base from latest remote app version: ${F}`);if(!F)return i.info(`ℹ️ No remote versions found for auto-bump, keeping local version ${Q}`),IL0($,D,Q,X,Q);let G=TL(F,X);return IL0($,D,G,X,F)}async function SL0($,D,J){let{data:Q,error:X}=await $.from("channels").select("version:app_versions!channels_version_fkey( id, name, deleted )").eq("app_id",D).eq("name",J);if(X)return i.error(`Cannot delete linked bundle on upload ${Z0(X)}`),null;if(Q.length===0)return i.warn("No linked bundle found in the channel you are trying to upload to"),null;let Y=Q[0].version;if(!Y)return i.warn("No linked bundle found in the channel you are trying to upload to"),null;if(Y.deleted)return i.warn("The linked bundle is already deleted"),null;return Y}async function ML1($,D){if(!D)return;let{error:J}=await $.from("app_versions").update({deleted:!0}).eq("id",D.id);if(J){i.error(`Cannot delete linked bundle on upload ${Z0(J)}`);return}i.info(`Linked bundle ${D.name} deleted`)}async function fk($,D,J,Q=!0){let{data:X,error:Y}=await $.from("channels").select("id, public, version, rollout_version").eq("app_id",D).eq("name",J).maybeSingle();if(Y&&Q)U1(`Cannot check channel ${J}: ${Z0(Y)}`);return X}async function wL1($,D,J,Q,X=!1,Y){let Z=new Map;for(let F of new Set(Q)){let G=await fk($,J,F);if(G){if(Z.set(F,G),!await zD($,D,"channel.promote_bundle",{appId:J,channelId:G.id}))U1("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");if(X||Y!=null){if(!await zD($,D,"channel.update_settings",{appId:J,channelId:G.id}))U1(X?"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(Y!=null&&!G.version)U1(`Cannot set rollout, channel ${F} needs a stable bundle before using progressive rollout`);continue}if(Y!=null)U1(`Cannot set rollout, channel ${F} must already exist with a stable bundle`);if(!await zD($,D,"app.create_channel",{appId:J}))U1("Cannot create target channel because this API key lacks app.create_channel");Z.set(F,null)}return Z}async function hk($){let D=$?.context;if(D?.json)try{return JSON.stringify(await D.json())}catch{}return Z0($)}async function TL0($,D,J,Q,X,Y,Z){let{error:F}=await L1("bundle",{apikey:$,method:"PUT",body:{app_id:D,version_id:J,channel_id:Q.id},supaHost:Z?.supaHost,supaAnon:Z?.supaAnon});if(F)await yL(F,async()=>`Cannot set channel because this API key does not have the required RBAC permission. ${await hk(F)}`);let G=`${X.hostWeb}/app/${D}/channel/${Q.id}`;if(Q.public)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${G}`);if(Y)i.info(`Bundle url: ${G}`);return!0}async function BL1($,D,J,Q,X,Y,Z,F,G,U,q=!1,W,z){let H=U!==null&&await zD($,D,"channel.promote_bundle",{appId:F,channelId:U.id}),K=U===null&&await zD($,D,"app.create_channel",{appId:F});if(U&&!H){if(q)U1("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");return i.warn("Cannot set channel because this API key lacks channel.promote_bundle for the target channel"),!1}if(U&&H){let O=await PL0($,D,F,Q);if(W){if(!await zD($,D,"channel.update_settings",{appId:F,channelId:U.id}))return i.warn("Cannot enable device self-assign because this API key lacks channel.update_settings"),TL0(D,F,O,U,G,J,z)}if(!W)return TL0(D,F,O,U,G,J,z);let{error:M,data:B}=await e50($,{name:X,app_id:F,created_by:Y,version:O,owner_org:Z,...W?{allow_device_self_set:!0}:{}});if(M)await yL(M,()=>`Cannot set channel because this API key does not have the required RBAC permission. ${Z0(M)}`);if(B?.id){let N=`${G.hostWeb}/app/${F}/channel/${B.id}`;if(B.public)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${N}`);if(J)i.info(`Bundle url: ${N}`)}return!0}if(K){let{error:O,data:M}=await L1("channel",{apikey:D,method:"POST",body:{app_id:F,channel:X,version:Q,...W?{allow_device_self_set:!0}:{}},supaHost:z?.supaHost,supaAnon:z?.supaAnon});if(O)await yL(O,async()=>`Cannot create channel and set its bundle because this API key does not have the required RBAC permission. ${await hk(O)}`);let B=M,N=Number(B?.id),L=B?.public===!0;if(!Number.isSafeInteger(N)||typeof B?.public!=="boolean"){let R=await fk($,F,X,!1),S=Number(R?.id);if(!Number.isSafeInteger(S)){if(!Number.isSafeInteger(N))return i.info("Your update is now available \uD83C\uDF89"),!0}else N=S,L=R?.public===!0}let w=`${G.hostWeb}/app/${F}/channel/${N}`;if(L)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${w}`);if(J)i.info(`Bundle url: ${w}`);return!0}let V="Cannot create target channel because this API key lacks app.create_channel";if(q)U1(V);return i.warn(V),!1}async function RL1($,D,J,Q,X,Y,Z,F,G,U,q,W){if(!F)U1(`Cannot set rollout, channel ${X} must already exist with a stable bundle`);if(!F.version)U1(`Cannot set rollout, channel ${X} needs a stable bundle before using progressive rollout`);let z=await PL0($,D,Y,Q),[H,K]=await Promise.all([zD($,D,"channel.promote_bundle",{appId:Y,channelId:F.id}),zD($,D,"channel.update_settings",{appId:Y,channelId:F.id})]);if(!H)U1("Cannot set rollout because this API key lacks channel.promote_bundle for the target channel");if(!K)U1("Cannot set rollout because this API key lacks channel.update_settings for the target channel");let V=F.rollout_version===z&&G>0,{error:O}=await L1("channel",{apikey:D,method:"POST",body:{app_id:Y,channel:X,rolloutVersion:Q,rolloutPercentageBps:G,rolloutEnabled:G>0,...V?{rolloutPaused:!1}:{},...U!=null?{rolloutCacheTtlSeconds:U}:{},...q?{allow_device_self_set:!0}:{}},supaHost:W?.supaHost,supaAnon:W?.supaAnon});if(O)await yL(O,async()=>`Cannot set rollout in channel ${await hk(O)}`);let M=`${Z.hostWeb}/app/${Y}/channel/${F.id}`;if(i.info(`Set ${Y} channel ${X} rollout target to @${Q} (${VL1(G)})`),J)i.info(`Bundle url: ${M}`);return!0}async function EL1($,D,J){let{error:Q,data:X}=await D.from("apps").select("default_upload_channel").eq("app_id",$).single();if(Q)throw Error(`Cannot find default upload channel: ${Z0(Q)}. You can set it here: ${J}/app/${$}/info`);return X.default_upload_channel}async function bk($,D,J=!1,Q){return Rl(Q,()=>AL1($,D,J))}async function AL1($,D,J){if(!J)s$().intro(`Uploading with CLI version ${JD.version}`);let Q,X=AU();await W$(s$());let{s3Region:Y,s3Apikey:Z,s3Apisecret:F,s3BucketName:G,s3Endpoint:U,s3Port:q,s3SSL:W}=D;if(D.verbose)i.info("[Verbose] Starting upload process with options:"),i.info(` - API key: ${D.apikey?"provided":"from saved key"}`),i.info(` - Path: ${D.path||"from capacitor config"}`),i.info(` - Channel: ${D.channel||"from default upload channel"}`),i.info(` - Bundle: ${D.bundle||"auto-detected"}`),i.info(` - External: ${D.external||"false"}`),i.info(` - Encryption: ${D.keyV2||D.keyDataV2?"v2":D.key===!1?"disabled":"auto"}`),i.info(` - Upload method: ${D.tus?"TUS":D.zip?"ZIP":"auto"}`),i.info(` - Delta updates: ${D.delta||D.partial?"enabled":"disabled"}`);let z=YL1(D);if(D.verbose)i.info("[Verbose] API key retrieved successfully");let H=await Z1();if(D.verbose)i.info("[Verbose] Capacitor config loaded successfully");D.userRequestedDelta=!!(D.partial||D.delta||D.partialOnly||D.deltaOnly);let K=QN0(H?.config?.plugins?.CapacitorUpdater),V=HY({silent:J});if(K&&D.delta===void 0){if(V){i.info("\uD83D\uDCA1 Instant updates are enabled in your config"),i.info(" Delta updates send only changed files instead of the full bundle");let I0=await w$({message:"Enable delta updates for this upload? (Recommended with instant updates)",initialValue:!0});if(!w1(I0)&&I0){if(D.delta=!0,D.verbose)i.info("[Verbose] Delta updates auto-enabled due to instant update configuration")}}else if(!J){if(D.delta!==!1){if(D.delta=!0,D.verbose)i.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to instant update configuration")}}}let O=await f50();if(D.verbose)i.info("[Verbose] Remote file config retrieved:"),i.info(` - Max upload length: ${Math.floor(O.maxUploadLength/1024/1024)} MB`),i.info(` - Alert upload size: ${Math.floor(O.alertUploadSize/1024/1024)} MB`),i.info(` - TUS upload: ${O.TUSUpload?"enabled":"disabled"}`),i.info(` - TUS upload forced: ${O.TUSUploadForced?"yes":"no"}`),i.info(` - Partial upload: ${O.partialUpload?"enabled":"disabled"}`),i.info(` - Max chunk size: ${Math.floor(O.maxChunkSize/1024/1024)} MB`);let{appid:M,path:B}=ZL1($,D,H.config);if(D.verbose)i.info(`[Verbose] App ID: ${M}, Build path: ${B}`);if(a3(D.autoBump)&&D.bundle)U1("Cannot use --bundle (-b) and --auto-bump together. Omit --bundle to auto-increment from the latest remote version.");let N=await XL1(H.config,D);if(D.verbose)i.info(`[Verbose] Bundle version: ${N}`);let L=D.external?"external":"r2-direct",w="none";if(FL1(D,B),D.verbose)i.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");let R=await N6();if(D.verbose)i.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if(D.supaHost&&D.supaAnon){if(i.info("Using custom supabase instance from provided options"),R.supaHost=D.supaHost,R.supaKey=D.supaAnon,D.verbose)i.info(`[Verbose] Custom Supabase host: ${D.supaHost}`)}let S=await G1(z,D.supaHost,D.supaAnon);if(D.verbose)i.info("[Verbose] Supabase client created successfully");if(await e$(S,M,J),await C$(S,z,M,"app.upload_bundle",J,!0),D.verbose)i.info("[Verbose] App exists and API key has app.upload_bundle permission");let v=await Z$(S,z);if(D.verbose)i.info(`[Verbose] User verified successfully, user_id: ${v}`);let A=_k(D.channel);if(D.channel!==void 0&&A.length===0)U1("Missing channel name, pass one channel or a comma-separated list with --channel");let _=A.length>0?null:await EL1(M,S,R.hostWeb),x=A.length>0?A:_k(_||"production");if(x.length===0)U1("Cannot resolve target channel");let b=EZ(x),d=x,J0=KL1(D);if(D.verbose)i.info(`[Verbose] Target channel${x.length>1?"s":""}: ${b}`);let h=await UD(z,M,{supaHost:D.supaHost,supaAnon:D.supaAnon});if(D.verbose)i.info(`[Verbose] Organization ID: ${h}`);if(await n50(S,h,JD.version),D.verbose)i.info("[Verbose] Remote CLI messages checked");if(await i50(S,h,M,!0),D.verbose)i.info("[Verbose] Plan validation passed");if(D.verbose)i.info("[Verbose] Trial check completed");let j=a3(D.autoBump);if(j){let I0;if(j==="ai"){let d0=await FN0({supabase:S,appid:M,channels:x,path:B,apikey:z,options:{supaHost:D.supaHost,supaAnon:D.supaAnon}});i.info(`\uD83E\uDD16 AI auto-bump chose ${d0.level}: ${d0.reason}`),I0=d0.level}else I0=j;if(D.verbose)i.info(`[Verbose] Resolving auto-bump (${I0}) version from channel/app remote versions...`);if(N=await LL1(S,M,x,N,I0),D.verbose)i.info(`[Verbose] Bundle version after auto-bump: ${N}`)}if(D.autoSetBundle){if(await y50({version:N}),D.verbose)i.info(`[Verbose] Auto-set bundle version in ${H.path}`)}if(i.info(`Upload ${M}@${N} started from path "${B}" to Capgo cloud`),D.verbose)i.info(`[Verbose] Checking if version ${N} already exists...`);let T=await UL1(S,M,N,D.versionExistsOk,V);if(D.verbose)i.info(`[Verbose] Version exists check: ${T?typeof T==="string"?`retry with ${T}`:"yes (skipping)":"no (continuing)"}`);if(T===!0)return{success:!0,appId:M,skipped:!0,reason:"VERSION_EXISTS",bundle:N,checksum:null,encryptionMethod:w,storageProvider:L};if(typeof T==="string")return i.info(`Retrying upload with new version: ${T}`),bk($,{...D,bundle:T,autoBump:void 0},J);if(D.external&&!D.external.startsWith("https://"))U1(`External link should should start with "https://" current is "${D.external}"`);let k=null,n="",c;if(!D.external){if(D.verbose)i.info(`[Verbose] Preparing bundle file from path: ${B}`);let I0=H.config?.plugins?.CapacitorUpdater?.publicKey;if(c=await zL1(B,D,z,h,M,O.maxUploadLength,O.alertUploadSize,I0),Q=c.sessionKey,k=c.zipped,w=c.encryptionMethod,n=c.finalKeyData,D.verbose)i.info("[Verbose] Bundle prepared:"),i.info(` - Size: ${Math.floor((c.zipped?.byteLength??0)/1024)} KB`),i.info(` - Checksum: ${c.checksum}`),i.info(` - Encryption: ${c.encryptionMethod}`),i.info(` - IV Session Key: ${c.ivSessionKey?"present":"none"}`),i.info(` - Key ID: ${c.keyId||"none"}`);if(!D.ignoreChecksumCheck&&J0==null){if(D.verbose)i.info("[Verbose] Checking for duplicate checksum...");if(d=await WL1(S,M,x,c.checksum),D.verbose)i.info("[Verbose] Checksum is unique or already satisfied across target channels")}}let m=EZ(d);if(D.verbose)i.info(`[Verbose] Checking compatibility with channel${d.length>1?"s":""} ${m}...`);let Y0=[];for(let I0 of d){let d0=await GL1(S,X,D,I0,M,N,h);Y0.push({channel:I0,...d0})}let l=Y0.find((I0)=>I0.nativePackages)?.nativePackages,Q0=qL1(Y0),K0=Y0.filter((I0)=>I0.compatibility.result==="incompatible"),U0=K0.length>0,T0=K0.reduce((I0,d0)=>Math.max(I0,d0.incompatibleCount),0),Q1=EZ(K0.map((I0)=>I0.channel)),G0=()=>{let I0=Q1||m;T1({channel:"bundle",event:"Bundle Upload Blocked",icon:"⛔",apikey:D.apikey,appId:M,orgId:h,tags:{reason:"incompatible",channel:I0,channel_name:I0,channel_names:I0,channel_count:K0.length||d.length,incompatible_count:T0,interactive:V}});let c1=`Upload aborted: bundle is incompatible with ${K0.length===1?"channel":"channels"} "${I0}" (${T0} 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 i.error(c1),new CL0(c1)};if(U0&&!J){if(D.failOnIncompatible&&!V)G0();let I0=await IO(M)!==null,d0=await qN0({incompatible:U0,interactive:V,hasCredentials:I0,appId:M,orgId:h,apikey:z,incompatibleCount:T0});if(d0==="abort")uk();if(d0!=="continue")return{success:!0,appId:M,skipped:!0,reason:"NATIVE_BUILD",builderAction:d0,bundle:N,checksum:null,encryptionMethod:w,storageProvider:L};if(GN0({incompatible:U0,failOnIncompatible:!!D.failOnIncompatible,interactive:V,builderAction:d0}))G0()}if(D.verbose)i.info("[Verbose] Compatibility check completed:"),i.info(` - Native packages: ${l?l.length:0}`),i.info(` - Min update version: ${Q0||"none"}`);if(D.deleteLinkedBundleOnUpload)i.warn(`Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the target channel${d.length>1?"s":""}: ${m}.`),i.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let _0=d.length>0,C=_0?await wL1(S,z,M,d,!!D.selfAssign,J0):new Map,I={name:N,app_id:M,session_key:D.external?D.ivSessionKey:c?.ivSessionKey,external_url:D.external,storage_provider:L,min_update_version:Q0,native_packages:l,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:JD.version};if(D.external){if(D.verbose)i.info(`[Verbose] Using external URL: ${D.external}`);if(await p0(z,{channel:"app",event:"App external",icon:"\uD83D\uDCE4",org_id:h,tracking_version:2,tags:{"app-id":M},notify:!1},D.verbose),D.verbose)i.info("[Verbose] External bundle configured:"),i.info(` - URL: ${D.external}`),i.info(` - IV Session Key: ${D.ivSessionKey?"provided":"none"}`),i.info(` - Encrypted Checksum: ${D.encryptedChecksum?"provided":"none"}`)}if(D.zip){if(D.tus=!1,D.verbose)i.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!O.TUSUpload||D.external){if(D.tus=!1,D.verbose)i.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if(D.tus=D.tus||O.TUSUploadForced,D.verbose)i.info(`[Verbose] Upload method: ${D.tus?"TUS (resumable)":"Standard"}`);if(!O.partialUpload||D.external){if(D.delta=!1,D.verbose&&D.external)i.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if(D.delta=D.delta||D.partial||D.deltaOnly||D.partialOnly||O.partialUploadForced,D.verbose)i.info(`[Verbose] Delta updates: ${D.delta?"enabled":"disabled"}`);if(D.encryptPartial&&w==="v1")U1("You cannot encrypt the partial update if you are not using the v2 encryption method");let a="5.30.0",g="6.30.0",t="7.30.0",W1=!1;if(D.delta&&w==="v2"&&!D.encryptPartial){let I0=ZD(yk()),d0=await I6("@capgo/capacitor-updater",I0,D.packageJson),c1;try{c1=d0?t1(d0):void 0}catch{c1=void 0}if(d0&&c1&&LM(c1,t1("6.14.4"))){if(i.info(`Auto-enabling partial update encryption for updater version ${c1} (> 6.14.4)`),D.verbose)i.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");D.encryptPartial=!0}}if(D.delta&&(D.encryptPartial||w==="v2")){let I0=ZD(yk()),d0=await I6("@capgo/capacitor-updater",I0,D.packageJson),c1;try{c1=d0?t1(d0):void 0}catch{c1=void 0}if(d0&&c1){if(W1=!q4(c1,a,g,t),D.verbose&&W1)i.info(`[Verbose] Using hex checksum format for updater version ${c1}`)}}if(D.verbose&&D.delta)i.info("[Verbose] Preparing delta/partial update manifest...");let i0=D.delta?await RL0(B,z,h,M,D.encryptPartial?w:"none",n,W1):[];if(D.verbose&&D.delta)i.info(`[Verbose] Delta manifest prepared with ${i0.length} files`);if(D.delta&&i0.length>TU)U1(hV(i0.length));if(D.verbose)i.info("[Verbose] Creating version record in database...");if(await kk(S,I,"add"),D.verbose)i.info("[Verbose] Version record created successfully");if(D.dryUpload){if(D.verbose)i.info("[Verbose] Dry upload mode: skipping bundle publishing and channel assignment");if(!J)s$().outro("Dry upload saved bundle metadata without uploading files or updating channels");return{success:!0,appId:M,bundle:N,checksum:I.checksum??null,encryptionMethod:w,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>O.maxChunkSize)i.error(`Chunk size ${D.tusChunkSize} is greater than the maximum chunk size ${O.maxChunkSize}, using the maximum chunk size`),D.tusChunkSize=O.maxChunkSize;else if(!D.tusChunkSize)D.tusChunkSize=O.maxChunkSize;if(D.verbose)i.info(`[Verbose] TUS chunk size: ${Math.floor(D.tusChunkSize/1024/1024)} MB`);if(k&&(G||U||Y||Z||F||q||W)){if(!G||!U||!Y||!Z||!F||!q)U1("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(i.info("Uploading to S3"),D.verbose)i.info("[Verbose] S3 configuration:"),i.info(` - Endpoint: ${U}`),i.info(` - Region: ${Y}`),i.info(` - Bucket: ${G}`),i.info(` - Port: ${q}`),i.info(` - SSL: ${W?"enabled":"disabled"}`);let I0=`${W?"https":"http"}://${U}${q?`:${q}`:""}`,d0=new RL({endPoint:U,region:Y,port:q,pathStyle:!0,bucket:G,accessKey:Z,secretKey:F}),c1=`${M}-${N}`,zJ=encodeURIComponent(c1);if(D.verbose)i.info(`[Verbose] Uploading to S3 as: ${c1}`);try{await d0.putObject(c1,Uint8Array.from(k)),I.external_url=`${I0}/${zJ}`,I.storage_provider="external",await kk(S,I,"update")}catch(O1){try{await pV(z,M,N,D)}catch(n$){U1(`Cannot upload bundle to S3 ${Z0(O1)}. Cleanup of the incomplete version also failed (${Z0(n$)}); delete bundle ${N} manually before retrying.`)}U1(`Cannot upload bundle to S3 ${Z0(O1)}`)}if(D.verbose)i.info(`[Verbose] S3 upload complete, external URL: ${I.external_url}`)}else if(k){if(!D.partialOnly&&!D.deltaOnly){if(D.verbose)i.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await HL1(z,S,M,N,h,k,D,D.tusChunkSize)}else if(D.verbose)i.info("[Verbose] Skipping full bundle upload (delta-only mode)");let I0=null;try{if(D.dryUpload){if(D.delta=!1,D.verbose)i.info("[Verbose] Dry upload mode: skipping delta upload")}let d0=I.session_key&&D.encryptPartial&&Q?{sessionKey:Q,ivSessionKey:I.session_key}:void 0;if(D.verbose&&D.delta)i.info("[Verbose] Starting delta/partial file upload..."),i.info(` - Manifest entries: ${i0.length}`),i.info(` - Encryption: ${d0?"enabled":"disabled"}`);if(I0=D.delta?await EL0(z,i0,B,M,h,d0,D):null,D.verbose&&I0)i.info(`[Verbose] Delta upload complete with ${I0.length} files`)}catch(d0){if(D.userRequestedDelta)throw d0;if(i.info(`Failed to upload partial files to capgo cloud. Error: ${Z0(d0)}. This is not a critical error, the bundle has been uploaded without the partial files`),D.verbose)i.info(`[Verbose] Delta upload error details: ${Z0(d0)}`)}if(I0?.length){if(D.verbose)i.info(`[Verbose] Writing ${I0.length} manifest rows via set_manifest...`);try{await s50(z,M,N,I0,D)}catch(d0){try{await pV(z,M,N,D)}catch(c1){U1(`Cannot set bundle manifest ${Z0(d0)}. Cleanup of the incomplete version also failed (${Z0(c1)}); delete bundle ${N} manually before retrying.`)}U1(`Cannot set bundle manifest ${Z0(d0)}`)}if(D.verbose)i.info("[Verbose] Manifest rows written (sizes filled by backend from R2)")}if(I.storage_provider="r2",I.manifest=null,D.verbose)i.info("[Verbose] Updating version record with storage provider...");if(await kk(S,I,"update"),D.verbose)i.info("[Verbose] Version record updated successfully")}let S$=await zD(S,z,"bundle.delete",{appId:M});if(D.verbose)i.info("[Verbose] Permissions:"),i.info(" - app.upload_bundle: yes"),i.info(` - bundle.delete: ${S$?"yes":"no"}`),i.info(" - channel permissions: checked per target channel");let H0=D.deleteLinkedBundleOnUpload&&S$,X1=H0?await Promise.all(d.map(async(I0)=>({channel:I0,version:await SL0(S,M,I0)}))):[];if(D.deleteLinkedBundleOnUpload&&!H0)i.warn("Cannot delete linked bundle on upload because this API key lacks bundle.delete");let s0=new Set(d).size,e0=new Set;for(let I0 of d){if(D.verbose)i.info(`[Verbose] Setting bundle ${N} to channel ${I0}...`);let d0=C.has(I0)?C.get(I0)??null:await fk(S,M,I0),c1=J0!=null?await RL1(S,z,!!D.bundleUrl,N,I0,M,R,d0,J0,D.rolloutCacheTtlSeconds,D.selfAssign,D):await BL1(S,z,!!D.bundleUrl,N,I0,v,h,M,R,d0,_0,D.selfAssign,D);if(c1)e0.add(I0);if(D.verbose)i.info(`[Verbose] Channel ${I0} ${c1?"updated successfully":"was not updated"}`)}if(H0){let I0=new Set;for(let d0 of X1){if(!e0.has(d0.channel))continue;if(!d0.version||I0.has(d0.version.id))continue;if(D.verbose)i.info(`[Verbose] Deleting previously linked bundle in channel ${d0.channel}...`);await ML1(S,d0.version),I0.add(d0.version.id)}}if(e0.size===0)i.warn("Cannot set channel because this API key lacks the required RBAC permission");if(_0&&e0.size!==s0)U1("Cannot complete upload because one or more target channels were not updated");if(D.verbose)i.info("[Verbose] Sending upload event...");await p0(z,{channel:"app",event:"App Uploaded",icon:"⏫",org_id:h,tracking_version:2,tags:{"app-id":M,bundle:N},notify:!1},D.verbose),await p0(z,{channel:"app",event:"Bundle Uploaded",icon:"⏫",org_id:h,tracking_version:2,tags:{"app-id":M,bundle:N},notify:!1,notifyConsole:!0}).catch(()=>{});for(let I0 of Y0){if(I0.compatibility.result!=="incompatible")continue;T1({channel:"bundle",event:"Bundle Incompatible",icon:"\uD83D\uDEAB",apikey:z,appId:M,orgId:h,tags:{source:"upload",channel:I0.channel,channel_name:I0.channel,channel_overwritten:e0.has(I0.channel),version_new_name:N,...I0.compatibility.versionOldId?{version_old_id:I0.compatibility.versionOldId}:{},...I0.compatibility.versionOldName?{version_old_name:I0.compatibility.versionOldName}:{}}})}let A1={success:!0,appId:M,bundle:N,updatedChannels:Array.from(e0),checksum:I.checksum??null,encryptionMethod:w,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)i.info("[Verbose] Upload completed successfully:"),i.info(` - Bundle: ${A1.bundle}`),i.info(` - Checksum: ${A1.checksum}`),i.info(` - Encryption: ${A1.encryptionMethod}`),i.info(` - Storage: ${A1.storageProvider}`);if(V&&!A1.skipped){let I0=D.showReplicationProgress;if(I0===void 0)I0=await eO0({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(I0)await JN0({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:V})}if(!J&&!A1.skipped)s$().outro("Time to share your update to the world \uD83C\uDF0D");return A1}Y1();$9();HD();pD();xG();D1();import{randomUUID as jL1}from"node:crypto";import{existsSync as IL1,writeFileSync as TL1}from"node:fs";import{cwd as CL1}from"node:process";var PL1=20;function SL1($){console.log(JSON.stringify($,null,2))}function Qq($){console.error(Z0($))}async function xL0($,D,J=!1){let{json:Q}=D,{bundle:X,path:Y}=D,Z=!Q&&!J;try{if(Z)await W$();let F=await Z1(),G=h1($,F?.config),U=jL1().split("-")[0],q=v7("",D.packageJson);if(X=X||q||`0.0.1-beta.local-${U}`,Z)c0(`Zipping ${G}@${X}`);if(X&&!zY.test(X)){let R=`Your bundle name ${X}, is not valid it should follow semver convention : https://semver.org/`;if(!J)if(Q)Qq({error:"invalid_semver"});else P.error(R);throw Error("Invalid bundle version format")}if(Y=Y||F?.config?.webDir,!G||!X||!Y){if(!J)if(Q)Qq({error:"missing_argument"});else P.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)P.info(`Started from path "${Y}"`);if(typeof D.codeCheck>"u"?!0:D.codeCheck){if(!t3(Y,"notifyAppReady")){if(!J)if(Q)Qq({error:"notifyAppReady_not_in_source_code"});else P.error("notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready");throw Error("notifyAppReady() is missing in build folder")}if(!CL(Y)){if(!J)if(Q)Qq({error:"index_html_not_found"});else P.error(`index.html is missing in the root folder of ${Y}`);throw Error("index.html is missing in root folder")}}let z=await nV(Y);if(Z)P.info(`Zipped ${z.byteLength} bytes`);let H=Z?x$():null;if(H)H.start("Calculating checksum");let K=ZD(CL1()),V=await I6("@capgo/capacitor-updater",K,D.packageJson);if(!V){if(!J)P.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 O=!1,M;try{M=V?t1(V):void 0}catch{M=void 0}if(M)O=!q4(M,void 0,void 0,"7.0.0");else if(V==="link:@capgo/capacitor-updater"){if(!J)P.warn("Using local @capgo/capacitor-updater. Assuming v7");O=!0}let B=await B7(z,D.keyV2||IL1(U4)||O?"sha256":"crc32");if(H)H.stop(`Checksum ${O?"SHA256":"CRC32"}: ${B}`);let N=Math.floor(z.byteLength/1024/1024);if(N>PL1&&Z)P.warn(`WARNING !!
661
+ Bundle uploaded \uD83D\uDCAA in 0 seconds`),Z.verbose)i.info("[Verbose] Dry upload mode - skipping actual upload");return}try{let H=await N6();if(Z.verbose)i.info("[Verbose] Local config retrieved for upload");if(Z.multipart!==void 0&&Z.multipart||Z.tus!==void 0&&Z.tus){if(Z.multipart)i.info("Uploading bundle with multipart is deprecated, we upload with TUS instead");else i.info("Uploading bundle with TUS protocol");if(Z.verbose)i.info("[Verbose] Starting TUS resumable upload..."),i.info(` - Host: ${H.hostWeb}`),i.info(` - Chunk size: ${Math.floor(F/1024/1024)} MB`);if(await t50($,Y,X,J,Q,G,H,F),q=!0,Z.verbose)i.info("[Verbose] TUS upload completed, updating database with R2 path...");let K=`orgs/${X}/apps/${J}/${Q}.zip`,{error:V}=await D.from("app_versions").update({r2_path:K}).eq("name",Q).eq("app_id",J);if(V){if(i.error(`Cannot finish TUS upload ${Z0(V)}`),Z.verbose)i.info(`[Verbose] Database update failed: ${Z0(V)}`);throw Error("Cannot finish TUS upload")}if(Z.verbose)i.info(`[Verbose] Database updated with R2 path: ${K}`)}else{if(Z.verbose)i.info("[Verbose] Using standard upload (non-TUS), getting presigned URL...");let K=await o50($,J,Q,Z);if(!K){if(i.error("Cannot get upload url"),Z.verbose)i.info("[Verbose] Failed to retrieve presigned upload URL from database");throw Error("Cannot get upload url")}let V=Z.timeout||v50;if(Z.verbose)i.info("[Verbose] Presigned URL obtained, uploading via HTTP PUT..."),i.info(` - Timeout: ${V}ms`),i.info(" - Retry attempts: 0 (standard upload does not retry, use --tus for resumable retries)"),i.info(" - Content-Type: application/zip");let O=new AbortController,M=setTimeout(()=>O.abort(),V);try{let B=await fetch(K,{method:"PUT",body:Y,headers:{"Content-Type":"application/zip"},signal:O.signal});if(!B.ok)throw Error(`HTTP error! status: ${B.status}`)}catch(B){if(O.signal.aborted||B?.name==="AbortError"){let N=Error(_50(V));throw N.name=lP,N}throw B}finally{clearTimeout(M)}if(Z.verbose)i.info("[Verbose] HTTP PUT upload completed successfully")}}catch(H){let V=((performance.now()-U)/1000).toFixed(2);if(G.error(`Failed to upload bundle ( after ${V} seconds)`),Z.verbose)i.info(`[Verbose] Upload failed after ${V} seconds`),i.info(`[Verbose] Error type: ${H instanceof Error?"Error":typeof H}`);if(H instanceof Error&&H.name===lP)i.error(H.message);else if(H instanceof Error&&H.message.includes("HTTP error"))try{let O=H.message.match(/status: (\d+)/),M=O?O[1]:"unknown";i.error(`Upload failed with status ${M}: ${H.message}`)}catch{i.error(`Upload failed: ${H.message}`)}else{if(Z.verbose)i.info(`[Verbose] Non-HTTP error: ${Z0(H)}`);if(!Z.tus)i.error(`Cannot upload bundle ( try again with --tus option) ${Z0(H)}`);else i.error(`Cannot upload bundle please contact support if the issue persists ${Z0(H)}`)}if(Z.verbose)i.info("[Verbose] Cleaning up failed version from database...");try{if(await pV($,J,Q,Z),Z.verbose)i.info("[Verbose] Failed version cleaned up")}catch(O){i.error(`Cleanup of the incomplete version failed (${Z0(O)}); delete bundle ${Q} manually before retrying.`)}throw H instanceof Error?H:Error(String(H))}let z=((performance.now()-U)/1000).toFixed(2);if(G.stop(`Bundle uploaded \uD83D\uDCAA in (${z} seconds)`),Z.verbose)i.info("[Verbose] Upload successful:"),i.info(` - Upload time: ${z} seconds`),i.info(` - Upload method: ${q?"TUS (resumable)":"Standard HTTP PUT"}`),i.info(` - Bundle size: ${Math.floor(Y.byteLength/1024)} KB`),i.info("[Verbose] Sending performance event...");if(await p0($,{channel:"performance",event:q?"TUS upload zip performance":"Upload zip performance",icon:"\uD83D\uDE84",org_id:X,tracking_version:2,tags:{"app-id":J,time:z},notify:!1},Z.verbose),Z.verbose)i.info("[Verbose] Performance event sent successfully")}function KL1($){if($.rollout==null&&$.rolloutPercentageBps==null)return;if($.rolloutPercentageBps!=null)return $.rolloutPercentageBps;return Math.round(($.rollout??0)*100)}function VL1($){return`${Number(($/100).toFixed(2))}%`}async function PL0($,D,J,Q){let{data:X}=await $.rpc("get_app_versions",{apikey:D,name_version:Q,appid:J}).single();if(!X)U1("Cannot get version id, cannot set channel");return X}async function OL1($,D,J){let{data:Q,error:X}=await $.rpc("exist_app_versions",{appid:D,name_version:J}).single();if(X)U1(`Cannot check if version ${J} already exists ${Z0(X)}`);return!!Q}async function NL1($,D){let{data:J,error:Q}=await $.from("app_versions").select("name").eq("app_id",D).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(Q)return i.warn(`Cannot fetch latest remote version ${Z0(Q)}`),null;return J?.name??null}async function IL0($,D,J,Q,X){let Y=J;for(let Z=0;Z<100;Z++){if(!await OL1($,D,Y)){if(Y!==X)i.info(`\uD83D\uDD22 Auto-bumped (${Q}) version from ${X} to ${Y}`);return Y}Y=TL(Y,Q)}U1(`Could not find a free ${Q}-bumped version after 100 attempts (started from ${X})`)}async function LL1($,D,J,Q,X){let Y=J[0],F=(await SL0($,D,Y))?.name??null;if(F)i.info(`\uD83D\uDCE6 Auto-bump base from channel ${Y}: ${F}`);else if(F=await NL1($,D),F)i.info(`\uD83D\uDCE6 Auto-bump base from latest remote app version: ${F}`);if(!F)return i.info(`ℹ️ No remote versions found for auto-bump, keeping local version ${Q}`),IL0($,D,Q,X,Q);let G=TL(F,X);return IL0($,D,G,X,F)}async function SL0($,D,J){let{data:Q,error:X}=await $.from("channels").select("version:app_versions!channels_version_fkey( id, name, deleted )").eq("app_id",D).eq("name",J);if(X)return i.error(`Cannot delete linked bundle on upload ${Z0(X)}`),null;if(Q.length===0)return i.warn("No linked bundle found in the channel you are trying to upload to"),null;let Y=Q[0].version;if(!Y)return i.warn("No linked bundle found in the channel you are trying to upload to"),null;if(Y.deleted)return i.warn("The linked bundle is already deleted"),null;return Y}async function ML1($,D){if(!D)return;let{error:J}=await $.from("app_versions").update({deleted:!0}).eq("id",D.id);if(J){i.error(`Cannot delete linked bundle on upload ${Z0(J)}`);return}i.info(`Linked bundle ${D.name} deleted`)}async function fk($,D,J,Q=!0){let{data:X,error:Y}=await $.from("channels").select("id, public, version, rollout_version, rollout_enabled").eq("app_id",D).eq("name",J).maybeSingle();if(Y&&Q)U1(`Cannot check channel ${J}: ${Z0(Y)}`);return X}async function wL1($,D,J,Q,X=!1,Y){let Z=new Map;for(let F of new Set(Q)){let G=await fk($,J,F);if(G){if(Z.set(F,G),!await zD($,D,"channel.promote_bundle",{appId:J,channelId:G.id}))U1("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");if(X||Y!=null){if(!await zD($,D,"channel.update_settings",{appId:J,channelId:G.id}))U1(X?"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(Y!=null&&!G.version)U1(`Cannot set rollout, channel ${F} needs a stable bundle before using progressive rollout`);continue}if(Y!=null)U1(`Cannot set rollout, channel ${F} must already exist with a stable bundle`);if(!await zD($,D,"app.create_channel",{appId:J}))U1("Cannot create target channel because this API key lacks app.create_channel");Z.set(F,null)}return Z}async function hk($){let D=$?.context;if(D?.json)try{return JSON.stringify(await D.json())}catch{}return Z0($)}async function TL0($,D,J,Q,X,Y,Z){let{error:F}=await L1("bundle",{apikey:$,method:"PUT",body:{app_id:D,version_id:J,channel_id:Q.id},supaHost:Z?.supaHost,supaAnon:Z?.supaAnon});if(F)await yL(F,async()=>`Cannot set channel because this API key does not have the required RBAC permission. ${await hk(F)}`);let G=`${X.hostWeb}/app/${D}/channel/${Q.id}`;if(Q.rollout_enabled&&Q.rollout_version!=null)i.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)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${G}`);if(Y)i.info(`Bundle url: ${G}`);return!0}async function BL1($,D,J,Q,X,Y,Z,F,G,U,q=!1,W,z){let H=U!==null&&await zD($,D,"channel.promote_bundle",{appId:F,channelId:U.id}),K=U===null&&await zD($,D,"app.create_channel",{appId:F});if(U&&!H){if(q)U1("Cannot set channel because this API key lacks channel.promote_bundle for the target channel");return i.warn("Cannot set channel because this API key lacks channel.promote_bundle for the target channel"),!1}if(U&&H){let O=await PL0($,D,F,Q);if(W){if(!await zD($,D,"channel.update_settings",{appId:F,channelId:U.id}))return i.warn("Cannot enable device self-assign because this API key lacks channel.update_settings"),TL0(D,F,O,U,G,J,z)}if(!W)return TL0(D,F,O,U,G,J,z);let{error:M,data:B}=await e50($,{name:X,app_id:F,created_by:Y,version:O,owner_org:Z,...W?{allow_device_self_set:!0}:{}});if(M)await yL(M,()=>`Cannot set channel because this API key does not have the required RBAC permission. ${Z0(M)}`);if(B?.id){let N=`${G.hostWeb}/app/${F}/channel/${B.id}`;if(U.rollout_enabled&&U.rollout_version!=null)i.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(B.public)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${N}`);if(J)i.info(`Bundle url: ${N}`)}return!0}if(K){let{error:O,data:M}=await L1("channel",{apikey:D,method:"POST",body:{app_id:F,channel:X,version:Q,...W?{allow_device_self_set:!0}:{}},supaHost:z?.supaHost,supaAnon:z?.supaAnon});if(O)await yL(O,async()=>`Cannot create channel and set its bundle because this API key does not have the required RBAC permission. ${await hk(O)}`);let B=M,N=Number(B?.id),L=B?.public===!0;if(!Number.isSafeInteger(N)||typeof B?.public!=="boolean"){let R=await fk($,F,X,!1),S=Number(R?.id);if(!Number.isSafeInteger(S)){if(!Number.isSafeInteger(N))return i.info("Your update is now available \uD83C\uDF89"),!0}else N=S,L=R?.public===!0}let w=`${G.hostWeb}/app/${F}/channel/${N}`;if(L)i.info("Your update is now available in your public channel \uD83C\uDF89");else i.info(`Link device to this bundle to try it: ${w}`);if(J)i.info(`Bundle url: ${w}`);return!0}let V="Cannot create target channel because this API key lacks app.create_channel";if(q)U1(V);return i.warn(V),!1}async function RL1($,D,J,Q,X,Y,Z,F,G,U,q,W){if(!F)U1(`Cannot set rollout, channel ${X} must already exist with a stable bundle`);if(!F.version)U1(`Cannot set rollout, channel ${X} needs a stable bundle before using progressive rollout`);let z=await PL0($,D,Y,Q),[H,K]=await Promise.all([zD($,D,"channel.promote_bundle",{appId:Y,channelId:F.id}),zD($,D,"channel.update_settings",{appId:Y,channelId:F.id})]);if(!H)U1("Cannot set rollout because this API key lacks channel.promote_bundle for the target channel");if(!K)U1("Cannot set rollout because this API key lacks channel.update_settings for the target channel");let V=F.rollout_version===z&&G>0,{error:O}=await L1("channel",{apikey:D,method:"POST",body:{app_id:Y,channel:X,rolloutVersion:Q,rolloutPercentageBps:G,rolloutEnabled:G>0,...V?{rolloutPaused:!1}:{},...U!=null?{rolloutCacheTtlSeconds:U}:{},...q?{allow_device_self_set:!0}:{}},supaHost:W?.supaHost,supaAnon:W?.supaAnon});if(O)await yL(O,async()=>`Cannot set rollout in channel ${await hk(O)}`);let M=`${Z.hostWeb}/app/${Y}/channel/${F.id}`;if(i.info(`Set ${Y} channel ${X} rollout target to @${Q} (${VL1(G)})`),J)i.info(`Bundle url: ${M}`);return!0}async function EL1($,D,J){let{error:Q,data:X}=await D.from("apps").select("default_upload_channel").eq("app_id",$).single();if(Q)throw Error(`Cannot find default upload channel: ${Z0(Q)}. You can set it here: ${J}/app/${$}/info`);return X.default_upload_channel}async function bk($,D,J=!1,Q){return Rl(Q,()=>AL1($,D,J))}async function AL1($,D,J){if(!J)s$().intro(`Uploading with CLI version ${JD.version}`);let Q,X=AU();await W$(s$());let{s3Region:Y,s3Apikey:Z,s3Apisecret:F,s3BucketName:G,s3Endpoint:U,s3Port:q,s3SSL:W}=D;if(D.verbose)i.info("[Verbose] Starting upload process with options:"),i.info(` - API key: ${D.apikey?"provided":"from saved key"}`),i.info(` - Path: ${D.path||"from capacitor config"}`),i.info(` - Channel: ${D.channel||"from default upload channel"}`),i.info(` - Bundle: ${D.bundle||"auto-detected"}`),i.info(` - External: ${D.external||"false"}`),i.info(` - Encryption: ${D.keyV2||D.keyDataV2?"v2":D.key===!1?"disabled":"auto"}`),i.info(` - Upload method: ${D.tus?"TUS":D.zip?"ZIP":"auto"}`),i.info(` - Delta updates: ${D.delta||D.partial?"enabled":"disabled"}`);let z=YL1(D);if(D.verbose)i.info("[Verbose] API key retrieved successfully");let H=await Z1();if(D.verbose)i.info("[Verbose] Capacitor config loaded successfully");D.userRequestedDelta=!!(D.partial||D.delta||D.partialOnly||D.deltaOnly);let K=QN0(H?.config?.plugins?.CapacitorUpdater),V=HY({silent:J});if(K&&D.delta===void 0){if(V){i.info("\uD83D\uDCA1 Instant updates are enabled in your config"),i.info(" Delta updates send only changed files instead of the full bundle");let I0=await w$({message:"Enable delta updates for this upload? (Recommended with instant updates)",initialValue:!0});if(!w1(I0)&&I0){if(D.delta=!0,D.verbose)i.info("[Verbose] Delta updates auto-enabled due to instant update configuration")}}else if(!J){if(D.delta!==!1){if(D.delta=!0,D.verbose)i.info("[Verbose] Delta updates auto-enabled in CI/CD mode due to instant update configuration")}}}let O=await f50();if(D.verbose)i.info("[Verbose] Remote file config retrieved:"),i.info(` - Max upload length: ${Math.floor(O.maxUploadLength/1024/1024)} MB`),i.info(` - Alert upload size: ${Math.floor(O.alertUploadSize/1024/1024)} MB`),i.info(` - TUS upload: ${O.TUSUpload?"enabled":"disabled"}`),i.info(` - TUS upload forced: ${O.TUSUploadForced?"yes":"no"}`),i.info(` - Partial upload: ${O.partialUpload?"enabled":"disabled"}`),i.info(` - Max chunk size: ${Math.floor(O.maxChunkSize/1024/1024)} MB`);let{appid:M,path:B}=ZL1($,D,H.config);if(D.verbose)i.info(`[Verbose] App ID: ${M}, Build path: ${B}`);if(a3(D.autoBump)&&D.bundle)U1("Cannot use --bundle (-b) and --auto-bump together. Omit --bundle to auto-increment from the latest remote version.");let N=await XL1(H.config,D);if(D.verbose)i.info(`[Verbose] Bundle version: ${N}`);let L=D.external?"external":"r2-direct",w="none";if(FL1(D,B),D.verbose)i.info("[Verbose] Code check passed (notifyAppReady found and index.html present)");let R=await N6();if(D.verbose)i.info(`[Verbose] Local config loaded: host=${R.hostWeb}`);if(D.supaHost&&D.supaAnon){if(i.info("Using custom supabase instance from provided options"),R.supaHost=D.supaHost,R.supaKey=D.supaAnon,D.verbose)i.info(`[Verbose] Custom Supabase host: ${D.supaHost}`)}let S=await G1(z,D.supaHost,D.supaAnon);if(D.verbose)i.info("[Verbose] Supabase client created successfully");if(await e$(S,M,J),await C$(S,z,M,"app.upload_bundle",J,!0),D.verbose)i.info("[Verbose] App exists and API key has app.upload_bundle permission");let v=await Z$(S,z);if(D.verbose)i.info(`[Verbose] User verified successfully, user_id: ${v}`);let A=_k(D.channel);if(D.channel!==void 0&&A.length===0)U1("Missing channel name, pass one channel or a comma-separated list with --channel");let _=A.length>0?null:await EL1(M,S,R.hostWeb),x=A.length>0?A:_k(_||"production");if(x.length===0)U1("Cannot resolve target channel");let b=EZ(x),d=x,J0=KL1(D);if(D.verbose)i.info(`[Verbose] Target channel${x.length>1?"s":""}: ${b}`);let h=await UD(z,M,{supaHost:D.supaHost,supaAnon:D.supaAnon});if(D.verbose)i.info(`[Verbose] Organization ID: ${h}`);if(await n50(S,h,JD.version),D.verbose)i.info("[Verbose] Remote CLI messages checked");if(await i50(S,h,M,!0),D.verbose)i.info("[Verbose] Plan validation passed");if(D.verbose)i.info("[Verbose] Trial check completed");let j=a3(D.autoBump);if(j){let I0;if(j==="ai"){let d0=await FN0({supabase:S,appid:M,channels:x,path:B,apikey:z,options:{supaHost:D.supaHost,supaAnon:D.supaAnon}});i.info(`\uD83E\uDD16 AI auto-bump chose ${d0.level}: ${d0.reason}`),I0=d0.level}else I0=j;if(D.verbose)i.info(`[Verbose] Resolving auto-bump (${I0}) version from channel/app remote versions...`);if(N=await LL1(S,M,x,N,I0),D.verbose)i.info(`[Verbose] Bundle version after auto-bump: ${N}`)}if(D.autoSetBundle){if(await y50({version:N}),D.verbose)i.info(`[Verbose] Auto-set bundle version in ${H.path}`)}if(i.info(`Upload ${M}@${N} started from path "${B}" to Capgo cloud`),D.verbose)i.info(`[Verbose] Checking if version ${N} already exists...`);let T=await UL1(S,M,N,D.versionExistsOk,V);if(D.verbose)i.info(`[Verbose] Version exists check: ${T?typeof T==="string"?`retry with ${T}`:"yes (skipping)":"no (continuing)"}`);if(T===!0)return{success:!0,appId:M,skipped:!0,reason:"VERSION_EXISTS",bundle:N,checksum:null,encryptionMethod:w,storageProvider:L};if(typeof T==="string")return i.info(`Retrying upload with new version: ${T}`),bk($,{...D,bundle:T,autoBump:void 0},J);if(D.external&&!D.external.startsWith("https://"))U1(`External link should should start with "https://" current is "${D.external}"`);let k=null,n="",c;if(!D.external){if(D.verbose)i.info(`[Verbose] Preparing bundle file from path: ${B}`);let I0=H.config?.plugins?.CapacitorUpdater?.publicKey;if(c=await zL1(B,D,z,h,M,O.maxUploadLength,O.alertUploadSize,I0),Q=c.sessionKey,k=c.zipped,w=c.encryptionMethod,n=c.finalKeyData,D.verbose)i.info("[Verbose] Bundle prepared:"),i.info(` - Size: ${Math.floor((c.zipped?.byteLength??0)/1024)} KB`),i.info(` - Checksum: ${c.checksum}`),i.info(` - Encryption: ${c.encryptionMethod}`),i.info(` - IV Session Key: ${c.ivSessionKey?"present":"none"}`),i.info(` - Key ID: ${c.keyId||"none"}`);if(!D.ignoreChecksumCheck&&J0==null){if(D.verbose)i.info("[Verbose] Checking for duplicate checksum...");if(d=await WL1(S,M,x,c.checksum),D.verbose)i.info("[Verbose] Checksum is unique or already satisfied across target channels")}}let m=EZ(d);if(D.verbose)i.info(`[Verbose] Checking compatibility with channel${d.length>1?"s":""} ${m}...`);let Y0=[];for(let I0 of d){let d0=await GL1(S,X,D,I0,M,N,h);Y0.push({channel:I0,...d0})}let l=Y0.find((I0)=>I0.nativePackages)?.nativePackages,Q0=qL1(Y0),K0=Y0.filter((I0)=>I0.compatibility.result==="incompatible"),U0=K0.length>0,T0=K0.reduce((I0,d0)=>Math.max(I0,d0.incompatibleCount),0),Q1=EZ(K0.map((I0)=>I0.channel)),G0=()=>{let I0=Q1||m;T1({channel:"bundle",event:"Bundle Upload Blocked",icon:"⛔",apikey:D.apikey,appId:M,orgId:h,tags:{reason:"incompatible",channel:I0,channel_name:I0,channel_names:I0,channel_count:K0.length||d.length,incompatible_count:T0,interactive:V}});let c1=`Upload aborted: bundle is incompatible with ${K0.length===1?"channel":"channels"} "${I0}" (${T0} 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 i.error(c1),new CL0(c1)};if(U0&&!J){if(D.failOnIncompatible&&!V)G0();let I0=await IO(M)!==null,d0=await qN0({incompatible:U0,interactive:V,hasCredentials:I0,appId:M,orgId:h,apikey:z,incompatibleCount:T0});if(d0==="abort")uk();if(d0!=="continue")return{success:!0,appId:M,skipped:!0,reason:"NATIVE_BUILD",builderAction:d0,bundle:N,checksum:null,encryptionMethod:w,storageProvider:L};if(GN0({incompatible:U0,failOnIncompatible:!!D.failOnIncompatible,interactive:V,builderAction:d0}))G0()}if(D.verbose)i.info("[Verbose] Compatibility check completed:"),i.info(` - Native packages: ${l?l.length:0}`),i.info(` - Min update version: ${Q0||"none"}`);if(D.deleteLinkedBundleOnUpload)i.warn(`Deleting linked bundle on upload is destructive, it will delete the currently linked bundle in the target channel${d.length>1?"s":""}: ${m}.`),i.warn("Please make sure you want to do this, if you are not sure, please do not use this option.");let _0=d.length>0,C=_0?await wL1(S,z,M,d,!!D.selfAssign,J0):new Map,I={name:N,app_id:M,session_key:D.external?D.ivSessionKey:c?.ivSessionKey,external_url:D.external,storage_provider:L,min_update_version:Q0,native_packages:l,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:JD.version};if(D.external){if(D.verbose)i.info(`[Verbose] Using external URL: ${D.external}`);if(await p0(z,{channel:"app",event:"App external",icon:"\uD83D\uDCE4",org_id:h,tracking_version:2,tags:{"app-id":M},notify:!1},D.verbose),D.verbose)i.info("[Verbose] External bundle configured:"),i.info(` - URL: ${D.external}`),i.info(` - IV Session Key: ${D.ivSessionKey?"provided":"none"}`),i.info(` - Encrypted Checksum: ${D.encryptedChecksum?"provided":"none"}`)}if(D.zip){if(D.tus=!1,D.verbose)i.info("[Verbose] Upload method: ZIP (explicitly set via --zip)")}else if(!O.TUSUpload||D.external){if(D.tus=!1,D.verbose)i.info("[Verbose] Upload method: Standard (TUS not available or external URL)")}else if(D.tus=D.tus||O.TUSUploadForced,D.verbose)i.info(`[Verbose] Upload method: ${D.tus?"TUS (resumable)":"Standard"}`);if(!O.partialUpload||D.external){if(D.delta=!1,D.verbose&&D.external)i.info("[Verbose] Delta updates disabled (not available with external URLs)")}else if(D.delta=D.delta||D.partial||D.deltaOnly||D.partialOnly||O.partialUploadForced,D.verbose)i.info(`[Verbose] Delta updates: ${D.delta?"enabled":"disabled"}`);if(D.encryptPartial&&w==="v1")U1("You cannot encrypt the partial update if you are not using the v2 encryption method");let a="5.30.0",g="6.30.0",t="7.30.0",W1=!1;if(D.delta&&w==="v2"&&!D.encryptPartial){let I0=ZD(yk()),d0=await I6("@capgo/capacitor-updater",I0,D.packageJson),c1;try{c1=d0?t1(d0):void 0}catch{c1=void 0}if(d0&&c1&&LM(c1,t1("6.14.4"))){if(i.info(`Auto-enabling partial update encryption for updater version ${c1} (> 6.14.4)`),D.verbose)i.info("[Verbose] Partial encryption auto-enabled for updater >= 6.14.4");D.encryptPartial=!0}}if(D.delta&&(D.encryptPartial||w==="v2")){let I0=ZD(yk()),d0=await I6("@capgo/capacitor-updater",I0,D.packageJson),c1;try{c1=d0?t1(d0):void 0}catch{c1=void 0}if(d0&&c1){if(W1=!q4(c1,a,g,t),D.verbose&&W1)i.info(`[Verbose] Using hex checksum format for updater version ${c1}`)}}if(D.verbose&&D.delta)i.info("[Verbose] Preparing delta/partial update manifest...");let i0=D.delta?await RL0(B,z,h,M,D.encryptPartial?w:"none",n,W1):[];if(D.verbose&&D.delta)i.info(`[Verbose] Delta manifest prepared with ${i0.length} files`);if(D.delta&&i0.length>TU)U1(hV(i0.length));if(D.verbose)i.info("[Verbose] Creating version record in database...");if(await kk(S,I,"add"),D.verbose)i.info("[Verbose] Version record created successfully");if(D.dryUpload){if(D.verbose)i.info("[Verbose] Dry upload mode: skipping bundle publishing and channel assignment");if(!J)s$().outro("Dry upload saved bundle metadata without uploading files or updating channels");return{success:!0,appId:M,bundle:N,checksum:I.checksum??null,encryptionMethod:w,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>O.maxChunkSize)i.error(`Chunk size ${D.tusChunkSize} is greater than the maximum chunk size ${O.maxChunkSize}, using the maximum chunk size`),D.tusChunkSize=O.maxChunkSize;else if(!D.tusChunkSize)D.tusChunkSize=O.maxChunkSize;if(D.verbose)i.info(`[Verbose] TUS chunk size: ${Math.floor(D.tusChunkSize/1024/1024)} MB`);if(k&&(G||U||Y||Z||F||q||W)){if(!G||!U||!Y||!Z||!F||!q)U1("Missing argument, for S3 upload you need to provide a bucket name, endpoint, region, port, API key, and API secret");if(i.info("Uploading to S3"),D.verbose)i.info("[Verbose] S3 configuration:"),i.info(` - Endpoint: ${U}`),i.info(` - Region: ${Y}`),i.info(` - Bucket: ${G}`),i.info(` - Port: ${q}`),i.info(` - SSL: ${W?"enabled":"disabled"}`);let I0=`${W?"https":"http"}://${U}${q?`:${q}`:""}`,d0=new RL({endPoint:U,region:Y,port:q,pathStyle:!0,bucket:G,accessKey:Z,secretKey:F}),c1=`${M}-${N}`,zJ=encodeURIComponent(c1);if(D.verbose)i.info(`[Verbose] Uploading to S3 as: ${c1}`);try{await d0.putObject(c1,Uint8Array.from(k)),I.external_url=`${I0}/${zJ}`,I.storage_provider="external",await kk(S,I,"update")}catch(O1){try{await pV(z,M,N,D)}catch(n$){U1(`Cannot upload bundle to S3 ${Z0(O1)}. Cleanup of the incomplete version also failed (${Z0(n$)}); delete bundle ${N} manually before retrying.`)}U1(`Cannot upload bundle to S3 ${Z0(O1)}`)}if(D.verbose)i.info(`[Verbose] S3 upload complete, external URL: ${I.external_url}`)}else if(k){if(!D.partialOnly&&!D.deltaOnly){if(D.verbose)i.info("[Verbose] Starting full bundle upload to Capgo Cloud...");await HL1(z,S,M,N,h,k,D,D.tusChunkSize)}else if(D.verbose)i.info("[Verbose] Skipping full bundle upload (delta-only mode)");let I0=null;try{if(D.dryUpload){if(D.delta=!1,D.verbose)i.info("[Verbose] Dry upload mode: skipping delta upload")}let d0=I.session_key&&D.encryptPartial&&Q?{sessionKey:Q,ivSessionKey:I.session_key}:void 0;if(D.verbose&&D.delta)i.info("[Verbose] Starting delta/partial file upload..."),i.info(` - Manifest entries: ${i0.length}`),i.info(` - Encryption: ${d0?"enabled":"disabled"}`);if(I0=D.delta?await EL0(z,i0,B,M,h,d0,D):null,D.verbose&&I0)i.info(`[Verbose] Delta upload complete with ${I0.length} files`)}catch(d0){if(D.userRequestedDelta)throw d0;if(i.info(`Failed to upload partial files to capgo cloud. Error: ${Z0(d0)}. This is not a critical error, the bundle has been uploaded without the partial files`),D.verbose)i.info(`[Verbose] Delta upload error details: ${Z0(d0)}`)}if(I0?.length){if(D.verbose)i.info(`[Verbose] Writing ${I0.length} manifest rows via set_manifest...`);try{await s50(z,M,N,I0,D)}catch(d0){try{await pV(z,M,N,D)}catch(c1){U1(`Cannot set bundle manifest ${Z0(d0)}. Cleanup of the incomplete version also failed (${Z0(c1)}); delete bundle ${N} manually before retrying.`)}U1(`Cannot set bundle manifest ${Z0(d0)}`)}if(D.verbose)i.info("[Verbose] Manifest rows written (sizes filled by backend from R2)")}if(I.storage_provider="r2",I.manifest=null,D.verbose)i.info("[Verbose] Updating version record with storage provider...");if(await kk(S,I,"update"),D.verbose)i.info("[Verbose] Version record updated successfully")}let S$=await zD(S,z,"bundle.delete",{appId:M});if(D.verbose)i.info("[Verbose] Permissions:"),i.info(" - app.upload_bundle: yes"),i.info(` - bundle.delete: ${S$?"yes":"no"}`),i.info(" - channel permissions: checked per target channel");let H0=D.deleteLinkedBundleOnUpload&&S$,X1=H0?await Promise.all(d.map(async(I0)=>({channel:I0,version:await SL0(S,M,I0)}))):[];if(D.deleteLinkedBundleOnUpload&&!H0)i.warn("Cannot delete linked bundle on upload because this API key lacks bundle.delete");let s0=new Set(d).size,e0=new Set;for(let I0 of d){if(D.verbose)i.info(`[Verbose] Setting bundle ${N} to channel ${I0}...`);let d0=C.has(I0)?C.get(I0)??null:await fk(S,M,I0),c1=J0!=null?await RL1(S,z,!!D.bundleUrl,N,I0,M,R,d0,J0,D.rolloutCacheTtlSeconds,D.selfAssign,D):await BL1(S,z,!!D.bundleUrl,N,I0,v,h,M,R,d0,_0,D.selfAssign,D);if(c1)e0.add(I0);if(D.verbose)i.info(`[Verbose] Channel ${I0} ${c1?"updated successfully":"was not updated"}`)}if(H0){let I0=new Set;for(let d0 of X1){if(!e0.has(d0.channel))continue;if(!d0.version||I0.has(d0.version.id))continue;if(D.verbose)i.info(`[Verbose] Deleting previously linked bundle in channel ${d0.channel}...`);await ML1(S,d0.version),I0.add(d0.version.id)}}if(e0.size===0)i.warn("Cannot set channel because this API key lacks the required RBAC permission");if(_0&&e0.size!==s0)U1("Cannot complete upload because one or more target channels were not updated");if(D.verbose)i.info("[Verbose] Sending upload event...");await p0(z,{channel:"app",event:"App Uploaded",icon:"⏫",org_id:h,tracking_version:2,tags:{"app-id":M,bundle:N},notify:!1},D.verbose),await p0(z,{channel:"app",event:"Bundle Uploaded",icon:"⏫",org_id:h,tracking_version:2,tags:{"app-id":M,bundle:N},notify:!1,notifyConsole:!0}).catch(()=>{});for(let I0 of Y0){if(I0.compatibility.result!=="incompatible")continue;T1({channel:"bundle",event:"Bundle Incompatible",icon:"\uD83D\uDEAB",apikey:z,appId:M,orgId:h,tags:{source:"upload",channel:I0.channel,channel_name:I0.channel,channel_overwritten:e0.has(I0.channel),version_new_name:N,...I0.compatibility.versionOldId?{version_old_id:I0.compatibility.versionOldId}:{},...I0.compatibility.versionOldName?{version_old_name:I0.compatibility.versionOldName}:{}}})}let A1={success:!0,appId:M,bundle:N,updatedChannels:Array.from(e0),checksum:I.checksum??null,encryptionMethod:w,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)i.info("[Verbose] Upload completed successfully:"),i.info(` - Bundle: ${A1.bundle}`),i.info(` - Checksum: ${A1.checksum}`),i.info(` - Encryption: ${A1.encryptionMethod}`),i.info(` - Storage: ${A1.storageProvider}`);if(V&&!A1.skipped){let I0=D.showReplicationProgress;if(I0===void 0)I0=await eO0({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(I0)await JN0({title:"Replicating your bundle in all regions to guarantee fast updates.",completeMessage:"Replication complete. Your update is now globally available.",interactive:V})}if(!J&&!A1.skipped)s$().outro("Time to share your update to the world \uD83C\uDF0D");return A1}Y1();$9();HD();pD();xG();D1();import{randomUUID as jL1}from"node:crypto";import{existsSync as IL1,writeFileSync as TL1}from"node:fs";import{cwd as CL1}from"node:process";var PL1=20;function SL1($){console.log(JSON.stringify($,null,2))}function Qq($){console.error(Z0($))}async function xL0($,D,J=!1){let{json:Q}=D,{bundle:X,path:Y}=D,Z=!Q&&!J;try{if(Z)await W$();let F=await Z1(),G=h1($,F?.config),U=jL1().split("-")[0],q=v7("",D.packageJson);if(X=X||q||`0.0.1-beta.local-${U}`,Z)c0(`Zipping ${G}@${X}`);if(X&&!zY.test(X)){let R=`Your bundle name ${X}, is not valid it should follow semver convention : https://semver.org/`;if(!J)if(Q)Qq({error:"invalid_semver"});else P.error(R);throw Error("Invalid bundle version format")}if(Y=Y||F?.config?.webDir,!G||!X||!Y){if(!J)if(Q)Qq({error:"missing_argument"});else P.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)P.info(`Started from path "${Y}"`);if(typeof D.codeCheck>"u"?!0:D.codeCheck){if(!t3(Y,"notifyAppReady")){if(!J)if(Q)Qq({error:"notifyAppReady_not_in_source_code"});else P.error("notifyAppReady() is missing in the build folder of your app. see: https://capgo.app/docs/plugin/api/#notifyappready");throw Error("notifyAppReady() is missing in build folder")}if(!CL(Y)){if(!J)if(Q)Qq({error:"index_html_not_found"});else P.error(`index.html is missing in the root folder of ${Y}`);throw Error("index.html is missing in root folder")}}let z=await nV(Y);if(Z)P.info(`Zipped ${z.byteLength} bytes`);let H=Z?x$():null;if(H)H.start("Calculating checksum");let K=ZD(CL1()),V=await I6("@capgo/capacitor-updater",K,D.packageJson);if(!V){if(!J)P.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 O=!1,M;try{M=V?t1(V):void 0}catch{M=void 0}if(M)O=!q4(M,void 0,void 0,"7.0.0");else if(V==="link:@capgo/capacitor-updater"){if(!J)P.warn("Using local @capgo/capacitor-updater. Assuming v7");O=!0}let B=await B7(z,D.keyV2||IL1(U4)||O?"sha256":"crc32");if(H)H.stop(`Checksum ${O?"SHA256":"CRC32"}: ${B}`);let N=Math.floor(z.byteLength/1024/1024);if(N>PL1&&Z)P.warn(`WARNING !!
662
662
  The bundle size is ${N} Mb, this may take a while to download for users
663
663
  `),P.warn(`Learn how to optimize your assets https://capgo.app/blog/optimise-your-images-for-updates/
664
664
  `);let L=Z?x$():null,w=D.name||`${G}_${X}.zip`;if(L)L.start(`Saving to ${w}`);if(TL1(w,z),L)L.stop(`Saved to ${w}`);if(T1({channel:"bundle",event:"Bundle Zipped",icon:"\uD83D\uDDDC️",tags:{zip_size_bytes:z.byteLength}}),Z)r0("Done ✅");if(!J&&Q)SL1({bundle:X,filename:w,checksum:B});return{bundle:X,filename:w,checksum:B}}catch(F){if(!J)if(Q)Qq(F);else P.error(Z0(F));throw F instanceof Error?F:Error(String(F))}}Y1();D1();async function vL0($,D,J,Q=!1){if(!Q)c0("Create channel");J.apikey=J.apikey||y0();let X=await Z1(Q).catch(()=>{return});if(D=h1(D,X?.config),!J.apikey){if(!Q)P.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!D){if(!Q)P.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}let Y=await G1(J.apikey,J.supaHost,J.supaAnon,Q);if(await e$(Y,D,Q),await Z$(Y,J.apikey),await C$(Y,J.apikey,D,"app.create_channel",Q,!0),!Q)P.info(`Creating channel ${D}#${$} to Capgo`);let Z=await UD(J.apikey,D,{supaHost:J.supaHost,supaAnon:J.supaAnon}),F=await UQ0({apikey:J.apikey,silent:Q,supaHost:J.supaHost,supaAnon:J.supaAnon},{channel:$,app_id:D,version:null,allow_device_self_set:J.selfAssign??!1,public:J.default??!1});if(F.error){if(!Q)P.error(`Cannot create Channel \uD83D\uDE40
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
3
  "type": "module",
4
- "version": "8.37.2",
4
+ "version": "8.37.3",
5
5
  "description": "A CLI to upload to capgo servers",
6
6
  "author": "Martin martin@capgo.app",
7
7
  "license": "Apache 2.0",