qualty 0.1.11 → 0.1.12
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/bin/qualty.js +46 -2
- package/package.json +1 -1
package/bin/qualty.js
CHANGED
|
@@ -1269,8 +1269,52 @@ async function runAuthSetup(args) {
|
|
|
1269
1269
|
|
|
1270
1270
|
let profile = String(args.profile || "").trim();
|
|
1271
1271
|
if (!profile) {
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1272
|
+
const existingProfilesPayload = await apiRequest({
|
|
1273
|
+
apiUrl,
|
|
1274
|
+
token,
|
|
1275
|
+
orgId,
|
|
1276
|
+
path: `/api/v1/projects/${encodeURIComponent(project.id)}/saved-login-profiles`,
|
|
1277
|
+
}).catch(() => []);
|
|
1278
|
+
const existingProfileNames = (Array.isArray(existingProfilesPayload) ? existingProfilesPayload : [])
|
|
1279
|
+
.map((p) => String(p?.name || "").trim())
|
|
1280
|
+
.filter(Boolean);
|
|
1281
|
+
|
|
1282
|
+
const suggestedName = "default";
|
|
1283
|
+
if (existingProfileNames.length > 0) {
|
|
1284
|
+
// eslint-disable-next-line no-console
|
|
1285
|
+
console.log("[qualty][auth] Found existing saved login profiles on dashboard:");
|
|
1286
|
+
// eslint-disable-next-line no-console
|
|
1287
|
+
console.log(" 0) Create new profile");
|
|
1288
|
+
for (let i = 0; i < existingProfileNames.length; i += 1) {
|
|
1289
|
+
const name = existingProfileNames[i];
|
|
1290
|
+
// eslint-disable-next-line no-console
|
|
1291
|
+
console.log(` ${i + 1}) ${name}`);
|
|
1292
|
+
}
|
|
1293
|
+
while (!profile) {
|
|
1294
|
+
const raw = String(
|
|
1295
|
+
await rl.question(`Select profile [0-${existingProfileNames.length}]: `)
|
|
1296
|
+
).trim();
|
|
1297
|
+
const picked = Number(raw);
|
|
1298
|
+
if (!Number.isInteger(picked) || picked < 0 || picked > existingProfileNames.length) {
|
|
1299
|
+
// eslint-disable-next-line no-console
|
|
1300
|
+
console.log(`[qualty] Please enter a number from 0 to ${existingProfileNames.length}.`);
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
if (picked === 0) {
|
|
1304
|
+
const proposed = String(await rl.question(`New profile name [${suggestedName}]: `)).trim() || suggestedName;
|
|
1305
|
+
if (!proposed) {
|
|
1306
|
+
// eslint-disable-next-line no-console
|
|
1307
|
+
console.log("[qualty] Profile name cannot be empty.");
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
profile = proposed;
|
|
1311
|
+
} else {
|
|
1312
|
+
profile = existingProfileNames[picked - 1];
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
} else {
|
|
1316
|
+
profile = String(await rl.question(`Profile name [${suggestedName}]: `)).trim() || suggestedName;
|
|
1317
|
+
}
|
|
1274
1318
|
}
|
|
1275
1319
|
const statePath = localAuthStatePath({
|
|
1276
1320
|
orgId,
|