@shipstatic/ship 3.6.0-beta.1 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD-PARTY-LICENSES.md +1 -1
- package/dist/browser.d.ts +4 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -290,5 +290,5 @@ ${t("EXAMPLES")}
|
|
|
290
290
|
${r("Please report any issues to https://github.com/shipstatic/ship/issues")}
|
|
291
291
|
`}var Xt=e=>new k(P.Validation,e);function io(e,t=[]){return t.concat([e])}function dd(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new Io("Not a number.");return t}var Pb={s:1,m:60,h:3600,d:1440*60};function yg(e){let t=/^(\d+)([smhd])?$/.exec(e.trim().toLowerCase());if(!t)throw new Io("Expected seconds or a duration like 90s, 30m, 1h, 7d.");return Number.parseInt(t[1],10)*(t[2]?Pb[t[2]]:1)}function oo(e){let t=e.label;if(!t?.length)return;let r=t.filter(i=>i!=="");return r.length?r:[]}function Ab(e){return e.password??(process.env.SHIP_PASSWORD||void 0)}function ao(e){return e.ttl}var Cb=new Set(["--token","--config","--api-url","--json","--quiet","--no-color","--version"]);function xg(e){let t=[];for(let r=e;r?.parent;r=r.parent)t.unshift(r.name());return t.length||t.push(...e.registeredArguments.map(r=>`<${r.name()}>`)),t.join(" ")}function bg(e,t){return[...e.options.some(r=>r.long===t)?[xg(e)]:[],...e.commands.flatMap(r=>bg(r,t))]}function jb(e,t){if(t!==e)for(let r of e.options){let i=r.long;if(!i||Cb.has(i)||e.getOptionValueSource(r.attributeName())!=="cli"||t.options.some(o=>o.long===i))continue;let n=bg(e,i).map(o=>`ship ${o}`);throw Xt(`option '${i}' does not apply to 'ship ${xg(t)}'${n.length?` \u2014 it belongs to ${n.join(", ")}`:""}`)}}function ze(e){let t=e.optsWithGlobals();t.color===!1&&(t.noColor=!0);let r=!!process.env.FORCE_COLOR&&process.env.FORCE_COLOR!=="0";return!t.noColor&&!r&&(!process.stdout.isTTY||process.env.NO_COLOR!==void 0)&&(t.noColor=!0),t}function Jn(){let e=ze(this),t=fe(this).map(i=>i.name()),r=this.args.find(i=>!t.includes(i));r&>(Xt(`unknown command '${r}'`),e.json,e.noColor),e.json||console.log(`usage: ship ${this.name()} <${t.join("|")}>
|
|
292
292
|
`),process.exitCode=1}async function _g(e,t,r){if(!(0,ut.existsSync)(t))throw k.file(`${t} path does not exist`,{filePath:t});let i=(0,ut.statSync)(t);if(!i.isDirectory()&&!i.isFile())throw k.file(`${t} path must be a file or directory`,{filePath:t});let n={via:Td(process.env[Fd])??Do.CLI},o=oo(r);o!==void 0&&(n.labels=o);let a=process.env.SHIP_IDEMPOTENCY_KEY||void 0;a!==void 0&&(n.idempotencyKey=a);let s=Ab(r);s!==void 0&&(n.password=s);let c=ao(r);c!==void 0&&(n.ttl=c),r.pathDetect!==void 0&&(n.pathDetect=r.pathDetect),r.spaDetect!==void 0&&(n.spaDetect=r.spaDetect);let u=new AbortController;n.signal=u.signal;let l=null;if(process.stdout.isTTY&&!r.json&&!r.quiet&&!r.noColor){let{default:p}=await Promise.resolve().then(()=>(vg(),gg));l=p({text:"uploading\u2026"}).start()}let f=()=>{u.abort(),l&&l.stop(),process.exit(130)};process.on("SIGINT",f);try{return await e.deployments.upload(t,n)}finally{process.removeListener("SIGINT",f),l&&l.stop()}}async function $g(e,t,r){let i=await e.domains.set(t,r);if(i.isCreate&&t.includes("."))try{let[n,o]=await Promise.all([e.domains.records(t),e.domains.share(t)]);return{...i,_dnsRecords:n.records,_shareUrl:o.url}}catch{}return i}function Sg(){let e=new Od;e.exitOverride(p=>{if(p.code==="commander.help"||p.code==="commander.version"||p.exitCode===0)throw p;let y=ze(e),b=p.message||"unknown command error";throw b=b.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),gt(Xt(b),y.json,y.noColor),y.json||e.outputHelp(),p}).configureOutput({writeErr:p=>{p.startsWith("error:")||process.stderr.write(p)},writeOut:p=>process.stdout.write(p)});function t(p){let y=ze(e),b=ag(p);if(y.json)gt(b,!0,y.noColor);else{let E=sg(b,{token:b.isAuthError()?no(e.opts()):void 0});gt(E,!1,y.noColor),b.type===P.Validation&&E.includes("unknown command")&&e.outputHelp()}process.exitCode=1}function r(p,y){return async function(...b){let E=ze(this);try{let{config:D,apiUrl:x,token:$}=e.opts(),m=og({config:D,apiUrl:x,token:$}),d=await p(m,E,...b);pg(d,y,{json:E.json,quiet:E.quiet,noColor:E.noColor})}catch(D){t(D)}}}e.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(Db.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:(p,y)=>p.parent===null?`${Tb(ze(p).noColor)}
|
|
293
|
-
`:zd.prototype.formatHelp.call(y,p,y)}).allowExcessArguments(),e.hook("preAction",(p,y)=>{let b=ze(p);try{jb(e,y),b.token&&typeof b.token=="string"&&Xe(b.token),b.apiUrl&&typeof b.apiUrl=="string"&&tr(b.apiUrl)}catch(E){throw ce(E)?(gt(E,b.json,b.noColor),new Xn(1,"ship.invalidOption",E.message)):E}}),e.command("ping").description("Check API connectivity").action(r((p,y)=>p.ping(),{operation:"ping"})),e.command("whoami").description("Get current account information").action(r((p,y)=>p.whoami(),{operation:"get",resource:"account"}));let i=r((p,y,b)=>{if(ao(y)!==void 0&&!no(e.opts()))throw k.config(`--ttl sets an expiry, which needs a token: ${ro}`);return _g(p,b,y)},{operation:"upload",resource:"deployment"}),n=p=>r(async(y,b,E)=>{if(!no(e.opts()))throw k.config(`--domain links a domain, which needs a token: ${ro}`);if(ao(b)!==void 0)throw Xt("--ttl and --domain cannot be combined: a domain cannot point at a deployment that expires.");let D=await _g(y,E,b);return dg(D,{operation:"upload",resource:"deployment"},b),$g(y,p,{deployment:D.deployment})},{operation:"set",resource:"domain"});function o(p){let{domain:y}=ze(this);return(y?n(y):i).call(this,p)}let a=p=>p.option("--domain <domain>","Serve this deployment at a domain (needs a token)").option("--label <label>","Label to add (can be repeated)",io,[]).option("--password <password>","Password-protect this deployment").option("--ttl <duration>","Expire after this long \u2014 3600, 1h, 7d (needs a token)",yg).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration"),s=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(Jn);s.command("list").description("List deployments (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.deployments.list(b),{operation:"list",resource:"deployment"})),a(s.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions()).action(o),s.command("get <deployment>").description("Show deployment information").action(r((p,y,b)=>p.deployments.get(b),{operation:"get",resource:"deployment"})),s.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",io,[]).action(r(async(p,y,b)=>p.deployments.set(b,{labels:oo(y)||[]}),{operation:"set",resource:"deployment"})),s.command("delete <deployment>").description("Delete deployment permanently").action(r((p,y,b)=>p.deployments.delete(b),{operation:"delete",resource:"deployment"}));let c=e.command("domains").description("Manage domains").enablePositionalOptions().action(Jn);c.command("list").description("List domains (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.domains.list(b),{operation:"list",resource:"domain"})),c.command("get <name>").description("Show domain information").action(r((p,y,b)=>p.domains.get(b),{operation:"get",resource:"domain"})),c.command("validate <name>").description("Check if domain name is valid and available").action(r(async(p,y,b)=>{let E=await p.domains.validate(b);return E.reason!==null&&(process.exitCode=1),E},{operation:"validate",resource:"domain"})),c.command("verify <name>").description("Trigger DNS verification for external domain").action(r(async(p,y,b)=>{let E=await p.domains.verify(b);try{let{deployment:D}=await p.domains.get(b);return{...E,_deployment:D}}catch{return E}},{operation:"verify",resource:"domain"})),c.command("records <name>").description("Show required DNS records for domain setup").action(r((p,y,b)=>p.domains.records(b),{operation:"records",resource:"domain"})),c.command("dns <name>").description("Look up DNS provider for a domain").action(r((p,y,b)=>p.domains.dns(b),{operation:"dns",resource:"domain"})),c.command("share <name>").description("Get shareable DNS setup link").action(r((p,y,b)=>p.domains.share(b),{operation:"share",resource:"domain"})),c.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",io,[]).action(r(async(p,y,b,E)=>{!E&&!process.stdin.isTTY&&(E=await new Promise($=>{let m="";process.stdin.on("data",d=>m+=d),process.stdin.on("end",()=>$(m.trim()||void 0))}));let D=oo(y),x={};return E&&(x.deployment=E),D!==void 0&&(x.labels=D),$g(p,b,x)},{operation:"set",resource:"domain"})),c.command("delete <name>").description("Delete domain permanently").action(r((p,y,b)=>p.domains.delete(b),{operation:"delete",resource:"domain"}));let u=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(Jn);u.command("list").description("List deploy tokens (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.tokens.list(b),{operation:"list",resource:"token"})),u.command("create").description("Create a new deploy token").option("--ttl <duration>","Expire after this long \u2014 3600, 1h, 7d",yg).option("--label <label>","Label
|
|
293
|
+
`:zd.prototype.formatHelp.call(y,p,y)}).allowExcessArguments(),e.hook("preAction",(p,y)=>{let b=ze(p);try{jb(e,y),b.token&&typeof b.token=="string"&&Xe(b.token),b.apiUrl&&typeof b.apiUrl=="string"&&tr(b.apiUrl)}catch(E){throw ce(E)?(gt(E,b.json,b.noColor),new Xn(1,"ship.invalidOption",E.message)):E}}),e.command("ping").description("Check API connectivity").action(r((p,y)=>p.ping(),{operation:"ping"})),e.command("whoami").description("Get current account information").action(r((p,y)=>p.whoami(),{operation:"get",resource:"account"}));let i=r((p,y,b)=>{if(ao(y)!==void 0&&!no(e.opts()))throw k.config(`--ttl sets an expiry, which needs a token: ${ro}`);return _g(p,b,y)},{operation:"upload",resource:"deployment"}),n=p=>r(async(y,b,E)=>{if(!no(e.opts()))throw k.config(`--domain links a domain, which needs a token: ${ro}`);if(ao(b)!==void 0)throw Xt("--ttl and --domain cannot be combined: a domain cannot point at a deployment that expires.");let D=await _g(y,E,b);return dg(D,{operation:"upload",resource:"deployment"},b),$g(y,p,{deployment:D.deployment})},{operation:"set",resource:"domain"});function o(p){let{domain:y}=ze(this);return(y?n(y):i).call(this,p)}let a=p=>p.option("--domain <domain>","Serve this deployment at a domain (needs a token)").option("--label <label>","Label to add (can be repeated)",io,[]).option("--password <password>","Password-protect this deployment").option("--ttl <duration>","Expire after this long \u2014 3600, 1h, 7d (needs a token)",yg).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration"),s=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(Jn);s.command("list").description("List deployments (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.deployments.list(b),{operation:"list",resource:"deployment"})),a(s.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions()).action(o),s.command("get <deployment>").description("Show deployment information").action(r((p,y,b)=>p.deployments.get(b),{operation:"get",resource:"deployment"})),s.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",io,[]).action(r(async(p,y,b)=>p.deployments.set(b,{labels:oo(y)||[]}),{operation:"set",resource:"deployment"})),s.command("delete <deployment>").description("Delete deployment permanently").action(r((p,y,b)=>p.deployments.delete(b),{operation:"delete",resource:"deployment"}));let c=e.command("domains").description("Manage domains").enablePositionalOptions().action(Jn);c.command("list").description("List domains (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.domains.list(b),{operation:"list",resource:"domain"})),c.command("get <name>").description("Show domain information").action(r((p,y,b)=>p.domains.get(b),{operation:"get",resource:"domain"})),c.command("validate <name>").description("Check if domain name is valid and available").action(r(async(p,y,b)=>{let E=await p.domains.validate(b);return E.reason!==null&&(process.exitCode=1),E},{operation:"validate",resource:"domain"})),c.command("verify <name>").description("Trigger DNS verification for external domain").action(r(async(p,y,b)=>{let E=await p.domains.verify(b);try{let{deployment:D}=await p.domains.get(b);return{...E,_deployment:D}}catch{return E}},{operation:"verify",resource:"domain"})),c.command("records <name>").description("Show required DNS records for domain setup").action(r((p,y,b)=>p.domains.records(b),{operation:"records",resource:"domain"})),c.command("dns <name>").description("Look up DNS provider for a domain").action(r((p,y,b)=>p.domains.dns(b),{operation:"dns",resource:"domain"})),c.command("share <name>").description("Get shareable DNS setup link").action(r((p,y,b)=>p.domains.share(b),{operation:"share",resource:"domain"})),c.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",io,[]).action(r(async(p,y,b,E)=>{!E&&!process.stdin.isTTY&&(E=await new Promise($=>{let m="";process.stdin.on("data",d=>m+=d),process.stdin.on("end",()=>$(m.trim()||void 0))}));let D=oo(y),x={};return E&&(x.deployment=E),D!==void 0&&(x.labels=D),$g(p,b,x)},{operation:"set",resource:"domain"})),c.command("delete <name>").description("Delete domain permanently").action(r((p,y,b)=>p.domains.delete(b),{operation:"delete",resource:"domain"}));let u=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(Jn);u.command("list").description("List deploy tokens (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",dd).option("--cursor <cursor>","Continue from a previous page's cursor").action(r((p,y,b)=>p.tokens.list(b),{operation:"list",resource:"token"})),u.command("create").description("Create a new deploy token").option("--ttl <duration>","Expire after this long \u2014 3600, 1h, 7d",yg).option("--label <label>","Label for the token and every deployment it uploads (can be repeated)",io,[]).action(r((p,y)=>{let b={},E=ao(y);E!==void 0&&(b.ttl=E);let D=oo(y);return D!==void 0&&(b.labels=D),p.tokens.create(b)},{operation:"create",resource:"token"})),u.command("get <token>").description("Show one deploy token").action(r((p,y,b)=>p.tokens.get(b),{operation:"get",resource:"token"})),u.command("delete <token>").description("Delete token permanently").action(r((p,y,b)=>p.tokens.delete(b),{operation:"delete",resource:"token"})),e.command("account").description("Manage account").action(Jn).command("get").description("Show account information").action(r((p,y)=>p.whoami(),{operation:"get",resource:"account"}));let f=e.command("completion").description("Setup shell completion").action(Jn);return f.command("install").description("Install shell completion script").action(()=>{let p=ze(e);try{yp(e,{json:p.json,noColor:p.noColor})}catch(y){t(y)}}),f.command("uninstall").description("Uninstall shell completion script").action(()=>{let p=ze(e);try{_p({json:p.json,noColor:p.noColor})}catch(y){t(y)}}),e.command("config").description("Save your token").action(async()=>{let p=ze(e);try{if(p.json)throw Xt("ship config is interactive \u2014 run it without --json (it shows the token already saved)");await Ih({noColor:p.noColor,configFile:p.config})}catch(y){t(y)}}),a(e.argument("[path]","Path to deploy")).action(async function(p){if(!p){this.outputHelp();return}if(!(0,ut.existsSync)(p)&&!p.includes("/")&&!p.includes("\\")&&!p.includes(".")&&!p.startsWith("~")){t(Xt(`unknown command '${p}'`));return}return o.call(this,p)}),e}Sg().parseAsync(process.argv).catch(e=>{if(e instanceof Xn){process.exitCode=e.exitCode;return}throw e});
|
|
294
294
|
//# sourceMappingURL=cli.cjs.map
|