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

Commit

Permalink
Fix #3: Storing configuration to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
Wtower committed Dec 25, 2016
1 parent ed8b095 commit 7f00adb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The generator creates a new project with:
and main urls routes.
- An additional 'core' python package for specifying application information, use signals and template tags.
- Default media, private and templates directories.
- A `.yo-rc.json` local yeoman configuration file with the options used to generate the project.

Prompts
-------
Expand Down
22 changes: 16 additions & 6 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,38 @@ module.exports = yeoman.Base.extend({
name: 'name',
message: 'Project name',
default: function () {
return lodash.snakeCase(self.appname);
return self.config.get('name') || lodash.snakeCase(self.appname);
}
}, {
// _name__core/ apps.py, tests.py
type: 'input',
name: 'pascalName',
message: 'Pascal name',
default: function (response) {
return lodash.upperFirst(lodash.camelCase(response.name));
return self.config.get('pascalName') || lodash.upperFirst(lodash.camelCase(response.name));
}
}, {
// _name_/settings.py, _name__core/apps.py
type: 'input',
name: 'verboseName',
message: 'Verbose name',
default: function (response) {
return lodash.startCase(response.name);
return self.config.get('verboseName') || lodash.startCase(response.name);
}
}, {
// README.md, package.json, _name_/settings.py
type: 'input',
name: 'description',
message: 'Description',
default: function (response) {
return lodash.startCase(response.name);
return self.config.get('description') || lodash.startCase(response.name);
}
}, {
// package.json
type: 'input',
name: 'git',
message: 'Git repository URL'
message: 'Git repository URL',
default: self.config.get('git')
}, {
// package.json, LICENSE, CONTRIBUTING.md
type: 'input',
Expand All @@ -69,7 +70,7 @@ module.exports = yeoman.Base.extend({
name: 'allowedHost',
message: 'Allowed host',
default: function (response) {
return response.name + '.com';
return self.config.get('allowedHost') || response.name + '.com';
}
}, {
// newrelic.ini
Expand All @@ -84,6 +85,15 @@ module.exports = yeoman.Base.extend({
}.bind(this));
},

saveConfig: function () {
this.config.set('name', this.props.name);
this.config.set('pascalName', this.props.pascalName);
this.config.set('verboseName', this.props.verboseName);
this.config.set('description', this.props.description);
this.config.set('git', this.props.git);
this.config.set('allowedHost', this.props.allowedHost);
},

writing: function () {
var templatePaths = [
'_name_/',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-django-ana",
"version": "0.1.1",
"version": "0.1.3",
"description": "Generate Django boilerplate. Featuring REST, gulp build and ng-gentelella.",
"homepage": "https://github.com/Wtower/generator-django-ana.git",
"author": {
Expand Down
3 changes: 2 additions & 1 deletion test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe('generator-django-ana:app', function () {
'manage.py',
'newrelic.ini',
'package.json',
'README.md'
'README.md',
'.yo-rc.json'
];
var copyPaths = [
'media/',
Expand Down

0 comments on commit 7f00adb

Please sign in to comment.