@shipstatic/ship 0.5.0 → 0.5.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 CHANGED
@@ -29,7 +29,7 @@ ship deployments remove <id>
29
29
 
30
30
  # Domains
31
31
  ship domains list
32
- ship domains set staging <deployment-id> # Point domain to deployment
32
+ ship domains set staging <deployment-id> # Link domain to deployment
33
33
  ship domains set staging --label production # Update domain labels
34
34
  ship domains get staging
35
35
  ship domains verify www.example.com
@@ -148,10 +148,10 @@ ship.ping() // Check API connectivity
148
148
  ### domains.set() Behavior
149
149
 
150
150
  ```typescript
151
- // Point domain to deployment
151
+ // Link domain to deployment
152
152
  ship.domains.set('staging', { deployment: 'abc123' });
153
153
 
154
- // Point domain to deployment with labels
154
+ // Link domain to deployment with labels
155
155
  ship.domains.set('staging', { deployment: 'abc123', labels: ['prod'] });
156
156
 
157
157
  // Update labels only (domain must exist)
package/dist/cli.cjs CHANGED
@@ -38,7 +38,7 @@ ${e("COMMANDS")}
38
38
 
39
39
  \u{1F30E} ${e("Domains")}
40
40
  ship domains list List all domains
41
- ship domains set <name> [deployment] Create domain, point to deployment, or update labels
41
+ ship domains set <name> [deployment] Create domain, link to deployment, or update labels
42
42
  ship domains get <name> Show domain information
43
43
  ship domains validate <name> Check if domain name is valid and available
44
44
  ship domains verify <name> Trigger DNS verification for external domain
@@ -69,6 +69,6 @@ ${e("FLAGS")}
69
69
 
70
70
  ${o("Please report any issues to https://github.com/shipstatic/ship/issues")}
71
71
  `;console.log(n)}function V(t,e=[]){return e.concat([t])}function ce(t,e){let o=t?.label?.length?t.label:e?.label;return o?.length?o:void 0}function W(t){return(...e)=>{let o=de(h),n=e[e.length-1];if(n?.args?.length){let i=n.args.find(s=>!t.includes(s));i&&E(`unknown command '${i}'`,o.json,o.noColor)}q(o.noColor),process.exit(1)}}function de(t){let e=t.optsWithGlobals?t.optsWithGlobals():t.opts();return e.color===!1&&(e.noColor=!0),e}function yt(t,e){let o=h.opts(),n=ut(t),i=ft(n,e,{apiKey:o.apiKey,deployToken:o.deployToken});o.json?console.error(ht(i,n.details)+`
72
- `):(E(i,o.json,o.noColor),n.isValidationError()&&i.includes("unknown command")&&q(o.noColor)),process.exit(1)}function x(t,e){return async function(...o){let n=de(this);try{let i=Yt(),s=await t(i,...o),r=e?{operation:e.operation,resourceType:e.resourceType,resourceId:e.getResourceId?e.getResourceId(...o):void 0}:{};Xt(s,r,n)}catch(i){let s=e?{operation:e.operation,resourceType:e.resourceType,resourceId:e.getResourceId?e.getResourceId(...o):void 0}:void 0;yt(i,s)}}}function Yt(){let{config:t,apiUrl:e,apiKey:o,deployToken:n}=h.opts();return new ie({configFile:t,apiUrl:e,apiKey:o,deployToken:n})}async function St(t,e,o,n){if(!(0,N.existsSync)(e))throw p.file(`${e} path does not exist`,e);let i=(0,N.statSync)(e);if(!i.isDirectory()&&!i.isFile())throw p.file(`${e} path must be a file or directory`,e);let s={via:"cli"},r=ce(o,h.opts());r&&(s.labels=r),o?.noPathDetect!==void 0&&(s.pathDetect=!o.noPathDetect),o?.noSpaDetect!==void 0&&(s.spaDetect=!o.noSpaDetect);let l=new AbortController;s.signal=l.signal;let a=null,c=n?de(n):{};if(process.stdout.isTTY&&!c.json&&!c.noColor){let{default:d}=await import("yocto-spinner");a=d({text:"uploading\u2026"}).start()}let m=()=>{l.abort(),a&&a.stop(),process.exit(130)};process.on("SIGINT",m);try{let d=await t.deployments.create(e,s);return process.removeListener("SIGINT",m),a&&a.stop(),d}catch(d){throw process.removeListener("SIGINT",m),a&&a.stop(),d}}function Xt(t,e,o){let n=o||h.opts();ot(t,e,{isJson:n.json,noColor:n.noColor})}h.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(Wt.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("--no-color","Disable colored output").option("--help","Display help for command").helpOption(!1);h.hook("preAction",(t,e)=>{let o=t.opts();if(o.help){let n=o.color===!1||o.noColor;q(n),process.exit(0)}});h.hook("preAction",(t,e)=>{let o=t.opts();try{o.apiKey&&typeof o.apiKey=="string"&&X(o.apiKey),o.deployToken&&typeof o.deployToken=="string"&&Ae(o.deployToken),o.apiUrl&&typeof o.apiUrl=="string"&&Pe(o.apiUrl)}catch(n){if(R(n)){let i=o.color===!1||o.noColor;E(n.message,o.json,i),process.exit(1)}throw n}});h.command("ping").description("Check API connectivity").action(x(t=>t.ping()));h.command("whoami").description("Get current account information").action(x(t=>t.whoami(),{operation:"get",resourceType:"Account"}));var Y=h.command("deployments").description("Manage deployments").enablePositionalOptions().action(W(["list","create","get","set","remove"]));Y.command("list").description("List all deployments").action(x(t=>t.deployments.list()));Y.command("create <path>").description("Create deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",V,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(x(function(t,e,o){return St(t,e,o,this)},{operation:"create"}));Y.command("get <deployment>").description("Show deployment information").action(x((t,e)=>t.deployments.get(e),{operation:"get",resourceType:"Deployment",getResourceId:t=>t}));Y.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",V,[]).action(x(async(t,e,o)=>{let n=ce(o,h.opts())||[];return t.deployments.set(e,{labels:n})},{operation:"set",resourceType:"Deployment",getResourceId:t=>t}));Y.command("remove <deployment>").description("Delete deployment permanently").action(x((t,e)=>t.deployments.remove(e),{operation:"remove",resourceType:"Deployment",getResourceId:t=>t}));var z=h.command("domains").description("Manage domains").enablePositionalOptions().action(W(["list","get","set","validate","verify","remove"]));z.command("list").description("List all domains").action(x(t=>t.domains.list()));z.command("get <name>").description("Show domain information").action(x((t,e)=>t.domains.get(e),{operation:"get",resourceType:"Domain",getResourceId:t=>t}));z.command("validate <name>").description("Check if domain name is valid and available").action(x((t,e)=>t.domains.validate(e),{operation:"validate",resourceType:"Domain",getResourceId:t=>t}));z.command("verify <name>").description("Trigger DNS verification for external domain").action(x((t,e)=>t.domains.verify(e),{operation:"verify",resourceType:"Domain",getResourceId:t=>t}));z.command("set <name> [deployment]").description("Create domain, point to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",V,[]).action(x(async(t,e,o,n)=>{let i=ce(n,h.opts()),s={};o&&(s.deployment=o),i&&i.length>0&&(s.labels=i);let r=await t.domains.set(e,s);if(r.isCreate&&e.includes("."))try{let[l,a]=await Promise.all([t.domains.records(e),t.domains.share(e)]);return{...r,_dnsRecords:l.records,_shareHash:a.hash}}catch{}return r},{operation:"set",resourceType:"Domain",getResourceId:t=>t}));z.command("remove <name>").description("Delete domain permanently").action(x((t,e)=>t.domains.remove(e),{operation:"remove",resourceType:"Domain",getResourceId:t=>t}));var Re=h.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(W(["list","create","remove"]));Re.command("list").description("List all tokens").action(x(t=>t.tokens.list()));Re.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)",V,[]).action(x((t,e)=>{let o={};e?.ttl!==void 0&&(o.ttl=e.ttl);let n=ce(e,h.opts());return n&&n.length>0&&(o.labels=n),t.tokens.create(o)},{operation:"create",resourceType:"Token"}));Re.command("remove <token>").description("Delete token permanently").action(x((t,e)=>t.tokens.remove(e),{operation:"remove",resourceType:"Token",getResourceId:t=>t}));var Zt=h.command("account").description("Manage account").action(W(["get"]));Zt.command("get").description("Show account information").action(x(t=>t.whoami(),{operation:"get",resourceType:"Account"}));var Ct=h.command("completion").description("Setup shell completion").action(W(["install","uninstall"]));Ct.command("install").description("Install shell completion script").action(()=>{let t=h.opts(),e=pe.resolve(__dirname,"completions");st(e,{isJson:t.json,noColor:t.noColor})});Ct.command("uninstall").description("Uninstall shell completion script").action(()=>{let t=h.opts();rt({isJson:t.json,noColor:t.noColor})});h.command("config").description("Create or update ~/.shiprc configuration").action(async()=>{let t=de(h);try{await mt({noColor:t.noColor,json:t.json})}catch(e){yt(e)}});h.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",V,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(x(async function(t,e,o){if(!e){let n=h.opts(),i=n.color===!1||n.noColor;q(i),process.exit(0)}if(!(0,N.existsSync)(e)&&!e.includes("/")&&!e.includes("\\")&&!e.includes(".")&&!e.startsWith("~"))throw p.validation(`unknown command '${e}'`);return St(t,e,o,this)},{operation:"create"}));function Qt(){let t=process.argv,e=t.includes("--compbash"),o=t.includes("--compzsh"),n=t.includes("--compfish");if(!e&&!o&&!n)return;console.log(["ping","whoami","deployments","domains","account","config","completion"].join(n?`
72
+ `):(E(i,o.json,o.noColor),n.isValidationError()&&i.includes("unknown command")&&q(o.noColor)),process.exit(1)}function x(t,e){return async function(...o){let n=de(this);try{let i=Yt(),s=await t(i,...o),r=e?{operation:e.operation,resourceType:e.resourceType,resourceId:e.getResourceId?e.getResourceId(...o):void 0}:{};Xt(s,r,n)}catch(i){let s=e?{operation:e.operation,resourceType:e.resourceType,resourceId:e.getResourceId?e.getResourceId(...o):void 0}:void 0;yt(i,s)}}}function Yt(){let{config:t,apiUrl:e,apiKey:o,deployToken:n}=h.opts();return new ie({configFile:t,apiUrl:e,apiKey:o,deployToken:n})}async function St(t,e,o,n){if(!(0,N.existsSync)(e))throw p.file(`${e} path does not exist`,e);let i=(0,N.statSync)(e);if(!i.isDirectory()&&!i.isFile())throw p.file(`${e} path must be a file or directory`,e);let s={via:"cli"},r=ce(o,h.opts());r&&(s.labels=r),o?.noPathDetect!==void 0&&(s.pathDetect=!o.noPathDetect),o?.noSpaDetect!==void 0&&(s.spaDetect=!o.noSpaDetect);let l=new AbortController;s.signal=l.signal;let a=null,c=n?de(n):{};if(process.stdout.isTTY&&!c.json&&!c.noColor){let{default:d}=await import("yocto-spinner");a=d({text:"uploading\u2026"}).start()}let m=()=>{l.abort(),a&&a.stop(),process.exit(130)};process.on("SIGINT",m);try{let d=await t.deployments.create(e,s);return process.removeListener("SIGINT",m),a&&a.stop(),d}catch(d){throw process.removeListener("SIGINT",m),a&&a.stop(),d}}function Xt(t,e,o){let n=o||h.opts();ot(t,e,{isJson:n.json,noColor:n.noColor})}h.name("ship").description("\u{1F680} Deploy static sites with simplicity").version(Wt.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("--no-color","Disable colored output").option("--help","Display help for command").helpOption(!1);h.hook("preAction",(t,e)=>{let o=t.opts();if(o.help){let n=o.color===!1||o.noColor;q(n),process.exit(0)}});h.hook("preAction",(t,e)=>{let o=t.opts();try{o.apiKey&&typeof o.apiKey=="string"&&X(o.apiKey),o.deployToken&&typeof o.deployToken=="string"&&Ae(o.deployToken),o.apiUrl&&typeof o.apiUrl=="string"&&Pe(o.apiUrl)}catch(n){if(R(n)){let i=o.color===!1||o.noColor;E(n.message,o.json,i),process.exit(1)}throw n}});h.command("ping").description("Check API connectivity").action(x(t=>t.ping()));h.command("whoami").description("Get current account information").action(x(t=>t.whoami(),{operation:"get",resourceType:"Account"}));var Y=h.command("deployments").description("Manage deployments").enablePositionalOptions().action(W(["list","create","get","set","remove"]));Y.command("list").description("List all deployments").action(x(t=>t.deployments.list()));Y.command("create <path>").description("Create deployment from file or directory").passThroughOptions().option("--label <label>","Label to add (can be repeated)",V,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(x(function(t,e,o){return St(t,e,o,this)},{operation:"create"}));Y.command("get <deployment>").description("Show deployment information").action(x((t,e)=>t.deployments.get(e),{operation:"get",resourceType:"Deployment",getResourceId:t=>t}));Y.command("set <deployment>").description("Set deployment labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",V,[]).action(x(async(t,e,o)=>{let n=ce(o,h.opts())||[];return t.deployments.set(e,{labels:n})},{operation:"set",resourceType:"Deployment",getResourceId:t=>t}));Y.command("remove <deployment>").description("Delete deployment permanently").action(x((t,e)=>t.deployments.remove(e),{operation:"remove",resourceType:"Deployment",getResourceId:t=>t}));var z=h.command("domains").description("Manage domains").enablePositionalOptions().action(W(["list","get","set","validate","verify","remove"]));z.command("list").description("List all domains").action(x(t=>t.domains.list()));z.command("get <name>").description("Show domain information").action(x((t,e)=>t.domains.get(e),{operation:"get",resourceType:"Domain",getResourceId:t=>t}));z.command("validate <name>").description("Check if domain name is valid and available").action(x((t,e)=>t.domains.validate(e),{operation:"validate",resourceType:"Domain",getResourceId:t=>t}));z.command("verify <name>").description("Trigger DNS verification for external domain").action(x((t,e)=>t.domains.verify(e),{operation:"verify",resourceType:"Domain",getResourceId:t=>t}));z.command("set <name> [deployment]").description("Create domain, link to deployment, or update labels").passThroughOptions().option("--label <label>","Label to set (can be repeated)",V,[]).action(x(async(t,e,o,n)=>{let i=ce(n,h.opts()),s={};o&&(s.deployment=o),i&&i.length>0&&(s.labels=i);let r=await t.domains.set(e,s);if(r.isCreate&&e.includes("."))try{let[l,a]=await Promise.all([t.domains.records(e),t.domains.share(e)]);return{...r,_dnsRecords:l.records,_shareHash:a.hash}}catch{}return r},{operation:"set",resourceType:"Domain",getResourceId:t=>t}));z.command("remove <name>").description("Delete domain permanently").action(x((t,e)=>t.domains.remove(e),{operation:"remove",resourceType:"Domain",getResourceId:t=>t}));var Re=h.command("tokens").description("Manage deploy tokens").enablePositionalOptions().action(W(["list","create","remove"]));Re.command("list").description("List all tokens").action(x(t=>t.tokens.list()));Re.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)",V,[]).action(x((t,e)=>{let o={};e?.ttl!==void 0&&(o.ttl=e.ttl);let n=ce(e,h.opts());return n&&n.length>0&&(o.labels=n),t.tokens.create(o)},{operation:"create",resourceType:"Token"}));Re.command("remove <token>").description("Delete token permanently").action(x((t,e)=>t.tokens.remove(e),{operation:"remove",resourceType:"Token",getResourceId:t=>t}));var Zt=h.command("account").description("Manage account").action(W(["get"]));Zt.command("get").description("Show account information").action(x(t=>t.whoami(),{operation:"get",resourceType:"Account"}));var Ct=h.command("completion").description("Setup shell completion").action(W(["install","uninstall"]));Ct.command("install").description("Install shell completion script").action(()=>{let t=h.opts(),e=pe.resolve(__dirname,"completions");st(e,{isJson:t.json,noColor:t.noColor})});Ct.command("uninstall").description("Uninstall shell completion script").action(()=>{let t=h.opts();rt({isJson:t.json,noColor:t.noColor})});h.command("config").description("Create or update ~/.shiprc configuration").action(async()=>{let t=de(h);try{await mt({noColor:t.noColor,json:t.json})}catch(e){yt(e)}});h.argument("[path]","Path to deploy").option("--label <label>","Label to add (can be repeated)",V,[]).option("--no-path-detect","Disable automatic path optimization and flattening").option("--no-spa-detect","Disable automatic SPA detection and configuration").action(x(async function(t,e,o){if(!e){let n=h.opts(),i=n.color===!1||n.noColor;q(i),process.exit(0)}if(!(0,N.existsSync)(e)&&!e.includes("/")&&!e.includes("\\")&&!e.includes(".")&&!e.startsWith("~"))throw p.validation(`unknown command '${e}'`);return St(t,e,o,this)},{operation:"create"}));function Qt(){let t=process.argv,e=t.includes("--compbash"),o=t.includes("--compzsh"),n=t.includes("--compfish");if(!e&&!o&&!n)return;console.log(["ping","whoami","deployments","domains","tokens","account","config","completion"].join(n?`
73
73
  `:" ")),process.exit(0)}process.env.NODE_ENV!=="test"&&(process.argv.includes("--compbash")||process.argv.includes("--compzsh")||process.argv.includes("--compfish"))&&Qt();if(process.env.NODE_ENV!=="test")try{h.parse(process.argv)}catch(t){if(t instanceof Error&&"code"in t){let e=t.code,o=t.exitCode;e?.startsWith("commander.")&&process.exit(o||1)}throw t}
74
74
  //# sourceMappingURL=cli.cjs.map