Skip to content

Commit b64d4e2

Browse files
committed
Closes #43
1 parent 6dfc6a3 commit b64d4e2

File tree

4 files changed

+73
-32
lines changed

4 files changed

+73
-32
lines changed

generators/app/index.js

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,28 @@ const _ = require('lodash');
77
const shelljs = require('shelljs');
88

99
module.exports = Generator.extend({
10-
initializing: function () {
10+
initializing: function() {
1111
const done = this.async();
1212

1313
// Have Yeoman greet the user.
14-
this.log(yosay(
15-
'Welcome to the minimal ' + chalk.red('Node TypeScript') + ' generator!'
16-
));
17-
1814
this.log(
19-
chalk.cyan('I simply get down to business of generating, no questions asked!')
20-
+ '\n'
21-
+ chalk.yellow('Libraries you ask? I use npm as task runner and jest for testing.')
22-
+ '\n'
23-
+ chalk.gray('Can you change these? Of course, it\'s your code. I get out of the way after scaffolding.')
15+
yosay(
16+
'Welcome to the minimal ' + chalk.red('Node TypeScript') + ' generator!'
17+
)
18+
);
19+
20+
this.log(
21+
chalk.cyan(
22+
'I simply get down to business of generating, no questions asked!'
23+
) +
24+
'\n' +
25+
chalk.yellow(
26+
'Libraries you ask? I use npm as task runner and jest for testing.'
27+
) +
28+
'\n' +
29+
chalk.gray(
30+
'Can you change these? Of course, it\'s your code. I get out of the way after scaffolding.'
31+
)
2432
);
2533

2634
this.composeWith(
@@ -36,8 +44,7 @@ module.exports = Generator.extend({
3644
},
3745

3846
writing: {
39-
40-
vsCodeFiles: function () {
47+
vsCodeFiles: function() {
4148
this.fs.copy(
4249
this.templatePath('_vscode/tasks.json'),
4350
this.destinationPath('.vscode/tasks.json')
@@ -46,18 +53,20 @@ module.exports = Generator.extend({
4653
this.templatePath('_vscode/settings.json'),
4754
this.destinationPath('.vscode/settings.json')
4855
);
49-
if (!(this.options.mocha || this.options.ava)) { // copy launch.json only for default jest configuration
56+
if (!(this.options.mocha || this.options.ava)) {
57+
// copy launch.json only for default jest configuration
5058
this.fs.copy(
5159
this.templatePath('_vscode/launch.json'),
5260
this.destinationPath('.vscode/launch.json')
5361
);
5462
}
5563
},
5664

57-
rootFiles: function () {
65+
rootFiles: function() {
5866
const today = new Date();
5967

60-
if (this.options.mocha) { // copy mocha files
68+
if (this.options.mocha) {
69+
// copy mocha files
6170
this.fs.copyTpl(
6271
this.templatePath('_package_mocha.json'),
6372
this.destinationPath('package.json'),
@@ -67,7 +76,8 @@ module.exports = Generator.extend({
6776
this.templatePath('travis_mocha.yml'),
6877
this.destinationPath('.travis.yml')
6978
);
70-
} else if (this.options.ava) { // copy ava files
79+
} else if (this.options.ava) {
80+
// copy ava files
7181
this.fs.copyTpl(
7282
this.templatePath('_package_ava.json'),
7383
this.destinationPath('package.json'),
@@ -81,7 +91,8 @@ module.exports = Generator.extend({
8191
this.templatePath('_tsconfig.test.json'),
8292
this.destinationPath('tsconfig.test.json')
8393
);
84-
} else { // copy files for default jest configuration
94+
} else {
95+
// copy files for default jest configuration
8596
this.fs.copyTpl(
8697
this.templatePath('_package.json'),
8798
this.destinationPath('package.json'),
@@ -113,6 +124,10 @@ module.exports = Generator.extend({
113124
this.templatePath('gitignore'),
114125
this.destinationPath('.gitignore')
115126
);
127+
this.fs.copy(
128+
this.templatePath('npmignore'),
129+
this.destinationPath('.npmignore')
130+
);
116131
this.fs.copyTpl(
117132
this.templatePath('LICENSE'),
118133
this.destinationPath('LICENSE'),
@@ -122,12 +137,14 @@ module.exports = Generator.extend({
122137
},
123138

124139
install: {
125-
npmInstall: function () {
140+
npmInstall: function() {
126141
const generator = this;
127142
if (shelljs.which('yarn')) {
128143
generator.yarnInstall();
129144
} else {
130-
generator.npmInstall(null, { skipInstall: this.options['skip-install'] });
145+
generator.npmInstall(null, {
146+
skipInstall: this.options['skip-install']
147+
});
131148
}
132149
}
133150
}

generators/app/templates/gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
coverage/
22
node_modules/
3-
npm-debug.log
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
46
.nyc_output
57
lib
68
lib_test

generators/app/templates/npmignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# gitignore
2+
3+
coverage/
4+
node_modules/
5+
npm-debug.log*
6+
yarn-debug.log*
7+
yarn-error.log*
8+
.nyc_output
9+
lib
10+
lib_test
11+
12+
# npmignore
13+
14+
src/
15+
__tests__/
16+
.vscode/

test/test-app.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ const path = require('path');
55
const assert = require('yeoman-assert');
66
const helpers = require('yeoman-test');
77

8-
describe('node-typescript:app with mocha', function () {
9-
before(function (done) {
10-
helpers.run(path.join(__dirname, '../generators/app'))
8+
describe('node-typescript:app with mocha', function() {
9+
before(function(done) {
10+
helpers
11+
.run(path.join(__dirname, '../generators/app'))
1112
.withOptions({
1213
skipInstall: true,
1314
mocha: true
1415
})
1516
.on('end', done);
1617
});
1718

18-
it('creates project files', function () {
19+
it('creates project files', function() {
1920
assert.file([
2021
'.vscode/tasks.json',
2122
'.vscode/settings.json',
@@ -29,23 +30,25 @@ describe('node-typescript:app with mocha', function () {
2930
'.travis.yml',
3031
'.editorconfig',
3132
'.gitignore',
33+
'.npmignore',
3234
'LICENSE',
3335
'README.md'
3436
]);
3537
});
3638
});
3739

38-
describe('node-typescript:app with ava', function () {
39-
before(function (done) {
40-
helpers.run(path.join(__dirname, '../generators/app'))
40+
describe('node-typescript:app with ava', function() {
41+
before(function(done) {
42+
helpers
43+
.run(path.join(__dirname, '../generators/app'))
4144
.withOptions({
4245
skipInstall: true,
4346
ava: true
4447
})
4548
.on('end', done);
4649
});
4750

48-
it('creates project files', function () {
51+
it('creates project files', function() {
4952
assert.file([
5053
'.vscode/tasks.json',
5154
'.vscode/settings.json',
@@ -60,22 +63,24 @@ describe('node-typescript:app with ava', function () {
6063
'.travis.yml',
6164
'.editorconfig',
6265
'.gitignore',
66+
'.npmignore',
6367
'LICENSE',
6468
'README.md'
6569
]);
6670
});
6771
});
6872

69-
describe('node-typescript:app with jest - default configuration', function () {
70-
before(function (done) {
71-
helpers.run(path.join(__dirname, '../generators/app'))
73+
describe('node-typescript:app with jest - default configuration', function() {
74+
before(function(done) {
75+
helpers
76+
.run(path.join(__dirname, '../generators/app'))
7277
.withOptions({
7378
skipInstall: true
7479
})
7580
.on('end', done);
7681
});
7782

78-
it('creates project files', function () {
83+
it('creates project files', function() {
7984
assert.file([
8085
'.vscode/tasks.json',
8186
'.vscode/settings.json',
@@ -90,6 +95,7 @@ describe('node-typescript:app with jest - default configuration', function () {
9095
'.travis.yml',
9196
'.editorconfig',
9297
'.gitignore',
98+
'.npmignore',
9399
'LICENSE',
94100
'README.md'
95101
]);

0 commit comments

Comments
 (0)