-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#25: Ministrapper for CLI bootstrap config
- Loading branch information
Showing
16 changed files
with
189 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* | ||
node "%~dp0\hyperdrive" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
module.exports = async options => { | ||
console.log(`example cnt hook running before ${options.id}`) | ||
} | ||
|
||
module.exports = async() => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
module.exports = async options => { | ||
console.log(`example postrun hook running before ${options.id}`) | ||
} | ||
module.exports = async() => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
const _ = require('lodash'); | ||
const {flags} = require('@oclif/command'); | ||
|
||
module.exports = async options => { | ||
// options.Command = require('./../commands/hello2'); | ||
// console.log(options); | ||
// options.Command.flags.name2 = flags.string({char: 'z', description: 'name to print'}), | ||
|
||
|
||
console.log(`example prerun hook running before ${options.id}`) | ||
} | ||
module.exports = async() => {}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bootstrap: | ||
module: ./lib/bootstrap.js | ||
env: | ||
separator: _ | ||
prefix: HYPERDRIVE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable no-console */ | ||
let debug; | ||
try { | ||
debug = require('debug'); // eslint-disable-line node/no-extraneous-require | ||
} catch (error) {} | ||
|
||
const displayWarnings = () => { | ||
if (process.listenerCount('warning') > 1) return; | ||
process.on('warning', warning => { | ||
console.error(warning.stack); | ||
if (warning.detail) console.error(warning.detail); | ||
}); | ||
}; | ||
|
||
module.exports = (...namespacers) => { | ||
if (!debug) return (..._) => {}; | ||
const bug = debug([...namespacers].join(':')); | ||
if (bug.enabled) displayWarnings(); | ||
return (...args) => bug(...args); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const Provider = require('nconf').Provider; | ||
|
||
/* | ||
* Just a lite wrapper around nconf to make things a bit easier | ||
*/ | ||
class Ministrapper extends Provider { | ||
constructor(namespace = 'ministrapper') { | ||
super(); | ||
this.namespace = namespace; | ||
} | ||
|
||
// Ministrapper only cares about merging in some env namespace | ||
env(namespace = 'HYPERDRIVE', separator = '_', overrides = {}) { | ||
const debug = require('./debug')(...this.namespace, 'env'); | ||
const starter = `${namespace.toLowerCase()}${separator}`; | ||
const defaults = { | ||
parseValues: true, | ||
lowerCase: true, | ||
separator, | ||
transform: obj => { | ||
if (obj.key.startsWith(starter)) { | ||
obj.key = obj.key.replace(starter, ''); | ||
debug('set %s=%s from environment', obj.key.split(separator).join(':'), obj.value); | ||
return obj; | ||
} | ||
}, | ||
}; | ||
super.env({...defaults, ...overrides}); | ||
} | ||
} | ||
|
||
module.exports = Ministrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* New plugin types: | ||
* HyperdrivePlugin extends Config.Plugin | ||
* 1. accepts a list of commands and an optional selector function for a "parent" | ||
* | ||
* | ||
*/ | ||
/* | ||
const Config = require('@oclif/config'); | ||
class DynamicPlugin extends Config.Plugin { | ||
get hooks() { return {} } | ||
get topics() { | ||
return [] | ||
} | ||
get commandIDs() { | ||
return ['mydynamiccommand'] | ||
} | ||
get commands() { | ||
const cmd = require('../more/bye'); | ||
cmd.id = 'bye'; | ||
cmd.load = () => cmd; | ||
return [cmd]; | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.