ht-skills 0.2.3 → 0.2.5

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/lib/cli.js +45 -14
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -265,6 +265,32 @@ async function promptToOpenBrowser(url, deps = {}) {
265
265
  }
266
266
  }
267
267
 
268
+ function startLoginWaitingIndicator(deps = {}) {
269
+ const isInteractive = typeof deps.isInteractive === "boolean"
270
+ ? deps.isInteractive
271
+ : Boolean(process.stdin.isTTY && process.stdout.isTTY);
272
+
273
+ if (!isInteractive || !process.stdout.isTTY) {
274
+ return () => {};
275
+ }
276
+
277
+ const frames = ["|", "/", "-", "\\"];
278
+ let frameIndex = 0;
279
+ process.stdout.write("Waiting for browser sign-in... ");
280
+ const timer = setInterval(() => {
281
+ const frame = frames[frameIndex % frames.length];
282
+ frameIndex += 1;
283
+ process.stdout.write(`\rWaiting for browser sign-in... ${frame}`);
284
+ }, 120);
285
+
286
+ return () => {
287
+ clearInterval(timer);
288
+ process.stdout.write("\r");
289
+ process.stdout.clearLine(0);
290
+ process.stdout.cursorTo(0);
291
+ };
292
+ }
293
+
268
294
  function formatInstallError(error, { slug, version = null, registry, stage = "resolve" }) {
269
295
  const rawMessage = String(error?.message || "Install failed").trim();
270
296
  const status = Number(error?.status || 0);
@@ -1284,28 +1310,33 @@ async function cmdLogin(flags, deps = {}) {
1284
1310
 
1285
1311
  try {
1286
1312
  await Promise.resolve(openBrowser(browserUrl));
1287
- log(`Opened browser for ${registry}. Complete sign-in to continue...`);
1288
1313
  } catch (error) {
1289
1314
  log(`Open this URL in your browser and sign in:\n${browserUrl}`);
1290
1315
  }
1291
1316
 
1292
1317
  const expiresAtMs = Date.parse(started.expires_at || "") || (Date.now() + timeoutMs);
1293
1318
  const deadline = Math.min(Date.now() + timeoutMs, expiresAtMs);
1319
+ const stopIndicator = startLoginWaitingIndicator(deps);
1294
1320
 
1295
- while (Date.now() <= deadline) {
1296
- await sleep(pollIntervalMs);
1297
- const status = await requestJsonImpl(pollUrl);
1298
- if (status.status === "approved") {
1299
- await setStoredRegistryAuth(registry, {
1300
- token: status.token,
1301
- user: status.user || null,
1302
- tokenExpiresAt: status.token_expires_at || null,
1303
- savedAt: new Date().toISOString(),
1304
- }, { homeDir });
1305
- const userLabel = status.user?.name || status.user?.email || status.user?.id || "user";
1306
- log(`Signed in to ${registry} as ${userLabel}.`);
1307
- return status;
1321
+ try {
1322
+ while (Date.now() <= deadline) {
1323
+ await sleep(pollIntervalMs);
1324
+ const status = await requestJsonImpl(pollUrl);
1325
+ if (status.status === "approved") {
1326
+ await setStoredRegistryAuth(registry, {
1327
+ token: status.token,
1328
+ user: status.user || null,
1329
+ tokenExpiresAt: status.token_expires_at || null,
1330
+ savedAt: new Date().toISOString(),
1331
+ }, { homeDir });
1332
+ const userLabel = status.user?.name || status.user?.email || status.user?.id || "user";
1333
+ stopIndicator();
1334
+ log(`Signed in to ${registry} as ${userLabel}.`);
1335
+ return status;
1336
+ }
1308
1337
  }
1338
+ } finally {
1339
+ stopIndicator();
1309
1340
  }
1310
1341
 
1311
1342
  throw new Error(`Timed out waiting for browser sign-in at ${registry}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ht-skills",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "CLI for installing and submitting skills from HT Skills Marketplace.",
5
5
  "type": "commonjs",
6
6
  "bin": {