From e6edd75d807d2b8a30036a71aeb30bffaa6b50d2 Mon Sep 17 00:00:00 2001 From: Derek Watson Date: Sat, 26 Mar 2016 22:26:48 -0400 Subject: [PATCH] supporting "generate plugin" command via generator-feathers-plugin --- package.json | 1 + src/commands/generate.js | 25 ++++++++++++++++++------- test/commands/generate.test.js | 3 ++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 41d4afa..a94c848 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "preferGlobal": true, "dependencies": { "generator-feathers": "^0.6.20", + "generator-feathers-plugin": "^0.6.9", "vorpal": "^1.10.9", "yeoman-environment": "^1.5.2" }, diff --git a/src/commands/generate.js b/src/commands/generate.js index 006a0d6..b98d11f 100644 --- a/src/commands/generate.js +++ b/src/commands/generate.js @@ -2,18 +2,20 @@ import yeoman from 'yeoman-environment'; const env = yeoman.createEnv(); -const generators = 'generator-feathers/generators'; +const feathersGenerators = 'generator-feathers/generators'; -env.register(require.resolve(`${generators}/app`), 'feathers:app'); -env.register(require.resolve(`${generators}/hook`), 'feathers:hook'); -env.register(require.resolve(`${generators}/middleware`), 'feathers:middleware'); -env.register(require.resolve(`${generators}/model`), 'feathers:model'); -env.register(require.resolve(`${generators}/service`), 'feathers:service'); +env.register(require.resolve(`${feathersGenerators}/app`), 'feathers:app'); +env.register(require.resolve(`${feathersGenerators}/hook`), 'feathers:hook'); +env.register(require.resolve(`${feathersGenerators}/middleware`), 'feathers:middleware'); +env.register(require.resolve(`${feathersGenerators}/model`), 'feathers:model'); +env.register(require.resolve(`${feathersGenerators}/service`), 'feathers:service'); +env.register(require.resolve(`${feathersGenerators}/service`), 'feathers:service'); +env.register(require.resolve('generator-feathers-plugin'), 'feathers-plugin'); export default function(vorpal) { vorpal .command('generate ', 'alias for generate app') - .autocomplete(['app', 'hook', 'middleware', 'model', 'service']) + .autocomplete(['app', 'hook', 'middleware', 'model', 'service', 'plugin']) .action(function (args, callback) { this.log(''); env.run('feathers:app', callback); @@ -58,6 +60,15 @@ export default function(vorpal) { this.log(''); env.run('feathers:service', callback); }); + + vorpal + .command('generate plugin') + .description('generate new plugin') + .action(function (args, callback) { + this.log(''); + env.run('feathers-plugin', callback); + }); + } export { env }; diff --git a/test/commands/generate.test.js b/test/commands/generate.test.js index 4f25cf7..d3f9c9c 100644 --- a/test/commands/generate.test.js +++ b/test/commands/generate.test.js @@ -19,7 +19,8 @@ describe('feathers-cli', () => { 'feathers:hook', 'feathers:middleware', 'feathers:model', - 'feathers:service' + 'feathers:service', + 'feathers-plugin' ]; assert.equal(_.difference(expected, env.namespaces()).length, 0, `namespaces() is incomplete: ${env.namespaces()}`);