@shipstatic/ship 2.0.0-beta.19 → 2.0.0-beta.20

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/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var dn=Object.create;var Re=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var fn=Object.getPrototypeOf,hn=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},yn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of un(t))!hn.call(e,i)&&i!==n&&Re(e,i,{get:()=>t[i],enumerable:!(o=mn(t,i))||o.enumerable});return e};var R=(e,t,n)=>(n=e!=null?dn(fn(e)):{},yn(t||!e||!e.__esModule?Re(n,"default",{value:e,enumerable:!0}):n,e));function tt(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values($e).includes(t)?t:void 0}function nt(e){if(e==null)return;if(typeof e!="string")throw p.validation("Idempotency key must be a string.");let t=e.trim();if(!t)throw p.validation("Idempotency key must not be empty.");if(t.length>le.MAX_LENGTH)throw p.validation(`Idempotency key must be at most ${le.MAX_LENGTH} characters.`);return t}function bn(e){return typeof e.code=="string"?!0:e instanceof TypeError&&e.message.includes("fetch")}function A(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function ve(e){let t=e.lastIndexOf(".");if(t===-1||t===e.length-1)return!1;let n=e.slice(t+1).toLowerCase();return wn.has(n)}function ot(e){return Tn.test(e)}function Le(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>xe.has(n))}function On(e){return e.startsWith(it.PREFIX)?z.API_KEY:e.startsWith(st.PREFIX)?z.DEPLOY_TOKEN:z.OPAQUE}function at(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n;try{n=JSON.parse(t)}catch(o){throw p.config(`invalid JSON format in config: ${o.message}`,{filePath:_})}if(n===null||typeof n!="object"||Array.isArray(n))throw p.config(`${_} must contain a JSON object`,{filePath:_})}function lt(e,t,n){if(!e.startsWith(t.PREFIX))throw p.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw p.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 p.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function Rn(e){lt(e,it,"API key")}function An(e){lt(e,st,"Deploy token")}function B(e){switch(On(e)){case z.API_KEY:Rn(e);return;case z.DEPLOY_TOKEN:An(e);return;case z.OPAQUE:if(!e)throw p.validation("Token must be a non-empty string")}}function pt(e){if(!e||e.length>Q.MAX_LENGTH||!Q.PATTERN.test(e))throw p.validation(`Caller must be 1-${Q.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function ct(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw p.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw p.validation("API URL must not contain a path");if(t.search||t.hash)throw p.validation("API URL must not contain query parameters or fragments")}catch(t){throw A(t)?t:p.validation("API URL must be a valid URL")}}function Ie(e){if(e==null)return;if(typeof e!="string")throw p.validation("Password must be a string");let t=e.trim();if(t.length<ae.MIN_LENGTH||t.length>ae.MAX_LENGTH)throw p.validation(`Password must be between ${ae.MIN_LENGTH} and ${ae.MAX_LENGTH} characters`);return t}var et,$e,le,E,I,h,En,Ae,Dn,Sn,p,wn,Cn,So,Tn,xe,Qe,it,st,Q,z,_,rt,pe,dt,ee,mt,bo,F,ut,ae,D=P(()=>{"use strict";et={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},$e={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},le={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};E={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},I={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},h={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"},En=new Set([h.Network,h.Cancelled,h.File,h.Config]),Ae={client:new Set([h.Business,h.Cancelled,h.Config,h.File,h.Forbidden,h.NotFound,h.RateLimit,h.Validation]),network:new Set([h.Network]),auth:new Set([h.Authentication])},Dn=new Set(Object.values(h).filter(e=>!En.has(e))),Sn=200;p=class e extends Error{type;status;details;constructor(t,n,o,i){super(n),this.type=t,this.status=o,this.details=i,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===h.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,i,s;try{if(t.headers.get("content-type")?.includes("application/json")){let r=await t.json();if(r&&typeof r=="object"){let a=r;typeof a.message=="string"?o=a.message:typeof a.error=="string"&&(o=a.error),i=a.details,typeof a.error=="string"&&Dn.has(a.error)&&(s=a.error)}}else{let r=(await t.text()).trim();r&&!r.startsWith("<")&&r.length<=Sn&&(o=r)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let m=l.trim(),r=/^\d+$/.test(m)?Number(m):Math.ceil((Date.parse(m)-Date.now())/1e3);if(Number.isFinite(r)&&r>=0){let a=i&&typeof i=="object"?i:{};a.retryAfter===void 0&&(i={...a,retryAfter:r})}}o=o||`${n||"Request"} failed with status ${t.status}`;let d=s??(t.status===401?h.Authentication:t.status===403?h.Forbidden:t.status===429?h.RateLimit:h.Api);return new e(d,o,t.status,i)}static fromFetchError(t,n){if(A(t))return t;let o=n||"Request";return t instanceof Error?t.name==="AbortError"?e.cancelled(`${o} was cancelled`):bn(t)?e.network(`${o} failed: ${t.message}`,{cause:t}):new e(h.Api,`${o} failed: ${t.message}`):new e(h.Api,`${o} failed: Unknown error`)}static validation(t,n){return new e(h.Validation,t,400,n)}static notFound(t,n){let o=n?`${t} ${n} not found`:`${t} not found`;return new e(h.NotFound,o,404)}static forbidden(t,n){return new e(h.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(h.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(h.Authentication,t,401,n)}static business(t,n=400,o){return new e(h.Business,t,n,o)}static network(t,n){return new e(h.Network,t,void 0,n)}static cancelled(t,n){return new e(h.Cancelled,t,void 0,n)}static file(t,n){return new e(h.File,t,void 0,n)}static config(t,n){return new e(h.Config,t,void 0,n)}static api(t,n=500,o){return new e(h.Api,t,n,o)}isClientError(){return Ae.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Ae.network.has(this.type)}isAuthError(){return Ae.auth.has(this.type)}isType(t){return this.type===t}};wn=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"]);Cn=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],So=Cn.map(e=>`.${e}`).join(","),Tn=/[\x00-\x1f\x7f#?%\\<>"]/;xe=new Set(["node_modules","package.json"]);Qe={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},it={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},st={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},Q={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},z={API_KEY:Qe.API_KEY,DEPLOY_TOKEN:Qe.TOKEN,OPAQUE:"opaque"};_="ship.json",rt={rewrites:[{source:"/(.*)",destination:"/index.html"}]},pe={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};dt="https://api.shipstatic.com",ee={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},mt="https://my.shipstatic.com/api-key",bo=4320*60,F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ut=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,ae={MIN_LENGTH:6,MAX_LENGTH:128}});function $n(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function K(){return ft||$n()}var ft,ce=P(()=>{"use strict";ft=null});async function Yn(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,o=2097152;for(let i=0;i<e.size;i+=o){let s=Math.min(i+o,e.size);n.append(await e.slice(i,s).arrayBuffer())}return{md5:n.end()}}async function Wn(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function Xn(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((o,i)=>{let s=t("md5"),l=n(e);l.on("error",d=>i(p.file(`Failed to read file for MD5: ${d.message}`,{filePath:e}))),l.on("data",d=>s.update(d)),l.on("end",()=>o({md5:s.digest("hex")}))})}async function De(e){if(e instanceof Blob)return Yn(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Wn(e);if(typeof e=="string")return Xn(e);throw p.business("Invalid input for MD5 calculation")}var qe=P(()=>{"use strict";D()});function Ut(e){if(!e||e.length===0)return"";let t=e.filter(s=>s&&typeof s=="string").map(s=>s.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(s=>s.split("/").filter(Boolean)),o=[],i=Math.min(...n.map(s=>s.length));for(let s=0;s<i;s++){let l=n[0][s];if(n.every(d=>d[s]===l))o.push(l);else break}return o.join("/")}function be(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ze=P(()=>{"use strict"});function jt(e,t={}){if(t.flatten===!1)return e.map(o=>({path:be(o),name:Ve(o)}));let n=Zn(e);return e.map(o=>{let i=be(o);if(n){let s=n.endsWith("/")?n:`${n}/`;i.startsWith(s)&&(i=i.substring(s.length))}return i||(i=Ve(o)),{path:i,name:Ve(o)}})}function Zn(e){if(!e.length)return"";let n=e.map(s=>be(s)).map(s=>s.split("/")),o=[],i=Math.min(...n.map(s=>s.length));for(let s=0;s<i-1;s++){let l=n[0][s];if(n.every(d=>d[s]===l))o.push(l);else break}return o.join("/")}function Ve(e){return e.split(/[/\\]/).pop()||e}var Gt=P(()=>{"use strict";ze()});function Ht(e){if(ot(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 Bt=P(()=>{"use strict";D()});function zt(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(o=>o&&Le(o)))throw p.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 i=o[o.length-1];if((0,qt.isJunk)(i))return!1;for(let l of o)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let s=o.slice(0,-1);for(let l of s)if(Qn.some(d=>l.toLowerCase()===d.toLowerCase()))return!1;return!0})}var qt,Qn,Vt=P(()=>{"use strict";D();qt=require("junk"),Qn=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Kt(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw p.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function Yt(e,t){let n=Ht(e);if(!n.valid)throw p.business(n.reason||"Invalid file name");if(ve(e))throw p.business(`File extension not allowed: "${t}"`)}var Wt=P(()=>{"use strict";D();Bt()});var Jt={};gn(Jt,{processFilesForNode:()=>eo});function Xt(e,t=new Set){let n=[],o=v.realpathSync(e);if(t.has(o))return n;t.add(o);let i=v.readdirSync(e);for(let s of i){let l=x.join(e,s),d=v.statSync(l);if(d.isDirectory()){let m=Xt(l,t);n.push(...m)}else d.isFile()&&n.push(l)}return n}async function eo(e,t={},n){if(K()!=="node")throw p.business("processFilesForNode can only be called in Node.js environment.");for(let f of e){let g=x.resolve(f);try{if(v.statSync(g).isDirectory()){let C=v.readdirSync(g).find(O=>xe.has(O));if(C)throw p.business(`"${C}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(C){if(A(C))throw C}}let o=e.flatMap(f=>{let g=x.resolve(f);try{return v.statSync(g).isDirectory()?Xt(g):[g]}catch{throw p.file(`Path does not exist: ${f}`,{filePath:f})}}),i=[...new Set(o)],s=e.map(f=>x.resolve(f)),l=Ut(s.map(f=>{try{return v.statSync(f).isDirectory()?f:x.dirname(f)}catch{return x.dirname(f)}})),d=i.map(f=>{if(l&&l.length>0){let g=x.relative(l,f);if(g&&typeof g=="string"&&!g.startsWith(".."))return g.replace(/\\/g,"/")}return x.basename(f)}),r=jt(d,{flatten:t.pathDetect!==!1}).map(f=>f.path),a=new Set(zt(r));if(a.size===0)return[];let c=[],u=[];for(let f=0;f<i.length;f++)a.has(r[f])&&(c.push(i[f]),u.push(r[f]));let w=[],$=0;if(!n)throw p.config("Platform limits not provided. processFilesForNode requires the limits argument \u2014 pass `ship.getLimits()` result.");for(let f=0;f<c.length;f++){let g=c[f],C=u[f];try{Kt(C,g);let O=v.statSync(g);if(O.size===0)continue;if(Yt(C,g),O.size>n.maxFileSize)throw p.business(`File ${g} is too large. Maximum allowed size is ${n.maxFileSize/(1024*1024)}MB.`);if($+=O.size,$>n.maxTotalSize)throw p.business(`Total deploy size is too large. Maximum allowed is ${n.maxTotalSize/(1024*1024)}MB.`);let H=v.readFileSync(g),{md5:cn}=await De(H);w.push({path:C,content:H,size:H.length,md5:cn})}catch(O){if(A(O))throw O;let H=O instanceof Error?O.message:String(O);throw p.file(`Failed to read file "${g}": ${H}`,{filePath:g})}}if(w.length>n.maxFilesCount)throw p.business(`Too many files to deploy. Maximum allowed is ${n.maxFilesCount} files.`);return w}var v,x,Zt=P(()=>{"use strict";v=R(require("fs"),1),x=R(require("path"),1);D();Gt();ce();Vt();qe();ze();Wt()});var pn=require("commander");var q=require("fs"),Ze=R(require("path"),1);D();var G=require("commander"),Oe=require("yoctocolors");D();var _e=require("zod");var Pe=require("zod"),V={apiUrl:Pe.z.string().url().optional(),token:Pe.z.string().min(1).optional()};ce();var vn=_e.z.object(V).strict(),xn={apiUrl:ee.API_URL,token:ee.TOKEN};function Y(){if(K()!=="node")return{};let e={apiUrl:process.env[ee.API_URL]||void 0,token:process.env[ee.TOKEN]||void 0};try{return vn.parse(e)}catch(t){if(t instanceof _e.z.ZodError){let n=t.issues[0],o=n.path[0],i=(o&&xn[o])??"SHIP environment configuration";throw p.config(`Invalid ${i}: ${n.message}`)}throw p.config("Invalid environment configuration")}}var S=R(require("fs"),1),je=R(require("os"),1),j=R(require("path"),1);D();var L=e=>e.commands.filter(t=>t.name()!=="help"),te=e=>L(e).filter(t=>L(t).length>0),Ln=e=>e.registeredArguments.some(t=>/^(path|file|dir)/i.test(t.name())),In=e=>e.options.filter(t=>/<(file|path|dir)\w*>/i.test(t.flags)).map(t=>t.long??""),ht=e=>e.options.flatMap(t=>[t.long,t.short].filter(Boolean).map(n=>({flag:n,description:t.description}))),ke=e=>te(e).flatMap(t=>L(t).filter(n=>n.options.length>0).map(n=>({path:`${t.name()} ${n.name()}`,cmd:n}))),gt=e=>e.options.flatMap(t=>[t.long,t.short].filter(Boolean).map(n=>({flag:n,description:t.description}))),Ne=e=>[...te(e).flatMap(t=>L(t).filter(Ln).map(n=>n.name())),...In(e)],Fe=e=>`${e} ship shell completion \u2014 GENERATED from the command tree.
2
+ "use strict";var dn=Object.create;var Re=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var fn=Object.getPrototypeOf,hn=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(e&&(t=e(e=0)),t);var gn=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},yn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of un(t))!hn.call(e,i)&&i!==n&&Re(e,i,{get:()=>t[i],enumerable:!(o=mn(t,i))||o.enumerable});return e};var R=(e,t,n)=>(n=e!=null?dn(fn(e)):{},yn(t||!e||!e.__esModule?Re(n,"default",{value:e,enumerable:!0}):n,e));function tt(e){if(!e||typeof e!="string")return;let t=e.trim().toLowerCase();return Object.values($e).includes(t)?t:void 0}function nt(e){if(e==null)return;if(typeof e!="string")throw p.validation("Idempotency key must be a string.");let t=e.trim();if(!t)throw p.validation("Idempotency key must not be empty.");if(t.length>le.MAX_LENGTH)throw p.validation(`Idempotency key must be at most ${le.MAX_LENGTH} characters.`);return t}function bn(e){return typeof e.code=="string"?!0:e instanceof TypeError&&e.message.includes("fetch")}function A(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function ve(e){let t=e.lastIndexOf(".");if(t===-1||t===e.length-1)return!1;let n=e.slice(t+1).toLowerCase();return wn.has(n)}function ot(e){return Cn.test(e)}function Le(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(n=>xe.has(n))}function On(e){return e.startsWith(it.PREFIX)?z.API_KEY:e.startsWith(st.PREFIX)?z.DEPLOY_TOKEN:z.OPAQUE}function at(e){let t=e.charCodeAt(0)===65279?e.slice(1):e,n;try{n=JSON.parse(t)}catch(o){throw p.config(`invalid JSON format in config: ${o.message}`,{filePath:_})}if(n===null||typeof n!="object"||Array.isArray(n))throw p.config(`${_} must contain a JSON object`,{filePath:_})}function lt(e,t,n){if(!e.startsWith(t.PREFIX))throw p.validation(`${n} must start with "${t.PREFIX}"`);if(e.length!==t.TOTAL_LENGTH)throw p.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 p.validation(`${n} must contain ${t.HEX_LENGTH} hexadecimal characters after "${t.PREFIX}" prefix`)}function Rn(e){lt(e,it,"API key")}function An(e){lt(e,st,"Deploy token")}function B(e){switch(On(e)){case z.API_KEY:Rn(e);return;case z.DEPLOY_TOKEN:An(e);return;case z.OPAQUE:if(!e)throw p.validation("Token must be a non-empty string")}}function pt(e){if(!e||e.length>Q.MAX_LENGTH||!Q.PATTERN.test(e))throw p.validation(`Caller must be 1-${Q.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function ct(e){try{let t=new URL(e);if(!["http:","https:"].includes(t.protocol))throw p.validation("API URL must use http:// or https:// protocol");if(t.pathname!=="/"&&t.pathname!=="")throw p.validation("API URL must not contain a path");if(t.search||t.hash)throw p.validation("API URL must not contain query parameters or fragments")}catch(t){throw A(t)?t:p.validation("API URL must be a valid URL")}}function Ie(e){if(e==null)return;if(typeof e!="string")throw p.validation("Password must be a string");let t=e.trim();if(t.length<ae.MIN_LENGTH||t.length>ae.MAX_LENGTH)throw p.validation(`Password must be between ${ae.MIN_LENGTH} and ${ae.MAX_LENGTH} characters`);return t}var et,$e,le,E,I,h,En,Ae,Dn,Sn,p,wn,Tn,So,Cn,xe,Qe,it,st,Q,z,_,rt,pe,dt,ee,mt,bo,F,ut,ae,D=P(()=>{"use strict";et={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},$e={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},le={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};E={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},I={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},h={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},En=new Set([h.Network,h.Cancelled,h.File,h.Config]),Ae={client:new Set([h.Business,h.Cancelled,h.Config,h.File,h.Forbidden,h.NotFound,h.RateLimit,h.Validation]),network:new Set([h.Network]),auth:new Set([h.Authentication])},Dn=new Set(Object.values(h).filter(e=>!En.has(e))),Sn=200;p=class e extends Error{type;status;details;constructor(t,n,o,i){super(n),this.type=t,this.status=o,this.details=i,this.name="ShipError"}toResponse(){let t=this.details,n=this.type===h.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,i,s;try{if(t.headers.get("content-type")?.includes("application/json")){let r=await t.json();if(r&&typeof r=="object"){let a=r;typeof a.message=="string"?o=a.message:typeof a.error=="string"&&(o=a.error),i=a.details,typeof a.error=="string"&&Dn.has(a.error)&&(s=a.error)}}else{let r=(await t.text()).trim();r&&!r.startsWith("<")&&r.length<=Sn&&(o=r)}}catch{}let l=t.headers.get("retry-after");if(l!==null){let m=l.trim(),r=/^\d+$/.test(m)?Number(m):Math.ceil((Date.parse(m)-Date.now())/1e3);if(Number.isFinite(r)&&r>=0){let a=i&&typeof i=="object"?i:{};a.retryAfter===void 0&&(i={...a,retryAfter:r})}}o=o||`${n||"Request"} failed with status ${t.status}`;let d=s??(t.status===401?h.Authentication:t.status===403?h.Forbidden:t.status===429?h.RateLimit:h.Api);return new e(d,o,t.status,i)}static fromFetchError(t,n){if(A(t))return t;let o=n||"Request";return t instanceof Error?t.name==="AbortError"?e.cancelled(`${o} was cancelled`):bn(t)?e.network(`${o} failed: ${t.message}`,{cause:t}):new e(h.Api,`${o} failed: ${t.message}`):new e(h.Api,`${o} failed: Unknown error`)}static validation(t,n){return new e(h.Validation,t,400,n)}static notFound(t,n){let o=n?`${t} ${n} not found`:`${t} not found`;return new e(h.NotFound,o,404)}static forbidden(t,n){return new e(h.Forbidden,t,403,n)}static rateLimit(t="Too many requests",n){return new e(h.RateLimit,t,429,n)}static authentication(t="Authentication required",n){return new e(h.Authentication,t,401,n)}static business(t,n=400,o){return new e(h.Business,t,n,o)}static network(t,n){return new e(h.Network,t,void 0,n)}static cancelled(t,n){return new e(h.Cancelled,t,void 0,n)}static file(t,n){return new e(h.File,t,void 0,n)}static config(t,n){return new e(h.Config,t,void 0,n)}static api(t,n=500,o){return new e(h.Api,t,n,o)}static maintenance(t,n){return new e(h.Maintenance,t,503,n)}isClientError(){return Ae.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Ae.network.has(this.type)}isAuthError(){return Ae.auth.has(this.type)}isType(t){return this.type===t}};wn=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"]);Tn=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],So=Tn.map(e=>`.${e}`).join(","),Cn=/[\x00-\x1f\x7f#?%\\<>"]/;xe=new Set(["node_modules","package.json"]);Qe={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},it={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},st={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},Q={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},z={API_KEY:Qe.API_KEY,DEPLOY_TOKEN:Qe.TOKEN,OPAQUE:"opaque"};_="ship.json",rt={rewrites:[{source:"/(.*)",destination:"/index.html"}]},pe={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};dt="https://api.shipstatic.com",ee={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},mt="https://my.shipstatic.com/api-key",bo=4320*60,F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ut=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,ae={MIN_LENGTH:6,MAX_LENGTH:128}});function $n(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function K(){return ft||$n()}var ft,ce=P(()=>{"use strict";ft=null});async function Yn(e){let t=(await import("spark-md5")).default,n=new t.ArrayBuffer,o=2097152;for(let i=0;i<e.size;i+=o){let s=Math.min(i+o,e.size);n.append(await e.slice(i,s).arrayBuffer())}return{md5:n.end()}}async function Wn(e){let{createHash:t}=await import("crypto"),n=t("md5");return n.update(e),{md5:n.digest("hex")}}async function Xn(e){let{createHash:t}=await import("crypto"),{createReadStream:n}=await import("fs");return new Promise((o,i)=>{let s=t("md5"),l=n(e);l.on("error",d=>i(p.file(`Failed to read file for MD5: ${d.message}`,{filePath:e}))),l.on("data",d=>s.update(d)),l.on("end",()=>o({md5:s.digest("hex")}))})}async function De(e){if(e instanceof Blob)return Yn(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Wn(e);if(typeof e=="string")return Xn(e);throw p.business("Invalid input for MD5 calculation")}var qe=P(()=>{"use strict";D()});function Ut(e){if(!e||e.length===0)return"";let t=e.filter(s=>s&&typeof s=="string").map(s=>s.replace(/\\/g,"/"));if(t.length===0)return"";if(t.length===1)return t[0];let n=t.map(s=>s.split("/").filter(Boolean)),o=[],i=Math.min(...n.map(s=>s.length));for(let s=0;s<i;s++){let l=n[0][s];if(n.every(d=>d[s]===l))o.push(l);else break}return o.join("/")}function be(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ze=P(()=>{"use strict"});function jt(e,t={}){if(t.flatten===!1)return e.map(o=>({path:be(o),name:Ve(o)}));let n=Zn(e);return e.map(o=>{let i=be(o);if(n){let s=n.endsWith("/")?n:`${n}/`;i.startsWith(s)&&(i=i.substring(s.length))}return i||(i=Ve(o)),{path:i,name:Ve(o)}})}function Zn(e){if(!e.length)return"";let n=e.map(s=>be(s)).map(s=>s.split("/")),o=[],i=Math.min(...n.map(s=>s.length));for(let s=0;s<i-1;s++){let l=n[0][s];if(n.every(d=>d[s]===l))o.push(l);else break}return o.join("/")}function Ve(e){return e.split(/[/\\]/).pop()||e}var Gt=P(()=>{"use strict";ze()});function Ht(e){if(ot(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 Bt=P(()=>{"use strict";D()});function zt(e,t){if(!e||e.length===0)return[];if(!t?.allowUnbuilt&&e.find(o=>o&&Le(o)))throw p.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 i=o[o.length-1];if((0,qt.isJunk)(i))return!1;for(let l of o)if(l!==".well-known"&&(l.startsWith(".")||l.length>255))return!1;let s=o.slice(0,-1);for(let l of s)if(Qn.some(d=>l.toLowerCase()===d.toLowerCase()))return!1;return!0})}var qt,Qn,Vt=P(()=>{"use strict";D();qt=require("junk"),Qn=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Kt(e,t){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw p.business(`Security error: Unsafe file path "${e}" for file: ${t}`)}function Yt(e,t){let n=Ht(e);if(!n.valid)throw p.business(n.reason||"Invalid file name");if(ve(e))throw p.business(`File extension not allowed: "${t}"`)}var Wt=P(()=>{"use strict";D();Bt()});var Jt={};gn(Jt,{processFilesForNode:()=>eo});function Xt(e,t=new Set){let n=[],o=v.realpathSync(e);if(t.has(o))return n;t.add(o);let i=v.readdirSync(e);for(let s of i){let l=x.join(e,s),d=v.statSync(l);if(d.isDirectory()){let m=Xt(l,t);n.push(...m)}else d.isFile()&&n.push(l)}return n}async function eo(e,t={},n){if(K()!=="node")throw p.business("processFilesForNode can only be called in Node.js environment.");for(let f of e){let g=x.resolve(f);try{if(v.statSync(g).isDirectory()){let T=v.readdirSync(g).find(O=>xe.has(O));if(T)throw p.business(`"${T}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(T){if(A(T))throw T}}let o=e.flatMap(f=>{let g=x.resolve(f);try{return v.statSync(g).isDirectory()?Xt(g):[g]}catch{throw p.file(`Path does not exist: ${f}`,{filePath:f})}}),i=[...new Set(o)],s=e.map(f=>x.resolve(f)),l=Ut(s.map(f=>{try{return v.statSync(f).isDirectory()?f:x.dirname(f)}catch{return x.dirname(f)}})),d=i.map(f=>{if(l&&l.length>0){let g=x.relative(l,f);if(g&&typeof g=="string"&&!g.startsWith(".."))return g.replace(/\\/g,"/")}return x.basename(f)}),r=jt(d,{flatten:t.pathDetect!==!1}).map(f=>f.path),a=new Set(zt(r));if(a.size===0)return[];let c=[],u=[];for(let f=0;f<i.length;f++)a.has(r[f])&&(c.push(i[f]),u.push(r[f]));let w=[],$=0;if(!n)throw p.config("Platform limits not provided. processFilesForNode requires the limits argument \u2014 pass `ship.getLimits()` result.");for(let f=0;f<c.length;f++){let g=c[f],T=u[f];try{Kt(T,g);let O=v.statSync(g);if(O.size===0)continue;if(Yt(T,g),O.size>n.maxFileSize)throw p.business(`File ${g} is too large. Maximum allowed size is ${n.maxFileSize/(1024*1024)}MB.`);if($+=O.size,$>n.maxTotalSize)throw p.business(`Total deploy size is too large. Maximum allowed is ${n.maxTotalSize/(1024*1024)}MB.`);let H=v.readFileSync(g),{md5:cn}=await De(H);w.push({path:T,content:H,size:H.length,md5:cn})}catch(O){if(A(O))throw O;let H=O instanceof Error?O.message:String(O);throw p.file(`Failed to read file "${g}": ${H}`,{filePath:g})}}if(w.length>n.maxFilesCount)throw p.business(`Too many files to deploy. Maximum allowed is ${n.maxFilesCount} files.`);return w}var v,x,Zt=P(()=>{"use strict";v=R(require("fs"),1),x=R(require("path"),1);D();Gt();ce();Vt();qe();ze();Wt()});var pn=require("commander");var q=require("fs"),Ze=R(require("path"),1);D();var G=require("commander"),Oe=require("yoctocolors");D();var _e=require("zod");var Pe=require("zod"),V={apiUrl:Pe.z.string().url().optional(),token:Pe.z.string().min(1).optional()};ce();var vn=_e.z.object(V).strict(),xn={apiUrl:ee.API_URL,token:ee.TOKEN};function Y(){if(K()!=="node")return{};let e={apiUrl:process.env[ee.API_URL]||void 0,token:process.env[ee.TOKEN]||void 0};try{return vn.parse(e)}catch(t){if(t instanceof _e.z.ZodError){let n=t.issues[0],o=n.path[0],i=(o&&xn[o])??"SHIP environment configuration";throw p.config(`Invalid ${i}: ${n.message}`)}throw p.config("Invalid environment configuration")}}var S=R(require("fs"),1),je=R(require("os"),1),j=R(require("path"),1);D();var L=e=>e.commands.filter(t=>t.name()!=="help"),te=e=>L(e).filter(t=>L(t).length>0),Ln=e=>e.registeredArguments.some(t=>/^(path|file|dir)/i.test(t.name())),In=e=>e.options.filter(t=>/<(file|path|dir)\w*>/i.test(t.flags)).map(t=>t.long??""),ht=e=>e.options.flatMap(t=>[t.long,t.short].filter(Boolean).map(n=>({flag:n,description:t.description}))),ke=e=>te(e).flatMap(t=>L(t).filter(n=>n.options.length>0).map(n=>({path:`${t.name()} ${n.name()}`,cmd:n}))),gt=e=>e.options.flatMap(t=>[t.long,t.short].filter(Boolean).map(n=>({flag:n,description:t.description}))),Ne=e=>[...te(e).flatMap(t=>L(t).filter(Ln).map(n=>n.name())),...In(e)],Fe=e=>`${e} ship shell completion \u2014 GENERATED from the command tree.
3
3
  ${e} Do not edit: rendered by src/node/cli/completions.ts at install time,
4
4
  ${e} so this file always matches the binary that wrote it.
5
5
  `;function Pn(e){let t=te(e).map(o=>` "${o.name()}")
@@ -110,18 +110,18 @@ fi
110
110
  `}var me=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"\\'");function kn(e){let t=[];t.push("# Top-level commands");for(let o of L(e))t.push(`complete -c ship -f -n '__fish_use_subcommand' -a '${o.name()}' -d '${me(o.description())}'`);t.push("","# Global options");for(let o of e.options){let i=o.long?.replace(/^--/,"");if(!i)continue;let s=/<(file|path|dir)\w*>/i.test(o.flags)?" -r":o.required||o.optional?" -x":"";t.push(`complete -c ship -l ${i} -d '${me(o.description)}'${s}`)}for(let o of te(e)){t.push("",`# ${o.name()} subcommands`);for(let i of L(o))t.push(`complete -c ship -f -n '__fish_seen_subcommand_from ${o.name()}' -a '${i.name()}' -d '${me(i.description())}'`)}for(let{path:o,cmd:i}of ke(e)){let[s,l]=o.split(" ");t.push("",`# ${o} options`);for(let d of i.options){let m=d.long?.replace(/^--/,"");if(!m)continue;let r=d.required||d.optional?" -x":"";t.push(`complete -c ship -l ${m} -d '${me(d.description)}'${r} -n '__fish_seen_subcommand_from ${s}; and __fish_seen_subcommand_from ${l}'`)}}let n=Ne(e);return t.push("","# Native file completion where a filesystem argument is expected","function __ship_needs_file"," set -l cmd (commandline -opc)"," if test (count $cmd) -ge 2"," set -l prev $cmd[-1]",` if contains -- "$prev" ${n.map(o=>`'${o}'`).join(" ")}`," return 0"," end"," end"," return 1","end","complete -c ship -F -n '__ship_needs_file'"),`${Fe("#")}
111
111
  ${t.join(`
112
112
  `)}
113
- `}function yt(e,t){switch(t){case"bash":return Pn(e);case"zsh":return _n(e);case"fish":return kn(e)}}var Me=R(require("columnify"),1),y=require("yoctocolors"),Et=["isCreate","claim"],T=(e,t,n)=>n?t:e(t),Nn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Fn=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e,W=e=>Fn(e).replace(/\.$/,""),k=(e,t,n)=>{console.log(t?`${JSON.stringify({success:e},null,2)}
114
- `:`${T(y.green,W(e),n)}
113
+ `}function yt(e,t){switch(t){case"bash":return Pn(e);case"zsh":return _n(e);case"fish":return kn(e)}}var Me=R(require("columnify"),1),y=require("yoctocolors"),Et=["isCreate","claim"],C=(e,t,n)=>n?t:e(t),Nn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Fn=e=>/^[A-Z][a-z]/.test(e)?e.charAt(0).toLowerCase()+e.slice(1):e,W=e=>Fn(e).replace(/\.$/,""),k=(e,t,n)=>{console.log(t?`${JSON.stringify({success:e},null,2)}
114
+ `:`${C(y.green,W(e),n)}
115
115
  `)},X=(e,t,n)=>{if(t)console.log(`${JSON.stringify({warning:e},null,2)}
116
- `);else{let o=T(s=>(0,y.inverse)((0,y.yellow)(s)),`${T(y.hidden,"[",n)}warning${T(y.hidden,"]",n)}`,n),i=T(y.yellow,W(e),n);console.log(`${o} ${i}
116
+ `);else{let o=C(s=>(0,y.inverse)((0,y.yellow)(s)),`${C(y.hidden,"[",n)}warning${C(y.hidden,"]",n)}`,n),i=C(y.yellow,W(e),n);console.log(`${o} ${i}
117
117
  `)}},M=(e,t,n)=>{if(t)console.log(`${JSON.stringify({info:e},null,2)}
118
- `);else{let o=T(s=>(0,y.inverse)((0,y.blue)(s)),`${T(y.hidden,"[",n)}info${T(y.hidden,"]",n)}`,n),i=T(y.blue,W(e),n);console.log(`${o} ${i}
118
+ `);else{let o=C(s=>(0,y.inverse)((0,y.blue)(s)),`${C(y.hidden,"[",n)}info${C(y.hidden,"]",n)}`,n),i=C(y.blue,W(e),n);console.log(`${o} ${i}
119
119
  `)}};function J(e,t,n){if(t&&typeof e!="string"){console.error(`${JSON.stringify(e.toResponse(),null,2)}
120
- `);return}let o=T(l=>(0,y.inverse)((0,y.red)(l)),`${T(y.hidden,"[",n)}error${T(y.hidden,"]",n)}`,n),i=typeof e=="string"?e:e.message,s=T(y.red,W(i),n);console.error(`${o} ${s}
121
- `)}var Mn=(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/,T(y.hidden,"T",n)).replace(/Z$/,T(y.hidden,"Z",n)):o},Ue=(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 Mn(t,n,o);if(e==="size"&&typeof t=="number"){let i=t/1048576;return i>=1?`${i.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"}if(Nn(t)){let i=Object.entries(t);return i.length===0?"-":i.map(([s,l])=>`${s}=${Ue(s,l,n,o)}`).join(", ")}return String(t)},ne=(e,t,n,o)=>{if(!e||e.length===0)return"";let i=e[0],s=t||Object.keys(i).filter(m=>i[m]!==void 0&&!Et.includes(m)),l=e.map(m=>{let r=m,a={};return s.forEach(c=>{c in r&&r[c]!==void 0&&(a[c]=Ue(c,r[c],"table",n))}),a});return`${(0,Me.default)(l,{columnSplitter:" ",columns:s,config:s.reduce((m,r)=>(m[r]={headingTransform:a=>T(y.dim,o?.[a]||a,n)},m),{})}).split(`
120
+ `);return}let o=C(l=>(0,y.inverse)((0,y.red)(l)),`${C(y.hidden,"[",n)}error${C(y.hidden,"]",n)}`,n),i=typeof e=="string"?e:e.message,s=C(y.red,W(i),n);console.error(`${o} ${s}
121
+ `)}var Mn=(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/,C(y.hidden,"T",n)).replace(/Z$/,C(y.hidden,"Z",n)):o},Ue=(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 Mn(t,n,o);if(e==="size"&&typeof t=="number"){let i=t/1048576;return i>=1?`${i.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"}if(Nn(t)){let i=Object.entries(t);return i.length===0?"-":i.map(([s,l])=>`${s}=${Ue(s,l,n,o)}`).join(", ")}return String(t)},ne=(e,t,n,o)=>{if(!e||e.length===0)return"";let i=e[0],s=t||Object.keys(i).filter(m=>i[m]!==void 0&&!Et.includes(m)),l=e.map(m=>{let r=m,a={};return s.forEach(c=>{c in r&&r[c]!==void 0&&(a[c]=Ue(c,r[c],"table",n))}),a});return`${(0,Me.default)(l,{columnSplitter:" ",columns:s,config:s.reduce((m,r)=>(m[r]={headingTransform:a=>C(y.dim,o?.[a]||a,n)},m),{})}).split(`
122
122
  `).map(m=>m.replace(/\0/g,"").replace(/\s+$/,"")).join(`
123
123
  `)}
124
- `},U=(e,t)=>{let n=Object.entries(e).filter(([s,l])=>Et.includes(s)?!1:l!==void 0);if(n.length===0)return"";let o=n.map(([s,l])=>({property:`${s}:`,value:Ue(s,l,"details",t)}));return`${(0,Me.default)(o,{columnSplitter:" ",showHeaders:!1,config:{property:{dataTransform:s=>T(y.dim,s,t)}}}).split(`
124
+ `},U=(e,t)=>{let n=Object.entries(e).filter(([s,l])=>Et.includes(s)?!1:l!==void 0);if(n.length===0)return"";let o=n.map(([s,l])=>({property:`${s}:`,value:Ue(s,l,"details",t)}));return`${(0,Me.default)(o,{columnSplitter:" ",showHeaders:!1,config:{property:{dataTransform:s=>C(y.dim,s,t)}}}).split(`
125
125
  `).map(s=>s.replace(/\0/g,"")).join(`
126
126
  `)}
127
127
  `};function Dt(){let e=process.env.SHELL||"";return e.includes("bash")?"bash":e.includes("zsh")?"zsh":e.includes("fish")?"fish":null}function St(e,t){switch(e){case"bash":return{completionFile:j.join(t,".ship_completion.bash"),profileFile:j.join(t,".bash_profile")};case"zsh":return{completionFile:j.join(t,".ship_completion.zsh"),profileFile:j.join(t,".zshrc")};case"fish":return{completionFile:j.join(t,".config/fish/completions/ship.fish"),profileFile:null}}}function bt(e,t={}){let{json:n,noColor:o}=t,i=Dt(),s=je.homedir();if(!i)throw p.config(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`);let l=St(i,s),d=yt(e,i);try{if(i==="fish"){let r=j.dirname(l.completionFile);S.existsSync(r)||S.mkdirSync(r,{recursive:!0}),S.writeFileSync(l.completionFile,d),k("fish completion installed successfully",n,o),M("please restart your shell to apply the changes",n,o);return}S.writeFileSync(l.completionFile,d);let m=`# ship
@@ -131,10 +131,10 @@ source '${l.completionFile}'
131
131
  `)?`
132
132
  `:"";S.appendFileSync(l.profileFile,a+m)}}else S.writeFileSync(l.profileFile,m);k(`completion script installed for ${i}`,n,o),X(`run "source ${l.profileFile}" or restart your shell`,n,o)}}catch(m){if(A(m))throw m;let r=m instanceof Error?m.message:String(m);throw p.file(`could not install completion script: ${r}`)}}function wt(e={}){let{json:t,noColor:n}=e,o=Dt(),i=je.homedir();if(!o)throw p.config(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`);let s=St(o,i);try{if(o==="fish"){S.existsSync(s.completionFile)?(S.unlinkSync(s.completionFile),k("fish completion uninstalled successfully",t,n)):X("fish completion was not installed",t,n),M("please restart your shell to apply the changes",t,n);return}if(S.existsSync(s.completionFile)&&S.unlinkSync(s.completionFile),!s.profileFile)return;if(!S.existsSync(s.profileFile))throw p.config("profile file not found");let d=S.readFileSync(s.profileFile,"utf-8").split(`
133
133
  `),m=[],r=0,a=!1;for(;r<d.length;)if(d[r].trim()==="# ship"){for(a=!0,r++;r<d.length&&d[r].trim()!=="# ship end";)r++;r<d.length&&r++}else m.push(d[r]),r++;if(a)S.writeFileSync(s.profileFile,m.join(`
134
- `)),k(`completion script uninstalled for ${o}`,t,n),X(`run "source ${s.profileFile}" or restart your shell`,t,n);else throw p.config("completion was not found in profile")}catch(l){if(A(l))throw l;let d=l instanceof Error?l.message:String(l);throw p.file(`could not uninstall completion script: ${d}`)}}var Z=require("fs"),At=require("os"),$t=require("path"),vt=require("readline/promises");D();var ge=require("yoctocolors");var fe=require("fs"),Ot=require("os"),Rt=require("path");D();var Ge=require("zod");var Un=Ge.z.object(V).strict(),jn=()=>(0,Rt.join)((0,Ot.homedir)(),".shiprc"),Ct=e=>e instanceof Error?e.message:String(e);function ue(e){let t;try{t=(0,fe.readFileSync)(e,"utf-8")}catch(o){throw p.config(`Failed to read ship config (${e}): ${Ct(o)}`)}if(!t.trim())return{};let n;try{n=JSON.parse(t)}catch(o){throw p.config(`Invalid config in ${e}: ${Ct(o)}`)}if(n===null||typeof n!="object"||Array.isArray(n))throw p.config(`Invalid config in ${e}: expected a JSON object`);return n}function Tt(e,t){try{return Un.parse(e)}catch(n){if(n instanceof Ge.z.ZodError){let o=n.issues[0];if(o.code==="unrecognized_keys"){let s=o.keys.filter(l=>l==="apiKey"||l==="deployToken");if(s.length>0){let l=s.map(d=>`"${d}"`).join(" and ");throw p.config(`Invalid config in ${t}: ${l} ${s.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let i=o.path.length>0?` at ${o.path.join(".")}`:"";throw p.config(`Invalid config in ${t}${i}: ${o.message}`)}throw p.config(`Invalid config in ${t}`)}}function he(e){let t=e||void 0;if(t)return Tt(ue(t),t);let n=jn();return(0,fe.existsSync)(n)?Tt(ue(n),n):{}}var He=Object.keys(V),Gn=()=>(0,$t.join)((0,At.homedir)(),".shiprc");function Hn(e){return e.length<13?"...":`${e.slice(0,9)}...${e.slice(-4)}`}function Bn(e){if(!(0,Z.existsSync)(e))return{};try{return ue(e)}catch(t){throw A(t)?p.config(`${t.message} \u2014 the file was left unchanged`):t}}async function xt(e={}){let{noColor:t}=e,n=e.configFile||Gn(),o=u=>t?u:(0,ge.dim)(u),i=u=>t?u:(0,ge.green)(u),s=Bn(n),l=typeof s.token=="string"?s.token:void 0,d=Object.keys(s).filter(u=>!He.includes(u)),m=(0,vt.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${o("Create a free API key at")} ${mt}`),console.log("");let r=l?` Token (${o(Hn(l))}): `:" Token: ",a;try{a=(await m.question(r)).trim()}finally{m.close()}a&&B(a);let c={};for(let u of He)s[u]!==void 0&&(c[u]=s[u]);a&&(c.token=a),d.length>0&&X(`dropped ${d.map(u=>`"${u}"`).join(", ")} \u2014 a ship config holds only ${He.join(" and ")}`,!1,t),(0,Z.writeFileSync)(n,`${JSON.stringify(c,null,2)}
134
+ `)),k(`completion script uninstalled for ${o}`,t,n),X(`run "source ${s.profileFile}" or restart your shell`,t,n);else throw p.config("completion was not found in profile")}catch(l){if(A(l))throw l;let d=l instanceof Error?l.message:String(l);throw p.file(`could not uninstall completion script: ${d}`)}}var Z=require("fs"),At=require("os"),$t=require("path"),vt=require("readline/promises");D();var ge=require("yoctocolors");var fe=require("fs"),Ot=require("os"),Rt=require("path");D();var Ge=require("zod");var Un=Ge.z.object(V).strict(),jn=()=>(0,Rt.join)((0,Ot.homedir)(),".shiprc"),Tt=e=>e instanceof Error?e.message:String(e);function ue(e){let t;try{t=(0,fe.readFileSync)(e,"utf-8")}catch(o){throw p.config(`Failed to read ship config (${e}): ${Tt(o)}`)}if(!t.trim())return{};let n;try{n=JSON.parse(t)}catch(o){throw p.config(`Invalid config in ${e}: ${Tt(o)}`)}if(n===null||typeof n!="object"||Array.isArray(n))throw p.config(`Invalid config in ${e}: expected a JSON object`);return n}function Ct(e,t){try{return Un.parse(e)}catch(n){if(n instanceof Ge.z.ZodError){let o=n.issues[0];if(o.code==="unrecognized_keys"){let s=o.keys.filter(l=>l==="apiKey"||l==="deployToken");if(s.length>0){let l=s.map(d=>`"${d}"`).join(" and ");throw p.config(`Invalid config in ${t}: ${l} ${s.length>1?"are":"is"} no longer supported \u2014 the key is now "token". Run \`ship config\` to rewrite it.`)}}let i=o.path.length>0?` at ${o.path.join(".")}`:"";throw p.config(`Invalid config in ${t}${i}: ${o.message}`)}throw p.config(`Invalid config in ${t}`)}}function he(e){let t=e||void 0;if(t)return Ct(ue(t),t);let n=jn();return(0,fe.existsSync)(n)?Ct(ue(n),n):{}}var He=Object.keys(V),Gn=()=>(0,$t.join)((0,At.homedir)(),".shiprc");function Hn(e){return e.length<13?"...":`${e.slice(0,9)}...${e.slice(-4)}`}function Bn(e){if(!(0,Z.existsSync)(e))return{};try{return ue(e)}catch(t){throw A(t)?p.config(`${t.message} \u2014 the file was left unchanged`):t}}async function xt(e={}){let{noColor:t}=e,n=e.configFile||Gn(),o=u=>t?u:(0,ge.dim)(u),i=u=>t?u:(0,ge.green)(u),s=Bn(n),l=typeof s.token=="string"?s.token:void 0,d=Object.keys(s).filter(u=>!He.includes(u)),m=(0,vt.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${o("Create a free API key at")} ${mt}`),console.log("");let r=l?` Token (${o(Hn(l))}): `:" Token: ",a;try{a=(await m.question(r)).trim()}finally{m.close()}a&&B(a);let c={};for(let u of He)s[u]!==void 0&&(c[u]=s[u]);a&&(c.token=a),d.length>0&&X(`dropped ${d.map(u=>`"${u}"`).join(", ")} \u2014 a ship config holds only ${He.join(" and ")}`,!1,t),(0,Z.writeFileSync)(n,`${JSON.stringify(c,null,2)}
135
135
  `,{mode:384}),(0,Z.chmodSync)(n,384),console.log(`
136
136
  ${i("saved to")} ${o(n)}
137
- `)}D();D();D();var ye=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 i=Array.from(o);for(let s of i)try{s(...n)}catch(l){o.delete(s),t!=="error"&&setTimeout(()=>{let d=l instanceof Error?l:new Error(String(l));this.emit("error",d,String(t))},0)}}};D();D();function oe(e){if(e==null)return;if(e.length===0)return e;if(e.length>F.MAX_COUNT)throw p.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let t=e.map((o,i)=>{if(typeof o!="string")throw p.validation(`Label at index ${i} must be a string`);let s=o.trim().toLowerCase();if(s.length<F.MIN_LENGTH)throw p.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(s.length>F.MAX_LENGTH)throw p.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!ut.test(s))throw p.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return s}),n=[...new Set(t)];if(n.length!==t.length)throw p.validation("Duplicate labels are not allowed");return n}async function Lt(e){let t=e.find(i=>i.path===_||i.path===`/${_}`);if(!t)return;let n=t.content,o=typeof n.text=="function"?await n.text():t.content.toString("utf8");at(o)}var qn=3e4,It=3e5,zn=3e5,Vn=It+zn,Kn="sdk";function Be(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 Ee=class extends ye{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||dt,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??qn,this.deployTimeout=n.timeout??It,this.deployBuildTimeout=n.timeout??Vn,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,i,s=this.timeout){let l=()=>{};try{let d=await this.mergeHeaders(o.headers),m=this.createTimeoutSignal(o.signal,s);l=m.cleanup;let r={...o,headers:d,credentials:this.session&&!d.Authorization?"include":void 0,signal:m.signal};this.emit("request",n,r);let a=await this.fetch(n,r);if(l(),!a.ok)throw await p.fromHttpResponse(a,i);return this.emit("response",this.safeClone(a),n),{data:await this.parseResponse(this.safeClone(a)),status:a.status}}catch(d){l();let m=p.fromFetchError(d,i);throw this.emit("error",m,n),m}}async request(n,o,i,s){let{data:l}=await this.executeRequest(n,o,i,s);return l}async requestWithStatus(n,o,i){return this.executeRequest(n,o,i)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{[Q.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n,o=this.timeout){let i=new AbortController,s=setTimeout(()=>i.abort(),o);if(n){let l=()=>i.abort();n.addEventListener("abort",l),n.aborted&&i.abort()}return{signal:i.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 p.business("No files to deploy");for(let r of n)if(!r.md5)throw p.file(`MD5 checksum missing for file: ${r.path}`,{filePath:r.path});Ie(o.password);let i=nt(o.idempotencyKey),s=oe(o.labels);await Lt(n);let l=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:d,headers:m}=await this.createDeployBody(n,{labels:s,via:o.via??Kn,password:o.password,flags:l,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:d,headers:i?{...m,[le.HEADER]:i}:m,signal:o.signal||null},"Deploy",o.build||o.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(n){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}${Be(n)}`,{method:"GET"},"List deployments")}async getDeployment(n){return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(n,o){let i=oe(o);return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:i})},"Update deployment labels")}async deleteDeployment(n){return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"DELETE"},"Delete deployment")}async setDomain(n,o,i){let s=oe(i),l={};o&&(l.deployment=o),s!==void 0&&(l.labels=s);let{data:d,status:m}=await this.requestWithStatus(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"Set domain");return{...d,isCreate:m===201}}async listDomains(n){return this.request(`${this.apiUrl}${E.DOMAINS}${Be(n)}`,{method:"GET"},"List domains")}async getDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"GET"},"Get domain")}async deleteDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN_VERIFY(encodeURIComponent(n))}`,{method:"POST"},"Verify domain")}async getDomainDns(n){return this.request(`${this.apiUrl}${E.DOMAIN_DNS(encodeURIComponent(n))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(n){return this.request(`${this.apiUrl}${E.DOMAIN_RECORDS(encodeURIComponent(n))}`,{method:"GET"},"Get domain records")}async getDomainShare(n){return this.request(`${this.apiUrl}${E.DOMAIN_SHARE(encodeURIComponent(n))}`,{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 i=oe(o),s={};return n!==void 0&&(s.ttl=n),i!==void 0&&(s.labels=i),this.request(`${this.apiUrl}${E.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},"Create token")}async listTokens(n){return this.request(`${this.apiUrl}${E.TOKENS}${Be(n)}`,{method:"GET"},"List tokens")}async deleteToken(n){return this.request(`${this.apiUrl}${E.TOKEN(encodeURIComponent(n))}`,{method:"DELETE"},"Delete token")}async getToken(n){return this.request(`${this.apiUrl}${E.TOKEN(encodeURIComponent(n))}`,{method:"GET"},"Get 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 this.request(`${this.apiUrl}${E.PING}`,{method:"GET"},"Ping")}async checkSPA(n,o={}){let i=n.find(m=>m.path===pe.INDEX_FILE||m.path===`/${pe.INDEX_FILE}`);if(!i||i.size>pe.MAX_INDEX_BYTES)return!1;let s;if(typeof Buffer<"u"&&Buffer.isBuffer(i.content))s=i.content.toString("utf-8");else if(typeof Blob<"u"&&i.content instanceof Blob)s=await i.content.text();else if(typeof File<"u"&&i.content instanceof File)s=await i.content.text();else return!1;let l={files:n.map(m=>m.path),index:s};return(await this.request(`${this.apiUrl}${E.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}};D();D();qe();async function Jn(){let e=JSON.stringify(rt,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:_,content:t,size:e.length,md5:n}}async function Pt(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(o=>o.path===_))return e;try{if(await t.checkSPA(e,n)){let i=await Jn();return[...e,i]}}catch{}return e}function _t(e){let{getApi:t,ensureInit:n,processInput:o}=e;return{upload:async(i,s={})=>{if(await n(),!o)throw p.config("processInput function is not provided.");let l=t(),d=await o(i,s);return d=await Pt(d,l,s),l.deploy(d,s)},list:async i=>(await n(),t().listDeployments(i)),get:async i=>(await n(),t().getDeployment(i)),set:async(i,s)=>(await n(),t().updateDeploymentLabels(i,s.labels)),delete:async i=>(await n(),t().deleteDeployment(i))}}function kt(e){let{getApi:t,ensureInit:n}=e;return{set:async(o,i={})=>(await n(),t().setDomain(o,i.deployment,i.labels)),list:async o=>(await n(),t().listDomains(o)),get:async o=>(await n(),t().getDomain(o)),delete:async o=>(await n(),t().deleteDomain(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 Nt(e){let{getApi:t,ensureInit:n}=e;return{get:async()=>(await n(),t().getAccount())}}function Ft(e){let{getApi:t,ensureInit:n}=e;return{create:async(o={})=>(await n(),t().createToken(o.ttl,o.labels)),list:async o=>(await n(),t().listTokens(o)),get:async o=>(await n(),t().getToken(o)),delete:async o=>(await n(),t().deleteToken(o))}}var Se=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&&pt(t.caller),t.token&&t.session)throw p.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(B(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ee({...t,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=_t({...n,processInput:(o,i)=>this.processInput(o,i)}),this.domains=kt(n),this.account=Nt(n),this.tokens=Ft(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 p.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw p.business("Invalid token provided. Token must be a non-empty string.");B(t),this.credential=t;return}if(typeof t!="function")throw p.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 p.authentication("Token provider returned no token.");if(typeof t!="string")throw p.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};ce();D();async function Mt(e,t={}){let{FormData:n,File:o}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),{labels:s,via:l,password:d,flags:m,captcha:r}=t,a=new n,c=[];for(let f of e){if(!Buffer.isBuffer(f.content)&&!(typeof Blob<"u"&&f.content instanceof Blob))throw p.file(`Unsupported file.content type for Node.js: ${f.path}`,{filePath:f.path});if(!f.md5)throw p.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});let g=new o([f.content],f.path,{type:"application/octet-stream"});a.append(I.FILES,g),c.push(f.md5)}a.append(I.CHECKSUMS,JSON.stringify(c)),s&&s.length>0&&a.append(I.LABELS,JSON.stringify(s)),l&&a.append(I.VIA,l),d&&a.append(I.PASSWORD,d),m?.build&&a.append(I.BUILD,"true"),m?.prerender&&a.append(I.PRERENDER,"true"),m?.spa&&a.append(I.SPA,"true"),r&&a.append(I.CAPTCHA,r);let u=new i(a),w=[];for await(let f of u.encode())w.push(Buffer.from(f));let $=Buffer.concat(w);return{body:$.buffer.slice($.byteOffset,$.byteOffset+$.byteLength),headers:{"Content-Type":u.contentType,"Content-Length":Buffer.byteLength($).toString()}}}var we=class extends Se{constructor(t={}){if(K()!=="node")throw p.business("Node.js Ship class can only be used in Node.js environment.");let n=Y();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(s=>typeof s=="string"))throw p.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw p.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(Zt(),Jt));return i(o,n,this.platformLimits??void 0)}getDeployBodyCreator(){return Mt}};function Ke(e,t,n){return{apiUrl:e.apiUrl||t.apiUrl||n.apiUrl,token:e.token||t.token||n.token}}function Qt(e={}){return new we(Ke(e,Y(),he(e.config)))}D();function en(e){return A(e)?e:e instanceof Error?p.business(e.message):p.business(String(e??"Unknown error"))}function tn(e,t){return e.isAuthError()?t?.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.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}D();var Xe=(e,t)=>`https://setup.shipstatic.com/${e}/${t}`;function Ye(e,t){return e[t]}var to={[et.DELETING]:"served until cleanup completes"},no={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function oo(e,t){let{operation:n,resource:o}=t;if(!o||e===null||typeof e!="object")return null;let i=n==="set"?Ye(e,"isCreate")?"created":"updated":no[n];if(!i)return null;let s=Ye(e,o);if(typeof s!="string")return null;let l=Ye(e,"status"),d=typeof l=="string"?to[l]:void 0;return`${s} ${o} ${d?`${l} \u2014 ${d}`:i}`}function io(e,t){let{noColor:n}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let o=["deployment","labels","files","size","created","via"];console.log(ne(e.deployments,o,n)),Je(e.cursor,n)}function Je(e,t){e&&M(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function so(e,t){let{noColor:n}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let o=["domain","deployment","labels","linked","links","created"];console.log(ne(e.domains,o,n)),Je(e.cursor,n)}function nn(e,t){let{noColor:n}=t,{_dnsRecords:o,_shareHash:i,isCreate:s,...l}=e;o&&o.length>0&&(console.log(),M("DNS records to configure:",!1,n),o.forEach(d=>{console.log(` ${d.type}: ${d.name} \u2192 ${d.value}`)})),i&&(console.log(),M(`Setup instructions: ${Xe(i,e.domain)}`,!1,n)),console.log(U(l,n))}function We(e,t){let{noColor:n}=t;console.log(U(e,n));let o=e.claim;if(o){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:
137
+ `)}D();D();D();var ye=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 i=Array.from(o);for(let s of i)try{s(...n)}catch(l){o.delete(s),t!=="error"&&setTimeout(()=>{let d=l instanceof Error?l:new Error(String(l));this.emit("error",d,String(t))},0)}}};D();D();function oe(e){if(e==null)return;if(e.length===0)return e;if(e.length>F.MAX_COUNT)throw p.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let t=e.map((o,i)=>{if(typeof o!="string")throw p.validation(`Label at index ${i} must be a string`);let s=o.trim().toLowerCase();if(s.length<F.MIN_LENGTH)throw p.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(s.length>F.MAX_LENGTH)throw p.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!ut.test(s))throw p.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return s}),n=[...new Set(t)];if(n.length!==t.length)throw p.validation("Duplicate labels are not allowed");return n}async function Lt(e){let t=e.find(i=>i.path===_||i.path===`/${_}`);if(!t)return;let n=t.content,o=typeof n.text=="function"?await n.text():t.content.toString("utf8");at(o)}var qn=3e4,It=3e5,zn=3e5,Vn=It+zn,Kn="sdk";function Be(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 Ee=class extends ye{constructor(n){super();this.globalHeaders={};this.apiUrl=n.apiUrl||dt,this.getAuthHeadersCallback=n.getAuthHeaders,this.session=n.session??!1,this.caller=n.caller,this.timeout=n.timeout??qn,this.deployTimeout=n.timeout??It,this.deployBuildTimeout=n.timeout??Vn,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,i,s=this.timeout){let l=()=>{};try{let d=await this.mergeHeaders(o.headers),m=this.createTimeoutSignal(o.signal,s);l=m.cleanup;let r={...o,headers:d,credentials:this.session&&!d.Authorization?"include":void 0,signal:m.signal};this.emit("request",n,r);let a=await this.fetch(n,r);if(l(),!a.ok)throw await p.fromHttpResponse(a,i);return this.emit("response",this.safeClone(a),n),{data:await this.parseResponse(this.safeClone(a)),status:a.status}}catch(d){l();let m=p.fromFetchError(d,i);throw this.emit("error",m,n),m}}async request(n,o,i,s){let{data:l}=await this.executeRequest(n,o,i,s);return l}async requestWithStatus(n,o,i){return this.executeRequest(n,o,i)}async mergeHeaders(n={}){return{...this.globalHeaders,...this.caller?{[Q.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...n}}createTimeoutSignal(n,o=this.timeout){let i=new AbortController,s=setTimeout(()=>i.abort(),o);if(n){let l=()=>i.abort();n.addEventListener("abort",l),n.aborted&&i.abort()}return{signal:i.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 p.business("No files to deploy");for(let r of n)if(!r.md5)throw p.file(`MD5 checksum missing for file: ${r.path}`,{filePath:r.path});Ie(o.password);let i=nt(o.idempotencyKey),s=oe(o.labels);await Lt(n);let l=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:d,headers:m}=await this.createDeployBody(n,{labels:s,via:o.via??Kn,password:o.password,flags:l,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:d,headers:i?{...m,[le.HEADER]:i}:m,signal:o.signal||null},"Deploy",o.build||o.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(n){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}${Be(n)}`,{method:"GET"},"List deployments")}async getDeployment(n){return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(n,o){let i=oe(o);return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:i})},"Update deployment labels")}async deleteDeployment(n){return this.request(`${this.apiUrl}${E.DEPLOYMENT(encodeURIComponent(n))}`,{method:"DELETE"},"Delete deployment")}async setDomain(n,o,i){let s=oe(i),l={};o&&(l.deployment=o),s!==void 0&&(l.labels=s);let{data:d,status:m}=await this.requestWithStatus(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"Set domain");return{...d,isCreate:m===201}}async listDomains(n){return this.request(`${this.apiUrl}${E.DOMAINS}${Be(n)}`,{method:"GET"},"List domains")}async getDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"GET"},"Get domain")}async deleteDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN(encodeURIComponent(n))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(n){return this.request(`${this.apiUrl}${E.DOMAIN_VERIFY(encodeURIComponent(n))}`,{method:"POST"},"Verify domain")}async getDomainDns(n){return this.request(`${this.apiUrl}${E.DOMAIN_DNS(encodeURIComponent(n))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(n){return this.request(`${this.apiUrl}${E.DOMAIN_RECORDS(encodeURIComponent(n))}`,{method:"GET"},"Get domain records")}async getDomainShare(n){return this.request(`${this.apiUrl}${E.DOMAIN_SHARE(encodeURIComponent(n))}`,{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 i=oe(o),s={};return n!==void 0&&(s.ttl=n),i!==void 0&&(s.labels=i),this.request(`${this.apiUrl}${E.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},"Create token")}async listTokens(n){return this.request(`${this.apiUrl}${E.TOKENS}${Be(n)}`,{method:"GET"},"List tokens")}async deleteToken(n){return this.request(`${this.apiUrl}${E.TOKEN(encodeURIComponent(n))}`,{method:"DELETE"},"Delete token")}async getToken(n){return this.request(`${this.apiUrl}${E.TOKEN(encodeURIComponent(n))}`,{method:"GET"},"Get 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 this.request(`${this.apiUrl}${E.PING}`,{method:"GET"},"Ping")}async checkSPA(n,o={}){let i=n.find(m=>m.path===pe.INDEX_FILE||m.path===`/${pe.INDEX_FILE}`);if(!i||i.size>pe.MAX_INDEX_BYTES)return!1;let s;if(typeof Buffer<"u"&&Buffer.isBuffer(i.content))s=i.content.toString("utf-8");else if(typeof Blob<"u"&&i.content instanceof Blob)s=await i.content.text();else if(typeof File<"u"&&i.content instanceof File)s=await i.content.text();else return!1;let l={files:n.map(m=>m.path),index:s};return(await this.request(`${this.apiUrl}${E.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}};D();D();qe();async function Jn(){let e=JSON.stringify(rt,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:_,content:t,size:e.length,md5:n}}async function Pt(e,t,n){if(n.spaDetect===!1||n.spa||n.build||n.prerender||e.some(o=>o.path===_))return e;try{if(await t.checkSPA(e,n)){let i=await Jn();return[...e,i]}}catch{}return e}function _t(e){let{getApi:t,ensureInit:n,processInput:o}=e;return{upload:async(i,s={})=>{if(await n(),!o)throw p.config("processInput function is not provided.");let l=t(),d=await o(i,s);return d=await Pt(d,l,s),l.deploy(d,s)},list:async i=>(await n(),t().listDeployments(i)),get:async i=>(await n(),t().getDeployment(i)),set:async(i,s)=>(await n(),t().updateDeploymentLabels(i,s.labels)),delete:async i=>(await n(),t().deleteDeployment(i))}}function kt(e){let{getApi:t,ensureInit:n}=e;return{set:async(o,i={})=>(await n(),t().setDomain(o,i.deployment,i.labels)),list:async o=>(await n(),t().listDomains(o)),get:async o=>(await n(),t().getDomain(o)),delete:async o=>(await n(),t().deleteDomain(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 Nt(e){let{getApi:t,ensureInit:n}=e;return{get:async()=>(await n(),t().getAccount())}}function Ft(e){let{getApi:t,ensureInit:n}=e;return{create:async(o={})=>(await n(),t().createToken(o.ttl,o.labels)),list:async o=>(await n(),t().listTokens(o)),get:async o=>(await n(),t().getToken(o)),delete:async o=>(await n(),t().deleteToken(o))}}var Se=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&&pt(t.caller),t.token&&t.session)throw p.config("Provide either `token` or `session`, not both.");typeof t.token=="string"?(B(t.token),this.credential=t.token):t.token&&(this.credential=t.token),this.http=new Ee({...t,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=_t({...n,processInput:(o,i)=>this.processInput(o,i)}),this.domains=kt(n),this.account=Nt(n),this.tokens=Ft(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 p.config("Provide either `token` or `session`, not both.");if(typeof t=="string"){if(!t)throw p.business("Invalid token provided. Token must be a non-empty string.");B(t),this.credential=t;return}if(typeof t!="function")throw p.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 p.authentication("Token provider returned no token.");if(typeof t!="string")throw p.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${t}`}}};ce();D();async function Mt(e,t={}){let{FormData:n,File:o}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),{labels:s,via:l,password:d,flags:m,captcha:r}=t,a=new n,c=[];for(let f of e){if(!Buffer.isBuffer(f.content)&&!(typeof Blob<"u"&&f.content instanceof Blob))throw p.file(`Unsupported file.content type for Node.js: ${f.path}`,{filePath:f.path});if(!f.md5)throw p.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});let g=new o([f.content],f.path,{type:"application/octet-stream"});a.append(I.FILES,g),c.push(f.md5)}a.append(I.CHECKSUMS,JSON.stringify(c)),s&&s.length>0&&a.append(I.LABELS,JSON.stringify(s)),l&&a.append(I.VIA,l),d&&a.append(I.PASSWORD,d),m?.build&&a.append(I.BUILD,"true"),m?.prerender&&a.append(I.PRERENDER,"true"),m?.spa&&a.append(I.SPA,"true"),r&&a.append(I.CAPTCHA,r);let u=new i(a),w=[];for await(let f of u.encode())w.push(Buffer.from(f));let $=Buffer.concat(w);return{body:$.buffer.slice($.byteOffset,$.byteOffset+$.byteLength),headers:{"Content-Type":u.contentType,"Content-Length":Buffer.byteLength($).toString()}}}var we=class extends Se{constructor(t={}){if(K()!=="node")throw p.business("Node.js Ship class can only be used in Node.js environment.");let n=Y();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(s=>typeof s=="string"))throw p.business("Invalid input type for Node.js environment. Expected string or string[].");if(o.length===0)throw p.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(Zt(),Jt));return i(o,n,this.platformLimits??void 0)}getDeployBodyCreator(){return Mt}};function Ke(e,t,n){return{apiUrl:e.apiUrl||t.apiUrl||n.apiUrl,token:e.token||t.token||n.token}}function Qt(e={}){return new we(Ke(e,Y(),he(e.config)))}D();function en(e){return A(e)?e:e instanceof Error?p.business(e.message):p.business(String(e??"Unknown error"))}function tn(e,t){return e.isAuthError()?t?.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.isType(h.Maintenance)?`${e.message.replace(/\.$/,"")} \u2014 check https://status.shipstatic.com`:e.isClientError()?e.message:`${e.message.replace(/\.$/,"")} \u2014 try again, or check https://status.shipstatic.com`}D();var Xe=(e,t)=>`https://setup.shipstatic.com/${e}/${t}`;function Ye(e,t){return e[t]}var to={[et.DELETING]:"served until cleanup completes"},no={upload:"uploaded",create:"created",delete:"deleted",verify:"verification queued"};function oo(e,t){let{operation:n,resource:o}=t;if(!o||e===null||typeof e!="object")return null;let i=n==="set"?Ye(e,"isCreate")?"created":"updated":no[n];if(!i)return null;let s=Ye(e,o);if(typeof s!="string")return null;let l=Ye(e,"status"),d=typeof l=="string"?to[l]:void 0;return`${s} ${o} ${d?`${l} \u2014 ${d}`:i}`}function io(e,t){let{noColor:n}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let o=["deployment","labels","files","size","created","via"];console.log(ne(e.deployments,o,n)),Je(e.cursor,n)}function Je(e,t){e&&M(`more results available \u2014 rerun with --cursor ${e}`,!1,t)}function so(e,t){let{noColor:n}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let o=["domain","deployment","labels","linked","links","created"];console.log(ne(e.domains,o,n)),Je(e.cursor,n)}function nn(e,t){let{noColor:n}=t,{_dnsRecords:o,_shareHash:i,isCreate:s,...l}=e;o&&o.length>0&&(console.log(),M("DNS records to configure:",!1,n),o.forEach(d=>{console.log(` ${d.type}: ${d.name} \u2192 ${d.value}`)})),i&&(console.log(),M(`Setup instructions: ${Xe(i,e.domain)}`,!1,n)),console.log(U(l,n))}function We(e,t){let{noColor:n}=t;console.log(U(e,n));let o=e.claim;if(o){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:
138
138
  ${o}
139
139
  `),M("configure a free API key with 'ship config' to deploy to your own account",!1,n)}}function ro(e,t){let{noColor:n}=t;console.log(U(e,n))}function ao(e,t){let{noColor:n}=t;if(e.valid){if(k(`${e.normalized??"domain"} domain is valid`,!1,n),console.log(),e.available!==null){let o=e.available?n?"available":"available \u2713":"already taken";console.log(` availability: ${o}`)}console.log()}else console.log(`${W(e.reason??"domain is invalid")}
140
140
  `)}function lo(e,t){let{noColor:n}=t;if(e.records.length===0){console.log("no records found"),console.log();return}let o=["type","name","value"];console.log(ne(e.records,o,n))}function po(e,t){let{noColor:n}=t,o=e.dns?.provider?.name||null;console.log(U({domain:e.domain,provider:o},n))}function co(e,t){let{noColor:n}=t;console.log(U({domain:e.domain,setup:Xe(e.hash,e.domain)},n))}function mo(e,t){let{noColor:n}=t;if(e.tokens.length===0){console.log("no tokens found"),console.log();return}let o=["token","labels","created","expires"];console.log(ne(e.tokens,o,n)),Je(e.cursor,n)}function on(e,t){let{noColor:n}=t;console.log(U(e,n))}var b=e=>e,uo=e=>e.resource?`${e.resource}.${e.operation}`:e.operation,fo={"deployment.list":b({quiet:e=>e.deployments.map(t=>t.deployment),text:io}),"deployment.upload":b({quiet:e=>[e.deployment],text:We}),"deployment.get":b({quiet:e=>[e.deployment],text:We}),"deployment.set":b({quiet:e=>[e.deployment],text:We}),"deployment.delete":b({quiet:e=>[e.deployment],text:()=>{}}),"domain.list":b({quiet:e=>e.domains.map(t=>t.domain),text:so}),"domain.get":b({quiet:e=>[e.domain],text:nn}),"domain.set":b({quiet:e=>[e.domain],text:nn}),"domain.validate":b({quiet:e=>e.valid&&e.normalized?[e.normalized]:[],text:ao}),"domain.verify":b({quiet:e=>[e.domain],text:()=>{}}),"domain.records":b({quiet:e=>e.records.map(t=>`${t.type} ${t.name} ${t.value}`),text:lo}),"domain.dns":b({quiet:e=>e.dns?.provider?.name?[e.dns.provider.name]:[],text:po}),"domain.share":b({quiet:e=>[Xe(e.hash,e.domain)],text:co}),"domain.delete":b({quiet:e=>[e.domain],text:()=>{}}),"token.list":b({quiet:e=>e.tokens.map(t=>t.token),text:mo}),"token.create":b({quiet:e=>[e.secret],text:on}),"token.get":b({quiet:e=>[e.token],text:on}),"token.delete":b({quiet:e=>[e.token],text:()=>{}}),"account.get":b({quiet:e=>[e.email],text:ro}),ping:b({quiet:()=>[],text:(e,t)=>k("api reachable",!1,t.noColor)})};function sn(e,t,n){let{json:o,quiet:i,noColor:s}=n,l=fo[uo(t)];if(i){for(let m of l?.quiet(e)??[])console.log(m);return}if(o&&e!==null&&typeof e=="object"){let m={...e};delete m._dnsRecords,delete m._shareHash,delete m.isCreate,console.log(JSON.stringify(m,null,2)),console.log();return}let d=oo(e,t);d&&k(d,!1,s),l?l.text(e,n):e!==null&&typeof e=="object"&&console.log(U(e,s))}function ho(){let e=[Ze.resolve(__dirname,"../package.json"),Ze.resolve(__dirname,"../../package.json")];for(let t of e)try{return JSON.parse((0,q.readFileSync)(t,"utf-8"))}catch{}return{version:"0.0.0"}}var go=ho();function yo(e){let t=s=>e?s:(0,Oe.bold)(s),n=s=>e?s:(0,Oe.dim)(s),o=s=>e?"":`${s} `;return`${t("USAGE")}
@@ -192,7 +192,7 @@ ${t("EXAMPLES")}
192
192
  ship ./dist -q | ship domains set www.example.com
193
193
 
194
194
  ${n("Please report any issues to https://github.com/shipstatic/ship/issues")}
195
- `}var Te=e=>new p(h.Validation,e);function ie(e,t=[]){return t.concat([e])}function Ce(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new G.InvalidArgumentError("Not a number.");return t}function se(e,t){let n=e?.label?.length?e.label:t?.label;if(!n?.length)return;let o=n.filter(i=>i!=="");return o.length?o:[]}function rn(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 re(){let e=N(this),t=L(this).map(o=>o.name()),n=this.args.find(o=>!t.includes(o));n&&J(Te(`unknown command '${n}'`),e.json,e.noColor),e.json||console.log(`usage: ship ${this.name()} <${t.join("|")}>
196
- `),process.exitCode=1}function Eo(e){let t={};try{t=he(e.config)}catch{}let n=Ke(e,Y(),t).token;return typeof n=="string"?n:void 0}async function an(e,t,n,o,i,s){if(!(0,q.existsSync)(t))throw p.file(`${t} path does not exist`,{filePath:t});let l=(0,q.statSync)(t);if(!l.isDirectory()&&!l.isFile())throw p.file(`${t} path must be a file or directory`,{filePath:t});let d={via:tt(process.env.SHIP_VIA)??$e.CLI};n!==void 0&&(d.labels=n);let m=process.env.SHIP_IDEMPOTENCY_KEY||void 0;m!==void 0&&(d.idempotencyKey=m),o!==void 0&&(d.password=o),i?.noPathDetect!==void 0&&(d.pathDetect=!i.noPathDetect),i?.noSpaDetect!==void 0&&(d.spaDetect=!i.noSpaDetect);let r=new AbortController;d.signal=r.signal;let a=null;if(process.stdout.isTTY&&!s.json&&!s.quiet&&!s.noColor){let{default:u}=await import("yocto-spinner");a=u({text:"uploading\u2026"}).start()}let c=()=>{r.abort(),a&&a.stop(),process.exit(130)};process.on("SIGINT",c);try{return await e.deployments.upload(t,d)}finally{process.removeListener("SIGINT",c),a&&a.stop()}}function ln(){let e=new G.Command;e.exitOverride(r=>{if(r.code==="commander.help"||r.code==="commander.version"||r.exitCode===0)throw r;let a=N(e),c=r.message||"unknown command error";throw c=c.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),J(Te(c),a.json,a.noColor),a.json||e.outputHelp(),r}).configureOutput({writeErr:r=>{r.startsWith("error:")||process.stderr.write(r)},writeOut:r=>process.stdout.write(r)});function t(r){let a=N(e),c=en(r);if(a.json)J(c,!0,a.noColor);else{let u=tn(c,{token:c.isAuthError()?Eo(e.opts()):void 0});J(u,!1,a.noColor),c.type===h.Validation&&u.includes("unknown command")&&e.outputHelp()}process.exitCode=1}function n(r,a){return async function(...c){let u=N(this);try{let{config:w,apiUrl:$,token:f}=e.opts(),g=Qt({config:w,apiUrl:$,token:f}),C=await r(g,u,...c);sn(C,a,{json:u.json,quiet:u.quiet,noColor:u.noColor})}catch(w){t(w)}}}e.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(go.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:(r,a)=>r.parent===null?`${yo(N(r).noColor)}
197
- `:G.Help.prototype.formatHelp.call(a,r,a)}).allowExcessArguments(),e.hook("preAction",r=>{let a=N(r);try{a.token&&typeof a.token=="string"&&B(a.token),a.apiUrl&&typeof a.apiUrl=="string"&&ct(a.apiUrl)}catch(c){throw A(c)?(J(c,a.json,a.noColor),new G.CommanderError(1,"ship.invalidOption",c.message)):c}}),e.command("ping").description("Check API connectivity").action(n((r,a)=>r.ping(),{operation:"ping"})),e.command("whoami").description("Get current account information").action(n((r,a)=>r.whoami(),{operation:"get",resource:"account"}));let o=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(re);o.command("list").description("List deployments (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Ce).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.deployments.list(c),{operation:"list",resource:"deployment"})),o.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",ie,[]).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(n((r,a,c,u)=>an(r,c,se(u,e.opts()),rn(u,e.opts()),u,a),{operation:"upload",resource:"deployment"})),o.command("get <deployment>").description("Show deployment information").action(n((r,a,c)=>r.deployments.get(c),{operation:"get",resource:"deployment"})),o.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",ie,[]).action(n(async(r,a,c,u)=>{let w=se(u,e.opts())||[];return r.deployments.set(c,{labels:w})},{operation:"set",resource:"deployment"})),o.command("delete <deployment>").description("Delete deployment permanently").action(n((r,a,c)=>r.deployments.delete(c),{operation:"delete",resource:"deployment"}));let i=e.command("domains").description("Manage domains").enablePositionalOptions().action(re);i.command("list").description("List domains (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Ce).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.domains.list(c),{operation:"list",resource:"domain"})),i.command("get <name>").description("Show domain information").action(n((r,a,c)=>r.domains.get(c),{operation:"get",resource:"domain"})),i.command("validate <name>").description("Check if domain name is valid and available").action(n(async(r,a,c)=>{let u=await r.domains.validate(c);return u.valid||(process.exitCode=1),u},{operation:"validate",resource:"domain"})),i.command("verify <name>").description("Trigger DNS verification for external domain").action(n((r,a,c)=>r.domains.verify(c),{operation:"verify",resource:"domain"})),i.command("records <name>").description("Show required DNS records for domain setup").action(n((r,a,c)=>r.domains.records(c),{operation:"records",resource:"domain"})),i.command("dns <name>").description("Look up DNS provider for a domain").action(n((r,a,c)=>r.domains.dns(c),{operation:"dns",resource:"domain"})),i.command("share <name>").description("Get shareable DNS setup link").action(n((r,a,c)=>r.domains.share(c),{operation:"share",resource:"domain"})),i.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",ie,[]).action(n(async(r,a,c,u,w)=>{!u&&!process.stdin.isTTY&&(u=await new Promise(C=>{let O="";process.stdin.on("data",H=>O+=H),process.stdin.on("end",()=>C(O.trim()||void 0))}));let $=se(w,e.opts()),f={};u&&(f.deployment=u),$!==void 0&&(f.labels=$);let g=await r.domains.set(c,f);if(g.isCreate&&c.includes("."))try{let[C,O]=await Promise.all([r.domains.records(c),r.domains.share(c)]);return{...g,_dnsRecords:C.records,_shareHash:O.hash}}catch{}return g},{operation:"set",resource:"domain"})),i.command("delete <name>").description("Delete domain permanently").action(n((r,a,c)=>r.domains.delete(c),{operation:"delete",resource:"domain"}));let s=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(re);s.command("list").description("List deploy tokens (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Ce).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.tokens.list(c),{operation:"list",resource:"token"})),s.command("create").description("Create a new deploy token").option("--ttl <seconds>","Time to live in seconds (default: never expires)",Ce).option("--label <label>","Label to set (can be repeated)",ie,[]).action(n((r,a,c)=>{let u={};c?.ttl!==void 0&&(u.ttl=c.ttl);let w=se(c,e.opts());return w!==void 0&&(u.labels=w),r.tokens.create(u)},{operation:"create",resource:"token"})),s.command("get <token>").description("Show one deploy token").action(n((r,a,c)=>r.tokens.get(c),{operation:"get",resource:"token"})),s.command("delete <token>").description("Delete token permanently").action(n((r,a,c)=>r.tokens.delete(c),{operation:"delete",resource:"token"})),e.command("account").description("Manage account").action(re).command("get").description("Show account information").action(n((r,a)=>r.whoami(),{operation:"get",resource:"account"}));let d=e.command("completion").description("Setup shell completion").action(re);d.command("install").description("Install shell completion script").action(()=>{let r=N(e);try{bt(e,{json:r.json,noColor:r.noColor})}catch(a){t(a)}}),d.command("uninstall").description("Uninstall shell completion script").action(()=>{let r=N(e);try{wt({json:r.json,noColor:r.noColor})}catch(a){t(a)}}),e.command("config").description("Save your token").action(async()=>{let r=N(e);try{if(r.json)throw Te("ship config is interactive \u2014 run it without --json (it shows the token already saved)");await xt({noColor:r.noColor,configFile:r.config})}catch(a){t(a)}});let m=n((r,a,c,u)=>an(r,c,se(u,e.opts()),rn(u,e.opts()),u,a),{operation:"upload",resource:"deployment"});return e.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",ie,[]).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(r,a){if(!r){this.outputHelp();return}if(!(0,q.existsSync)(r)&&!r.includes("/")&&!r.includes("\\")&&!r.includes(".")&&!r.startsWith("~")){t(Te(`unknown command '${r}'`));return}return m.call(this,r,a)}),e}ln().parseAsync(process.argv).catch(e=>{if(e instanceof pn.CommanderError){process.exitCode=e.exitCode;return}throw e});
195
+ `}var Ce=e=>new p(h.Validation,e);function ie(e,t=[]){return t.concat([e])}function Te(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new G.InvalidArgumentError("Not a number.");return t}function se(e,t){let n=e?.label?.length?e.label:t?.label;if(!n?.length)return;let o=n.filter(i=>i!=="");return o.length?o:[]}function rn(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 re(){let e=N(this),t=L(this).map(o=>o.name()),n=this.args.find(o=>!t.includes(o));n&&J(Ce(`unknown command '${n}'`),e.json,e.noColor),e.json||console.log(`usage: ship ${this.name()} <${t.join("|")}>
196
+ `),process.exitCode=1}function Eo(e){let t={};try{t=he(e.config)}catch{}let n=Ke(e,Y(),t).token;return typeof n=="string"?n:void 0}async function an(e,t,n,o,i,s){if(!(0,q.existsSync)(t))throw p.file(`${t} path does not exist`,{filePath:t});let l=(0,q.statSync)(t);if(!l.isDirectory()&&!l.isFile())throw p.file(`${t} path must be a file or directory`,{filePath:t});let d={via:tt(process.env.SHIP_VIA)??$e.CLI};n!==void 0&&(d.labels=n);let m=process.env.SHIP_IDEMPOTENCY_KEY||void 0;m!==void 0&&(d.idempotencyKey=m),o!==void 0&&(d.password=o),i?.noPathDetect!==void 0&&(d.pathDetect=!i.noPathDetect),i?.noSpaDetect!==void 0&&(d.spaDetect=!i.noSpaDetect);let r=new AbortController;d.signal=r.signal;let a=null;if(process.stdout.isTTY&&!s.json&&!s.quiet&&!s.noColor){let{default:u}=await import("yocto-spinner");a=u({text:"uploading\u2026"}).start()}let c=()=>{r.abort(),a&&a.stop(),process.exit(130)};process.on("SIGINT",c);try{return await e.deployments.upload(t,d)}finally{process.removeListener("SIGINT",c),a&&a.stop()}}function ln(){let e=new G.Command;e.exitOverride(r=>{if(r.code==="commander.help"||r.code==="commander.version"||r.exitCode===0)throw r;let a=N(e),c=r.message||"unknown command error";throw c=c.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),J(Ce(c),a.json,a.noColor),a.json||e.outputHelp(),r}).configureOutput({writeErr:r=>{r.startsWith("error:")||process.stderr.write(r)},writeOut:r=>process.stdout.write(r)});function t(r){let a=N(e),c=en(r);if(a.json)J(c,!0,a.noColor);else{let u=tn(c,{token:c.isAuthError()?Eo(e.opts()):void 0});J(u,!1,a.noColor),c.type===h.Validation&&u.includes("unknown command")&&e.outputHelp()}process.exitCode=1}function n(r,a){return async function(...c){let u=N(this);try{let{config:w,apiUrl:$,token:f}=e.opts(),g=Qt({config:w,apiUrl:$,token:f}),T=await r(g,u,...c);sn(T,a,{json:u.json,quiet:u.quiet,noColor:u.noColor})}catch(w){t(w)}}}e.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(go.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:(r,a)=>r.parent===null?`${yo(N(r).noColor)}
197
+ `:G.Help.prototype.formatHelp.call(a,r,a)}).allowExcessArguments(),e.hook("preAction",r=>{let a=N(r);try{a.token&&typeof a.token=="string"&&B(a.token),a.apiUrl&&typeof a.apiUrl=="string"&&ct(a.apiUrl)}catch(c){throw A(c)?(J(c,a.json,a.noColor),new G.CommanderError(1,"ship.invalidOption",c.message)):c}}),e.command("ping").description("Check API connectivity").action(n((r,a)=>r.ping(),{operation:"ping"})),e.command("whoami").description("Get current account information").action(n((r,a)=>r.whoami(),{operation:"get",resource:"account"}));let o=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(re);o.command("list").description("List deployments (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Te).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.deployments.list(c),{operation:"list",resource:"deployment"})),o.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",ie,[]).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(n((r,a,c,u)=>an(r,c,se(u,e.opts()),rn(u,e.opts()),u,a),{operation:"upload",resource:"deployment"})),o.command("get <deployment>").description("Show deployment information").action(n((r,a,c)=>r.deployments.get(c),{operation:"get",resource:"deployment"})),o.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",ie,[]).action(n(async(r,a,c,u)=>{let w=se(u,e.opts())||[];return r.deployments.set(c,{labels:w})},{operation:"set",resource:"deployment"})),o.command("delete <deployment>").description("Delete deployment permanently").action(n((r,a,c)=>r.deployments.delete(c),{operation:"delete",resource:"deployment"}));let i=e.command("domains").description("Manage domains").enablePositionalOptions().action(re);i.command("list").description("List domains (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Te).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.domains.list(c),{operation:"list",resource:"domain"})),i.command("get <name>").description("Show domain information").action(n((r,a,c)=>r.domains.get(c),{operation:"get",resource:"domain"})),i.command("validate <name>").description("Check if domain name is valid and available").action(n(async(r,a,c)=>{let u=await r.domains.validate(c);return u.valid||(process.exitCode=1),u},{operation:"validate",resource:"domain"})),i.command("verify <name>").description("Trigger DNS verification for external domain").action(n((r,a,c)=>r.domains.verify(c),{operation:"verify",resource:"domain"})),i.command("records <name>").description("Show required DNS records for domain setup").action(n((r,a,c)=>r.domains.records(c),{operation:"records",resource:"domain"})),i.command("dns <name>").description("Look up DNS provider for a domain").action(n((r,a,c)=>r.domains.dns(c),{operation:"dns",resource:"domain"})),i.command("share <name>").description("Get shareable DNS setup link").action(n((r,a,c)=>r.domains.share(c),{operation:"share",resource:"domain"})),i.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",ie,[]).action(n(async(r,a,c,u,w)=>{!u&&!process.stdin.isTTY&&(u=await new Promise(T=>{let O="";process.stdin.on("data",H=>O+=H),process.stdin.on("end",()=>T(O.trim()||void 0))}));let $=se(w,e.opts()),f={};u&&(f.deployment=u),$!==void 0&&(f.labels=$);let g=await r.domains.set(c,f);if(g.isCreate&&c.includes("."))try{let[T,O]=await Promise.all([r.domains.records(c),r.domains.share(c)]);return{...g,_dnsRecords:T.records,_shareHash:O.hash}}catch{}return g},{operation:"set",resource:"domain"})),i.command("delete <name>").description("Delete domain permanently").action(n((r,a,c)=>r.domains.delete(c),{operation:"delete",resource:"domain"}));let s=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(re);s.command("list").description("List deploy tokens (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",Te).option("--cursor <cursor>","Continue from a previous page's cursor").action(n((r,a,c)=>r.tokens.list(c),{operation:"list",resource:"token"})),s.command("create").description("Create a new deploy token").option("--ttl <seconds>","Time to live in seconds (default: never expires)",Te).option("--label <label>","Label to set (can be repeated)",ie,[]).action(n((r,a,c)=>{let u={};c?.ttl!==void 0&&(u.ttl=c.ttl);let w=se(c,e.opts());return w!==void 0&&(u.labels=w),r.tokens.create(u)},{operation:"create",resource:"token"})),s.command("get <token>").description("Show one deploy token").action(n((r,a,c)=>r.tokens.get(c),{operation:"get",resource:"token"})),s.command("delete <token>").description("Delete token permanently").action(n((r,a,c)=>r.tokens.delete(c),{operation:"delete",resource:"token"})),e.command("account").description("Manage account").action(re).command("get").description("Show account information").action(n((r,a)=>r.whoami(),{operation:"get",resource:"account"}));let d=e.command("completion").description("Setup shell completion").action(re);d.command("install").description("Install shell completion script").action(()=>{let r=N(e);try{bt(e,{json:r.json,noColor:r.noColor})}catch(a){t(a)}}),d.command("uninstall").description("Uninstall shell completion script").action(()=>{let r=N(e);try{wt({json:r.json,noColor:r.noColor})}catch(a){t(a)}}),e.command("config").description("Save your token").action(async()=>{let r=N(e);try{if(r.json)throw Ce("ship config is interactive \u2014 run it without --json (it shows the token already saved)");await xt({noColor:r.noColor,configFile:r.config})}catch(a){t(a)}});let m=n((r,a,c,u)=>an(r,c,se(u,e.opts()),rn(u,e.opts()),u,a),{operation:"upload",resource:"deployment"});return e.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",ie,[]).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(r,a){if(!r){this.outputHelp();return}if(!(0,q.existsSync)(r)&&!r.includes("/")&&!r.includes("\\")&&!r.includes(".")&&!r.startsWith("~")){t(Ce(`unknown command '${r}'`));return}return m.call(this,r,a)}),e}ln().parseAsync(process.argv).catch(e=>{if(e instanceof pn.CommanderError){process.exitCode=e.exitCode;return}throw e});
198
198
  //# sourceMappingURL=cli.cjs.map