@reactful/create 0.0.69 → 0.0.71
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +14 -14
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { execSync } from 'child_process'
|
4
4
|
import inquirer from 'inquirer'
|
5
5
|
import fetch from 'node-fetch'
|
6
6
|
import path from 'path'
|
@@ -32,17 +32,16 @@ const questions = [
|
|
32
32
|
]
|
33
33
|
|
34
34
|
inquirer.prompt(questions).then(async function (answers) {
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
fs.mkdirSync(answers.project)
|
36
|
+
|
38
37
|
const destination = path.join(process.cwd(), answers.project)
|
39
|
-
|
38
|
+
|
40
39
|
await downloadRepo(`commons`, destination)
|
41
40
|
await downloadRepo(`templates/${answers.template}`, destination)
|
42
|
-
|
41
|
+
|
43
42
|
renamingJSON(destination, answers.project)
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
execSync(`cd ${answers.project}; bun install`)
|
46
45
|
})
|
47
46
|
|
48
47
|
function renamingJSON(directory, projectName) {
|
@@ -60,15 +59,16 @@ function renamingJSON(directory, projectName) {
|
|
60
59
|
const downloadRepo = async (subfolder, destination) =>
|
61
60
|
downloadGitHub('jsenaribeiro', 'reactful', subfolder, destination)
|
62
61
|
|
63
|
-
async function downloadGitHub(user, repository,
|
62
|
+
async function downloadGitHub(user, repository, subdir, destination) {
|
64
63
|
const prefix = `https://api.github.com/repos/${user}/${repository}`
|
65
|
-
const url = `${prefix}/contents/installation/${
|
66
|
-
const
|
64
|
+
const url = `${prefix}/contents/installation/${subdir}`
|
65
|
+
const contents = await fetch(url).then(x => x.json())
|
67
66
|
|
68
|
-
|
69
|
-
|
67
|
+
for (const item of contents) {
|
68
|
+
const from = `${subdir}/${item.name}`
|
69
|
+
const goto = `${destination}/${item.name}`
|
70
70
|
|
71
|
-
|
71
|
+
if (item.type === 'dir') await downloadGitHub(from, goto)
|
72
72
|
if (item.type != 'file') continue
|
73
73
|
|
74
74
|
const filename = path.join(destination, item.name)
|