Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

Commit

Permalink
Update to v1 of yeoman-generator
Browse files Browse the repository at this point in the history
This required a major overhaul of the entirety of the generator,
including running Prettier over it as well.
  • Loading branch information
sondr3 committed May 2, 2017
1 parent 49973a0 commit 7f153ff
Show file tree
Hide file tree
Showing 17 changed files with 376 additions and 209 deletions.
3 changes: 1 addition & 2 deletions generators/app/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ beforeAll(() => {
authorName: 'Ola Nordmann',
authorEmail: 'ola.nordmann@gmail.com'
})
.withOptions({ 'skip-install': true })
.toPromise();
.withOptions({ 'skip-install': true });
});

test('generates expected files', () => {
Expand Down
86 changes: 29 additions & 57 deletions generators/app/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';
var generators = require('yeoman-generator');
var _ = require('lodash');
const Generator = require('yeoman-generator');
const _ = require('lodash');

module.exports = generators.Base.extend({
constructor: function() {
generators.Base.apply(this, arguments);
module.exports = class extends Generator {
constructor(args, options) {
super(args, options);

this.option('babel', {
type: Boolean,
Expand All @@ -23,14 +23,14 @@ module.exports = generators.Base.extend({
requred: true,
desc: 'Gulp tasks to build your site with your static site generator'
});
},
}

initializing: function() {
initializing() {
this.props = {};
this.pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
},
}

prompting: function() {
prompting() {
var questions = [
{
name: 'projectName',
Expand Down Expand Up @@ -77,9 +77,9 @@ module.exports = generators.Base.extend({
this.props = props;
}.bind(this)
);
},
}

writing: function() {
writing() {
var pkgJSONFields = {
name: _.kebabCase(this.props.projectName),
version: '0.0.0',
Expand All @@ -92,56 +92,28 @@ module.exports = generators.Base.extend({
};

this.fs.writeJSON('package.json', _.extend(pkgJSONFields, this.pkg));
},
}

default: function() {
this.composeWith(
'statisk:editorconfig',
{},
{
local: require.resolve('../editorconfig')
}
);
default() {
this.composeWith(require.resolve('../editorconfig'));

this.composeWith(
'statisk:git',
{},
{
local: require.resolve('../git')
}
);
this.composeWith(require.resolve('../git'));

this.composeWith(
'statisk:gulp',
{
options: {
uploading: this.props.uploading,
babel: this.props.babel
}
},
{
local: require.resolve('../gulp')
}
);
// this.composeWith(require.resolve('../gulp'), {
// uploading: this.props.uploading,
// babel: this.props.babel
// });

this.composeWith(
'statisk:readme',
{
options: {
projectName: this.props.projectName,
projectDescription: this.props.projectDescription,
projectURL: this.props.projectURL,
authorName: this.props.authorName,
content: this.options.readme
}
},
{
local: require.resolve('../readme')
}
);
},
this.composeWith(require.resolve('../readme'), {
projectName: this.props.projectName,
projectDescription: this.props.projectDescription,
projectURL: this.props.projectURL,
authorName: this.props.authorName,
content: this.options.readme
});
}

install: function() {
install() {
this.installDependencies({ bower: false });
}
});
};
3 changes: 1 addition & 2 deletions generators/editorconfig/editorconfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var helpers = require('yeoman-test');
beforeAll(() => {
return helpers
.run(path.join(__dirname, '.'))
.withOptions({ 'skip-install': true })
.toPromise();
.withOptions({ 'skip-install': true });
});

test('generates expected files', () => {
Expand Down
8 changes: 4 additions & 4 deletions generators/editorconfig/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

var generators = require('yeoman-generator');
const Generator = require('yeoman-generator');

module.exports = generators.Base.extend({
configuring: function() {
module.exports = class extends Generator {
configuring() {
this.fs.copy(
this.templatePath('editorconfig'),
this.destinationPath('.editorconfig')
);
}
});
};
3 changes: 1 addition & 2 deletions generators/git/git.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var helpers = require('yeoman-test');
beforeAll(() => {
return helpers
.run(path.join(__dirname, '.'))
.withOptions({ 'skip-install': true })
.toPromise();
.withOptions({ 'skip-install': true });
});

test('generates expected files', () => {
Expand Down
12 changes: 6 additions & 6 deletions generators/git/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

var generators = require('yeoman-generator');
const Generator = require('yeoman-generator');

module.exports = generators.Base.extend({
configuring: function() {
module.exports = class extends Generator {
configuring() {
this.fs.copy(
this.templatePath('gitattributes'),
this.destinationPath('.gitattributes')
Expand All @@ -13,11 +13,11 @@ module.exports = generators.Base.extend({
this.templatePath('gitignore'),
this.destinationPath('.gitignore')
);
},
}

end: function() {
end() {
this.spawnCommandSync('git', ['init', '--quiet'], {
cwd: this.destinationPath()
});
}
});
};
3 changes: 1 addition & 2 deletions generators/gulp/aws.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var helpers = require('yeoman-test');
beforeAll(() => {
return helpers
.run(path.join(__dirname, '.'))
.withOptions({ uploading: 'Amazon S3' })
.toPromise();
.withOptions({ uploading: 'Amazon S3' });
});

test('creates gulpfile', () => {
Expand Down
13 changes: 5 additions & 8 deletions generators/gulp/babel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ var assert = require('yeoman-assert');
var helpers = require('yeoman-test');

beforeAll(() => {
return helpers
.run(path.join(__dirname, '.'))
.withOptions({
'skip-install': true,
uploading: 'None',
babel: true
})
.toPromise();
return helpers.run(path.join(__dirname, '.')).withOptions({
'skip-install': true,
uploading: 'None',
babel: true
});
});

test('creates gulpfile.js', () => {
Expand Down
3 changes: 1 addition & 2 deletions generators/gulp/ghpages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var helpers = require('yeoman-test');
beforeAll(() => {
return helpers
.run(path.join(__dirname, '.'))
.withOptions({ uploading: 'Github Pages' })
.toPromise();
.withOptions({ uploading: 'Github Pages' });
});

test('creates gulpfile', () => {
Expand Down
17 changes: 7 additions & 10 deletions generators/gulp/gulp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ var helpers = require('yeoman-test');
beforeAll(() => {
const pkg = require('../../package.json');

return helpers
.run(path.join(__dirname, '.'))
.withOptions({
name: pkg.name,
version: pkg.version,
'skip-install': true,
uploading: 'None',
babel: false
})
.toPromise();
return helpers.run(path.join(__dirname, '.')).withOptions({
name: pkg.name,
version: pkg.version,
'skip-install': true,
uploading: 'None',
babel: false
});
});

test('creates gulpfile', () => {
Expand Down
Loading

0 comments on commit 7f153ff

Please sign in to comment.