From b143969c820b2b102c3a7c2952956ab1bbb58a76 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 01:19:00 +0000 Subject: [PATCH 1/6] feat: print suggested next steps after mutating commands After create/add commands complete, print a hint about the next logical action to help users discover related commands. Resolves #149 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/field-add-boolean.ts | 8 +++++++- src/commands/field-add-color.ts | 8 +++++++- src/commands/field-add-content-relationship.ts | 8 +++++++- src/commands/field-add-date.ts | 8 +++++++- src/commands/field-add-embed.ts | 8 +++++++- src/commands/field-add-geopoint.ts | 8 +++++++- src/commands/field-add-group.ts | 8 +++++++- src/commands/field-add-image.ts | 8 +++++++- src/commands/field-add-integration.ts | 8 +++++++- src/commands/field-add-link.ts | 8 +++++++- src/commands/field-add-number.ts | 8 +++++++- src/commands/field-add-rich-text.ts | 8 +++++++- src/commands/field-add-select.ts | 8 +++++++- src/commands/field-add-table.ts | 8 +++++++- src/commands/field-add-text.ts | 8 +++++++- src/commands/field-add-timestamp.ts | 8 +++++++- src/commands/field-add-uid.ts | 1 + src/commands/init.ts | 4 ++++ src/commands/preview-add.ts | 3 +++ src/commands/repo-create.ts | 3 +++ src/commands/slice-create.ts | 4 ++++ src/commands/token-create.ts | 10 ++++++++-- src/commands/type-create.ts | 4 ++++ src/commands/webhook-create.ts | 3 +++ 24 files changed, 142 insertions(+), 18 deletions(-) diff --git a/src/commands/field-add-boolean.ts b/src/commands/field-add-boolean.ts index 6f856a9..5a968c5 100644 --- a/src/commands/field-add-boolean.ts +++ b/src/commands/field-add-boolean.ts @@ -34,7 +34,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: BooleanField = { @@ -52,4 +52,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-color.ts b/src/commands/field-add-color.ts index ac0daf6..a8d7e31 100644 --- a/src/commands/field-add-color.ts +++ b/src/commands/field-add-color.ts @@ -26,7 +26,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Color = { @@ -42,4 +42,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-content-relationship.ts b/src/commands/field-add-content-relationship.ts index 03fb30e..cd939c2 100644 --- a/src/commands/field-add-content-relationship.ts +++ b/src/commands/field-add-content-relationship.ts @@ -63,7 +63,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); let resolvedCustomTypes: NonNullable["customtypes"] = customtypes; @@ -94,4 +94,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-date.ts b/src/commands/field-add-date.ts index f0d3c8a..1c63490 100644 --- a/src/commands/field-add-date.ts +++ b/src/commands/field-add-date.ts @@ -27,7 +27,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: DateField = { @@ -44,4 +44,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-embed.ts b/src/commands/field-add-embed.ts index c58a249..d953ac1 100644 --- a/src/commands/field-add-embed.ts +++ b/src/commands/field-add-embed.ts @@ -26,7 +26,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Embed = { @@ -42,4 +42,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-geopoint.ts b/src/commands/field-add-geopoint.ts index 07d8e76..f3ff8be 100644 --- a/src/commands/field-add-geopoint.ts +++ b/src/commands/field-add-geopoint.ts @@ -25,7 +25,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: GeoPoint = { @@ -40,4 +40,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-group.ts b/src/commands/field-add-group.ts index 6b5a0e6..f254e2f 100644 --- a/src/commands/field-add-group.ts +++ b/src/commands/field-add-group.ts @@ -25,7 +25,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Group = { @@ -40,4 +40,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-image.ts b/src/commands/field-add-image.ts index ea19993..45fc49e 100644 --- a/src/commands/field-add-image.ts +++ b/src/commands/field-add-image.ts @@ -26,7 +26,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Image = { @@ -42,4 +42,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-integration.ts b/src/commands/field-add-integration.ts index 5489e54..2488fbb 100644 --- a/src/commands/field-add-integration.ts +++ b/src/commands/field-add-integration.ts @@ -27,7 +27,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: IntegrationField = { @@ -44,4 +44,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-link.ts b/src/commands/field-add-link.ts index b28bb26..0569622 100644 --- a/src/commands/field-add-link.ts +++ b/src/commands/field-add-link.ts @@ -49,7 +49,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Link = { @@ -69,4 +69,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-number.ts b/src/commands/field-add-number.ts index 68756d4..c8b1f49 100644 --- a/src/commands/field-add-number.ts +++ b/src/commands/field-add-number.ts @@ -33,7 +33,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: NumberField = { @@ -52,6 +52,12 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); function parseNumber(value: string | undefined, optionName: string): number | undefined { diff --git a/src/commands/field-add-rich-text.ts b/src/commands/field-add-rich-text.ts index 61d4a65..571a0b7 100644 --- a/src/commands/field-add-rich-text.ts +++ b/src/commands/field-add-rich-text.ts @@ -49,7 +49,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: RichText = { @@ -67,4 +67,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-select.ts b/src/commands/field-add-select.ts index 949d946..bd44fa0 100644 --- a/src/commands/field-add-select.ts +++ b/src/commands/field-add-select.ts @@ -38,7 +38,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Select = { @@ -56,4 +56,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-table.ts b/src/commands/field-add-table.ts index 624d94b..240f8b0 100644 --- a/src/commands/field-add-table.ts +++ b/src/commands/field-add-table.ts @@ -25,7 +25,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Table = { @@ -40,4 +40,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-text.ts b/src/commands/field-add-text.ts index 3787517..aeda7cd 100644 --- a/src/commands/field-add-text.ts +++ b/src/commands/field-add-text.ts @@ -26,7 +26,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Text = { @@ -42,4 +42,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-timestamp.ts b/src/commands/field-add-timestamp.ts index 669dc12..a615147 100644 --- a/src/commands/field-add-timestamp.ts +++ b/src/commands/field-add-timestamp.ts @@ -27,7 +27,7 @@ export default createCommand(config, async ({ positionals, values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const [targetFields, fieldId] = resolveFieldTarget(fields, id); const field: Timestamp = { @@ -44,4 +44,10 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; + if (modelKind === "slice") { + console.info(` View slice: prismic slice view ${targetId}`); + } else { + console.info(` View type: prismic type view ${targetId}`); + } }); diff --git a/src/commands/field-add-uid.ts b/src/commands/field-add-uid.ts index cc3bb6f..2640e0a 100644 --- a/src/commands/field-add-uid.ts +++ b/src/commands/field-add-uid.ts @@ -37,4 +37,5 @@ export default createCommand(config, async ({ values }) => { await saveModel(); console.info("Field added: uid"); + console.info(` View type: prismic type view ${values["to-type"]!}`); }); diff --git a/src/commands/init.ts b/src/commands/init.ts index f403af1..df9a791 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -153,4 +153,8 @@ export default createCommand(config, async ({ values }) => { await adapter.syncModels({ repo, token, host }); console.info(`\nInitialized Prismic for repository "${repo}".`); + console.info(""); + console.info("Next steps:"); + console.info(" Create a type: prismic type create "); + console.info(" Sync models: prismic sync"); }); diff --git a/src/commands/preview-add.ts b/src/commands/preview-add.ts index e4cf7bd..9b850de 100644 --- a/src/commands/preview-add.ts +++ b/src/commands/preview-add.ts @@ -50,4 +50,7 @@ export default createCommand(config, async ({ positionals, values }) => { } console.info(`Preview added: ${previewUrl}`); + console.info(""); + console.info("Next steps:"); + console.info(" Set simulator: prismic preview set-simulator"); }); diff --git a/src/commands/repo-create.ts b/src/commands/repo-create.ts index d0ea8f8..5b8f94b 100644 --- a/src/commands/repo-create.ts +++ b/src/commands/repo-create.ts @@ -40,6 +40,9 @@ export default createCommand(config, async ({ values }) => { console.info(`Repository created: ${domain}`); console.info(`URL: https://${domain}.${host}/`); + console.info(""); + console.info("Next steps:"); + console.info(` Initialize project: prismic init --repo ${domain}`); }); async function findAvailableDomain(config: { diff --git a/src/commands/slice-create.ts b/src/commands/slice-create.ts index c8f71a8..c035ef1 100644 --- a/src/commands/slice-create.ts +++ b/src/commands/slice-create.ts @@ -60,4 +60,8 @@ export default createCommand(config, async ({ positionals, values }) => { await adapter.generateTypes(); console.info(`Created slice "${name}" (id: "${id}")`); + console.info(""); + console.info("Next steps:"); + console.info(` Add fields: prismic field add --to-slice ${id}`); + console.info(` Connect to type: prismic slice connect ${id} --to `); }); diff --git a/src/commands/token-create.ts b/src/commands/token-create.ts index 73e25c0..6fadc39 100644 --- a/src/commands/token-create.ts +++ b/src/commands/token-create.ts @@ -39,10 +39,11 @@ export default createCommand(config, async ({ values }) => { const token = await getToken(); const host = await getHost(); + let createdToken: string; try { if (write) { const writeToken = await createWriteToken(CLI_APP_NAME, { repo, token, host }); - console.info(`Token created: ${writeToken.token}`); + createdToken = writeToken.token; } else { const scope = allowReleases ? "master+releases" : "master"; @@ -52,7 +53,7 @@ export default createCommand(config, async ({ values }) => { if (!app) app = await createOAuthApp(CLI_APP_NAME, { repo, token, host }); const accessToken = await createOAuthAuthorization(app.id, scope, { repo, token, host }); - console.info(`Token created: ${accessToken.token}`); + createdToken = accessToken.token; } } catch (error) { if (error instanceof UnknownRequestError) { @@ -61,4 +62,9 @@ export default createCommand(config, async ({ values }) => { } throw error; } + + console.info(`Token created: ${createdToken}`); + console.info(""); + console.info("Next steps:"); + console.info(` Add to .env: PRISMIC_TOKEN=${createdToken}`); }); diff --git a/src/commands/type-create.ts b/src/commands/type-create.ts index db6f364..f31f6ed 100644 --- a/src/commands/type-create.ts +++ b/src/commands/type-create.ts @@ -113,4 +113,8 @@ export default createCommand(config, async ({ positionals, values }) => { await adapter.generateTypes(); console.info(`Created type "${name}" (id: "${id}", format: "${format}")`); + console.info(""); + console.info("Next steps:"); + console.info(` Add fields: prismic field add --to-type ${id}`); + console.info(` View type: prismic type view ${id}`); }); diff --git a/src/commands/webhook-create.ts b/src/commands/webhook-create.ts index 19c15f8..a3611e6 100644 --- a/src/commands/webhook-create.ts +++ b/src/commands/webhook-create.ts @@ -82,4 +82,7 @@ export default createCommand(config, async ({ positionals, values }) => { } console.info(`Webhook created: ${webhookUrl}`); + console.info(""); + console.info("Next steps:"); + console.info(` Set triggers: prismic webhook set-triggers ${webhookUrl}`); }); From c27729a53808f4b189b97b997ca22d82f85d1020 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 01:37:28 +0000 Subject: [PATCH 2/6] fix: include required url placeholder in preview set-simulator hint Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/preview-add.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/preview-add.ts b/src/commands/preview-add.ts index 9b850de..3755f18 100644 --- a/src/commands/preview-add.ts +++ b/src/commands/preview-add.ts @@ -52,5 +52,5 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Preview added: ${previewUrl}`); console.info(""); console.info("Next steps:"); - console.info(" Set simulator: prismic preview set-simulator"); + console.info(" Set simulator: prismic preview set-simulator "); }); From a2863f98dc03c2d9dc8edad097e803807bae3bda Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 01:51:26 +0000 Subject: [PATCH 3/6] refactor: use natural language for next-step hints Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/field-add-boolean.ts | 4 ++-- src/commands/field-add-color.ts | 4 ++-- src/commands/field-add-content-relationship.ts | 4 ++-- src/commands/field-add-date.ts | 4 ++-- src/commands/field-add-embed.ts | 4 ++-- src/commands/field-add-geopoint.ts | 4 ++-- src/commands/field-add-group.ts | 4 ++-- src/commands/field-add-image.ts | 4 ++-- src/commands/field-add-integration.ts | 4 ++-- src/commands/field-add-link.ts | 4 ++-- src/commands/field-add-number.ts | 4 ++-- src/commands/field-add-rich-text.ts | 4 ++-- src/commands/field-add-select.ts | 4 ++-- src/commands/field-add-table.ts | 4 ++-- src/commands/field-add-text.ts | 4 ++-- src/commands/field-add-timestamp.ts | 4 ++-- src/commands/field-add-uid.ts | 2 +- src/commands/init.ts | 6 ++---- src/commands/preview-add.ts | 4 +--- src/commands/repo-create.ts | 4 +--- src/commands/slice-create.ts | 6 ++---- src/commands/token-create.ts | 4 +--- src/commands/type-create.ts | 6 ++---- src/commands/webhook-create.ts | 4 +--- 24 files changed, 43 insertions(+), 57 deletions(-) diff --git a/src/commands/field-add-boolean.ts b/src/commands/field-add-boolean.ts index 5a968c5..b1f8e3a 100644 --- a/src/commands/field-add-boolean.ts +++ b/src/commands/field-add-boolean.ts @@ -54,8 +54,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-color.ts b/src/commands/field-add-color.ts index a8d7e31..2631d2a 100644 --- a/src/commands/field-add-color.ts +++ b/src/commands/field-add-color.ts @@ -44,8 +44,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-content-relationship.ts b/src/commands/field-add-content-relationship.ts index cd939c2..933715b 100644 --- a/src/commands/field-add-content-relationship.ts +++ b/src/commands/field-add-content-relationship.ts @@ -96,8 +96,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-date.ts b/src/commands/field-add-date.ts index 1c63490..c6016c0 100644 --- a/src/commands/field-add-date.ts +++ b/src/commands/field-add-date.ts @@ -46,8 +46,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-embed.ts b/src/commands/field-add-embed.ts index d953ac1..ec7e216 100644 --- a/src/commands/field-add-embed.ts +++ b/src/commands/field-add-embed.ts @@ -44,8 +44,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-geopoint.ts b/src/commands/field-add-geopoint.ts index f3ff8be..41775b3 100644 --- a/src/commands/field-add-geopoint.ts +++ b/src/commands/field-add-geopoint.ts @@ -42,8 +42,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-group.ts b/src/commands/field-add-group.ts index f254e2f..67b7167 100644 --- a/src/commands/field-add-group.ts +++ b/src/commands/field-add-group.ts @@ -42,8 +42,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-image.ts b/src/commands/field-add-image.ts index 45fc49e..4af3878 100644 --- a/src/commands/field-add-image.ts +++ b/src/commands/field-add-image.ts @@ -44,8 +44,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-integration.ts b/src/commands/field-add-integration.ts index 2488fbb..e794c1e 100644 --- a/src/commands/field-add-integration.ts +++ b/src/commands/field-add-integration.ts @@ -46,8 +46,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-link.ts b/src/commands/field-add-link.ts index 0569622..66ede8d 100644 --- a/src/commands/field-add-link.ts +++ b/src/commands/field-add-link.ts @@ -71,8 +71,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-number.ts b/src/commands/field-add-number.ts index c8b1f49..931419e 100644 --- a/src/commands/field-add-number.ts +++ b/src/commands/field-add-number.ts @@ -54,9 +54,9 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-rich-text.ts b/src/commands/field-add-rich-text.ts index 571a0b7..16c09a3 100644 --- a/src/commands/field-add-rich-text.ts +++ b/src/commands/field-add-rich-text.ts @@ -69,8 +69,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-select.ts b/src/commands/field-add-select.ts index bd44fa0..bf8791f 100644 --- a/src/commands/field-add-select.ts +++ b/src/commands/field-add-select.ts @@ -58,8 +58,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-table.ts b/src/commands/field-add-table.ts index 240f8b0..db8bf1d 100644 --- a/src/commands/field-add-table.ts +++ b/src/commands/field-add-table.ts @@ -42,8 +42,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-text.ts b/src/commands/field-add-text.ts index aeda7cd..4a8ce95 100644 --- a/src/commands/field-add-text.ts +++ b/src/commands/field-add-text.ts @@ -44,8 +44,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-timestamp.ts b/src/commands/field-add-timestamp.ts index a615147..8ada087 100644 --- a/src/commands/field-add-timestamp.ts +++ b/src/commands/field-add-timestamp.ts @@ -46,8 +46,8 @@ export default createCommand(config, async ({ positionals, values }) => { console.info(`Field added: ${id}`); const targetId = values["to-slice"] ?? values["to-type"]!; if (modelKind === "slice") { - console.info(` View slice: prismic slice view ${targetId}`); + console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); } else { - console.info(` View type: prismic type view ${targetId}`); + console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); } }); diff --git a/src/commands/field-add-uid.ts b/src/commands/field-add-uid.ts index 2640e0a..a1de186 100644 --- a/src/commands/field-add-uid.ts +++ b/src/commands/field-add-uid.ts @@ -37,5 +37,5 @@ export default createCommand(config, async ({ values }) => { await saveModel(); console.info("Field added: uid"); - console.info(` View type: prismic type view ${values["to-type"]!}`); + console.info(`Run \`prismic type view ${values["to-type"]!}\` to view the updated type.`); }); diff --git a/src/commands/init.ts b/src/commands/init.ts index df9a791..2057ed6 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -153,8 +153,6 @@ export default createCommand(config, async ({ values }) => { await adapter.syncModels({ repo, token, host }); console.info(`\nInitialized Prismic for repository "${repo}".`); - console.info(""); - console.info("Next steps:"); - console.info(" Create a type: prismic type create "); - console.info(" Sync models: prismic sync"); + console.info("Run `prismic type create ` to create a content type."); + console.info("Run `prismic sync` to sync models from Prismic."); }); diff --git a/src/commands/preview-add.ts b/src/commands/preview-add.ts index 3755f18..fa1f85c 100644 --- a/src/commands/preview-add.ts +++ b/src/commands/preview-add.ts @@ -50,7 +50,5 @@ export default createCommand(config, async ({ positionals, values }) => { } console.info(`Preview added: ${previewUrl}`); - console.info(""); - console.info("Next steps:"); - console.info(" Set simulator: prismic preview set-simulator "); + console.info("Run `prismic preview set-simulator ` to set the slice simulator URL."); }); diff --git a/src/commands/repo-create.ts b/src/commands/repo-create.ts index 5b8f94b..e20e9a2 100644 --- a/src/commands/repo-create.ts +++ b/src/commands/repo-create.ts @@ -40,9 +40,7 @@ export default createCommand(config, async ({ values }) => { console.info(`Repository created: ${domain}`); console.info(`URL: https://${domain}.${host}/`); - console.info(""); - console.info("Next steps:"); - console.info(` Initialize project: prismic init --repo ${domain}`); + console.info(`Run \`prismic init --repo ${domain}\` to initialize a project.`); }); async function findAvailableDomain(config: { diff --git a/src/commands/slice-create.ts b/src/commands/slice-create.ts index c035ef1..4405096 100644 --- a/src/commands/slice-create.ts +++ b/src/commands/slice-create.ts @@ -60,8 +60,6 @@ export default createCommand(config, async ({ positionals, values }) => { await adapter.generateTypes(); console.info(`Created slice "${name}" (id: "${id}")`); - console.info(""); - console.info("Next steps:"); - console.info(` Add fields: prismic field add --to-slice ${id}`); - console.info(` Connect to type: prismic slice connect ${id} --to `); + console.info(`Run \`prismic field add --to-slice ${id}\` to add fields.`); + console.info(`Run \`prismic slice connect ${id} --to \` to connect the slice to a type.`); }); diff --git a/src/commands/token-create.ts b/src/commands/token-create.ts index 6fadc39..f82bfe7 100644 --- a/src/commands/token-create.ts +++ b/src/commands/token-create.ts @@ -64,7 +64,5 @@ export default createCommand(config, async ({ values }) => { } console.info(`Token created: ${createdToken}`); - console.info(""); - console.info("Next steps:"); - console.info(` Add to .env: PRISMIC_TOKEN=${createdToken}`); + console.info(`Add it to your .env file: PRISMIC_TOKEN=${createdToken}`); }); diff --git a/src/commands/type-create.ts b/src/commands/type-create.ts index f31f6ed..ef6c32c 100644 --- a/src/commands/type-create.ts +++ b/src/commands/type-create.ts @@ -113,8 +113,6 @@ export default createCommand(config, async ({ positionals, values }) => { await adapter.generateTypes(); console.info(`Created type "${name}" (id: "${id}", format: "${format}")`); - console.info(""); - console.info("Next steps:"); - console.info(` Add fields: prismic field add --to-type ${id}`); - console.info(` View type: prismic type view ${id}`); + console.info(`Run \`prismic field add --to-type ${id}\` to add fields.`); + console.info(`Run \`prismic type view ${id}\` to view the type.`); }); diff --git a/src/commands/webhook-create.ts b/src/commands/webhook-create.ts index a3611e6..884f031 100644 --- a/src/commands/webhook-create.ts +++ b/src/commands/webhook-create.ts @@ -82,7 +82,5 @@ export default createCommand(config, async ({ positionals, values }) => { } console.info(`Webhook created: ${webhookUrl}`); - console.info(""); - console.info("Next steps:"); - console.info(` Set triggers: prismic webhook set-triggers ${webhookUrl}`); + console.info(`Run \`prismic webhook set-triggers ${webhookUrl}\` to configure triggers.`); }); From f99df372a438f4c6d49bee8cfea02bd1225459b2 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 02:45:20 +0000 Subject: [PATCH 4/6] refactor: use getPostFieldAddMessage in all field-add commands Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/field-add-boolean.ts | 8 +++----- src/commands/field-add-color.ts | 8 +++----- src/commands/field-add-content-relationship.ts | 8 +++----- src/commands/field-add-date.ts | 8 +++----- src/commands/field-add-embed.ts | 8 +++----- src/commands/field-add-geopoint.ts | 8 +++----- src/commands/field-add-group.ts | 8 +++----- src/commands/field-add-image.ts | 8 +++----- src/commands/field-add-integration.ts | 8 +++----- src/commands/field-add-link.ts | 8 +++----- src/commands/field-add-number.ts | 8 +++----- src/commands/field-add-rich-text.ts | 8 +++----- src/commands/field-add-select.ts | 8 +++----- src/commands/field-add-table.ts | 8 +++----- src/commands/field-add-text.ts | 8 +++----- src/commands/field-add-timestamp.ts | 8 +++----- src/commands/field-add-uid.ts | 7 +++++-- src/commands/field-add.ts | 13 +++++++++++++ 18 files changed, 66 insertions(+), 82 deletions(-) diff --git a/src/commands/field-add-boolean.ts b/src/commands/field-add-boolean.ts index b1f8e3a..33e0a7a 100644 --- a/src/commands/field-add-boolean.ts +++ b/src/commands/field-add-boolean.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add boolean", @@ -52,10 +53,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-color.ts b/src/commands/field-add-color.ts index 2631d2a..9b0077e 100644 --- a/src/commands/field-add-color.ts +++ b/src/commands/field-add-color.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add color", @@ -42,10 +43,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-content-relationship.ts b/src/commands/field-add-content-relationship.ts index 933715b..f9b777e 100644 --- a/src/commands/field-add-content-relationship.ts +++ b/src/commands/field-add-content-relationship.ts @@ -7,6 +7,7 @@ import { getCustomType } from "../clients/custom-types"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldSelection, resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add content-relationship", @@ -94,10 +95,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-date.ts b/src/commands/field-add-date.ts index c6016c0..3f2d7f6 100644 --- a/src/commands/field-add-date.ts +++ b/src/commands/field-add-date.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add date", @@ -44,10 +45,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-embed.ts b/src/commands/field-add-embed.ts index ec7e216..07d761b 100644 --- a/src/commands/field-add-embed.ts +++ b/src/commands/field-add-embed.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add embed", @@ -42,10 +43,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-geopoint.ts b/src/commands/field-add-geopoint.ts index 41775b3..141c5e6 100644 --- a/src/commands/field-add-geopoint.ts +++ b/src/commands/field-add-geopoint.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add geopoint", @@ -40,10 +41,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-group.ts b/src/commands/field-add-group.ts index 67b7167..11f55e7 100644 --- a/src/commands/field-add-group.ts +++ b/src/commands/field-add-group.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add group", @@ -40,10 +41,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-image.ts b/src/commands/field-add-image.ts index 4af3878..4aeb9ac 100644 --- a/src/commands/field-add-image.ts +++ b/src/commands/field-add-image.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add image", @@ -42,10 +43,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-integration.ts b/src/commands/field-add-integration.ts index e794c1e..b6d01b0 100644 --- a/src/commands/field-add-integration.ts +++ b/src/commands/field-add-integration.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add integration", @@ -44,10 +45,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-link.ts b/src/commands/field-add-link.ts index 66ede8d..a3b855d 100644 --- a/src/commands/field-add-link.ts +++ b/src/commands/field-add-link.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add link", @@ -69,10 +70,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-number.ts b/src/commands/field-add-number.ts index 931419e..b77aacc 100644 --- a/src/commands/field-add-number.ts +++ b/src/commands/field-add-number.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add number", @@ -52,12 +53,9 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); function parseNumber(value: string | undefined, optionName: string): number | undefined { diff --git a/src/commands/field-add-rich-text.ts b/src/commands/field-add-rich-text.ts index 16c09a3..245b5c8 100644 --- a/src/commands/field-add-rich-text.ts +++ b/src/commands/field-add-rich-text.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const ALL_BLOCKS = "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl"; @@ -67,10 +68,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-select.ts b/src/commands/field-add-select.ts index bf8791f..deeea18 100644 --- a/src/commands/field-add-select.ts +++ b/src/commands/field-add-select.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add select", @@ -56,10 +57,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-table.ts b/src/commands/field-add-table.ts index db8bf1d..47af397 100644 --- a/src/commands/field-add-table.ts +++ b/src/commands/field-add-table.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add table", @@ -40,10 +41,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-text.ts b/src/commands/field-add-text.ts index 4a8ce95..37b9374 100644 --- a/src/commands/field-add-text.ts +++ b/src/commands/field-add-text.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add text", @@ -42,10 +43,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-timestamp.ts b/src/commands/field-add-timestamp.ts index 8ada087..8054e5e 100644 --- a/src/commands/field-add-timestamp.ts +++ b/src/commands/field-add-timestamp.ts @@ -6,6 +6,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add timestamp", @@ -44,10 +45,7 @@ export default createCommand(config, async ({ positionals, values }) => { await saveModel(); console.info(`Field added: ${id}`); + const targetId = values["to-slice"] ?? values["to-type"]!; - if (modelKind === "slice") { - console.info(`Run \`prismic slice view ${targetId}\` to view the updated slice.`); - } else { - console.info(`Run \`prismic type view ${targetId}\` to view the updated type.`); - } + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add-uid.ts b/src/commands/field-add-uid.ts index a1de186..d035a49 100644 --- a/src/commands/field-add-uid.ts +++ b/src/commands/field-add-uid.ts @@ -4,6 +4,7 @@ import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; import { resolveModel } from "../models"; import { getRepositoryName } from "../project"; +import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add uid", @@ -22,7 +23,7 @@ export default createCommand(config, async ({ values }) => { const token = await getToken(); const host = await getHost(); - const [fields, saveModel] = await resolveModel(values, { repo, token, host }); + const [fields, saveModel, modelKind] = await resolveModel(values, { repo, token, host }); const field: UID = { type: "UID", @@ -37,5 +38,7 @@ export default createCommand(config, async ({ values }) => { await saveModel(); console.info("Field added: uid"); - console.info(`Run \`prismic type view ${values["to-type"]!}\` to view the updated type.`); + + const targetId = values["to-type"]!; + console.info(getPostFieldAddMessage({ targetId, modelKind })); }); diff --git a/src/commands/field-add.ts b/src/commands/field-add.ts index 2f256f6..fb4a79f 100644 --- a/src/commands/field-add.ts +++ b/src/commands/field-add.ts @@ -92,3 +92,16 @@ export default createCommandRouter({ }, }, }); + +export function getPostFieldAddMessage(args: { + targetId: string; + modelKind: "slice" | "customType"; +}): string { + const { modelKind, targetId } = args; + + if (modelKind === "slice") { + return `Run \`prismic slice view ${targetId}\` to view the updated slice.`; + } else { + return `Run \`prismic type view ${targetId}\` to view the updated type.`; + } +} From b3762208c5fa41d598ab56ab633a98002c41886d Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 02:57:14 +0000 Subject: [PATCH 5/6] refactor: move getPostFieldAddMessage to models module Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/field-add-boolean.ts | 8 ++++++-- src/commands/field-add-color.ts | 8 ++++++-- src/commands/field-add-content-relationship.ts | 9 +++++++-- src/commands/field-add-date.ts | 8 ++++++-- src/commands/field-add-embed.ts | 8 ++++++-- src/commands/field-add-geopoint.ts | 8 ++++++-- src/commands/field-add-group.ts | 8 ++++++-- src/commands/field-add-image.ts | 8 ++++++-- src/commands/field-add-integration.ts | 8 ++++++-- src/commands/field-add-link.ts | 8 ++++++-- src/commands/field-add-number.ts | 8 ++++++-- src/commands/field-add-rich-text.ts | 8 ++++++-- src/commands/field-add-select.ts | 8 ++++++-- src/commands/field-add-table.ts | 8 ++++++-- src/commands/field-add-text.ts | 8 ++++++-- src/commands/field-add-timestamp.ts | 8 ++++++-- src/commands/field-add-uid.ts | 3 +-- src/commands/field-add.ts | 13 ------------- src/models.ts | 13 +++++++++++++ 19 files changed, 111 insertions(+), 47 deletions(-) diff --git a/src/commands/field-add-boolean.ts b/src/commands/field-add-boolean.ts index 33e0a7a..18cf5c2 100644 --- a/src/commands/field-add-boolean.ts +++ b/src/commands/field-add-boolean.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add boolean", diff --git a/src/commands/field-add-color.ts b/src/commands/field-add-color.ts index 9b0077e..55baa7c 100644 --- a/src/commands/field-add-color.ts +++ b/src/commands/field-add-color.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add color", diff --git a/src/commands/field-add-content-relationship.ts b/src/commands/field-add-content-relationship.ts index f9b777e..0b3e39d 100644 --- a/src/commands/field-add-content-relationship.ts +++ b/src/commands/field-add-content-relationship.ts @@ -5,9 +5,14 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { getCustomType } from "../clients/custom-types"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldSelection, resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldSelection, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add content-relationship", diff --git a/src/commands/field-add-date.ts b/src/commands/field-add-date.ts index 3f2d7f6..d5989ec 100644 --- a/src/commands/field-add-date.ts +++ b/src/commands/field-add-date.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add date", diff --git a/src/commands/field-add-embed.ts b/src/commands/field-add-embed.ts index 07d761b..1abda71 100644 --- a/src/commands/field-add-embed.ts +++ b/src/commands/field-add-embed.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add embed", diff --git a/src/commands/field-add-geopoint.ts b/src/commands/field-add-geopoint.ts index 141c5e6..682492f 100644 --- a/src/commands/field-add-geopoint.ts +++ b/src/commands/field-add-geopoint.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add geopoint", diff --git a/src/commands/field-add-group.ts b/src/commands/field-add-group.ts index 11f55e7..1047f70 100644 --- a/src/commands/field-add-group.ts +++ b/src/commands/field-add-group.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add group", diff --git a/src/commands/field-add-image.ts b/src/commands/field-add-image.ts index 4aeb9ac..aba3011 100644 --- a/src/commands/field-add-image.ts +++ b/src/commands/field-add-image.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add image", diff --git a/src/commands/field-add-integration.ts b/src/commands/field-add-integration.ts index b6d01b0..e02bb8a 100644 --- a/src/commands/field-add-integration.ts +++ b/src/commands/field-add-integration.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add integration", diff --git a/src/commands/field-add-link.ts b/src/commands/field-add-link.ts index a3b855d..d27160b 100644 --- a/src/commands/field-add-link.ts +++ b/src/commands/field-add-link.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add link", diff --git a/src/commands/field-add-number.ts b/src/commands/field-add-number.ts index b77aacc..2653ca8 100644 --- a/src/commands/field-add-number.ts +++ b/src/commands/field-add-number.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add number", diff --git a/src/commands/field-add-rich-text.ts b/src/commands/field-add-rich-text.ts index 245b5c8..269da6f 100644 --- a/src/commands/field-add-rich-text.ts +++ b/src/commands/field-add-rich-text.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const ALL_BLOCKS = "paragraph,preformatted,heading1,heading2,heading3,heading4,heading5,heading6,strong,em,hyperlink,image,embed,list-item,o-list-item,rtl"; diff --git a/src/commands/field-add-select.ts b/src/commands/field-add-select.ts index deeea18..972c777 100644 --- a/src/commands/field-add-select.ts +++ b/src/commands/field-add-select.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add select", diff --git a/src/commands/field-add-table.ts b/src/commands/field-add-table.ts index 47af397..59bd1a7 100644 --- a/src/commands/field-add-table.ts +++ b/src/commands/field-add-table.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add table", diff --git a/src/commands/field-add-text.ts b/src/commands/field-add-text.ts index 37b9374..7f1f2ea 100644 --- a/src/commands/field-add-text.ts +++ b/src/commands/field-add-text.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add text", diff --git a/src/commands/field-add-timestamp.ts b/src/commands/field-add-timestamp.ts index 8054e5e..0ef03a3 100644 --- a/src/commands/field-add-timestamp.ts +++ b/src/commands/field-add-timestamp.ts @@ -4,9 +4,13 @@ import { capitalCase } from "change-case"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveFieldTarget, resolveModel, TARGET_OPTIONS } from "../models"; +import { + getPostFieldAddMessage, + resolveFieldTarget, + resolveModel, + TARGET_OPTIONS, +} from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add timestamp", diff --git a/src/commands/field-add-uid.ts b/src/commands/field-add-uid.ts index d035a49..5dafbe9 100644 --- a/src/commands/field-add-uid.ts +++ b/src/commands/field-add-uid.ts @@ -2,9 +2,8 @@ import type { UID } from "@prismicio/types-internal/lib/customtypes"; import { getHost, getToken } from "../auth"; import { CommandError, createCommand, type CommandConfig } from "../lib/command"; -import { resolveModel } from "../models"; +import { getPostFieldAddMessage, resolveModel } from "../models"; import { getRepositoryName } from "../project"; -import { getPostFieldAddMessage } from "./field-add"; const config = { name: "prismic field add uid", diff --git a/src/commands/field-add.ts b/src/commands/field-add.ts index fb4a79f..2f256f6 100644 --- a/src/commands/field-add.ts +++ b/src/commands/field-add.ts @@ -92,16 +92,3 @@ export default createCommandRouter({ }, }, }); - -export function getPostFieldAddMessage(args: { - targetId: string; - modelKind: "slice" | "customType"; -}): string { - const { modelKind, targetId } = args; - - if (modelKind === "slice") { - return `Run \`prismic slice view ${targetId}\` to view the updated slice.`; - } else { - return `Run \`prismic type view ${targetId}\` to view the updated type.`; - } -} diff --git a/src/models.ts b/src/models.ts index e78d730..acf6cd9 100644 --- a/src/models.ts +++ b/src/models.ts @@ -435,3 +435,16 @@ function validateLeafField(id: string, fields: Record, context: s ); } } + +export function getPostFieldAddMessage(args: { + targetId: string; + modelKind: "slice" | "customType"; +}): string { + const { modelKind, targetId } = args; + + if (modelKind === "slice") { + return `Run \`prismic slice view ${targetId}\` to view the updated slice.`; + } else { + return `Run \`prismic type view ${targetId}\` to view the updated type.`; + } +} From 73976d5feb85f0f404a13bf42f2fbb4b1cccaad8 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Sat, 18 Apr 2026 03:08:54 +0000 Subject: [PATCH 6/6] fix: use correct env var names in token create hint Use PRISMIC_ACCESS_TOKEN for read tokens and PRISMIC_WRITE_TOKEN for write tokens. Fix token-create tests to extract the token from only the first output line. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/commands/token-create.ts | 3 ++- test/token-create.test.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/commands/token-create.ts b/src/commands/token-create.ts index f82bfe7..2fb3728 100644 --- a/src/commands/token-create.ts +++ b/src/commands/token-create.ts @@ -64,5 +64,6 @@ export default createCommand(config, async ({ values }) => { } console.info(`Token created: ${createdToken}`); - console.info(`Add it to your .env file: PRISMIC_TOKEN=${createdToken}`); + const envVar = write ? "PRISMIC_WRITE_TOKEN" : "PRISMIC_ACCESS_TOKEN"; + console.info(`Add it to your .env file: ${envVar}=${createdToken}`); }); diff --git a/test/token-create.test.ts b/test/token-create.test.ts index 46cf18e..aa9b5c9 100644 --- a/test/token-create.test.ts +++ b/test/token-create.test.ts @@ -12,7 +12,8 @@ it("creates an access token", async ({ expect, prismic, repo, token, host }) => expect(exitCode).toBe(0); expect(stdout).toContain("Token created:"); - const createdToken = stdout.replace("Token created:", "").trim(); + const createdToken = stdout.match(/Token created: (.+)/)?.[1]; + expect(createdToken).toBeDefined(); const apps = await getAccessTokens({ repo, token, host }); const app = apps.find((a) => a.name === "Prismic CLI"); @@ -32,7 +33,8 @@ it("creates an access token with --allow-releases", async ({ expect(exitCode).toBe(0); expect(stdout).toContain("Token created:"); - const createdToken = stdout.replace("Token created:", "").trim(); + const createdToken = stdout.match(/Token created: (.+)/)?.[1]; + expect(createdToken).toBeDefined(); const apps = await getAccessTokens({ repo, token, host }); const app = apps.find((a) => a.name === "Prismic CLI"); @@ -47,7 +49,8 @@ it("creates a write token", async ({ expect, prismic, repo, token, host }) => { expect(exitCode).toBe(0); expect(stdout).toContain("Token created:"); - const createdToken = stdout.replace("Token created:", "").trim(); + const createdToken = stdout.match(/Token created: (.+)/)?.[1]; + expect(createdToken).toBeDefined(); const writeTokensInfo = await getWriteTokens({ repo, token, host }); const found = writeTokensInfo.tokens.find((t) => t.token === createdToken);