mythix-cli 1.3.6 → 1.3.7

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/bin/runner.js +12 -15
  2. package/package.json +1 -1
package/bin/runner.js CHANGED
@@ -203,7 +203,7 @@ async function initApplication(args) {
203
203
  }
204
204
  }
205
205
 
206
- function generateCommandHelp(commandsObj, globalHelp) {
206
+ async function generateCommandHelp(application, commandsObj, globalHelp) {
207
207
  let commandNames = Object.keys(commandsObj || {});
208
208
  for (let i = 0, il = commandNames.length; i < il; i++) {
209
209
  let commandName = commandNames[i];
@@ -211,7 +211,7 @@ function generateCommandHelp(commandsObj, globalHelp) {
211
211
  let help = null;
212
212
 
213
213
  if (typeof Klass.commandArguments === 'function') {
214
- let result = (Klass.commandArguments() || {});
214
+ let result = ((await Klass.commandArguments(application, 'help')) || {});
215
215
  help = result.help;
216
216
  }
217
217
 
@@ -230,7 +230,7 @@ function generateCommandHelp(commandsObj, globalHelp) {
230
230
  }
231
231
  }
232
232
 
233
- function commandRunners(commandsObj, context, showHelp) {
233
+ async function commandRunners(application, commandsObj, context, showHelp) {
234
234
  let commandNames = Object.keys(commandsObj);
235
235
 
236
236
  for (let i = 0, il = commandNames.length; i < il; i++) {
@@ -239,16 +239,16 @@ function commandRunners(commandsObj, context, showHelp) {
239
239
  let runner = null;
240
240
 
241
241
  if (typeof Klass.commandArguments === 'function') {
242
- let result = (Klass.commandArguments() || {});
242
+ let result = ((await Klass.commandArguments(application, 'runner')) || {});
243
243
  runner = result.runner;
244
244
  }
245
245
 
246
- let result = context.match(commandName, ({ scope, store, fetch }, parserResult) => {
246
+ let result = await context.match(commandName, async ({ scope, store, fetch, showHelp }, parserResult) => {
247
247
  store({ command: commandName });
248
248
 
249
- return scope(commandName, (context) => {
249
+ return await scope(commandName, async (context) => {
250
250
  if (typeof runner === 'function') {
251
- let runnerResult = runner(context, parserResult);
251
+ let runnerResult = await runner(context, parserResult);
252
252
  if (!runnerResult) {
253
253
  showHelp(commandName);
254
254
  return false;
@@ -354,13 +354,13 @@ function commandRunners(commandsObj, context, showHelp) {
354
354
  try {
355
355
  let helpShown = false;
356
356
 
357
- const customShowHelp = (scope) => {
357
+ const customShowHelp = (subHelp) => {
358
358
  if (helpShown)
359
359
  return;
360
360
 
361
361
  helpShown = true;
362
362
 
363
- showHelp(help[scope] || help)
363
+ showHelp(subHelp)
364
364
  };
365
365
 
366
366
  let rootOptions = { help, showHelp: customShowHelp, helpArgPattern: null };
@@ -377,9 +377,9 @@ function commandRunners(commandsObj, context, showHelp) {
377
377
  let applicationOptions = application.getOptions();
378
378
 
379
379
  let commands = await mythixCLI.loadCommands(applicationOptions.commandsPath);
380
- generateCommandHelp(commands, help);
380
+ await generateCommandHelp(application, commands, help);
381
381
 
382
- let commandContext = CMDed((context) => {
382
+ let commandContext = await CMDed(async (context) => {
383
383
  let { $, Types, store } = context;
384
384
 
385
385
  store('mythixApplication', application);
@@ -395,7 +395,7 @@ function commandRunners(commandsObj, context, showHelp) {
395
395
 
396
396
  $('--help', Types.BOOLEAN());
397
397
 
398
- return commandRunners(commands, context, customShowHelp);
398
+ return await commandRunners(application, commands, context, customShowHelp);
399
399
  }, rootOptions);
400
400
 
401
401
  if (!commandContext) {
@@ -415,7 +415,4 @@ function commandRunners(commandsObj, context, showHelp) {
415
415
  } catch (error) {
416
416
  console.error(error);
417
417
  }
418
- // rootCommand = SimpleYargs.buildCommands(rootCommand, initApplication, [ 'init(Create a new application with the given name) <appName:string(Specify application name)> [-d,-dir:string(Path at which to create application)] [-t,-template:string(Git URL to use to clone and create new project from)=https://github.com/th317erd/mythix-app-template.git(Default "https://github.com/th317erd/mythix-app-template.git")] [-tag:string(Specify tag or commit hash to clone template from)]' ]);
419
-
420
- // rootCommand.version(packageJSON.version).strictCommands().wrap(120).parse();
421
418
  })();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "mythix-cli": "./bin/mythix-cli.js"
4
4
  },
5
5
  "name": "mythix-cli",
6
- "version": "1.3.6",
6
+ "version": "1.3.7",
7
7
  "description": "Mythix CLI utility",
8
8
  "main": "src/index.js",
9
9
  "scripts": {