forked from transitive-bullshit/create-react-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·52 lines (39 loc) · 1.13 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
'use strict'
require('util.promisify/shim')()
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)
})
}