Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('ensure build', async () => {
const result = await baseRuntimeConfiguration()
expect(result).toMatchSnapshot()
expect(build.mock.calls.length).toBe(1)
expect(build().brand.mock.calls.length).toBe(1)
expect(build().brand.mock.calls[0][0]).toBe('solidarity')
expect(build().src.mock.calls.length).toBe(1)
// Check local and globals for Windows/Darwin + Yarn === 4 checks
expect(build().plugins.mock.calls.length).toBe(4)
expect(build().create.mock.calls.length).toBe(1)
expect(build().run.mock.calls.length).toBe(1)
})
test('ensure build', async () => {
const result = await baseRuntimeConfiguration()
expect(result).toMatchSnapshot()
expect(build.mock.calls.length).toBe(1)
expect(build().brand.mock.calls.length).toBe(1)
expect(build().brand.mock.calls[0][0]).toBe('solidarity')
expect(build().src.mock.calls.length).toBe(1)
// Check local and globals for Windows/Darwin + Yarn === 4 checks
expect(build().plugins.mock.calls.length).toBe(4)
expect(build().create.mock.calls.length).toBe(1)
expect(build().run.mock.calls.length).toBe(1)
})
test('ensure build', async () => {
const result = await baseRuntimeConfiguration()
expect(result).toMatchSnapshot()
expect(build.mock.calls.length).toBe(1)
expect(build().brand.mock.calls.length).toBe(1)
expect(build().brand.mock.calls[0][0]).toBe('solidarity')
expect(build().src.mock.calls.length).toBe(1)
// Check local and globals for Windows/Darwin + Yarn === 4 checks
expect(build().plugins.mock.calls.length).toBe(4)
expect(build().create.mock.calls.length).toBe(1)
expect(build().run.mock.calls.length).toBe(1)
})
async function run(argv) {
const nodeModulesDirPath = path.join(__dirname, '../node_modules');
const globalNodeModulesDirPath = path.join(globalPrefix, 'lib/node_modules');
const cli = build()
.brand('amplify')
.src(__dirname)
.plugins(nodeModulesDirPath, { matching: 'amplify-*', hidden: false })
.plugins(globalNodeModulesDirPath, { matching: 'amplify-*', hidden: false })
.version() // provides default for version, v, --version, -v
.create();
// and run it
const context = await cli.run(argv);
// send it back (for testing, mostly)
return context;
}
module.exports = async function run (argv) {
// create a runtime
const runtime = build()
.brand('ignite')
.loadAll(`${__dirname}/../plugins`)
.token('commandName', 'cliCommand')
.token('commandDescription', 'cliDescription')
.token('extensionName', 'contextExtension')
.createRuntime()
// run the command
const context = await runtime.run()
// print the commands (TODO: but not if we just ran i guess)
if (isNil(context.plugin) || isNil(context.command)) {
header()
printCommands(context)
}
export async function run(argv: string[]) {
// create a CLI runtime
const cli = build()
.brand('warthog')
.src(__dirname)
// .plugins('./node_modules', { matching: 'warthog-*', hidden: true })
.help() // provides default for help, h, --help, -h
.version() // provides default for version, v, --version, -v
.create();
// and run it
const toolbox = await cli.run(argv);
// send it back (for testing, mostly)
return toolbox;
}
export default async (argv?: string[]): Promise => {
// create a CLI runtime
const cli = build()
.brand('zce')
.exclude(['config', 'semver', 'http', 'strings', 'system', 'patching'])
.src(__dirname)
.defaultCommand(zce)
.version(version)
.help(help)
.create()
// and run the CLI
const toolbox = await cli.run(argv)
// send it back (for testing, mostly)
return toolbox
}
async function run(argv) {
// create a CLI runtime
const cli = build()
.brand('fiddly')
.src(__dirname)
.help() // provides default for help, h, --help, -h
.version() // provides default for version, v, --version, -v
.create()
// and run it
const toolbox = await cli.run(argv)
// send it back (for testing, mostly)
return toolbox
}
function configureRuntime () {
return (
build()
// Brand is used for default config files (if any).
.brand(BRAND)
// The default plugin is the directory we're in right now, so
// the commands sub-directory will contain the first right of
// refusal to handle user's requests.
.src(__dirname)
// TODO: maybe there's other places you'd like to load plugins from?
// .load(`~/.${BRAND}`)
// These are the magic tokens found inside command js sources
// which plugin authors use to specify the command users can type
// as well as the help they see.
// .token('commandName', `${BRAND}Command`)
// .token('commandDescription', `${BRAND}Description`)
// let's build it
.create()
const run = async argv => {
const cli = build()
.brand('graph')
.src(__dirname)
.plugins('./node_modules', { matching: 'graph-cli-*', hidden: true })
.help()
.version()
.defaultCommand()
.create()
return await cli.run(argv)
}