@sap-ux/generator-adp 1.0.69 → 1.0.70

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.
@@ -272,7 +272,10 @@ class default_1 extends yeoman_generator_1.default {
272
272
  if (this.attributeAnswers.importKeyUserChanges) {
273
273
  this.keyUserPrompter = new key_user_js_1.KeyUserImportPrompter(this.systemLookup, this.configAnswers.application.id, this.prompter.provider, this.configAnswers.system, this.logger);
274
274
  const keyUserQuestions = this.keyUserPrompter.getPrompts({
275
- keyUserSystem: { default: this.configAnswers.system }
275
+ keyUserSystem: { default: this.configAnswers.system },
276
+ keyUserSystemValidationCli: { hide: !this.isCli },
277
+ keyUserAdaptationValidationCli: { hide: !this.isCli },
278
+ keyUserRestrictedViewsLabel: { hide: this.isCli }
276
279
  });
277
280
  await this.prompt(keyUserQuestions);
278
281
  }
@@ -389,6 +392,9 @@ class default_1 extends yeoman_generator_1.default {
389
392
  this.logger.error(`Failed to send telemetry: ${error}`);
390
393
  });
391
394
  }
395
+ if (this.isCli && this.keyUserPrompter?.detectRestrictedViews()) {
396
+ this.logger.warn(`${(0, i18n_js_1.t)('prompts.keyUserRestrictedViewsLabel')} ${(0, i18n_js_1.t)('prompts.keyUserRestrictedViewsDocLink')}`);
397
+ }
392
398
  if (this.isCli || this.isCfEnv || this.shouldCreateExtProject) {
393
399
  return;
394
400
  }
@@ -430,7 +436,10 @@ class default_1 extends yeoman_generator_1.default {
430
436
  wasFlpConfigDone: this.attributeAnswers?.addFlpConfig ?? false,
431
437
  wasTypeScriptChosen: this.attributeAnswers?.enableTypeScript ?? false,
432
438
  wasDeployConfigDone: this.attributeAnswers?.addDeployConfig ?? false,
433
- wasExtProjectGenerated: this.shouldCreateExtProject ?? false
439
+ wasExtProjectGenerated: this.shouldCreateExtProject ?? false,
440
+ wereKeyUserChangesImported: this.jsonInput
441
+ ? !!this.jsonInputFile?.keyUserChanges?.length
442
+ : (this.attributeAnswers?.importKeyUserChanges ?? false)
434
443
  };
435
444
  if (this.isCfEnv) {
436
445
  telemetryData.baseAppTechnicalName = this.cfPrompter?.manifest?.['sap.app']?.id ?? '';
@@ -90,6 +90,29 @@ export declare class KeyUserImportPrompter {
90
90
  * @returns {KeyUserImportQuestion} The adaptation prompt.
91
91
  */
92
92
  private getAdaptationPrompt;
93
+ /**
94
+ * Only used in the CLI context: the system prompt is of type `list`, whose `validate` does not
95
+ * run on CLI, so the key-user data (flex versions, adaptations and — for a single DEFAULT
96
+ * adaptation — the changes) would never be loaded. This hidden prompt triggers that loading
97
+ * once the system has been selected.
98
+ *
99
+ * @returns {KeyUserImportQuestion} Dummy prompt that runs in the CLI only.
100
+ */
101
+ private getSystemValidationPromptForCli;
102
+ /**
103
+ * Only used in the CLI context: the adaptation prompt is of type `list`, whose `validate` does
104
+ * not run on CLI, so the key-user changes for the selected adaptation would never be loaded.
105
+ * This hidden prompt triggers that loading once an adaptation has been selected.
106
+ *
107
+ * @returns {KeyUserImportQuestion} Dummy prompt that runs in the CLI only.
108
+ */
109
+ private getAdaptationValidationPromptForCli;
110
+ /**
111
+ * Returns the restricted views label prompt.
112
+ *
113
+ * @returns {KeyUserImportQuestion} The restricted views label prompt.
114
+ */
115
+ private getRestrictedViewsLabelPrompt;
93
116
  /**
94
117
  * Loads adaptations for the current provider.
95
118
  */
@@ -131,5 +154,17 @@ export declare class KeyUserImportPrompter {
131
154
  * @returns An error message if validation fails, or true if the key-user changes are valid.
132
155
  */
133
156
  private validateKeyUserChanges;
157
+ /**
158
+ * Checks whether any imported key-user change still carries a view restriction.
159
+ *
160
+ * A restriction is either a change that exists solely to restrict views (see
161
+ * `isViewRestrictionOnlyChange`, which is skipped on write) or a change with a non-empty
162
+ * `contexts.role` list, on the outer or nested inner content, alongside other content (whose
163
+ * `contexts` is stripped on write). In all cases the restriction is lost, so the developer must
164
+ * be notified that the imported views will become non-restricted.
165
+ *
166
+ * @returns {boolean} `true` if at least one change has a restricted view.
167
+ */
168
+ detectRestrictedViews(): boolean;
134
169
  }
135
170
  //# sourceMappingURL=key-user.d.ts.map
@@ -105,9 +105,12 @@ class KeyUserImportPrompter {
105
105
  getPrompts(promptOptions) {
106
106
  const keyedPrompts = {
107
107
  [types_js_1.keyUserPromptNames.keyUserSystem]: this.getSystemPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserSystem]),
108
+ [types_js_1.keyUserPromptNames.keyUserSystemValidationCli]: this.getSystemValidationPromptForCli(),
108
109
  [types_js_1.keyUserPromptNames.keyUserUsername]: this.getUsernamePrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserUsername]),
109
110
  [types_js_1.keyUserPromptNames.keyUserPassword]: this.getPasswordPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserPassword]),
110
- [types_js_1.keyUserPromptNames.keyUserAdaptation]: this.getAdaptationPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserAdaptation])
111
+ [types_js_1.keyUserPromptNames.keyUserAdaptation]: this.getAdaptationPrompt(promptOptions?.[types_js_1.keyUserPromptNames.keyUserAdaptation]),
112
+ [types_js_1.keyUserPromptNames.keyUserAdaptationValidationCli]: this.getAdaptationValidationPromptForCli(),
113
+ [types_js_1.keyUserPromptNames.keyUserRestrictedViewsLabel]: this.getRestrictedViewsLabelPrompt()
111
114
  };
112
115
  const questions = Object.entries(keyedPrompts)
113
116
  .filter(([promptName, _]) => {
@@ -203,6 +206,71 @@ class KeyUserImportPrompter {
203
206
  when: () => this.adaptations.length > 1
204
207
  };
205
208
  }
209
+ /**
210
+ * Only used in the CLI context: the system prompt is of type `list`, whose `validate` does not
211
+ * run on CLI, so the key-user data (flex versions, adaptations and — for a single DEFAULT
212
+ * adaptation — the changes) would never be loaded. This hidden prompt triggers that loading
213
+ * once the system has been selected.
214
+ *
215
+ * @returns {KeyUserImportQuestion} Dummy prompt that runs in the CLI only.
216
+ */
217
+ getSystemValidationPromptForCli() {
218
+ return {
219
+ name: types_js_1.keyUserPromptNames.keyUserSystemValidationCli,
220
+ when: async (answers) => {
221
+ if (!answers.keyUserSystem) {
222
+ return false;
223
+ }
224
+ const result = await this.validateSystem(answers.keyUserSystem, answers);
225
+ if (result !== true) {
226
+ throw new Error(typeof result === 'string' ? result : 'Validation failed');
227
+ }
228
+ return false;
229
+ }
230
+ };
231
+ }
232
+ /**
233
+ * Only used in the CLI context: the adaptation prompt is of type `list`, whose `validate` does
234
+ * not run on CLI, so the key-user changes for the selected adaptation would never be loaded.
235
+ * This hidden prompt triggers that loading once an adaptation has been selected.
236
+ *
237
+ * @returns {KeyUserImportQuestion} Dummy prompt that runs in the CLI only.
238
+ */
239
+ getAdaptationValidationPromptForCli() {
240
+ return {
241
+ name: types_js_1.keyUserPromptNames.keyUserAdaptationValidationCli,
242
+ when: async (answers) => {
243
+ if (this.adaptations.length <= 1) {
244
+ return false;
245
+ }
246
+ const result = await this.validateKeyUserChanges(answers.keyUserAdaptation?.id);
247
+ if (result !== true) {
248
+ throw new Error(typeof result === 'string' ? result : 'Validation failed');
249
+ }
250
+ return false;
251
+ }
252
+ };
253
+ }
254
+ /**
255
+ * Returns the restricted views label prompt.
256
+ *
257
+ * @returns {KeyUserImportQuestion} The restricted views label prompt.
258
+ */
259
+ getRestrictedViewsLabelPrompt() {
260
+ return {
261
+ type: 'input',
262
+ name: types_js_1.keyUserPromptNames.keyUserRestrictedViewsLabel,
263
+ message: (0, i18n_js_1.t)('prompts.keyUserRestrictedViewsLabel'),
264
+ guiOptions: {
265
+ type: 'label',
266
+ link: {
267
+ text: (0, i18n_js_1.t)('prompts.keyUserRestrictedViewsLinkText'),
268
+ url: 'https://help.sap.com/docs/bas/developing-sap-fiori-app-in-sap-business-application-studio/importing-key-user-changes'
269
+ }
270
+ },
271
+ when: () => this.detectRestrictedViews()
272
+ };
273
+ }
206
274
  /**
207
275
  * Loads adaptations for the current provider.
208
276
  */
@@ -357,6 +425,27 @@ class KeyUserImportPrompter {
357
425
  return getUnsupportedApiMessage(e, (0, i18n_js_1.t)('error.keyUserNotSupported'));
358
426
  }
359
427
  }
428
+ /**
429
+ * Checks whether any imported key-user change still carries a view restriction.
430
+ *
431
+ * A restriction is either a change that exists solely to restrict views (see
432
+ * `isViewRestrictionOnlyChange`, which is skipped on write) or a change with a non-empty
433
+ * `contexts.role` list, on the outer or nested inner content, alongside other content (whose
434
+ * `contexts` is stripped on write). In all cases the restriction is lost, so the developer must
435
+ * be notified that the imported views will become non-restricted.
436
+ *
437
+ * @returns {boolean} `true` if at least one change has a restricted view.
438
+ */
439
+ detectRestrictedViews() {
440
+ return this.keyUserChanges.some((change) => {
441
+ if ((0, adp_tooling_1.isViewRestrictionOnlyChange)(change.content)) {
442
+ return true;
443
+ }
444
+ const outerRoles = change.content.contexts?.role?.length ?? 0;
445
+ const innerRoles = change.content.content?.contexts?.role?.length ?? 0;
446
+ return outerRoles > 0 || innerRoles > 0;
447
+ });
448
+ }
360
449
  }
361
450
  exports.KeyUserImportPrompter = KeyUserImportPrompter;
362
451
  //# sourceMappingURL=key-user.js.map
@@ -170,9 +170,12 @@ export type KeyUserImportQuestion = YUIQuestion<KeyUserImportAnswers>;
170
170
  */
171
171
  export declare enum keyUserPromptNames {
172
172
  keyUserSystem = "keyUserSystem",
173
+ keyUserSystemValidationCli = "keyUserSystemValidationCli",
173
174
  keyUserUsername = "keyUserUsername",
174
175
  keyUserPassword = "keyUserPassword",
175
- keyUserAdaptation = "keyUserAdaptation"
176
+ keyUserAdaptation = "keyUserAdaptation",
177
+ keyUserAdaptationValidationCli = "keyUserAdaptationValidationCli",
178
+ keyUserRestrictedViewsLabel = "keyUserRestrictedViewsLabel"
176
179
  }
177
180
  export interface KeyUserSystemPromptOptions {
178
181
  default?: string;
@@ -190,14 +193,20 @@ export interface KeyUserAdaptationPromptOptions {
190
193
  default?: string;
191
194
  hide?: boolean;
192
195
  }
196
+ export interface KeyUserRestrictedViewsLabelPromptOptions {
197
+ hide?: boolean;
198
+ }
193
199
  /**
194
200
  * Options for the key-user import inquirer & the prompts.
195
201
  */
196
202
  export type KeyUserImportPromptOptions = Partial<{
197
203
  [keyUserPromptNames.keyUserSystem]: KeyUserSystemPromptOptions;
204
+ [keyUserPromptNames.keyUserSystemValidationCli]: CliValidationPromptOptions;
198
205
  [keyUserPromptNames.keyUserUsername]: KeyUserUsernamePromptOptions;
199
206
  [keyUserPromptNames.keyUserPassword]: KeyUserPasswordPromptOptions;
200
207
  [keyUserPromptNames.keyUserAdaptation]: KeyUserAdaptationPromptOptions;
208
+ [keyUserPromptNames.keyUserAdaptationValidationCli]: CliValidationPromptOptions;
209
+ [keyUserPromptNames.keyUserRestrictedViewsLabel]: KeyUserRestrictedViewsLabelPromptOptions;
201
210
  }>;
202
211
  export interface KeyUserImportAnswers {
203
212
  keyUserSystem: string;
@@ -39,9 +39,12 @@ var attributePromptNames;
39
39
  var keyUserPromptNames;
40
40
  (function (keyUserPromptNames) {
41
41
  keyUserPromptNames["keyUserSystem"] = "keyUserSystem";
42
+ keyUserPromptNames["keyUserSystemValidationCli"] = "keyUserSystemValidationCli";
42
43
  keyUserPromptNames["keyUserUsername"] = "keyUserUsername";
43
44
  keyUserPromptNames["keyUserPassword"] = "keyUserPassword";
44
45
  keyUserPromptNames["keyUserAdaptation"] = "keyUserAdaptation";
46
+ keyUserPromptNames["keyUserAdaptationValidationCli"] = "keyUserAdaptationValidationCli";
47
+ keyUserPromptNames["keyUserRestrictedViewsLabel"] = "keyUserRestrictedViewsLabel";
45
48
  })(keyUserPromptNames || (exports.keyUserPromptNames = keyUserPromptNames = {}));
46
49
  var targetEnvPromptNames;
47
50
  (function (targetEnvPromptNames) {
@@ -6,7 +6,8 @@ const DEFAULT_DATA = {
6
6
  wasExtProjectGenerated: false,
7
7
  wasFlpConfigDone: false,
8
8
  wasDeployConfigDone: false,
9
- wasTypeScriptChosen: false
9
+ wasTypeScriptChosen: false,
10
+ wereKeyUserChangesImported: false
10
11
  };
11
12
  /**
12
13
  * Telemetry collector for ADP generator. Tracks telemetry data throughout the generation process.
@@ -59,6 +59,9 @@
59
59
  "importKeyUserChangesLabel": "Import Key User Changes",
60
60
  "keyUserAdaptationLabel": "Context-Based Adaptation",
61
61
  "keyUserAdaptationBreadcrumb": "Adaptation",
62
+ "keyUserRestrictedViewsLabel": "⚠️ At least one imported change has a restricted view. The restriction cannot be kept in the adaptation project, so the affected views will be imported as non-restricted. Key users can restrict them again after the adaptation project has been deployed. For more information, see the",
63
+ "keyUserRestrictedViewsDocLink": "documentation: https://help.sap.com/docs/bas/developing-sap-fiori-app-in-sap-business-application-studio/importing-key-user-changes",
64
+ "keyUserRestrictedViewsLinkText": "SAP Help Portal.",
62
65
  "targetEnvLabel": "Environment",
63
66
  "targetEnvTooltip": "Select the target environment for your Adaptation Project.",
64
67
  "targetEnvBreadcrumb": "Target Environment",
@@ -57,6 +57,10 @@ export interface AdpTelemetryProperties {
57
57
  * Whether TypeScript was chosen.
58
58
  */
59
59
  wasTypeScriptChosen: boolean;
60
+ /**
61
+ * Whether the user chose to import key-user changes into the generated project.
62
+ */
63
+ wereKeyUserChangesImported: boolean;
60
64
  }
61
65
  /**
62
66
  * Complete telemetry data collected throughout the ADP generation process.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "displayName": "SAPUI5 Adaptation Project",
4
4
  "homepage": "https://help.sap.com/viewer/584e0bcbfd4a4aff91c815cefa0bce2d/Cloud/en-US/ada9567b767941aba8d49fdb4fdedea7.html",
5
5
  "description": "Adaptation project allows you to create an app variant for an existing SAP Fiori elements-based or SAPUI5 freestyle application, without changing the original application.",
6
- "version": "1.0.69",
6
+ "version": "1.0.70",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,17 +30,17 @@
30
30
  "i18next": "26.3.6",
31
31
  "yeoman-generator": "5.10.0",
32
32
  "uuid": "11.1.1",
33
- "@sap-ux/axios-extension": "2.1.0",
33
+ "@sap-ux/adp-tooling": "1.0.64",
34
+ "@sap-ux/axios-extension": "2.1.1",
34
35
  "@sap-ux/btp-utils": "2.0.6",
35
36
  "@sap-ux/feature-toggle": "1.0.5",
36
- "@sap-ux/adp-tooling": "1.0.63",
37
- "@sap-ux/inquirer-common": "1.0.46",
37
+ "@sap-ux/inquirer-common": "1.0.47",
38
38
  "@sap-ux/logger": "1.0.3",
39
39
  "@sap-ux/project-access": "2.3.0",
40
40
  "@sap-ux/store": "2.0.7",
41
- "@sap-ux/system-access": "1.0.14",
41
+ "@sap-ux/system-access": "1.0.15",
42
42
  "@sap-ux/project-input-validator": "1.0.23",
43
- "@sap-ux/fiori-generator-shared": "1.2.20",
43
+ "@sap-ux/fiori-generator-shared": "1.2.21",
44
44
  "@sap-ux/odata-service-writer": "1.0.25",
45
45
  "@sap-ux/telemetry": "2.0.10"
46
46
  },
@@ -58,7 +58,7 @@
58
58
  "fs-extra": "11.3.6",
59
59
  "rimraf": "6.1.3",
60
60
  "yeoman-test": "6.3.0",
61
- "@sap-ux/deploy-config-sub-generator": "1.0.79"
61
+ "@sap-ux/deploy-config-sub-generator": "1.0.80"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22.x"