create-sitecore-jss 22.2.0-canary.9 → 22.3.0-canary.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 (129) hide show
  1. package/dist/bin.js +17 -43
  2. package/dist/common/processes/next.js +4 -1
  3. package/dist/common/processes/transform.js +2 -12
  4. package/dist/common/prompts/base.js +0 -13
  5. package/dist/common/prompts/proxy.js +35 -0
  6. package/dist/common/prompts/sxp.js +16 -2
  7. package/dist/common/utils/helpers.js +27 -2
  8. package/dist/init-runner.js +1 -1
  9. package/dist/initializers/angular/prompts.js +4 -4
  10. package/dist/initializers/angular-xmcloud/index.js +21 -7
  11. package/dist/initializers/node-xmcloud-proxy/index.js +2 -1
  12. package/dist/templates/angular/.env +4 -5
  13. package/dist/templates/angular/.eslintrc +1 -0
  14. package/dist/templates/angular/gitignore +5 -0
  15. package/dist/templates/angular/package.json +6 -8
  16. package/dist/templates/angular/scripts/config/plugins/fallback.ts +0 -1
  17. package/dist/templates/angular/scripts/generate-component-factory/index.ts +45 -0
  18. package/dist/templates/angular/scripts/generate-component-factory/plugins/component-factory.ts +147 -0
  19. package/dist/templates/angular/scripts/generate-component-factory/plugins/components.ts +19 -0
  20. package/dist/templates/angular/scripts/generate-component-factory/plugins/packages.ts +29 -0
  21. package/dist/templates/angular/scripts/generate-component-factory/template.ts +46 -0
  22. package/dist/templates/angular/scripts/generate-config.ts +25 -6
  23. package/dist/templates/angular/scripts/generate-plugins.ts +5 -0
  24. package/dist/templates/angular/scripts/update-graphql-fragment-data.ts +21 -30
  25. package/dist/templates/angular/server.bundle.ts +3 -23
  26. package/dist/templates/angular/server.exports.ts +13 -0
  27. package/dist/templates/angular/src/app/JssState.ts +2 -9
  28. package/dist/templates/angular/src/app/app.module.ts +5 -4
  29. package/dist/templates/angular/src/app/app.server.module.ts +9 -6
  30. package/dist/templates/angular/src/app/components/gitignore +1 -1
  31. package/dist/templates/angular/src/app/i18n/jss-translation-client-loader.service.ts +15 -7
  32. package/dist/templates/angular/src/app/i18n/jss-translation-server-loader.service.ts +14 -2
  33. package/dist/templates/angular/src/app/jss-context.server-side.service.ts +4 -2
  34. package/dist/templates/angular/src/app/jss-context.service.ts +14 -11
  35. package/dist/templates/angular/src/app/jss-graphql.service.ts +7 -7
  36. package/dist/templates/angular/src/app/layout/jss-layout.service.ts +2 -2
  37. package/dist/templates/angular/src/app/lib/dictionary-service-factory.ts +4 -1
  38. package/dist/templates/angular/src/app/lib/graphql-client-factory/config.ts +21 -0
  39. package/dist/templates/angular/src/app/lib/graphql-client-factory/index.ts +16 -0
  40. package/dist/templates/angular/src/app/lib/layout-service-factory.ts +1 -1
  41. package/dist/templates/angular/src/app/routing/layout/layout.component.ts +10 -9
  42. package/dist/templates/angular/src/environments/gitignore +2 -1
  43. package/dist/templates/angular-sxp/.env +2 -0
  44. package/dist/templates/angular-sxp/scripts/config/plugins/disconnected.ts +4 -2
  45. package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +1 -1
  46. package/dist/templates/angular-xmcloud/.env +15 -2
  47. package/dist/templates/angular-xmcloud/angular.json +0 -1
  48. package/dist/templates/angular-xmcloud/package.json +2 -0
  49. package/dist/templates/angular-xmcloud/scripts/bootstrap.ts +28 -0
  50. package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +16 -0
  51. package/dist/templates/angular-xmcloud/scripts/generate-component-factory/plugins/packages.ts +34 -0
  52. package/dist/templates/angular-xmcloud/scripts/generate-component-factory/template.ts +57 -0
  53. package/dist/templates/angular-xmcloud/scripts/generate-metadata.ts +25 -0
  54. package/dist/templates/angular-xmcloud/server.exports.ts +24 -0
  55. package/dist/templates/angular-xmcloud/src/app/components/app-components.shared.module.ts +21 -0
  56. package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html +5 -0
  57. package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts +40 -0
  58. package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +2 -3
  59. package/dist/templates/angular-xmcloud/src/app/components/image/image.component.html +36 -0
  60. package/dist/templates/angular-xmcloud/src/app/components/image/image.component.ts +67 -0
  61. package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.html +15 -0
  62. package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.ts +41 -0
  63. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.html +23 -0
  64. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.ts +65 -0
  65. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.html +21 -0
  66. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts +49 -0
  67. package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.html +5 -0
  68. package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts +39 -0
  69. package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.html +1 -0
  70. package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.ts +15 -0
  71. package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.html +21 -0
  72. package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.ts +13 -0
  73. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +7 -12
  74. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +6 -1
  75. package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html +11 -0
  76. package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts +35 -0
  77. package/dist/templates/angular-xmcloud/src/app/components/sxa.component.ts +3 -3
  78. package/dist/templates/angular-xmcloud/src/app/components/title/title.component.html +10 -0
  79. package/dist/templates/angular-xmcloud/src/app/components/title/title.component.ts +56 -0
  80. package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +55 -0
  81. package/dist/templates/angular-xmcloud/src/app/lib/config.ts +2 -0
  82. package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +58 -0
  83. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +38 -0
  84. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +104 -0
  85. package/dist/templates/angular-xmcloud/src/app/routing/scripts/cdp-page-view.component.ts +77 -0
  86. package/dist/templates/angular-xmcloud/src/app/routing/scripts/cloud-sdk-init.component.ts +48 -0
  87. package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.component.html +5 -0
  88. package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.module.ts +12 -0
  89. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_header.scss +3 -1
  90. package/dist/templates/angular-xmcloud/src/assets/styles/main.scss +10 -0
  91. package/dist/templates/nextjs/package.json +5 -5
  92. package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +0 -1
  93. package/dist/templates/nextjs/scripts/generate-config.ts +8 -1
  94. package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +2 -1
  95. package/dist/templates/nextjs-styleguide/package.json +1 -1
  96. package/dist/templates/nextjs-styleguide/scripts/config/plugins/disconnected.ts +1 -0
  97. package/dist/templates/nextjs-sxa/src/assets/sass/components/common/_alignment.scss +34 -7
  98. package/dist/templates/nextjs-sxa/src/components/Container.tsx +6 -14
  99. package/dist/templates/nextjs-xmcloud/package.json +3 -2
  100. package/dist/templates/nextjs-xmcloud/src/Bootstrap.tsx +25 -10
  101. package/dist/templates/nextjs-xmcloud/src/byoc/{index.ts → index.tsx} +25 -8
  102. package/dist/templates/nextjs-xmcloud/src/components/CdpPageView.tsx +9 -14
  103. package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/component-themes.ts +2 -1
  104. package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/preview-mode.ts +2 -1
  105. package/dist/templates/node-headless-ssr-experience-edge/gitignore +19 -0
  106. package/dist/templates/node-headless-ssr-experience-edge/package.json +2 -2
  107. package/dist/templates/node-headless-ssr-proxy/gitignore +19 -0
  108. package/dist/templates/node-headless-ssr-proxy/package.json +3 -3
  109. package/dist/templates/node-headless-ssr-proxy/src/config.ts +3 -3
  110. package/dist/templates/node-headless-ssr-proxy/src/httpAgents.ts +2 -2
  111. package/dist/templates/node-headless-ssr-proxy/src/index.ts +9 -2
  112. package/dist/templates/node-xmcloud-proxy/.env +7 -1
  113. package/dist/templates/node-xmcloud-proxy/README.md +1 -1
  114. package/dist/templates/node-xmcloud-proxy/gitignore +33 -0
  115. package/dist/templates/node-xmcloud-proxy/package.json +3 -2
  116. package/dist/templates/node-xmcloud-proxy/src/config.ts +9 -3
  117. package/dist/templates/node-xmcloud-proxy/src/index.ts +54 -5
  118. package/dist/templates/node-xmcloud-proxy/src/types.ts +10 -42
  119. package/dist/templates/react/package.json +5 -5
  120. package/dist/templates/react/scripts/generate-config.js +10 -3
  121. package/dist/templates/react-native/package.json +4 -4
  122. package/dist/templates/vue/package.json +4 -4
  123. package/dist/templates/vue/scripts/generate-config.js +5 -0
  124. package/package.json +2 -2
  125. package/dist/templates/angular/scripts/generate-component-factory.ts +0 -166
  126. package/dist/templates/angular/src/app/lib/graphql-client-factory.ts +0 -28
  127. package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory.ts +0 -44
  128. package/dist/templates/nextjs-xmcloud/src/lib/context/index.ts +0 -22
  129. package/dist/templates/nextjs-xmcloud/src/lib/context/sdk/events.ts +0 -26
package/dist/bin.js CHANGED
@@ -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.main = exports.promptDestination = exports.getDestinations = exports.parseArgs = void 0;
38
+ exports.main = exports.promptDestination = exports.getDestination = exports.parseArgs = void 0;
39
39
  const fs_1 = __importDefault(require("fs"));
40
40
  const path_1 = __importStar(require("path"));
41
41
  const chalk_1 = __importDefault(require("chalk"));
@@ -43,7 +43,6 @@ const inquirer_1 = __importDefault(require("inquirer"));
43
43
  const init_runner_1 = require("./init-runner");
44
44
  const minimist_1 = __importDefault(require("minimist"));
45
45
  const common_1 = require("./common");
46
- const helpers_1 = require("./common/utils/helpers");
47
46
  const parseArgs = () => {
48
47
  // parse any command line arguments passed into `init sitecore-jss`
49
48
  // to pass to the generator prompts and skip them.
@@ -71,7 +70,7 @@ const parseArgs = () => {
71
70
  return args;
72
71
  };
73
72
  exports.parseArgs = parseArgs;
74
- const getDestinations = (args, templates) => __awaiter(void 0, void 0, void 0, function* () {
73
+ const getDestination = (args, templates) => __awaiter(void 0, void 0, void 0, function* () {
75
74
  if (templates.length === 0) {
76
75
  throw new Error('Unable to get destinations, provided templates are empty');
77
76
  }
@@ -83,30 +82,9 @@ const getDestinations = (args, templates) => __awaiter(void 0, void 0, void 0, f
83
82
  ? defaultBaseDestination
84
83
  : yield (0, exports.promptDestination)('Where would you like your new app created?', defaultBaseDestination);
85
84
  }
86
- // work with node-proxy destination if needed
87
- const proxyApp = templates.find((template) => template.match(helpers_1.proxyAppMatcher));
88
- if (proxyApp) {
89
- // put the proxy alongside main app by default
90
- const defaultProxyDestination = (0, helpers_1.getDefaultProxyDestination)(destination, proxyApp);
91
- let proxyAppDestination = args.proxyAppDestination;
92
- if (!proxyAppDestination) {
93
- proxyAppDestination = args.yes
94
- ? defaultProxyDestination
95
- : yield (0, exports.promptDestination)('Where would you like your proxy app created?', defaultProxyDestination);
96
- }
97
- while (path_1.default.resolve(proxyAppDestination) === path_1.default.resolve(destination)) {
98
- proxyAppDestination = yield (0, exports.promptDestination)('Proxy app and base app cannot be located in the same folder. Please input another path for proxy', defaultProxyDestination);
99
- }
100
- return {
101
- destination,
102
- proxyAppDestination,
103
- };
104
- }
105
- return {
106
- destination,
107
- };
85
+ return destination;
108
86
  });
109
- exports.getDestinations = getDestinations;
87
+ exports.getDestination = getDestination;
110
88
  const promptDestination = (prompt, defaultDestination) => __awaiter(void 0, void 0, void 0, function* () {
111
89
  return (yield inquirer_1.default.prompt({
112
90
  type: 'input',
@@ -153,24 +131,20 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
153
131
  });
154
132
  templates.push(answer.template);
155
133
  }
156
- const destinations = yield (0, exports.getDestinations)(args, templates);
157
- for (const destination of [destinations.destination, destinations.proxyAppDestination]) {
158
- if (!destination)
159
- continue;
160
- if (!args.force && fs_1.default.existsSync(destination) && fs_1.default.readdirSync(destination).length > 0) {
161
- const answer = yield inquirer_1.default.prompt({
162
- type: 'confirm',
163
- name: 'continue',
164
- message: `Directory '${destination}' not empty. Are you sure you want to continue?`,
165
- });
166
- if (!answer.continue) {
167
- process.exit();
168
- }
169
- }
170
- else {
171
- args.force = true;
134
+ const destination = yield (0, exports.getDestination)(args, templates);
135
+ if (!args.force && fs_1.default.existsSync(destination) && fs_1.default.readdirSync(destination).length > 0) {
136
+ const answer = yield inquirer_1.default.prompt({
137
+ type: 'confirm',
138
+ name: 'continue',
139
+ message: `Directory '${destination}' not empty. Are you sure you want to continue?`,
140
+ });
141
+ if (!answer.continue) {
142
+ process.exit();
172
143
  }
173
144
  }
145
+ else {
146
+ args.force = true;
147
+ }
174
148
  if (!args.yes) {
175
149
  if (args.prePushHook === null) {
176
150
  const answer = yield inquirer_1.default.prompt({
@@ -188,7 +162,7 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
188
162
  }
189
163
  }
190
164
  try {
191
- yield (0, init_runner_1.initRunner)(templates.slice(), Object.assign(Object.assign(Object.assign({}, args), destinations), { templates }));
165
+ yield (0, init_runner_1.initRunner)(templates.slice(), Object.assign(Object.assign({}, args), { destination, templates }));
192
166
  }
193
167
  catch (error) {
194
168
  console.log(chalk_1.default.red('An error occurred: ', error));
@@ -20,6 +20,9 @@ const chalk_1 = __importDefault(require("chalk"));
20
20
  * @param {string[]} nextStepsArr next steps to be performed after app is created
21
21
  */
22
22
  const nextSteps = (appNames, nextStepsArr) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const successMessage = appNames.length > 1
24
+ ? `JSS applications ${chalk_1.default.green(appNames.join(', '))} are ready!`
25
+ : `JSS application ${chalk_1.default.green(appNames[0])} is ready!`;
23
26
  console.log(chalk_1.default.red(' -/oyhdmNNNNmdhyo/- '));
24
27
  console.log(chalk_1.default.red(' :sdMMMMMMMMMMMMMMMMMMMMds: '));
25
28
  console.log(chalk_1.default.red(' :yNMMMMMMMMMMMMMMMMMMMMMMMMMMNy: '));
@@ -51,7 +54,7 @@ const nextSteps = (appNames, nextStepsArr) => __awaiter(void 0, void 0, void 0,
51
54
  console.log(chalk_1.default.white(' / // /\\ \\_\\ \\ '));
52
55
  console.log(chalk_1.default.white(' \\___/___/___/'));
53
56
  console.log();
54
- console.log(`JSS application(s) ${chalk_1.default.green(appNames.join(', '))} is ready!`);
57
+ console.log(successMessage);
55
58
  console.log();
56
59
  console.log(chalk_1.default.yellow('Next steps:'));
57
60
  nextStepsArr.forEach((step) => {
@@ -187,11 +187,6 @@ const populateEjsData = (answers, destination) => {
187
187
  getPascalCaseName: helpers_1.getPascalCaseName,
188
188
  getAppPrefix: helpers_1.getAppPrefix,
189
189
  } });
190
- // When SPA application and XM Cloud proxy is used we need to calculate relative path between SPA app and proxy to apply that in EJS template
191
- // Absolute path can't be used across all the machines
192
- if (answers.proxyAppDestination) {
193
- ejsData.helper.relativeProxyAppDestination = `${path_1.default.relative(path_1.default.resolve(answers.destination), path_1.default.resolve(answers.proxyAppDestination))}${path_1.sep}`;
194
- }
195
190
  return ejsData;
196
191
  };
197
192
  exports.populateEjsData = populateEjsData;
@@ -209,16 +204,11 @@ exports.populateEjsData = populateEjsData;
209
204
  */
210
205
  const transform = (templatePath, answers, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
211
206
  const { isFileForCopy, isFileForSkip, fileForCopyRegExp = FILE_FOR_COPY_REGEXP } = options;
212
- let destination = undefined;
213
- // allow proxy app to be installed separately alongside base app
214
- if (templatePath.match(/.*node-.+-proxy$/g) && answers.proxyAppDestination) {
215
- destination = answers.proxyAppDestination;
216
- }
217
- const destinationPath = path_1.default.resolve(destination || answers.destination);
207
+ const destinationPath = path_1.default.resolve(answers.destination);
218
208
  if (!answers.appPrefix) {
219
209
  answers.appPrefix = false;
220
210
  }
221
- const ejsData = (0, exports.populateEjsData)(answers, destination);
211
+ const ejsData = (0, exports.populateEjsData)(answers);
222
212
  // the templates to be run through ejs render or copied directly
223
213
  const files = glob_1.default.sync('**/*', { cwd: templatePath, dot: true, nodir: true });
224
214
  for (const file of files) {
@@ -38,19 +38,6 @@ exports.clientAppPrompts = [
38
38
  return !answers.appName;
39
39
  },
40
40
  },
41
- {
42
- type: 'list',
43
- name: 'fetchWith',
44
- message: 'How would you like to fetch Layout and Dictionary data?',
45
- choices: Object.values(FetchWith),
46
- default: exports.DEFAULT_FETCHWITH,
47
- when: (answers) => {
48
- if (answers.yes && !answers.fetchWith) {
49
- answers.fetchWith = exports.DEFAULT_FETCHWITH;
50
- }
51
- return !answers.fetchWith;
52
- },
53
- },
54
41
  ];
55
42
  const missingAddonMsg = (source, missingAddon) => chalk_1.default.yellow(`Warning: ${source} add-on cannot be used without the ${missingAddon} add-on. This may cause unexpected results.`);
56
43
  exports.missingAddonMsg = missingAddonMsg;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.proxyPrompts = exports.FALLBACK_PROXYNAME = void 0;
7
+ const helpers_1 = require("../utils/helpers");
8
+ const path_1 = __importDefault(require("path"));
9
+ exports.FALLBACK_PROXYNAME = 'sitecore-jss-proxy-app';
10
+ /**
11
+ * Set of CLI prompts for an SXP app
12
+ */
13
+ exports.proxyPrompts = [
14
+ {
15
+ type: 'input',
16
+ name: 'proxyAppDestination',
17
+ message: 'Where would you like your proxy app created?',
18
+ default: (answers) => {
19
+ // default proxy destination should be under same root as main app
20
+ return (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
21
+ },
22
+ when: (answers) => {
23
+ if (answers.yes && !answers.proxyAppDestination) {
24
+ answers.proxyAppDestination = (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
25
+ }
26
+ return !answers.proxyAppDestination;
27
+ },
28
+ validate: (input, answers) => {
29
+ if (path_1.default.resolve(input) === path_1.default.resolve(answers.destination)) {
30
+ return 'Paths for main app and proxy cannot match. Please choose another destination';
31
+ }
32
+ return true;
33
+ },
34
+ },
35
+ ];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sxpPrompts = void 0;
4
+ const base_1 = require("./base");
4
5
  /**
5
6
  * Set of CLI prompts for an SXP app
6
7
  */
@@ -9,12 +10,25 @@ exports.sxpPrompts = [
9
10
  type: 'input',
10
11
  name: 'hostName',
11
12
  message: 'What is your Sitecore hostname (used if deployed to Sitecore)?',
12
- default: (answers) => `${answers.appName}.dev.local`,
13
+ default: (answers) => `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`,
13
14
  when: (answers) => {
14
15
  if (answers.yes && !answers.hostName) {
15
- answers.hostName = `${answers.appName}.dev.local`;
16
+ answers.hostName = `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`;
16
17
  }
17
18
  return !answers.hostName;
18
19
  },
19
20
  },
21
+ {
22
+ type: 'list',
23
+ name: 'fetchWith',
24
+ message: 'How would you like to fetch Layout and Dictionary data?',
25
+ choices: Object.values(base_1.FetchWith),
26
+ default: base_1.DEFAULT_FETCHWITH,
27
+ when: (answers) => {
28
+ if (answers.yes && !answers.fetchWith) {
29
+ answers.fetchWith = base_1.DEFAULT_FETCHWITH;
30
+ }
31
+ return !answers.fetchWith;
32
+ },
33
+ },
20
34
  ];
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12,10 +35,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
36
  };
14
37
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.removeFile = exports.writeFileToPath = exports.getAppPrefix = exports.getBaseTemplates = exports.getAllTemplates = exports.sortKeys = exports.saveConfiguration = exports.writeJsonFile = exports.openJsonFile = exports.getPascalCaseName = exports.isDevEnvironment = exports.getDefaultProxyDestination = exports.proxyAppMatcher = void 0;
38
+ exports.removeFile = exports.writeFileToPath = exports.getAppPrefix = exports.getBaseTemplates = exports.getAllTemplates = exports.sortKeys = exports.saveConfiguration = exports.writeJsonFile = exports.openJsonFile = exports.getPascalCaseName = exports.isDevEnvironment = exports.getRelativeProxyDestination = exports.getDefaultProxyDestination = exports.proxyAppMatcher = void 0;
16
39
  const chalk_1 = __importDefault(require("chalk"));
17
40
  const fs_1 = __importDefault(require("fs"));
18
- const path_1 = __importDefault(require("path"));
41
+ const path_1 = __importStar(require("path"));
19
42
  const InitializerFactory_1 = require("../../InitializerFactory");
20
43
  // matched for proxy templates
21
44
  exports.proxyAppMatcher = /node-headless.+|node-xmcloud.+/g;
@@ -27,6 +50,8 @@ exports.proxyAppMatcher = /node-headless.+|node-xmcloud.+/g;
27
50
  */
28
51
  const getDefaultProxyDestination = (mainAppDestination, proxyName) => path_1.default.join(mainAppDestination, '..', proxyName);
29
52
  exports.getDefaultProxyDestination = getDefaultProxyDestination;
53
+ const getRelativeProxyDestination = (mainDestination, proxyDestination) => `${path_1.default.relative(path_1.default.resolve(mainDestination), path_1.default.resolve(proxyDestination))}${path_1.sep}`;
54
+ exports.getRelativeProxyDestination = getRelativeProxyDestination;
30
55
  /**
31
56
  * Determines whether you are in a dev environment.
32
57
  * It's `true` if you are inside the monorepo
@@ -53,7 +53,7 @@ const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, fun
53
53
  }
54
54
  args.silent || console.log(chalk_1.default.cyan(`Initializing '${init}'...`));
55
55
  const response = yield initializer.init(args);
56
- // App names can be multiple if the base template requires to setup additional standalone app (e.g. XM Cloud proxy)
56
+ // We can have multiple appNames if base template requires to setup an additional standalone app (e.g. XM Cloud proxy)
57
57
  appNames.add(response.appName);
58
58
  nextStepsArr = [...nextStepsArr, ...((_a = response.nextSteps) !== null && _a !== void 0 ? _a : [])];
59
59
  // process any returned initializers
@@ -11,14 +11,14 @@ exports.prompts = [
11
11
  default: false,
12
12
  when: (answers) => {
13
13
  // don't prompt if --yes or angular-xmcloud template was specified
14
- if (answers.yes) {
15
- return false;
16
- }
17
- else if (answers.templates.includes('angular-xmcloud') &&
14
+ if (answers.templates.includes('angular-xmcloud') &&
18
15
  !answers.templates.includes('angular-sxp')) {
19
16
  answers.xmcloud = true;
20
17
  return false;
21
18
  }
19
+ if (answers.yes) {
20
+ return false;
21
+ }
22
22
  return true;
23
23
  },
24
24
  },
@@ -31,29 +31,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
34
37
  Object.defineProperty(exports, "__esModule", { value: true });
35
38
  const path_1 = __importStar(require("path"));
36
39
  const common_1 = require("../../common");
40
+ const proxy_1 = require("../../common/prompts/proxy");
41
+ const inquirer_1 = __importDefault(require("inquirer"));
37
42
  const helpers_1 = require("../../common/utils/helpers");
38
43
  class AngularXmCloudInitializer {
39
44
  get isBase() {
40
45
  return false;
41
46
  }
42
47
  init(args) {
43
- var _a, _b;
48
+ var _a, _b, _c, _d;
44
49
  return __awaiter(this, void 0, void 0, function* () {
45
50
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
46
51
  const addInitializers = [];
47
- // when installing proxy alongside main app, have a separate path ready
48
- if (!args.proxyAppDestination) {
49
- args.proxyAppDestination = (0, helpers_1.getDefaultProxyDestination)(args.destination, 'node-xmcloud-proxy');
50
- }
52
+ // angular-xmcloud requires node-xmcloud-proxy
51
53
  if (!args.templates.includes('node-xmcloud-proxy')) {
52
54
  addInitializers.push('node-xmcloud-proxy');
53
55
  }
54
- 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 });
56
+ // ensure args.proxyAppDestination is populated
57
+ const promptArgs = {
58
+ yes: args.yes,
59
+ destination: args.destination,
60
+ proxyName: 'node-xmcloud-proxy',
61
+ proxyAppDestination: args.proxyAppDestination,
62
+ };
63
+ const proxyDetails = yield inquirer_1.default.prompt(proxy_1.proxyPrompts, promptArgs);
64
+ args.proxyAppDestination = proxyDetails.proxyAppDestination;
65
+ const finalArgs = Object.assign(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 }), proxyDetails), { relativeProxyAppDestination: (0, helpers_1.getRelativeProxyDestination)(args.destination, args.proxyAppDestination) });
55
66
  const templatePath = path_1.default.resolve(__dirname, '../../templates/angular-xmcloud');
56
- yield (0, common_1.transform)(templatePath, mergedArgs);
67
+ yield (0, common_1.transform)(templatePath, finalArgs);
68
+ if (args.templates.includes('angular-sxp') || ((_d = (_c = pkg.config) === null || _c === void 0 ? void 0 : _c.templates) === null || _d === void 0 ? void 0 : _d.includes('angular-sxp'))) {
69
+ console.log((0, common_1.incompatibleAddonsMsg)('angular-xmcloud', 'angular-sxp'));
70
+ }
57
71
  const response = {
58
72
  nextSteps: [],
59
73
  appName: args.appName || common_1.DEFAULT_APPNAME,
@@ -21,7 +21,8 @@ class AngularXmCloudInitializer {
21
21
  init(args) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  const templatePath = path_1.default.resolve(__dirname, '../../templates/node-xmcloud-proxy');
24
- yield (0, common_1.transform)(templatePath, args);
24
+ const modifiedArgs = Object.assign(Object.assign({}, args), { destination: args.proxyAppDestination || args.destination });
25
+ yield (0, common_1.transform)(templatePath, modifiedArgs);
25
26
  const response = {
26
27
  appName: 'node-xmcloud-proxy',
27
28
  };
@@ -1,3 +1,5 @@
1
+ # ====== Sitecore Preview / Delivery Edge ======
2
+
1
3
  # Your Sitecore API key is needed to build the app. Typically, the API key is
2
4
  # defined in `scjssconfig.json` (as `sitecore.apiKey`). This file may not exist
3
5
  # when building locally (if you've never run `jss setup`), or when building in a
@@ -17,15 +19,12 @@ SITECORE_API_HOST=
17
19
  # the resolved Sitecore API hostname + the `graphQLEndpointPath` defined in your `package.json`.
18
20
  GRAPH_QL_ENDPOINT=
19
21
 
22
+ # ==============================================
23
+
20
24
  # Your Sitecore site name.
21
25
  # Uses your `package.json` config `appName` if empty.
22
26
  SITECORE_SITE_NAME=
23
27
 
24
- <% if (!locals.xmcloud) { -%>
25
- # The way in which layout and dictionary data is fetched from Sitecore
26
- FETCH_WITH=<%- fetchWith %>
27
- <% } -%>
28
-
29
28
  # Your default app language.
30
29
  DEFAULT_LANGUAGE=
31
30
 
@@ -20,6 +20,7 @@
20
20
  "plugin:@angular-eslint/template/process-inline-templates"
21
21
  ],
22
22
  "rules": {
23
+ "@angular-eslint/no-host-metadata-property": "off",
23
24
  "@angular-eslint/component-selector": [
24
25
  "error",
25
26
  {
@@ -9,10 +9,15 @@ scjssconfig.json
9
9
  /dist-server
10
10
  /tmp
11
11
  /out-tsc
12
+ /.angular
12
13
 
13
14
  # dependencies
14
15
  /node_modules
15
16
 
17
+ # local env files
18
+ .env.local
19
+ .env.*.local
20
+
16
21
  # IDEs and editors
17
22
  /.idea
18
23
  .project
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%- appName %>",
3
- "version": "22.2.0-canary",
3
+ "version": "22.3.0-canary",
4
4
  "description": "Application utilizing Sitecore JavaScript Services and Angular (angular-cli).",
5
5
  "config": {
6
6
  "appName": "<%- appName %>",
@@ -22,7 +22,7 @@
22
22
  "build": "npm-run-all --serial bootstrap build:client build:server",
23
23
  "scaffold": "ng generate @sitecore-jss/sitecore-jss-angular-schematics:jss-component --no-manifest",
24
24
  "start:angular": "ng serve -o",
25
- "start:watch-components": "ts-node --project src/tsconfig.webpack-server.json scripts/generate-component-factory.ts --watch",
25
+ "start:watch-components": "ts-node --project src/tsconfig.webpack-server.json scripts/generate-component-factory/index.ts --watch",
26
26
  "build:client": "cross-env-shell ng build --configuration=production --base-href $npm_package_config_sitecoreDistPath/browser/ --output-path=$npm_package_config_buildArtifactsPath/browser/",
27
27
  "build:server": "cross-env-shell ng run <%- appName %>:server:production --output-path=$npm_package_config_buildArtifactsPath",
28
28
  "postbuild:server": "move-cli ./dist/main.js ./dist/server.bundle.js",
@@ -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.2.0-canary",
60
+ "@sitecore-jss/sitecore-jss-angular": "~22.3.0-canary",
61
61
  "apollo-angular": "~6.0.0",
62
62
  "bootstrap": "^5.3.3",
63
63
  "core-js": "~3.37.1",
@@ -78,10 +78,9 @@
78
78
  "@angular/cli": "~17.3.8",
79
79
  "@angular/compiler-cli": "~17.3.11",
80
80
  "@angular/language-service": "~17.3.11",
81
- "@sitecore-jss/sitecore-jss-angular-schematics": "~22.2.0-canary",
82
- "@sitecore-jss/sitecore-jss-cli": "~22.2.0-canary",
83
- "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.0-canary",
84
- "@types/isomorphic-fetch": "0.0.35",
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",
85
84
  "@types/jasmine": "~3.6.7",
86
85
  "@types/jasminewd2": "~2.0.8",
87
86
  "@types/node": "~20.14.10",
@@ -99,7 +98,6 @@
99
98
  "eslint-plugin-import": "2.29.1",
100
99
  "eslint-plugin-jsdoc": "48.7.0",
101
100
  "eslint-plugin-prefer-arrow": "1.2.3",
102
- "isomorphic-fetch": "^3.0.0",
103
101
  "jasmine-core": "~3.7.1",
104
102
  "jasmine-spec-reporter": "~6.0.0",
105
103
  "karma": "^6.3.2",
@@ -12,7 +12,6 @@ class FallbackPlugin implements ConfigPlugin {
12
12
  async exec(config: JssConfig) {
13
13
  return Object.assign({}, config, {
14
14
  defaultLanguage: config.defaultLanguage || 'en',
15
- sitecoreApiKey: config.sitecoreApiKey || 'no-api-key-set',
16
15
  <% if (!locals.xmcloud) { -%>
17
16
  layoutServiceConfigurationName: config.layoutServiceConfigurationName || 'default',
18
17
  <% } -%>
@@ -0,0 +1,45 @@
1
+ const plugins = require('scripts/temp/generate-component-factory-plugins');
2
+ import { PackageDefinition } from '@sitecore-jss/sitecore-jss-dev-tools';
3
+
4
+ export interface ComponentFactoryPluginConfig {
5
+ watch?: boolean;
6
+ packages: PackageDefinition[];
7
+ components: string[];
8
+ }
9
+
10
+ export interface ComponentFactoryPlugin {
11
+ /**
12
+ * Detect order when the plugin should be called, e.g. 0 - will be called first (can be a plugin which data is required for other plugins)
13
+ */
14
+ order: number;
15
+ /**
16
+ * A function which will be called during component factory generation
17
+ * @param {JssConfig} config Current (accumulated) config
18
+ */
19
+ exec(config: ComponentFactoryPluginConfig): ComponentFactoryPluginConfig;
20
+ }
21
+
22
+ /*
23
+ COMPONENT FACTORY GENERATION
24
+ Generates the /src/app/components/app-components.module.ts file which maps Angular components
25
+ to JSS components.
26
+
27
+ The component factory module defines a mapping between a string component name and a Angular component instance.
28
+ When the Sitecore Layout service returns a layout definition, it returns named components.
29
+ This mapping is used to construct the component hierarchy for the layout.
30
+
31
+ NOTE: this script can run in two modes. The default mode, the component factory file is written once.
32
+ But if `--watch` is a process argument, the component factory source folder will be watched,
33
+ and the componentFactory.js rewritten on added or deleted files.
34
+ This is used during `jss start` to pick up new or removed components at runtime.
35
+ */
36
+
37
+ const defaultConfig: ComponentFactoryPluginConfig = {
38
+ watch: process.argv.some(arg => arg === '--watch'),
39
+ packages: [],
40
+ components: [],
41
+ };
42
+
43
+ (Object.values(plugins) as ComponentFactoryPlugin[])
44
+ .sort((p1, p2) => p1.order - p2.order)
45
+ .reduce((config, plugin) => plugin.exec(config), defaultConfig);