From ee9b4613bbda9bca23b598d915b537cfb8b3c6f1 Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Fri, 24 Sep 2021 09:29:04 -0400 Subject: [PATCH] #25: Add in basic --debug flag handling --- cli/hooks/init.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/cli/hooks/init.js b/cli/hooks/init.js index cea5605..497c7a1 100644 --- a/cli/hooks/init.js +++ b/cli/hooks/init.js @@ -31,13 +31,30 @@ class DynamicPlugin extends Config.Plugin { module.exports = async({id, argv, config}) => { let debug = createDebugger(config.dirname, 'hooks', 'init'); - - // @TODO: set this based on some options (--debug?). if boolean/null should set * if string should set as if DEBUG - // envvar was set. - // @NOTE: this shows all debug right now for dev purposes. see @TODO above. - // require('debug').enable('*'); // eslint-disable-line node/no-extraneous-require + // Check for --debug and internally set DEBUG=* if its set + // @TODO: we should make debug a string flag so it can work like setting DEBUG=something + // @TODO: should we handle --debug on our own or use something lightweight like minimist? + if ([id, ...argv].find(element => element === '--debug') === '--debug') { + require('debug').enable('*'); // eslint-disable-line node/no-extraneous-require + } + // Below is mostly just to DEBUG confirm we get this far debug('cli init start with id=%s, argv=%O', id, argv); + // @TODOS: + /* + * ~~1. get debug flag~~ + * 2. plugin helper commands that to do not require lodash (find plugins) + * 3. extended plugin class with extra methods? + * * eg removeCommand, replaceCommand + * 4. extended plugin class with ability to dynamically add commands vs from manifest file + * 5. create metadata to handle the below + * 6. revisit config loading to handle metadata above (ministrapper -> configurator) + * 7. stub out all our needed commands, methods, installers, etc + * 8. revisit get help, we need a help class that can delegate help and print other things eg list of available installers + * 9. stub out hyperdrive library? + * 10. move configurator into its own thing, move oclif helpers in their own thing? + */ + // handle argv aliases if ((id === 'install' || id === 'uninstall') && argv[0] === 'engine') { argv[0] = 'docker-desktop';