-
Notifications
You must be signed in to change notification settings - Fork 3
/
plopfile.js
68 lines (65 loc) · 1.78 KB
/
plopfile.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const path = require('path')
const execa = require('execa')
const npmName = require('npm-name')
const originUrl = require('git-remote-origin-url')
const templatePath = path.join(__dirname, './templates')
module.exports = plop => {
plop.setGenerator('npm package', {
description: 'create a new package',
prompts: [
{
name: 'location',
type: 'input',
message: 'package location',
filter: location =>
path.isAbsolute(location) ? location : path.resolve(location),
},
{
name: 'name',
type: 'input',
message: 'package name',
validate: async name =>
(await npmName(name)) ? true : 'Name already taken',
default: _ => `@react-bootstrap/${path.basename(_.location)}`,
},
{
name: 'author',
type: 'input',
message: 'author',
},
{
name: 'repository',
type: 'input',
message: 'repository',
default: () => originUrl().catch(() => ''),
},
],
actions({ location }) {
return [
{
type: 'add',
path: '{{location}}/package.json',
templateFile: `${templatePath}/package.json.hbs`,
},
{
type: 'add',
path: '{{location}}/.gitignore',
templateFile: `${templatePath}/gitignore`,
skipIfExists: true,
},
{
type: 'add',
path: `{{location}}/LICENSE`,
templateFile: `${templatePath}/LICENSE.hbs`,
skipIfExists: true,
},
() => execa('yarn', ['install'], { cwd: location, stdio: 'inherit' }),
() =>
execa('yarn', ['upgrade-interactive', '--latest'], {
cwd: location,
stdio: 'inherit',
}),
]
},
})
}