@shipstatic/ship 2.0.0-beta.0 → 2.0.0-beta.10

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