Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from feathersjs/feature/generator-feathers-plugin
Browse files Browse the repository at this point in the history
supporting "generate plugin" command via generator-feathers-plugin
  • Loading branch information
Derek Watson committed Mar 27, 2016
2 parents 7f33ee0 + e6edd75 commit 8be89f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
25 changes: 18 additions & 7 deletions src/commands/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 };
3 changes: 2 additions & 1 deletion test/commands/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`);
Expand Down

0 comments on commit 8be89f2

Please sign in to comment.