@reactful/create 0.0.86 → 0.0.88

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +35 -24
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -62,38 +62,49 @@ const downloadRepo = async (subfolder, destination) =>
62
62
  async function downloadGitHub(user, repository, subdir, destination) {
63
63
  const prefix = `https://api.github.com/repos/${user}/${repository}`
64
64
  const address = `${prefix}/contents/installation/${subdir}`
65
+ const response = await fetch(address)
66
+ const contents = await response.json()
65
67
 
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...'
68
+ if (!Array.isArray(contents) || !response.ok) {
69
+ console.log('moment: DIRECTORY...')
70
+ logging(response, contents)
71
+ throw 'failed to download scafold from github...'
72
+ }
73
+
74
+ for (const item of contents) {
75
+ if (item.type === 'dir' && item.name) {
76
+ const from = `${subdir}/${item.name}`
77
+ const goto = `${destination}/${item.name}`
78
+ await downloadRepo(from, goto); continue
77
79
  }
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
-
80
+
81
+ if (item.type != 'file') continue
82
+
83
+ try {
88
84
  const filename = path.join(destination, item.name)
89
85
  const response = await fetch(item.download_url)
90
86
  const filetext = await response.text()
91
-
87
+
92
88
  fs.writeFileSync(filename, filetext)
93
- }
89
+ }
90
+ catch(ex) {
91
+ console.log('MOMMENT: file...')
92
+ logging(response, contents)
93
+ throw ex
94
+ }
95
+ }
96
+
97
+ try {
94
98
  }
95
99
  catch(ex) {
96
- console.log('url: ', address)
100
+ console.log('fetching: ', address)
97
101
  throw ex
98
102
  }
103
+ }
104
+
105
+ function logging(response, contents) {
106
+ console.log('url: ', response.url)
107
+ console.log('code: ', response.status)
108
+ console.log('array: ', Array.isArray(contents))
109
+ console.log('textual: ', JSON.stringify(contents))
99
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactful/create",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "description": "reactful scafold tool",