use node-compat-require instead of webpack for node >= 4 support; update dependencies
This commit is contained in:
parent
fa8df25694
commit
dd83df8f4e
10 changed files with 1327 additions and 10673 deletions
|
@ -1,8 +1,7 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
|
cache: yarn
|
||||||
node_js:
|
node_js:
|
||||||
- 9
|
- 9
|
||||||
- 8
|
- 8
|
||||||
cache:
|
- 6
|
||||||
yarn: true
|
- 4
|
||||||
directories:
|
|
||||||
- node_modules
|
|
||||||
|
|
|
@ -1,52 +1,5 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
require('util.promisify/shim')()
|
const compatRequire = require('node-compat-require')
|
||||||
|
compatRequire('./lib', { node: '>= 8' })
|
||||||
const meow = require('meow')
|
|
||||||
|
|
||||||
const getLibraryDefaults = require('./lib/get-library-defaults')
|
|
||||||
const createLibrary = require('./lib/create-library')
|
|
||||||
const promptLibraryInfo = require('./lib/prompt-library-info')
|
|
||||||
|
|
||||||
module.exports = async () => {
|
|
||||||
const defaults = await getLibraryDefaults()
|
|
||||||
const info = await promptLibraryInfo(defaults)
|
|
||||||
await createLibrary(info)
|
|
||||||
|
|
||||||
return info
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!module.parent) {
|
|
||||||
meow(`
|
|
||||||
Usage
|
|
||||||
$ create-react-library
|
|
||||||
`)
|
|
||||||
|
|
||||||
module.exports()
|
|
||||||
.then((info) => {
|
|
||||||
console.log(`
|
|
||||||
|
|
||||||
Your module has been created at ${info.dest}.
|
|
||||||
|
|
||||||
To get started, in one tab, run:
|
|
||||||
$ cd ${info.name} && ${info.manager} start
|
|
||||||
|
|
||||||
And in another tab, run the create-react-app devserver:
|
|
||||||
$ cd ${info.name}/example && ${info.manager} start
|
|
||||||
`)
|
|
||||||
|
|
||||||
if (info.manager === 'npm') {
|
|
||||||
console.log(`
|
|
||||||
|
|
||||||
Because you're using npm, you'll need to publish a dummy version of ${info.name} first before you can "npm link" your package into the example app.
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
|
@ -88,8 +88,6 @@ module.exports.initPackageManager = async (opts) => {
|
||||||
info
|
info
|
||||||
} = opts
|
} = opts
|
||||||
|
|
||||||
const example = path.join(dest, 'example')
|
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
cmd: `${info.manager} install`,
|
cmd: `${info.manager} install`,
|
||||||
|
@ -99,13 +97,7 @@ module.exports.initPackageManager = async (opts) => {
|
||||||
cmd: `${info.manager} link`,
|
cmd: `${info.manager} link`,
|
||||||
cwd: dest
|
cwd: dest
|
||||||
}
|
}
|
||||||
].concat(info.manager === 'yarn' ? [
|
]
|
||||||
{
|
|
||||||
cmd: `${info.manager}`,
|
|
||||||
cwd: example
|
|
||||||
}
|
|
||||||
] : [ ]
|
|
||||||
)
|
|
||||||
|
|
||||||
return pEachSeries(commands, async ({ cmd, cwd }) => {
|
return pEachSeries(commands, async ({ cmd, cwd }) => {
|
||||||
return execa.shell(cmd, { cwd })
|
return execa.shell(cmd, { cwd })
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const { test } = require('ava')
|
const { test } = require('ava')
|
||||||
const execa = require('execa')
|
const execa = require('execa')
|
||||||
|
const path = require('path')
|
||||||
const rmfr = require('rmfr')
|
const rmfr = require('rmfr')
|
||||||
|
|
||||||
const createLibrary = require('./create-library')
|
const createLibrary = require('./create-library')
|
||||||
|
@ -36,18 +37,26 @@ const tests = [
|
||||||
tests.forEach((info) => {
|
tests.forEach((info) => {
|
||||||
test.serial(`creating "${info.name}" using ${info.manager}`, async (t) => {
|
test.serial(`creating "${info.name}" using ${info.manager}`, async (t) => {
|
||||||
console.log(`creating "${info.name}" using ${info.manager}...`)
|
console.log(`creating "${info.name}" using ${info.manager}...`)
|
||||||
|
let ret
|
||||||
|
|
||||||
// ensure library is created successfully
|
// ensure library is created successfully
|
||||||
const root = await createLibrary(info)
|
const root = await createLibrary(info)
|
||||||
t.truthy(root.indexOf(info.shortName) >= 0)
|
t.truthy(root.indexOf(info.shortName) >= 0)
|
||||||
|
|
||||||
// ensure yarn runs successfully
|
// ensure yarn runs successfully in src/
|
||||||
let ret = await execa.shell('yarn', { cwd: root })
|
ret = await execa.shell('yarn', { cwd: root })
|
||||||
t.is(ret.code, 0)
|
t.is(ret.code, 0)
|
||||||
|
|
||||||
// ensure jest tests pass
|
// ensure jest tests pass
|
||||||
ret = await execa.shell('yarn test', { cwd: root })
|
ret = await execa.shell('yarn test', { cwd: root })
|
||||||
t.is(ret.code, 0)
|
t.is(ret.code, 0)
|
||||||
|
|
||||||
|
if (info.manager === 'yarn') {
|
||||||
|
// ensure yarn runs successfully in example/
|
||||||
|
ret = await execa.shell('yarn install', { cwd: path.join(root, 'example') })
|
||||||
|
t.is(ret.code, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// ensure git is initialized properly
|
// ensure git is initialized properly
|
||||||
ret = await execa.shell('git status', { cwd: root })
|
ret = await execa.shell('git status', { cwd: root })
|
||||||
t.is(ret.code, 0)
|
t.is(ret.code, 0)
|
||||||
|
|
48
packages/create-freesewing-pattern/lib/index.js
Normal file
48
packages/create-freesewing-pattern/lib/index.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const meow = require('meow')
|
||||||
|
|
||||||
|
const getLibraryDefaults = require('./get-library-defaults')
|
||||||
|
const createLibrary = require('./create-library')
|
||||||
|
const promptLibraryInfo = require('./prompt-library-info')
|
||||||
|
|
||||||
|
module.exports = async () => {
|
||||||
|
const defaults = await getLibraryDefaults()
|
||||||
|
const info = await promptLibraryInfo(defaults)
|
||||||
|
await createLibrary(info)
|
||||||
|
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
|
meow(`
|
||||||
|
Usage
|
||||||
|
$ create-react-library
|
||||||
|
`)
|
||||||
|
|
||||||
|
module.exports()
|
||||||
|
.then((info) => {
|
||||||
|
console.log(`
|
||||||
|
|
||||||
|
Your module has been created at ${info.dest}.
|
||||||
|
|
||||||
|
To get started, in one tab, run:
|
||||||
|
$ cd ${info.name} && ${info.manager} start
|
||||||
|
|
||||||
|
And in another tab, run the create-react-app devserver:
|
||||||
|
$ cd ${info.name}/example && ${info.manager} start
|
||||||
|
`)
|
||||||
|
|
||||||
|
if (info.manager === 'npm') {
|
||||||
|
console.log(`
|
||||||
|
|
||||||
|
Because you're using npm, you'll need to publish a dummy version of ${info.name} first before you can "npm link" your package into the example app.
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
9243
packages/create-freesewing-pattern/package-lock.json
generated
9243
packages/create-freesewing-pattern/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -4,20 +4,16 @@
|
||||||
"description": "CLI for easily bootstrapping modern react libraries",
|
"description": "CLI for easily bootstrapping modern react libraries",
|
||||||
"repository": "transitive-bullshit/create-react-library",
|
"repository": "transitive-bullshit/create-react-library",
|
||||||
"author": "Travis Fischer <travis@automagical.ai>",
|
"author": "Travis Fischer <travis@automagical.ai>",
|
||||||
"main": "dist/index.js",
|
"main": "index.js",
|
||||||
"module": "index.js",
|
|
||||||
"jsnext:main": "index.js",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"create-react-library": "index.js"
|
"create-react-library": "index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "ava -v && standard *.js lib/*.js",
|
"test": "ava -v && standard *.js lib/*.js"
|
||||||
"dev": "webpack -w",
|
|
||||||
"build": "webpack"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=4"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
@ -34,36 +30,24 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"conf": "^1.4.0",
|
"conf": "^1.4.0",
|
||||||
"cp-file": "^5.0.0",
|
"cp-file": "^5.0.0",
|
||||||
"execa": "^0.9.0",
|
"execa": "^0.10.0",
|
||||||
"git-config-path": "^1.0.1",
|
"git-config-path": "^1.0.1",
|
||||||
"github-username": "^4.1.0",
|
"github-username": "^4.1.0",
|
||||||
"globby": "^8.0.1",
|
"globby": "^8.0.1",
|
||||||
"handlebars": "^4.0.11",
|
"handlebars": "^4.0.11",
|
||||||
"inquirer": "^3",
|
"inquirer": "^5.2.0",
|
||||||
"make-dir": "^1.2.0",
|
"make-dir": "^1.2.0",
|
||||||
"meow": "^4.0.0",
|
"meow": "^5.0.0",
|
||||||
"ora": "^2.0.0",
|
"node-compat-require": "^1.0.3",
|
||||||
|
"ora": "^2.1.0",
|
||||||
"p-each-series": "^1.0.0",
|
"p-each-series": "^1.0.0",
|
||||||
"parse-git-config": "^2.0.0",
|
"parse-git-config": "^2.0.2",
|
||||||
"util.promisify": "^1.0.0",
|
|
||||||
"validate-npm-package-name": "^3.0.0",
|
"validate-npm-package-name": "^3.0.0",
|
||||||
"which": "^1.3.0"
|
"which": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ava": "^0.25.0",
|
"ava": "^0.25.0",
|
||||||
"babel-core": "6.26.0",
|
|
||||||
"babel-eslint": "8.0.1",
|
|
||||||
"babel-loader": "7.1.2",
|
|
||||||
"babel-plugin-transform-async-to-generator": "6.24.1",
|
|
||||||
"babel-plugin-transform-flow-comments": "6.22.0",
|
|
||||||
"babel-plugin-transform-runtime": "6.23.0",
|
|
||||||
"babel-preset-env": "1.6.0",
|
|
||||||
"babel-preset-stage-0": "^6.24.1",
|
|
||||||
"babel-runtime": "^6.26.0",
|
|
||||||
"rmfr": "^2.0.0",
|
"rmfr": "^2.0.0",
|
||||||
"shebang-loader": "0.0.1",
|
"standard": "^11.0.1"
|
||||||
"standard": "^11.0.0",
|
|
||||||
"webpack": "3.6.0",
|
|
||||||
"webpack-node-externals": "1.6.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/create-react-library) [](https://travis-ci.org/transitive-bullshit/create-react-library) [](https://standardjs.com)
|
[](https://www.npmjs.com/package/create-react-library) [](https://travis-ci.org/transitive-bullshit/create-react-library) [](https://standardjs.com)
|
||||||
|
|
||||||
|
|
||||||
## Intro
|
## Intro
|
||||||
|
|
||||||
**The purpose of this CLI is to make publishing your own React components as simple as possible.**
|
**The purpose of this CLI is to make publishing your own React components as simple as possible.**
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
|
|
||||||
The CLI is based on this [boilerplate](https://github.com/transitive-bullshit/react-modern-library-boilerplate), which you can optionally read about [here](https://hackernoon.com/publishing-baller-react-modules-2b039d84bce7).
|
The CLI is based on this [boilerplate](https://github.com/transitive-bullshit/react-modern-library-boilerplate), which you can optionally read about [here](https://hackernoon.com/publishing-baller-react-modules-2b039d84bce7).
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Easy-to-use CLI
|
- Easy-to-use CLI
|
||||||
|
@ -28,12 +30,16 @@ The CLI is based on this [boilerplate](https://github.com/transitive-bullshit/re
|
||||||
- Sourcemap creation
|
- Sourcemap creation
|
||||||
- Thorough documentation :heart_eyes:
|
- Thorough documentation :heart_eyes:
|
||||||
|
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
This package requires `node >= 4`, but we recommend `node >= 8`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g create-react-library
|
npm install -g create-react-library
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Creating a New Module
|
## Creating a New Module
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -52,6 +58,7 @@ At this point, your new module should resemble this screenshot and is all setup
|
||||||
<img width="600" src="https://cdn.rawgit.com/transitive-bullshit/create-react-library/master/media/tree.svg">
|
<img width="600" src="https://cdn.rawgit.com/transitive-bullshit/create-react-library/master/media/tree.svg">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
Local development is broken into two parts.
|
Local development is broken into two parts.
|
||||||
|
@ -77,6 +84,7 @@ Now, anytime you make a change to your component in `src/` or to the example app
|
||||||
|
|
||||||
Note: if you're using yarn, there is no need to use `yarn link`, as the generated module's example includes a local-link by default.
|
Note: if you're using yarn, there is no need to use `yarn link`, as the generated module's example includes a local-link by default.
|
||||||
|
|
||||||
|
|
||||||
#### NPM Stuffs
|
#### NPM Stuffs
|
||||||
|
|
||||||
The only difference when publishing your component to **npm** is to make sure you add any npm modules you want as peer dependencies are properly marked as `peerDependencies` in `package.json`. The rollup config will automatically recognize them as peer dependencies and not try to bundle them in your module.
|
The only difference when publishing your component to **npm** is to make sure you add any npm modules you want as peer dependencies are properly marked as `peerDependencies` in `package.json`. The rollup config will automatically recognize them as peer dependencies and not try to bundle them in your module.
|
||||||
|
@ -88,6 +96,7 @@ Then publish as per usual.
|
||||||
npm publish
|
npm publish
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Github Pages
|
#### Github Pages
|
||||||
|
|
||||||
Deploying the example to github pages is simple. We create a production build of our example `create-react-app` that showcases your library and then run `gh-pages` to deploy the resulting bundle. This can be done as follows:
|
Deploying the example to github pages is simple. We create a production build of our example `create-react-app` that showcases your library and then run `gh-pages` to deploy the resulting bundle. This can be done as follows:
|
||||||
|
@ -96,6 +105,7 @@ Deploying the example to github pages is simple. We create a production build of
|
||||||
npm run deploy
|
npm run deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Multiple Named Exports
|
### Multiple Named Exports
|
||||||
|
@ -106,6 +116,7 @@ Here is a [branch](https://github.com/transitive-bullshit/react-modern-library-b
|
||||||
|
|
||||||
Here is a [branch](https://github.com/transitive-bullshit/react-modern-library-boilerplate/tree/feature/material-ui) which demonstrates how to make use of a relatively complicated peer dependency, [material-ui](https://github.com/mui-org/material-ui). It shows the power of [rollup-plugin-peer-deps-external](https://www.npmjs.com/package/rollup-plugin-peer-deps-external) which makes it a breeze to create reusable modules that include complicated material-ui subcomponents without having them bundled as a part of your module.
|
Here is a [branch](https://github.com/transitive-bullshit/react-modern-library-boilerplate/tree/feature/material-ui) which demonstrates how to make use of a relatively complicated peer dependency, [material-ui](https://github.com/mui-org/material-ui). It shows the power of [rollup-plugin-peer-deps-external](https://www.npmjs.com/package/rollup-plugin-peer-deps-external) which makes it a breeze to create reusable modules that include complicated material-ui subcomponents without having them bundled as a part of your module.
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT © [Travis Fischer](https://github.com/transitive-bullshit)
|
MIT © [Travis Fischer](https://github.com/transitive-bullshit)
|
|
@ -1,65 +0,0 @@
|
||||||
/**
|
|
||||||
* Transpiles the CLI to ES5 in order to support node >= 4.
|
|
||||||
*
|
|
||||||
* Note: we use Webpack to compile the CLI, but the generated template still
|
|
||||||
* uses Rollup for compiling libraries. We don't judge between the two, but
|
|
||||||
* rather try to use the best tool for the job.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const nodeExternals = require('webpack-node-externals')
|
|
||||||
const path = require('path')
|
|
||||||
const webpack = require('webpack')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
target: 'node',
|
|
||||||
node: {
|
|
||||||
__dirname: false,
|
|
||||||
__filename: false,
|
|
||||||
process: false
|
|
||||||
},
|
|
||||||
entry: [
|
|
||||||
'./index.js'
|
|
||||||
],
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, 'dist'),
|
|
||||||
filename: 'index.js'
|
|
||||||
},
|
|
||||||
externals: [
|
|
||||||
nodeExternals()
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
new webpack.BannerPlugin({
|
|
||||||
banner: '#!/usr/bin/env node',
|
|
||||||
raw: true
|
|
||||||
})
|
|
||||||
],
|
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
test: /.js$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
loader: 'shebang-loader'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'babel-loader',
|
|
||||||
query: {
|
|
||||||
babelrc: false,
|
|
||||||
plugins: [
|
|
||||||
'transform-async-to-generator',
|
|
||||||
'transform-runtime'
|
|
||||||
],
|
|
||||||
presets: [
|
|
||||||
'env',
|
|
||||||
'stage-0'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue