@plume-press/cli 0.7.0 → 0.8.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.
Files changed (3) hide show
  1. package/README.md +4 -2
  2. package/dist/cli.mjs +444 -239
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Use Node.js 22.13 or newer. Install the scoped package in your website project before using its plume command. These examples use npm; keep your project's chosen package manager.
4
4
 
5
5
  ```sh
6
- npm install --save-dev @plume-press/cli@0.7.0
6
+ npm install --save-dev @plume-press/cli@0.8.0
7
7
  npx plume init --check
8
8
  npx plume --help
9
9
  ```
@@ -29,7 +29,9 @@ A successful connection saves nonsecret Site/editor URL facts in Git-ignored .pl
29
29
 
30
30
  ## Check a connected build
31
31
 
32
- Use plume build -- <your existing framework build command> in the build script. The wrapper checks the committed plume.lock and matching plume.schema.ts against the sealed content version, writes .plume/binding.json, then runs the framework. It performs no publication. PLUME_ENDPOINT defaults to https://app.plume.press; build validation needs no token. The same fixed binding can build a prepared host preview or production artifact. Schema files execute locally as trusted framework configuration does.
32
+ Choose plume build --delivery production-ssr -- <your existing framework build command> for public request-time content, --delivery selected-preview for an immutable publication candidate, or --delivery static (the default) for a pinned build. The wrapper validates clean exact Git HEAD, plume.lock and matching plume.schema.ts once, writes .plume/binding.json and .plume/delivery.json, then runs the framework. Selected-preview HEAD trailers must identify an existing immutable native reservation and agree with the lock. Compilation records operation ID, actual SHA and environment; later host evidence must match the final prepared target. There is no build UUID or preparation wait. It performs no publication. PLUME_ENDPOINT defaults to https://app.plume.press; validation needs no token. Schema files execute locally as trusted framework configuration does.
33
+
34
+ Production SSR resolves createLatestPlume once per render and shares the reader across page queries; selected preview/static use createPlume with the compiled binding. Emit same-reader render evidence with the compiled descriptor. Static or cached pages need a rebuild or real invalidation for freshness; runtime environment variables must not switch an immutable preview to latest.
33
35
 
34
36
  ## Export a Site
35
37
 
package/dist/cli.mjs CHANGED
@@ -35540,7 +35540,7 @@ var init_src = __esm({
35540
35540
  });
35541
35541
 
35542
35542
  // packages/sdk/src/protocol.ts
35543
- 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;
35543
+ var MAX_CONTENT_DATA_BYTES, MAX_CONTENT_RESPONSE_BYTES, MAX_MEDIA_BYTES, contentBindingSchema, publicPublicationSchema, latestPublicationSchema, previewCandidateSchema, deliveryArtifactSchema, deliveryDescriptorSchema, renderEvidenceSchema, name, depth, contentQuerySchema, mediaPath, mediaQuerySchema, mediaRequestSchema, contentRequestSchema, timestamp, contentRecordSchema, contentAssetSchema, contentResponseSchema;
35544
35544
  var init_protocol = __esm({
35545
35545
  "packages/sdk/src/protocol.ts"() {
35546
35546
  "use strict";
@@ -35553,12 +35553,50 @@ var init_protocol = __esm({
35553
35553
  contentVersionId: external_exports.uuidv7(),
35554
35554
  schemaHash: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/)
35555
35555
  }).strict();
35556
+ publicPublicationSchema = external_exports.object({
35557
+ operationId: external_exports.uuidv7(),
35558
+ sequence: external_exports.number().int().positive().max(Number.MAX_SAFE_INTEGER),
35559
+ commitSha: external_exports.string().regex(/^[a-f0-9]{40}$/),
35560
+ branch: external_exports.string().min(1).max(256),
35561
+ acceptedAt: external_exports.iso.datetime({ offset: false, precision: 3 })
35562
+ }).strict();
35556
35563
  latestPublicationSchema = external_exports.object({
35557
35564
  binding: contentBindingSchema,
35558
35565
  commitSha: external_exports.string().min(1).max(64),
35559
35566
  branch: external_exports.string().min(1).max(256),
35560
- acceptedAt: external_exports.iso.datetime({ offset: false, precision: 3 })
35561
- });
35567
+ acceptedAt: external_exports.iso.datetime({ offset: false, precision: 3 }),
35568
+ /** Null on a legacy channel without an exact native receipt. */
35569
+ publication: publicPublicationSchema.nullable().default(null)
35570
+ }).refine(
35571
+ (value) => !value.publication || value.publication.commitSha === value.commitSha && value.publication.branch === value.branch && value.publication.acceptedAt === value.acceptedAt
35572
+ );
35573
+ previewCandidateSchema = external_exports.object({
35574
+ operationId: external_exports.uuidv7(),
35575
+ commitSha: external_exports.string().regex(/^[a-f0-9]{40}$/)
35576
+ }).strict();
35577
+ deliveryArtifactSchema = external_exports.object({
35578
+ commitSha: external_exports.string().regex(/^[a-f0-9]{40}$/),
35579
+ environment: external_exports.enum(["production", "preview"])
35580
+ }).strict();
35581
+ deliveryDescriptorSchema = external_exports.object({
35582
+ version: external_exports.literal(1),
35583
+ mode: external_exports.enum(["production-ssr", "selected-preview", "static"]),
35584
+ artifact: deliveryArtifactSchema,
35585
+ binding: contentBindingSchema,
35586
+ candidate: previewCandidateSchema.nullable()
35587
+ }).strict().refine(
35588
+ (value) => value.mode !== "production-ssr" || value.artifact.environment === "production"
35589
+ ).refine(
35590
+ (value) => value.mode !== "selected-preview" || value.artifact.environment === "preview" && value.candidate?.commitSha === value.artifact.commitSha
35591
+ );
35592
+ renderEvidenceSchema = external_exports.object({
35593
+ version: external_exports.literal(1),
35594
+ mode: external_exports.enum(["production-ssr", "selected-preview", "static"]),
35595
+ artifact: deliveryArtifactSchema,
35596
+ binding: contentBindingSchema,
35597
+ candidate: previewCandidateSchema.nullable(),
35598
+ publication: publicPublicationSchema.nullable()
35599
+ }).strict();
35562
35600
  name = external_exports.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/).max(100);
35563
35601
  depth = external_exports.union([external_exports.literal(0), external_exports.literal(1)]).optional();
35564
35602
  contentQuerySchema = external_exports.discriminatedUnion("kind", [
@@ -35900,56 +35938,56 @@ async function runLocalPrepare(options2) {
35900
35938
  "The local plume.schema.ts does not match this Update's registered schema. Register it before preparing."
35901
35939
  );
35902
35940
  await verifyCheckout(resolve(options2.cwd), inspect2, input2);
35903
- if (inspect2.state === "prepared") {
35904
- if (!inspect2.binding || !inspect2.preparedHeadSha || inspect2.headSha !== inspect2.preparedHeadSha || inspect2.binding.siteId !== input2.siteId || inspect2.binding.contentVersionId !== input2.expectedVersionId || inspect2.binding.schemaHash !== inspect2.schemaHash)
35905
- throw new PlumeToolError(
35906
- "INVALID_RESPONSE",
35907
- "Plume returned an inconsistent prepared Update. No preparation was requested."
35908
- );
35909
- return {
35910
- preparedHeadSha: inspect2.preparedHeadSha,
35911
- binding: inspect2.binding,
35912
- next: `git pull --ff-only origin ${inspect2.branch}`
35913
- };
35914
- }
35915
35941
  if (!input2.sessionId || !input2.token)
35916
35942
  throw new PlumeToolError(
35917
35943
  "INVALID_INPUT",
35918
- "An active preparation requires the writer sessionId and token."
35919
- );
35920
- const expectedHeadSha = inspect2.state === "preparing" ? inspect2.preparationBaseSha : inspect2.headSha;
35921
- if (!expectedHeadSha)
35922
- throw new PlumeToolError(
35923
- "INVALID_RESPONSE",
35924
- "Plume did not provide the preparation starting commit."
35925
- );
35926
- let prepared;
35927
- try {
35928
- prepared = preparedResult.parse(
35929
- (await runDeveloperTool({
35930
- action: "update.prepare",
35931
- input: { ...input2, expectedHeadSha },
35932
- endpoint: options2.endpoint,
35933
- token: options2.token
35934
- })).result
35935
- );
35936
- } catch (error62) {
35937
- if (error62 instanceof PlumeToolError) throw error62;
35938
- throw new PlumeToolError(
35939
- "INVALID_RESPONSE",
35940
- "Preparation may have completed, but Plume returned an invalid receipt. Inspect the Update before retrying."
35944
+ "Preparation requires the writer sessionId and token."
35941
35945
  );
35942
- }
35943
- if (prepared.update.id !== input2.updateId || prepared.update.branch !== inspect2.branch || prepared.update.preparationId !== input2.preparationId || prepared.update.preparationBaseSha !== expectedHeadSha || prepared.binding.siteId !== input2.siteId || prepared.binding.contentVersionId !== input2.expectedVersionId || prepared.binding.schemaHash !== inspect2.schemaHash)
35944
- throw new PlumeToolError(
35945
- "INVALID_RESPONSE",
35946
- "Preparation may have completed, but its receipt did not match the requested Update. Inspect before retrying."
35947
- );
35948
- return {
35949
- preparedHeadSha: prepared.update.preparedHeadSha,
35950
- binding: prepared.binding,
35951
- next: `git pull --ff-only origin ${inspect2.branch}`
35952
- };
35946
+ const plan = external_exports.object({
35947
+ fingerprint: external_exports.string(),
35948
+ operationId: id.nullable(),
35949
+ content: external_exports.object({ present: external_exports.boolean() }),
35950
+ website: external_exports.object({ present: external_exports.boolean() })
35951
+ }).parse(
35952
+ (await runDeveloperTool({
35953
+ action: "publication.plan",
35954
+ input: { siteId: input2.siteId, updateId: input2.updateId },
35955
+ endpoint: options2.endpoint,
35956
+ token: options2.token
35957
+ })).result
35958
+ );
35959
+ if (plan.operationId) {
35960
+ if (plan.operationId !== input2.preparationId)
35961
+ throw new PlumeToolError(
35962
+ "UPDATE_CONFLICT",
35963
+ "Another saved publication owns this Update. Inspect it before retrying."
35964
+ );
35965
+ return (await runDeveloperTool({
35966
+ action: "publication.status",
35967
+ input: {
35968
+ siteId: input2.siteId,
35969
+ updateId: input2.updateId,
35970
+ operationId: plan.operationId
35971
+ },
35972
+ endpoint: options2.endpoint,
35973
+ token: options2.token
35974
+ })).result;
35975
+ }
35976
+ return (await runDeveloperTool({
35977
+ action: "publication.start",
35978
+ input: {
35979
+ siteId: input2.siteId,
35980
+ updateId: input2.updateId,
35981
+ operationId: input2.preparationId,
35982
+ sessionId: input2.sessionId,
35983
+ token: input2.token,
35984
+ planFingerprint: plan.fingerprint,
35985
+ scope: plan.content.present && plan.website.present ? "both" : plan.content.present ? "content" : "website",
35986
+ purpose: "preview"
35987
+ },
35988
+ endpoint: options2.endpoint,
35989
+ token: options2.token
35990
+ })).result;
35953
35991
  }
35954
35992
  async function readInput() {
35955
35993
  let size = 0;
@@ -36074,7 +36112,7 @@ async function developerMain(args, env2 = process.env) {
36074
36112
  return 1;
36075
36113
  }
36076
36114
  }
36077
- 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;
36115
+ 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, schemas, developerActions, PlumeToolError, developerHelp;
36078
36116
  var init_developer = __esm({
36079
36117
  "packages/cli/src/developer.ts"() {
36080
36118
  "use strict";
@@ -36166,22 +36204,28 @@ var init_developer = __esm({
36166
36204
  schemaHash: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
36167
36205
  binding: contentBindingSchema.nullable()
36168
36206
  });
36169
- preparedResult = external_exports.object({
36170
- update: external_exports.object({
36171
- id,
36172
- branch: external_exports.string(),
36173
- state: external_exports.literal("prepared"),
36174
- preparationId: id,
36175
- preparationBaseSha: sha,
36176
- preparedHeadSha: sha
36177
- }),
36178
- binding: contentBindingSchema
36179
- });
36180
36207
  schemas = {
36181
36208
  // Needs no IDs: answers with the credential's own Site and Update.
36182
36209
  status: external_exports.object({ sessionId: id.optional() }).strict(),
36183
36210
  context: external_exports.object(context).strict(),
36184
36211
  "update.inspect": external_exports.object(context).strict(),
36212
+ "publication.plan": external_exports.object(context).strict(),
36213
+ "publication.start": external_exports.object({
36214
+ ...context,
36215
+ ...writer,
36216
+ operationId: id,
36217
+ scope: external_exports.enum(["content", "website", "both"]),
36218
+ purpose: external_exports.enum(["publish", "preview"]),
36219
+ planFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/)
36220
+ }).strict(),
36221
+ "publication.status": external_exports.object({ ...context, operationId: id }).strict(),
36222
+ "publication.recover": external_exports.object({ ...context, operationId: id }).strict(),
36223
+ "publication.cancel": external_exports.object({ ...context, operationId: id }).strict(),
36224
+ "publication.publishPrepared": external_exports.object({
36225
+ ...context,
36226
+ operationId: id,
36227
+ preparedFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/)
36228
+ }).strict(),
36185
36229
  "update.prepare": prepareInput.extend({
36186
36230
  sessionId: id,
36187
36231
  token: id,
@@ -36245,7 +36289,7 @@ Usage: plume tool <action> < request.json
36245
36289
 
36246
36290
  Actions: ${developerActions.join(", ")}
36247
36291
  Use PLUME_ENDPOINT and a separate PLUME_DEVELOPER_TOKEN. Send siteId and updateId explicitly on stdin (status needs neither and returns them). The action belongs in the command, not the JSON. schema.register without a schema field loads the named schema export from plume.schema.ts.
36248
- Mutations require an explicit Update, expected version/revision, and writer lease. Acquire with writer.acquire, retain its sessionId/token for writes, and release with writer.release. A busy Site answers WRITER_BUSY with details.holder (name, since); writer.takeover takes control explicitly, never automatically. record.replace requires fullReplacement: true and replaces the whole record. update.discard takes a free lease for sessionId when token is omitted. plume prepare requires a clean checkout at the connected GitHub origin and exact Update branch/commit. It commits plume.lock through Plume and returns a prepared commit; then run the printed git pull --ff-only command. Publish with plume publish.
36292
+ Mutations require an explicit Update, expected version/revision, and writer lease. Acquire with writer.acquire, retain its sessionId/token for writes, and release with writer.release. A busy Site answers WRITER_BUSY with details.holder (name, since); writer.takeover takes control explicitly, never automatically. record.replace requires fullReplacement: true and replaces the whole record. update.discard takes a free lease for sessionId when token is omitted. plume prepare requires a clean checkout at the connected GitHub origin and exact Update branch/commit. It admits one scoped preview operation and returns durable status; poll publication.status. Publishing the prepared candidate requires publication.publishPrepared with its exact preparedFingerprint. Publish with plume publish.
36249
36293
  Exit codes: 0 success, 1 refused or failed, 2 wrong usage.`;
36250
36294
  }
36251
36295
  });
@@ -36634,7 +36678,7 @@ For an unconnected local project, plume local schema applies safe additions; plu
36634
36678
 
36635
36679
  Hosted schemas arrive through an ordinary Update: add plume.schema.ts and page wiring on its branch, register the schema with plume schema apply using developer access for that Update, then prepare/publish through the existing Plume workflow when requested. To transfer local records once, the publication branch first needs a published schema-only Update and plume.lock, no hosted content, no open Updates and no active writer. plume connect performs browser approval, an explicit transfer choice and confirmation; its setup credential is not ongoing developer access. Resume interrupted transfers with plume connect; never silently merge them into an open Update. Transfer supports at most 100 records/1 MiB and rejects media.
36636
36680
 
36637
- Use only implemented commands in npx plume --help. There is no plume push, doctor, automatic deploy-hook configuration or universal website-check command. Prepare writes plume.lock remotely; deliberately run the printed git pull --ff-only on the correct branch before building. Never claim a local change is published or deployed.
36681
+ Use only implemented commands in npx plume --help. There is no plume push, doctor, automatic deploy-hook configuration or universal website-check command. Preparation returns one durable scoped operation; observe publication.status and deliberately check out its exact candidate before a selected host-preview build. Never claim a local change is published or deployed.
36638
36682
 
36639
36683
  ## One server-only reader, explicit content modes
36640
36684
 
@@ -36643,13 +36687,16 @@ Create or adapt one reader factory beside the site's existing server data helper
36643
36687
  Choose the mode explicitly in application/server configuration:
36644
36688
 
36645
36689
  - **Plume session preview:** when PLUME_PREVIEW is exactly true, require the session-provided PLUME_ENDPOINT and use createPlume({ schema, binding, endpoint, mode: "preview" }). Read the session's generated .plume/binding.json; fail if it is absent or malformed. Local loopback preview URLs can carry a path capability: keep the complete URL server-only. Do not replace it with the public CMS origin.
36646
- - **Prepared host preview or deliberately static build:** run plume build -- <existing framework build command>, then use createPlume with that generated .plume/binding.json and mode: "published". Public SDK reads default to https://cms.plume.press. The build's committed plume.lock is its authority; a missing/mismatched binding must fail rather than switch to latest.
36647
- - **Public SSR:** only for an explicitly selected public production SSR mode on a host that supports it, await createLatestPlume({ schema, siteId }) once per request/render. Derive siteId from the committed Site binding, and pass the reader to all page/metadata queries. Use a request-scoped promise/cache, never a module-global reader or promise. A public URL or matching schema does not by itself select latest. A prepared host preview must keep its fixed candidate even if public latest advances.
36690
+ - **Immutable host preview:** run plume build --delivery selected-preview -- <existing framework build command> from its clean exact Git candidate. The build reads its committed Plume operation trailers and validates the exact sealed binding against the native immutable reservation, then writes .plume/delivery.json with operationId and compiled code SHA. Final native preparation must match that operation, SHA and binding before Plume confirms the host preview. Use createPlume with the generated .plume/binding.json and mode: "published". Never resolve latest for this mode.
36691
+ - **Deliberately static build:** plume build --delivery static -- <existing framework build command> compiles an immutable selection. Content changes require a real rebuild or supported invalidation; a latest probe cannot certify an old page.
36692
+ - **Public SSR:** compile the explicit descriptor with plume build --delivery production-ssr -- <existing framework build command>. Only for an explicitly selected public production SSR mode on a host that supports it, await createLatestPlume({ schema, siteId }) once per request/render. Derive siteId from the committed Site binding, and pass the reader to all page/metadata queries. Use a request-scoped promise/cache, never a module-global reader or promise. A public URL or matching schema does not by itself select latest. A prepared host preview must keep its fixed candidate even if public latest advances.
36648
36693
 
36649
36694
  Next.js: keep the helper server-only (import "server-only"). In App Router, use the existing server components and request-scoped React cache to share the async reader across a render/metadata pass; opt affected public SSR routes into the framework's dynamic behavior and avoid persistent caching of the latest binding. Preserve Pages Router if the site uses it: resolve once inside getServerSideProps and pass rendered data. Keep getStaticProps/static routes pinned when intentional.
36650
36695
 
36651
36696
  Astro: resolve once in page frontmatter or the existing request context and pass the reader/data into layouts and components. Public latest needs a configured SSR adapter and on-demand rendering (export const prerender = false for the affected routes); preserve deliberate static output and its fixed build binding. Do not add an arbitrary host adapter without checking the actual deployment.
36652
36697
 
36698
+ Emit cooperative publication evidence from the exact reader used for actual page queries: createRenderEvidence(reader, compiledDescriptor), serialized with serializeRenderEvidence. In Astro set X-Plume-Render on the actual HTML response; in Next App Router render one inert script type="application/json" data-plume-render="1" with that escaped JSON. Do not make a separate latest lookup or add a redundant probe endpoint. Intentional static routes emit mode static. Local/working preview dev configuration must select an explicit private module with no compiled descriptor and emit no publication evidence. Runtime flags cannot switch the compiled host-preview mode. Configure the host connection's Content page path to that real route. These are cooperative integration facts, not cryptographic attestation or a completed provider build receipt.
36699
+
36653
36700
  ## Admin entry and visitor metadata
36654
36701
 
36655
36702
  If /admin is free, add a framework-native server redirect to the verified editorUrl in .plume/site.json. In Next App Router this can be an app/admin route/page; in Astro use its existing redirects configuration or a server route as appropriate. Carry the nonsecret URL into reviewed application configuration that exists at deployment; .plume/site.json is Git-ignored. If /admin already has a purpose, preserve it and resolve the entry route in the integration diff. The destination's sign-in return and Site membership checks remain the authority: embed no shared secret, developer token or auth capability.
@@ -37141,7 +37188,7 @@ var init_package = __esm({
37141
37188
  "packages/sdk/package.json"() {
37142
37189
  package_default = {
37143
37190
  name: "@plume-press/sdk",
37144
- version: "0.3.0",
37191
+ version: "0.4.0",
37145
37192
  private: true,
37146
37193
  license: "MIT",
37147
37194
  type: "module",
@@ -37168,7 +37215,7 @@ var init_package2 = __esm({
37168
37215
  "packages/cli/package.json"() {
37169
37216
  package_default2 = {
37170
37217
  name: "@plume-press/cli",
37171
- version: "0.7.0",
37218
+ version: "0.8.0",
37172
37219
  private: true,
37173
37220
  license: "MIT",
37174
37221
  type: "module",
@@ -37663,9 +37710,10 @@ var sessionShape = external_exports.object({
37663
37710
  sessionId: uuid3,
37664
37711
  token: uuid3.optional(),
37665
37712
  publish: external_exports.object({
37666
- publishId: uuid3,
37667
- expectedVersionId: uuid3,
37668
- expectedRevision: external_exports.number().int().nonnegative()
37713
+ operationId: uuid3,
37714
+ scope: external_exports.enum(["content", "website", "both"]),
37715
+ purpose: external_exports.enum(["publish", "preview"]),
37716
+ planFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/)
37669
37717
  }).optional()
37670
37718
  });
37671
37719
  async function checkoutRoot(cwd) {
@@ -38393,164 +38441,221 @@ async function schema2(ctx, args) {
38393
38441
  }
38394
38442
  return exitCodes.done;
38395
38443
  }
38396
- var stepLabels = {
38397
- checking: "Checking for newer published changes\u2026",
38398
- updating: "Bringing in newer published changes\u2026",
38399
- freezing: "Freezing content\u2026",
38400
- publishing: "Publishing\u2026"
38401
- };
38402
- var notMerged = {
38403
- needs_approval: "In review: waiting for an Admin to approve.",
38404
- check_failed: "In review: the Plume check failed. See the check on the pull request.",
38405
- target_moved: "In review: something changed while publishing. Run plume publish again to check it afresh.",
38406
- merge_refused: "In review: GitHub couldn\u2019t publish it (conflicting changes or repository rules). Fix that on the Update\u2019s branch, then run plume publish again.",
38407
- changed: "In review: this Update changed while publishing. Run plume publish again."
38408
- };
38409
- var publishedShape = external_exports.object({
38410
- outcome: external_exports.enum(["merged", "awaiting_review"]),
38411
- reason: external_exports.string().optional(),
38412
- pullRequest: external_exports.object({ number: external_exports.number().int(), url: external_exports.string().optional() }).nullable().optional(),
38413
- mergeVerification: external_exports.object({ verified: external_exports.boolean() }).nullable().optional()
38444
+ var publicationStatusShape = external_exports.object({
38445
+ operationId: uuid3,
38446
+ sourceUpdateId: uuid3,
38447
+ scope: external_exports.enum(["content", "website", "both"]),
38448
+ purpose: external_exports.enum(["publish", "preview"]),
38449
+ publicationRequested: external_exports.boolean(),
38450
+ state: external_exports.enum([
38451
+ "preparing",
38452
+ "prepared",
38453
+ "needs_approval",
38454
+ "publishing",
38455
+ "recovery_required",
38456
+ "accepted",
38457
+ "cancelling",
38458
+ "cancelled",
38459
+ "blocked"
38460
+ ]),
38461
+ progress: external_exports.string().nullable(),
38462
+ reason: external_exports.string().nullable(),
38463
+ allowedActions: external_exports.array(external_exports.enum(["publish_prepared", "recover", "cancel"])),
38464
+ candidate: external_exports.object({ preparedFingerprint: external_exports.string().nullable() }).passthrough().nullable(),
38465
+ result: external_exports.object({
38466
+ receipt: external_exports.object({ operationId: uuid3, sequence: external_exports.number().int().positive() }).passthrough(),
38467
+ sourceUpdateId: uuid3,
38468
+ continuationUpdateId: uuid3.nullable()
38469
+ }).passthrough().nullable()
38470
+ }).passthrough().refine(
38471
+ (value) => value.state === "accepted" ? value.result?.receipt.operationId === value.operationId : value.result === null
38472
+ );
38473
+ var scopePlanShape = external_exports.object({
38474
+ present: external_exports.boolean(),
38475
+ permission: external_exports.enum(["allowed", "approval", "locked"]),
38476
+ disabledReason: external_exports.string().nullable()
38477
+ });
38478
+ var publicationPlanShape = external_exports.object({
38479
+ operationId: uuid3.nullable(),
38480
+ fingerprint: external_exports.string(),
38481
+ content: scopePlanShape,
38482
+ website: scopePlanShape,
38483
+ schemaPartialBlocked: external_exports.boolean()
38414
38484
  });
38415
- async function press(ctx, input2, onStep) {
38416
- const response = await postDeveloperTool({
38417
- body: JSON.stringify({ action: "update.publish", ...input2 }),
38418
- endpoint: ctx.endpoint,
38419
- token: ctx.token,
38420
- timeoutMs: PUBLISH_TIMEOUT_MS,
38421
- ...ctx.io.fetch ? { fetch: ctx.io.fetch } : {}
38422
- });
38423
- const reader = response.body?.getReader();
38424
- if (!reader) return null;
38425
- const decoder = new TextDecoder("utf-8", { fatal: true });
38426
- let buffer = "";
38427
- let size = 0;
38428
- try {
38429
- while (true) {
38430
- const { done, value } = await reader.read();
38431
- if (done) break;
38432
- size += value.byteLength;
38433
- if (size > 4 * 1024 * 1024) throw new Error();
38434
- buffer += decoder.decode(value, { stream: true });
38435
- let newline = buffer.indexOf("\n");
38436
- while (newline >= 0) {
38437
- const line = JSON.parse(buffer.slice(0, newline));
38438
- buffer = buffer.slice(newline + 1);
38439
- newline = buffer.indexOf("\n");
38440
- if (typeof line.step === "string") onStep(line.step);
38441
- else if ("error" in line) throw remoteError(409, line);
38442
- else if ("result" in line) {
38443
- const parsed = publishedShape.safeParse(line.result);
38444
- if (!parsed.success) return null;
38445
- return parsed.data;
38446
- }
38447
- }
38448
- }
38449
- } catch (error62) {
38450
- if (error62 instanceof PlumeToolError) throw error62;
38451
- return null;
38452
- } finally {
38453
- reader.releaseLock();
38454
- }
38455
- return null;
38456
- }
38457
38485
  async function publish(ctx, args) {
38458
- const options2 = parse6(args);
38486
+ const options2 = parse6(
38487
+ args,
38488
+ ["--preview", "--status", "--recover", "--cancel", "--publish-prepared"],
38489
+ ["--scope"]
38490
+ );
38459
38491
  if (options2.positional.length)
38460
- throw new UsageError("plume publish takes no arguments.");
38492
+ throw new UsageError("plume publish takes no positional arguments.");
38493
+ const actionFlags = [
38494
+ "--status",
38495
+ "--recover",
38496
+ "--cancel",
38497
+ "--publish-prepared"
38498
+ ].filter((flag) => options2.flags.has(flag));
38499
+ if (actionFlags.length > 1)
38500
+ throw new UsageError("Choose one publication action.");
38501
+ const requestedScope = options2.values.get("--scope");
38502
+ if (requestedScope && !["content", "website", "both"].includes(requestedScope))
38503
+ throw new UsageError("--scope takes content, website or both.");
38461
38504
  let { session } = await scope(ctx);
38462
- const current = await context2(ctx, session);
38463
- const editable = !!current.update && ["editing", "preparing"].includes(current.update.state);
38464
- const lease = editable ? await control(ctx, session) : null;
38465
- if (lease) session = await readSession(ctx) ?? session;
38466
- const stop = lease ? keepControl(ctx, session, lease) : () => {
38467
- };
38468
- const steps = [];
38469
- const onStep = (step) => {
38470
- steps.push(step);
38471
- if (!ctx.json) ctx.io.out(`${stepLabels[step] ?? step}
38472
- `);
38505
+ let pending = session.publish;
38506
+ let status2;
38507
+ let stop = () => {
38473
38508
  };
38474
- const fresh = () => ({
38475
- publishId: uuidv72(),
38476
- expectedVersionId: current.versionId,
38477
- expectedRevision: current.revision
38478
- });
38479
- let pending = session.publish ?? fresh();
38480
- let resuming = !!session.publish;
38481
- await writeSession(ctx, { ...session, publish: pending });
38482
- const forget = () => writeSession(ctx, { ...session, publish: void 0 });
38483
38509
  try {
38484
- let result = null;
38485
- for (let attempt = 0; attempt < 3 && !result; attempt++) {
38486
- if (attempt) await delay(attempt * 2e3);
38510
+ if (pending) {
38511
+ if (requestedScope && requestedScope !== pending.scope || options2.flags.has("--preview") && pending.purpose !== "preview")
38512
+ throw new UsageError(
38513
+ "This checkout has a saved publication. Inspect or cancel it before choosing a different scope."
38514
+ );
38487
38515
  try {
38488
- result = await press(
38516
+ status2 = await call(
38517
+ ctx,
38518
+ "publication.status",
38519
+ { ...ids(session), operationId: pending.operationId },
38520
+ publicationStatusShape,
38521
+ true
38522
+ );
38523
+ } catch (error62) {
38524
+ if (!(error62 instanceof PlumeToolError) || error62.code !== "NOT_FOUND" || actionFlags.length)
38525
+ throw error62;
38526
+ const lease = await control(ctx, session);
38527
+ session = await readSession(ctx) ?? session;
38528
+ stop = keepControl(ctx, session, lease);
38529
+ status2 = await call(
38489
38530
  ctx,
38531
+ "publication.start",
38490
38532
  {
38491
38533
  ...ids(session),
38534
+ ...pending,
38492
38535
  sessionId: session.sessionId,
38493
- ...lease ? { token: lease.token } : {},
38494
- ...pending
38536
+ token: lease.token
38495
38537
  },
38496
- onStep
38538
+ publicationStatusShape
38497
38539
  );
38498
- } catch (error62) {
38499
- if (uncertain(error62)) continue;
38500
- if (resuming && error62 instanceof PlumeToolError && error62.code === "PUBLISH_CHANGED") {
38501
- resuming = false;
38502
- attempt = -1;
38503
- steps.length = 0;
38504
- pending = fresh();
38505
- await writeSession(ctx, { ...session, publish: pending });
38506
- if (!ctx.json)
38507
- ctx.io.out(
38508
- "The content changed since publishing was last tried. Starting again\u2026\n"
38509
- );
38510
- continue;
38511
- }
38512
- await forget();
38513
- throw error62;
38514
38540
  }
38541
+ } else {
38542
+ const plan = await call(
38543
+ ctx,
38544
+ "publication.plan",
38545
+ ids(session),
38546
+ publicationPlanShape,
38547
+ true
38548
+ );
38549
+ if (plan.operationId) {
38550
+ status2 = await call(
38551
+ ctx,
38552
+ "publication.status",
38553
+ { ...ids(session), operationId: plan.operationId },
38554
+ publicationStatusShape,
38555
+ true
38556
+ );
38557
+ pending = {
38558
+ operationId: status2.operationId,
38559
+ scope: status2.scope,
38560
+ purpose: status2.purpose,
38561
+ planFingerprint: plan.fingerprint
38562
+ };
38563
+ } else {
38564
+ if (actionFlags.length)
38565
+ throw new UsageError(
38566
+ "There is no saved publication for this Update."
38567
+ );
38568
+ const selected = requestedScope ?? (plan.content.present && plan.website.present ? "both" : plan.content.present ? "content" : "website");
38569
+ const scopes = selected === "both" ? [plan.content, plan.website] : [selected === "content" ? plan.content : plan.website];
38570
+ if (scopes.some(
38571
+ (value) => !value.present || value.permission === "locked" || value.disabledReason
38572
+ ) || selected !== "both" && plan.schemaPartialBlocked)
38573
+ throw new PlumeToolError(
38574
+ "SCOPE_UNAVAILABLE",
38575
+ "The selected publication scope is unavailable. Inspect this Update in Plume."
38576
+ );
38577
+ const lease = await control(ctx, session);
38578
+ session = await readSession(ctx) ?? session;
38579
+ stop = keepControl(ctx, session, lease);
38580
+ pending = {
38581
+ operationId: uuidv72(),
38582
+ scope: selected,
38583
+ purpose: options2.flags.has("--preview") ? "preview" : "publish",
38584
+ planFingerprint: plan.fingerprint
38585
+ };
38586
+ await writeSession(ctx, { ...session, publish: pending });
38587
+ status2 = await call(
38588
+ ctx,
38589
+ "publication.start",
38590
+ {
38591
+ ...ids(session),
38592
+ ...pending,
38593
+ sessionId: session.sessionId,
38594
+ token: lease.token
38595
+ },
38596
+ publicationStatusShape
38597
+ );
38598
+ }
38599
+ await writeSession(ctx, { ...session, publish: pending });
38515
38600
  }
38516
- if (!result)
38601
+ if (status2.operationId !== pending.operationId || status2.sourceUpdateId !== session.updateId)
38517
38602
  throw new PlumeToolError(
38518
- "PUBLISH_UNFINISHED",
38519
- "Publishing didn\u2019t finish: the connection to Plume was lost. Run plume publish again; it continues this press."
38603
+ "INVALID_RESPONSE",
38604
+ "The publication response identifies another operation or Update."
38520
38605
  );
38521
- await forget();
38522
- if (lease) {
38523
- stop();
38524
- await call(
38606
+ const action = actionFlags[0];
38607
+ if (action && action !== "--status") {
38608
+ const allowed = action === "--publish-prepared" ? "publish_prepared" : action.slice(2);
38609
+ if (!status2.allowedActions.includes(
38610
+ allowed
38611
+ ))
38612
+ throw new PlumeToolError(
38613
+ "ACTION_UNAVAILABLE",
38614
+ "This action is unavailable for the saved publication."
38615
+ );
38616
+ const input2 = { ...ids(session), operationId: status2.operationId };
38617
+ status2 = await call(
38525
38618
  ctx,
38526
- "writer.release",
38527
- { ...ids(session), sessionId: session.sessionId, token: lease.token },
38528
- external_exports.unknown()
38529
- ).catch(() => {
38530
- });
38619
+ action === "--publish-prepared" ? "publication.publishPrepared" : action === "--cancel" ? "publication.cancel" : "publication.recover",
38620
+ action === "--publish-prepared" ? {
38621
+ ...input2,
38622
+ preparedFingerprint: status2.candidate?.preparedFingerprint
38623
+ } : input2,
38624
+ publicationStatusShape
38625
+ );
38626
+ }
38627
+ stop();
38628
+ const deadline = Date.now() + PUBLISH_TIMEOUT_MS;
38629
+ let previous = "";
38630
+ while (action !== "--status" && ["preparing", "publishing", "cancelling"].includes(status2.state) && Date.now() < deadline) {
38631
+ const label = status2.progress ?? status2.state;
38632
+ if (!ctx.json && label !== previous) ctx.io.out(`${printable(label)}\u2026
38633
+ `);
38634
+ previous = label;
38635
+ await delay(1e3);
38636
+ status2 = await call(
38637
+ ctx,
38638
+ "publication.status",
38639
+ { ...ids(session), operationId: pending.operationId },
38640
+ publicationStatusShape,
38641
+ true
38642
+ );
38643
+ if (status2.operationId !== pending.operationId || status2.sourceUpdateId !== session.updateId)
38644
+ throw new PlumeToolError(
38645
+ "INVALID_RESPONSE",
38646
+ "The saved publication identity changed."
38647
+ );
38648
+ }
38649
+ if (["accepted", "cancelled"].includes(status2.state))
38531
38650
  await writeSession(ctx, {
38532
38651
  ...session,
38533
38652
  publish: void 0,
38534
38653
  token: void 0
38535
38654
  });
38536
- }
38537
- const outcome = result;
38538
38655
  emit(
38539
38656
  ctx,
38540
- {
38541
- outcome: outcome.outcome,
38542
- reason: outcome.reason ?? null,
38543
- pullRequest: outcome.pullRequest ?? null,
38544
- mergeVerification: outcome.mergeVerification ?? null,
38545
- steps
38546
- },
38547
- () => [
38548
- outcome.outcome === "merged" ? "Published. Your website updates when your host deploys it." : notMerged[outcome.reason ?? ""] ?? "In review.",
38549
- ...outcome.mergeVerification?.verified === false ? [
38550
- "Verification after publishing failed. Ask a developer to check it; your host may already be deploying it."
38551
- ] : [],
38552
- ...outcome.pullRequest ? [`Pull request #${outcome.pullRequest.number}`] : []
38553
- ].join("\n")
38657
+ status2,
38658
+ () => status2.state === "accepted" && status2.result ? `Published ${status2.scope}. Publication ${status2.operationId}, sequence ${status2.result.receipt.sequence}.${status2.result.continuationUpdateId ? ` Retained work: ${status2.result.continuationUpdateId}.` : ""}` : `Publication ${status2.operationId}: ${status2.state}${status2.reason ? ` (${status2.reason})` : ""}.${status2.allowedActions.length ? ` Available actions: ${status2.allowedActions.map((value) => `--${value.replaceAll("_", "-")}`).join(", ")}.` : ""}`
38554
38659
  );
38555
38660
  return exitCodes.done;
38556
38661
  } finally {
@@ -38676,9 +38781,9 @@ Examples:
38676
38781
  summary: "Publish the Update, showing each step",
38677
38782
  help: `plume publish \u2014 publish this checkout's Update, as Publish in Plume does.
38678
38783
 
38679
- Usage: plume publish [--json]
38784
+ Usage: plume publish [--scope content|website|both] [--preview] [--status|--recover|--cancel|--publish-prepared] [--json]
38680
38785
 
38681
- Brings in newer published changes (when nothing conflicts), freezes the content, checks it and publishes it, printing each step. It stops when a person is needed: Items changed both here and in the published version (choose in Plume with Resolve conflicts), code changed in both places, a failed check, or an Admin's approval. If the connection drops, run it again: it continues the same press.
38786
+ Starts one saved scoped publication and observes its status. The default selects the changed scopes. --preview prepares an immutable host preview; publishing it later requires --publish-prepared. --status only reads. --recover wakes an authorized recoverable operation; --cancel requests cancellation. A lost response keeps the same operation identity. Content publication does not cause a Website build.
38682
38787
 
38683
38788
  Example:
38684
38789
  plume publish`,
@@ -39873,7 +39978,8 @@ var MAX_SCHEMA_BYTES2 = 256 * 1024;
39873
39978
  var validationSchema = external_exports.object({
39874
39979
  binding: contentBindingSchema,
39875
39980
  revision: external_exports.number().int().nonnegative(),
39876
- sealed: external_exports.literal(true)
39981
+ sealed: external_exports.literal(true),
39982
+ candidate: previewCandidateSchema.nullable().optional()
39877
39983
  }).strict();
39878
39984
  var PlumeBuildError = class extends Error {
39879
39985
  constructor(code, message) {
@@ -39955,39 +40061,55 @@ function validationUrl(endpoint) {
39955
40061
  );
39956
40062
  }
39957
40063
  }
39958
- async function validateRemote(url2, binding) {
39959
- let response;
40064
+ async function validateRemote(url2, binding, commitSha, operationId) {
40065
+ const abort = new AbortController(), interrupt = () => abort.abort();
40066
+ process.on("SIGINT", interrupt);
40067
+ process.on("SIGTERM", interrupt);
39960
40068
  try {
39961
- response = await fetch(url2, {
39962
- method: "POST",
39963
- headers: { "content-type": "application/json" },
39964
- body: JSON.stringify({ binding }),
39965
- redirect: "error",
39966
- cache: "no-store",
39967
- credentials: "omit",
39968
- signal: AbortSignal.timeout(15e3)
39969
- });
39970
- if (!response.ok) {
40069
+ let response;
40070
+ try {
40071
+ response = await fetch(url2, {
40072
+ method: "POST",
40073
+ headers: { "content-type": "application/json" },
40074
+ body: JSON.stringify({
40075
+ binding,
40076
+ commitSha,
40077
+ ...operationId ? { mode: "selected-preview", operationId } : {}
40078
+ }),
40079
+ redirect: "error",
40080
+ cache: "no-store",
40081
+ credentials: "omit",
40082
+ signal: AbortSignal.any([abort.signal, AbortSignal.timeout(15e3)])
40083
+ });
40084
+ } catch {
40085
+ throw new PlumeBuildError(
40086
+ "VALIDATION_FAILED",
40087
+ "Plume could not confirm this build. No framework build was started."
40088
+ );
40089
+ }
40090
+ if (response.status !== 200) {
39971
40091
  await response.body?.cancel();
39972
- throw new Error();
40092
+ throw new PlumeBuildError(
40093
+ "VALIDATION_FAILED",
40094
+ "Plume could not confirm this build. No framework build was started."
40095
+ );
39973
40096
  }
39974
- } catch {
39975
- throw new PlumeBuildError(
39976
- "VALIDATION_FAILED",
39977
- "Plume could not confirm this build. Build a commit whose plume.lock names prepared or published content (Plume commits it when you prepare or publish an Update), with the plume.schema.ts committed beside it."
39978
- );
39979
- }
39980
- try {
39981
- const result = validationSchema.parse(
39982
- await boundedJson(response, MAX_RESPONSE_BYTES2)
39983
- );
39984
- if (canonicalJson(result.binding) !== canonicalJson(binding))
39985
- throw new Error();
39986
- } catch {
39987
- throw new PlumeBuildError(
39988
- "INVALID_RESPONSE",
39989
- "Plume returned an invalid build validation response. No framework build was started."
39990
- );
40097
+ try {
40098
+ const result = validationSchema.parse(
40099
+ await boundedJson(response, MAX_RESPONSE_BYTES2)
40100
+ );
40101
+ if (canonicalJson(result.binding) !== canonicalJson(binding) || operationId && (!result.candidate || result.candidate.commitSha !== commitSha || result.candidate.operationId !== operationId))
40102
+ throw Error();
40103
+ return result;
40104
+ } catch {
40105
+ throw new PlumeBuildError(
40106
+ "INVALID_RESPONSE",
40107
+ "Plume returned an invalid build validation response. No framework build was started."
40108
+ );
40109
+ }
40110
+ } finally {
40111
+ process.off("SIGINT", interrupt);
40112
+ process.off("SIGTERM", interrupt);
39991
40113
  }
39992
40114
  }
39993
40115
  async function runCommand2(cwd, command) {
@@ -40029,6 +40151,7 @@ async function runBuild(options2) {
40029
40151
  const cwd = resolve8(options2.cwd);
40030
40152
  const directory = resolve8(cwd, ".plume");
40031
40153
  const bindingFile = resolve8(directory, "binding.json");
40154
+ const deliveryFile = resolve8(directory, "delivery.json");
40032
40155
  try {
40033
40156
  await mkdir4(directory, { recursive: true });
40034
40157
  if (!(await lstat5(directory)).isDirectory()) throw new Error();
@@ -40041,6 +40164,7 @@ async function runBuild(options2) {
40041
40164
  const temporary = resolve8(directory, `.binding-${randomUUID3()}.json`);
40042
40165
  try {
40043
40166
  await rm5(bindingFile, { force: true });
40167
+ await rm5(deliveryFile, { force: true });
40044
40168
  if (!options2.command.length || options2.command.some(
40045
40169
  (part) => typeof part !== "string" || part.includes("\0")
40046
40170
  ) || !options2.command[0]?.trim())
@@ -40051,17 +40175,79 @@ async function runBuild(options2) {
40051
40175
  const url2 = validationUrl(options2.endpoint);
40052
40176
  const binding = await readLock(cwd);
40053
40177
  await validateSchema(cwd, options2.schemaPath ?? "plume.schema.ts", binding);
40054
- await validateRemote(url2, binding);
40178
+ const commitSha = await git(cwd, "rev-parse", "HEAD");
40179
+ if (await git(cwd, "status", "--porcelain=v1", "--untracked-files=all"))
40180
+ throw new PlumeBuildError(
40181
+ "INVALID_CONFIGURATION",
40182
+ "Build from a clean Git checkout so the compiled code identity names the code being built."
40183
+ );
40184
+ if (!/^[a-f0-9]{40}$/.test(commitSha))
40185
+ throw new PlumeBuildError(
40186
+ "INVALID_CONFIGURATION",
40187
+ "Build from an exact Git commit."
40188
+ );
40189
+ const mode = options2.delivery ?? "static";
40190
+ let operationId;
40191
+ if (mode === "selected-preview") {
40192
+ const message = await git(cwd, "show", "-s", "--format=%B", "HEAD");
40193
+ const trailers = /^Prepare Plume publication\n\nPlume-Publication: ([a-f0-9-]{36})\nPlume-Content: ([a-f0-9-]{36})\nPlume-Schema: (sha256:[a-f0-9]{64})$/.exec(
40194
+ message
40195
+ );
40196
+ const candidate = previewCandidateSchema.safeParse({
40197
+ operationId: trailers?.[1],
40198
+ commitSha
40199
+ });
40200
+ if (!candidate.success || trailers?.[2] !== binding.contentVersionId || trailers?.[3] !== binding.schemaHash)
40201
+ throw new PlumeBuildError(
40202
+ "INVALID_CONFIGURATION",
40203
+ "Build a selected preview from its exact Plume binding commit and matching lock."
40204
+ );
40205
+ operationId = candidate.data.operationId;
40206
+ }
40207
+ const validation = await validateRemote(
40208
+ url2,
40209
+ binding,
40210
+ commitSha,
40211
+ operationId
40212
+ );
40213
+ const descriptor = deliveryDescriptorSchema.safeParse({
40214
+ version: 1,
40215
+ mode,
40216
+ artifact: {
40217
+ commitSha,
40218
+ environment: options2.environment ?? (mode === "selected-preview" ? "preview" : "production")
40219
+ },
40220
+ binding,
40221
+ candidate: mode === "selected-preview" ? validation.candidate ?? null : null
40222
+ });
40223
+ if (!descriptor.success)
40224
+ throw new PlumeBuildError(
40225
+ "VALIDATION_FAILED",
40226
+ "Choose a valid delivery mode; a selected preview requires an exact native reservation."
40227
+ );
40228
+ await writeFile3(
40229
+ deliveryFile,
40230
+ `${JSON.stringify(descriptor.data, null, 2)}
40231
+ `,
40232
+ { flag: "wx", mode: 420 }
40233
+ );
40055
40234
  await writeFile3(temporary, `${JSON.stringify(binding, null, 2)}
40056
40235
  `, {
40057
40236
  flag: "wx",
40058
40237
  mode: 420
40059
40238
  });
40060
40239
  await rename3(temporary, bindingFile);
40240
+ if (await git(cwd, "rev-parse", "HEAD") !== commitSha || await git(cwd, "status", "--porcelain=v1", "--untracked-files=all"))
40241
+ throw new PlumeBuildError(
40242
+ "INVALID_CONFIGURATION",
40243
+ "The checkout changed while validating the build."
40244
+ );
40061
40245
  return { exitCode: await runCommand2(cwd, options2.command), binding };
40062
40246
  } catch (error62) {
40063
40247
  await rm5(bindingFile, { force: true }).catch(() => {
40064
40248
  });
40249
+ await rm5(deliveryFile, { force: true }).catch(() => {
40250
+ });
40065
40251
  if (error62 instanceof PlumeBuildError) throw error62;
40066
40252
  throw new PlumeBuildError(
40067
40253
  "ARTIFACT_FAILED",
@@ -40152,15 +40338,34 @@ ${developerHelp}
40152
40338
  }
40153
40339
  const divider = args.indexOf("--");
40154
40340
  const prefix = args.slice(0, divider);
40155
- if (divider < 1 || prefix.length !== 1 || prefix[0] !== "build" || divider === args.length - 1) {
40341
+ if (divider < 1 || ![1, 3, 5].includes(prefix.length) || prefix[0] !== "build" || divider === args.length - 1) {
40156
40342
  process.stderr.write("Usage: plume build -- <command ...>\n");
40157
40343
  return 1;
40158
40344
  }
40159
40345
  try {
40346
+ const buildFlags = /* @__PURE__ */ new Map();
40347
+ for (let i = 1; i < prefix.length; i += 2) {
40348
+ const flag = prefix[i], value = prefix[i + 1];
40349
+ if (!flag || !value || !["--delivery", "--environment"].includes(flag) || buildFlags.has(flag))
40350
+ throw new PlumeBuildError(
40351
+ "INVALID_CONFIGURATION",
40352
+ "Usage: plume build [--delivery production-ssr|selected-preview|static] [--environment production|preview] -- <command ...>"
40353
+ );
40354
+ buildFlags.set(flag, value);
40355
+ }
40356
+ const mode = buildFlags.get("--delivery") ?? "static";
40357
+ const environment = buildFlags.get("--environment");
40358
+ if (!["production-ssr", "selected-preview", "static"].includes(mode) || environment && !["production", "preview"].includes(environment))
40359
+ throw new PlumeBuildError(
40360
+ "INVALID_CONFIGURATION",
40361
+ "Choose a supported delivery mode and environment."
40362
+ );
40160
40363
  const result = await runBuild({
40161
40364
  cwd: process.cwd(),
40162
40365
  command: args.slice(divider + 1),
40163
- endpoint: env2.PLUME_ENDPOINT || DEFAULT_ENDPOINT
40366
+ endpoint: env2.PLUME_ENDPOINT || DEFAULT_ENDPOINT,
40367
+ delivery: mode,
40368
+ ...environment ? { environment } : {}
40164
40369
  });
40165
40370
  return result.exitCode;
40166
40371
  } catch (error62) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plume-press/cli",
3
- "version": "0.7.0",
3
+ "version": "0.8.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",