-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
86 lines (84 loc) · 1.94 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// @ts-check
const path = require('path')
const { name, version } = require('./package.json')
/** @type {import('caz').Template} */
module.exports = {
name,
version,
metadata: {
year: new Date().getFullYear()
},
prompts: [
{
name: 'name',
type: 'text',
message: 'Project name'
},
{
name: 'version',
type: 'text',
message: 'Project version'
},
{
name: 'description',
type: 'text',
message: 'Project description',
initial: 'Awesome vercel apps.'
},
{
name: 'author',
type: 'text',
message: 'Project author name'
},
{
name: 'email',
type: 'text',
message: 'Project author email'
},
{
name: 'url',
type: 'text',
message: 'Project author url'
},
{
name: 'github',
type: 'text',
message: 'GitHub username or organization',
initial: 'zce'
},
{
name: 'install',
type: 'confirm',
message: 'Install dependencies',
initial: true
},
{
name: 'pm',
type: prev => process.env.NODE_ENV === 'test' || prev ? 'select' : null,
message: 'Package manager',
hint: ' ',
choices: [
{ title: 'npm', value: 'npm' },
{ title: 'pnpm', value: 'pnpm' },
{ title: 'yarn', value: 'yarn' }
]
}
],
init: true,
setup: async ctx => {
ctx.config.install = ctx.answers.install && ctx.answers.pm
},
complete: async ctx => {
console.clear()
console.log(`Created a new project in ${ctx.project} by the ${ctx.template} template.\n`)
console.log('Getting Started:')
if (ctx.dest !== process.cwd()) {
console.log(` $ cd ${path.relative(process.cwd(), ctx.dest)}`)
}
if (ctx.config.install === false) {
console.log(' $ npm install')
}
console.log(` $ ${ctx.config.install ? ctx.config.install : 'npm'} run develop`)
console.log('\nHappy hacking :)\n')
}
}