create-sitecore-jss 22.2.0-canary.6 → 22.2.0-canary.60

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 (114) hide show
  1. package/dist/bin.js +17 -42
  2. package/dist/common/index.js +3 -1
  3. package/dist/common/processes/next.js +6 -3
  4. package/dist/common/processes/transform.js +13 -13
  5. package/dist/common/prompts/base.js +0 -25
  6. package/dist/common/prompts/proxy.js +35 -0
  7. package/dist/common/prompts/sxp.js +34 -0
  8. package/dist/common/utils/helpers.js +37 -2
  9. package/dist/init-runner.js +4 -3
  10. package/dist/initializers/angular/index.js +0 -3
  11. package/dist/initializers/angular/prompts.js +6 -6
  12. package/dist/initializers/angular-sxp/index.js +7 -1
  13. package/dist/initializers/angular-xmcloud/index.js +27 -3
  14. package/dist/initializers/nextjs/prompts.js +2 -0
  15. package/dist/initializers/node-xmcloud-proxy/index.js +2 -1
  16. package/dist/initializers/react/prompts.js +1 -1
  17. package/dist/initializers/react-native/prompts.js +1 -0
  18. package/dist/initializers/vue/prompts.js +1 -1
  19. package/dist/templates/angular/.env +4 -5
  20. package/dist/templates/angular/.eslintrc +1 -0
  21. package/dist/templates/angular/gitignore +5 -0
  22. package/dist/templates/angular/package.json +0 -2
  23. package/dist/templates/angular/scripts/config/plugins/fallback.ts +0 -1
  24. package/dist/templates/angular/scripts/generate-component-factory.ts +8 -0
  25. package/dist/templates/angular/scripts/generate-config.ts +25 -6
  26. package/dist/templates/angular/scripts/update-graphql-fragment-data.ts +21 -30
  27. package/dist/templates/angular/server.bundle.ts +3 -23
  28. package/dist/templates/angular/server.exports.ts +13 -0
  29. package/dist/templates/angular/src/app/JssState.ts +2 -9
  30. package/dist/templates/angular/src/app/app.module.ts +5 -4
  31. package/dist/templates/angular/src/app/app.server.module.ts +9 -6
  32. package/dist/templates/angular/src/app/i18n/jss-translation-client-loader.service.ts +15 -7
  33. package/dist/templates/angular/src/app/i18n/jss-translation-server-loader.service.ts +14 -2
  34. package/dist/templates/angular/src/app/jss-context.server-side.service.ts +4 -2
  35. package/dist/templates/angular/src/app/jss-context.service.ts +14 -11
  36. package/dist/templates/angular/src/app/jss-graphql.service.ts +7 -7
  37. package/dist/templates/angular/src/app/layout/jss-layout.service.ts +2 -2
  38. package/dist/templates/angular/src/app/lib/dictionary-service-factory.ts +4 -1
  39. package/dist/templates/angular/src/app/lib/graphql-client-factory/config.ts +21 -0
  40. package/dist/templates/angular/src/app/lib/graphql-client-factory/index.ts +16 -0
  41. package/dist/templates/angular/src/app/lib/layout-service-factory.ts +1 -1
  42. package/dist/templates/angular/src/app/routing/layout/layout.component.ts +10 -9
  43. package/dist/templates/angular/src/environments/gitignore +2 -1
  44. package/dist/templates/angular-sxp/.env +2 -0
  45. package/dist/templates/angular-sxp/scripts/config/plugins/disconnected.ts +4 -2
  46. package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +1 -1
  47. package/dist/templates/angular-xmcloud/.env +8 -2
  48. package/dist/templates/angular-xmcloud/angular.json +0 -1
  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-metadata.ts +25 -0
  52. package/dist/templates/angular-xmcloud/server.exports.ts +24 -0
  53. package/dist/templates/angular-xmcloud/src/app/components/app-components.shared.module.ts +21 -0
  54. package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html +5 -0
  55. package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts +40 -0
  56. package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +14 -0
  57. package/dist/templates/angular-xmcloud/src/app/components/container/container.component.ts +30 -0
  58. package/dist/templates/angular-xmcloud/src/app/components/image/image.component.html +36 -0
  59. package/dist/templates/angular-xmcloud/src/app/components/image/image.component.ts +67 -0
  60. package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.html +15 -0
  61. package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.ts +41 -0
  62. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.html +23 -0
  63. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.ts +65 -0
  64. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.html +21 -0
  65. package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts +49 -0
  66. package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.html +5 -0
  67. package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts +39 -0
  68. package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.html +1 -0
  69. package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.ts +15 -0
  70. package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.html +21 -0
  71. package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.ts +13 -0
  72. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +7 -12
  73. package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +6 -1
  74. package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html +11 -0
  75. package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts +35 -0
  76. package/dist/templates/angular-xmcloud/src/app/components/sxa.component.ts +4 -4
  77. package/dist/templates/angular-xmcloud/src/app/components/title/title.component.html +10 -0
  78. package/dist/templates/angular-xmcloud/src/app/components/title/title.component.ts +56 -0
  79. package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +55 -0
  80. package/dist/templates/angular-xmcloud/src/app/lib/config.ts +2 -0
  81. package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +58 -0
  82. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +38 -0
  83. package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +104 -0
  84. package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.component.html +3 -0
  85. package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.module.ts +10 -0
  86. package/dist/templates/angular-xmcloud/src/assets/styles/basic/_header.scss +3 -1
  87. package/dist/templates/angular-xmcloud/src/assets/styles/main.scss +10 -0
  88. package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-image.scss +1 -1
  89. package/dist/templates/nextjs/package.json +1 -1
  90. package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +0 -1
  91. package/dist/templates/nextjs/scripts/generate-config.ts +8 -1
  92. package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +2 -1
  93. package/dist/templates/nextjs-styleguide/scripts/config/plugins/disconnected.ts +1 -0
  94. package/dist/templates/nextjs-sxa/src/assets/sass/components/_component-image.scss +1 -1
  95. package/dist/templates/nextjs-sxa/src/components/Container.tsx +6 -14
  96. package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/component-themes.ts +2 -1
  97. package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/preview-mode.ts +2 -1
  98. package/dist/templates/node-headless-ssr-experience-edge/gitignore +19 -0
  99. package/dist/templates/node-headless-ssr-proxy/gitignore +19 -0
  100. package/dist/templates/node-headless-ssr-proxy/src/config.ts +3 -3
  101. package/dist/templates/node-headless-ssr-proxy/src/httpAgents.ts +2 -2
  102. package/dist/templates/node-headless-ssr-proxy/src/index.ts +9 -2
  103. package/dist/templates/node-xmcloud-proxy/.env +7 -1
  104. package/dist/templates/node-xmcloud-proxy/README.md +1 -1
  105. package/dist/templates/node-xmcloud-proxy/gitignore +33 -0
  106. package/dist/templates/node-xmcloud-proxy/package.json +3 -2
  107. package/dist/templates/node-xmcloud-proxy/src/config.ts +9 -3
  108. package/dist/templates/node-xmcloud-proxy/src/index.ts +54 -5
  109. package/dist/templates/node-xmcloud-proxy/src/types.ts +10 -42
  110. package/dist/templates/react/scripts/generate-config.js +10 -3
  111. package/dist/templates/vue/scripts/generate-config.js +5 -0
  112. package/package.json +2 -2
  113. package/dist/templates/angular/src/app/lib/graphql-client-factory.ts +0 -28
  114. package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory.ts +0 -44
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 proxyAppMatcher = /node-.+-proxy/g;
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,29 +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(proxyAppMatcher));
88
- if (proxyApp) {
89
- const defaultProxyDestination = proxyApp && `${process.cwd()}${path_1.sep}${proxyApp}`;
90
- let proxyAppDestination = args.proxyAppDestination;
91
- if (!proxyAppDestination) {
92
- proxyAppDestination = args.yes
93
- ? defaultProxyDestination
94
- : yield (0, exports.promptDestination)('Where would you like your proxy app created?', defaultProxyDestination);
95
- }
96
- while (proxyAppDestination === destination) {
97
- proxyAppDestination = yield (0, exports.promptDestination)('Proxy app and base app cannot be located in the same folder. Please input another path for proxy', defaultProxyDestination);
98
- }
99
- return {
100
- destination,
101
- proxyAppDestination,
102
- };
103
- }
104
- return {
105
- destination,
106
- };
85
+ return destination;
107
86
  });
108
- exports.getDestinations = getDestinations;
87
+ exports.getDestination = getDestination;
109
88
  const promptDestination = (prompt, defaultDestination) => __awaiter(void 0, void 0, void 0, function* () {
110
89
  return (yield inquirer_1.default.prompt({
111
90
  type: 'input',
@@ -152,24 +131,20 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
152
131
  });
153
132
  templates.push(answer.template);
154
133
  }
155
- const destinations = yield (0, exports.getDestinations)(args, templates);
156
- for (const destination of [destinations.destination, destinations.proxyAppDestination]) {
157
- if (!destination)
158
- continue;
159
- if (!args.force && fs_1.default.existsSync(destination) && fs_1.default.readdirSync(destination).length > 0) {
160
- const answer = yield inquirer_1.default.prompt({
161
- type: 'confirm',
162
- name: 'continue',
163
- message: `Directory '${destination}' not empty. Are you sure you want to continue?`,
164
- });
165
- if (!answer.continue) {
166
- process.exit();
167
- }
168
- }
169
- else {
170
- 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();
171
143
  }
172
144
  }
145
+ else {
146
+ args.force = true;
147
+ }
173
148
  if (!args.yes) {
174
149
  if (args.prePushHook === null) {
175
150
  const answer = yield inquirer_1.default.prompt({
@@ -187,7 +162,7 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
187
162
  }
188
163
  }
189
164
  try {
190
- 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 }));
191
166
  }
192
167
  catch (error) {
193
168
  console.log(chalk_1.default.red('An error occurred: ', error));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installPrePushHook = exports.lintFix = exports.installPackages = exports.nextSteps = exports.transform = exports.removeFile = exports.saveConfiguration = exports.getBaseTemplates = exports.getAllTemplates = exports.writeJsonFile = exports.openJsonFile = exports.isDevEnvironment = exports.styleguidePrompts = exports.missingAddonMsg = exports.incompatibleAddonsMsg = exports.DEFAULT_APPNAME = exports.clientAppPrompts = void 0;
3
+ exports.installPrePushHook = exports.lintFix = exports.installPackages = exports.nextSteps = exports.transform = exports.removeFile = exports.saveConfiguration = exports.getBaseTemplates = exports.getAllTemplates = exports.writeJsonFile = exports.openJsonFile = exports.isDevEnvironment = exports.sxpPrompts = exports.styleguidePrompts = exports.missingAddonMsg = exports.incompatibleAddonsMsg = exports.DEFAULT_APPNAME = exports.clientAppPrompts = void 0;
4
4
  var base_1 = require("./prompts/base");
5
5
  Object.defineProperty(exports, "clientAppPrompts", { enumerable: true, get: function () { return base_1.clientAppPrompts; } });
6
6
  Object.defineProperty(exports, "DEFAULT_APPNAME", { enumerable: true, get: function () { return base_1.DEFAULT_APPNAME; } });
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "incompatibleAddonsMsg", { enumerable: true, get:
8
8
  Object.defineProperty(exports, "missingAddonMsg", { enumerable: true, get: function () { return base_1.missingAddonMsg; } });
9
9
  var styleguide_1 = require("./prompts/styleguide");
10
10
  Object.defineProperty(exports, "styleguidePrompts", { enumerable: true, get: function () { return styleguide_1.styleguidePrompts; } });
11
+ var sxp_1 = require("./prompts/sxp");
12
+ Object.defineProperty(exports, "sxpPrompts", { enumerable: true, get: function () { return sxp_1.sxpPrompts; } });
11
13
  var helpers_1 = require("./utils/helpers");
12
14
  Object.defineProperty(exports, "isDevEnvironment", { enumerable: true, get: function () { return helpers_1.isDevEnvironment; } });
13
15
  Object.defineProperty(exports, "openJsonFile", { enumerable: true, get: function () { return helpers_1.openJsonFile; } });
@@ -16,10 +16,13 @@ exports.nextSteps = void 0;
16
16
  const chalk_1 = __importDefault(require("chalk"));
17
17
  /**
18
18
  * Logs app creation completion message and next steps
19
- * @param {string} appName application name for the new app
19
+ * @param {string[]} appNames application name(s) for the new app
20
20
  * @param {string[]} nextStepsArr next steps to be performed after app is created
21
21
  */
22
- const nextSteps = (appName, nextStepsArr) => __awaiter(void 0, void 0, void 0, function* () {
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 = (appName, nextStepsArr) => __awaiter(void 0, void 0, void 0, f
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 ${chalk_1.default.green(appName)} 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) => {
@@ -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.populateEjsData = exports.diffAndWriteFiles = exports.diffFiles = exports.mergeEnv = 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"));
@@ -180,6 +180,16 @@ const diffAndWriteFiles = ({ rendered, pathToNewFile, answers, }) => __awaiter(v
180
180
  }
181
181
  });
182
182
  exports.diffAndWriteFiles = diffAndWriteFiles;
183
+ const populateEjsData = (answers, destination) => {
184
+ // pass in helper to answers object
185
+ const ejsData = Object.assign(Object.assign({}, answers), { helper: {
186
+ isDev: (0, helpers_1.isDevEnvironment)(destination || answers.destination),
187
+ getPascalCaseName: helpers_1.getPascalCaseName,
188
+ getAppPrefix: helpers_1.getAppPrefix,
189
+ } });
190
+ return ejsData;
191
+ };
192
+ exports.populateEjsData = populateEjsData;
183
193
  /**
184
194
  * Handles each template file and applies ejs renderer, also:
185
195
  * * determines files for copy
@@ -194,21 +204,11 @@ exports.diffAndWriteFiles = diffAndWriteFiles;
194
204
  */
195
205
  const transform = (templatePath, answers, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
196
206
  const { isFileForCopy, isFileForSkip, fileForCopyRegExp = FILE_FOR_COPY_REGEXP } = options;
197
- let destination = undefined;
198
- // allow proxy app to be installed separately alongside base app
199
- if (templatePath.match(/.*node-.+-proxy$/g)) {
200
- destination = answers.proxyAppDestination;
201
- }
202
- const destinationPath = path_1.default.resolve(destination || answers.destination);
207
+ const destinationPath = path_1.default.resolve(answers.destination);
203
208
  if (!answers.appPrefix) {
204
209
  answers.appPrefix = false;
205
210
  }
206
- // pass in helper to answers object
207
- const ejsData = Object.assign(Object.assign({}, answers), { helper: {
208
- isDev: (0, helpers_1.isDevEnvironment)(destination || answers.destination),
209
- getPascalCaseName: helpers_1.getPascalCaseName,
210
- getAppPrefix: helpers_1.getAppPrefix,
211
- } });
211
+ const ejsData = (0, exports.populateEjsData)(answers);
212
212
  // the templates to be run through ejs render or copied directly
213
213
  const files = glob_1.default.sync('**/*', { cwd: templatePath, dot: true, nodir: true });
214
214
  for (const file of files) {
@@ -38,31 +38,6 @@ exports.clientAppPrompts = [
38
38
  return !answers.appName;
39
39
  },
40
40
  },
41
- {
42
- type: 'input',
43
- name: 'hostName',
44
- message: 'What is your Sitecore hostname (used if deployed to Sitecore)?',
45
- default: (answers) => `${answers.appName}.dev.local`,
46
- when: (answers) => {
47
- if (answers.yes && !answers.hostName) {
48
- answers.hostName = `${answers.appName}.dev.local`;
49
- }
50
- return !answers.hostName;
51
- },
52
- },
53
- {
54
- type: 'list',
55
- name: 'fetchWith',
56
- message: 'How would you like to fetch Layout and Dictionary data?',
57
- choices: Object.values(FetchWith),
58
- default: exports.DEFAULT_FETCHWITH,
59
- when: (answers) => {
60
- if (answers.yes && !answers.fetchWith) {
61
- answers.fetchWith = exports.DEFAULT_FETCHWITH;
62
- }
63
- return !answers.fetchWith;
64
- },
65
- },
66
41
  ];
67
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.`);
68
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
+ ];
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sxpPrompts = void 0;
4
+ const base_1 = require("./base");
5
+ /**
6
+ * Set of CLI prompts for an SXP app
7
+ */
8
+ exports.sxpPrompts = [
9
+ {
10
+ type: 'input',
11
+ name: 'hostName',
12
+ message: 'What is your Sitecore hostname (used if deployed to Sitecore)?',
13
+ default: (answers) => `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`,
14
+ when: (answers) => {
15
+ if (answers.yes && !answers.hostName) {
16
+ answers.hostName = `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`;
17
+ }
18
+ return !answers.hostName;
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
+ },
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,11 +35,23 @@ 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 = 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");
43
+ // matched for proxy templates
44
+ exports.proxyAppMatcher = /node-headless.+|node-xmcloud.+/g;
45
+ /**
46
+ * Returns the default path for proxy app initialized alongside main JSS tempalates.
47
+ * @param {string} mainAppDestination target destination for main app
48
+ * @param {string} proxyName name of for the proxy app folder
49
+ * @returns {string} target path for proxy app
50
+ */
51
+ const getDefaultProxyDestination = (mainAppDestination, proxyName) => path_1.default.join(mainAppDestination, '..', proxyName);
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;
20
55
  /**
21
56
  * Determines whether you are in a dev environment.
22
57
  * It's `true` if you are inside the monorepo
@@ -42,7 +42,7 @@ const common_1 = require("./common");
42
42
  const InitializerFactory_1 = require("./InitializerFactory");
43
43
  const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, function* () {
44
44
  let nextStepsArr = [];
45
- let appName;
45
+ const appNames = new Set([]);
46
46
  const initFactory = new InitializerFactory_1.InitializerFactory();
47
47
  const runner = (inits) => __awaiter(void 0, void 0, void 0, function* () {
48
48
  var _a;
@@ -53,7 +53,8 @@ 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
- appName = response.appName;
56
+ // We can have multiple appNames if base template requires to setup an additional standalone app (e.g. XM Cloud proxy)
57
+ appNames.add(response.appName);
57
58
  nextStepsArr = [...nextStepsArr, ...((_a = response.nextSteps) !== null && _a !== void 0 ? _a : [])];
58
59
  // process any returned initializers
59
60
  if (response.initializers && response.initializers.length > 0) {
@@ -81,7 +82,7 @@ const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, fun
81
82
  }
82
83
  }
83
84
  if (!args.silent) {
84
- (0, common_1.nextSteps)(appName || '', nextStepsArr);
85
+ (0, common_1.nextSteps)([...appNames], nextStepsArr);
85
86
  }
86
87
  });
87
88
  exports.initRunner = initRunner;
@@ -32,9 +32,6 @@ class AngularInitializer {
32
32
  if (!args.templates.includes('angular-xmcloud')) {
33
33
  addInitializers.push('angular-xmcloud');
34
34
  }
35
- if (!args.templates.includes('node-xmcloud-proxy')) {
36
- addInitializers.push('node-xmcloud-proxy');
37
- }
38
35
  }
39
36
  else {
40
37
  // invoke default non-XMC init
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prompts = void 0;
4
4
  const common_1 = require("../../common");
5
5
  exports.prompts = [
6
- ...common_1.clientAppPrompts,
6
+ // XMCloud answer defines init behavior. Prompt must go first
7
7
  {
8
8
  type: 'confirm',
9
9
  name: 'xmcloud',
@@ -11,16 +11,16 @@ 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
  },
25
- ...common_1.styleguidePrompts,
25
+ ...common_1.clientAppPrompts,
26
26
  ];
@@ -31,9 +31,13 @@ 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 inquirer_1 = __importDefault(require("inquirer"));
37
41
  class AngularSxpInitializer {
38
42
  get isBase() {
39
43
  return false;
@@ -42,7 +46,9 @@ class AngularSxpInitializer {
42
46
  var _a, _b;
43
47
  return __awaiter(this, void 0, void 0, function* () {
44
48
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
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 });
49
+ const answers = yield inquirer_1.default.prompt(common_1.sxpPrompts, args);
50
+ const styleguideAnswers = yield inquirer_1.default.prompt(common_1.styleguidePrompts, args);
51
+ const mergedArgs = 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 }), answers), styleguideAnswers);
46
52
  const templatePath = path_1.default.resolve(__dirname, '../../templates/angular-sxp');
47
53
  yield (0, common_1.transform)(templatePath, mergedArgs);
48
54
  const response = {
@@ -31,23 +31,47 @@ 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"));
42
+ const helpers_1 = require("../../common/utils/helpers");
37
43
  class AngularXmCloudInitializer {
38
44
  get isBase() {
39
45
  return false;
40
46
  }
41
47
  init(args) {
42
- var _a, _b;
48
+ var _a, _b, _c, _d;
43
49
  return __awaiter(this, void 0, void 0, function* () {
44
50
  const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
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 });
51
+ const addInitializers = [];
52
+ // angular-xmcloud requires node-xmcloud-proxy
53
+ if (!args.templates.includes('node-xmcloud-proxy')) {
54
+ addInitializers.push('node-xmcloud-proxy');
55
+ }
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) });
46
66
  const templatePath = path_1.default.resolve(__dirname, '../../templates/angular-xmcloud');
47
- 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
+ }
48
71
  const response = {
49
72
  nextSteps: [],
50
73
  appName: args.appName || common_1.DEFAULT_APPNAME,
74
+ initializers: addInitializers,
51
75
  };
52
76
  return response;
53
77
  });
@@ -12,8 +12,10 @@ var Prerender;
12
12
  Prerender["SSR"] = "SSR";
13
13
  })(Prerender = exports.Prerender || (exports.Prerender = {}));
14
14
  const DEFAULT_PRERENDER = Prerender.SSG;
15
+ // still need sxp prompts here until sitecore/config is no longer added to xmc app
15
16
  exports.prompts = [
16
17
  ...common_1.clientAppPrompts,
18
+ ...common_1.sxpPrompts,
17
19
  {
18
20
  type: 'list',
19
21
  name: 'prerender',
@@ -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
  };
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prompts = void 0;
4
4
  const common_1 = require("../../common");
5
- exports.prompts = [...common_1.clientAppPrompts, ...common_1.styleguidePrompts];
5
+ exports.prompts = [...common_1.clientAppPrompts, ...common_1.sxpPrompts, ...common_1.styleguidePrompts];
@@ -4,5 +4,6 @@ exports.prompts = void 0;
4
4
  const common_1 = require("../../common");
5
5
  exports.prompts = [
6
6
  ...common_1.clientAppPrompts.filter((p) => p.name !== 'fetchWith'),
7
+ ...common_1.sxpPrompts,
7
8
  ...common_1.styleguidePrompts,
8
9
  ];
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.prompts = void 0;
4
4
  const common_1 = require("../../common");
5
- exports.prompts = [...common_1.clientAppPrompts, ...common_1.styleguidePrompts];
5
+ exports.prompts = [...common_1.clientAppPrompts, ...common_1.sxpPrompts, ...common_1.styleguidePrompts];
@@ -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
@@ -81,7 +81,6 @@
81
81
  "@sitecore-jss/sitecore-jss-angular-schematics": "~22.2.0-canary",
82
82
  "@sitecore-jss/sitecore-jss-cli": "~22.2.0-canary",
83
83
  "@sitecore-jss/sitecore-jss-dev-tools": "~22.2.0-canary",
84
- "@types/isomorphic-fetch": "0.0.35",
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
  <% } -%>