@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.
Files changed (2) hide show
  1. package/index.js +33 -27
  2. 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 response = await fetch(`${prefix}/contents/installation/${subdir}`)
65
- const contents = await response.json()
66
-
67
- if (!Array.isArray(contents) || !response.ok) {
68
- console.error('failed to download scafold from github...')
69
- console.log('textual: ', JSON.stringify(contents))
70
- console.log('array: ', Array.isArray(contents))
71
- console.log('code: ', response.status)
72
- console.log('url: ', response.url)
73
- }
74
-
75
- for (const item of contents) {
76
- if (item.type === 'dir' && item.name) {
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
- if (item.type != 'file') continue
86
-
87
- const filename = path.join(destination, item.name)
88
- const response = await fetch(item.download_url)
89
- const filetext = await response.text()
90
-
91
- fs.writeFileSync(filename, filetext)
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",