diff --git a/README.md b/README.md
index 7dfe83de0c..ec69068713 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,9 @@ To create a JSS project for an older version of JSS and Sitecore:
## Documentation and community resources
-- [Official JSS documentation](https://doc.sitecore.com/xp/en/developers/hd/200/sitecore-headless-development/sitecore-javascript-rendering-sdks--jss-.html)
+- Official JSS documentation:
+ - [XM Cloud](https://doc.sitecore.com/xmc/en/developers/jss/latest/jss-xmc/index-en.html)
+ - [XP](https://doc.sitecore.com/xp/en/developers/hd/latest/sitecore-headless-development/sitecore-javascript-rendering-sdks--jss-.html)
- [StackExchange](https://sitecore.stackexchange.com/)
- [Community Slack](https://sitecorechat.slack.com/messages/jss)
- [Sitecore Community Forum](https://community.sitecore.net/developers/f/40)
diff --git a/UPGRADING.md b/UPGRADING.md
deleted file mode 100644
index 856d66d161..0000000000
--- a/UPGRADING.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# Upgrade guides
-
-This document includes the links to upgrade guides for different versions of JSS apps.
-Each version contains the list of files, dependencies and environment variables that need to be added, updated or removed. Changes are grouped by templates and add-ons in each corresponding page.
-Work-in-progress items are listed in [Unreleased](./docs/upgrades/unreleased.md).
-
-## Upgrade paths for 21.x versions
-- [Upgrade from JSS 21.6 to 21.7](./docs/upgrades/21.x/21.7.md)
-- [Upgrade from JSS 21.5 to 21.6](./docs/upgrades/21.x/21.6.md)
-
-## Upgrade paths for 22.x versions
-- [Upgrade from JSS 22.0 to 22.1]((./docs/upgrades/22.x/22.1.md))
-- [Upgrade from JSS 21.7 to 22.0]((./docs/upgrades/22.x/22.0.md))
\ No newline at end of file
diff --git a/docs/upgrades/21.x/21.6.md b/docs/upgrades/21.x/21.6.md
deleted file mode 100644
index dfc1f33f4d..0000000000
--- a/docs/upgrades/21.x/21.6.md
+++ /dev/null
@@ -1,6 +0,0 @@
-## Upgrade to JSS 21.6 from 21.5
-
-* Find the list of changes in Sitecore documentation:
- * [XM Cloud](https://doc.sitecore.com/xmc/en/developers/jss/216/jss-xmc/upgrade-jss-21-5-next-js-apps-to-version-21-6.html)
- * [SXP / OnPrem](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/upgrade-jss-21-5-next-js-apps-to-version-21-6.html)
-
\ No newline at end of file
diff --git a/docs/upgrades/21.x/21.7.md b/docs/upgrades/21.x/21.7.md
deleted file mode 100644
index d26e155d47..0000000000
--- a/docs/upgrades/21.x/21.7.md
+++ /dev/null
@@ -1,6 +0,0 @@
-## Upgrade to JSS 21.7 from 21.6
-
-* Find the list of changes in Sitecore documentation:
- * [XM Cloud (to be added when published)](https://doc.sitecore.com/xmc/en/developers/jss/latest/jss-xmc/upgrade-jss-21-6-4-next-js-apps-to-version-21-7.html)
- * [SXP / OnPrem](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/upgrade-jss-apps-to-jss-21-7.html)
-
\ No newline at end of file
diff --git a/docs/upgrades/21.x/21.8.md b/docs/upgrades/21.x/21.8.md
deleted file mode 100644
index 46a654502a..0000000000
--- a/docs/upgrades/21.x/21.8.md
+++ /dev/null
@@ -1,4 +0,0 @@
-## Upgrade to JSS 21.8 from 21.7
-
-* Find the list of changes in Sitecore documentation:
- * [SXP / OnPrem](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/upgrade-jss-apps-to-jss-21-8.html)
diff --git a/docs/upgrades/22.x/22.0.md b/docs/upgrades/22.x/22.0.md
deleted file mode 100644
index 7750509d73..0000000000
--- a/docs/upgrades/22.x/22.0.md
+++ /dev/null
@@ -1,6 +0,0 @@
-## Upgrade to JSS 22.0 from 21.7
-
-* Find the list of changes in Sitecore documentation:
- * [XM Cloud](https://doc.sitecore.com/xmc/en/developers/jss/220/jss-xmc/upgrade-jss-21-7-next-js-apps-to-version-22-0-0.html)
- * [SXP / OnPrem](https://doc.sitecore.com/xp/en/developers/hd/22/sitecore-headless-development/upgrade-jss-apps-to-jss-22-0-0.html)
-
\ No newline at end of file
diff --git a/docs/upgrades/22.x/22.1.md b/docs/upgrades/22.x/22.1.md
deleted file mode 100644
index 398aa067be..0000000000
--- a/docs/upgrades/22.x/22.1.md
+++ /dev/null
@@ -1,237 +0,0 @@
-## Upgrade to JSS 22.1 from 22.0
-
-* If you are importing any _editing_ utils from `@sitecore-jss/sitecore-jss/utils` in your code, please update the import path to `@sitecore-jss/sitecore-jss/editing`. For now these exports are still available in the old path and marked as deprecated. They will be removed in the next major version release. Specifically for the following utils:
- * ExperienceEditor
- * HorizonEditor
- * isEditorActive
- * resetEditorChromes
- * handleEditorAnchors
- * Metadata
- * DefaultEditFrameButton
- * DefaultEditFrameButtons
- * DefaultEditFrameButtonIds
- * EditFrameDataSource
- * ChromeCommand
- * FieldEditButton
- * WebEditButton
- * EditButtonTypes
- * mapButtonToCommand
-
-# react
-
-* With the simplification of Editing Support work we have added the following breaking changes to the `sitecore-jss-react` package. Please make the necessary updates.
- - `ComponentConsumerProps` is removed. You might need to reuse _WithSitecoreContextProps_ type.
-
-### headless-ssr-experience-edge
-* Replace `scripts/generate-config.js` if you have not modified it. Otherwise:
- * Add a `trim()` call to `config[prop]` and replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
-
- ```ts
- configText += `config.${prop} = process.env.REACT_APP_${constantCase(prop)} || "${
- config[prop]?.trim()
- }";\n`;
- ```
-
-# angular
-
-* Update Angular and core dependencies to ~17.3.1, related dependencies
-
-* Update Typescript to ~5.2.2
-
-* Replace `scripts/generate-config.ts` if you have not modified it. Otherwise:
- * Add a `trim()` call to `config[prop]` (use toString() to avoid type conflicts) and replace commas before a newline (`,`) with semicolon (`;`) in configText prop assignments so it would look like this:
-
- ```ts
- configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]?.toString().trim()}";\n`;
- ```
-
-* Update import in _src/templates/angular/server.bundle.ts_
- Use _'zone.js'_ instead of _'zone.js/dist/zone-node'_
-
- ```ts
- import 'zone.js';
- ```
-* Update import in _src/templates/angular/src/polyfills.ts_
- Use _'zone.js'_ instead of _'zone.js/dist/zone-node'_
-
- ```ts
- import 'zone.js';
- ```
-
-# vue
-
-* Replace `scripts/generate-config.js` if you have not modified it. Otherwise:
- * Add a `trim()` call to `config[prop]` and replace commas before a newline (`,`) with semicolon (`;`) in configText prop assignments so it would look like this:
-
- ```ts
- configText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || "${
- config[prop]?.trim()
- }";\n`;
- ```
-
-# nextjs
-
-* Replace `scripts/generate-config.ts` if you have not modified it. Otherwise:
- * Add a `trim()` call to `config[prop]` and replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
-
- ```ts
- configText += `config.${prop} = process.env.${constantCase(prop)} || '${config[prop]?.trim()}';\n`;
- ```
-
-* Remove cors header for API endpoints from _lib/next-config/plugins/cors-header_ plugin since cors is handled by API handlers / middlewares:
-
- ```ts
- {
- source: '/api/:path*',
- headers: [
- {
- key: 'Access-Control-Allow-Origin',
- value: config.sitecoreApiHost.replace(/\/$/, ''),
- },
- ],
- },
- ```
-
-* Update _pages/api/editing/render.ts_ API handler initialization signature, since _resolvePageUrl_ function now accepts an object and _serverUrl_ now is optional, it's ommited when Pages Metadata Edit Mode is used. Update the handler initialization as follows:
-
- ```ts
- const handler = new EditingRenderMiddleware({
- resolvePageUrl: ({ serverUrl, itemPath }) => `${serverUrl}${itemPath}`,
- }).getHandler();
- ```
-
-* The implementation of 'EditingComponentPlaceholder' has been removed. Its purpose to avoid refreshing the entire page during component editing in Pages had never been fully utilized. The references to it and to `RenderingType` enum in `[[...path]].tsx` of the nextjs app (and in any custom code) should be removed:
-
- ```ts
- import Layout from 'src/Layout';
- import { RenderingType, EditingComponentPlaceholder } from '@sitecore-jss/sitecore-jss-nextjs';
- ...
- const isComponentRendering =
- layoutData.sitecore.context.renderingType === RenderingType.Component;
- ...
- {isComponentRendering ? (
-
- ) : (
-
- )}
- ...
- ```
-
-* It's highly recommended to install `sharp` dependency version `0.32.6` for nextjs apps in order to improve memory usage of Image Optimization feature. Run the `npm` command to install it:
- `npm i sharp@0.32.6`
-
-# nextjs-sxa
-
-* The implementation for the following SXA components has been updated. Replace the existing files with updated versions.
- * `src/components/Image.tsx`
- * `src/components/Promo.tsx`
- * `src/components/Title.tsx`
-
-# nextjs-xmcloud
-
-* Render a new `EditingScripts` component in your `Scripts.ts` file to support a new Editing Integration feature.
-
- ```ts
- import { EditingScripts } from '@sitecore-jss/sitecore-jss-nextjs';
- ...
- const Scripts = (): JSX.Element | null => (
- <>
-
- ...
- >
- );
- ```
-
-* Add a `useSiteQuery` parameter when `GraphQLDictionaryService` is initialized in `/src/lib/dictionary-service-factory.ts` :
- ```
- new GraphQLDictionaryService({
- siteName,
- clientFactory,
- .....
- useSiteQuery: true,
- })
-
-* We have introduced a new configuration option, `pagesEditMode`, in the `\src\pages\api\editing\config.ts` file to support the new editing metadata architecture for Pages (XMCloud). This option allows you to specify the editing mode used by Pages. It is set to `metadata` by default. However, if you are not ready to use a new integration and continue using the existing architecture, you can explicitly set the `pagesEditMode` to `chromes`.
-
- ```ts
- import { EditMode } from '@sitecore-jss/sitecore-jss-nextjs';
-
- const handler = new EditingConfigMiddleware({
- ...
- pagesEditMode: EditMode.Chromes,
- }).getHandler();
- ```
-
-* Introduce a new _lib/graphql-editing-service.ts_ file to initialize a _graphQLEditingService_ to support a new Editing Metadata Mode. Can be done by adding this file from the latest version introduced in _nextjs-xmcloud_ base template.
-
-* Update _lib/page-props-factory/plugins/preview-mode_ plugin to support a new Editing Metadata Mode. Can be done by replacing this file with the latest version introduced in _nextjs-xmcloud_ base template.
-
-* To support editing for fields in Pages, the new editing metadata architecture relies on the new metadata property 'field.metadata' (instead of on 'field.editable', which won't be used in this scenario). If you are using the new editing arhitecture in Pages (EditMode.Metadata) and have custom field component that manipulates or relies on 'field.editable' in some way, it may need to be reworked. Experience Editor still relies on 'field.editable', so it needs to be supported. See example below from SXA's Banner component:
-
- ```ts
- import { useSitecoreContext, EditMode } from '@sitecore-jss/sitecore-jss-nextjs';
- ...
- export const Banner = (props: ImageProps): JSX.Element => {
- const { sitecoreContext } = useSitecoreContext();
- const isMetadataMode = sitecoreContext?.editMode === EditMode.Metadata;
- ...
- const modifyImageProps = !isMetadataMode
- ? {
- ...props.fields.Image,
- editable: props?.fields?.Image?.editable
- ?.replace(`width="${props?.fields?.Image?.value?.width}"`, 'width="100%"')
- .replace(`height="${props?.fields?.Image?.value?.height}"`, 'height="100%"'),
- }
- : { ...props.fields.Image };
- ...
- }
- ...
- ```
-
-* To prepare your JSS app for AB testing and component level personalization support in Pages:
- * Ensure `componentVariantIds` are passed to `personalizeLayout` function call in `/lib/page-props-factory/plugins/personalize.ts`:
-
- ```ts
- // Get variant(s) for personalization (from path)
- const personalizeData = getPersonalizedRewriteData(path);
-
- // Modify layoutData to use specific variant(s) instead of default
- // This will also set the variantId on the Sitecore context so that it is accessible here
- personalizeLayout(
- props.layoutData,
- personalizeData.variantId,
- personalizeData.componentVariantIds
- );
- ```
-
- * For preview mode, prepare and pass `componentVariantIds` into `personalizeLayout` in `/lib/page-props-factory/plugins/preview-mode.ts`:
-
- ```ts
- import {
- SiteInfo,
- personalizeLayout,
- getGroomedVariantIds,
- } from '@sitecore-jss/sitecore-jss-nextjs';
- ```
- ```ts
- props.headLinks = [];
- const personalizeData = getGroomedVariantIds(variantIds);
- personalizeLayout(
- props.layoutData,
- personalizeData.variantId,
- personalizeData.componentVariantIds
- );
- ```
-
-* Update _lib/middleware/plugins/personalize.ts_ `PersonalizeMiddleware` constructor signature, moving `scope` from `cdpConfig` to the root. For now this option will continue working but is marked as deprecated. It will be removed in the next major version release.
-
- ```ts
- this.personalizeMiddleware = new PersonalizeMiddleware({
- ...
- cdpConfig: {
- ...
- scope: process.env.NEXT_PUBLIC_PERSONALIZE_SCOPE, // REMOVE
- },
- scope: process.env.NEXT_PUBLIC_PERSONALIZE_SCOPE, // ADD
- });
- ```
\ No newline at end of file
diff --git a/docs/upgrades/22.x/22.2.md b/docs/upgrades/22.x/22.2.md
deleted file mode 100644
index c135874e7c..0000000000
--- a/docs/upgrades/22.x/22.2.md
+++ /dev/null
@@ -1,129 +0,0 @@
-# Nextjs - XMCloud
-
-* Update the `@sitecore/components` dependency to `~2.0.0`
-* Update the `@sitecore-cloudsdk/events` dependency to `^0.4.0`
-* Add the dependency on `@sitecore-cloudsdk/core` with version `^0.4.0`. You should now have the below dependencies present:
-```
- "@sitecore/components": "~2.0.0",
- "@sitecore-cloudsdk/core": "^0.4.0",
- "@sitecore-cloudsdk/events": "^0.4.0",
-```
-* Remove the `src/lib/context` folder
-
-* Update `src/Bootstrap.tsx`:
- * Remove the context import:
- ```
- import { context } from 'src/lib/context';
- ```
- * Add imports required for CloudSDK setup:
- ```
- import { CloudSDK } from '@sitecore-cloudsdk/core/browser';
- import '@sitecore-cloudsdk/events/browser';
- import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-nextjs';
- ```
- * Remove the context.init() call:
- ```
- context.init({
- siteName: props.site?.name || config.sitecoreSiteName,
- pageState: props.layoutData?.sitecore?.context?.pageState,
- });
- ```
- * Replace it with CloudSDK initialization, making sure it is performed within `useEffect()` and only in normal, non-dev mode:
- ```
- useEffect(() => {
- const pageState = props.layoutData?.sitecore?.context.pageState;
- if (process.env.NODE_ENV === 'development')
- console.debug('Browser Events SDK is not initialized in development environment');
- else if (pageState !== LayoutServicePageState.Normal)
- console.debug('Browser Events SDK is not initialized in edit and preview modes');
- else {
- CloudSDK({
- sitecoreEdgeUrl: config.sitecoreEdgeUrl,
- sitecoreEdgeContextId: config.sitecoreEdgeContextId,
- siteName: props.site?.name || config.sitecoreSiteName,
- enableBrowserCookie: true,
- // Replace with the top level cookie domain of the website that is being integrated e.g ".example.com" and not "www.example.com"
- cookieDomain: window.location.hostname.replace(/^www\./, ''),
- })
- .addEvents()
- .initialize();
- }
- }, [props.site?.name]);
- ```
-
-* Update `src/components/CDPPageView.tsx`:
- * Remove the context import:
- ```
- import { context } from 'lib/context';
- ```
- * Add import for CloudSDK:
- ```
- import { pageView } from '@sitecore-cloudsdk/events/browser';
- ```
- * Replace the context promise code
- ```
- context
- .getSDK('Events')
- .then((Events) =>
- Events.pageView({
- channel: 'WEB',
- currency: 'USD',
- page: route.name,
- pageVariantId,
- language,
- })
- )
- .catch((e) => console.debug(e));
- ```
- with a simplified `pageView` direct call:
- ```
- pageView({
- channel: 'WEB',
- currency: 'USD',
- page: route.name,
- pageVariantId,
- language,
- }).catch((e) => console.debug(e));
- ```
-
-* Update `src/byoc/index.ts` to make sure Forms are functioning post-upgrade:
- * Rename the file to `index.tsx`
- * Remove the context import:
- ```
- import { context } from 'lib/context';
- ```
- * Add imports for config and CloudSDK:
- ```
- import React from 'react';
- import * as Events from '@sitecore-cloudsdk/events/browser';
- import config from 'temp/config';
- import {
- LayoutServicePageState,
- SitecoreContextReactContext,
- } from '@sitecore-jss/sitecore-jss-nextjs';
- ```
- * Remove the existing `FEAAS.setContextProperties()` call
- * Add the component defintion that will hold the updated logic:
- ```
- const BYOCInit = (): JSX.Element | null => {
- const sitecoreContext = React.useContext(SitecoreContextReactContext).context;
- // Set context properties to be available within BYOC components
- FEAAS.setContextProperties({
- sitecoreEdgeUrl: config.sitecoreEdgeUrl,
- sitecoreEdgeContextId: config.sitecoreEdgeContextId,
- pageState: sitecoreContext?.pageState || LayoutServicePageState.Normal,
- siteName: sitecoreContext?.site?.name || config.sitecoreSiteName,
- eventsSDK: Events,
- });
-
- return ;
- };
- ```
- * Replace the default import at the end of the file with
- ```
- export default BYOCInit;
- ```
-
-* If you have any other instances of using CloudSDK in your app, follow the CloudSDK 0.4.0 upgrade guide.
-
-* Remove any other `lib/context` import, if present. If you used `context.getSDK()` method, you can now use CloudSDK method calls directly. If `context` was used to retrieve other values, consider using `temp/config` instead.
\ No newline at end of file
diff --git a/packages/create-sitecore-jss/package.json b/packages/create-sitecore-jss/package.json
index b5f0b6e1ec..1741b9d0b4 100644
--- a/packages/create-sitecore-jss/package.json
+++ b/packages/create-sitecore-jss/package.json
@@ -50,6 +50,7 @@
"@types/minimist": "^1.2.2",
"@types/mocha": "^10.0.1",
"@types/node": "^20.14.2",
+ "@types/proxyquire": "^1.3.31",
"@types/sinon": "10.0.6",
"@types/sinon-chai": "^3.2.9",
"chai": "^4.3.7",
@@ -58,6 +59,7 @@
"eslint": "^8.32.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
+ "proxyquire": "^2.1.3",
"sinon": "^15.0.1",
"sinon-chai": "^3.7.0",
"ts-node": "^10.9.1",
diff --git a/packages/create-sitecore-jss/src/common/processes/transform.test.ts b/packages/create-sitecore-jss/src/common/processes/transform.test.ts
index e9a1cc8d13..cdba0d5ba6 100644
--- a/packages/create-sitecore-jss/src/common/processes/transform.test.ts
+++ b/packages/create-sitecore-jss/src/common/processes/transform.test.ts
@@ -10,6 +10,7 @@ import sinon, { SinonStub } from 'sinon';
import { currentPkg, partialPkg } from '../test-data/pkg';
import * as transform from './transform';
import * as helpers from '../utils/helpers';
+import proxyquire from 'proxyquire';
const {
transformFilename,
@@ -507,7 +508,6 @@ describe('transform', () => {
globSyncStub = sinon.stub(glob, 'sync').returns([file]);
ejsRenderFileStub = sinon.stub(ejs, 'renderFile').returns(Promise.resolve(renderFileOutput));
- diffAndWriteFilesStub = sinon.stub(transform, 'diffAndWriteFiles');
const answers = {
destination: destinationPath,
@@ -516,10 +516,17 @@ describe('transform', () => {
force: false,
};
- await transformFunc(templatePath, answers);
+ const transformModule = proxyquire('./transform', {
+ '../../../package.json': { version: '22.2.1-canary.33' },
+ });
+
+ diffAndWriteFilesStub = sinon.stub(transformModule, 'diffAndWriteFiles');
+
+ await transformModule.transform(templatePath, answers);
expect(ejsRenderFileStub).to.have.been.calledOnceWith(path.join(templatePath, file), {
...answers,
+ version: '22.2.1-canary',
helper: {
isDev: false,
getPascalCaseName: helpers.getPascalCaseName,
@@ -629,8 +636,6 @@ describe('transform', () => {
fsExistsSyncStub = sinon.stub(fs, 'existsSync').returns(true);
openPackageJsonStub = sinon.stub(helpers, 'openPackageJson').returns(currentPkg);
ejsRenderFileStub = sinon.stub(ejs, 'renderFile').returns(Promise.resolve(renderFileOutput));
- mergeStub = sinon.stub(transform, 'merge').returns(mergedPkg);
- diffAndWriteFilesStub = sinon.stub(transform, 'diffAndWriteFiles');
const answers = {
destination: destinationPath,
@@ -639,10 +644,18 @@ describe('transform', () => {
force: false,
};
- await transformFunc(templatePath, answers);
+ const transformModule = proxyquire('./transform', {
+ '../../../package.json': { version: '22.2.1-canary.33' },
+ });
+
+ diffAndWriteFilesStub = sinon.stub(transformModule, 'diffAndWriteFiles');
+ mergeStub = sinon.stub(transformModule, 'merge').returns(mergedPkg);
+
+ await transformModule.transform(templatePath, answers);
expect(ejsRenderFileStub).to.have.been.calledOnceWith(path.join(templatePath, file), {
...answers,
+ version: '22.2.1-canary',
helper: {
isDev: false,
getPascalCaseName: helpers.getPascalCaseName,
@@ -669,8 +682,13 @@ describe('transform', () => {
fsExistsSyncStub = sinon.stub(fs, 'existsSync').returns(true);
fsReadFileSunc = sinon.stub(fs, 'readFileSync').returns(currentDotEnv);
ejsRenderFileStub = sinon.stub(ejs, 'renderFile').returns(Promise.resolve(templateDotEnv));
- mergeEnvStub = sinon.stub(transform, 'mergeEnv').returns(concatDotEnv);
- diffAndWriteFilesStub = sinon.stub(transform, 'diffAndWriteFiles');
+
+ const transformModule = proxyquire('./transform', {
+ '../../../package.json': { version: '22.2.1-canary.33' },
+ });
+
+ mergeEnvStub = sinon.stub(transformModule, 'mergeEnv').returns(concatDotEnv);
+ diffAndWriteFilesStub = sinon.stub(transformModule, 'diffAndWriteFiles');
const answers = {
destination: destinationPath,
@@ -679,10 +697,11 @@ describe('transform', () => {
force: false,
};
- await transformFunc(templatePath, answers);
+ await transformModule.transform(templatePath, answers);
expect(ejsRenderFileStub).to.have.been.calledOnceWith(path.join(templatePath, file), {
...answers,
+ version: '22.2.1-canary',
helper: {
isDev: false,
getPascalCaseName: helpers.getPascalCaseName,
diff --git a/packages/create-sitecore-jss/src/common/processes/transform.ts b/packages/create-sitecore-jss/src/common/processes/transform.ts
index 2533866c60..700b4899a2 100644
--- a/packages/create-sitecore-jss/src/common/processes/transform.ts
+++ b/packages/create-sitecore-jss/src/common/processes/transform.ts
@@ -14,6 +14,7 @@ import {
isDevEnvironment,
} from '../utils/helpers';
import { diffLines, diffJson, Change } from 'diff';
+const { version } = require('../../../package.json');
import { BaseArgs } from '../args/base';
const FILE_FOR_COPY_REGEXP = /(index\.html)$|\.(gif|jpg|jpeg|tiff|png|svg|ashx|ico|pdf|jar|eot|woff|ttf|woff2)$/;
@@ -237,9 +238,15 @@ export const transform = async (
answers.appPrefix = false;
}
+ // Don't expose canary build number in the generated app
+ const jssVersion = version.includes('canary')
+ ? version.replace(/(-canary\.\d+)$/, '-canary')
+ : version;
+
// pass in helper to answers object
const ejsData: Data = {
...answers,
+ version: jssVersion,
helper: {
isDev: isDevEnvironment(answers.destination),
getPascalCaseName: getPascalCaseName,
diff --git a/packages/create-sitecore-jss/src/templates/angular/package.json b/packages/create-sitecore-jss/src/templates/angular/package.json
index cee4472db7..b368581628 100644
--- a/packages/create-sitecore-jss/src/templates/angular/package.json
+++ b/packages/create-sitecore-jss/src/templates/angular/package.json
@@ -1,6 +1,6 @@
{
"name": "<%- appName %>",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"description": "Application utilizing Sitecore JavaScript Services and Angular (angular-cli).",
"config": {
"appName": "<%- appName %>",
@@ -60,7 +60,7 @@
"@apollo/client": "^3.3.12",
"@ngx-translate/core": "~15.0.0",
"@ngx-translate/http-loader": "~8.0.0",
- "@sitecore-jss/sitecore-jss-angular": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-angular": "~<%- version %>",
"apollo-angular": "~6.0.0",
"bootstrap": "^5.3.3",
"core-js": "~3.37.1",
@@ -82,9 +82,9 @@
"@angular/cli": "~17.3.8",
"@angular/compiler-cli": "~17.3.11",
"@angular/language-service": "~17.3.11",
- "@sitecore-jss/sitecore-jss-angular-schematics": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-cli": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-angular-schematics": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
"@types/isomorphic-fetch": "0.0.35",
"@types/jasmine": "~3.6.7",
"@types/jasminewd2": "~2.0.8",
diff --git a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/package.json b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/package.json
index 14d8e0eb0a..f1723a9537 100644
--- a/packages/create-sitecore-jss/src/templates/nextjs-styleguide/package.json
+++ b/packages/create-sitecore-jss/src/templates/nextjs-styleguide/package.json
@@ -4,7 +4,7 @@
"nprogress": "~0.2.0"
},
"devDependencies": {
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
"@types/nprogress": "^0.2.0"
},
"scripts": {
diff --git a/packages/create-sitecore-jss/src/templates/nextjs/package.json b/packages/create-sitecore-jss/src/templates/nextjs/package.json
index bc722304d5..c7084b745c 100644
--- a/packages/create-sitecore-jss/src/templates/nextjs/package.json
+++ b/packages/create-sitecore-jss/src/templates/nextjs/package.json
@@ -1,7 +1,7 @@
{
"name": "<%- appName %>",
"description": "Application utilizing Sitecore JavaScript Services and Next.js",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"private": true,
"config": {
"appName": "<%- appName %>",
@@ -25,7 +25,7 @@
},
"license": "Apache-2.0",
"dependencies": {
- "@sitecore-jss/sitecore-jss-nextjs": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-nextjs": "~<%- version %>",
"graphql": "~15.8.0",
"graphql-tag": "^2.12.6",
"next": "^14.2.7",
@@ -43,8 +43,8 @@
"@graphql-codegen/typescript-operations": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@graphql-typed-document-node/core": "^3.2.0",
- "@sitecore-jss/sitecore-jss-cli": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
"@types/node": "^20.14.2",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.0.5",
diff --git a/packages/create-sitecore-jss/src/templates/node-headless-ssr-experience-edge/package.json b/packages/create-sitecore-jss/src/templates/node-headless-ssr-experience-edge/package.json
index 93bf06cbfe..180586991d 100644
--- a/packages/create-sitecore-jss/src/templates/node-headless-ssr-experience-edge/package.json
+++ b/packages/create-sitecore-jss/src/templates/node-headless-ssr-experience-edge/package.json
@@ -1,6 +1,6 @@
{
"name": "node-headless-ssr-experience-edge-sample",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"description": "Node server-side-rendering sample for running JSS apps under Node hosting using Experience Edge",
"scripts": {
"start": "ts-node ./src/index.ts"
@@ -19,7 +19,7 @@
"homepage": "https://jss.sitecore.com",
"license": "Apache-2.0",
"dependencies": {
- "@sitecore-jss/sitecore-jss": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss": "~<%- version %>",
"compression": "^1.7.4",
"express": "^4.18.2",
"dotenv": "^16.0.3"
diff --git a/packages/create-sitecore-jss/src/templates/node-headless-ssr-proxy/package.json b/packages/create-sitecore-jss/src/templates/node-headless-ssr-proxy/package.json
index ea32e2e7c6..5dd99a6059 100644
--- a/packages/create-sitecore-jss/src/templates/node-headless-ssr-proxy/package.json
+++ b/packages/create-sitecore-jss/src/templates/node-headless-ssr-proxy/package.json
@@ -1,6 +1,6 @@
{
"name": "node-headless-ssr-proxy-sample",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"description": "Node server-side-rendering proxy sample for running JSS apps under Node hosting",
"scripts": {
"start": "ts-node ./src/index.ts"
@@ -19,8 +19,8 @@
"homepage": "https://jss.sitecore.com",
"license": "Apache-2.0",
"dependencies": {
- "@sitecore-jss/sitecore-jss": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-proxy": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-proxy": "~<%- version %>",
"agentkeepalive": "^4.2.1",
"compression": "~1.7.4",
"express": "~4.19.2",
diff --git a/packages/create-sitecore-jss/src/templates/react-native/package.json b/packages/create-sitecore-jss/src/templates/react-native/package.json
index 6d71a81bd7..ca352662ec 100644
--- a/packages/create-sitecore-jss/src/templates/react-native/package.json
+++ b/packages/create-sitecore-jss/src/templates/react-native/package.json
@@ -1,6 +1,6 @@
{
"name": "<%- appName %>",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"description": "A basic React Native app utilizing Sitecore JavaScript Services",
"config": {
"appName": "<%- appName %>",
@@ -23,7 +23,7 @@
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
- "@sitecore-jss/sitecore-jss-react-native": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-react-native": "~<%- version %>",
"prop-types": "^15.6.0",
"react": "16.13.1",
"react-native": "^0.63.4",
@@ -37,8 +37,8 @@
},
"private": true,
"devDependencies": {
- "@sitecore-jss/sitecore-jss-cli": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-plugin-inline-replace-variables": "^1.3.1",
diff --git a/packages/create-sitecore-jss/src/templates/react/package.json b/packages/create-sitecore-jss/src/templates/react/package.json
index 6bc338eee2..bb0997927a 100644
--- a/packages/create-sitecore-jss/src/templates/react/package.json
+++ b/packages/create-sitecore-jss/src/templates/react/package.json
@@ -1,7 +1,7 @@
{
"name": "<%- appName %>",
"description": "Application utilizing Sitecore JavaScript Services and React (create-react-app).",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"private": true,
"config": {
"appName": "<%- appName %>",
@@ -28,7 +28,7 @@
"license": "Apache-2.0",
"dependencies": {
"@apollo/client": "^3.7.1",
- "@sitecore-jss/sitecore-jss-react": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-react": "~<%- version %>",
"axios": "^1.2.0",
"bootstrap": "^5.2.3",
"cross-fetch": "^3.1.5",
@@ -53,9 +53,9 @@
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/register": "~7.18.9",
- "@sitecore-jss/sitecore-jss-cli": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-rendering-host": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-rendering-host": "~<%- version %>",
"babel-loader": "~9.1.0",
"babel-preset-react-app": "~10.0.1",
"chalk": "~4.1.2",
diff --git a/packages/create-sitecore-jss/src/templates/vue/package.json b/packages/create-sitecore-jss/src/templates/vue/package.json
index 0f2a2a6268..59a6095782 100644
--- a/packages/create-sitecore-jss/src/templates/vue/package.json
+++ b/packages/create-sitecore-jss/src/templates/vue/package.json
@@ -1,6 +1,6 @@
{
"name": "<%- appName %>",
- "version": "22.2.2-canary",
+ "version": "<%- version %>",
"description": "Application utilizing Sitecore JavaScript Services and Vue (vue-cli).",
"private": true,
"config": {
@@ -45,7 +45,7 @@
"dependencies": {
"@apollo/client": "^3.7.4",
"@panter/vue-i18next": "~0.15.2",
- "@sitecore-jss/sitecore-jss-vue": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-vue": "~<%- version %>",
"@vue/apollo-composable": "4.0.0-beta.2",
"@vue/apollo-option": "^4.0.0-alpha.20",
"@vue/apollo-ssr": "^4.0.0-alpha.18",
@@ -64,8 +64,8 @@
"devDependencies": {
"@babel/eslint-parser": "^7.19.1",
"@babel/register": "7.18.9",
- "@sitecore-jss/sitecore-jss-cli": "~22.2.2-canary",
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.2-canary",
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
"@vue/cli-plugin-babel": "~5.0.8",
"@vue/cli-plugin-eslint": "~5.0.8",
"@vue/cli-service": "~5.0.8",
diff --git a/yarn.lock b/yarn.lock
index 323ae94ad5..360b8cdaed 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7225,6 +7225,13 @@ __metadata:
languageName: node
linkType: hard
+"@types/proxyquire@npm:^1.3.31":
+ version: 1.3.31
+ resolution: "@types/proxyquire@npm:1.3.31"
+ checksum: 945024495fc991f6152686795ac6f2f2d0f571834e67fa41c1e84877eeb1a321a24ab8ff67fc5152d9227f5b39f6254213dced15deaf80ed7443059c2257e072
+ languageName: node
+ linkType: hard
+
"@types/qs@npm:*":
version: 6.9.10
resolution: "@types/qs@npm:6.9.10"
@@ -11984,6 +11991,7 @@ __metadata:
"@types/minimist": ^1.2.2
"@types/mocha": ^10.0.1
"@types/node": ^20.14.2
+ "@types/proxyquire": ^1.3.31
"@types/sinon": 10.0.6
"@types/sinon-chai": ^3.2.9
chai: ^4.3.7
@@ -12001,6 +12009,7 @@ __metadata:
minimist: ^1.2.7
mocha: ^10.2.0
nyc: ^15.1.0
+ proxyquire: ^2.1.3
sinon: ^15.0.1
sinon-chai: ^3.7.0
ts-node: ^10.9.1
@@ -14622,6 +14631,16 @@ __metadata:
languageName: node
linkType: hard
+"fill-keys@npm:^1.0.2":
+ version: 1.0.2
+ resolution: "fill-keys@npm:1.0.2"
+ dependencies:
+ is-object: ~1.0.1
+ merge-descriptors: ~1.0.0
+ checksum: 6ac5ff60ff08f2f44d19e919c9ca579f4efaaa8c88232b4aab5a5b5522aeb8ec91501956e780cb2b44574fe4a4a337e9b43187829267d0b66a6bfedbafae893f
+ languageName: node
+ linkType: hard
+
"fill-range@npm:^4.0.0":
version: 4.0.0
resolution: "fill-range@npm:4.0.0"
@@ -16715,6 +16734,13 @@ __metadata:
languageName: node
linkType: hard
+"is-object@npm:~1.0.1":
+ version: 1.0.2
+ resolution: "is-object@npm:1.0.2"
+ checksum: 971219c4b1985b9751f65e4c8296d3104f0457b0e8a70849e848a4a2208bc47317d73b3b85d4a369619cb2df8284dc22584cb2695a7d99aca5e8d0aa64fc075a
+ languageName: node
+ linkType: hard
+
"is-path-cwd@npm:^2.2.0":
version: 2.2.0
resolution: "is-path-cwd@npm:2.2.0"
@@ -19611,6 +19637,13 @@ __metadata:
languageName: node
linkType: hard
+"merge-descriptors@npm:~1.0.0":
+ version: 1.0.3
+ resolution: "merge-descriptors@npm:1.0.3"
+ checksum: 52117adbe0313d5defa771c9993fe081e2d2df9b840597e966aadafde04ae8d0e3da46bac7ca4efc37d4d2b839436582659cd49c6a43eacb3fe3050896a105d1
+ languageName: node
+ linkType: hard
+
"merge-stream@npm:^1.0.1":
version: 1.0.1
resolution: "merge-stream@npm:1.0.1"
@@ -20352,6 +20385,13 @@ __metadata:
languageName: node
linkType: hard
+"module-not-found-error@npm:^1.0.1":
+ version: 1.0.1
+ resolution: "module-not-found-error@npm:1.0.1"
+ checksum: ebd65339d4d5980dd55cd32dbf112ec02b8e33f30866312b94caeee4783322259f18cf2270e9d2e600df3bd1876c35612b87f5c2525c21885fb1f83e85a9b9b0
+ languageName: node
+ linkType: hard
+
"moo@npm:^0.5.0":
version: 0.5.2
resolution: "moo@npm:0.5.2"
@@ -22719,6 +22759,17 @@ __metadata:
languageName: node
linkType: hard
+"proxyquire@npm:^2.1.3":
+ version: 2.1.3
+ resolution: "proxyquire@npm:2.1.3"
+ dependencies:
+ fill-keys: ^1.0.2
+ module-not-found-error: ^1.0.1
+ resolve: ^1.11.1
+ checksum: a320f1a04d65aeb41625bfd6bbf848492523b730b07926b6c1ed48f9342f2a30c4a4c0b399e07391e76691b65f604773327767c33a8578e5e4ab19299ba46a02
+ languageName: node
+ linkType: hard
+
"prr@npm:~1.0.1":
version: 1.0.1
resolution: "prr@npm:1.0.1"
@@ -23685,7 +23736,7 @@ __metadata:
languageName: node
linkType: hard
-"resolve@npm:1.22.8, resolve@npm:^1.10.0, resolve@npm:^1.14.2, resolve@npm:^1.20.0, resolve@npm:^1.22.1, resolve@npm:^1.5.0":
+"resolve@npm:1.22.8, resolve@npm:^1.10.0, resolve@npm:^1.11.1, resolve@npm:^1.14.2, resolve@npm:^1.20.0, resolve@npm:^1.22.1, resolve@npm:^1.5.0":
version: 1.22.8
resolution: "resolve@npm:1.22.8"
dependencies:
@@ -23718,7 +23769,7 @@ __metadata:
languageName: node
linkType: hard
-"resolve@patch:resolve@1.22.8#~builtin, resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin, resolve@patch:resolve@^1.5.0#~builtin":
+"resolve@patch:resolve@1.22.8#~builtin, resolve@patch:resolve@^1.10.0#~builtin, resolve@patch:resolve@^1.11.1#~builtin, resolve@patch:resolve@^1.14.2#~builtin, resolve@patch:resolve@^1.20.0#~builtin, resolve@patch:resolve@^1.22.1#~builtin, resolve@patch:resolve@^1.5.0#~builtin":
version: 1.22.8
resolution: "resolve@patch:resolve@npm%3A1.22.8#~builtin::version=1.22.8&hash=07638b"
dependencies: