@yybpc/cli 1.0.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -21
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -1,36 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
3
- var Ir=Object.create;var wt=Object.defineProperty;var $r=Object.getOwnPropertyDescriptor;var Nr=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Lr=Object.prototype.hasOwnProperty;var W=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var _=(r,t)=>()=>(r&&(t=r(r=0)),t);var $=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),j=(r,t)=>{for(var e in t)wt(r,e,{get:t[e],enumerable:!0})},Hr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nr(t))!Lr.call(r,o)&&o!==e&&wt(r,o,{get:()=>t[o],enumerable:!(n=$r(t,o))||n.enumerable});return r};var Mr=(r,t,e)=>(e=r!=null?Ir(jr(r)):{},Hr(t||!r||!r.__esModule?wt(e,"default",{value:r,enumerable:!0}):e,r));var J=$(St=>{"use strict";var tt=class extends Error{constructor(t,e,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},At=class extends tt{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};St.CommanderError=tt;St.InvalidArgumentError=At});var et=$(Tt=>{"use strict";var{InvalidArgumentError:Vr}=J(),Rt=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new Vr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function qr(r){let t=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+t+">":"["+t+"]"}Tt.Argument=Rt;Tt.humanReadableArgName=qr});var xt=$(vt=>{"use strict";var{humanReadableArgName:Gr}=et(),Et=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(o=>!o._hidden),n=t._getHelpCommand();return n&&!n._hidden&&e.push(n),this.sortSubcommands&&e.sort((o,i)=>o.name().localeCompare(i.name())),e}compareOptions(t,e){let n=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return n(t).localeCompare(n(e))}visibleOptions(t){let e=t.options.filter(o=>!o.hidden),n=t._getHelpOption();if(n&&!n.hidden){let o=n.short&&t._findOption(n.short),i=n.long&&t._findOption(n.long);!o&&!i?e.push(n):n.long&&!i?e.push(t.createOption(n.long,n.description)):n.short&&!o&&e.push(t.createOption(n.short,n.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let n=t.parent;n;n=n.parent){let o=n.options.filter(i=>!i.hidden);e.push(...o)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(n=>Gr(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(o)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleOptionTerm(e.optionTerm(o)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleOptionTerm(e.optionTerm(o)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(o)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let n="";for(let o=t.parent;o;o=o.parent)n=o.name()+" "+n;return n+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0){let n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatItemList(t,e,n){return e.length===0?[]:[n.styleTitle(t),...e,""]}groupItems(t,e,n){let o=new Map;return t.forEach(i=>{let s=n(i);o.has(s)||o.set(s,[])}),e.forEach(i=>{let s=n(i);o.has(s)||o.set(s,[]),o.get(s).push(i)}),o}formatHelp(t,e){let n=e.padWidth(t,e),o=e.helpWidth??80;function i(u,l){return e.formatItem(u,n,l,e)}let s=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(s=s.concat([e.boxWrap(e.styleCommandDescription(a),o),""]));let c=e.visibleArguments(t).map(u=>i(e.styleArgumentTerm(e.argumentTerm(u)),e.styleArgumentDescription(e.argumentDescription(u))));if(s=s.concat(this.formatItemList("Arguments:",c,e)),this.groupItems(t.options,e.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,l)=>{let m=u.map(y=>i(e.styleOptionTerm(e.optionTerm(y)),e.styleOptionDescription(e.optionDescription(y))));s=s.concat(this.formatItemList(l,m,e))}),e.showGlobalOptions){let u=e.visibleGlobalOptions(t).map(l=>i(e.styleOptionTerm(e.optionTerm(l)),e.styleOptionDescription(e.optionDescription(l))));s=s.concat(this.formatItemList("Global Options:",u,e))}return this.groupItems(t.commands,e.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,l)=>{let m=u.map(y=>i(e.styleSubcommandTerm(e.subcommandTerm(y)),e.styleSubcommandDescription(e.subcommandDescription(y))));s=s.concat(this.formatItemList(l,m,e))}),s.join(`
4
- `)}displayWidth(t){return de(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,n,o){let s=" ".repeat(2);if(!n)return s+t;let a=t.padEnd(e+t.length-o.displayWidth(t)),c=2,p=(this.helpWidth??80)-e-c-2,u;return p<this.minWidthToWrap||o.preformatted(n)?u=n:u=o.boxWrap(n,p).replace(/\n/g,`
3
+ var Lr=Object.create;var Rt=Object.defineProperty;var Hr=Object.getOwnPropertyDescriptor;var Mr=Object.getOwnPropertyNames;var Vr=Object.getPrototypeOf,qr=Object.prototype.hasOwnProperty;var J=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var _=(r,t)=>()=>(r&&(t=r(r=0)),t);var N=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),L=(r,t)=>{for(var e in t)Rt(r,e,{get:t[e],enumerable:!0})},Gr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mr(t))!qr.call(r,o)&&o!==e&&Rt(r,o,{get:()=>t[o],enumerable:!(n=Hr(t,o))||n.enumerable});return r};var Fr=(r,t,e)=>(e=r!=null?Lr(Vr(r)):{},Gr(t||!r||!r.__esModule?Rt(e,"default",{value:r,enumerable:!0}):e,r));var K=N(Et=>{"use strict";var rt=class extends Error{constructor(t,e,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},St=class extends rt{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Et.CommanderError=rt;Et.InvalidArgumentError=St});var nt=N(xt=>{"use strict";var{InvalidArgumentError:Yr}=K(),Tt=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new Yr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ur(r){let t=r.name()+(r.variadic===!0?"...":"");return r.required?"<"+t+">":"["+t+"]"}xt.Argument=Tt;xt.humanReadableArgName=Ur});var Pt=N(Dt=>{"use strict";var{humanReadableArgName:Wr}=nt(),vt=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(o=>!o._hidden),n=t._getHelpCommand();return n&&!n._hidden&&e.push(n),this.sortSubcommands&&e.sort((o,i)=>o.name().localeCompare(i.name())),e}compareOptions(t,e){let n=o=>o.short?o.short.replace(/^-/,""):o.long.replace(/^--/,"");return n(t).localeCompare(n(e))}visibleOptions(t){let e=t.options.filter(o=>!o.hidden),n=t._getHelpOption();if(n&&!n.hidden){let o=n.short&&t._findOption(n.short),i=n.long&&t._findOption(n.long);!o&&!i?e.push(n):n.long&&!i?e.push(t.createOption(n.long,n.description)):n.short&&!o&&e.push(t.createOption(n.short,n.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let n=t.parent;n;n=n.parent){let o=n.options.filter(i=>!i.hidden);e.push(...o)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(n=>Wr(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(o)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleOptionTerm(e.optionTerm(o)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleOptionTerm(e.optionTerm(o)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((n,o)=>Math.max(n,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(o)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let n="";for(let o=t.parent;o;o=o.parent)n=o.name()+" "+n;return n+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0){let n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let n=`(${e.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatItemList(t,e,n){return e.length===0?[]:[n.styleTitle(t),...e,""]}groupItems(t,e,n){let o=new Map;return t.forEach(i=>{let s=n(i);o.has(s)||o.set(s,[])}),e.forEach(i=>{let s=n(i);o.has(s)||o.set(s,[]),o.get(s).push(i)}),o}formatHelp(t,e){let n=e.padWidth(t,e),o=e.helpWidth??80;function i(u,l){return e.formatItem(u,n,l,e)}let s=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(s=s.concat([e.boxWrap(e.styleCommandDescription(a),o),""]));let c=e.visibleArguments(t).map(u=>i(e.styleArgumentTerm(e.argumentTerm(u)),e.styleArgumentDescription(e.argumentDescription(u))));if(s=s.concat(this.formatItemList("Arguments:",c,e)),this.groupItems(t.options,e.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,l)=>{let m=u.map(y=>i(e.styleOptionTerm(e.optionTerm(y)),e.styleOptionDescription(e.optionDescription(y))));s=s.concat(this.formatItemList(l,m,e))}),e.showGlobalOptions){let u=e.visibleGlobalOptions(t).map(l=>i(e.styleOptionTerm(e.optionTerm(l)),e.styleOptionDescription(e.optionDescription(l))));s=s.concat(this.formatItemList("Global Options:",u,e))}return this.groupItems(t.commands,e.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,l)=>{let m=u.map(y=>i(e.styleSubcommandTerm(e.subcommandTerm(y)),e.styleSubcommandDescription(e.subcommandDescription(y))));s=s.concat(this.formatItemList(l,m,e))}),s.join(`
4
+ `)}displayWidth(t){return fe(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,n,o){let s=" ".repeat(2);if(!n)return s+t;let a=t.padEnd(e+t.length-o.displayWidth(t)),c=2,p=(this.helpWidth??80)-e-c-2,u;return p<this.minWidthToWrap||o.preformatted(n)?u=n:u=o.boxWrap(n,p).replace(/\n/g,`
5
5
  `+" ".repeat(e+c)),s+a+" ".repeat(c)+u.replace(/\n/g,`
6
6
  ${s}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let n=t.split(/\r\n|\n/),o=/[\s]*[^\s]+/g,i=[];return n.forEach(s=>{let a=s.match(o);if(a===null){i.push("");return}let c=[a.shift()],d=this.displayWidth(c[0]);a.forEach(p=>{let u=this.displayWidth(p);if(d+u<=e){c.push(p),d+=u;return}i.push(c.join(""));let l=p.trimStart();c=[l],d=this.displayWidth(l)}),i.push(c.join(""))}),i.join(`
7
- `)}};function de(r){let t=/\x1b\[\d*(;\d*)*m/g;return r.replace(t,"")}vt.Help=Et;vt.stripColor=de});var It=$(Pt=>{"use strict";var{InvalidArgumentError:Fr}=J(),Dt=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let n=Yr(t);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return typeof t=="string"&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new Fr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?me(this.name().replace(/^no-/,"")):me(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},kt=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(t,e){let n=e.attributeName();if(!this.dualOptions.has(n))return!0;let o=this.negativeOptions.get(n).presetArg,i=o!==void 0?o:!1;return e.negate===(i===t)}};function me(r){return r.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}function Yr(r){let t,e,n=/^-[^-]$/,o=/^--[^-]/,i=r.split(/[ |,]+/).concat("guard");if(n.test(i[0])&&(t=i.shift()),o.test(i[0])&&(e=i.shift()),!t&&n.test(i[0])&&(t=i.shift()),!t&&o.test(i[0])&&(t=e,e=i.shift()),i[0].startsWith("-")){let s=i[0],a=`option creation failed due to '${s}' in option flags '${r}'`;throw/^-[^-][^-]/.test(s)?new Error(`${a}
7
+ `)}};function fe(r){let t=/\x1b\[\d*(;\d*)*m/g;return r.replace(t,"")}Dt.Help=vt;Dt.stripColor=fe});var Nt=N(It=>{"use strict";var{InvalidArgumentError:Jr}=K(),kt=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let n=Kr(t);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return typeof t=="string"&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new Jr(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?ge(this.name().replace(/^no-/,"")):ge(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},$t=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(t,e){let n=e.attributeName();if(!this.dualOptions.has(n))return!0;let o=this.negativeOptions.get(n).presetArg,i=o!==void 0?o:!1;return e.negate===(i===t)}};function ge(r){return r.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}function Kr(r){let t,e,n=/^-[^-]$/,o=/^--[^-]/,i=r.split(/[ |,]+/).concat("guard");if(n.test(i[0])&&(t=i.shift()),o.test(i[0])&&(e=i.shift()),!t&&n.test(i[0])&&(t=i.shift()),!t&&o.test(i[0])&&(t=e,e=i.shift()),i[0].startsWith("-")){let s=i[0],a=`option creation failed due to '${s}' in option flags '${r}'`;throw/^-[^-][^-]/.test(s)?new Error(`${a}
8
8
  - a short flag is a single dash and a single character
9
9
  - either use a single dash and a single character (for a short flag)
10
10
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(s)?new Error(`${a}
11
11
  - too many short flags`):o.test(s)?new Error(`${a}
12
12
  - too many long flags`):new Error(`${a}
13
- - unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:t,longFlag:e}}Pt.Option=Dt;Pt.DualOptions=kt});var fe=$(he=>{"use strict";function Ur(r,t){if(Math.abs(r.length-t.length)>3)return Math.max(r.length,t.length);let e=[];for(let n=0;n<=r.length;n++)e[n]=[n];for(let n=0;n<=t.length;n++)e[0][n]=n;for(let n=1;n<=t.length;n++)for(let o=1;o<=r.length;o++){let i=1;r[o-1]===t[n-1]?i=0:i=1,e[o][n]=Math.min(e[o-1][n]+1,e[o][n-1]+1,e[o-1][n-1]+i),o>1&&n>1&&r[o-1]===t[n-2]&&r[o-2]===t[n-1]&&(e[o][n]=Math.min(e[o][n],e[o-2][n-2]+1))}return e[r.length][t.length]}function Wr(r,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=r.startsWith("--");e&&(r=r.slice(2),t=t.map(s=>s.slice(2)));let n=[],o=3,i=.4;return t.forEach(s=>{if(s.length<=1)return;let a=Ur(r,s),c=Math.max(r.length,s.length);(c-a)/c>i&&(a<o?(o=a,n=[s]):a===o&&n.push(s))}),n.sort((s,a)=>s.localeCompare(a)),e&&(n=n.map(s=>`--${s}`)),n.length>1?`
13
+ - unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:t,longFlag:e}}It.Option=kt;It.DualOptions=$t});var _e=N(ye=>{"use strict";function Qr(r,t){if(Math.abs(r.length-t.length)>3)return Math.max(r.length,t.length);let e=[];for(let n=0;n<=r.length;n++)e[n]=[n];for(let n=0;n<=t.length;n++)e[0][n]=n;for(let n=1;n<=t.length;n++)for(let o=1;o<=r.length;o++){let i=1;r[o-1]===t[n-1]?i=0:i=1,e[o][n]=Math.min(e[o-1][n]+1,e[o][n-1]+1,e[o-1][n-1]+i),o>1&&n>1&&r[o-1]===t[n-2]&&r[o-2]===t[n-1]&&(e[o][n]=Math.min(e[o][n],e[o-2][n-2]+1))}return e[r.length][t.length]}function zr(r,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=r.startsWith("--");e&&(r=r.slice(2),t=t.map(s=>s.slice(2)));let n=[],o=3,i=.4;return t.forEach(s=>{if(s.length<=1)return;let a=Qr(r,s),c=Math.max(r.length,s.length);(c-a)/c>i&&(a<o?(o=a,n=[s]):a===o&&n.push(s))}),n.sort((s,a)=>s.localeCompare(a)),e&&(n=n.map(s=>`--${s}`)),n.length>1?`
14
14
  (Did you mean one of ${n.join(", ")}?)`:n.length===1?`
15
- (Did you mean ${n[0]}?)`:""}he.suggestSimilar=Wr});var Ce=$(Ht=>{"use strict";var Jr=W("events").EventEmitter,$t=W("child_process"),v=W("path"),rt=W("fs"),f=W("process"),{Argument:Kr,humanReadableArgName:Qr}=et(),{CommanderError:Nt}=J(),{Help:Br,stripColor:zr}=xt(),{Option:ge,DualOptions:Xr}=It(),{suggestSimilar:ye}=fe(),jt=class r extends Jr{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>f.stdout.write(e),writeErr:e=>f.stderr.write(e),outputError:(e,n)=>n(e),getOutHelpWidth:()=>f.stdout.isTTY?f.stdout.columns:void 0,getErrHelpWidth:()=>f.stderr.isTTY?f.stderr.columns:void 0,getOutHasColors:()=>Lt()??(f.stdout.isTTY&&f.stdout.hasColors?.()),getErrHasColors:()=>Lt()??(f.stderr.isTTY&&f.stderr.hasColors?.()),stripColor:e=>zr(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,n){let o=e,i=n;typeof o=="object"&&o!==null&&(i=o,o=null),i=i||{};let[,s,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(s);return o&&(c.description(o),c._executableHandler=!0),i.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(i.noHelp||i.hidden),c._executableFile=i.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),o?this:c}createCommand(t){return new r(t)}createHelp(){return Object.assign(new Br,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
16
- - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new Kr(t,e)}argument(t,e,n,o){let i=this.createArgument(t,e);return typeof n=="function"?i.default(o).argParser(n):i.default(n),this.addArgument(i),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=t??"help [command]",[,o,i]=n.match(/([^ ]+) *(.*)/),s=e??"display help for command",a=this.createCommand(o);return a.helpOption(!1),i&&a.arguments(i),s&&a.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||e)&&this._initCommandGroup(a),this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let n=["preSubcommand","preAction","postAction"];if(!n.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
17
- Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,n){this._exitCallback&&this._exitCallback(new Nt(t,e,n)),f.exit(t)}action(t){let e=n=>{let o=this.registeredArguments.length,i=n.slice(0,o);return this._storeOptionsAsProperties?i[o]=this:i[o]=this.opts(),i.push(this),t.apply(this,i)};return this._actionHandler=e,this}createOption(t,e){return new ge(t,e)}_callParseArg(t,e,n,o){try{return t.parseArg(e,n)}catch(i){if(i.code==="commander.invalidArgument"){let s=`${o} ${i.message}`;this.error(s,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let n=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
18
- - already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=o=>[o.name()].concat(o.aliases()),n=e(t).find(o=>this._findCommand(o));if(n){let o=e(this._findCommand(n)).join("|"),i=e(t).join("|");throw new Error(`cannot add command '${i}' as already have command '${o}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),n=t.attributeName();if(t.negate){let i=t.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(n,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(n,t.defaultValue,"default");let o=(i,s,a)=>{i==null&&t.presetArg!==void 0&&(i=t.presetArg);let c=this.getOptionValue(n);i!==null&&t.parseArg?i=this._callParseArg(t,i,c,s):i!==null&&t.variadic&&(i=t._collectValue(i,c)),i==null&&(t.negate?i=!1:t.isBoolean()||t.optional?i=!0:i=""),this.setOptionValueWithSource(n,i,a)};return this.on("option:"+e,i=>{let s=`error: option '${t.flags}' argument '${i}' is invalid.`;o(i,s,"cli")}),t.envVar&&this.on("optionEnv:"+e,i=>{let s=`error: option '${t.flags}' value '${i}' from env '${t.envVar}' is invalid.`;o(i,s,"env")}),this}_optionEx(t,e,n,o,i){if(typeof e=="object"&&e instanceof ge)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(e,n);if(s.makeOptionMandatory(!!t.mandatory),typeof o=="function")s.default(i).argParser(o);else if(o instanceof RegExp){let a=o;o=(c,d)=>{let p=a.exec(c);return p?p[0]:d},s.default(i).argParser(o)}else s.default(o);return this.addOption(s)}option(t,e,n,o){return this._optionEx({},t,e,n,o)}requiredOption(t,e,n,o){return this._optionEx({mandatory:!0},t,e,n,o)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,n){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=n,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(t)!==void 0&&(e=n.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){f.versions?.electron&&(e.from="electron");let o=f.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(e.from="eval")}t===void 0&&(t=f.argv),this.rawArgs=t.slice();let n;switch(e.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":f.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;case"eval":n=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,e){this._prepareForParse();let n=this._prepareUserArgs(t,e);return this._parseCommand([],n),this}async parseAsync(t,e){this._prepareForParse();let n=this._prepareUserArgs(t,e);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
19
- - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,n){if(rt.existsSync(t))return;let o=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${t}' does not exist
15
+ (Did you mean ${n[0]}?)`:""}ye.suggestSimilar=zr});var we=N(Vt=>{"use strict";var Br=J("events").EventEmitter,jt=J("child_process"),x=J("path"),ot=J("fs"),f=J("process"),{Argument:Xr,humanReadableArgName:Zr}=nt(),{CommanderError:Lt}=K(),{Help:tn,stripColor:en}=Pt(),{Option:be,DualOptions:rn}=Nt(),{suggestSimilar:Oe}=_e(),Ht=class r extends Br{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>f.stdout.write(e),writeErr:e=>f.stderr.write(e),outputError:(e,n)=>n(e),getOutHelpWidth:()=>f.stdout.isTTY?f.stdout.columns:void 0,getErrHelpWidth:()=>f.stderr.isTTY?f.stderr.columns:void 0,getOutHasColors:()=>Mt()??(f.stdout.isTTY&&f.stdout.hasColors?.()),getErrHasColors:()=>Mt()??(f.stderr.isTTY&&f.stderr.hasColors?.()),stripColor:e=>en(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,n){let o=e,i=n;typeof o=="object"&&o!==null&&(i=o,o=null),i=i||{};let[,s,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(s);return o&&(c.description(o),c._executableHandler=!0),i.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(i.noHelp||i.hidden),c._executableFile=i.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),o?this:c}createCommand(t){return new r(t)}createHelp(){return Object.assign(new tn,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
16
+ - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new Xr(t,e)}argument(t,e,n,o){let i=this.createArgument(t,e);return typeof n=="function"?i.default(o).argParser(n):i.default(n),this.addArgument(i),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=t??"help [command]",[,o,i]=n.match(/([^ ]+) *(.*)/),s=e??"display help for command",a=this.createCommand(o);return a.helpOption(!1),i&&a.arguments(i),s&&a.description(s),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||e)&&this._initCommandGroup(a),this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let n=["preSubcommand","preAction","postAction"];if(!n.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
17
+ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,n){this._exitCallback&&this._exitCallback(new Lt(t,e,n)),f.exit(t)}action(t){let e=n=>{let o=this.registeredArguments.length,i=n.slice(0,o);return this._storeOptionsAsProperties?i[o]=this:i[o]=this.opts(),i.push(this),t.apply(this,i)};return this._actionHandler=e,this}createOption(t,e){return new be(t,e)}_callParseArg(t,e,n,o){try{return t.parseArg(e,n)}catch(i){if(i.code==="commander.invalidArgument"){let s=`${o} ${i.message}`;this.error(s,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let n=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
18
+ - already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=o=>[o.name()].concat(o.aliases()),n=e(t).find(o=>this._findCommand(o));if(n){let o=e(this._findCommand(n)).join("|"),i=e(t).join("|");throw new Error(`cannot add command '${i}' as already have command '${o}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),n=t.attributeName();if(t.negate){let i=t.long.replace(/^--no-/,"--");this._findOption(i)||this.setOptionValueWithSource(n,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(n,t.defaultValue,"default");let o=(i,s,a)=>{i==null&&t.presetArg!==void 0&&(i=t.presetArg);let c=this.getOptionValue(n);i!==null&&t.parseArg?i=this._callParseArg(t,i,c,s):i!==null&&t.variadic&&(i=t._collectValue(i,c)),i==null&&(t.negate?i=!1:t.isBoolean()||t.optional?i=!0:i=""),this.setOptionValueWithSource(n,i,a)};return this.on("option:"+e,i=>{let s=`error: option '${t.flags}' argument '${i}' is invalid.`;o(i,s,"cli")}),t.envVar&&this.on("optionEnv:"+e,i=>{let s=`error: option '${t.flags}' value '${i}' from env '${t.envVar}' is invalid.`;o(i,s,"env")}),this}_optionEx(t,e,n,o,i){if(typeof e=="object"&&e instanceof be)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(e,n);if(s.makeOptionMandatory(!!t.mandatory),typeof o=="function")s.default(i).argParser(o);else if(o instanceof RegExp){let a=o;o=(c,d)=>{let p=a.exec(c);return p?p[0]:d},s.default(i).argParser(o)}else s.default(o);return this.addOption(s)}option(t,e,n,o){return this._optionEx({},t,e,n,o)}requiredOption(t,e,n,o){return this._optionEx({mandatory:!0},t,e,n,o)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,n){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=n,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(t)!==void 0&&(e=n.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){f.versions?.electron&&(e.from="electron");let o=f.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(e.from="eval")}t===void 0&&(t=f.argv),this.rawArgs=t.slice();let n;switch(e.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":f.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;case"eval":n=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,e){this._prepareForParse();let n=this._prepareUserArgs(t,e);return this._parseCommand([],n),this}async parseAsync(t,e){this._prepareForParse();let n=this._prepareUserArgs(t,e);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
19
+ - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,n){if(ot.existsSync(t))return;let o=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${t}' does not exist
20
20
  - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
21
21
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
22
- - ${o}`;throw new Error(i)}_executeSubCommand(t,e){e=e.slice();let n=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function i(p,u){let l=v.resolve(p,u);if(rt.existsSync(l))return l;if(o.includes(v.extname(u)))return;let m=o.find(y=>rt.existsSync(`${l}${y}`));if(m)return`${l}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=rt.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=v.resolve(v.dirname(p),a)}if(a){let p=i(a,s);if(!p&&!t._executableFile&&this._scriptPath){let u=v.basename(this._scriptPath,v.extname(this._scriptPath));u!==this._name&&(p=i(a,`${u}-${t._name}`))}s=p||s}n=o.includes(v.extname(s));let c;f.platform!=="win32"?n?(e.unshift(s),e=_e(f.execArgv).concat(e),c=$t.spawn(f.argv[0],e,{stdio:"inherit"})):c=$t.spawn(s,e,{stdio:"inherit"}):(this._checkForMissingExecutable(s,a,t._name),e.unshift(s),e=_e(f.execArgv).concat(e),c=$t.spawn(f.execPath,e,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{f.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let d=this._exitCallback;c.on("close",p=>{p=p??1,d?d(new Nt(p,"commander.executeSubCommandAsync","(close)")):f.exit(p)}),c.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(s,a,t._name);else if(p.code==="EACCES")throw new Error(`'${s}' not executable`);if(!d)f.exit(1);else{let u=new Nt(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,d(u)}}),this.runningCommand=c}_dispatchSubcommand(t,e,n){let o=this._findCommand(t);o||this.help({error:!0}),o._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,o,"preSubcommand"),i=this._chainOrCall(i,()=>{if(o._executableHandler)this._executeSubCommand(o,e.concat(n));else return o._parseCommand(e,n)}),i}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(n,o,i)=>{let s=o;if(o!==null&&n.parseArg){let a=`error: command-argument value '${o}' is invalid for argument '${n.name()}'.`;s=this._callParseArg(n,o,i,a)}return s};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((n,o)=>{let i=n.defaultValue;n.variadic?o<this.args.length?(i=this.args.slice(o),n.parseArg&&(i=i.reduce((s,a)=>t(n,a,s),n.defaultValue))):i===void 0&&(i=[]):o<this.args.length&&(i=this.args[o],n.parseArg&&(i=t(n,i,n.defaultValue))),e[o]=i}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let n=t,o=[];return this._getCommandAndAncestors().reverse().filter(i=>i._lifeCycleHooks[e]!==void 0).forEach(i=>{i._lifeCycleHooks[e].forEach(s=>{o.push({hookedCommand:i,callback:s})})}),e==="postAction"&&o.reverse(),o.forEach(i=>{n=this._chainOrCall(n,()=>i.callback(i.hookedCommand,this))}),n}_chainOrCallSubCommandHook(t,e,n){let o=t;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(i=>{o=this._chainOrCall(o,()=>i(this,e))}),o}_parseCommand(t,e){let n=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(n.operands),e=n.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(i,t,e)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent?.listenerCount(i))o(),this._processArguments(),this.parent.emit(i,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(n=>{let o=n.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});t.filter(n=>n.conflictsWith.length>0).forEach(n=>{let o=t.find(i=>n.conflictsWith.includes(i.attributeName()));o&&this._conflictingOption(n,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],n=[],o=e;function i(p){return p.length>1&&p[0]==="-"}let s=p=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(p)?!this._getCommandAndAncestors().some(u=>u.options.map(l=>l.short).some(l=>/^-\d$/.test(l))):!1,a=null,c=null,d=0;for(;d<t.length||c;){let p=c??t[d++];if(c=null,p==="--"){o===n&&o.push(p),o.push(...t.slice(d));break}if(a&&(!i(p)||s(p))){this.emit(`option:${a.name()}`,p);continue}if(a=null,i(p)){let u=this._findOption(p);if(u){if(u.required){let l=t[d++];l===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,l)}else if(u.optional){let l=null;d<t.length&&(!i(t[d])||s(t[d]))&&(l=t[d++]),this.emit(`option:${u.name()}`,l)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),c=`-${p.slice(2)}`);continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),l=this._findOption(p.slice(0,u));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,p.slice(u+1));continue}}if(o===e&&i(p)&&!(this.commands.length===0&&s(p))&&(o=n),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&n.length===0){if(this._findCommand(p)){e.push(p),n.push(...t.slice(d));break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){e.push(p,...t.slice(d));break}else if(this._defaultCommandName){n.push(p,...t.slice(d));break}}if(this._passThroughOptions){o.push(p,...t.slice(d));break}o.push(p)}return{operands:e,unknown:n}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let n=0;n<e;n++){let o=this.options[n].attributeName();t[o]=o===this._versionOptionName?this._version:this[o]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}
22
+ - ${o}`;throw new Error(i)}_executeSubCommand(t,e){e=e.slice();let n=!1,o=[".js",".ts",".tsx",".mjs",".cjs"];function i(p,u){let l=x.resolve(p,u);if(ot.existsSync(l))return l;if(o.includes(x.extname(u)))return;let m=o.find(y=>ot.existsSync(`${l}${y}`));if(m)return`${l}${m}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let p;try{p=ot.realpathSync(this._scriptPath)}catch{p=this._scriptPath}a=x.resolve(x.dirname(p),a)}if(a){let p=i(a,s);if(!p&&!t._executableFile&&this._scriptPath){let u=x.basename(this._scriptPath,x.extname(this._scriptPath));u!==this._name&&(p=i(a,`${u}-${t._name}`))}s=p||s}n=o.includes(x.extname(s));let c;f.platform!=="win32"?n?(e.unshift(s),e=Ce(f.execArgv).concat(e),c=jt.spawn(f.argv[0],e,{stdio:"inherit"})):c=jt.spawn(s,e,{stdio:"inherit"}):(this._checkForMissingExecutable(s,a,t._name),e.unshift(s),e=Ce(f.execArgv).concat(e),c=jt.spawn(f.execPath,e,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{f.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let d=this._exitCallback;c.on("close",p=>{p=p??1,d?d(new Lt(p,"commander.executeSubCommandAsync","(close)")):f.exit(p)}),c.on("error",p=>{if(p.code==="ENOENT")this._checkForMissingExecutable(s,a,t._name);else if(p.code==="EACCES")throw new Error(`'${s}' not executable`);if(!d)f.exit(1);else{let u=new Lt(1,"commander.executeSubCommandAsync","(error)");u.nestedError=p,d(u)}}),this.runningCommand=c}_dispatchSubcommand(t,e,n){let o=this._findCommand(t);o||this.help({error:!0}),o._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,o,"preSubcommand"),i=this._chainOrCall(i,()=>{if(o._executableHandler)this._executeSubCommand(o,e.concat(n));else return o._parseCommand(e,n)}),i}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(n,o,i)=>{let s=o;if(o!==null&&n.parseArg){let a=`error: command-argument value '${o}' is invalid for argument '${n.name()}'.`;s=this._callParseArg(n,o,i,a)}return s};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((n,o)=>{let i=n.defaultValue;n.variadic?o<this.args.length?(i=this.args.slice(o),n.parseArg&&(i=i.reduce((s,a)=>t(n,a,s),n.defaultValue))):i===void 0&&(i=[]):o<this.args.length&&(i=this.args[o],n.parseArg&&(i=t(n,i,n.defaultValue))),e[o]=i}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let n=t,o=[];return this._getCommandAndAncestors().reverse().filter(i=>i._lifeCycleHooks[e]!==void 0).forEach(i=>{i._lifeCycleHooks[e].forEach(s=>{o.push({hookedCommand:i,callback:s})})}),e==="postAction"&&o.reverse(),o.forEach(i=>{n=this._chainOrCall(n,()=>i.callback(i.hookedCommand,this))}),n}_chainOrCallSubCommandHook(t,e,n){let o=t;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(i=>{o=this._chainOrCall(o,()=>i(this,e))}),o}_parseCommand(t,e){let n=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(n.operands),e=n.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){o(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(i,t,e)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent?.listenerCount(i))o(),this._processArguments(),this.parent.emit(i,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(n=>{let o=n.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});t.filter(n=>n.conflictsWith.length>0).forEach(n=>{let o=t.find(i=>n.conflictsWith.includes(i.attributeName()));o&&this._conflictingOption(n,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],n=[],o=e;function i(p){return p.length>1&&p[0]==="-"}let s=p=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(p)?!this._getCommandAndAncestors().some(u=>u.options.map(l=>l.short).some(l=>/^-\d$/.test(l))):!1,a=null,c=null,d=0;for(;d<t.length||c;){let p=c??t[d++];if(c=null,p==="--"){o===n&&o.push(p),o.push(...t.slice(d));break}if(a&&(!i(p)||s(p))){this.emit(`option:${a.name()}`,p);continue}if(a=null,i(p)){let u=this._findOption(p);if(u){if(u.required){let l=t[d++];l===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,l)}else if(u.optional){let l=null;d<t.length&&(!i(t[d])||s(t[d]))&&(l=t[d++]),this.emit(`option:${u.name()}`,l)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(p.length>2&&p[0]==="-"&&p[1]!=="-"){let u=this._findOption(`-${p[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,p.slice(2)):(this.emit(`option:${u.name()}`),c=`-${p.slice(2)}`);continue}}if(/^--[^=]+=/.test(p)){let u=p.indexOf("="),l=this._findOption(p.slice(0,u));if(l&&(l.required||l.optional)){this.emit(`option:${l.name()}`,p.slice(u+1));continue}}if(o===e&&i(p)&&!(this.commands.length===0&&s(p))&&(o=n),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&n.length===0){if(this._findCommand(p)){e.push(p),n.push(...t.slice(d));break}else if(this._getHelpCommand()&&p===this._getHelpCommand().name()){e.push(p,...t.slice(d));break}else if(this._defaultCommandName){n.push(p,...t.slice(d));break}}if(this._passThroughOptions){o.push(p,...t.slice(d));break}o.push(p)}return{operands:e,unknown:n}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let n=0;n<e;n++){let o=this.options[n].attributeName();t[o]=o===this._versionOptionName?this._version:this[o]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}
23
23
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
24
24
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
25
- `),this.outputHelp({error:!0}));let n=e||{},o=n.exitCode||1,i=n.code||"commander.error";this._exit(o,i,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in f.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,f.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Xr(this.options),e=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&e(n.attributeName())&&t.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(o=>!e(o)).forEach(o=>{this.setOptionValueWithSource(o,n.implied[o],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let n=s=>{let a=s.attributeName(),c=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),p=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:p||s},o=s=>{let a=n(s),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},i=`error: ${o(t)} cannot be used with ${o(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let o=[],i=this;do{let s=i.createHelp().visibleOptions(i).filter(a=>a.long).map(a=>a.long);o=o.concat(s),i=i.parent}while(i&&!i._enablePositionalOptions);e=ye(t,o)}let n=`error: unknown option '${t}'${e}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,n=e===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${n} but got ${t.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(i=>{o.push(i.name()),i.alias()&&o.push(i.alias())}),e=ye(t,o)}let n=`error: unknown command '${t}'${e}`;this.error(n,{code:"commander.unknownCommand"})}version(t,e,n){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",n=n||"output the version number";let o=this.createOption(e,n);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${t}
26
- `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(t);if(n){let o=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${o}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(n=>Qr(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=v.basename(t,v.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),n=this._getOutputContext(t);e.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let o=e.formatHelp(this,e);return n.hasColors?o:this._outputConfiguration.stripColor(o)}_getOutputContext(t){t=t||{};let e=!!t.error,n,o,i;return e?(n=a=>this._outputConfiguration.writeErr(a),o=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),o=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(o||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:o,helpWidth:i}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let n=this._getOutputContext(t),o={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let i=this.helpInformation({error:n.error});if(e&&(i=e(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",o),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",o))}helpOption(t,e){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(f.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.
25
+ `),this.outputHelp({error:!0}));let n=e||{},o=n.exitCode||1,i=n.code||"commander.error";this._exit(o,i,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in f.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,f.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new rn(this.options),e=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&e(n.attributeName())&&t.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(o=>!e(o)).forEach(o=>{this.setOptionValueWithSource(o,n.implied[o],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let n=s=>{let a=s.attributeName(),c=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),p=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&c===!1||d.presetArg!==void 0&&c===d.presetArg)?d:p||s},o=s=>{let a=n(s),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},i=`error: ${o(t)} cannot be used with ${o(e)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let o=[],i=this;do{let s=i.createHelp().visibleOptions(i).filter(a=>a.long).map(a=>a.long);o=o.concat(s),i=i.parent}while(i&&!i._enablePositionalOptions);e=Oe(t,o)}let n=`error: unknown option '${t}'${e}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,n=e===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${n} but got ${t.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let o=[];this.createHelp().visibleCommands(this).forEach(i=>{o.push(i.name()),i.alias()&&o.push(i.alias())}),e=Oe(t,o)}let n=`error: unknown command '${t}'${e}`;this.error(n,{code:"commander.unknownCommand"})}version(t,e,n){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",n=n||"output the version number";let o=this.createOption(e,n);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${t}
26
+ `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(t);if(n){let o=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${o}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(n=>Zr(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=x.basename(t,x.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),n=this._getOutputContext(t);e.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let o=e.formatHelp(this,e);return n.hasColors?o:this._outputConfiguration.stripColor(o)}_getOutputContext(t){t=t||{};let e=!!t.error,n,o,i;return e?(n=a=>this._outputConfiguration.writeErr(a),o=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),o=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(o||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:o,helpWidth:i}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let n=this._getOutputContext(t),o={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let i=this.helpInformation({error:n.error});if(e&&(i=e(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",o),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",o))}helpOption(t,e){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(f.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.
27
27
  Expecting one of '${n.join("', '")}'`);let o=`${t}Help`;return this.on(o,i=>{let s;typeof e=="function"?s=e({error:i.error,command:i.command}):s=e,s&&i.write(`${s}
28
- `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(o=>e.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function _e(r){return r.map(t=>{if(!t.startsWith("--inspect"))return t;let e,n="127.0.0.1",o="9229",i;return(i=t.match(/^(--inspect(-brk)?)$/))!==null?e=i[1]:(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=i[1],/^\d+$/.test(i[3])?o=i[3]:n=i[3]):(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=i[1],n=i[3],o=i[4]),e&&o!=="0"?`${e}=${n}:${parseInt(o)+1}`:t})}function Lt(){if(f.env.NO_COLOR||f.env.FORCE_COLOR==="0"||f.env.FORCE_COLOR==="false")return!1;if(f.env.FORCE_COLOR||f.env.CLICOLOR_FORCE!==void 0)return!0}Ht.Command=jt;Ht.useColor=Lt});var Ae=$(A=>{"use strict";var{Argument:Oe}=et(),{Command:Mt}=Ce(),{CommanderError:Zr,InvalidArgumentError:be}=J(),{Help:tn}=xt(),{Option:we}=It();A.program=new Mt;A.createCommand=r=>new Mt(r);A.createOption=(r,t)=>new we(r,t);A.createArgument=(r,t)=>new Oe(r,t);A.Command=Mt;A.Option=we;A.Argument=Oe;A.Help=tn;A.CommanderError=Zr;A.InvalidArgumentError=be;A.InvalidOptionArgumentError=be});var h,R=_(()=>{"use strict";h=class extends Error{constructor(e,n,o,i){super(o);this.type=e;this.code=n;this.service=i;this.name="SvcError"}type;code;service;isAuthError(){return this.type==="AUTH_ERROR"}toJSON(){return{success:!1,error:{type:this.type,code:this.code,message:this.message,service:this.service}}}}});function nt(r){let t=r??"prod";if(!(t in Vt))throw new Error(`Unknown env: ${t}. Valid: ${Object.keys(Vt).join(", ")}`);return Vt[t]}function Te(r){let t=r??"prod";if(!(t in qt))throw new Error(`Unknown env: ${t}. Valid: ${Object.keys(qt).join(", ")}`);return qt[t]}function Ee(r){return en[r]??{timeout:rn}}var Vt,qt,en,rn,ot=_(()=>{"use strict";Vt={dev:"https://dev-hhl.yeyecha.com/api",prod:"https://hhl.yeyecha.com/api"},qt={dev:"https://dev-api.yeyecha.com",prod:"https://api.yeyecha.com"},en={report:{timeout:1e4},mdm:{timeout:1e4},baseinfo:{timeout:1e4},contract:{timeout:1e4},"user-center":{timeout:1e4}},rn=1e4});function ve(r){return{"X-Request-Id":crypto.randomUUID(),"X-Client":"yybpc-cli","X-Source":r}}var xe=_(()=>{"use strict"});var O,L=_(()=>{"use strict";O={agentLoginPath:"/sso/agentLogin",oauth:{clientId:"",authorizationURL:"",tokenURL:"",authorizePath:"/oauth2/authorize",tokenPath:"/oauth2/token",refreshPath:"/oauth2/refresh",userinfoPath:"/oauth2/userinfo",redirectPort:8399,redirectPath:"/callback",scopes:["authorize"]},storage:{get dir(){return process.env.YYBPC_CLI_HOME??`${process.env.HOME}/.yybpc-cli`},sessionFile:"session.json",tokenCacheDir:"token-cache"},refreshBufferMs:3e5}});function nn(r,t){let e=JSON.stringify(t),n=r==="prod"&&typeof t.msg=="string"&&t.msg.includes("\u767D\u540D\u5355")?"\uFF1B\u5982\u679C\u5F53\u524D\u8981\u67E5\u8BE2\u5F00\u53D1\u73AF\u5883\uFF0C\u8BF7\u663E\u5F0F\u4F20\u5165 --env dev":"";return`Agent \u767B\u5F55\u5931\u8D25: ${e}${n}`}async function on(r,t){let n=`${Te(t)}${O.agentLoginPath}`,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`mobile=${encodeURIComponent(r)}`});if(!o.ok)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",`Agent \u624B\u673A\u53F7\u767B\u5F55\u5931\u8D25: HTTP ${o.status}`);let i=await o.json();if(i.status!==0||!i.data)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",nn(t,i));let s=typeof i.data=="string"?i.data:i.data.tokenValue??i.data.access_token;if(!s)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",`Agent \u767B\u5F55\u54CD\u5E94\u7F3A\u5C11 token: ${JSON.stringify(i)}`);return{tokenValue:s,expiresIn:7200}}async function De(r){let{phone:t,cache:e,env:n}=r;if(e){let i=await e.get(t);if(i)return i.accessToken}let o=await on(t,n);if(e){let i={userId:t,accessToken:o.tokenValue,expiresAt:Date.now()+o.expiresIn*1e3,obtainedVia:"delegation",createdAt:Date.now()};await e.set(t,i)}return o.tokenValue}var ke=_(()=>{"use strict";R();L();ot()});import{mkdir as sn,readFile as an,writeFile as cn,chmod as un,unlink as pn}from"fs/promises";import{existsSync as Pe}from"fs";async function it(r,t=448){await sn(r,{recursive:!0,mode:t})}async function H(r){if(!Pe(r))return null;try{return JSON.parse(await an(r,"utf8"))}catch{return null}}async function M(r,t,e=384){await cn(r,JSON.stringify(t,null,2)),await un(r,e)}async function V(r){Pe(r)&&await pn(r)}var st=_(()=>{"use strict"});import{join as ln}from"path";function Gt(r){let t=r??O.storage.dir;return ln(t,dn)}async function at(r){return H(Gt(r))}async function ct(r,t){let e=t??O.storage.dir;await it(e,448),await M(Gt(t),r,384)}async function Ie(r){await V(Gt(r))}var dn,K=_(()=>{"use strict";L();st();dn="session.json"});import{createServer as Mo}from"http";import{spawn as qo}from"child_process";function ut(r){return r?r.expiresAt>Date.now():!1}function Ft(r){return r?r.expiresAt-Date.now()<O.refreshBufferMs:!1}async function mn(r,t){try{let e=await fetch(O.oauth.tokenURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:r.refreshToken,client_id:O.oauth.clientId})});if(!e.ok)return null;let n=await e.json(),o={...r,accessToken:n.access_token,refreshToken:n.refresh_token??r.refreshToken,expiresAt:Date.now()+n.expires_in*1e3};return await ct(o,t),o.accessToken}catch{return null}}async function $e(r){let t=await at(r);if(!t)return null;if(ut(t)&&!Ft(t))return t.accessToken;if(t.refreshToken){let e=await mn(t,r);if(e)return e}return ut(t)?t.accessToken:null}var Yt=_(()=>{"use strict";L();K()});import{join as Ut}from"path";import{mkdirSync as hn}from"fs";var pt,Ne=_(()=>{"use strict";L();st();pt=class{dir;constructor(t,e){let n=t??Ut(O.storage.dir,O.storage.tokenCacheDir);this.dir=e?Ut(n,e):n,hn(this.dir,{recursive:!0,mode:448})}filePath(t){let e=t.replace(/[^a-zA-Z0-9_-]/g,"_");return Ut(this.dir,`${e}.json`)}async get(t){let e=await H(this.filePath(t));return!e||e.expiresAt<=Date.now()?null:e}async set(t,e){await M(this.filePath(t),e,384)}async del(t){await V(this.filePath(t))}}});function je(r){return Wt.has(r)||Wt.set(r,new pt(void 0,r)),Wt.get(r)}function Le(r){return process.env.SVC_USER_PHONE??r}function fn(r){return Le(r.asPhone)?"agent":"human"}async function D(r){let t=fn(r);if(t==="agent"){let n=Le(r.asPhone);return{token:await De({phone:n,cache:je(r.env),env:r.env}),mode:t}}let e=await $e();if(!e)throw new h("AUTH_ERROR","NOT_LOGGED_IN","\u672A\u63D0\u4F9B\u8EAB\u4EFD\u8BA4\u8BC1\uFF1A\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD");return{token:e,mode:t}}async function He(r,t){await je(t).del(r)}var Wt,lt=_(()=>{"use strict";R();ke();Yt();Ne();Wt=new Map});function gn(r,t,e){let n=r.replace(/\/$/,""),o=t.startsWith("/")?t:`/${t}`,i=`${n}${o}`;if(e){let s=new URLSearchParams;for(let[c,d]of Object.entries(e))d!=null&&s.set(c,String(d));let a=s.toString();a&&(i+=`?${a}`)}return i}function Me(r,t){return{satoken:r,"Content-Type":"application/json",...ve(t)}}function Ve(r){Jt=r}function b(){return Jt}async function q(r){let t=Jt,e=nt(t.env),n=Ee(r.service),o={asPhone:t.asPhone,env:t.env},i="",s="human";if(r.anonymous)try{let g=await D(o);i=g.token,s=g.mode}catch{}else{let g=await D(o);i=g.token,s=g.mode}let a=gn(e,r.path,r.query),c=Me(i,s);if(t.dryRun)return{dryRun:!0,method:r.method,url:a,headers:{...c,satoken:"***"},body:r.body??null};t.verbose&&console.error(`[verbose] ${r.method} ${a}`);let d=Date.now(),p=async g=>{let w=new AbortController,C=setTimeout(()=>w.abort(),n.timeout);try{return await fetch(a,{method:r.method,headers:g,body:r.body?JSON.stringify(r.body):void 0,signal:w.signal})}catch(U){throw U.name==="AbortError"?new h("TRANSPORT_ERROR","TIMEOUT",`${r.service} \u670D\u52A1\u8BF7\u6C42\u8D85\u65F6`,r.service):new h("TRANSPORT_ERROR","NETWORK_ERROR",`\u7F51\u7EDC\u9519\u8BEF: ${U.message}`,r.service)}finally{clearTimeout(C)}},u=await p(c);if(u.status===401&&!r.anonymous)if(s==="agent"){let g=t.asPhone;g&&await He(g,t.env);let w=await D(o),C=Me(w.token,w.mode);u=await p(C)}else throw new h("AUTH_ERROR","TOKEN_EXPIRED","\u767B\u5F55\u5DF2\u8FC7\u671F\uFF1A\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u91CD\u65B0\u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD");let l=Date.now()-d,m=c["X-Request-Id"];if(!u.ok){if(u.status===401||u.status===403)throw new h("AUTH_ERROR",`HTTP_${u.status}`,"\u6743\u9650\u4E0D\u8DB3\u6216\u767B\u5F55\u5DF2\u8FC7\u671F",r.service);let g;try{g=(await u.json()).message??`\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF: ${u.status}`}catch{g=`\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF: ${u.status}`}throw new h("BUSINESS_ERROR",`HTTP_${u.status}`,g,r.service)}return{success:!0,data:await u.json(),meta:{service:r.service,requestId:m,duration:l}}}var Jt,x=_(()=>{"use strict";R();ot();xe();lt();Jt={env:"prod",verbose:!1,dryRun:!1}});function qe(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&Object.keys(r).length===0}function Kt(r){if(Array.isArray(r))return r.map(Kt).filter(e=>e!=null&&e!==""&&!(Array.isArray(e)&&e.length===0)&&!qe(e));if(r&&typeof r=="object"){let t={};for(let[e,n]of Object.entries(r)){let o=Kt(n);o!=null&&o!==""&&!(Array.isArray(o)&&o.length===0)&&!qe(o)&&(t[e]=o)}return t}return r}function Qt(r){if(Array.isArray(r))return r.map(Qt);if(r&&typeof r=="object"){let t={};for(let[e,n]of Object.entries(r)){let o=yn[e]??e;t[o]=Qt(n)}return t}return r}function Bt(r,t={}){let e=r;return t.stripNulls&&(e=Kt(e)),t.shortenKeys&&(e=Qt(e)),e}var yn,Ge=_(()=>{"use strict";yn={id:"i",name:"n",code:"c",type:"t",status:"s",label:"lbl",value:"v",createTime:"ct",updateTime:"ut",createdAt:"crt",updatedAt:"udt",children:"ch",parentId:"pid",storeName:"sn",storeCode:"sc",address:"addr",phone:"ph",contact:"cnt",region:"rgn",warehouse:"wh",warehouseName:"whn",product:"pdt",productName:"pdn",skuCode:"skc",barcode:"bc",category:"cat",company:"co",companyName:"cn",franchisee:"fr",franchiseeName:"frn",supplier:"sup",supplierName:"spn",area:"ar",areaName:"arn",unit:"un",unitName:"unn"}});function Fe(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function _n(r){return Array.isArray(r)&&r.length>0&&r.every(Fe)}function Cn(r){let t=[],e=new Set;for(let o of r)for(let i of Object.keys(o))e.has(i)||(e.add(i),t.push(i));let n=r.map(o=>t.map(i=>i in o?G(o[i]):null));return{columns:t,rows:n}}function G(r){if(_n(r))return Cn(r);if(Array.isArray(r))return r.map(G);if(Fe(r)){let t={};for(let[e,n]of Object.entries(r))t[e]=G(n);return t}return r}var Ye=_(()=>{"use strict"});function zt(r,t,e="none"){if(r&&typeof r=="object"&&r.dryRun===!0)return JSON.stringify(r,null,2);if(t==="raw")return JSON.stringify(r.data,null,2);if(e!=="none"){let n=e==="agent"?Bt(r.data,{stripNulls:!0,shortenKeys:!0}):e==="slim"?Bt(r.data,{stripNulls:!0}):r.data;return JSON.stringify(G(n))}return JSON.stringify({...r,data:G(r.data)},null,2)}function Q(r){if(r instanceof h)return JSON.stringify(r.toJSON(),null,2);let t=r instanceof Error?r.message:String(r);return JSON.stringify({success:!1,error:{type:"TRANSPORT_ERROR",code:"UNKNOWN",message:t}},null,2)}async function dt(r,t,e){try{let n=await e();console.log(zt(n,r,t))}catch(n){console.error(Q(n)),process.exit(1)}}var Xt=_(()=>{"use strict";R();Ge();Ye()});import{join as On}from"path";function Zt(r){return On(O.storage.dir,`report-cache-${r}.json`)}async function An(r){let t=await H(Zt(r));return!t||Date.now()-t.fetchedAt>bn||t.env!==r?null:t}async function Sn(r,t){await it(O.storage.dir,448);let e={fetchedAt:Date.now(),env:r,reports:t};await M(Zt(r),e,384)}async function Rn(r,t){let n=`${nt(r)}/report/config/list`,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",satoken:t},body:JSON.stringify({page:{pageNo:1,pageSize:500}})});if(o.status===401||o.status===403){let a=!!b().asPhone?"\u8BF7\u786E\u8BA4 --as-phone \u624B\u673A\u53F7\u6B63\u786E\uFF0C\u4E14\u5F53\u524D\u51FA\u53E3 IP \u5728\u8BE5\u73AF\u5883\u767D\u540D\u5355\u5185":"\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD";throw new h("AUTH_ERROR","NOT_LOGGED_IN",`\u83B7\u53D6\u62A5\u8868\u5217\u8868\u9700\u8981\u8EAB\u4EFD\u8BA4\u8BC1\uFF08HTTP ${o.status}\uFF09\u3002${a}`,"report")}if(!o.ok)throw new h("TRANSPORT_ERROR",`HTTP_${o.status}`,`\u62A5\u8868\u5217\u8868\u83B7\u53D6\u5931\u8D25: ${n} \u8FD4\u56DE HTTP ${o.status}`,"report");let i=await o.json();if(i.status!==0||!i.data?.data)throw new h("BUSINESS_ERROR","REPORT_LIST_FAILED",`\u62A5\u8868\u5217\u8868\u83B7\u53D6\u5931\u8D25: ${JSON.stringify(i)}`,"report");return i.data.data.map(s=>{let a=(s.items||[]).flatMap(d=>(d.params||[]).map(p=>p.paramKey)).filter(Boolean),c=[...new Set(a)].filter(d=>!wn.has(d));return{reportId:s.reportId,name:s.reportName,category:s.categoryCode,params:c}})}async function mt(r,t,e=!1){if(!e){let o=await An(r);if(o)return o.reports}let n=await Rn(r,t);return await Sn(r,n),n}function Ue(r,t){return r.find(e=>e.reportId===t)}async function k(r){await V(Zt(r))}var bn,wn,N=_(()=>{"use strict";L();ot();st();R();x();bn=1440*60*1e3,wn=new Set(["determinePeriod","determineTrendPeriod","storeDataAuth","reginDataAuth","storeCountDataAuth","storeRepurchaseDataAuth","storeHourDataAuth","storeHourCountDataAuth","hundredMillion","tenThousand","hundredMillionName","tenThousandName","currentTableName","momDateDiff","pageSize","offset","limit","1"])});var ze={};j(ze,{filterReports:()=>Ke,meta:()=>P,renderReportDetail:()=>Qe,renderReportsText:()=>Be,runReportList:()=>En});function We(r){return r.trim().toLowerCase()}function Je(r){return r.params.filter(t=>t!=="startDate"&&t!=="endDate")}function Ke(r,t={}){let e=r;if(t.reportId){let n=e.find(o=>o.reportId===t.reportId);return n?[n]:[]}if(t.category){let n=We(t.category);e=e.filter(o=>We(o.category)===n)}return e}function Tn(r){let t=`yybpc-cli report query --report-id ${r.reportId} --start-date YYYY-MM-DD --end-date YYYY-MM-DD`,e=Je(r);return e.length===0?t:`${t} --param-json '{"${e[0]}":["VALUE"]}'`}function Qe(r){let t=Je(r),e=[`reportId: ${r.reportId}`,`name: ${r.name}`,`category: ${r.category}`,`params: ${r.params.join(", ")||"(none)"}`,`query: ${Tn(r)}`];return t.length>0&&e.push(`extraParams: ${t.join(", ")}`),e.join(`
29
- `)}function Be(r,t={}){if(r.length===0)return"\u65E0\u53EF\u7528\u62A5\u8868";if(t.detail||t.reportId)return r.map(Qe).join(`
28
+ `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(o=>e.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ce(r){return r.map(t=>{if(!t.startsWith("--inspect"))return t;let e,n="127.0.0.1",o="9229",i;return(i=t.match(/^(--inspect(-brk)?)$/))!==null?e=i[1]:(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=i[1],/^\d+$/.test(i[3])?o=i[3]:n=i[3]):(i=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=i[1],n=i[3],o=i[4]),e&&o!=="0"?`${e}=${n}:${parseInt(o)+1}`:t})}function Mt(){if(f.env.NO_COLOR||f.env.FORCE_COLOR==="0"||f.env.FORCE_COLOR==="false")return!1;if(f.env.FORCE_COLOR||f.env.CLICOLOR_FORCE!==void 0)return!0}Vt.Command=Ht;Vt.useColor=Mt});var Ee=N(A=>{"use strict";var{Argument:Ae}=nt(),{Command:qt}=we(),{CommanderError:nn,InvalidArgumentError:Re}=K(),{Help:on}=Pt(),{Option:Se}=Nt();A.program=new qt;A.createCommand=r=>new qt(r);A.createOption=(r,t)=>new Se(r,t);A.createArgument=(r,t)=>new Ae(r,t);A.Command=qt;A.Option=Se;A.Argument=Ae;A.Help=on;A.CommanderError=nn;A.InvalidArgumentError=Re;A.InvalidOptionArgumentError=Re});var h,S=_(()=>{"use strict";h=class extends Error{constructor(e,n,o,i){super(o);this.type=e;this.code=n;this.service=i;this.name="SvcError"}type;code;service;isAuthError(){return this.type==="AUTH_ERROR"}toJSON(){return{success:!1,error:{type:this.type,code:this.code,message:this.message,service:this.service}}}}});function it(r){let t=r??"prod";if(!(t in Gt))throw new Error(`Unknown env: ${t}. Valid: ${Object.keys(Gt).join(", ")}`);return Gt[t]}function ve(r){let t=r??"prod";if(!(t in Ft))throw new Error(`Unknown env: ${t}. Valid: ${Object.keys(Ft).join(", ")}`);return Ft[t]}function De(r){return sn[r]??{timeout:an}}var Gt,Ft,sn,an,st=_(()=>{"use strict";Gt={dev:"https://dev-hhl.yeyecha.com/api",prod:"https://hhl.yeyecha.com/api"},Ft={dev:"https://dev-api.yeyecha.com",prod:"https://api.yeyecha.com"},sn={report:{timeout:1e4},mdm:{timeout:1e4},baseinfo:{timeout:1e4},contract:{timeout:1e4},"user-center":{timeout:1e4}},an=1e4});function Pe(r){return{"X-Request-Id":crypto.randomUUID(),"X-Client":"yybpc-cli","X-Source":r}}var ke=_(()=>{"use strict"});var O,H=_(()=>{"use strict";O={agentLoginPath:"/sso/agentLogin",oauth:{clientId:"",authorizationURL:"",tokenURL:"",authorizePath:"/oauth2/authorize",tokenPath:"/oauth2/token",refreshPath:"/oauth2/refresh",userinfoPath:"/oauth2/userinfo",redirectPort:8399,redirectPath:"/callback",scopes:["authorize"]},storage:{get dir(){return process.env.YYBPC_CLI_HOME??`${process.env.HOME}/.yybpc-cli`},sessionFile:"session.json",tokenCacheDir:"token-cache"},refreshBufferMs:3e5}});function cn(r,t){let e=JSON.stringify(t),n=r==="prod"&&typeof t.msg=="string"&&t.msg.includes("\u767D\u540D\u5355")?"\uFF1B\u5982\u679C\u5F53\u524D\u8981\u67E5\u8BE2\u5F00\u53D1\u73AF\u5883\uFF0C\u8BF7\u663E\u5F0F\u4F20\u5165 --env dev":"";return`Agent \u767B\u5F55\u5931\u8D25: ${e}${n}`}async function un(r,t){let n=`${ve(t)}${O.agentLoginPath}`,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`mobile=${encodeURIComponent(r)}`});if(!o.ok)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",`Agent \u624B\u673A\u53F7\u767B\u5F55\u5931\u8D25: HTTP ${o.status}`);let i=await o.json();if(i.status!==0||!i.data)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",cn(t,i));let s=typeof i.data=="string"?i.data:i.data.tokenValue??i.data.access_token;if(!s)throw new h("AUTH_ERROR","AGENT_LOGIN_FAILED",`Agent \u767B\u5F55\u54CD\u5E94\u7F3A\u5C11 token: ${JSON.stringify(i)}`);return{tokenValue:s,expiresIn:7200}}async function $e(r){let{phone:t,cache:e,env:n}=r;if(e){let i=await e.get(t);if(i)return i.accessToken}let o=await un(t,n);if(e){let i={userId:t,accessToken:o.tokenValue,expiresAt:Date.now()+o.expiresIn*1e3,obtainedVia:"delegation",createdAt:Date.now()};await e.set(t,i)}return o.tokenValue}var Ie=_(()=>{"use strict";S();H();st()});import{mkdir as pn,readFile as ln,writeFile as dn,chmod as mn,unlink as hn}from"fs/promises";import{existsSync as Ne}from"fs";async function at(r,t=448){await pn(r,{recursive:!0,mode:t})}async function M(r){if(!Ne(r))return null;try{return JSON.parse(await ln(r,"utf8"))}catch{return null}}async function V(r,t,e=384){await dn(r,JSON.stringify(t,null,2)),await mn(r,e)}async function q(r){Ne(r)&&await hn(r)}var ct=_(()=>{"use strict"});import{join as fn}from"path";function Yt(r){let t=r??O.storage.dir;return fn(t,gn)}async function ut(r){return M(Yt(r))}async function pt(r,t){let e=t??O.storage.dir;await at(e,448),await V(Yt(t),r,384)}async function je(r){await q(Yt(r))}var gn,Q=_(()=>{"use strict";H();ct();gn="session.json"});import{createServer as Wo}from"http";import{spawn as Ko}from"child_process";function lt(r){return r?r.expiresAt>Date.now():!1}function Ut(r){return r?r.expiresAt-Date.now()<O.refreshBufferMs:!1}async function yn(r,t){try{let e=await fetch(O.oauth.tokenURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:r.refreshToken,client_id:O.oauth.clientId})});if(!e.ok)return null;let n=await e.json(),o={...r,accessToken:n.access_token,refreshToken:n.refresh_token??r.refreshToken,expiresAt:Date.now()+n.expires_in*1e3};return await pt(o,t),o.accessToken}catch{return null}}async function Le(r){let t=await ut(r);if(!t)return null;if(lt(t)&&!Ut(t))return t.accessToken;if(t.refreshToken){let e=await yn(t,r);if(e)return e}return lt(t)?t.accessToken:null}var Wt=_(()=>{"use strict";H();Q()});import{join as Jt}from"path";import{mkdirSync as _n}from"fs";var dt,He=_(()=>{"use strict";H();ct();dt=class{dir;constructor(t,e){let n=t??Jt(O.storage.dir,O.storage.tokenCacheDir);this.dir=e?Jt(n,e):n,_n(this.dir,{recursive:!0,mode:448})}filePath(t){let e=t.replace(/[^a-zA-Z0-9_-]/g,"_");return Jt(this.dir,`${e}.json`)}async get(t){let e=await M(this.filePath(t));return!e||e.expiresAt<=Date.now()?null:e}async set(t,e){await V(this.filePath(t),e,384)}async del(t){await q(this.filePath(t))}}});function Me(r){return Kt.has(r)||Kt.set(r,new dt(void 0,r)),Kt.get(r)}function Ve(r){return process.env.SVC_USER_PHONE??r}function bn(r){return Ve(r.asPhone)?"agent":"human"}async function D(r){let t=bn(r);if(t==="agent"){let n=Ve(r.asPhone);return{token:await $e({phone:n,cache:Me(r.env),env:r.env}),mode:t}}let e=await Le();if(!e)throw new h("AUTH_ERROR","NOT_LOGGED_IN","\u672A\u63D0\u4F9B\u8EAB\u4EFD\u8BA4\u8BC1\uFF1A\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD");return{token:e,mode:t}}async function qe(r,t){await Me(t).del(r)}var Kt,mt=_(()=>{"use strict";S();Ie();Wt();He();Kt=new Map});function On(r,t,e){let n=r.replace(/\/$/,""),o=t.startsWith("/")?t:`/${t}`,i=`${n}${o}`;if(e){let s=new URLSearchParams;for(let[c,d]of Object.entries(e))d!=null&&s.set(c,String(d));let a=s.toString();a&&(i+=`?${a}`)}return i}function Ge(r,t){return{satoken:r,"Content-Type":"application/json",...Pe(t)}}function Fe(r){Qt=r}function C(){return Qt}async function G(r){let t=Qt,e=it(t.env),n=De(r.service),o={asPhone:t.asPhone,env:t.env},i="",s="human";if(r.anonymous)try{let g=await D(o);i=g.token,s=g.mode}catch{}else{let g=await D(o);i=g.token,s=g.mode}let a=On(e,r.path,r.query),c=Ge(i,s);if(t.dryRun)return{dryRun:!0,method:r.method,url:a,headers:{...c,satoken:"***"},body:r.body??null};t.verbose&&console.error(`[verbose] ${r.method} ${a}`);let d=Date.now(),p=async g=>{let w=new AbortController,b=setTimeout(()=>w.abort(),n.timeout);try{return await fetch(a,{method:r.method,headers:g,body:r.body?JSON.stringify(r.body):void 0,signal:w.signal})}catch(W){throw W.name==="AbortError"?new h("TRANSPORT_ERROR","TIMEOUT",`${r.service} \u670D\u52A1\u8BF7\u6C42\u8D85\u65F6`,r.service):new h("TRANSPORT_ERROR","NETWORK_ERROR",`\u7F51\u7EDC\u9519\u8BEF: ${W.message}`,r.service)}finally{clearTimeout(b)}},u=await p(c);if(u.status===401&&!r.anonymous)if(s==="agent"){let g=t.asPhone;g&&await qe(g,t.env);let w=await D(o),b=Ge(w.token,w.mode);u=await p(b)}else throw new h("AUTH_ERROR","TOKEN_EXPIRED","\u767B\u5F55\u5DF2\u8FC7\u671F\uFF1A\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u91CD\u65B0\u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD");let l=Date.now()-d,m=c["X-Request-Id"];if(!u.ok){if(u.status===401||u.status===403)throw new h("AUTH_ERROR",`HTTP_${u.status}`,"\u6743\u9650\u4E0D\u8DB3\u6216\u767B\u5F55\u5DF2\u8FC7\u671F",r.service);let g;try{g=(await u.json()).message??`\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF: ${u.status}`}catch{g=`\u670D\u52A1\u8FD4\u56DE\u9519\u8BEF: ${u.status}`}throw new h("BUSINESS_ERROR",`HTTP_${u.status}`,g,r.service)}return{success:!0,data:await u.json(),meta:{service:r.service,requestId:m,duration:l}}}var Qt,v=_(()=>{"use strict";S();st();ke();mt();Qt={env:"prod",verbose:!1,dryRun:!1}});function Ye(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&Object.keys(r).length===0}function zt(r){if(Array.isArray(r))return r.map(zt).filter(e=>e!=null&&e!==""&&!(Array.isArray(e)&&e.length===0)&&!Ye(e));if(r&&typeof r=="object"){let t={};for(let[e,n]of Object.entries(r)){let o=zt(n);o!=null&&o!==""&&!(Array.isArray(o)&&o.length===0)&&!Ye(o)&&(t[e]=o)}return t}return r}function Bt(r){if(Array.isArray(r))return r.map(Bt);if(r&&typeof r=="object"){let t={};for(let[e,n]of Object.entries(r)){let o=Cn[e]??e;t[o]=Bt(n)}return t}return r}function Xt(r,t={}){let e=r;return t.stripNulls&&(e=zt(e)),t.shortenKeys&&(e=Bt(e)),e}var Cn,Ue=_(()=>{"use strict";Cn={id:"i",name:"n",code:"c",type:"t",status:"s",label:"lbl",value:"v",createTime:"ct",updateTime:"ut",createdAt:"crt",updatedAt:"udt",children:"ch",parentId:"pid",storeName:"sn",storeCode:"sc",address:"addr",phone:"ph",contact:"cnt",region:"rgn",warehouse:"wh",warehouseName:"whn",product:"pdt",productName:"pdn",skuCode:"skc",barcode:"bc",category:"cat",company:"co",companyName:"cn",franchisee:"fr",franchiseeName:"frn",supplier:"sup",supplierName:"spn",area:"ar",areaName:"arn",unit:"un",unitName:"unn"}});function We(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function wn(r){return Array.isArray(r)&&r.length>0&&r.every(We)}function An(r){let t=[],e=new Set;for(let o of r)for(let i of Object.keys(o))e.has(i)||(e.add(i),t.push(i));let n=r.map(o=>t.map(i=>i in o?F(o[i]):null));return{columns:t,rows:n}}function F(r){if(wn(r))return An(r);if(Array.isArray(r))return r.map(F);if(We(r)){let t={};for(let[e,n]of Object.entries(r))t[e]=F(n);return t}return r}var Je=_(()=>{"use strict"});function Zt(r,t,e="none"){if(r&&typeof r=="object"&&r.dryRun===!0)return JSON.stringify(r,null,2);if(t==="raw")return JSON.stringify(r.data,null,2);if(e!=="none"){let n=e==="agent"?Xt(r.data,{stripNulls:!0,shortenKeys:!0}):e==="slim"?Xt(r.data,{stripNulls:!0}):r.data;return JSON.stringify(F(n))}return JSON.stringify({...r,data:F(r.data)},null,2)}function z(r){if(r instanceof h)return JSON.stringify(r.toJSON(),null,2);let t=r instanceof Error?r.message:String(r);return JSON.stringify({success:!1,error:{type:"TRANSPORT_ERROR",code:"UNKNOWN",message:t}},null,2)}async function ht(r,t,e){try{let n=await e();console.log(Zt(n,r,t))}catch(n){console.error(z(n)),process.exit(1)}}var te=_(()=>{"use strict";S();Ue();Je()});import{join as Rn}from"path";function ee(r){return Rn(O.storage.dir,`report-cache-${r}.json`)}async function Tn(r){let t=await M(ee(r));return!t||Date.now()-t.fetchedAt>Sn||t.env!==r?null:t}async function xn(r,t){await at(O.storage.dir,448);let e={fetchedAt:Date.now(),env:r,reports:t};await V(ee(r),e,384)}function vn(r){let t=r;if(t?.status!==0||!t.data?.data)throw new h("BUSINESS_ERROR","REPORT_LIST_FAILED",`\u62A5\u8868\u5217\u8868\u83B7\u53D6\u5931\u8D25: ${JSON.stringify(r)}`,"report");let e=t.data.data.map(o=>{let i=(o.items||[]).flatMap(a=>(a.params||[]).map(c=>c.paramKey)).filter(Boolean),s=[...new Set(i)].filter(a=>!En.has(a));return{reportId:o.reportId,name:o.reportName,category:o.categoryCode,params:s}}),n=typeof t.data.totalSize=="number"?t.data.totalSize:e.length;return{reports:e,total:n}}async function Dn(r,t){let e=[],n=1;for(;;){let{reports:o,total:i}=await r(n,t);if(e.push(...o),o.length===0||e.length>=i)break;n++}return e}async function Pn(r,t,e,n){let i=`${it(r)}/report/config/list`,s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",satoken:t},body:JSON.stringify({page:{pageNo:e,pageSize:n}})});if(s.status===401||s.status===403){let c=!!C().asPhone?"\u8BF7\u786E\u8BA4 --as-phone \u624B\u673A\u53F7\u6B63\u786E\uFF0C\u4E14\u5F53\u524D\u51FA\u53E3 IP \u5728\u8BE5\u73AF\u5883\u767D\u540D\u5355\u5185":"\u8BF7\u901A\u8FC7 --as-phone <\u624B\u673A\u53F7> \u6307\u5B9A\u8C03\u7528\u8EAB\u4EFD";throw new h("AUTH_ERROR","NOT_LOGGED_IN",`\u83B7\u53D6\u62A5\u8868\u5217\u8868\u9700\u8981\u8EAB\u4EFD\u8BA4\u8BC1\uFF08HTTP ${s.status}\uFF09\u3002${c}`,"report")}if(!s.ok)throw new h("TRANSPORT_ERROR",`HTTP_${s.status}`,`\u62A5\u8868\u5217\u8868\u83B7\u53D6\u5931\u8D25: ${i} \u8FD4\u56DE HTTP ${s.status}`,"report");return vn(await s.json())}async function kn(r,t,e=j){return Dn((n,o)=>Pn(r,t,n,o),e)}async function ft(r,t,e=!1){if(!e){let o=await Tn(r);if(o)return o.reports}let n=await kn(r,t);return await xn(r,n),n}function Ke(r,t){return r.find(e=>e.reportId===t)}async function P(r){await q(ee(r))}var Sn,j,En,k=_(()=>{"use strict";H();st();ct();S();v();Sn=1440*60*1e3,j=500,En=new Set(["determinePeriod","determineTrendPeriod","storeDataAuth","reginDataAuth","storeCountDataAuth","storeRepurchaseDataAuth","storeHourDataAuth","storeHourCountDataAuth","hundredMillion","tenThousand","hundredMillionName","tenThousandName","currentTableName","momDateDiff","pageSize","offset","limit","1"])});var er={};L(er,{filterReports:()=>Xe,meta:()=>$,paginate:()=>tr,renderReportDetail:()=>Ze,renderReportsText:()=>re,runReportList:()=>In});function Qe(r){return r.trim().toLowerCase()}function Be(r){return r.params.filter(t=>t!=="startDate"&&t!=="endDate")}function Xe(r,t={}){let e=r;if(t.reportId){let n=e.find(o=>o.reportId===t.reportId);return n?[n]:[]}if(t.category){let n=Qe(t.category);e=e.filter(o=>Qe(o.category)===n)}return e}function $n(r){let t=`yybpc-cli report query --report-id ${r.reportId} --start-date YYYY-MM-DD --end-date YYYY-MM-DD`,e=Be(r);return e.length===0?t:`${t} --param-json '{"${e[0]}":["VALUE"]}'`}function Ze(r){let t=Be(r),e=[`reportId: ${r.reportId}`,`name: ${r.name}`,`category: ${r.category}`,`params: ${r.params.join(", ")||"(none)"}`,`query: ${$n(r)}`];return t.length>0&&(e.push(`extraParams: ${t.join(", ")}`),e.push("tip: \u6807\u91CF\u53C2\u6570\u53EF\u76F4\u63A5\u4F5C\u4E3A --<\u53C2\u6570\u540D> \u503C\u4F20(\u5982 --productName X);\u6570\u7EC4\u578B\u53C2\u6570(xxxList)\u7528 --param-json")),e.join(`
29
+ `)}function ze(r,t){if(!r||r.totalPages<=1)return`\u5171 ${r?.total??t} \u4E2A\u62A5\u8868`;let{total:e,pageNo:n,pageSize:o,totalPages:i,hasMore:s}=r,a=s?`;\u4E0B\u4E00\u9875: report list --page ${n+1} --page-size ${o}`:"";return`\u5171 ${e} \u4E2A\u62A5\u8868(\u7B2C ${n}/${i} \u9875,\u672C\u9875 ${t} \u4E2A,\u6BCF\u9875 ${o})${a}`}function re(r,t={},e){if(r.length===0)return e&&e.total>0?`\u5171 ${e.total} \u4E2A\u62A5\u8868;\u7B2C ${e.pageNo} \u9875\u65E0\u6570\u636E(\u5171 ${e.totalPages} \u9875,\u6BCF\u9875 ${e.pageSize})`:"\u65E0\u53EF\u7528\u62A5\u8868";if(t.detail||t.reportId){let i=r.map(Ze).join(`
30
30
 
31
- `);let e=[];e.push(`\u5171 ${r.length} \u4E2A\u62A5\u8868`);let n="";for(let o of r){o.category!==n&&(e.length>0&&e.push(""),e.push(`[${o.category}]`),n=o.category);let i=o.params.length>0?o.params.join(", "):"(none)";e.push(`${o.reportId} ${o.name}`),e.push(` params: ${i}`)}return e.join(`
32
- `)}async function En(r={}){let t=r.json??!1,e=b(),{token:n}=await D({asPhone:e.asPhone,env:e.env}),o=await mt(e.env,n,r.refresh??!1),i=Ke(o,r);if(r.reportId&&i.length===0)throw new h("INPUT_ERROR","INVALID_REPORT_ID",`\u672A\u77E5\u7684\u62A5\u8868ID: ${r.reportId}`);console.log(t?JSON.stringify({reports:i},null,2):Be(i,r))}var P,ht=_(()=>{"use strict";N();lt();x();R();P={path:["report","list"],description:"\u5217\u51FA\u5206\u6790\u62A5\u8868\u5E76\u5C55\u793A\u53C2\u6570\u6458\u8981\uFF1B\u6240\u6709\u7ECF\u8425\u5206\u6790\u7C7B\u9700\u6C42\u5148\u4ECE report \u627E\u62A5\u8868",args:{json:{type:"boolean",description:"\u4EE5 JSON \u683C\u5F0F\u8F93\u51FA"},category:{type:"string",description:"\u4EC5\u663E\u793A\u6307\u5B9A\u5206\u7C7B"},"report-id":{type:"string",description:"\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u8BE6\u60C5\uFF08\u542B\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B\uFF09"},detail:{type:"boolean",description:"\u663E\u793A\u8BE6\u7EC6\u4FE1\u606F"},refresh:{type:"boolean",description:"\u5F3A\u5236\u4ECE\u670D\u52A1\u7AEF\u5237\u65B0\u62A5\u8868\u5217\u8868\uFF0C\u5FFD\u7565\u672C\u5730\u7F13\u5B58"}}}});async function ft(r){let t=await Promise.all(Xe.map(n=>r({service:"baseinfo",method:"POST",path:"/baseinfo/common/dict/list/v1",body:{dictType:n},anonymous:!0}))),e={};return Xe.forEach((n,o)=>{let s=(t[o]?.data?.data??{})[n];e[n]=Array.isArray(s)?s.map(a=>({code:a.dictCode,name:a.dictName})):[]}),e}function gt(r){if(typeof r!="string"||r.trim()==="")throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","\u5FC5\u987B\u63D0\u4F9B --config-json\uFF08\u62A5\u8868\u914D\u7F6E JSON\uFF09");let t;try{t=JSON.parse(r)}catch{throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","--config-json \u4E0D\u662F\u5408\u6CD5\u7684 JSON")}if(t===null||typeof t!="object"||Array.isArray(t))throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","--config-json \u5FC5\u987B\u662F JSON \u5BF9\u8C61");let e=t;if("categoryCode"in e&&e.categoryCode!==te)throw new h("INPUT_ERROR","INVALID_CATEGORY",`\u4EC5\u5141\u8BB8\u64CD\u4F5C\u4E1A\u52A1\u81EA\u5B9A\u4E49\u5206\u7C7B\uFF08categoryCode=${te}\uFF09\uFF1B\u4E0D\u5141\u8BB8\u64CD\u4F5C ${String(e.categoryCode)}`);return{...e,categoryCode:te}}var te,Xe,B=_(()=>{"use strict";R();te="business_custom",Xe=["report_type","report_datasource","report_result_function","report_connection_type","report_category"]});var tr={};j(tr,{meta:()=>F,renderGuide:()=>Ze,runGuide:()=>Dn});function ee(r){return vn.replace("__DATASOURCES__",r||xn)}async function Ze(r){if(!r)return ee("");try{let n=((await ft(r)).report_datasource??[]).map(o=>` ${o.code} = ${o.name}`).join(`
33
- `);return ee(n)}catch{return ee("")}}async function Dn(r){console.log(await Ze(r))}var F,vn,xn,yt=_(()=>{"use strict";B();F={path:["report","config","guide"],description:"\u8F93\u51FA\u62A5\u8868\u7814\u53D1\u81EA\u5305\u542B\u624B\u518C\uFF08\u7ED9 AI agent \u7528\uFF0C\u542B\u5DE5\u4F5C\u6D41/\u914D\u7F6E\u7ED3\u6784/\u53C2\u6570\u8BF4\u660E/\u793A\u4F8B\uFF0C\u514D\u767B\u5F55\uFF09",args:{}},vn=`\u62A5\u8868\u7814\u53D1\u624B\u518C\uFF08report config\uFF09
31
+ `);return e&&e.totalPages>1?`${ze(e,r.length)}
32
+
33
+ ${i}`:i}let n=new Map;for(let i of r){let s=n.get(i.category);s?s.push(i):n.set(i.category,[i])}let o=[ze(e,r.length)];for(let[i,s]of n){o.push(""),o.push(`[${i}]`);for(let a of s){let c=a.params.length>0?a.params.join(", "):"(none)";o.push(`${a.reportId} ${a.name}`),o.push(` params: ${c}`)}}return o.join(`
34
+ `)}function tr(r,t,e){let n=r.length,o=Number.isInteger(e)&&e>0?e:j,i=Number.isInteger(t)&&t>0?t:1,s=Math.ceil(n/o),a=(i-1)*o;return{items:r.slice(a,a+o),pagination:{total:n,pageNo:i,pageSize:o,totalPages:s,hasMore:i<s}}}async function In(r={}){let t=r.json??!1,e=C(),{token:n}=await D({asPhone:e.asPhone,env:e.env}),o=await ft(e.env,n,r.refresh??!1),i=Xe(o,r);if(r.reportId&&i.length===0)throw new h("INPUT_ERROR","INVALID_REPORT_ID",`\u672A\u77E5\u7684\u62A5\u8868ID: ${r.reportId}`);if(r.reportId){console.log(t?JSON.stringify({reports:i},null,2):re(i,r));return}let s=r.page!=null?Number(r.page):1,a=r.pageSize!=null?Number(r.pageSize):j,{items:c,pagination:d}=tr(i,s,a);console.log(t?JSON.stringify({reports:c,pagination:d},null,2):re(c,r,d))}var $,gt=_(()=>{"use strict";k();mt();v();S();$={path:["report","list"],description:"\u5217\u51FA\u5206\u6790\u62A5\u8868\u5E76\u5C55\u793A\u53C2\u6570\u6458\u8981\uFF1B\u6240\u6709\u7ECF\u8425\u5206\u6790\u7C7B\u9700\u6C42\u5148\u4ECE report \u627E\u62A5\u8868",args:{json:{type:"boolean",description:"\u4EE5 JSON \u683C\u5F0F\u8F93\u51FA"},category:{type:"string",description:"\u4EC5\u663E\u793A\u6307\u5B9A\u5206\u7C7B"},"report-id":{type:"string",description:"\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u8BE6\u60C5\uFF08\u542B\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B\uFF09"},detail:{type:"boolean",description:"\u663E\u793A\u8BE6\u7EC6\u4FE1\u606F"},refresh:{type:"boolean",description:"\u5F3A\u5236\u4ECE\u670D\u52A1\u7AEF\u5237\u65B0\u62A5\u8868\u5217\u8868\uFF0C\u5FFD\u7565\u672C\u5730\u7F13\u5B58"},page:{type:"number",description:"\u9875\u7801,\u4ECE 1 \u5F00\u59CB(\u9ED8\u8BA4 1)"},"page-size":{type:"number",description:`\u6BCF\u9875\u6570\u91CF(\u9ED8\u8BA4 ${j})`}}}});async function yt(r){let t=await Promise.all(rr.map(n=>r({service:"baseinfo",method:"POST",path:"/baseinfo/common/dict/list/v1",body:{dictType:n},anonymous:!0}))),e={};return rr.forEach((n,o)=>{let s=(t[o]?.data?.data??{})[n];e[n]=Array.isArray(s)?s.map(a=>({code:a.dictCode,name:a.dictName})):[]}),e}function _t(r){if(typeof r!="string"||r.trim()==="")throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","\u5FC5\u987B\u63D0\u4F9B --config-json\uFF08\u62A5\u8868\u914D\u7F6E JSON\uFF09");let t;try{t=JSON.parse(r)}catch{throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","--config-json \u4E0D\u662F\u5408\u6CD5\u7684 JSON")}if(t===null||typeof t!="object"||Array.isArray(t))throw new h("INPUT_ERROR","INVALID_CONFIG_JSON","--config-json \u5FC5\u987B\u662F JSON \u5BF9\u8C61");let e=t;if("categoryCode"in e&&e.categoryCode!==ne)throw new h("INPUT_ERROR","INVALID_CATEGORY",`\u4EC5\u5141\u8BB8\u64CD\u4F5C\u4E1A\u52A1\u81EA\u5B9A\u4E49\u5206\u7C7B\uFF08categoryCode=${ne}\uFF09\uFF1B\u4E0D\u5141\u8BB8\u64CD\u4F5C ${String(e.categoryCode)}`);return{...e,categoryCode:ne}}var ne,rr,B=_(()=>{"use strict";S();ne="business_custom",rr=["report_type","report_datasource","report_result_function","report_connection_type","report_category"]});var or={};L(or,{meta:()=>Y,renderGuide:()=>nr,runGuide:()=>Ln});function oe(r){return Nn.replace("__DATASOURCES__",r||jn)}async function nr(r){if(!r)return oe("");try{let n=((await yt(r)).report_datasource??[]).map(o=>` ${o.code} = ${o.name}`).join(`
35
+ `);return oe(n)}catch{return oe("")}}async function Ln(r){console.log(await nr(r))}var Y,Nn,jn,bt=_(()=>{"use strict";B();Y={path:["report","config","guide"],description:"\u8F93\u51FA\u62A5\u8868\u7814\u53D1\u81EA\u5305\u542B\u624B\u518C\uFF08\u7ED9 AI agent \u7528\uFF0C\u542B\u5DE5\u4F5C\u6D41/\u914D\u7F6E\u7ED3\u6784/\u53C2\u6570\u8BF4\u660E/\u793A\u4F8B\uFF0C\u514D\u767B\u5F55\uFF09",args:{}},Nn=`\u62A5\u8868\u7814\u53D1\u624B\u518C\uFF08report config\uFF09
34
36
  \u76EE\u6807: \u7528 yybpc-cli report config \u7CFB\u5217\u547D\u4EE4\u4ECE\u96F6\u7814\u53D1\u4E1A\u52A1\u81EA\u5B9A\u4E49\u62A5\u8868\u3002categoryCode \u9501\u5B9A business_custom\u3002
35
37
  \u9002\u7528\u8303\u56F4: \u81EA\u52A9\u5F00\u53D1\u5E38\u89C1\u62A5\u8868\uFF08\u805A\u5408\u7EDF\u8BA1 / \u6761\u4EF6\u8FC7\u6EE4 / \u5206\u7EC4\u6392\u884C / \u8D8B\u52BF / \u6811\u5F62\u4E0B\u94BB\uFF09\u3002
36
38
  \u590D\u6742\u62A5\u8868\u5EFA\u8BAE\u5148 yybpc-cli report config get <\u73B0\u6709\u62A5\u8868ID> \u62F7\u8D1D\u73B0\u6709\u914D\u7F6E\u518D\u6539\u3002
@@ -171,7 +173,7 @@ query \u65F6\u7528\u6237\u53C2\u6570\u5982\u4F55\u5BF9\u63A5 config params
171
173
  \u793A\u4F8B 5 \u2014 \u6570\u636E\u6743\u9650\u8FC7\u6EE4: \u95E8\u5E97\u660E\u7EC6\u6309\u767B\u5F55\u7528\u6237\u53EF\u89C1\u8303\u56F4\u81EA\u52A8\u8FC7\u6EE4\uFF08data_auth \u4E0E storeList \u914D\u5BF9\u53E0\u52A0\uFF09
172
174
  {"reportId":"demo_store_scoped","reportName":"\u6211\u7684\u95E8\u5E97\u660E\u7EC6","reportType":"single","items":[{"dataSource":"baseInfoDS","executeSql":"select store_code, store_name from store where data_state=1 and #{storeDataAuth}","resultFunction":"none","params":[{"paramKey":"storeDataAuth","connectionType":"data_auth","value":"{\\"appCode\\":\\"yk\\",\\"skipIfNoConfig\\":true,\\"missingEnableSpecialValue\\":true,\\"templateCode\\":\\"yk_common_store_temp\\"}"}]}]}
173
175
  \u8981\u70B9: #{storeDataAuth} \u88AB\u540E\u7AEF\u66FF\u6362\u6210 1 = 1 and (store_code in (\u5F53\u524D\u7528\u6237\u8D1F\u8D23\u95E8\u5E97...))\uFF1BtemplateCode \u7528 rbac \u5DF2\u5B58\u5728\u6A21\u677F\uFF08\u95E8\u5E97 yk_common_store_temp / \u533A\u57DF yk_common_region_temp\uFF09\uFF0C\u52FF\u81C6\u9020
174
- `,xn=" \uFF08\u672A\u80FD\u5B9E\u65F6\u83B7\u53D6\uFF0C\u8BF7\u8FD0\u884C yybpc-cli report config dict \u67E5\u770B\u53EF\u7528\u6570\u636E\u6E90\uFF09"});var T=_(()=>{"use strict"});var ue={};j(ue,{buildReportQueryBody:()=>mr,default:()=>ce,normalizeReportQueryArgs:()=>ae,parseParamJson:()=>se,runReportQuery:()=>hr});function Ct(r,...t){for(let e of t){let n=r[e];if(n==null)continue;let o=String(n).trim();if(o)return o}}function ie(r){let t=r.trim();if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(n=>String(n))}catch{}return t.includes(",")?t.split(",").map(e=>e.trim()).filter(Boolean):t}function se(r){if(!r)return{};try{let t=JSON.parse(r);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("not an object");return t}catch{throw new h("INPUT_ERROR","INVALID_PARAM_JSON",'--param-json \u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF0C\u4F8B\u5982 {"regionList":["3301"]}')}}function ae(r){let t=se(r.params),e=se(r.paramJson??r["param-json"]),n={...t,...e},o=Ct(r,"date"),i=Ct(r,"reportId","report-id","report")??(typeof n.reportId=="string"?n.reportId:void 0),s=Ct(r,"startDate","start-date")??(typeof n.startDate=="string"?n.startDate:void 0)??o,a=Ct(r,"endDate","end-date")??(typeof n.endDate=="string"?n.endDate:void 0)??o;return delete n.reportId,delete n.startDate,delete n.endDate,{reportId:i,startDate:s,endDate:a,extraParams:n,passthroughArgs:r}}function dr(r){if(!r.reportId)throw new h("INPUT_ERROR","MISSING_REPORT_ID","\u5FC5\u987B\u63D0\u4F9B\u62A5\u8868ID\uFF1B\u5148\u6267\u884C yybpc-cli report list \u67E5\u770B\u53EF\u7528\u62A5\u8868\uFF0C\u518D\u4F7F\u7528 --report-id");if(!r.startDate||!r.endDate)throw new h("INPUT_ERROR","MISSING_DATE_RANGE","\u5FC5\u987B\u63D0\u4F9B\u67E5\u8BE2\u65E5\u671F\uFF1B\u4F7F\u7528 --date YYYY-MM-DD\uFF0C\u6216\u540C\u65F6\u63D0\u4F9B --start-date \u548C --end-date")}function lr(r,t,e){if(e==="reportId")throw new h("INPUT_ERROR","INVALID_REPORT_PARAM","--param-json \u4E0D\u80FD\u5305\u542B reportId");if(!r.params.includes(e))throw new h("INPUT_ERROR","UNSUPPORTED_REPORT_PARAM",`\u62A5\u8868 ${t} \u4E0D\u652F\u6301\u53C2\u6570 ${e}\uFF1B\u53EF\u7528\u53C2\u6570: ${r.params.join(", ")}`)}function mr(r,t){let e=ae(t);dr(e);let n=e.reportId,o={reportId:n,startDate:e.startDate,endDate:e.endDate},i={...e.extraParams};for(let a of Object.keys(i))lr(r,n,a);Object.assign(o,i);let s={region:{apiParam:"regionList",parse:ie},storeId:{apiParam:"storeList",parse:ie},channel:{apiParam:"channelList",parse:ie},orderField:{apiParam:"orderField"},orderDir:{apiParam:"orderDir"}};for(let[a,c]of Object.entries(s)){let d=e.passthroughArgs[a];d==null||d===""||(lr(r,n,c.apiParam),o[c.apiParam]=c.parse?c.parse(String(d)):d)}return o}async function hr(r,t){let e=b(),n=ae(r);dr(n);let o=n.reportId,{token:i}=await D({asPhone:e.asPhone,env:e.env}),s=await mt(e.env,i),a=Ue(s,o);if(!a)throw new h("INPUT_ERROR","INVALID_REPORT_ID",`\u672A\u77E5\u7684\u62A5\u8868ID: ${o}\uFF1B\u5148\u6267\u884C yybpc-cli report list \u67E5\u627E\u53EF\u7528\u62A5\u8868`);let c=mr(a,r);return t({service:"report",method:"POST",path:"/report/query/single",body:c})}var ce,Ot=_(()=>{"use strict";T();N();lt();x();R();ce={meta:{description:"\u67E5\u8BE2\u62A5\u8868\u5206\u6790\u6570\u636E\uFF1B\u6240\u6709\u5206\u6790\u7C7B\u67E5\u8BE2\u4F18\u5148\u4F7F\u7528 report"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID\uFF08\u5982 gj_target_achievement_3\uFF09"},date:{type:"string",description:"\u5355\u65E5\u5FEB\u6377\u5199\u6CD5 (YYYY-MM-DD)\uFF1B\u4F1A\u540C\u65F6\u4F5C\u4E3A\u5F00\u59CB\u548C\u7ED3\u675F\u65E5\u671F"},"start-date":{type:"string",description:"\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)"},"end-date":{type:"string",description:"\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)"},region:{type:"string",description:"\u6218\u533AID\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},"store-id":{type:"string",description:"\u95E8\u5E97ID\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},channel:{type:"string",description:"\u6E20\u9053\u7F16\u7801\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},"order-field":{type:"string",description:"\u6392\u5E8F\u5B57\u6BB5"},"order-dir":{type:"string",description:"\u6392\u5E8F\u65B9\u5411 (asc/desc)"},"param-json":{type:"string",description:'\u989D\u5916\u62A5\u8868\u53C2\u6570 JSON\uFF0C\u5982 {"brandList":["B01"]}'}},api:{service:"report",method:"POST",path:"/report/query/single"},run:async({args:r,request:t})=>hr(r,t)}});var Sr={};j(Sr,{runSetToken:()=>Wn});async function Wn(r){let t={accessToken:r,refreshToken:"",expiresAt:Date.now()+864e5,userId:"",username:"",loginAt:Date.now()};await ct(t),console.log(JSON.stringify({success:!0,data:{message:"Token \u5DF2\u4FDD\u5B58"}},null,2))}var Rr=_(()=>{"use strict";K()});var Tr={};j(Tr,{runLogout:()=>Jn});async function Jn(){await Ie(),console.log(JSON.stringify({success:!0,data:{message:"\u5DF2\u9000\u51FA\u767B\u5F55"}},null,2))}var Er=_(()=>{"use strict";K()});var vr={};j(vr,{runStatus:()=>Kn});async function Kn(){let r=await at();if(!r){console.log(JSON.stringify({success:!0,data:{loggedIn:!1,message:"\u5F53\u524D\u672A\u767B\u5F55\uFF0C\u8BF7\u6267\u884C yybpc-cli auth set-token <token>"}},null,2));return}let t=ut(r),e=Ft(r);console.log(zt({success:!0,data:{loggedIn:t,userId:r.userId,username:r.username,expiresAt:new Date(r.expiresAt).toISOString(),needsRefresh:e,loginAt:new Date(r.loginAt).toISOString()},meta:{service:"auth",requestId:"-",duration:0}},"json"))}var xr=_(()=>{"use strict";K();Yt();Xt()});var Se=Mr(Ae(),1),{program:lo,createCommand:mo,createArgument:ho,createOption:fo,CommanderError:go,InvalidArgumentError:yo,InvalidOptionArgumentError:_o,Command:Re,Argument:Co,Option:Oo,Help:bo}=Se.default;x();Xt();ht();yt();var er={name:"@yybpc/cli",version:"1.0.0",description:"\u516C\u53F8\u5185\u90E8\u670D\u52A1\u7EDF\u4E00 CLI\uFF08\u62A5\u8868\u67E5\u8BE2 + \u4E2D\u53F0\u4E3B\u6863/\u4F9B\u5E94\u94FE/\u7528\u6237\u4E2D\u5FC3\uFF09",type:"module",bin:{"yybpc-cli":"dist/index.js"},files:["dist/index.js"],engines:{node:">=18"},scripts:{dev:"tsx src/index.ts",build:"tsup","build:sea":"bash scripts/build-sea.sh","build:sea:linux":"bash scripts/build-sea-linux.sh",typecheck:"tsc --noEmit",prepublishOnly:"tsup"},devDependencies:{"@types/node":"^22.10.0",commander:"^14.0.3",tsup:"^8.3.5",tsx:"^4.19.2",typescript:"^5.7.2"}};var z=er.version;var rr=[{...P,path:[...P.path]},{description:F.description,path:[...F.path]}],Pn=[{bullet:"`--env <dev|prod>` \u2014 \u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 prod\uFF09"},{bullet:"`--format <auto|json|raw>` \u2014 \u8F93\u51FA\u683C\u5F0F\uFF08\u9ED8\u8BA4 auto\uFF09\u3002auto=\u7D27\u51D1\u5217\u5F0F\uFF08\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u7701 token\uFF0C\u9002\u5408 agent\uFF09\uFF1Bjson=\u5E26\u7F29\u8FDB\u7684\u5B8C\u6574\u4FE1\u5C01\uFF08\u9002\u5408\u4EBA\u8BFB\uFF09\uFF1Braw=\u540E\u7AEF\u539F\u6837\u6570\u636E\u3002\u6CE8\uFF1Areport config \u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u540E\u7AEF\u539F\u6837\u7ED3\u6784\uFF08\u4E0D\u538B {columns,rows}\uFF0C\u4FBF\u4E8E\u5B66\u4E60\u914D\u7F6E shape\uFF09\uFF0C\u9700\u7701 token \u53EF\u663E\u5F0F\u52A0 --compact"},{bullet:"`--compact` \u2014 \u7D27\u51D1\u5217\u5F0F\u8F93\u51FA\uFF08\u7B49\u540C\u9ED8\u8BA4 auto\uFF1A\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u4E0D\u7F29\u8FDB\uFF09"},{bullet:"`--slim` \u2014 compact \u57FA\u7840\u4E0A\u518D\u79FB\u9664 null/\u7A7A\u503C"},{bullet:"`--agent` \u2014 slim \u57FA\u7840\u4E0A\u518D\u7F29\u77ED\u5B57\u6BB5\u540D\uFF08\u6700\u7701 token\uFF0C\u7ED9 LLM \u7528\uFF09"},{bullet:"`--verbose` \u2014 \u6253\u5370\u8C03\u8BD5\u4FE1\u606F\uFF08\u8BF7\u6C42 URL \u7B49\uFF0C\u8F93\u51FA\u5230 stderr\uFF09"},{bullet:"`--dry-run` \u2014 \u9884\u89C8\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42\uFF08method/url/body\uFF09\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C"},{bullet:"`--as-phone <phone>` \u2014 Agent \u6A21\u5F0F\uFF1A\u4EE3\u8868\u6307\u5B9A\u624B\u673A\u53F7\u7528\u6237\u8C03\u7528"}],In=[{flag:"--env",description:"\u76EE\u6807\u73AF\u5883\uFF08dev/prod\uFF09",default:"prod"},{flag:"--format",description:"\u8F93\u51FA\u683C\u5F0F\uFF1Aauto=\u7D27\u51D1\u5217\u5F0F({columns,rows},\u7701token)/json=\u5E26\u7F29\u8FDB\u5B8C\u6574\u4FE1\u5C01/raw=\u540E\u7AEF\u539F\u6837\u3002report config \u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u539F\u6837\u7ED3\u6784(\u4E0D\u538B\u7F29),\u7701 token \u53EF\u52A0 --compact",default:"auto"},{flag:"--compact",description:"\u7D27\u51D1\u5217\u5F0F\u8F93\u51FA\uFF08\u7B49\u540C\u9ED8\u8BA4 auto\uFF1A\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u4E0D\u7F29\u8FDB\uFF09"},{flag:"--slim",description:"compact \u57FA\u7840\u4E0A\u518D\u79FB\u9664 null/\u7A7A\u503C"},{flag:"--agent",description:"slim \u57FA\u7840\u4E0A\u518D\u7F29\u77ED\u5B57\u6BB5\u540D\uFF08\u6700\u7701 token\uFF0C\u7ED9 LLM \u7528\uFF09"},{flag:"--verbose",description:"\u6253\u5370\u8C03\u8BD5\u4FE1\u606F\uFF08\u8F93\u51FA\u5230 stderr\uFF09"},{flag:"--dry-run",description:"\u9884\u89C8\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42\uFF08method/url/body\uFF09\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C"},{flag:"--as-phone",description:"Agent \u6A21\u5F0F\uFF1A\u4EE3\u8868\u6307\u5B9A\u624B\u673A\u53F7\u7528\u6237\u8C03\u7528"}],ir=["\u6240\u6709\u7ECF\u8425\u5206\u6790\u3001\u8D8B\u52BF\u5224\u65AD\u3001\u4E1A\u7EE9\u89E3\u8BFB\u7C7B\u9700\u6C42\uFF0C\u4F18\u5148\u4F7F\u7528 report","\u53EA\u6709 report \u67E5\u4E0D\u5230\u3001\u672A\u8986\u76D6\u6216\u5F53\u524D\u6CA1\u6709\u76F8\u5173\u62A5\u8868\u65F6\uFF0C\u624D\u5141\u8BB8\u4F7F\u7528\u5176\u4ED6\u6A21\u5757","\u6539\u7528 master-data / supply-chain / user-center \u65F6\uFF0C\u5FC5\u987B\u660E\u786E\u544A\u77E5\u7528\u6237\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868","master-data / supply-chain / user-center \u4E3B\u8981\u7528\u4E8E\u8865\u5145\u4E3B\u6863\u3001\u4F9B\u5E94\u94FE\u3001\u7EC4\u7EC7\u7B49\u57FA\u7840\u4FE1\u606F\uFF0C\u4E0D\u5E94\u9ED8\u8BA4\u66FF\u4EE3 report"],$n=ir.map((r,t)=>({priority:t+1,rule:r})),sr=["\u6700\u9AD8\u4F18\u5148\u7EA7\u547D\u4EE4: yybpc-cli report query","\u6240\u6709\u7ECF\u8425\u5206\u6790\u3001\u8D8B\u52BF\u5224\u65AD\u3001\u4E1A\u7EE9\u89E3\u8BFB\u7C7B\u9700\u6C42\uFF0C\u9ED8\u8BA4\u5148\u7528 yybpc-cli report query","\u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868\uFF0C\u518D\u7528 yybpc-cli report list --report-id REPORT_ID \u67E5\u770B\u8BE6\u60C5","\u6807\u51C6\u8DEF\u5F84: \u5168\u91CF\u62A5\u8868 -> \u5355\u62A5\u8868\u8BE6\u60C5 -> \u6267\u884C\u67E5\u8BE2","\u793A\u4F8B: yybpc-cli report list\uFF0C\u7136\u540E\u6267\u884C yybpc-cli report query --report-id REPORT_ID --date 2026-04-22"],Nn=sr.map((r,t)=>({priority:t+1,hint:r})),nr=["report","master-data","supply-chain","user-center"];function jn(r,t){return r.join(" ").localeCompare(t.join(" "))}function or(r){if(r.path[0]==="report"){if(r.path[1]==="list")return 0;if(r.path[1]==="query")return 1}return 100}function re(r){return[...r].sort((t,e)=>{let n=nr.indexOf(t.path[0]),o=nr.indexOf(e.path[0]),i=n===-1?Number.MAX_SAFE_INTEGER:n,s=o===-1?Number.MAX_SAFE_INTEGER:o;if(i!==s)return i-s;let a=or(t),c=or(e);return a!==c?a-c:jn(t.path,e.path)})}function _t(r){let t=r.map(e=>({path:e.path,description:e.def.meta.description,args:e.def.args}));for(let e of rr)if(t.some(n=>n.path.length===e.path.length&&n.path.every((o,i)=>o===e.path[i])))throw new Error(`MANUAL_COMMANDS collides with apiCommands on path: ${e.path.join(" ")}`);return[...t,...rr]}function Ln(r){let t=re(_t(r)),e=[];e.push(`yybpc-cli ${z}`),e.push("\u9996\u9009\u5165\u53E3");for(let o of sr)e.push(` ${o}`);e.push(""),e.push("\u6570\u636E\u4F18\u5148\u7EA7");for(let o of ir)e.push(` ${o}`);e.push(""),e.push("\u5168\u5C40\u53C2\u6570");for(let o of Pn)e.push(` ${o.bullet.replaceAll("`","")}`);e.push(""),e.push("\u547D\u4EE4");let n="";for(let o of t)o.path[0]!==n&&(e[e.length-1]!=="\u547D\u4EE4"&&e.push(""),e.push(` [${o.path[0]}]`),n=o.path[0]),e.push(` yybpc-cli ${o.path.join(" ")} ${o.description}`);return e.push(""),e.push("\u66F4\u591A\u5E2E\u52A9"),e.push(" yybpc-cli help <command> \u4F8B\u5982: yybpc-cli help report query"),e}function ar(r,t){return re(_t(t)).filter(e=>e.path.length>r.length&&r.every((n,o)=>e.path[o]===n))}function Hn(r,t){let e=ar(r,t);if(e.length===0)return[`\u672A\u627E\u5230: ${r.join(" ")}`];let n=[];n.push(`yybpc-cli ${r.join(" ")} \u4E0B\u7684\u547D\u4EE4`);let o=pr(r);if(o.length>0){n.push("\u89C4\u5219");for(let i of o)n.push(` ${i}`);n.push("")}n.push("\u547D\u4EE4");for(let i of e)n.push(` yybpc-cli ${i.path.join(" ")} ${i.description}`);return n}function ne(r,t){return _t(t).find(e=>e.path.length===r.length&&e.path.every((n,o)=>n===r[o]))}function Mn(r,t){let e=ne(r,t),n=[];n.push(`yybpc-cli ${e.path.join(" ")}`),n.push(e.description);let o=qn(e);if(o.length>0){n.push(""),n.push("\u5FEB\u901F\u5F00\u59CB");for(let a of o)n.push(` ${a}`)}n.push(""),n.push("\u793A\u4F8B");for(let a of Vn(e))n.push(` ${a}`);n.push(""),n.push("\u53C2\u6570");let i=e.args??{};if(Object.keys(i).length===0)n.push(" \uFF08\u65E0\u53C2\u6570\uFF09");else for(let[a,c]of Object.entries(i)){let d=c.required?" \u5FC5\u586B":"",p=c.description??"",u=c.default!==void 0?` \u9ED8\u8BA4 ${c.default}`:"",l=`${d}${p?` ${p}`:""}${u}`,m=c.enum?c.enum.join("|"):c.type,y=c.type==="boolean"?`--${a}`:`--${a} <${m}>`;n.push(` ${y}${l}`)}let s=ur(e);if(s.length>0){n.push(""),n.push("\u89C4\u5219");for(let a of s)n.push(` ${a}`)}return n}function cr(r){let t=[`yybpc-cli ${r.path.join(" ")}`];for(let[e,n]of Object.entries(r.args??{}))if(n.required){let o=n.enum?n.enum.join("|"):e.toUpperCase().replace(/-/g,"_");t.push(`--${e} <${o}>`)}return t.join(" ")}function Vn(r){let t=`yybpc-cli ${r.path.join(" ")}`;return r.path[0]==="report"&&r.path[1]==="list"?[t,`${t} --category gj_store_ranking`,`${t} --report-id gj_target_achievement_3`]:r.path[0]==="report"&&r.path[1]==="query"?["\u5148\u770B\u5168\u91CF\u62A5\u8868: yybpc-cli report list","\u770B\u53C2\u6570: yybpc-cli report list --report-id gj_target_achievement_3",`${t} --report-id gj_target_achievement_3 --date 2026-04-22`,`${t} --report-id gj_target_achievement_3 --start-date 2026-04-01 --end-date 2026-04-30`,`${t} --report-id gj_target_achievement_3 --start-date 2026-04-01 --end-date 2026-04-30 --param-json '{"regionList":["3301"]}'`,"\u517C\u5BB9\u65E7\u5199\u6CD5: yybpc-cli report get gj_target_achievement_3 2026-04-22",`\u517C\u5BB9\u65E7\u5199\u6CD5: yybpc-cli report data --report gj_target_achievement_3 --params '{"startDate":"2026-04-22","endDate":"2026-04-22"}'`]:[cr(r).replace(/[<>]/g,"")]}function qn(r){return r.path[0]==="report"&&r.path[1]==="list"?["1. \u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868\uFF0C\u4E0D\u505A\u5173\u952E\u8BCD\u731C\u6D4B","2. \u9ED8\u8BA4\u5217\u8868\u4F1A\u5C55\u793A\u6BCF\u4E2A\u62A5\u8868\u7684\u53C2\u6570\u6458\u8981\uFF0C\u5148\u5FEB\u901F\u5224\u65AD\u8FD9\u4E2A\u62A5\u8868\u80FD\u4E0D\u80FD\u67E5","3. \u7528 --category \u7F29\u5C0F\u62A5\u8868\u8303\u56F4","4. \u7528 --report-id \u67E5\u770B\u5355\u4E2A\u62A5\u8868\u8BE6\u60C5\u3001\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B","5. \u786E\u8BA4\u62A5\u8868\u53EF\u7528\u540E\uFF0C\u518D\u6267\u884C yybpc-cli report query"]:r.path[0]==="report"&&r.path[1]==="query"?["1. \u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868","2. \u518D\u6267\u884C yybpc-cli report list --report-id REPORT_ID \u786E\u8BA4\u8BE5\u62A5\u8868\u652F\u6301\u7684\u53C2\u6570","3. \u5355\u65E5\u67E5\u8BE2\u4F18\u5148\u4F7F\u7528 --date\uFF1B\u533A\u95F4\u67E5\u8BE2\u518D\u4F7F\u7528 --start-date \u548C --end-date","4. \u6700\u540E\u6267\u884C yybpc-cli report query --report-id REPORT_ID --date YYYY-MM-DD\uFF0C\u6216\u663E\u5F0F\u4F20\u5F00\u59CB/\u7ED3\u675F\u65E5\u671F",'5. \u82E5\u9700\u989D\u5916\u53C2\u6570\uFF0C\u4F7F\u7528 --param-json \u4F20\u5165\u62A5\u8868\u652F\u6301\u7684\u5B57\u6BB5\uFF0C\u4F8B\u5982 {"regionList":["3301"]}']:[]}function ur(r){return r.path[0]==="report"&&r.path[1]==="list"?["report \u662F\u6240\u6709\u7ECF\u8425\u5206\u6790\u6570\u636E\u7684\u9996\u9009\u6765\u6E90","\u5148\u62C9\u5168\u91CF\u62A5\u8868\uFF0C\u4E0D\u5728 CLI \u5185\u505A\u5173\u952E\u8BCD\u731C\u6D4B\uFF0C\u907F\u514D\u8BEF\u5BFC AI \u9009\u62E9\u9519\u8BEF\u62A5\u8868","\u9ED8\u8BA4\u5217\u8868\u4F1A\u76F4\u63A5\u5C55\u793A\u62A5\u8868\u53C2\u6570\u6458\u8981\uFF0C\u907F\u514D\u5148\u770B\u5217\u8868\u5374\u4E0D\u77E5\u9053\u600E\u4E48\u67E5","\u5148\u770B\u5168\u91CF\uFF0C\u518D\u7528 --category \u7F29\u5C0F\u8303\u56F4\uFF0C\u518D\u770B\u5177\u4F53\u62A5\u8868","\u7528 --report-id \u53EF\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u7684\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B","\u82E5 report \u5F53\u524D\u6CA1\u6709\u76F8\u5173\u6570\u636E\uFF0C\u518D\u6539\u7528\u5176\u4ED6\u6A21\u5757\uFF0C\u5E76\u660E\u786E\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F"]:r.path[0]==="report"&&r.path[1]==="query"?["\u6240\u6709\u5206\u6790\u7C7B\u67E5\u8BE2\u4F18\u5148\u8D70 report\uFF1B\u4E0D\u8981\u9ED8\u8BA4\u6539\u7528\u4E3B\u6863\u6570\u636E","\u4E0D\u77E5\u9053 report-id \u65F6\uFF0C\u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868","query \u9636\u6BB5\u53EA\u4F7F\u7528\u786E\u5B9A\u7684 --report-id\uFF0C\u4E0D\u5728\u6267\u884C\u65F6\u505A\u5173\u952E\u8BCD\u731C\u6D4B","report query \u652F\u6301\u5355\u65E5\u5FEB\u6377\u5199\u6CD5 --date YYYY-MM-DD","\u517C\u5BB9\u65E7\u5199\u6CD5 report get / report data\uFF0C\u4F46\u9ED8\u8BA4\u4ECD\u5E94\u4F18\u5148\u4F7F\u7528 report query","\u53EA\u6709 report \u65E0\u76F8\u5173\u6570\u636E\u65F6\uFF0C\u624D\u5141\u8BB8\u6539\u7528\u5176\u4ED6\u6A21\u5757\uFF0C\u5E76\u660E\u786E\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F"]:r.path[0]==="report"&&r.path[1]==="config"?["\u672C\u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u540E\u7AEF\u539F\u6837\u5BF9\u8C61\u7ED3\u6784\uFF08\u4E0D\u538B {columns,rows}\uFF09\uFF0C\u4FBF\u4E8E\u51C6\u786E\u5B66\u4E60\u548C\u590D\u7528\u62A5\u8868\u914D\u7F6E\u7684\u771F\u5B9E shape","\u5982\u9700\u7701 token\uFF0C\u53EF\u663E\u5F0F\u52A0 --compact/--agent\uFF08\u4ECD\u4F1A\u538B\u6210 {columns,rows}\uFF09"]:r.path[0]==="master-data"||r.path[0]==="supply-chain"||r.path[0]==="user-center"?["\u4EC5\u5728 report \u65E0\u76F8\u5173\u62A5\u8868\u6216\u5F53\u524D\u67E5\u4E0D\u5230\u5206\u6790\u6570\u636E\u65F6\u4F7F\u7528\u672C\u547D\u4EE4","\u4F7F\u7528\u672C\u547D\u4EE4\u524D\u540E\uFF0C\u90FD\u5E94\u660E\u786E\u544A\u77E5\u7528\u6237\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:[]}function pr(r){return r[0]==="report"?["report \u662F\u7ECF\u8425\u5206\u6790\u4E0E\u6570\u636E\u89E3\u8BFB\u7684\u9996\u9009\u5165\u53E3","\u5148 list \u627E\u62A5\u8868\uFF0C\u518D query \u67E5\u6570\u636E\uFF1B\u5206\u6790\u7ED3\u8BBA\u4F18\u5148\u57FA\u4E8E report \u8F93\u51FA","\u53EA\u6709 report \u65E0\u76F8\u5173\u6570\u636E\u65F6\uFF0C\u624D\u5141\u8BB8\u6539\u7528\u5176\u4ED6\u6A21\u5757\u8865\u5145\u4FE1\u606F","\u6539\u7528\u5176\u4ED6\u6A21\u5757\u65F6\uFF0C\u5FC5\u987B\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:r[0]==="master-data"||r[0]==="supply-chain"||r[0]==="user-center"?["\u672C\u6A21\u5757\u63D0\u4F9B\u4E3B\u6863/\u4F9B\u5E94\u94FE/\u7EC4\u7EC7\u7B49\u57FA\u7840\u4FE1\u606F\uFF0C\u4E0D\u662F\u7ECF\u8425\u5206\u6790\u9996\u9009\u6765\u6E90","\u8C03\u7528\u524D\u8BF7\u5148\u786E\u8BA4 report \u5F53\u524D\u6CA1\u6709\u76F8\u5173\u62A5\u8868\u6216\u65E0\u6CD5\u63D0\u4F9B\u6240\u9700\u5206\u6790\u6570\u636E","\u82E5\u57FA\u4E8E\u672C\u6A21\u5757\u8F93\u51FA\u5206\u6790\uFF0C\u5FC5\u987B\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:[]}function Gn(r){let t=re(_t(r));return JSON.stringify({version:z,featuredQuery:[...Nn],dataPriority:[...$n],globals:[...In],commands:t.map(e=>({path:e.path,command:`yybpc-cli ${e.path.join(" ")}`,description:e.description}))},null,2)}function Fn(r,t){let e=ar(r,t);return e.length===0?JSON.stringify({error:`\u672A\u627E\u5230: ${r.join(" ")}`},null,2):JSON.stringify({domain:r.join(" "),rules:pr(r),commands:e.map(n=>({path:n.path,command:`yybpc-cli ${n.path.join(" ")}`,description:n.description}))},null,2)}function Yn(r,t){let e=ne(r,t);return JSON.stringify({command:`yybpc-cli ${e.path.join(" ")}`,description:e.description,rules:ur(e),args:Object.entries(e.args??{}).map(([n,o])=>({name:n,flag:`--${n}`,type:o.type,required:o.required??!1,description:o.description??"",default:o.default})),example:cr(e)},null,2)}function oe(r,t={}){let{commandPath:e,json:n}=t;return!e||e.length===0?n?Gn(r):Ln(r).join(`
175
- `).trimEnd():ne(e,r)?n?Yn(e,r):Mn(e,r).join(`
176
- `).trimEnd():n?Fn(e,r):Hn(e,r).join(`
177
- `).trimEnd()}Ot();T();var fr={meta:{description:"\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u7684\u5B8C\u6574\u914D\u7F6E\uFF08SQL\u3001items\u3001params\uFF09"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"GET",path:"/report/config/detail"}};T();x();N();var gr={meta:{description:"\u542F\u7528\u6307\u5B9A\u62A5\u8868"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"POST",path:"/report/config/enable"},run:async({args:r,request:t})=>{let e=b(),n=await t({service:"report",method:"POST",path:"/report/config/enable",body:{reportId:r.reportId}});return e.dryRun||await k(e.env),n}};T();x();N();var yr={meta:{description:"\u7981\u7528\u6307\u5B9A\u62A5\u8868"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"POST",path:"/report/config/disable"},run:async({args:r,request:t})=>{let e=b(),n=await t({service:"report",method:"POST",path:"/report/config/disable",body:{reportId:r.reportId}});return e.dryRun||await k(e.env),n}};T();x();N();B();var _r={meta:{description:"\u65B0\u5EFA\u4E1A\u52A1\u81EA\u7814\u62A5\u8868\uFF08\u5F3A\u5236 business_custom \u5206\u7C7B\uFF09\uFF1B\u53C2\u6570\u53D6\u503C\u89C1 report config dict"},args:{"config-json":{type:"string",required:!0,description:"\u62A5\u8868\u914D\u7F6E JSON\uFF08reportId/reportName/reportType/items\uFF09"}},api:{service:"report",method:"POST",path:"/report/config/save"},run:async({args:r,request:t})=>{let e=b(),n=gt(r.configJson),o=await t({service:"report",method:"POST",path:"/report/config/save",body:n});return e.dryRun||await k(e.env),o}};T();x();N();B();var Cr={meta:{description:"\u4FEE\u6539\u4E1A\u52A1\u81EA\u7814\u62A5\u8868\uFF08\u5F3A\u5236 business_custom \u5206\u7C7B\uFF09"},args:{"config-json":{type:"string",required:!0,description:"\u62A5\u8868\u914D\u7F6E JSON\uFF08\u542B reportId\uFF09"}},api:{service:"report",method:"POST",path:"/report/config/update"},run:async({args:r,request:t})=>{let e=b(),n=gt(r.configJson),o=await t({service:"report",method:"POST",path:"/report/config/update",body:n});return e.dryRun||await k(e.env),o}};T();B();var Or={meta:{description:"\u5217\u51FA\u62A5\u8868\u7814\u53D1\u76F8\u5173\u679A\u4E3E\uFF08\u6570\u636E\u6E90/\u7ED3\u679C\u51FD\u6570/\u7C7B\u578B\u7B49\u53EF\u586B\u53D6\u503C\uFF0C\u514D\u767B\u5F55\uFF09"},args:{},api:{service:"baseinfo",method:"POST",path:"/baseinfo/common/dict/list/v1"},run:async({request:r})=>({success:!0,data:await ft(r),meta:{service:"baseinfo",requestId:"-",duration:0}})};yt();T();R();function br(r,t,e){if(r==null)return t;let n=Number(r);if(!Number.isInteger(n)||n<1)throw new h("INPUT_ERROR","INVALID_ARG",`${e} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);return n}function Un(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function S(r){let t=Object.keys(r.filters??{}),e=["page","page-size"];for(let o of t)if(e.includes(o))throw new Error(`defineListCommand: filter key "${o}" collides with reserved pagination arg. Rename the filter or use a different CLI flag.`);let n={...r.filters??{},page:{type:"number",description:"\u9875\u7801",default:1},"page-size":{type:"number",description:"\u6BCF\u9875\u6570\u91CF",default:20}};return{meta:{description:r.description},args:n,api:{service:r.service,method:"POST",path:r.apiPath},run:async({args:o,request:i})=>{let s=br(o.page,1,"--page"),a=br(o.pageSize,20,"--page-size"),c={page:{pageNo:s,pageSize:a}};for(let d of Object.keys(r.filters??{})){let p=Un(d),u=o[p]??o[d];(typeof u=="string"&&u.length>0||typeof u=="number"||typeof u=="boolean")&&(c[p]=u)}return i({service:r.service,method:"POST",path:r.apiPath,body:c})}}}T();function wr(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function bt(r){if(r.extraBody&&r.filters){let t=Object.keys(r.extraBody),e=Object.keys(r.filters).map(wr);for(let n of t)if(e.includes(n))throw new Error(`defineTreeCommand: extraBody key "${n}" collides with filter name. Remove one or rename the filter.`)}return{meta:{description:r.description},args:r.filters??{},api:{service:r.service,method:"POST",path:r.apiPath},run:async({args:t,request:e})=>{let n={...r.extraBody??{}};for(let o of Object.keys(r.filters??{})){let i=wr(o),s=t[i]??t[o];(typeof s=="string"&&s.length>0||typeof s=="number"||typeof s=="boolean")&&(n[i]=s)}return e({service:r.service,method:"POST",path:r.apiPath,body:n})}}}var Ar=[{path:["master-data","franchisee","list"],def:S({description:"\u52A0\u76DF\u5546\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/franchisee/list"})},{path:["master-data","store","list"],def:S({description:"\u95E8\u5E97\u6863\u6848\u5217\u8868\uFF08\u652F\u6301\u5173\u952E\u5B57\u6A21\u7CCA\u641C\u7D22\uFF09",service:"mdm",apiPath:"/baseinfo/mdm/store/list",filters:{keyword:{type:"string",description:"\u95E8\u5E97\u5173\u952E\u5B57\u6A21\u7CCA\u641C\u7D22"}}})},{path:["master-data","company","list"],def:S({description:"\u516C\u53F8\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/company/list"})},{path:["master-data","contract","list"],def:S({description:"\u95E8\u5E97\u5408\u540C\u6863\u6848\u5217\u8868",service:"contract",apiPath:"/contract/contract/list"})},{path:["master-data","bank","list"],def:S({description:"\u94F6\u884C\u6863\u6848\u5217\u8868",service:"baseinfo",apiPath:"/baseinfo/common/bank/branch/list"})},{path:["master-data","warehouse","list"],def:S({description:"\u4ED3\u5E93\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/warehouse/list"})},{path:["master-data","unit","list"],def:S({description:"\u5355\u4F4D\u6570\u636E\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/unit/list"})},{path:["master-data","area","list"],def:S({description:"\u533A\u57DF\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/area/list"})},{path:["master-data","region","tree"],def:bt({description:"\u7701\u5E02\u533A\u6811",service:"baseinfo",apiPath:"/baseinfo/common/region/tree"})},{path:["supply-chain","supplier","list"],def:S({description:"\u4F9B\u5E94\u5546\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/supplier/list"})},{path:["supply-chain","product-category","tree"],def:bt({description:"\u5546\u54C1\u5206\u7C7B\u6811",service:"mdm",apiPath:"/baseinfo/mdm/product/category/tree/list"})},{path:["supply-chain","product","list"],def:S({description:"\u5546\u54C1\u6863\u6848\u5217\u8868\uFF08SKU \u7EF4\u5EA6\uFF09",service:"mdm",apiPath:"/baseinfo/mdm/product/sku/list"})},{path:["user-center","org","tree"],def:bt({description:"\u7EC4\u7EC7\u67B6\u6784\u6811",service:"user-center",apiPath:"/user-center/org/tree"})},{path:["user-center","user","list"],def:S({description:"\u7528\u6237\u5217\u8868",service:"user-center",apiPath:"/user-center/user/list"})}];ht();var E=[{path:["report","query"],def:ce},{path:["report","config","get"],def:fr},{path:["report","config","enable"],def:gr},{path:["report","config","disable"],def:yr},{path:["report","config","create"],def:_r},{path:["report","config","update"],def:Cr},{path:["report","config","dict"],def:Or},...Ar],Qn=["env","format","compact","slim","agent","verbose","dry-run","as-phone"];function pe(r){return r.option("--env <env>","Target environment (dev/test/prod)","prod").option("--format <format>","Output format: auto(\u9ED8\u8BA4,minified columns/rows)/json(\u5E26\u7F29\u8FDB,\u7ED9\u4EBA\u8BFB)/raw(\u539F\u6837)","auto").option("--compact","Compact JSON: minified data only, no wrapper",!1).option("--slim","Compact + strip null/empty values",!1).option("--agent","Compact + strip nulls + shorten field names (optimized for LLM)",!1).option("--verbose","Print debug info",!1).option("--dry-run","Preview request without executing",!1).option("--as-phone <phone>","Agent mode: act as phone number")}function Dr(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function Bn(){let r=new Set;for(let e of Qn)r.add(`--${e}`);for(let{def:e}of E)for(let n of Object.keys(e.args))r.add(`--${n}`);for(let e of Object.keys(P.args))r.add(`--${e}`);let t=["report","params","date","start-date","end-date","region","store-id","channel","order-field","order-dir"];for(let e of t)r.add(`--${e}`);return r}function zn(r,t){if(!r.startsWith("--"))return r;let e=r.indexOf("="),n=e===-1?r:r.slice(0,e),o=e===-1?"":r.slice(e);if(t.has(n))return r;let i=`--${Dr(n.slice(2))}`,s=[...t].find(a=>Dr(a.slice(2))===i.slice(2));return s?`${s}${o}`:r}function Xn(r,t){return r.map(e=>zn(e,t))}function kr(r,t){for(let[e,n]of Object.entries(t)){let o=n.type==="boolean"?`--${e}`:n.required?`--${e} <${n.type}>`:`--${e} [${n.type}]`;r.option(o,n.description??"",n.default)}return r}function X(r){let t=r.optsWithGlobals();Ve({env:t.env,asPhone:t.asPhone,verbose:t.verbose,dryRun:t.dryRun})}function Y(r,t,e){let n=()=>oe(t,{commandPath:e});r.helpInformation=n}function le(r){let t=r.optsWithGlobals(),e=t.format??"auto",n="none";return t.agent?n="agent":t.slim?n="slim":t.compact&&(n="compact"),n==="none"&&e==="auto"&&(n="compact"),{format:e==="auto"?"json":e,compactMode:n}}var Zn=[["report","config"]];function to(r){return Zn.some(t=>t.every((e,n)=>r[n]===e))}function eo(r,t,e){let n=t[t.length-1],o=r.command(n).description(e.meta.description);kr(o,e.args),Y(o,E,t),o.action(async()=>{X(o);let i=o.opts(),s=le(o),a=o.optsWithGlobals(),d=(a.format??"auto")==="auto"&&!a.agent&&!a.slim&&!a.compact&&to(t)?"raw":s.format,{compactMode:p}=s;await dt(d,p,async()=>{if(e.run)return e.run({args:i,request:q});let u=e.api.method==="GET";return q({service:e.api.service,method:e.api.method,path:e.api.path,...u?{query:i}:{body:i}})})})}async function ro(){let r=Bn(),t=new Re;t.name("yybpc-cli").version(z).description("Internal service CLI"),Y(t,E),pe(t);let e=new Map;function n(l,m){let y=m.join(" "),g=e.get(y);if(g)return g;let w=m[m.length-1],C=l.command(w).description(`${w} commands`);return pe(C),Y(C,E,m),e.set(y,C),C}for(let{path:l,def:m}of E){let y=t;for(let g=0;g<l.length-1;g++)y=n(y,l.slice(0,g+1));eo(y,l,m)}let o=n(t,["report"]),i=o.command("list").description(P.description);kr(i,P.args),Y(i,E,["report","list"]),i.action(async()=>{X(i);try{let{runReportList:l}=await Promise.resolve().then(()=>(ht(),ze));await l(i.opts())}catch(l){console.error(Q(l)),process.exit(1)}});let a=n(t,["report","config"]).command("guide").description(F.description);pe(a),a.action(async()=>{X(a);try{let{runGuide:l}=await Promise.resolve().then(()=>(yt(),tr));await l(q)}catch(l){console.error(Q(l)),process.exit(1)}});let c=o.command("get <reportId> <date> [endDate]").description("Compatibility alias for yybpc-cli report query");Y(c,E,["report","query"]),c.action(async(l,m,y)=>{X(c);let{format:g,compactMode:w}=le(c);await dt(g,w,async()=>{let{runReportQuery:C}=await Promise.resolve().then(()=>(Ot(),ue));return C({reportId:l,date:m,endDate:y},q)})});let d=o.command("data").description("Compatibility alias for yybpc-cli report query").requiredOption("--report <reportId>","Legacy alias for --report-id").option("--params <json>","Legacy alias for --param-json; may also include startDate/endDate").option("--date <date>","Single date shortcut (YYYY-MM-DD)").option("--start-date <date>","Start date (YYYY-MM-DD)").option("--end-date <date>","End date (YYYY-MM-DD)").option("--region <value>","Region IDs").option("--store-id <value>","Store IDs").option("--channel <value>","Channel IDs").option("--order-field <field>","Sort field").option("--order-dir <dir>","Sort direction");Y(d,E,["report","query"]),d.action(async()=>{X(d);let{format:l,compactMode:m}=le(d);await dt(l,m,async()=>{let{runReportQuery:y}=await Promise.resolve().then(()=>(Ot(),ue));return y(d.opts(),q)})});let p=t.command("auth",{hidden:!0}).description("Authentication management");p.command("set-token <token>").description("Manually set satoken for human login").action(async l=>{let{runSetToken:m}=await Promise.resolve().then(()=>(Rr(),Sr));await m(l)}),p.command("logout").description("Clear local session").action(async()=>{let{runLogout:l}=await Promise.resolve().then(()=>(Er(),Tr));await l()}),p.command("status").description("Show current login status").action(async()=>{let{runStatus:l}=await Promise.resolve().then(()=>(xr(),vr));await l()});let u=t.command("help [command...]").description("Show complete command reference (yybpc-cli help, yybpc-cli help <domain>, yybpc-cli help <domain> <cmd>)").option("--json","Output as JSON");u.action(l=>{let m=l.length>0?l:void 0,y=u.opts().json??!1;if(!y){let g=m?.join(" ")??"";if(!m||e.has(g)){let C=m?e.get(g):t;process.stdout.write(C.helpInformation());return}if(E.find(C=>C.path.length===m.length&&C.path.every((U,Z)=>U===m[Z]))){let C=m.slice(0,-1).join(" "),Z=(m.length>1?e.get(C):t)?.commands.find(Pr=>Pr.name()===m[m.length-1]);if(Z){process.stdout.write(Z.helpInformation());return}}if(m.length===2&&m[0]==="report"&&m[1]==="list"){process.stdout.write(i.helpInformation());return}}process.stdout.write(oe(E,{commandPath:m,json:y}))}),await t.parseAsync(Xn(process.argv,r))}ro().catch(r=>{console.error(Q(r)),process.exit(1)});export{ro as main,Xn as normalizeArgv};
176
+ `,jn=" \uFF08\u672A\u80FD\u5B9E\u65F6\u83B7\u53D6\uFF0C\u8BF7\u8FD0\u884C yybpc-cli report config dict \u67E5\u770B\u53EF\u7528\u6570\u636E\u6E90\uFF09"});var E=_(()=>{"use strict"});var de={};L(de,{buildReportQueryBody:()=>_r,default:()=>le,normalizeReportQueryArgs:()=>pe,parseParamJson:()=>ue,runReportQuery:()=>br});function Ct(r,...t){for(let e of t){let n=r[e];if(n==null)continue;let o=String(n).trim();if(o)return o}}function ce(r){let t=r.trim();if(t.startsWith("["))try{let e=JSON.parse(t);if(Array.isArray(e))return e.map(n=>String(n))}catch{}return t.includes(",")?t.split(",").map(e=>e.trim()).filter(Boolean):t}function ue(r){if(!r)return{};try{let t=JSON.parse(r);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("not an object");return t}catch{throw new h("INPUT_ERROR","INVALID_PARAM_JSON",'--param-json \u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF0C\u4F8B\u5982 {"regionList":["3301"]}')}}function pe(r){let t=ue(r.params),e=ue(r.paramJson??r["param-json"]),n=r.dynamicParams&&typeof r.dynamicParams=="object"&&!Array.isArray(r.dynamicParams)?r.dynamicParams:{},o={...t,...n,...e},i=Ct(r,"date"),s=Ct(r,"reportId","report-id","report")??(typeof o.reportId=="string"?o.reportId:void 0),a=Ct(r,"startDate","start-date")??(typeof o.startDate=="string"?o.startDate:void 0)??i,c=Ct(r,"endDate","end-date")??(typeof o.endDate=="string"?o.endDate:void 0)??i;return delete o.reportId,delete o.startDate,delete o.endDate,{reportId:s,startDate:a,endDate:c,extraParams:o,passthroughArgs:r}}function yr(r){if(!r.reportId)throw new h("INPUT_ERROR","MISSING_REPORT_ID","\u5FC5\u987B\u63D0\u4F9B\u62A5\u8868ID\uFF1B\u5148\u6267\u884C yybpc-cli report list \u67E5\u770B\u53EF\u7528\u62A5\u8868\uFF0C\u518D\u4F7F\u7528 --report-id");if(!r.startDate||!r.endDate)throw new h("INPUT_ERROR","MISSING_DATE_RANGE","\u5FC5\u987B\u63D0\u4F9B\u67E5\u8BE2\u65E5\u671F\uFF1B\u4F7F\u7528 --date YYYY-MM-DD\uFF0C\u6216\u540C\u65F6\u63D0\u4F9B --start-date \u548C --end-date")}function gr(r,t,e){if(e==="reportId")throw new h("INPUT_ERROR","INVALID_REPORT_PARAM","--param-json \u4E0D\u80FD\u5305\u542B reportId");if(!r.params.includes(e))throw new h("INPUT_ERROR","UNSUPPORTED_REPORT_PARAM",`\u62A5\u8868 ${t} \u4E0D\u652F\u6301\u53C2\u6570 ${e}\uFF1B\u53EF\u7528\u53C2\u6570: ${r.params.join(", ")}`)}function _r(r,t){let e=pe(t);yr(e);let n=e.reportId,o={reportId:n,startDate:e.startDate,endDate:e.endDate},i={...e.extraParams};for(let a of Object.keys(i))gr(r,n,a);Object.assign(o,i);let s={region:{apiParam:"regionList",parse:ce},storeId:{apiParam:"storeList",parse:ce},channel:{apiParam:"channelList",parse:ce},orderField:{apiParam:"orderField"},orderDir:{apiParam:"orderDir"}};for(let[a,c]of Object.entries(s)){let d=e.passthroughArgs[a];d==null||d===""||(gr(r,n,c.apiParam),o[c.apiParam]=c.parse?c.parse(String(d)):d)}return o}async function br(r,t){let e=C(),n=pe(r);yr(n);let o=n.reportId,{token:i}=await D({asPhone:e.asPhone,env:e.env}),s=await ft(e.env,i),a=Ke(s,o);if(!a)throw new h("INPUT_ERROR","INVALID_REPORT_ID",`\u672A\u77E5\u7684\u62A5\u8868ID: ${o}\uFF1B\u5148\u6267\u884C yybpc-cli report list \u67E5\u627E\u53EF\u7528\u62A5\u8868`);let c=_r(a,r);return t({service:"report",method:"POST",path:"/report/query/single",body:c})}var le,wt=_(()=>{"use strict";E();k();mt();v();S();le={meta:{description:"\u67E5\u8BE2\u62A5\u8868\u5206\u6790\u6570\u636E\uFF1B\u6240\u6709\u5206\u6790\u7C7B\u67E5\u8BE2\u4F18\u5148\u4F7F\u7528 report"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID\uFF08\u5982 gj_target_achievement_3\uFF09"},date:{type:"string",description:"\u5355\u65E5\u5FEB\u6377\u5199\u6CD5 (YYYY-MM-DD)\uFF1B\u4F1A\u540C\u65F6\u4F5C\u4E3A\u5F00\u59CB\u548C\u7ED3\u675F\u65E5\u671F"},"start-date":{type:"string",description:"\u5F00\u59CB\u65E5\u671F (YYYY-MM-DD)"},"end-date":{type:"string",description:"\u7ED3\u675F\u65E5\u671F (YYYY-MM-DD)"},region:{type:"string",description:"\u6218\u533AID\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},"store-id":{type:"string",description:"\u95E8\u5E97ID\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},channel:{type:"string",description:"\u6E20\u9053\u7F16\u7801\uFF1B\u652F\u6301\u5355\u503C\u3001\u9017\u53F7\u5206\u9694\u6216 JSON \u6570\u7EC4"},"order-field":{type:"string",description:"\u6392\u5E8F\u5B57\u6BB5"},"order-dir":{type:"string",description:"\u6392\u5E8F\u65B9\u5411 (asc/desc)"},"param-json":{type:"string",description:'\u989D\u5916\u62A5\u8868\u53C2\u6570 JSON(\u6570\u7EC4\u578B\u53C2\u6570\u7528\u5B83),\u5982 {"regionList":["3301"]};\u6807\u91CF\u53C2\u6570\u4E5F\u53EF\u76F4\u63A5 --<\u53C2\u6570\u540D> \u503C'}},allowDynamicParams:!0,api:{service:"report",method:"POST",path:"/report/query/single"},run:async({args:r,request:t})=>br(r,t)}});var vr={};L(vr,{runSetToken:()=>Zn});async function Zn(r){let t={accessToken:r,refreshToken:"",expiresAt:Date.now()+864e5,userId:"",username:"",loginAt:Date.now()};await pt(t),console.log(JSON.stringify({success:!0,data:{message:"Token \u5DF2\u4FDD\u5B58"}},null,2))}var Dr=_(()=>{"use strict";Q()});var Pr={};L(Pr,{runLogout:()=>to});async function to(){await je(),console.log(JSON.stringify({success:!0,data:{message:"\u5DF2\u9000\u51FA\u767B\u5F55"}},null,2))}var kr=_(()=>{"use strict";Q()});var $r={};L($r,{runStatus:()=>eo});async function eo(){let r=await ut();if(!r){console.log(JSON.stringify({success:!0,data:{loggedIn:!1,message:"\u5F53\u524D\u672A\u767B\u5F55\uFF0C\u8BF7\u6267\u884C yybpc-cli auth set-token <token>"}},null,2));return}let t=lt(r),e=Ut(r);console.log(Zt({success:!0,data:{loggedIn:t,userId:r.userId,username:r.username,expiresAt:new Date(r.expiresAt).toISOString(),needsRefresh:e,loginAt:new Date(r.loginAt).toISOString()},meta:{service:"auth",requestId:"-",duration:0}},"json"))}var Ir=_(()=>{"use strict";Q();Wt();te()});var Te=Fr(Ee(),1),{program:bo,createCommand:Oo,createArgument:Co,createOption:wo,CommanderError:Ao,InvalidArgumentError:Ro,InvalidOptionArgumentError:So,Command:xe,Argument:Eo,Option:To,Help:xo}=Te.default;v();te();gt();bt();var ir={name:"@yybpc/cli",version:"1.2.0",description:"\u516C\u53F8\u5185\u90E8\u670D\u52A1\u7EDF\u4E00 CLI\uFF08\u62A5\u8868\u67E5\u8BE2 + \u4E2D\u53F0\u4E3B\u6863/\u4F9B\u5E94\u94FE/\u7528\u6237\u4E2D\u5FC3\uFF09",type:"module",bin:{"yybpc-cli":"dist/index.js"},files:["dist/index.js"],engines:{node:">=18"},scripts:{dev:"tsx src/index.ts",build:"tsup","build:sea":"bash scripts/build-sea.sh","build:sea:linux":"bash scripts/build-sea-linux.sh","build:sea:all":"bash scripts/build-sea.sh && bash scripts/build-sea-linux.sh",typecheck:"tsc --noEmit",test:'tsx --test "src/**/*.test.ts"',prepublishOnly:"tsup"},devDependencies:{"@types/node":"^22.10.0",commander:"^14.0.3",tsup:"^8.3.5",tsx:"^4.19.2",typescript:"^5.7.2"}};var X=ir.version;k();var sr=[{...$,path:[...$.path]},{description:Y.description,path:[...Y.path]}],Mn=[{bullet:"`--env <dev|prod>` \u2014 \u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 prod\uFF09"},{bullet:"`--format <auto|json|raw>` \u2014 \u8F93\u51FA\u683C\u5F0F\uFF08\u9ED8\u8BA4 auto\uFF09\u3002auto=\u7D27\u51D1\u5217\u5F0F\uFF08\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u7701 token\uFF0C\u9002\u5408 agent\uFF09\uFF1Bjson=\u5E26\u7F29\u8FDB\u7684\u5B8C\u6574\u4FE1\u5C01\uFF08\u9002\u5408\u4EBA\u8BFB\uFF09\uFF1Braw=\u540E\u7AEF\u539F\u6837\u6570\u636E\u3002\u6CE8\uFF1Areport config \u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u540E\u7AEF\u539F\u6837\u7ED3\u6784\uFF08\u4E0D\u538B {columns,rows}\uFF0C\u4FBF\u4E8E\u5B66\u4E60\u914D\u7F6E shape\uFF09\uFF0C\u9700\u7701 token \u53EF\u663E\u5F0F\u52A0 --compact"},{bullet:"`--compact` \u2014 \u7D27\u51D1\u5217\u5F0F\u8F93\u51FA\uFF08\u7B49\u540C\u9ED8\u8BA4 auto\uFF1A\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u4E0D\u7F29\u8FDB\uFF09"},{bullet:"`--slim` \u2014 compact \u57FA\u7840\u4E0A\u518D\u79FB\u9664 null/\u7A7A\u503C"},{bullet:"`--agent` \u2014 slim \u57FA\u7840\u4E0A\u518D\u7F29\u77ED\u5B57\u6BB5\u540D\uFF08\u6700\u7701 token\uFF0C\u7ED9 LLM \u7528\uFF09"},{bullet:"`--verbose` \u2014 \u6253\u5370\u8C03\u8BD5\u4FE1\u606F\uFF08\u8BF7\u6C42 URL \u7B49\uFF0C\u8F93\u51FA\u5230 stderr\uFF09"},{bullet:"`--dry-run` \u2014 \u9884\u89C8\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42\uFF08method/url/body\uFF09\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C"},{bullet:"`--as-phone <phone>` \u2014 Agent \u6A21\u5F0F\uFF1A\u4EE3\u8868\u6307\u5B9A\u624B\u673A\u53F7\u7528\u6237\u8C03\u7528"}],Vn=[{flag:"--env",description:"\u76EE\u6807\u73AF\u5883\uFF08dev/prod\uFF09",default:"prod"},{flag:"--format",description:"\u8F93\u51FA\u683C\u5F0F\uFF1Aauto=\u7D27\u51D1\u5217\u5F0F({columns,rows},\u7701token)/json=\u5E26\u7F29\u8FDB\u5B8C\u6574\u4FE1\u5C01/raw=\u540E\u7AEF\u539F\u6837\u3002report config \u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u539F\u6837\u7ED3\u6784(\u4E0D\u538B\u7F29),\u7701 token \u53EF\u52A0 --compact",default:"auto"},{flag:"--compact",description:"\u7D27\u51D1\u5217\u5F0F\u8F93\u51FA\uFF08\u7B49\u540C\u9ED8\u8BA4 auto\uFF1A\u5BF9\u8C61\u6570\u7EC4\u8F6C {columns,rows}\uFF0C\u4E0D\u7F29\u8FDB\uFF09"},{flag:"--slim",description:"compact \u57FA\u7840\u4E0A\u518D\u79FB\u9664 null/\u7A7A\u503C"},{flag:"--agent",description:"slim \u57FA\u7840\u4E0A\u518D\u7F29\u77ED\u5B57\u6BB5\u540D\uFF08\u6700\u7701 token\uFF0C\u7ED9 LLM \u7528\uFF09"},{flag:"--verbose",description:"\u6253\u5370\u8C03\u8BD5\u4FE1\u606F\uFF08\u8F93\u51FA\u5230 stderr\uFF09"},{flag:"--dry-run",description:"\u9884\u89C8\u5C06\u53D1\u51FA\u7684\u8BF7\u6C42\uFF08method/url/body\uFF09\uFF0C\u4E0D\u5B9E\u9645\u6267\u884C"},{flag:"--as-phone",description:"Agent \u6A21\u5F0F\uFF1A\u4EE3\u8868\u6307\u5B9A\u624B\u673A\u53F7\u7528\u6237\u8C03\u7528"}],ur=["\u6240\u6709\u7ECF\u8425\u5206\u6790\u3001\u8D8B\u52BF\u5224\u65AD\u3001\u4E1A\u7EE9\u89E3\u8BFB\u7C7B\u9700\u6C42\uFF0C\u4F18\u5148\u4F7F\u7528 report","\u53EA\u6709 report \u67E5\u4E0D\u5230\u3001\u672A\u8986\u76D6\u6216\u5F53\u524D\u6CA1\u6709\u76F8\u5173\u62A5\u8868\u65F6\uFF0C\u624D\u5141\u8BB8\u4F7F\u7528\u5176\u4ED6\u6A21\u5757","\u6539\u7528 master-data / supply-chain / user-center \u65F6\uFF0C\u5FC5\u987B\u660E\u786E\u544A\u77E5\u7528\u6237\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868","master-data / supply-chain / user-center \u4E3B\u8981\u7528\u4E8E\u8865\u5145\u4E3B\u6863\u3001\u4F9B\u5E94\u94FE\u3001\u7EC4\u7EC7\u7B49\u57FA\u7840\u4FE1\u606F\uFF0C\u4E0D\u5E94\u9ED8\u8BA4\u66FF\u4EE3 report"],qn=ur.map((r,t)=>({priority:t+1,rule:r})),pr=["\u6700\u9AD8\u4F18\u5148\u7EA7\u547D\u4EE4: yybpc-cli report query","\u6240\u6709\u7ECF\u8425\u5206\u6790\u3001\u8D8B\u52BF\u5224\u65AD\u3001\u4E1A\u7EE9\u89E3\u8BFB\u7C7B\u9700\u6C42\uFF0C\u9ED8\u8BA4\u5148\u7528 yybpc-cli report query","\u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868\uFF0C\u518D\u7528 yybpc-cli report list --report-id REPORT_ID \u67E5\u770B\u8BE6\u60C5","\u6807\u51C6\u8DEF\u5F84: \u5168\u91CF\u62A5\u8868 -> \u5355\u62A5\u8868\u8BE6\u60C5 -> \u6267\u884C\u67E5\u8BE2","\u793A\u4F8B: yybpc-cli report list\uFF0C\u7136\u540E\u6267\u884C yybpc-cli report query --report-id REPORT_ID --date 2026-04-22"],Gn=pr.map((r,t)=>({priority:t+1,hint:r})),ar=["report","master-data","supply-chain","user-center"];function Fn(r,t){return r.join(" ").localeCompare(t.join(" "))}function cr(r){if(r.path[0]==="report"){if(r.path[1]==="list")return 0;if(r.path[1]==="query")return 1}return 100}function ie(r){return[...r].sort((t,e)=>{let n=ar.indexOf(t.path[0]),o=ar.indexOf(e.path[0]),i=n===-1?Number.MAX_SAFE_INTEGER:n,s=o===-1?Number.MAX_SAFE_INTEGER:o;if(i!==s)return i-s;let a=cr(t),c=cr(e);return a!==c?a-c:Fn(t.path,e.path)})}function Ot(r){let t=r.map(e=>({path:e.path,description:e.def.meta.description,args:e.def.args}));for(let e of sr)if(t.some(n=>n.path.length===e.path.length&&n.path.every((o,i)=>o===e.path[i])))throw new Error(`MANUAL_COMMANDS collides with apiCommands on path: ${e.path.join(" ")}`);return[...t,...sr]}function Yn(r){let t=ie(Ot(r)),e=[];e.push(`yybpc-cli ${X}`),e.push("\u9996\u9009\u5165\u53E3");for(let o of pr)e.push(` ${o}`);e.push(""),e.push("\u6570\u636E\u4F18\u5148\u7EA7");for(let o of ur)e.push(` ${o}`);e.push(""),e.push("\u5168\u5C40\u53C2\u6570");for(let o of Mn)e.push(` ${o.bullet.replaceAll("`","")}`);e.push(""),e.push("\u547D\u4EE4");let n="";for(let o of t)o.path[0]!==n&&(e[e.length-1]!=="\u547D\u4EE4"&&e.push(""),e.push(` [${o.path[0]}]`),n=o.path[0]),e.push(` yybpc-cli ${o.path.join(" ")} ${o.description}`);return e.push(""),e.push("\u66F4\u591A\u5E2E\u52A9"),e.push(" yybpc-cli help <command> \u4F8B\u5982: yybpc-cli help report query"),e}function lr(r,t){return ie(Ot(t)).filter(e=>e.path.length>r.length&&r.every((n,o)=>e.path[o]===n))}function Un(r,t){let e=lr(r,t);if(e.length===0)return[`\u672A\u627E\u5230: ${r.join(" ")}`];let n=[];n.push(`yybpc-cli ${r.join(" ")} \u4E0B\u7684\u547D\u4EE4`);let o=hr(r);if(o.length>0){n.push("\u89C4\u5219");for(let i of o)n.push(` ${i}`);n.push("")}n.push("\u547D\u4EE4");for(let i of e)n.push(` yybpc-cli ${i.path.join(" ")} ${i.description}`);return n}function se(r,t){return Ot(t).find(e=>e.path.length===r.length&&e.path.every((n,o)=>n===r[o]))}function Wn(r,t){let e=se(r,t),n=[];n.push(`yybpc-cli ${e.path.join(" ")}`),n.push(e.description);let o=Kn(e);if(o.length>0){n.push(""),n.push("\u5FEB\u901F\u5F00\u59CB");for(let a of o)n.push(` ${a}`)}n.push(""),n.push("\u793A\u4F8B");for(let a of Jn(e))n.push(` ${a}`);n.push(""),n.push("\u53C2\u6570");let i=e.args??{};if(Object.keys(i).length===0)n.push(" \uFF08\u65E0\u53C2\u6570\uFF09");else for(let[a,c]of Object.entries(i)){let d=c.required?" \u5FC5\u586B":"",p=c.description??"",u=c.default!==void 0?` \u9ED8\u8BA4 ${c.default}`:"",l=`${d}${p?` ${p}`:""}${u}`,m=c.enum?c.enum.join("|"):c.type,y=c.type==="boolean"?`--${a}`:`--${a} <${m}>`;n.push(` ${y}${l}`)}let s=mr(e);if(s.length>0){n.push(""),n.push("\u89C4\u5219");for(let a of s)n.push(` ${a}`)}return n}function dr(r){let t=[`yybpc-cli ${r.path.join(" ")}`];for(let[e,n]of Object.entries(r.args??{}))if(n.required){let o=n.enum?n.enum.join("|"):e.toUpperCase().replace(/-/g,"_");t.push(`--${e} <${o}>`)}return t.join(" ")}function Jn(r){let t=`yybpc-cli ${r.path.join(" ")}`;return r.path[0]==="report"&&r.path[1]==="list"?[t,`${t} --category gj_store_ranking`,`${t} --report-id gj_target_achievement_3`,`${t} --page 2 --page-size 20`]:r.path[0]==="report"&&r.path[1]==="query"?["\u5148\u770B\u5168\u91CF\u62A5\u8868: yybpc-cli report list","\u770B\u53C2\u6570: yybpc-cli report list --report-id gj_target_achievement_3",`${t} --report-id gj_target_achievement_3 --date 2026-04-22`,`${t} --report-id gj_target_achievement_3 --start-date 2026-04-01 --end-date 2026-04-30`,`${t} --report-id gj_target_achievement_3 --start-date 2026-04-01 --end-date 2026-04-30 --param-json '{"regionList":["3301"]}'`,`${t} --report-id gj_store_ranking_5 --start-date 2026-05-01 --end-date 2026-05-31 --product-name \u7F8E\u5341\u4E09\u8349\u8393\u5976\u51BB`,"\u517C\u5BB9\u65E7\u5199\u6CD5: yybpc-cli report get gj_target_achievement_3 2026-04-22",`\u517C\u5BB9\u65E7\u5199\u6CD5: yybpc-cli report data --report gj_target_achievement_3 --params '{"startDate":"2026-04-22","endDate":"2026-04-22"}'`]:[dr(r).replace(/[<>]/g,"")]}function Kn(r){return r.path[0]==="report"&&r.path[1]==="list"?["1. \u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868\uFF0C\u4E0D\u505A\u5173\u952E\u8BCD\u731C\u6D4B","2. \u9ED8\u8BA4\u5217\u8868\u4F1A\u5C55\u793A\u6BCF\u4E2A\u62A5\u8868\u7684\u53C2\u6570\u6458\u8981\uFF0C\u5148\u5FEB\u901F\u5224\u65AD\u8FD9\u4E2A\u62A5\u8868\u80FD\u4E0D\u80FD\u67E5","3. \u7528 --category \u7F29\u5C0F\u62A5\u8868\u8303\u56F4","4. \u7528 --report-id \u67E5\u770B\u5355\u4E2A\u62A5\u8868\u8BE6\u60C5\u3001\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B","5. \u786E\u8BA4\u62A5\u8868\u53EF\u7528\u540E\uFF0C\u518D\u6267\u884C yybpc-cli report query"]:r.path[0]==="report"&&r.path[1]==="query"?["1. \u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868","2. \u518D\u6267\u884C yybpc-cli report list --report-id REPORT_ID \u786E\u8BA4\u8BE5\u62A5\u8868\u652F\u6301\u7684\u53C2\u6570","3. \u5355\u65E5\u67E5\u8BE2\u4F18\u5148\u4F7F\u7528 --date\uFF1B\u533A\u95F4\u67E5\u8BE2\u518D\u4F7F\u7528 --start-date \u548C --end-date","4. \u6700\u540E\u6267\u884C yybpc-cli report query --report-id REPORT_ID --date YYYY-MM-DD\uFF0C\u6216\u663E\u5F0F\u4F20\u5F00\u59CB/\u7ED3\u675F\u65E5\u671F",'5. \u82E5\u9700\u989D\u5916\u53C2\u6570\uFF1A\u6807\u91CF\u53C2\u6570\u53EF\u76F4\u63A5\u4F5C\u4E3A --<\u53C2\u6570\u540D> \u503C\u4F20(\u5982 --product-name \u7F8E\u5341\u4E09\u8349\u8393\u5976\u51BB)\uFF1B\u6570\u7EC4\u578B\u53C2\u6570(xxxList)\u7528 --param-json\uFF0C\u4F8B\u5982 {"regionList":["3301"]}']:[]}function mr(r){return r.path[0]==="report"&&r.path[1]==="list"?["report \u662F\u6240\u6709\u7ECF\u8425\u5206\u6790\u6570\u636E\u7684\u9996\u9009\u6765\u6E90","\u5148\u62C9\u5168\u91CF\u62A5\u8868\uFF0C\u4E0D\u5728 CLI \u5185\u505A\u5173\u952E\u8BCD\u731C\u6D4B\uFF0C\u907F\u514D\u8BEF\u5BFC AI \u9009\u62E9\u9519\u8BEF\u62A5\u8868","\u9ED8\u8BA4\u5217\u8868\u4F1A\u76F4\u63A5\u5C55\u793A\u62A5\u8868\u53C2\u6570\u6458\u8981\uFF0C\u907F\u514D\u5148\u770B\u5217\u8868\u5374\u4E0D\u77E5\u9053\u600E\u4E48\u67E5","\u5148\u770B\u5168\u91CF\uFF0C\u518D\u7528 --category \u7F29\u5C0F\u8303\u56F4\uFF0C\u518D\u770B\u5177\u4F53\u62A5\u8868","\u7528 --report-id \u53EF\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u7684\u53C2\u6570\u548C\u67E5\u8BE2\u793A\u4F8B",`\u62A5\u8868\u8F83\u591A\u65F6\u53EF\u5206\u9875\uFF1A--page / --page-size\uFF08\u9ED8\u8BA4\u6BCF\u9875 ${j}\uFF0C\u5373\u4E00\u6B21\u62FF\u5168\u91CF\uFF09\uFF1B\u8F93\u51FA\u542B total \u4E0E hasMore\uFF0C\u636E\u6B64\u7FFB\u9875`,"\u82E5 report \u5F53\u524D\u6CA1\u6709\u76F8\u5173\u6570\u636E\uFF0C\u518D\u6539\u7528\u5176\u4ED6\u6A21\u5757\uFF0C\u5E76\u660E\u786E\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F"]:r.path[0]==="report"&&r.path[1]==="query"?["\u6240\u6709\u5206\u6790\u7C7B\u67E5\u8BE2\u4F18\u5148\u8D70 report\uFF1B\u4E0D\u8981\u9ED8\u8BA4\u6539\u7528\u4E3B\u6863\u6570\u636E","\u4E0D\u77E5\u9053 report-id \u65F6\uFF0C\u5148\u6267\u884C yybpc-cli report list \u62C9\u53D6\u5168\u90E8\u62A5\u8868","query \u9636\u6BB5\u53EA\u4F7F\u7528\u786E\u5B9A\u7684 --report-id\uFF0C\u4E0D\u5728\u6267\u884C\u65F6\u505A\u5173\u952E\u8BCD\u731C\u6D4B","report query \u652F\u6301\u5355\u65E5\u5FEB\u6377\u5199\u6CD5 --date YYYY-MM-DD","\u62A5\u8868\u4E13\u5C5E\u53C2\u6570\u53EF\u76F4\u63A5\u4F5C\u4E3A --<\u53C2\u6570\u540D> \u4F20(\u5982 --product-name X\uFF0C\u7B49\u4EF7 --param-json)\uFF1B\u53C2\u6570\u540D\u4EE5 report list \u8BE6\u60C5\u4E3A\u51C6\uFF0C\u4F20\u9519\u4F1A\u62A5\u9519\u5E76\u5217\u51FA\u8BE5\u62A5\u8868\u53EF\u7528\u53C2\u6570","\u6570\u7EC4\u578B\u53C2\u6570(xxxList)\u4ECD\u7528 --param-json\uFF1B\u52A8\u6001 --<\u53C2\u6570> \u539F\u6837\u900F\u4F20\u4E0D\u505A\u6570\u7EC4\u62C6\u5206","\u517C\u5BB9\u65E7\u5199\u6CD5 report get / report data\uFF0C\u4F46\u9ED8\u8BA4\u4ECD\u5E94\u4F18\u5148\u4F7F\u7528 report query","\u53EA\u6709 report \u65E0\u76F8\u5173\u6570\u636E\u65F6\uFF0C\u624D\u5141\u8BB8\u6539\u7528\u5176\u4ED6\u6A21\u5757\uFF0C\u5E76\u660E\u786E\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F"]:r.path[0]==="report"&&r.path[1]==="config"?["\u672C\u7CFB\u5217\u9ED8\u8BA4\u8F93\u51FA\u540E\u7AEF\u539F\u6837\u5BF9\u8C61\u7ED3\u6784\uFF08\u4E0D\u538B {columns,rows}\uFF09\uFF0C\u4FBF\u4E8E\u51C6\u786E\u5B66\u4E60\u548C\u590D\u7528\u62A5\u8868\u914D\u7F6E\u7684\u771F\u5B9E shape","\u5982\u9700\u7701 token\uFF0C\u53EF\u663E\u5F0F\u52A0 --compact/--agent\uFF08\u4ECD\u4F1A\u538B\u6210 {columns,rows}\uFF09"]:r.path[0]==="master-data"||r.path[0]==="supply-chain"||r.path[0]==="user-center"?["\u4EC5\u5728 report \u65E0\u76F8\u5173\u62A5\u8868\u6216\u5F53\u524D\u67E5\u4E0D\u5230\u5206\u6790\u6570\u636E\u65F6\u4F7F\u7528\u672C\u547D\u4EE4","\u4F7F\u7528\u672C\u547D\u4EE4\u524D\u540E\uFF0C\u90FD\u5E94\u660E\u786E\u544A\u77E5\u7528\u6237\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:[]}function hr(r){return r[0]==="report"?["report \u662F\u7ECF\u8425\u5206\u6790\u4E0E\u6570\u636E\u89E3\u8BFB\u7684\u9996\u9009\u5165\u53E3","\u5148 list \u627E\u62A5\u8868\uFF0C\u518D query \u67E5\u6570\u636E\uFF1B\u5206\u6790\u7ED3\u8BBA\u4F18\u5148\u57FA\u4E8E report \u8F93\u51FA","\u53EA\u6709 report \u65E0\u76F8\u5173\u6570\u636E\u65F6\uFF0C\u624D\u5141\u8BB8\u6539\u7528\u5176\u4ED6\u6A21\u5757\u8865\u5145\u4FE1\u606F","\u6539\u7528\u5176\u4ED6\u6A21\u5757\u65F6\uFF0C\u5FC5\u987B\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:r[0]==="master-data"||r[0]==="supply-chain"||r[0]==="user-center"?["\u672C\u6A21\u5757\u63D0\u4F9B\u4E3B\u6863/\u4F9B\u5E94\u94FE/\u7EC4\u7EC7\u7B49\u57FA\u7840\u4FE1\u606F\uFF0C\u4E0D\u662F\u7ECF\u8425\u5206\u6790\u9996\u9009\u6765\u6E90","\u8C03\u7528\u524D\u8BF7\u5148\u786E\u8BA4 report \u5F53\u524D\u6CA1\u6709\u76F8\u5173\u62A5\u8868\u6216\u65E0\u6CD5\u63D0\u4F9B\u6240\u9700\u5206\u6790\u6570\u636E","\u82E5\u57FA\u4E8E\u672C\u6A21\u5757\u8F93\u51FA\u5206\u6790\uFF0C\u5FC5\u987B\u8BF4\u660E\uFF1A\u5F53\u524D\u62A5\u8868\u7CFB\u7EDF\u6682\u65E0\u76F8\u5173\u6570\u636E\uFF0C\u4EE5\u4E0B\u5206\u6790\u57FA\u4E8E\u4E3B\u6863\u4FE1\u606F\uFF0C\u4E0D\u7B49\u540C\u4E8E\u7ECF\u8425\u5206\u6790\u62A5\u8868"]:[]}function Qn(r){let t=ie(Ot(r));return JSON.stringify({version:X,featuredQuery:[...Gn],dataPriority:[...qn],globals:[...Vn],commands:t.map(e=>({path:e.path,command:`yybpc-cli ${e.path.join(" ")}`,description:e.description}))},null,2)}function zn(r,t){let e=lr(r,t);return e.length===0?JSON.stringify({error:`\u672A\u627E\u5230: ${r.join(" ")}`},null,2):JSON.stringify({domain:r.join(" "),rules:hr(r),commands:e.map(n=>({path:n.path,command:`yybpc-cli ${n.path.join(" ")}`,description:n.description}))},null,2)}function Bn(r,t){let e=se(r,t);return JSON.stringify({command:`yybpc-cli ${e.path.join(" ")}`,description:e.description,rules:mr(e),args:Object.entries(e.args??{}).map(([n,o])=>({name:n,flag:`--${n}`,type:o.type,required:o.required??!1,description:o.description??"",default:o.default})),example:dr(e)},null,2)}function ae(r,t={}){let{commandPath:e,json:n}=t;return!e||e.length===0?n?Qn(r):Yn(r).join(`
177
+ `).trimEnd():se(e,r)?n?Bn(e,r):Wn(e,r).join(`
178
+ `).trimEnd():n?zn(e,r):Un(e,r).join(`
179
+ `).trimEnd()}function Z(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function fr(r){let t={};for(let e=0;e<r.length;e++){let n=r[e];if(!n.startsWith("--"))continue;let o=n.slice(2);if(!o)continue;let i=o.indexOf("=");if(i!==-1){t[Z(o.slice(0,i))]=o.slice(i+1);continue}let s=Z(o),a=r[e+1];a!=null&&!a.startsWith("--")?(t[s]=a,e++):t[s]=!0}return t}wt();E();var Or={meta:{description:"\u67E5\u770B\u5355\u4E2A\u62A5\u8868\u7684\u5B8C\u6574\u914D\u7F6E\uFF08SQL\u3001items\u3001params\uFF09"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"GET",path:"/report/config/detail"}};E();v();k();var Cr={meta:{description:"\u542F\u7528\u6307\u5B9A\u62A5\u8868"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"POST",path:"/report/config/enable"},run:async({args:r,request:t})=>{let e=C(),n=await t({service:"report",method:"POST",path:"/report/config/enable",body:{reportId:r.reportId}});return e.dryRun||await P(e.env),n}};E();v();k();var wr={meta:{description:"\u7981\u7528\u6307\u5B9A\u62A5\u8868"},args:{"report-id":{type:"string",required:!0,description:"\u62A5\u8868ID"}},api:{service:"report",method:"POST",path:"/report/config/disable"},run:async({args:r,request:t})=>{let e=C(),n=await t({service:"report",method:"POST",path:"/report/config/disable",body:{reportId:r.reportId}});return e.dryRun||await P(e.env),n}};E();v();k();B();var Ar={meta:{description:"\u65B0\u5EFA\u4E1A\u52A1\u81EA\u7814\u62A5\u8868\uFF08\u5F3A\u5236 business_custom \u5206\u7C7B\uFF09\uFF1B\u53C2\u6570\u53D6\u503C\u89C1 report config dict"},args:{"config-json":{type:"string",required:!0,description:"\u62A5\u8868\u914D\u7F6E JSON\uFF08reportId/reportName/reportType/items\uFF09"}},api:{service:"report",method:"POST",path:"/report/config/save"},run:async({args:r,request:t})=>{let e=C(),n=_t(r.configJson),o=await t({service:"report",method:"POST",path:"/report/config/save",body:n});return e.dryRun||await P(e.env),o}};E();v();k();B();var Rr={meta:{description:"\u4FEE\u6539\u4E1A\u52A1\u81EA\u7814\u62A5\u8868\uFF08\u5F3A\u5236 business_custom \u5206\u7C7B\uFF09"},args:{"config-json":{type:"string",required:!0,description:"\u62A5\u8868\u914D\u7F6E JSON\uFF08\u542B reportId\uFF09"}},api:{service:"report",method:"POST",path:"/report/config/update"},run:async({args:r,request:t})=>{let e=C(),n=_t(r.configJson),o=await t({service:"report",method:"POST",path:"/report/config/update",body:n});return e.dryRun||await P(e.env),o}};E();B();var Sr={meta:{description:"\u5217\u51FA\u62A5\u8868\u7814\u53D1\u76F8\u5173\u679A\u4E3E\uFF08\u6570\u636E\u6E90/\u7ED3\u679C\u51FD\u6570/\u7C7B\u578B\u7B49\u53EF\u586B\u53D6\u503C\uFF0C\u514D\u767B\u5F55\uFF09"},args:{},api:{service:"baseinfo",method:"POST",path:"/baseinfo/common/dict/list/v1"},run:async({request:r})=>({success:!0,data:await yt(r),meta:{service:"baseinfo",requestId:"-",duration:0}})};bt();E();S();function Er(r,t,e){if(r==null)return t;let n=Number(r);if(!Number.isInteger(n)||n<1)throw new h("INPUT_ERROR","INVALID_ARG",`${e} \u5FC5\u987B\u662F\u6B63\u6574\u6570`);return n}function Xn(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function R(r){let t=Object.keys(r.filters??{}),e=["page","page-size"];for(let o of t)if(e.includes(o))throw new Error(`defineListCommand: filter key "${o}" collides with reserved pagination arg. Rename the filter or use a different CLI flag.`);let n={...r.filters??{},page:{type:"number",description:"\u9875\u7801",default:1},"page-size":{type:"number",description:"\u6BCF\u9875\u6570\u91CF",default:20}};return{meta:{description:r.description},args:n,api:{service:r.service,method:"POST",path:r.apiPath},run:async({args:o,request:i})=>{let s=Er(o.page,1,"--page"),a=Er(o.pageSize,20,"--page-size"),c={page:{pageNo:s,pageSize:a}};for(let d of Object.keys(r.filters??{})){let p=Xn(d),u=o[p]??o[d];(typeof u=="string"&&u.length>0||typeof u=="number"||typeof u=="boolean")&&(c[p]=u)}return i({service:r.service,method:"POST",path:r.apiPath,body:c})}}}E();function Tr(r){return r.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}function At(r){if(r.extraBody&&r.filters){let t=Object.keys(r.extraBody),e=Object.keys(r.filters).map(Tr);for(let n of t)if(e.includes(n))throw new Error(`defineTreeCommand: extraBody key "${n}" collides with filter name. Remove one or rename the filter.`)}return{meta:{description:r.description},args:r.filters??{},api:{service:r.service,method:"POST",path:r.apiPath},run:async({args:t,request:e})=>{let n={...r.extraBody??{}};for(let o of Object.keys(r.filters??{})){let i=Tr(o),s=t[i]??t[o];(typeof s=="string"&&s.length>0||typeof s=="number"||typeof s=="boolean")&&(n[i]=s)}return e({service:r.service,method:"POST",path:r.apiPath,body:n})}}}var xr=[{path:["master-data","franchisee","list"],def:R({description:"\u52A0\u76DF\u5546\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/franchisee/list"})},{path:["master-data","store","list"],def:R({description:"\u95E8\u5E97\u6863\u6848\u5217\u8868\uFF08\u652F\u6301\u5173\u952E\u5B57\u6A21\u7CCA\u641C\u7D22\uFF09",service:"mdm",apiPath:"/baseinfo/mdm/store/list",filters:{keyword:{type:"string",description:"\u95E8\u5E97\u5173\u952E\u5B57\u6A21\u7CCA\u641C\u7D22"}}})},{path:["master-data","company","list"],def:R({description:"\u516C\u53F8\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/company/list"})},{path:["master-data","contract","list"],def:R({description:"\u95E8\u5E97\u5408\u540C\u6863\u6848\u5217\u8868",service:"contract",apiPath:"/contract/contract/list"})},{path:["master-data","bank","list"],def:R({description:"\u94F6\u884C\u6863\u6848\u5217\u8868",service:"baseinfo",apiPath:"/baseinfo/common/bank/branch/list"})},{path:["master-data","warehouse","list"],def:R({description:"\u4ED3\u5E93\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/warehouse/list"})},{path:["master-data","unit","list"],def:R({description:"\u5355\u4F4D\u6570\u636E\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/unit/list"})},{path:["master-data","area","list"],def:R({description:"\u533A\u57DF\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/area/list"})},{path:["master-data","region","tree"],def:At({description:"\u7701\u5E02\u533A\u6811",service:"baseinfo",apiPath:"/baseinfo/common/region/tree"})},{path:["supply-chain","supplier","list"],def:R({description:"\u4F9B\u5E94\u5546\u6863\u6848\u5217\u8868",service:"mdm",apiPath:"/baseinfo/mdm/supplier/list"})},{path:["supply-chain","product-category","tree"],def:At({description:"\u5546\u54C1\u5206\u7C7B\u6811",service:"mdm",apiPath:"/baseinfo/mdm/product/category/tree/list"})},{path:["supply-chain","product","list"],def:R({description:"\u5546\u54C1\u6863\u6848\u5217\u8868\uFF08SKU \u7EF4\u5EA6\uFF09",service:"mdm",apiPath:"/baseinfo/mdm/product/sku/list"})},{path:["user-center","org","tree"],def:At({description:"\u7EC4\u7EC7\u67B6\u6784\u6811",service:"user-center",apiPath:"/user-center/org/tree"})},{path:["user-center","user","list"],def:R({description:"\u7528\u6237\u5217\u8868",service:"user-center",apiPath:"/user-center/user/list"})}];gt();var T=[{path:["report","query"],def:le},{path:["report","config","get"],def:Or},{path:["report","config","enable"],def:Cr},{path:["report","config","disable"],def:wr},{path:["report","config","create"],def:Ar},{path:["report","config","update"],def:Rr},{path:["report","config","dict"],def:Sr},...xr],ro=["env","format","compact","slim","agent","verbose","dry-run","as-phone"];function me(r){return r.option("--env <env>","Target environment (dev/test/prod)","prod").option("--format <format>","Output format: auto(\u9ED8\u8BA4,minified columns/rows)/json(\u5E26\u7F29\u8FDB,\u7ED9\u4EBA\u8BFB)/raw(\u539F\u6837)","auto").option("--compact","Compact JSON: minified data only, no wrapper",!1).option("--slim","Compact + strip null/empty values",!1).option("--agent","Compact + strip nulls + shorten field names (optimized for LLM)",!1).option("--verbose","Print debug info",!1).option("--dry-run","Preview request without executing",!1).option("--as-phone <phone>","Agent mode: act as phone number")}function no(){let r=new Set;for(let e of ro)r.add(`--${e}`);for(let{def:e}of T)for(let n of Object.keys(e.args))r.add(`--${n}`);for(let e of Object.keys($.args))r.add(`--${e}`);let t=["report","params","date","start-date","end-date","region","store-id","channel","order-field","order-dir"];for(let e of t)r.add(`--${e}`);return r}function oo(r,t){if(!r.startsWith("--"))return r;let e=r.indexOf("="),n=e===-1?r:r.slice(0,e),o=e===-1?"":r.slice(e);if(t.has(n))return r;let i=`--${Z(n.slice(2))}`,s=[...t].find(a=>Z(a.slice(2))===i.slice(2));return s?`${s}${o}`:r}function io(r,t){return r.map(e=>oo(e,t))}function Nr(r,t){for(let[e,n]of Object.entries(t)){let o=n.type==="boolean"?`--${e}`:n.required?`--${e} <${n.type}>`:`--${e} [${n.type}]`;r.option(o,n.description??"",n.default)}return r}function tt(r){let t=r.optsWithGlobals();Fe({env:t.env,asPhone:t.asPhone,verbose:t.verbose,dryRun:t.dryRun})}function U(r,t,e){let n=()=>ae(t,{commandPath:e});r.helpInformation=n}function he(r){let t=r.optsWithGlobals(),e=t.format??"auto",n="none";return t.agent?n="agent":t.slim?n="slim":t.compact&&(n="compact"),n==="none"&&e==="auto"&&(n="compact"),{format:e==="auto"?"json":e,compactMode:n}}var so=[["report","config"]];function ao(r){return so.some(t=>t.every((e,n)=>r[n]===e))}function co(r,t,e){let n=t[t.length-1],o=r.command(n).description(e.meta.description);Nr(o,e.args),e.allowDynamicParams&&o.allowUnknownOption(!0).allowExcessArguments(!0),U(o,T,t),o.action(async()=>{tt(o);let i=o.opts();if(e.allowDynamicParams){let u=fr(o.args);Object.keys(u).length>0&&(i.dynamicParams=u)}let s=he(o),a=o.optsWithGlobals(),d=(a.format??"auto")==="auto"&&!a.agent&&!a.slim&&!a.compact&&ao(t)?"raw":s.format,{compactMode:p}=s;await ht(d,p,async()=>{if(e.run)return e.run({args:i,request:G});let u=e.api.method==="GET";return G({service:e.api.service,method:e.api.method,path:e.api.path,...u?{query:i}:{body:i}})})})}async function uo(){let r=no(),t=new xe;t.name("yybpc-cli").version(X).description("Internal service CLI"),U(t,T),me(t);let e=new Map;function n(l,m){let y=m.join(" "),g=e.get(y);if(g)return g;let w=m[m.length-1],b=l.command(w).description(`${w} commands`);return me(b),U(b,T,m),e.set(y,b),b}for(let{path:l,def:m}of T){let y=t;for(let g=0;g<l.length-1;g++)y=n(y,l.slice(0,g+1));co(y,l,m)}let o=n(t,["report"]),i=o.command("list").description($.description);Nr(i,$.args),U(i,T,["report","list"]),i.action(async()=>{tt(i);try{let{runReportList:l}=await Promise.resolve().then(()=>(gt(),er));await l(i.opts())}catch(l){console.error(z(l)),process.exit(1)}});let a=n(t,["report","config"]).command("guide").description(Y.description);me(a),a.action(async()=>{tt(a);try{let{runGuide:l}=await Promise.resolve().then(()=>(bt(),or));await l(G)}catch(l){console.error(z(l)),process.exit(1)}});let c=o.command("get <reportId> <date> [endDate]").description("Compatibility alias for yybpc-cli report query");U(c,T,["report","query"]),c.action(async(l,m,y)=>{tt(c);let{format:g,compactMode:w}=he(c);await ht(g,w,async()=>{let{runReportQuery:b}=await Promise.resolve().then(()=>(wt(),de));return b({reportId:l,date:m,endDate:y},G)})});let d=o.command("data").description("Compatibility alias for yybpc-cli report query").requiredOption("--report <reportId>","Legacy alias for --report-id").option("--params <json>","Legacy alias for --param-json; may also include startDate/endDate").option("--date <date>","Single date shortcut (YYYY-MM-DD)").option("--start-date <date>","Start date (YYYY-MM-DD)").option("--end-date <date>","End date (YYYY-MM-DD)").option("--region <value>","Region IDs").option("--store-id <value>","Store IDs").option("--channel <value>","Channel IDs").option("--order-field <field>","Sort field").option("--order-dir <dir>","Sort direction");U(d,T,["report","query"]),d.action(async()=>{tt(d);let{format:l,compactMode:m}=he(d);await ht(l,m,async()=>{let{runReportQuery:y}=await Promise.resolve().then(()=>(wt(),de));return y(d.opts(),G)})});let p=t.command("auth",{hidden:!0}).description("Authentication management");p.command("set-token <token>").description("Manually set satoken for human login").action(async l=>{let{runSetToken:m}=await Promise.resolve().then(()=>(Dr(),vr));await m(l)}),p.command("logout").description("Clear local session").action(async()=>{let{runLogout:l}=await Promise.resolve().then(()=>(kr(),Pr));await l()}),p.command("status").description("Show current login status").action(async()=>{let{runStatus:l}=await Promise.resolve().then(()=>(Ir(),$r));await l()});let u=t.command("help [command...]").description("Show complete command reference (yybpc-cli help, yybpc-cli help <domain>, yybpc-cli help <domain> <cmd>)").option("--json","Output as JSON");u.action(l=>{let m=l.length>0?l:void 0,y=u.opts().json??!1;if(!y){let g=m?.join(" ")??"";if(!m||e.has(g)){let b=m?e.get(g):t;process.stdout.write(b.helpInformation());return}if(T.find(b=>b.path.length===m.length&&b.path.every((W,et)=>W===m[et]))){let b=m.slice(0,-1).join(" "),et=(m.length>1?e.get(b):t)?.commands.find(jr=>jr.name()===m[m.length-1]);if(et){process.stdout.write(et.helpInformation());return}}if(m.length===2&&m[0]==="report"&&m[1]==="list"){process.stdout.write(i.helpInformation());return}}process.stdout.write(ae(T,{commandPath:m,json:y}))}),await t.parseAsync(io(process.argv,r))}uo().catch(r=>{console.error(z(r)),process.exit(1)});export{uo as main,io as normalizeArgv};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yybpc/cli",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "公司内部服务统一 CLI(报表查询 + 中台主档/供应链/用户中心)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,9 @@
17
17
  "build": "tsup",
18
18
  "build:sea": "bash scripts/build-sea.sh",
19
19
  "build:sea:linux": "bash scripts/build-sea-linux.sh",
20
+ "build:sea:all": "bash scripts/build-sea.sh && bash scripts/build-sea-linux.sh",
20
21
  "typecheck": "tsc --noEmit",
22
+ "test": "tsx --test \"src/**/*.test.ts\"",
21
23
  "prepublishOnly": "tsup"
22
24
  },
23
25
  "devDependencies": {