colana 1.0.0-beta.77 → 1.0.0-beta.78
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/admin.js +14 -2
- package/package.json +1 -1
package/bin/admin.js
CHANGED
|
@@ -156,12 +156,14 @@ async function createKey(flags) {
|
|
|
156
156
|
console.error(`\n ${icons.fail} ${c.error}ERROR: --name is required.${c.reset}\n`);
|
|
157
157
|
console.error(' Usage: colana admin create-key --name "Sarah" --type staff [--email x] [--expires 2026-12-31]\n');
|
|
158
158
|
process.exit(1);
|
|
159
|
+
return;
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
const validTypes = ['admin', 'staff', 'beta'];
|
|
162
163
|
if (!validTypes.includes(type)) {
|
|
163
164
|
console.error(`\n ${icons.fail} ${c.error}ERROR: Invalid type "${type}". Must be one of: ${validTypes.join(', ')}${c.reset}\n`);
|
|
164
165
|
process.exit(1);
|
|
166
|
+
return;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
// Prefer server API (avoids sql.js in-memory DB conflict)
|
|
@@ -174,6 +176,7 @@ async function createKey(flags) {
|
|
|
174
176
|
} catch (err) {
|
|
175
177
|
console.error(`\n ${icons.fail} ${c.error}${err.message}${c.reset} ${c.muted}(via server)${c.reset}\n`);
|
|
176
178
|
process.exit(1);
|
|
179
|
+
return;
|
|
177
180
|
}
|
|
178
181
|
} else {
|
|
179
182
|
// Fallback: direct DB access (only safe when server is NOT running)
|
|
@@ -184,6 +187,7 @@ async function createKey(flags) {
|
|
|
184
187
|
} catch (err) {
|
|
185
188
|
console.error(`\n ${icons.fail} ${c.error}${err.message}${c.reset}\n`);
|
|
186
189
|
process.exit(1);
|
|
190
|
+
return;
|
|
187
191
|
}
|
|
188
192
|
}
|
|
189
193
|
|
|
@@ -225,6 +229,7 @@ async function listKeysCmd(flags) {
|
|
|
225
229
|
} catch (err) {
|
|
226
230
|
console.error(`\n ${icons.fail} ${c.error}${err.message}${c.reset} ${c.muted}(via server)${c.reset}\n`);
|
|
227
231
|
process.exit(1);
|
|
232
|
+
return;
|
|
228
233
|
}
|
|
229
234
|
} else {
|
|
230
235
|
await ensureDb();
|
|
@@ -232,7 +237,7 @@ async function listKeysCmd(flags) {
|
|
|
232
237
|
result = listKeys(filters);
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
if (!result.keys.length) {
|
|
240
|
+
if (!result || !result.keys || !result.keys.length) {
|
|
236
241
|
console.log('\n No keys found.\n');
|
|
237
242
|
return;
|
|
238
243
|
}
|
|
@@ -263,6 +268,7 @@ async function revokeKeyCmd(positional) {
|
|
|
263
268
|
console.error(`\n ${icons.fail} ${c.error}ERROR: Key ID is required.${c.reset}\n`);
|
|
264
269
|
console.error(' Usage: colana admin revoke-key <id>\n');
|
|
265
270
|
process.exit(1);
|
|
271
|
+
return;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
// Prefer server API
|
|
@@ -275,6 +281,7 @@ async function revokeKeyCmd(positional) {
|
|
|
275
281
|
} catch (err) {
|
|
276
282
|
console.error(`\n ${icons.fail} ${c.error}${err.message}${c.reset} ${c.muted}(via server)${c.reset}\n`);
|
|
277
283
|
process.exit(1);
|
|
284
|
+
return;
|
|
278
285
|
}
|
|
279
286
|
} else {
|
|
280
287
|
await ensureDb();
|
|
@@ -285,6 +292,7 @@ async function revokeKeyCmd(positional) {
|
|
|
285
292
|
} catch (err) {
|
|
286
293
|
console.error(`\n ${icons.fail} ${c.error}${err.message}${c.reset}\n`);
|
|
287
294
|
process.exit(1);
|
|
295
|
+
return;
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
}
|
|
@@ -381,7 +389,11 @@ async function main() {
|
|
|
381
389
|
console.error(` ${icons.fail} Unknown command: ${c.value}${command}${c.reset}`);
|
|
382
390
|
console.error(` ${c.muted}Run "colana admin help" for usage.${c.reset}`);
|
|
383
391
|
process.exit(1);
|
|
392
|
+
return;
|
|
384
393
|
}
|
|
385
394
|
}
|
|
386
395
|
|
|
387
|
-
main()
|
|
396
|
+
main().catch((err) => {
|
|
397
|
+
console.error(` ${icons.fail} ${c.error}${err.message || err}${c.reset}`);
|
|
398
|
+
process.exit(1);
|
|
399
|
+
});
|