-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (44 loc) · 1.29 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
#!/usr/bin/env node
import { Command } from "commander";
import simpleGit from "simple-git";
import { readFile, writeFile } from "fs";
import { rimraf } from "rimraf";
const program = new Command();
program
.command("create-app <name>")
.description("Clona um repositório do GitHub")
.action((name) => {
console.log(`Criando app ${name}...`);
const git = simpleGit();
git
.clone("https://github.com/PS-Smart-Hub/app-template", name || "", {
"--depth": 1,
})
.then(() => {
const package_json = readFile(
`./${name}/package.json`,
"utf-8",
(err, data) => {
const parseJSON = JSON.parse(data);
parseJSON.name = name;
writeFile(
`./${name}/package.json`,
JSON.stringify(parseJSON, null, 2),
(err) => {
if (err) {
console.error(
"Erro ao escrever no arquivo package.json:",
err
);
return;
}
}
);
}
);
console.log("App criado com sucesso!");
rimraf(`./${name}/.git`)
})
.catch((err) => console.error("Erro ao clonar o repositório:", err));
});
program.parse();