@reactful/create 0.0.84 → 0.0.86
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 +33 -27
- package/package.json +1 -1
package/index.js
CHANGED
@@ -61,33 +61,39 @@ const downloadRepo = async (subfolder, destination) =>
|
|
61
61
|
|
62
62
|
async function downloadGitHub(user, repository, subdir, destination) {
|
63
63
|
const prefix = `https://api.github.com/repos/${user}/${repository}`
|
64
|
-
const
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
const from = `${subdir}/${item.name}`
|
78
|
-
const goto = `${destination}/${item.name}`
|
79
|
-
console.log('- from', from)
|
80
|
-
console.log('- goto', goto)
|
81
|
-
await downloadGitHub(from, goto)
|
82
|
-
continue
|
64
|
+
const address = `${prefix}/contents/installation/${subdir}`
|
65
|
+
|
66
|
+
try {
|
67
|
+
const response = await fetch(address)
|
68
|
+
const contents = await response.json()
|
69
|
+
|
70
|
+
if (!Array.isArray(contents) || !response.ok) {
|
71
|
+
console.log('url: ', response.url)
|
72
|
+
console.log('code: ', response.status)
|
73
|
+
console.log('array: ', Array.isArray(contents))
|
74
|
+
console.log('textual: ', JSON.stringify(contents))
|
75
|
+
|
76
|
+
throw 'failed to download scafold from github...'
|
83
77
|
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
78
|
+
|
79
|
+
for (const item of contents) {
|
80
|
+
if (item.type === 'dir' && item.name) {
|
81
|
+
const from = `${subdir}/${item.name}`
|
82
|
+
const goto = `${destination}/${item.name}`
|
83
|
+
await downloadRepo(from, goto); continue
|
84
|
+
}
|
85
|
+
|
86
|
+
if (item.type != 'file') continue
|
87
|
+
|
88
|
+
const filename = path.join(destination, item.name)
|
89
|
+
const response = await fetch(item.download_url)
|
90
|
+
const filetext = await response.text()
|
91
|
+
|
92
|
+
fs.writeFileSync(filename, filetext)
|
93
|
+
}
|
94
|
+
}
|
95
|
+
catch(ex) {
|
96
|
+
console.log('url: ', address)
|
97
|
+
throw ex
|
92
98
|
}
|
93
99
|
}
|