@shipstatic/ship 0.8.2 → 0.8.3

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
@@ -50,7 +50,7 @@ ${o("COMMANDS")}
50
50
  ship tokens remove <token> Delete token permanently
51
51
 
52
52
  \u2699\uFE0F ${o("Setup")}
53
- ship config Create or update ~/.shiprc configuration
53
+ ship config Save your API key
54
54
  ship whoami Get current account information
55
55
 
56
56
  \u{1F6E0}\uFE0F ${o("Completion")}
@@ -70,10 +70,12 @@ ${o("FLAGS")}
70
70
  --version Show version information
71
71
 
72
72
  ${o("EXAMPLES")}
73
+ ship ./dist
74
+ ship domains set www.example.com happy-cat-abc1234.shipstatic.com
73
75
  ship ./dist -q | ship domains set www.example.com
74
76
 
75
77
  ${t("Please report any issues to https://github.com/shipstatic/ship/issues")}
76
78
  `;console.log(n)}function X(e,o=[]){return o.concat([e])}function Z(e,o){let t=e?.label?.length?e.label:o?.label;return t?.length?t:void 0}function Q(e){return(...o)=>{let t=L(f),n=o[o.length-1];if(n?.args?.length){let i=n.args.find(s=>!e.includes(s));i&&A(`unknown command '${i}'`,t.json,t.noColor)}Y(t.noColor),process.exit(1)}}function L(e){let o=e.optsWithGlobals();return o.color===!1&&(o.noColor=!0),o}function Et(e,o){let t=L(f),n=Dt(e),i=Ct(n,o,{apiKey:t.apiKey,deployToken:t.deployToken});t.json?console.error(vt(i,n.details)+`
77
- `):(A(i,!1,t.noColor),n.isValidationError()&&i.includes("unknown command")&&Y(t.noColor)),process.exit(1)}function v(e,o){return async function(...t){let n=L(this),i=o?{operation:o.operation,resourceType:o.resourceType,resourceId:o.getResourceId?.(...t)}:{};try{let s=so(),r=await e(s,n,...t);pt(r,i,{json:n.json,quiet:n.quiet,noColor:n.noColor})}catch(s){Et(s,i)}}}function so(){let{config:e,apiUrl:o,apiKey:t,deployToken:n}=f.opts();return new le({configFile:e,apiUrl:o,apiKey:t,deployToken:n})}async function Tt(e,o,t,n,i){if(!(0,U.existsSync)(o))throw c.file(`${o} path does not exist`,o);let s=(0,U.statSync)(o);if(!s.isDirectory()&&!s.isFile())throw c.file(`${o} path must be a file or directory`,o);let r={via:process.env.SHIP_VIA||"cli"};t&&(r.labels=t),n?.noPathDetect!==void 0&&(r.pathDetect=!n.noPathDetect),n?.noSpaDetect!==void 0&&(r.spaDetect=!n.noSpaDetect);let a=new AbortController;r.signal=a.signal;let l=null;if(process.stdout.isTTY&&!i.json&&!i.quiet&&!i.noColor){let{default:d}=await import("yocto-spinner");l=d({text:"uploading\u2026"}).start()}let p=()=>{a.abort(),l&&l.stop(),process.exit(130)};process.on("SIGINT",p);try{return await e.deployments.upload(o,r)}finally{process.removeListener("SIGINT",p),l&&l.stop()}}f.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(io.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=L(e);o.help&&(Y(o.noColor),process.exit(0))});f.hook("preAction",e=>{let o=L(e);try{o.apiKey&&typeof o.apiKey=="string"&&te(o.apiKey),o.deployToken&&typeof o.deployToken=="string"&&$e(o.deployToken),o.apiUrl&&typeof o.apiUrl=="string"&&Le(o.apiUrl)}catch(t){throw k(t)&&(A(t.message,o.json,o.noColor),process.exit(1)),t}});f.command("ping").description("Check API connectivity").action(v((e,o)=>e.ping()));f.command("whoami").description("Get current account information").action(v((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var ee=f.command("deployments").description("Manage deployments").enablePositionalOptions().action(Q(["list","upload","get","set","remove"]));ee.command("list").description("List all deployments").action(v((e,o)=>e.deployments.list()));ee.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",X,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(v((e,o,t,n)=>Tt(e,t,Z(n,f.opts()),n,o),{operation:"upload"}));ee.command("get <deployment>").description("Show deployment information").action(v((e,o,t)=>e.deployments.get(t),{operation:"get",resourceType:"Deployment",getResourceId:e=>e}));ee.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",X,[]).action(v(async(e,o,t,n)=>{let i=Z(n,f.opts())||[];return e.deployments.set(t,{labels:i})},{operation:"set",resourceType:"Deployment",getResourceId:e=>e}));ee.command("remove <deployment>").description("Delete deployment permanently").action(v((e,o,t)=>e.deployments.remove(t),{operation:"remove",resourceType:"Deployment",getResourceId:e=>e}));var V=f.command("domains").description("Manage domains").enablePositionalOptions().action(Q(["list","get","set","validate","verify","remove"]));V.command("list").description("List all domains").action(v((e,o)=>e.domains.list()));V.command("get <name>").description("Show domain information").action(v((e,o,t)=>e.domains.get(t),{operation:"get",resourceType:"Domain",getResourceId:e=>e}));V.command("validate <name>").description("Check if domain name is valid and available").action(v((e,o,t)=>e.domains.validate(t),{operation:"validate",resourceType:"Domain",getResourceId:e=>e}));V.command("verify <name>").description("Trigger DNS verification for external domain").action(v((e,o,t)=>e.domains.verify(t),{operation:"verify",resourceType:"Domain",getResourceId:e=>e}));V.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",X,[]).action(v(async(e,o,t,n,i)=>{!n&&!process.stdin.isTTY&&(n=await new Promise(l=>{let p="";process.stdin.on("data",d=>p+=d),process.stdin.on("end",()=>l(p.trim()||void 0))}));let s=Z(i,f.opts()),r={};n&&(r.deployment=n),s&&s.length>0&&(r.labels=s);let a=await e.domains.set(t,r);if(a.isCreate&&t.includes("."))try{let[l,p]=await Promise.all([e.domains.records(t),e.domains.share(t)]);return{...a,_dnsRecords:l.records,_shareHash:p.hash}}catch{}return a},{operation:"set",resourceType:"Domain",getResourceId:e=>e}));V.command("remove <name>").description("Delete domain permanently").action(v((e,o,t)=>e.domains.remove(t),{operation:"remove",resourceType:"Domain",getResourceId:e=>e}));var Oe=f.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(Q(["list","create","remove"]));Oe.command("list").description("List all tokens").action(v((e,o)=>e.tokens.list()));Oe.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)",X,[]).action(v((e,o,t)=>{let n={};t?.ttl!==void 0&&(n.ttl=t.ttl);let i=Z(t,f.opts());return i&&i.length>0&&(n.labels=i),e.tokens.create(n)},{operation:"create",resourceType:"Token"}));Oe.command("remove <token>").description("Delete token permanently").action(v((e,o,t)=>e.tokens.remove(t),{operation:"remove",resourceType:"Token",getResourceId:e=>e}));var ro=f.command("account").description("Manage account").action(Q(["get"]));ro.command("get").description("Show account information").action(v((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var At=f.command("completion").description("Setup shell completion").action(Q(["install","uninstall"]));At.command("install").description("Install shell completion script").action(()=>{let e=L(f),o=ue.resolve(__dirname,"completions");ut(o,{json:e.json,noColor:e.noColor})});At.command("uninstall").description("Uninstall shell completion script").action(()=>{let e=L(f);mt({json:e.json,noColor:e.noColor})});f.command("config").description("Create or update ~/.shiprc configuration").action(async()=>{let e=L(f);try{await bt({noColor:e.noColor,json:e.json})}catch(o){Et(o)}});f.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",X,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(v(async(e,o,t,n)=>{if(t||(Y(o.noColor),process.exit(0)),!(0,U.existsSync)(t)&&!t.includes("/")&&!t.includes("\\")&&!t.includes(".")&&!t.startsWith("~"))throw c.validation(`unknown command '${t}'`);return Tt(e,t,Z(n,f.opts()),n,o)},{operation:"upload"}));function ao(){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?`
79
+ `):(A(i,!1,t.noColor),n.isValidationError()&&i.includes("unknown command")&&Y(t.noColor)),process.exit(1)}function v(e,o){return async function(...t){let n=L(this),i=o?{operation:o.operation,resourceType:o.resourceType,resourceId:o.getResourceId?.(...t)}:{};try{let s=so(),r=await e(s,n,...t);pt(r,i,{json:n.json,quiet:n.quiet,noColor:n.noColor})}catch(s){Et(s,i)}}}function so(){let{config:e,apiUrl:o,apiKey:t,deployToken:n}=f.opts();return new le({configFile:e,apiUrl:o,apiKey:t,deployToken:n})}async function Tt(e,o,t,n,i){if(!(0,U.existsSync)(o))throw c.file(`${o} path does not exist`,o);let s=(0,U.statSync)(o);if(!s.isDirectory()&&!s.isFile())throw c.file(`${o} path must be a file or directory`,o);let r={via:process.env.SHIP_VIA||"cli"};t&&(r.labels=t),n?.noPathDetect!==void 0&&(r.pathDetect=!n.noPathDetect),n?.noSpaDetect!==void 0&&(r.spaDetect=!n.noSpaDetect);let a=new AbortController;r.signal=a.signal;let l=null;if(process.stdout.isTTY&&!i.json&&!i.quiet&&!i.noColor){let{default:d}=await import("yocto-spinner");l=d({text:"uploading\u2026"}).start()}let p=()=>{a.abort(),l&&l.stop(),process.exit(130)};process.on("SIGINT",p);try{return await e.deployments.upload(o,r)}finally{process.removeListener("SIGINT",p),l&&l.stop()}}f.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(io.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=L(e);o.help&&(Y(o.noColor),process.exit(0))});f.hook("preAction",e=>{let o=L(e);try{o.apiKey&&typeof o.apiKey=="string"&&te(o.apiKey),o.deployToken&&typeof o.deployToken=="string"&&$e(o.deployToken),o.apiUrl&&typeof o.apiUrl=="string"&&Le(o.apiUrl)}catch(t){throw k(t)&&(A(t.message,o.json,o.noColor),process.exit(1)),t}});f.command("ping").description("Check API connectivity").action(v((e,o)=>e.ping()));f.command("whoami").description("Get current account information").action(v((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var ee=f.command("deployments").description("Manage deployments").enablePositionalOptions().action(Q(["list","upload","get","set","remove"]));ee.command("list").description("List all deployments").action(v((e,o)=>e.deployments.list()));ee.command("upload <path>").description("Upload deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",X,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(v((e,o,t,n)=>Tt(e,t,Z(n,f.opts()),n,o),{operation:"upload"}));ee.command("get <deployment>").description("Show deployment information").action(v((e,o,t)=>e.deployments.get(t),{operation:"get",resourceType:"Deployment",getResourceId:e=>e}));ee.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",X,[]).action(v(async(e,o,t,n)=>{let i=Z(n,f.opts())||[];return e.deployments.set(t,{labels:i})},{operation:"set",resourceType:"Deployment",getResourceId:e=>e}));ee.command("remove <deployment>").description("Delete deployment permanently").action(v((e,o,t)=>e.deployments.remove(t),{operation:"remove",resourceType:"Deployment",getResourceId:e=>e}));var V=f.command("domains").description("Manage domains").enablePositionalOptions().action(Q(["list","get","set","validate","verify","remove"]));V.command("list").description("List all domains").action(v((e,o)=>e.domains.list()));V.command("get <name>").description("Show domain information").action(v((e,o,t)=>e.domains.get(t),{operation:"get",resourceType:"Domain",getResourceId:e=>e}));V.command("validate <name>").description("Check if domain name is valid and available").action(v((e,o,t)=>e.domains.validate(t),{operation:"validate",resourceType:"Domain",getResourceId:e=>e}));V.command("verify <name>").description("Trigger DNS verification for external domain").action(v((e,o,t)=>e.domains.verify(t),{operation:"verify",resourceType:"Domain",getResourceId:e=>e}));V.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",X,[]).action(v(async(e,o,t,n,i)=>{!n&&!process.stdin.isTTY&&(n=await new Promise(l=>{let p="";process.stdin.on("data",d=>p+=d),process.stdin.on("end",()=>l(p.trim()||void 0))}));let s=Z(i,f.opts()),r={};n&&(r.deployment=n),s&&s.length>0&&(r.labels=s);let a=await e.domains.set(t,r);if(a.isCreate&&t.includes("."))try{let[l,p]=await Promise.all([e.domains.records(t),e.domains.share(t)]);return{...a,_dnsRecords:l.records,_shareHash:p.hash}}catch{}return a},{operation:"set",resourceType:"Domain",getResourceId:e=>e}));V.command("remove <name>").description("Delete domain permanently").action(v((e,o,t)=>e.domains.remove(t),{operation:"remove",resourceType:"Domain",getResourceId:e=>e}));var Oe=f.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(Q(["list","create","remove"]));Oe.command("list").description("List all tokens").action(v((e,o)=>e.tokens.list()));Oe.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)",X,[]).action(v((e,o,t)=>{let n={};t?.ttl!==void 0&&(n.ttl=t.ttl);let i=Z(t,f.opts());return i&&i.length>0&&(n.labels=i),e.tokens.create(n)},{operation:"create",resourceType:"Token"}));Oe.command("remove <token>").description("Delete token permanently").action(v((e,o,t)=>e.tokens.remove(t),{operation:"remove",resourceType:"Token",getResourceId:e=>e}));var ro=f.command("account").description("Manage account").action(Q(["get"]));ro.command("get").description("Show account information").action(v((e,o)=>e.whoami(),{operation:"get",resourceType:"Account"}));var At=f.command("completion").description("Setup shell completion").action(Q(["install","uninstall"]));At.command("install").description("Install shell completion script").action(()=>{let e=L(f),o=ue.resolve(__dirname,"completions");ut(o,{json:e.json,noColor:e.noColor})});At.command("uninstall").description("Uninstall shell completion script").action(()=>{let e=L(f);mt({json:e.json,noColor:e.noColor})});f.command("config").description("Save your API key").action(async()=>{let e=L(f);try{await bt({noColor:e.noColor,json:e.json})}catch(o){Et(o)}});f.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",X,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(v(async(e,o,t,n)=>{if(t||(Y(o.noColor),process.exit(0)),!(0,U.existsSync)(t)&&!t.includes("/")&&!t.includes("\\")&&!t.includes(".")&&!t.startsWith("~"))throw c.validation(`unknown command '${t}'`);return Tt(e,t,Z(n,f.opts()),n,o)},{operation:"upload"}));function ao(){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?`
78
80
  `:" ")),process.exit(0)}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish"))&&ao();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}
79
81
  //# sourceMappingURL=cli.cjs.map