@dayofweek/dcli 1.9.0 → 1.9.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/dist/bin/dcli.js CHANGED
@@ -267,10 +267,31 @@ brainSource
267
267
  .option("--mime <mimeType>", "MIME type; inferred from extension when omitted")
268
268
  .option("--meeting", "Mark this source as a recorded meeting")
269
269
  .option("--consent-ack", "Confirm recorded participants were informed and consented")
270
+ .option("--as-source", "Store an HTML document as a raw source instead of publishing it as a Page")
270
271
  .action(async (opts) => {
271
272
  if (opts.meeting && !opts.consentAck) {
272
273
  throw new Error("--consent-ack is required: you are attesting that recorded participants were informed and consented");
273
274
  }
275
+ // A full HTML document is almost always meant to be a Page (the Pages tab),
276
+ // which is published as a note via `brain share` — not stored as a raw
277
+ // source. Uploading it here would land it in Sources, where nobody looks
278
+ // for a page. Refuse unless the caller explicitly wants a raw source.
279
+ if (!opts.asSource) {
280
+ const looksHtmlName = /\.html?$/i.test(opts.file);
281
+ let looksHtmlContent = false;
282
+ try {
283
+ const head = readFileSync(opts.file, "utf8").slice(0, 512);
284
+ looksHtmlContent = /^\s*(<!doctype html|<html[\s>])/i.test(head);
285
+ }
286
+ catch {
287
+ // Unreadable as text (binary) — not an HTML page.
288
+ }
289
+ if (looksHtmlName || looksHtmlContent) {
290
+ throw new Error("This looks like a Page (a full HTML document). Pages live in the area's Pages tab and are published with:\n" +
291
+ " dcli brain share --area <areaId> --title \"…\" --file " + opts.file + "\n" +
292
+ "Pass --as-source only if you really want the raw HTML stored as a source file.");
293
+ }
294
+ }
274
295
  output(await getClient().uploadBrainSource({
275
296
  areaId: opts.area,
276
297
  path: opts.file,
@@ -5144,7 +5144,7 @@ var import_promises4 = require("node:readline/promises");
5144
5144
  // package.json
5145
5145
  var package_default = {
5146
5146
  name: "@dayofweek/dcli",
5147
- version: "1.9.0",
5147
+ version: "1.9.1",
5148
5148
  description: "CLI for the Day of Week AgTech platform \u2014 read data and submit proposals for review",
5149
5149
  license: "MIT",
5150
5150
  type: "module",
@@ -5435,10 +5435,25 @@ brainSource.command("get <uri>").description("Read source metadata and derived t
5435
5435
  if (source.areaId !== parsed.areaId) throw new Error("Server returned a mismatched area");
5436
5436
  output(source);
5437
5437
  });
5438
- brainSource.command("upload").description("Upload an original file or meeting recording").requiredOption("--area <areaId>", "Destination area").requiredOption("--file <path>", "File to upload").option("--mime <mimeType>", "MIME type; inferred from extension when omitted").option("--meeting", "Mark this source as a recorded meeting").option("--consent-ack", "Confirm recorded participants were informed and consented").action(async (opts) => {
5438
+ brainSource.command("upload").description("Upload an original file or meeting recording").requiredOption("--area <areaId>", "Destination area").requiredOption("--file <path>", "File to upload").option("--mime <mimeType>", "MIME type; inferred from extension when omitted").option("--meeting", "Mark this source as a recorded meeting").option("--consent-ack", "Confirm recorded participants were informed and consented").option("--as-source", "Store an HTML document as a raw source instead of publishing it as a Page").action(async (opts) => {
5439
5439
  if (opts.meeting && !opts.consentAck) {
5440
5440
  throw new Error("--consent-ack is required: you are attesting that recorded participants were informed and consented");
5441
5441
  }
5442
+ if (!opts.asSource) {
5443
+ const looksHtmlName = /\.html?$/i.test(opts.file);
5444
+ let looksHtmlContent = false;
5445
+ try {
5446
+ const head = (0, import_node_fs8.readFileSync)(opts.file, "utf8").slice(0, 512);
5447
+ looksHtmlContent = /^\s*(<!doctype html|<html[\s>])/i.test(head);
5448
+ } catch {
5449
+ }
5450
+ if (looksHtmlName || looksHtmlContent) {
5451
+ throw new Error(
5452
+ `This looks like a Page (a full HTML document). Pages live in the area's Pages tab and are published with:
5453
+ dcli brain share --area <areaId> --title "\u2026" --file ` + opts.file + "\nPass --as-source only if you really want the raw HTML stored as a source file."
5454
+ );
5455
+ }
5456
+ }
5442
5457
  output(await getClient().uploadBrainSource({
5443
5458
  areaId: opts.area,
5444
5459
  path: opts.file,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dayofweek/dcli",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "CLI for the Day of Week AgTech platform \u2014 read data and submit proposals for review",
5
5
  "license": "MIT",
6
6
  "type": "module",