@sap-ux/create 0.10.12 → 0.11.0

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.
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addAnnotationsToOdataCommand = addAnnotationsToOdataCommand;
4
4
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
5
+ const system_access_1 = require("@sap-ux/system-access");
5
6
  const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
6
- const tracing_1 = require("../../tracing");
7
7
  const common_1 = require("../../common");
8
+ const tracing_1 = require("../../tracing");
8
9
  const validation_1 = require("../../validation/validation");
9
10
  let loginAttempts = 3;
10
11
  /**
@@ -35,8 +36,11 @@ async function addAnnotationsToOdata(basePath, simulate, yamlPath) {
35
36
  }
36
37
  await (0, validation_1.validateAdpProject)(basePath);
37
38
  const variant = (0, adp_tooling_1.getVariant)(basePath);
38
- const adpConfig = await (0, adp_tooling_1.getAdpConfig)(basePath, yamlPath);
39
- const manifestService = await adp_tooling_1.ManifestService.initMergedManifest(basePath, variant, adpConfig, logger);
39
+ const { target, ignoreCertErrors = false } = await (0, adp_tooling_1.getAdpConfig)(basePath, yamlPath);
40
+ const provider = await (0, system_access_1.createAbapServiceProvider)(target, {
41
+ ignoreCertErrors
42
+ }, true, logger);
43
+ const manifestService = await adp_tooling_1.ManifestService.initMergedManifest(provider, basePath, variant, logger);
40
44
  const dataSources = manifestService.getManifestDataSources();
41
45
  const answers = await (0, common_1.promptYUIQuestions)((0, adp_tooling_1.getPromptsForAddAnnotationsToOData)(basePath, dataSources), false);
42
46
  let namespaces = [];
@@ -1,8 +1,22 @@
1
1
  import type { Command } from 'commander';
2
+ import { type Editor } from 'mem-fs-editor';
3
+ import type { ToolsLogger } from '@sap-ux/logger';
4
+ import type { Manifest } from '@sap-ux/project-access';
2
5
  /**
3
6
  * Add the "add inbound-navigation" command to a passed command.
4
7
  *
5
8
  * @param cmd - commander command for adding navigation inbounds config command
6
9
  */
7
10
  export declare function addInboundNavigationConfigCommand(cmd: Command): void;
11
+ /**
12
+ * Retrieves the project's manifest file, handling both Fiori and Adaptation project scenarios.
13
+ *
14
+ * @param {string} basePath - The base path to the project.
15
+ * @param {boolean} isAdp - Indicates whether the project is an ADP project.
16
+ * @param {Editor} fs - The mem-fs editor instance.
17
+ * @param {ToolsLogger} logger - The logger instance.
18
+ * @returns {Promise<Manifest>} The manifest file content.
19
+ * @throws {Error} If the project is not CloudReady or the manifest cannot be retrieved.
20
+ */
21
+ export declare function getManifest(basePath: string, isAdp: boolean, fs: Editor, logger: ToolsLogger): Promise<Manifest>;
8
22
  //# sourceMappingURL=navigation-config.d.ts.map
@@ -1,12 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addInboundNavigationConfigCommand = addInboundNavigationConfigCommand;
4
- const mem_fs_editor_1 = require("mem-fs-editor");
4
+ exports.getManifest = getManifest;
5
+ const path_1 = require("path");
5
6
  const mem_fs_1 = require("mem-fs");
7
+ const mem_fs_editor_1 = require("mem-fs-editor");
8
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
6
9
  const flp_config_inquirer_1 = require("@sap-ux/flp-config-inquirer");
10
+ const project_access_1 = require("@sap-ux/project-access");
11
+ const system_access_1 = require("@sap-ux/system-access");
7
12
  const app_config_writer_1 = require("@sap-ux/app-config-writer");
8
13
  const common_1 = require("../../common");
9
14
  const validation_1 = require("../../validation");
15
+ const prompts_1 = require("../../common/prompts");
10
16
  const tracing_1 = require("../../tracing");
11
17
  /**
12
18
  * Add the "add inbound-navigation" command to a passed command.
@@ -25,25 +31,38 @@ function addInboundNavigationConfigCommand(cmd) {
25
31
  });
26
32
  }
27
33
  /**
28
- * Adds an inbound navigation config to an app. To prevent overwriting existing inbounds will be checked.
34
+ * Adds an inbound navigation configuration to an app. Checks existing inbounds to prevent overwriting.
29
35
  *
30
- * @param basePath - path to application root
31
- * @param simulate - if true, do not write but just show what would be changed; otherwise write
36
+ * @param {string} basePath - The path to the application root.
37
+ * @param {boolean} simulate - If true, simulates the changes without writing them; otherwise, writes changes.
38
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
32
39
  */
33
40
  async function addInboundNavigationConfig(basePath, simulate) {
34
41
  const logger = (0, tracing_1.getLogger)();
35
42
  try {
36
43
  logger.debug(`Called add inbound navigation-config for path '${basePath}', simulate is '${simulate}'`);
37
44
  await (0, validation_1.validateBasePath)(basePath);
45
+ const appType = await (0, project_access_1.getAppType)(basePath);
46
+ const isAdp = appType === 'Fiori Adaptation';
47
+ if (isAdp && (0, adp_tooling_1.flpConfigurationExists)(basePath)) {
48
+ logger.info('FLP Configuration already exists.');
49
+ return;
50
+ }
38
51
  const fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
39
- const { manifest } = await (0, app_config_writer_1.readManifest)(basePath, fs);
40
- const inbounds = manifest?.['sap.app']?.crossNavigation?.inbounds;
41
- const config = await getUserConfig(inbounds);
52
+ const manifest = await getManifest(basePath, isAdp, fs, logger);
53
+ const inbounds = (0, adp_tooling_1.getInboundsFromManifest)(manifest);
54
+ const appId = (0, adp_tooling_1.getRegistrationIdFromManifest)(manifest);
55
+ const config = await getUserConfig(inbounds, isAdp, appId);
42
56
  if (!config) {
43
57
  logger.info('User chose not to overwrite existing inbound navigation configuration.');
44
58
  return;
45
59
  }
46
- await (0, app_config_writer_1.generateInboundNavigationConfig)(basePath, config, true, fs);
60
+ if (isAdp) {
61
+ await (0, adp_tooling_1.generateInboundConfig)(basePath, config, fs);
62
+ }
63
+ else {
64
+ await (0, app_config_writer_1.generateInboundNavigationConfig)(basePath, config, true, fs);
65
+ }
47
66
  if (!simulate) {
48
67
  fs.commit(() => logger.info(`Inbound navigation configuration complete.`));
49
68
  }
@@ -56,14 +75,72 @@ async function addInboundNavigationConfig(basePath, simulate) {
56
75
  logger.debug(error);
57
76
  }
58
77
  }
78
+ /**
79
+ * Retrieves the project's manifest file, handling both Fiori and Adaptation project scenarios.
80
+ *
81
+ * @param {string} basePath - The base path to the project.
82
+ * @param {boolean} isAdp - Indicates whether the project is an ADP project.
83
+ * @param {Editor} fs - The mem-fs editor instance.
84
+ * @param {ToolsLogger} logger - The logger instance.
85
+ * @returns {Promise<Manifest>} The manifest file content.
86
+ * @throws {Error} If the project is not CloudReady or the manifest cannot be retrieved.
87
+ */
88
+ async function getManifest(basePath, isAdp, fs, logger) {
89
+ if (isAdp) {
90
+ return retrieveMergedManifest(basePath, logger);
91
+ }
92
+ return retrieveManifest(basePath, fs);
93
+ }
94
+ /**
95
+ * Retrieves the manifest for a Fiori project.
96
+ *
97
+ * @param {string} basePath - The base path to the project.
98
+ * @param {Editor} fs - The mem-fs editor instance.
99
+ * @returns {Promise<Manifest>} The base project manifest.
100
+ */
101
+ async function retrieveManifest(basePath, fs) {
102
+ const { manifest } = await (0, app_config_writer_1.readManifest)(basePath, fs);
103
+ return manifest;
104
+ }
105
+ /**
106
+ * Retrieves the manifest for an Adaptation Project (ADP).
107
+ *
108
+ * @param {string} basePath - The base path to the ADP project.
109
+ * @param {ToolsLogger} logger - The logger instance.
110
+ * @returns {Promise<Manifest>} The merged manifest for the ADP project.
111
+ * @throws {Error} If the project is not CloudReady.
112
+ */
113
+ async function retrieveMergedManifest(basePath, logger) {
114
+ const variant = (0, adp_tooling_1.getVariant)(basePath);
115
+ const { target, ignoreCertErrors = false } = await (0, adp_tooling_1.getAdpConfig)(basePath, (0, path_1.join)(basePath, project_access_1.FileName.Ui5Yaml));
116
+ const provider = await (0, system_access_1.createAbapServiceProvider)(target, { ignoreCertErrors }, true, logger);
117
+ const manifestService = await adp_tooling_1.ManifestService.initMergedManifest(provider, basePath, variant, logger);
118
+ return manifestService.getManifest();
119
+ }
59
120
  /**
60
121
  * Prompts the user for inbound navigation configuration.
61
122
  *
62
- * @param inbounds - The existing inbounds to avoid conflicts.
63
- * @returns {Promise<FLPConfigAnswers | undefined>} The user-provided configuration or undefined if skipped.
123
+ * @param {ManifestNamespace.Inbound | undefined} inbounds - The existing inbounds if any.
124
+ * @param {boolean} isAdp - Indicates whether the project is an ADP project.
125
+ * @param {string} [appId] - The application ID used for generating prompts specific to the app.
126
+ * @returns {Promise<FLPConfigAnswers | undefined>} A promise resolving to the user-provided configuration,
127
+ * or `undefined` if the user opts not to overwrite.
64
128
  */
65
- async function getUserConfig(inbounds) {
66
- const config = await (0, common_1.promptYUIQuestions)(await (0, flp_config_inquirer_1.getPrompts)(Object.keys(inbounds ?? {})), false);
129
+ async function getUserConfig(inbounds, isAdp, appId) {
130
+ let promptOptions;
131
+ if (!isAdp) {
132
+ promptOptions = {
133
+ inboundId: { hide: true },
134
+ additionalParameters: { hide: true },
135
+ createAnotherInbound: { hide: true },
136
+ emptyInboundsInfo: { hide: true }
137
+ };
138
+ }
139
+ else {
140
+ promptOptions = { overwrite: { hide: true }, createAnotherInbound: { hide: true } };
141
+ }
142
+ const prompts = await (0, prompts_1.filterLabelTypeQuestions)(await (0, flp_config_inquirer_1.getPrompts)(inbounds, appId, promptOptions));
143
+ const config = await (0, common_1.promptYUIQuestions)(prompts, false);
67
144
  if (config?.subTitle === '') {
68
145
  config.subTitle = undefined;
69
146
  }
@@ -5,6 +5,7 @@ const adp_tooling_1 = require("@sap-ux/adp-tooling");
5
5
  const tracing_1 = require("../../tracing");
6
6
  const common_1 = require("../../common");
7
7
  const validation_1 = require("../../validation/validation");
8
+ const system_access_1 = require("@sap-ux/system-access");
8
9
  let loginAttempts = 3;
9
10
  /**
10
11
  * Add a new sub-command to change the data source of an adaptation project to the given command.
@@ -34,8 +35,11 @@ async function changeDataSource(basePath, simulate, yamlPath) {
34
35
  }
35
36
  await (0, validation_1.validateAdpProject)(basePath);
36
37
  const variant = (0, adp_tooling_1.getVariant)(basePath);
37
- const adpConfig = await (0, adp_tooling_1.getAdpConfig)(basePath, yamlPath);
38
- const manifestService = await adp_tooling_1.ManifestService.initBaseManifest(variant.reference, adpConfig, logger);
38
+ const { target, ignoreCertErrors = false } = await (0, adp_tooling_1.getAdpConfig)(basePath, yamlPath);
39
+ const provider = await (0, system_access_1.createAbapServiceProvider)(target, {
40
+ ignoreCertErrors
41
+ }, true, logger);
42
+ const manifestService = await adp_tooling_1.ManifestService.initBaseManifest(provider, variant.reference, logger);
39
43
  const dataSources = manifestService.getManifestDataSources();
40
44
  const answers = await (0, common_1.promptYUIQuestions)((0, adp_tooling_1.getPromptsForChangeDataSource)(dataSources), false);
41
45
  const fs = await (0, adp_tooling_1.generateChange)(basePath, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, {
@@ -5,6 +5,14 @@ type AutoCompleteCallbackFn = (answers: Answers, input: string) => Promise<Array
5
5
  name: string;
6
6
  value: unknown;
7
7
  }>>;
8
+ /**
9
+ * Filters out questions from an array that are marked with the type 'label' in their GUI options.
10
+ *
11
+ * @param {YUIQuestion<T>[]} questions - An array of questions or prompts, where each question can contain various GUI options.
12
+ * @returns {Promise<YUIQuestion<T>[]>} A promise that resolves to an array of questions, excluding those with a 'label' type.
13
+ * @template T - The generic type parameter that extends Answers, used to type the questions array.
14
+ */
15
+ export declare function filterLabelTypeQuestions<T extends Answers>(questions: YUIQuestion<T>[]): Promise<YUIQuestion<T>[]>;
8
16
  /**
9
17
  * Converts a YUI question to a simple prompts question.
10
18
  *
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.filterLabelTypeQuestions = filterLabelTypeQuestions;
6
7
  exports.convertQuestion = convertQuestion;
7
8
  exports.promptYUIQuestions = promptYUIQuestions;
8
9
  const prompts_1 = __importDefault(require("prompts"));
@@ -34,6 +35,16 @@ function mapChoices(choices) {
34
35
  value: typeof choice === 'object' ? choice.value : choice
35
36
  }));
36
37
  }
38
+ /**
39
+ * Filters out questions from an array that are marked with the type 'label' in their GUI options.
40
+ *
41
+ * @param {YUIQuestion<T>[]} questions - An array of questions or prompts, where each question can contain various GUI options.
42
+ * @returns {Promise<YUIQuestion<T>[]>} A promise that resolves to an array of questions, excluding those with a 'label' type.
43
+ * @template T - The generic type parameter that extends Answers, used to type the questions array.
44
+ */
45
+ async function filterLabelTypeQuestions(questions) {
46
+ return questions.filter((question) => question?.guiOptions?.type !== 'label');
47
+ }
37
48
  /**
38
49
  * Enhances the new prompt with the choices from the original list question.
39
50
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/create",
3
3
  "description": "SAP Fiori tools module to add or remove features",
4
- "version": "0.10.12",
4
+ "version": "0.11.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,21 +30,20 @@
30
30
  "mem-fs": "2.1.0",
31
31
  "mem-fs-editor": "9.4.0",
32
32
  "prompts": "2.4.2",
33
- "@sap-ux/abap-deploy-config-inquirer": "1.1.9",
33
+ "@sap-ux/abap-deploy-config-inquirer": "1.1.10",
34
34
  "@sap-ux/abap-deploy-config-writer": "0.0.68",
35
- "@sap-ux/adp-tooling": "0.12.94",
35
+ "@sap-ux/adp-tooling": "0.12.95",
36
36
  "@sap-ux/app-config-writer": "0.5.5",
37
37
  "@sap-ux/cap-config-writer": "0.7.64",
38
38
  "@sap-ux/cards-editor-config-writer": "0.4.8",
39
- "@sap-ux/inquirer-common": "0.5.10",
40
39
  "@sap-ux/logger": "0.6.0",
41
40
  "@sap-ux/mockserver-config-writer": "0.7.0",
42
41
  "@sap-ux/odata-service-writer": "0.24.1",
43
- "@sap-ux/preview-middleware": "0.16.146",
42
+ "@sap-ux/preview-middleware": "0.16.147",
44
43
  "@sap-ux/project-access": "1.28.9",
45
44
  "@sap-ux/system-access": "0.5.22",
46
45
  "@sap-ux/ui5-config": "0.26.0",
47
- "@sap-ux/flp-config-inquirer": "0.1.6"
46
+ "@sap-ux/flp-config-inquirer": "0.2.0"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@types/diff": "5.0.9",
@@ -52,7 +51,7 @@
52
51
  "@types/mem-fs": "1.1.2",
53
52
  "@types/mem-fs-editor": "7.0.1",
54
53
  "@types/prompts": "2.4.4",
55
- "@sap-ux/inquirer-common": "0.5.10",
54
+ "@sap-ux/inquirer-common": "0.5.11",
56
55
  "@sap-ux/store": "0.9.3"
57
56
  },
58
57
  "scripts": {