Skip to content

fix: create new slices in the first configured library#199

Merged
lihbr merged 2 commits into
mainfrom
lh/fix-slice-library-pull
Jun 23, 2026
Merged

fix: create new slices in the first configured library#199
lihbr merged 2 commits into
mainfrom
lh/fix-slice-library-pull

Conversation

@lihbr

@lihbr lihbr commented Jun 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Use the first slice library from prismic.config.json when creating slices via pull, sync, and slice create
  • Fall back to the framework default library when no libraries are configured
  • Add integration tests and update test helpers/matchers for custom library paths

Test plan

  • Run npm test -- test/pull.test.ts test/slice-create.test.ts with E2E credentials
  • Configure libraries: ["./slices/blog"] in a project, create a slice in Type Builder, run prismic pull, and confirm the slice lands under ./slices/blog/
  • Run a subsequent prismic push and confirm the slice is recognized

Note

Low Risk
Behavior change is limited to slice creation target paths; existing multi-library read paths were already in place, with new tests covering the configured-library case.

Overview
New slices from pull, sync, and slice create are written to the first path in prismic.config.json libraries, instead of always using the framework default (e.g. ./slices/).

Adapter.createSlice now defaults library to (await getSliceLibraries())[0], which already resolves configured libraries or falls back to the default when none are set.

Test helpers and toContainSlice were updated to scan all configured libraries (via getSliceLibraries / glob), and integration tests assert slices land under the first library (e.g. ./slices/blog) and not the root ./slices/ path.

Reviewed by Cursor Bugbot for commit 20bbcef. Bugbot is set up for automated code reviews on this repo. Configure here.

When prismic.config.json defines slice libraries, pull and slice create
were writing new slices to the framework default path instead of the first
listed library, causing them to be missed on subsequent push/pull cycles.

Co-authored-by: Cursor <cursoragent@cursor.com>

@jomifepe jomifepe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@angeloashmore angeloashmore mentioned this pull request Jun 23, 2026
3 tasks

@angeloashmore angeloashmore left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it looks good. I made a few refactors for the sake of code cleanliness, but the functionality remains the same: #200

@lihbr lihbr merged commit b5dda43 into main Jun 23, 2026
28 of 29 checks passed
@lihbr lihbr deleted the lh/fix-slice-library-pull branch June 23, 2026 23:58
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.

3 participants