Skip to content

Commit

Permalink
angular cli component config added
Browse files Browse the repository at this point in the history
  • Loading branch information
prosenjit-manna committed Oct 31, 2017
1 parent 4435de7 commit fa5fd72
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
42 changes: 25 additions & 17 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const chalk = require('chalk');
const log = console.log;
var shell = require('shelljs');
const updateNotifier = require('update-notifier');
const replace = require('replace');
const pkg = require('../../package.json');
const notifier = updateNotifier({
pkg,
Expand Down Expand Up @@ -63,19 +64,19 @@ module.exports = class extends Generator {
value: 'prefix',
checked: true
}]
},
{
name: 'includeTemplate',
message: 'Include predefined template / module / service',
type: 'checkbox',
choices: [
{
name: 'home module / router module / interceptor',
value: 'home',
checked: true
}
]
}];
},
{
name: 'includeTemplate',
message: 'Include predefined template / module / service',
type: 'checkbox',
choices: [
{
name: 'home module / router module / interceptor',
value: 'home',
checked: true
}
]
}];

return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
Expand All @@ -94,17 +95,17 @@ module.exports = class extends Generator {
// console.log(this.props);
var startCommand = ' ';
this.props.newoptions.map(item => {
switch(item) {
switch (item) {
case 'style':
item = 'style="scss"';
break;
case 'prefix':
item = 'prefix=' + this.props.projectname.toLowerCase();
break;
default:
item = item + '="true"'
};
startCommand = startCommand + ' --' + item
item = item + '="true"';
}
startCommand = startCommand + ' --' + item;
});
log(chalk.blue(startCommand));

Expand Down Expand Up @@ -144,6 +145,13 @@ module.exports = class extends Generator {
shell.exec('cp -R ng-home/environments ./' + this.props.projectname + '/src');
// // Remove template
shell.exec('rm -rf ng-home');
replace({
regex: `"component": {}`,
replacement: `"component": { "spec": false, "changeDetection": "OnPush" }`,
paths: [this.props.projectname + '/.angular-cli.json'],
recursive: true,
silent: true
});
}

// Run NG serve
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-ng-itobuz",
"version": "0.0.4",
"version": "0.0.5",
"description": "Create angular project with new way and maintain same structure for all projects",
"homepage": "http://itobuz.com",
"author": {
Expand Down Expand Up @@ -32,11 +32,12 @@
},
"dependencies": {
"chalk": "^1.1.3",
"replace": "^0.3.0",
"shell": "^0.3.2",
"shelljs": "^0.7.8",
"update-notifier": "^2.2.0",
"yeoman-generator": "^1.0.0",
"yosay": "^2.0.0",
"update-notifier": "^2.2.0"
"yosay": "^2.0.0"
},
"jest": {
"testEnvironment": "node"
Expand Down

0 comments on commit fa5fd72

Please sign in to comment.