@sap-ux/repo-app-import-sub-generator 0.3.151 → 0.3.153
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.
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
import { type FioriElementsApp, type LROPSettings } from '@sap-ux/fiori-elements-writer';
|
|
2
|
+
import type { AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
2
3
|
import type { Editor } from 'mem-fs-editor';
|
|
3
4
|
import type { AppInfo, QfaJsonConfig } from '../app/types';
|
|
4
5
|
import type { AbapDeployConfig } from '@sap-ux/ui5-config';
|
|
5
6
|
import { type OdataServiceAnswers } from '@sap-ux/odata-service-inquirer';
|
|
7
|
+
/**
|
|
8
|
+
* Shared context for downloading and deploying ABAP applications.
|
|
9
|
+
*/
|
|
10
|
+
export interface AppDownloadContext {
|
|
11
|
+
serviceProvider?: AbapServiceProvider;
|
|
12
|
+
qfaJson: QfaJsonConfig;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Generates the deployment configuration for an ABAP application.
|
|
8
16
|
*
|
|
9
|
-
* @param {
|
|
17
|
+
* @param {AppDownloadContext} context - The download context with service provider and qfa info.
|
|
10
18
|
* @returns {AbapDeployConfig} The deployment configuration containing `target` and `app` info.
|
|
11
19
|
*/
|
|
12
|
-
export declare const getAbapDeployConfig: (
|
|
20
|
+
export declare const getAbapDeployConfig: (context: AppDownloadContext) => Promise<AbapDeployConfig>;
|
|
13
21
|
/**
|
|
14
22
|
* Gets the application configuration based on the provided user answers and manifest data.
|
|
15
23
|
* This configuration will be used to initialize a new Fiori application.
|
|
16
24
|
*
|
|
17
25
|
* @param {AppInfo} app - Selected app information.
|
|
18
26
|
* @param {string} extractedProjectPath - Path where the app files are extracted.
|
|
19
|
-
* @param {
|
|
27
|
+
* @param {AppDownloadContext} context - The download context with service provider and qfa info.
|
|
20
28
|
* @param {OdataServiceAnswers} systemSelection - User's selection of the OData service and system.
|
|
21
29
|
* @param {Editor} fs - The file system editor to manipulate project files.
|
|
22
30
|
* @returns {Promise<FioriElementsApp<LROPSettings>>} - A promise resolving to the generated app configuration.
|
|
23
31
|
* @throws {Error} - Throws an error if there are issues generating the configuration.
|
|
24
32
|
*/
|
|
25
|
-
export declare function getAppConfig(app: AppInfo, extractedProjectPath: string,
|
|
33
|
+
export declare function getAppConfig(app: AppInfo, extractedProjectPath: string, context: AppDownloadContext, systemSelection: OdataServiceAnswers, fs: Editor): Promise<FioriElementsApp<LROPSettings>>;
|
|
26
34
|
//# sourceMappingURL=app-config.d.ts.map
|
|
@@ -7,6 +7,7 @@ exports.getAbapDeployConfig = void 0;
|
|
|
7
7
|
exports.getAppConfig = getAppConfig;
|
|
8
8
|
const fiori_elements_writer_1 = require("@sap-ux/fiori-elements-writer");
|
|
9
9
|
const odata_service_inquirer_1 = require("@sap-ux/odata-service-inquirer");
|
|
10
|
+
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
10
11
|
const i18n_1 = require("../utils/i18n");
|
|
11
12
|
const file_helpers_1 = require("../utils/file-helpers");
|
|
12
13
|
const constants_1 = require("../utils/constants");
|
|
@@ -15,13 +16,50 @@ const logger_1 = __importDefault(require("../utils/logger"));
|
|
|
15
16
|
const project_access_1 = require("@sap-ux/project-access");
|
|
16
17
|
const node_path_1 = require("node:path");
|
|
17
18
|
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a transport request for the given app/package context.
|
|
21
|
+
* This function performs defensive checks and logs clear, actionable messages.
|
|
22
|
+
*
|
|
23
|
+
* @param context - AppDownloadContext containing qfaJson and serviceProvider
|
|
24
|
+
* @returns { Promise<string> } - Resolved transport request string
|
|
25
|
+
* - '' when package is local ('$TMP')
|
|
26
|
+
* - '<transport-request-id>' when transport request is found
|
|
27
|
+
* - 'REPLACE_WITH_TRANSPORT' when no transport request is found
|
|
28
|
+
* @throws Error when the transport check fails
|
|
29
|
+
*/
|
|
30
|
+
async function resolveTransportRequest(context) {
|
|
31
|
+
const { serviceProvider, qfaJson } = context;
|
|
32
|
+
const packageName = qfaJson.metadata.package;
|
|
33
|
+
const appName = qfaJson.deploymentDetails.repositoryName;
|
|
34
|
+
if (packageName === '$TMP') {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const transportService = await serviceProvider?.getAdtService(axios_extension_1.TransportChecksService);
|
|
39
|
+
const transportRequests = await transportService?.getTransportRequests(packageName, appName);
|
|
40
|
+
if (transportRequests?.length === 1) {
|
|
41
|
+
return transportRequests[0].transportNumber;
|
|
42
|
+
}
|
|
43
|
+
return 'REPLACE_WITH_TRANSPORT';
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error.message === axios_extension_1.TransportChecksService.LocalPackageError) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
const msg = (0, i18n_1.t)('error.transportCheckFailed', { error: error?.message });
|
|
50
|
+
logger_1.default.logger?.error(msg);
|
|
51
|
+
throw new Error(msg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
18
54
|
/**
|
|
19
55
|
* Generates the deployment configuration for an ABAP application.
|
|
20
56
|
*
|
|
21
|
-
* @param {
|
|
57
|
+
* @param {AppDownloadContext} context - The download context with service provider and qfa info.
|
|
22
58
|
* @returns {AbapDeployConfig} The deployment configuration containing `target` and `app` info.
|
|
23
59
|
*/
|
|
24
|
-
const getAbapDeployConfig = (
|
|
60
|
+
const getAbapDeployConfig = async (context) => {
|
|
61
|
+
const { qfaJson } = context;
|
|
62
|
+
const transportRequest = await resolveTransportRequest(context);
|
|
25
63
|
return {
|
|
26
64
|
target: {
|
|
27
65
|
url: prompt_state_1.PromptState.baseURL,
|
|
@@ -32,7 +70,7 @@ const getAbapDeployConfig = (qfaJson) => {
|
|
|
32
70
|
name: qfaJson.deploymentDetails.repositoryName,
|
|
33
71
|
package: qfaJson.metadata.package,
|
|
34
72
|
description: qfaJson.deploymentDetails.repositoryDescription,
|
|
35
|
-
transport:
|
|
73
|
+
transport: transportRequest
|
|
36
74
|
}
|
|
37
75
|
}; // NOSONAR
|
|
38
76
|
};
|
|
@@ -46,9 +84,9 @@ exports.getAbapDeployConfig = getAbapDeployConfig;
|
|
|
46
84
|
*/
|
|
47
85
|
const fetchServiceMetadata = async (provider, serviceUrl) => {
|
|
48
86
|
try {
|
|
49
|
-
const
|
|
87
|
+
const metadata = await provider.service(serviceUrl).metadata();
|
|
50
88
|
logger_1.default.logger?.debug('Metadata fetched successfully');
|
|
51
|
-
return
|
|
89
|
+
return metadata;
|
|
52
90
|
}
|
|
53
91
|
catch (err) {
|
|
54
92
|
logger_1.default.logger?.error((0, i18n_1.t)('error.metadataFetchError', { error: err.message }));
|
|
@@ -60,16 +98,17 @@ const fetchServiceMetadata = async (provider, serviceUrl) => {
|
|
|
60
98
|
*
|
|
61
99
|
* @param {AppInfo} app - Selected app information.
|
|
62
100
|
* @param {string} extractedProjectPath - Path where the app files are extracted.
|
|
63
|
-
* @param {
|
|
101
|
+
* @param {AppDownloadContext} context - The download context with service provider and qfa info.
|
|
64
102
|
* @param {OdataServiceAnswers} systemSelection - User's selection of the OData service and system.
|
|
65
103
|
* @param {Editor} fs - The file system editor to manipulate project files.
|
|
66
104
|
* @returns {Promise<FioriElementsApp<LROPSettings>>} - A promise resolving to the generated app configuration.
|
|
67
105
|
* @throws {Error} - Throws an error if there are issues generating the configuration.
|
|
68
106
|
*/
|
|
69
|
-
async function getAppConfig(app, extractedProjectPath,
|
|
107
|
+
async function getAppConfig(app, extractedProjectPath, context, systemSelection, fs) {
|
|
70
108
|
try {
|
|
71
109
|
const manifest = (0, file_helpers_1.readManifest)((0, node_path_1.join)(extractedProjectPath, project_access_1.FileName.Manifest), fs);
|
|
72
110
|
const serviceProvider = prompt_state_1.PromptState.systemSelection?.connectedSystem?.serviceProvider;
|
|
111
|
+
context.serviceProvider = serviceProvider;
|
|
73
112
|
if (!manifest?.['sap.app']?.dataSources) {
|
|
74
113
|
logger_1.default.logger?.error((0, i18n_1.t)('error.dataSourcesNotFound'));
|
|
75
114
|
}
|
|
@@ -103,7 +142,7 @@ async function getAppConfig(app, extractedProjectPath, qfaJson, systemSelection,
|
|
|
103
142
|
type: fiori_elements_writer_1.TemplateType.ListReportObjectPage,
|
|
104
143
|
settings: {
|
|
105
144
|
entityConfig: {
|
|
106
|
-
mainEntityName: qfaJson.serviceBindingDetails.mainEntityName
|
|
145
|
+
mainEntityName: context.qfaJson.serviceBindingDetails.mainEntityName
|
|
107
146
|
}
|
|
108
147
|
}
|
|
109
148
|
},
|
package/generators/app/index.js
CHANGED
|
@@ -123,11 +123,14 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
123
123
|
const qfaJson = (0, file_helpers_1.makeValidJson)(qfaJsonFilePath, this.fs);
|
|
124
124
|
// Generate project files
|
|
125
125
|
(0, validators_1.validateQfaJsonFile)(qfaJson);
|
|
126
|
+
const context = {
|
|
127
|
+
qfaJson
|
|
128
|
+
};
|
|
126
129
|
// Generate app config
|
|
127
|
-
const config = await (0, app_config_1.getAppConfig)(this.answers.selectedApp, this.extractedProjectPath,
|
|
130
|
+
const config = await (0, app_config_1.getAppConfig)(this.answers.selectedApp, this.extractedProjectPath, context, this.answers.systemSelection, this.fs);
|
|
128
131
|
await (0, fiori_elements_writer_1.generate)(this.projectPath, config, this.fs);
|
|
129
132
|
// Generate deploy config
|
|
130
|
-
const deployConfig = (0, app_config_1.getAbapDeployConfig)(
|
|
133
|
+
const deployConfig = await (0, app_config_1.getAbapDeployConfig)(context);
|
|
131
134
|
await (0, abap_deploy_config_writer_1.generate)(this.projectPath, deployConfig, undefined, this.fs);
|
|
132
135
|
if (this.vscode) {
|
|
133
136
|
// Generate Fiori launch config
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"invalidManifestStructureError": "Invalid `manifest.json file` structure: `sap.ui5` or `sap.app` are missing. Check they exist."
|
|
40
40
|
},
|
|
41
41
|
"quickDeployedAppDownloadErrors": {
|
|
42
|
-
"noAppsFound": "No application with the ID {{ appId }} was found in the system. Please check if the application is deployed correctly or select another app."
|
|
42
|
+
"noAppsFound": "No application with the ID {{ appId }} was found in the system. Please check if the application is deployed correctly or select another app.",
|
|
43
|
+
"transportCheckFailed": "Transport request resolution failed with error: {error}."
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"warn": {
|
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.
|
|
4
|
+
"version": "0.3.153",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@sap-ux/fiori-generator-shared": "0.13.33",
|
|
29
29
|
"@sap-ux/inquirer-common": "0.9.3",
|
|
30
30
|
"@sap-ux/project-access": "1.32.8",
|
|
31
|
-
"@sap-ux/odata-service-inquirer": "2.11.
|
|
31
|
+
"@sap-ux/odata-service-inquirer": "2.11.5",
|
|
32
32
|
"@sap-ux/fiori-elements-writer": "2.8.0",
|
|
33
33
|
"@sap-ux/logger": "0.7.1",
|
|
34
34
|
"@sap-ux/project-input-validator": "0.6.30",
|