@solongate/proxy 0.1.3 → 0.1.4

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 (3) hide show
  1. package/dist/create.js +32 -16
  2. package/dist/index.js +668 -547
  3. package/package.json +1 -1
package/dist/create.js CHANGED
@@ -190,14 +190,28 @@ dist/
190
190
  `
191
191
  );
192
192
  }
193
- function installDeps(dir) {
194
- log(" Installing dependencies with npm...");
193
+ function withSpinner(message, fn) {
194
+ const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
195
+ let i = 0;
196
+ const id = setInterval(() => {
197
+ process.stderr.write(`\r ${frames[i++ % frames.length]} ${message}`);
198
+ }, 80);
195
199
  try {
196
- execSync("npm install", { cwd: dir, stdio: "pipe" });
200
+ fn();
201
+ clearInterval(id);
202
+ process.stderr.write(`\r \u2713 ${message}
203
+ `);
197
204
  } catch {
198
- log(" npm install failed \u2014 run it manually.");
205
+ clearInterval(id);
206
+ process.stderr.write(`\r \u2717 ${message} \u2014 failed
207
+ `);
199
208
  }
200
209
  }
210
+ function installDeps(dir) {
211
+ withSpinner("Installing dependencies...", () => {
212
+ execSync("npm install", { cwd: dir, stdio: "pipe" });
213
+ });
214
+ }
201
215
  async function main() {
202
216
  const opts = parseCreateArgs(process.argv);
203
217
  const dir = resolve(opts.name);
@@ -227,18 +241,20 @@ async function main() {
227
241
  installDeps(dir);
228
242
  log("");
229
243
  }
230
- log(" \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510");
231
- log(" \u2502 Project created! \u2502");
232
- log(" \u2502 \u2502");
233
- log(` \u2502 cd ${opts.name.padEnd(39)}\u2502`);
234
- log(" \u2502 \u2502");
235
- log(" \u2502 npm run build # Build \u2502");
236
- log(" \u2502 npm run dev # Dev mode (tsx) \u2502");
237
- log(" \u2502 npm start # Run built server \u2502");
238
- log(" \u2502 \u2502");
239
- log(" \u2502 Set your API key: \u2502");
240
- log(" \u2502 export SOLONGATE_API_KEY=sg_live_xxx \u2502");
241
- log(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");
244
+ const W = 46;
245
+ const line = (s) => log(` \u2502 ${s.padEnd(W)} \u2502`);
246
+ log(` \u250C${"\u2500".repeat(W + 2)}\u2510`);
247
+ line("Project created!");
248
+ line("");
249
+ line(`cd ${opts.name}`);
250
+ line("");
251
+ line("npm run build # Build");
252
+ line("npm run dev # Dev mode (tsx)");
253
+ line("npm start # Run built server");
254
+ line("");
255
+ line("Set your API key:");
256
+ line("export SOLONGATE_API_KEY=sg_live_xxx");
257
+ log(` \u2514${"\u2500".repeat(W + 2)}\u2518`);
242
258
  log("");
243
259
  }
244
260
  main().catch((err) => {