Skip to content

feat: report file and remote mutations via structured action logger#143

Draft
angeloashmore wants to merge 1 commit intomainfrom
aa/structured-logs
Draft

feat: report file and remote mutations via structured action logger#143
angeloashmore wants to merge 1 commit intomainfrom
aa/structured-logs

Conversation

@angeloashmore
Copy link
Copy Markdown
Member

Resolves: #142

Description

Adds a structured action logger (src/lib/logger.ts) so commands can tell users (and AI agents) exactly which files and remote resources were mutated. Adapters and commands call reportAction at mutation sites; commands flushActions and formatAction to print details alongside their existing summary line.

Actions are a discriminated union (file-created/file-updated/file-deleted/remote-created/remote-updated/remote-deleted), so future --json and --quiet modes can format the same data differently without changing call sites.

Example output for prismic type create "Blog Post" --format page:

Created remote type "Blog Post"
Created customtypes/blog_post/index.json
Created app/blog-post/[uid]/page.tsx
Updated prismicio-types.d.ts
Created type "Blog Post" (id: "blog_post", format: "page")

Wired into the adapter base class (all seven CRUD methods), all three framework adapters (Next.js/Nuxt/SvelteKit hooks + setupProject helpers), and the following commands: type-create, slice-create, type-remove, slice-remove, gen-types, gen-setup, init, sync (both non-watch and watch modes).

Deferred to follow-up: field mutation commands (models.ts, field-add-*, etc.), webhook/preview/token commands, --json/--quiet flags themselves.

Checklist

  • A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

How to QA

  • prismic type create Foo --format page — confirm file paths and remote action print before the summary
  • prismic slice create Hero — same
  • prismic gen types — confirm Updated prismicio-types.d.ts prints
  • prismic sync --watch — confirm actions flush per cycle (no accumulation)
  • prismic init in a fresh Next.js/Nuxt/SvelteKit project — confirm all generated files are listed

Adds `src/lib/logger.ts` — a module-level action collector with a
discriminated union for file/remote created/updated/deleted actions,
`reportAction`, `flushActions`, and `formatAction`. Adapters and
commands report mutations; commands flush and print them alongside
their summary. Lays groundwork for future `--json`/`--quiet` modes.

Resolves: #142

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

type create --format page silently skips page file generation

1 participant