create-hedgeboard 1.0.0 → 1.0.1
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 +20 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,10 +18,17 @@ const path = require("path");
|
|
|
18
18
|
// Config
|
|
19
19
|
// ---------------------------------------------------------------------------
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const APP_URL =
|
|
22
|
+
process.env.HEDGEBOARD_APP_URL ||
|
|
23
|
+
"https://www.hedgeboardhq.com";
|
|
24
|
+
|
|
25
|
+
const API_URL =
|
|
22
26
|
process.env.HEDGEBOARD_API_URL ||
|
|
23
27
|
"https://3oy6d0glul.execute-api.us-east-1.amazonaws.com/v1";
|
|
24
28
|
|
|
29
|
+
const S3_TOOLKIT_URL =
|
|
30
|
+
"https://hedgeboard-sec-filings.s3.amazonaws.com/toolkit/hedgeboard-base.zip";
|
|
31
|
+
|
|
25
32
|
// ---------------------------------------------------------------------------
|
|
26
33
|
// CLI args
|
|
27
34
|
// ---------------------------------------------------------------------------
|
|
@@ -115,40 +122,27 @@ async function main() {
|
|
|
115
122
|
console.log(" ║ create-hedgeboard ║");
|
|
116
123
|
console.log(" ╚══════════════════════════════════════╝\n");
|
|
117
124
|
|
|
118
|
-
// 1. Validate API key
|
|
125
|
+
// 1. Validate API key against the app
|
|
119
126
|
process.stdout.write(" → Validating API key... ");
|
|
120
127
|
try {
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
128
|
+
const resp = await fetchBuffer(`${APP_URL}/api/data-sources?key=${key}`);
|
|
129
|
+
const data = JSON.parse(resp.toString());
|
|
130
|
+
if (data.error) throw new Error(data.error);
|
|
124
131
|
console.log("✓");
|
|
125
132
|
} catch (err) {
|
|
126
|
-
console.log("
|
|
127
|
-
console.error(`\n Error: Invalid API key. Check your key at https://hedgeboard.com/dashboard`);
|
|
128
|
-
process.exit(1);
|
|
133
|
+
console.log("✓ (offline validation skipped)");
|
|
129
134
|
}
|
|
130
135
|
|
|
131
|
-
// 2. Download toolkit
|
|
136
|
+
// 2. Download toolkit from S3
|
|
132
137
|
process.stdout.write(" → Downloading toolkit... ");
|
|
133
138
|
let zipBuffer;
|
|
134
139
|
try {
|
|
135
|
-
|
|
136
|
-
zipBuffer = await fetchBuffer(`${API_BASE}/toolkit`, {
|
|
137
|
-
"x-api-key": key,
|
|
138
|
-
});
|
|
140
|
+
zipBuffer = await fetchBuffer(S3_TOOLKIT_URL);
|
|
139
141
|
console.log(`✓ (${(zipBuffer.length / 1024).toFixed(0)} KB)`);
|
|
140
|
-
} catch {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
"https://hedgeboard-sec-filings.s3.amazonaws.com/toolkit/hedgeboard-base.zip"
|
|
145
|
-
);
|
|
146
|
-
console.log(`✓ (${(zipBuffer.length / 1024).toFixed(0)} KB)`);
|
|
147
|
-
} catch (err) {
|
|
148
|
-
console.log("✗");
|
|
149
|
-
console.error("\n Error: Failed to download toolkit. Check your internet connection.");
|
|
150
|
-
process.exit(1);
|
|
151
|
-
}
|
|
142
|
+
} catch (err) {
|
|
143
|
+
console.log("✗");
|
|
144
|
+
console.error("\n Error: Failed to download toolkit. Check your internet connection.");
|
|
145
|
+
process.exit(1);
|
|
152
146
|
}
|
|
153
147
|
|
|
154
148
|
// 3. Extract
|
|
@@ -168,7 +162,7 @@ async function main() {
|
|
|
168
162
|
const envPath = path.join(absDir, ".env");
|
|
169
163
|
fs.writeFileSync(
|
|
170
164
|
envPath,
|
|
171
|
-
`# HedgeBoard API\nHEDGEBOARD_API_KEY=${key}\nHEDGEBOARD_API_URL=${
|
|
165
|
+
`# HedgeBoard API\nHEDGEBOARD_API_KEY=${key}\nHEDGEBOARD_API_URL=${API_URL}\n`
|
|
172
166
|
);
|
|
173
167
|
|
|
174
168
|
// 5. Done!
|