@sap-ux/repo-app-import-sub-generator 0.3.17 → 0.3.18

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,14 +2,14 @@ import { type FioriElementsApp, type LROPSettings } from '@sap-ux/fiori-elements
2
2
  import type { Editor } from 'mem-fs-editor';
3
3
  import type { AppInfo, QfaJsonConfig } from '../app/types';
4
4
  import type { AbapDeployConfig } from '@sap-ux/ui5-config';
5
+ import { type OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
5
6
  /**
6
7
  * Generates the deployment configuration for an ABAP application.
7
8
  *
8
- * @param {AppInfo} app - Application info containing `url` and `repoName`.
9
9
  * @param {QfaJsonConfig} qfaJson - The QFA JSON configuration containing app details.
10
10
  * @returns {AbapDeployConfig} The deployment configuration containing `target` and `app` info.
11
11
  */
12
- export declare const getAbapDeployConfig: (app: AppInfo, qfaJson: QfaJsonConfig) => AbapDeployConfig;
12
+ export declare const getAbapDeployConfig: (qfaJson: QfaJsonConfig) => AbapDeployConfig;
13
13
  /**
14
14
  * Gets the application configuration based on the provided user answers and manifest data.
15
15
  * This configuration will be used to initialize a new Fiori application.
@@ -17,9 +17,10 @@ export declare const getAbapDeployConfig: (app: AppInfo, qfaJson: QfaJsonConfig)
17
17
  * @param {AppInfo} app - Selected app information.
18
18
  * @param {string} extractedProjectPath - Path where the app files are extracted.
19
19
  * @param {QfaJsonConfig} qfaJson - The QFA JSON configuration containing app details.
20
+ * @param {OdataServiceAnswers} systemSelection - User's selection of the OData service and system.
20
21
  * @param {Editor} fs - The file system editor to manipulate project files.
21
22
  * @returns {Promise<FioriElementsApp<LROPSettings>>} - A promise resolving to the generated app configuration.
22
23
  * @throws {Error} - Throws an error if there are issues generating the configuration.
23
24
  */
24
- export declare function getAppConfig(app: AppInfo, extractedProjectPath: string, qfaJson: QfaJsonConfig, fs: Editor): Promise<FioriElementsApp<LROPSettings>>;
25
+ export declare function getAppConfig(app: AppInfo, extractedProjectPath: string, qfaJson: QfaJsonConfig, systemSelection: OdataServiceAnswers, fs: Editor): Promise<FioriElementsApp<LROPSettings>>;
25
26
  //# sourceMappingURL=app-config.d.ts.map
@@ -17,16 +17,15 @@ const ui5_info_1 = require("@sap-ux/ui5-info");
17
17
  /**
18
18
  * Generates the deployment configuration for an ABAP application.
19
19
  *
20
- * @param {AppInfo} app - Application info containing `url` and `repoName`.
21
20
  * @param {QfaJsonConfig} qfaJson - The QFA JSON configuration containing app details.
22
21
  * @returns {AbapDeployConfig} The deployment configuration containing `target` and `app` info.
23
22
  */
24
- const getAbapDeployConfig = (app, qfaJson) => {
23
+ const getAbapDeployConfig = (qfaJson) => {
25
24
  return {
26
25
  target: {
27
26
  url: prompt_state_1.PromptState.baseURL,
28
27
  client: prompt_state_1.PromptState.sapClient,
29
- destination: app.repoName
28
+ destination: prompt_state_1.PromptState.destinationName
30
29
  },
31
30
  app: {
32
31
  name: qfaJson.deploymentDetails.repositoryName,
@@ -34,7 +33,7 @@ const getAbapDeployConfig = (app, qfaJson) => {
34
33
  description: qfaJson.deploymentDetails.repositoryDescription,
35
34
  transport: 'REPLACE_WITH_TRANSPORT'
36
35
  }
37
- };
36
+ }; // NOSONAR
38
37
  };
39
38
  exports.getAbapDeployConfig = getAbapDeployConfig;
40
39
  /**
@@ -61,11 +60,12 @@ const fetchServiceMetadata = async (provider, serviceUrl) => {
61
60
  * @param {AppInfo} app - Selected app information.
62
61
  * @param {string} extractedProjectPath - Path where the app files are extracted.
63
62
  * @param {QfaJsonConfig} qfaJson - The QFA JSON configuration containing app details.
63
+ * @param {OdataServiceAnswers} systemSelection - User's selection of the OData service and system.
64
64
  * @param {Editor} fs - The file system editor to manipulate project files.
65
65
  * @returns {Promise<FioriElementsApp<LROPSettings>>} - A promise resolving to the generated app configuration.
66
66
  * @throws {Error} - Throws an error if there are issues generating the configuration.
67
67
  */
68
- async function getAppConfig(app, extractedProjectPath, qfaJson, fs) {
68
+ async function getAppConfig(app, extractedProjectPath, qfaJson, systemSelection, fs) {
69
69
  try {
70
70
  const manifest = (0, file_helpers_1.readManifest)((0, path_1.join)(extractedProjectPath, project_access_1.FileName.Manifest), fs);
71
71
  const serviceProvider = prompt_state_1.PromptState.systemSelection?.connectedSystem?.serviceProvider;
@@ -110,7 +110,8 @@ async function getAppConfig(app, extractedProjectPath, qfaJson, fs) {
110
110
  path: manifest?.['sap.app']?.dataSources?.mainService.uri,
111
111
  version: odataVersion,
112
112
  metadata: metadata,
113
- url: serviceProvider.defaults.baseURL
113
+ url: prompt_state_1.PromptState.baseURL,
114
+ client: prompt_state_1.PromptState.sapClient
114
115
  },
115
116
  appOptions: {
116
117
  addAnnotations: odataVersion === odata_service_inquirer_1.OdataVersion.v4,
@@ -120,6 +121,9 @@ async function getAppConfig(app, extractedProjectPath, qfaJson, fs) {
120
121
  localVersion
121
122
  }
122
123
  };
124
+ if (prompt_state_1.PromptState.destinationName) {
125
+ appConfig.service.destination = { name: prompt_state_1.PromptState.destinationName };
126
+ }
123
127
  return appConfig;
124
128
  }
125
129
  catch (error) {
@@ -124,10 +124,10 @@ class default_1 extends yeoman_generator_1.default {
124
124
  // Generate project files
125
125
  (0, validators_1.validateQfaJsonFile)(qfaJson);
126
126
  // Generate app config
127
- const config = await (0, app_config_1.getAppConfig)(this.answers.selectedApp, this.extractedProjectPath, qfaJson, this.fs);
127
+ const config = await (0, app_config_1.getAppConfig)(this.answers.selectedApp, this.extractedProjectPath, qfaJson, this.answers.systemSelection, this.fs);
128
128
  await (0, fiori_elements_writer_1.generate)(this.projectPath, config, this.fs);
129
129
  // Generate deploy config
130
- const deployConfig = (0, app_config_1.getAbapDeployConfig)(this.answers.selectedApp, qfaJson);
130
+ const deployConfig = (0, app_config_1.getAbapDeployConfig)(qfaJson);
131
131
  await (0, abap_deploy_config_writer_1.generate)(this.projectPath, deployConfig, undefined, this.fs);
132
132
  if (this.vscode) {
133
133
  // Generate Fiori launch config
@@ -1,9 +1,8 @@
1
1
  import type Generator from 'yeoman-generator';
2
2
  import type { AppWizard } from '@sap-devx/yeoman-ui-types';
3
3
  import type { VSCodeInstance, TelemetryData, LogWrapper } from '@sap-ux/fiori-generator-shared';
4
- import type { Destination } from '@sap-ux/btp-utils';
5
- import type { BackendSystem } from '@sap-ux/store';
6
- import type { AbapServiceProvider, AppIndex } from '@sap-ux/axios-extension';
4
+ import type { AppIndex } from '@sap-ux/axios-extension';
5
+ import type { OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
7
6
  import type { YUIQuestion } from '@sap-ux/inquirer-common';
8
7
  import type { AutocompleteQuestionOptions } from 'inquirer-autocomplete-prompt';
9
8
  /**
@@ -46,27 +45,6 @@ export interface RepoAppDownloadOptions extends Generator.GeneratorOptions {
46
45
  /** Logger instance for logging operations. */
47
46
  logWrapper?: LogWrapper;
48
47
  }
49
- /**
50
- * Answers related to system selection in the application download process.
51
- */
52
- export interface SystemSelectionAnswers {
53
- /**
54
- * Details of the connected system allowing downstream consumers to access it without creating new connections.
55
- */
56
- connectedSystem?: {
57
- /** Service provider for the connected ABAP system. */
58
- serviceProvider: AbapServiceProvider;
59
- /**
60
- * Persistable backend system representation of the connected service provider.
61
- * `newOrUpdated` is true if the system was newly created or updated during connection validation.
62
- */
63
- backendSystem?: BackendSystem & {
64
- newOrUpdated?: boolean;
65
- };
66
- /** Destination details of the connected system. */
67
- destination?: Destination;
68
- };
69
- }
70
48
  /**
71
49
  * Represents a question in the app download process.
72
50
  * Extends `YUIQuestion` with optional autocomplete functionality.
@@ -93,7 +71,7 @@ export declare enum PromptNames {
93
71
  */
94
72
  export interface RepoAppDownloadAnswers {
95
73
  /** Selected backend system connection details. */
96
- [PromptNames.systemSelection]: SystemSelectionAnswers;
74
+ [PromptNames.systemSelection]: OdataServiceAnswers;
97
75
  /** Information about the selected application for download. */
98
76
  [PromptNames.selectedApp]: AppInfo;
99
77
  /** Target folder where the application will be generated. */
@@ -1,5 +1,6 @@
1
- import type { AbapServiceProvider, AppIndex } from '@sap-ux/axios-extension';
1
+ import type { AppIndex } from '@sap-ux/axios-extension';
2
2
  import type { AppInfo, AppItem } from '../app/types';
3
+ import { type ConnectedSystem } from '@sap-ux/odata-service-inquirer';
3
4
  /**
4
5
  * Returns the details for the YUI prompt.
5
6
  *
@@ -32,9 +33,9 @@ export declare const formatAppChoices: (appList: AppIndex) => Array<{
32
33
  /**
33
34
  * Fetches the application list for the selected system.
34
35
  *
35
- * @param {AbapServiceProvider} serviceProvider - The ABAP service provider.
36
+ * @param {ConnectedSystem} connectedSystem - The ABAP service provider.
36
37
  * @param {string} appId - Application ID to be downloaded.
37
38
  * @returns {Promise<AppIndex>} A list of applications filtered by source template.
38
39
  */
39
- export declare function fetchAppListForSelectedSystem(serviceProvider: AbapServiceProvider, appId?: string): Promise<AppIndex>;
40
+ export declare function fetchAppListForSelectedSystem(connectedSystem: ConnectedSystem, appId?: string): Promise<AppIndex>;
40
41
  //# sourceMappingURL=prompt-helpers.d.ts.map
@@ -96,16 +96,16 @@ async function getAppList(provider, appId) {
96
96
  /**
97
97
  * Fetches the application list for the selected system.
98
98
  *
99
- * @param {AbapServiceProvider} serviceProvider - The ABAP service provider.
99
+ * @param {ConnectedSystem} connectedSystem - The ABAP service provider.
100
100
  * @param {string} appId - Application ID to be downloaded.
101
101
  * @returns {Promise<AppIndex>} A list of applications filtered by source template.
102
102
  */
103
- async function fetchAppListForSelectedSystem(serviceProvider, appId) {
104
- if (serviceProvider) {
103
+ async function fetchAppListForSelectedSystem(connectedSystem, appId) {
104
+ if (connectedSystem?.serviceProvider) {
105
105
  prompt_state_1.PromptState.systemSelection = {
106
- connectedSystem: { serviceProvider }
106
+ connectedSystem: connectedSystem
107
107
  };
108
- return await getAppList(serviceProvider, appId);
108
+ return await getAppList(connectedSystem.serviceProvider, appId);
109
109
  }
110
110
  return [];
111
111
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import type { SystemSelectionAnswers } from '../app/types';
3
2
  import AdmZip from 'adm-zip';
3
+ import { type OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
4
4
  /**
5
5
  * Much of the values returned by the app downloader prompting are derived from prompt answers and are not direct answer values.
6
6
  * Since inquirer does not provide a way to return values that are not direct answers from prompts, this class will maintain the derived values
@@ -15,13 +15,13 @@ export declare class PromptState {
15
15
  *
16
16
  * @returns {SystemSelectionAnswers} service config
17
17
  */
18
- static get systemSelection(): SystemSelectionAnswers;
18
+ static get systemSelection(): OdataServiceAnswers;
19
19
  /**
20
20
  * Set the state of the system selection.
21
21
  *
22
- * @param {SystemSelectionAnswers} value - system selection value
22
+ * @param {OdataServiceAnswers} value - system selection value
23
23
  */
24
- static set systemSelection(value: Partial<SystemSelectionAnswers>);
24
+ static set systemSelection(value: Partial<OdataServiceAnswers>);
25
25
  /**
26
26
  * Set the downloaded app package.
27
27
  */
@@ -44,6 +44,12 @@ export declare class PromptState {
44
44
  * @returns {string | undefined} sap-client
45
45
  */
46
46
  static get sapClient(): string | undefined;
47
+ /**
48
+ * Get the destination parameter from the connected system's service provider defaults.
49
+ *
50
+ * @returns {string | undefined} sap-client
51
+ */
52
+ static get destinationName(): string | undefined;
47
53
  static reset(): void;
48
54
  }
49
55
  //# sourceMappingURL=prompt-state.d.ts.map
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PromptState = void 0;
7
7
  const adm_zip_1 = __importDefault(require("adm-zip"));
8
+ const odata_service_inquirer_1 = require("@sap-ux/odata-service-inquirer");
8
9
  /**
9
10
  * Much of the values returned by the app downloader prompting are derived from prompt answers and are not direct answer values.
10
11
  * Since inquirer does not provide a way to return values that are not direct answers from prompts, this class will maintain the derived values
@@ -12,7 +13,7 @@ const adm_zip_1 = __importDefault(require("adm-zip"));
12
13
  *
13
14
  */
14
15
  class PromptState {
15
- static _systemSelection = {};
16
+ static _systemSelection = { datasourceType: odata_service_inquirer_1.DatasourceType.sapSystem };
16
17
  static _admZipInstance;
17
18
  /**
18
19
  * Returns the current state of the service config.
@@ -25,10 +26,10 @@ class PromptState {
25
26
  /**
26
27
  * Set the state of the system selection.
27
28
  *
28
- * @param {SystemSelectionAnswers} value - system selection value
29
+ * @param {OdataServiceAnswers} value - system selection value
29
30
  */
30
31
  static set systemSelection(value) {
31
- this._systemSelection = value;
32
+ this._systemSelection = value; // NOSONAR
32
33
  }
33
34
  /**
34
35
  * Set the downloaded app package.
@@ -50,7 +51,8 @@ class PromptState {
50
51
  * @returns {string | undefined} baseURL
51
52
  */
52
53
  static get baseURL() {
53
- return this._systemSelection.connectedSystem?.serviceProvider?.defaults?.baseURL;
54
+ return (this._systemSelection.connectedSystem?.backendSystem?.url ??
55
+ this._systemSelection.connectedSystem?.destination?.Host);
54
56
  }
55
57
  /**
56
58
  * Get the sap-client parameter from the connected system's service provider defaults.
@@ -58,7 +60,16 @@ class PromptState {
58
60
  * @returns {string | undefined} sap-client
59
61
  */
60
62
  static get sapClient() {
61
- return this._systemSelection.connectedSystem?.serviceProvider?.defaults?.params?.['sap-client'];
63
+ return (this._systemSelection.connectedSystem?.backendSystem?.client ??
64
+ this._systemSelection.connectedSystem?.destination?.['sap-client']);
65
+ }
66
+ /**
67
+ * Get the destination parameter from the connected system's service provider defaults.
68
+ *
69
+ * @returns {string | undefined} sap-client
70
+ */
71
+ static get destinationName() {
72
+ return this._systemSelection.connectedSystem?.destination?.Name;
62
73
  }
63
74
  static reset() {
64
75
  PromptState.systemSelection = {};
@@ -47,8 +47,9 @@ const getTargetFolderPrompt = (appRootPath, appId) => {
47
47
  default: () => appRootPath
48
48
  };
49
49
  };
50
- const getCliValidatePrompts = async (appList, quickDeployedAppConfig, appWizard) => {
50
+ const getCliValidatePrompts = (appList, quickDeployedAppConfig, appWizard) => {
51
51
  return {
52
+ type: 'input',
52
53
  when: async (answers) => {
53
54
  if (answers?.[types_1.PromptNames.selectedApp]) {
54
55
  try {
@@ -90,7 +91,7 @@ async function getPrompts(appRootPath, quickDeployedAppConfig, appWizard, isCli
90
91
  when: async (answers) => {
91
92
  if (answers[types_1.PromptNames.systemSelection] &&
92
93
  systemQuestions.answers.connectedSystem?.serviceProvider) {
93
- appList = await (0, prompt_helpers_1.fetchAppListForSelectedSystem)(systemQuestions.answers.connectedSystem?.serviceProvider, quickDeployedAppConfig?.appId);
94
+ appList = await (0, prompt_helpers_1.fetchAppListForSelectedSystem)(systemQuestions.answers.connectedSystem, quickDeployedAppConfig?.appId);
94
95
  }
95
96
  return !!systemQuestions.answers.connectedSystem?.serviceProvider;
96
97
  },
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appListResultFields = exports.appListSearchParams = exports.extractedFilePath = exports.defaultAnswers = exports.qfaJsonFileName = exports.fioriAppSourcetemplateId = exports.adtSourceTemplateId = exports.generatorName = exports.generatorDescription = exports.generatorTitle = void 0;
4
+ const odata_service_inquirer_1 = require("@sap-ux/odata-service-inquirer");
4
5
  const types_1 = require("../app/types");
5
6
  // Title and description for the generator
6
7
  exports.generatorTitle = 'Download ADT deployed app from UI5 ABAP repository';
@@ -15,7 +16,7 @@ exports.fioriAppSourcetemplateId = '@sap/generator-fiori:lrop';
15
16
  exports.qfaJsonFileName = 'qfa.json';
16
17
  // Default initial answers to use as a fallback.
17
18
  exports.defaultAnswers = {
18
- [types_1.PromptNames.systemSelection]: {},
19
+ [types_1.PromptNames.systemSelection]: { datasourceType: odata_service_inquirer_1.DatasourceType.sapSystem },
19
20
  [types_1.PromptNames.selectedApp]: {
20
21
  appId: '',
21
22
  title: '',
@@ -119,7 +119,7 @@ async function validateAppSelection(answers, appList, quickDeployedAppConfig, ap
119
119
  return await generateAppNotFoundHelpLink();
120
120
  }
121
121
  // No apps available at all
122
- if (appList.length === 0) {
122
+ if (appList.length === 0 && !answers?.appId) {
123
123
  return await generateAppNotFoundHelpLink();
124
124
  }
125
125
  // Valid app selected, try to download
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/repo-app-import-sub-generator",
3
3
  "description": "Generator to download LROP Fiori applications deployed from an ABAP repository.",
4
- "version": "0.3.17",
4
+ "version": "0.3.18",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,18 +29,18 @@
29
29
  "@sap-ux/inquirer-common": "0.7.5",
30
30
  "@sap-ux/project-access": "1.30.2",
31
31
  "@sap-ux/odata-service-inquirer": "2.4.11",
32
- "@sap-ux/fiori-elements-writer": "2.4.10",
33
32
  "@sap-ux/logger": "0.7.0",
33
+ "@sap-ux/fiori-elements-writer": "2.4.10",
34
34
  "@sap-ux/project-input-validator": "0.6.2",
35
35
  "@sap-ux/launch-config": "0.10.2",
36
36
  "@sap-ux/fiori-tools-settings": "0.2.0",
37
- "@sap-ux/abap-deploy-config-writer": "0.1.4",
38
37
  "@sap-ux/btp-utils": "1.1.0",
39
38
  "@sap-ux/ui5-info": "0.11.0",
40
- "@sap-ux/axios-extension": "1.21.2",
39
+ "@sap-ux/abap-deploy-config-writer": "0.1.4",
41
40
  "@sap-ux/store": "1.1.0",
42
- "@sap-ux/system-access": "0.6.2",
43
- "@sap-ux/guided-answers-helper": "0.3.0"
41
+ "@sap-ux/axios-extension": "1.21.2",
42
+ "@sap-ux/guided-answers-helper": "0.3.0",
43
+ "@sap-ux/system-access": "0.6.2"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@jest/types": "29.6.3",