filecafe 0.3.4 → 0.3.5
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
CHANGED
|
@@ -53,14 +53,25 @@ Settings → API tokens on file.cafe. `logout` revokes the token even if you sav
|
|
|
53
53
|
## Upload
|
|
54
54
|
|
|
55
55
|
```sh
|
|
56
|
-
filecafe upload screenshot.png #
|
|
57
|
-
filecafe upload a.png b.mp4 notes.txt # one
|
|
58
|
-
filecafe upload build.zip | pbcopy #
|
|
56
|
+
filecafe upload screenshot.png # shows the share URL, size and expiry date
|
|
57
|
+
filecafe upload a.png b.mp4 notes.txt # one summary per file, in order
|
|
58
|
+
filecafe upload build.zip | pbcopy # piped: just the link, copied to the clipboard
|
|
59
59
|
filecafe upload video.mp4 --collection <uuid> # add to a collection
|
|
60
60
|
filecafe upload report.pdf --json # machine-readable output
|
|
61
61
|
filecafe upload big.mov --quiet # no progress output
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
In a terminal each upload ends with a summary:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Successfully uploaded screenshot.png
|
|
68
|
+
URL: https://file.cafe/9e54VITGmPY.png
|
|
69
|
+
Size: 1.2 MB
|
|
70
|
+
Expires: November 7th 2026
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
When the output is piped (scripts, CI, AI agents) or with `--quiet`, stdout is just the share URLs, one per line.
|
|
74
|
+
|
|
64
75
|
Files are uploaded one after another; large files (over 64 MiB) are split into parts that upload in parallel. Every input is checked before anything is uploaded: if any path is missing or is not a regular file, nothing is uploaded.
|
|
65
76
|
|
|
66
77
|
### `--json` output
|
|
@@ -76,7 +87,8 @@ A single JSON array on stdout with one object per input file, in the order given
|
|
|
76
87
|
"filename": "report.pdf",
|
|
77
88
|
"size": 482113,
|
|
78
89
|
"url": "https://file.cafe/...",
|
|
79
|
-
"password_protected": false
|
|
90
|
+
"password_protected": false,
|
|
91
|
+
"expires_at": "2026-11-07T12:00:00+00:00"
|
|
80
92
|
},
|
|
81
93
|
{
|
|
82
94
|
"file": "missing.png",
|
|
@@ -86,6 +98,8 @@ A single JSON array on stdout with one object per input file, in the order given
|
|
|
86
98
|
]
|
|
87
99
|
```
|
|
88
100
|
|
|
101
|
+
`expires_at` is `null` for files that never expire.
|
|
102
|
+
|
|
89
103
|
The exit code is `0` if every file uploaded and `1` if any failed.
|
|
90
104
|
|
|
91
105
|
## Configuration
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as updateCachePath, d as normalizeBaseUrl, f as readConfig, l as configPath, m as writeConfig, n as fetchLatestVersion, o as updateUpdateCache, p as resolveSettings, r as readUpdateCache, s as VERSION, t as CHECK_INTERVAL_MS, u as deleteConfig } from "./update-cache-
|
|
2
|
+
import { a as updateCachePath, d as normalizeBaseUrl, f as readConfig, l as configPath, m as writeConfig, n as fetchLatestVersion, o as updateUpdateCache, p as resolveSettings, r as readUpdateCache, s as VERSION, t as CHECK_INTERVAL_MS, u as deleteConfig } from "./update-cache-DPfI7tdr.js";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { homedir, hostname, tmpdir } from "node:os";
|
|
5
5
|
import { realpath, stat } from "node:fs/promises";
|
|
@@ -327,6 +327,14 @@ function supportsHyperlinks(stream, env) {
|
|
|
327
327
|
function hyperlink(text, url) {
|
|
328
328
|
return `\u001B]8;;${url}\u0007${text}\u001B]8;;\u0007`;
|
|
329
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* A URL styled like the Vercel CLI's links: cyan and clickable where the terminal supports
|
|
332
|
+
* links (which usually underline it themselves), otherwise cyan and underlined.
|
|
333
|
+
*/
|
|
334
|
+
function styledUrl(stream, env, url) {
|
|
335
|
+
const color = colorsFor(stream, env);
|
|
336
|
+
return supportsHyperlinks(stream, env) ? hyperlink(color.cyan(url), url) : color.cyan.underline(url);
|
|
337
|
+
}
|
|
330
338
|
const FRAMES = [
|
|
331
339
|
"⠋",
|
|
332
340
|
"⠙",
|
|
@@ -826,6 +834,27 @@ function uploadFilename(path) {
|
|
|
826
834
|
const keep = extension.length > 0 && extension.length <= 16 ? extension : [];
|
|
827
835
|
return characters.slice(0, MAX_FILENAME_LENGTH - keep.length).join("") + keep.join("");
|
|
828
836
|
}
|
|
837
|
+
/** "November 7th 2026", in the local time zone. */
|
|
838
|
+
function formatExpiry(iso) {
|
|
839
|
+
const date = new Date(iso);
|
|
840
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
841
|
+
const day = date.getDate();
|
|
842
|
+
const suffix = {
|
|
843
|
+
one: "st",
|
|
844
|
+
two: "nd",
|
|
845
|
+
few: "rd"
|
|
846
|
+
}[new Intl.PluralRules("en-US", { type: "ordinal" }).select(day)] ?? "th";
|
|
847
|
+
return `${date.toLocaleString("en-US", { month: "long" })} ${day}${suffix} ${date.getFullYear()}`;
|
|
848
|
+
}
|
|
849
|
+
function summary(result, url, color) {
|
|
850
|
+
const lines = [
|
|
851
|
+
`${color.green("Successfully uploaded")} ${color.bold(result.filename)}`,
|
|
852
|
+
`${color.gray("URL:")} ${url}`,
|
|
853
|
+
`${color.gray("Size:")} ${formatBytes(result.size)}`
|
|
854
|
+
];
|
|
855
|
+
if (result.expires_at !== void 0) lines.push(`${color.gray("Expires:")} ${result.expires_at === null ? "Never" : formatExpiry(result.expires_at)}`);
|
|
856
|
+
return `${lines.join("\n")}\n`;
|
|
857
|
+
}
|
|
829
858
|
function formatBytes(bytes) {
|
|
830
859
|
const units = [
|
|
831
860
|
"B",
|
|
@@ -894,6 +923,9 @@ async function uploadCommand(files, options, globals, context) {
|
|
|
894
923
|
if (files.length === 0) throw new CliError("No files given. Usage: filecafe upload <files...>");
|
|
895
924
|
const showProgress = Boolean(context.stderr.isTTY) && !options.json && !options.quiet;
|
|
896
925
|
const err = colorsFor(context.stderr, context.env);
|
|
926
|
+
const showSummary = Boolean(context.stdout.isTTY) && !options.quiet;
|
|
927
|
+
const out = colorsFor(context.stdout, context.env);
|
|
928
|
+
let summaries = 0;
|
|
897
929
|
const progress = createProgress(context, showProgress);
|
|
898
930
|
const notice = (message) => {
|
|
899
931
|
if (!options.quiet) {
|
|
@@ -951,7 +983,8 @@ async function uploadCommand(files, options, globals, context) {
|
|
|
951
983
|
filename: completed.filename,
|
|
952
984
|
size: completed.size,
|
|
953
985
|
url: completed.url ?? null,
|
|
954
|
-
password_protected: Boolean(completed.password_protected)
|
|
986
|
+
password_protected: Boolean(completed.password_protected),
|
|
987
|
+
...completed.expires_at !== void 0 && { expires_at: completed.expires_at }
|
|
955
988
|
};
|
|
956
989
|
} catch (error) {
|
|
957
990
|
result = {
|
|
@@ -966,7 +999,8 @@ async function uploadCommand(files, options, globals, context) {
|
|
|
966
999
|
}
|
|
967
1000
|
results.push(result);
|
|
968
1001
|
if (!options.json) {
|
|
969
|
-
if (result.ok && result.url) context.stdout.write(`${result.url}
|
|
1002
|
+
if (result.ok && result.url && showSummary) context.stdout.write(`${summaries++ > 0 ? "\n" : ""}${summary(result, styledUrl(context.stdout, context.env, result.url), out)}`);
|
|
1003
|
+
else if (result.ok && result.url) context.stdout.write(`${result.url}\n`);
|
|
970
1004
|
else if (result.ok) context.stderr.write(`${err.yellow(`${file}:`)} uploaded (id ${result.id}), but the server returned no share link.\n`);
|
|
971
1005
|
else context.stderr.write(`${err.red(`${file}:`)} ${result.error}\n`);
|
|
972
1006
|
}
|
|
@@ -1057,7 +1091,7 @@ function startUpdateCheck(context) {
|
|
|
1057
1091
|
async function offerUpdate(context, version) {
|
|
1058
1092
|
const color = colorsFor(context.stderr, context.env);
|
|
1059
1093
|
const run = (command) => color.cyan(command);
|
|
1060
|
-
context.stderr.write(version ? `\nUpdate available for filecafe (${color.gray(`v${VERSION}`)} → ${color.green(`v${version}`)})\nChangelog: ${
|
|
1094
|
+
context.stderr.write(version ? `\nUpdate available for filecafe (${color.gray(`v${VERSION}`)} → ${color.green(`v${version}`)})\nChangelog: ${styledUrl(context.stderr, context.env, `${RELEASES_URL}/v${version}`)}\n` : "\nA newer version of filecafe may be available.\n");
|
|
1061
1095
|
if (context.env.npm_command === "exec" || context.scriptPath.replaceAll("\\", "/").includes("/_npx/")) {
|
|
1062
1096
|
context.stderr.write(`Run: ${run("npx filecafe@latest")}\n`);
|
|
1063
1097
|
return;
|
|
@@ -1201,7 +1235,7 @@ function isNewer(candidate, current) {
|
|
|
1201
1235
|
const MAIN_EXAMPLES = `
|
|
1202
1236
|
Examples:
|
|
1203
1237
|
$ filecafe login # log in via your browser (one time)
|
|
1204
|
-
$ filecafe upload report.pdf #
|
|
1238
|
+
$ filecafe upload report.pdf # shows the share URL, size and expiry date
|
|
1205
1239
|
$ filecafe upload a.png b.mp4 --json # machine-readable results (for scripts and AI agents)
|
|
1206
1240
|
$ filecafe upload ./build.zip | pbcopy # copy the share URL to the clipboard
|
|
1207
1241
|
$ FILECAFE_TOKEN=... npx filecafe upload notes.txt --json # CI / headless
|
|
@@ -1215,10 +1249,11 @@ Exit codes: 0 on success, 1 on any failure. Errors and progress go to stderr.
|
|
|
1215
1249
|
`;
|
|
1216
1250
|
const UPLOAD_EXAMPLES = `
|
|
1217
1251
|
Output:
|
|
1218
|
-
|
|
1252
|
+
Terminal: a summary per file (share URL, size, expiry date).
|
|
1253
|
+
Piped or --quiet: one share URL per line on stdout, in the order the files were given.
|
|
1219
1254
|
--json: a JSON array on stdout with one object per input file:
|
|
1220
|
-
{"file": "a.png", "ok": true, "id": "...", "filename": "a.png",
|
|
1221
|
-
"
|
|
1255
|
+
{"file": "a.png", "ok": true, "id": "...", "filename": "a.png", "size": 1234,
|
|
1256
|
+
"url": "https://file.cafe/...", "password_protected": false, "expires_at": "2026-11-07T12:00:00+00:00"}
|
|
1222
1257
|
{"file": "b.png", "ok": false, "error": "No such file."}
|
|
1223
1258
|
Exit code is 0 if every file uploaded, 1 if any failed.
|
|
1224
1259
|
|
|
@@ -108,7 +108,7 @@ async function resolveSettings(environment, urlOption) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
// src/version.ts
|
|
111
|
-
const VERSION = "0.3.
|
|
111
|
+
const VERSION = "0.3.5";
|
|
112
112
|
// src/update-cache.ts
|
|
113
113
|
const REGISTRY_URL = "https://registry.npmjs.org/filecafe/latest";
|
|
114
114
|
/** Ask npm at most once a day. */
|
package/dist/update-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as refreshUpdateCache, s as VERSION } from "./update-cache-
|
|
1
|
+
import { i as refreshUpdateCache, s as VERSION } from "./update-cache-DPfI7tdr.js";
|
|
2
2
|
// src/update-worker.ts
|
|
3
3
|
/**
|
|
4
4
|
* Spawned detached by the CLI to refresh the update cache, so no command ever waits on npm.
|