commercebuild-cli 0.0.2 → 0.0.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/index.js +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";var y6=Object.create;var rd=Object.defineProperty;var _6=Object.getOwnPropertyDescriptor;var F6=Object.getOwnPropertyNames;var E6=Object.getPrototypeOf,w6=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var C6=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of F6(e))!w6.call(t,i)&&i!==r&&rd(t,i,{get:()=>e[i],enumerable:!(n=_6(e,i))||n.enumerable});return t};var A=(t,e,r)=>(r=t!=null?y6(E6(t)):{},C6(e||!t||!t.__esModule?rd(r,"default",{value:t,enumerable:!0}):r,t));var vn=d(Is=>{var oi=class extends Error{constructor(e,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=e,this.nestedError=void 0}},ks=class extends oi{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Is.CommanderError=oi;Is.InvalidArgumentError=ks});var si=d(Rs=>{var{InvalidArgumentError:O6}=vn(),Ms=class{constructor(e,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:r.concat(e)}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new O6(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function S6(t){let e=t.name()+(t.variadic===!0?"...":"");return t.required?"<"+e+">":"["+e+"]"}Rs.Argument=Ms;Rs.humanReadableArgName=S6});var $s=d(Us=>{var{humanReadableArgName:A6}=si(),Ls=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let r=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((i,u)=>i.name().localeCompare(u.name())),r}compareOptions(e,r){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(r))}visibleOptions(e){let r=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),u=n.long&&e._findOption(n.long);!i&&!u?r.push(n):n.long&&!u?r.push(e.createOption(n.long,n.description)):n.short&&!i&&r.push(e.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let r=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(u=>!u.hidden);r.push(...i)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(r=>{r.description=r.description||e._argsDescription[r.name()]||""}),e.registeredArguments.find(r=>r.description)?e.registeredArguments:[]}subcommandTerm(e){let r=e.registeredArguments.map(n=>A6(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,r){return r.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(i)))),0)}longestOptionTermLength(e,r){return r.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,r){return r.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestArgumentTermLength(e,r){return r.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(i)))),0)}commandUsage(e){let r=e._name;e._aliases[0]&&(r=r+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+r+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&r.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&r.push(`env: ${e.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,r,n){return r.length===0?[]:[n.styleTitle(e),...r,""]}groupItems(e,r,n){let i=new Map;return e.forEach(u=>{let a=n(u);i.has(a)||i.set(a,[])}),r.forEach(u=>{let a=n(u);i.has(a)||i.set(a,[]),i.get(a).push(u)}),i}formatHelp(e,r){let n=r.padWidth(e,r),i=r.helpWidth??80;function u(h,x){return r.formatItem(h,n,x,r)}let a=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(e))}`,""],o=r.commandDescription(e);o.length>0&&(a=a.concat([r.boxWrap(r.styleCommandDescription(o),i),""]));let s=r.visibleArguments(e).map(h=>u(r.styleArgumentTerm(r.argumentTerm(h)),r.styleArgumentDescription(r.argumentDescription(h))));if(a=a.concat(this.formatItemList("Arguments:",s,r)),this.groupItems(e.options,r.visibleOptions(e),h=>h.helpGroupHeading??"Options:").forEach((h,x)=>{let p=h.map(m=>u(r.styleOptionTerm(r.optionTerm(m)),r.styleOptionDescription(r.optionDescription(m))));a=a.concat(this.formatItemList(x,p,r))}),r.showGlobalOptions){let h=r.visibleGlobalOptions(e).map(x=>u(r.styleOptionTerm(r.optionTerm(x)),r.styleOptionDescription(r.optionDescription(x))));a=a.concat(this.formatItemList("Global Options:",h,r))}return this.groupItems(e.commands,r.visibleCommands(e),h=>h.helpGroup()||"Commands:").forEach((h,x)=>{let p=h.map(m=>u(r.styleSubcommandTerm(r.subcommandTerm(m)),r.styleSubcommandDescription(r.subcommandDescription(m))));a=a.concat(this.formatItemList(x,p,r))}),a.join(`
|
|
2
3
|
`)}displayWidth(e){return nd(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,r){return Math.max(r.longestOptionTermLength(e,r),r.longestGlobalOptionTermLength(e,r),r.longestSubcommandTermLength(e,r),r.longestArgumentTermLength(e,r))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,r,n,i){let a=" ".repeat(2);if(!n)return a+e;let o=e.padEnd(r+e.length-i.displayWidth(e)),s=2,l=(this.helpWidth??80)-r-s-2,h;return l<this.minWidthToWrap||i.preformatted(n)?h=n:h=i.boxWrap(n,l).replace(/\n/g,`
|
|
3
4
|
`+" ".repeat(r+s)),a+o+" ".repeat(s)+h.replace(/\n/g,`
|
|
@@ -87,7 +88,7 @@ Store ID: ${i.store_id}
|
|
|
87
88
|
User ID: ${a?.user?.id}
|
|
88
89
|
User Email: ${a?.user?.email}
|
|
89
90
|
Customer: ${a?.user?.customer.customerCode||""} ${a.user?.customer.name||""}`,{padding:1}))}catch(e){t.fail(`${te.red(`An error occurred: ${e.message||"An unknown issue was encountered."}`)}
|
|
90
|
-
Please try logging in again, or contact the administrator if the issue persists.`)}finally{process.exit()}});var bn=new hr;bn.name("extension").description("commercebuild Extension CLI");bn.command("list").description("list all available extensions").action(()=>{console.log("Listing all extensions...")});bn.command("create <directory>").description("create a new extension in the specified directory").action(t=>{console.log(`Creating a new extension in directory: ${t}`)});bn.command("checkout").description("checkout an existing extension for modification").action(()=>{console.log("Checking out an extension...")});var b6="commercebuild-cli",td="0.0.
|
|
91
|
+
Please try logging in again, or contact the administrator if the issue persists.`)}finally{process.exit()}});var bn=new hr;bn.name("extension").description("commercebuild Extension CLI");bn.command("list").description("list all available extensions").action(()=>{console.log("Listing all extensions...")});bn.command("create <directory>").description("create a new extension in the specified directory").action(t=>{console.log(`Creating a new extension in directory: ${t}`)});bn.command("checkout").description("checkout an existing extension for modification").action(()=>{console.log("Checking out an extension...")});var b6="commercebuild-cli",td="0.0.3",v6="CLI tool for executing commercebuild commands";var fP=new hr;fP.name(b6).description(`${v6}
|
|
91
92
|
|
|
92
93
|
Version: ${td}`).version(td).addCommand(Dn).addCommand(bn).addHelpText("after",`
|
|
93
94
|
For more information, see https://docs.commercebuild.com/cli`).parse();
|