Merge pull request #13 from transitive-bullshit/feature/es5-support
transpile to es5 for node >= 4 support
This commit is contained in:
parent
288d18f616
commit
519cd7ea8e
6 changed files with 1403 additions and 94 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict'
|
||||
|
||||
require('util.promisify/shim')()
|
||||
|
||||
const meow = require('meow')
|
||||
|
||||
const getLibraryDefaults = require('./lib/get-library-defaults')
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const consolidate = require('consolidate')
|
||||
const handlebars = require('handlebars')
|
||||
const execa = require('execa')
|
||||
const fs = require('fs')
|
||||
const globby = require('globby')
|
||||
|
@ -70,7 +70,8 @@ module.exports.copyTemplateFile = async (opts) => {
|
|||
const destFilePath = path.join(dest, fileRelativePath)
|
||||
const destFileDir = path.parse(destFilePath).dir
|
||||
|
||||
const content = await consolidate.handlebars(file, {
|
||||
const template = handlebars.compile(fs.readFileSync(file, 'utf8'))
|
||||
const content = template({
|
||||
...info,
|
||||
yarn: (info.manager === 'yarn')
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const inquirer = require('inquirer')
|
||||
const isValidNpmName = require('is-valid-npm-name')
|
||||
const validateNpmName = require('validate-npm-package-name')
|
||||
|
||||
const config = require('./config')
|
||||
|
||||
|
@ -12,7 +12,7 @@ module.exports = async (defaults) => {
|
|||
name: 'name',
|
||||
message: 'Package Name',
|
||||
validate: (name) => {
|
||||
return name && name.length && isValidNpmName(name)
|
||||
return name && validateNpmName(name).validForNewPackages
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -4,16 +4,21 @@
|
|||
"description": "CLI for easily bootstrapping modern react libraries",
|
||||
"repository": "transitive-bullshit/create-react-library",
|
||||
"author": "Travis Fischer <travis@automagical.ai>",
|
||||
"main": "index.js",
|
||||
"main": "dist/index.js",
|
||||
"module": "index.js",
|
||||
"jsnext:main": "index.js",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"create-react-library": "index.js"
|
||||
"create-react-library": "dist/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "ava -v && standard *.js lib/*.js"
|
||||
"test": "ava -v && standard *.js lib/*.js",
|
||||
"dev": "webpack -w",
|
||||
"prepare": "yarn run build",
|
||||
"build": "webpack"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
"node": ">=4"
|
||||
},
|
||||
"keywords": [
|
||||
"react",
|
||||
|
@ -29,25 +34,36 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"conf": "^1.4.0",
|
||||
"consolidate": "^0.15.0",
|
||||
"cp-file": "^5.0.0",
|
||||
"execa": "^0.9.0",
|
||||
"git-config-path": "^1.0.1",
|
||||
"github-username": "^4.1.0",
|
||||
"globby": "^8.0.1",
|
||||
"handlebars": "^4.0.11",
|
||||
"inquirer": "^5.1.0",
|
||||
"is-valid-npm-name": "^0.0.4",
|
||||
"inquirer": "^3",
|
||||
"make-dir": "^1.2.0",
|
||||
"meow": "^4.0.0",
|
||||
"ora": "^2.0.0",
|
||||
"p-each-series": "^1.0.0",
|
||||
"parse-git-config": "^2.0.0",
|
||||
"util.promisify": "^1.0.0",
|
||||
"validate-npm-package-name": "^3.0.0",
|
||||
"which": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"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",
|
||||
"rmfr": "^2.0.0",
|
||||
"standard": "^11.0.0"
|
||||
"shebang-loader": "0.0.1",
|
||||
"standard": "^11.0.0",
|
||||
"webpack": "3.6.0",
|
||||
"webpack-node-externals": "1.6.0"
|
||||
}
|
||||
}
|
||||
|
|
51
packages/create-freesewing-pattern/webpack.config.js
Normal file
51
packages/create-freesewing-pattern/webpack.config.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Transpiles create-react-library 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 the library. 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')
|
||||
|
||||
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()
|
||||
],
|
||||
module: {
|
||||
loaders: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
test: /.js$/,
|
||||
exclude: /node_modules/,
|
||||
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