From ff99de0c185a52f214cc48c35a08f7ef915e6d3e Mon Sep 17 00:00:00 2001 From: Mike Pirog Date: Fri, 24 Sep 2021 14:06:51 -0400 Subject: [PATCH] #25: Remove windows command entrypoint and move debug handling to top of bin/hyperdrive --- bin/hyperdrive | 10 ++++++++++ bin/hyperdrive.cmd | 3 --- cli/hooks/init.js | 21 +++++++++++---------- 3 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 bin/hyperdrive.cmd diff --git a/bin/hyperdrive b/bin/hyperdrive index 9bfeea8..ba3d6f1 100755 --- a/bin/hyperdrive +++ b/bin/hyperdrive @@ -1,4 +1,14 @@ #!/usr/bin/env node + +// 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? +// @TODO: or maybe add this as a util? +// @TODO: we should give preference to process.env.DEBUG if its set. +if (process.argv.slice(2).find(element => element === '--debug') === '--debug') { + require('debug').enable('*'); // eslint-disable-line node/no-extraneous-require +} + require('@oclif/command') .run() .then(require('@oclif/command/flush')) diff --git a/bin/hyperdrive.cmd b/bin/hyperdrive.cmd deleted file mode 100644 index e34b6c5..0000000 --- a/bin/hyperdrive.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -node "%~dp0\hyperdrive" %* diff --git a/cli/hooks/init.js b/cli/hooks/init.js index a2ac9d5..74cdd67 100644 --- a/cli/hooks/init.js +++ b/cli/hooks/init.js @@ -6,22 +6,23 @@ const LandoOclifPlugin = require('./../../utils/plugin'); module.exports = async({id, argv, config}) => { let debug = createDebugger(config.dirname, 'hooks', 'init'); - // 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? - // @TODO: or maybe add this as a util? - // @TODO: this should go at the top of bin/hyperdrive so we get debug output before this point - // @TODO: we should give preference to process.env.DEBUG if its set. - 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 can get this far debug('cli init start with id=%s, argv=%O', id, argv); + // @TODO: eventually we will want to grab a cached config file that was the result of a previous bootstrap + // for speed purposes, we want to minimize the time it takes to show the list of commands or help and put all + // time instensive dep loading after the command has been run(). + // @NOTE that the config file should likely be in a hashmap where landoAppRoot -> someconfigfile because a Landofile + // may contain plugins that hyperdrive needs to install for that lando app or it may contain some config overrides + // eg maybe a given lando app wants to set a default plugin install method or provides a new installer/command + // within itself + // @TODO: this also implies we have a way to delete the cache, it would be cool if we could target that deletion + // for specific things so that clearing the cache for app A does not blow away the cache for app B + // @TODOS: /* * ~~1. get debug flag~~ - * 2. plugin helper commands that to do not require lodash (find plugins) + * ~~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