This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
saofile.js
121 lines (113 loc) · 3 KB
/
saofile.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
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
121
const path = require('path');
module.exports = {
prompts: [
{
name: 'name',
type: 'string',
message: 'Project name',
default: 'www.fqdn.com',
},
{
name: 'description',
type: 'string',
message: 'Project description',
default: ({ name }) => `Repository for ${name}.`,
},
{
name: 'url',
type: 'string',
message: 'Project URL',
default: ({ name }) => `https://${name}`,
},
{
name: 'hub',
message: 'Where is the project’s repository?',
type: 'list',
choices: [
{ name: 'GitLab', value: '[email protected]:studiometa' },
{ name: 'GitHub', value: '[email protected]:studiometa' },
],
default: 0,
},
{
name: 'repository',
type: 'string',
message: 'Project repository',
default: ({ name, hub }) => `${hub}/${name}.git`,
},
{
name: 'features',
message: 'Choose features to add',
type: 'checkbox',
choices: [{ name: 'i18n', value: 'i18n' }],
default: [],
},
],
templateData() {
const { features } = this.answers;
const i18n = features.includes('i18n');
return {
i18n,
};
},
actions() {
const actions = [
{
type: 'add',
files: '**',
filters: {
'*.DS_Store': false,
'/node_modules/*': false,
'/vendor/*': false,
'.gitlab-ci.yml': this.answers.hub.includes('gitlab.com'),
},
templateDir: 'template',
},
{
type: 'move',
patterns: {
_gitignore: '.gitignore',
'_package.json': 'package.json',
},
},
];
// Remove GitLab of Github files based on the selected hub
if (this.answers.hub.includes('github.com')) {
actions.push({
type: 'move',
patterns: {
_github: '.github',
},
});
} else {
actions.push({
type: 'remove',
files: '_github/',
});
}
return actions;
},
async completed() {
// Init Git and install NPM dependencies
this.gitInit();
await this.npmInstall({ npmClient: 'npm' });
// Display useful informations
const { chalk } = this;
const isNewFolder = this.outDir !== process.cwd();
const relativeOutFolder = path.relative(process.cwd(), this.outDir);
const tab = ' ';
console.log();
console.log(chalk`${tab}🎉 {bold Successfully created project} {cyan ${this.answers.name}}!`);
console.log();
console.log(chalk`${tab}{bold To get started:}\n`);
if (isNewFolder) {
console.log(chalk`${tab}Go in your project's directory`);
console.log(chalk`${tab}{cyan cd ${relativeOutFolder}}\n`);
}
console.log(chalk`${tab}Create your .env file and fill it`);
console.log(chalk`${tab}{cyan cp .env.example .env}\n`);
console.log(chalk`${tab}Start the development server`);
console.log(chalk`${tab}{cyan npm run dev}\n`);
console.log(chalk`${tab}🎊 {bold Happy coding!}\n`);
},
};