@shipstatic/ship 2.0.0-beta.2 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/browser.d.ts +76 -79
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +30 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/completions/ship.fish +1 -1
- package/dist/completions/ship.zsh +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -79
- package/dist/index.d.ts +76 -79
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +30 -24
package/dist/cli.cjs
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var jt=Object.create;var Se=Object.defineProperty;var Gt=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var zt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var qt=(e,t)=>{for(var n in t)Se(e,n,{get:t[n],enumerable:!0})},Vt=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ht(t))!Bt.call(e,s)&&s!==n&&Se(e,s,{get:()=>t[s],enumerable:!(o=Gt(t,s))||o.enumerable});return e};var R=(e,t,n)=>(n=e!=null?jt(zt(e)):{},Vt(t||!e||!e.__esModule?Se(n,"default",{value:e,enumerable:!0}):n,e));function I(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function Ee(e){let t=e.lastIndexOf(".");if(t===-1||t===e.length-1)return!1;let n=e.slice(t+1).toLowerCase();return Yt.has(n)}function Me(e){return Jt.test(e)}function ve(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>we.has(n))}function Wt(e){return e.startsWith(je.PREFIX)?B.API_KEY:e.startsWith(Ge.PREFIX)?B.DEPLOY_TOKEN:B.OPAQUE}function ze(e,t,n){if(!e.startsWith(t.PREFIX))throw l.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw l.validation(`${n} must be ${t.TOTAL_LENGTH} characters total (${t.PREFIX} + ${t.HEX_LENGTH} hex chars)`);let o=e.slice(t.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${t.HEX_LENGTH}}$`,"i").test(o))throw l.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function Zt(e){ze(e,je,"API key")}function Qt(e){ze(e,Ge,"Deploy token")}function M(e){switch(Wt(e)){case B.API_KEY:Zt(e);return;case B.DEPLOY_TOKEN:Qt(e);return;case B.OPAQUE:if(!e)throw l.validation("Token must be a non-empty string")}}function Be(e){if(!e||e.length>be.MAX_LENGTH||!be.PATTERN.test(e))throw l.validation(`Caller must be 1-${be.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function qe(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw l.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw l.validation("API URL must not contain a path");if(t.search||t.hash)throw l.validation("API URL must not contain query parameters or fragments")}catch(t){throw I(t)?t:l.validation("API URL must be a valid URL")}}function Re(e){if(e==null)return;if(typeof e!="string")throw l.validation("Password must be a string");let t=e.trim();if(t.length<ne.MIN_LENGTH||t.length>ne.MAX_LENGTH)throw l.validation(`Password must be between ${ne.MIN_LENGTH} and ${ne.MAX_LENGTH} characters`);return t}var u,Kt,De,Xt,l,Yt,Jt,we,Ue,je,Ge,be,B,Te,He,oe,U,Ve,ne,E=P(()=>{"use strict";u={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Kt=new Set([u.Network,u.Cancelled,u.File,u.Config]),De={client:new Set([u.Business,u.Config,u.File,u.Forbidden,u.Validation]),network:new Set([u.Network]),auth:new Set([u.Authentication])},Xt=new Set(Object.values(u).filter(e=>!Kt.has(e))),l=class e extends Error{type;status;details;constructor(t,n,o,s){super(n),this.type=t,this.status=o,this.details=s,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===u.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:n}}static async fromHttpResponse(t,n){let o,s,i;try{if(t.headers.get("content-type")?.includes("application/json")){let p=await t.json();if(p&&typeof p=="object"){let a=p;typeof a.message=="string"?o=a.message:typeof a.error=="string"&&(o=a.error),s=a.details,typeof a.error=="string"&&Xt.has(a.error)&&(i=a.error)}}else{let p=await t.text();p&&(o=p)}}catch{}o=o||`${n||"Request"} failed with status ${t.status}`;let r=i??(t.status===401?u.Authentication:t.status===403?u.Forbidden:t.status===429?u.RateLimit:u.Api);return new e(r,o,t.status,s)}static fromFetchError(t,n){if(I(t))return t;let o=n||"Request";return t instanceof Error?t.name==="AbortError"?e.cancelled(`${o} was cancelled`):t instanceof TypeError&&t.message.includes("fetch")?e.network(`${o} failed: ${t.message}`,{cause:t}):new e(u.Api,`${o} failed: ${t.message}`):new e(u.Api,`${o} failed: Unknown error`)}static validation(t,n){return new e(u.Validation,t,400,n)}static notFound(t,n){let o=n?`${t} ${n} not found`:`${t} not found`;return new e(u.NotFound,o,404)}static forbidden(t,n){return new e(u.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(u.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(u.Authentication,t,401,n)}static business(t,n=400,o){return new e(u.Business,t,n,o)}static network(t,n){return new e(u.Network,t,void 0,n)}static cancelled(t,n){return new e(u.Cancelled,t,void 0,n)}static file(t,n){return new e(u.File,t,void 0,n)}static config(t,n){return new e(u.Config,t,void 0,n)}static api(t,n=500,o){return new e(u.Api,t,n,o)}isClientError(){return De.client.has(this.type)}isNetworkError(){return De.network.has(this.type)}isAuthError(){return De.auth.has(this.type)}isType(t){return this.type===t}};Yt=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Jt=/[\x00-\x1f\x7f#?%\\<>"]/;we=new Set(["node_modules","package.json"]);Ue={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},je={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},Ge={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},be={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},B={API_KEY:Ue.API_KEY,DEPLOY_TOKEN:Ue.TOKEN,OPAQUE:"opaque"};Te="ship.json",He={rewrites:[{source:"/(.*)",destination:"/index.html"}]};oe="https://api.shipstatic.com",U={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ve=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,ne={MIN_LENGTH:6,MAX_LENGTH:128}});function en(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function q(){return Ke||en()}var Ke,se=P(()=>{"use strict";Ke=null});async function rn(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,o=2097152;for(let s=0;s<e.size;s+=o){let i=Math.min(s+o,e.size);n.append(await e.slice(s,i).arrayBuffer())}return{md5:n.end()}}async function an(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function ln(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((o,s)=>{let i=t("md5"),r=n(e);r.on("error",c=>s(l.business(`Failed to read file for MD5: ${c.message}`))),r.on("data",c=>i.update(c)),r.on("end",()=>o({md5:i.digest("hex")}))})}async function de(e){if(e instanceof Blob)return rn(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return an(e);if(typeof e=="string")return ln(e);throw l.business("Invalid input for MD5 calculation")}var ke=P(()=>{"use strict";E()});function ut(e){if(!e||e.length===0)return"";let t=e.filter(i=>i&&typeof i=="string").map(i=>i.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(i=>i.split("/").filter(Boolean)),o=[],s=Math.min(...n.map(i=>i.length));for(let i=0;i<s;i++){let r=n[0][i];if(n.every(c=>c[i]===r))o.push(r);else break}return o.join("/")}function ue(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ie=P(()=>{"use strict"});function ft(e,t={}){if(t.flatten===!1)return e.map(o=>({path:ue(o),name:Le(o)}));let n=cn(e);return e.map(o=>{let s=ue(o);if(n){let i=n.endsWith("/")?n:`${n}/`;s.startsWith(i)&&(s=s.substring(i.length))}return s||(s=Le(o)),{path:s,name:Le(o)}})}function cn(e){if(!e.length)return"";let n=e.map(i=>ue(i)).map(i=>i.split("/")),o=[],s=Math.min(...n.map(i=>i.length));for(let i=0;i<s-1;i++){let r=n[0][i];if(n.every(c=>c[i]===r))o.push(r);else break}return o.join("/")}function Le(e){return e.split(/[/\\]/).pop()||e}var ht=P(()=>{"use strict";Ie()});function gt(e){if(Me(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,n=e.split("/").pop()||e;return t.test(n)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}var yt=P(()=>{"use strict";E()});function Dt(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(o=>o&&ve(o)))throw l.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(n=>{if(!n)return!1;let o=n.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let s=o[o.length-1];if((0,St.isJunk)(s))return!1;for(let r of o)if(r!==".well-known"&&(r.startsWith(".")||r.length>255))return!1;let i=o.slice(0,-1);for(let r of i)if(dn.some(c=>r.toLowerCase()===c.toLowerCase()))return!1;return!0})}var St,dn,bt=P(()=>{"use strict";E();St=require("junk"),dn=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Et(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw l.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function wt(e,t){let n=gt(e);if(!n.valid)throw l.business(n.reason||"Invalid file name");if(Ee(e))throw l.business(`File extension not allowed: "${t}"`)}var vt=P(()=>{"use strict";E();yt()});var Rt={};qt(Rt,{processFilesForNode:()=>mn});function Tt(e,t=new Set){let n=[],o=C.realpathSync(e);if(t.has(o))return n;t.add(o);let s=C.readdirSync(e);for(let i of s){let r=O.join(e,i),c=C.statSync(r);if(c.isDirectory()){let p=Tt(r,t);n.push(...p)}else c.isFile()&&n.push(r)}return n}async function mn(e,t={},n){if(q()!=="node")throw l.business("processFilesForNode can only be called in Node.js environment.");for(let m of e){let g=O.resolve(m);try{if(C.statSync(g).isDirectory()){let A=C.readdirSync(g).find(k=>we.has(k));if(A)throw l.business(`"${A}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(A){if(I(A))throw A}}let o=e.flatMap(m=>{let g=O.resolve(m);try{return C.statSync(g).isDirectory()?Tt(g):[g]}catch{throw l.file(`Path does not exist: ${m}`,{filePath:m})}}),s=[...new Set(o)],i=e.map(m=>O.resolve(m)),r=ut(i.map(m=>{try{return C.statSync(m).isDirectory()?m:O.dirname(m)}catch{return O.dirname(m)}})),c=s.map(m=>{if(r&&r.length>0){let g=O.relative(r,m);if(g&&typeof g=="string"&&!g.startsWith(".."))return g.replace(/\\/g,"/")}return O.basename(m)}),a=ft(c,{flatten:t.pathDetect!==!1}).map(m=>m.path),d=new Set(Dt(a));if(d.size===0)return[];let b=[],x=[];for(let m=0;m<s.length;m++)d.has(a[m])&&(b.push(s[m]),x.push(a[m]));let z=[],_=0;if(!n)throw l.config("Platform limits not provided. processFilesForNode requires the limits argument \u2014 pass `ship.getLimits()` result.");for(let m=0;m<b.length;m++){let g=b[m],A=x[m];try{Et(A,g);let k=C.statSync(g);if(k.size===0)continue;if(wt(A,g),k.size>n.maxFileSize)throw l.business(`File ${g} is too large. Maximum allowed size is ${n.maxFileSize/(1024*1024)}MB.`);if(_+=k.size,_>n.maxTotalSize)throw l.business(`Total deploy size is too large. Maximum allowed is ${n.maxTotalSize/(1024*1024)}MB.`);let X=C.readFileSync(g),{md5:Mt}=await de(X);z.push({path:A,content:X,size:X.length,md5:Mt})}catch(k){if(I(k))throw k;let X=k instanceof Error?k.message:String(k);throw l.file(`Failed to read file "${g}": ${X}`,{filePath:g})}}if(z.length>n.maxFilesCount)throw l.business(`Too many files to deploy. Maximum allowed is ${n.maxFilesCount} files.`);return z}var C,O,Ct=P(()=>{"use strict";C=R(require("fs"),1),O=R(require("path"),1);E();ht();se();bt();ke();Ie();vt()});var H=require("fs"),ge=R(require("path"),1);E();var $t=require("commander"),ye=require("yoctocolors");E();var Oe=require("zod");var Ce=require("zod"),ie={apiUrl:Ce.z.string().url().optional(),token:Ce.z.string().min(1).optional()};se();var tn=Oe.z.object(ie).strict(),nn={apiUrl:"SHIP_API_URL",token:"SHIP_TOKEN"};function V(){if(q()!=="node")return{};let e={apiUrl:process.env.SHIP_API_URL||void 0,token:process.env.SHIP_TOKEN||void 0};try{return tn.parse(e)}catch(t){if(t instanceof Oe.z.ZodError){let n=t.issues[0],o=n.path[0],s=(o&&nn[o])??"SHIP environment configuration";throw l.config(`Invalid ${s}: ${n.message}`)}throw l.config("Invalid environment configuration")}}var y=R(require("fs"),1),Ae=R(require("os"),1),$=R(require("path"),1);var xe=R(require("columnify"),1),h=require("yoctocolors"),Xe=["isCreate","claim"],w=(e,t,n)=>n?t:e(t),re=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e,v=(e,t,n)=>{console.log(t?`${JSON.stringify({success:e},null,2)}
|
|
3
|
-
`:`${
|
|
4
|
-
`)},
|
|
5
|
-
`);else{let o=
|
|
6
|
-
`)}},
|
|
7
|
-
`);else{let o=
|
|
8
|
-
`)}},
|
|
9
|
-
`);else{let o=
|
|
10
|
-
`)}},
|
|
11
|
-
`).map(
|
|
2
|
+
"use strict";var Nt=Object.create;var W=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Mt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var $e=(e,t)=>{for(var n in t)W(e,n,{get:t[n],enumerable:!0})},Fe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ut(t))!jt.call(e,r)&&r!==n&&W(e,r,{get:()=>t[r],enumerable:!(o=_t(t,r))||o.enumerable});return e};var A=(e,t,n)=>(n=e!=null?Nt(Mt(e)):{},Fe(t||!e||!e.__esModule?W(n,"default",{value:e,enumerable:!0}):n,e)),Gt=e=>Fe(W({},"__esModule",{value:!0}),e);function I(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function ye(e){let t=e.lastIndexOf(".");if(t===-1||t===e.length-1)return!1;let n=e.slice(t+1).toLowerCase();return Bt.has(n)}function _e(e){return qt.test(e)}function De(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>Se.has(n))}function Vt(e){return e.startsWith(Ue.PREFIX)?z.API_KEY:e.startsWith(Me.PREFIX)?z.DEPLOY_TOKEN:z.OPAQUE}function Ge(e,t,n){if(!e.startsWith(t.PREFIX))throw l.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw l.validation(`${n} must be ${t.TOTAL_LENGTH} characters total (${t.PREFIX} + ${t.HEX_LENGTH} hex chars)`);let o=e.slice(t.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${t.HEX_LENGTH}}$`,"i").test(o))throw l.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function Kt(e){Ge(e,Ue,"API key")}function Xt(e){Ge(e,Me,"Deploy token")}function j(e){switch(Vt(e)){case z.API_KEY:Kt(e);return;case z.DEPLOY_TOKEN:Xt(e);return;case z.OPAQUE:if(!e)throw l.validation("Token must be a non-empty string")}}function He(e){if(!e||e.length>ge.MAX_LENGTH||!ge.PATTERN.test(e))throw l.validation(`Caller must be 1-${ge.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function ze(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw l.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw l.validation("API URL must not contain a path");if(t.search||t.hash)throw l.validation("API URL must not contain query parameters or fragments")}catch(t){throw I(t)?t:l.validation("API URL must be a valid URL")}}function Ee(e){if(e==null)return;if(typeof e!="string")throw l.validation("Password must be a string");let t=e.trim();if(t.length<Z.MIN_LENGTH||t.length>Z.MAX_LENGTH)throw l.validation(`Password must be between ${Z.MIN_LENGTH} and ${Z.MAX_LENGTH} characters`);return t}var g,Ht,he,zt,l,Bt,qt,Se,Ne,Ue,Me,ge,z,be,je,Q,U,Be,Z,w=P(()=>{"use strict";g={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Ht=new Set([g.Network,g.Cancelled,g.File,g.Config]),he={client:new Set([g.Business,g.Config,g.File,g.Forbidden,g.Validation]),network:new Set([g.Network]),auth:new Set([g.Authentication])},zt=new Set(Object.values(g).filter(e=>!Ht.has(e))),l=class e extends Error{type;status;details;constructor(t,n,o,r){super(n),this.type=t,this.status=o,this.details=r,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===g.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:n}}static async fromHttpResponse(t,n){let o,r,i;try{if(t.headers.get("content-type")?.includes("application/json")){let d=await t.json();if(d&&typeof d=="object"){let s=d;typeof s.message=="string"?o=s.message:typeof s.error=="string"&&(o=s.error),r=s.details,typeof s.error=="string"&&zt.has(s.error)&&(i=s.error)}}else{let d=await t.text();d&&(o=d)}}catch{}let a=t.headers.get("retry-after");if(a!==null){let u=a.trim(),d=/^\d+$/.test(u)?Number(u):Math.ceil((Date.parse(u)-Date.now())/1e3);if(Number.isFinite(d)&&d>=0){let s=r&&typeof r=="object"?r:{};s.retryAfter===void 0&&(r={...s,retryAfter:d})}}o=o||`${n||"Request"} failed with status ${t.status}`;let m=i??(t.status===401?g.Authentication:t.status===403?g.Forbidden:t.status===429?g.RateLimit:g.Api);return new e(m,o,t.status,r)}static fromFetchError(t,n){if(I(t))return t;let o=n||"Request";return t instanceof Error?t.name==="AbortError"?e.cancelled(`${o} was cancelled`):t instanceof TypeError&&t.message.includes("fetch")?e.network(`${o} failed: ${t.message}`,{cause:t}):new e(g.Api,`${o} failed: ${t.message}`):new e(g.Api,`${o} failed: Unknown error`)}static validation(t,n){return new e(g.Validation,t,400,n)}static notFound(t,n){let o=n?`${t} ${n} not found`:`${t} not found`;return new e(g.NotFound,o,404)}static forbidden(t,n){return new e(g.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(g.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(g.Authentication,t,401,n)}static business(t,n=400,o){return new e(g.Business,t,n,o)}static network(t,n){return new e(g.Network,t,void 0,n)}static cancelled(t,n){return new e(g.Cancelled,t,void 0,n)}static file(t,n){return new e(g.File,t,void 0,n)}static config(t,n){return new e(g.Config,t,void 0,n)}static api(t,n=500,o){return new e(g.Api,t,n,o)}isClientError(){return he.client.has(this.type)}isNetworkError(){return he.network.has(this.type)}isAuthError(){return he.auth.has(this.type)}isType(t){return this.type===t}};Bt=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);qt=/[\x00-\x1f\x7f#?%\\<>"]/;Se=new Set(["node_modules","package.json"]);Ne={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Ue={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},Me={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},ge={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},z={API_KEY:Ne.API_KEY,DEPLOY_TOKEN:Ne.TOKEN,OPAQUE:"opaque"};be="ship.json",je={rewrites:[{source:"/(.*)",destination:"/index.html"}]};Q="https://api.shipstatic.com",U={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Be=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,Z={MIN_LENGTH:6,MAX_LENGTH:128}});function Yt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function B(){return qe||Yt()}var qe,te=P(()=>{"use strict";qe=null});async function en(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,o=2097152;for(let r=0;r<e.size;r+=o){let i=Math.min(r+o,e.size);n.append(await e.slice(r,i).arrayBuffer())}return{md5:n.end()}}async function tn(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function nn(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((o,r)=>{let i=t("md5"),a=n(e);a.on("error",m=>r(l.business(`Failed to read file for MD5: ${m.message}`))),a.on("data",m=>i.update(m)),a.on("end",()=>o({md5:i.digest("hex")}))})}async function ae(e){if(e instanceof Blob)return en(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return tn(e);if(typeof e=="string")return nn(e);throw l.business("Invalid input for MD5 calculation")}var Ce=P(()=>{"use strict";w()});function dt(e){if(!e||e.length===0)return"";let t=e.filter(i=>i&&typeof i=="string").map(i=>i.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(i=>i.split("/").filter(Boolean)),o=[],r=Math.min(...n.map(i=>i.length));for(let i=0;i<r;i++){let a=n[0][i];if(n.every(m=>m[i]===a))o.push(a);else break}return o.join("/")}function pe(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Oe=P(()=>{"use strict"});function mt(e,t={}){if(t.flatten===!1)return e.map(o=>({path:pe(o),name:Ae(o)}));let n=sn(e);return e.map(o=>{let r=pe(o);if(n){let i=n.endsWith("/")?n:`${n}/`;r.startsWith(i)&&(r=r.substring(i.length))}return r||(r=Ae(o)),{path:r,name:Ae(o)}})}function sn(e){if(!e.length)return"";let n=e.map(i=>pe(i)).map(i=>i.split("/")),o=[],r=Math.min(...n.map(i=>i.length));for(let i=0;i<r-1;i++){let a=n[0][i];if(n.every(m=>m[i]===a))o.push(a);else break}return o.join("/")}function Ae(e){return e.split(/[/\\]/).pop()||e}var ut=P(()=>{"use strict";Oe()});function ft(e){if(_e(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let t=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,n=e.split("/").pop()||e;return t.test(n)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}var ht=P(()=>{"use strict";w()});function yt(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(o=>o&&De(o)))throw l.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(n=>{if(!n)return!1;let o=n.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let r=o[o.length-1];if((0,gt.isJunk)(r))return!1;for(let a of o)if(a!==".well-known"&&(a.startsWith(".")||a.length>255))return!1;let i=o.slice(0,-1);for(let a of i)if(rn.some(m=>a.toLowerCase()===m.toLowerCase()))return!1;return!0})}var gt,rn,St=P(()=>{"use strict";w();gt=require("junk"),rn=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Dt(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw l.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function bt(e,t){let n=ft(e);if(!n.valid)throw l.business(n.reason||"Invalid file name");if(ye(e))throw l.business(`File extension not allowed: "${t}"`)}var Et=P(()=>{"use strict";w();ht()});var vt={};$e(vt,{processFilesForNode:()=>an});function wt(e,t=new Set){let n=[],o=x.realpathSync(e);if(t.has(o))return n;t.add(o);let r=x.readdirSync(e);for(let i of r){let a=L.join(e,i),m=x.statSync(a);if(m.isDirectory()){let u=wt(a,t);n.push(...u)}else m.isFile()&&n.push(a)}return n}async function an(e,t={},n){if(B()!=="node")throw l.business("processFilesForNode can only be called in Node.js environment.");for(let f of e){let y=L.resolve(f);try{if(x.statSync(y).isDirectory()){let v=x.readdirSync(y).find(T=>Se.has(T));if(v)throw l.business(`"${v}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(v){if(I(v))throw v}}let o=e.flatMap(f=>{let y=L.resolve(f);try{return x.statSync(y).isDirectory()?wt(y):[y]}catch{throw l.file(`Path does not exist: ${f}`,{filePath:f})}}),r=[...new Set(o)],i=e.map(f=>L.resolve(f)),a=dt(i.map(f=>{try{return x.statSync(f).isDirectory()?f:L.dirname(f)}catch{return L.dirname(f)}})),m=r.map(f=>{if(a&&a.length>0){let y=L.relative(a,f);if(y&&typeof y=="string"&&!y.startsWith(".."))return y.replace(/\\/g,"/")}return L.basename(f)}),d=mt(m,{flatten:t.pathDetect!==!1}).map(f=>f.path),s=new Set(yt(d));if(s.size===0)return[];let p=[],c=[];for(let f=0;f<r.length;f++)s.has(d[f])&&(p.push(r[f]),c.push(d[f]));let h=[],D=0;if(!n)throw l.config("Platform limits not provided. processFilesForNode requires the limits argument \u2014 pass `ship.getLimits()` result.");for(let f=0;f<p.length;f++){let y=p[f],v=c[f];try{Dt(v,y);let T=x.statSync(y);if(T.size===0)continue;if(bt(v,y),T.size>n.maxFileSize)throw l.business(`File ${y} is too large. Maximum allowed size is ${n.maxFileSize/(1024*1024)}MB.`);if(D+=T.size,D>n.maxTotalSize)throw l.business(`Total deploy size is too large. Maximum allowed is ${n.maxTotalSize/(1024*1024)}MB.`);let k=x.readFileSync(y),{md5:fe}=await ae(k);h.push({path:v,content:k,size:k.length,md5:fe})}catch(T){if(I(T))throw T;let k=T instanceof Error?T.message:String(T);throw l.file(`Failed to read file "${y}": ${k}`,{filePath:y})}}if(h.length>n.maxFilesCount)throw l.business(`Too many files to deploy. Maximum allowed is ${n.maxFilesCount} files.`);return h}var x,L,Tt=P(()=>{"use strict";x=A(require("fs"),1),L=A(require("path"),1);w();ut();te();St();Ce();Oe();Et()});var Cn={};$e(Cn,{buildProgram:()=>Ft});module.exports=Gt(Cn);var H=require("fs"),me=A(require("path"),1);w();var _=require("commander"),ue=require("yoctocolors");w();var ve=require("zod");var we=require("zod"),ee={apiUrl:we.z.string().url().optional(),token:we.z.string().min(1).optional()};te();var Jt=ve.z.object(ee).strict(),Wt={apiUrl:"SHIP_API_URL",token:"SHIP_TOKEN"};function q(){if(B()!=="node")return{};let e={apiUrl:process.env.SHIP_API_URL||void 0,token:process.env.SHIP_TOKEN||void 0};try{return Jt.parse(e)}catch(t){if(t instanceof ve.z.ZodError){let n=t.issues[0],o=n.path[0],r=(o&&Wt[o])??"SHIP environment configuration";throw l.config(`Invalid ${r}: ${n.message}`)}throw l.config("Invalid environment configuration")}}var b=A(require("fs"),1),Re=A(require("os"),1),$=A(require("path"),1);var Te=A(require("columnify"),1),S=require("yoctocolors"),Ve=["isCreate","claim"],R=(e,t,n)=>n?t:e(t),ne=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e,C=(e,t,n)=>{console.log(t?`${JSON.stringify({success:e},null,2)}
|
|
3
|
+
`:`${R(S.green,ne(e).replace(/\.$/,""),n)}
|
|
4
|
+
`)},O=(e,t,n)=>{if(t)console.error(`${JSON.stringify({error:e},null,2)}
|
|
5
|
+
`);else{let o=R(i=>(0,S.inverse)((0,S.red)(i)),`${R(S.hidden,"[",n)}error${R(S.hidden,"]",n)}`,n),r=R(S.red,ne(e).replace(/\.$/,""),n);console.error(`${o} ${r}
|
|
6
|
+
`)}},oe=(e,t,n)=>{if(t)console.log(`${JSON.stringify({warning:e},null,2)}
|
|
7
|
+
`);else{let o=R(i=>(0,S.inverse)((0,S.yellow)(i)),`${R(S.hidden,"[",n)}warning${R(S.hidden,"]",n)}`,n),r=R(S.yellow,ne(e).replace(/\.$/,""),n);console.log(`${o} ${r}
|
|
8
|
+
`)}},M=(e,t,n)=>{if(t)console.log(`${JSON.stringify({info:e},null,2)}
|
|
9
|
+
`);else{let o=R(i=>(0,S.inverse)((0,S.blue)(i)),`${R(S.hidden,"[",n)}info${R(S.hidden,"]",n)}`,n),r=R(S.blue,ne(e).replace(/\.$/,""),n);console.log(`${o} ${r}
|
|
10
|
+
`)}},Zt=(e,t="details",n)=>{if(e==null||e===0)return"-";let o=new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z");return t==="table"?o.replace(/T/,R(S.hidden,"T",n)).replace(/Z$/,R(S.hidden,"Z",n)):o},Ke=(e,t,n="details",o)=>{if(t===null||Array.isArray(t)&&t.length===0)return"-";if(typeof t=="number"&&(e==="created"||e==="activated"||e==="expires"||e==="linked"||e==="grace"||e==="used"))return Zt(t,n,o);if(e==="size"&&typeof t=="number"){let r=t/1048576;return r>=1?`${r.toFixed(1)}Mb`:`${(t/1024).toFixed(1)}Kb`}if(e==="config"||e==="password"){if(typeof t=="boolean")return t?"yes":"no";if(typeof t=="number")return t===1?"yes":"no"}return String(t)},K=(e,t,n,o)=>{if(!e||e.length===0)return"";let r=e[0],i=t||Object.keys(r).filter(u=>r[u]!==void 0&&!Ve.includes(u)),a=e.map(u=>{let d=u,s={};return i.forEach(p=>{p in d&&d[p]!==void 0&&(s[p]=Ke(p,d[p],"table",n))}),s});return`${(0,Te.default)(a,{columnSplitter:" ",columns:i,config:i.reduce((u,d)=>(u[d]={headingTransform:s=>R(S.dim,o?.[s]||s,n)},u),{})}).split(`
|
|
11
|
+
`).map(u=>u.replace(/\0/g,"").replace(/\s+$/,"")).join(`
|
|
12
12
|
`)}
|
|
13
|
-
`},
|
|
13
|
+
`},V=(e,t)=>{let n=Object.entries(e).filter(([i,a])=>Ve.includes(i)?!1:a!==void 0);if(n.length===0)return"";let o=n.map(([i,a])=>({property:`${i}:`,value:Ke(i,a,"details",t)}));return`${(0,Te.default)(o,{columnSplitter:" ",showHeaders:!1,config:{property:{dataTransform:i=>R(S.dim,i,t)}}}).split(`
|
|
14
14
|
`).map(i=>i.replace(/\0/g,"")).join(`
|
|
15
15
|
`)}
|
|
16
|
-
`};function
|
|
17
|
-
source '${
|
|
18
|
-
# ship end
|
|
16
|
+
`};function Xe(){let e=process.env.SHELL||"";return e.includes("bash")?"bash":e.includes("zsh")?"zsh":e.includes("fish")?"fish":null}function Ye(e,t){switch(e){case"bash":return{completionFile:$.join(t,".ship_completion.bash"),profileFile:$.join(t,".bash_profile"),scriptName:"ship.bash"};case"zsh":return{completionFile:$.join(t,".ship_completion.zsh"),profileFile:$.join(t,".zshrc"),scriptName:"ship.zsh"};case"fish":return{completionFile:$.join(t,".config/fish/completions/ship.fish"),profileFile:null,scriptName:"ship.fish"}}}function Je(e,t={}){let{json:n,noColor:o}=t,r=Xe(),i=Re.homedir();if(!r){O(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`,n,o);return}let a=Ye(r,i),m=$.join(e,a.scriptName);try{if(r==="fish"){let d=$.dirname(a.completionFile);b.existsSync(d)||b.mkdirSync(d,{recursive:!0}),b.copyFileSync(m,a.completionFile),C("fish completion installed successfully",n,o),M("please restart your shell to apply the changes",n,o);return}b.copyFileSync(m,a.completionFile);let u=`# ship
|
|
17
|
+
source '${a.completionFile}'
|
|
18
|
+
# ship end
|
|
19
|
+
`;if(a.profileFile){if(b.existsSync(a.profileFile)){let d=b.readFileSync(a.profileFile,"utf-8");if(!d.includes("# ship")||!d.includes("# ship end")){let s=d.length>0&&!d.endsWith(`
|
|
19
20
|
`)?`
|
|
20
|
-
`:"";
|
|
21
|
-
`),
|
|
22
|
-
`),
|
|
23
|
-
`)
|
|
24
|
-
`:"");y.writeFileSync(i.profileFile,x),v(`completion script uninstalled for ${o}`,t,n),ae(`run "source ${i.profileFile}" or restart your shell`,t,n)}else T("completion was not found in profile",t,n)}catch(r){let c=r instanceof Error?r.message:String(r);T(`could not uninstall completion script: ${c}`,t,n)}}var F=require("fs"),nt=require("os"),ot=require("path"),it=require("readline/promises");E();var le=require("yoctocolors"),G=(0,ot.join)((0,nt.homedir)(),".shiprc");function et(e){return e.length<13?"...":`${e.slice(0,9)}...${e.slice(-4)}`}function tt(){try{return(0,F.existsSync)(G)?JSON.parse((0,F.readFileSync)(G,"utf-8")):{}}catch{return{}}}async function st(e={}){let{noColor:t,json:n}=e,o=d=>t?d:(0,le.dim)(d),s=d=>t?d:(0,le.green)(d);if(n){let d=tt(),b=typeof d.token=="string"?d.token:void 0,x=typeof d.apiUrl=="string"?d.apiUrl:void 0;console.log(`${JSON.stringify({path:G,exists:(0,F.existsSync)(G),...b?{token:et(b)}:{},...x&&x!==oe?{apiUrl:x}:{}},null,2)}
|
|
25
|
-
`);return}let i=tt(),r=typeof i.token=="string"?i.token:void 0,c=(0,it.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${o("Create a free API key at")} https://my.shipstatic.com/api-key`),console.log("");let p=r?` Token (${o(et(r))}): `:" Token: ",a;try{a=(await c.question(p)).trim()}finally{c.close()}a&&(M(a),i.token=a),(0,F.writeFileSync)(G,`${JSON.stringify(i,null,2)}
|
|
21
|
+
`:"";b.appendFileSync(a.profileFile,s+u)}}else b.writeFileSync(a.profileFile,u);C(`completion script installed for ${r}`,n,o),oe(`run "source ${a.profileFile}" or restart your shell`,n,o)}}catch(u){let d=u instanceof Error?u.message:String(u);O(`could not install completion script: ${d}`,n,o)}}function We(e={}){let{json:t,noColor:n}=e,o=Xe(),r=Re.homedir();if(!o){O(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`,t,n);return}let i=Ye(o,r);try{if(o==="fish"){b.existsSync(i.completionFile)?(b.unlinkSync(i.completionFile),C("fish completion uninstalled successfully",t,n)):oe("fish completion was not installed",t,n),M("please restart your shell to apply the changes",t,n);return}if(b.existsSync(i.completionFile)&&b.unlinkSync(i.completionFile),!i.profileFile)return;if(!b.existsSync(i.profileFile)){O("profile file not found",t,n);return}let m=b.readFileSync(i.profileFile,"utf-8").split(`
|
|
22
|
+
`),u=[],d=0,s=!1;for(;d<m.length;)if(m[d].trim()==="# ship"){for(s=!0,d++;d<m.length&&m[d].trim()!=="# ship end";)d++;d<m.length&&d++}else u.push(m[d]),d++;s?(b.writeFileSync(i.profileFile,u.join(`
|
|
23
|
+
`)),C(`completion script uninstalled for ${o}`,t,n),oe(`run "source ${i.profileFile}" or restart your shell`,t,n)):O("completion was not found in profile",t,n)}catch(a){let m=a instanceof Error?a.message:String(a);O(`could not uninstall completion script: ${m}`,t,n)}}var F=require("fs"),et=require("os"),tt=require("path"),nt=require("readline/promises");w();var ie=require("yoctocolors"),G=(0,tt.join)((0,et.homedir)(),".shiprc");function Ze(e){return e.length<13?"...":`${e.slice(0,9)}...${e.slice(-4)}`}function Qe(){try{return(0,F.existsSync)(G)?JSON.parse((0,F.readFileSync)(G,"utf-8")):{}}catch{return{}}}async function ot(e={}){let{noColor:t,json:n}=e,o=s=>t?s:(0,ie.dim)(s),r=s=>t?s:(0,ie.green)(s);if(n){let s=Qe(),p=typeof s.token=="string"?s.token:void 0,c=typeof s.apiUrl=="string"?s.apiUrl:void 0;console.log(`${JSON.stringify({path:G,exists:(0,F.existsSync)(G),...p?{token:Ze(p)}:{},...c&&c!==Q?{apiUrl:c}:{}},null,2)}
|
|
24
|
+
`);return}let i=Qe(),a=typeof i.token=="string"?i.token:void 0,m=(0,nt.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${o("Create a free API key at")} https://my.shipstatic.com/api-key`),console.log("");let u=a?` Token (${o(Ze(a))}): `:" Token: ",d;try{d=(await m.question(u)).trim()}finally{m.close()}d&&(j(d),i.token=d),(0,F.writeFileSync)(G,`${JSON.stringify(i,null,2)}
|
|
26
25
|
`,{mode:384}),(0,F.chmodSync)(G,384),console.log(`
|
|
27
|
-
${
|
|
28
|
-
`)}E();E();E();var pe=class{constructor(){this.handlers=new Map}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n)}off(t,n){let o=this.handlers.get(t);o&&(o.delete(n),o.size===0&&this.handlers.delete(t))}emit(t,...n){let o=this.handlers.get(t);if(!o)return;let s=Array.from(o);for(let i of s)try{i(...n)}catch(r){o.delete(i),t!=="error"&&setTimeout(()=>{let c=r instanceof Error?r:new Error(String(r));this.emit("error",c,String(t))},0)}}};E();E();function J(e){if(e==null)return;if(e.length===0)return e;if(e.length>U.MAX_COUNT)throw l.validation(`Maximum ${U.MAX_COUNT} labels allowed`);let t=e.map((o,s)=>{if(typeof o!="string")throw l.validation(`Label at index ${s} must be a string`);let i=o.trim().toLowerCase();if(i.length<U.MIN_LENGTH)throw l.validation(`Labels must be at least ${U.MIN_LENGTH} characters long`);if(i.length>U.MAX_LENGTH)throw l.validation(`Labels must be no more than ${U.MAX_LENGTH} characters long`);if(!Ve.test(i))throw l.validation(`Labels must start and end with alphanumeric characters, with optional separators (${U.SEPARATORS}) between segments`);return i}),n=[...new Set(t)];if(n.length!==t.length)throw l.validation("Duplicate labels are not allowed");return n}var S={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},sn=3e4,ce=class extends pe{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||oe,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??sn,this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=n.createDeployBody,this.deployEndpoint=n.deployEndpoint||S.DEPLOYMENTS}setGlobalHeaders(n){this.globalHeaders=n}async executeRequest(n,o,s){let i=()=>{};try{let r=await this.mergeHeaders(o.headers),c=this.createTimeoutSignal(o.signal);i=c.cleanup;let p={...o,headers:r,credentials:this.session&&!r.Authorization?"include":void 0,signal:c.signal};this.emit("request",n,p);let a=await this.fetch(n,p);if(i(),!a.ok)throw await l.fromHttpResponse(a,s);return this.emit("response",this.safeClone(a),n),{data:await this.parseResponse(this.safeClone(a)),status:a.status}}catch(r){i();let c=l.fromFetchError(r,s);throw this.emit("error",c,n),c}}async request(n,o,s){let{data:i}=await this.executeRequest(n,o,s);return i}async requestWithStatus(n,o,s){return this.executeRequest(n,o,s)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n){let o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout);if(n){let i=()=>o.abort();n.addEventListener("abort",i),n.aborted&&o.abort()}return{signal:o.signal,cleanup:()=>clearTimeout(s)}}safeClone(n){try{return n.clone()}catch{return n}}async parseResponse(n){if(!(n.headers.get("Content-Length")==="0"||n.status===204))return n.json()}async deploy(n,o={}){if(!n.length)throw l.business("No files to deploy");for(let p of n)if(!p.md5)throw l.file(`MD5 checksum missing for file: ${p.path}`,{filePath:p.path});Re(o.password);let s=J(o.labels),i=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:r,headers:c}=await this.createDeployBody(n,{labels:s,via:o.via,password:o.password,flags:i,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:r,headers:c,signal:o.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(n){return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(n,o){let s=J(o);return this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:s})},"Update deployment labels")}async removeDeployment(n){await this.request(`${this.apiUrl}${S.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove deployment")}async setDomain(n,o,s){let i=J(s),r={};o&&(r.deployment=o),i!==void 0&&(r.labels=i);let{data:c,status:p}=await this.requestWithStatus(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},"Set domain");return{...c,isCreate:p===201}}async listDomains(){return this.request(`${this.apiUrl}${S.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(n){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}`,{method:"GET"},"Get domain")}async removeDomain(n){await this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(n){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(n){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(n){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(n){return this.request(`${this.apiUrl}${S.DOMAINS}/${encodeURIComponent(n)}/share`,{method:"GET"},"Get domain share")}async validateDomain(n){return this.request(`${this.apiUrl}${S.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:n})},"Validate domain")}async createToken(n,o){let s=J(o),i={};return n!==void 0&&(i.ttl=n),s!==void 0&&(i.labels=s),this.request(`${this.apiUrl}${S.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${S.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(n){await this.request(`${this.apiUrl}${S.TOKENS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove token")}async getAccount(){return this.request(`${this.apiUrl}${S.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${S.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${S.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(n,o={}){let s=n.find(p=>p.path==="index.html"||p.path==="/index.html");if(!s||s.size>100*1024)return!1;let i;if(typeof Buffer<"u"&&Buffer.isBuffer(s.content))i=s.content.toString("utf-8");else if(typeof Blob<"u"&&s.content instanceof Blob)i=await s.content.text();else if(typeof File<"u"&&s.content instanceof File)i=await s.content.text();else return!1;let r={files:n.map(p=>p.path),index:i};return(await this.request(`${this.apiUrl}${S.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)},"SPA check")).isSPA}};E();function rt(e,t){let n={...e};return n.timeout===void 0&&t.timeout!==void 0&&(n.timeout=t.timeout),n.maxConcurrency===void 0&&t.maxConcurrency!==void 0&&(n.maxConcurrency=t.maxConcurrency),n.onProgress===void 0&&t.onProgress!==void 0&&(n.onProgress=t.onProgress),n}E();ke();async function pn(){let e=JSON.stringify(He,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await de(t);return{path:Te,content:t,size:e.length,md5:n}}async function at(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(o=>o.path===Te))return e;try{if(await t.checkSPA(e,n)){let s=await pn();return[...e,s]}}catch{}return e}function lt(e){let{getApi:t,ensureInit:n,processInput:o,clientDefaults:s}=e;return{upload:async(i,r={})=>{await n();let c=s?rt(r,s):r;if(!o)throw l.config("processInput function is not provided.");let p=t(),a=await o(i,c);return a=await at(a,p,c),p.deploy(a,c)},list:async()=>(await n(),t().listDeployments()),get:async i=>(await n(),t().getDeployment(i)),set:async(i,r)=>(await n(),t().updateDeploymentLabels(i,r.labels)),remove:async i=>{await n(),await t().removeDeployment(i)}}}function pt(e){let{getApi:t,ensureInit:n}=e;return{set:async(o,s={})=>(await n(),t().setDomain(o,s.deployment,s.labels)),list:async()=>(await n(),t().listDomains()),get:async o=>(await n(),t().getDomain(o)),remove:async o=>{await n(),await t().removeDomain(o)},verify:async o=>(await n(),t().verifyDomain(o)),validate:async o=>(await n(),t().validateDomain(o)),dns:async o=>(await n(),t().getDomainDns(o)),records:async o=>(await n(),t().getDomainRecords(o)),share:async o=>(await n(),t().getDomainShare(o))}}function ct(e){let{getApi:t,ensureInit:n}=e;return{get:async()=>(await n(),t().getAccount())}}function dt(e){let{getApi:t,ensureInit:n}=e;return{create:async(o={})=>(await n(),t().createToken(o.ttl,o.labels)),list:async()=>(await n(),t().listTokens()),remove:async o=>{await n(),await t().removeToken(o)}}}var me=class{constructor(t={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&Be(t.caller),t.token&&t.session)throw l.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(M(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new ce({...t,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=lt({...n,processInput:(o,s)=>this.processInput(o,s),clientDefaults:this.clientOptions}),this.domains=pt(n),this.account=ct(n),this.tokens=dt(n)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(t){throw this.initPromise=null,t}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(t,n){return this.deployments.upload(t,n)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(t,n){this.http.on(t,n)}off(t,n){this.http.off(t,n)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw l.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw l.business("Invalid token provided. Token must be a non-empty string.");M(t),this.credential=t;return}if(typeof t!="function")throw l.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw l.authentication("Token provider returned no token.");if(typeof t!="string")throw l.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};se();E();async function mt(e,t={}){let{FormData:n,File:o}=await import("formdata-node"),{FormDataEncoder:s}=await import("form-data-encoder"),{labels:i,via:r,password:c,flags:p,captcha:a}=t,d=new n,b=[];for(let m of e){if(!Buffer.isBuffer(m.content)&&!(typeof Blob<"u"&&m.content instanceof Blob))throw l.file(`Unsupported file.content type for Node.js: ${m.path}`,{filePath:m.path});if(!m.md5)throw l.file(`File missing md5 checksum: ${m.path}`,{filePath:m.path});let g=new o([m.content],m.path,{type:"application/octet-stream"});d.append("files[]",g),b.push(m.md5)}d.append("checksums",JSON.stringify(b)),i&&i.length>0&&d.append("labels",JSON.stringify(i)),r&&d.append("via",r),c&&d.append("password",c),p?.build&&d.append("build","true"),p?.prerender&&d.append("prerender","true"),p?.spa&&d.append("spa","true"),a&&d.append("captcha",a);let x=new s(d),z=[];for await(let m of x.encode())z.push(Buffer.from(m));let _=Buffer.concat(z);return{body:_.buffer.slice(_.byteOffset,_.byteOffset+_.byteLength),headers:{"Content-Type":x.contentType,"Content-Length":Buffer.byteLength(_).toString()}}}var fe=class extends me{constructor(t={}){if(q()!=="node")throw l.business("Node.js Ship class can only be used in Node.js environment.");let n=V();super({...t,apiUrl:t.apiUrl||n.apiUrl,token:t.token||(t.session?void 0:n.token)})}async deploy(t,n){return super.deploy(t,n)}async processInput(t,n){let o=typeof t=="string"?[t]:t;if(!Array.isArray(o)||!o.every(i=>typeof i=="string"))throw l.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw l.business("No files to deploy.");let{processFilesForNode:s}=await Promise.resolve().then(()=>(Ct(),Rt));return s(o,n,this.platformLimits??void 0)}getDeployBodyCreator(){return mt}};var Ot=require("os");E();var xt=require("cosmiconfig"),$e=require("zod");var un=$e.z.object(ie).strict(),Pe="ship";function he(e){let t=e||void 0,n=(0,Ot.homedir)(),o=(0,xt.cosmiconfigSync)(Pe,{searchPlaces:[`.${Pe}rc`,"package.json",`${n}/.${Pe}rc`],stopDir:n}),s;try{s=t?o.load(t):o.search()}catch(i){if(I(i))throw i;let r=i instanceof Error?i.message:String(i),c=t?` (${t})`:"";throw l.config(`Failed to read ship config${c}: ${r}`)}if(!s?.config)return{};try{return un.parse(s.config)}catch(i){if(i instanceof $e.z.ZodError){let r=i.issues[0];if(r.code==="unrecognized_keys"){let p=r.keys.filter(a=>a==="apiKey"||a==="deployToken");if(p.length>0){let a=p.map(d=>`"${d}"`).join(" and ");throw l.config(`Invalid config in ${s.filepath}: ${a} ${p.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let c=r.path.length>0?` at ${r.path.join(".")}`:"";throw l.config(`Invalid config in ${s.filepath}${c}: ${r.message}`)}throw l.config(`Invalid config in ${s.filepath}`)}}function Fe(e,t,n){return{apiUrl:e.apiUrl||t.apiUrl||n.apiUrl,token:e.token||t.token||n.token}}function At(e={}){return new fe(Fe(e,V(),he(e.config)))}E();function kt(e){return I(e)?e:e instanceof Error?l.business(e.message):l.business(String(e??"Unknown error"))}function It(e,t,n){if(e.isAuthError())return n?.token?"authentication failed: invalid or expired token":"authentication required: pass --token, set SHIP_TOKEN, or run ship config";if(e.isNetworkError()){let o=e.details?.url;return o?`network error: could not reach ${o}`:"network error: could not reach the API. check your internet connection"}return e.isClientError()||e.status&&e.status>=400&&e.status<500?e.message:"server error: please try again or check https://status.shipstatic.com"}function Lt(e,t){return JSON.stringify({error:e,...t?{details:t}:{}},null,2)}var Ne=(e,t)=>`https://setup.shipstatic.com/${e}/${t}`;function fn(e,t,n){let{noColor:o}=n;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let s=["deployment","labels","files","size","created","via"];console.log(Y(e.deployments,s,o))}function hn(e,t,n){let{noColor:o}=n;if(e.domains.length===0){console.log("no domains found"),console.log();return}let s=["domain","deployment","labels","linked","links","created"];console.log(Y(e.domains,s,o))}function gn(e,t,n){let{noColor:o}=n,{_dnsRecords:s,_shareHash:i,isCreate:r,...c}=e;if(t.operation==="set"){let p=r?"created":"updated";v(`${e.url} domain ${p}`,!1,o)}s&&s.length>0&&(console.log(),j("DNS Records to configure:",!1,o),s.forEach(p=>{console.log(` ${p.type}: ${p.name} \u2192 ${p.value}`)})),i&&(console.log(),j(`Setup instructions: ${Ne(i,e.domain)}`,!1,o)),console.log(K(c,o))}function yn(e,t,n){let{noColor:o}=n;t.operation==="upload"&&v(`${e.url} deployment uploaded`,!1,o),console.log(K(e,o));let s=e.claim;if(s){let i=e.expires?Math.round((e.expires-e.created)/86400):null;console.log(`IMPORTANT: this deployment${i?` expires in ${i} day${i!==1?"s":""}`:" will expire"}, claim it to keep permanently:
|
|
29
|
-
${
|
|
30
|
-
`),
|
|
26
|
+
${r("saved to")} ${o(G)}
|
|
27
|
+
`)}w();w();w();var se=class{constructor(){this.handlers=new Map}on(t,n){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t)?.add(n)}off(t,n){let o=this.handlers.get(t);o&&(o.delete(n),o.size===0&&this.handlers.delete(t))}emit(t,...n){let o=this.handlers.get(t);if(!o)return;let r=Array.from(o);for(let i of r)try{i(...n)}catch(a){o.delete(i),t!=="error"&&setTimeout(()=>{let m=a instanceof Error?a:new Error(String(a));this.emit("error",m,String(t))},0)}}};w();w();function X(e){if(e==null)return;if(e.length===0)return e;if(e.length>U.MAX_COUNT)throw l.validation(`Maximum ${U.MAX_COUNT} labels allowed`);let t=e.map((o,r)=>{if(typeof o!="string")throw l.validation(`Label at index ${r} must be a string`);let i=o.trim().toLowerCase();if(i.length<U.MIN_LENGTH)throw l.validation(`Labels must be at least ${U.MIN_LENGTH} characters long`);if(i.length>U.MAX_LENGTH)throw l.validation(`Labels must be no more than ${U.MAX_LENGTH} characters long`);if(!Be.test(i))throw l.validation(`Labels must start and end with alphanumeric characters, with optional separators (${U.SEPARATORS}) between segments`);return i}),n=[...new Set(t)];if(n.length!==t.length)throw l.validation("Duplicate labels are not allowed");return n}var E={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",LIMITS:"/limits",PING:"/ping",SPA_CHECK:"/spa-check"},Qt=3e4;function it(e){let t=new URLSearchParams;e?.limit!==void 0&&t.set("limit",String(e.limit)),e?.cursor!==void 0&&t.set("cursor",e.cursor);let n=t.toString();return n?`?${n}`:""}var re=class extends se{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||Q,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??Qt,this.fetch=n.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=n.createDeployBody,this.deployEndpoint=n.deployEndpoint||E.DEPLOYMENTS}setGlobalHeaders(n){this.globalHeaders=n}async executeRequest(n,o,r){let i=()=>{};try{let a=await this.mergeHeaders(o.headers),m=this.createTimeoutSignal(o.signal);i=m.cleanup;let u={...o,headers:a,credentials:this.session&&!a.Authorization?"include":void 0,signal:m.signal};this.emit("request",n,u);let d=await this.fetch(n,u);if(i(),!d.ok)throw await l.fromHttpResponse(d,r);return this.emit("response",this.safeClone(d),n),{data:await this.parseResponse(this.safeClone(d)),status:d.status}}catch(a){i();let m=l.fromFetchError(a,r);throw this.emit("error",m,n),m}}async request(n,o,r){let{data:i}=await this.executeRequest(n,o,r);return i}async requestWithStatus(n,o,r){return this.executeRequest(n,o,r)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n){let o=new AbortController,r=setTimeout(()=>o.abort(),this.timeout);if(n){let i=()=>o.abort();n.addEventListener("abort",i),n.aborted&&o.abort()}return{signal:o.signal,cleanup:()=>clearTimeout(r)}}safeClone(n){try{return n.clone()}catch{return n}}async parseResponse(n){if(!(n.headers.get("Content-Length")==="0"||n.status===204))return n.json()}async deploy(n,o={}){if(!n.length)throw l.business("No files to deploy");for(let u of n)if(!u.md5)throw l.file(`MD5 checksum missing for file: ${u.path}`,{filePath:u.path});Ee(o.password);let r=X(o.labels),i=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:a,headers:m}=await this.createDeployBody(n,{labels:r,via:o.via,password:o.password,flags:i,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:a,headers:m,signal:o.signal||null},"Deploy")}async listDeployments(n){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}${it(n)}`,{method:"GET"},"List deployments")}async getDeployment(n){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(n,o){let r=X(o);return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:r})},"Update deployment labels")}async removeDeployment(n){await this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove deployment")}async setDomain(n,o,r){let i=X(r),a={};o&&(a.deployment=o),i!==void 0&&(a.labels=i);let{data:m,status:u}=await this.requestWithStatus(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)},"Set domain");return{...m,isCreate:u===201}}async listDomains(n){return this.request(`${this.apiUrl}${E.DOMAINS}${it(n)}`,{method:"GET"},"List domains")}async getDomain(n){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}`,{method:"GET"},"Get domain")}async removeDomain(n){await this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(n){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(n){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(n){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(n){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(n)}/share`,{method:"GET"},"Get domain share")}async validateDomain(n){return this.request(`${this.apiUrl}${E.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:n})},"Validate domain")}async createToken(n,o){let r=X(o),i={};return n!==void 0&&(i.ttl=n),r!==void 0&&(i.labels=r),this.request(`${this.apiUrl}${E.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${E.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(n){await this.request(`${this.apiUrl}${E.TOKENS}/${encodeURIComponent(n)}`,{method:"DELETE"},"Remove token")}async getAccount(){return this.request(`${this.apiUrl}${E.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${E.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${E.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(n,o={}){let r=n.find(u=>u.path==="index.html"||u.path==="/index.html");if(!r||r.size>100*1024)return!1;let i;if(typeof Buffer<"u"&&Buffer.isBuffer(r.content))i=r.content.toString("utf-8");else if(typeof Blob<"u"&&r.content instanceof Blob)i=await r.content.text();else if(typeof File<"u"&&r.content instanceof File)i=await r.content.text();else return!1;let a={files:n.map(u=>u.path),index:i};return(await this.request(`${this.apiUrl}${E.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)},"SPA check")).isSPA}};w();w();Ce();async function on(){let e=JSON.stringify(je,null,2),t;typeof Buffer<"u"?t=Buffer.from(e,"utf-8"):t=new Blob([e],{type:"application/json"});let{md5:n}=await ae(t);return{path:be,content:t,size:e.length,md5:n}}async function st(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(o=>o.path===be))return e;try{if(await t.checkSPA(e,n)){let r=await on();return[...e,r]}}catch{}return e}function rt(e){let{getApi:t,ensureInit:n,processInput:o}=e;return{upload:async(r,i={})=>{if(await n(),!o)throw l.config("processInput function is not provided.");let a=t(),m=await o(r,i);return m=await st(m,a,i),a.deploy(m,i)},list:async r=>(await n(),t().listDeployments(r)),get:async r=>(await n(),t().getDeployment(r)),set:async(r,i)=>(await n(),t().updateDeploymentLabels(r,i.labels)),remove:async r=>{await n(),await t().removeDeployment(r)}}}function at(e){let{getApi:t,ensureInit:n}=e;return{set:async(o,r={})=>(await n(),t().setDomain(o,r.deployment,r.labels)),list:async o=>(await n(),t().listDomains(o)),get:async o=>(await n(),t().getDomain(o)),remove:async o=>{await n(),await t().removeDomain(o)},verify:async o=>(await n(),t().verifyDomain(o)),validate:async o=>(await n(),t().validateDomain(o)),dns:async o=>(await n(),t().getDomainDns(o)),records:async o=>(await n(),t().getDomainRecords(o)),share:async o=>(await n(),t().getDomainShare(o))}}function lt(e){let{getApi:t,ensureInit:n}=e;return{get:async()=>(await n(),t().getAccount())}}function pt(e){let{getApi:t,ensureInit:n}=e;return{create:async(o={})=>(await n(),t().createToken(o.ttl,o.labels)),list:async()=>(await n(),t().listTokens()),remove:async o=>{await n(),await t().removeToken(o)}}}var le=class{constructor(t={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(t={...t,apiUrl:t.apiUrl||void 0,token:t.token||void 0,caller:t.caller||void 0},this.clientOptions=t,t.caller!==void 0&&He(t.caller),t.token&&t.session)throw l.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(j(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new re({...t,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=rt({...n,processInput:(o,r)=>this.processInput(o,r)}),this.domains=at(n),this.account=lt(n),this.tokens=pt(n)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(t){throw this.initPromise=null,t}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(t,n){return this.deployments.upload(t,n)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(t,n){this.http.on(t,n)}off(t,n){this.http.off(t,n)}setHeaders(t){this.http.setGlobalHeaders(t)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(t){if(this.clientOptions.session)throw l.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw l.business("Invalid token provided. Token must be a non-empty string.");j(t),this.credential=t;return}if(typeof t!="function")throw l.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=t}async getAuthHeaders(){if(this.credential===null)return{};let t=typeof this.credential=="function"?await this.credential():this.credential;if(!t)throw l.authentication("Token provider returned no token.");if(typeof t!="string")throw l.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};te();w();async function ct(e,t={}){let{FormData:n,File:o}=await import("formdata-node"),{FormDataEncoder:r}=await import("form-data-encoder"),{labels:i,via:a,password:m,flags:u,captcha:d}=t,s=new n,p=[];for(let f of e){if(!Buffer.isBuffer(f.content)&&!(typeof Blob<"u"&&f.content instanceof Blob))throw l.file(`Unsupported file.content type for Node.js: ${f.path}`,{filePath:f.path});if(!f.md5)throw l.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});let y=new o([f.content],f.path,{type:"application/octet-stream"});s.append("files[]",y),p.push(f.md5)}s.append("checksums",JSON.stringify(p)),i&&i.length>0&&s.append("labels",JSON.stringify(i)),a&&s.append("via",a),m&&s.append("password",m),u?.build&&s.append("build","true"),u?.prerender&&s.append("prerender","true"),u?.spa&&s.append("spa","true"),d&&s.append("captcha",d);let c=new r(s),h=[];for await(let f of c.encode())h.push(Buffer.from(f));let D=Buffer.concat(h);return{body:D.buffer.slice(D.byteOffset,D.byteOffset+D.byteLength),headers:{"Content-Type":c.contentType,"Content-Length":Buffer.byteLength(D).toString()}}}var ce=class extends le{constructor(t={}){if(B()!=="node")throw l.business("Node.js Ship class can only be used in Node.js environment.");let n=q();super({...t,apiUrl:t.apiUrl||n.apiUrl,token:t.token||(t.session?void 0:n.token)})}async deploy(t,n){return super.deploy(t,n)}async processInput(t,n){let o=typeof t=="string"?[t]:t;if(!Array.isArray(o)||!o.every(i=>typeof i=="string"))throw l.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw l.business("No files to deploy.");let{processFilesForNode:r}=await Promise.resolve().then(()=>(Tt(),vt));return r(o,n,this.platformLimits??void 0)}getDeployBodyCreator(){return ct}};var Rt=require("os");w();var Ct=require("cosmiconfig"),Le=require("zod");var ln=Le.z.object(ee).strict(),xe="ship";function de(e){let t=e||void 0,n=(0,Rt.homedir)(),o=(0,Ct.cosmiconfigSync)(xe,{searchPlaces:[`.${xe}rc`,"package.json",`${n}/.${xe}rc`],stopDir:n}),r;try{r=t?o.load(t):o.search()}catch(i){if(I(i))throw i;let a=i instanceof Error?i.message:String(i),m=t?` (${t})`:"";throw l.config(`Failed to read ship config${m}: ${a}`)}if(!r?.config)return{};try{return ln.parse(r.config)}catch(i){if(i instanceof Le.z.ZodError){let a=i.issues[0];if(a.code==="unrecognized_keys"){let u=a.keys.filter(d=>d==="apiKey"||d==="deployToken");if(u.length>0){let d=u.map(s=>`"${s}"`).join(" and ");throw l.config(`Invalid config in ${r.filepath}: ${d} ${u.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let m=a.path.length>0?` at ${a.path.join(".")}`:"";throw l.config(`Invalid config in ${r.filepath}${m}: ${a.message}`)}throw l.config(`Invalid config in ${r.filepath}`)}}function ke(e,t,n){return{apiUrl:e.apiUrl||t.apiUrl||n.apiUrl,token:e.token||t.token||n.token}}function Ot(e={}){return new ce(ke(e,q(),de(e.config)))}w();function At(e){return I(e)?e:e instanceof Error?l.business(e.message):l.business(String(e??"Unknown error"))}function xt(e,t,n){return e.isAuthError()?n?.token?"authentication failed: invalid or expired token":"authentication required: pass --token, set SHIP_TOKEN, or run ship config":e.isNetworkError()?"network error: could not reach the API. check your internet connection":e.isClientError()||e.status&&e.status>=400&&e.status<500?e.message:"server error: please try again or check https://status.shipstatic.com"}function Lt(e,t){return JSON.stringify({error:e,...t?{details:t}:{}},null,2)}var Ie=(e,t)=>`https://setup.shipstatic.com/${e}/${t}`;function pn(e,t,n){let{noColor:o}=n;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let r=["deployment","labels","files","size","created","via"];console.log(K(e.deployments,r,o)),kt(e.cursor,o)}function kt(e,t){e&&M(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function cn(e,t,n){let{noColor:o}=n;if(e.domains.length===0){console.log("no domains found"),console.log();return}let r=["domain","deployment","labels","linked","links","created"];console.log(K(e.domains,r,o)),kt(e.cursor,o)}function dn(e,t,n){let{noColor:o}=n,{_dnsRecords:r,_shareHash:i,isCreate:a,...m}=e;if(t.operation==="set"){let u=a?"created":"updated";C(`${e.url} domain ${u}`,!1,o)}r&&r.length>0&&(console.log(),M("DNS Records to configure:",!1,o),r.forEach(u=>{console.log(` ${u.type}: ${u.name} \u2192 ${u.value}`)})),i&&(console.log(),M(`Setup instructions: ${Ie(i,e.domain)}`,!1,o)),console.log(V(m,o))}function mn(e,t,n){let{noColor:o}=n;t.operation==="upload"&&C(`${e.url} deployment uploaded`,!1,o),console.log(V(e,o));let r=e.claim;if(r){let i=e.expires?Math.round((e.expires-e.created)/86400):null;console.log(`IMPORTANT: this deployment${i?` expires in ${i} day${i!==1?"s":""}`:" will expire"}, claim it to keep permanently:
|
|
28
|
+
${r}
|
|
29
|
+
`),M("configure a free API key with 'ship config' to deploy to your own account",!1,o)}}function un(e,t,n){let{noColor:o}=n;console.log(V(e,o))}function fn(e,t,n){let{noColor:o}=n;e.message&&C(e.message,!1,o)}function hn(e,t,n){let{noColor:o}=n;if(e.valid){if(C("domain is valid",!1,o),console.log(),e.normalized&&console.log(` normalized: ${e.normalized}`),e.available!==null){let r=e.available?o?"available":"available \u2713":"already taken";console.log(` availability: ${r}`)}console.log()}else O(e.error||"domain is invalid",!1,o)}function gn(e,t,n){let{noColor:o}=n;if(e.records.length===0){console.log("no records found"),console.log();return}let r=["type","name","value"];console.log(K(e.records,r,o))}function yn(e,t,n){let{noColor:o}=n,r=e.dns?.provider?.name||null;console.log(V({domain:e.domain,provider:r},o))}function Sn(e,t,n){let{noColor:o}=n;C(Ie(e.hash,e.domain),!1,o)}function Dn(e,t,n){let{noColor:o}=n;if(e.tokens.length===0){console.log("no tokens found"),console.log();return}let r=["token","labels","created","expires"];console.log(K(e.tokens,r,o))}function bn(e,t,n){let{noColor:o}=n;t.operation==="create"&&e.token&&C(`token ${e.token} created`,!1,o),console.log(V(e,o))}function It(e,t,n){let{json:o,quiet:r,noColor:i}=n;if(r){if(e===void 0||typeof e=="boolean")return;if(e!==null&&typeof e=="object")if("deployments"in e)for(let a of e.deployments)console.log(a.deployment);else if("domains"in e)for(let a of e.domains)console.log(a.domain);else if("tokens"in e)for(let a of e.tokens)console.log(a.token);else if("records"in e)for(let a of e.records)console.log(`${a.type} ${a.name} ${a.value}`);else if("hash"in e){let a=e;console.log(Ie(a.hash,a.domain))}else if("dns"in e){let a=e.dns?.provider?.name;a&&console.log(a)}else if("domain"in e)console.log(e.domain);else if("deployment"in e)console.log(e.deployment);else if("secret"in e)console.log(e.secret);else if("email"in e)console.log(e.email);else if("valid"in e){let a=e;a.valid&&a.normalized&&console.log(a.normalized)}else"message"in e&&console.log(e.message);return}if(e===void 0){t.operation==="remove"&&t.resourceType&&t.resourceId?C(`${t.resourceId} ${t.resourceType.toLowerCase()} removed`,o,i):C("removed successfully",o,i);return}if(typeof e=="boolean"){e?C("api reachable",o,i):O("api unreachable",o,i);return}if(o&&e!==null&&typeof e=="object"){let a={...e};delete a._dnsRecords,delete a._shareHash,delete a.isCreate,console.log(JSON.stringify(a,null,2)),console.log();return}e!==null&&typeof e=="object"?"deployments"in e?pn(e,t,n):"domains"in e?cn(e,t,n):"tokens"in e?Dn(e,t,n):"records"in e?gn(e,t,n):"hash"in e?Sn(e,t,n):"dns"in e?yn(e,t,n):"domain"in e?dn(e,t,n):"deployment"in e?mn(e,t,n):"token"in e?bn(e,t,n):"email"in e?un(e,t,n):"valid"in e?hn(e,t,n):"message"in e?fn(e,t,n):C("success",o,i):C("success",o,i)}function En(){let e=[me.resolve(__dirname,"../package.json"),me.resolve(__dirname,"../../package.json")];for(let t of e)try{return JSON.parse((0,H.readFileSync)(t,"utf-8"))}catch{}return{version:"0.0.0"}}var wn=En();function vn(e){let t=i=>e?i:(0,ue.bold)(i),n=i=>e?i:(0,ue.dim)(i),o=i=>e?"":`${i} `;return`${t("USAGE")}
|
|
31
30
|
ship <path> ${o("\u{1F680}")}Deploy static sites with simplicity
|
|
32
31
|
|
|
33
32
|
${t("COMMANDS")}
|
|
34
33
|
${o("\u{1F4E6}")}${t("Deployments")}
|
|
35
34
|
ship deployments list List all deployments
|
|
36
|
-
ship deployments upload <path> Upload deployment from directory
|
|
35
|
+
ship deployments upload <path> Upload deployment from file or directory
|
|
37
36
|
ship deployments get <deployment> Show deployment information
|
|
38
37
|
ship deployments set <deployment> Set deployment labels
|
|
39
38
|
ship deployments remove <deployment> Delete deployment permanently
|
|
@@ -72,7 +71,7 @@ ${t("FLAGS")}
|
|
|
72
71
|
--no-color Disable colored output
|
|
73
72
|
--json Output results in JSON format
|
|
74
73
|
-q, --quiet Output only the resource identifier
|
|
75
|
-
--version
|
|
74
|
+
-V, --version Show version information
|
|
76
75
|
|
|
77
76
|
${t("EXAMPLES")}
|
|
78
77
|
ship ./dist
|
|
@@ -80,8 +79,9 @@ ${t("EXAMPLES")}
|
|
|
80
79
|
ship ./dist -q | ship domains set www.example.com
|
|
81
80
|
|
|
82
81
|
${n("Please report any issues to https://github.com/shipstatic/ship/issues")}
|
|
83
|
-
|
|
84
|
-
`),process.
|
|
85
|
-
`):(
|
|
86
|
-
`:" ")),
|
|
82
|
+
`}function Y(e,t=[]){return t.concat([e])}function Pe(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new _.InvalidArgumentError("Not a number.");return t}function J(e,t){let n=e?.label?.length?e.label:t?.label;if(!n?.length)return;let o=n.filter(r=>r!=="");return o.length?o:[]}function Pt(e,t){return e?.password??t?.password??(process.env.SHIP_PASSWORD||void 0)}function N(e){let t=e.optsWithGlobals();t.color===!1&&(t.noColor=!0);let n=!!process.env.FORCE_COLOR&&process.env.FORCE_COLOR!=="0";return!t.noColor&&!n&&(!process.stdout.isTTY||process.env.NO_COLOR!==void 0)&&(t.noColor=!0),t}function Tn(e){let t={};try{t=de(e.config)}catch{}let n=ke(e,q(),t).token;return typeof n=="string"?n:void 0}async function $t(e,t,n,o,r,i){if(!(0,H.existsSync)(t))throw l.file(`${t} path does not exist`,{filePath:t});let a=(0,H.statSync)(t);if(!a.isDirectory()&&!a.isFile())throw l.file(`${t} path must be a file or directory`,{filePath:t});let m={via:process.env.SHIP_VIA||"cli"};n!==void 0&&(m.labels=n),o!==void 0&&(m.password=o),r?.noPathDetect!==void 0&&(m.pathDetect=!r.noPathDetect),r?.noSpaDetect!==void 0&&(m.spaDetect=!r.noSpaDetect);let u=new AbortController;m.signal=u.signal;let d=null;if(process.stdout.isTTY&&!i.json&&!i.quiet&&!i.noColor){let{default:p}=await import("yocto-spinner");d=p({text:"uploading\u2026"}).start()}let s=()=>{u.abort(),d&&d.stop(),process.exit(130)};process.on("SIGINT",s);try{return await e.deployments.upload(t,m)}finally{process.removeListener("SIGINT",s),d&&d.stop()}}function Ft(){let e=new _.Command;e.exitOverride(s=>{if(s.code==="commander.help"||s.code==="commander.version"||s.exitCode===0)throw s;let p=N(e),c=s.message||"unknown command error";throw c=c.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),O(c,p.json,p.noColor),p.json||e.outputHelp(),s}).configureOutput({writeErr:s=>{s.startsWith("error:")||process.stderr.write(s)},writeOut:s=>process.stdout.write(s)});function t(s,p){return(...c)=>{let h=N(e),D=c[c.length-1];if(D?.args?.length){let f=D.args.find(y=>!p.includes(y));f&&O(`unknown command '${f}'`,h.json,h.noColor)}h.json||console.log(`usage: ship ${s} <${p.join("|")}>
|
|
83
|
+
`),process.exitCode=1}}function n(s,p){let c=N(e),h=At(s),D=xt(h,p,{token:Tn(e.opts())});c.json?console.error(`${Lt(D,h.details)}
|
|
84
|
+
`):(O(D,!1,c.noColor),h.type===g.Validation&&D.includes("unknown command")&&e.outputHelp()),process.exitCode=1}function o(s,p){return async function(...c){let h=N(this),D=p?{operation:p.operation,resourceType:p.resourceType,resourceId:p.getResourceId?.(...c)}:{};try{let{config:f,apiUrl:y,token:v}=e.opts(),T=Ot({config:f,apiUrl:y,token:v}),k=await s(T,h,...c);It(k,D,{json:h.json,quiet:h.quiet,noColor:h.noColor})}catch(f){n(f,D)}}}e.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(wn.version,"-V, --version","Show version information").option("--token <token>","Any ship token: API key (ship-\u2026) or deploy token (deploy-\u2026)").option("--config <file>","Custom config file path").option("--api-url <url>","API URL (for development)").option("--json","Output results in JSON format").option("-q, --quiet","Output only the resource identifier").option("--no-color","Disable colored output").helpOption("-h, --help","Display help for command").helpCommand("help [command]","Display help for command").configureHelp({formatHelp:(s,p)=>s.parent===null?`${vn(N(s).noColor)}
|
|
85
|
+
`:_.Help.prototype.formatHelp.call(p,s,p)}).allowExcessArguments(),e.hook("preAction",s=>{let p=N(s);try{p.token&&typeof p.token=="string"&&j(p.token),p.apiUrl&&typeof p.apiUrl=="string"&&ze(p.apiUrl)}catch(c){throw I(c)?(O(c.message,p.json,p.noColor),new _.CommanderError(1,"ship.invalidOption",c.message)):c}}),e.command("ping").description("Check API connectivity").action(o(async(s,p)=>{let c=await s.ping();return c||(process.exitCode=1),c})),e.command("whoami").description("Get current account information").action(o((s,p)=>s.whoami(),{operation:"get",resourceType:"Account"}));let r=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(t("deployments",["list","upload","get","set","remove"]));r.command("list").description("List all deployments").option("--limit <count>","Maximum number of results per page",Pe).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((s,p,c)=>s.deployments.list(c))),r.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(o((s,p,c,h)=>$t(s,c,J(h,e.opts()),Pt(h,e.opts()),h,p),{operation:"upload"})),r.command("get <deployment>").description("Show deployment information").action(o((s,p,c)=>s.deployments.get(c),{operation:"get",resourceType:"Deployment",getResourceId:s=>s})),r.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(s,p,c,h)=>{let D=J(h,e.opts())||[];return s.deployments.set(c,{labels:D})},{operation:"set",resourceType:"Deployment",getResourceId:s=>s})),r.command("remove <deployment>").description("Delete deployment permanently").action(o((s,p,c)=>s.deployments.remove(c),{operation:"remove",resourceType:"Deployment",getResourceId:s=>s}));let i=e.command("domains").description("Manage domains").enablePositionalOptions().action(t("domains",["list","get","set","validate","records","dns","share","verify","remove"]));i.command("list").description("List all domains").option("--limit <count>","Maximum number of results per page",Pe).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((s,p,c)=>s.domains.list(c))),i.command("get <name>").description("Show domain information").action(o((s,p,c)=>s.domains.get(c),{operation:"get",resourceType:"Domain",getResourceId:s=>s})),i.command("validate <name>").description("Check if domain name is valid and available").action(o(async(s,p,c)=>{let h=await s.domains.validate(c);return h.valid||(process.exitCode=1),h},{operation:"validate",resourceType:"Domain",getResourceId:s=>s})),i.command("verify <name>").description("Trigger DNS verification for external domain").action(o((s,p,c)=>s.domains.verify(c),{operation:"verify",resourceType:"Domain",getResourceId:s=>s})),i.command("records <name>").description("Show required DNS records for domain setup").action(o((s,p,c)=>s.domains.records(c),{operation:"records",resourceType:"Domain",getResourceId:s=>s})),i.command("dns <name>").description("Look up DNS provider for a domain").action(o((s,p,c)=>s.domains.dns(c),{operation:"dns",resourceType:"Domain",getResourceId:s=>s})),i.command("share <name>").description("Get shareable DNS setup link").action(o((s,p,c)=>s.domains.share(c),{operation:"share",resourceType:"Domain",getResourceId:s=>s})),i.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(s,p,c,h,D)=>{!h&&!process.stdin.isTTY&&(h=await new Promise(T=>{let k="";process.stdin.on("data",fe=>k+=fe),process.stdin.on("end",()=>T(k.trim()||void 0))}));let f=J(D,e.opts()),y={};h&&(y.deployment=h),f!==void 0&&(y.labels=f);let v=await s.domains.set(c,y);if(v.isCreate&&c.includes("."))try{let[T,k]=await Promise.all([s.domains.records(c),s.domains.share(c)]);return{...v,_dnsRecords:T.records,_shareHash:k.hash}}catch{}return v},{operation:"set",resourceType:"Domain",getResourceId:s=>s})),i.command("remove <name>").description("Delete domain permanently").action(o((s,p,c)=>s.domains.remove(c),{operation:"remove",resourceType:"Domain",getResourceId:s=>s}));let a=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(t("tokens",["list","create","remove"]));a.command("list").description("List all deploy tokens").action(o((s,p)=>s.tokens.list())),a.command("create").description("Create a new deploy token").option("--ttl <seconds>","Time to live in seconds (default: never expires)",Pe).option("--label <label>","Label to set (can be repeated)",Y,[]).action(o((s,p,c)=>{let h={};c?.ttl!==void 0&&(h.ttl=c.ttl);let D=J(c,e.opts());return D!==void 0&&(h.labels=D),s.tokens.create(h)},{operation:"create",resourceType:"Token"})),a.command("remove <token>").description("Delete token permanently").action(o((s,p,c)=>s.tokens.remove(c),{operation:"remove",resourceType:"Token",getResourceId:s=>s})),e.command("account").description("Manage account").action(t("account",["get"])).command("get").description("Show account information").action(o((s,p)=>s.whoami(),{operation:"get",resourceType:"Account"}));let u=e.command("completion").description("Setup shell completion").action(t("completion",["install","uninstall"]));u.command("install").description("Install shell completion script").action(()=>{let s=N(e),p=me.resolve(__dirname,"completions");Je(p,{json:s.json,noColor:s.noColor})}),u.command("uninstall").description("Uninstall shell completion script").action(()=>{let s=N(e);We({json:s.json,noColor:s.noColor})}),e.command("config").description("Save your token").action(async()=>{let s=N(e);try{await ot({noColor:s.noColor,json:s.json})}catch(p){n(p)}});let d=o((s,p,c,h)=>$t(s,c,J(h,e.opts()),Pt(h,e.opts()),h,p),{operation:"upload"});return e.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(async function(s,p){if(!s){this.outputHelp();return}if(!(0,H.existsSync)(s)&&!s.includes("/")&&!s.includes("\\")&&!s.includes(".")&&!s.startsWith("~")){n(l.validation(`unknown command '${s}'`),{operation:"upload"});return}return d.call(this,s,p)}),e}function Rn(){let e=process.argv.includes("--compfish");console.log(["ping","whoami","deployments","domains","tokens","account","config","completion"].join(e?`
|
|
86
|
+
`:" "))}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish")?Rn():Ft().parseAsync(process.argv).catch(t=>{if(t instanceof _.CommanderError){process.exitCode=t.exitCode;return}throw t}));0&&(module.exports={buildProgram});
|
|
87
87
|
//# sourceMappingURL=cli.cjs.map
|