generator-mnm 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -14
- package/generators/app/index.js +7 -7
- package/generators/base.js +17 -0
- package/generators/cli/index.js +1 -1
- package/generators/src/index.js +25 -16
- package/generators/src/templates/rollup.config.tpl +19 -0
- package/generators/test/index.js +4 -8
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="https://cloud.githubusercontent.com/assets/1616682/11403449/409e561e-9373-11e5-9aeb-7dbea090a0bd.gif" width="400px" />
|
|
3
3
|
|
|
4
4
|
<p>
|
|
5
|
-
Create node modules writing ES6 today compiled with Babel, tested with ava and linted with standard on top of npm scripts
|
|
5
|
+
Create node modules writing ES6/ES7 today compiled with Babel, tested with ava, bundled with rollup and linted with standard on top of npm scripts
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p>
|
|
@@ -37,7 +37,7 @@ Options:
|
|
|
37
37
|
--skip-cache # Do not remember prompt answers Default: false
|
|
38
38
|
--skip-install # Do not automatically install dependencies Default: false
|
|
39
39
|
-a, --all # Ask all questions Default: false
|
|
40
|
-
-y, --yes # Skip some questions, like $ npm init -y
|
|
40
|
+
-y, --yes # Skip some questions, like $ npm init -y Default: false
|
|
41
41
|
|
|
42
42
|
Arguments:
|
|
43
43
|
name # module name
|
|
@@ -63,17 +63,18 @@ $ yo mnm -y
|
|
|
63
63
|
create test/index.js
|
|
64
64
|
create .travis.yml
|
|
65
65
|
create .babelrc
|
|
66
|
+
create rollup.config.js
|
|
66
67
|
```
|
|
67
68
|
|
|
68
69
|
## Features
|
|
69
70
|
|
|
70
71
|
- Made out of many other generators, the main generator only creates a [`package.json` file](https://github.com/maurizzzio/generator-mnm/blob/master/generators/app/index.js#L225-L240) and a [minimal `.gitignore` file](https://github.com/maurizzzio/generator-mnm/blob/master/generators/app/index.js#L246-L248)
|
|
71
|
-
- Composable, since the logic to create the README, cli and other files is
|
|
72
|
-
- [Babel](https://babeljs.io)
|
|
72
|
+
- Composable, since the logic to create the README, cli and other files is on their own subgenerator
|
|
73
|
+
- [Babel](https://babeljs.io) transpiles the code/tests
|
|
73
74
|
- [standard](http://standardjs.com/) to lint the code
|
|
74
75
|
- [ava](https://github.com/sindresorhus/ava) for testing
|
|
75
76
|
- [yargs](https://github.com/bcoe/yargs) to parse cli arguments (optional)
|
|
76
|
-
- [
|
|
77
|
+
- [rollup](https://github.com/rollup/rollup) to create a common js compatible bundle
|
|
77
78
|
- npm scripts as the build system
|
|
78
79
|
|
|
79
80
|
## Example
|
|
@@ -87,7 +88,7 @@ Common tasks
|
|
|
87
88
|
| task | description |
|
|
88
89
|
| ----- | --- |
|
|
89
90
|
| `npm test` | `ava` |
|
|
90
|
-
| `npm run build` | `
|
|
91
|
+
| `npm run build` | `rollup --config`|
|
|
91
92
|
| `npm run lint` | `standard` |
|
|
92
93
|
| `npm run clean` | Removes all the files inside `dist/`|
|
|
93
94
|
|
|
@@ -132,11 +133,11 @@ This project is heavily inspired by [this article by Keith Cirkel][stop-using-gr
|
|
|
132
133
|
- https://github.com/iamstarkov/generator-zen
|
|
133
134
|
- https://github.com/keithamus/npm-scripts-example 's awesome `package.json` file
|
|
134
135
|
|
|
135
|
-
I'd like to thank [iamstarkov](https://github.com/iamstarkov) for his awesome
|
|
136
|
+
I'd like to thank [iamstarkov](https://github.com/iamstarkov) for his awesome work on generators that are actually composable
|
|
136
137
|
|
|
137
138
|
## Composability
|
|
138
139
|
|
|
139
|
-
Just plug in any of the subgenerators or the generator itself on your generator
|
|
140
|
+
Just plug in any of the subgenerators or the `app` generator itself on your generator
|
|
140
141
|
|
|
141
142
|
<div align="center">
|
|
142
143
|
<img src="https://camo.githubusercontent.com/f8dc3e07d956f1f8dbdea5f895800fe53772a50d/687474703a2f2f692e696d6775722e636f6d2f326771696966742e6a7067">
|
|
@@ -145,7 +146,6 @@ Just plug in any of the subgenerators or the generator itself on your generator
|
|
|
145
146
|
Generators used in this project
|
|
146
147
|
|
|
147
148
|
- [generator-babel](https://github.com/iamstarkov/generator-babel)
|
|
148
|
-
- [generator-travis](https://github.com/iamstarkov/generator-travis)
|
|
149
149
|
- [generator-git-init](https://github.com/iamstarkov/generator-git-init)
|
|
150
150
|
- [generator-license](https://github.com/jozefizso/generator-license)
|
|
151
151
|
- [generator-mnm/generators/src](./generators/src)
|
|
@@ -153,17 +153,15 @@ Generators used in this project
|
|
|
153
153
|
- [generator-mnm/generators/cli](./generators/cli)
|
|
154
154
|
- [generator-mnm/generators/readme](./generators/readme)
|
|
155
155
|
|
|
156
|
-
Refer to their README files on how to include it your generators
|
|
157
|
-
|
|
158
156
|
## Workflow
|
|
159
157
|
|
|
160
158
|
```sh
|
|
161
159
|
# equivalent to npm init -y
|
|
162
160
|
yo mnm -y
|
|
163
161
|
# see https://www.npmjs.com/package/ghrepo
|
|
164
|
-
ghrepo -m "
|
|
162
|
+
ghrepo -m "initial commit"
|
|
165
163
|
# see https://www.npmjs.com/package/travisjs
|
|
166
|
-
travisjs hook
|
|
164
|
+
travisjs hook # or travis enable with the travis gem
|
|
167
165
|
|
|
168
166
|
# if a cli is needed
|
|
169
167
|
yo mnm:cli
|
|
@@ -171,7 +169,8 @@ yo mnm:cli
|
|
|
171
169
|
|
|
172
170
|
## Development
|
|
173
171
|
|
|
174
|
-
- `npm test
|
|
172
|
+
- `npm test`
|
|
173
|
+
- `npm test:ci` run the tests (open `./test/ci/.tmp` to see a generated)
|
|
175
174
|
|
|
176
175
|
## License
|
|
177
176
|
|
package/generators/app/index.js
CHANGED
|
@@ -232,11 +232,13 @@ module.exports = Base.extend({
|
|
|
232
232
|
email: this.props.email,
|
|
233
233
|
url: this.props.website
|
|
234
234
|
},
|
|
235
|
-
main: this.props.dist + '
|
|
236
|
-
|
|
235
|
+
main: this.props.dist + this.props.moduleName + '.js',
|
|
236
|
+
module: this.props.dist + this.props.moduleName + '.mjs',
|
|
237
|
+
'jsnext:main': this.props.dist + this.props.moduleName + '.mjs',
|
|
237
238
|
keywords: this.props.moduleKeywords,
|
|
238
239
|
repository: this.props.githubUsername + '/' + this.props.moduleName,
|
|
239
|
-
scripts: {}
|
|
240
|
+
scripts: {},
|
|
241
|
+
dependencies: {}
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
// Let's extend package.json so we're not overwriting user previous fields
|
|
@@ -249,8 +251,6 @@ module.exports = Base.extend({
|
|
|
249
251
|
},
|
|
250
252
|
|
|
251
253
|
default: function () {
|
|
252
|
-
// TODO: compose with mnm:rollup
|
|
253
|
-
|
|
254
254
|
// git init
|
|
255
255
|
this.composeWith('git-init', {}, {
|
|
256
256
|
local: require.resolve('generator-git-init/generators/app')
|
|
@@ -267,10 +267,10 @@ module.exports = Base.extend({
|
|
|
267
267
|
|
|
268
268
|
this.composeWith('mnm:test', {
|
|
269
269
|
options: {
|
|
270
|
-
'skip-install': this.options['skip-install'],
|
|
271
270
|
src: this.props.src,
|
|
272
271
|
test: this.props.test,
|
|
273
|
-
coverage: this.props.coverage
|
|
272
|
+
coverage: this.props.coverage,
|
|
273
|
+
'skip-install': this.options['skip-install']
|
|
274
274
|
}
|
|
275
275
|
}, { local: require.resolve('../test') })
|
|
276
276
|
|
package/generators/base.js
CHANGED
|
@@ -2,6 +2,7 @@ var yeoman = require('yeoman-generator')
|
|
|
2
2
|
var extend = require('extend')
|
|
3
3
|
var sortedObject = require('sorted-object')
|
|
4
4
|
var depsObject = require('deps-object')
|
|
5
|
+
var yaml = require('yamljs')
|
|
5
6
|
|
|
6
7
|
module.exports = yeoman.Base.extend({
|
|
7
8
|
_saveDepsToPkg: function (deps) {
|
|
@@ -21,6 +22,22 @@ module.exports = yeoman.Base.extend({
|
|
|
21
22
|
.catch(function (err) { throw err })
|
|
22
23
|
},
|
|
23
24
|
|
|
25
|
+
_travis: function (additional) {
|
|
26
|
+
var travisPath = this.destinationPath('.travis.yml')
|
|
27
|
+
var existing = this.fs.exists(travisPath)
|
|
28
|
+
? yaml.parse(this.fs.read(travisPath))
|
|
29
|
+
: {}
|
|
30
|
+
var result = Object.assign({
|
|
31
|
+
language: 'node_js',
|
|
32
|
+
node_js: ['stable']
|
|
33
|
+
}, existing, additional)
|
|
34
|
+
|
|
35
|
+
this.fs.write(
|
|
36
|
+
this.destinationPath('.travis.yml'),
|
|
37
|
+
yaml.stringify(result, 3, 2)
|
|
38
|
+
)
|
|
39
|
+
},
|
|
40
|
+
|
|
24
41
|
_gitignore: function (ignores) {
|
|
25
42
|
var giPath = this.destinationPath('.gitignore')
|
|
26
43
|
var file = this.fs.read(giPath, { defaults: '' })
|
package/generators/cli/index.js
CHANGED
package/generators/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
var path = require('path')
|
|
3
|
+
var toCase = require('to-case')
|
|
3
4
|
|
|
4
5
|
var Base = require('../base')
|
|
5
6
|
|
|
@@ -29,14 +30,13 @@ module.exports = Base.extend({
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {})
|
|
32
|
-
|
|
33
|
-
var srcPath = path.join(this.options.src, 'index.js')
|
|
34
|
-
var buildScript = 'babel ' + srcPath + ' --out-file ' + distPath
|
|
33
|
+
|
|
35
34
|
var scripts = pkg.scripts || {}
|
|
36
35
|
setTask('clean', 'rimraf ' + this.options.dist + ' && mkdirp ' + this.options.dist)
|
|
37
36
|
setTask('lint', 'standard')
|
|
37
|
+
setTask('changelog', 'conventional-changelog -p eslint -i CHANGELOG.md -s -r 0')
|
|
38
38
|
setTask('prebuild', 'npm run clean -s && npm run lint -s')
|
|
39
|
-
setTask('build',
|
|
39
|
+
setTask('build', 'rollup --config')
|
|
40
40
|
setTask('build:watch', 'npm run build -- --watch')
|
|
41
41
|
// instead of runnning this on prepublish which doesn't work as expecte on
|
|
42
42
|
// npm@3 run it on preversion, this is because it's highly unlikely to do
|
|
@@ -64,17 +64,31 @@ module.exports = Base.extend({
|
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
pkgDeps: function () {
|
|
67
|
-
return this._saveDeps([
|
|
67
|
+
return this._saveDeps([
|
|
68
|
+
'rimraf', 'mkdirp', 'standard', 'conventional-changelog',
|
|
69
|
+
'rollup', 'rollup-plugin-babel', 'rollup-watch', 'babelrc-rollup'
|
|
70
|
+
])
|
|
68
71
|
},
|
|
69
72
|
|
|
70
73
|
templates: function () {
|
|
74
|
+
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {})
|
|
71
75
|
var srcPath = path.join(this.options.src, 'index.js')
|
|
72
76
|
|
|
73
|
-
// copy
|
|
77
|
+
// copy index.tpl as srcPath
|
|
78
|
+
// e.g. src/index.js
|
|
74
79
|
this.fs.copyTpl(
|
|
75
80
|
this.templatePath('index.tpl'),
|
|
76
81
|
this.destinationPath(srcPath), {}
|
|
77
82
|
)
|
|
83
|
+
|
|
84
|
+
// copy rollup.config.tpl to rollup.config.js
|
|
85
|
+
this.fs.copyTpl(
|
|
86
|
+
this.templatePath('rollup.config.tpl'),
|
|
87
|
+
this.destinationPath('rollup.config.js'), {
|
|
88
|
+
srcPath: srcPath,
|
|
89
|
+
moduleName: toCase.camel(pkg.name || this.appname)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
78
92
|
},
|
|
79
93
|
|
|
80
94
|
gitignore: function () {
|
|
@@ -83,21 +97,16 @@ module.exports = Base.extend({
|
|
|
83
97
|
},
|
|
84
98
|
|
|
85
99
|
default: function () {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
script: 'npm run build'
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}, { local: require.resolve('generator-travis/generators/app') })
|
|
100
|
+
// using my own .travis generator because the other one force defaults
|
|
101
|
+
this._travis({
|
|
102
|
+
script: 'npm run build'
|
|
103
|
+
})
|
|
94
104
|
|
|
95
105
|
this.composeWith('babel', {
|
|
96
106
|
options: {
|
|
97
107
|
'skip-install': this.options['skip-install'],
|
|
98
108
|
config: {
|
|
99
|
-
plugins: ['
|
|
100
|
-
sourceMaps: true
|
|
109
|
+
plugins: ['external-helpers']
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
}, { local: require.resolve('generator-babel/generators/app') })
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import babel from 'rollup-plugin-babel'
|
|
2
|
+
import babelrc from 'babelrc-rollup'
|
|
3
|
+
|
|
4
|
+
let pkg = require('./package.json')
|
|
5
|
+
let external = Object.keys(pkg.dependencies)
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
entry: '<%= srcPath %>',
|
|
9
|
+
plugins: [ babel(babelrc()) ],
|
|
10
|
+
external: external,
|
|
11
|
+
targets: [{
|
|
12
|
+
dest: pkg['main'],
|
|
13
|
+
format: 'cjs'
|
|
14
|
+
}, {
|
|
15
|
+
dest: pkg['jsnext:main'],
|
|
16
|
+
format: 'es'
|
|
17
|
+
}]
|
|
18
|
+
}
|
|
19
|
+
|
package/generators/test/index.js
CHANGED
|
@@ -85,14 +85,10 @@ module.exports = Base.extend({
|
|
|
85
85
|
|
|
86
86
|
default: function () {
|
|
87
87
|
if (this.options.coverage) {
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
after_success: 'npm run coverage'
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, { local: require.resolve('generator-travis/generators/app') })
|
|
88
|
+
this._travis({
|
|
89
|
+
before_install: 'npm install codecov && npm install nyc',
|
|
90
|
+
after_success: 'npm run coverage'
|
|
91
|
+
})
|
|
96
92
|
}
|
|
97
93
|
},
|
|
98
94
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-mnm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Create node modules writing ES6 today compiled with Babel, tested with ava and linted with standard on top of npm scripts Create node modules with es6, test with tape on top of npm scripts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
7
|
-
"repository": "
|
|
8
|
-
"author":
|
|
9
|
-
"name": "Mauricio Poppe",
|
|
10
|
-
"email": "mauricio.poppe@gmail.com",
|
|
11
|
-
"url": "https://github.com/maurizzzio"
|
|
12
|
-
},
|
|
7
|
+
"repository": "mauriciopoppe/generator-mnm",
|
|
8
|
+
"author": "Mauricio Poppe (https://mauriciopoppe.com)",
|
|
13
9
|
"engines": {
|
|
14
10
|
"node": ">=4"
|
|
15
11
|
},
|
|
@@ -44,7 +40,6 @@
|
|
|
44
40
|
"generator-babel": "^2.0.2",
|
|
45
41
|
"generator-git-init": "^1.0.4",
|
|
46
42
|
"generator-license": "^3.1.1",
|
|
47
|
-
"generator-travis": "^1.2.2",
|
|
48
43
|
"github-username": "^2.1.0",
|
|
49
44
|
"is-url": "^1.2.1",
|
|
50
45
|
"mkdirp": "^0.5.1",
|
|
@@ -53,6 +48,7 @@
|
|
|
53
48
|
"relative": "^3.0.2",
|
|
54
49
|
"sorted-object": "^2.0.0",
|
|
55
50
|
"to-case": "^2.0.0",
|
|
51
|
+
"yamljs": "^0.2.8",
|
|
56
52
|
"yeoman-generator": "^0.22.6"
|
|
57
53
|
},
|
|
58
54
|
"devDependencies": {
|