@reactful/create 0.0.88 → 0.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +16 -13
- package/package.json +1 -1
package/index.js
CHANGED
@@ -40,8 +40,11 @@ inquirer.prompt(questions).then(async function (answers) {
|
|
40
40
|
await downloadRepo(`templates/${answers.template}`, destination)
|
41
41
|
|
42
42
|
renamingJSON(destination, answers.project)
|
43
|
+
|
44
|
+
console.log('- installing dependencies...')
|
43
45
|
|
44
|
-
execSync(`cd ${answers.project}
|
46
|
+
execSync(`cd ${answers.project}`)
|
47
|
+
execSync(`bun install`)
|
45
48
|
})
|
46
49
|
|
47
50
|
function renamingJSON(directory, projectName) {
|
@@ -60,6 +63,8 @@ const downloadRepo = async (subfolder, destination) =>
|
|
60
63
|
downloadGitHub('jsenaribeiro', 'reactful', subfolder, destination)
|
61
64
|
|
62
65
|
async function downloadGitHub(user, repository, subdir, destination) {
|
66
|
+
console.log(`- downloading ${subdir}...`)
|
67
|
+
|
63
68
|
const prefix = `https://api.github.com/repos/${user}/${repository}`
|
64
69
|
const address = `${prefix}/contents/installation/${subdir}`
|
65
70
|
const response = await fetch(address)
|
@@ -81,30 +86,28 @@ async function downloadGitHub(user, repository, subdir, destination) {
|
|
81
86
|
if (item.type != 'file') continue
|
82
87
|
|
83
88
|
try {
|
84
|
-
const
|
89
|
+
const filePath = path.join(destination, item.name)
|
85
90
|
const response = await fetch(item.download_url)
|
86
|
-
const
|
91
|
+
const fileText = await response.text()
|
92
|
+
const baseFile = path.dirname(filePath)
|
93
|
+
const notFound = fs.existsSync(baseFile) == false
|
94
|
+
|
95
|
+
if (notFound) fs.mkdirSync(baseFile, { recursive: true })
|
87
96
|
|
88
|
-
fs.writeFileSync(
|
97
|
+
fs.writeFileSync(filePath, fileText)
|
89
98
|
}
|
90
99
|
catch(ex) {
|
91
100
|
console.log('MOMMENT: file...')
|
92
|
-
logging(response, contents)
|
101
|
+
logging(response, contents, item.download_url)
|
93
102
|
throw ex
|
94
103
|
}
|
95
|
-
}
|
96
|
-
|
97
|
-
try {
|
98
|
-
}
|
99
|
-
catch(ex) {
|
100
|
-
console.log('fetching: ', address)
|
101
|
-
throw ex
|
102
104
|
}
|
103
105
|
}
|
104
106
|
|
105
|
-
function logging(response, contents) {
|
107
|
+
function logging(response, contents, download) {
|
106
108
|
console.log('url: ', response.url)
|
107
109
|
console.log('code: ', response.status)
|
108
110
|
console.log('array: ', Array.isArray(contents))
|
109
111
|
console.log('textual: ', JSON.stringify(contents))
|
112
|
+
console.log('download: ', item.download_url)
|
110
113
|
}
|