create-sitecore-jss 22.3.0-canary.9 → 22.3.1-canary.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/InitializerFactory.js +2 -2
  2. package/dist/common/processes/transform.js +14 -9
  3. package/dist/common/prompts/base.js +1 -1
  4. package/dist/common/utils/helpers.js +1 -1
  5. package/dist/initializers/angular-sxp/index.js +1 -1
  6. package/dist/initializers/angular-xmcloud/index.js +1 -1
  7. package/dist/initializers/nextjs/prompts.js +1 -1
  8. package/dist/initializers/nextjs-multisite/index.js +1 -1
  9. package/dist/initializers/nextjs-styleguide/index.js +1 -1
  10. package/dist/initializers/nextjs-styleguide-tracking/index.js +1 -1
  11. package/dist/initializers/nextjs-sxa/index.js +1 -1
  12. package/dist/initializers/nextjs-xmcloud/index.js +1 -1
  13. package/dist/templates/angular/angular.json +0 -1
  14. package/dist/templates/angular/package.json +12 -11
  15. package/dist/templates/angular/src/tsconfig.app.json +1 -2
  16. package/dist/templates/angular/src/tsconfig.server.json +1 -2
  17. package/dist/templates/angular/tsconfig.json +4 -2
  18. package/dist/templates/angular/webpack.config.js +11 -5
  19. package/dist/templates/angular-sxp/angular.json +13 -0
  20. package/dist/templates/angular-xmcloud/.env +9 -1
  21. package/dist/templates/angular-xmcloud/README.md +60 -0
  22. package/dist/templates/angular-xmcloud/package.json +2 -2
  23. package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +2 -0
  24. package/dist/templates/angular-xmcloud/scripts/proxy-build.ts +3 -3
  25. package/dist/templates/angular-xmcloud/server.exports.ts +2 -0
  26. package/dist/templates/nextjs/.eslintrc +6 -1
  27. package/dist/templates/nextjs/next.config.js +3 -0
  28. package/dist/templates/nextjs/package.json +10 -10
  29. package/dist/templates/nextjs/scripts/config/index.ts +1 -1
  30. package/dist/templates/nextjs/scripts/config/plugins/scjssconfig.ts +1 -0
  31. package/dist/templates/nextjs/scripts/generate-component-builder/index.ts +1 -1
  32. package/dist/templates/nextjs/scripts/scaffold-component/index.ts +1 -1
  33. package/dist/templates/nextjs/scripts/utils.ts +1 -1
  34. package/dist/templates/nextjs/tsconfig.json +1 -0
  35. package/dist/templates/nextjs-styleguide/package.json +1 -1
  36. package/dist/templates/nextjs-styleguide/src/lib/sitemap-fetcher/plugins/disconnected-sitemap-service.ts +1 -1
  37. package/dist/templates/nextjs-xmcloud/package.json +2 -2
  38. package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/content-styles.ts +1 -1
  39. package/dist/templates/node-headless-ssr-experience-edge/package.json +3 -3
  40. package/dist/templates/node-headless-ssr-proxy/package.json +5 -5
  41. package/dist/templates/node-xmcloud-proxy/.env +0 -5
  42. package/dist/templates/node-xmcloud-proxy/README.md +106 -12
  43. package/dist/templates/node-xmcloud-proxy/package.json +4 -4
  44. package/dist/templates/node-xmcloud-proxy/src/config.ts +1 -1
  45. package/dist/templates/node-xmcloud-proxy/src/types.ts +1 -0
  46. package/dist/templates/react/.eslintrc +2 -0
  47. package/dist/templates/react/package.json +6 -6
  48. package/dist/templates/react-native/package.json +4 -4
  49. package/dist/templates/vue/package.json +5 -5
  50. package/package.json +11 -9
@@ -46,10 +46,10 @@ class InitializerFactory {
46
46
  }
47
47
  create(name) {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
- var _a;
50
49
  try {
51
- const { default: Initializer } = yield (_a = path_1.default.resolve(this.rootPath, 'initializers', name, 'index'), Promise.resolve().then(() => __importStar(require(_a))));
50
+ const { default: Initializer } = yield Promise.resolve(`${path_1.default.resolve(this.rootPath, 'initializers', name, 'index')}`).then(s => __importStar(require(s)));
52
51
  return new Initializer();
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
53
  }
54
54
  catch (error) {
55
55
  return undefined;
@@ -45,6 +45,7 @@ const ejs_1 = require("ejs");
45
45
  const inquirer_1 = __importDefault(require("inquirer"));
46
46
  const helpers_1 = require("../utils/helpers");
47
47
  const diff_1 = require("diff");
48
+ const { version } = require('../../../package.json');
48
49
  const FILE_FOR_COPY_REGEXP = /(index\.html)$|\.(gif|jpg|jpeg|tiff|png|svg|ashx|ico|pdf|jar|eot|woff|ttf|woff2)$/;
49
50
  const transformFilename = (file, args) => {
50
51
  // eslint-disable-next-line guard-for-in
@@ -151,7 +152,7 @@ const diffFiles = (sourceFileContent, targetFilePath) => __awaiter(void 0, void
151
152
  return answer.choice;
152
153
  });
153
154
  exports.diffFiles = diffFiles;
154
- const diffAndWriteFiles = ({ rendered, pathToNewFile, answers, }) => __awaiter(void 0, void 0, void 0, function* () {
155
+ const diffAndWriteFiles = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rendered, pathToNewFile, answers, }) {
155
156
  const targetFilePath = (0, exports.transformFilename)(pathToNewFile, answers);
156
157
  const choice = yield (0, exports.diffFiles)(rendered, targetFilePath);
157
158
  switch (choice) {
@@ -182,7 +183,11 @@ const diffAndWriteFiles = ({ rendered, pathToNewFile, answers, }) => __awaiter(v
182
183
  exports.diffAndWriteFiles = diffAndWriteFiles;
183
184
  const populateEjsData = (answers, destination) => {
184
185
  // pass in helper to answers object
185
- const ejsData = Object.assign(Object.assign({}, answers), { helper: {
186
+ // Don't expose canary build number in the generated app
187
+ const jssVersion = version.includes('canary')
188
+ ? version.replace(/(-canary\.\d+)$/, '-canary')
189
+ : version;
190
+ const ejsData = Object.assign(Object.assign({}, answers), { version: jssVersion, helper: {
186
191
  isDev: (0, helpers_1.isDevEnvironment)(destination || answers.destination),
187
192
  getPascalCaseName: helpers_1.getPascalCaseName,
188
193
  getAppPrefix: helpers_1.getAppPrefix,
@@ -192,17 +197,17 @@ const populateEjsData = (answers, destination) => {
192
197
  exports.populateEjsData = populateEjsData;
193
198
  /**
194
199
  * Handles each template file and applies ejs renderer, also:
195
- * * determines files for copy
196
- * * determines files for skip
197
- * * if some files already exist:
198
- * * merges package.json files
199
- * * concatenates .env files
200
- * * compares diffs
200
+ * - Determines files for copy.
201
+ * - Determines files for skip.
202
+ * if some files already exist:
203
+ * - merges package.json files
204
+ * - concatenates .env files
205
+ * - compares diffs
201
206
  * @param {string} templatePath path to the template
202
207
  * @param {BaseArgs} answers CLI arguments
203
208
  * @param {TransformOptions} options custom options
204
209
  */
205
- const transform = (templatePath, answers, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
210
+ const transform = (templatePath_1, answers_1, ...args_1) => __awaiter(void 0, [templatePath_1, answers_1, ...args_1], void 0, function* (templatePath, answers, options = {}) {
206
211
  const { isFileForCopy, isFileForSkip, fileForCopyRegExp = FILE_FOR_COPY_REGEXP } = options;
207
212
  const destinationPath = path_1.default.resolve(answers.destination);
208
213
  if (!answers.appPrefix) {
@@ -9,7 +9,7 @@ var FetchWith;
9
9
  (function (FetchWith) {
10
10
  FetchWith["GraphQL"] = "GraphQL";
11
11
  FetchWith["REST"] = "REST";
12
- })(FetchWith = exports.FetchWith || (exports.FetchWith = {}));
12
+ })(FetchWith || (exports.FetchWith = FetchWith = {}));
13
13
  /**
14
14
  * Default app name for the new app
15
15
  */
@@ -90,7 +90,7 @@ const openJsonFile = (jsonFilePath) => {
90
90
  exports.openJsonFile = openJsonFile;
91
91
  /**
92
92
  * Creates a .json file and inserts provided data
93
- * @param {Object} data data to be written into the .json file
93
+ * @param {object} data data to be written into the .json file
94
94
  * @param {string} jsonFilePath a path to a file.
95
95
  */
96
96
  const writeJsonFile = (data, jsonFilePath) => {
@@ -43,8 +43,8 @@ class AngularSxpInitializer {
43
43
  return false;
44
44
  }
45
45
  init(args) {
46
- var _a, _b;
47
46
  return __awaiter(this, void 0, void 0, function* () {
47
+ var _a, _b;
48
48
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
49
49
  const answers = yield inquirer_1.default.prompt(common_1.sxpPrompts, args);
50
50
  const styleguideAnswers = yield inquirer_1.default.prompt(common_1.styleguidePrompts, args);
@@ -45,8 +45,8 @@ class AngularXmCloudInitializer {
45
45
  return false;
46
46
  }
47
47
  init(args) {
48
- var _a, _b, _c, _d;
49
48
  return __awaiter(this, void 0, void 0, function* () {
49
+ var _a, _b, _c, _d;
50
50
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
51
51
  const addInitializers = [];
52
52
  // angular-xmcloud requires node-xmcloud-proxy
@@ -10,7 +10,7 @@ var Prerender;
10
10
  (function (Prerender) {
11
11
  Prerender["SSG"] = "SSG";
12
12
  Prerender["SSR"] = "SSR";
13
- })(Prerender = exports.Prerender || (exports.Prerender = {}));
13
+ })(Prerender || (exports.Prerender = Prerender = {}));
14
14
  const DEFAULT_PRERENDER = Prerender.SSG;
15
15
  // still need sxp prompts here until sitecore/config is no longer added to xmc app
16
16
  exports.prompts = [
@@ -39,8 +39,8 @@ class NextjsMultisiteInitializer {
39
39
  return false;
40
40
  }
41
41
  init(args) {
42
- var _a, _b;
43
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ var _a, _b;
44
44
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
45
45
  const mergedArgs = Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false });
46
46
  const templatePath = path_1.default.resolve(__dirname, '../../templates/nextjs-multisite');
@@ -44,8 +44,8 @@ class NextjsStyleguideInitializer {
44
44
  return false;
45
45
  }
46
46
  init(args) {
47
- var _a, _b;
48
47
  return __awaiter(this, void 0, void 0, function* () {
48
+ var _a, _b;
49
49
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
50
50
  const answers = yield inquirer_1.default.prompt(common_1.styleguidePrompts, args);
51
51
  const mergedArgs = Object.assign(Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false }), answers);
@@ -39,8 +39,8 @@ class NextjsStyleguideInitializer {
39
39
  return false;
40
40
  }
41
41
  init(args) {
42
- var _a, _b, _c, _d, _e, _f;
43
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ var _a, _b, _c, _d, _e, _f;
44
44
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
45
45
  const mergedArgs = Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false });
46
46
  const templatePath = path_1.default.resolve(__dirname, '../../templates/nextjs-styleguide-tracking');
@@ -39,8 +39,8 @@ class NextjsSxaInitializer {
39
39
  return false;
40
40
  }
41
41
  init(args) {
42
- var _a, _b, _c, _d;
43
42
  return __awaiter(this, void 0, void 0, function* () {
43
+ var _a, _b, _c, _d;
44
44
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
45
45
  // TODO: prompts for SXA
46
46
  // const answers = await prompt<StyleguideAnswer>(styleguidePrompts, args);
@@ -40,8 +40,8 @@ class NextjsXMCloudInitializer {
40
40
  return false;
41
41
  }
42
42
  init(args) {
43
- var _a, _b, _c, _d;
44
43
  return __awaiter(this, void 0, void 0, function* () {
44
+ var _a, _b, _c, _d;
45
45
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
46
46
  const mergedArgs = Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false });
47
47
  const templatePath = path_1.default.resolve(__dirname, '../../templates/nextjs-xmcloud');
@@ -24,7 +24,6 @@
24
24
  "src/favicon.ico"
25
25
  ],
26
26
  "styles": [
27
- "node_modules/bootstrap/dist/css/bootstrap.min.css",
28
27
  "src/styles.css"
29
28
  ],
30
29
  "scripts": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "Application utilizing Sitecore JavaScript Services and Angular (angular-cli).",
5
5
  "config": {
6
6
  "appName": "<%- appName %>",
@@ -57,7 +57,7 @@
57
57
  "@apollo/client": "^3.3.12",
58
58
  "@ngx-translate/core": "~15.0.0",
59
59
  "@ngx-translate/http-loader": "~8.0.0",
60
- "@sitecore-jss/sitecore-jss-angular": "~22.3.0-canary",
60
+ "@sitecore-jss/sitecore-jss-angular": "~<%- version %>",
61
61
  "apollo-angular": "~6.0.0",
62
62
  "bootstrap": "^5.3.3",
63
63
  "core-js": "~3.37.1",
@@ -65,7 +65,8 @@
65
65
  "graphql-tag": "~2.11.0",
66
66
  "rxjs": "~7.8.1",
67
67
  "tslib": "^2.6.3",
68
- "zone.js": "~0.14.7"
68
+ "zone.js": "~0.14.7",
69
+ "reflect-metadata": "^0.2.2"
69
70
  },
70
71
  "devDependencies": {
71
72
  "@angular-builders/custom-webpack": "^17.0.2",
@@ -78,14 +79,14 @@
78
79
  "@angular/cli": "~17.3.8",
79
80
  "@angular/compiler-cli": "~17.3.11",
80
81
  "@angular/language-service": "~17.3.11",
81
- "@sitecore-jss/sitecore-jss-angular-schematics": "~22.3.0-canary",
82
- "@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
83
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
82
+ "@sitecore-jss/sitecore-jss-angular-schematics": "~<%- version %>",
83
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
84
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
84
85
  "@types/jasmine": "~3.6.7",
85
86
  "@types/jasminewd2": "~2.0.8",
86
- "@types/node": "~20.14.10",
87
- "@typescript-eslint/eslint-plugin": "^7.16.0",
88
- "@typescript-eslint/parser": "^7.16.0",
87
+ "@types/node": "~22.9.0",
88
+ "@typescript-eslint/eslint-plugin": "^8.14.0",
89
+ "@typescript-eslint/parser": "^8.14.0",
89
90
  "chalk": "~4.1.0",
90
91
  "chokidar": "^3.5.2",
91
92
  "codelyzer": "~6.0.1",
@@ -107,9 +108,9 @@
107
108
  "karma-jasmine": "~4.0.1",
108
109
  "karma-jasmine-html-reporter": "~1.5.4",
109
110
  "move-cli": "^2.0.0",
110
- "npm-run-all": "~4.1.5",
111
+ "npm-run-all2": "^7.0.1",
111
112
  "protractor": "^7.0.0",
112
113
  "ts-node": "~10.9.2",
113
- "typescript": "~5.2.2"
114
+ "typescript": "~5.4.0"
114
115
  }
115
116
  }
@@ -3,8 +3,7 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "../out-tsc/app",
5
5
  "baseUrl": "./",
6
- "newLine": "LF",
7
- "types": []
6
+ "newLine": "LF"
8
7
  },
9
8
  "lib": [
10
9
  "esnext.asynciterable"
@@ -5,8 +5,7 @@
5
5
  "baseUrl": "./",
6
6
  "target": "ES2022",
7
7
  "module": "commonjs",
8
- "newLine": "LF",
9
- "types": []
8
+ "newLine": "LF"
10
9
  },
11
10
  "lib": [
12
11
  "esnext.asynciterable"
@@ -20,8 +20,10 @@
20
20
  "noUnusedLocals": true,
21
21
  "noUnusedParameters": true,
22
22
  "newLine": "LF",
23
- "typeRoots": ["node_modules/@types"],
24
- "lib": ["es2018", "dom", "esnext.asynciterable"],
23
+ "types": ["node"],
24
+ // add additional type root in case of monorepo where dependencies are hoisted to root node_modules
25
+ "typeRoots": ["node_modules/@types", "../node_modules/@types"],
26
+ "lib": ["es2019", "dom", "esnext.asynciterable"],
25
27
  "paths": {
26
28
  "@angular/*": ["../node_modules/@angular/*"],
27
29
  "rxjs": ["node_modules/rxjs", "../node_modules/rxjs"],
@@ -1,7 +1,13 @@
1
- const Dotenv = require("dotenv-webpack");
1
+ const Dotenv = require('dotenv-webpack');
2
+ const path = require('path');
2
3
 
3
4
  module.exports = {
4
- plugins: [
5
- new Dotenv(),
6
- ],
7
- }
5
+ plugins: [new Dotenv()],
6
+ <% if (helper.isDev) { %>
7
+ resolve: {
8
+ alias: {
9
+ '@sitecore-cloudsdk': path.resolve(__dirname, 'node_modules/@sitecore-cloudsdk'),
10
+ },
11
+ },
12
+ <% } %>
13
+ };
@@ -0,0 +1,13 @@
1
+ {
2
+ "projects": {
3
+ "<%- appName %>": {
4
+ "architect": {
5
+ "build": {
6
+ "options": {
7
+ "styles": ["node_modules/bootstrap/dist/css/bootstrap.min.css"]
8
+ }
9
+ }
10
+ }
11
+ }
12
+ }
13
+ }
@@ -11,4 +11,12 @@ SITECORE_EDGE_CONTEXT_ID=
11
11
  PROXY_HOST=http://localhost:3000
12
12
 
13
13
  # Your XM Cloud Proxy server path is needed to build the app. The build output will be copied to the proxy server path.
14
- PROXY_BUILD_PATH=<%- locals.relativeProxyAppDestination.replace(/\\/g, '\\\\') %>dist
14
+ # Use a relative unix style path to ensure compatibility when deployment runs on Windows or Unix based systems.
15
+ PROXY_BUILD_PATH=<%- locals.relativeProxyAppDestination.replace(/\\/g, '\/') %>dist
16
+
17
+ # ==============================================
18
+
19
+ # An optional Sitecore Personalize scope identifier.
20
+ # This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
21
+ # This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
22
+ PERSONALIZE_SCOPE=
@@ -0,0 +1,60 @@
1
+ # Angular for XMCloud
2
+
3
+ > Sitecore JSS Angular App for XM Cloud. For the current release this feature is experimental.
4
+
5
+ [Documentation](<TODO>)
6
+
7
+ This Single Page Application (SPA) built with Angular is designed to be fully compatible with XM Cloud, incorporating several key add-ons and features to streamline the development process and enable seamless integration. The supported key features are as follows:
8
+
9
+ - `Context ID`: The Context ID environment variable simplifies setting up and configuring XM Cloud solutions. It's a unified identifier that maps to all your configured resources, such as content, sites, files, forms, and integration settings.
10
+
11
+ - `XM Cloud Pages editing integration`: full integration with Pages - the dynamic visual page editor of XM Cloud.
12
+
13
+ - `XM Cloud proxy personalization` with embedded personalization and A/B Component Test support.
14
+
15
+ - `Forms support`: provides the capability to consume and post Sitecore Forms from JSS apps. Sitecore Forms is a form-authoring framework that enables marketers to author their own forms, collect data, and analyze form performance.
16
+
17
+ This SPA is tailored to enhance development workflows and enable full utilization of XM Cloud’s capabilities, providing a seamless and efficient foundation for developers.
18
+
19
+ ## Components and Supporting Applications
20
+
21
+ The following components and supporting applications have been added to the Angular base app to ensure compatibility with XM Cloud:
22
+
23
+ - `XM Cloud Angular`: Adds support for the Sitecore Context data, which simplifies connecting the application to XM Cloud and configuring the integration of multiple composable Sitecore products. Angular app provides components and can be used during development. Once the app is built and its build artifacts are copied into the proxy, the proxy app can be used to connect to an XMCloud instance and render its content (including personalization etc).
24
+
25
+ - `XM Cloud Proxy`: Adds integration with XMCloud for the JSS SPA applications and enables editing, personalization and A/B component testing support.
26
+
27
+ ## Environment Variables
28
+
29
+ The following environment variables can be set to configure the angular app. You can use the `.env` file located in the root of the app or set these directly in the environment (for example, in containers).
30
+
31
+ | Parameter | Description |
32
+ | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
33
+ | `PROXY_HOST` | Your XM Cloud Proxy hostname is needed to build the app and execute the client-side requests against the proxy server. Default value `http://localhost:3000` |
34
+ | `PROXY_BUILD_PATH` | Your XM Cloud Proxy server path is needed to build the app. The build output will be copied to the XMCloud Proxy application path. Default value `<xmcloud_proxy_path>\dist`.
35
+ | `SITECORE_EDGE_CONTEXT_ID` | The Context ID, which covers many system configurations, required for connecting to the XM Cloud back end. This is an XM Cloud system environment variable. When the application runs on the XM Cloud rendering host, this value is always set to the preview Context ID. |
36
+ | `SITECORE_API_KEY` | The API key for GRAPH_QL_ENDPOINT authentication. For Experience Edge, you can find the API key in the Sites dashboard by opening the actions menu for a site and navigating to Settings > Developer settings. Copy the value for SITECORE_API_KEY. For a preview endpoint (a CM instance either on XM Cloud or locally), use your preview API Key from the CM instance.
37
+ | `SITECORE_API_HOST` | The API hostname, needed to build the application. This should be used in combination with SITECORE_API_KEY for local development or local container setup. For example, https://<xmc_cm_host>.sitecorecloud.io. |
38
+ | `GRAPH_QL_ENDPOINT` | Your GraphQL Edge endpoint. This is typically optional. By default, the endpoint is calculated using the resolved Sitecore API hostname + the `graphQLEndpointPath` defined in your `package.json`. For a preview endpoint (a CM instance on XM Cloud or a local one), the value is <xmc_cm_host>/sitecore/api/graph/edge. |
39
+ | `SITECORE_SITE_NAME` | The name of your site. This variable overrides the config.appName defined in the package.json file. You can find this value in the Sites dashboard by opening the actions menu for a site and navigating to Settings > Developer settings. Default value `<appName>`,
40
+ ` |
41
+ | `DEFAULT_LANGUAGE` | The default language of your app. Default value `en` |
42
+ | `DEBUG` | Optional. Debug level for the proxy. Set the DEBUG environment variable to 'sitecore-jss:*,proxy*,http-proxy-middleware*' to see all logs. Refer to the [official docs](https://doc.sitecore.com/xp/en/developers/hd/latest/sitecore-headless-development/debug-logging-in-jss-apps.html#namespaces) for all the available namespaces.
43
+
44
+ ## Build & run
45
+
46
+ ### Running the application in production mode
47
+
48
+ To build and run in production mode you need to have your angular app side by side with the [Node XM CLoud proxy](https://github.com/Sitecore/jss/tree/dev/packages/create-sitecore-jss/src/templates/node-xmcloud-proxy). For additional information on how to set up and run SPA app in production mode against XM CLoud instance you can check the [spa-starters](https://github.com/sitecorelabs/xmcloud-foundation-head/tree/main/headapps/spa-starter) monoreopo readme.
49
+
50
+ 1. Run `npm install` for both angular and proxy apps
51
+ 2. Run `npm run build` in the angular app root; this will build the angular app and copy the the resulting `/dist` folder into the specified proxy app folder
52
+ 3. Run `npm run start` in the proxy app root
53
+
54
+ ### Running the application in connected mode
55
+
56
+ When building and running your app in connected mode the proxy application is not needed. However, please note that certain features, such as personalization, server-side rendering, and editing, will not be available.
57
+
58
+ 1. Run `npm install`
59
+ 2. Run `npm run build`
60
+ 3. Run `npm run start:connected`
@@ -8,8 +8,8 @@
8
8
  "prepare:proxy-build": "ts-node --project src/tsconfig.webpack-server.json ./scripts/proxy-build.ts"
9
9
  },
10
10
  "dependencies": {
11
- "@sitecore-cloudsdk/core": "^0.4.1",
12
- "@sitecore-cloudsdk/events": "^0.4.1",
11
+ "@sitecore-cloudsdk/core": "^0.4.2",
12
+ "@sitecore-cloudsdk/events": "^0.4.2",
13
13
  "font-awesome": "^4.7.0",
14
14
  "sass": "^1.52.3",
15
15
  "sass-alias": "^1.0.5"
@@ -18,6 +18,7 @@ class XMCloudPlugin implements ConfigPlugin {
18
18
  process.env[`${constantCase('sitecoreEdgeUrl')}`]?.replace(/\/$/, '') ||
19
19
  'https://edge-platform.sitecorecloud.io';
20
20
  const sitecoreEdgeContextId = process.env[`${constantCase('sitecoreEdgeContextId')}`];
21
+ const personalizeScope = process.env[`${constantCase('personalizeScope')}`]
21
22
 
22
23
  if (config.sitecoreApiKey && sitecoreEdgeContextId) {
23
24
  console.log(
@@ -32,6 +33,7 @@ class XMCloudPlugin implements ConfigPlugin {
32
33
  proxyHost,
33
34
  sitecoreEdgeUrl,
34
35
  sitecoreEdgeContextId,
36
+ personalizeScope,
35
37
  });
36
38
  }
37
39
  }
@@ -1,13 +1,13 @@
1
- import { execSync } from 'child_process';
2
1
  import { environment } from '../src/environments/environment';
2
+ import { cpSync, rmSync } from 'fs';
3
3
 
4
4
  // Executed at the end of the build process (jss build) to move the build output to the proxy build path
5
5
 
6
6
  try {
7
7
  console.log('Moving build output to proxy build path:', environment.proxyBuildPath);
8
8
 
9
- execSync(`del-cli ${environment.proxyBuildPath} --force`, { stdio: 'inherit' });
10
- execSync(`move-cli ./dist ${environment.proxyBuildPath}`, { stdio: 'inherit' });
9
+ rmSync(environment.proxyBuildPath, { recursive: true, force: true });
10
+ cpSync('./dist', environment.proxyBuildPath, { recursive: true });
11
11
 
12
12
  console.log('Proxy build prepared successfully!');
13
13
  } catch (error) {
@@ -11,6 +11,7 @@ import metadata from './src/environments/metadata.json';
11
11
 
12
12
  const defaultLanguage = environment.defaultLanguage;
13
13
  const sitecoreSiteName = environment.sitecoreSiteName;
14
+ const personalizeScope = environment.personalizeScope;
14
15
  const getClientFactoryConfig = getGraphQLClientFactoryConfig;
15
16
 
16
17
  export {
@@ -20,6 +21,7 @@ export {
20
21
  layoutServiceFactory,
21
22
  defaultLanguage,
22
23
  sitecoreSiteName,
24
+ personalizeScope,
23
25
  components,
24
26
  metadata,
25
27
  };
@@ -19,7 +19,12 @@
19
19
  "@next/next/no-img-element": "off", // Don't force next/image
20
20
  "jsx-a11y/alt-text": ["warn", { "elements": ["img"] }], // Don't force alt for <Image/> (sourced from Sitecore media)
21
21
  "no-unused-vars": "off",
22
- "@typescript-eslint/no-unused-vars": "error",
22
+ "@typescript-eslint/no-unused-vars": [
23
+ "error",
24
+ {
25
+ "caughtErrorsIgnorePattern": "."
26
+ }
27
+ ],
23
28
  "@typescript-eslint/no-explicit-any": "error",
24
29
  "jsx-quotes": ["error", "prefer-double"]
25
30
  }
@@ -30,6 +30,9 @@ const nextConfig = {
30
30
  // Enable React Strict Mode
31
31
  reactStrictMode: true,
32
32
 
33
+ // Disable the X-Powered-By header. Follows security best practices.
34
+ poweredByHeader: false,
35
+
33
36
  // use this configuration to ensure that only images from the whitelisted domains
34
37
  // can be served from the Next.js Image Optimization API
35
38
  // see https://nextjs.org/docs/app/api-reference/components/image#remotepatterns
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
3
  "description": "Application utilizing Sitecore JavaScript Services and Next.js",
4
- "version": "22.3.0-canary",
4
+ "version": "<%- version %>",
5
5
  "private": true,
6
6
  "config": {
7
7
  "appName": "<%- appName %>",
@@ -25,10 +25,10 @@
25
25
  },
26
26
  "license": "Apache-2.0",
27
27
  "dependencies": {
28
- "@sitecore-jss/sitecore-jss-nextjs": "~22.3.0-canary",
28
+ "@sitecore-jss/sitecore-jss-nextjs": "~<%- version %>",
29
29
  "graphql": "~15.8.0",
30
30
  "graphql-tag": "^2.12.6",
31
- "next": "^14.2.7",
31
+ "next": "^14.2.18",
32
32
  "next-localization": "^0.12.0",
33
33
  "react": "^18.2.0",
34
34
  "react-dom": "^18.2.0",
@@ -43,19 +43,19 @@
43
43
  "@graphql-codegen/typescript-operations": "^4.0.1",
44
44
  "@graphql-codegen/typescript-resolvers": "^4.0.1",
45
45
  "@graphql-typed-document-node/core": "^3.2.0",
46
- "@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
47
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
48
- "@types/node": "^20.14.2",
46
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
47
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
48
+ "@types/node": "^22.9.0",
49
49
  "@types/react": "^18.2.22",
50
50
  "@types/react-dom": "^18.0.5",
51
- "@typescript-eslint/eslint-plugin": "^5.49.0",
52
- "@typescript-eslint/parser": "^5.49.0",
51
+ "@typescript-eslint/eslint-plugin": "^8.14.0",
52
+ "@typescript-eslint/parser": "^8.14.0",
53
53
  "chalk": "~4.1.2",
54
54
  "chokidar": "~3.5.3",
55
55
  "constant-case": "^3.0.4",
56
56
  "cross-env": "~7.0.3",
57
57
  "dotenv-flow": "^4.1.0",
58
- "eslint": "^8.32.0",
58
+ "eslint": "^8.56.0",
59
59
  "eslint-config-next": "^13.1.5",
60
60
  "eslint-config-prettier": "^8.6.0",
61
61
  "eslint-plugin-prettier": "^4.2.1",
@@ -66,7 +66,7 @@
66
66
  "prettier": "^2.8.3",
67
67
  "ts-node": "^10.9.1",
68
68
  "tsconfig-paths": "^4.1.2",
69
- "typescript": "~4.9.4",
69
+ "typescript": "~5.4.0",
70
70
  "yaml-loader": "^0.8.0"
71
71
  },
72
72
  "scripts": {
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
2
2
  const plugins = require('scripts/temp/config-plugins');
3
3
  import { JssConfig } from 'lib/config';
4
4
 
@@ -12,6 +12,7 @@ class ScJssConfigPlugin implements ConfigPlugin {
12
12
  async exec(config: JssConfig) {
13
13
  let scJssConfig;
14
14
  try {
15
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
15
16
  scJssConfig = require('scjssconfig.json');
16
17
  } catch (e) {
17
18
  return config;
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
2
2
  const plugins = require('scripts/temp/generate-component-builder-plugins');
3
3
  import { PackageDefinition, ComponentFile } from '@sitecore-jss/sitecore-jss-dev-tools';
4
4
 
@@ -23,7 +23,7 @@ generatePlugins({
23
23
  Edit this script if you wish to use your own conventions for component storage in your JSS app.
24
24
  */
25
25
 
26
- // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
27
27
  const plugins = require('scripts/temp/scaffold-component-plugins');
28
28
 
29
29
  export interface ScaffoldComponentPluginConfig {
@@ -40,7 +40,7 @@ export function getItems<Item>(settings: {
40
40
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
41
41
  const name = item.name.match(fileFormat)![1];
42
42
  items.push(resolveItem(path, name));
43
- cb && cb(name);
43
+ if (cb) cb(name);
44
44
  }
45
45
  });
46
46
 
@@ -10,6 +10,7 @@
10
10
  "react": ["node_modules/react"]
11
11
  },
12
12
  "target": "es5",
13
+ "types": ["node"],
13
14
  "lib": ["dom", "dom.iterable", "esnext"],
14
15
  "allowJs": true,
15
16
  "skipLibCheck": true,
@@ -4,7 +4,7 @@
4
4
  "nprogress": "~0.2.0"
5
5
  },
6
6
  "devDependencies": {
7
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
7
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
8
8
  "@types/nprogress": "^0.2.0"
9
9
  },
10
10
  "scripts": {
@@ -19,7 +19,7 @@ class DisconnectedSitemapServicePlugin implements SitemapFetcherPlugin {
19
19
  if (process.env.JSS_MODE !== constants.JSS_MODE.DISCONNECTED) return null;
20
20
 
21
21
  try {
22
- // eslint-disable-next-line @typescript-eslint/no-var-requires
22
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
23
23
  const manifest = require('sitecore/manifest/sitecore-import.json');
24
24
 
25
25
  return manifest;
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@sitecore/components": "~2.0.1",
4
- "@sitecore-cloudsdk/core": "^0.4.1",
5
- "@sitecore-cloudsdk/events": "^0.4.1",
4
+ "@sitecore-cloudsdk/core": "^0.4.2",
5
+ "@sitecore-cloudsdk/events": "^0.4.2",
6
6
  "@sitecore-feaas/clientside": "^0.5.19"
7
7
  }
8
8
  }
@@ -14,7 +14,7 @@ class ContentStylesPlugin implements Plugin {
14
14
  config.sitecoreEdgeUrl
15
15
  );
16
16
 
17
- contentStyles && props.headLinks.push(contentStyles);
17
+ if (contentStyles) props.headLinks.push(contentStyles);
18
18
 
19
19
  return props;
20
20
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-headless-ssr-experience-edge-sample",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "Node server-side-rendering sample for running JSS apps under Node hosting using Experience Edge",
5
5
  "scripts": {
6
6
  "start": "ts-node ./src/index.ts"
@@ -19,7 +19,7 @@
19
19
  "homepage": "https://jss.sitecore.com",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@sitecore-jss/sitecore-jss": "~22.3.0-canary",
22
+ "@sitecore-jss/sitecore-jss": "~<%- version %>",
23
23
  "compression": "^1.7.4",
24
24
  "express": "^4.18.2",
25
25
  "dotenv": "^16.0.3"
@@ -28,7 +28,7 @@
28
28
  "@types/compression": "^1.7.2",
29
29
  "@types/express": "^4.17.17",
30
30
  "ts-node": "^10.9.1",
31
- "typescript": "~4.9.5"
31
+ "typescript": "~5.6.3"
32
32
  },
33
33
  "private": true
34
34
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-headless-ssr-proxy-sample",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "Node server-side-rendering proxy sample for running JSS apps under Node hosting",
5
5
  "scripts": {
6
6
  "start": "ts-node ./src/index.ts"
@@ -19,8 +19,8 @@
19
19
  "homepage": "https://jss.sitecore.com",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@sitecore-jss/sitecore-jss": "~22.3.0-canary",
23
- "@sitecore-jss/sitecore-jss-proxy": "~22.3.0-canary",
22
+ "@sitecore-jss/sitecore-jss": "~<%- version %>",
23
+ "@sitecore-jss/sitecore-jss-proxy": "~<%- version %>",
24
24
  "agentkeepalive": "^4.2.1",
25
25
  "compression": "~1.7.4",
26
26
  "express": "~4.19.2",
@@ -31,9 +31,9 @@
31
31
  "@types/compression": "^1.7.2",
32
32
  "@types/express": "^4.17.17",
33
33
  "@types/memory-cache": "^0.2.2",
34
- "@types/node": "^20.14.2",
34
+ "@types/node": "^22.9.0",
35
35
  "ts-node": "^10.9.1",
36
- "typescript": "~4.9.5"
36
+ "typescript": "~5.6.3"
37
37
  },
38
38
  "private": true
39
39
  }
@@ -13,11 +13,6 @@ PROXY_BUNDLE_PATH=
13
13
  # Set the DEBUG environment variable to 'sitecore-jss:*,sitecore-jss:proxy,http-proxy-middleware*' to see all logs:
14
14
  #DEBUG=sitecore-jss:*,http-proxy-middleware*
15
15
 
16
- # An optional Sitecore Personalize scope identifier.
17
- # This can be used to isolate personalization data when multiple XM Cloud Environments share a Personalize tenant.
18
- # This should match the PAGES_PERSONALIZE_SCOPE environment variable for your connected XM Cloud Environment.
19
- PERSONALIZE_SCOPE=
20
-
21
16
  # Timeout (ms) for Sitecore CDP requests to respond within. Default is 400.
22
17
  PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT=
23
18
 
@@ -2,35 +2,129 @@
2
2
 
3
3
  > Sitecore JSS Proxy for XM Cloud is considered experimental.
4
4
 
5
- [Documentation](<TODO>)
5
+ [Documentation](TODO)
6
+
7
+ This proxy will serve as the backbone for supporting various SPA frameworks by handling server-side rendering (SSR), data queries, and middleware functionalities.
6
8
 
7
9
  This is a sample setup showing one of how you can configure XM Cloud rendering server.
8
10
 
9
- ## Pre-requisites
11
+ ## Features Supported
10
12
 
11
- 1. SPA sample supports XM Cloud out of the box.
13
+ - `Context ID`: The Context ID environment variable simplifies setting up and configuring XM Cloud solutions. It's a unified identifier that maps to all your configured resources, such as content, sites, files, forms, and integration settings.
14
+
15
+ - `XM Cloud Pages editing integration`: full integration with Pages - the dynamic visual page editor of XM Cloud.
16
+
17
+ - `XM Cloud proxy personalization` with embedded personalization and A/B Component Test support.
18
+
19
+ - `Forms support`: provides the capability to consume and post Sitecore Forms from JSS apps. Sitecore Forms is a form-authoring framework that enables marketers to author their own forms, collect data, and analyze form performance.
20
+
21
+ ## Configuration Setup
22
+
23
+ The config.ts file in this proxy app handles essential configurations for server-side rendering, data queries, and middleware functionalities. Here are the main configurations defined:
24
+
25
+ - Server Bundle Configuration:
26
+
27
+ - The app loads a server.bundle.js file, pre-built from your SPA app, for SSR support.
28
+ - This file contains the configuration and factory functions essential for rendering and data querying.
29
+
30
+ - GraphQL Endpoint Setup:
12
31
 
13
- 1. Build your SPA app bundle with `jss build`. The build output should be placed in the `dist` folder.
32
+ - Defines a graphQLEndpoint for handling Sitecore GraphQL requests. It differentiates between production (Sitecore Edge) and development (Sitecore CM) endpoints.
33
+ - Constructs the target URL and path for proxy requests, ensuring compliance with http-proxy-middleware requirements.
14
34
 
15
- ## Setup
35
+ - Port Configuration:
16
36
 
17
- Open `config.js` and specify your application settings.
37
+ - Configures the port for running the proxy, with a default of 3000 or an environment-specified port.
38
+
39
+ - Personalization Configuration (personalizeConfig):
40
+
41
+ - Sets up Sitecore personalization through PersonalizeConfig, defining settings for both Sitecore Experience Edge and CDP endpoints.
42
+ - Contains options to control personalization features, including:
43
+ - Timeouts for Edge and CDP endpoints (default 400ms, configurable via environment variables).
44
+ - Scope and site name used for Sitecore Personalize.
45
+ - Enable/Disable Switch: Functions that allow you to conditionally disable personalization based on the environment (e.g., disabled in development mode) and cookie consent policy.
46
+ - Language Configuration: defaultLanguage serves as a fallback if language data is unavailable in layout data.
47
+
48
+ This configuration is designed to be flexible and secure, with dynamic settings managed via environment variables where appropriate.
18
49
 
19
50
  ### Environment Variables
20
51
 
21
52
  The following environment variables can be set to configure the Proxy sample instead of modifying `config.js`. You can use the `.env` file located in the root of the app or set these directly in the environment (for example, in containers).
22
53
 
23
- | Parameter | Description |
24
- | -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
25
- | `PROXY_BUNDLE_PATH` | Path to the JSS SPA app's `server.bundle.js`. Default can be seen in [config.js](./config.js) file. |
26
- | `PROXY_PORT` | Optional. Port which will be used when start sample. Default can be seen in [config.js](./config.js) file. |
27
- | `DEBUG` | Optional. Debug level for the proxy. Set the DEBUG environment variable to 'sitecore-jss:*,proxy*,http-proxy-middleware*' to see all logs. |
54
+ | Parameter | Description |
55
+ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
56
+ | `PROXY_BUNDLE_PATH` | Path to the JSS SPA app's `server.bundle.js`. Default can be seen in [config.js](./config.js) file. |
57
+ | `PROXY_PORT` | Optional. Port which will be used when start sample. Default can be seen in [config.js](./config.js) file. |
58
+ | `DEBUG` | Optional. Debug level for the proxy. Set the DEBUG environment variable to 'sitecore-jss:_,proxy_,http-proxy-middleware\*, 'sitecore-jss:layout','sitecore-jss:personalize' to see all logs. |
59
+
60
+ ## Pre-requisites
61
+
62
+ 1. SPA sample supports XM Cloud out of the box.
63
+
64
+ 2. Build your SPA app bundle with `jss build` or `npm run build`. The build output should be placed in the `dist` folder. |
28
65
 
29
66
  ## Build & run
30
67
 
31
68
  1. Run `npm install`
32
69
 
33
- 1. Run `npm run start`
70
+ 2. Run `npm run start`
34
71
 
35
72
  You should be able to see the following message:
36
73
  `server listening on port 3000!`.
74
+
75
+ ## Deploy to Netlify
76
+
77
+ `NOTE: If you are using the Angular starter from the XM-Cloud Foundation repository within a monorepo, please skip to Step 3.`
78
+
79
+ 1. Run `npm init` in the root directory and add the following scripts to package.json:
80
+ ```
81
+ "build": "cd ./<your-proxy-app-name> && npm run build-all && cd ..",
82
+ "install": "cd ./<your-proxy-app-name> && npm install && npm run install-all && cd ..",
83
+ ```
84
+ 2. Ensure that `<your-proxy-app-name>/package.json` includes the following commands to handle the build and install steps properly::
85
+ ```
86
+ "build-all": "cd ../angular && npm run build && cd ../<your-proxy-app-name> && tsc",
87
+ "install-all": "cd ../angular && npm i && cd ../<your-proxy-app-name>"
88
+ ```
89
+ 3. Add `serverless-http` to the list of dependencies in `<your-proxy-app-name>/package.json` and then add the following variable to your ``<your-proxy-app-name>/src/index.ts` file.
90
+ ```
91
+ export const handler = serverless(server);
92
+ ```
93
+ 4. Create a `netlfiy.toml` file if not already created and ensure that the following Netlify configuration is added there:
94
+ - Following functions lets the proxy app to treated as netlify functions. [Functions Overview](https://docs.netlify.com/functions/overview/)
95
+ ```
96
+ [functions]
97
+ directory = "<your-proxy-app-name>/src"
98
+ node_bundler = "esbuild"
99
+ included_files = ["<your-proxy-app-name>/dist/**"]
100
+ ```
101
+ - To ensure that static assets are accessed properly we may need to add redirects statement for them to the toml file:
102
+ ```
103
+ [[redirects]]
104
+ from = "/dist/browser/*"
105
+ status = 200
106
+ to = "/browser/:splat"
107
+ ```
108
+ - To ensure that static files under /dist are not accessible via browser add `force=true` to the above
109
+ ```
110
+ [[redirects]]
111
+ from = "/*"
112
+ status = 200
113
+ to = "/.netlify/functions/index/:splat"
114
+ force = true
115
+ ```
116
+ - Build command
117
+ ```
118
+ [build]
119
+ command = "npm run build"
120
+ publish = "<your-proxy-app-name>/dist"
121
+ ```
122
+ 5. Create your netlify deployment: [A Step-by-Step Guide: Deploying on Netlify | Netlify](https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/)
123
+ a. Set up all your necessary environment variables like SITECORE_EDGE_CONTEXT_ID, SITECORE_SITE_NAME etc.
124
+ b. Set up your build settings in Site configuration --> Build and Deploy tab.
125
+ sample configuration:
126
+ Base Directory: /
127
+ Build command: npm run build
128
+ Publish directory: /proxy/dist
129
+ Functions directory: /proxy/src
130
+ NOTE: If proxy/dist folder is not picked up properly by Netlify make sure that the `PROXY_BUILD_PATH` env variable is unix style path e.g. `../proxy/dist`
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-xmcloud-sample",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "Node XM Cloud Proxy sample for running XM Cloud JSS SPA apps",
5
5
  "author": {
6
6
  "name": "Sitecore Corporation",
@@ -10,17 +10,17 @@
10
10
  "start": "ts-node ./src/index.ts"
11
11
  },
12
12
  "dependencies": {
13
- "@sitecore-jss/sitecore-jss-proxy": "~22.3.0-canary",
13
+ "@sitecore-jss/sitecore-jss-proxy": "~<%- version %>",
14
14
  "compression": "^1.7.4",
15
15
  "express": "^4.18.2",
16
16
  "dotenv": "^16.0.3",
17
17
  "http-proxy-middleware": "^3.0.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@sitecore-jss/sitecore-jss": "~22.3.0-canary",
20
+ "@sitecore-jss/sitecore-jss": "~<%- version %>",
21
21
  "@types/compression": "^1.7.2",
22
22
  "@types/express": "^4.17.17",
23
23
  "ts-node": "^10.9.1",
24
- "typescript": "~4.9.5"
24
+ "typescript": "~5.6.3"
25
25
  }
26
26
  }
@@ -77,7 +77,7 @@ export const personalizeConfig: PersonalizeConfig = {
77
77
  400,
78
78
  },
79
79
  // Optional Sitecore Personalize scope identifier.
80
- scope: process.env.PERSONALIZE_SCOPE,
80
+ scope: serverBundle.personalizeScope,
81
81
  // This function determines if the personalization should be turned off.
82
82
  // IMPORTANT: You should implement based on your cookie consent management solution of choice.
83
83
  // You may wish to keep it disabled while in development mode.
@@ -17,6 +17,7 @@ export interface ServerBundle {
17
17
  getClientFactoryConfig: () => GraphQLRequestClientFactoryConfig;
18
18
  defaultLanguage: string;
19
19
  sitecoreSiteName: string;
20
+ personalizeScope?: string;
20
21
  layoutServiceFactory: { create: () => LayoutService };
21
22
  dictionaryServiceFactory: { create: () => DictionaryService };
22
23
  components: string[] | Map<string, unknown>;
@@ -14,6 +14,8 @@
14
14
  "ecmaFeatures": {
15
15
  "jsx": true
16
16
  },
17
+ //prevent 'ImportDeclaration should appear when the mode is ES6' error when running lint
18
+ "ecmaVersion": 13,
17
19
  "babelOptions": {
18
20
  "presets": ["@babel/preset-react"]
19
21
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
3
  "description": "Application utilizing Sitecore JavaScript Services and React (create-react-app).",
4
- "version": "22.3.0-canary",
4
+ "version": "<%- version %>",
5
5
  "private": true,
6
6
  "config": {
7
7
  "appName": "<%- appName %>",
@@ -28,7 +28,7 @@
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
30
  "@apollo/client": "^3.7.1",
31
- "@sitecore-jss/sitecore-jss-react": "~22.3.0-canary",
31
+ "@sitecore-jss/sitecore-jss-react": "~<%- version %>",
32
32
  "axios": "^1.2.0",
33
33
  "bootstrap": "^5.2.3",
34
34
  "cross-fetch": "^3.1.5",
@@ -53,9 +53,9 @@
53
53
  "@babel/preset-env": "^7.20.2",
54
54
  "@babel/preset-react": "^7.18.6",
55
55
  "@babel/register": "~7.18.9",
56
- "@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
57
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
58
- "@sitecore-jss/sitecore-jss-rendering-host": "~22.3.0-canary",
56
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
57
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
58
+ "@sitecore-jss/sitecore-jss-rendering-host": "~<%- version %>",
59
59
  "babel-loader": "~9.1.0",
60
60
  "babel-preset-react-app": "~10.0.1",
61
61
  "chalk": "~4.1.2",
@@ -64,7 +64,7 @@
64
64
  "cross-spawn": "^7.0.3",
65
65
  "del-cli": "^5.0.0",
66
66
  "dotenv": "^16.0.3",
67
- "eslint": "^8.28.0",
67
+ "eslint": "^8.56.0",
68
68
  "eslint-config-prettier": "^8.5.0",
69
69
  "eslint-plugin-import": "^2.26.0",
70
70
  "eslint-plugin-prettier": "^4.2.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "A basic React Native app utilizing Sitecore JavaScript Services",
5
5
  "config": {
6
6
  "appName": "<%- appName %>",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@react-native-community/masked-view": "^0.1.10",
26
- "@sitecore-jss/sitecore-jss-react-native": "~22.3.0-canary",
26
+ "@sitecore-jss/sitecore-jss-react-native": "~<%- version %>",
27
27
  "prop-types": "^15.6.0",
28
28
  "react": "16.13.1",
29
29
  "react-native": "^0.63.4",
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "private": true,
39
39
  "devDependencies": {
40
- "@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
41
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
40
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
41
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
42
42
  "babel-core": "^6.26.0",
43
43
  "babel-eslint": "^8.2.1",
44
44
  "babel-plugin-inline-replace-variables": "^1.3.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "22.3.0-canary",
3
+ "version": "<%- version %>",
4
4
  "description": "Application utilizing Sitecore JavaScript Services and Vue (vue-cli).",
5
5
  "private": true,
6
6
  "config": {
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@apollo/client": "^3.7.4",
47
47
  "@panter/vue-i18next": "~0.15.2",
48
- "@sitecore-jss/sitecore-jss-vue": "~22.3.0-canary",
48
+ "@sitecore-jss/sitecore-jss-vue": "~<%- version %>",
49
49
  "@vue/apollo-composable": "4.2.1",
50
50
  "@vue/apollo-option": "^4.0.0",
51
51
  "@vue/apollo-ssr": "^4.0.0",
@@ -63,8 +63,8 @@
63
63
  "devDependencies": {
64
64
  "@babel/eslint-parser": "^7.19.1",
65
65
  "@babel/register": "7.18.9",
66
- "@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
67
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
66
+ "@sitecore-jss/sitecore-jss-cli": "~<%- version %>",
67
+ "@sitecore-jss/sitecore-jss-dev-tools": "~<%- version %>",
68
68
  "@vue/cli-plugin-babel": "~5.0.8",
69
69
  "@vue/cli-plugin-eslint": "~5.0.8",
70
70
  "@vue/cli-service": "~5.0.8",
@@ -74,7 +74,7 @@
74
74
  "constant-case": "^3.0.4",
75
75
  "cross-env": "~7.0.3",
76
76
  "dotenv": "^16.0.3",
77
- "eslint": "^8.32.0",
77
+ "eslint": "^8.56.0",
78
78
  "eslint-plugin-prettier": "^5.0.0",
79
79
  "eslint-plugin-vue": "~9.9.0",
80
80
  "eslint-plugin-yaml": "^0.5.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "22.3.0-canary.9",
3
+ "version": "22.3.1-canary.10",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "coverage": "nyc npm test"
13
13
  },
14
14
  "engines": {
15
- "node": ">=20"
15
+ "node": ">=22"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
@@ -49,19 +49,21 @@
49
49
  "@types/inquirer": "^9.0.3",
50
50
  "@types/minimist": "^1.2.2",
51
51
  "@types/mocha": "^10.0.1",
52
- "@types/node": "^20.14.2",
53
- "@types/sinon": "10.0.6",
54
- "@types/sinon-chai": "^3.2.9",
52
+ "@types/node": "^22.9.0",
53
+ "@types/proxyquire": "^1.3.31",
54
+ "@types/sinon": "17.0.3",
55
+ "@types/sinon-chai": "^4.0.0",
55
56
  "chai": "^4.3.7",
56
57
  "chokidar": "^3.5.3",
57
58
  "del-cli": "^5.0.0",
58
- "eslint": "^8.32.0",
59
+ "eslint": "^8.56.0",
59
60
  "mocha": "^10.2.0",
60
61
  "nyc": "^15.1.0",
61
- "sinon": "^15.0.1",
62
+ "proxyquire": "^2.1.3",
63
+ "sinon": "^18.0.0",
62
64
  "sinon-chai": "^3.7.0",
63
65
  "ts-node": "^10.9.1",
64
- "typescript": "~4.9.5"
66
+ "typescript": "~5.6.3"
65
67
  },
66
- "gitHead": "80aab2e2e832a1a9ae024c771a955c2d403e63fe"
68
+ "gitHead": "501bf3b7c73be6cf633b4f86a9ca418c4d61745d"
67
69
  }