@shipstatic/ship 2.0.0-beta.4 → 2.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -31,14 +31,14 @@ ${s}
31
31
 
32
32
  ${t("COMMANDS")}
33
33
  ${o("\u{1F4E6}")}${t("Deployments")}
34
- ship deployments list List all deployments
34
+ ship deployments list List deployments
35
35
  ship deployments upload <path> Upload deployment from file or directory
36
36
  ship deployments get <deployment> Show deployment information
37
37
  ship deployments set <deployment> Set deployment labels
38
38
  ship deployments remove <deployment> Delete deployment permanently
39
39
 
40
40
  ${o("\u{1F30E}")}${t("Domains")}
41
- ship domains list List all domains
41
+ ship domains list List domains
42
42
  ship domains set <name> [deployment] Create domain, link to deployment, or update labels
43
43
  ship domains get <name> Show domain information
44
44
  ship domains validate <name> Check if domain name is valid and available
@@ -49,7 +49,7 @@ ${t("COMMANDS")}
49
49
  ship domains remove <name> Delete domain permanently
50
50
 
51
51
  ${o("\u{1F511}")}${t("Tokens")}
52
- ship tokens list List all deploy tokens
52
+ ship tokens list List deploy tokens
53
53
  ship tokens create Create a new deploy token
54
54
  ship tokens remove <token> Delete token permanently
55
55
 
@@ -82,6 +82,6 @@ ${n("Please report any issues to https://github.com/shipstatic/ship/issues")}
82
82
  `}function Y(e,t=[]){return t.concat([e])}function ue(e){let t=Number.parseInt(e,10);if(Number.isNaN(t))throw new U.InvalidArgumentError("Not a number.");return t}function W(e,t){let n=e?.label?.length?e.label:t?.label;if(!n?.length)return;let o=n.filter(s=>s!=="");return o.length?o:[]}function Ft(e,t){return e?.password??t?.password??(process.env.SHIP_PASSWORD||void 0)}function _(e){let t=e.optsWithGlobals();t.color===!1&&(t.noColor=!0);let n=!!process.env.FORCE_COLOR&&process.env.FORCE_COLOR!=="0";return!t.noColor&&!n&&(!process.stdout.isTTY||process.env.NO_COLOR!==void 0)&&(t.noColor=!0),t}function An(e){let t={};try{t=me(e.config)}catch{}let n=$e(e,q(),t).token;return typeof n=="string"?n:void 0}async function Nt(e,t,n,o,s,i){if(!(0,z.existsSync)(t))throw l.file(`${t} path does not exist`,{filePath:t});let a=(0,z.statSync)(t);if(!a.isDirectory()&&!a.isFile())throw l.file(`${t} path must be a file or directory`,{filePath:t});let m={via:process.env.SHIP_VIA||"cli"};n!==void 0&&(m.labels=n),o!==void 0&&(m.password=o),s?.noPathDetect!==void 0&&(m.pathDetect=!s.noPathDetect),s?.noSpaDetect!==void 0&&(m.spaDetect=!s.noSpaDetect);let u=new AbortController;m.signal=u.signal;let d=null;if(process.stdout.isTTY&&!i.json&&!i.quiet&&!i.noColor){let{default:p}=await import("yocto-spinner");d=p({text:"uploading\u2026"}).start()}let r=()=>{u.abort(),d&&d.stop(),process.exit(130)};process.on("SIGINT",r);try{return await e.deployments.upload(t,m)}finally{process.removeListener("SIGINT",r),d&&d.stop()}}function _t(){let e=new U.Command;e.exitOverride(r=>{if(r.code==="commander.help"||r.code==="commander.version"||r.exitCode===0)throw r;let p=_(e),c=r.message||"unknown command error";throw c=c.replace(/^error: /,"").replace(/\n.*/,"").replace(/\.$/,"").toLowerCase(),R(c,p.json,p.noColor),p.json||e.outputHelp(),r}).configureOutput({writeErr:r=>{r.startsWith("error:")||process.stderr.write(r)},writeOut:r=>process.stdout.write(r)});function t(r,p){return(...c)=>{let h=_(e),D=c[c.length-1];if(D?.args?.length){let f=D.args.find(y=>!p.includes(y));f&&R(`unknown command '${f}'`,h.json,h.noColor)}h.json||console.log(`usage: ship ${r} <${p.join("|")}>
83
83
  `),process.exitCode=1}}function n(r,p){let c=_(e),h=kt(r),D=It(h,p,{token:An(e.opts())});c.json?console.error(`${Pt(D,h.details)}
84
84
  `):(R(D,!1,c.noColor),h.type===g.Validation&&D.includes("unknown command")&&e.outputHelp()),process.exitCode=1}function o(r,p){return async function(...c){let h=_(this),D=p?{operation:p.operation,resourceType:p.resourceType,resourceId:p.getResourceId?.(...c)}:{};try{let{config:f,apiUrl:y,token:v}=e.opts(),T=Lt({config:f,apiUrl:y,token:v}),k=await r(T,h,...c);$t(k,D,{json:h.json,quiet:h.quiet,noColor:h.noColor})}catch(f){n(f,D)}}}e.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(On.version,"-V, --version","Show version information").option("--token <token>","Any ship token: API key (ship-\u2026) or deploy token (deploy-\u2026)").option("--config <file>","Custom config file path").option("--api-url <url>","API URL (for development)").option("--json","Output results in JSON format").option("-q, --quiet","Output only the resource identifier").option("--no-color","Disable colored output").helpOption("-h, --help","Display help for command").helpCommand("help [command]","Display help for command").configureHelp({formatHelp:(r,p)=>r.parent===null?`${Rn(_(r).noColor)}
85
- `:U.Help.prototype.formatHelp.call(p,r,p)}).allowExcessArguments(),e.hook("preAction",r=>{let p=_(r);try{p.token&&typeof p.token=="string"&&G(p.token),p.apiUrl&&typeof p.apiUrl=="string"&&Ke(p.apiUrl)}catch(c){throw I(c)?(R(c.message,p.json,p.noColor),new U.CommanderError(1,"ship.invalidOption",c.message)):c}}),e.command("ping").description("Check API connectivity").action(o(async(r,p)=>{let c=await r.ping();return c||(process.exitCode=1),c})),e.command("whoami").description("Get current account information").action(o((r,p)=>r.whoami(),{operation:"get",resourceType:"Account"}));let s=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(t("deployments",["list","upload","get","set","remove"]));s.command("list").description("List all deployments").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.deployments.list(c))),s.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(o((r,p,c,h)=>Nt(r,c,W(h,e.opts()),Ft(h,e.opts()),h,p),{operation:"upload"})),s.command("get <deployment>").description("Show deployment information").action(o((r,p,c)=>r.deployments.get(c),{operation:"get",resourceType:"Deployment",getResourceId:r=>r})),s.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(r,p,c,h)=>{let D=W(h,e.opts())||[];return r.deployments.set(c,{labels:D})},{operation:"set",resourceType:"Deployment",getResourceId:r=>r})),s.command("remove <deployment>").description("Delete deployment permanently").action(o((r,p,c)=>r.deployments.remove(c),{operation:"remove",resourceType:"Deployment",getResourceId:r=>r}));let i=e.command("domains").description("Manage domains").enablePositionalOptions().action(t("domains",["list","get","set","validate","records","dns","share","verify","remove"]));i.command("list").description("List all domains").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.domains.list(c))),i.command("get <name>").description("Show domain information").action(o((r,p,c)=>r.domains.get(c),{operation:"get",resourceType:"Domain",getResourceId:r=>r})),i.command("validate <name>").description("Check if domain name is valid and available").action(o(async(r,p,c)=>{let h=await r.domains.validate(c);return h.valid||(process.exitCode=1),h},{operation:"validate",resourceType:"Domain",getResourceId:r=>r})),i.command("verify <name>").description("Trigger DNS verification for external domain").action(o((r,p,c)=>r.domains.verify(c),{operation:"verify",resourceType:"Domain",getResourceId:r=>r})),i.command("records <name>").description("Show required DNS records for domain setup").action(o((r,p,c)=>r.domains.records(c),{operation:"records",resourceType:"Domain",getResourceId:r=>r})),i.command("dns <name>").description("Look up DNS provider for a domain").action(o((r,p,c)=>r.domains.dns(c),{operation:"dns",resourceType:"Domain",getResourceId:r=>r})),i.command("share <name>").description("Get shareable DNS setup link").action(o((r,p,c)=>r.domains.share(c),{operation:"share",resourceType:"Domain",getResourceId:r=>r})),i.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(r,p,c,h,D)=>{!h&&!process.stdin.isTTY&&(h=await new Promise(T=>{let k="";process.stdin.on("data",ge=>k+=ge),process.stdin.on("end",()=>T(k.trim()||void 0))}));let f=W(D,e.opts()),y={};h&&(y.deployment=h),f!==void 0&&(y.labels=f);let v=await r.domains.set(c,y);if(v.isCreate&&c.includes("."))try{let[T,k]=await Promise.all([r.domains.records(c),r.domains.share(c)]);return{...v,_dnsRecords:T.records,_shareHash:k.hash}}catch{}return v},{operation:"set",resourceType:"Domain",getResourceId:r=>r})),i.command("remove <name>").description("Delete domain permanently").action(o((r,p,c)=>r.domains.remove(c),{operation:"remove",resourceType:"Domain",getResourceId:r=>r}));let a=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(t("tokens",["list","create","remove"]));a.command("list").description("List all deploy tokens").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.tokens.list(c))),a.command("create").description("Create a new deploy token").option("--ttl <seconds>","Time to live in seconds (default: never expires)",ue).option("--label <label>","Label to set (can be repeated)",Y,[]).action(o((r,p,c)=>{let h={};c?.ttl!==void 0&&(h.ttl=c.ttl);let D=W(c,e.opts());return D!==void 0&&(h.labels=D),r.tokens.create(h)},{operation:"create",resourceType:"Token"})),a.command("remove <token>").description("Delete token permanently").action(o((r,p,c)=>r.tokens.remove(c),{operation:"remove",resourceType:"Token",getResourceId:r=>r})),e.command("account").description("Manage account").action(t("account",["get"])).command("get").description("Show account information").action(o((r,p)=>r.whoami(),{operation:"get",resourceType:"Account"}));let u=e.command("completion").description("Setup shell completion").action(t("completion",["install","uninstall"]));u.command("install").description("Install shell completion script").action(()=>{let r=_(e),p=fe.resolve(__dirname,"completions");Qe(p,{json:r.json,noColor:r.noColor})}),u.command("uninstall").description("Uninstall shell completion script").action(()=>{let r=_(e);et({json:r.json,noColor:r.noColor})}),e.command("config").description("Save your token").action(async()=>{let r=_(e);try{await rt({noColor:r.noColor,json:r.json})}catch(p){n(p)}});let d=o((r,p,c,h)=>Nt(r,c,W(h,e.opts()),Ft(h,e.opts()),h,p),{operation:"upload"});return e.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(async function(r,p){if(!r){this.outputHelp();return}if(!(0,z.existsSync)(r)&&!r.includes("/")&&!r.includes("\\")&&!r.includes(".")&&!r.startsWith("~")){n(l.validation(`unknown command '${r}'`),{operation:"upload"});return}return d.call(this,r,p)}),e}function xn(){let e=process.argv.includes("--compfish");console.log(["ping","whoami","deployments","domains","tokens","account","config","completion"].join(e?`
85
+ `:U.Help.prototype.formatHelp.call(p,r,p)}).allowExcessArguments(),e.hook("preAction",r=>{let p=_(r);try{p.token&&typeof p.token=="string"&&G(p.token),p.apiUrl&&typeof p.apiUrl=="string"&&Ke(p.apiUrl)}catch(c){throw I(c)?(R(c.message,p.json,p.noColor),new U.CommanderError(1,"ship.invalidOption",c.message)):c}}),e.command("ping").description("Check API connectivity").action(o(async(r,p)=>{let c=await r.ping();return c||(process.exitCode=1),c})),e.command("whoami").description("Get current account information").action(o((r,p)=>r.whoami(),{operation:"get",resourceType:"Account"}));let s=e.command("deployments").description("Manage deployments").enablePositionalOptions().action(t("deployments",["list","upload","get","set","remove"]));s.command("list").description("List deployments (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.deployments.list(c))),s.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(o((r,p,c,h)=>Nt(r,c,W(h,e.opts()),Ft(h,e.opts()),h,p),{operation:"upload"})),s.command("get <deployment>").description("Show deployment information").action(o((r,p,c)=>r.deployments.get(c),{operation:"get",resourceType:"Deployment",getResourceId:r=>r})),s.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(r,p,c,h)=>{let D=W(h,e.opts())||[];return r.deployments.set(c,{labels:D})},{operation:"set",resourceType:"Deployment",getResourceId:r=>r})),s.command("remove <deployment>").description("Delete deployment permanently").action(o((r,p,c)=>r.deployments.remove(c),{operation:"remove",resourceType:"Deployment",getResourceId:r=>r}));let i=e.command("domains").description("Manage domains").enablePositionalOptions().action(t("domains",["list","get","set","validate","records","dns","share","verify","remove"]));i.command("list").description("List domains (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.domains.list(c))),i.command("get <name>").description("Show domain information").action(o((r,p,c)=>r.domains.get(c),{operation:"get",resourceType:"Domain",getResourceId:r=>r})),i.command("validate <name>").description("Check if domain name is valid and available").action(o(async(r,p,c)=>{let h=await r.domains.validate(c);return h.valid||(process.exitCode=1),h},{operation:"validate",resourceType:"Domain",getResourceId:r=>r})),i.command("verify <name>").description("Trigger DNS verification for external domain").action(o((r,p,c)=>r.domains.verify(c),{operation:"verify",resourceType:"Domain",getResourceId:r=>r})),i.command("records <name>").description("Show required DNS records for domain setup").action(o((r,p,c)=>r.domains.records(c),{operation:"records",resourceType:"Domain",getResourceId:r=>r})),i.command("dns <name>").description("Look up DNS provider for a domain").action(o((r,p,c)=>r.domains.dns(c),{operation:"dns",resourceType:"Domain",getResourceId:r=>r})),i.command("share <name>").description("Get shareable DNS setup link").action(o((r,p,c)=>r.domains.share(c),{operation:"share",resourceType:"Domain",getResourceId:r=>r})),i.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",Y,[]).action(o(async(r,p,c,h,D)=>{!h&&!process.stdin.isTTY&&(h=await new Promise(T=>{let k="";process.stdin.on("data",ge=>k+=ge),process.stdin.on("end",()=>T(k.trim()||void 0))}));let f=W(D,e.opts()),y={};h&&(y.deployment=h),f!==void 0&&(y.labels=f);let v=await r.domains.set(c,y);if(v.isCreate&&c.includes("."))try{let[T,k]=await Promise.all([r.domains.records(c),r.domains.share(c)]);return{...v,_dnsRecords:T.records,_shareHash:k.hash}}catch{}return v},{operation:"set",resourceType:"Domain",getResourceId:r=>r})),i.command("remove <name>").description("Delete domain permanently").action(o((r,p,c)=>r.domains.remove(c),{operation:"remove",resourceType:"Domain",getResourceId:r=>r}));let a=e.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(t("tokens",["list","create","remove"]));a.command("list").description("List deploy tokens (one page \u2014 see --limit and --cursor)").option("--limit <count>","Maximum number of results per page",ue).option("--cursor <cursor>","Continue from a previous page's cursor").action(o((r,p,c)=>r.tokens.list(c))),a.command("create").description("Create a new deploy token").option("--ttl <seconds>","Time to live in seconds (default: never expires)",ue).option("--label <label>","Label to set (can be repeated)",Y,[]).action(o((r,p,c)=>{let h={};c?.ttl!==void 0&&(h.ttl=c.ttl);let D=W(c,e.opts());return D!==void 0&&(h.labels=D),r.tokens.create(h)},{operation:"create",resourceType:"Token"})),a.command("remove <token>").description("Delete token permanently").action(o((r,p,c)=>r.tokens.remove(c),{operation:"remove",resourceType:"Token",getResourceId:r=>r})),e.command("account").description("Manage account").action(t("account",["get"])).command("get").description("Show account information").action(o((r,p)=>r.whoami(),{operation:"get",resourceType:"Account"}));let u=e.command("completion").description("Setup shell completion").action(t("completion",["install","uninstall"]));u.command("install").description("Install shell completion script").action(()=>{let r=_(e),p=fe.resolve(__dirname,"completions");Qe(p,{json:r.json,noColor:r.noColor})}),u.command("uninstall").description("Uninstall shell completion script").action(()=>{let r=_(e);et({json:r.json,noColor:r.noColor})}),e.command("config").description("Save your token").action(async()=>{let r=_(e);try{await rt({noColor:r.noColor,json:r.json})}catch(p){n(p)}});let d=o((r,p,c,h)=>Nt(r,c,W(h,e.opts()),Ft(h,e.opts()),h,p),{operation:"upload"});return e.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",Y,[]).option("--password <password>","Password-protect this deployment").option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(async function(r,p){if(!r){this.outputHelp();return}if(!(0,z.existsSync)(r)&&!r.includes("/")&&!r.includes("\\")&&!r.includes(".")&&!r.startsWith("~")){n(l.validation(`unknown command '${r}'`),{operation:"upload"});return}return d.call(this,r,p)}),e}function xn(){let e=process.argv.includes("--compfish");console.log(["ping","whoami","deployments","domains","tokens","account","config","completion"].join(e?`
86
86
  `:" "))}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish")?xn():_t().parseAsync(process.argv).catch(t=>{if(t instanceof U.CommanderError){process.exitCode=t.exitCode;return}throw t}));0&&(module.exports={buildProgram});
87
87
  //# sourceMappingURL=cli.cjs.map