cutsio 0.2.0 → 0.2.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/README.md +1 -0
- package/dist/index.js +40 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Create an **organization** API key in Cutsio: Settings → Organization → API
|
|
|
20
20
|
cutsio login --url https://studio.cutsio.com --key ak_...
|
|
21
21
|
cutsio whoami
|
|
22
22
|
cutsio logout # removes the stored key
|
|
23
|
+
cutsio welcome # replay the first-run banner
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
On macOS the key goes into the **Keychain**; elsewhere it is written to
|
package/dist/index.js
CHANGED
|
@@ -93,20 +93,21 @@ function resolveApiUrl(flag) {
|
|
|
93
93
|
}
|
|
94
94
|
async function resolveApiKey() {
|
|
95
95
|
const fromEnv = process.env.CUTSIO_API_KEY;
|
|
96
|
-
if (fromEnv && fromEnv.length > 0) return fromEnv;
|
|
96
|
+
if (fromEnv && fromEnv.length > 0) return { apiKey: fromEnv, migrated: false };
|
|
97
97
|
const stored = await getStoredKey();
|
|
98
|
-
if (stored) return stored;
|
|
98
|
+
if (stored) return { apiKey: stored, migrated: false };
|
|
99
99
|
const config = readConfig();
|
|
100
100
|
const legacy = config?.apiKey;
|
|
101
|
-
if (!legacy) return null;
|
|
101
|
+
if (!legacy) return { apiKey: null, migrated: false };
|
|
102
102
|
if (keychainAvailable()) {
|
|
103
103
|
try {
|
|
104
104
|
await setStoredKey(legacy);
|
|
105
105
|
writeConfig({ apiUrl: config?.apiUrl ?? DEFAULT_API_URL });
|
|
106
|
+
return { apiKey: legacy, migrated: true };
|
|
106
107
|
} catch {
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
return legacy;
|
|
110
|
+
return { apiKey: legacy, migrated: false };
|
|
110
111
|
}
|
|
111
112
|
async function saveCredentials(apiUrl, apiKey) {
|
|
112
113
|
if (keychainAvailable()) {
|
|
@@ -351,7 +352,8 @@ function resolveSelection(manifest, selection) {
|
|
|
351
352
|
|
|
352
353
|
// src/commands/list.ts
|
|
353
354
|
async function listCommand(flags) {
|
|
354
|
-
const apiKey = await resolveApiKey();
|
|
355
|
+
const { apiKey, migrated } = await resolveApiKey();
|
|
356
|
+
if (migrated) console.error("Moved your API key into the macOS Keychain.");
|
|
355
357
|
if (!apiKey) {
|
|
356
358
|
console.error("No API key. Run `cutsio login` or set CUTSIO_API_KEY.");
|
|
357
359
|
return 1;
|
|
@@ -1113,7 +1115,8 @@ async function promptSelection(manifest) {
|
|
|
1113
1115
|
|
|
1114
1116
|
// src/commands/sync.ts
|
|
1115
1117
|
async function syncCommand(flags) {
|
|
1116
|
-
const apiKey = await resolveApiKey();
|
|
1118
|
+
const { apiKey, migrated } = await resolveApiKey();
|
|
1119
|
+
if (migrated) console.error("Moved your API key into the macOS Keychain.");
|
|
1117
1120
|
if (!apiKey) {
|
|
1118
1121
|
console.error("No API key. Run `cutsio login` or set CUTSIO_API_KEY.");
|
|
1119
1122
|
return 1;
|
|
@@ -1230,23 +1233,6 @@ function positiveInt(value, fallback) {
|
|
|
1230
1233
|
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : fallback;
|
|
1231
1234
|
}
|
|
1232
1235
|
|
|
1233
|
-
// src/commands/whoami.ts
|
|
1234
|
-
async function whoamiCommand(flags) {
|
|
1235
|
-
const apiKey = await resolveApiKey();
|
|
1236
|
-
if (!apiKey) {
|
|
1237
|
-
console.error("No API key. Run `cutsio login` or set CUTSIO_API_KEY.");
|
|
1238
|
-
return 1;
|
|
1239
|
-
}
|
|
1240
|
-
const client = new CutsioClient(resolveApiUrl(flags.url), apiKey);
|
|
1241
|
-
try {
|
|
1242
|
-
console.log(JSON.stringify(await client.whoami(), null, 2));
|
|
1243
|
-
return 0;
|
|
1244
|
-
} catch (error) {
|
|
1245
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
1246
|
-
return 1;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
1236
|
// src/ui/banner.ts
|
|
1251
1237
|
var WORDMARK = [
|
|
1252
1238
|
" \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 ",
|
|
@@ -1275,6 +1261,34 @@ async function revealBanner() {
|
|
|
1275
1261
|
if (animationsEnabled) await sleep2(60);
|
|
1276
1262
|
}
|
|
1277
1263
|
|
|
1264
|
+
// src/commands/welcome.ts
|
|
1265
|
+
async function welcomeCommand() {
|
|
1266
|
+
await revealBanner();
|
|
1267
|
+
console.log(` ${color.dim("login")} cutsio login`);
|
|
1268
|
+
console.log(` ${color.dim("browse")} cutsio list`);
|
|
1269
|
+
console.log(` ${color.dim("sync")} cutsio sync --out ~/Cutsio --interactive`);
|
|
1270
|
+
console.log();
|
|
1271
|
+
return 0;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
// src/commands/whoami.ts
|
|
1275
|
+
async function whoamiCommand(flags) {
|
|
1276
|
+
const { apiKey, migrated } = await resolveApiKey();
|
|
1277
|
+
if (migrated) console.error("Moved your API key into the macOS Keychain.");
|
|
1278
|
+
if (!apiKey) {
|
|
1279
|
+
console.error("No API key. Run `cutsio login` or set CUTSIO_API_KEY.");
|
|
1280
|
+
return 1;
|
|
1281
|
+
}
|
|
1282
|
+
const client = new CutsioClient(resolveApiUrl(flags.url), apiKey);
|
|
1283
|
+
try {
|
|
1284
|
+
console.log(JSON.stringify(await client.whoami(), null, 2));
|
|
1285
|
+
return 0;
|
|
1286
|
+
} catch (error) {
|
|
1287
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1288
|
+
return 1;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1278
1292
|
// src/index.ts
|
|
1279
1293
|
function parseFlags(args) {
|
|
1280
1294
|
const flags = {};
|
|
@@ -1306,6 +1320,7 @@ function printHelp() {
|
|
|
1306
1320
|
Usage:
|
|
1307
1321
|
cutsio login [--url URL] [--key KEY]
|
|
1308
1322
|
cutsio logout
|
|
1323
|
+
cutsio welcome
|
|
1309
1324
|
cutsio whoami [--url URL]
|
|
1310
1325
|
cutsio list [--videos] [--search TERM] [--json] [--url URL]
|
|
1311
1326
|
cutsio sync [--all | --folder REFS | --collection REFS | --video IDS | --search TERMS | --unfiled | --interactive]
|
|
@@ -1352,6 +1367,8 @@ async function main() {
|
|
|
1352
1367
|
return loginCommand(flags);
|
|
1353
1368
|
case "logout":
|
|
1354
1369
|
return logoutCommand();
|
|
1370
|
+
case "welcome":
|
|
1371
|
+
return welcomeCommand();
|
|
1355
1372
|
case "whoami":
|
|
1356
1373
|
return whoamiCommand(flags);
|
|
1357
1374
|
case "list":
|