@easybits.cloud/cli 0.15.2 → 0.15.4

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
@@ -42,6 +42,7 @@ easybits sandboxes exec sb_abc123 -- npm test
42
42
  easybits sandboxes logs sb_abc123 --unit myapp --lines 100 --since "10 min ago" --grep ERROR
43
43
  easybits sandboxes files ls sb_abc123 /data/work
44
44
  easybits sandboxes files read sb_abc123 /etc/os-release
45
+ easybits sandboxes files read sb_abc123 /data/app.db --out app.db # tope 8 MB: más grande sale con código 1 ("truncated")
45
46
  easybits sandboxes files write sb_abc123 /data/work/app.js ./app.js
46
47
  easybits sandboxes suspend sb_abc123
47
48
  easybits sandboxes resume sb_abc123
@@ -105,6 +106,7 @@ easybits agents create --from helper.json --name helper-3
105
106
  # Files, websites, account
106
107
  easybits files ls
107
108
  easybits files upload ./report.pdf
109
+ easybits files upload ./logo.png --public # open CDN URL; private by default
108
110
  easybits files rm FILE_ID --yes
109
111
  easybits websites ls
110
112
  easybits websites create "My shop" --slug my-shop # slug optional
package/dist/index.js CHANGED
@@ -866,22 +866,30 @@ var files = {
866
866
  },
867
867
  upload: {
868
868
  summary: "Upload a local file",
869
- usage: "easybits files upload <path>",
870
- examples: ["easybits files upload ./report.pdf", "easybits files upload ./logo.png --json"],
869
+ usage: "easybits files upload <path> [--public]",
870
+ options: {
871
+ public: { type: "boolean", description: "Public file with an open CDN URL (default: private)" }
872
+ },
873
+ examples: ["easybits files upload ./report.pdf", "easybits files upload ./logo.png --public --json"],
871
874
  async run(ctx) {
872
875
  const path = need(ctx, 0, "path", this.usage);
873
876
  if (!existsSync2(path)) throw usageError(t(`File not found: ${path}`, `No existe el archivo: ${path}`), this.usage);
874
877
  const size = statSync(path).size;
875
878
  const contentType = MIME[extname(path).slice(1).toLowerCase()] || "application/octet-stream";
876
879
  const eb = await getClient(ctx);
877
- const data = await eb.uploadFile({ fileName: basename(path), contentType, size });
880
+ const access = bool(ctx, "public") ? "public" : void 0;
881
+ const data = await eb.uploadFile({ fileName: basename(path), contentType, size, access });
878
882
  const res = await fetch(data.putUrl, {
879
883
  method: "PUT",
880
884
  body: readFileSync3(path),
881
885
  headers: { "Content-Type": contentType }
882
886
  });
883
887
  if (!res.ok) throw new CliError(t(`Upload failed: storage answered ${res.status}`, `Fall\xF3 la subida: el almacenamiento contest\xF3 ${res.status}`), 1, void 0, "upload_failed", res.status);
884
- emit(ctx, data.file, () => console.log(`${t("Uploaded", "Subido")}: ${data.file.id}`));
888
+ const url = data.file.url;
889
+ emit(ctx, data.file, () => {
890
+ console.log(`${t("Uploaded", "Subido")}: ${data.file.id}`);
891
+ if (url) console.log(`URL: ${url}`);
892
+ });
885
893
  }
886
894
  },
887
895
  rm: {
@@ -1236,6 +1244,16 @@ async function sandbox(ctx, usage2) {
1236
1244
  const eb = await getClient(ctx);
1237
1245
  return eb.sandboxes.get(id);
1238
1246
  }
1247
+ var FILE_READ_CAP = 8 << 20;
1248
+ function checkNotTruncated(size, path) {
1249
+ if (size < FILE_READ_CAP) return;
1250
+ throw new CliError(
1251
+ t(`${path} is 8 MB or larger and the read was cut at 8 MB.`, `${path} pesa 8 MB o m\xE1s y la lectura se cort\xF3 en 8 MB.`),
1252
+ 1,
1253
+ t("Compress or split it inside the sandbox first (exec), then read the pieces.", "Compr\xEDmelo o p\xE1rtelo dentro de la caja (exec) y lee las partes."),
1254
+ "truncated"
1255
+ );
1256
+ }
1239
1257
  var FILES_USAGE = "easybits sandboxes files <ls|read|write> <sandbox> <path> [local-file]";
1240
1258
  var sandboxes = {
1241
1259
  name: "sandboxes",
@@ -1401,10 +1419,12 @@ var sandboxes = {
1401
1419
  const out = str(ctx, "out");
1402
1420
  if (out) {
1403
1421
  const r = await sb.files.read(path, { encoding: "base64" });
1422
+ checkNotTruncated(r.size, path);
1404
1423
  writeFileSync3(out, Buffer.from(r.content, "base64"));
1405
1424
  emit(ctx, { path, out, size: r.size }, () => console.error(t(`Saved ${fmtBytes(r.size)} to ${out}`, `Guard\xE9 ${fmtBytes(r.size)} en ${out}`)));
1406
1425
  } else {
1407
1426
  const r = await sb.files.read(path);
1427
+ checkNotTruncated(r.size, path);
1408
1428
  emit(ctx, r, () => process.stdout.write(r.content));
1409
1429
  }
1410
1430
  } else if (action === "write") {
@@ -3715,7 +3735,7 @@ async function updateNotice(current2) {
3715
3735
  }
3716
3736
 
3717
3737
  // src/commands/doctor.ts
3718
- var VERSION = true ? "0.15.2" : "dev";
3738
+ var VERSION = true ? "0.15.4" : "dev";
3719
3739
  var doctor2 = {
3720
3740
  name: "doctor",
3721
3741
  group: "Account",
@@ -4000,6 +4020,7 @@ var HELP_ES = {
4000
4020
  "Your files in EasyBits storage": "Tus archivos en el almacenamiento de EasyBits",
4001
4021
  "List your files": "Enlista tus archivos",
4002
4022
  "Upload a local file": "Sube un archivo local",
4023
+ "Public file with an open CDN URL (default: private)": "Archivo p\xFAblico con URL abierta en el CDN (por defecto: privado)",
4003
4024
  "Delete a file (soft delete, 7-day trash)": "Borra un archivo (a la papelera 7 d\xEDas)",
4004
4025
  "List your static websites": "Enlista tus sitios est\xE1ticos",
4005
4026
  "Static websites: list, create, change slug": "Sitios est\xE1ticos: enlistar, crear, cambiar slug",
@@ -4223,7 +4244,7 @@ function normalizeArgs(input) {
4223
4244
  }
4224
4245
 
4225
4246
  // src/index.ts
4226
- var VERSION2 = true ? "0.15.2" : "dev";
4247
+ var VERSION2 = true ? "0.15.4" : "dev";
4227
4248
  var GLOBAL_OPTIONS = {
4228
4249
  json: { type: "boolean" },
4229
4250
  token: { type: "string" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easybits.cloud/cli",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "Official CLI for EasyBits, the cloud for AI agents — sandboxes, hosting, domains, databases, agents and files from your terminal",
5
5
  "type": "module",
6
6
  "bin": {