slice-machine icon indicating copy to clipboard operation
slice-machine copied to clipboard

fix(init): allow `@slicemachine/init` to run in Gatsby projects

Open angeloashmore opened this issue 3 years ago • 0 comments

Types of changes

  • [x] Bug fix (a non-breaking change which fixes an issue)
  • [ ] New feature (a non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR allows @slicemachine/init to be used in Gatsby project. Slice Machine itself does not fully support Gatsby, but @slicemachine/init should be usable in projects that have Gatsby installed. Gatsby projects can use Slice Machine in its framework-agnostic mode.

This PR treats Gatsby like other non-Next.js/Nuxt supported frameworks, including React, Svelte, and Vanilla JS.

Current behavior

Running npx @slicemachine/init today in a project with gatsby as a dependency displays the following error:

You're about to configure Slicemachine... Press ctrl + C to cancel
✔ Logged in as [email protected]
Error! Gatsby is currently not supported
Please run npx @slicemachine/init in a Nuxt or Next.js project

You can see this happening by testing the Gatsby Blog starter:

npx degit prismicio-community/gatsby-starter-prismic-blog your-project-name
cd your-project-name
npx @slicemachine/init

Alternatives

  1. We could introduce an --ignore-framework flag that bypasses the framework check:

    npx @slicemachine/init --ignore-framework
    
  2. We could read the framework property in sm.json to detect the framework. @slicemachine/init currently ignores the framework configuration property.

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly. (PR: #)
  • [x] All new and existing tests are passing.

angeloashmore avatar Aug 30 '22 21:08 angeloashmore