@shipstatic/ship 0.8.14 → 0.8.15
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/SKILL.md +10 -0
- package/dist/cli.cjs +18 -18
- package/dist/cli.cjs.map +1 -1
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -70,6 +70,15 @@ ship ./dist --label v1.0 --label production
|
|
|
70
70
|
|
|
71
71
|
Labels **replace all existing**, not append. Include current labels to keep them.
|
|
72
72
|
|
|
73
|
+
### Password protection
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
ship ./dist --password "hunter22" # protect deployment
|
|
77
|
+
SHIP_PASSWORD="hunter22" ship ./dist # via env var
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Visitors get an unlock page until they enter the password. Length: 6–128 characters. Set per-deployment at upload time — cannot be added or changed later (deploy a new version to rotate). Works on both internal (`*.shipstatic.com`) and custom domains.
|
|
81
|
+
|
|
73
82
|
### SPA routing
|
|
74
83
|
|
|
75
84
|
Ship auto-detects single-page apps from `index.html` content and configures client-side routing rewrites — all paths serve `index.html`. No action needed. Skipped if a `ship.json` config is already included in the deployment. Disable with `--no-spa-detect`.
|
|
@@ -250,6 +259,7 @@ ship tokens remove <token> # Revoke
|
|
|
250
259
|
| `--api-key <key>` | API key for this command |
|
|
251
260
|
| `--deploy-token <token>` | Single-use deploy token |
|
|
252
261
|
| `--label <label>` | Set label (repeatable, replaces all) |
|
|
262
|
+
| `--password <pwd>` | Password-protect deployment (6–128 chars) |
|
|
253
263
|
| `--no-path-detect` | Skip build output auto-detection |
|
|
254
264
|
| `--no-spa-detect` | Skip SPA rewrite auto-configuration |
|
|
255
265
|
| `--no-color` | Disable colors |
|
package/dist/cli.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Nt=Object.create;var Se=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Mt=Object.getPrototypeOf,jt=Object.prototype.hasOwnProperty;var P=(e,o)=>()=>(e&&(o=e(e=0)),o);var Kt=(e,o)=>{for(var t in o)Se(e,t,{get:o[t],enumerable:!0})},Gt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Ut(o))!jt.call(e,i)&&i!==t&&Se(e,i,{get:()=>o[i],enumerable:!(n=_t(o,i))||n.enumerable});return e};var T=(e,o,t)=>(t=e!=null?Nt(Mt(e)):{},Gt(o||!e||!e.__esModule?Se(t,"default",{value:e,enumerable:!0}):t,e));function x(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function ve(e){let o=e.lastIndexOf(".");if(o===-1||o===e.length-1)return!1;let t=e.slice(o+1).toLowerCase();return zt.has(t)}function Ue(e){return Bt.test(e)}function Ee(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>we.has(t))}function re(e){if(!e.startsWith(z))throw l.validation(`API key must start with "${z}"`);if(e.length!==Ne)throw l.validation(`API key must be ${Ne} characters total (${z} + ${be} hex chars)`);let o=e.slice(z.length);if(!/^[a-f0-9]{64}$/i.test(o))throw l.validation(`API key must contain ${be} hexadecimal characters after "${z}" prefix`)}function je(e){if(!e.startsWith(B))throw l.validation(`Deploy token must start with "${B}"`);if(e.length!==_e)throw l.validation(`Deploy token must be ${_e} characters total (${B} + ${Ce} hex chars)`);let o=e.slice(B.length);if(!/^[a-f0-9]{64}$/i.test(o))throw l.validation(`Deploy token must contain ${Ce} hexadecimal characters after "${B}" prefix`)}function Ke(e){try{let o=new URL(e);if(!["http:","https:"].includes(o.protocol))throw l.validation("API URL must use http:// or https:// protocol");if(o.pathname!=="/"&&o.pathname!=="")throw l.validation("API URL must not contain a path");if(o.search||o.hash)throw l.validation("API URL must not contain query parameters or fragments")}catch(o){throw x(o)?o:l.validation("API URL must be a valid URL")}}var g,De,l,zt,Bt,we,z,be,Ne,B,Ce,_e,Te,Me,H,M,Ge,X,v=P(()=>{"use strict";(function(e){e.Validation="validation_failed",e.NotFound="not_found",e.RateLimit="rate_limit_exceeded",e.Authentication="authentication_failed",e.Business="business_logic_error",e.Api="internal_server_error",e.Network="network_error",e.Cancelled="operation_cancelled",e.File="file_error",e.Config="config_error"})(g||(g={}));De={client:new Set([g.Business,g.Config,g.File,g.Validation]),network:new Set([g.Network]),auth:new Set([g.Authentication])},l=class e extends Error{type;status;details;constructor(o,t,n,i){super(t),this.type=o,this.status=n,this.details=i,this.name="ShipError"}toResponse(){let o=this.type===g.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:o}}static fromResponse(o){return new e(o.error,o.message,o.status,o.details)}static validation(o,t){return new e(g.Validation,o,400,t)}static notFound(o,t){let n=t?`${o} ${t} not found`:`${o} not found`;return new e(g.NotFound,n,404)}static rateLimit(o="Too many requests"){return new e(g.RateLimit,o,429)}static authentication(o="Authentication required",t){return new e(g.Authentication,o,401,t)}static business(o,t=400){return new e(g.Business,o,t)}static network(o,t){return new e(g.Network,o,void 0,{cause:t})}static cancelled(o){return new e(g.Cancelled,o)}static file(o,t){return new e(g.File,o,void 0,{filePath:t})}static config(o,t){return new e(g.Config,o,void 0,t)}static api(o,t=500){return new e(g.Api,o,t)}static database(o,t=500){return new e(g.Api,o,t)}static storage(o,t=500){return new e(g.Api,o,t)}get filePath(){return this.details?.filePath}isClientError(){return De.client.has(this.type)}isNetworkError(){return De.network.has(this.type)}isAuthError(){return De.auth.has(this.type)}isValidationError(){return this.type===g.Validation}isFileError(){return this.type===g.File}isConfigError(){return this.type===g.Config}isType(o){return this.type===o}};zt=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"]);Bt=/[\x00-\x1f\x7f#?%\\<>"]/;we=new Set(["node_modules","package.json"]);z="ship-",be=64,Ne=z.length+be,B="token-",Ce=64,_e=B.length+Ce,Te="ship.json",Me={rewrites:[{source:"/(.*)",destination:"/index.html"}]};H="https://api.shipstatic.com",M={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ge=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,X={MIN_LENGTH:6,MAX_LENGTH:128}});function Be(e){Re=e}function le(){if(Re===null)throw l.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Re}var Re,pe=P(()=>{"use strict";v();Re=null});function Vt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return Ve||Vt()}var Ve,Q=P(()=>{"use strict";Ve=null});async function qt(e){let o=(await import("spark-md5")).default;return new Promise((t,n)=>{let s=Math.ceil(e.size/2097152),r=0,c=new o.ArrayBuffer,p=new FileReader,a=()=>{let d=r*2097152,u=Math.min(d+2097152,e.size);p.readAsArrayBuffer(e.slice(d,u))};p.onload=d=>{let u=d.target?.result;if(!u){n(l.business("Failed to read file chunk"));return}c.append(u),r++,r<s?a():t({md5:c.end()})},p.onerror=()=>{n(l.business("Failed to calculate MD5: FileReader error"))},a()})}async function Jt(e){let o=await import("crypto");if(Buffer.isBuffer(e)){let n=o.createHash("md5");return n.update(e),{md5:n.digest("hex")}}let t=await import("fs");return new Promise((n,i)=>{let s=o.createHash("md5"),r=t.createReadStream(e);r.on("error",c=>i(l.business(`Failed to read file for MD5: ${c.message}`))),r.on("data",c=>s.update(c)),r.on("end",()=>n({md5:s.digest("hex")}))})}async function ce(e){let o=L();if(o==="browser"){if(!(e instanceof Blob))throw l.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return qt(e)}if(o==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw l.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Jt(e)}throw l.business("Unknown or unsupported execution environment for MD5 calculation.")}var xe=P(()=>{"use strict";Q();v()});function ot(e,o){if(!e||e.length===0)return[];if(!o?.allowUnbuilt&&e.find(n=>n&&Ee(n)))throw l.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let n=t.replace(/\\/g,"/").split("/").filter(Boolean);if(n.length===0)return!0;let i=n[n.length-1];if((0,tt.isJunk)(i))return!1;for(let r of n)if(r!==".well-known"&&(r.startsWith(".")||r.length>255))return!1;let s=n.slice(0,-1);for(let r of s)if(Zt.some(c=>r.toLowerCase()===c.toLowerCase()))return!1;return!0})}var tt,Zt,nt=P(()=>{"use strict";tt=require("junk");v();Zt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function it(e){if(!e||e.length===0)return"";let o=e.filter(s=>s&&typeof s=="string").map(s=>s.replace(/\\/g,"/"));if(o.length===0)return"";if(o.length===1)return o[0];let t=o.map(s=>s.split("/").filter(Boolean)),n=[],i=Math.min(...t.map(s=>s.length));for(let s=0;s<i;s++){let r=t[0][s];if(t.every(c=>c[s]===r))n.push(r);else break}return n.join("/")}function me(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ke=P(()=>{"use strict"});function st(e,o={}){if(o.flatten===!1)return e.map(n=>({path:me(n),name:Ie(n)}));let t=Qt(e);return e.map(n=>{let i=me(n);if(t){let s=t.endsWith("/")?t:`${t}/`;i.startsWith(s)&&(i=i.substring(s.length))}return i||(i=Ie(n)),{path:i,name:Ie(n)}})}function Qt(e){if(!e.length)return"";let t=e.map(s=>me(s)).map(s=>s.split("/")),n=[],i=Math.min(...t.map(s=>s.length));for(let s=0;s<i-1;s++){let r=t[0][s];if(t.every(c=>c[s]===r))n.push(r);else break}return n.join("/")}function Ie(e){return e.split(/[/\\]/).pop()||e}var rt=P(()=>{"use strict";ke()});function at(e){if(Ue(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 o=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return o.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}var lt=P(()=>{"use strict";v()});function pt(e,o){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw l.business(`Security error: Unsafe file path "${e}" for file: ${o}`)}function ct(e,o){let t=at(e);if(!t.valid)throw l.business(t.reason||"Invalid file name");if(ve(e))throw l.business(`File extension not allowed: "${o}"`)}var dt=P(()=>{"use strict";v();lt()});var ut={};Kt(ut,{processFilesForNode:()=>eo});function mt(e,o=new Set){let t=[],n=O.realpathSync(e);if(o.has(n))return t;o.add(n);let i=O.readdirSync(e);for(let s of i){let r=k.join(e,s),c=O.statSync(r);if(c.isDirectory()){let p=mt(r,o);t.push(...p)}else c.isFile()&&t.push(r)}return t}async function eo(e,o={}){if(L()!=="node")throw l.business("processFilesForNode can only be called in Node.js environment.");for(let m of e){let b=k.resolve(m);try{if(O.statSync(b).isDirectory()){let I=O.readdirSync(b).find(F=>we.has(F));if(I)throw l.business(`"${I}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(I){if(x(I))throw I}}let t=e.flatMap(m=>{let b=k.resolve(m);try{return O.statSync(b).isDirectory()?mt(b):[b]}catch{throw l.file(`Path does not exist: ${m}`,m)}}),n=[...new Set(t)],i=e.map(m=>k.resolve(m)),s=it(i.map(m=>{try{return O.statSync(m).isDirectory()?m:k.dirname(m)}catch{return k.dirname(m)}})),r=n.map(m=>{if(s&&s.length>0){let b=k.relative(s,m);if(b&&typeof b=="string"&&!b.startsWith(".."))return b.replace(/\\/g,"/")}return k.basename(m)}),p=st(r,{flatten:o.pathDetect!==!1}).map(m=>m.path),a=new Set(ot(p));if(a.size===0)return[];let d=[],u=[];for(let m=0;m<n.length;m++)a.has(p[m])&&(d.push(n[m]),u.push(p[m]));let A=[],U=0,C=le();for(let m=0;m<d.length;m++){let b=d[m],I=u[m];try{pt(I,b);let F=O.statSync(b);if(F.size===0)continue;if(ct(I,b),F.size>C.maxFileSize)throw l.business(`File ${b} is too large. Maximum allowed size is ${C.maxFileSize/(1024*1024)}MB.`);if(U+=F.size,U>C.maxTotalSize)throw l.business(`Total deploy size is too large. Maximum allowed is ${C.maxTotalSize/(1024*1024)}MB.`);let Y=O.readFileSync(b),{md5:Lt}=await ce(Y);A.push({path:I,content:Y,size:Y.length,md5:Lt})}catch(F){if(x(F))throw F;let Y=F instanceof Error?F.message:String(F);throw l.file(`Failed to read file "${b}": ${Y}`,b)}}if(A.length>C.maxFilesCount)throw l.business(`Too many files to deploy. Maximum allowed is ${C.maxFilesCount} files.`);return A}var O,k,ft=P(()=>{"use strict";Q();xe();nt();dt();v();pe();rt();ke();O=T(require("fs"),1),k=T(require("path"),1)});var It=require("commander");v();var ae=class{constructor(){this.handlers=new Map}on(o,t){this.handlers.has(o)||this.handlers.set(o,new Set),this.handlers.get(o).add(t)}off(o,t){let n=this.handlers.get(o);n&&(n.delete(t),n.size===0&&this.handlers.delete(o))}emit(o,...t){let n=this.handlers.get(o);if(!n)return;let i=Array.from(n);for(let s of i)try{s(...t)}catch(r){n.delete(s),o!=="error"&&setTimeout(()=>{r instanceof Error?this.emit("error",r,String(o)):this.emit("error",new Error(String(r)),String(o))},0)}}transfer(o){this.handlers.forEach((t,n)=>{t.forEach(i=>{o.on(n,i)})})}clear(){this.handlers.clear()}};v();function ze(e){if(e!=null){if(typeof e!="string")throw l.validation("Password must be a string");if(e.length<X.MIN_LENGTH||e.length>X.MAX_LENGTH)throw l.validation(`Password must be between ${X.MIN_LENGTH} and ${X.MAX_LENGTH} characters`)}}function Z(e){if(e==null)return;if(e.length===0)return e;if(e.length>M.MAX_COUNT)throw l.validation(`Maximum ${M.MAX_COUNT} labels allowed`);let o=e.map((n,i)=>{if(typeof n!="string")throw l.validation(`Label at index ${i} must be a string`);let s=n.trim().toLowerCase();if(s.length<M.MIN_LENGTH)throw l.validation(`Labels must be at least ${M.MIN_LENGTH} characters long`);if(s.length>M.MAX_LENGTH)throw l.validation(`Labels must be no more than ${M.MAX_LENGTH} characters long`);if(!Ge.test(s))throw l.validation(`Labels must start and end with alphanumeric characters, with optional separators (${M.SEPARATORS}) between segments`);return s}),t=[...new Set(o)];if(t.length!==o.length)throw l.validation("Duplicate labels are not allowed");return t}var y={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Ht=3e4,V=class extends ae{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||H,this.getAuthHeadersCallback=t.getAuthHeaders,this.useCredentials=t.useCredentials??!1,this.timeout=t.timeout??Ht,this.createDeployBody=t.createDeployBody,this.deployEndpoint=t.deployEndpoint||y.DEPLOYMENTS}setGlobalHeaders(t){this.globalHeaders=t}transferEventsTo(t){this.transfer(t)}async executeRequest(t,n,i){let s=this.mergeHeaders(n.headers),{signal:r,cleanup:c}=this.createTimeoutSignal(n.signal),p={...n,headers:s,credentials:this.useCredentials&&!s.Authorization?"include":void 0,signal:r};this.emit("request",t,p);try{let a=await fetch(t,p);return c(),a.ok||await this.handleResponseError(a,i),this.emit("response",this.safeClone(a),t),{data:await this.parseResponse(this.safeClone(a)),status:a.status}}catch(a){c();let d=a instanceof Error?a:new Error(String(a));this.emit("error",d,t),this.handleFetchError(a,i)}}async request(t,n,i){let{data:s}=await this.executeRequest(t,n,i);return s}async requestWithStatus(t,n,i){return this.executeRequest(t,n,i)}mergeHeaders(t={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t){let n=new AbortController,i=setTimeout(()=>n.abort(),this.timeout);if(t){let s=()=>n.abort();t.addEventListener("abort",s),t.aborted&&n.abort()}return{signal:n.signal,cleanup:()=>clearTimeout(i)}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}async handleResponseError(t,n){let i={};try{if(t.headers.get("content-type")?.includes("application/json")){let c=await t.json();if(c&&typeof c=="object"){let p=c;typeof p.message=="string"&&(i.message=p.message),typeof p.error=="string"&&(i.error=p.error)}}else i={message:await t.text()}}catch{i={message:"Failed to parse error response"}}let s=i.message||i.error||`${n} failed`;throw t.status===401?l.authentication(s):t.status===429?l.rateLimit(s):l.api(s,t.status)}handleFetchError(t,n){throw x(t)?t:t instanceof Error&&t.name==="AbortError"?l.cancelled(`${n} was cancelled`):t instanceof TypeError&&t.message.includes("fetch")?l.network(`${n} failed: ${t.message}`,t):t instanceof Error?l.business(`${n} failed: ${t.message}`):l.business(`${n} failed: Unknown error`)}async deploy(t,n={}){if(!t.length)throw l.business("No files to deploy");for(let a of t)if(!a.md5)throw l.file(`MD5 checksum missing for file: ${a.path}`,a.path);ze(n.password);let i=Z(n.labels),s=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa}:void 0,{body:r,headers:c}=await this.createDeployBody(t,{labels:i,via:n.via,password:n.password,flags:s}),p={};return n.deployToken?p.Authorization=`Bearer ${n.deployToken}`:n.apiKey&&(p.Authorization=`Bearer ${n.apiKey}`),n.caller&&(p["X-Caller"]=n.caller),this.request(`${n.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:r,headers:{...c,...p},signal:n.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${y.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(t){return this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(t,n){let i=Z(n);return this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:i})},"Update deployment labels")}async removeDeployment(t){await this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove deployment")}async setDomain(t,n,i){let s=Z(i),r={};n&&(r.deployment=n),s!==void 0&&(r.labels=s);let{data:c,status:p}=await this.requestWithStatus(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{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}${y.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{method:"GET"},"Get domain")}async removeDomain(t){await this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/share`,{method:"GET"},"Get domain share")}async validateDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:t})},"Validate domain")}async createToken(t,n){let i=Z(n),s={};return t!==void 0&&(s.ttl=t),i!==void 0&&(s.labels=i),this.request(`${this.apiUrl}${y.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${y.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(t){await this.request(`${this.apiUrl}${y.TOKENS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${y.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${y.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${y.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${y.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(t,n={}){let i=t.find(a=>a.path==="index.html"||a.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 r={"Content-Type":"application/json"};n.deployToken?r.Authorization=`Bearer ${n.deployToken}`:n.apiKey&&(r.Authorization=`Bearer ${n.apiKey}`);let c={files:t.map(a=>a.path),index:s};return(await this.request(`${this.apiUrl}${y.SPA_CHECK}`,{method:"POST",headers:r,body:JSON.stringify(c)},"SPA check")).isSPA}};v();pe();v();v();function Ae(e={},o={}){let t={apiUrl:e.apiUrl||o.apiUrl||H,apiKey:e.apiKey!==void 0?e.apiKey:o.apiKey,deployToken:e.deployToken!==void 0?e.deployToken:o.deployToken},n={apiUrl:t.apiUrl};return t.apiKey!==void 0&&(n.apiKey=t.apiKey),t.deployToken!==void 0&&(n.deployToken=t.deployToken),n}function He(e,o){let t={...e};return t.apiUrl===void 0&&o.apiUrl!==void 0&&(t.apiUrl=o.apiUrl),t.apiKey===void 0&&o.apiKey!==void 0&&(t.apiKey=o.apiKey),t.deployToken===void 0&&o.deployToken!==void 0&&(t.deployToken=o.deployToken),t.timeout===void 0&&o.timeout!==void 0&&(t.timeout=o.timeout),t.maxConcurrency===void 0&&o.maxConcurrency!==void 0&&(t.maxConcurrency=o.maxConcurrency),t.onProgress===void 0&&o.onProgress!==void 0&&(t.onProgress=o.onProgress),t.caller===void 0&&o.caller!==void 0&&(t.caller=o.caller),t}v();xe();async function Wt(){let e=JSON.stringify(Me,null,2),o;typeof Buffer<"u"?o=Buffer.from(e,"utf-8"):o=new Blob([e],{type:"application/json"});let{md5:t}=await ce(o);return{path:Te,content:o,size:e.length,md5:t}}async function qe(e,o,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(n=>n.path===Te))return e;try{if(await o.checkSPA(e,t)){let i=await Wt();return[...e,i]}}catch{}return e}function Je(e){let{getApi:o,ensureInit:t,processInput:n,clientDefaults:i,hasAuth:s}=e;return{upload:async(r,c={})=>{await t();let p=i?He(c,i):c;if(s&&!s()&&!p.deployToken&&!p.apiKey)try{let u=o(),{secret:A}=await u.fetchAgentToken();p.deployToken=A}catch(u){throw x(u)&&u.type===g.RateLimit?l.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):u}if(!n)throw l.config("processInput function is not provided.");let a=o(),d=await n(r,p);return d=await qe(d,a,p),a.deploy(d,p)},list:async()=>(await t(),o().listDeployments()),get:async r=>(await t(),o().getDeployment(r)),set:async(r,c)=>(await t(),o().updateDeploymentLabels(r,c.labels)),remove:async r=>{await t(),await o().removeDeployment(r)}}}function We(e){let{getApi:o,ensureInit:t}=e;return{set:async(n,i={})=>(await t(),o().setDomain(n,i.deployment,i.labels)),list:async()=>(await t(),o().listDomains()),get:async n=>(await t(),o().getDomain(n)),remove:async n=>{await t(),await o().removeDomain(n)},verify:async n=>(await t(),o().verifyDomain(n)),validate:async n=>(await t(),o().validateDomain(n)),dns:async n=>(await t(),o().getDomainDns(n)),records:async n=>(await t(),o().getDomainRecords(n)),share:async n=>(await t(),o().getDomainShare(n))}}function Ye(e){let{getApi:o,ensureInit:t}=e;return{get:async()=>(await t(),o().getAccount())}}function Xe(e){let{getApi:o,ensureInit:t}=e;return{create:async(n={})=>(await t(),o().createToken(n.ttl,n.labels)),list:async()=>(await t(),o().listTokens()),remove:async n=>{await t(),await o().removeToken(n)}}}var de=class{constructor(o={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=o,o.deployToken?this.auth={type:"token",value:o.deployToken}:o.apiKey&&(this.auth={type:"apiKey",value:o.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let t=this.resolveInitialConfig(o);this.http=new V({...o,...t,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=Je({...n,processInput:(i,s)=>this.processInput(i,s),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=We(n),this._account=Ye(n),this._tokens=Xe(n)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(o,t){return this.deployments.upload(o,t)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=le(),this._config)}on(o,t){this.http.on(o,t)}off(o,t){this.http.off(o,t)}setHeaders(o){this.customHeaders=o,this.http.setGlobalHeaders(o)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(o){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(o)}catch(t){console.warn("Event transfer failed during client replacement:",t)}this.http=o,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(o){if(!o||typeof o!="string")throw l.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:o}}setApiKey(o){if(!o||typeof o!="string")throw l.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:o}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};v();Q();var q=require("zod");v();Q();var Oe="ship",Yt=q.z.object({apiUrl:q.z.string().url().optional(),apiKey:q.z.string().min(1).optional(),deployToken:q.z.string().min(1).optional()}).strict();function Ze(e){try{return Yt.parse(e)}catch(o){if(o instanceof q.z.ZodError){let t=o.issues[0],n=t.path.length>0?` at ${t.path.join(".")}`:"";throw l.config(`Configuration validation failed${n}: ${t.message}`)}throw l.config("Configuration validation failed")}}async function Xt(e){try{if(L()!=="node")return{};let{cosmiconfigSync:o}=await import("cosmiconfig"),t=await import("os"),n=o(Oe,{searchPlaces:[`.${Oe}rc`,"package.json",`${t.homedir()}/.${Oe}rc`],stopDir:t.homedir()}),i;if(e?i=n.load(e):i=n.search(),i&&i.config)return Ze(i.config)}catch(o){if(x(o))throw o}return{}}async function Qe(e){if(L()!=="node")return{};let o={apiUrl:process.env.SHIP_API_URL||void 0,apiKey:process.env.SHIP_API_KEY||void 0,deployToken:process.env.SHIP_DEPLOY_TOKEN||void 0},t=await Xt(e),n={apiUrl:o.apiUrl??t.apiUrl,apiKey:o.apiKey??t.apiKey,deployToken:o.deployToken??t.deployToken};return Ze(n)}pe();v();async function et(e,o={}){let{FormData:t,File:n}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),{labels:s,via:r,password:c,flags:p}=o,a=new t,d=[];for(let C of e){if(!Buffer.isBuffer(C.content)&&!(typeof Blob<"u"&&C.content instanceof Blob))throw l.file(`Unsupported file.content type for Node.js: ${C.path}`,C.path);if(!C.md5)throw l.file(`File missing md5 checksum: ${C.path}`,C.path);let m=new n([C.content],C.path,{type:"application/octet-stream"});a.append("files[]",m),d.push(C.md5)}a.append("checksums",JSON.stringify(d)),s&&s.length>0&&a.append("labels",JSON.stringify(s)),r&&a.append("via",r),c&&a.append("password",c),p?.build&&a.append("build","true"),p?.prerender&&a.append("prerender","true"),p?.spa&&a.append("spa","true");let u=new i(a),A=[];for await(let C of u.encode())A.push(Buffer.from(C));let U=Buffer.concat(A);return{body:U.buffer.slice(U.byteOffset,U.byteOffset+U.byteLength),headers:{"Content-Type":u.contentType,"Content-Length":Buffer.byteLength(U).toString()}}}var ue=class extends de{constructor(o={}){if(L()!=="node")throw l.business("Node.js Ship class can only be used in Node.js environment.");super(o)}resolveInitialConfig(o){return Ae(o,{})}async loadFullConfig(){try{let o=await Qe(this.clientOptions.configFile),t=Ae(this.clientOptions,o);t.deployToken&&!this.clientOptions.deployToken?this.setDeployToken(t.deployToken):t.apiKey&&!this.clientOptions.apiKey&&this.setApiKey(t.apiKey);let n=new V({...this.clientOptions,...t,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});this.replaceHttpClient(n);let i=await this.http.getConfig();Be(i)}catch(o){throw this.initPromise=null,o}}async processInput(o,t){let n=typeof o=="string"?[o]:o;if(!Array.isArray(n)||!n.every(s=>typeof s=="string"))throw l.business("Invalid input type for Node.js environment. Expected string or string[].");if(n.length===0)throw l.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(ft(),ut));return i(n,t)}getDeployBodyCreator(){return et}};v();var G=require("fs"),ge=T(require("path"),1);var Fe=T(require("columnify"),1),f=require("yoctocolors"),ht=["isCreate","claim"],w=(e,o,t)=>t?o:e(o),E=(e,o,t)=>{console.log(o?JSON.stringify({success:e},null,2)+`
|
|
3
|
-
`:`${
|
|
2
|
+
"use strict";var _t=Object.create;var Se=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty;var P=(e,o)=>()=>(e&&(o=e(e=0)),o);var Gt=(e,o)=>{for(var t in o)Se(e,t,{get:o[t],enumerable:!0})},zt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of Mt(o))!Kt.call(e,i)&&i!==t&&Se(e,i,{get:()=>o[i],enumerable:!(n=Ut(o,i))||n.enumerable});return e};var T=(e,o,t)=>(t=e!=null?_t(jt(e)):{},zt(o||!e||!e.__esModule?Se(t,"default",{value:e,enumerable:!0}):t,e));function x(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function we(e){let o=e.lastIndexOf(".");if(o===-1||o===e.length-1)return!1;let t=e.slice(o+1).toLowerCase();return Bt.has(t)}function Ue(e){return Ht.test(e)}function Ee(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>ve.has(t))}function re(e){if(!e.startsWith(z))throw l.validation(`API key must start with "${z}"`);if(e.length!==Ne)throw l.validation(`API key must be ${Ne} characters total (${z} + ${be} hex chars)`);let o=e.slice(z.length);if(!/^[a-f0-9]{64}$/i.test(o))throw l.validation(`API key must contain ${be} hexadecimal characters after "${z}" prefix`)}function je(e){if(!e.startsWith(B))throw l.validation(`Deploy token must start with "${B}"`);if(e.length!==_e)throw l.validation(`Deploy token must be ${_e} characters total (${B} + ${Ce} hex chars)`);let o=e.slice(B.length);if(!/^[a-f0-9]{64}$/i.test(o))throw l.validation(`Deploy token must contain ${Ce} hexadecimal characters after "${B}" prefix`)}function Ke(e){try{let o=new URL(e);if(!["http:","https:"].includes(o.protocol))throw l.validation("API URL must use http:// or https:// protocol");if(o.pathname!=="/"&&o.pathname!=="")throw l.validation("API URL must not contain a path");if(o.search||o.hash)throw l.validation("API URL must not contain query parameters or fragments")}catch(o){throw x(o)?o:l.validation("API URL must be a valid URL")}}var g,De,l,Bt,Ht,ve,z,be,Ne,B,Ce,_e,Te,Me,H,M,Ge,X,w=P(()=>{"use strict";(function(e){e.Validation="validation_failed",e.NotFound="not_found",e.RateLimit="rate_limit_exceeded",e.Authentication="authentication_failed",e.Business="business_logic_error",e.Api="internal_server_error",e.Network="network_error",e.Cancelled="operation_cancelled",e.File="file_error",e.Config="config_error"})(g||(g={}));De={client:new Set([g.Business,g.Config,g.File,g.Validation]),network:new Set([g.Network]),auth:new Set([g.Authentication])},l=class e extends Error{type;status;details;constructor(o,t,n,i){super(t),this.type=o,this.status=n,this.details=i,this.name="ShipError"}toResponse(){let o=this.type===g.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:o}}static fromResponse(o){return new e(o.error,o.message,o.status,o.details)}static validation(o,t){return new e(g.Validation,o,400,t)}static notFound(o,t){let n=t?`${o} ${t} not found`:`${o} not found`;return new e(g.NotFound,n,404)}static rateLimit(o="Too many requests"){return new e(g.RateLimit,o,429)}static authentication(o="Authentication required",t){return new e(g.Authentication,o,401,t)}static business(o,t=400){return new e(g.Business,o,t)}static network(o,t){return new e(g.Network,o,void 0,{cause:t})}static cancelled(o){return new e(g.Cancelled,o)}static file(o,t){return new e(g.File,o,void 0,{filePath:t})}static config(o,t){return new e(g.Config,o,void 0,t)}static api(o,t=500){return new e(g.Api,o,t)}static database(o,t=500){return new e(g.Api,o,t)}static storage(o,t=500){return new e(g.Api,o,t)}get filePath(){return this.details?.filePath}isClientError(){return De.client.has(this.type)}isNetworkError(){return De.network.has(this.type)}isAuthError(){return De.auth.has(this.type)}isValidationError(){return this.type===g.Validation}isFileError(){return this.type===g.File}isConfigError(){return this.type===g.Config}isType(o){return this.type===o}};Bt=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Ht=/[\x00-\x1f\x7f#?%\\<>"]/;ve=new Set(["node_modules","package.json"]);z="ship-",be=64,Ne=z.length+be,B="token-",Ce=64,_e=B.length+Ce,Te="ship.json",Me={rewrites:[{source:"/(.*)",destination:"/index.html"}]};H="https://api.shipstatic.com",M={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ge=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,X={MIN_LENGTH:6,MAX_LENGTH:128}});function Be(e){Re=e}function le(){if(Re===null)throw l.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Re}var Re,pe=P(()=>{"use strict";w();Re=null});function qt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function L(){return Ve||qt()}var Ve,Q=P(()=>{"use strict";Ve=null});async function Jt(e){let o=(await import("spark-md5")).default;return new Promise((t,n)=>{let s=Math.ceil(e.size/2097152),r=0,c=new o.ArrayBuffer,p=new FileReader,a=()=>{let d=r*2097152,m=Math.min(d+2097152,e.size);p.readAsArrayBuffer(e.slice(d,m))};p.onload=d=>{let m=d.target?.result;if(!m){n(l.business("Failed to read file chunk"));return}c.append(m),r++,r<s?a():t({md5:c.end()})},p.onerror=()=>{n(l.business("Failed to calculate MD5: FileReader error"))},a()})}async function Wt(e){let o=await import("crypto");if(Buffer.isBuffer(e)){let n=o.createHash("md5");return n.update(e),{md5:n.digest("hex")}}let t=await import("fs");return new Promise((n,i)=>{let s=o.createHash("md5"),r=t.createReadStream(e);r.on("error",c=>i(l.business(`Failed to read file for MD5: ${c.message}`))),r.on("data",c=>s.update(c)),r.on("end",()=>n({md5:s.digest("hex")}))})}async function ce(e){let o=L();if(o==="browser"){if(!(e instanceof Blob))throw l.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return Jt(e)}if(o==="node"){if(!(Buffer.isBuffer(e)||typeof e=="string"))throw l.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Wt(e)}throw l.business("Unknown or unsupported execution environment for MD5 calculation.")}var xe=P(()=>{"use strict";Q();w()});function ot(e,o){if(!e||e.length===0)return[];if(!o?.allowUnbuilt&&e.find(n=>n&&Ee(n)))throw l.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let n=t.replace(/\\/g,"/").split("/").filter(Boolean);if(n.length===0)return!0;let i=n[n.length-1];if((0,tt.isJunk)(i))return!1;for(let r of n)if(r!==".well-known"&&(r.startsWith(".")||r.length>255))return!1;let s=n.slice(0,-1);for(let r of s)if(Qt.some(c=>r.toLowerCase()===c.toLowerCase()))return!1;return!0})}var tt,Qt,nt=P(()=>{"use strict";tt=require("junk");w();Qt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function it(e){if(!e||e.length===0)return"";let o=e.filter(s=>s&&typeof s=="string").map(s=>s.replace(/\\/g,"/"));if(o.length===0)return"";if(o.length===1)return o[0];let t=o.map(s=>s.split("/").filter(Boolean)),n=[],i=Math.min(...t.map(s=>s.length));for(let s=0;s<i;s++){let r=t[0][s];if(t.every(c=>c[s]===r))n.push(r);else break}return n.join("/")}function ue(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ke=P(()=>{"use strict"});function st(e,o={}){if(o.flatten===!1)return e.map(n=>({path:ue(n),name:Ie(n)}));let t=eo(e);return e.map(n=>{let i=ue(n);if(t){let s=t.endsWith("/")?t:`${t}/`;i.startsWith(s)&&(i=i.substring(s.length))}return i||(i=Ie(n)),{path:i,name:Ie(n)}})}function eo(e){if(!e.length)return"";let t=e.map(s=>ue(s)).map(s=>s.split("/")),n=[],i=Math.min(...t.map(s=>s.length));for(let s=0;s<i-1;s++){let r=t[0][s];if(t.every(c=>c[s]===r))n.push(r);else break}return n.join("/")}function Ie(e){return e.split(/[/\\]/).pop()||e}var rt=P(()=>{"use strict";ke()});function at(e){if(Ue(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 o=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return o.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}var lt=P(()=>{"use strict";w()});function pt(e,o){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw l.business(`Security error: Unsafe file path "${e}" for file: ${o}`)}function ct(e,o){let t=at(e);if(!t.valid)throw l.business(t.reason||"Invalid file name");if(we(e))throw l.business(`File extension not allowed: "${o}"`)}var dt=P(()=>{"use strict";w();lt()});var mt={};Gt(mt,{processFilesForNode:()=>to});function ut(e,o=new Set){let t=[],n=O.realpathSync(e);if(o.has(n))return t;o.add(n);let i=O.readdirSync(e);for(let s of i){let r=k.join(e,s),c=O.statSync(r);if(c.isDirectory()){let p=ut(r,o);t.push(...p)}else c.isFile()&&t.push(r)}return t}async function to(e,o={}){if(L()!=="node")throw l.business("processFilesForNode can only be called in Node.js environment.");for(let u of e){let b=k.resolve(u);try{if(O.statSync(b).isDirectory()){let I=O.readdirSync(b).find(F=>ve.has(F));if(I)throw l.business(`"${I}" detected \u2014 deploy your build output (dist/, build/, out/), not the project folder`)}}catch(I){if(x(I))throw I}}let t=e.flatMap(u=>{let b=k.resolve(u);try{return O.statSync(b).isDirectory()?ut(b):[b]}catch{throw l.file(`Path does not exist: ${u}`,u)}}),n=[...new Set(t)],i=e.map(u=>k.resolve(u)),s=it(i.map(u=>{try{return O.statSync(u).isDirectory()?u:k.dirname(u)}catch{return k.dirname(u)}})),r=n.map(u=>{if(s&&s.length>0){let b=k.relative(s,u);if(b&&typeof b=="string"&&!b.startsWith(".."))return b.replace(/\\/g,"/")}return k.basename(u)}),p=st(r,{flatten:o.pathDetect!==!1}).map(u=>u.path),a=new Set(ot(p));if(a.size===0)return[];let d=[],m=[];for(let u=0;u<n.length;u++)a.has(p[u])&&(d.push(n[u]),m.push(p[u]));let A=[],U=0,C=le();for(let u=0;u<d.length;u++){let b=d[u],I=m[u];try{pt(I,b);let F=O.statSync(b);if(F.size===0)continue;if(ct(I,b),F.size>C.maxFileSize)throw l.business(`File ${b} is too large. Maximum allowed size is ${C.maxFileSize/(1024*1024)}MB.`);if(U+=F.size,U>C.maxTotalSize)throw l.business(`Total deploy size is too large. Maximum allowed is ${C.maxTotalSize/(1024*1024)}MB.`);let Y=O.readFileSync(b),{md5:Nt}=await ce(Y);A.push({path:I,content:Y,size:Y.length,md5:Nt})}catch(F){if(x(F))throw F;let Y=F instanceof Error?F.message:String(F);throw l.file(`Failed to read file "${b}": ${Y}`,b)}}if(A.length>C.maxFilesCount)throw l.business(`Too many files to deploy. Maximum allowed is ${C.maxFilesCount} files.`);return A}var O,k,ft=P(()=>{"use strict";Q();xe();nt();dt();w();pe();rt();ke();O=T(require("fs"),1),k=T(require("path"),1)});var It=require("commander");w();var ae=class{constructor(){this.handlers=new Map}on(o,t){this.handlers.has(o)||this.handlers.set(o,new Set),this.handlers.get(o).add(t)}off(o,t){let n=this.handlers.get(o);n&&(n.delete(t),n.size===0&&this.handlers.delete(o))}emit(o,...t){let n=this.handlers.get(o);if(!n)return;let i=Array.from(n);for(let s of i)try{s(...t)}catch(r){n.delete(s),o!=="error"&&setTimeout(()=>{r instanceof Error?this.emit("error",r,String(o)):this.emit("error",new Error(String(r)),String(o))},0)}}transfer(o){this.handlers.forEach((t,n)=>{t.forEach(i=>{o.on(n,i)})})}clear(){this.handlers.clear()}};w();function ze(e){if(e!=null){if(typeof e!="string")throw l.validation("Password must be a string");if(e.length<X.MIN_LENGTH||e.length>X.MAX_LENGTH)throw l.validation(`Password must be between ${X.MIN_LENGTH} and ${X.MAX_LENGTH} characters`)}}function Z(e){if(e==null)return;if(e.length===0)return e;if(e.length>M.MAX_COUNT)throw l.validation(`Maximum ${M.MAX_COUNT} labels allowed`);let o=e.map((n,i)=>{if(typeof n!="string")throw l.validation(`Label at index ${i} must be a string`);let s=n.trim().toLowerCase();if(s.length<M.MIN_LENGTH)throw l.validation(`Labels must be at least ${M.MIN_LENGTH} characters long`);if(s.length>M.MAX_LENGTH)throw l.validation(`Labels must be no more than ${M.MAX_LENGTH} characters long`);if(!Ge.test(s))throw l.validation(`Labels must start and end with alphanumeric characters, with optional separators (${M.SEPARATORS}) between segments`);return s}),t=[...new Set(o)];if(t.length!==o.length)throw l.validation("Duplicate labels are not allowed");return t}var y={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Vt=3e4,V=class extends ae{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||H,this.getAuthHeadersCallback=t.getAuthHeaders,this.useCredentials=t.useCredentials??!1,this.timeout=t.timeout??Vt,this.createDeployBody=t.createDeployBody,this.deployEndpoint=t.deployEndpoint||y.DEPLOYMENTS}setGlobalHeaders(t){this.globalHeaders=t}transferEventsTo(t){this.transfer(t)}async executeRequest(t,n,i){let s=this.mergeHeaders(n.headers),{signal:r,cleanup:c}=this.createTimeoutSignal(n.signal),p={...n,headers:s,credentials:this.useCredentials&&!s.Authorization?"include":void 0,signal:r};this.emit("request",t,p);try{let a=await fetch(t,p);return c(),a.ok||await this.handleResponseError(a,i),this.emit("response",this.safeClone(a),t),{data:await this.parseResponse(this.safeClone(a)),status:a.status}}catch(a){c();let d=a instanceof Error?a:new Error(String(a));this.emit("error",d,t),this.handleFetchError(a,i)}}async request(t,n,i){let{data:s}=await this.executeRequest(t,n,i);return s}async requestWithStatus(t,n,i){return this.executeRequest(t,n,i)}mergeHeaders(t={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t){let n=new AbortController,i=setTimeout(()=>n.abort(),this.timeout);if(t){let s=()=>n.abort();t.addEventListener("abort",s),t.aborted&&n.abort()}return{signal:n.signal,cleanup:()=>clearTimeout(i)}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}async handleResponseError(t,n){let i={};try{if(t.headers.get("content-type")?.includes("application/json")){let c=await t.json();if(c&&typeof c=="object"){let p=c;typeof p.message=="string"&&(i.message=p.message),typeof p.error=="string"&&(i.error=p.error)}}else i={message:await t.text()}}catch{i={message:"Failed to parse error response"}}let s=i.message||i.error||`${n} failed`;throw t.status===401?l.authentication(s):t.status===429?l.rateLimit(s):l.api(s,t.status)}handleFetchError(t,n){throw x(t)?t:t instanceof Error&&t.name==="AbortError"?l.cancelled(`${n} was cancelled`):t instanceof TypeError&&t.message.includes("fetch")?l.network(`${n} failed: ${t.message}`,t):t instanceof Error?l.business(`${n} failed: ${t.message}`):l.business(`${n} failed: Unknown error`)}async deploy(t,n={}){if(!t.length)throw l.business("No files to deploy");for(let a of t)if(!a.md5)throw l.file(`MD5 checksum missing for file: ${a.path}`,a.path);ze(n.password);let i=Z(n.labels),s=n.build||n.prerender||n.spa?{build:n.build,prerender:n.prerender,spa:n.spa}:void 0,{body:r,headers:c}=await this.createDeployBody(t,{labels:i,via:n.via,password:n.password,flags:s}),p={};return n.deployToken?p.Authorization=`Bearer ${n.deployToken}`:n.apiKey&&(p.Authorization=`Bearer ${n.apiKey}`),n.caller&&(p["X-Caller"]=n.caller),this.request(`${n.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:r,headers:{...c,...p},signal:n.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${y.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(t){return this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(t,n){let i=Z(n);return this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:i})},"Update deployment labels")}async removeDeployment(t){await this.request(`${this.apiUrl}${y.DEPLOYMENTS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove deployment")}async setDomain(t,n,i){let s=Z(i),r={};n&&(r.deployment=n),s!==void 0&&(r.labels=s);let{data:c,status:p}=await this.requestWithStatus(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{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}${y.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{method:"GET"},"Get domain")}async removeDomain(t){await this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(t){return this.request(`${this.apiUrl}${y.DOMAINS}/${encodeURIComponent(t)}/share`,{method:"GET"},"Get domain share")}async validateDomain(t){return this.request(`${this.apiUrl}${y.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:t})},"Validate domain")}async createToken(t,n){let i=Z(n),s={};return t!==void 0&&(s.ttl=t),i!==void 0&&(s.labels=i),this.request(`${this.apiUrl}${y.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${y.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(t){await this.request(`${this.apiUrl}${y.TOKENS}/${encodeURIComponent(t)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${y.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${y.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${y.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${y.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(t,n={}){let i=t.find(a=>a.path==="index.html"||a.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 r={"Content-Type":"application/json"};n.deployToken?r.Authorization=`Bearer ${n.deployToken}`:n.apiKey&&(r.Authorization=`Bearer ${n.apiKey}`);let c={files:t.map(a=>a.path),index:s};return(await this.request(`${this.apiUrl}${y.SPA_CHECK}`,{method:"POST",headers:r,body:JSON.stringify(c)},"SPA check")).isSPA}};w();pe();w();w();function Ae(e={},o={}){let t={apiUrl:e.apiUrl||o.apiUrl||H,apiKey:e.apiKey!==void 0?e.apiKey:o.apiKey,deployToken:e.deployToken!==void 0?e.deployToken:o.deployToken},n={apiUrl:t.apiUrl};return t.apiKey!==void 0&&(n.apiKey=t.apiKey),t.deployToken!==void 0&&(n.deployToken=t.deployToken),n}function He(e,o){let t={...e};return t.apiUrl===void 0&&o.apiUrl!==void 0&&(t.apiUrl=o.apiUrl),t.apiKey===void 0&&o.apiKey!==void 0&&(t.apiKey=o.apiKey),t.deployToken===void 0&&o.deployToken!==void 0&&(t.deployToken=o.deployToken),t.timeout===void 0&&o.timeout!==void 0&&(t.timeout=o.timeout),t.maxConcurrency===void 0&&o.maxConcurrency!==void 0&&(t.maxConcurrency=o.maxConcurrency),t.onProgress===void 0&&o.onProgress!==void 0&&(t.onProgress=o.onProgress),t.caller===void 0&&o.caller!==void 0&&(t.caller=o.caller),t}w();xe();async function Yt(){let e=JSON.stringify(Me,null,2),o;typeof Buffer<"u"?o=Buffer.from(e,"utf-8"):o=new Blob([e],{type:"application/json"});let{md5:t}=await ce(o);return{path:Te,content:o,size:e.length,md5:t}}async function qe(e,o,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(n=>n.path===Te))return e;try{if(await o.checkSPA(e,t)){let i=await Yt();return[...e,i]}}catch{}return e}function Je(e){let{getApi:o,ensureInit:t,processInput:n,clientDefaults:i,hasAuth:s}=e;return{upload:async(r,c={})=>{await t();let p=i?He(c,i):c;if(s&&!s()&&!p.deployToken&&!p.apiKey)try{let m=o(),{secret:A}=await m.fetchAgentToken();p.deployToken=A}catch(m){throw x(m)&&m.type===g.RateLimit?l.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):m}if(!n)throw l.config("processInput function is not provided.");let a=o(),d=await n(r,p);return d=await qe(d,a,p),a.deploy(d,p)},list:async()=>(await t(),o().listDeployments()),get:async r=>(await t(),o().getDeployment(r)),set:async(r,c)=>(await t(),o().updateDeploymentLabels(r,c.labels)),remove:async r=>{await t(),await o().removeDeployment(r)}}}function We(e){let{getApi:o,ensureInit:t}=e;return{set:async(n,i={})=>(await t(),o().setDomain(n,i.deployment,i.labels)),list:async()=>(await t(),o().listDomains()),get:async n=>(await t(),o().getDomain(n)),remove:async n=>{await t(),await o().removeDomain(n)},verify:async n=>(await t(),o().verifyDomain(n)),validate:async n=>(await t(),o().validateDomain(n)),dns:async n=>(await t(),o().getDomainDns(n)),records:async n=>(await t(),o().getDomainRecords(n)),share:async n=>(await t(),o().getDomainShare(n))}}function Ye(e){let{getApi:o,ensureInit:t}=e;return{get:async()=>(await t(),o().getAccount())}}function Xe(e){let{getApi:o,ensureInit:t}=e;return{create:async(n={})=>(await t(),o().createToken(n.ttl,n.labels)),list:async()=>(await t(),o().listTokens()),remove:async n=>{await t(),await o().removeToken(n)}}}var de=class{constructor(o={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=o,o.deployToken?this.auth={type:"token",value:o.deployToken}:o.apiKey&&(this.auth={type:"apiKey",value:o.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let t=this.resolveInitialConfig(o);this.http=new V({...o,...t,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let n={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=Je({...n,processInput:(i,s)=>this.processInput(i,s),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=We(n),this._account=Ye(n),this._tokens=Xe(n)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(o,t){return this.deployments.upload(o,t)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=le(),this._config)}on(o,t){this.http.on(o,t)}off(o,t){this.http.off(o,t)}setHeaders(o){this.customHeaders=o,this.http.setGlobalHeaders(o)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(o){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(o)}catch(t){console.warn("Event transfer failed during client replacement:",t)}this.http=o,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(o){if(!o||typeof o!="string")throw l.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:o}}setApiKey(o){if(!o||typeof o!="string")throw l.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:o}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};w();Q();var q=require("zod");w();Q();var Oe="ship",Xt=q.z.object({apiUrl:q.z.string().url().optional(),apiKey:q.z.string().min(1).optional(),deployToken:q.z.string().min(1).optional()}).strict();function Ze(e){try{return Xt.parse(e)}catch(o){if(o instanceof q.z.ZodError){let t=o.issues[0],n=t.path.length>0?` at ${t.path.join(".")}`:"";throw l.config(`Configuration validation failed${n}: ${t.message}`)}throw l.config("Configuration validation failed")}}async function Zt(e){try{if(L()!=="node")return{};let{cosmiconfigSync:o}=await import("cosmiconfig"),t=await import("os"),n=o(Oe,{searchPlaces:[`.${Oe}rc`,"package.json",`${t.homedir()}/.${Oe}rc`],stopDir:t.homedir()}),i;if(e?i=n.load(e):i=n.search(),i&&i.config)return Ze(i.config)}catch(o){if(x(o))throw o}return{}}async function Qe(e){if(L()!=="node")return{};let o={apiUrl:process.env.SHIP_API_URL||void 0,apiKey:process.env.SHIP_API_KEY||void 0,deployToken:process.env.SHIP_DEPLOY_TOKEN||void 0},t=await Zt(e),n={apiUrl:o.apiUrl??t.apiUrl,apiKey:o.apiKey??t.apiKey,deployToken:o.deployToken??t.deployToken};return Ze(n)}pe();w();async function et(e,o={}){let{FormData:t,File:n}=await import("formdata-node"),{FormDataEncoder:i}=await import("form-data-encoder"),{labels:s,via:r,password:c,flags:p}=o,a=new t,d=[];for(let C of e){if(!Buffer.isBuffer(C.content)&&!(typeof Blob<"u"&&C.content instanceof Blob))throw l.file(`Unsupported file.content type for Node.js: ${C.path}`,C.path);if(!C.md5)throw l.file(`File missing md5 checksum: ${C.path}`,C.path);let u=new n([C.content],C.path,{type:"application/octet-stream"});a.append("files[]",u),d.push(C.md5)}a.append("checksums",JSON.stringify(d)),s&&s.length>0&&a.append("labels",JSON.stringify(s)),r&&a.append("via",r),c&&a.append("password",c),p?.build&&a.append("build","true"),p?.prerender&&a.append("prerender","true"),p?.spa&&a.append("spa","true");let m=new i(a),A=[];for await(let C of m.encode())A.push(Buffer.from(C));let U=Buffer.concat(A);return{body:U.buffer.slice(U.byteOffset,U.byteOffset+U.byteLength),headers:{"Content-Type":m.contentType,"Content-Length":Buffer.byteLength(U).toString()}}}var me=class extends de{constructor(o={}){if(L()!=="node")throw l.business("Node.js Ship class can only be used in Node.js environment.");super(o)}resolveInitialConfig(o){return Ae(o,{})}async loadFullConfig(){try{let o=await Qe(this.clientOptions.configFile),t=Ae(this.clientOptions,o);t.deployToken&&!this.clientOptions.deployToken?this.setDeployToken(t.deployToken):t.apiKey&&!this.clientOptions.apiKey&&this.setApiKey(t.apiKey);let n=new V({...this.clientOptions,...t,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});this.replaceHttpClient(n);let i=await this.http.getConfig();Be(i)}catch(o){throw this.initPromise=null,o}}async processInput(o,t){let n=typeof o=="string"?[o]:o;if(!Array.isArray(n)||!n.every(s=>typeof s=="string"))throw l.business("Invalid input type for Node.js environment. Expected string or string[].");if(n.length===0)throw l.business("No files to deploy.");let{processFilesForNode:i}=await Promise.resolve().then(()=>(ft(),mt));return i(n,t)}getDeployBodyCreator(){return et}};w();var G=require("fs"),ge=T(require("path"),1);var Fe=T(require("columnify"),1),h=require("yoctocolors"),ht=["isCreate","claim"],v=(e,o,t)=>t?o:e(o),E=(e,o,t)=>{console.log(o?JSON.stringify({success:e},null,2)+`
|
|
3
|
+
`:`${v(h.green,e.toLowerCase().replace(/\.$/,""),t)}
|
|
4
4
|
`)},R=(e,o,t)=>{if(o)console.error(JSON.stringify({error:e},null,2)+`
|
|
5
|
-
`);else{let n=
|
|
5
|
+
`);else{let n=v(s=>(0,h.inverse)((0,h.red)(s)),`${v(h.hidden,"[",t)}error${v(h.hidden,"]",t)}`,t),i=v(h.red,e.toLowerCase().replace(/\.$/,""),t);console.error(`${n} ${i}
|
|
6
6
|
`)}},fe=(e,o,t)=>{if(o)console.log(JSON.stringify({warning:e},null,2)+`
|
|
7
|
-
`);else{let n=
|
|
7
|
+
`);else{let n=v(s=>(0,h.inverse)((0,h.yellow)(s)),`${v(h.hidden,"[",t)}warning${v(h.hidden,"]",t)}`,t),i=v(h.yellow,e.toLowerCase().replace(/\.$/,""),t);console.log(`${n} ${i}
|
|
8
8
|
`)}},j=(e,o,t)=>{if(o)console.log(JSON.stringify({info:e},null,2)+`
|
|
9
|
-
`);else{let n=
|
|
10
|
-
`)}},
|
|
9
|
+
`);else{let n=v(s=>(0,h.inverse)((0,h.blue)(s)),`${v(h.hidden,"[",t)}info${v(h.hidden,"]",t)}`,t),i=v(h.blue,e.toLowerCase().replace(/\.$/,""),t);console.log(`${n} ${i}
|
|
10
|
+
`)}},oo=(e,o="details",t)=>{if(e==null||e===0)return"-";let n=new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z");return o==="table"?n.replace(/T/,v(h.hidden,"T",t)).replace(/Z$/,v(h.hidden,"Z",t)):n},gt=(e,o,t="details",n)=>{if(o===null||Array.isArray(o)&&o.length===0)return"-";if(typeof o=="number"&&(e==="created"||e==="activated"||e==="expires"||e==="linked"||e==="grace"))return oo(o,t,n);if(e==="size"&&typeof o=="number"){let i=o/1048576;return i>=1?`${i.toFixed(1)}Mb`:`${(o/1024).toFixed(1)}Kb`}if(e==="config"){if(typeof o=="boolean")return o?"yes":"no";if(typeof o=="number")return o===1?"yes":"no"}return String(o)},ee=(e,o,t,n)=>{if(!e||e.length===0)return"";let i=e[0],s=o||Object.keys(i).filter(p=>i[p]!==void 0&&!ht.includes(p)),r=e.map(p=>{let a=p,d={};return s.forEach(m=>{m in a&&a[m]!==void 0&&(d[m]=gt(m,a[m],"table",t))}),d});return(0,Fe.default)(r,{columnSplitter:" ",columns:s,config:s.reduce((p,a)=>(p[a]={headingTransform:d=>v(h.dim,n?.[d]||d,t)},p),{})}).split(`
|
|
11
11
|
`).map(p=>p.replace(/\0/g,"").replace(/\s+$/,"")).join(`
|
|
12
12
|
`)+`
|
|
13
|
-
`},J=(e,o)=>{let t=Object.entries(e).filter(([s,r])=>ht.includes(s)?!1:r!==void 0);if(t.length===0)return"";let n=t.map(([s,r])=>({property:s+":",value:gt(s,r,"details",o)}));return(0,Fe.default)(n,{columnSplitter:" ",showHeaders:!1,config:{property:{dataTransform:s=>
|
|
13
|
+
`},J=(e,o)=>{let t=Object.entries(e).filter(([s,r])=>ht.includes(s)?!1:r!==void 0);if(t.length===0)return"";let n=t.map(([s,r])=>({property:s+":",value:gt(s,r,"details",o)}));return(0,Fe.default)(n,{columnSplitter:" ",showHeaders:!1,config:{property:{dataTransform:s=>v(h.dim,s,o)}}}).split(`
|
|
14
14
|
`).map(s=>s.replace(/\0/g,"")).join(`
|
|
15
15
|
`)+`
|
|
16
|
-
`};var Pe=(e,o)=>`https://setup.shipstatic.com/${e}/${o}`;function
|
|
16
|
+
`};var Pe=(e,o)=>`https://setup.shipstatic.com/${e}/${o}`;function no(e,o,t){let{noColor:n}=t;if(e.deployments.length===0){console.log("no deployments found"),console.log();return}let i=["deployment","labels","files","size","created","via"];console.log(ee(e.deployments,i,n))}function io(e,o,t){let{noColor:n}=t;if(e.domains.length===0){console.log("no domains found"),console.log();return}let i=["domain","deployment","labels","linked","links","created"];console.log(ee(e.domains,i,n))}function so(e,o,t){let{noColor:n}=t,{_dnsRecords:i,_shareHash:s,isCreate:r,...c}=e;if(o.operation==="set"){let p=r?"created":"updated";E(`${e.url} domain ${p}`,!1,n)}i&&i.length>0&&(console.log(),j("DNS Records to configure:",!1,n),i.forEach(p=>{console.log(` ${p.type}: ${p.name} \u2192 ${p.value}`)})),s&&(console.log(),j(`Setup instructions: ${Pe(s,e.domain)}`,!1,n)),console.log(J(c,n))}function ro(e,o,t){let{noColor:n}=t;o.operation==="upload"&&E(`${e.url} deployment uploaded`,!1,n),console.log(J(e,n));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:
|
|
17
17
|
${i}
|
|
18
|
-
`),j("configure a free API key with 'ship config' to deploy to your own account",!1,n)}}function
|
|
18
|
+
`),j("configure a free API key with 'ship config' to deploy to your own account",!1,n)}}function ao(e,o,t){let{noColor:n}=t;console.log(J(e,n))}function lo(e,o,t){let{noColor:n}=t;e.message&&E(e.message,!1,n)}function po(e,o,t){let{noColor:n}=t;if(e.valid){if(E("domain is valid",!1,n),console.log(),e.normalized&&console.log(` normalized: ${e.normalized}`),e.available!==null){let i=e.available?n?"available":"available \u2713":"already taken";console.log(` availability: ${i}`)}console.log()}else R(e.error||"domain is invalid",!1,n)}function co(e,o,t){let{noColor:n}=t;if(e.records.length===0){console.log("no records found"),console.log();return}let i=["type","name","value"];console.log(ee(e.records,i,n))}function uo(e,o,t){let{noColor:n}=t,i=e.dns?.provider?.name||null;console.log(J({domain:e.domain,provider:i},n))}function mo(e,o,t){let{noColor:n}=t;E(Pe(e.hash,e.domain),!1,n)}function fo(e,o,t){let{noColor:n}=t;if(e.tokens.length===0){console.log("no tokens found"),console.log();return}let i=["token","labels","created","expires"];console.log(ee(e.tokens,i,n))}function ho(e,o,t){let{noColor:n}=t;o.operation==="create"&&e.token&&E(`token ${e.token} created`,!1,n),console.log(J(e,n))}function yt(e,o,t){let{json:n,quiet:i,noColor:s}=t;if(i){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(Pe(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){o.operation==="remove"&&o.resourceType&&o.resourceId?E(`${o.resourceId} ${o.resourceType.toLowerCase()} removed`,n,s):E("removed successfully",n,s);return}if(typeof e=="boolean"){e?E("api reachable",n,s):R("api unreachable",n,s);return}if(n&&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?no(e,o,t):"domains"in e?io(e,o,t):"tokens"in e?fo(e,o,t):"records"in e?co(e,o,t):"hash"in e?mo(e,o,t):"dns"in e?uo(e,o,t):"domain"in e?so(e,o,t):"deployment"in e?ro(e,o,t):"token"in e?ho(e,o,t):"email"in e?ao(e,o,t):"valid"in e?po(e,o,t):"message"in e?lo(e,o,t):E("success",n,s):E("success",n,s)}var S=T(require("fs"),1),N=T(require("path"),1),$e=T(require("os"),1);function St(){let e=process.env.SHELL||"";return e.includes("bash")?"bash":e.includes("zsh")?"zsh":e.includes("fish")?"fish":null}function Dt(e,o){switch(e){case"bash":return{completionFile:N.join(o,".ship_completion.bash"),profileFile:N.join(o,".bash_profile"),scriptName:"ship.bash"};case"zsh":return{completionFile:N.join(o,".ship_completion.zsh"),profileFile:N.join(o,".zshrc"),scriptName:"ship.zsh"};case"fish":return{completionFile:N.join(o,".config/fish/completions/ship.fish"),profileFile:null,scriptName:"ship.fish"}}}function bt(e,o={}){let{json:t,noColor:n}=o,i=St(),s=$e.homedir();if(!i){R(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`,t,n);return}let r=Dt(i,s),c=N.join(e,r.scriptName);try{if(i==="fish"){let a=N.dirname(r.completionFile);S.existsSync(a)||S.mkdirSync(a,{recursive:!0}),S.copyFileSync(c,r.completionFile),E("fish completion installed successfully",t,n),j("please restart your shell to apply the changes",t,n);return}S.copyFileSync(c,r.completionFile);let p=`# ship
|
|
19
19
|
source '${r.completionFile}'
|
|
20
20
|
# ship end`;if(r.profileFile){if(S.existsSync(r.profileFile)){let a=S.readFileSync(r.profileFile,"utf-8");if(!a.includes("# ship")||!a.includes("# ship end")){let d=a.length>0&&!a.endsWith(`
|
|
21
21
|
`)?`
|
|
22
22
|
`:"";S.appendFileSync(r.profileFile,d+p)}}else S.writeFileSync(r.profileFile,p);E(`completion script installed for ${i}`,t,n),fe(`run "source ${r.profileFile}" or restart your shell`,t,n)}}catch(p){let a=p instanceof Error?p.message:String(p);R(`could not install completion script: ${a}`,t,n)}}function Ct(e={}){let{json:o,noColor:t}=e,n=St(),i=$e.homedir();if(!n){R(`unsupported shell: ${process.env.SHELL}. supported: bash, zsh, fish`,o,t);return}let s=Dt(n,i);try{if(n==="fish"){S.existsSync(s.completionFile)?(S.unlinkSync(s.completionFile),E("fish completion uninstalled successfully",o,t)):fe("fish completion was not installed",o,t),j("please restart your shell to apply the changes",o,t);return}if(S.existsSync(s.completionFile)&&S.unlinkSync(s.completionFile),!s.profileFile)return;if(!S.existsSync(s.profileFile)){R("profile file not found",o,t);return}let r=S.readFileSync(s.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
|
|
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 m=r.endsWith(`
|
|
24
24
|
`),A=p.length===0?"":p.join(`
|
|
25
|
-
`)+(
|
|
26
|
-
`:"");S.writeFileSync(s.profileFile,A),E(`completion script uninstalled for ${n}`,o,t),fe(`run "source ${s.profileFile}" or restart your shell`,o,t)}else R("completion was not found in profile",o,t)}catch(r){let c=r instanceof Error?r.message:String(r);R(`could not uninstall completion script: ${c}`,o,t)}}var Et=require("readline/promises"),K=require("fs"),Tt=require("os"),Rt=require("path");
|
|
27
|
-
`);return}let s=
|
|
25
|
+
`)+(m?`
|
|
26
|
+
`:"");S.writeFileSync(s.profileFile,A),E(`completion script uninstalled for ${n}`,o,t),fe(`run "source ${s.profileFile}" or restart your shell`,o,t)}else R("completion was not found in profile",o,t)}catch(r){let c=r instanceof Error?r.message:String(r);R(`could not uninstall completion script: ${c}`,o,t)}}var Et=require("readline/promises"),K=require("fs"),Tt=require("os"),Rt=require("path");w();var he=require("yoctocolors"),W=(0,Rt.join)((0,Tt.homedir)(),".shiprc");function wt(e){return e.length<13?e:e.slice(0,9)+"..."+e.slice(-4)}function vt(){try{return(0,K.existsSync)(W)?JSON.parse((0,K.readFileSync)(W,"utf-8")):{}}catch{return{}}}async function At(e={}){let{noColor:o,json:t}=e,n=d=>o?d:(0,he.dim)(d),i=d=>o?d:(0,he.green)(d);if(t){let d=vt(),m=typeof d.apiKey=="string"?d.apiKey:void 0,A=typeof d.apiUrl=="string"?d.apiUrl:void 0;console.log(JSON.stringify({path:W,exists:(0,K.existsSync)(W),...m?{apiKey:wt(m)}:{},...A&&A!==H?{apiUrl:A}:{}},null,2)+`
|
|
27
|
+
`);return}let s=vt(),r=typeof s.apiKey=="string"?s.apiKey:void 0,c=(0,Et.createInterface)({input:process.stdin,output:process.stdout});console.log(""),console.log(` ${n("Create a free API key at")} https://my.shipstatic.com/api-key`),console.log("");let p=r?` API Key (${n(wt(r))}): `:" API Key: ",a;try{a=(await c.question(p)).trim()}finally{c.close()}a&&(re(a),s.apiKey=a),(0,K.writeFileSync)(W,JSON.stringify(s,null,2)+`
|
|
28
28
|
`),console.log(`
|
|
29
29
|
${i("saved to")} ${n(W)}
|
|
30
|
-
`)}
|
|
30
|
+
`)}w();function xt(e){return x(e)?e:e instanceof Error?l.business(e.message):l.business(String(e??"Unknown error"))}function Ot(e,o,t){if(e.isAuthError())return t?.apiKey?"authentication failed: invalid API key":t?.deployToken?"authentication failed: invalid or expired deploy token":"authentication required: use --api-key or --deploy-token, or set SHIP_API_KEY";if(e.isNetworkError()){let n=e.details?.url;return n?`network error: could not reach ${n}`:"network error: could not reach the API. check your internet connection"}return e.isFileError()||e.isValidationError()||e.isClientError()||e.status&&e.status>=400&&e.status<500?e.message:"server error: please try again or check https://status.shipstatic.com"}function kt(e,o){return JSON.stringify({error:e,...o?{details:o}:{}},null,2)}var ye=require("yoctocolors");function go(){let e=[ge.resolve(__dirname,"../package.json"),ge.resolve(__dirname,"../../package.json")];for(let o of e)try{return JSON.parse((0,G.readFileSync)(o,"utf-8"))}catch{}return{version:"0.0.0"}}var yo=go(),f=new It.Command;f.exitOverride(e=>{(e.code==="commander.help"||e.code==="commander.version"||e.exitCode===0)&&process.exit(e.exitCode||0),process.argv.includes("--help")&&(te($(f).noColor),process.exit(0));let o=$(f),t=e.message||"unknown command error";t=t.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),R(t,o.json,o.noColor),o.json||te(o.noColor),process.exit(e.exitCode||1)}).configureOutput({writeErr:e=>{e.startsWith("error:")||process.stderr.write(e)},writeOut:e=>process.stdout.write(e)});function te(e){let o=s=>e?s:(0,ye.bold)(s),t=s=>e?s:(0,ye.dim)(s),n=s=>e?"":`${s} `,i=`${o("USAGE")}
|
|
31
31
|
ship <path> ${n("\u{1F680}")}Deploy static sites with simplicity
|
|
32
32
|
|
|
33
33
|
${o("COMMANDS")}
|
|
@@ -81,8 +81,8 @@ ${o("EXAMPLES")}
|
|
|
81
81
|
ship ./dist -q | ship domains set www.example.com
|
|
82
82
|
|
|
83
83
|
${t("Please report any issues to https://github.com/shipstatic/ship/issues")}
|
|
84
|
-
`;console.log(i)}function oe(e,o=[]){return o.concat([e])}function ne(e,o){let t=e?.label?.length?e.label:o?.label;if(!t?.length)return;let n=t.filter(i=>i!=="");return n.length?n:[]}function ie(e,o){return(...t)=>{let n=$(
|
|
85
|
-
`),process.exit(1)}}function $(e){let o=e.optsWithGlobals();o.color===!1&&(o.noColor=!0);let t=!!process.env.FORCE_COLOR&&process.env.FORCE_COLOR!=="0";return!o.noColor&&!t&&(!process.stdout.isTTY||process.env.NO_COLOR!==void 0)&&(o.noColor=!0),o}function
|
|
86
|
-
`):(R(i,!1,t.noColor),n.isValidationError()&&i.includes("unknown command")&&te(t.noColor)),process.exit(1)}function D(e,o){return async function(...t){let n=$(this),i=o?{operation:o.operation,resourceType:o.resourceType,resourceId:o.getResourceId?.(...t)}:{};try{let s=
|
|
87
|
-
`:" ")),process.exit(0)}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish"))&&
|
|
84
|
+
`;console.log(i)}function oe(e,o=[]){return o.concat([e])}function ne(e,o){let t=e?.label?.length?e.label:o?.label;if(!t?.length)return;let n=t.filter(i=>i!=="");return n.length?n:[]}function Ft(e,o){return e?.password??o?.password??process.env.SHIP_PASSWORD}function ie(e,o){return(...t)=>{let n=$(f),i=t[t.length-1];if(i?.args?.length){let s=i.args.find(r=>!o.includes(r));s&&R(`unknown command '${s}'`,n.json,n.noColor)}n.json||console.log(`usage: ship ${e} <${o.join("|")}>
|
|
85
|
+
`),process.exit(1)}}function $(e){let o=e.optsWithGlobals();o.color===!1&&(o.noColor=!0);let t=!!process.env.FORCE_COLOR&&process.env.FORCE_COLOR!=="0";return!o.noColor&&!t&&(!process.stdout.isTTY||process.env.NO_COLOR!==void 0)&&(o.noColor=!0),o}function Pt(e,o){let t=$(f),n=xt(e),i=Ot(n,o,{apiKey:t.apiKey,deployToken:t.deployToken});t.json?console.error(kt(i,n.details)+`
|
|
86
|
+
`):(R(i,!1,t.noColor),n.isValidationError()&&i.includes("unknown command")&&te(t.noColor)),process.exit(1)}function D(e,o){return async function(...t){let n=$(this),i=o?{operation:o.operation,resourceType:o.resourceType,resourceId:o.getResourceId?.(...t)}:{};try{let s=So(),r=await e(s,n,...t);yt(r,i,{json:n.json,quiet:n.quiet,noColor:n.noColor})}catch(s){Pt(s,i)}}}function So(){let{config:e,apiUrl:o,apiKey:t,deployToken:n}=f.opts();return new me({configFile:e,apiUrl:o,apiKey:t,deployToken:n})}async function $t(e,o,t,n,i,s){if(!(0,G.existsSync)(o))throw l.file(`${o} path does not exist`,o);let r=(0,G.statSync)(o);if(!r.isDirectory()&&!r.isFile())throw l.file(`${o} path must be a file or directory`,o);let c={via:process.env.SHIP_VIA||"cli"};t!==void 0&&(c.labels=t),n!==void 0&&(c.password=n),i?.noPathDetect!==void 0&&(c.pathDetect=!i.noPathDetect),i?.noSpaDetect!==void 0&&(c.spaDetect=!i.noSpaDetect);let p=new AbortController;c.signal=p.signal;let a=null;if(process.stdout.isTTY&&!s.json&&!s.quiet&&!s.noColor){let{default:m}=await import("yocto-spinner");a=m({text:"uploading\u2026"}).start()}let d=()=>{p.abort(),a&&a.stop(),process.exit(130)};process.on("SIGINT",d);try{return await e.deployments.upload(o,c)}finally{process.removeListener("SIGINT",d),a&&a.stop()}}f.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(yo.version,"--version","Show version information").option("--api-key <key>","API key for authenticated deployments").option("--deploy-token <token>","Deploy token for single-use deployments").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 o=$(e);o.help&&(te(o.noColor),process.exit(0))});f.hook("preAction",e=>{let o=$(e);try{o.apiKey&&typeof o.apiKey=="string"&&re(o.apiKey),o.deployToken&&typeof o.deployToken=="string"&&je(o.deployToken),o.apiUrl&&typeof o.apiUrl=="string"&&Ke(o.apiUrl)}catch(t){throw x(t)&&(R(t.message,o.json,o.noColor),process.exit(1)),t}});f.command("ping").description("Check API connectivity").action(D((e,o)=>e.ping()));f.command("whoami").description("Get current account information").action(D((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var se=f.command("deployments").description("Manage deployments").enablePositionalOptions().action(ie("deployments",["list","upload","get","set","remove"]));se.command("list").description("List all deployments").action(D((e,o)=>e.deployments.list()));se.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",oe,[]).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,o,t,n)=>$t(e,t,ne(n,f.opts()),Ft(n,f.opts()),n,o),{operation:"upload"}));se.command("get <deployment>").description("Show deployment information").action(D((e,o,t)=>e.deployments.get(t),{operation:"get",resourceType:"Deployment",getResourceId:e=>e}));se.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",oe,[]).action(D(async(e,o,t,n)=>{let i=ne(n,f.opts())||[];return e.deployments.set(t,{labels:i})},{operation:"set",resourceType:"Deployment",getResourceId:e=>e}));se.command("remove <deployment>").description("Delete deployment permanently").action(D((e,o,t)=>e.deployments.remove(t),{operation:"remove",resourceType:"Deployment",getResourceId:e=>e}));var _=f.command("domains").description("Manage domains").enablePositionalOptions().action(ie("domains",["list","get","set","validate","records","dns","share","verify","remove"]));_.command("list").description("List all domains").action(D((e,o)=>e.domains.list()));_.command("get <name>").description("Show domain information").action(D((e,o,t)=>e.domains.get(t),{operation:"get",resourceType:"Domain",getResourceId:e=>e}));_.command("validate <name>").description("Check if domain name is valid and available").action(D(async(e,o,t)=>{let n=await e.domains.validate(t);return n.valid||(process.exitCode=1),n},{operation:"validate",resourceType:"Domain",getResourceId:e=>e}));_.command("verify <name>").description("Trigger DNS verification for external domain").action(D((e,o,t)=>e.domains.verify(t),{operation:"verify",resourceType:"Domain",getResourceId:e=>e}));_.command("records <name>").description("Show required DNS records for domain setup").action(D((e,o,t)=>e.domains.records(t),{operation:"records",resourceType:"Domain",getResourceId:e=>e}));_.command("dns <name>").description("Look up DNS provider for a domain").action(D((e,o,t)=>e.domains.dns(t),{operation:"dns",resourceType:"Domain",getResourceId:e=>e}));_.command("share <name>").description("Get shareable DNS setup link").action(D((e,o,t)=>e.domains.share(t),{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)",oe,[]).action(D(async(e,o,t,n,i)=>{!n&&!process.stdin.isTTY&&(n=await new Promise(p=>{let a="";process.stdin.on("data",d=>a+=d),process.stdin.on("end",()=>p(a.trim()||void 0))}));let s=ne(i,f.opts()),r={};n&&(r.deployment=n),s!==void 0&&(r.labels=s);let c=await e.domains.set(t,r);if(c.isCreate&&t.includes("."))try{let[p,a]=await Promise.all([e.domains.records(t),e.domains.share(t)]);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,o,t)=>e.domains.remove(t),{operation:"remove",resourceType:"Domain",getResourceId:e=>e}));var Le=f.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(ie("tokens",["list","create","remove"]));Le.command("list").description("List all tokens").action(D((e,o)=>e.tokens.list()));Le.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)",oe,[]).action(D((e,o,t)=>{let n={};t?.ttl!==void 0&&(n.ttl=t.ttl);let i=ne(t,f.opts());return i!==void 0&&(n.labels=i),e.tokens.create(n)},{operation:"create",resourceType:"Token"}));Le.command("remove <token>").description("Delete token permanently").action(D((e,o,t)=>e.tokens.remove(t),{operation:"remove",resourceType:"Token",getResourceId:e=>e}));var Do=f.command("account").description("Manage account").action(ie("account",["get"]));Do.command("get").description("Show account information").action(D((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var Lt=f.command("completion").description("Setup shell completion").action(ie("completion",["install","uninstall"]));Lt.command("install").description("Install shell completion script").action(()=>{let e=$(f),o=ge.resolve(__dirname,"completions");bt(o,{json:e.json,noColor:e.noColor})});Lt.command("uninstall").description("Uninstall shell completion script").action(()=>{let e=$(f);Ct({json:e.json,noColor:e.noColor})});f.command("config").description("Save your API key").action(async()=>{let e=$(f);try{await At({noColor:e.noColor,json:e.json})}catch(o){Pt(o)}});f.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",oe,[]).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,o,t,n)=>{if(t||(te(o.noColor),process.exit(0)),!(0,G.existsSync)(t)&&!t.includes("/")&&!t.includes("\\")&&!t.includes(".")&&!t.startsWith("~"))throw l.validation(`unknown command '${t}'`);return $t(e,t,ne(n,f.opts()),Ft(n,f.opts()),n,o)},{operation:"upload"}));function bo(){let e=process.argv,o=e.includes("--compbash"),t=e.includes("--compzsh"),n=e.includes("--compfish");if(!o&&!t&&!n)return;console.log(["ping","whoami","deployments","domains","tokens","account","config","completion"].join(n?`
|
|
87
|
+
`:" ")),process.exit(0)}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish"))&&bo();if(process.env.NODE_ENV!=="test")try{f.parse(process.argv)}catch(e){if(e instanceof Error&&"code"in e){let o=e.code,t=e.exitCode;o?.startsWith("commander.")&&process.exit(t||1)}throw e}
|
|
88
88
|
//# sourceMappingURL=cli.cjs.map
|