Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nextjs] Use the app name as the prefix value for templates #800

Merged
merged 12 commits into from
Sep 8, 2021

Conversation

CobyPear
Copy link
Contributor

@CobyPear CobyPear commented Sep 3, 2021

When developing locally, multiple templates with the same name will conflict causing errors when using strongly typed GraphQL queries.
This feature adds a prefix to some files so that when jss create is run, the prefix is replaced with the appname, which will give each template a unique name in Sitecore when using jss deploy

Description / Motivation

  • Added a prefix to pertinent files and filenames in the Nextjs sample app
  • Added a function to the create script in sitecore-jss-cli that replaces the prefix with the appname

Faster internal development

Testing Details

  • GraphQL components and queries require Capitalization format. A function was written to preform this task and a unit test was added.
  • Used jss create to scaffold a new Nextjs app and deployed it to Sitecore along with the sample app - no conflicting template names = no errors! 🥳

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update (non-breaking change; modified files are limited to the /docs directory)

@CobyPear CobyPear requested a review from a team September 3, 2021 15:07
@vercel
Copy link

vercel bot commented Sep 3, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sitecore-jss/edge-e2e-styleguide/Gc7iaWwqJwuez84sNFdA4tx2d7ym
✅ Preview: https://edge-e2e-styleguide-git-feature-482700-pref-0684b5-sitecore-jss.vercel.app

[Deployment for cf39f5b failed]

packages/sitecore-jss-cli/src/create/index.test.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

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

This is working brilliantly. Not sure if you had this planned for "phase 2" (apply to RAV), but we discussed adding a flag to jss create to make the prefix opt-in (for backwards compatibility). I think this is still valuable, and I don't think it'd be that much extra work?

packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

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

Just a couple minor things, otherwise looks good!

packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
packages/sitecore-jss-cli/src/create/index.ts Outdated Show resolved Hide resolved
@CobyPear CobyPear merged commit d70c608 into dev Sep 8, 2021
@CobyPear CobyPear deleted the feature/482700-prefix-templates branch September 8, 2021 17:28
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.

2 participants