create-sitecore-jss 21.3.0 → 21.3.1

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 (58) hide show
  1. package/dist/common/processes/transform.js +11 -32
  2. package/dist/templates/angular/README.md +0 -3
  3. package/dist/templates/angular/angular.json +6 -1
  4. package/dist/templates/angular/package.json +6 -6
  5. package/dist/templates/angular/scripts/generate-config.ts +0 -1
  6. package/dist/templates/angular/src/app/lib/layout-service-factory.ts +1 -1
  7. package/dist/templates/angular/src/tsconfig.server.json +1 -1
  8. package/dist/templates/nextjs/README.md +0 -3
  9. package/dist/templates/nextjs/package.json +4 -4
  10. package/dist/templates/nextjs/scripts/config/index.ts +0 -1
  11. package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +1 -2
  12. package/dist/templates/nextjs/scripts/generate-component-builder/index.ts +1 -2
  13. package/dist/templates/nextjs/scripts/generate-component-builder/plugins/component-builder.ts +1 -1
  14. package/dist/templates/nextjs/scripts/generate-config.ts +0 -1
  15. package/dist/templates/nextjs/scripts/scaffold-component/index.ts +1 -15
  16. package/dist/templates/nextjs/scripts/scaffold-component/plugins/component.ts +6 -4
  17. package/dist/templates/nextjs/scripts/scaffold-component/plugins/next-steps.ts +3 -7
  18. package/dist/templates/nextjs/src/lib/layout-service-factory.ts +1 -1
  19. package/dist/templates/nextjs/src/lib/middleware/index.ts +1 -10
  20. package/dist/templates/nextjs/src/lib/page-props-factory/index.ts +0 -6
  21. package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +1 -15
  22. package/dist/templates/nextjs/src/pages/api/editing/data/[key].ts +1 -0
  23. package/dist/templates/nextjs/src/pages/api/editing/render.ts +0 -6
  24. package/dist/templates/nextjs-styleguide/package.json +1 -1
  25. package/dist/templates/nextjs-styleguide/scripts/scaffold-component/plugins/{next-steps-styleguide.ts → next-steps.ts} +13 -4
  26. package/dist/templates/nextjs-sxa/package.json +1 -1
  27. package/dist/templates/nextjs-sxa/src/assets/basic/_component.scss +0 -30
  28. package/dist/templates/nextjs-sxa/src/assets/sass/_app.scss +0 -4
  29. package/dist/templates/nextjs-sxa/src/assets/sass/components/image/_image-banner.scss +15 -0
  30. package/dist/templates/nextjs-sxa/src/assets/sass/components/image/index.scss +1 -0
  31. package/dist/templates/nextjs-sxa/src/components/Image.tsx +2 -10
  32. package/dist/templates/nextjs-sxa/src/pages/api/robots.ts +2 -1
  33. package/dist/templates/node-headless-ssr-experience-edge/README.md +0 -4
  34. package/dist/templates/node-headless-ssr-experience-edge/package.json +2 -2
  35. package/dist/templates/node-headless-ssr-proxy/README.md +0 -4
  36. package/dist/templates/node-headless-ssr-proxy/package.json +3 -3
  37. package/dist/templates/react/README.md +0 -3
  38. package/dist/templates/react/package.json +5 -5
  39. package/dist/templates/react/scripts/config/plugins/fallback.js +0 -1
  40. package/dist/templates/react/scripts/generate-component-builder/plugins/component-builder.js +1 -1
  41. package/dist/templates/react/scripts/generate-config.js +0 -1
  42. package/dist/templates/react/src/lib/layout-service-factory.js +1 -1
  43. package/dist/templates/react-native/README.MD +0 -3
  44. package/dist/templates/react-native/package.json +4 -4
  45. package/dist/templates/vue/README.md +0 -3
  46. package/dist/templates/vue/package.json +5 -6
  47. package/dist/templates/vue/scripts/generate-config.js +0 -1
  48. package/dist/templates/vue/src/lib/layout-service-factory.js +1 -1
  49. package/package.json +2 -2
  50. package/dist/templates/nextjs/scripts/generate-component-builder/plugins/components.ts +0 -30
  51. package/dist/templates/nextjs/src/lib/next-config/plugins/cors-header.js +0 -22
  52. package/dist/templates/nextjs-sxa/scripts/config/plugins/sxa.ts +0 -17
  53. package/dist/templates/nextjs-sxa/scripts/scaffold-component/plugins/byoc.ts +0 -19
  54. package/dist/templates/nextjs-sxa/scripts/scaffold-component/plugins/next-steps-byoc.ts +0 -20
  55. package/dist/templates/nextjs-sxa/scripts/templates/byoc-component-src.ts +0 -49
  56. package/dist/templates/nextjs-sxa/src/components/BYOCWrapper.tsx +0 -19
  57. package/dist/templates/nextjs-sxa/src/lib/page-props-factory/plugins/feaas-themes.ts +0 -16
  58. package/dist/templates/react/scripts/generate-component-builder/plugins/components.js +0 -28
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.transform = exports.diffAndWriteFiles = exports.diffFiles = exports.mergeEnv = exports.merge = exports.transformFilename = void 0;
38
+ exports.transform = exports.diffAndWriteFiles = exports.diffFiles = exports.concatEnv = exports.merge = exports.transformFilename = void 0;
39
39
  const chalk_1 = __importDefault(require("chalk"));
40
40
  const fs_extra_1 = __importDefault(require("fs-extra"));
41
41
  const glob_1 = __importDefault(require("glob"));
@@ -81,40 +81,19 @@ const merge = (targetObj, sourceObj) => {
81
81
  return mergeObject(targetObj, sourceObj);
82
82
  };
83
83
  exports.merge = merge;
84
- const mergeEnv = (targetContent, sourceContent) => {
85
- const sourceEnv = (0, dotenv_1.parse)(sourceContent);
86
- if (!sourceEnv || !Object.keys(sourceEnv).length)
87
- return targetContent;
88
- const targetEnv = (0, dotenv_1.parse)(targetContent);
89
- const sourceLines = sourceContent.split('\r\n');
90
- Object.keys(sourceEnv).forEach((sourceEnvVar) => {
91
- const isDuplicate = Object.keys(targetEnv).includes(sourceEnvVar);
92
- if (!isDuplicate)
93
- return;
94
- // Overriding value in a target .env file
95
- targetContent = targetContent.replace(new RegExp(`^${sourceEnvVar}=.*$`, 'gm'), `${sourceEnvVar}=${sourceEnv[sourceEnvVar]}`);
96
- // Removing duplicate variable and related comments in a source .env file,
97
- // since source and target will be concatenated
98
- let lineIndex = sourceLines.findIndex((line) => line.startsWith(sourceEnvVar));
99
- // remove empty lines after the definition
100
- while (sourceLines[lineIndex + 1] === '') {
101
- sourceLines.splice(lineIndex + 1, 1);
102
- }
103
- // remove definition and comments
104
- do {
105
- sourceLines.splice(lineIndex, 1);
106
- lineIndex--;
107
- } while (lineIndex >= 0 && sourceLines[lineIndex].startsWith('#'));
108
- });
109
- sourceContent = sourceLines.join('\r\n');
110
- // No variables left in a source
111
- if (!sourceContent)
84
+ const concatEnv = (targetContent, sourceContent) => {
85
+ const env = (0, dotenv_1.parse)(sourceContent);
86
+ if (env &&
87
+ Object.keys(env).length > 0 &&
88
+ Object.keys(env).every((value) => targetContent.includes(value))) {
89
+ // Don't add if the target already contains every .env value
112
90
  return targetContent;
91
+ }
113
92
  // NOTE we are enforcing CRLF for the repo in .gitattributes, so match it here
114
93
  const eol = '\r\n';
115
94
  return targetContent + eol + sourceContent;
116
95
  };
117
- exports.mergeEnv = mergeEnv;
96
+ exports.concatEnv = concatEnv;
118
97
  /**
119
98
  * @param {string} sourceFileContent transformed version of our template
120
99
  * @param {string} targetFilePath user's file path
@@ -242,8 +221,8 @@ const transform = (templatePath, answers, options = {}) => __awaiter(void 0, voi
242
221
  // read the current .env and the template .env (rendered with ejs)
243
222
  const currentDotEnv = fs_extra_1.default.readFileSync(path_1.default.resolve(process.cwd(), pathToNewFile), 'utf8');
244
223
  const templateDotEnv = yield (0, ejs_1.renderFile)(path_1.default.resolve(pathToTemplate), ejsData);
245
- // merge them and set the result to str which will then go through diff
246
- str = (0, exports.mergeEnv)(currentDotEnv, templateDotEnv);
224
+ // concatenate them and set the result to str which will then go through diff
225
+ str = (0, exports.concatEnv)(currentDotEnv, templateDotEnv);
247
226
  }
248
227
  str = str !== null && str !== void 0 ? str : (yield (0, ejs_1.renderFile)(path_1.default.resolve(pathToTemplate), ejsData));
249
228
  if (!answers.force) {
@@ -1,8 +1,5 @@
1
1
  # Sitecore JSS Angular Sample Application
2
2
 
3
- <!---
4
- @TODO: Update to next version docs before release
5
- -->
6
3
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-angular.html)
7
4
 
8
5
 
@@ -46,7 +46,12 @@
46
46
  ],
47
47
  "baseHref": "/",
48
48
  "aot": true,
49
- "optimization": true,
49
+ "//": [
50
+ "You might want to adjust the optimization entry to workaround a bug with bootstrap warnings caused by Angular",
51
+ "The warnings may occur during build and when running connected mode. Check below for possible fixes.",
52
+ "https://github.com/ng-bootstrap/ng-bootstrap/issues/4306"
53
+ ],
54
+ "optimization": "true",
50
55
  "outputHashing": "all",
51
56
  "sourceMap": false,
52
57
  "namedChunks": false,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "21.3.0-canary",
3
+ "version": "21.3.1",
4
4
  "description": "Application utilizing Sitecore JavaScript Services and Angular (angular-cli).",
5
5
  "config": {
6
6
  "appName": "<%- appName %>",
@@ -64,10 +64,10 @@
64
64
  "@apollo/client": "^3.3.12",
65
65
  "@ngx-translate/core": "~14.0.0",
66
66
  "@ngx-translate/http-loader": "~7.0.0",
67
- "@sitecore-jss/sitecore-jss-angular": "~21.3.0-canary",
67
+ "@sitecore-jss/sitecore-jss-angular": "~21.3.1",
68
68
  "apollo-angular": "~4.2.1",
69
69
  "bootstrap": "^5.3.1",
70
- "core-js": "~3.9.1",
70
+ "core-js": "~3.32.1",
71
71
  "graphql": "15.5.0",
72
72
  "graphql-tag": "~2.11.0",
73
73
  "lodash": "^4.17.21",
@@ -86,9 +86,9 @@
86
86
  "@angular/cli": "~15.2.9",
87
87
  "@angular/compiler-cli": "~15.2.9",
88
88
  "@angular/language-service": "~15.2.9",
89
- "@sitecore-jss/sitecore-jss-angular-schematics": "~21.3.0-canary",
90
- "@sitecore-jss/sitecore-jss-cli": "~21.3.0-canary",
91
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
89
+ "@sitecore-jss/sitecore-jss-angular-schematics": "~21.3.1",
90
+ "@sitecore-jss/sitecore-jss-cli": "~21.3.1",
91
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.1",
92
92
  "@types/isomorphic-fetch": "0.0.35",
93
93
  "@types/jasmine": "~3.6.7",
94
94
  "@types/jasminewd2": "~2.0.8",
@@ -19,7 +19,6 @@ export function generateConfig(configOverrides?: { [key: string]: unknown }, out
19
19
  sitecoreLayoutServiceConfig: 'jss',
20
20
  defaultLanguage: 'en',
21
21
  defaultServerRoute: '/',
22
- layoutServiceConfigurationName: 'default',
23
22
  };
24
23
 
25
24
  if (!outputPath) {
@@ -18,7 +18,7 @@ export class LayoutServiceFactory {
18
18
  apiHost: environment.sitecoreApiHost,
19
19
  apiKey: environment.sitecoreApiKey,
20
20
  siteName: environment.jssAppName,
21
- configurationName: environment.layoutServiceConfigurationName,
21
+ configurationName: 'default',
22
22
  });
23
23
  }
24
24
  }
@@ -3,7 +3,7 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "../out-tsc/app",
5
5
  "baseUrl": "./",
6
- "target": "es2016",
6
+ "target": "ES2022",
7
7
  "module": "commonjs",
8
8
  "newLine": "LF",
9
9
  "types": []
@@ -1,8 +1,5 @@
1
1
  # Sitecore JSS Next.js Sample Application
2
2
 
3
- <!---
4
- @TODO: Update to next version docs before release
5
- -->
6
3
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
7
4
 
8
5
  [Documentation (XM Cloud)](https://doc.sitecore.com/xmc/en/developers/xm-cloud/sitecore-javascript-rendering-sdk--jss--for-next-js.html)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
3
  "description": "Application utilizing Sitecore JavaScript Services and Next.js",
4
- "version": "21.3.0-canary",
4
+ "version": "21.3.1",
5
5
  "private": true,
6
6
  "config": {
7
7
  "appName": "<%- appName %>",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "license": "Apache-2.0",
31
31
  "dependencies": {
32
- "@sitecore-jss/sitecore-jss-nextjs": "~21.3.0-canary",
32
+ "@sitecore-jss/sitecore-jss-nextjs": "~21.3.1",
33
33
  "graphql": "~15.8.0",
34
34
  "graphql-tag": "^2.12.6",
35
35
  "next": "^13.1.6",
@@ -46,8 +46,8 @@
46
46
  "@graphql-codegen/typescript-operations": "^2.5.12",
47
47
  "@graphql-codegen/typescript-resolvers": "^2.7.12",
48
48
  "@graphql-typed-document-node/core": "^3.1.1",
49
- "@sitecore-jss/sitecore-jss-cli": "~21.3.0-canary",
50
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
49
+ "@sitecore-jss/sitecore-jss-cli": "~21.3.1",
50
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.1",
51
51
  "@types/node": "^18.11.18",
52
52
  "@types/react": "^18.0.12",
53
53
  "@types/react-dom": "^18.0.5",
@@ -11,7 +11,6 @@ export interface JssConfig extends Record<string, string | undefined> {
11
11
  graphQLEndpointPath?: string;
12
12
  defaultLanguage?: string;
13
13
  graphQLEndpoint?: string;
14
- layoutServiceConfigurationName?: string;
15
14
  }
16
15
 
17
16
  export interface ConfigPlugin {
@@ -11,8 +11,7 @@ class FallbackPlugin implements ConfigPlugin {
11
11
  async exec(config: JssConfig) {
12
12
  return Object.assign({}, config, {
13
13
  defaultLanguage: config.defaultLanguage || 'en',
14
- sitecoreApiKey: config.sitecoreApiKey || 'no-api-key-set',
15
- layoutServiceConfigurationName: config.layoutServiceConfigurationName || 'default',
14
+ sitecoreApiKey: config.sitecoreApiKey || 'no-api-key-set'
16
15
  });
17
16
  }
18
17
  }
@@ -1,11 +1,10 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-var-requires
2
2
  const plugins = require('scripts/temp/generate-component-builder-plugins');
3
- import { PackageDefinition, ComponentFile } from '@sitecore-jss/sitecore-jss-dev-tools';
3
+ import { PackageDefinition } from '@sitecore-jss/sitecore-jss-dev-tools';
4
4
 
5
5
  export interface ComponentBuilderPluginConfig {
6
6
  watch?: boolean;
7
7
  packages?: PackageDefinition[];
8
- components?: ComponentFile[];
9
8
  }
10
9
 
11
10
  export interface ComponentBuilderPlugin {
@@ -11,7 +11,7 @@ class ComponentBuilderPlugin implements ComponentBuilderPluginType {
11
11
  order = 9999;
12
12
 
13
13
  exec(config: ComponentBuilderPluginConfig) {
14
- generateComponentBuilder(config);
14
+ generateComponentBuilder({ packages: config.packages, watch: config.watch });
15
15
 
16
16
  return config;
17
17
  }
@@ -17,7 +17,6 @@ const defaultConfig: JssConfig = {
17
17
  graphQLEndpointPath: process.env[`${constantCase('graphQLEndpointPath')}`],
18
18
  defaultLanguage: process.env[`${constantCase('defaultLanguage')}`],
19
19
  graphQLEndpoint: process.env[`${constantCase('graphQLEndpoint')}`],
20
- layoutServiceConfigurationName: process.env[`${constantCase('layoutServiceConfigurationName')}`],
21
20
  };
22
21
 
23
22
  generateConfig(defaultConfig);
@@ -1,6 +1,4 @@
1
1
  import { ModuleType, generatePlugins } from '@sitecore-jss/sitecore-jss-dev-tools';
2
- import generateComponentSrc from 'scripts/templates/component-src';
3
- import chalk from 'chalk';
4
2
 
5
3
  generatePlugins({
6
4
  distPath: 'scripts/temp/scaffold-component-plugins.ts',
@@ -30,8 +28,6 @@ export interface ScaffoldComponentPluginConfig {
30
28
  [key: string]: unknown;
31
29
  componentName: string;
32
30
  componentPath: string;
33
- componentTemplateGenerator: (componentName: string) => string;
34
- args: string[];
35
31
  nextSteps: string[];
36
32
  }
37
33
 
@@ -49,9 +45,8 @@ export interface ScaffoldComponentPlugin {
49
45
 
50
46
  // Matches component names that start with a capital letter, and contain only letters, number,
51
47
  // underscores, or dashes. Optionally, the component name can be preceded by a relative path
52
- const nameParamFormat = new RegExp(/^((?:[\w\-]+\/)*)([A-Z][\w-]+)$/);
48
+ const nameParamFormat = new RegExp(/^((?:[\w-]+\/)*)([A-Z][\w-]+)$/);
53
49
  const componentArg = process.argv[2];
54
- const args = process.argv.slice(3);
55
50
 
56
51
  if (!componentArg) {
57
52
  throw 'Component name was not passed. Usage: jss scaffold <ComponentName>';
@@ -67,18 +62,9 @@ dashes, or underscores. If specifying a path, it must be relative to src/compone
67
62
  const defaultConfig: ScaffoldComponentPluginConfig = {
68
63
  componentPath: regExResult[1],
69
64
  componentName: regExResult[2],
70
- componentTemplateGenerator: generateComponentSrc,
71
- args: args,
72
65
  nextSteps: [],
73
66
  };
74
67
 
75
- // default entry in next steps
76
- defaultConfig.nextSteps.push(
77
- chalk.green(`
78
- Scaffolding of ${defaultConfig.componentName} complete.
79
- Next steps:`)
80
- );
81
-
82
68
  const config = (Object.values(plugins) as ScaffoldComponentPlugin[])
83
69
  .sort((p1, p2) => p1.order - p2.order)
84
70
  .reduce((config, plugin) => plugin.exec(config), defaultConfig);
@@ -1,19 +1,21 @@
1
1
  import path from 'path';
2
2
  import { scaffoldFile } from '@sitecore-jss/sitecore-jss-dev-tools';
3
+ import generateComponentSrc from 'scripts/templates/component-src';
3
4
  import { ScaffoldComponentPlugin, ScaffoldComponentPluginConfig } from '..';
4
5
 
5
6
  /**
6
7
  * Generates the component file.
7
8
  */
8
9
  class ComponentPlugin implements ScaffoldComponentPlugin {
9
- order = 99;
10
+ order = 0;
11
+
12
+ componentRootPath = 'src/components';
10
13
 
11
14
  exec(config: ScaffoldComponentPluginConfig) {
12
15
  const { componentName, componentPath } = config;
13
16
  const filename = `${componentName}.tsx`;
14
- const componentRoot = componentPath.startsWith('src/') ? '' : 'src/components';
15
- const outputFilePath = path.join(componentRoot, componentPath, filename);
16
- const template = config.componentTemplateGenerator(componentName);
17
+ const outputFilePath = path.join(this.componentRootPath, componentPath, filename);
18
+ const template = generateComponentSrc(componentName);
17
19
 
18
20
  const componentOutputPath = scaffoldFile(outputFilePath, template);
19
21
 
@@ -12,16 +12,12 @@ class NextStepsPlugin implements ScaffoldComponentPlugin {
12
12
 
13
13
  if (componentOutputPath) {
14
14
  config.nextSteps.push(
15
+ chalk.green(`
16
+ Scaffolding of ${componentName} complete.
17
+ Next steps:`),
15
18
  `* Implement the React component in ${chalk.green(componentOutputPath)}`
16
19
  );
17
20
  }
18
- if (!(componentOutputPath as string).includes('src\\components')) {
19
- config.nextSteps.push(
20
- `* ${chalk.green(
21
- componentName
22
- )} has been created outside src\\components. Ensure it is registered via scripts\\generate-component-builder.`
23
- );
24
- }
25
21
 
26
22
  return config;
27
23
  }
@@ -25,7 +25,7 @@ export class LayoutServiceFactory {
25
25
  apiHost: config.sitecoreApiHost,
26
26
  apiKey: config.sitecoreApiKey,
27
27
  siteName,
28
- configurationName: config.layoutServiceConfigurationName,
28
+ configurationName: 'default',
29
29
  });
30
30
  }
31
31
  }
@@ -1,6 +1,5 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import type { NextFetchEvent, NextRequest } from 'next/server';
3
- import { debug } from '@sitecore-jss/sitecore-jss-nextjs/middleware';
4
3
  import * as plugins from 'temp/middleware-plugins';
5
4
 
6
5
  export interface MiddlewarePlugin {
@@ -20,15 +19,7 @@ export default async function middleware(
20
19
  ): Promise<NextResponse> {
21
20
  const response = NextResponse.next();
22
21
 
23
- debug.common('next middleware start');
24
-
25
- const start = Date.now();
26
-
27
- const finalRes = await (Object.values(plugins) as MiddlewarePlugin[])
22
+ return (Object.values(plugins) as MiddlewarePlugin[])
28
23
  .sort((p1, p2) => p1.order - p2.order)
29
24
  .reduce((p, plugin) => p.then((res) => plugin.exec(req, res, ev)), Promise.resolve(response));
30
-
31
- debug.common('next middleware end in %dms', Date.now() - start);
32
-
33
- return finalRes;
34
25
  }
@@ -1,5 +1,4 @@
1
1
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
- import { debug } from '@sitecore-jss/sitecore-jss-nextjs';
3
2
  import { SitecorePageProps } from 'lib/page-props';
4
3
  import * as plugins from 'temp/page-props-factory-plugins';
5
4
 
@@ -36,9 +35,6 @@ export class SitecorePagePropsFactory {
36
35
  public async create(
37
36
  context: GetServerSidePropsContext | GetStaticPropsContext
38
37
  ): Promise<SitecorePageProps> {
39
- const startTimestamp = Date.now();
40
- debug.common('page-props-factory start');
41
-
42
38
  const extendedProps = await (Object.values(plugins) as Plugin[])
43
39
  .sort((p1, p2) => p1.order - p2.order)
44
40
  .reduce(async (result, plugin) => {
@@ -47,8 +43,6 @@ export class SitecorePagePropsFactory {
47
43
  return newProps;
48
44
  }, Promise.resolve({} as SitecorePageProps));
49
45
 
50
- debug.common('page-props-factory end in %dms', Date.now() - startTimestamp);
51
-
52
46
  return extendedProps;
53
47
  }
54
48
  }
@@ -1,4 +1,4 @@
1
- import { ComponentPropsService, ComponentPropsError } from '@sitecore-jss/sitecore-jss-nextjs';
1
+ import { ComponentPropsService } from '@sitecore-jss/sitecore-jss-nextjs';
2
2
  import { SitecorePageProps } from 'lib/page-props';
3
3
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
4
4
  import { moduleFactory } from 'temp/componentBuilder';
@@ -31,20 +31,6 @@ class ComponentPropsPlugin implements Plugin {
31
31
  });
32
32
  }
33
33
 
34
- const errors = Object.keys(props.componentProps)
35
- .map(id => {
36
- const component = props.componentProps[id] as ComponentPropsError;
37
-
38
- return component.error
39
- ? `\nUnable to get component props for ${component.componentName} (${id}): ${component.error}`
40
- : '';
41
- })
42
- .join('');
43
-
44
- if (errors.length) {
45
- throw new Error(errors);
46
- }
47
-
48
34
  return props;
49
35
  }
50
36
  }
@@ -1,4 +1,5 @@
1
1
  import { EditingDataMiddleware } from '@sitecore-jss/sitecore-jss-nextjs/editing';
2
+
2
3
  /**
3
4
  * This Next.js API route is used to handle Sitecore editor data storage and retrieval by key
4
5
  * on serverless deployment architectures (e.g. Vercel) via the `ServerlessEditingDataService`.
@@ -14,12 +14,6 @@ import { EditingRenderMiddleware } from '@sitecore-jss/sitecore-jss-nextjs/editi
14
14
  * 5. Return the rendered page HTML to the Sitecore editor
15
15
  */
16
16
 
17
- /**
18
- * For Vercel deployments:
19
- * if you experience crashes in editing, you may need to use VercelEditingDataCache or a custom Redis data cache implementation with EditingRenderMiddleware
20
- * Please refer to documentation for a detailed guide.
21
- */
22
-
23
17
  // Bump body size limit (1mb by default) and disable response limit for Sitecore editor payloads
24
18
  // See https://nextjs.org/docs/api-routes/request-helpers#custom-config
25
19
  export const config = {
@@ -4,7 +4,7 @@
4
4
  "nprogress": "~0.2.0"
5
5
  },
6
6
  "devDependencies": {
7
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
7
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.2.2",
8
8
  "@types/nprogress": "^0.2.0"
9
9
  },
10
10
  "scripts": {
@@ -4,11 +4,17 @@ import { ScaffoldComponentPlugin, ScaffoldComponentPluginConfig } from '..';
4
4
  /**
5
5
  * Set next steps.
6
6
  */
7
- class NextStepsStyleguidePlugin implements ScaffoldComponentPlugin {
8
- order = 101;
7
+ class NextStepsPlugin implements ScaffoldComponentPlugin {
8
+ order = 100;
9
9
 
10
10
  exec(config: ScaffoldComponentPluginConfig) {
11
- const { manifestOutputPath, componentName } = config;
11
+ const { componentOutputPath, manifestOutputPath, componentName } = config;
12
+
13
+ config.nextSteps.push(
14
+ chalk.green(`
15
+ Scaffolding of ${componentName} complete.
16
+ Next steps:`)
17
+ );
12
18
 
13
19
  if (manifestOutputPath) {
14
20
  config.nextSteps.push(`* Define the component's data in ${chalk.green(manifestOutputPath)}`);
@@ -19,6 +25,9 @@ class NextStepsStyleguidePlugin implements ScaffoldComponentPlugin {
19
25
  )}, or create the rendering item and datasource template yourself.`
20
26
  );
21
27
  }
28
+ if (componentOutputPath) {
29
+ config.nextSteps.push(`* Implement the React component in ${chalk.green(componentOutputPath)}`);
30
+ }
22
31
  if (manifestOutputPath) {
23
32
  config.nextSteps.push(
24
33
  `* Add the component to a route layout (/data/routes) and test it with ${chalk.green(
@@ -38,4 +47,4 @@ class NextStepsStyleguidePlugin implements ScaffoldComponentPlugin {
38
47
  }
39
48
  }
40
49
 
41
- export const nextStepsStyleguidePlugin = new NextStepsStyleguidePlugin();
50
+ export const nextStepsPlugin = new NextStepsPlugin();
@@ -7,6 +7,6 @@
7
7
  "sass-alias": "^1.0.5"
8
8
  },
9
9
  "scripts": {
10
- "scaffold": "ts-node --project tsconfig.scripts.json scripts/scaffold-component/index.ts"
10
+ "scaffold": "ts-node --project tsconfig.scripts.json scripts/scaffold-component.ts"
11
11
  }
12
12
  }
@@ -16,33 +16,3 @@
16
16
  }
17
17
  }
18
18
  }
19
-
20
- .hero-banner {
21
- .component-content {
22
- background-position: center;
23
- background-repeat: no-repeat;
24
- background-size: cover;
25
- height: 800px;
26
-
27
- @include respond-to(mobile-large) {
28
- height: 300px;
29
- }
30
- }
31
- .sc-image-wrapper {
32
- opacity: 0;
33
- }
34
- &.scEnabledChrome {
35
- &.hero-banner-empty {
36
- .sc-image-wrapper {
37
- display: block;
38
- width: 100%;
39
-
40
- .scEmptyImage {
41
- max-height: 800px;
42
- max-width: 100%;
43
- width: 100%;
44
- }
45
- }
46
- }
47
- }
48
- }
@@ -100,7 +100,3 @@ ul li {
100
100
  color:#fff;
101
101
  max-width: 500px;
102
102
  }
103
-
104
- .editing-mode {
105
- padding: 0 8px;
106
- }
@@ -0,0 +1,15 @@
1
+ .hero-banner {
2
+ .component-content {
3
+ background-position: center;
4
+ background-repeat: no-repeat;
5
+ background-size: cover;
6
+ height: 800px;
7
+
8
+ @include respond-to(mobile-large) {
9
+ height: 300px;
10
+ }
11
+ }
12
+ .sc-image-wrapper {
13
+ opacity: 0;
14
+ }
15
+ }
@@ -1 +1,2 @@
1
1
  @import "image-default-size";
2
+ @import "image-banner";
@@ -30,11 +30,6 @@ const ImageDefault = (props: ImageProps): JSX.Element => (
30
30
 
31
31
  export const Banner = (props: ImageProps): JSX.Element => {
32
32
  const { sitecoreContext } = useSitecoreContext();
33
- const isPageEditing = sitecoreContext.pageEditing;
34
- const classHeroBannerEmpty =
35
- isPageEditing && props.fields?.Image?.value?.class === 'scEmptyImage'
36
- ? 'hero-banner-empty'
37
- : '';
38
33
  const backgroundStyle = { backgroundImage: `url('${props?.fields?.Image?.value?.src}')` };
39
34
  const modifyImageProps = {
40
35
  ...props.fields.Image,
@@ -45,10 +40,7 @@ export const Banner = (props: ImageProps): JSX.Element => {
45
40
  const id = props.params.RenderingIdentifier;
46
41
 
47
42
  return (
48
- <div
49
- className={`component hero-banner ${props.params.styles} ${classHeroBannerEmpty}`}
50
- id={id ? id : undefined}
51
- >
43
+ <div className={`component hero-banner ${props.params.styles}`} id={id ? id : undefined}>
52
44
  <div className="component-content sc-sxa-image-hero-banner" style={backgroundStyle}>
53
45
  {sitecoreContext.pageEditing ? <JssImage field={modifyImageProps} /> : ''}
54
46
  </div>
@@ -66,7 +58,7 @@ export const Default = (props: ImageProps): JSX.Element => {
66
58
  return (
67
59
  <div className={`component image ${props.params.styles}`} id={id ? id : undefined}>
68
60
  <div className="component-content">
69
- {sitecoreContext.pageState === 'edit' || !props.fields.TargetUrl?.value?.href ? (
61
+ {sitecoreContext.pageState === 'edit' ? (
70
62
  <Image />
71
63
  ) : (
72
64
  <JssLink field={props.fields.TargetUrl}>
@@ -4,7 +4,8 @@ import { siteResolver } from 'lib/site-resolver';
4
4
  import config from 'temp/config';
5
5
 
6
6
  const robotsApi = async (req: NextApiRequest, res: NextApiResponse): Promise<void> => {
7
- res.setHeader('Content-Type', 'text/plain');
7
+ // Ensure response is text/html
8
+ res.setHeader('Content-Type', 'text/html;charset=utf-8');
8
9
 
9
10
  // Resolve site based on hostname
10
11
  const hostName = req.headers['host']?.split(':')[0] || 'localhost';
@@ -2,10 +2,6 @@
2
2
 
3
3
  Sitecore JSS for SSR using Experience Edge is considered experimental.
4
4
 
5
- <!---
6
- @TODO: Update to next version docs before release
7
- -->
8
-
9
5
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/server-side-render-jss-apps-headlessly-using-a-sitecore-experience-edge-endpoint.html)
10
6
 
11
7
  > This is a sample setup that is not officially supported by Sitecore.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-headless-ssr-experience-edge-sample",
3
- "version": "21.3.0-canary",
3
+ "version": "21.3.1",
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"
@@ -23,7 +23,7 @@
23
23
  "homepage": "https://jss.sitecore.com",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@sitecore-jss/sitecore-jss": "~21.3.0-canary",
26
+ "@sitecore-jss/sitecore-jss": "~21.3.1",
27
27
  "compression": "^1.7.4",
28
28
  "express": "^4.18.2",
29
29
  "dotenv": "^16.0.3"
@@ -4,10 +4,6 @@ This is a sample setup showing one one of how you can configure rendering server
4
4
 
5
5
  The setup is using `sitecore-jss-proxy` that enables request proxying to Sitecore CD along with the http cookies to enable tracking, personalization and contact identification.
6
6
 
7
- <!---
8
- @TODO: Update to next version docs before release
9
- -->
10
-
11
7
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/walkthrough--rendering-a-jss-app-server-side-using-the-headless-jss-proxy.html)
12
8
 
13
9
  > This is a sample setup that is not officially supported by Sitecore.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-headless-ssr-proxy-sample",
3
- "version": "21.3.0-canary",
3
+ "version": "21.3.1",
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"
@@ -23,8 +23,8 @@
23
23
  "homepage": "https://jss.sitecore.com",
24
24
  "license": "Apache-2.0",
25
25
  "dependencies": {
26
- "@sitecore-jss/sitecore-jss": "~21.3.0-canary",
27
- "@sitecore-jss/sitecore-jss-proxy": "~21.3.0-canary",
26
+ "@sitecore-jss/sitecore-jss": "~21.3.1",
27
+ "@sitecore-jss/sitecore-jss-proxy": "~21.3.1",
28
28
  "agentkeepalive": "^4.2.1",
29
29
  "compression": "~1.7.4",
30
30
  "express": "~4.18.2",
@@ -1,8 +1,5 @@
1
1
  # Sitecore JSS React Sample Application
2
2
 
3
- <!---
4
- @TODO: Update to next version docs before release
5
- -->
6
3
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-react.html)
7
4
 
8
5
  ## Disconnected Sitecore-less Development
@@ -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": "21.3.0-canary",
4
+ "version": "21.3.1",
5
5
  "private": true,
6
6
  "config": {
7
7
  "appName": "<%- appName %>",
@@ -32,7 +32,7 @@
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
34
  "@apollo/client": "^3.7.1",
35
- "@sitecore-jss/sitecore-jss-react": "~21.3.0-canary",
35
+ "@sitecore-jss/sitecore-jss-react": "~21.3.1",
36
36
  "axios": "^1.2.0",
37
37
  "bootstrap": "^5.2.3",
38
38
  "cross-fetch": "^3.1.5",
@@ -57,9 +57,9 @@
57
57
  "@babel/preset-env": "^7.20.2",
58
58
  "@babel/preset-react": "^7.18.6",
59
59
  "@babel/register": "~7.18.9",
60
- "@sitecore-jss/sitecore-jss-cli": "~21.3.0-canary",
61
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
62
- "@sitecore-jss/sitecore-jss-rendering-host": "~21.3.0-canary",
60
+ "@sitecore-jss/sitecore-jss-cli": "~21.3.1",
61
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.1",
62
+ "@sitecore-jss/sitecore-jss-rendering-host": "~21.3.1",
63
63
  "babel-loader": "~9.1.0",
64
64
  "babel-preset-react-app": "~10.0.1",
65
65
  "chalk": "~4.1.2",
@@ -11,7 +11,6 @@ class FallbackPlugin {
11
11
  defaultLanguage: config.defaultLanguage || 'en',
12
12
  sitecoreApiKey: config.sitecoreApiKey || 'no-api-key-set',
13
13
  jssAppName: config.jssAppName || 'Unknown',
14
- layoutServiceConfigurationName: config.layoutServiceConfigurationName || 'default',
15
14
  });
16
15
  }
17
16
  }
@@ -7,7 +7,7 @@ class ComponentBuilderPlugin {
7
7
  order = 9999;
8
8
 
9
9
  exec(config) {
10
- generateComponentBuilder(config);
10
+ generateComponentBuilder({ packages: config.packages, watch: config.watch });
11
11
  }
12
12
  }
13
13
 
@@ -16,7 +16,6 @@ const defaultConfig = {
16
16
  graphQLEndpointPath: process.env[`${constantCase('reactAppGraphQLEndpointPath')}`],
17
17
  defaultLanguage: process.env[`${constantCase('reactAppDefaultLanguage')}`],
18
18
  graphQLEndpoint: process.env[`${constantCase('reactAppGraphQLEndpoint')}`],
19
- layoutServiceConfigurationName: process.env[`${constantCase('reactAppLayoutServiceConfigurationName')}`],
20
19
  };
21
20
 
22
21
  generateConfig()
@@ -17,7 +17,7 @@ export class LayoutServiceFactory {
17
17
  apiHost: config.sitecoreApiHost,
18
18
  apiKey: config.sitecoreApiKey,
19
19
  siteName: config.jssAppName,
20
- configurationName: config.layoutServiceConfigurationName,
20
+ configurationName: 'default',
21
21
  });
22
22
  }
23
23
  }
@@ -1,8 +1,5 @@
1
1
  # Sitecore JSS React Native Sample Application
2
2
 
3
- <!---
4
- @TODO: Update to next version docs before release
5
- -->
6
3
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-react-native.html)
7
4
 
8
5
  ## Note
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "21.3.0-canary",
3
+ "version": "21.3.1",
4
4
  "description": "A basic React Native app utilizing Sitecore JavaScript Services",
5
5
  "config": {
6
6
  "appName": "<%- appName %>",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@react-native-community/masked-view": "^0.1.10",
30
- "@sitecore-jss/sitecore-jss-react-native": "~21.3.0-canary",
30
+ "@sitecore-jss/sitecore-jss-react-native": "~21.3.1",
31
31
  "prop-types": "^15.6.0",
32
32
  "react": "16.13.1",
33
33
  "react-native": "^0.63.4",
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "private": true,
43
43
  "devDependencies": {
44
- "@sitecore-jss/sitecore-jss-cli": "~21.3.0-canary",
45
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
44
+ "@sitecore-jss/sitecore-jss-cli": "~21.3.1",
45
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.1",
46
46
  "babel-core": "^6.26.0",
47
47
  "babel-eslint": "^8.2.1",
48
48
  "babel-plugin-inline-replace-variables": "^1.3.1",
@@ -1,8 +1,5 @@
1
1
  # Sitecore JSS Vue.js Sample Application
2
2
 
3
- <!---
4
- @TODO: Update to next version docs before release
5
- -->
6
3
  [Documentation (Experience Platform)](https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/sitecore-javascript-rendering-sdk--jss--for-vue-js.html)
7
4
 
8
5
  ## Project setup
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "21.3.0-canary",
3
+ "version": "21.3.1",
4
4
  "description": "Application utilizing Sitecore JavaScript Services and Vue (vue-cli).",
5
5
  "private": true,
6
6
  "config": {
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "@apollo/client": "^3.7.4",
51
51
  "@panter/vue-i18next": "~0.15.2",
52
- "@sitecore-jss/sitecore-jss-vue": "~21.3.0-canary",
52
+ "@sitecore-jss/sitecore-jss-vue": "~21.3.1",
53
53
  "@vue/apollo-composable": "4.0.0-beta.2",
54
54
  "@vue/apollo-option": "^4.0.0-alpha.20",
55
55
  "@vue/apollo-ssr": "^4.0.0-alpha.18",
@@ -68,8 +68,8 @@
68
68
  "devDependencies": {
69
69
  "@babel/eslint-parser": "^7.19.1",
70
70
  "@babel/register": "7.18.9",
71
- "@sitecore-jss/sitecore-jss-cli": "~21.3.0-canary",
72
- "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.0-canary",
71
+ "@sitecore-jss/sitecore-jss-cli": "~21.3.1",
72
+ "@sitecore-jss/sitecore-jss-dev-tools": "~21.3.1",
73
73
  "@vue/cli-plugin-babel": "~5.0.8",
74
74
  "@vue/cli-plugin-eslint": "~5.0.8",
75
75
  "@vue/cli-service": "~5.0.8",
@@ -81,14 +81,13 @@
81
81
  "cross-env": "~7.0.3",
82
82
  "dotenv": "^16.0.3",
83
83
  "eslint": "^8.32.0",
84
- "eslint-plugin-prettier": "^5.0.0",
84
+ "eslint-plugin-prettier": "^4.2.1",
85
85
  "eslint-plugin-vue": "~9.9.0",
86
86
  "eslint-plugin-yaml": "^0.5.0",
87
87
  "graphql-tag": "^2.12.6",
88
88
  "html-loader": "~1.3.2",
89
89
  "npm-run-all": "~4.1.5",
90
90
  "null-loader": "~4.0.1",
91
- "prettier": "^3.0.0",
92
91
  "tslib": "2.5.1"
93
92
  }
94
93
  }
@@ -18,7 +18,6 @@ module.exports = function generateConfig(configOverrides) {
18
18
  sitecoreApiKey: 'no-api-key-set',
19
19
  sitecoreApiHost: '',
20
20
  jssAppName: 'Unknown',
21
- layoutServiceConfigurationName: 'default',
22
21
  };
23
22
 
24
23
  // require + combine config sources
@@ -13,7 +13,7 @@ export class LayoutServiceFactory {
13
13
  apiHost: config.sitecoreApiHost,
14
14
  apiKey: config.sitecoreApiKey,
15
15
  siteName: config.jssAppName,
16
- configurationName: config.layoutServiceConfigurationName,
16
+ configurationName: 'default',
17
17
  });
18
18
  }
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sitecore-jss",
3
- "version": "21.3.0",
3
+ "version": "21.3.1",
4
4
  "description": "Sitecore JSS initializer",
5
5
  "bin": "./dist/index.js",
6
6
  "scripts": {
@@ -64,5 +64,5 @@
64
64
  "ts-node": "^10.9.1",
65
65
  "typescript": "~4.9.5"
66
66
  },
67
- "gitHead": "a01a4693a0c1c4b58d74595a3591277b00e9d2cf"
67
+ "gitHead": "973fe436c7fe943ec07123b315fadbe72313a945"
68
68
  }
@@ -1,30 +0,0 @@
1
- import { ComponentBuilderPlugin, ComponentBuilderPluginConfig } from '..';
2
-
3
- /**
4
- * Provides custom components configuration
5
- */
6
- class ComponentsPlugin implements ComponentBuilderPlugin {
7
- order = 0;
8
-
9
- exec(config: ComponentBuilderPluginConfig) {
10
- /**
11
- * You can specify components which you want to import using custom path in format:
12
- * {
13
- * path: string; // path to component
14
- * moduleName: string; // module name to import
15
- * componentName: 'component name'; // component rendering name
16
- * }
17
- *
18
- * Or you can register all components from a path using the below approach:
19
- * import { getComponentList } from '@sitecore-jss/sitecore-jss-dev-tools';
20
- * ...
21
- * const componentsPath = 'src/extra';
22
- * config.components = getComponentList(componentsPath);
23
- */
24
- config.components = [];
25
-
26
- return config;
27
- }
28
- }
29
-
30
- export const componentsPlugin = new ComponentsPlugin();
@@ -1,22 +0,0 @@
1
- const config = require('../../../temp/config');
2
-
3
- /**
4
- * @param {import('next').NextConfig} nextConfig
5
- */
6
- const corsHeaderPlugin = (nextConfig = {}) => {
7
- if (!config.sitecoreApiHost) {
8
- return nextConfig;
9
- }
10
- return Object.assign({}, nextConfig, {
11
- async headers() {
12
- return [
13
- {
14
- source: '/_next/:path*',
15
- headers: [{ key: 'Access-Control-Allow-Origin', value: config.sitecoreApiHost }],
16
- },
17
- ];
18
- },
19
- });
20
- };
21
-
22
- module.exports = corsHeaderPlugin;
@@ -1,17 +0,0 @@
1
- import { ConfigPlugin, JssConfig } from '..';
2
-
3
- /**
4
- * This plugin will set configuration specific for SXA.
5
- */
6
- class SXAPlugin implements ConfigPlugin {
7
- // should come before fallback
8
- order = 1;
9
-
10
- async exec(config: JssConfig) {
11
- return Object.assign({}, config, {
12
- layoutServiceConfigurationName: 'sxa-jss',
13
- });
14
- }
15
- }
16
-
17
- export const sxaPlugin = new SXAPlugin();
@@ -1,19 +0,0 @@
1
- import { ScaffoldComponentPlugin, ScaffoldComponentPluginConfig } from '..';
2
- import generateByocComponentSrc from 'scripts/templates/byoc-component-src';
3
-
4
- /**
5
- * Sets up generation for BYOC components
6
- */
7
- class ByocPlugin implements ScaffoldComponentPlugin {
8
- order = 0;
9
-
10
- exec(config: ScaffoldComponentPluginConfig) {
11
- if (config.args.includes('--byoc')) {
12
- config.componentTemplateGenerator = generateByocComponentSrc;
13
- }
14
-
15
- return config;
16
- }
17
- }
18
-
19
- export const byocPlugin = new ByocPlugin();
@@ -1,20 +0,0 @@
1
- import { ScaffoldComponentPlugin, ScaffoldComponentPluginConfig } from '..';
2
-
3
- /**
4
- * Set next steps for BYOC component.
5
- */
6
- class NextStepsByocPlugin implements ScaffoldComponentPlugin {
7
- order = 101;
8
-
9
- exec(config: ScaffoldComponentPluginConfig) {
10
- if (config.args.includes('--byoc')) {
11
- config.nextSteps.push(
12
- `* Modify component registration through FEAAS.External.registerComponent if needed`
13
- );
14
- }
15
-
16
- return config;
17
- }
18
- }
19
-
20
- export const nextStepsByocPlugin = new NextStepsByocPlugin();
@@ -1,49 +0,0 @@
1
- /**
2
- * Generates React boilerplate for a component under `src/components`
3
- * @param componentName - the component name
4
- * @returns component src boilerplate as a string
5
- */
6
- function generateComponentSrc(componentName: string): string {
7
- return `import React from 'react';
8
- import * as FEAAS from '@sitecore-feaas/clientside/react';
9
-
10
- interface ${componentName}Props {
11
- title: string;
12
- columnsCount: number;
13
- }
14
-
15
- export const ${componentName} = (props: ${componentName}Props): JSX.Element => {
16
- const columns: string[] = [];
17
- for (let i = 0; i < props.columnsCount; i++) {
18
- columns.push(\`Component Column \${i + 1}\`);
19
- }
20
- return (
21
- <div className="container">
22
- <h2>{props.title || 'BYOC Demo'}</h2>
23
- <p>${componentName} Component</p>
24
- <div className="row">
25
- {columns.map((text, index) => (
26
- <div key={index} className={\`col-sm-\${props.columnsCount}\`}>
27
- {text}
28
- </div>
29
- ))}
30
- </div>
31
- </div>
32
- );
33
- };
34
-
35
- FEAAS.External.registerComponent(${componentName}, {
36
- name: '${componentName}',
37
- properties: {
38
- title: {
39
- type: 'string',
40
- },
41
- columnsCount: {
42
- type: 'number',
43
- },
44
- },
45
- });
46
- `;
47
- }
48
-
49
- export default generateComponentSrc;
@@ -1,19 +0,0 @@
1
- import { BYOCProps, BYOCRenderer } from '@sitecore-jss/sitecore-jss-nextjs';
2
- import React from 'react';
3
- import * as FEAAS from '@sitecore-feaas/clientside/react';
4
-
5
- export const Default = (props: BYOCProps): JSX.Element => {
6
- const styles = props.params?.styles?.trimEnd();
7
- const id = props.params?.RenderingIdentifier;
8
- const rendererProps = {
9
- components: FEAAS.External.registered,
10
- ...props,
11
- };
12
- return (
13
- <div className={styles ? styles : undefined} id={id ? id : undefined}>
14
- <div className="component-content">
15
- <BYOCRenderer {...rendererProps} />
16
- </div>
17
- </div>
18
- );
19
- };
@@ -1,16 +0,0 @@
1
- import { SitecorePageProps } from 'lib/page-props';
2
- import { getFEAASLibraryStylesheetLinks } from '@sitecore-jss/sitecore-jss-nextjs';
3
- import { Plugin } from '..';
4
-
5
- class FEeaSThemesPlugin implements Plugin {
6
- order = 2;
7
-
8
- async exec(props: SitecorePageProps) {
9
- // Collect FEAAS themes
10
- props.headLinks.push(...getFEAASLibraryStylesheetLinks(props.layoutData));
11
-
12
- return props;
13
- }
14
- }
15
-
16
- export const feaasThemesPlugin = new FEeaSThemesPlugin();
@@ -1,28 +0,0 @@
1
- /**
2
- * Provides custom components configuration
3
- */
4
- class ComponentsPlugin {
5
- order = 0;
6
-
7
- exec(config) {
8
- /**
9
- * You can specify components which you want to import using custom path in format:
10
- * {
11
- * path: string; // path to component
12
- * moduleName: string; // module name to import
13
- * componentName: 'component name'; // component rendering name
14
- * }
15
- *
16
- * Or you can register all components from a path using the below approach:
17
- * const { getComponentList } = require('@sitecore-jss/sitecore-jss-dev-tools');
18
- * ...
19
- * const componentsPath = 'src/extra';
20
- * config.components = getComponentList(componentsPath);
21
- */
22
- config.components = [];
23
-
24
- return config;
25
- }
26
- }
27
-
28
- module.exports = new ComponentsPlugin();