refactor: re-implement sync command without plugin system#7
refactor: re-implement sync command without plugin system#7angeloashmore merged 2 commits intomainfrom
Conversation
Replace plugin-system-based sync with direct file operations via a new Next.js-specific module. This removes the dependency on @prismicio/plugin-kit and handles custom type/slice CRUD, component scaffolding, and library index generation natively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Slice Machine plugin-based framework handling with direct framework adapters. Each adapter manages slice component generation, library index files, and framework-specific templates natively. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| await rename(existingCustomTypeDirectory, newCustomTypeDirectory); | ||
| const { modelPath } = await this.#writeCustomTypeModel(model); | ||
| return { modelPath }; | ||
| } |
There was a problem hiding this comment.
renameCustomType renames directory to itself
Medium Severity
renameCustomType computes both existingCustomTypeDirectory and newCustomTypeDirectory by calling #getCustomTypeDirectory(model.id) with the same model.id, producing identical paths. The rename() call is a no-op. Compare with renameSlice, which correctly uses the existing on-disk directory vs a newly computed directory from model.name.
Additional Locations (1)
| } | ||
| const projectRoot = new URL("./", packageJsonPath); | ||
| return projectRoot; | ||
| } |
There was a problem hiding this comment.
Entire nextjs.ts file is unused dead code
Medium Severity
src/lib/nextjs.ts is a 391-line file with exported functions (initProject, createSlice, readSlice, updateSlice, etc.) that duplicates the functionality already implemented in FrameworkAdapter and NextJsFramework. No file in the codebase imports from ./lib/nextjs. This appears to be a leftover from an earlier implementation approach that was superseded by the class-based framework-adapter.ts system.
| if (customTypesChanged) { | ||
| await syncCustomTypes(repo, framework); | ||
| lastRemoteCustomTypesHash = remoteCustomTypesHash; | ||
| } |
There was a problem hiding this comment.
Watch loop double-fetches remote data on sync
Low Severity
In watchForChanges, each poll cycle fetches remote slices and custom types for hash comparison. When changes are detected, syncSlices and syncCustomTypes each fetch the same data again from the API, doubling API calls on every change detection cycle. The already-fetched data from the hash check could be passed through instead.


Resolves:
Description
Remove the dependency on
@prismicio/plugin-kitand the Slice Machine plugin system from the sync command. Instead, the CLI now handles all sync operations natively.Framework adapters: New
FrameworkAdapterabstraction with concrete implementations for Next.js, Nuxt, and SvelteKit. The implementations are based on the original Slice Machine adapters.Checklist
Preview
How to QA 1
Note
High Risk
Large refactor of the
prismic syncflow plus changes to token validation inisAuthenticated(); mistakes could cause sync to write/delete the wrong local files or incorrectly treat users as logged out.Overview
prismic syncis reimplemented to no longer rely on the Slice Machine plugin system. It now detects the project framework (Next.js/Nuxt/SvelteKit) viapackage.jsonand syncs slices/custom types by directly reading/writing local model files through a newFrameworkAdapterabstraction.Adds concrete adapters for Next.js, Nuxt, and SvelteKit, including template generation for slice components and framework-specific scaffolding/config tweaks (e.g., Nuxt module registration, Next.js preview/simulator routes, SvelteKit preview routing and Vite allowlist).
Separately, updates auth verification to validate the stored
prismic-authtoken via the user-serviceprofileendpoint (dropping refresh-token parsing), and introduces small supporting utilities (dedent,addDependencies, globbing/indent detection) with new dev dependencies.Written by Cursor Bugbot for commit 3466e03. This will update automatically on new commits. Configure here.
Footnotes
Please use these labels when submitting a review:
⚠️ #issue: Strongly suggest a change.
❓ #ask: Ask a question.
💡 #idea: Suggest an idea.
🎉 #nice: Share a compliment. ↩