@plume-press/cli 0.4.0 → 0.5.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.mjs CHANGED
@@ -35490,6 +35490,16 @@ var init_markers = __esm({
35490
35490
  }
35491
35491
  });
35492
35492
 
35493
+ // packages/core/src/media-object-key.ts
35494
+ var identifier;
35495
+ var init_media_object_key = __esm({
35496
+ "packages/core/src/media-object-key.ts"() {
35497
+ "use strict";
35498
+ init_zod();
35499
+ identifier = external_exports.uuidv7();
35500
+ }
35501
+ });
35502
+
35493
35503
  // packages/core/src/permissions.ts
35494
35504
  var init_permissions = __esm({
35495
35505
  "packages/core/src/permissions.ts"() {
@@ -35513,6 +35523,7 @@ var init_src = __esm({
35513
35523
  init_delivered();
35514
35524
  init_image_size();
35515
35525
  init_markers();
35526
+ init_media_object_key();
35516
35527
  init_permissions();
35517
35528
  init_reconcile();
35518
35529
  init_rich_text();
@@ -35522,7 +35533,7 @@ var init_src = __esm({
35522
35533
  });
35523
35534
 
35524
35535
  // packages/sdk/src/protocol.ts
35525
- var MAX_CONTENT_DATA_BYTES, MAX_CONTENT_RESPONSE_BYTES, MAX_MEDIA_BYTES, contentBindingSchema, name, depth, contentQuerySchema, mediaPath, mediaQuerySchema, mediaRequestSchema, contentRequestSchema, timestamp, contentRecordSchema, contentAssetSchema, contentResponseSchema;
35536
+ var MAX_CONTENT_DATA_BYTES, MAX_CONTENT_RESPONSE_BYTES, MAX_MEDIA_BYTES, contentBindingSchema, latestPublicationSchema, name, depth, contentQuerySchema, mediaPath, mediaQuerySchema, mediaRequestSchema, contentRequestSchema, timestamp, contentRecordSchema, contentAssetSchema, contentResponseSchema;
35526
35537
  var init_protocol = __esm({
35527
35538
  "packages/sdk/src/protocol.ts"() {
35528
35539
  "use strict";
@@ -35535,6 +35546,12 @@ var init_protocol = __esm({
35535
35546
  contentVersionId: external_exports.uuidv7(),
35536
35547
  schemaHash: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/)
35537
35548
  }).strict();
35549
+ latestPublicationSchema = external_exports.object({
35550
+ binding: contentBindingSchema,
35551
+ commitSha: external_exports.string().min(1).max(64),
35552
+ branch: external_exports.string().min(1).max(256),
35553
+ acceptedAt: external_exports.iso.datetime({ offset: false, precision: 3 })
35554
+ });
35538
35555
  name = external_exports.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/).max(100);
35539
35556
  depth = external_exports.union([external_exports.literal(0), external_exports.literal(1)]).optional();
35540
35557
  contentQuerySchema = external_exports.discriminatedUnion("kind", [
@@ -35573,6 +35590,11 @@ var init_protocol = __esm({
35573
35590
  updatedAt: timestamp
35574
35591
  });
35575
35592
  contentAssetSchema = external_exports.object({
35593
+ /** Direct immutable public object URL when the service has a media origin. */
35594
+ url: external_exports.url().refine((value) => {
35595
+ const url2 = new URL(value);
35596
+ return !url2.username && !url2.password && (url2.protocol === "https:" || url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname));
35597
+ }, "Media URLs require HTTPS or a local development origin.").optional(),
35576
35598
  filename: external_exports.string().min(1).max(256),
35577
35599
  mediaType: external_exports.enum([
35578
35600
  "image/jpeg",
@@ -35602,7 +35624,7 @@ var init_protocol = __esm({
35602
35624
 
35603
35625
  // packages/cli/src/developer.ts
35604
35626
  import { execFile } from "node:child_process";
35605
- import { realpath } from "node:fs/promises";
35627
+ import { readFile, realpath, stat } from "node:fs/promises";
35606
35628
  import { resolve } from "node:path";
35607
35629
  import { pathToFileURL } from "node:url";
35608
35630
  import { promisify } from "node:util";
@@ -35943,6 +35965,23 @@ async function readInput() {
35943
35965
  );
35944
35966
  }
35945
35967
  }
35968
+ async function unresolvedSchemaImport(error62, schemaPath) {
35969
+ if (!(error62 instanceof Error) || error62.code !== "MODULE_NOT_FOUND")
35970
+ return void 0;
35971
+ let source;
35972
+ try {
35973
+ const file2 = await stat(schemaPath);
35974
+ if (!file2.isFile() || file2.size > MAX_SCHEMA_SOURCE_BYTES) return void 0;
35975
+ source = await readFile(schemaPath, "utf8");
35976
+ } catch {
35977
+ return void 0;
35978
+ }
35979
+ if (/(?:\bfrom|\bimport|\brequire)\s*\(?\s*["']@plume\/cli\/schema["']/.test(
35980
+ source
35981
+ ))
35982
+ return "plume.schema.ts imports @plume/cli/schema, which is now @plume-press/cli/schema. Change the import, then install @plume-press/cli.";
35983
+ return "An import in plume.schema.ts can't be found. Install the package or fix the import path.";
35984
+ }
35946
35985
  async function loadCheckoutSchema(cwd) {
35947
35986
  try {
35948
35987
  const jiti = createJiti(pathToFileURL(resolve(cwd, "package.json")).href, {
@@ -35959,10 +35998,10 @@ async function loadCheckoutSchema(cwd) {
35959
35998
  if (Buffer.byteLength(canonicalJson(schema3), "utf8") > MAX_SCHEMA_BYTES)
35960
35999
  throw new Error();
35961
36000
  return schema3;
35962
- } catch {
36001
+ } catch (error62) {
35963
36002
  throw new PlumeToolError(
35964
36003
  "INVALID_SCHEMA",
35965
- "Export a valid declarative schema named schema from plume.schema.ts."
36004
+ await unresolvedSchemaImport(error62, resolve(cwd, "plume.schema.ts")) ?? "Export a valid declarative schema named schema from plume.schema.ts."
35966
36005
  );
35967
36006
  }
35968
36007
  }
@@ -36026,7 +36065,7 @@ async function developerMain(args, env2 = process.env) {
36026
36065
  return 1;
36027
36066
  }
36028
36067
  }
36029
- var execFileAsync, MAX_INPUT_BYTES, MAX_RESPONSE_BYTES, MAX_SCHEMA_BYTES, schemaIssues, remoteText, detailShapes, id, context, writer, revision, record2, sha, operation, prepareInput, inspectResult, preparedResult, schemas, developerActions, PlumeToolError, developerHelp;
36068
+ var execFileAsync, MAX_INPUT_BYTES, MAX_RESPONSE_BYTES, MAX_SCHEMA_BYTES, MAX_SCHEMA_SOURCE_BYTES, schemaIssues, remoteText, detailShapes, id, context, writer, revision, record2, sha, operation, prepareInput, inspectResult, preparedResult, schemas, developerActions, PlumeToolError, developerHelp;
36030
36069
  var init_developer = __esm({
36031
36070
  "packages/cli/src/developer.ts"() {
36032
36071
  "use strict";
@@ -36037,6 +36076,7 @@ var init_developer = __esm({
36037
36076
  MAX_INPUT_BYTES = 512 * 1024;
36038
36077
  MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
36039
36078
  MAX_SCHEMA_BYTES = 256 * 1024;
36079
+ MAX_SCHEMA_SOURCE_BYTES = 1024 * 1024;
36040
36080
  schemaIssues = external_exports.object({
36041
36081
  issues: external_exports.array(
36042
36082
  external_exports.object({
@@ -36691,7 +36731,7 @@ var init_package = __esm({
36691
36731
  "packages/sdk/package.json"() {
36692
36732
  package_default = {
36693
36733
  name: "@plume-press/sdk",
36694
- version: "0.1.0",
36734
+ version: "0.2.0",
36695
36735
  private: true,
36696
36736
  license: "MIT",
36697
36737
  type: "module",
@@ -36718,7 +36758,7 @@ var init_package2 = __esm({
36718
36758
  "packages/cli/package.json"() {
36719
36759
  package_default2 = {
36720
36760
  name: "@plume-press/cli",
36721
- version: "0.4.0",
36761
+ version: "0.5.0",
36722
36762
  private: true,
36723
36763
  license: "MIT",
36724
36764
  type: "module",
@@ -36768,9 +36808,9 @@ function assertRuntime() {
36768
36808
  }
36769
36809
  async function inspect(path) {
36770
36810
  try {
36771
- const stat = await lstat3(path);
36772
- if (stat.isFile()) return "file";
36773
- if (stat.isDirectory()) return "directory";
36811
+ const stat2 = await lstat3(path);
36812
+ if (stat2.isFile()) return "file";
36813
+ if (stat2.isDirectory()) return "directory";
36774
36814
  throw new PlumeLocalError(
36775
36815
  "UNSAFE_PATH",
36776
36816
  `${path} must be a regular file or directory, not a symbolic link or special file.`
@@ -37146,7 +37186,7 @@ import { createHash, randomBytes } from "node:crypto";
37146
37186
  import {
37147
37187
  lstat,
37148
37188
  mkdir,
37149
- readFile,
37189
+ readFile as readFile2,
37150
37190
  rename,
37151
37191
  rm,
37152
37192
  writeFile
@@ -37181,7 +37221,7 @@ var statusLabels = {
37181
37221
  };
37182
37222
  function updateLabel(id3) {
37183
37223
  const timestamp2 = Number.parseInt(id3.replaceAll("-", "").slice(0, 12), 16);
37184
- return Number.isFinite(timestamp2) ? `Update \xB7 ${new Intl.DateTimeFormat("en", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" }).format(timestamp2)}` : "Update";
37224
+ return Number.isFinite(timestamp2) ? `Update \xB7 ${new Intl.DateTimeFormat("en", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", timeZone: "Europe/Prague" }).format(timestamp2)}` : "Update";
37185
37225
  }
37186
37226
  function clock(at) {
37187
37227
  const time3 = new Date(at);
@@ -37276,7 +37316,7 @@ var credentialHash = (token) => createHash("sha256").update(token).digest("hex")
37276
37316
  async function readSession(ctx) {
37277
37317
  try {
37278
37318
  const session = sessionShape.parse(
37279
- JSON.parse(await readFile(sessionFile(ctx), "utf8"))
37319
+ JSON.parse(await readFile2(sessionFile(ctx), "utf8"))
37280
37320
  );
37281
37321
  return session.credential === credentialHash(ctx.token) ? session : null;
37282
37322
  } catch {
@@ -37546,7 +37586,7 @@ function assignments(fields, pairs) {
37546
37586
  }
37547
37587
  async function readData(ctx, path) {
37548
37588
  try {
37549
- const value = JSON.parse(await readFile(resolve2(ctx.io.cwd, path), "utf8"));
37589
+ const value = JSON.parse(await readFile2(resolve2(ctx.io.cwd, path), "utf8"));
37550
37590
  if (!value || typeof value !== "object" || Array.isArray(value))
37551
37591
  throw new Error();
37552
37592
  return value;
@@ -38965,8 +39005,8 @@ async function existingLock(path) {
38965
39005
  try {
38966
39006
  const handle2 = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW);
38967
39007
  try {
38968
- const stat = await handle2.stat();
38969
- if (!stat.isFile() || stat.size > MAX_LOCK_BYTES) throw new Error();
39008
+ const stat2 = await handle2.stat();
39009
+ if (!stat2.isFile() || stat2.size > MAX_LOCK_BYTES) throw new Error();
38970
39010
  const value = JSON.parse(
38971
39011
  new TextDecoder("utf-8", { fatal: true }).decode(
38972
39012
  await handle2.readFile()
@@ -39208,10 +39248,10 @@ async function validateSchema(cwd, path, binding) {
39208
39248
  if (new TextEncoder().encode(canonicalJson(schema3)).byteLength > MAX_SCHEMA_BYTES2)
39209
39249
  throw new Error();
39210
39250
  hash2 = await schemaHash(schema3);
39211
- } catch {
39251
+ } catch (error62) {
39212
39252
  throw new PlumeBuildError(
39213
39253
  "INVALID_SCHEMA",
39214
- "Export a valid declarative schema named schema from plume.schema.ts (maximum 256 KiB)."
39254
+ await unresolvedSchemaImport(error62, resolve7(cwd, path)) ?? "Export a valid declarative schema named schema from plume.schema.ts (maximum 256 KiB)."
39215
39255
  );
39216
39256
  }
39217
39257
  if (hash2 !== binding.schemaHash)
package/dist/local.mjs CHANGED
@@ -34120,7 +34120,7 @@ function deliverRecord(fields, data, context, prefix = []) {
34120
34120
  const asset = context.asset(entry.id);
34121
34121
  if (!asset || kind === "image" && !asset.mediaType.startsWith("image/"))
34122
34122
  throw new TypeError("Unknown media asset.");
34123
- const url2 = context.mediaUrl(path);
34123
+ const url2 = context.preferAssetUrl && asset.url ? asset.url : context.mediaUrl(path);
34124
34124
  return kind === "image" ? {
34125
34125
  url: url2,
34126
34126
  width: asset.width,
@@ -34156,7 +34156,10 @@ function deliverRecord(fields, data, context, prefix = []) {
34156
34156
  case "richText":
34157
34157
  if (typeof value === "string")
34158
34158
  result[field.name] = renderRichText(value, {
34159
- imageUrl: (_image, index2) => context.mediaUrl([...path, index2])
34159
+ imageUrl: (image, index2) => {
34160
+ const asset = context.asset(image.id);
34161
+ return context.preferAssetUrl && asset?.url ? asset.url : context.mediaUrl([...path, index2]);
34162
+ }
34160
34163
  });
34161
34164
  break;
34162
34165
  case "reference":
@@ -34180,6 +34183,9 @@ function defaultMediaUrl(input2) {
34180
34183
  // packages/core/src/image-size.ts
34181
34184
  var MAX_HEADER_BYTES = 1024 * 1024;
34182
34185
 
34186
+ // packages/core/src/media-object-key.ts
34187
+ var identifier = external_exports.uuidv7();
34188
+
34183
34189
  // packages/local/src/index.ts
34184
34190
  import { lstat, mkdir, open as openFile, rm } from "node:fs/promises";
34185
34191
  import { join, resolve } from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plume-press/cli",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "The plume command: set up a website's Plume CMS and check its builds.",
5
5
  "homepage": "https://app.plume.press",
6
6
  "license": "MIT",