@moostjs/event-cli 0.2.36 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -69,6 +69,7 @@ const CONTEXT_TYPE = 'CLI';
69
69
  class MoostCli {
70
70
  constructor(opts) {
71
71
  this.opts = opts;
72
+ this.optionTypes = {};
72
73
  const cliAppOpts = opts === null || opts === void 0 ? void 0 : opts.wooksCli;
73
74
  if (cliAppOpts && cliAppOpts instanceof eventCli.WooksCli) {
74
75
  this.cliApp = cliAppOpts;
@@ -104,7 +105,13 @@ class MoostCli {
104
105
  }
105
106
  onInit(moost) {
106
107
  this.moost = moost;
107
- void this.cliApp.run();
108
+ const boolean = Object
109
+ .entries(this.optionTypes)
110
+ .filter(([_key, val]) => val.length === 1 && val[0] === Boolean)
111
+ .map(([key, _val]) => key);
112
+ void this.cliApp.run(undefined, {
113
+ boolean,
114
+ });
108
115
  }
109
116
  bindHandler(opts) {
110
117
  var _a, _b, _c, _d;
@@ -145,6 +152,7 @@ class MoostCli {
145
152
  keys: param.cliOptionsKeys,
146
153
  value: typeof param.value === 'string' ? param.value : '',
147
154
  description: param.description || '',
155
+ type: param.type,
148
156
  })) : []),
149
157
  ].forEach(o => cliOptions.set(o.keys[0], o));
150
158
  const aliases = [];
@@ -154,18 +162,29 @@ class MoostCli {
154
162
  aliases.push(targetPath);
155
163
  }
156
164
  }
165
+ const cliOptionsArray = Array.from(cliOptions.values());
166
+ cliOptionsArray.forEach(o => {
167
+ for (const key of o.keys) {
168
+ if (!this.optionTypes[key]) {
169
+ this.optionTypes[key] = [];
170
+ }
171
+ if (!(this.optionTypes[key].includes(o.type))) {
172
+ this.optionTypes[key].push(o.type);
173
+ }
174
+ }
175
+ });
157
176
  const args = {};
158
177
  (_d = meta === null || meta === void 0 ? void 0 : meta.params) === null || _d === void 0 ? void 0 : _d.filter(p => p.paramSource === 'ROUTE' && p.description).forEach(p => args[p.paramName] = p.description);
159
178
  const routerBinding = this.cliApp.cli(targetPath, {
160
179
  description: (meta === null || meta === void 0 ? void 0 : meta.description) || '',
161
- options: Array.from(cliOptions.values()),
180
+ options: cliOptionsArray,
162
181
  args,
163
182
  aliases,
164
183
  examples: (meta === null || meta === void 0 ? void 0 : meta.cliExamples) || [],
165
184
  handler: fn,
166
- onRegister: (path, aliasType) => {
185
+ onRegister: (path, aliasType, route) => {
167
186
  var _a;
168
- opts.register(handler, path, routerBinding.getArgs());
187
+ opts.register(handler, path, (route === null || route === void 0 ? void 0 : route.getArgs()) || routerBinding.getArgs());
169
188
  if ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.debug) {
170
189
  opts.logHandler(`${''}(${aliasTypes[aliasType]})${''}${path}`);
171
190
  }
package/dist/index.d.ts CHANGED
@@ -181,6 +181,7 @@ export declare function CliOption(...keys: string[]): ParameterDecorator;
181
181
  export declare class MoostCli implements TMoostAdapter<TCliHandlerMeta> {
182
182
  protected opts?: TMoostCliOpts | undefined;
183
183
  protected cliApp: WooksCli;
184
+ protected optionTypes: Record<string, TFunction[]>;
184
185
  constructor(opts?: TMoostCliOpts | undefined);
185
186
  onNotFound(): Promise<unknown>;
186
187
  protected moost?: Moost;
@@ -192,6 +193,8 @@ export declare interface TCliHandlerMeta {
192
193
  path: string;
193
194
  }
194
195
 
196
+ declare type TFunction = Function;
197
+
195
198
  export declare interface TMoostCliOpts {
196
199
  /**
197
200
  * WooksCli options or instance
@@ -207,6 +210,7 @@ export declare interface TMoostCliOpts {
207
210
  globalCliOptions?: {
208
211
  keys: string[];
209
212
  description?: string;
213
+ type?: TFunction;
210
214
  }[];
211
215
  }
212
216
 
package/dist/index.mjs CHANGED
@@ -68,6 +68,7 @@ const CONTEXT_TYPE = 'CLI';
68
68
  class MoostCli {
69
69
  constructor(opts) {
70
70
  this.opts = opts;
71
+ this.optionTypes = {};
71
72
  const cliAppOpts = opts === null || opts === void 0 ? void 0 : opts.wooksCli;
72
73
  if (cliAppOpts && cliAppOpts instanceof WooksCli) {
73
74
  this.cliApp = cliAppOpts;
@@ -103,7 +104,13 @@ class MoostCli {
103
104
  }
104
105
  onInit(moost) {
105
106
  this.moost = moost;
106
- void this.cliApp.run();
107
+ const boolean = Object
108
+ .entries(this.optionTypes)
109
+ .filter(([_key, val]) => val.length === 1 && val[0] === Boolean)
110
+ .map(([key, _val]) => key);
111
+ void this.cliApp.run(undefined, {
112
+ boolean,
113
+ });
107
114
  }
108
115
  bindHandler(opts) {
109
116
  var _a, _b, _c, _d;
@@ -144,6 +151,7 @@ class MoostCli {
144
151
  keys: param.cliOptionsKeys,
145
152
  value: typeof param.value === 'string' ? param.value : '',
146
153
  description: param.description || '',
154
+ type: param.type,
147
155
  })) : []),
148
156
  ].forEach(o => cliOptions.set(o.keys[0], o));
149
157
  const aliases = [];
@@ -153,18 +161,29 @@ class MoostCli {
153
161
  aliases.push(targetPath);
154
162
  }
155
163
  }
164
+ const cliOptionsArray = Array.from(cliOptions.values());
165
+ cliOptionsArray.forEach(o => {
166
+ for (const key of o.keys) {
167
+ if (!this.optionTypes[key]) {
168
+ this.optionTypes[key] = [];
169
+ }
170
+ if (!(this.optionTypes[key].includes(o.type))) {
171
+ this.optionTypes[key].push(o.type);
172
+ }
173
+ }
174
+ });
156
175
  const args = {};
157
176
  (_d = meta === null || meta === void 0 ? void 0 : meta.params) === null || _d === void 0 ? void 0 : _d.filter(p => p.paramSource === 'ROUTE' && p.description).forEach(p => args[p.paramName] = p.description);
158
177
  const routerBinding = this.cliApp.cli(targetPath, {
159
178
  description: (meta === null || meta === void 0 ? void 0 : meta.description) || '',
160
- options: Array.from(cliOptions.values()),
179
+ options: cliOptionsArray,
161
180
  args,
162
181
  aliases,
163
182
  examples: (meta === null || meta === void 0 ? void 0 : meta.cliExamples) || [],
164
183
  handler: fn,
165
- onRegister: (path, aliasType) => {
184
+ onRegister: (path, aliasType, route) => {
166
185
  var _a;
167
- opts.register(handler, path, routerBinding.getArgs());
186
+ opts.register(handler, path, (route === null || route === void 0 ? void 0 : route.getArgs()) || routerBinding.getArgs());
168
187
  if ((_a = this.opts) === null || _a === void 0 ? void 0 : _a.debug) {
169
188
  opts.logHandler(`${''}(${aliasTypes[aliasType]})${''}${path}`);
170
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/event-cli",
3
- "version": "0.2.36",
3
+ "version": "0.3.1",
4
4
  "description": "@moostjs/event-cli",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -36,12 +36,12 @@
36
36
  },
37
37
  "homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
38
38
  "peerDependencies": {
39
- "moost": "0.2.36",
40
- "wooks": "^0.3.12",
41
- "@wooksjs/event-core": "^0.3.12"
39
+ "moost": "0.3.1",
40
+ "wooks": "^0.4.1",
41
+ "@wooksjs/event-core": "^0.4.1"
42
42
  },
43
43
  "dependencies": {
44
- "@wooksjs/event-cli": "^0.3.12",
44
+ "@wooksjs/event-cli": "^0.4.1",
45
45
  "@prostojs/wf": "^0.0.3"
46
46
  }
47
47
  }