Skip to content

Commit 91a13ff

Browse files
committed
feat(gen): add new route subgenerator
1 parent 9cc59f8 commit 91a13ff

File tree

3 files changed

+49
-73
lines changed

3 files changed

+49
-73
lines changed

Diff for: package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"babel-register": "^6.22.0",
4747
"bluebird": "^3.4.5",
4848
"chalk": "^2.1.0",
49+
"generator-angular-fullstack-component": "1.0.0",
4950
"glob": "^7.0.5",
5051
"gulp-eslint": "^3.0.1",
5152
"gulp-filter": "^5.0.0",
@@ -57,7 +58,7 @@
5758
"lodash": "^4.17.4",
5859
"semver": "^5.1.0",
5960
"underscore.string": "^3.1.1",
60-
"yeoman-generator": "^1.1.1",
61+
"yeoman-generator": "2.0.4",
6162
"yeoman-welcome": "^1.0.1"
6263
},
6364
"devDependencies": {
@@ -83,6 +84,7 @@
8384
"gulp-util": "^3.0.7",
8485
"jit-grunt": "~0.10.0",
8586
"lazypipe": "^1.0.1",
87+
"mem-fs-editor": "4.0.0",
8688
"merge-stream": "^1.0.0",
8789
"minimatch": "^3.0.2",
8890
"mocha": "^3.1.2",
@@ -91,8 +93,8 @@
9193
"run-sequence": "^2.1.0",
9294
"shelljs": "^0.7.5",
9395
"should": "^12.0.0",
94-
"yeoman-assert": "^3.0.0",
95-
"yeoman-test": "~1.7.0"
96+
"yeoman-assert": "^3.1.1",
97+
"yeoman-test": "^1.7.2"
9698
},
9799
"peerDependencies": {
98100
"yo": ">= 1.7.1"

Diff for: src/generators/app/index.js

+34-62
Original file line numberDiff line numberDiff line change
@@ -387,68 +387,40 @@ export class Generator extends Base {
387387
this.config.set('filters', this.filters);
388388
this.config.save();
389389
},
390-
// TODO: switch to ng2 component generator
391-
// ngComponent: function() {
392-
// if(this.skipConfig) return;
393-
// var appPath = 'client/app/';
394-
// var extensions = [];
395-
// var filters = [
396-
// 'ngroute',
397-
// 'uirouter',
398-
// 'jasmine',
399-
// 'mocha',
400-
// 'expect',
401-
// 'should'
402-
// ].filter(v => this.filters[v]);
403-
404-
// if(this.filters.ngroute) filters.push('ngroute');
405-
// if(this.filters.uirouter) filters.push('uirouter');
406-
// if(this.filters.babel) extensions.push('babel');
407-
// if(this.filters.ts) extensions.push('ts');
408-
// if(this.filters.js) extensions.push('js');
409-
// if(this.filters.html) extensions.push('html');
410-
// if(this.filters.pug) extensions.push('pug');
411-
// if(this.filters.css) extensions.push('css');
412-
// if(this.filters.stylus) extensions.push('styl');
413-
// if(this.filters.sass) extensions.push('scss');
414-
// if(this.filters.less) extensions.push('less');
415-
416-
// filters.push('es6'); // Generate ES6 syntax code
417-
// filters.push('webpack'); // Generate ES6 Module imports/exports
418-
419-
// this.composeWith('ng-component', {
420-
// options: {
421-
// 'routeDirectory': appPath,
422-
// 'directiveDirectory': appPath,
423-
// 'filterDirectory': appPath,
424-
// 'serviceDirectory': appPath,
425-
// 'componentDirectory': `${appPath}components/`,
426-
// 'filters': filters,
427-
// 'extensions': extensions,
428-
// 'basePath': 'client',
429-
// 'forceConfig': this.forceConfig
430-
// }
431-
// }, { local: require.resolve('generator-ng-component/generators/app/index.js') });
432-
// },
433-
// ngModules: function() {
434-
// var angModules = [
435-
// `'${this.scriptAppName}.constants'`,
436-
// "'ngCookies'",
437-
// "'ngResource'",
438-
// "'ngSanitize'"
439-
// ];
440-
// if(this.filters.ngroute) angModules.push("'ngRoute'");
441-
// if(this.filters.socketio) angModules.push("'btford.socket-io'");
442-
// if(this.filters.uirouter) angModules.push("'ui.router'");
443-
// if(this.filters.uibootstrap) angModules.push("'ui.bootstrap'");
444-
// if(this.filters.auth) {
445-
// angModules.unshift(`'${this.scriptAppName}.admin'`);
446-
// angModules.unshift(`'${this.scriptAppName}.auth'`);
447-
// angModules.push("'validation.match'");
448-
// }
449-
450-
// this.angularModules = '\n ' + angModules.join(',\n ') +'\n';
451-
// }
390+
angularComponent: function() {
391+
if(this.skipConfig) return;
392+
var appPath = 'client/app/';
393+
var extensions = [];
394+
var filters = [
395+
'jasmine',
396+
'mocha',
397+
'expect',
398+
'should'
399+
].filter(v => this.filters[v]);
400+
401+
if(this.filters.babel) extensions.push('babel');
402+
if(this.filters.ts) extensions.push('ts');
403+
if(this.filters.js) extensions.push('js');
404+
if(this.filters.html) extensions.push('html');
405+
if(this.filters.pug) extensions.push('pug');
406+
if(this.filters.css) extensions.push('css');
407+
if(this.filters.stylus) extensions.push('styl');
408+
if(this.filters.sass) extensions.push('scss');
409+
if(this.filters.less) extensions.push('less');
410+
411+
this.composeWith(require.resolve('generator-angular-fullstack-component/generators/app/index.js'), {
412+
appModulePath: `${appPath}app.module.${this.filters.ts ? 'ts' : 'js'}`,
413+
routeDirectory: appPath,
414+
directiveDirectory: appPath,
415+
filterDirectory: appPath,
416+
serviceDirectory: appPath,
417+
componentDirectory: `${appPath}components/`,
418+
filters: filters,
419+
extensions: extensions,
420+
basePath: 'client',
421+
forceConfig: this.forceConfig
422+
});
423+
},
452424
};
453425
}
454426

Diff for: src/generators/route/index.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
'use strict';
2-
var yeoman = require('yeoman-generator');
1+
import Generator from 'yeoman-generator';
2+
import { Base } from '../generator-base';
33

4-
var Generator = yeoman.Base.extend({
5-
compose: function() {
6-
this.composeWith('ng-component:route', {arguments: this.arguments}, { local: require.resolve('generator-ng-component/generators/route') });
4+
class RouteGenerator extends Base {
5+
compose() {
6+
this.composeWith(
7+
require.resolve('generator-angular-fullstack-component/generators/route'),
8+
{arguments: this.arguments},
9+
);
710
}
8-
});
9-
10-
module.exports = Generator;
11+
}
12+
module.exports = RouteGenerator;

0 commit comments

Comments
 (0)