Skip to content

Commit

Permalink
#25: Stub out command files for core apis
Browse files Browse the repository at this point in the history
  • Loading branch information
pirog committed Sep 27, 2021
1 parent 8e9765b commit 87efca8
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 104 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"extends": "oclif",
"extends": ["oclif"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false
},
"rules": {
"no-console": ["warn"],
"semi": ["error", "always"],
Expand Down
19 changes: 19 additions & 0 deletions cli/commands/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const {Command} = require('@oclif/command');

class InstallCommand extends Command {
static description = 'install things';

static usage = 'usage';

static aliases = ['install'];

static examples = [];

async run() {
const {flags} = this.parse(InstallCommand);
const name = flags.name || 'world';
this.log(`goodbye ${name} from ./src/commands/hello.js`);
}
}

module.exports = InstallCommand;
21 changes: 0 additions & 21 deletions cli/commands/bye.js

This file was deleted.

43 changes: 43 additions & 0 deletions cli/commands/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const {Command, flags} = require('@oclif/command');

class UninstallCommand extends Command {
// static _base = 'thing';
// static id = 'thing';
// static title = 'title';

static description = `Describe the command here
Extra documentation goes here
`;
// static hidden - false;

static usage = 'stuff';

static help = 'stuff';

// static aliases = ['uninstall'];

// static strict = false;
// static parse = true;
static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

// static args
// static plugin
// static examples
// static parserOptions
// static

static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

async run() {
const {flags} = this.parse(UninstallCommand);
const name = flags.name || 'world';
this.log(`hello ${name} from ./src/commands/hello.js`);
}
}

module.exports = UninstallCommand;
20 changes: 0 additions & 20 deletions cli/commands/hello.js

This file was deleted.

43 changes: 43 additions & 0 deletions cli/commands/info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const {Command, flags} = require('@oclif/command');

class UninstallCommand extends Command {
// static _base = 'thing';
// static id = 'thing';
// static title = 'title';

static description = `Describe the command here
Extra documentation goes here
`;
// static hidden - false;

static usage = 'stuff';

static help = 'stuff';

static aliases = ['uninstall'];

// static strict = false;
// static parse = true;
static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

// static args
// static plugin
// static examples
// static parserOptions
// static

static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

async run() {
const {flags} = this.parse(UninstallCommand);
const name = flags.name || 'world';
this.log(`hello ${name} from ./src/commands/hello.js`);
}
}

module.exports = UninstallCommand;
43 changes: 43 additions & 0 deletions cli/commands/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const {Command, flags} = require('@oclif/command');

class UninstallCommand extends Command {
// static _base = 'thing';
// static id = 'thing';
// static title = 'title';

static description = `Describe the command here
Extra documentation goes here
`;
// static hidden - false;

static usage = 'stuff';

static help = 'stuff';

static aliases = ['uninstall'];

// static strict = false;
// static parse = true;
static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

// static args
// static plugin
// static examples
// static parserOptions
// static

static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

async run() {
const {flags} = this.parse(UninstallCommand);
const name = flags.name || 'world';
this.log(`hello ${name} from ./src/commands/hello.js`);
}
}

module.exports = UninstallCommand;
43 changes: 43 additions & 0 deletions cli/commands/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const {Command, flags} = require('@oclif/command');

class UninstallCommand extends Command {
// static _base = 'thing';
// static id = 'thing';
// static title = 'title';

static description = `Describe the command here
Extra documentation goes here
`;
// static hidden - false;

static usage = 'stuff';

static help = 'stuff';

static aliases = ['uninstall'];

// static strict = false;
// static parse = true;
static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

// static args
// static plugin
// static examples
// static parserOptions
// static

static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

async run() {
const {flags} = this.parse(UninstallCommand);
const name = flags.name || 'world';
this.log(`hello ${name} from ./src/commands/hello.js`);
}
}

module.exports = UninstallCommand;
43 changes: 43 additions & 0 deletions cli/commands/status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const {Command, flags} = require('@oclif/command');

class UninstallCommand extends Command {
// static _base = 'thing';
// static id = 'thing';
// static title = 'title';

static description = `Describe the command here
Extra documentation goes here
`;
// static hidden - false;

static usage = 'stuff';

static help = 'stuff';

static aliases = ['uninstall'];

// static strict = false;
// static parse = true;
static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

// static args
// static plugin
// static examples
// static parserOptions
// static

static flags = {
name: flags.string({char: 'n', description: 'name to print'}),
}

async run() {
const {flags} = this.parse(UninstallCommand);
const name = flags.name || 'world';
this.log(`hello ${name} from ./src/commands/hello.js`);
}
}

module.exports = UninstallCommand;
52 changes: 30 additions & 22 deletions cli/hooks/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ module.exports = async({id, argv, config}) => {
require('debug').enable('*'); // eslint-disable-line node/no-extraneous-require
debug('cli init start with id=%s, argv=%O', id, argv);

// if config cache exists then just load that and move on?

// Get config vars
const ENV_PREFIX = process.env.HYPERDRIVE_BOOTSTRAP_ENV_PREFIX || 'HYPERDRIVE';
const ENV_SEPARATOR = process.env.HYPERDRIVE_BOOTSTRAP_ENV_SEPARATOR || '_';
Expand All @@ -38,18 +40,40 @@ module.exports = async({id, argv, config}) => {

// Then defaults
bootstrapConf.defaults({
mode: 'cli',
leia: Object.prototype.hasOwnProperty.call(process.env, 'LEIA_PARSER_RUNNING'),
packaged: Object.prototype.hasOwnProperty.call(process, 'pkg'),
plugins: [],
pluginDirs: [],
product: 'hyperdrive',
mode: 'cli',
bootstrap: {
module: path.join(__dirname, '..', '..', 'utils', 'bootstrap.js'),
env: {
separator: '_',
prefix: 'HYPERDRIVE',
},
landoPlugins: true,
// @TODO: core plugin() below?
/*
plugins/core
plugins/
*/
plugins: [],
// @TODO:
pluginDirs: [],
},
});
debug('get config from defaults');

// @TODO: optionally add in lando plugin dirs?
// @NOTE: this will need to do a light lando bootstrap to get plugin dirs and such
// plugin manifests should be yaml eg dumpable to file

// Reset debugger to indicate product status
debug = createDebugger(bootstrapConf.get('product'), 'hooks', 'init');
debug('bootstrap config set to %O', bootstrapConf.get());
debug('bootstrap config set to %O', bootstrapConf.get('source'));

// @TODO: load in oclif somewhere?
// leia: Object.prototype.hasOwnProperty.call(process.env, 'LEIA_PARSER_RUNNING'),
// packaged: Object.prototype.hasOwnProperty.call(process, 'pkg'),

// merge in some oclif stuff?

// 0. need to add plugins and plugin dirs to bootstrap config
// 1. Check if bootstrap exists, throw error if not
Expand All @@ -72,22 +96,6 @@ module.exports = async({id, argv, config}) => {
// *. what do commandIDs do?
// *. install defaults eg desktop -> lando-desktop
/*
hyperdrive:
config:
// list of installers
installers:
// Just OCLIF command objects, this is just a list of metadata
commands:
- {id: 'install', variant: 'lando-docker-engine', path: }
plugins:
- pathtofunction -> gets config and returns plugin
// Final mods to commands, useful to add more options/args etc
mods: (?)
- {id: 'install', path: }
// commands = [require('./../more/bye')];
// config.plugins.push(new DynamicPlugin(config))
// console.log(config.plugins);
Expand Down
Loading

0 comments on commit 87efca8

Please sign in to comment.