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

supporting "generate plugin" command via generator-feathers-plugin #5

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably just call it feathers:plugin so that it follows the same naming convention. This one is a bit different however because that generator sort of assumes that the plugin will be published to npm.

];

assert.equal(_.difference(expected, env.namespaces()).length, 0, `namespaces() is incomplete: ${env.namespaces()}`);
Expand Down