From 3b505d7449415b373366f6272b55f5cbe188ae35 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Tue, 31 Jan 2023 14:19:13 -0500 Subject: [PATCH] [create-sitecore-jss] Incompatibility message when installing sxa and styleguide (#1315) * Incompatibility message when installing sxa and styleguide * add prompt warning --- .../src/initializers/nextjs-sxa/index.ts | 8 ++++++++ .../src/initializers/nextjs/prompts.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/create-sitecore-jss/src/initializers/nextjs-sxa/index.ts b/packages/create-sitecore-jss/src/initializers/nextjs-sxa/index.ts index d24687c824..7a7d6cad64 100644 --- a/packages/create-sitecore-jss/src/initializers/nextjs-sxa/index.ts +++ b/packages/create-sitecore-jss/src/initializers/nextjs-sxa/index.ts @@ -5,6 +5,7 @@ import { transform, DEFAULT_APPNAME, ClientAppArgs, + incompatibleAddonsMsg, } from '../../common'; export default class NextjsSxaInitializer implements Initializer { @@ -28,6 +29,13 @@ export default class NextjsSxaInitializer implements Initializer { await transform(templatePath, mergedArgs); + if ( + args.templates.includes('nextjs-styleguide') || + pkg.config?.templates?.includes('nextjs-styleguide') + ) { + console.log(incompatibleAddonsMsg('nextjs-sxa', 'nextjs-styleguide')); + } + const response = { // TODO: next steps nextSteps: [], diff --git a/packages/create-sitecore-jss/src/initializers/nextjs/prompts.ts b/packages/create-sitecore-jss/src/initializers/nextjs/prompts.ts index d44236f4c4..e501ed1d91 100644 --- a/packages/create-sitecore-jss/src/initializers/nextjs/prompts.ts +++ b/packages/create-sitecore-jss/src/initializers/nextjs/prompts.ts @@ -53,5 +53,14 @@ export class NextjsCheckbox extends CheckboxPrompt { isValid: incompatibleAddonsMsg('nextjs-styleguide-tracking', 'nextjs-personalize'), }); } + + const isSxaSelected = isSelected('nextjs-sxa'); + const isStyleguideSelected = isSelected('nextjs-styleguide'); + + if (isSxaSelected && isStyleguideSelected) { + this.onError({ + isValid: incompatibleAddonsMsg('nextjs-sxa', 'nextjs-styleguide'), + }); + } } }