1
0
Fork 0

use node-compat-require instead of webpack for node >= 4 support; update dependencies

This commit is contained in:
Travis Fischer 2018-05-06 19:01:46 -04:00 committed by Joost De Cock
parent fa8df25694
commit dd83df8f4e
10 changed files with 1327 additions and 10673 deletions

View file

@ -88,8 +88,6 @@ module.exports.initPackageManager = async (opts) => {
info
} = opts
const example = path.join(dest, 'example')
const commands = [
{
cmd: `${info.manager} install`,
@ -99,13 +97,7 @@ module.exports.initPackageManager = async (opts) => {
cmd: `${info.manager} link`,
cwd: dest
}
].concat(info.manager === 'yarn' ? [
{
cmd: `${info.manager}`,
cwd: example
}
] : [ ]
)
]
return pEachSeries(commands, async ({ cmd, cwd }) => {
return execa.shell(cmd, { cwd })

View file

@ -2,6 +2,7 @@
const { test } = require('ava')
const execa = require('execa')
const path = require('path')
const rmfr = require('rmfr')
const createLibrary = require('./create-library')
@ -36,18 +37,26 @@ const tests = [
tests.forEach((info) => {
test.serial(`creating "${info.name}" using ${info.manager}`, async (t) => {
console.log(`creating "${info.name}" using ${info.manager}...`)
let ret
// ensure library is created successfully
const root = await createLibrary(info)
t.truthy(root.indexOf(info.shortName) >= 0)
// ensure yarn runs successfully
let ret = await execa.shell('yarn', { cwd: root })
// ensure yarn runs successfully in src/
ret = await execa.shell('yarn', { cwd: root })
t.is(ret.code, 0)
// ensure jest tests pass
ret = await execa.shell('yarn test', { cwd: root })
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
ret = await execa.shell('git status', { cwd: root })
t.is(ret.code, 0)

View 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)
})