From 8e6068f0b0266aa234230a7da5ddfe68de071ef2 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Thu, 18 Jul 2024 16:35:21 -0400 Subject: [PATCH 1/7] sxp/xmc journey prep (cherry picked from commit 6a9058d7d2cb5ff62151f8c80f3ee24c1a8df2d0) --- .../src/initializers/angular/index.ts | 15 +++++++++++++ .../src/initializers/angular/prompts.ts | 21 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/create-sitecore-jss/src/initializers/angular/index.ts b/packages/create-sitecore-jss/src/initializers/angular/index.ts index 3881e51efe..12321ed47c 100644 --- a/packages/create-sitecore-jss/src/initializers/angular/index.ts +++ b/packages/create-sitecore-jss/src/initializers/angular/index.ts @@ -19,10 +19,25 @@ export default class AngularInitializer implements Initializer { }; const templatePath = path.resolve(__dirname, '../../templates/angular'); await transform(templatePath, mergedArgs); + const addInitializers: string[] = []; + + if (answers.xmcloud) { + if (!args.templates.includes('angular-xmcloud')) { + addInitializers.push('angular-xmcloud'); + } + if (!args.templates.includes('node-xmcloud-proxy')) { + addInitializers.push('angular-xmcloud'); + } + } else { + if (!args.templates.includes('angular-sxp')) { + addInitializers.push('angular-sxp'); + } + } const response = { nextSteps: [`* Connect to Sitecore with ${chalk.green('jss setup')} (optional)`], appName: answers.appName, + initializers: addInitializers, }; return response; diff --git a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts index 8d14703ca7..fae22c0732 100644 --- a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts +++ b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts @@ -5,6 +5,23 @@ import { styleguidePrompts, } from '../../common'; -export type AngularAnswer = ClientAppAnswer & StyleguideAnswer; +export type AngularAnswer = ClientAppAnswer & StyleguideAnswer & { + xmcloud: boolean +}; -export const prompts = [...clientAppPrompts, ...styleguidePrompts]; +export const prompts = [...clientAppPrompts, { + type: 'confirm', + name: 'xmcloud', + message: 'Are you building for Sitecore XM Cloud?', + default: false, + when: (answers: AngularAnswer): boolean => { + // don't prompt if --yes or nextjs-xmcloud template was specified + if (answers.yes) { + return false; + } else if (answers.templates.includes('angular-xmcloud') && !answers.templates.includes('angular-sxp')) { + answers.xmcloud = true; + return false; + } + return true; + }, +}, ...styleguidePrompts]; From 798edbe4d67187560f274311429ce3d6a756dce8 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Fri, 19 Jul 2024 08:14:53 -0400 Subject: [PATCH 2/7] lint (cherry picked from commit 9501b262420715fa4acb477780f15885b93dc68e) --- .../src/initializers/angular/prompts.ts | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts index fae22c0732..11b0bc8cf3 100644 --- a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts +++ b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts @@ -5,23 +5,31 @@ import { styleguidePrompts, } from '../../common'; -export type AngularAnswer = ClientAppAnswer & StyleguideAnswer & { - xmcloud: boolean -}; +export type AngularAnswer = ClientAppAnswer & + StyleguideAnswer & { + xmcloud: boolean; + }; -export const prompts = [...clientAppPrompts, { - type: 'confirm', - name: 'xmcloud', - message: 'Are you building for Sitecore XM Cloud?', - default: false, - when: (answers: AngularAnswer): boolean => { - // don't prompt if --yes or nextjs-xmcloud template was specified - if (answers.yes) { - return false; - } else if (answers.templates.includes('angular-xmcloud') && !answers.templates.includes('angular-sxp')) { - answers.xmcloud = true; - return false; - } - return true; +export const prompts = [ + ...clientAppPrompts, + { + type: 'confirm', + name: 'xmcloud', + message: 'Are you building for Sitecore XM Cloud?', + default: false, + when: (answers: AngularAnswer): boolean => { + // don't prompt if --yes or nextjs-xmcloud template was specified + if (answers.yes) { + return false; + } else if ( + answers.templates.includes('angular-xmcloud') && + !answers.templates.includes('angular-sxp') + ) { + answers.xmcloud = true; + return false; + } + return true; + }, }, -}, ...styleguidePrompts]; + ...styleguidePrompts, +]; From f59e55d0e5e9e34e52f2f208b806cfc354d748be Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Sun, 21 Jul 2024 21:31:00 -0400 Subject: [PATCH 3/7] add stub initializers (cherry picked from commit f90190b889e2d6005ab836492b24a12d07a75d01) --- .../src/initializers/angular-sxp/index.ts | 17 +++++++++++++++++ .../src/initializers/angular-xmcloud/index.ts | 17 +++++++++++++++++ .../initializers/node-xmcloud-proxy/index.ts | 15 +++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 packages/create-sitecore-jss/src/initializers/angular-sxp/index.ts create mode 100644 packages/create-sitecore-jss/src/initializers/angular-xmcloud/index.ts create mode 100644 packages/create-sitecore-jss/src/initializers/node-xmcloud-proxy/index.ts diff --git a/packages/create-sitecore-jss/src/initializers/angular-sxp/index.ts b/packages/create-sitecore-jss/src/initializers/angular-sxp/index.ts new file mode 100644 index 0000000000..53899d047e --- /dev/null +++ b/packages/create-sitecore-jss/src/initializers/angular-sxp/index.ts @@ -0,0 +1,17 @@ +import { ClientAppArgs, DEFAULT_APPNAME, Initializer } from '../../common'; +import { InitializerResults } from '../../common/Initializer'; + +export default class AngularXmCloudInitializer implements Initializer { + get isBase(): boolean { + return false; + } + + async init(args: ClientAppArgs) { + const response: InitializerResults = { + nextSteps: [], + appName: args.appName || DEFAULT_APPNAME, + }; + + return response; + } +} diff --git a/packages/create-sitecore-jss/src/initializers/angular-xmcloud/index.ts b/packages/create-sitecore-jss/src/initializers/angular-xmcloud/index.ts new file mode 100644 index 0000000000..53899d047e --- /dev/null +++ b/packages/create-sitecore-jss/src/initializers/angular-xmcloud/index.ts @@ -0,0 +1,17 @@ +import { ClientAppArgs, DEFAULT_APPNAME, Initializer } from '../../common'; +import { InitializerResults } from '../../common/Initializer'; + +export default class AngularXmCloudInitializer implements Initializer { + get isBase(): boolean { + return false; + } + + async init(args: ClientAppArgs) { + const response: InitializerResults = { + nextSteps: [], + appName: args.appName || DEFAULT_APPNAME, + }; + + return response; + } +} diff --git a/packages/create-sitecore-jss/src/initializers/node-xmcloud-proxy/index.ts b/packages/create-sitecore-jss/src/initializers/node-xmcloud-proxy/index.ts new file mode 100644 index 0000000000..2f29a3752b --- /dev/null +++ b/packages/create-sitecore-jss/src/initializers/node-xmcloud-proxy/index.ts @@ -0,0 +1,15 @@ +import { Initializer } from '../../common'; + +export default class AngularXmCloudInitializer implements Initializer { + get isBase(): boolean { + return false; + } + + async init() { + const response = { + appName: 'node-xmcloud-proxy', + }; + + return response; + } +} From bc59fcf2f6a942b3ff10b089a25c144866ea5633 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Sun, 21 Jul 2024 21:31:25 -0400 Subject: [PATCH 4/7] fix proxy initializer naming (cherry picked from commit 60aadf7fbc5d0be781fc2339dae56f62ac5ed7db) --- packages/create-sitecore-jss/src/initializers/angular/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-sitecore-jss/src/initializers/angular/index.ts b/packages/create-sitecore-jss/src/initializers/angular/index.ts index 12321ed47c..d33cdc579a 100644 --- a/packages/create-sitecore-jss/src/initializers/angular/index.ts +++ b/packages/create-sitecore-jss/src/initializers/angular/index.ts @@ -26,7 +26,7 @@ export default class AngularInitializer implements Initializer { addInitializers.push('angular-xmcloud'); } if (!args.templates.includes('node-xmcloud-proxy')) { - addInitializers.push('angular-xmcloud'); + addInitializers.push('node-xmcloud-proxy'); } } else { if (!args.templates.includes('angular-sxp')) { From 3293f7b83a4425a02515dc6c2f0636587d12fd63 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Sun, 21 Jul 2024 21:44:13 -0400 Subject: [PATCH 5/7] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fc4744b15..e5b3c2acb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ Our versioning strategy is as follows: ### ๐ŸŽ‰ New Features & Improvements +* `[create-sitecore-jss]``[angular]``[sitecore-jss-angular]` Introduce support for XM Cloud for Angular apps + * `[create-sitecore-jss]` Rework Angular initializer ([#1845](https://github.com/Sitecore/jss/pull/1845)) + * `[sitecore-jss-react]` Introduce ErrorBoundary component. All rendered components are wrapped with it and it will catch client or server side errors from any of its children, display appropriate message and prevent the rest of the application from failing. It accepts and can display custom error component and loading message if it is passed as a prop to parent Placeholder. ([#1786](https://github.com/Sitecore/jss/pull/1786))([#1790](https://github.com/Sitecore/jss/pull/1790))([#1793](https://github.com/Sitecore/jss/pull/1793))([#1794](https://github.com/Sitecore/jss/pull/1794))([#1799](https://github.com/Sitecore/jss/pull/1799))([#1807](https://github.com/Sitecore/jss/pull/1807))([#1829](https://github.com/Sitecore/jss/pull/1829)) * `[sitecore-jss-nextjs]` Enforce CORS policy that matches Sitecore Pages domains for editing middleware API endpoints ([#1798](https://github.com/Sitecore/jss/pull/1798)[#1801](https://github.com/Sitecore/jss/pull/1801)) * `[sitecore-jss]` _GraphQLRequestClient_ now can accept custom 'headers' in the constructor or via _createClientFactory_ ([#1806](https://github.com/Sitecore/jss/pull/1806)) From bf4713677a04a6f636c21eb16f88c4a4653e798b Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Mon, 22 Jul 2024 10:07:41 -0400 Subject: [PATCH 6/7] minor comment typo --- .../create-sitecore-jss/src/initializers/angular/prompts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts index 11b0bc8cf3..0b62737af9 100644 --- a/packages/create-sitecore-jss/src/initializers/angular/prompts.ts +++ b/packages/create-sitecore-jss/src/initializers/angular/prompts.ts @@ -18,7 +18,7 @@ export const prompts = [ message: 'Are you building for Sitecore XM Cloud?', default: false, when: (answers: AngularAnswer): boolean => { - // don't prompt if --yes or nextjs-xmcloud template was specified + // don't prompt if --yes or angular-xmcloud template was specified if (answers.yes) { return false; } else if ( From 62ec977c5ad1675e67842586e6a4b33ee8a7e9a4 Mon Sep 17 00:00:00 2001 From: Artem Alexeyenko Date: Tue, 23 Jul 2024 09:36:13 -0400 Subject: [PATCH 7/7] adjust changelog for future use --- CHANGELOG.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5b3c2acb1..2df353156a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,15 +13,24 @@ Our versioning strategy is as follows: ### ๐Ÿ› Bug Fixes +### ๐ŸŽ‰ New Features & Improvements + +### ๐Ÿ›  Breaking Change + +* `[create-sitecore-jss]` Rework Angular initializer to support XMCloud and SXP journeys ([#1845](https://github.com/Sitecore/jss/pull/1845)) + +### ๐Ÿงน Chores + +## 22.1.0 + +### ๐Ÿ› Bug Fixes + * `[templates/nextjs]` `[templates/react]` `[templates/vue]` `[templates/angular]` Changed formatting in temp/config to prevent parse issues in Unix systems ([#1787](https://github.com/Sitecore/jss/pull/1787))([#1791](https://github.com/Sitecore/jss/pull/1791)) * `[templates/nextjs-sxa]` The banner variant of image component is fixed with supporting metadata mode. ([#1826](https://github.com/Sitecore/jss/pull/1826)) * `[sitecore-jss]` `[sitecore-jss-react]` DateField empty value is not treated as empty ([#1836](https://github.com/Sitecore/jss/pull/1836)) ### ๐ŸŽ‰ New Features & Improvements -* `[create-sitecore-jss]``[angular]``[sitecore-jss-angular]` Introduce support for XM Cloud for Angular apps - * `[create-sitecore-jss]` Rework Angular initializer ([#1845](https://github.com/Sitecore/jss/pull/1845)) - * `[sitecore-jss-react]` Introduce ErrorBoundary component. All rendered components are wrapped with it and it will catch client or server side errors from any of its children, display appropriate message and prevent the rest of the application from failing. It accepts and can display custom error component and loading message if it is passed as a prop to parent Placeholder. ([#1786](https://github.com/Sitecore/jss/pull/1786))([#1790](https://github.com/Sitecore/jss/pull/1790))([#1793](https://github.com/Sitecore/jss/pull/1793))([#1794](https://github.com/Sitecore/jss/pull/1794))([#1799](https://github.com/Sitecore/jss/pull/1799))([#1807](https://github.com/Sitecore/jss/pull/1807))([#1829](https://github.com/Sitecore/jss/pull/1829)) * `[sitecore-jss-nextjs]` Enforce CORS policy that matches Sitecore Pages domains for editing middleware API endpoints ([#1798](https://github.com/Sitecore/jss/pull/1798)[#1801](https://github.com/Sitecore/jss/pull/1801)) * `[sitecore-jss]` _GraphQLRequestClient_ now can accept custom 'headers' in the constructor or via _createClientFactory_ ([#1806](https://github.com/Sitecore/jss/pull/1806))