-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·56 lines (45 loc) · 1.58 KB
/
Copy pathindex.js
File metadata and controls
executable file
·56 lines (45 loc) · 1.58 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
#!/usr/bin/env node
var options = require('./package.json');
var shell = require('shelljs');
var chalk = require('chalk');
var program = require('commander');
const templates = require('./template/templates').default;
program
.version(options.version)
.option('-n, --name <name>', 'Give new project name', 'demo')
.option('-a, --author <author>', 'Author name', "")
.parse(process.argv);
console.log(chalk.green("Creating new project "+ program.name));
//creating basic template
if (program.name !== "undefined") {
shell.mkdir(program.name);
// Go inside project folder
shell.cd(program.name);
// create package.json file
var app = {
name: program.name.toLowerCase(),
author: program.author
}
const html = templates.getHTMLTemplate(app);
const packageJson = templates.getPackageJsonTemplate(app);
const jsscript = templates.getInitialScript(app);
const css = templates.getInitialCss();
// Create package.json file
shell.exec("echo '"+packageJson+"' >>package.json");
// create html file
shell.exec("echo '"+html+"' >>index.html");
// create script file
shell.mkdir("script");
shell.exec("echo '"+jsscript+"' >> script/main.js");
// create css file
shell.mkdir("css");
shell.exec("echo '"+css+"' >> css/style.css");
// install dependencies
shell.exec('npm install');
// G0 back from project folder
shell.cd('..');
console.log(chalk.yellow("Thanks for using test-cli"));
} else {
console.log("No project name found");
console.log(chalk.yellow("Thanks for using test-cli"));
}