Create-slice behaves differently since prismic-cli 4.2

Since I upgraded to the prismic-cli v4.2 the sm --create-slice behaves differently in the sense:

  1. it throws a conflict with slices\index.js and asks if it should overwrite it. I usually confirm that it can be overwritten, but i get this question every single time. Any idea how to fix this?

  2. It creates the index.stories.js and mocks.json into the .slicemachine\assets... folder instead in the slices... folder. This causes storybook to not recognize the slice. I can probably easily change this by telling storybook where to search, but I would like to get some advicehow to do it the right way.


Hello Peter, thanks for reaching out!

--create-slice is a legacy command that is no longer available to create new Slices. Now you should use Slice Machine that helps you create your Slices visually:

We've mentioned this in other threads. Here's some useful advice:

Thanks, i updated now slice-machine-ui and when i run prismic sm --develop I get an error that Slicemachine requires node version >=15. To be able to test the website with the same node version as on production, I'm limitted to v12 and v14 though (production is on vercel). Do you have any tips for this issue?

That is strange. It should be working with at least version 12.16.1 of node. Can you please send us a screenshot of the error and your package.json file so we can reproduce your use case on our end?

I upgraded to 16 for testing purpose and it started fine.
In package.json I have for slicemachine this under devDependencies:
"slice-machine-ui": "^0.1.0"

I got another problem as well with the new version - it suddenly doesn't except special characters in field API ID's despite that the standard API fields have all underscores, such as first_publication_date. Why this inconsistency and do i really need to change all fields now?

I see. I'll share this with the product team, and we'll add it as a feature request.

About the errors with node 12. The dev team is going to release a brand new version of the Slice Machine workflow. This will involve installing this in your project:

npx @slicemachine/init

This will allow you to start Slice Machine with one command:

npm run slicemachine

Next week we'll also release a fix that will enable this command to support node 12!
So for the moment, if you want to test this beta version of @slicemachine/init, you'll need to use node 15.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

@Pau - Is there any plan to fix this inconsistency?

@peter2, Slice Machine now works entirely with the npx @slicemachine/init dependency, so commands like --create-slice are no longer supported. Are you referring to this?

no, i was referring to the syntax change. I seem to be able to use any syntax when changing the json model itself which prevents that I have to go through all custom types and documents, but it's very disruptive.

I understand.

No, it is not yet possible to add special characters to fields.
We recommend that you do not make these types of manual modifications to the JSON to prevent Slice Machine from returning a conflict.

Hi Pau, I think you misunderstood. With one of the last versions Slice Machine changed from underscore to camelCase syntax for fields added through the slice machine. Prismic on the other hand still uses underscore syntax. So, right now when I make an API call, I get some fields with underscore and some others with camelCase syntax in the response. And worse - if I created a slice prior one of the last updates of slice machine, it used underscore and if I make any change, the new version just changes the syntax to cancelCase. So, you got inconsistencies as well as further production disruption in case slice machine changes their mind again.


Now I understand. This is a limitation that we are aware of. At the moment we do not have a standardized migration process from Legacy Builder to Slice Machine and unfortunately, this means that, if in the early stages you started out using both builders and now just use Slice Machine, you might run into these inconsistencies.

The only way to solve it is to re-add the fields that previously used underscore syntax and change them to use camelCase. This will imply that the content of the original field is removed. This is a workaround that has drawbacks but it is the workaround available to integrate a single type of syntax into your new Custom Types.