@dropthis/cli 0.23.0 → 0.24.0
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 +2 -2
- package/dist/cli.cjs +35 -47
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/README.md +28 -0
- package/node_modules/@dropthis/node/dist/{drops-DNwOp7g_.d.cts → drops-O6ymlqmb.d.cts} +56 -4
- package/node_modules/@dropthis/node/dist/{drops-DNwOp7g_.d.ts → drops-O6ymlqmb.d.ts} +56 -4
- package/node_modules/@dropthis/node/dist/edge.cjs +23 -6
- package/node_modules/@dropthis/node/dist/edge.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.cts +1 -1
- package/node_modules/@dropthis/node/dist/edge.d.ts +1 -1
- package/node_modules/@dropthis/node/dist/edge.mjs +23 -6
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +31 -6
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +8 -2
- package/node_modules/@dropthis/node/dist/index.d.ts +8 -2
- package/node_modules/@dropthis/node/dist/index.mjs +30 -6
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -1
- package/node_modules/@dropthis/node/package.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ All publish flags:
|
|
|
155
155
|
|------|-------------|
|
|
156
156
|
| `--title <title>` | Drop title |
|
|
157
157
|
| `--visibility <public\|unlisted>` | Drop visibility |
|
|
158
|
-
| `--password <password>` |
|
|
158
|
+
| `--password <password>` | Require a password to view the drop (Pro plan) |
|
|
159
159
|
| `--noindex` | Prevent search indexing |
|
|
160
160
|
| `--entry <path>` | Entry file for directories |
|
|
161
161
|
| `--content-type <mime>` | MIME type (required for stdin) |
|
|
@@ -294,7 +294,7 @@ dropthis publish ./dist --url
|
|
|
294
294
|
| 0 | Success |
|
|
295
295
|
| 1 | API or generic error |
|
|
296
296
|
| 2 | Invalid usage |
|
|
297
|
-
| 3 | Auth required |
|
|
297
|
+
| 3 | Auth required (no credential, or the API returned 401 — re-authenticate) |
|
|
298
298
|
| 4 | Local input error (file or directory not found, too many files) |
|
|
299
299
|
| 5 | Network error (could not reach the API) |
|
|
300
300
|
| 6 | Domain verification pending (`domains verify` one-shot, not live yet) |
|
package/dist/cli.cjs
CHANGED
|
@@ -227,6 +227,15 @@ function cliNextAction(error2) {
|
|
|
227
227
|
if (error2.code === "publish_conflict") {
|
|
228
228
|
return "The drop changed state mid-publish (likely deleted). Run dropthis publish again to create a fresh drop.";
|
|
229
229
|
}
|
|
230
|
+
if (error2.code === "access_token_cannot_delete_account") {
|
|
231
|
+
return "Account deletion needs a real API key, not a login session. Create one with dropthis api-keys create, then re-run with --api-key sk_\u2026";
|
|
232
|
+
}
|
|
233
|
+
if (error2.code === "otp_expired") {
|
|
234
|
+
return "Request a fresh code with: dropthis login request --email <email>.";
|
|
235
|
+
}
|
|
236
|
+
if (error2.code === "otp_invalid") {
|
|
237
|
+
return "Re-enter the code from your email; if it keeps failing, request a fresh one with dropthis login request --email <email>.";
|
|
238
|
+
}
|
|
230
239
|
if (error2.statusCode === 404 || error2.code === "not_found") {
|
|
231
240
|
return "Check the drop id or slug and retry; list your drops with dropthis list.";
|
|
232
241
|
}
|
|
@@ -434,17 +443,10 @@ function writeApiError(deps, details) {
|
|
|
434
443
|
function cliErrorCodeFor(details) {
|
|
435
444
|
if (details.code === "network_error") return "network_error";
|
|
436
445
|
if (details.code === "file_not_found") return "local_input_error";
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
function writeApiErrorSimple(deps, message) {
|
|
440
|
-
if (deps.outputMode === "human") {
|
|
441
|
-
deps.stderr(`${error(message)}
|
|
442
|
-
`);
|
|
443
|
-
} else {
|
|
444
|
-
deps.stderr(`${JSON.stringify(errorEnvelope("api_error", message))}
|
|
445
|
-
`);
|
|
446
|
+
if (details.statusCode === 401 || details.code === "authentication_required" || details.code === "missing_api_key") {
|
|
447
|
+
return "auth_error";
|
|
446
448
|
}
|
|
447
|
-
return
|
|
449
|
+
return "api_error";
|
|
448
450
|
}
|
|
449
451
|
function writeAuthError(deps) {
|
|
450
452
|
return writeError(
|
|
@@ -916,13 +918,13 @@ async function runDoctor(_input, deps) {
|
|
|
916
918
|
const authSource = credential?.source ?? "missing";
|
|
917
919
|
const storageBackend = stored?.storage ?? "none";
|
|
918
920
|
const pairs = [
|
|
919
|
-
["Version", "0.
|
|
921
|
+
["Version", "0.24.0"],
|
|
920
922
|
["Auth", authSource],
|
|
921
923
|
["Storage", storageBackend]
|
|
922
924
|
];
|
|
923
925
|
writeKv(deps, pairs, {
|
|
924
926
|
ok: true,
|
|
925
|
-
version: "0.
|
|
927
|
+
version: "0.24.0",
|
|
926
928
|
auth: { source: authSource },
|
|
927
929
|
storage: { backend: storageBackend }
|
|
928
930
|
});
|
|
@@ -1548,19 +1550,16 @@ async function runLoginRequest(input, deps) {
|
|
|
1548
1550
|
email: input.email
|
|
1549
1551
|
});
|
|
1550
1552
|
if (result.error) {
|
|
1551
|
-
deps.
|
|
1552
|
-
`${JSON.stringify(errorEnvelope("api_error", result.error.message))}
|
|
1553
|
-
`
|
|
1554
|
-
);
|
|
1555
|
-
return { exitCode: exitCodeFor("api_error") };
|
|
1553
|
+
return writeApiError(deps, result.error);
|
|
1556
1554
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1555
|
+
writeHumanOrJson(
|
|
1556
|
+
deps,
|
|
1557
|
+
success(`Code sent to ${input.email}. Check your inbox.`),
|
|
1558
|
+
{
|
|
1559
1559
|
ok: true,
|
|
1560
1560
|
email: input.email,
|
|
1561
1561
|
expires_in: result.data.expiresIn
|
|
1562
|
-
}
|
|
1563
|
-
`
|
|
1562
|
+
}
|
|
1564
1563
|
);
|
|
1565
1564
|
return { exitCode: 0 };
|
|
1566
1565
|
}
|
|
@@ -1570,20 +1569,12 @@ async function runLoginVerify(input, deps) {
|
|
|
1570
1569
|
code: input.otp
|
|
1571
1570
|
});
|
|
1572
1571
|
if (session.error) {
|
|
1573
|
-
deps.
|
|
1574
|
-
`${JSON.stringify(errorEnvelope("api_error", session.error.message))}
|
|
1575
|
-
`
|
|
1576
|
-
);
|
|
1577
|
-
return { exitCode: exitCodeFor("api_error") };
|
|
1572
|
+
return writeApiError(deps, session.error);
|
|
1578
1573
|
}
|
|
1579
1574
|
const authedClient = deps.createClient(session.data.token);
|
|
1580
1575
|
const apiKey = await authedClient.apiKeys.create({ label: "CLI" });
|
|
1581
1576
|
if (apiKey.error) {
|
|
1582
|
-
deps.
|
|
1583
|
-
`${JSON.stringify(errorEnvelope("api_error", apiKey.error.message))}
|
|
1584
|
-
`
|
|
1585
|
-
);
|
|
1586
|
-
return { exitCode: exitCodeFor("api_error") };
|
|
1577
|
+
return writeApiError(deps, apiKey.error);
|
|
1587
1578
|
}
|
|
1588
1579
|
await deps.store.save({
|
|
1589
1580
|
apiKey: apiKey.data.key,
|
|
@@ -1593,16 +1584,13 @@ async function runLoginVerify(input, deps) {
|
|
|
1593
1584
|
email: input.email,
|
|
1594
1585
|
storage: "secure"
|
|
1595
1586
|
});
|
|
1596
|
-
deps.
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
})}
|
|
1604
|
-
`
|
|
1605
|
-
);
|
|
1587
|
+
writeHumanOrJson(deps, success(`Logged in as ${input.email}.`), {
|
|
1588
|
+
ok: true,
|
|
1589
|
+
account_id: apiKey.data.accountId ?? session.data.accountId,
|
|
1590
|
+
key_id: apiKey.data.id,
|
|
1591
|
+
key_last4: apiKey.data.keyLast4,
|
|
1592
|
+
is_new_account: apiKey.data.isNewAccount ?? session.data.isNewAccount
|
|
1593
|
+
});
|
|
1606
1594
|
return { exitCode: 0 };
|
|
1607
1595
|
}
|
|
1608
1596
|
|
|
@@ -1612,12 +1600,12 @@ async function runLogout(input, deps) {
|
|
|
1612
1600
|
let revokeError;
|
|
1613
1601
|
if (input.revoke && stored?.keyId) {
|
|
1614
1602
|
const result = await deps.client.apiKeys.delete(stored.keyId);
|
|
1615
|
-
if (result?.error) revokeError = result.error
|
|
1603
|
+
if (result?.error) revokeError = result.error;
|
|
1616
1604
|
}
|
|
1605
|
+
await deps.store.clear();
|
|
1617
1606
|
if (revokeError) {
|
|
1618
|
-
return
|
|
1607
|
+
return writeApiError(deps, revokeError);
|
|
1619
1608
|
}
|
|
1620
|
-
await deps.store.clear();
|
|
1621
1609
|
writeHumanOrJson(deps, success("Logged out."), { ok: true });
|
|
1622
1610
|
return { exitCode: 0 };
|
|
1623
1611
|
}
|
|
@@ -2789,7 +2777,7 @@ function buildProgram(options = {}) {
|
|
|
2789
2777
|
` ${import_picocolors6.default.cyan("dropthis login")}`,
|
|
2790
2778
|
` ${import_picocolors6.default.cyan("dropthis publish ./dist")}`
|
|
2791
2779
|
].join("\n")
|
|
2792
|
-
).version("0.
|
|
2780
|
+
).version("0.24.0").configureHelp({
|
|
2793
2781
|
subcommandTerm(cmd) {
|
|
2794
2782
|
const args = cmd.registeredArguments.map((a) => {
|
|
2795
2783
|
const name = a.name();
|
|
@@ -3391,7 +3379,7 @@ ${import_picocolors6.default.bold("Canonical vs raw URLs:")}`,
|
|
|
3391
3379
|
);
|
|
3392
3380
|
const result = await runUpgrade(commandOptions, {
|
|
3393
3381
|
...deps,
|
|
3394
|
-
currentVersion: "0.
|
|
3382
|
+
currentVersion: "0.24.0"
|
|
3395
3383
|
});
|
|
3396
3384
|
process.exitCode = result.exitCode;
|
|
3397
3385
|
});
|
|
@@ -3645,7 +3633,7 @@ var showNotice = shouldShowNotice({
|
|
|
3645
3633
|
if (showNotice) {
|
|
3646
3634
|
const notice = noticeFromCache({
|
|
3647
3635
|
cache: updateCache,
|
|
3648
|
-
currentVersion: "0.
|
|
3636
|
+
currentVersion: "0.24.0"
|
|
3649
3637
|
});
|
|
3650
3638
|
if (notice) {
|
|
3651
3639
|
process.stderr.write(`
|