diff --git a/evals/configure-repositories.eval.ts b/evals/configure-repositories.eval.ts index e738906..7feda9e 100644 --- a/evals/configure-repositories.eval.ts +++ b/evals/configure-repositories.eval.ts @@ -5,6 +5,7 @@ import { getPreviews, getRepository, getWebhooks, + setSimulatorUrl, } from "../test/prismic"; import { it, trials } from "./it"; @@ -22,6 +23,7 @@ it.for(trials)( "updates previews for production after a deploy", async (_, { agent, expect, repo, token, host }) => { await addPreview("http://localhost:3000/api/preview", "Development", { repo, token, host }); + await setSimulatorUrl("http://localhost:3000/slice-simulator", { repo, token, host }); const result = await agent( `We just deployed the site to https://example.com. Set up content previews for production.`, diff --git a/src/commands/index.ts b/src/commands/index.ts index 6b9548e..0cdee21 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -34,6 +34,15 @@ export default createCommandRouter({ it directly. There is no route command. Run \`prismic docs view routes\` for path keywords and route properties. `, + PREVIEWS: ` + Writers use previews to see draft content before it is published. + Previews need two settings. After a deploy, set both: + prismic preview add https://example.com/api/preview + prismic preview set-simulator https://example.com + A repository can hold multiple preview URLs but only one simulator URL, + which the Page Builder loads live slice previews from. + Run \`prismic docs view previews\` for details. + `, }, commands: { init: { @@ -91,7 +100,7 @@ export default createCommandRouter({ }, preview: { handler: preview, - description: "Manage preview configurations", + description: "Manage preview and simulator URLs", }, token: { handler: token, diff --git a/src/commands/preview.ts b/src/commands/preview.ts index 5680992..4d03508 100644 --- a/src/commands/preview.ts +++ b/src/commands/preview.ts @@ -6,19 +6,26 @@ import previewSetSimulator from "./preview-set-simulator"; export default createCommandRouter({ name: "prismic preview", - description: "Manage preview configurations in a Prismic repository.", + description: "Manage previews in a Prismic repository.", + sections: { + EXAMPLES: ` + Set up previews after a deploy, using both settings: + prismic preview add https://example.com/api/preview + prismic preview set-simulator https://example.com + `, + }, commands: { add: { handler: previewAdd, - description: "Add a preview configuration", + description: "Add a preview URL", }, list: { handler: previewList, - description: "List preview configurations", + description: "List preview URLs and the simulator URL", }, remove: { handler: previewRemove, - description: "Remove a preview configuration", + description: "Remove a preview URL", }, "set-simulator": { handler: previewSetSimulator, diff --git a/test/index.test.ts b/test/index.test.ts index 37c9bb8..fb843e7 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -8,6 +8,7 @@ it("supports --help", async ({ expect, prismic }) => { expect(exitCode, stderr).toBe(0); expect(stdout).toContain("prismic [options]"); expect(stdout).toContain("ROUTES"); + expect(stdout).toContain("PREVIEWS"); expect(stdout).not.toContain("starter"); }); diff --git a/test/preview.test.ts b/test/preview.test.ts index f5c0349..ba06d58 100644 --- a/test/preview.test.ts +++ b/test/preview.test.ts @@ -11,3 +11,10 @@ it("supports --help", async ({ expect, prismic }) => { expect(exitCode, stderr).toBe(0); expect(stdout).toContain("prismic preview [options]"); }); + +it("shows how to set up both preview settings", async ({ expect, prismic }) => { + const { stdout, stderr, exitCode } = await prismic("preview", ["--help"]); + expect(exitCode, stderr).toBe(0); + expect(stdout).toContain("EXAMPLES"); + expect(stdout).toContain("prismic preview set-simulator"); +});