question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: Add support of the `pull` command in the Prismic CLI

See original GitHub issue

Summary

We want to add a way to synchronize your components between Prismic and your project. It would be a CLI command that will scan all your slices on Prismic side and all your slicemachine components on the other side to help you create the missing ones and update the others if needed.

Motivation

The goal of Slicemachine is to have a more code-centric approach and avoid all these steps of simply synchronizing your setup on Prismic and your project. The CLI is supposed to be here to resolve this connection and automate things for you.

Here we face the case where you add Components from the Writing Room that is connected to all of our Slicemachine Libraries. You can even imagine that these slices that already exists in your project might have been updated since then. So here, it’s just a quick way to resolve these cases seamlessly.

Scenario

Let’s say that you just setup your project for SliceMachine with the following command:

> prismic sm --setup

It created 3 slices:

  • CallToAction
  • Banner
  • HighlightItems

At some point, you decide to change the models of CallToAction and Banner and to add a new slice called HelloWorld from the writing room. You can use the following command to update your project accordingly:

> prismic sm --sync

These slices were added to your project:
 - HelloWorld

Conflicts on the custom type `page`.
All these components already exists but their model diverge.
Select the components you'd like to update:
 [ ] CallToAction
 [x] Banner

 We successfully updated the model of:
  - Banner

Please update your implementation accordingly.

implementation

  • Create a new command --sync for slicemachine that will be recognize by the CLI.
  • Gather all the models of the slices coming from the different libraries listed in sm.json
  • Fetch all the slices coming from your custom types through the CustomTypes API (see create-slice as an example)
  • Make a diff between these to identify:
    • Existing slices already up to date
    • Existing slices that have conflicts because of updates on the Writing room
    • Missing slices that should be added to the project
  • Create the Missing Slices
  • Create an interactive way with inquirer (Already the dependency used for Prompts) to resolve conflicts and update or not the models in the code.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
arnaudlewiscommented, Jun 12, 2020
3reactions
lihbrcommented, Jun 9, 2020

Took me a bit of time to understand the sync described here but if I’m right current behavior of prismic sm --sync looks more like a pull than a true sync to me (which would have been applying last diffs on both sides) That’s why I find it a bit misleading put that way, probably 🤔

In my opinion, it’ll be clearer to make it like prismic sm --pull or similar so we’ll be able to work on it from that point, and then we’ll be able to work on a counterpart prismic sm --push if needed? Both resulting to some sort of an interactive prompt allowing people to choose which contents to override and whatnot with the pull/push command (like on the example described in the given scenario).

As for slices used through dependencies perhaps it’ll be simpler to introduce a third command like prismic sm --push-deps (not sure at all about that name), to just push/update their models to Prismic with an interactive prompt again to be sure we’re not overriding anything not wanted. If we get through this path though this means that the previous pull/push commands will only care about project-level slices (not the ones from dependencies), hope that makes sense~

With all of that in mind, I think it raises few questions like how we’re sure we’re doing the matching correctly between Prismic slices and their models (not sure how that’s done currently), also as @hypervillain pointed out what about knowing which customs types a model belongs to?

Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC: Add support of the pull command in the Prismic CLI #8
We want to add a way to synchronize your components between Prismic and your project. It would be a CLI command that will...
Read more >
Slice Machine Iteration 8 June 2020 - Pull command & Next.js Support
Slice Machine Iteration 8 June 2020 - Pull command & Next.js Support · Developing with Prismic ... RFC: Add support of the `pull`...
Read more >
lDf - River Thames Conditions - Environment Agency - GOV.UK
Aikatsu ran shibuki, 270 shoe size us, Hp factory restore command prompt, Salicylic acid ... Hunter fred dryer season 7, Chelsea pensioners carol...
Read more >
Gatsby Changelog | 5.3.0
We plan on adding support in a future minor release by using the .mts ... ElegantStack: chore(docs): add options command to cli reference...
Read more >
Untitled
Muzikal film, Magamba nature reserve, Kdk support.msi, Bondi gold lounge, Wait a minute doc are you telling me. Hd english new movies! Cmenu...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found