@dropthis/cli 0.17.0 → 0.18.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/dist/cli.cjs +89 -28
- package/dist/cli.cjs.map +1 -1
- package/node_modules/@dropthis/node/README.md +10 -6
- package/node_modules/@dropthis/node/dist/{drops-BxDQRrvu.d.cts → drops-DmTdQTnd.d.cts} +10 -15
- package/node_modules/@dropthis/node/dist/{drops-BxDQRrvu.d.ts → drops-DmTdQTnd.d.ts} +10 -15
- package/node_modules/@dropthis/node/dist/edge.cjs +17 -59
- 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 +17 -59
- package/node_modules/@dropthis/node/dist/edge.mjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.cjs +17 -59
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -1
- package/node_modules/@dropthis/node/dist/index.d.cts +2 -2
- package/node_modules/@dropthis/node/dist/index.d.ts +2 -2
- package/node_modules/@dropthis/node/dist/index.mjs +17 -59
- 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/dist/cli.cjs
CHANGED
|
@@ -702,6 +702,13 @@ var COMMAND_ANNOTATIONS = {
|
|
|
702
702
|
auth: "required",
|
|
703
703
|
examples: ["dropthis get drop_abc --json"]
|
|
704
704
|
},
|
|
705
|
+
resolve: {
|
|
706
|
+
auth: "required",
|
|
707
|
+
examples: [
|
|
708
|
+
"dropthis resolve https://abc123.dropthis.app/",
|
|
709
|
+
"dropthis resolve abc123 --json"
|
|
710
|
+
]
|
|
711
|
+
},
|
|
705
712
|
list: {
|
|
706
713
|
auth: "required",
|
|
707
714
|
examples: [
|
|
@@ -909,13 +916,13 @@ async function runDoctor(_input, deps) {
|
|
|
909
916
|
const authSource = credential?.source ?? "missing";
|
|
910
917
|
const storageBackend = stored?.storage ?? "none";
|
|
911
918
|
const pairs = [
|
|
912
|
-
["Version", "0.
|
|
919
|
+
["Version", "0.18.0"],
|
|
913
920
|
["Auth", authSource],
|
|
914
921
|
["Storage", storageBackend]
|
|
915
922
|
];
|
|
916
923
|
writeKv(deps, pairs, {
|
|
917
924
|
ok: true,
|
|
918
|
-
version: "0.
|
|
925
|
+
version: "0.18.0",
|
|
919
926
|
auth: { source: authSource },
|
|
920
927
|
storage: { backend: storageBackend }
|
|
921
928
|
});
|
|
@@ -1286,9 +1293,19 @@ async function resolveDropTarget(target, deps) {
|
|
|
1286
1293
|
return {
|
|
1287
1294
|
ok: true,
|
|
1288
1295
|
dropId: resolved.data.id,
|
|
1289
|
-
|
|
1296
|
+
resolvedFrom: target,
|
|
1297
|
+
...resolved.data.slug ? { slug: resolved.data.slug } : {},
|
|
1298
|
+
...typeof resolved.data.title === "string" ? { title: resolved.data.title } : {}
|
|
1290
1299
|
};
|
|
1291
1300
|
}
|
|
1301
|
+
function writeResolvedLine(deps, resolved) {
|
|
1302
|
+
if (!resolved.resolvedFrom || deps.outputMode !== "human") return;
|
|
1303
|
+
const title = resolved.title ? ` (${resolved.title})` : "";
|
|
1304
|
+
deps.stdout(
|
|
1305
|
+
`${hint(`resolved ${resolved.resolvedFrom} \u2192 ${resolved.dropId}${title}`)}
|
|
1306
|
+
`
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1292
1309
|
async function runDropsList(input, deps) {
|
|
1293
1310
|
try {
|
|
1294
1311
|
await requireCredential({
|
|
@@ -1352,6 +1369,7 @@ async function runDropsGet(target, _input, deps) {
|
|
|
1352
1369
|
}
|
|
1353
1370
|
const resolved = await resolveDropTarget(target, deps);
|
|
1354
1371
|
if (!resolved.ok) return { exitCode: resolved.exitCode };
|
|
1372
|
+
writeResolvedLine(deps, resolved);
|
|
1355
1373
|
const result = await deps.client.drops.get(resolved.dropId);
|
|
1356
1374
|
if (result.error) return writeApiError(deps, result.error);
|
|
1357
1375
|
const data = result.data;
|
|
@@ -1374,6 +1392,34 @@ async function runDropsGet(target, _input, deps) {
|
|
|
1374
1392
|
writeKv(deps, pairs, { ok: true, drop: result.data });
|
|
1375
1393
|
return { exitCode: 0 };
|
|
1376
1394
|
}
|
|
1395
|
+
async function runDropsResolve(target, _input, deps) {
|
|
1396
|
+
try {
|
|
1397
|
+
await requireCredential({
|
|
1398
|
+
...deps.apiKey ? { apiKey: deps.apiKey } : {},
|
|
1399
|
+
env: deps.env,
|
|
1400
|
+
store: deps.store
|
|
1401
|
+
});
|
|
1402
|
+
} catch {
|
|
1403
|
+
return writeAuthError(deps);
|
|
1404
|
+
}
|
|
1405
|
+
const result = await deps.client.drops.resolve(target);
|
|
1406
|
+
if (result.error) return writeApiError(deps, result.error);
|
|
1407
|
+
if (result.data === null) {
|
|
1408
|
+
return writeApiError(deps, {
|
|
1409
|
+
code: "not_found",
|
|
1410
|
+
message: `No drop matching "${target}" found in your account.`,
|
|
1411
|
+
suggestion: "It may belong to another account or have been deleted. Run dropthis list to see your drops, or pass the full drop_\u2026 id."
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
const drop = result.data;
|
|
1415
|
+
const pairs = [];
|
|
1416
|
+
if (drop.id) pairs.push(["ID", String(drop.id)]);
|
|
1417
|
+
if (drop.url) pairs.push(["URL", url(String(drop.url))]);
|
|
1418
|
+
if (drop.title) pairs.push(["Title", String(drop.title)]);
|
|
1419
|
+
if (drop.slug) pairs.push(["Slug", String(drop.slug)]);
|
|
1420
|
+
writeKv(deps, pairs, { ok: true, drop });
|
|
1421
|
+
return { exitCode: 0 };
|
|
1422
|
+
}
|
|
1377
1423
|
async function runDropsDelete(target, input, deps) {
|
|
1378
1424
|
if (!input.yes && input.interactive === false) {
|
|
1379
1425
|
return writeError(
|
|
@@ -1393,6 +1439,7 @@ async function runDropsDelete(target, input, deps) {
|
|
|
1393
1439
|
}
|
|
1394
1440
|
const resolved = await resolveDropTarget(target, deps);
|
|
1395
1441
|
if (!resolved.ok) return { exitCode: resolved.exitCode };
|
|
1442
|
+
writeResolvedLine(deps, resolved);
|
|
1396
1443
|
const dropId = resolved.dropId;
|
|
1397
1444
|
if (!input.yes && input.interactive !== false) {
|
|
1398
1445
|
const confirmed = await prompts3.confirm({
|
|
@@ -1820,6 +1867,7 @@ async function runPull(target, input, deps) {
|
|
|
1820
1867
|
}
|
|
1821
1868
|
const resolved = await resolveDropTarget(target, deps);
|
|
1822
1869
|
if (!resolved.ok) return { exitCode: resolved.exitCode };
|
|
1870
|
+
writeResolvedLine(deps, resolved);
|
|
1823
1871
|
const dropId = resolved.dropId;
|
|
1824
1872
|
const defaultDirName = resolved.slug || resolved.dropId;
|
|
1825
1873
|
const spin = shouldSpin(deps.outputMode) ? createSpinner("Pulling content\u2026", deps.stderr) : void 0;
|
|
@@ -1905,22 +1953,30 @@ function contentOptions(options) {
|
|
|
1905
1953
|
if (options.path !== void 0) out.path = options.path;
|
|
1906
1954
|
return out;
|
|
1907
1955
|
}
|
|
1908
|
-
async function runUpdateContent(
|
|
1956
|
+
async function runUpdateContent(target, input, raw, deps) {
|
|
1957
|
+
const apiKey = raw.apiKey ?? deps.apiKey;
|
|
1909
1958
|
try {
|
|
1910
1959
|
await requireCredential({
|
|
1911
|
-
...
|
|
1960
|
+
...apiKey ? { apiKey } : {},
|
|
1912
1961
|
env: deps.env,
|
|
1913
1962
|
store: deps.store
|
|
1914
1963
|
});
|
|
1915
1964
|
} catch {
|
|
1916
1965
|
return writeAuthError(deps);
|
|
1917
1966
|
}
|
|
1967
|
+
const resolveDeps = {
|
|
1968
|
+
...deps,
|
|
1969
|
+
...apiKey ? { apiKey } : {}
|
|
1970
|
+
};
|
|
1971
|
+
const resolved = await resolveDropTarget(target, resolveDeps);
|
|
1972
|
+
if (!resolved.ok) return { exitCode: resolved.exitCode };
|
|
1973
|
+
const dropId = resolved.dropId;
|
|
1918
1974
|
if (raw.dryRun) {
|
|
1919
1975
|
return handleDryRun(dropId, input, raw, deps);
|
|
1920
1976
|
}
|
|
1977
|
+
writeResolvedLine(deps, resolved);
|
|
1921
1978
|
let spin;
|
|
1922
1979
|
try {
|
|
1923
|
-
assertDropId(dropId);
|
|
1924
1980
|
const hasInput = Array.isArray(input) ? input.length > 0 : input !== void 0;
|
|
1925
1981
|
if (!hasInput) {
|
|
1926
1982
|
return writeError(
|
|
@@ -1967,7 +2023,6 @@ async function handleDryRun(dropId, input, raw, deps) {
|
|
|
1967
2023
|
);
|
|
1968
2024
|
}
|
|
1969
2025
|
try {
|
|
1970
|
-
assertDropId(dropId);
|
|
1971
2026
|
const hasInput = Array.isArray(input) ? input.length > 0 : input !== void 0;
|
|
1972
2027
|
if (!hasInput) {
|
|
1973
2028
|
return writeError(
|
|
@@ -1995,34 +2050,35 @@ async function handleDryRun(dropId, input, raw, deps) {
|
|
|
1995
2050
|
return writeError(deps, code, message);
|
|
1996
2051
|
}
|
|
1997
2052
|
}
|
|
1998
|
-
function assertDropId(target) {
|
|
1999
|
-
if (!target.startsWith("drop_")) {
|
|
2000
|
-
throw new Error(
|
|
2001
|
-
"update-content needs the full drop_\u2026 id from the publish response, not the URL slug, for example drop_..."
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
2053
|
|
|
2006
2054
|
// src/commands/update-settings.ts
|
|
2007
2055
|
var prompts5 = __toESM(require("@clack/prompts"), 1);
|
|
2008
2056
|
var NO_SETTINGS_MESSAGE = "Nothing to update. Provide at least one settings option.";
|
|
2009
2057
|
var NO_SETTINGS_NEXT_ACTION = "Run dropthis update-settings --help, or retry with one of: --title, --visibility, --password, --no-password, --noindex, --index, --expires-at, --metadata, or --metadata-file. To replace the content at the URL instead, use dropthis update-content <dropId> ./dist.";
|
|
2010
|
-
async function runUpdateSettings(
|
|
2058
|
+
async function runUpdateSettings(target, raw, deps) {
|
|
2059
|
+
const apiKey = raw.apiKey ?? deps.apiKey;
|
|
2011
2060
|
try {
|
|
2012
2061
|
await requireCredential({
|
|
2013
|
-
...
|
|
2062
|
+
...apiKey ? { apiKey } : {},
|
|
2014
2063
|
env: deps.env,
|
|
2015
2064
|
store: deps.store
|
|
2016
2065
|
});
|
|
2017
2066
|
} catch {
|
|
2018
2067
|
return writeAuthError(deps);
|
|
2019
2068
|
}
|
|
2069
|
+
const resolveDeps = {
|
|
2070
|
+
...deps,
|
|
2071
|
+
...apiKey ? { apiKey } : {}
|
|
2072
|
+
};
|
|
2073
|
+
const resolved = await resolveDropTarget(target, resolveDeps);
|
|
2074
|
+
if (!resolved.ok) return { exitCode: resolved.exitCode };
|
|
2075
|
+
const dropId = resolved.dropId;
|
|
2020
2076
|
if (raw.dryRun) {
|
|
2021
2077
|
return handleDryRun2(dropId, raw, deps);
|
|
2022
2078
|
}
|
|
2079
|
+
writeResolvedLine(deps, resolved);
|
|
2023
2080
|
let spin;
|
|
2024
2081
|
try {
|
|
2025
|
-
assertDropId2(dropId);
|
|
2026
2082
|
let parsed = await parseDropOptions(raw);
|
|
2027
2083
|
if (!hasSettingsFields(parsed)) {
|
|
2028
2084
|
if (shouldPrompt(deps)) {
|
|
@@ -2211,7 +2267,6 @@ async function handleDryRun2(dropId, raw, deps) {
|
|
|
2211
2267
|
);
|
|
2212
2268
|
}
|
|
2213
2269
|
try {
|
|
2214
|
-
assertDropId2(dropId);
|
|
2215
2270
|
const options = await parseDropOptions(raw);
|
|
2216
2271
|
const fields = {};
|
|
2217
2272
|
if (options.title) fields.title = options.title;
|
|
@@ -2230,13 +2285,6 @@ async function handleDryRun2(dropId, raw, deps) {
|
|
|
2230
2285
|
return writeError(deps, "invalid_usage", message);
|
|
2231
2286
|
}
|
|
2232
2287
|
}
|
|
2233
|
-
function assertDropId2(target) {
|
|
2234
|
-
if (!target.startsWith("drop_")) {
|
|
2235
|
-
throw new Error(
|
|
2236
|
-
"update-settings needs the full drop_\u2026 id from the publish response, not the URL slug, for example drop_..."
|
|
2237
|
-
);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
2288
|
|
|
2241
2289
|
// src/commands/upgrade.ts
|
|
2242
2290
|
var import_node_child_process = require("child_process");
|
|
@@ -2596,7 +2644,7 @@ function buildProgram(options = {}) {
|
|
|
2596
2644
|
` ${import_picocolors6.default.cyan("dropthis login")}`,
|
|
2597
2645
|
` ${import_picocolors6.default.cyan("dropthis publish ./dist")}`
|
|
2598
2646
|
].join("\n")
|
|
2599
|
-
).version("0.
|
|
2647
|
+
).version("0.18.0").configureHelp({
|
|
2600
2648
|
subcommandTerm(cmd) {
|
|
2601
2649
|
const args = cmd.registeredArguments.map((a) => {
|
|
2602
2650
|
const name = a.name();
|
|
@@ -2849,6 +2897,19 @@ ${import_picocolors6.default.bold("Canonical vs raw URLs:")}`,
|
|
|
2849
2897
|
const result = await runDropsGet(dropId, commandOptions, deps);
|
|
2850
2898
|
process.exitCode = result.exitCode;
|
|
2851
2899
|
});
|
|
2900
|
+
program.command("resolve <target>").description(
|
|
2901
|
+
"Resolve a public drop URL or slug back to its drop_\u2026 id (accepts the id too).\nWrites are id-only \u2014 use this to recover the id from a URL, then update-content/update-settings/delete by that id."
|
|
2902
|
+
).option("--json", "Force JSON output").addHelpText(
|
|
2903
|
+
"after",
|
|
2904
|
+
examplesBlock([
|
|
2905
|
+
"dropthis resolve https://abc123.dropthis.app/ # \u2192 drop_\u2026 id + url",
|
|
2906
|
+
"dropthis resolve abc123 --json | jq -r .drop.id"
|
|
2907
|
+
])
|
|
2908
|
+
).action(async (target, commandOptions) => {
|
|
2909
|
+
const deps = await commandDeps(program, options, store, commandOptions);
|
|
2910
|
+
const result = await runDropsResolve(target, commandOptions, deps);
|
|
2911
|
+
process.exitCode = result.exitCode;
|
|
2912
|
+
});
|
|
2852
2913
|
program.command("list").description("List your drops").option("--limit <n>", "Page size", parseInteger).option("--cursor <cursor>", "Pagination cursor").option("--domain <hostname>", "Only drops mounted on this custom domain").option("--json", "Force JSON output").addHelpText(
|
|
2853
2914
|
"after",
|
|
2854
2915
|
examplesBlock([
|
|
@@ -3153,7 +3214,7 @@ ${import_picocolors6.default.bold("Canonical vs raw URLs:")}`,
|
|
|
3153
3214
|
);
|
|
3154
3215
|
const result = await runUpgrade(commandOptions, {
|
|
3155
3216
|
...deps,
|
|
3156
|
-
currentVersion: "0.
|
|
3217
|
+
currentVersion: "0.18.0"
|
|
3157
3218
|
});
|
|
3158
3219
|
process.exitCode = result.exitCode;
|
|
3159
3220
|
});
|
|
@@ -3396,7 +3457,7 @@ var showNotice = shouldShowNotice({
|
|
|
3396
3457
|
if (showNotice) {
|
|
3397
3458
|
const notice = noticeFromCache({
|
|
3398
3459
|
cache: updateCache,
|
|
3399
|
-
currentVersion: "0.
|
|
3460
|
+
currentVersion: "0.18.0"
|
|
3400
3461
|
});
|
|
3401
3462
|
if (notice) {
|
|
3402
3463
|
process.stderr.write(`
|