@capgo/cli 8.5.3 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +513 -513
- package/dist/package.json +1 -1
- package/dist/src/build/onboarding/analytics.d.ts +2 -0
- package/dist/src/build/onboarding/android/ui/app.d.ts +5 -0
- package/dist/src/build/onboarding/journey.d.ts +16 -0
- package/dist/src/build/onboarding/telemetry.d.ts +37 -0
- package/dist/src/build/onboarding/ui/app.d.ts +5 -0
- package/dist/src/build/onboarding/ui/shell.d.ts +5 -0
- package/dist/src/schemas/build.d.ts +1 -0
- package/dist/src/sdk.js +3 -3
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -14,6 +14,8 @@ interface TrackBuildOnboardingWorkflowOptions extends WorkflowDiffTelemetry {
|
|
|
14
14
|
appId: string;
|
|
15
15
|
platform: 'ios' | 'android';
|
|
16
16
|
apikey?: string;
|
|
17
|
+
/** Correlation id tying every event from one onboarding run together. */
|
|
18
|
+
journeyId?: string;
|
|
17
19
|
decision?: BuildOnboardingWorkflowDecision;
|
|
18
20
|
packageManager?: PackageManager;
|
|
19
21
|
buildScriptType?: BuildScriptChoice['type'];
|
|
@@ -8,6 +8,11 @@ interface AppProps {
|
|
|
8
8
|
/** Optional Capgo API key passed via -a/--apikey flag; takes precedence over saved key. */
|
|
9
9
|
apikey?: string;
|
|
10
10
|
supaHost?: string;
|
|
11
|
+
/** Correlation id for this onboarding run; emitted as `journey_id` on every analytics event. */
|
|
12
|
+
journeyId: string;
|
|
13
|
+
/** Reports the current step to the shell on every transition, so the caller can
|
|
14
|
+
* record where the user dropped off for the quit event. */
|
|
15
|
+
onStep?: (step: string) => void;
|
|
11
16
|
/** Reports the wizard outcome to the shell when it reaches build-complete, so
|
|
12
17
|
* the caller prints an accurate post-exit message + durable summary instead of
|
|
13
18
|
* always claiming success. Never fires on cancel/missing-platform exits. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A correlation id for a single Builder onboarding journey.
|
|
3
|
+
*
|
|
4
|
+
* Generated once per `build init` / onboarding process (in command.ts) and
|
|
5
|
+
* threaded through every analytics event the wizard emits — per-step funnel
|
|
6
|
+
* events, named action events, workflow-file events, and the terminal
|
|
7
|
+
* quit/cancel event. Without it, the events from one user's run are
|
|
8
|
+
* indistinguishable from another's in PostHog, so a "journey" can't be
|
|
9
|
+
* reconstructed when several runs overlap in the same window.
|
|
10
|
+
*
|
|
11
|
+
* The `bj_` prefix (Builder Journey) makes the id self-identifying in raw
|
|
12
|
+
* analytics payloads and easy to grep for. Scope is one process: a
|
|
13
|
+
* quit-and-resume starts a fresh journey id (cross-run stitching is a possible
|
|
14
|
+
* future enhancement, but each run is still fully correlated on its own).
|
|
15
|
+
*/
|
|
16
|
+
export declare function newBuilderJourneyId(): string;
|
|
@@ -4,6 +4,8 @@ export interface TrackBuilderOnboardingStepInput {
|
|
|
4
4
|
apikey: string;
|
|
5
5
|
appId: string;
|
|
6
6
|
orgId: string;
|
|
7
|
+
/** Correlation id tying every event from one onboarding run together. */
|
|
8
|
+
journeyId: string;
|
|
7
9
|
platform: Platform;
|
|
8
10
|
step: OnboardingStep | AndroidOnboardingStep;
|
|
9
11
|
durationMs?: number;
|
|
@@ -19,6 +21,8 @@ export interface TrackBuilderOnboardingActionInput {
|
|
|
19
21
|
apikey: string;
|
|
20
22
|
appId: string;
|
|
21
23
|
orgId: string;
|
|
24
|
+
/** Correlation id tying every event from one onboarding run together. */
|
|
25
|
+
journeyId: string;
|
|
22
26
|
platform: Platform;
|
|
23
27
|
step: OnboardingStep | AndroidOnboardingStep;
|
|
24
28
|
action: BuilderOnboardingAction;
|
|
@@ -26,3 +30,36 @@ export interface TrackBuilderOnboardingActionInput {
|
|
|
26
30
|
}
|
|
27
31
|
export declare function trackBuilderOnboardingStep(input: TrackBuilderOnboardingStepInput): Promise<void>;
|
|
28
32
|
export declare function trackBuilderOnboardingAction(input: TrackBuilderOnboardingActionInput): Promise<void>;
|
|
33
|
+
export interface TrackBuilderOnboardingCancelledInput {
|
|
34
|
+
apikey: string;
|
|
35
|
+
appId: string;
|
|
36
|
+
/** May be undefined when the owner org couldn't be resolved post-exit. */
|
|
37
|
+
orgId?: string;
|
|
38
|
+
/** Correlation id tying every event from one onboarding run together. */
|
|
39
|
+
journeyId: string;
|
|
40
|
+
/**
|
|
41
|
+
* The platform being onboarded, or undefined when the user quit BEFORE
|
|
42
|
+
* choosing one (e.g. on the platform picker). The undefined case is itself a
|
|
43
|
+
* useful signal — it isolates "left at the very first screen" drop-off.
|
|
44
|
+
*/
|
|
45
|
+
platform?: Platform;
|
|
46
|
+
/** The step the user was on when they quit, when known. */
|
|
47
|
+
lastStep?: string;
|
|
48
|
+
/** Total wall-clock duration of the journey, from launch to quit. */
|
|
49
|
+
durationMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Abort signal used to time-box the post-quit flush so a stalled network
|
|
52
|
+
* can't keep the CLI alive after the user has already exited the wizard.
|
|
53
|
+
*/
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Emits the terminal "Builder Onboarding Quit" event when a journey ends
|
|
58
|
+
* without reaching build-complete (user cancel, Ctrl+C, missing platform, or a
|
|
59
|
+
* fatal error that exits). Fired ONCE from command.ts after the wizard tears
|
|
60
|
+
* down — never mid-flow — so each journey has at most one quit marker. Unlike
|
|
61
|
+
* the per-step events this carries no org-scoped requirement: it sends with
|
|
62
|
+
* whatever org id could be resolved (possibly none) rather than dropping the
|
|
63
|
+
* event, because a quit is exactly when we most want the funnel exit recorded.
|
|
64
|
+
*/
|
|
65
|
+
export declare function trackBuilderOnboardingCancelled(input: TrackBuilderOnboardingCancelledInput): Promise<void>;
|
|
@@ -36,6 +36,11 @@ interface AppProps {
|
|
|
36
36
|
/** Optional Capgo API key passed via -a/--apikey flag; takes precedence over saved key */
|
|
37
37
|
apikey?: string;
|
|
38
38
|
supaHost?: string;
|
|
39
|
+
/** Correlation id for this onboarding run; emitted as `journey_id` on every analytics event. */
|
|
40
|
+
journeyId: string;
|
|
41
|
+
/** Reports the current step to the shell on every transition, so the caller can
|
|
42
|
+
* record where the user dropped off for the quit event. */
|
|
43
|
+
onStep?: (step: string) => void;
|
|
39
44
|
/**
|
|
40
45
|
* Reports the wizard outcome to the shell when it reaches build-complete, so
|
|
41
46
|
* the caller prints an accurate post-exit message + durable summary instead of
|
|
@@ -25,6 +25,8 @@ export interface OnboardingShellProps {
|
|
|
25
25
|
guidedHelperUsable: boolean;
|
|
26
26
|
apikey?: string;
|
|
27
27
|
supaHost?: string;
|
|
28
|
+
/** Correlation id for this onboarding run; threaded into every analytics event the apps emit. */
|
|
29
|
+
journeyId: string;
|
|
28
30
|
/** Pre-resolved platform (--platform flag or the single existing native dir); skips the picker. */
|
|
29
31
|
initialPlatform?: Platform;
|
|
30
32
|
/**
|
|
@@ -38,6 +40,9 @@ export interface OnboardingShellProps {
|
|
|
38
40
|
};
|
|
39
41
|
/** Called once a platform is chosen so the caller can print the completion breadcrumb. */
|
|
40
42
|
onResolvePlatform?: (platform: Platform) => void;
|
|
43
|
+
/** Called by the mounted app on every step transition, so the caller can record
|
|
44
|
+
* where the user dropped off for the quit event. */
|
|
45
|
+
onStep?: (step: string) => void;
|
|
41
46
|
/** Called by the mounted app when it reaches the build-complete screen, so the
|
|
42
47
|
* caller prints the accurate post-exit message + durable summary. If the wizard
|
|
43
48
|
* exits any other way (cancel / missing platform), this never fires and the
|
|
@@ -64,6 +64,7 @@ export declare const buildRequestOptionsSchema: z.ZodObject<{
|
|
|
64
64
|
"auto-prompt": "auto-prompt";
|
|
65
65
|
"caller-handled": "caller-handled";
|
|
66
66
|
}>>;
|
|
67
|
+
builderJourneyId: z.ZodOptional<z.ZodString>;
|
|
67
68
|
}, z.core.$strip>;
|
|
68
69
|
export type BuildRequestOptions = z.infer<typeof buildRequestOptionsSchema>;
|
|
69
70
|
export declare const buildNeededOptionsSchema: z.ZodObject<{
|
package/dist/src/sdk.js
CHANGED
|
@@ -124,7 +124,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
124
124
|
`)}),$.__defineSetter__("stack",function(X){return[X].concat($.stack).join(`
|
|
125
125
|
|
|
126
126
|
`)}),$}});var sx=E((ke0,ax)=>{var I4=l("constants"),TW0=process.cwd,yF=null,CW0=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){if(!yF)yF=TW0.call(process);return yF};try{process.cwd()}catch(D){}if(typeof process.chdir==="function"){if(bF=process.chdir,process.chdir=function(D){yF=null,bF.call(process,D)},Object.setPrototypeOf)Object.setPrototypeOf(process.chdir,bF)}var bF;ax.exports=PW0;function PW0(D){if(I4.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./))$(D);if(!D.lutimes)X(D);if(D.chown=F(D.chown),D.fchown=F(D.fchown),D.lchown=F(D.lchown),D.chmod=J(D.chmod),D.fchmod=J(D.fchmod),D.lchmod=J(D.lchmod),D.chownSync=Q(D.chownSync),D.fchownSync=Q(D.fchownSync),D.lchownSync=Q(D.lchownSync),D.chmodSync=Y(D.chmodSync),D.fchmodSync=Y(D.fchmodSync),D.lchmodSync=Y(D.lchmodSync),D.stat=U(D.stat),D.fstat=U(D.fstat),D.lstat=U(D.lstat),D.statSync=Z(D.statSync),D.fstatSync=Z(D.fstatSync),D.lstatSync=Z(D.lstatSync),D.chmod&&!D.lchmod)D.lchmod=function(O,q,w){if(w)process.nextTick(w)},D.lchmodSync=function(){};if(D.chown&&!D.lchown)D.lchown=function(O,q,w,W){if(W)process.nextTick(W)},D.lchownSync=function(){};if(CW0==="win32")D.rename=typeof D.rename!=="function"?D.rename:function(O){function q(w,W,K){var H=Date.now(),B=0;O(w,W,function M(j){if(j&&(j.code==="EACCES"||j.code==="EPERM"||j.code==="EBUSY")&&Date.now()-H<60000){if(setTimeout(function(){D.stat(W,function(z,V){if(z&&z.code==="ENOENT")O(w,W,M);else K(j)})},B),B<100)B+=10;return}if(K)K(j)})}if(Object.setPrototypeOf)Object.setPrototypeOf(q,O);return q}(D.rename);D.read=typeof D.read!=="function"?D.read:function(O){function q(w,W,K,H,B,M){var j;if(M&&typeof M==="function"){var z=0;j=function(V,N,A){if(V&&V.code==="EAGAIN"&&z<10)return z++,O.call(D,w,W,K,H,B,j);M.apply(this,arguments)}}return O.call(D,w,W,K,H,B,j)}if(Object.setPrototypeOf)Object.setPrototypeOf(q,O);return q}(D.read),D.readSync=typeof D.readSync!=="function"?D.readSync:function(O){return function(q,w,W,K,H){var B=0;while(!0)try{return O.call(D,q,w,W,K,H)}catch(M){if(M.code==="EAGAIN"&&B<10){B++;continue}throw M}}}(D.readSync);function $(O){O.lchmod=function(q,w,W){O.open(q,I4.O_WRONLY|I4.O_SYMLINK,w,function(K,H){if(K){if(W)W(K);return}O.fchmod(H,w,function(B){O.close(H,function(M){if(W)W(B||M)})})})},O.lchmodSync=function(q,w){var W=O.openSync(q,I4.O_WRONLY|I4.O_SYMLINK,w),K=!0,H;try{H=O.fchmodSync(W,w),K=!1}finally{if(K)try{O.closeSync(W)}catch(B){}else O.closeSync(W)}return H}}function X(O){if(I4.hasOwnProperty("O_SYMLINK")&&O.futimes)O.lutimes=function(q,w,W,K){O.open(q,I4.O_SYMLINK,function(H,B){if(H){if(K)K(H);return}O.futimes(B,w,W,function(M){O.close(B,function(j){if(K)K(M||j)})})})},O.lutimesSync=function(q,w,W){var K=O.openSync(q,I4.O_SYMLINK),H,B=!0;try{H=O.futimesSync(K,w,W),B=!1}finally{if(B)try{O.closeSync(K)}catch(M){}else O.closeSync(K)}return H};else if(O.futimes)O.lutimes=function(q,w,W,K){if(K)process.nextTick(K)},O.lutimesSync=function(){}}function J(O){if(!O)return O;return function(q,w,W){return O.call(D,q,w,function(K){if(G(K))K=null;if(W)W.apply(this,arguments)})}}function Y(O){if(!O)return O;return function(q,w){try{return O.call(D,q,w)}catch(W){if(!G(W))throw W}}}function F(O){if(!O)return O;return function(q,w,W,K){return O.call(D,q,w,W,function(H){if(G(H))H=null;if(K)K.apply(this,arguments)})}}function Q(O){if(!O)return O;return function(q,w,W){try{return O.call(D,q,w,W)}catch(K){if(!G(K))throw K}}}function U(O){if(!O)return O;return function(q,w,W){if(typeof w==="function")W=w,w=null;function K(H,B){if(B){if(B.uid<0)B.uid+=4294967296;if(B.gid<0)B.gid+=4294967296}if(W)W.apply(this,arguments)}return w?O.call(D,q,w,K):O.call(D,q,K)}}function Z(O){if(!O)return O;return function(q,w){var W=w?O.call(D,q,w):O.call(D,q);if(W){if(W.uid<0)W.uid+=4294967296;if(W.gid<0)W.gid+=4294967296}return W}}function G(O){if(!O)return!0;if(O.code==="ENOSYS")return!0;var q=!process.getuid||process.getuid()!==0;if(q){if(O.code==="EINVAL"||O.code==="EPERM")return!0}return!1}}});var $_=E((ye0,D_)=>{var ex=l("stream").Stream;D_.exports=SW0;function SW0(D){return{ReadStream:$,WriteStream:X};function $(J,Y){if(!(this instanceof $))return new $(J,Y);ex.call(this);var F=this;this.path=J,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,Y=Y||{};var Q=Object.keys(Y);for(var U=0,Z=Q.length;U<Z;U++){var G=Q[U];this[G]=Y[G]}if(this.encoding)this.setEncoding(this.encoding);if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!=="number")throw TypeError("end must be a Number");if(this.start>this.end)throw Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){F._read()});return}D.open(this.path,this.flags,this.mode,function(O,q){if(O){F.emit("error",O),F.readable=!1;return}F.fd=q,F.emit("open",q),F._read()})}function X(J,Y){if(!(this instanceof X))return new X(J,Y);ex.call(this),this.path=J,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,Y=Y||{};var F=Object.keys(Y);for(var Q=0,U=F.length;Q<U;Q++){var Z=F[Q];this[Z]=Y[Z]}if(this.start!==void 0){if(typeof this.start!=="number")throw TypeError("start must be a Number");if(this.start<0)throw Error("start must be >= zero");this.pos=this.start}if(this.busy=!1,this._queue=[],this.fd===null)this._open=D.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush()}}});var J_=E((be0,X_)=>{X_.exports=uW0;var vW0=Object.getPrototypeOf||function(D){return D.__proto__};function uW0(D){if(D===null||typeof D!=="object")return D;if(D instanceof Object)var $={__proto__:vW0(D)};else var $=Object.create(null);return Object.getOwnPropertyNames(D).forEach(function(X){Object.defineProperty($,X,Object.getOwnPropertyDescriptor(D,X))}),$}});var mD=E((ge0,NW)=>{var xD=l("fs"),xW0=sx(),_W0=$_(),fW0=J_(),gF=l("util"),Z1,mF;if(typeof Symbol==="function"&&typeof Symbol.for==="function")Z1=Symbol.for("graceful-fs.queue"),mF=Symbol.for("graceful-fs.previous");else Z1="___graceful-fs.queue",mF="___graceful-fs.previous";function kW0(){}function F_(D,$){Object.defineProperty(D,Z1,{get:function(){return $}})}var n8=kW0;if(gF.debuglog)n8=gF.debuglog("gfs4");else if(/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))n8=function(){var D=gF.format.apply(gF,arguments);D="GFS4: "+D.split(/\n/).join(`
|
|
127
|
-
GFS4: `),console.error(D)};if(!xD[Z1]){if(HW=global[Z1]||[],F_(xD,HW),xD.close=function(D){function $(X,J){return D.call(xD,X,function(Y){if(!Y)Y_();if(typeof J==="function")J.apply(this,arguments)})}return Object.defineProperty($,mF,{value:D}),$}(xD.close),xD.closeSync=function(D){function $(X){D.apply(xD,arguments),Y_()}return Object.defineProperty($,mF,{value:D}),$}(xD.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){n8(xD[Z1]),l("assert").equal(xD[Z1].length,0)})}var HW;if(!global[Z1])F_(global,xD[Z1]);NW.exports=zW(fW0(xD));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!xD.__patched)NW.exports=zW(xD),xD.__patched=!0;function zW(D){xW0(D),D.gracefulify=zW,D.createReadStream=N,D.createWriteStream=A;var $=D.readFile;D.readFile=X;function X(I,x,P){if(typeof x==="function")P=x,x=null;return m(I,x,P);function m(b,p,k,R){return $(b,p,function(S){if(S&&(S.code==="EMFILE"||S.code==="ENFILE"))x5([m,[b,p,k],S,R||Date.now(),Date.now()]);else if(typeof k==="function")k.apply(this,arguments)})}}var J=D.writeFile;D.writeFile=Y;function Y(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return J(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var F=D.appendFile;if(F)D.appendFile=Q;function Q(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return F(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var U=D.copyFile;if(U)D.copyFile=Z;function Z(I,x,P,m){if(typeof P==="function")m=P,P=0;return b(I,x,P,m);function b(p,k,R,S,v){return U(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var G=D.readdir;D.readdir=q;var O=/^v[0-5]\./;function q(I,x,P){if(typeof x==="function")P=x,x=null;var m=O.test(process.version)?function(k,R,S,v){return G(k,b(k,R,S,v))}:function(k,R,S,v){return G(k,R,b(k,R,S,v))};return m(I,x,P);function b(p,k,R,S){return function(v,f){if(v&&(v.code==="EMFILE"||v.code==="ENFILE"))x5([m,[p,k,R],v,S||Date.now(),Date.now()]);else{if(f&&f.sort)f.sort();if(typeof R==="function")R.call(this,v,f)}}}}if(process.version.substr(0,4)==="v0.8"){var w=_W0(D);M=w.ReadStream,z=w.WriteStream}var W=D.ReadStream;if(W)M.prototype=Object.create(W.prototype),M.prototype.open=j;var K=D.WriteStream;if(K)z.prototype=Object.create(K.prototype),z.prototype.open=V;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(I){M=I},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return z},set:function(I){z=I},enumerable:!0,configurable:!0});var H=M;Object.defineProperty(D,"FileReadStream",{get:function(){return H},set:function(I){H=I},enumerable:!0,configurable:!0});var B=z;Object.defineProperty(D,"FileWriteStream",{get:function(){return B},set:function(I){B=I},enumerable:!0,configurable:!0});function M(I,x){if(this instanceof M)return W.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function j(){var I=this;_(I.path,I.flags,I.mode,function(x,P){if(x){if(I.autoClose)I.destroy();I.emit("error",x)}else I.fd=P,I.emit("open",P),I.read()})}function z(I,x){if(this instanceof z)return K.apply(this,arguments),this;else return z.apply(Object.create(z.prototype),arguments)}function V(){var I=this;_(I.path,I.flags,I.mode,function(x,P){if(x)I.destroy(),I.emit("error",x);else I.fd=P,I.emit("open",P)})}function N(I,x){return new D.ReadStream(I,x)}function A(I,x){return new D.WriteStream(I,x)}var u=D.open;D.open=_;function _(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return u(p,k,R,function(f,h){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}return D}function x5(D){n8("ENQUEUE",D[0].name,D[1]),xD[Z1].push(D),VW()}var hF;function Y_(){var D=Date.now();for(var $=0;$<xD[Z1].length;++$)if(xD[Z1][$].length>2)xD[Z1][$][3]=D,xD[Z1][$][4]=D;VW()}function VW(){if(clearTimeout(hF),hF=void 0,xD[Z1].length===0)return;var D=xD[Z1].shift(),$=D[0],X=D[1],J=D[2],Y=D[3],F=D[4];if(Y===void 0)n8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-Y>=60000){n8("TIMEOUT",$.name,X);var Q=X.pop();if(typeof Q==="function")Q.call(null,J)}else{var U=Date.now()-F,Z=Math.max(F-Y,1),G=Math.min(Z*1.2,100);if(U>=G)n8("RETRY",$.name,X),$.apply(null,X.concat([Y]));else xD[Z1].push(D)}if(hF===void 0)hF=setTimeout(VW,0)}});var U_=E((he0,Q_)=>{function E$(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Q_.exports=E$;E$.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};E$.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};E$.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var J=this,Y=setTimeout(function(){if(J._attempts++,J._operationTimeoutCb){if(J._timeout=setTimeout(function(){J._operationTimeoutCb(J._attempts)},J._operationTimeout),J._options.unref)J._timeout.unref()}J._fn(J._attempts)},X);if(this._options.unref)Y.unref();return!0};E$.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};E$.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};E$.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};E$.prototype.start=E$.prototype.try;E$.prototype.errors=function(){return this._errors};E$.prototype.attempts=function(){return this._attempts};E$.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var J=0;J<this._errors.length;J++){var Y=this._errors[J],F=Y.message,Q=(D[F]||0)+1;if(D[F]=Q,Q>=X)$=Y,X=Q}return $}});var G_=E((bW0)=>{var yW0=U_();bW0.operation=function(D){var $=bW0.timeouts(D);return new yW0($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};bW0.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var J=[];for(var Y=0;Y<$.retries;Y++)J.push(this.createTimeout(Y,$));if(D&&D.forever&&!J.length)J.push(this.createTimeout(Y,$));return J.sort(function(F,Q){return F-Q}),J};bW0.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,J=Math.round(X*$.minTimeout*Math.pow($.factor,D));return J=Math.min(J,$.maxTimeout),J};bW0.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var J in D)if(typeof D[J]==="function")X.push(J)}for(var Y=0;Y<X.length;Y++){var F=X[Y],Q=D[F];D[F]=function(Z){var G=bW0.operation($),O=Array.prototype.slice.call(arguments,1),q=O.pop();O.push(function(w){if(G.retry(w))return;if(w)arguments[0]=G.mainError();q.apply(this,arguments)}),G.attempt(function(){Z.apply(D,O)})}.bind(D,Q),D[F].options=$}}});var O_=E((ce0,cF)=>{cF.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")cF.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")cF.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var lF=E((de0,f5)=>{var TD=global.process,l8=function(D){return D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function"};if(!l8(TD))f5.exports=function(){return function(){}};else{if(LW=l("assert"),i8=O_(),BW=/^win/i.test(TD.platform),_5=l("events"),typeof _5!=="function")_5=_5.EventEmitter;if(TD.__signal_exit_emitter__)sD=TD.__signal_exit_emitter__;else sD=TD.__signal_exit_emitter__=new _5,sD.count=0,sD.emitted={};if(!sD.infinite)sD.setMaxListeners(1/0),sD.infinite=!0;f5.exports=function(D,$){if(!l8(global.process))return function(){};if(LW.equal(typeof D,"function","a callback must be provided for exit handler"),p8===!1)dF();var X="exit";if($&&$.alwaysLast)X="afterexit";var J=function(){if(sD.removeListener(X,D),sD.listeners("exit").length===0&&sD.listeners("afterexit").length===0)v2()};return sD.on(X,D),J},v2=function(){if(!p8||!l8(global.process))return;p8=!1,i8.forEach(function($){try{TD.removeListener($,u2[$])}catch(X){}}),TD.emit=x2,TD.reallyExit=nF,sD.count-=1},f5.exports.unload=v2,E4=function($,X,J){if(sD.emitted[$])return;sD.emitted[$]=!0,sD.emit($,X,J)},u2={},i8.forEach(function(D){u2[D]=function(){if(!l8(global.process))return;var X=TD.listeners(D);if(X.length===sD.count){if(v2(),E4("exit",null,D),E4("afterexit",null,D),BW&&D==="SIGHUP")D="SIGINT";TD.kill(TD.pid,D)}}}),f5.exports.signals=function(){return i8},p8=!1,dF=function(){if(p8||!l8(global.process))return;p8=!0,sD.count+=1,i8=i8.filter(function($){try{return TD.on($,u2[$]),!0}catch(X){return!1}}),TD.emit=jW,TD.reallyExit=MW},f5.exports.load=dF,nF=TD.reallyExit,MW=function($){if(!l8(global.process))return;TD.exitCode=$||0,E4("exit",TD.exitCode,null),E4("afterexit",TD.exitCode,null),nF.call(TD,TD.exitCode)},x2=TD.emit,jW=function($,X){if($==="exit"&&l8(global.process)){if(X!==void 0)TD.exitCode=X;var J=x2.apply(this,arguments);return E4("exit",TD.exitCode,null),E4("afterexit",TD.exitCode,null),J}else return x2.apply(this,arguments)}}var LW,i8,BW,_5,sD,v2,E4,u2,p8,dF,nF,MW,x2,jW});var w_=E((nW0,IW)=>{var q_=Symbol();function cW0(D,$,X){let J=$[q_];if(J)return $.stat(D,(F,Q)=>{if(F)return X(F);X(null,Q.mtime,J)});let Y=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,Y,Y,(F)=>{if(F)return X(F);$.stat(D,(Q,U)=>{if(Q)return X(Q);let Z=U.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,q_,{value:Z}),X(null,U.mtime,Z)})})}function dW0(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}nW0.probe=cW0;nW0.getMtime=dW0});var V_=E((eW0,f2)=>{var pW0=l("path"),RW=mD(),rW0=G_(),tW0=lF(),W_=w_(),c6={};function _2(D,$){return $.lockfilePath||`${D}.lock`}function TW(D,$,X){if(!$.realpath)return X(null,pW0.resolve(D));$.fs.realpath(D,X)}function AW(D,$,X){let J=_2(D,$);$.fs.mkdir(J,(Y)=>{if(!Y)return W_.probe(J,$.fs,(F,Q,U)=>{if(F)return $.fs.rmdir(J,()=>{}),X(F);X(null,Q,U)});if(Y.code!=="EEXIST")return X(Y);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(J,(F,Q)=>{if(F){if(F.code==="ENOENT")return AW(D,{...$,stale:0},X);return X(F)}if(!K_(Q,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));H_(D,$,(U)=>{if(U)return X(U);AW(D,{...$,stale:0},X)})})})}function K_(D,$){return D.mtime.getTime()<Date.now()-$.stale}function H_(D,$,X){$.fs.rmdir(_2(D,$),(J)=>{if(J&&J.code!=="ENOENT")return X(J);X()})}function iF(D,$){let X=c6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(J,Y)=>{let F=X.lastUpdate+$.stale<Date.now();if(J){if(J.code==="ENOENT"||F)return EW(D,X,Object.assign(J,{code:"ECOMPROMISED"}));return X.updateDelay=1000,iF(D,$)}if(X.mtime.getTime()!==Y.mtime.getTime())return EW(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let U=W_.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,U,U,(Z)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||G)return EW(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,iF(D,$)}X.mtime=U,X.lastUpdate=Date.now(),X.updateDelay=null,iF(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function EW(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(c6[D]===$)delete c6[D];$.options.onCompromised(X)}function oW0(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:RW,onCompromised:(J)=>{throw J},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),TW(D,$,(J,Y)=>{if(J)return X(J);let F=rW0.operation($.retries);F.attempt(()=>{AW(Y,$,(Q,U,Z)=>{if(F.retry(Q))return;if(Q)return X(F.mainError());let G=c6[Y]={lockfilePath:_2(Y,$),mtime:U,mtimePrecision:Z,options:$,lastUpdate:Date.now()};iF(Y,$),X(null,(O)=>{if(G.released)return O&&O(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));z_(Y,{...$,realpath:!1},O)})})})})}function z_(D,$,X){$={fs:RW,realpath:!0,...$},TW(D,$,(J,Y)=>{if(J)return X(J);let F=c6[Y];if(!F)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));F.updateTimeout&&clearTimeout(F.updateTimeout),F.released=!0,delete c6[Y],H_(Y,$,X)})}function aW0(D,$,X){$={stale:1e4,realpath:!0,fs:RW,...$},$.stale=Math.max($.stale||0,2000),TW(D,$,(J,Y)=>{if(J)return X(J);$.fs.stat(_2(Y,$),(F,Q)=>{if(F)return F.code==="ENOENT"?X(null,!1):X(F);return X(null,!K_(Q,$))})})}function sW0(){return c6}tW0(()=>{for(let D in c6){let $=c6[D].options;try{$.fs.rmdirSync(_2(D,$))}catch(X){}}});eW0.lock=oW0;eW0.unlock=z_;eW0.check=aW0;eW0.getLocks=sW0});var L_=E((ne0,N_)=>{var YK0=mD();function FK0(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((J)=>{X[J]=(...Y)=>{let F=Y.pop(),Q;try{Q=D[`${J}Sync`](...Y)}catch(U){return F(U)}F(null,Q)}}),X}function QK0(D){return(...$)=>new Promise((X,J)=>{$.push((Y,F)=>{if(Y)J(Y);else X(F)}),D(...$)})}function UK0(D){return(...$)=>{let X,J;if($.push((Y,F)=>{X=Y,J=F}),D(...$),X)throw X;return J}}function ZK0(D){if(D={...D},D.fs=FK0(D.fs||YK0),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}N_.exports={toPromise:QK0,toSync:UK0,toSyncOptions:ZK0}});var M_=E((le0,A4)=>{var k5=V_(),{toPromise:pF,toSync:rF,toSyncOptions:CW}=L_();async function B_(D,$){let X=await pF(k5.lock)(D,$);return pF(X)}function GK0(D,$){let X=rF(k5.lock)(D,CW($));return rF(X)}function OK0(D,$){return pF(k5.unlock)(D,$)}function qK0(D,$){return rF(k5.unlock)(D,CW($))}function wK0(D,$){return pF(k5.check)(D,$)}function WK0(D,$){return rF(k5.check)(D,CW($))}A4.exports=B_;A4.exports.lock=B_;A4.exports.unlock=OK0;A4.exports.lockSync=GK0;A4.exports.unlockSync=qK0;A4.exports.check=wK0;A4.exports.checkSync=WK0});var C_=E((R_)=>{Object.defineProperty(R_,"__esModule",{value:!0});R_.canStoreURLs=R_.FileUrlStorage=void 0;var j_=l("fs"),KK0=zK0(ox()),I_=HK0(M_());function A_(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(A_=function(J){return J?X:$})(D)}function HK0(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=A_($);if(X&&X.has(D))return X.get(D);var J={__proto__:null},Y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var F in D)if(F!=="default"&&{}.hasOwnProperty.call(D,F)){var Q=Y?Object.getOwnPropertyDescriptor(D,F):null;Q&&(Q.get||Q.set)?Object.defineProperty(J,F,Q):J[F]=D[F]}return J.default=D,X&&X.set(D,J),J}function zK0(D){return D&&D.__esModule?D:{default:D}}function k2(D){return k2=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},k2(D)}function VK0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function E_(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,LK0(J.key),J)}}function NK0(D,$,X){if($)E_(D.prototype,$);if(X)E_(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function LK0(D){var $=BK0(D,"string");return k2($)=="symbol"?$:$+""}function BK0(D,$){if(k2(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(k2(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var ie0=R_.canStoreURLs=!0,pe0=R_.FileUrlStorage=function(){function D($){VK0(this,D),this.path=$}return NK0(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(J,Y){X._getItems("tus::",function(F,Q){if(F)Y(F);else J(Q)})})}},{key:"findUploadsByFingerprint",value:function(X){var J=this;return new Promise(function(Y,F){J._getItems("tus::".concat(X),function(Q,U){if(Q)F(Q);else Y(U)})})}},{key:"removeUpload",value:function(X){var J=this;return new Promise(function(Y,F){J._removeItem(X,function(Q){if(Q)F(Q);else Y()})})}},{key:"addUpload",value:function(X,J){var Y=this,F=Math.round(Math.random()*1000000000000),Q="tus::".concat(X,"::").concat(F);return new Promise(function(U,Z){Y._setItem(Q,J,function(G){if(G)Z(G);else U(Q)})})}},{key:"_setItem",value:function(X,J,Y){var F=this;I_.lock(this.path,this._lockfileOptions()).then(function(Q){Y=F._releaseAndCb(Q,Y),F._getData(function(U,Z){if(U){Y(U);return}Z[X]=J,F._writeData(Z,function(G){return Y(G)})})}).catch(Y)}},{key:"_getItems",value:function(X,J){this._getData(function(Y,F){if(Y){J(Y);return}var Q=Object.keys(F).filter(function(U){return U.startsWith(X)}).map(function(U){var Z=F[U];return Z.urlStorageKey=U,Z});J(null,Q)})}},{key:"_removeItem",value:function(X,J){var Y=this;I_.lock(this.path,this._lockfileOptions()).then(function(F){J=Y._releaseAndCb(F,J),Y._getData(function(Q,U){if(Q){J(Q);return}delete U[X],Y._writeData(U,function(Z){return J(Z)})})}).catch(J)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,J){return function(Y){if(Y){X().then(function(){return J(Y)}).catch(function(F){return J((0,KK0.default)([Y,F]))});return}X().then(J).catch(J)}}},{key:"_writeData",value:function(X,J){var Y={encoding:"utf8",mode:432,flag:"w"};(0,j_.writeFile)(this.path,JSON.stringify(X),Y,function(F){return J(F)})}},{key:"_getData",value:function(X){(0,j_.readFile)(this.path,"utf8",function(J,Y){if(J){if(J.code==="ENOENT")X(null,{});else X(J);return}try{Y=!Y.trim().length?{}:JSON.parse(Y)}catch(F){X(F);return}X(null,Y)})}}])}()});var oF=E((R4)=>{Object.defineProperty(R4,"__esModule",{value:!0});Object.defineProperty(R4,"DefaultHttpStack",{enumerable:!0,get:function(){return u_.default}});Object.defineProperty(R4,"DetailedError",{enumerable:!0,get:function(){return jK0.default}});Object.defineProperty(R4,"FileUrlStorage",{enumerable:!0,get:function(){return x_.FileUrlStorage}});Object.defineProperty(R4,"StreamSource",{enumerable:!0,get:function(){return TK0.default}});R4.Upload=void 0;Object.defineProperty(R4,"canStoreURLs",{enumerable:!0,get:function(){return x_.canStoreURLs}});R4.defaultOptions=void 0;Object.defineProperty(R4,"enableDebugLog",{enumerable:!0,get:function(){return IK0.enableDebugLog}});R4.isSupported=void 0;var jK0=r8(Cw()),IK0=Pw(),EK0=r8(Mv()),PW=r8(Du()),AK0=r8(Bu()),RK0=r8(Au()),u_=r8(mu()),TK0=r8(hw()),x_=C_();function r8(D){return D&&D.__esModule?D:{default:D}}function b5(D){return b5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},b5(D)}function CK0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function P_(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,f_(J.key),J)}}function PK0(D,$,X){if($)P_(D.prototype,$);if(X)P_(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function SK0(D,$,X){return $=tF($),vK0(D,__()?Reflect.construct($,X||[],tF(D).constructor):$.apply(D,X))}function vK0(D,$){if($&&(b5($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return uK0(D)}function uK0(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function __(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(__=function(){return!!D})()}function tF(D){return tF=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},tF(D)}function xK0(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)SW(D,$)}function SW(D,$){return SW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(J,Y){return J.__proto__=Y,J},SW(D,$)}function S_(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(D);$&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(D,Y).enumerable})),X.push.apply(X,J)}return X}function y5(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?S_(Object(X),!0).forEach(function(J){_K0(D,J,X[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):S_(Object(X)).forEach(function(J){Object.defineProperty(D,J,Object.getOwnPropertyDescriptor(X,J))})}return D}function _K0(D,$,X){if($=f_($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function f_(D){var $=fK0(D,"string");return b5($)=="symbol"?$:$+""}function fK0(D,$){if(b5(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(b5(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var v_=R4.defaultOptions=y5(y5({},PW.default.defaultOptions),{},{httpStack:new u_.default,fileReader:new AK0.default,urlStorage:new EK0.default,fingerprint:RK0.default}),te0=R4.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return CK0(this,$),J=y5(y5({},v_),J),SK0(this,$,[X,J])}return xK0($,D),PK0($,null,[{key:"terminate",value:function(J){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Y=y5(y5({},v_),Y),PW.default.terminate(J,Y)}}])}(PW.default),oe0=R4.isSupported=!0});var B1;var T4=r(()=>{B1={name:"@capgo/cli",type:"module",version:"8.5.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: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: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: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: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:init-guardrails":"bun test/test-init-guardrails.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.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: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: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: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:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && 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:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:mcp-analytics && 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-app-conflict && bun run test:init-guardrails && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && 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: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: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-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:platform-flow-contract && bun run test:tail-engine-shared","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: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-bundle-files":"bun test/test-support-bundle-files.mjs"},dependencies:{"@inkjs/ui":"^2.0.0",ink:"^7.0.4","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.6","string-width":"^8.2.1"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1"},devDependencies:{"@antfu/eslint-config":"^9.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.3.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.4.0","@modelcontextprotocol/sdk":"^1.29.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.106.2","@tanstack/intent":"^0.0.41","@types/adm-zip":"^0.5.8","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.9.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.15","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native-preview":"7.0.0-dev.20260526.1","@vercel/ncc":"^0.38.4","@xterm/headless":"^6.0.0","adm-zip":"^0.5.17","ci-info":"^4.4.0",commander:"^14.0.3",eslint:"^10.4.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.67.0",partysocket:"^1.1.19",prettyjson:"^1.2.5",tmp:"^0.2.6","tus-js-client":"^4.3.1",typescript:"^6.0.3",ws:"^8.21.0",zod:"^4.4.3"}}});async function aF(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,J=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!J.ok)return null;return(await J.json())["dist-tags"]?.latest||null}catch{return null}}async function yK0(){let D=await aF("@capgo/cli")??"",$=D?.split(".")[0]??"";return{currentVersion:B1.version,latestVersion:D,isOutdated:!!D&&D!==B1.version,majorVersion:$}}async function VD(){let{isOutdated:D,currentVersion:$,latestVersion:X,majorVersion:J}=await yK0();if(D)L.warning(`\uD83D\uDEA8 You are using @capgo/cli@${$} it's not the latest version.
|
|
127
|
+
GFS4: `),console.error(D)};if(!xD[Z1]){if(HW=global[Z1]||[],F_(xD,HW),xD.close=function(D){function $(X,J){return D.call(xD,X,function(Y){if(!Y)Y_();if(typeof J==="function")J.apply(this,arguments)})}return Object.defineProperty($,mF,{value:D}),$}(xD.close),xD.closeSync=function(D){function $(X){D.apply(xD,arguments),Y_()}return Object.defineProperty($,mF,{value:D}),$}(xD.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||""))process.on("exit",function(){n8(xD[Z1]),l("assert").equal(xD[Z1].length,0)})}var HW;if(!global[Z1])F_(global,xD[Z1]);NW.exports=zW(fW0(xD));if(process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!xD.__patched)NW.exports=zW(xD),xD.__patched=!0;function zW(D){xW0(D),D.gracefulify=zW,D.createReadStream=N,D.createWriteStream=A;var $=D.readFile;D.readFile=X;function X(I,x,P){if(typeof x==="function")P=x,x=null;return m(I,x,P);function m(b,p,k,R){return $(b,p,function(S){if(S&&(S.code==="EMFILE"||S.code==="ENFILE"))x5([m,[b,p,k],S,R||Date.now(),Date.now()]);else if(typeof k==="function")k.apply(this,arguments)})}}var J=D.writeFile;D.writeFile=Y;function Y(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return J(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var F=D.appendFile;if(F)D.appendFile=Q;function Q(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return F(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var U=D.copyFile;if(U)D.copyFile=Z;function Z(I,x,P,m){if(typeof P==="function")m=P,P=0;return b(I,x,P,m);function b(p,k,R,S,v){return U(p,k,R,function(f){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}var G=D.readdir;D.readdir=q;var O=/^v[0-5]\./;function q(I,x,P){if(typeof x==="function")P=x,x=null;var m=O.test(process.version)?function(k,R,S,v){return G(k,b(k,R,S,v))}:function(k,R,S,v){return G(k,R,b(k,R,S,v))};return m(I,x,P);function b(p,k,R,S){return function(v,f){if(v&&(v.code==="EMFILE"||v.code==="ENFILE"))x5([m,[p,k,R],v,S||Date.now(),Date.now()]);else{if(f&&f.sort)f.sort();if(typeof R==="function")R.call(this,v,f)}}}}if(process.version.substr(0,4)==="v0.8"){var w=_W0(D);M=w.ReadStream,z=w.WriteStream}var W=D.ReadStream;if(W)M.prototype=Object.create(W.prototype),M.prototype.open=j;var K=D.WriteStream;if(K)z.prototype=Object.create(K.prototype),z.prototype.open=V;Object.defineProperty(D,"ReadStream",{get:function(){return M},set:function(I){M=I},enumerable:!0,configurable:!0}),Object.defineProperty(D,"WriteStream",{get:function(){return z},set:function(I){z=I},enumerable:!0,configurable:!0});var H=M;Object.defineProperty(D,"FileReadStream",{get:function(){return H},set:function(I){H=I},enumerable:!0,configurable:!0});var B=z;Object.defineProperty(D,"FileWriteStream",{get:function(){return B},set:function(I){B=I},enumerable:!0,configurable:!0});function M(I,x){if(this instanceof M)return W.apply(this,arguments),this;else return M.apply(Object.create(M.prototype),arguments)}function j(){var I=this;_(I.path,I.flags,I.mode,function(x,P){if(x){if(I.autoClose)I.destroy();I.emit("error",x)}else I.fd=P,I.emit("open",P),I.read()})}function z(I,x){if(this instanceof z)return K.apply(this,arguments),this;else return z.apply(Object.create(z.prototype),arguments)}function V(){var I=this;_(I.path,I.flags,I.mode,function(x,P){if(x)I.destroy(),I.emit("error",x);else I.fd=P,I.emit("open",P)})}function N(I,x){return new D.ReadStream(I,x)}function A(I,x){return new D.WriteStream(I,x)}var u=D.open;D.open=_;function _(I,x,P,m){if(typeof P==="function")m=P,P=null;return b(I,x,P,m);function b(p,k,R,S,v){return u(p,k,R,function(f,h){if(f&&(f.code==="EMFILE"||f.code==="ENFILE"))x5([b,[p,k,R,S],f,v||Date.now(),Date.now()]);else if(typeof S==="function")S.apply(this,arguments)})}}return D}function x5(D){n8("ENQUEUE",D[0].name,D[1]),xD[Z1].push(D),VW()}var hF;function Y_(){var D=Date.now();for(var $=0;$<xD[Z1].length;++$)if(xD[Z1][$].length>2)xD[Z1][$][3]=D,xD[Z1][$][4]=D;VW()}function VW(){if(clearTimeout(hF),hF=void 0,xD[Z1].length===0)return;var D=xD[Z1].shift(),$=D[0],X=D[1],J=D[2],Y=D[3],F=D[4];if(Y===void 0)n8("RETRY",$.name,X),$.apply(null,X);else if(Date.now()-Y>=60000){n8("TIMEOUT",$.name,X);var Q=X.pop();if(typeof Q==="function")Q.call(null,J)}else{var U=Date.now()-F,Z=Math.max(F-Y,1),G=Math.min(Z*1.2,100);if(U>=G)n8("RETRY",$.name,X),$.apply(null,X.concat([Y]));else xD[Z1].push(D)}if(hF===void 0)hF=setTimeout(VW,0)}});var U_=E((he0,Q_)=>{function E$(D,$){if(typeof $==="boolean")$={forever:$};if(this._originalTimeouts=JSON.parse(JSON.stringify(D)),this._timeouts=D,this._options=$||{},this._maxRetryTime=$&&$.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Q_.exports=E$;E$.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};E$.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);this._timeouts=[],this._cachedTimeouts=null};E$.prototype.retry=function(D){if(this._timeout)clearTimeout(this._timeout);if(!D)return!1;var $=new Date().getTime();if(D&&$-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(D);var X=this._timeouts.shift();if(X===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),X=this._timeouts.shift();else return!1;var J=this,Y=setTimeout(function(){if(J._attempts++,J._operationTimeoutCb){if(J._timeout=setTimeout(function(){J._operationTimeoutCb(J._attempts)},J._operationTimeout),J._options.unref)J._timeout.unref()}J._fn(J._attempts)},X);if(this._options.unref)Y.unref();return!0};E$.prototype.attempt=function(D,$){if(this._fn=D,$){if($.timeout)this._operationTimeout=$.timeout;if($.cb)this._operationTimeoutCb=$.cb}var X=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){X._operationTimeoutCb()},X._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};E$.prototype.try=function(D){console.log("Using RetryOperation.try() is deprecated"),this.attempt(D)};E$.prototype.start=function(D){console.log("Using RetryOperation.start() is deprecated"),this.attempt(D)};E$.prototype.start=E$.prototype.try;E$.prototype.errors=function(){return this._errors};E$.prototype.attempts=function(){return this._attempts};E$.prototype.mainError=function(){if(this._errors.length===0)return null;var D={},$=null,X=0;for(var J=0;J<this._errors.length;J++){var Y=this._errors[J],F=Y.message,Q=(D[F]||0)+1;if(D[F]=Q,Q>=X)$=Y,X=Q}return $}});var G_=E((bW0)=>{var yW0=U_();bW0.operation=function(D){var $=bW0.timeouts(D);return new yW0($,{forever:D&&D.forever,unref:D&&D.unref,maxRetryTime:D&&D.maxRetryTime})};bW0.timeouts=function(D){if(D instanceof Array)return[].concat(D);var $={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var X in D)$[X]=D[X];if($.minTimeout>$.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var J=[];for(var Y=0;Y<$.retries;Y++)J.push(this.createTimeout(Y,$));if(D&&D.forever&&!J.length)J.push(this.createTimeout(Y,$));return J.sort(function(F,Q){return F-Q}),J};bW0.createTimeout=function(D,$){var X=$.randomize?Math.random()+1:1,J=Math.round(X*$.minTimeout*Math.pow($.factor,D));return J=Math.min(J,$.maxTimeout),J};bW0.wrap=function(D,$,X){if($ instanceof Array)X=$,$=null;if(!X){X=[];for(var J in D)if(typeof D[J]==="function")X.push(J)}for(var Y=0;Y<X.length;Y++){var F=X[Y],Q=D[F];D[F]=function(Z){var G=bW0.operation($),O=Array.prototype.slice.call(arguments,1),q=O.pop();O.push(function(w){if(G.retry(w))return;if(w)arguments[0]=G.mainError();q.apply(this,arguments)}),G.attempt(function(){Z.apply(D,O)})}.bind(D,Q),D[F].options=$}}});var O_=E((ce0,cF)=>{cF.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];if(process.platform!=="win32")cF.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")cF.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var lF=E((de0,f5)=>{var TD=global.process,l8=function(D){return D&&typeof D==="object"&&typeof D.removeListener==="function"&&typeof D.emit==="function"&&typeof D.reallyExit==="function"&&typeof D.listeners==="function"&&typeof D.kill==="function"&&typeof D.pid==="number"&&typeof D.on==="function"};if(!l8(TD))f5.exports=function(){return function(){}};else{if(LW=l("assert"),i8=O_(),BW=/^win/i.test(TD.platform),_5=l("events"),typeof _5!=="function")_5=_5.EventEmitter;if(TD.__signal_exit_emitter__)sD=TD.__signal_exit_emitter__;else sD=TD.__signal_exit_emitter__=new _5,sD.count=0,sD.emitted={};if(!sD.infinite)sD.setMaxListeners(1/0),sD.infinite=!0;f5.exports=function(D,$){if(!l8(global.process))return function(){};if(LW.equal(typeof D,"function","a callback must be provided for exit handler"),p8===!1)dF();var X="exit";if($&&$.alwaysLast)X="afterexit";var J=function(){if(sD.removeListener(X,D),sD.listeners("exit").length===0&&sD.listeners("afterexit").length===0)v2()};return sD.on(X,D),J},v2=function(){if(!p8||!l8(global.process))return;p8=!1,i8.forEach(function($){try{TD.removeListener($,u2[$])}catch(X){}}),TD.emit=x2,TD.reallyExit=nF,sD.count-=1},f5.exports.unload=v2,E4=function($,X,J){if(sD.emitted[$])return;sD.emitted[$]=!0,sD.emit($,X,J)},u2={},i8.forEach(function(D){u2[D]=function(){if(!l8(global.process))return;var X=TD.listeners(D);if(X.length===sD.count){if(v2(),E4("exit",null,D),E4("afterexit",null,D),BW&&D==="SIGHUP")D="SIGINT";TD.kill(TD.pid,D)}}}),f5.exports.signals=function(){return i8},p8=!1,dF=function(){if(p8||!l8(global.process))return;p8=!0,sD.count+=1,i8=i8.filter(function($){try{return TD.on($,u2[$]),!0}catch(X){return!1}}),TD.emit=jW,TD.reallyExit=MW},f5.exports.load=dF,nF=TD.reallyExit,MW=function($){if(!l8(global.process))return;TD.exitCode=$||0,E4("exit",TD.exitCode,null),E4("afterexit",TD.exitCode,null),nF.call(TD,TD.exitCode)},x2=TD.emit,jW=function($,X){if($==="exit"&&l8(global.process)){if(X!==void 0)TD.exitCode=X;var J=x2.apply(this,arguments);return E4("exit",TD.exitCode,null),E4("afterexit",TD.exitCode,null),J}else return x2.apply(this,arguments)}}var LW,i8,BW,_5,sD,v2,E4,u2,p8,dF,nF,MW,x2,jW});var w_=E((nW0,IW)=>{var q_=Symbol();function cW0(D,$,X){let J=$[q_];if(J)return $.stat(D,(F,Q)=>{if(F)return X(F);X(null,Q.mtime,J)});let Y=new Date(Math.ceil(Date.now()/1000)*1000+5);$.utimes(D,Y,Y,(F)=>{if(F)return X(F);$.stat(D,(Q,U)=>{if(Q)return X(Q);let Z=U.mtime.getTime()%1000===0?"s":"ms";Object.defineProperty($,q_,{value:Z}),X(null,U.mtime,Z)})})}function dW0(D){let $=Date.now();if(D==="s")$=Math.ceil($/1000)*1000;return new Date($)}nW0.probe=cW0;nW0.getMtime=dW0});var V_=E((eW0,f2)=>{var pW0=l("path"),RW=mD(),rW0=G_(),tW0=lF(),W_=w_(),c6={};function _2(D,$){return $.lockfilePath||`${D}.lock`}function TW(D,$,X){if(!$.realpath)return X(null,pW0.resolve(D));$.fs.realpath(D,X)}function AW(D,$,X){let J=_2(D,$);$.fs.mkdir(J,(Y)=>{if(!Y)return W_.probe(J,$.fs,(F,Q,U)=>{if(F)return $.fs.rmdir(J,()=>{}),X(F);X(null,Q,U)});if(Y.code!=="EEXIST")return X(Y);if($.stale<=0)return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));$.fs.stat(J,(F,Q)=>{if(F){if(F.code==="ENOENT")return AW(D,{...$,stale:0},X);return X(F)}if(!K_(Q,$))return X(Object.assign(Error("Lock file is already being held"),{code:"ELOCKED",file:D}));H_(D,$,(U)=>{if(U)return X(U);AW(D,{...$,stale:0},X)})})})}function K_(D,$){return D.mtime.getTime()<Date.now()-$.stale}function H_(D,$,X){$.fs.rmdir(_2(D,$),(J)=>{if(J&&J.code!=="ENOENT")return X(J);X()})}function iF(D,$){let X=c6[D];if(X.updateTimeout)return;if(X.updateDelay=X.updateDelay||$.update,X.updateTimeout=setTimeout(()=>{X.updateTimeout=null,$.fs.stat(X.lockfilePath,(J,Y)=>{let F=X.lastUpdate+$.stale<Date.now();if(J){if(J.code==="ENOENT"||F)return EW(D,X,Object.assign(J,{code:"ECOMPROMISED"}));return X.updateDelay=1000,iF(D,$)}if(X.mtime.getTime()!==Y.mtime.getTime())return EW(D,X,Object.assign(Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let U=W_.getMtime(X.mtimePrecision);$.fs.utimes(X.lockfilePath,U,U,(Z)=>{let G=X.lastUpdate+$.stale<Date.now();if(X.released)return;if(Z){if(Z.code==="ENOENT"||G)return EW(D,X,Object.assign(Z,{code:"ECOMPROMISED"}));return X.updateDelay=1000,iF(D,$)}X.mtime=U,X.lastUpdate=Date.now(),X.updateDelay=null,iF(D,$)})})},X.updateDelay),X.updateTimeout.unref)X.updateTimeout.unref()}function EW(D,$,X){if($.released=!0,$.updateTimeout)clearTimeout($.updateTimeout);if(c6[D]===$)delete c6[D];$.options.onCompromised(X)}function oW0(D,$,X){$={stale:1e4,update:null,realpath:!0,retries:0,fs:RW,onCompromised:(J)=>{throw J},...$},$.retries=$.retries||0,$.retries=typeof $.retries==="number"?{retries:$.retries}:$.retries,$.stale=Math.max($.stale||0,2000),$.update=$.update==null?$.stale/2:$.update||0,$.update=Math.max(Math.min($.update,$.stale/2),1000),TW(D,$,(J,Y)=>{if(J)return X(J);let F=rW0.operation($.retries);F.attempt(()=>{AW(Y,$,(Q,U,Z)=>{if(F.retry(Q))return;if(Q)return X(F.mainError());let G=c6[Y]={lockfilePath:_2(Y,$),mtime:U,mtimePrecision:Z,options:$,lastUpdate:Date.now()};iF(Y,$),X(null,(O)=>{if(G.released)return O&&O(Object.assign(Error("Lock is already released"),{code:"ERELEASED"}));z_(Y,{...$,realpath:!1},O)})})})})}function z_(D,$,X){$={fs:RW,realpath:!0,...$},TW(D,$,(J,Y)=>{if(J)return X(J);let F=c6[Y];if(!F)return X(Object.assign(Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));F.updateTimeout&&clearTimeout(F.updateTimeout),F.released=!0,delete c6[Y],H_(Y,$,X)})}function aW0(D,$,X){$={stale:1e4,realpath:!0,fs:RW,...$},$.stale=Math.max($.stale||0,2000),TW(D,$,(J,Y)=>{if(J)return X(J);$.fs.stat(_2(Y,$),(F,Q)=>{if(F)return F.code==="ENOENT"?X(null,!1):X(F);return X(null,!K_(Q,$))})})}function sW0(){return c6}tW0(()=>{for(let D in c6){let $=c6[D].options;try{$.fs.rmdirSync(_2(D,$))}catch(X){}}});eW0.lock=oW0;eW0.unlock=z_;eW0.check=aW0;eW0.getLocks=sW0});var L_=E((ne0,N_)=>{var YK0=mD();function FK0(D){let $=["mkdir","realpath","stat","rmdir","utimes"],X={...D};return $.forEach((J)=>{X[J]=(...Y)=>{let F=Y.pop(),Q;try{Q=D[`${J}Sync`](...Y)}catch(U){return F(U)}F(null,Q)}}),X}function QK0(D){return(...$)=>new Promise((X,J)=>{$.push((Y,F)=>{if(Y)J(Y);else X(F)}),D(...$)})}function UK0(D){return(...$)=>{let X,J;if($.push((Y,F)=>{X=Y,J=F}),D(...$),X)throw X;return J}}function ZK0(D){if(D={...D},D.fs=FK0(D.fs||YK0),typeof D.retries==="number"&&D.retries>0||D.retries&&typeof D.retries.retries==="number"&&D.retries.retries>0)throw Object.assign(Error("Cannot use retries with the sync api"),{code:"ESYNC"});return D}N_.exports={toPromise:QK0,toSync:UK0,toSyncOptions:ZK0}});var M_=E((le0,A4)=>{var k5=V_(),{toPromise:pF,toSync:rF,toSyncOptions:CW}=L_();async function B_(D,$){let X=await pF(k5.lock)(D,$);return pF(X)}function GK0(D,$){let X=rF(k5.lock)(D,CW($));return rF(X)}function OK0(D,$){return pF(k5.unlock)(D,$)}function qK0(D,$){return rF(k5.unlock)(D,CW($))}function wK0(D,$){return pF(k5.check)(D,$)}function WK0(D,$){return rF(k5.check)(D,CW($))}A4.exports=B_;A4.exports.lock=B_;A4.exports.unlock=OK0;A4.exports.lockSync=GK0;A4.exports.unlockSync=qK0;A4.exports.check=wK0;A4.exports.checkSync=WK0});var C_=E((R_)=>{Object.defineProperty(R_,"__esModule",{value:!0});R_.canStoreURLs=R_.FileUrlStorage=void 0;var j_=l("fs"),KK0=zK0(ox()),I_=HK0(M_());function A_(D){if(typeof WeakMap!="function")return null;var $=new WeakMap,X=new WeakMap;return(A_=function(J){return J?X:$})(D)}function HK0(D,$){if(!$&&D&&D.__esModule)return D;if(D===null||typeof D!="object"&&typeof D!="function")return{default:D};var X=A_($);if(X&&X.has(D))return X.get(D);var J={__proto__:null},Y=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var F in D)if(F!=="default"&&{}.hasOwnProperty.call(D,F)){var Q=Y?Object.getOwnPropertyDescriptor(D,F):null;Q&&(Q.get||Q.set)?Object.defineProperty(J,F,Q):J[F]=D[F]}return J.default=D,X&&X.set(D,J),J}function zK0(D){return D&&D.__esModule?D:{default:D}}function k2(D){return k2=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},k2(D)}function VK0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function E_(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,LK0(J.key),J)}}function NK0(D,$,X){if($)E_(D.prototype,$);if(X)E_(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function LK0(D){var $=BK0(D,"string");return k2($)=="symbol"?$:$+""}function BK0(D,$){if(k2(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(k2(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var ie0=R_.canStoreURLs=!0,pe0=R_.FileUrlStorage=function(){function D($){VK0(this,D),this.path=$}return NK0(D,[{key:"findAllUploads",value:function(){var X=this;return new Promise(function(J,Y){X._getItems("tus::",function(F,Q){if(F)Y(F);else J(Q)})})}},{key:"findUploadsByFingerprint",value:function(X){var J=this;return new Promise(function(Y,F){J._getItems("tus::".concat(X),function(Q,U){if(Q)F(Q);else Y(U)})})}},{key:"removeUpload",value:function(X){var J=this;return new Promise(function(Y,F){J._removeItem(X,function(Q){if(Q)F(Q);else Y()})})}},{key:"addUpload",value:function(X,J){var Y=this,F=Math.round(Math.random()*1000000000000),Q="tus::".concat(X,"::").concat(F);return new Promise(function(U,Z){Y._setItem(Q,J,function(G){if(G)Z(G);else U(Q)})})}},{key:"_setItem",value:function(X,J,Y){var F=this;I_.lock(this.path,this._lockfileOptions()).then(function(Q){Y=F._releaseAndCb(Q,Y),F._getData(function(U,Z){if(U){Y(U);return}Z[X]=J,F._writeData(Z,function(G){return Y(G)})})}).catch(Y)}},{key:"_getItems",value:function(X,J){this._getData(function(Y,F){if(Y){J(Y);return}var Q=Object.keys(F).filter(function(U){return U.startsWith(X)}).map(function(U){var Z=F[U];return Z.urlStorageKey=U,Z});J(null,Q)})}},{key:"_removeItem",value:function(X,J){var Y=this;I_.lock(this.path,this._lockfileOptions()).then(function(F){J=Y._releaseAndCb(F,J),Y._getData(function(Q,U){if(Q){J(Q);return}delete U[X],Y._writeData(U,function(Z){return J(Z)})})}).catch(J)}},{key:"_lockfileOptions",value:function(){return{realpath:!1,retries:{retries:5,minTimeout:20}}}},{key:"_releaseAndCb",value:function(X,J){return function(Y){if(Y){X().then(function(){return J(Y)}).catch(function(F){return J((0,KK0.default)([Y,F]))});return}X().then(J).catch(J)}}},{key:"_writeData",value:function(X,J){var Y={encoding:"utf8",mode:432,flag:"w"};(0,j_.writeFile)(this.path,JSON.stringify(X),Y,function(F){return J(F)})}},{key:"_getData",value:function(X){(0,j_.readFile)(this.path,"utf8",function(J,Y){if(J){if(J.code==="ENOENT")X(null,{});else X(J);return}try{Y=!Y.trim().length?{}:JSON.parse(Y)}catch(F){X(F);return}X(null,Y)})}}])}()});var oF=E((R4)=>{Object.defineProperty(R4,"__esModule",{value:!0});Object.defineProperty(R4,"DefaultHttpStack",{enumerable:!0,get:function(){return u_.default}});Object.defineProperty(R4,"DetailedError",{enumerable:!0,get:function(){return jK0.default}});Object.defineProperty(R4,"FileUrlStorage",{enumerable:!0,get:function(){return x_.FileUrlStorage}});Object.defineProperty(R4,"StreamSource",{enumerable:!0,get:function(){return TK0.default}});R4.Upload=void 0;Object.defineProperty(R4,"canStoreURLs",{enumerable:!0,get:function(){return x_.canStoreURLs}});R4.defaultOptions=void 0;Object.defineProperty(R4,"enableDebugLog",{enumerable:!0,get:function(){return IK0.enableDebugLog}});R4.isSupported=void 0;var jK0=r8(Cw()),IK0=Pw(),EK0=r8(Mv()),PW=r8(Du()),AK0=r8(Bu()),RK0=r8(Au()),u_=r8(mu()),TK0=r8(hw()),x_=C_();function r8(D){return D&&D.__esModule?D:{default:D}}function b5(D){return b5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function($){return typeof $}:function($){return $&&typeof Symbol=="function"&&$.constructor===Symbol&&$!==Symbol.prototype?"symbol":typeof $},b5(D)}function CK0(D,$){if(!(D instanceof $))throw TypeError("Cannot call a class as a function")}function P_(D,$){for(var X=0;X<$.length;X++){var J=$[X];if(J.enumerable=J.enumerable||!1,J.configurable=!0,"value"in J)J.writable=!0;Object.defineProperty(D,f_(J.key),J)}}function PK0(D,$,X){if($)P_(D.prototype,$);if(X)P_(D,X);return Object.defineProperty(D,"prototype",{writable:!1}),D}function SK0(D,$,X){return $=tF($),vK0(D,__()?Reflect.construct($,X||[],tF(D).constructor):$.apply(D,X))}function vK0(D,$){if($&&(b5($)==="object"||typeof $==="function"))return $;else if($!==void 0)throw TypeError("Derived constructors may only return object or undefined");return uK0(D)}function uK0(D){if(D===void 0)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return D}function __(){try{var D=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch($){}return(__=function(){return!!D})()}function tF(D){return tF=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(X){return X.__proto__||Object.getPrototypeOf(X)},tF(D)}function xK0(D,$){if(typeof $!=="function"&&$!==null)throw TypeError("Super expression must either be null or a function");if(D.prototype=Object.create($&&$.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),$)SW(D,$)}function SW(D,$){return SW=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(J,Y){return J.__proto__=Y,J},SW(D,$)}function S_(D,$){var X=Object.keys(D);if(Object.getOwnPropertySymbols){var J=Object.getOwnPropertySymbols(D);$&&(J=J.filter(function(Y){return Object.getOwnPropertyDescriptor(D,Y).enumerable})),X.push.apply(X,J)}return X}function y5(D){for(var $=1;$<arguments.length;$++){var X=arguments[$]!=null?arguments[$]:{};$%2?S_(Object(X),!0).forEach(function(J){_K0(D,J,X[J])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(X)):S_(Object(X)).forEach(function(J){Object.defineProperty(D,J,Object.getOwnPropertyDescriptor(X,J))})}return D}function _K0(D,$,X){if($=f_($),$ in D)Object.defineProperty(D,$,{value:X,enumerable:!0,configurable:!0,writable:!0});else D[$]=X;return D}function f_(D){var $=fK0(D,"string");return b5($)=="symbol"?$:$+""}function fK0(D,$){if(b5(D)!="object"||!D)return D;var X=D[Symbol.toPrimitive];if(X!==void 0){var J=X.call(D,$||"default");if(b5(J)!="object")return J;throw TypeError("@@toPrimitive must return a primitive value.")}return($==="string"?String:Number)(D)}var v_=R4.defaultOptions=y5(y5({},PW.default.defaultOptions),{},{httpStack:new u_.default,fileReader:new AK0.default,urlStorage:new EK0.default,fingerprint:RK0.default}),te0=R4.Upload=function(D){function $(){var X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,J=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return CK0(this,$),J=y5(y5({},v_),J),SK0(this,$,[X,J])}return xK0($,D),PK0($,null,[{key:"terminate",value:function(J){var Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Y=y5(y5({},v_),Y),PW.default.terminate(J,Y)}}])}(PW.default),oe0=R4.isSupported=!0});var B1;var T4=r(()=>{B1={name:"@capgo/cli",type:"module",version:"8.6.0",description:"A CLI to upload to capgo servers",author:"Martin martin@capgo.app",license:"Apache 2.0",homepage:"https://github.com/Cap-go/capgo/tree/main/cli#readme",repository:{type:"git",url:"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: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: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: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: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:init-guardrails":"bun test/test-init-guardrails.mjs","test:prompt-preferences":"bun test/test-prompt-preferences.mjs","test:esm-sdk":"node test/test-sdk-esm.mjs","test:mcp":"node test/test-mcp.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: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: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: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:version-edge-cases && bun run test:regex && bun run test:upload && bun run test:fail-on-incompatible && 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:analytics-error-category && bun run test:analytics-org-resolver && bun run test:supabase-perf && bun run test:preview-qr && bun run test:mcp-analytics && 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-app-conflict && bun run test:init-guardrails && bun run test:prompt-preferences && bun run test:esm-sdk && bun run test:mcp && bun run test:version-detection && bun run test:platform-paths && 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: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: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-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:platform-flow-contract && bun run test:tail-engine-shared","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: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-bundle-files":"bun test/test-support-bundle-files.mjs"},dependencies:{"@inkjs/ui":"^2.0.0",ink:"^7.0.4","ink-spinner":"^5.0.0",jsonwebtoken:"^9.0.3","node-forge":"^1.4.0",qrcode:"^1.5.4",react:"^19.2.6","string-width":"^8.2.1"},optionalDependencies:{"@capgo/cli-helper-darwin-arm64":"^1.1.1","@capgo/cli-helper-darwin-x64":"^1.1.1"},devDependencies:{"@antfu/eslint-config":"^9.0.0","@bradenmacdonald/s3-lite-client":"npm:@jsr/bradenmacdonald__s3-lite-client@0.9.6","@capacitor/cli":"^8.3.4","@capgo/find-package-manager":"^0.0.18","@clack/prompts":"^1.4.0","@modelcontextprotocol/sdk":"^1.29.0","@sauber/table":"npm:@jsr/sauber__table","@std/semver":"npm:@jsr/std__semver@1.0.8","@supabase/supabase-js":"^2.106.2","@tanstack/intent":"^0.0.41","@types/adm-zip":"^0.5.8","@types/jsonwebtoken":"^9.0.10","@types/node":"^25.9.1","@types/node-forge":"^1.3.14","@types/prettyjson":"^0.0.33","@types/qrcode":"^1.5.6","@types/react":"^19.2.15","@types/tmp":"^0.2.6","@types/ws":"^8.18.1","@typescript/native-preview":"7.0.0-dev.20260526.1","@vercel/ncc":"^0.38.4","@xterm/headless":"^6.0.0","adm-zip":"^0.5.17","ci-info":"^4.4.0",commander:"^14.0.3",eslint:"^10.4.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.67.0",partysocket:"^1.1.19",prettyjson:"^1.2.5",tmp:"^0.2.6","tus-js-client":"^4.3.1",typescript:"^6.0.3",ws:"^8.21.0",zod:"^4.4.3"}}});async function aF(D){try{let X=`https://registry.npmjs.org/${encodeURIComponent(D.toLowerCase())}`,J=await fetch(X,{headers:{accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"}});if(!J.ok)return null;return(await J.json())["dist-tags"]?.latest||null}catch{return null}}async function yK0(){let D=await aF("@capgo/cli")??"",$=D?.split(".")[0]??"";return{currentVersion:B1.version,latestVersion:D,isOutdated:!!D&&D!==B1.version,majorVersion:$}}async function VD(){let{isOutdated:D,currentVersion:$,latestVersion:X,majorVersion:J}=await yK0();if(D)L.warning(`\uD83D\uDEA8 You are using @capgo/cli@${$} it's not the latest version.
|
|
128
128
|
Please use @capgo/cli@${X}" or @capgo/cli@${J} to keep up to date with the latest features and bug fixes.`)}var x1=r(()=>{g0();T4()});async function g_(D,$,X,J,Y,F="✅"){await j0(X,{channel:D,event:J,icon:F,org_id:$,tracking_version:2,...Y?{tags:{"app-id":Y}}:{},notify:!1})}var h_=r(()=>{g0();i9();x1();_0()});var c_=E((G0D,m_)=>{var g5=1000,h5=g5*60,m5=h5*60,t8=m5*24,bK0=t8*7,gK0=t8*365.25;m_.exports=function(D,$){$=$||{};var X=typeof D;if(X==="string"&&D.length>0)return hK0(D);else if(X==="number"&&isFinite(D))return $.long?cK0(D):mK0(D);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(D))};function hK0(D){if(D=String(D),D.length>100)return;var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(D);if(!$)return;var X=parseFloat($[1]),J=($[2]||"ms").toLowerCase();switch(J){case"years":case"year":case"yrs":case"yr":case"y":return X*gK0;case"weeks":case"week":case"w":return X*bK0;case"days":case"day":case"d":return X*t8;case"hours":case"hour":case"hrs":case"hr":case"h":return X*m5;case"minutes":case"minute":case"mins":case"min":case"m":return X*h5;case"seconds":case"second":case"secs":case"sec":case"s":return X*g5;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return X;default:return}}function mK0(D){var $=Math.abs(D);if($>=t8)return Math.round(D/t8)+"d";if($>=m5)return Math.round(D/m5)+"h";if($>=h5)return Math.round(D/h5)+"m";if($>=g5)return Math.round(D/g5)+"s";return D+"ms"}function cK0(D){var $=Math.abs(D);if($>=t8)return sF(D,$,t8,"day");if($>=m5)return sF(D,$,m5,"hour");if($>=h5)return sF(D,$,h5,"minute");if($>=g5)return sF(D,$,g5,"second");return D+" ms"}function sF(D,$,X,J){var Y=$>=X*1.5;return Math.round(D/X)+" "+J+(Y?"s":"")}});var vW=E((O0D,d_)=>{function dK0(D){X.debug=X,X.default=X,X.coerce=Z,X.disable=Q,X.enable=Y,X.enabled=U,X.humanize=c_(),X.destroy=G,Object.keys(D).forEach((O)=>{X[O]=D[O]}),X.names=[],X.skips=[],X.formatters={};function $(O){let q=0;for(let w=0;w<O.length;w++)q=(q<<5)-q+O.charCodeAt(w),q|=0;return X.colors[Math.abs(q)%X.colors.length]}X.selectColor=$;function X(O){let q,w=null,W,K;function H(...B){if(!H.enabled)return;let M=H,j=Number(new Date),z=j-(q||j);if(M.diff=z,M.prev=q,M.curr=j,q=j,B[0]=X.coerce(B[0]),typeof B[0]!=="string")B.unshift("%O");let V=0;B[0]=B[0].replace(/%([a-zA-Z%])/g,(A,u)=>{if(A==="%%")return"%";V++;let _=X.formatters[u];if(typeof _==="function"){let I=B[V];A=_.call(M,I),B.splice(V,1),V--}return A}),X.formatArgs.call(M,B),(M.log||X.log).apply(M,B)}if(H.namespace=O,H.useColors=X.useColors(),H.color=X.selectColor(O),H.extend=J,H.destroy=X.destroy,Object.defineProperty(H,"enabled",{enumerable:!0,configurable:!1,get:()=>{if(w!==null)return w;if(W!==X.namespaces)W=X.namespaces,K=X.enabled(O);return K},set:(B)=>{w=B}}),typeof X.init==="function")X.init(H);return H}function J(O,q){let w=X(this.namespace+(typeof q>"u"?":":q)+O);return w.log=this.log,w}function Y(O){X.save(O),X.namespaces=O,X.names=[],X.skips=[];let q=(typeof O==="string"?O:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let w of q)if(w[0]==="-")X.skips.push(w.slice(1));else X.names.push(w)}function F(O,q){let w=0,W=0,K=-1,H=0;while(w<O.length)if(W<q.length&&(q[W]===O[w]||q[W]==="*"))if(q[W]==="*")K=W,H=w,W++;else w++,W++;else if(K!==-1)W=K+1,H++,w=H;else return!1;while(W<q.length&&q[W]==="*")W++;return W===q.length}function Q(){let O=[...X.names,...X.skips.map((q)=>"-"+q)].join(",");return X.enable(""),O}function U(O){for(let q of X.skips)if(F(O,q))return!1;for(let q of X.names)if(F(O,q))return!0;return!1}function Z(O){if(O instanceof Error)return O.stack||O.message;return O}function G(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return X.enable(X.load()),X}d_.exports=dK0});var l_=E((n_,eF)=>{n_.formatArgs=lK0;n_.save=iK0;n_.load=pK0;n_.useColors=nK0;n_.storage=rK0();n_.destroy=(()=>{let D=!1;return()=>{if(!D)D=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}})();n_.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function nK0(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let D;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(D=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(D[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function lK0(D){if(D[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+D[0]+(this.useColors?"%c ":" ")+"+"+eF.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;D.splice(1,0,$,"color: inherit");let X=0,J=0;D[0].replace(/%[a-zA-Z%]/g,(Y)=>{if(Y==="%%")return;if(X++,Y==="%c")J=X}),D.splice(J,0,$)}n_.log=console.debug||console.log||(()=>{});function iK0(D){try{if(D)n_.storage.setItem("debug",D);else n_.storage.removeItem("debug")}catch($){}}function pK0(){let D;try{D=n_.storage.getItem("debug")||n_.storage.getItem("DEBUG")}catch($){}if(!D&&typeof process<"u"&&"env"in process)D=process.env.DEBUG;return D}function rK0(){try{return localStorage}catch(D){}}eF.exports=vW()(n_);var{formatters:tK0}=eF.exports;tK0.j=function(D){try{return JSON.stringify(D)}catch($){return"[UnexpectedJSONParseError]: "+$.message}}});var p_=E((w0D,i_)=>{i_.exports=(D,$=process.argv)=>{let X=D.startsWith("-")?"":D.length===1?"-":"--",J=$.indexOf(X+D),Y=$.indexOf("--");return J!==-1&&(Y===-1||J<Y)}});var o_=E((W0D,t_)=>{var JH0=l("os"),r_=l("tty"),A$=p_(),{env:X1}=process,C4;if(A$("no-color")||A$("no-colors")||A$("color=false")||A$("color=never"))C4=0;else if(A$("color")||A$("colors")||A$("color=true")||A$("color=always"))C4=1;if("FORCE_COLOR"in X1)if(X1.FORCE_COLOR==="true")C4=1;else if(X1.FORCE_COLOR==="false")C4=0;else C4=X1.FORCE_COLOR.length===0?1:Math.min(parseInt(X1.FORCE_COLOR,10),3);function uW(D){if(D===0)return!1;return{level:D,hasBasic:!0,has256:D>=2,has16m:D>=3}}function xW(D,$){if(C4===0)return 0;if(A$("color=16m")||A$("color=full")||A$("color=truecolor"))return 3;if(A$("color=256"))return 2;if(D&&!$&&C4===void 0)return 0;let X=C4||0;if(X1.TERM==="dumb")return X;if(process.platform==="win32"){let J=JH0.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in X1){if(["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some((J)=>(J in X1))||X1.CI_NAME==="codeship")return 1;return X}if("TEAMCITY_VERSION"in X1)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(X1.TEAMCITY_VERSION)?1:0;if(X1.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in X1){let J=parseInt((X1.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(X1.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(X1.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(X1.TERM))return 1;if("COLORTERM"in X1)return 1;return X}function YH0(D){let $=xW(D,D&&D.isTTY);return uW($)}t_.exports={supportsColor:YH0,stdout:uW(xW(!0,r_.isatty(1))),stderr:uW(xW(!0,r_.isatty(2)))}});var Df=E((s_,$Q)=>{var FH0=l("tty"),DQ=l("util");s_.init=wH0;s_.log=GH0;s_.formatArgs=UH0;s_.save=OH0;s_.load=qH0;s_.useColors=QH0;s_.destroy=DQ.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");s_.colors=[6,2,3,4,5,1];try{let D=o_();if(D&&(D.stderr||D).level>=2)s_.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221]}catch(D){}s_.inspectOpts=Object.keys(process.env).filter((D)=>{return/^debug_/i.test(D)}).reduce((D,$)=>{let X=$.substring(6).toLowerCase().replace(/_([a-z])/g,(Y,F)=>{return F.toUpperCase()}),J=process.env[$];if(/^(yes|on|true|enabled)$/i.test(J))J=!0;else if(/^(no|off|false|disabled)$/i.test(J))J=!1;else if(J==="null")J=null;else J=Number(J);return D[X]=J,D},{});function QH0(){return"colors"in s_.inspectOpts?Boolean(s_.inspectOpts.colors):FH0.isatty(process.stderr.fd)}function UH0(D){let{namespace:$,useColors:X}=this;if(X){let J=this.color,Y="\x1B[3"+(J<8?J:"8;5;"+J),F=` ${Y};1m${$} \x1B[0m`;D[0]=F+D[0].split(`
|
|
129
129
|
`).join(`
|
|
130
130
|
`+F),D.push(Y+"m+"+$Q.exports.humanize(this.diff)+"\x1B[0m")}else D[0]=ZH0()+$+" "+D[0]}function ZH0(){if(s_.inspectOpts.hideDate)return"";return new Date().toISOString()+" "}function GH0(...D){return process.stderr.write(DQ.formatWithOptions(s_.inspectOpts,...D)+`
|
|
@@ -565,7 +565,7 @@ ${$.gzPath}${U}`,G=`${V$0(D.body,Z)}${Z}`,O=MI({to:v9,subject:D.subject,body:G})
|
|
|
565
565
|
`))X(Q);X(Y),X("")}catch{X(""),X(Y),X("")}return}J(`Unknown message type "${D}" — you may need to update the CLI`),X(JSON.stringify($,null,2))}_0();function Td0(D){if(!D||typeof D!=="object")return;let $=D.originalResponse?.getStatus?.();return typeof $==="number"?$:void 0}function Cd0(D){let $=Td0(D);if($===401||$===403)return"unauthorized";if($===413)return"payload_too_large";if($!==void 0&&$>=500&&$<600)return"storage_failure";if($===void 0||$===0)return"network_error";return"unknown"}var Pd0={started:"Builder Upload Started",succeeded:"Builder Upload Succeeded",failed:"Builder Upload Failed"},Sd0={started:"⬆️",succeeded:"\uD83D\uDCE6",failed:"\uD83D\uDEAB"};async function CO(D){let $={app_id:D.appId,platform:D.platform,build_mode:D.buildMode,job_id:D.jobId,upload_size_bytes:String(D.sizeBytes)};if(typeof D.durationSeconds==="number"&&Number.isFinite(D.durationSeconds))$.upload_duration_seconds=String(Math.round(D.durationSeconds));if(D.phase==="failed"&&D.error!==void 0)$.failure_category=Cd0(D.error);try{await j0(D.apikey,{event:Pd0[D.phase],channel:"build-lifecycle",icon:Sd0[D.phase],notify:!1,org_id:D.orgId,tracking_version:2,tags:$})}catch{}}async function yd0(){return Q1({message:"No platform selected. Which platform do you want to build?",options:[{value:"ios",label:"iOS"},{value:"android",label:"Android"}]})}async function bd0(D,{silent:$=!1,interactive:X=kG({silent:$}),promptPlatform:J=yd0}={}){if(D==="ios"||D==="android")return D;if(D)throw Error(`Invalid platform "${D}". Must be "ios" or "android"`);if(!X)throw Error("Missing required argument: --platform <ios|android>. In an interactive terminal, you can omit --platform and choose one when prompted.");let Y=await J();if(c0(Y))throw Error("Build request canceled.");if(Y!=="ios"&&Y!=="android")throw Error("Build request canceled.");return Y}function gd0(D){return{info:($)=>{if(!D)L.info($)},error:($)=>{if(!D)L.error($)},warn:($)=>{if(!D)L.warn($)},success:($)=>{if(!D)L.success($)},buildLog:($)=>{if(!D)console.log($)},uploadProgress:(()=>{let $=D?null:jD(),X=!1;return(J)=>{if(D||!$)return;if(!X)$.start("Uploading bundle"),X=!0;if(J>=100)$.stop("Upload complete!");else $.message(`Uploading ${J.toFixed(0)}%`)}})(),customMsg:async($,X)=>{if(!D)await AE($,X,(J)=>console.log(J),(J)=>L.warn(J))}}}var r40=Promise.resolve();async function hd0(D,$){let X=async()=>{let Y=CE();try{p40(D)}catch(F){throw Error(`Failed to change working directory to "${D}": ${F.message}`)}try{return await $()}finally{try{p40(Y)}catch(F){q3(`cwd restore failed (ignored): ${F instanceof Error?F.message:String(F)}`)}}},J=r40.then(X,X);return r40=J.then(()=>{return},()=>{return}),J}async function md0(D,$,X=3,J){let Y=[1000,3000,5000];for(let F=1;F<=X;F++)try{let Q=await fetch(D,$);if(Q.ok||Q.status>=400&&Q.status<500)return Q;let U=await Q.text().catch(()=>"unknown error");if(J?.warn(`Build request attempt ${F}/${X} failed: ${Q.status} - ${U}`),F<X){let Z=Y[F-1]||5000;J?.info(`Retrying in ${Z/1000}s...`),await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${Q.status} - ${U}`)}catch(Q){let U=Q instanceof Error?Q.message:String(Q);if(U.startsWith("Failed to request build after"))throw Q;if(J?.warn(`Build request attempt ${F}/${X} failed: ${U}`),F<X){let Z=Y[F-1]||5000;J?.info(`Retrying in ${Z/1000}s...`),await new Promise((G)=>setTimeout(G,Z))}else throw Error(`Failed to request build after ${X} attempts: ${U}`)}throw Error("Unexpected error in fetchWithRetry")}var cd0=["succeeded","failed","expired","released","cancelled"],SO=new Set(cd0);function dd0(D){if(typeof D.data==="string")return D.data;if(D.data instanceof ArrayBuffer)return new TextDecoder().decode(D.data);if(ArrayBuffer.isView(D.data)){let $=D.data;return new TextDecoder().decode(new Uint8Array($.buffer,$.byteOffset,$.byteLength))}if(D.data&&typeof D.data.toString==="function")return D.data.toString();return""}function a40(D,$,X){if($)$.warn(D);else if(!X)L.warn(D)}async function nd0(D,$,X,J){try{if(X)await X.customMsg(D,$);else if(!J)await AE(D,$,(Y)=>console.log(Y),(Y)=>L.warn(Y))}catch(Y){a40(`Custom message handler encountered an error, continuing... ${String(Y)}`,X,J)}}async function ld0(D,$=!1,X,J,Y,F,Q,U){if(D&&!U)return null;let Z=null,G=!1,O=(w)=>{if(!w.trim())return;if(Z)return;if(!G)if(G=!0,U)U.buildLog("");else console.log("");if(U)U.buildLog(w);else console.log(w)},q=async()=>{if(!X||!J)return null;let w=X.replace(/\/+$/,""),W=`${w}/start`,H=`${w}/stream?token=${encodeURIComponent(J)}`.replace(/^https:/,"wss:").replace(/^http:/,"ws:");if(U)U.info("Connecting to log streaming...");else if(!D)console.log("Connecting to log streaming...");let B=await fetch(W,{method:"POST",headers:{"x-capgo-log-token":J}});if(!B.ok){let M=await B.text().catch(()=>"unknown error");if(U)U.warn(`Could not start log session (${B.status}): ${M}`);else if(!D)console.warn(`Could not start log session (${B.status}): ${M}`);return null}return await new Promise((M)=>{let j=!1,z=10,V=0,N=!1,A=new _J(H,void 0,{maxRetries:z,WebSocket:l10}),u=null,_=0,I=Date.now(),x=!1,P=2000,m=4,b=SO,p=null,k=null,R=(h)=>{if(j)return;if(j=!0,k)clearTimeout(k),k=null;if(u)clearInterval(u),u=null;if(F&&p)F.removeEventListener("abort",p),p=null;try{A.close()}catch(y){q3(`ws.close failed during cleanup (ignored): ${y instanceof Error?y.message:String(y)}`)}M(h)};k=setTimeout(()=>{if(!j){if(U)U.warn("Log streaming timed out after 3 hours");else if(!D)console.warn("Log streaming timed out after 3 hours");R(null)}},10800000);let S=()=>{if(u)return;u=setInterval(async()=>{try{if(A.readyState===_J.OPEN)A.send(JSON.stringify({type:"heartbeat",lastId:_}));let h=Date.now();if(Y&&!x&&h-I>=P*m){x=!0;try{let y=await Y();if(y&&b.has(y))Z=y,R(Z)}finally{x=!1}}}catch(h){if(U)U.warn(`Heartbeat encountered an error, continuing... ${String(h)}`);else if(!D)L.warn(`Heartbeat encountered an error, continuing... ${String(h)}`)}},P)},v=async(h)=>{if(h.type==="custom_msg"&&typeof h.kind==="string"&&h.data){I=Date.now(),await nd0(h.kind,h.data,U,D);return}if(h.type==="status"&&typeof h.status==="string"){let y=h.status.toLowerCase();if(I=Date.now(),b.has(y))Z=y;return}if(h.type==="log"&&typeof h.message==="string"){I=Date.now(),O(h.message);return}if(typeof h.message==="string")I=Date.now(),O(h.message)},f=(h)=>{if(A.readyState!==_J.OPEN)return;try{A.send(JSON.stringify({type:"confirmed_received",lastId:h}))}catch(y){a40(`Failed to send log confirmation, continuing... ${String(y)}`,U,D)}};if(S(),F){if(p=()=>{if(!j)R("cancelled")},F.aborted){R("cancelled");return}F.addEventListener("abort",p)}A.addEventListener("message",async(h)=>{let y=dd0(h),a=null;try{a=JSON.parse(y)}catch{a=null}if(a?.type==="heartbeat_response")return;if(a?.type==="batch_messages"&&Array.isArray(a.messages)){let c=_;for(let t of a.messages)if(await v(t),typeof t.id==="number")c=Math.max(c,t.id);if(c>_)_=c,f(c)}else{if(a)await v(a);else if(y)I=Date.now(),O(y);if(a&&typeof a.id==="number"&&a.id>_)_=a.id,f(a.id)}if(Z)R(Z)}),A.addEventListener("error",()=>{if(V+=1,U)U.warn(`Log stream encountered an error, retrying (${V}/${z})...`);else if(!D)console.warn(`Log stream encountered an error, retrying (${V}/${z})...`);if(!N&&V>=z){if(N=!0,U)U.warn("Log stream retry limit reached. Falling back to status checks.");else if(!D)L.warn("Log stream retry limit reached. Falling back to status checks.");if(Q)Q();R(null)}}),A.addEventListener("close",()=>{if(j)return;if(Z){R(Z);return}if(U)U.warn("Log stream closed, waiting for reconnect...");else if(!D)L.warn("Log stream closed, waiting for reconnect...")})})};try{let w=await q();if(w||Z)return w||Z}catch(w){if(U)U.warn(`Direct log streaming failed${w instanceof Error?`: ${w.message}`:""}`);else if(!D)L.warn(`Direct log streaming failed${w instanceof Error?`: ${w.message}`:""}`)}return Z}async function id0(D,$,X,J,Y,F,Q=!1,U,Z){let O=0;while(O<120){if(U?.aborted)return"cancelled";try{let q=await fetch(`${D}/build/status?job_id=${encodeURIComponent($)}&app_id=${encodeURIComponent(X)}&platform=${J}`,{headers:{authorization:Y},signal:U});if(!q.ok){Z?.warn(`Status check failed: ${q.status}`),await new Promise((K)=>setTimeout(K,5000)),O++;continue}let w=await q.json(),W=w.status?.toLowerCase?.()??"";if(Q)Z?.info(`Build status: ${W||w.status}`);if(SO.has(W))return W;await new Promise((K)=>setTimeout(K,5000)),O++}catch(q){if(U?.aborted)return"cancelled";Z?.warn(`Status check error: ${q}`),await new Promise((w)=>setTimeout(w,5000)),O++}}return Z?.warn("Build status polling timed out"),"timeout"}async function pd0(D,$,X){let J=new Set,Y=new Set,F=!1,Q=!1;if($==="ios"){let U=Z$(D,X,"App","CapApp-SPM","Package.swift");if(S6(U)){F=!0;let O=(await PO(U,"utf-8")).matchAll(/\.package\s*\([^)]*path:\s*["'](?:\.\.\/)*node_modules\/([^"']+)["']\s*\)/g);for(let q of O){let w=q[1],W=w.lastIndexOf("node_modules/");if(W!==-1)w=w.substring(W+13);J.add(w)}}let Z=Z$(D,X);if(S6(Z)){let G=[Z$(Z,"App","Podfile"),Z$(Z,"Podfile")];for(let q of PE(Z,{withFileTypes:!0}))if(q.isDirectory())G.push(Z$(Z,q.name,"Podfile"));let O=[...new Set(G)].filter((q)=>S6(q));if(O.length>0)Q=!0;for(let q of O){let W=(await PO(q,"utf-8")).matchAll(/pod\s+['"][^'"]+['"],\s*:path\s*=>\s*['"](?:\.\.\/)+node_modules\/([^'"]+)['"]/g);for(let K of W){let H=K[1],B=H.lastIndexOf("node_modules/");if(B!==-1)H=H.substring(B+13);J.add(H)}}}}else if($==="android"){let U=Z$(D,X,"capacitor.settings.gradle");if(S6(U)){let O=(await PO(U,"utf-8")).matchAll(/new\s+File\s*\(\s*['"]\.\.\/node_modules\/([^'"]+)['"]\s*\)/g);for(let q of O){let w=q[1],W=w.lastIndexOf("node_modules/");if(W!==-1)w=w.substring(W+13);let K=w.replace(/\/(android|capacitor)$/,"");J.add(K)}}let Z=Z$(D,X,"capacitor-cordova-android-plugins","build.gradle");if(S6(Z)){let O=(await PO(Z,"utf-8")).matchAll(/apply\s+from\s*:\s*["'](?:\.\.\/)+node_modules\/([^"']+)["']/g);for(let q of O){let w=q[1],W=w.lastIndexOf("node_modules/");if(W!==-1)w=w.substring(W+13);let K=w.split("/"),H=K[0].startsWith("@")&&K.length>=2?`${K[0]}/${K[1]}`:K[0];Y.add(H)}}}return{packages:J,cordovaPackages:Y,usesSPM:F,usesCocoaPods:Q}}function t40(D,$,X,J){let Y=D.replace(/\\/g,"/");if(Y.startsWith(`${J}/`))return!0;if(Y==="package.json"||Y==="package-lock.json"||Y.startsWith("capacitor.config."))return!0;if(Y.startsWith("resources/"))return!0;if($==="ios"&&Y.startsWith("node_modules/@capacitor/ios/"))return!0;if($==="android"&&Y.startsWith("node_modules/@capacitor/android/"))return!0;if($==="android")for(let F of X.cordovaPackages){let Q=`node_modules/${F}/`;if(Y===`node_modules/${F}/package.json`)return!0;if(Y.startsWith(Q)){let U=Y.slice(Q.length);if(U==="node_modules"||U.startsWith("node_modules/"))continue;return!0}}for(let F of X.packages){let Q=`node_modules/${F}/`;if(Y===`${Q}package.json`)return!0;if($==="android"){if(Y.startsWith(`${Q}android/`))return!0}else if($==="ios"){if(Y.startsWith(`${Q}ios/`))return!0;if(X.usesSPM){if(Y===`${Q}Package.swift`)return!0}if(X.usesCocoaPods||!X.usesSPM){if(Y.startsWith(Q)&&Y.endsWith(".podspec"))return!0}}}return!1}function eJ(D,$,X,J,Y,F){let Q=PE($);for(let U of Q){let Z=Z$($,U),G=X?`${X}/${U}`:U,O=vd0(Z);if(O.isDirectory()){if(U===".git"||U==="dist"||U==="build"||U===".angular"||U===".vite"||U===".gradle"||U===".idea"||U===".swiftpm")continue;if(U==="node_modules"){eJ(D,Z,G,J,Y,F);continue}if(U==="resources"){eJ(D,Z,G,J,Y,F);continue}let q=G.replace(/\\/g,"/"),w=[...Y.packages,...Y.cordovaPackages];if(t40(G,J,Y,F)||F===q||F.startsWith(`${q}/`)||w.some((K)=>{return`node_modules/${K}/`.startsWith(`${q}/`)||q.startsWith(`node_modules/${K}`)}))eJ(D,Z,G,J,Y,F)}else if(O.isFile()){if(U===".DS_Store"||U.endsWith(".log"))continue;if(t40(G,J,Y,F))rd0(D,Z,G)}}}function rd0(D,$,X){let J=X.replace(/\\/g,"/");if(D.getEntry(J))return;let Y=J.lastIndexOf("/"),F=Y===-1?void 0:J.slice(0,Y);D.addLocalFile($,F)}function td0(D){if(!D)return[];let $=D.split(",").map((X)=>X.trim()).filter(Boolean).map((X)=>TE(X));return[...new Set($)]}function od0(D,$){let X=new Set([...$.packages,...$.cordovaPackages]);return X.add(D==="ios"?"@capacitor/ios":"@capacitor/android"),X}function ad0(D,$){let X=Z$(D,...$.split("/"));if(S6(X))return X;let J=Z$(D,".pnpm");if(!S6(J))return;let Y=$.replace("/","+"),F=PE(J,{withFileTypes:!0}).filter((Q)=>Q.isDirectory()).map((Q)=>Q.name).filter((Q)=>Q.startsWith(`${Y}@`)).sort();if(F.length>1)throw Error(`Multiple pnpm store entries found for ${$} in ${J}; provide the app-specific node_modules path so the native build archive can use the exact resolved package.`);for(let Q of F){let U=Z$(J,Q,"node_modules",...$.split("/"));if(S6(U))return U}return}function sd0(D,$,X,J,Y){if($.length===0)return;let F=$.filter((Q)=>!S6(Q));if(F.length>0)throw Error(`Missing node_modules folder at ${F.join(", ")}`);for(let Q of $)for(let U of od0(X,J)){let Z=ad0(Q,U);if(!Z)continue;eJ(D,Z,`node_modules/${U}`,X,J,Y)}}async function ed0(D,$,X,J,Y={}){let F=sJ(J,X),Q=await pd0(D,X,F),U=new o40.default;eJ(U,D,"",X,Q,F),sd0(U,td0(Y.nodeModules),X,Q,F);let Z=/node_modules\/\.pnpm\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,G=/node_modules\/\.bun\/[^/\n\r]+(?:\/[^/\n\r]+)*\/node_modules\//g,O=new Set(["",".gradle",".swift",".json",".lock",".xml",".properties",".pbxproj",".xcconfig",".plist",".podspec",".rb",".yaml",".yml"]);for(let w of U.getEntries()){if(w.isDirectory)continue;let W=w.entryName.includes(".")?`.${w.entryName.split(".").pop()}`:"",K=w.entryName.split("/").pop()||"";if(!O.has(W)&&K!=="Podfile")continue;let H=w.getData().toString("utf-8"),B=H.replace(Z,"node_modules/").replace(G,"node_modules/");if(X==="ios"){let M="../".repeat(w.entryName.split("/").length-1);B=B.replace(/(?:\.\.\/){4,}(ios\/|node_modules\/)/g,(j,z)=>`${M}${z}`)}if(B!==H)U.updateFile(w.entryName,l40.from(B,"utf-8"))}let q=Z$(D,"capacitor.config.json");if(J&&!S6(q)){let w=`${JSON.stringify(J,null,2)}
|
|
566
566
|
`;U.addFile("capacitor.config.json",l40.from(w,"utf-8"))}await fd0($,U.toBuffer())}var Dn0=new Set(["CAPGO_IOS_SCHEME","CAPGO_IOS_TARGET","CAPGO_IOS_DISTRIBUTION","BUILD_OUTPUT_UPLOAD_ENABLED","BUILD_OUTPUT_RETENTION_SECONDS","SKIP_BUILD_NUMBER_BUMP","CAPGO_IOS_SOURCE_DIR","CAPGO_IOS_APP_DIR","CAPGO_IOS_PROJECT_DIR","IOS_PROJECT_DIR","CAPGO_ANDROID_SOURCE_DIR","CAPGO_ANDROID_APP_DIR","CAPGO_ANDROID_PROJECT_DIR","ANDROID_PROJECT_DIR","CAPGO_ANDROID_FLAVOR"]);function $n0(D,$,X,J){let Y={platform:$,buildMode:X,cliVersion:J,iosScheme:D.CAPGO_IOS_SCHEME,iosTarget:D.CAPGO_IOS_TARGET,iosDistribution:D.CAPGO_IOS_DISTRIBUTION,iosSourceDir:D.CAPGO_IOS_SOURCE_DIR,iosAppDir:D.CAPGO_IOS_APP_DIR,iosProjectDir:D.CAPGO_IOS_PROJECT_DIR,androidSourceDir:D.CAPGO_ANDROID_SOURCE_DIR,androidAppDir:D.CAPGO_ANDROID_APP_DIR,androidProjectDir:D.CAPGO_ANDROID_PROJECT_DIR,androidFlavor:D.CAPGO_ANDROID_FLAVOR,outputUploadEnabled:D.BUILD_OUTPUT_UPLOAD_ENABLED==="true",outputRetentionSeconds:D.BUILD_OUTPUT_RETENTION_SECONDS?Number.parseInt(D.BUILD_OUTPUT_RETENTION_SECONDS,10)||u9:u9,skipBuildNumberBump:D.SKIP_BUILD_NUMBER_BUMP==="true"},F={};for(let[Q,U]of Object.entries(D))if(!Dn0.has(Q)&&U!==void 0)F[Q]=U;return{buildOptions:Y,buildCredentials:F}}async function s40(D,$,X=!1,J){if(!II())M$0(D);q3(`build request: started for ${D} (platform ${$.platform??"auto"})`);let Y=Date.now(),F=$.verbose??!1,Q=J||gd0(X),U=null,Z=$.outputRecord?{...Q,customMsg:async(G,O)=>{if(G==="qr_download_link"&&typeof O.url==="string")U=O.url;await Q.customMsg(G,O)}}:Q;try{$.apikey=$.apikey||z0(X);let G=TE($.path||CE()),O=await hd0(G,()=>E0());if(D=D||O?.config?.appId,!D)throw Error("Missing argument, you need to provide a appId, or be in a capacitor project");let q=await bd0($.platform,{silent:X}),w=$.supaHost||"https://api.capgo.app",W=await C0($.apikey,$.supaHost,$.supaAnon);await uJ(W,$.apikey,"app.build_native",{appId:D},{message:`Insufficient permissions to request a native build for app ${D}`,silent:X});let K=await rD(W,D);if(Z.info(`Requesting native build for ${D}`),Z.info(`Platform: ${q}`),Z.info(`Project: ${G}`),Z.info(`
|
|
567
567
|
\uD83D\uDD12 Security: Credentials are never stored on Capgo servers`),Z.info(" They are used only during build and deleted after"),Z.info(` Build outputs can optionally be uploaded for time-limited download links
|
|
568
|
-
`),F)Z.info(`API host: ${w}`);let H={};if($.buildCertificateBase64)H.BUILD_CERTIFICATE_BASE64=$.buildCertificateBase64;if($.p12Password)H.P12_PASSWORD=$.p12Password;if($.appleKeyId)H.APPLE_KEY_ID=$.appleKeyId;if($.appleIssuerId)H.APPLE_ISSUER_ID=$.appleIssuerId;if($.appleKeyContent)H.APPLE_KEY_CONTENT=$.appleKeyContent;if($.appStoreConnectTeamId)H.APP_STORE_CONNECT_TEAM_ID=$.appStoreConnectTeamId;if($.iosScheme)H.CAPGO_IOS_SCHEME=$.iosScheme;if($.iosTarget)H.CAPGO_IOS_TARGET=$.iosTarget;if($.iosDistribution)H.CAPGO_IOS_DISTRIBUTION=$.iosDistribution;if($.iosProvisioningProfile&&$.iosProvisioningProfile.length>0){let f=x$0($.iosProvisioningProfile,TE($.path||CE()));H.CAPGO_IOS_PROVISIONING_MAP=JSON.stringify(f)}if($.iosProvisioningMap)H.CAPGO_IOS_PROVISIONING_MAP=$.iosProvisioningMap;if($.androidKeystoreFile)H.ANDROID_KEYSTORE_FILE=$.androidKeystoreFile;if($.keystoreKeyAlias)H.KEYSTORE_KEY_ALIAS=$.keystoreKeyAlias;let B=!!$.keystoreKeyPassword,M=!!$.keystoreStorePassword;if(B&&!M)H.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreKeyPassword;else if(!B&&M)H.KEYSTORE_KEY_PASSWORD=$.keystoreStorePassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;else if(B&&M)H.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;if(typeof $.androidFlavor==="string"){let f=$.androidFlavor.trim();if(f)H.CAPGO_ANDROID_FLAVOR=f}if($.playConfigJson)H.PLAY_CONFIG_JSON=$.playConfigJson;if($.inAppUpdatePriority!==void 0)H.PLAY_STORE_IN_APP_UPDATE_PRIORITY=String(HO($.inAppUpdatePriority));if($.outputUpload!==void 0)H.BUILD_OUTPUT_UPLOAD_ENABLED=W3($.outputUpload)?"true":"false";if($.outputRetention)H.BUILD_OUTPUT_RETENTION_SECONDS=String(KO($.outputRetention));if($.skipBuildNumberBump!==void 0)H.SKIP_BUILD_NUMBER_BUMP=W3($.skipBuildNumberBump)?"true":"false";let j=await A$0(D,q,Object.keys(H).length>0?H:void 0);if($.playstoreUpload===!1&&j)delete j.PLAY_CONFIG_JSON,Z.info("ℹ️ --no-playstore-upload specified, Play Store upload disabled for this build");let z=sJ(O?.config,q);if(j&&z)if(q==="ios")j.CAPGO_IOS_SOURCE_DIR=z,j.CAPGO_IOS_APP_DIR=z,j.CAPGO_IOS_PROJECT_DIR=z,j.IOS_PROJECT_DIR=z;else j.CAPGO_ANDROID_SOURCE_DIR=z,j.CAPGO_ANDROID_APP_DIR=z,j.CAPGO_ANDROID_PROJECT_DIR=z,j.ANDROID_PROJECT_DIR=z;if(!j)throw Z.error("❌ No credentials found for this app and platform"),Z.error(""),Z.error("You must provide credentials via:"),Z.error(" 1. CLI arguments (--apple-key-id, --p12-password, etc.)"),Z.error(" 2. Environment variables (APPLE_KEY_ID, P12_PASSWORD, etc.)"),Z.error(" 3. Saved credentials file:"),Z.error(` npx @capgo/cli build credentials save --appId ${D} --platform ${q}`),Z.error(""),Z.error("Documentation:"),Z.error(" https://capgo.app/docs/cli/cloud-build/credentials/"),Error("No credentials found. Please provide credentials before building.");let V=[];if(q==="ios"){let f=j.CAPGO_IOS_DISTRIBUTION,h=["app_store","ad_hoc"];if(f&&!h.includes(f))V.push(`Invalid CAPGO_IOS_DISTRIBUTION value: '${f}'. Must be one of: ${h.join(", ")}`);let y=f&&h.includes(f)?f:"app_store";if(!f)Z.info("ℹ️ --ios-distribution not specified, defaulting to app_store");if(j.CAPGO_IOS_DISTRIBUTION=y,!j.BUILD_CERTIFICATE_BASE64)V.push("BUILD_CERTIFICATE_BASE64 (or --build-certificate-base64)");if(!j.P12_PASSWORD)Z.warn("⚠️ P12_PASSWORD not provided - assuming certificate has no password"),Z.warn(" If your certificate requires a password, provide it with --p12-password");if(!!(j.BUILD_PROVISION_PROFILE_BASE64||j.APPLE_PROFILE_NAME)&&!j.CAPGO_IOS_PROVISIONING_MAP)throw Z.error("❌ Legacy provisioning profile format detected. Run:"),Z.error(" npx @capgo/cli build credentials migrate --platform ios"),Z.error(""),Z.error(" This will convert your existing provisioning profile to the new multi-target format."),Error("Legacy provisioning profile format detected. Run: npx @capgo/cli build credentials migrate --platform ios");if(!j.CAPGO_IOS_PROVISIONING_MAP)V.push('CAPGO_IOS_PROVISIONING_MAP (use --ios-provisioning-profile or save via "build credentials save")');if(y==="app_store"){let c=!!j.APPLE_KEY_ID,t=!!j.APPLE_ISSUER_ID,W0=!!j.APPLE_KEY_CONTENT,F0=c||t||W0;if(!(c&&t&&W0))if(F0){let h0=[];if(!c)h0.push("APPLE_KEY_ID (or --apple-key-id)");if(!t)h0.push("APPLE_ISSUER_ID (or --apple-issuer-id)");if(!W0)h0.push("APPLE_KEY_CONTENT (or --apple-key-content)");V.push(`Incomplete App Store Connect API key - missing: ${h0.join(", ")}`)}else if(j.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")V.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or BUILD_OUTPUT_UPLOAD_ENABLED=true (or --output-upload) (build has no output destination - enable either TestFlight upload or Capgo download link)");else if(j.SKIP_BUILD_NUMBER_BUMP!=="true")V.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or --skip-build-number-bump (App Store Connect API key not provided - build numbers cannot be auto-incremented without it)");else Z.warn("⚠️ App Store Connect API key not provided - build will succeed but cannot auto-upload to TestFlight")}else if(y==="ad_hoc")Z.info("\uD83D\uDCE6 Ad-hoc distribution mode: App Store Connect API key not required"),Z.info(" Build number will use timestamp-based fallback");if(!j.APP_STORE_CONNECT_TEAM_ID)V.push("APP_STORE_CONNECT_TEAM_ID (or --app-store-connect-team-id)")}else if(q==="android"){if(!j.ANDROID_KEYSTORE_FILE)V.push("ANDROID_KEYSTORE_FILE (or --android-keystore-file)");if(!j.KEYSTORE_KEY_ALIAS)V.push("KEYSTORE_KEY_ALIAS (or --keystore-key-alias)");if(!j.KEYSTORE_KEY_PASSWORD&&!j.KEYSTORE_STORE_PASSWORD)V.push("KEYSTORE_KEY_PASSWORD or KEYSTORE_STORE_PASSWORD (at least one password required)");if(!j.PLAY_CONFIG_JSON)if(j.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")V.push("PLAY_CONFIG_JSON or BUILD_OUTPUT_UPLOAD_ENABLED=true (build has no output destination - enable either Play Store upload or Capgo download link)");else Z.warn("⚠️ PLAY_CONFIG_JSON not provided - build will succeed but cannot auto-upload to Play Store")}if(V.length>0){Z.error(`❌ Missing required credentials for ${q}:`),Z.error("");for(let f of V)Z.error(` • ${f}`);throw Z.error(""),Z.error("Provide credentials via:"),Z.error(` 1. CLI arguments: npx @capgo/cli build request --platform ${q} ${q==="ios"?'--apple-key-id "..." --apple-issuer-id "..." --apple-key-content "..."':'--android-keystore-file "..." --keystore-key-alias "..."'}`),Z.error(` 2. Environment variables: ${q==="ios"?'export APPLE_KEY_ID="..." APPLE_ISSUER_ID="..." APPLE_KEY_CONTENT="..."':'export ANDROID_KEYSTORE_FILE="..." KEYSTORE_KEY_ALIAS="..."'}`),Z.error(` 3. Saved credentials: npx @capgo/cli build credentials save --platform ${q} ...`),Z.error(""),Z.error("Documentation:"),Z.error(` https://capgo.app/docs/cli/cloud-build/${q}/`),Error(`Missing required credentials for ${q}: ${V.join(", ")}`)}if(!$.buildMode)Z.info("ℹ️ --build-mode not specified, defaulting to release");if(!j.BUILD_OUTPUT_UPLOAD_ENABLED)Z.info("ℹ️ --output-upload not specified, defaulting to false (no Capgo download link)");if(!j.BUILD_OUTPUT_RETENTION_SECONDS)Z.info(`ℹ️ --output-retention not specified, defaulting to ${u9}s (1 hour)`);if(!j.SKIP_BUILD_NUMBER_BUMP)Z.info("ℹ️ --skip-build-number-bump not specified, build number will be auto-incremented (default)");let{buildOptions:N,buildCredentials:A}=$n0(j,q,$.buildMode||"release",B1.version),u={app_id:D,platform:q,build_mode:$.buildMode||"release",build_options:N,build_credentials:A};if(Z.info("✓ Using credentials (merged from CLI args, env vars, and saved file)"),F){let f=Object.keys(A);Z.info(`Credentials provided: ${f.join(", ")}`),Z.info(`Build options: platform=${N.platform}, mode=${N.buildMode}, cliVersion=${N.cliVersion}`)}Z.info("Requesting build from Capgo...");let _=3,I=await md0(`${w}/build/request`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify(u)},_,Z);if(!I.ok){let f=await I.text();throw Error(`Failed to request build: ${I.status} - ${f}`)}let x=await I.json();if(Z.success(`Build job created: ${x.job_id}`),Z.info(`Status: ${x.status}`),F)Z.info(`Upload URL: ${x.upload_url}`),Z.info(`Upload expires: ${x.upload_expires_at}`);let P=$.aiAnalysisMode??"auto-prompt",m=(r10()||$.aiAnalytics===!0||P==="caller-handled")&&P!=="skip",b=null,p=!1,k;if(m&&x.job_id)b=x.job_id,await t10(x.job_id),s10(x.job_id,()=>p);let R={...Z,buildLog:(f)=>{if(Z.buildLog(f),m&&b)o10(b,f)}};await j0($.apikey,{channel:"native-builder",event:"Build requested",icon:"\uD83C\uDFD7️",org_id:K,tracking_version:2,tags:{"app-id":D,platform:q},notify:!1}).catch();let S=Z$(kd0(),`capgo-build-${Date.now()}`);await ud0(S,{recursive:!0});let v=Z$(S,`${i40(G)}.zip`);try{Z.info(`Zipping ${q} project from ${G}...`),await ed0(G,v,q,O?.config,{nodeModules:$.nodeModules});let f=await _d0(v),h=(f.size/1024/1024).toFixed(2);if(Z.success(`Created zip: ${v} (${h} MB)`),Z.info("Uploading to builder..."),F)Z.info(`Upload endpoint: ${x.upload_url}`),Z.info(`File size: ${h} MB`),Z.info(`Job ID: ${x.job_id}`);let y=RE(v);Z.uploadProgress(0);let a=Date.now(),c=$.buildMode||"release";CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"started"}),await new Promise((Z0,v0)=>{let P0=new vO.Upload(y,{endpoint:x.upload_url,chunkSize:5242880,retryDelays:[...SJ],metadata:{filename:i40(v),filetype:"application/zip"},headers:{authorization:$.apikey},onBeforeRequest(y0){if(F){Z.info(`[TUS] ${y0.getMethod()} ${y0.getURL()}`);let U0=y0.getHeader("authorization");Z.info(`[TUS] Authorization header present: ${!!U0}`)}},onAfterResponse(y0,U0){if(F){Z.info(`[TUS] Response status: ${U0.getStatus()}`);let I0=U0.getHeader("upload-offset"),u0=U0.getHeader("tus-resumable");Z.info(`[TUS] Upload-Offset: ${I0}, Tus-Resumable: ${u0}`)}},async onError(y0){if(await CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"failed",durationSeconds:(Date.now()-a)/1000,error:y0}),Z.error(`Upload error: ${y0.message}`),y0 instanceof vO.DetailedError){let U0=y0.originalResponse?.getBody(),I0=y0.originalResponse?.getStatus(),u0=y0.originalRequest?.getURL();if(F)Z.error(`[TUS] Request URL: ${u0}`),Z.error(`[TUS] Response status: ${I0}`),Z.error(`[TUS] Response body: ${U0}`);let t0=(()=>{try{let z1=JSON.parse(U0||'{"error": "unknown error"}');return z1.status||z1.error||z1.message||"unknown error"}catch{return U0||y0.message}})();v0(Error(`TUS upload failed: ${t0}`))}else v0(Error(`TUS upload failed: ${y0.message||y0.toString()}`))},onProgress(y0,U0){let I0=Number.parseFloat((y0/U0*100).toFixed(2));Z.uploadProgress(I0)},onSuccess(){if(CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"succeeded",durationSeconds:(Date.now()-a)/1000}),Z.uploadProgress(100),F)Z.success("TUS upload completed successfully");Z0()}});if(F)Z.info("[TUS] Starting upload...");P0.start()}),Z.info("Starting build job...");let t=await fetch(`${w}/build/start/${x.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D})});if(!t.ok){let Z0=await t.text();throw Error(`Failed to start build: ${t.status} - ${Z0}`)}let W0=await t.json();Z.success("Build started!"),Z.info("Streaming build logs...");let F0=new AbortController,R0=!1,h0=async()=>{if(R0)return;R0=!0;let Z0=new AbortController,v0=setTimeout(()=>Z0.abort(),4000);try{await fetch(`${w}/build/cancel/${x.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D}),signal:Z0.signal})}catch(P0){q3(`build cancel request errored (ignored): ${P0 instanceof Error?P0.message:String(P0)}`)}finally{clearTimeout(v0)}},Q0=async()=>{try{if(R0)p1.exit(1);Z.warn("Canceling build... (press Ctrl+C again to force quit)"),await h0(),F0.abort()}catch{}};p1.on("SIGINT",Q0);let T0,C=!1,T=async()=>{try{let Z0=await fetch(`${w}/build/status?job_id=${encodeURIComponent(x.job_id)}&app_id=${encodeURIComponent(D)}&platform=${q}`,{headers:{authorization:$.apikey}});if(!Z0.ok)return null;let v0=await Z0.json(),P0=v0.status?.toLowerCase?.()??"";if(C)Z.info(`Build status: ${P0||v0.status}`);if(SO.has(P0))return P0;return null}catch{return null}},n=null;try{n=await ld0(X,F,W0.logs_url,W0.logs_token,T,F0.signal,()=>{C=!0},X&&!J&&!$.outputRecord?void 0:R)}finally{p1.removeListener("SIGINT",Q0)}if(n){if(T0=n,SO.has(n))await T().catch(()=>{})}else T0=await id0(w,x.job_id,D,q,$.apikey,X,C,F0.signal,Z);if(T0==="succeeded")Z.success("Build completed successfully!");else if(T0==="failed")Z.error("Build failed");else Z.warn(`Build finished with status: ${T0}`);if($.outputRecord&&T0==="succeeded")try{let Z0=await d40($.outputRecord,{jobId:x.job_id,appId:D,platform:q,buildMode:$.buildMode??"release",status:T0,outputUrl:U},(v0)=>Z.warn(v0));if(Z.success(`Build output record written to ${$.outputRecord}`),!Z0.outputUrl)Z.info("ℹ️ Record contains no download URL — pass --output-upload to publish one.");if(Z0.qrCodePngPath)Z.info(`ℹ️ QR code PNG written to ${Z0.qrCodePngPath}`)}catch(Z0){Z.warn(`Failed to write build output record to ${$.outputRecord}: ${Z0 instanceof Error?Z0.message:String(Z0)}`)}if(T0==="failed"&&m&&b&&P==="caller-handled"){p=!0;let Z0=`${p1.env.CAPGO_AI_LOG_BASE_DIR||"/tmp/capgo-builds"}/${b}.log`;k={jobId:b,capturedLogPath:Z0,ready:!0}}else if(T0==="failed"&&m&&b&&P==="auto-prompt"){let Z0=$$0({isTTY:p1.stdout.isTTY===!0,aiAnalyticsFlag:$.aiAnalytics===!0}),v0="⚠ AI can make mistakes. Always verify the diagnosis against the full log before applying the suggested fix.",P0=async(t0,z1)=>{await GO({apikey:$.apikey,orgId:K,appId:D,platform:q,jobId:b,choice:t0,triggeredBy:z1});let u6=`${p1.env.CAPGO_AI_LOG_BASE_DIR||"/tmp/capgo-builds"}/${b}.log`,CD="";try{let{readFile:x6}=await import("node:fs/promises");CD=await x6(u6,"utf8")}catch(x6){let t50=x6 instanceof Error?x6.message:String(x6);p1.stderr.write(`AI analysis skipped: could not read captured log at ${u6}: ${t50}
|
|
568
|
+
`),F)Z.info(`API host: ${w}`);let H={};if($.buildCertificateBase64)H.BUILD_CERTIFICATE_BASE64=$.buildCertificateBase64;if($.p12Password)H.P12_PASSWORD=$.p12Password;if($.appleKeyId)H.APPLE_KEY_ID=$.appleKeyId;if($.appleIssuerId)H.APPLE_ISSUER_ID=$.appleIssuerId;if($.appleKeyContent)H.APPLE_KEY_CONTENT=$.appleKeyContent;if($.appStoreConnectTeamId)H.APP_STORE_CONNECT_TEAM_ID=$.appStoreConnectTeamId;if($.iosScheme)H.CAPGO_IOS_SCHEME=$.iosScheme;if($.iosTarget)H.CAPGO_IOS_TARGET=$.iosTarget;if($.iosDistribution)H.CAPGO_IOS_DISTRIBUTION=$.iosDistribution;if($.iosProvisioningProfile&&$.iosProvisioningProfile.length>0){let f=x$0($.iosProvisioningProfile,TE($.path||CE()));H.CAPGO_IOS_PROVISIONING_MAP=JSON.stringify(f)}if($.iosProvisioningMap)H.CAPGO_IOS_PROVISIONING_MAP=$.iosProvisioningMap;if($.androidKeystoreFile)H.ANDROID_KEYSTORE_FILE=$.androidKeystoreFile;if($.keystoreKeyAlias)H.KEYSTORE_KEY_ALIAS=$.keystoreKeyAlias;let B=!!$.keystoreKeyPassword,M=!!$.keystoreStorePassword;if(B&&!M)H.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreKeyPassword;else if(!B&&M)H.KEYSTORE_KEY_PASSWORD=$.keystoreStorePassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;else if(B&&M)H.KEYSTORE_KEY_PASSWORD=$.keystoreKeyPassword,H.KEYSTORE_STORE_PASSWORD=$.keystoreStorePassword;if(typeof $.androidFlavor==="string"){let f=$.androidFlavor.trim();if(f)H.CAPGO_ANDROID_FLAVOR=f}if($.playConfigJson)H.PLAY_CONFIG_JSON=$.playConfigJson;if($.inAppUpdatePriority!==void 0)H.PLAY_STORE_IN_APP_UPDATE_PRIORITY=String(HO($.inAppUpdatePriority));if($.outputUpload!==void 0)H.BUILD_OUTPUT_UPLOAD_ENABLED=W3($.outputUpload)?"true":"false";if($.outputRetention)H.BUILD_OUTPUT_RETENTION_SECONDS=String(KO($.outputRetention));if($.skipBuildNumberBump!==void 0)H.SKIP_BUILD_NUMBER_BUMP=W3($.skipBuildNumberBump)?"true":"false";let j=await A$0(D,q,Object.keys(H).length>0?H:void 0);if($.playstoreUpload===!1&&j)delete j.PLAY_CONFIG_JSON,Z.info("ℹ️ --no-playstore-upload specified, Play Store upload disabled for this build");let z=sJ(O?.config,q);if(j&&z)if(q==="ios")j.CAPGO_IOS_SOURCE_DIR=z,j.CAPGO_IOS_APP_DIR=z,j.CAPGO_IOS_PROJECT_DIR=z,j.IOS_PROJECT_DIR=z;else j.CAPGO_ANDROID_SOURCE_DIR=z,j.CAPGO_ANDROID_APP_DIR=z,j.CAPGO_ANDROID_PROJECT_DIR=z,j.ANDROID_PROJECT_DIR=z;if(!j)throw Z.error("❌ No credentials found for this app and platform"),Z.error(""),Z.error("You must provide credentials via:"),Z.error(" 1. CLI arguments (--apple-key-id, --p12-password, etc.)"),Z.error(" 2. Environment variables (APPLE_KEY_ID, P12_PASSWORD, etc.)"),Z.error(" 3. Saved credentials file:"),Z.error(` npx @capgo/cli build credentials save --appId ${D} --platform ${q}`),Z.error(""),Z.error("Documentation:"),Z.error(" https://capgo.app/docs/cli/cloud-build/credentials/"),Error("No credentials found. Please provide credentials before building.");let V=[];if(q==="ios"){let f=j.CAPGO_IOS_DISTRIBUTION,h=["app_store","ad_hoc"];if(f&&!h.includes(f))V.push(`Invalid CAPGO_IOS_DISTRIBUTION value: '${f}'. Must be one of: ${h.join(", ")}`);let y=f&&h.includes(f)?f:"app_store";if(!f)Z.info("ℹ️ --ios-distribution not specified, defaulting to app_store");if(j.CAPGO_IOS_DISTRIBUTION=y,!j.BUILD_CERTIFICATE_BASE64)V.push("BUILD_CERTIFICATE_BASE64 (or --build-certificate-base64)");if(!j.P12_PASSWORD)Z.warn("⚠️ P12_PASSWORD not provided - assuming certificate has no password"),Z.warn(" If your certificate requires a password, provide it with --p12-password");if(!!(j.BUILD_PROVISION_PROFILE_BASE64||j.APPLE_PROFILE_NAME)&&!j.CAPGO_IOS_PROVISIONING_MAP)throw Z.error("❌ Legacy provisioning profile format detected. Run:"),Z.error(" npx @capgo/cli build credentials migrate --platform ios"),Z.error(""),Z.error(" This will convert your existing provisioning profile to the new multi-target format."),Error("Legacy provisioning profile format detected. Run: npx @capgo/cli build credentials migrate --platform ios");if(!j.CAPGO_IOS_PROVISIONING_MAP)V.push('CAPGO_IOS_PROVISIONING_MAP (use --ios-provisioning-profile or save via "build credentials save")');if(y==="app_store"){let c=!!j.APPLE_KEY_ID,t=!!j.APPLE_ISSUER_ID,W0=!!j.APPLE_KEY_CONTENT,F0=c||t||W0;if(!(c&&t&&W0))if(F0){let h0=[];if(!c)h0.push("APPLE_KEY_ID (or --apple-key-id)");if(!t)h0.push("APPLE_ISSUER_ID (or --apple-issuer-id)");if(!W0)h0.push("APPLE_KEY_CONTENT (or --apple-key-content)");V.push(`Incomplete App Store Connect API key - missing: ${h0.join(", ")}`)}else if(j.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")V.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or BUILD_OUTPUT_UPLOAD_ENABLED=true (or --output-upload) (build has no output destination - enable either TestFlight upload or Capgo download link)");else if(j.SKIP_BUILD_NUMBER_BUMP!=="true")V.push("APPLE_KEY_ID/APPLE_ISSUER_ID/APPLE_KEY_CONTENT or --skip-build-number-bump (App Store Connect API key not provided - build numbers cannot be auto-incremented without it)");else Z.warn("⚠️ App Store Connect API key not provided - build will succeed but cannot auto-upload to TestFlight")}else if(y==="ad_hoc")Z.info("\uD83D\uDCE6 Ad-hoc distribution mode: App Store Connect API key not required"),Z.info(" Build number will use timestamp-based fallback");if(!j.APP_STORE_CONNECT_TEAM_ID)V.push("APP_STORE_CONNECT_TEAM_ID (or --app-store-connect-team-id)")}else if(q==="android"){if(!j.ANDROID_KEYSTORE_FILE)V.push("ANDROID_KEYSTORE_FILE (or --android-keystore-file)");if(!j.KEYSTORE_KEY_ALIAS)V.push("KEYSTORE_KEY_ALIAS (or --keystore-key-alias)");if(!j.KEYSTORE_KEY_PASSWORD&&!j.KEYSTORE_STORE_PASSWORD)V.push("KEYSTORE_KEY_PASSWORD or KEYSTORE_STORE_PASSWORD (at least one password required)");if(!j.PLAY_CONFIG_JSON)if(j.BUILD_OUTPUT_UPLOAD_ENABLED!=="true")V.push("PLAY_CONFIG_JSON or BUILD_OUTPUT_UPLOAD_ENABLED=true (build has no output destination - enable either Play Store upload or Capgo download link)");else Z.warn("⚠️ PLAY_CONFIG_JSON not provided - build will succeed but cannot auto-upload to Play Store")}if(V.length>0){Z.error(`❌ Missing required credentials for ${q}:`),Z.error("");for(let f of V)Z.error(` • ${f}`);throw Z.error(""),Z.error("Provide credentials via:"),Z.error(` 1. CLI arguments: npx @capgo/cli build request --platform ${q} ${q==="ios"?'--apple-key-id "..." --apple-issuer-id "..." --apple-key-content "..."':'--android-keystore-file "..." --keystore-key-alias "..."'}`),Z.error(` 2. Environment variables: ${q==="ios"?'export APPLE_KEY_ID="..." APPLE_ISSUER_ID="..." APPLE_KEY_CONTENT="..."':'export ANDROID_KEYSTORE_FILE="..." KEYSTORE_KEY_ALIAS="..."'}`),Z.error(` 3. Saved credentials: npx @capgo/cli build credentials save --platform ${q} ...`),Z.error(""),Z.error("Documentation:"),Z.error(` https://capgo.app/docs/cli/cloud-build/${q}/`),Error(`Missing required credentials for ${q}: ${V.join(", ")}`)}if(!$.buildMode)Z.info("ℹ️ --build-mode not specified, defaulting to release");if(!j.BUILD_OUTPUT_UPLOAD_ENABLED)Z.info("ℹ️ --output-upload not specified, defaulting to false (no Capgo download link)");if(!j.BUILD_OUTPUT_RETENTION_SECONDS)Z.info(`ℹ️ --output-retention not specified, defaulting to ${u9}s (1 hour)`);if(!j.SKIP_BUILD_NUMBER_BUMP)Z.info("ℹ️ --skip-build-number-bump not specified, build number will be auto-incremented (default)");let{buildOptions:N,buildCredentials:A}=$n0(j,q,$.buildMode||"release",B1.version),u={app_id:D,platform:q,build_mode:$.buildMode||"release",build_options:N,build_credentials:A};if(Z.info("✓ Using credentials (merged from CLI args, env vars, and saved file)"),F){let f=Object.keys(A);Z.info(`Credentials provided: ${f.join(", ")}`),Z.info(`Build options: platform=${N.platform}, mode=${N.buildMode}, cliVersion=${N.cliVersion}`)}Z.info("Requesting build from Capgo...");let _=3,I=await md0(`${w}/build/request`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify(u)},_,Z);if(!I.ok){let f=await I.text();throw Error(`Failed to request build: ${I.status} - ${f}`)}let x=await I.json();if(Z.success(`Build job created: ${x.job_id}`),Z.info(`Status: ${x.status}`),F)Z.info(`Upload URL: ${x.upload_url}`),Z.info(`Upload expires: ${x.upload_expires_at}`);let P=$.aiAnalysisMode??"auto-prompt",m=(r10()||$.aiAnalytics===!0||P==="caller-handled")&&P!=="skip",b=null,p=!1,k;if(m&&x.job_id)b=x.job_id,await t10(x.job_id),s10(x.job_id,()=>p);let R={...Z,buildLog:(f)=>{if(Z.buildLog(f),m&&b)o10(b,f)}};await j0($.apikey,{channel:"native-builder",event:"Build requested",icon:"\uD83C\uDFD7️",org_id:K,tracking_version:2,tags:{"app-id":D,platform:q,...$.builderJourneyId?{journey_id:$.builderJourneyId}:{}},notify:!1}).catch();let S=Z$(kd0(),`capgo-build-${Date.now()}`);await ud0(S,{recursive:!0});let v=Z$(S,`${i40(G)}.zip`);try{Z.info(`Zipping ${q} project from ${G}...`),await ed0(G,v,q,O?.config,{nodeModules:$.nodeModules});let f=await _d0(v),h=(f.size/1024/1024).toFixed(2);if(Z.success(`Created zip: ${v} (${h} MB)`),Z.info("Uploading to builder..."),F)Z.info(`Upload endpoint: ${x.upload_url}`),Z.info(`File size: ${h} MB`),Z.info(`Job ID: ${x.job_id}`);let y=RE(v);Z.uploadProgress(0);let a=Date.now(),c=$.buildMode||"release";CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"started"}),await new Promise((Z0,v0)=>{let P0=new vO.Upload(y,{endpoint:x.upload_url,chunkSize:5242880,retryDelays:[...SJ],metadata:{filename:i40(v),filetype:"application/zip"},headers:{authorization:$.apikey},onBeforeRequest(y0){if(F){Z.info(`[TUS] ${y0.getMethod()} ${y0.getURL()}`);let U0=y0.getHeader("authorization");Z.info(`[TUS] Authorization header present: ${!!U0}`)}},onAfterResponse(y0,U0){if(F){Z.info(`[TUS] Response status: ${U0.getStatus()}`);let I0=U0.getHeader("upload-offset"),u0=U0.getHeader("tus-resumable");Z.info(`[TUS] Upload-Offset: ${I0}, Tus-Resumable: ${u0}`)}},async onError(y0){if(await CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"failed",durationSeconds:(Date.now()-a)/1000,error:y0}),Z.error(`Upload error: ${y0.message}`),y0 instanceof vO.DetailedError){let U0=y0.originalResponse?.getBody(),I0=y0.originalResponse?.getStatus(),u0=y0.originalRequest?.getURL();if(F)Z.error(`[TUS] Request URL: ${u0}`),Z.error(`[TUS] Response status: ${I0}`),Z.error(`[TUS] Response body: ${U0}`);let t0=(()=>{try{let z1=JSON.parse(U0||'{"error": "unknown error"}');return z1.status||z1.error||z1.message||"unknown error"}catch{return U0||y0.message}})();v0(Error(`TUS upload failed: ${t0}`))}else v0(Error(`TUS upload failed: ${y0.message||y0.toString()}`))},onProgress(y0,U0){let I0=Number.parseFloat((y0/U0*100).toFixed(2));Z.uploadProgress(I0)},onSuccess(){if(CO({apikey:$.apikey,appId:D,orgId:K,platform:q,buildMode:c,jobId:x.job_id,sizeBytes:f.size,phase:"succeeded",durationSeconds:(Date.now()-a)/1000}),Z.uploadProgress(100),F)Z.success("TUS upload completed successfully");Z0()}});if(F)Z.info("[TUS] Starting upload...");P0.start()}),Z.info("Starting build job...");let t=await fetch(`${w}/build/start/${x.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D})});if(!t.ok){let Z0=await t.text();throw Error(`Failed to start build: ${t.status} - ${Z0}`)}let W0=await t.json();Z.success("Build started!"),Z.info("Streaming build logs...");let F0=new AbortController,R0=!1,h0=async()=>{if(R0)return;R0=!0;let Z0=new AbortController,v0=setTimeout(()=>Z0.abort(),4000);try{await fetch(`${w}/build/cancel/${x.job_id}`,{method:"POST",headers:{"Content-Type":"application/json",authorization:$.apikey},body:JSON.stringify({app_id:D}),signal:Z0.signal})}catch(P0){q3(`build cancel request errored (ignored): ${P0 instanceof Error?P0.message:String(P0)}`)}finally{clearTimeout(v0)}},Q0=async()=>{try{if(R0)p1.exit(1);Z.warn("Canceling build... (press Ctrl+C again to force quit)"),await h0(),F0.abort()}catch{}};p1.on("SIGINT",Q0);let T0,C=!1,T=async()=>{try{let Z0=await fetch(`${w}/build/status?job_id=${encodeURIComponent(x.job_id)}&app_id=${encodeURIComponent(D)}&platform=${q}`,{headers:{authorization:$.apikey}});if(!Z0.ok)return null;let v0=await Z0.json(),P0=v0.status?.toLowerCase?.()??"";if(C)Z.info(`Build status: ${P0||v0.status}`);if(SO.has(P0))return P0;return null}catch{return null}},n=null;try{n=await ld0(X,F,W0.logs_url,W0.logs_token,T,F0.signal,()=>{C=!0},X&&!J&&!$.outputRecord?void 0:R)}finally{p1.removeListener("SIGINT",Q0)}if(n){if(T0=n,SO.has(n))await T().catch(()=>{})}else T0=await id0(w,x.job_id,D,q,$.apikey,X,C,F0.signal,Z);if(T0==="succeeded")Z.success("Build completed successfully!");else if(T0==="failed")Z.error("Build failed");else Z.warn(`Build finished with status: ${T0}`);if($.outputRecord&&T0==="succeeded")try{let Z0=await d40($.outputRecord,{jobId:x.job_id,appId:D,platform:q,buildMode:$.buildMode??"release",status:T0,outputUrl:U},(v0)=>Z.warn(v0));if(Z.success(`Build output record written to ${$.outputRecord}`),!Z0.outputUrl)Z.info("ℹ️ Record contains no download URL — pass --output-upload to publish one.");if(Z0.qrCodePngPath)Z.info(`ℹ️ QR code PNG written to ${Z0.qrCodePngPath}`)}catch(Z0){Z.warn(`Failed to write build output record to ${$.outputRecord}: ${Z0 instanceof Error?Z0.message:String(Z0)}`)}if(T0==="failed"&&m&&b&&P==="caller-handled"){p=!0;let Z0=`${p1.env.CAPGO_AI_LOG_BASE_DIR||"/tmp/capgo-builds"}/${b}.log`;k={jobId:b,capturedLogPath:Z0,ready:!0}}else if(T0==="failed"&&m&&b&&P==="auto-prompt"){let Z0=$$0({isTTY:p1.stdout.isTTY===!0,aiAnalyticsFlag:$.aiAnalytics===!0}),v0="⚠ AI can make mistakes. Always verify the diagnosis against the full log before applying the suggested fix.",P0=async(t0,z1)=>{await GO({apikey:$.apikey,orgId:K,appId:D,platform:q,jobId:b,choice:t0,triggeredBy:z1});let u6=`${p1.env.CAPGO_AI_LOG_BASE_DIR||"/tmp/capgo-builds"}/${b}.log`,CD="";try{let{readFile:x6}=await import("node:fs/promises");CD=await x6(u6,"utf8")}catch(x6){let t50=x6 instanceof Error?x6.message:String(x6);p1.stderr.write(`AI analysis skipped: could not read captured log at ${u6}: ${t50}
|
|
569
569
|
`);return}let C1=p1.stdout.isTTY===!0,V1=C1?p1.stdout:p1.stderr,aO=C1?jD():null;aO?.start("Analyzing build log with Capgo AI");let v3=!1,sO=C1?Y$0((x6)=>V1.write(x6),!0):null,p50=C1?(x6)=>{if(!v3)aO?.stop("Capgo AI streaming"),V1.write(`
|
|
570
570
|
--- AI analysis ---
|
|
571
571
|
`),v3=!0;sO.feed(x6)}:void 0,t1;try{t1=await J$0({apiHost:w,apikey:$.apikey,jobId:b,appId:D,logs:CD,onChunk:p50})}finally{if(!v3)aO?.stop("Capgo AI finished")}let r50=F$0(t1);if(await Q$0({apikey:$.apikey,orgId:K,appId:D,platform:q,jobId:b,result:r50,errorStatus:t1.kind==="error"?t1.status:void 0}),t1.kind==="ok")if(v3)sO?.flush(),V1.write(`
|
|
@@ -602,7 +602,7 @@ Platform: ${q}
|
|
|
602
602
|
Job: ${b}`,confirm:async(CD,C1)=>{for(;;){let V1=await Q1({message:CD,options:[{value:"yes",label:"\uD83D\uDCE8 Yes, send to support"},{value:"view",label:"\uD83D\uDC40 View logs first (opens the file)"},{value:"no",label:"✖ Cancel"}]});if(c0(V1)||V1==="no")return!1;if(V1==="view"){L.info(`Logs to be sent: ${C1}`);try{(await Promise.resolve().then(() => (p7(),AJ))).default(C1)}catch{}continue}return!0}},buildFiles:()=>{let CD=jD();CD.start("Preparing your logs to send…");try{return q$0({kind:"build-request",appId:D,error:`Cloud build ${b} failed`,logs:u6,sections:z1.length>0?[{title:"Internal log",lines:z1}]:[]})}finally{CD.stop("Logs ready.")}},copyPath:(CD)=>W$0(CD).ok,reveal:(CD)=>K$0(CD),openUrl:async(CD)=>(await Promise.resolve().then(() => (p7(),AJ))).default(CD),print:(CD)=>L.info(CD),upload:async(CD)=>{let C1=jD();C1.start("Uploading your logs to Capgo support…");let V1=await j$0({apiHost:w,apikey:$.apikey,appId:D,jobId:b??void 0,gzPath:CD});return C1.stop(V1?"Logs uploaded.":"Logs upload unavailable — falling back to attaching the file."),V1}})};async function u0(){if(await HI(b)){p1.stdout.write(`Log too big for AI analysis (>10 MB). Offering local AI instead.
|
|
603
603
|
`),await y0();return}let t0=await Q1({message:"Build failed — get help or analyze the log",options:[{value:"support",label:"\uD83D\uDCE8 Email Capgo support"},{value:"capgo",label:"\uD83E\uDD16 Capgo AI"},{value:"local",label:"Local AI (write prompt to file)"},{value:"skip",label:"Skip"}]});if(t0==="support")await I0();else if(t0==="capgo")await P0("capgo_ai","menu");else if(t0==="local")await y0();else await U0()}try{if(Z0==="skip")await U0();else if(Z0==="auto_upload")if(await HI(b))p1.stderr.write(`Log too big for AI analysis (>10 MB), skipping
|
|
604
604
|
`),await U0();else await P0("auto_upload","ci_flag");else if(Z0==="ask_then_menu"){let t0=await kD({message:"Build failed. See help options (email Capgo support / AI analysis)?"});if(!t0||typeof t0==="symbol")await U0();else await u0()}else await u0()}catch(t0){let z1=t0 instanceof Error?t0.message:String(t0);q3(`AI analysis flow errored: ${z1}`),p1.stderr.write(`AI analysis flow errored: ${z1}
|
|
605
|
-
`)}}let g=((Date.now()-Y)/1000).toFixed(2);return await j0($.apikey,{channel:"native-builder",event:T0==="succeeded"?"Build succeeded":"Build failed",icon:T0==="succeeded"?"✅":"❌",org_id:K,tracking_version:2,tags:{"app-id":D,platform:q,status:T0||"unknown",time:g},notify:!1}).catch(),{success:T0==="succeeded",jobId:x.job_id,uploadUrl:x.upload_url,status:T0||W0.status||x.status,aiAnalysis:k}}finally{await xd0(S,{recursive:!0,force:!0})}}catch(G){let O=G instanceof Error?G.message:String(G);return Z.error(O),{success:!1,error:O}}}g0();k6();H1();x1();_0();async function Xn0(D,$,X,J){for await(let Y of D){if(!J)L.warn(`Removing ${Y.name} created on ${e7(Y.created_at)}`);await iG($,X,Y.name)}}function Jn0(D,$,X){let J=[];for(let Y of D??[]){let F=YD(Y.name);if(Tq(F,$)&&M8(F,X))J.push(Y)}return J}async function e40(D,$,X=!1){if(!X)B0("Cleanup versions in Capgo");await VD(),$.apikey=$.apikey||z0();let{bundle:J,keep:Y=4}=$,F=$.force||!1,Q=$.ignoreChannel||!1,U=await E0();if(D=i0(D,U?.config),!$.apikey){if(!X)L.error("Missing API key, you need to provide an API key to delete your app");throw Error("Missing API key")}if(!D){if(!X)L.error("Missing argument, you need to provide a appid, or be in a capacitor project");throw Error("Missing appId")}let Z=await C0($.apikey,$.supaHost,$.supaAnon);if(await tD(Z,D,X),await $D(Z,$.apikey),await fD(Z,$.apikey,D,3,X,!0),!X)L.info("Querying all available versions in Capgo");let G=await pG(Z,D),O=await HD0(Z,D);if(!X)L.info(`Total active versions in Capgo: ${G?.length??0}`);if(!G?.length){if(!X)L.error("No versions found, aborting cleanup");throw Error("No versions found")}if(J){let W=YD(J),K=g3(W,"major");if(!X)L.info(`Querying available versions in Capgo between ${y$(W)} and ${y$(K)}`);if(G=Jn0(G,W,K),!X)L.info(`Active versions in Capgo between ${y$(W)} and ${y$(K)}: ${G?.length??0}`)}let q=[],w=0;for(let W of G){let K=O.find((H)=>H===W.id);if(w<Y||K&&!Q)W.keep=K?"✅ (Linked to channel)":"✅",w+=1;else W.keep="❌",q.push(W)}if(!q.length){if(!X)L.warn("Nothing to be removed, aborting removal...");return{removed:0,kept:w}}if(!X)KD0(G);if(!F)if(!X){let W=await kD({message:"Do you want to continue removing the versions specified?"});if(c0(W)||!W)throw L.warn("Not confirmed, aborting removal..."),Error("Cleanup cancelled by user")}else throw Error("Cleanup requires force=true in SDK mode to prevent accidental deletions");if(!X)L.success("You have confirmed removal, removing versions now");if(await Xn0(q,Z,D,X),l0({channel:"bundle",event:"Bundles Cleaned",icon:"\uD83E\uDDF9",tags:{kept_count:w,deleted_count:q.length}}),!X)M0("Done ✅");return{removed:q.length,kept:w}}g0();H1();var Yn0=new RegExp("\\u001B(?:\\[[0-?]*[ -/]*[@-~]|\\][^\\u0007]*(?:\\u0007|\\u001B\\\\)|[@-Z\\\\-_])","g"),Fn0=/\p{Mark}/u;function Qn0(D){return D.replace(Yn0,"")}function Un0(D){return D>=4352&&(D<=4447||D===9001||D===9002||D>=9728&&D<=10175||D>=11904&&D<=42191&&D!==12351||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65135||D>=65280&&D<=65376||D>=65504&&D<=65510||D>=126976&&D<=129791)}function $80(D){let $=0;for(let X of Qn0(D)){let J=X.codePointAt(0);if(!J)continue;if(J<=31||J>=127&&J<=159)continue;if(J===8205||J>=65024&&J<=65039||Fn0.test(X))continue;$+=Un0(J)?2:1}return $}function D80(D){if(D==null)return"";return String(D)}function Zn0(D,$){let X=$-$80(D);return X>0?`${D}${" ".repeat(X)}`:D}function Gn0(D){return`\x1B[1m${D}\x1B[0m`}function M3({headers:D=[],rows:$}){let X=D.map(D80),J=$.map((G)=>G.map(D80)),Y=[...X.length?[X]:[],...J];if(!Y.length)return"";let F=Math.max(...Y.map((G)=>G.length)),Q=Array.from({length:F},(G,O)=>Math.max(...Y.map((q)=>$80(q[O]??"")))),U=(G,O,q)=>`${G}${Q.map((w)=>"─".repeat(w)).join(O)}${q}`,Z=(G,O=!1)=>`│ ${Q.map((q,w)=>{let W=G[w]??"";return Zn0(O?Gn0(W):W,q)}).join(" │ ")} │`;return[U("╭─","─┬─","─╮"),...X.length?[Z(X,!0),...J.length?[U("├─","─┼─","─┤")]:[]]:[],...J.map((G)=>Z(G)),U("╰─","─┴─","─╯")].join(`
|
|
605
|
+
`)}}let g=((Date.now()-Y)/1000).toFixed(2);return await j0($.apikey,{channel:"native-builder",event:T0==="succeeded"?"Build succeeded":"Build failed",icon:T0==="succeeded"?"✅":"❌",org_id:K,tracking_version:2,tags:{"app-id":D,platform:q,status:T0||"unknown",time:g,...$.builderJourneyId?{journey_id:$.builderJourneyId}:{}},notify:!1}).catch(),{success:T0==="succeeded",jobId:x.job_id,uploadUrl:x.upload_url,status:T0||W0.status||x.status,aiAnalysis:k}}finally{await xd0(S,{recursive:!0,force:!0})}}catch(G){let O=G instanceof Error?G.message:String(G);return Z.error(O),{success:!1,error:O}}}g0();k6();H1();x1();_0();async function Xn0(D,$,X,J){for await(let Y of D){if(!J)L.warn(`Removing ${Y.name} created on ${e7(Y.created_at)}`);await iG($,X,Y.name)}}function Jn0(D,$,X){let J=[];for(let Y of D??[]){let F=YD(Y.name);if(Tq(F,$)&&M8(F,X))J.push(Y)}return J}async function e40(D,$,X=!1){if(!X)B0("Cleanup versions in Capgo");await VD(),$.apikey=$.apikey||z0();let{bundle:J,keep:Y=4}=$,F=$.force||!1,Q=$.ignoreChannel||!1,U=await E0();if(D=i0(D,U?.config),!$.apikey){if(!X)L.error("Missing API key, you need to provide an API key to delete your app");throw Error("Missing API key")}if(!D){if(!X)L.error("Missing argument, you need to provide a appid, or be in a capacitor project");throw Error("Missing appId")}let Z=await C0($.apikey,$.supaHost,$.supaAnon);if(await tD(Z,D,X),await $D(Z,$.apikey),await fD(Z,$.apikey,D,3,X,!0),!X)L.info("Querying all available versions in Capgo");let G=await pG(Z,D),O=await HD0(Z,D);if(!X)L.info(`Total active versions in Capgo: ${G?.length??0}`);if(!G?.length){if(!X)L.error("No versions found, aborting cleanup");throw Error("No versions found")}if(J){let W=YD(J),K=g3(W,"major");if(!X)L.info(`Querying available versions in Capgo between ${y$(W)} and ${y$(K)}`);if(G=Jn0(G,W,K),!X)L.info(`Active versions in Capgo between ${y$(W)} and ${y$(K)}: ${G?.length??0}`)}let q=[],w=0;for(let W of G){let K=O.find((H)=>H===W.id);if(w<Y||K&&!Q)W.keep=K?"✅ (Linked to channel)":"✅",w+=1;else W.keep="❌",q.push(W)}if(!q.length){if(!X)L.warn("Nothing to be removed, aborting removal...");return{removed:0,kept:w}}if(!X)KD0(G);if(!F)if(!X){let W=await kD({message:"Do you want to continue removing the versions specified?"});if(c0(W)||!W)throw L.warn("Not confirmed, aborting removal..."),Error("Cleanup cancelled by user")}else throw Error("Cleanup requires force=true in SDK mode to prevent accidental deletions");if(!X)L.success("You have confirmed removal, removing versions now");if(await Xn0(q,Z,D,X),l0({channel:"bundle",event:"Bundles Cleaned",icon:"\uD83E\uDDF9",tags:{kept_count:w,deleted_count:q.length}}),!X)M0("Done ✅");return{removed:q.length,kept:w}}g0();H1();var Yn0=new RegExp("\\u001B(?:\\[[0-?]*[ -/]*[@-~]|\\][^\\u0007]*(?:\\u0007|\\u001B\\\\)|[@-Z\\\\-_])","g"),Fn0=/\p{Mark}/u;function Qn0(D){return D.replace(Yn0,"")}function Un0(D){return D>=4352&&(D<=4447||D===9001||D===9002||D>=9728&&D<=10175||D>=11904&&D<=42191&&D!==12351||D>=44032&&D<=55203||D>=63744&&D<=64255||D>=65040&&D<=65049||D>=65072&&D<=65135||D>=65280&&D<=65376||D>=65504&&D<=65510||D>=126976&&D<=129791)}function $80(D){let $=0;for(let X of Qn0(D)){let J=X.codePointAt(0);if(!J)continue;if(J<=31||J>=127&&J<=159)continue;if(J===8205||J>=65024&&J<=65039||Fn0.test(X))continue;$+=Un0(J)?2:1}return $}function D80(D){if(D==null)return"";return String(D)}function Zn0(D,$){let X=$-$80(D);return X>0?`${D}${" ".repeat(X)}`:D}function Gn0(D){return`\x1B[1m${D}\x1B[0m`}function M3({headers:D=[],rows:$}){let X=D.map(D80),J=$.map((G)=>G.map(D80)),Y=[...X.length?[X]:[],...J];if(!Y.length)return"";let F=Math.max(...Y.map((G)=>G.length)),Q=Array.from({length:F},(G,O)=>Math.max(...Y.map((q)=>$80(q[O]??"")))),U=(G,O,q)=>`${G}${Q.map((w)=>"─".repeat(w)).join(O)}${q}`,Z=(G,O=!1)=>`│ ${Q.map((q,w)=>{let W=G[w]??"";return Zn0(O?Gn0(W):W,q)}).join(" │ ")} │`;return[U("╭─","─┬─","─╮"),...X.length?[Z(X,!0),...J.length?[U("├─","─┼─","─┤")]:[]]:[],...J.map((G)=>Z(G)),U("╰─","─┴─","─╯")].join(`
|
|
606
606
|
`)}_0();async function X80(D,$,X=!1){if(!X)B0("Check compatibility");let J={...$,apikey:$.apikey||z0()},Y=D?void 0:await E0(),F=i0(D,Y?.config),Q=J.channel;if(!Q){if(!X)L.error("Missing argument, you need to provide a channel");throw Error("Missing channel")}if(!J.apikey){if(!X)L.error("Missing API key, you need to provide an API key to access Capgo Cloud metadata");throw Error("Missing API key")}if(!F){if(!X)L.error("Missing argument, you need to provide an appId, or be in a capacitor project");throw Error("Missing appId")}let U=await C0(J.apikey,J.supaHost,J.supaAnon);await tD(U,F,X),await fD(U,J.apikey,F,1,X,!0);let Z=await lG(U,F,Q,J.packageJson,J.nodeModules),G=Z.finalCompatibility.some((O)=>!E6(O));if(l0({channel:"bundle",event:"Bundle Compatibility Checked",icon:"\uD83E\uDDEA",tags:{result:G?"incompatible":"compatible",missing_deps_count:Z.finalCompatibility.filter((O)=>!E6(O)).length}}),!X){let O=J.text?"OK":"✅",q=J.text?"FAIL":"❌",w=Z.finalCompatibility.map((W)=>{let K=F8(W);return[W.name,W.localVersion||"-",W.remoteVersion||"-",K.compatible?O:q,K.message]});if(L.success("Compatibility Check Results"),L.info(M3({headers:["Package","Local","Remote","Status","Details"],rows:w})),G){let W=Z.finalCompatibility.filter((K)=>!E6(K)).length;L.warn(`
|
|
607
607
|
${W} package(s) are incompatible with channel "${Q}"`),L.warn("An app store update may be required for these changes to take effect.")}else L.success(`
|
|
608
608
|
All packages are compatible with channel "${Q}"`)}return{finalCompatibility:Z.finalCompatibility,hasIncompatible:G,resolvedAppId:F,channel:Q}}function J80(D){if(!D)return{result:"skipped",incompatibleCount:0,reasons:[]};let $=D.filter((J)=>!E6(J)),X=[...new Set($.flatMap((J)=>F8(J).reasons))];return{result:$.length>0?"incompatible":"compatible",incompatibleCount:$.length,reasons:X}}g0();k6();H1();import{existsSync as uE,readFileSync as q80,writeFileSync as Kn0}from"node:fs";import{cwd as Hn0}from"node:process";import{Buffer as G4}from"node:buffer";import{constants as On0,createCipheriv as qn0,createDecipheriv as wn0,generateKeyPairSync as Wn0,privateEncrypt as SE,publicDecrypt as vE,randomBytes as Y80}from"node:crypto";var F80="aes-128-cbc",O4="base64",uO="hex",j3=On0.RSA_PKCS1_PADDING;function xO(D){let $=Y80(16),X=Y80(16),J=$.toString(O4),Y=SE({key:D,padding:j3},X).toString(O4);return{sessionKey:X,ivSessionKey:`${J}:${Y}`}}function I3(D,$,X){let[J]=X.split(":"),Y=G4.from(J,O4),F=qn0(F80,$,Y);return F.setAutoPadding(!0),G4.concat([F.update(D),F.final()])}function Q80(D,$,X){let[J,Y]=$.split(":"),F=vE({key:X,padding:j3},G4.from(Y,O4)),Q=G4.from(J,O4),U=wn0(F80,F,Q);return U.setAutoPadding(!0),G4.concat([U.update(D),U.final()])}function E3(D,$){return SE({key:$,padding:j3},G4.from(D,O4)).toString(O4)}function A3(D,$){return SE({key:$,padding:j3},G4.from(D,uO)).toString(uO)}function U80(D,$){return vE({key:$,padding:j3},G4.from(D,O4)).toString(O4)}function Z80(D,$){return vE({key:$,padding:j3},G4.from(D,uO)).toString(uO)}function G80(){let{publicKey:D,privateKey:$}=Wn0("rsa",{modulusLength:2048});return{publicKey:D.export({type:"pkcs1",format:"pem"}),privateKey:$.export({type:"pkcs1",format:"pem"})}}function O80(D){if(!D)return"";return D.replace(/-----BEGIN RSA PUBLIC KEY-----/g,"").replace(/-----END RSA PUBLIC KEY-----/g,"").replace(/\n/g,"").replace(/\r/g,"").replace(/ /g,"").substring(0,20)}x1();xX();_0();var zn0="5.30.0",Vn0="6.30.0",Nn0="7.30.0";function Ln0(D,$){let X=D.key||F4,J=$.config.plugins?.CapacitorUpdater?.publicKey;if(uE(X))J=q80(X,"utf8");else if(!J&&D.keyData)J=D.keyData;return{publicKey:J,fallbackKeyPath:X}}async function w80(D,$,X,J=!1){if(!J)B0("Decrypt zip file");try{if(await VD(),!uE(D)){let q=`Zip not found at the path ${D}`;if(!J)L.error(q);throw Error(q)}let Y=await E0();if(!X.key&&!uE(F4)&&!Y.config.plugins?.CapacitorUpdater?.publicKey){let q=`Public Key not found at the path ${F4} or in ${Y.path}`;if(!J)L.error(q);throw Error(q)}let{publicKey:F,fallbackKeyPath:Q}=Ln0(X,Y);if(!F){let q=`Cannot find public key ${Q} or as keyData option or in ${Y.path}`;if(!J)L.error(q);throw Error(q)}let U=q80(D),Z=Q80(U,$,X.keyData??F),G=`${D}_decrypted.zip`;if(Kn0(G,Z),!J)L.info(`Decrypted zip file at ${G}`);let O;if(X.checksum){let q=await p4(Z,"sha256"),w=K1(Hn0()),W=await U$("@capgo/capacitor-updater",w,X.packageJson),K=!1,H;try{H=W?YD(W):void 0}catch{H=void 0}if(H)K=!u$(H,zn0,Vn0,Nn0);if(!J)L.info(`Decrypting checksum with ${K?"V3":"V2"} (based on updater version ${W||"unknown"})`);let B=K?Z80(X.checksum,X.keyData??F):U80(X.checksum,X.keyData??F);if(O=q===B,!O){let M=`Checksum does not match ${q} !== ${B}`;if(!J)L.error(M);throw Error(M)}if(!J)L.info("Checksum matches")}if(l0({channel:"bundle",event:"Bundle Decrypted",icon:"\uD83D\uDD13",tags:{}}),!J)M0("✅ done");return{outputPath:G,checksumMatches:O}}catch(Y){if(!J)L.error(`Error decrypting zip file ${o(Y)}`);throw Y instanceof Error?Y:Error(String(Y))}}g0();_0();async function W80(D,$,X,J=!1){if(!J)B0("Delete bundle");X.apikey=X.apikey||z0();let Y=await E0();if($=i0($,Y?.config),!X.apikey){if(!J)L.error("Missing API key, you need to provide an API key to upload your bundle");throw Error("Missing API key")}if(!$){if(!J)L.error("Missing argument, you need to provide a appId, or be in a capacitor project");throw Error("Missing appId")}if(!D){if(!J)L.error("Missing argument, you need to provide a bundleId, or be in a capacitor project");throw Error("Missing bundleId")}let F=await C0(X.apikey,X.supaHost,X.supaAnon);if(await tD(F,$,J),await $D(F,X.apikey),await fD(F,X.apikey,$,3,J,!0),!J)L.info(`Deleting bundle ${$}@${D} from Capgo`),L.info("Keep in mind that you will not be able to reuse this bundle version, it's gone forever");await iG(F,$,D);let Q=await rD(F,$);if(await j0(X.apikey,{channel:"app",event:"Bundle Deleted",icon:"\uD83D\uDDD1️",org_id:Q,tracking_version:2,tags:{"app-id":$,bundle:D},notify:!1,notifyConsole:!0}).catch(()=>{}),!J)L.success(`Bundle ${$}@${D} deleted in Capgo`),M0("Done");return!0}g0();k6();H1();import{existsSync as xE,readFileSync as K80,writeFileSync as Bn0}from"node:fs";import{cwd as Mn0}from"node:process";x1();_0();var jn0="5.30.0",In0="6.30.0",En0="7.30.0";function DY(D){console.error(o(D))}async function H80(D,$,X,J=!1){let{json:Y}=X,F=!Y&&!J;if(F)B0("Encryption"),await VD();try{let Q=await E0(),U=!!Q.config.plugins?.CapacitorUpdater?.privateKey,Z=!!Q.config.plugins?.CapacitorUpdater?.publicKey;if(U&&F)L.warning("There is still a privateKey in the config");if(!xE(D)){let N=`Zip not found at the path ${D}`;if(!J)if(Y)DY({error:"zip_not_found"});else L.error(`Error: ${N}`);throw Error(N)}if(!Z){if(!J)if(Y)DY({error:"missing_public_key"});else L.warning("Warning: Missing Public Key in config");throw Error("Missing public key in config")}let G=X.key||V$,O=X.keyData||"";if(!xE(G)&&!O){if(!J)if(Y)DY({error:"missing_key"});else L.warning(`Cannot find a private key at ${G} or as a keyData option`),L.error("Error: Missing key");throw Error("Missing private key")}else if(xE(G))O=K80(G,"utf8");if(O&&!O.startsWith("-----BEGIN RSA PRIVATE KEY-----")){if(!J)if(Y)DY({error:"invalid_private_key"});else L.error("The private key provided is not a valid RSA Private key");throw Error("Invalid private key format")}let q=K80(D),{sessionKey:w,ivSessionKey:W}=xO(O),K=I3(q,w,W),H=K1(Mn0()),B=await U$("@capgo/capacitor-updater",H,X.packageJson),M=!1,j;try{j=B?YD(B):void 0}catch{j=void 0}if(j)M=!u$(j,jn0,In0,En0);let z=M?A3($,O):E3($,O);if(F)L.info(`Encrypting checksum with ${M?"V3":"V2"} (based on updater version ${B||"unknown"})`);let V=`${D}_encrypted.zip`;if(Bn0(V,K),l0({channel:"bundle",event:"Bundle Encrypted",icon:"\uD83D\uDD12",tags:{}}),!J)if(Y)console.log(JSON.stringify({checksum:z,filename:V,ivSessionKey:W},null,2));else L.success(`Encoded Checksum: ${z}`),L.success(`ivSessionKey: ${W}`),L.success(`Encrypted zip saved at ${V}`),M0("Done ✅");return{checksum:z,filename:V,ivSessionKey:W}}catch(Q){if(!J)if(X.json)DY(Q);else L.error(`Error encrypting zip file ${o(Q)}`);throw Q instanceof Error?Q:Error(String(Q))}}import{randomUUID as Gp0}from"node:crypto";import{existsSync as rO,readFileSync as Op0}from"node:fs";import{cwd as zA}from"node:process";class _E extends TransformStream{outChunkSize;constructor(D){let $=new Uint8Array(D),X=0;super({transform(J,Y){let F=0;while(F<J.length){let Q=D-X,U=Math.min(Q,J.length-F);if($.set(J.subarray(F,F+U),X),F+=U,X+=U,X===D)Y.enqueue($),$=new Uint8Array(D),X=0}},flush(J){if(X>0)J.enqueue($.subarray(0,X))}}),this.outChunkSize=D}}function z8(D){return D=D.trim(),D=D.replace(/<!--[\s\S]*?-->/g,""),$();function $(){return{declaration:X(),root:J()}}function X(){if(!Z(/^<\?xml\s*/))return;let w={attributes:{}};while(!(G()||O("?>"))){let W=F();if(!W)return w;w.attributes[W.name]=W.value}return Z(/\?>\s*/),w}function J(){let q=Z(/^<([\w-:.]+)\s*/);if(!q)return;let w={name:q[1],attributes:{},children:[]};while(!(G()||O(">")||O("?>")||O("/>"))){let K=F();if(!K)return w;w.attributes[K.name]=K.value}if(Z(/^\s*\/>\s*/))return w;Z(/\??>\s*/),w.content=Y();let W;while(W=J())w.children.push(W);return Z(/^<\/[\w-:.]+>\s*/),w}function Y(){let q=Z(/^([^<]*)/);if(q)return U(q[1]);return""}function F(){let q=Z(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(!q)return;return{name:q[1],value:U(Q(q[2]))}}function Q(q){return q.replace(/^['"]|['"]$/g,"")}function U(q){return q.replaceAll("<","<").replaceAll(">",">").replaceAll("&","&")}function Z(q){let w=D.match(q);if(!w)return;return D=D.slice(w[0].length),w}function G(){return D.length===0}function O(q){return D.startsWith(q)}}class q4 extends Error{}class r1 extends q4{}class _O extends q4{}class fE extends q4{bucketName;constructor(D){super(`Invalid bucket name: ${D}`),this.bucketName=D}}class w4 extends q4{objectName;constructor(D){super(`Invalid object name: ${D}`),this.objectName=D}}class f9 extends q4{constructor(){super("accessKey is required")}}class $Y extends q4{constructor(){super("secretKey is required")}}class fO extends q4{constructor(){super("expirySeconds cannot be less than 1 second or more than 7 days")}}class V8 extends q4{statusCode;code;key;bucketName;resource;region;constructor(D,$,X,J={}){super(X),this.statusCode=D,this.code=$,this.key=J.key,this.bucketName=J.bucketName,this.resource=J.resource,this.region=J.region}}async function z80(D){try{let X=z8(await D.text()).root;if(X?.name!=="Error")throw Error("Invalid root, expected <Error>");let J=X.children.find((G)=>G.name==="Code")?.content??"UnknownErrorCode",Y=X.children.find((G)=>G.name==="Message")?.content??"The error message could not be determined.",F=X.children.find((G)=>G.name==="Key")?.content,Q=X.children.find((G)=>G.name==="BucketName")?.content,U=X.children.find((G)=>G.name==="Resource")?.content,Z=X.children.find((G)=>G.name==="Region")?.content;return new V8(D.status,J,Y,{key:F,bucketName:Q,resource:U,region:Z})}catch{return new V8(D.status,"UnrecognizedError",`Error: Unexpected response code ${D.status} ${D.statusText}. Unable to parse response as XML.`)}}function V80(D){if(typeof D!=="number"||isNaN(D))return!1;return D>=1&&D<=65535}function N80(D){if(typeof D!=="string")return!1;if(D.length>255)return!1;if(D.includes(".."))return!1;return Boolean(D.match(/^[a-zA-Z0-9][a-zA-Z0-9.-]+[a-zA-Z0-9]$/))}function N8(D){if(!An0(D))return!1;if(D.length===0)return!1;return!0}function An0(D){if(typeof D!=="string")return!1;if(D.length>1024)return!1;return!0}function XY(D){return Array.from(D).map(($)=>$.toString(16).padStart(2,"0")).join("")}function k9(D=""){let $={'"':"",""":"",""":"",""":"",""":""};return D.replace(/^("|"|")|("|"|")$/g,(X)=>$[X])}function yE(D){return D.get("x-amz-version-id")??null}function y9(D){let $=D.toISOString();return $.slice(0,4)+$.slice(5,7)+$.slice(8,13)+$.slice(14,16)+$.slice(17,19)+"Z"}function bE(D){return y9(D).slice(0,8)}function gE(D,$){return`${bE($)}/${D}/s3/aws4_request`}async function kO(D){if(!(D instanceof Uint8Array))D=new TextEncoder().encode(D);return XY(new Uint8Array(await crypto.subtle.digest("SHA-256",D)))}var Rn0=["x-amz-server-side-encryption-customer-algorithm","x-amz-server-side-encryption-customer-key","x-amz-server-side-encryption-customer-key-MD5"];class hE extends WritableStream{getResult;constructor({client:D,bucketName:$,objectName:X,partSize:J,metadata:Y}){let F,Q=1,U,Z=[],G,O=[];super({start(){},async write(q,w){let K=Q++;try{if(K==1&&q.length<J){let M=await D.makeRequest({method:"PUT",headers:new Headers({...Y,"Content-Length":String(q.length)}),bucketName:$,objectName:X,payload:q});F={etag:k9(M.headers.get("etag")??void 0),versionId:yE(M.headers)};return}if(K===1)U=(await Tn0({client:D,bucketName:$,objectName:X,metadata:Y})).uploadId;let H={"Content-Length":String(q.length)};for(let M of Rn0){let j=Y[M];if(j)H[M]=j}let B=D.makeRequest({method:"PUT",query:{partNumber:K.toString(),uploadId:U},headers:new Headers(H),bucketName:$,objectName:X,payload:q}).then((M)=>{let j=M.headers.get("etag")??"";if(j)j=j.replace(/^"/,"").replace(/"$/,"");return Z.push({part:K,etag:j}),M});O.push(B.catch((M)=>{if(!G)G=M}))}catch(H){throw H}},async close(){if(F);else if(U){if(await Promise.all(O),G)throw G;Z.sort((q,w)=>q.part>w.part?1:-1),F=await Cn0({client:D,bucketName:$,objectName:X,uploadId:U,etags:Z})}else throw Error("Stream was closed without uploading any data.")}});this.getResult=()=>{if(F===void 0)throw Error("Result is not ready. await the stream first.");return F}}}async function Tn0(D){let X=new Headers(D.metadata),J="uploads",F=await(await D.client.makeRequest({method:"POST",bucketName:D.bucketName,objectName:D.objectName,query:"uploads",headers:X,returnBody:!0})).text(),Q=z8(F).root;if(!Q||Q.name!=="InitiateMultipartUploadResult")throw Error(`Unexpected response: ${F}`);let U=Q.children.find((Z)=>Z.name==="UploadId")?.content;if(!U)throw Error(`Unable to get UploadId from response: ${F}`);return{uploadId:U}}async function Cn0({client:D,bucketName:$,objectName:X,uploadId:J,etags:Y}){let F=`
|