forked from ThatOpen/engine_templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 1.04 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
#!/usr/bin/env node
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { createRequire } from 'module';
import inquirer from 'inquirer';
import ncp from 'ncp';
const require = createRequire(import.meta.url);
const templatesPath = join(dirname(fileURLToPath(import.meta.url)), 'templates');
const chooseTemplateMsg = "Choose a template for your new BIM app:"
const completedMsg = `
Project created successfully! Now execute the following in terminal:
/* If using NPM */
npm i
npm run dev
/* If using Yarn */
yarn install
yarn dev
`
const templateChoices = require('fs').readdirSync(templatesPath);
inquirer
.prompt([
{
type: 'list',
name: 'template',
message: chooseTemplateMsg,
choices: templateChoices,
},
])
.then((answers) => {
const templatePath = join(templatesPath, answers.template);
ncp.ncp(templatePath, process.cwd(), (err) => {
if (err) {
console.error('Failed to create project:', err);
return;
}
console.log(completedMsg);
});
});