-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeta.js
More file actions
120 lines (114 loc) · 3.19 KB
/
meta.js
File metadata and controls
120 lines (114 loc) · 3.19 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const path = require('path')
const fs = require('fs')
const { sortDependencies, installDependencies, initializeRepository, runLintFix, printMessage } = require('./utils')
const pkg = require('./package.json')
const templateVersion = pkg.version
module.exports = {
helpers: {
template_version() {
return templateVersion
},
updated_date() {
return new Date().toISOString().slice(0, 10)
},
builds_url() {
return 'https://graphics.afpforum.com/builds/'
},
build_id() {
return new Date().toISOString().slice(0, 10).replace(/-/g,'')
}
},
prompts: {
name: {
type: "string",
required: true,
message: "Name your project (lowercase and dashes only)",
default: "my-awesome-project",
validate (input) {
const regex = /^[a-z0-9-]+[a-z0-9]$/
if (input.match(regex) !== null) return true
return false
}
},
description: {
type: "string",
required: false,
message: "Describe your project",
default: "A Vue.js project with AFP templating"
},
author: {
type: "string",
message: "Who are you ?"
},
mainComponent: {
type: "list",
message: "Want to start from a template ?",
choices: [
{
name: "Let me start from scratch",
value: "basic",
short: "basic"
},
{
name: "I want to switch between figures (tab-story)",
value: "tabstory",
short: "tabstory"
},
{
name: "I want a gallery of images that I can open (modal-gallery)",
value: "modalgallery",
short: "modalgallery"
},
{
name: "I want to explain an algorithm with user data (calculator)",
value: "calculator",
short: "calculator"
}
]
},
autoInstall: {
type: "confirm",
message: "Should I run `npm install` for you after the project has been created ?",
default: true
},
initRepo: {
type: "confirm",
message: "Should I initialize a repository for the project ?",
default: true
}
},
skipInterpolation: "src/**/*.vue",
completeMessage: "{{#inPlace}}To get started:\n\n npm install\n npm run dev.{{else}}To get started:\n\n cd {{destDirName}}\n npm install\n npm run dev.{{/inPlace}}",
complete: function (data, { chalk }) {
const green = chalk.green
sortDependencies(data, green)
const cwd = path.join(process.cwd(), data.inPlace ? '' : data.destDirName)
Promise.resolve()
.then(() => {
if (data.autoInstall) {
return installDependencies(cwd, 'npm', green)
.then(() => {
return runLintFix(cwd, data, green)
})
.catch(e => {
console.log(chalk.red('Error:'), e)
})
} else {
return Promise.resolve()
}
})
.then(() => {
if (data.initRepo) {
return initializeRepository(cwd, 'git', green)
} else {
return Promise.resolve()
}
})
.then(() => {
printMessage(data, green)
})
.catch(e => {
console.log(chalk.red('Error:'), e)
})
}
}