@sap-ux/adp-tooling 0.19.10 → 1.0.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.
- package/dist/abap/client.d.ts +1 -1
- package/dist/abap/client.js +8 -13
- package/dist/abap/config.js +5 -8
- package/dist/abap/index.d.ts +3 -3
- package/dist/abap/index.js +3 -19
- package/dist/abap/provider.js +5 -8
- package/dist/base/abap/manifest-service.d.ts +1 -1
- package/dist/base/abap/manifest-service.js +9 -18
- package/dist/base/cf.js +8 -11
- package/dist/base/change-utils.d.ts +1 -1
- package/dist/base/change-utils.js +49 -62
- package/dist/base/constants/index.js +12 -15
- package/dist/base/credentials.d.ts +2 -2
- package/dist/base/credentials.js +6 -9
- package/dist/base/helper.d.ts +1 -1
- package/dist/base/helper.js +40 -57
- package/dist/base/project-builder.js +3 -6
- package/dist/base/prompt.d.ts +1 -1
- package/dist/base/prompt.js +19 -25
- package/dist/btp/api.d.ts +1 -1
- package/dist/btp/api.js +10 -18
- package/dist/btp/index.d.ts +1 -1
- package/dist/btp/index.js +1 -17
- package/dist/cf/app/discovery.d.ts +1 -1
- package/dist/cf/app/discovery.js +11 -18
- package/dist/cf/app/html5-repo.d.ts +1 -1
- package/dist/cf/app/html5-repo.js +24 -32
- package/dist/cf/app/index.d.ts +2 -2
- package/dist/cf/app/index.js +2 -18
- package/dist/cf/core/auth.d.ts +1 -1
- package/dist/cf/core/auth.js +4 -8
- package/dist/cf/core/config.d.ts +1 -1
- package/dist/cf/core/config.js +9 -15
- package/dist/cf/core/index.d.ts +2 -2
- package/dist/cf/core/index.js +2 -18
- package/dist/cf/deploy.d.ts +1 -1
- package/dist/cf/deploy.js +33 -44
- package/dist/cf/index.d.ts +6 -6
- package/dist/cf/index.js +6 -22
- package/dist/cf/project/index.d.ts +3 -3
- package/dist/cf/project/index.js +3 -19
- package/dist/cf/project/mta.d.ts +1 -1
- package/dist/cf/project/mta.js +23 -66
- package/dist/cf/project/yaml-loader.d.ts +1 -1
- package/dist/cf/project/yaml-loader.js +8 -16
- package/dist/cf/project/yaml.d.ts +2 -2
- package/dist/cf/project/yaml.js +28 -72
- package/dist/cf/services/api.d.ts +1 -1
- package/dist/cf/services/api.js +46 -93
- package/dist/cf/services/cli.d.ts +1 -1
- package/dist/cf/services/cli.js +31 -42
- package/dist/cf/services/destinations.js +12 -48
- package/dist/cf/services/index.d.ts +5 -5
- package/dist/cf/services/index.js +5 -21
- package/dist/cf/services/manifest.d.ts +1 -1
- package/dist/cf/services/manifest.js +9 -13
- package/dist/cf/services/ssh.js +14 -22
- package/dist/cf/utils/index.d.ts +1 -1
- package/dist/cf/utils/index.js +1 -17
- package/dist/cf/utils/validation.d.ts +1 -1
- package/dist/cf/utils/validation.js +12 -18
- package/dist/common/flp-parameters.d.ts +1 -1
- package/dist/common/flp-parameters.js +1 -4
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -17
- package/dist/i18n.js +8 -16
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -46
- package/dist/preview/adp-preview.d.ts +1 -1
- package/dist/preview/adp-preview.js +41 -39
- package/dist/preview/change-handler.d.ts +1 -1
- package/dist/preview/change-handler.js +51 -59
- package/dist/preview/descriptor-change-handler.d.ts +1 -1
- package/dist/preview/descriptor-change-handler.js +18 -21
- package/dist/preview/ovp-routes-handler.js +11 -13
- package/dist/preview/routes-handler.js +36 -71
- package/dist/preview/utils.d.ts +1 -1
- package/dist/preview/utils.js +5 -8
- package/dist/prompts/add-annotations-to-odata/index.d.ts +1 -1
- package/dist/prompts/add-annotations-to-odata/index.js +24 -26
- package/dist/prompts/add-component-usages/index.d.ts +1 -1
- package/dist/prompts/add-component-usages/index.js +41 -43
- package/dist/prompts/add-new-model/index.d.ts +1 -1
- package/dist/prompts/add-new-model/index.js +75 -80
- package/dist/prompts/change-data-source/index.d.ts +1 -1
- package/dist/prompts/change-data-source/index.js +19 -22
- package/dist/prompts/change-inbound/index.d.ts +1 -1
- package/dist/prompts/change-inbound/index.js +11 -14
- package/dist/prompts/index.d.ts +5 -5
- package/dist/prompts/index.js +5 -15
- package/dist/source/applications.d.ts +2 -2
- package/dist/source/applications.js +7 -11
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +3 -19
- package/dist/source/manifest.d.ts +1 -1
- package/dist/source/manifest.js +15 -25
- package/dist/source/systems.d.ts +1 -1
- package/dist/source/systems.js +20 -27
- package/dist/types.d.ts +1 -1
- package/dist/types.js +64 -17
- package/dist/ui5/fetch.d.ts +1 -1
- package/dist/ui5/fetch.js +8 -12
- package/dist/ui5/format.d.ts +1 -1
- package/dist/ui5/format.js +17 -29
- package/dist/ui5/index.d.ts +4 -4
- package/dist/ui5/index.js +4 -20
- package/dist/ui5/network.d.ts +1 -1
- package/dist/ui5/network.js +1 -4
- package/dist/ui5/validator.js +14 -20
- package/dist/ui5/version-info.d.ts +1 -1
- package/dist/ui5/version-info.js +25 -36
- package/dist/writer/cf.d.ts +1 -1
- package/dist/writer/cf.js +35 -43
- package/dist/writer/changes/writer-factory.d.ts +2 -2
- package/dist/writer/changes/writer-factory.js +10 -13
- package/dist/writer/changes/writers/annotations-writer.d.ts +1 -1
- package/dist/writer/changes/writers/annotations-writer.js +11 -46
- package/dist/writer/changes/writers/component-usages-writer.d.ts +1 -1
- package/dist/writer/changes/writers/component-usages-writer.js +9 -12
- package/dist/writer/changes/writers/data-source-writer.d.ts +1 -1
- package/dist/writer/changes/writers/data-source-writer.js +7 -10
- package/dist/writer/changes/writers/inbound-writer.d.ts +1 -1
- package/dist/writer/changes/writers/inbound-writer.js +10 -13
- package/dist/writer/changes/writers/index.d.ts +5 -5
- package/dist/writer/changes/writers/index.js +5 -21
- package/dist/writer/changes/writers/new-model-writer.d.ts +1 -1
- package/dist/writer/changes/writers/new-model-writer.js +16 -20
- package/dist/writer/editors.d.ts +1 -1
- package/dist/writer/editors.js +6 -9
- package/dist/writer/i18n/index.d.ts +1 -1
- package/dist/writer/i18n/index.js +13 -17
- package/dist/writer/i18n/key-user-translations.js +9 -14
- package/dist/writer/inbound-navigation.d.ts +1 -1
- package/dist/writer/inbound-navigation.js +18 -27
- package/dist/writer/index.d.ts +1 -1
- package/dist/writer/index.js +36 -37
- package/dist/writer/manifest/descriptor-content.d.ts +2 -2
- package/dist/writer/manifest/descriptor-content.js +9 -15
- package/dist/writer/manifest/index.d.ts +1 -1
- package/dist/writer/manifest/index.js +1 -17
- package/dist/writer/options.d.ts +1 -1
- package/dist/writer/options.js +16 -27
- package/dist/writer/project-utils.d.ts +1 -1
- package/dist/writer/project-utils.js +49 -57
- package/dist/writer/writer-config.d.ts +2 -2
- package/dist/writer/writer-config.js +25 -30
- package/package.json +19 -17
package/dist/cf/services/api.js
CHANGED
|
@@ -1,61 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getBusinessServiceInfo = getBusinessServiceInfo;
|
|
40
|
-
exports.getFDCRequestArguments = getFDCRequestArguments;
|
|
41
|
-
exports.getFDCApps = getFDCApps;
|
|
42
|
-
exports.getCfUi5AppInfo = getCfUi5AppInfo;
|
|
43
|
-
exports.getCfBaseAppInbounds = getCfBaseAppInbounds;
|
|
44
|
-
exports.createServiceInstance = createServiceInstance;
|
|
45
|
-
exports.getServiceNameByTags = getServiceNameByTags;
|
|
46
|
-
exports.createServices = createServices;
|
|
47
|
-
exports.getOrCreateServiceInstanceKeys = getOrCreateServiceInstanceKeys;
|
|
48
|
-
exports.getOrCreateServiceKeys = getOrCreateServiceKeys;
|
|
49
|
-
exports.getServiceTags = getServiceTags;
|
|
50
|
-
exports.getServiceKeyCredentialsWithTags = getServiceKeyCredentialsWithTags;
|
|
51
|
-
const fs = __importStar(require("node:fs"));
|
|
52
|
-
const axios_1 = __importDefault(require("axios"));
|
|
53
|
-
const path = __importStar(require("node:path"));
|
|
54
|
-
const cf_tools_1 = require("@sap/cf-tools");
|
|
55
|
-
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
56
|
-
const i18n_1 = require("../../i18n");
|
|
57
|
-
const project_1 = require("../project");
|
|
58
|
-
const cli_1 = require("./cli");
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { Cli } from '@sap/cf-tools';
|
|
6
|
+
import { dirname } from 'node:path';
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
import { isAppStudio } from '@sap-ux/btp-utils';
|
|
9
|
+
import { t } from '../../i18n.js';
|
|
10
|
+
import { getProjectNameForXsSecurity } from '../project/index.js';
|
|
11
|
+
import { createServiceKey, getServiceKeys, requestCfApi } from './cli.js';
|
|
59
12
|
const PARAM_MAP = new Map([
|
|
60
13
|
['spaceGuids', 'space_guids'],
|
|
61
14
|
['planNames', 'service_plan_names'],
|
|
@@ -69,7 +22,7 @@ const PARAM_MAP = new Map([
|
|
|
69
22
|
* @param {ToolsLogger} logger - The logger.
|
|
70
23
|
* @returns {Promise<ServiceInfo | null>} The service info.
|
|
71
24
|
*/
|
|
72
|
-
async function getBusinessServiceInfo(businessService, config, logger) {
|
|
25
|
+
export async function getBusinessServiceInfo(businessService, config, logger) {
|
|
73
26
|
const serviceKeys = await getOrCreateServiceInstanceKeys({
|
|
74
27
|
spaceGuids: [config.space.GUID],
|
|
75
28
|
names: [businessService]
|
|
@@ -83,7 +36,7 @@ async function getBusinessServiceInfo(businessService, config, logger) {
|
|
|
83
36
|
* @param {CfConfig} cfConfig - The CF config.
|
|
84
37
|
* @returns {RequestArguments} The request arguments.
|
|
85
38
|
*/
|
|
86
|
-
function getFDCRequestArguments(cfConfig) {
|
|
39
|
+
export function getFDCRequestArguments(cfConfig) {
|
|
87
40
|
const fdcUrl = 'https://ui5-flexibility-design-and-configuration.';
|
|
88
41
|
const cfApiEndpoint = `https://api.cf.${cfConfig.url}`;
|
|
89
42
|
const endpointParts = /https:\/\/api\.cf(?:\.([^-.]*)(-\d+)?(\.hana\.ondemand\.com)|(.*))/.exec(cfApiEndpoint);
|
|
@@ -94,7 +47,7 @@ function getFDCRequestArguments(cfConfig) {
|
|
|
94
47
|
}
|
|
95
48
|
};
|
|
96
49
|
let url;
|
|
97
|
-
const isBAS =
|
|
50
|
+
const isBAS = isAppStudio();
|
|
98
51
|
if (endpointParts?.[3]) {
|
|
99
52
|
// Public cloud
|
|
100
53
|
const region = endpointParts[1];
|
|
@@ -131,24 +84,24 @@ function getFDCRequestArguments(cfConfig) {
|
|
|
131
84
|
* @param {ToolsLogger} logger - The logger.
|
|
132
85
|
* @returns {Promise<CFApp[]>} The FDC apps.
|
|
133
86
|
*/
|
|
134
|
-
async function getFDCApps(appHostIds, cfConfig, logger) {
|
|
87
|
+
export async function getFDCApps(appHostIds, cfConfig, logger) {
|
|
135
88
|
const requestArguments = getFDCRequestArguments(cfConfig);
|
|
136
89
|
logger?.log(`App Hosts: ${JSON.stringify(appHostIds)}, request arguments: ${JSON.stringify(requestArguments)}`);
|
|
137
90
|
const appHostIdParams = appHostIds.map((id) => `appHostId=${encodeURIComponent(id)}`).join('&');
|
|
138
91
|
const url = `${requestArguments.url}/api/business-service/discovery?${appHostIdParams}`;
|
|
139
92
|
try {
|
|
140
|
-
const response = await
|
|
93
|
+
const response = await axios.get(url, requestArguments.options);
|
|
141
94
|
if (response.status === 200) {
|
|
142
95
|
logger?.log(`Retrieved FDC apps with request url: ${JSON.stringify(response.data)}`);
|
|
143
96
|
return response.data.results;
|
|
144
97
|
}
|
|
145
98
|
else {
|
|
146
|
-
throw new Error(
|
|
99
|
+
throw new Error(t('error.failedToConnectToFDCService', { status: response.status }));
|
|
147
100
|
}
|
|
148
101
|
}
|
|
149
102
|
catch (error) {
|
|
150
103
|
logger?.error(`Getting FDC apps failed. Request url: ${url}. ${error}`);
|
|
151
|
-
throw new Error(
|
|
104
|
+
throw new Error(t('error.failedToGetFDCApps', { error: error.message }));
|
|
152
105
|
}
|
|
153
106
|
}
|
|
154
107
|
/**
|
|
@@ -160,19 +113,19 @@ async function getFDCApps(appHostIds, cfConfig, logger) {
|
|
|
160
113
|
* @param {ToolsLogger} logger - The logger.
|
|
161
114
|
* @returns {Promise<CfUi5AppInfo>} The ui5AppInfo.json content.
|
|
162
115
|
*/
|
|
163
|
-
async function getCfUi5AppInfo(appId, appHostIds, cfConfig, logger) {
|
|
116
|
+
export async function getCfUi5AppInfo(appId, appHostIds, cfConfig, logger) {
|
|
164
117
|
const requestArguments = getFDCRequestArguments(cfConfig);
|
|
165
118
|
const appHostIdParams = appHostIds.map((id) => `appHostId=${encodeURIComponent(id)}`).join('&');
|
|
166
119
|
const url = `${requestArguments.url}/api/business-service/ui5appinfo?appId=${encodeURIComponent(appId)}&${appHostIdParams}`;
|
|
167
120
|
logger?.log(`Fetching ui5AppInfo.json`);
|
|
168
121
|
try {
|
|
169
|
-
const response = await
|
|
122
|
+
const response = await axios.get(url, requestArguments.options);
|
|
170
123
|
if (response.status === 200) {
|
|
171
124
|
logger?.log('Successfully retrieved ui5AppInfo.json from FDC');
|
|
172
125
|
return response.data;
|
|
173
126
|
}
|
|
174
127
|
else {
|
|
175
|
-
throw new Error(
|
|
128
|
+
throw new Error(t('error.failedToConnectToFDCService', { status: response.status }));
|
|
176
129
|
}
|
|
177
130
|
}
|
|
178
131
|
catch (error) {
|
|
@@ -190,15 +143,15 @@ async function getCfUi5AppInfo(appId, appHostIds, cfConfig, logger) {
|
|
|
190
143
|
* @param {string} lang - The language parameter (defaults to 'en').
|
|
191
144
|
* @returns {Promise<ManifestNamespace.Inbound | undefined>} The inbounds or undefined if empty.
|
|
192
145
|
*/
|
|
193
|
-
async function getCfBaseAppInbounds(appId, appHostId, cfConfig, logger, lang = 'en') {
|
|
146
|
+
export async function getCfBaseAppInbounds(appId, appHostId, cfConfig, logger, lang = 'en') {
|
|
194
147
|
const requestArguments = getFDCRequestArguments(cfConfig);
|
|
195
148
|
const params = new URLSearchParams({ appId, appHostId, 'sap-language': lang });
|
|
196
149
|
const url = `${requestArguments.url}/api/business-service/inbounds?${params}`;
|
|
197
150
|
logger?.log(`Fetching inbounds from FDC: ${url}`);
|
|
198
151
|
try {
|
|
199
|
-
const response = await
|
|
152
|
+
const response = await axios.get(url, requestArguments.options);
|
|
200
153
|
if (response.status !== 200) {
|
|
201
|
-
throw new Error(
|
|
154
|
+
throw new Error(t('error.failedToConnectToFDCService', { status: response.status }));
|
|
202
155
|
}
|
|
203
156
|
logger?.log('Successfully retrieved inbounds from FDC');
|
|
204
157
|
const inbounds = response.data.inbounds;
|
|
@@ -206,7 +159,7 @@ async function getCfBaseAppInbounds(appId, appHostId, cfConfig, logger, lang = '
|
|
|
206
159
|
}
|
|
207
160
|
catch (e) {
|
|
208
161
|
logger?.debug(e);
|
|
209
|
-
throw new Error(
|
|
162
|
+
throw new Error(t('error.failedToGetFDCInbounds', { error: e.message }));
|
|
210
163
|
}
|
|
211
164
|
}
|
|
212
165
|
/**
|
|
@@ -218,7 +171,7 @@ async function getCfBaseAppInbounds(appId, appHostId, cfConfig, logger, lang = '
|
|
|
218
171
|
* @param {CreateServiceOptions} [options] - Additional options.
|
|
219
172
|
* @returns {Promise<void>} The promise.
|
|
220
173
|
*/
|
|
221
|
-
async function createServiceInstance(plan, serviceInstanceName, serviceName, options) {
|
|
174
|
+
export async function createServiceInstance(plan, serviceInstanceName, serviceName, options) {
|
|
222
175
|
const { xsSecurityProjectName, templatePathOverwrite, logger } = options ?? {};
|
|
223
176
|
try {
|
|
224
177
|
logger?.log(`Creating service instance '${serviceInstanceName}' of service '${serviceName}' with '${plan}' plan`);
|
|
@@ -235,11 +188,11 @@ async function createServiceInstance(plan, serviceInstanceName, serviceName, opt
|
|
|
235
188
|
}
|
|
236
189
|
catch (err) {
|
|
237
190
|
logger?.error(`Failed to parse xs-security.json file: ${err}`);
|
|
238
|
-
throw new Error(
|
|
191
|
+
throw new Error(t('error.xsSecurityJsonCouldNotBeParsed'));
|
|
239
192
|
}
|
|
240
193
|
commandParameters.push('-c', JSON.stringify(xsSecurity));
|
|
241
194
|
}
|
|
242
|
-
const result = await
|
|
195
|
+
const result = await Cli.execute(commandParameters);
|
|
243
196
|
if (result && result.exitCode !== 0) {
|
|
244
197
|
logger?.error(`Service creation failed: ${result.stderr || 'Unknown error'}`);
|
|
245
198
|
throw new Error(`Service creation failed with code ${result.exitCode}: ${result.stderr || ''}`);
|
|
@@ -248,7 +201,7 @@ async function createServiceInstance(plan, serviceInstanceName, serviceName, opt
|
|
|
248
201
|
}
|
|
249
202
|
catch (e) {
|
|
250
203
|
logger?.error(e);
|
|
251
|
-
throw new Error(
|
|
204
|
+
throw new Error(t('error.failedToCreateServiceInstance', { serviceInstanceName, error: e.message }));
|
|
252
205
|
}
|
|
253
206
|
}
|
|
254
207
|
/**
|
|
@@ -258,8 +211,8 @@ async function createServiceInstance(plan, serviceInstanceName, serviceName, opt
|
|
|
258
211
|
* @param {string[]} tags - The service tags for discovery.
|
|
259
212
|
* @returns {Promise<string>} The service name.
|
|
260
213
|
*/
|
|
261
|
-
async function getServiceNameByTags(spaceGuid, tags) {
|
|
262
|
-
const json = await
|
|
214
|
+
export async function getServiceNameByTags(spaceGuid, tags) {
|
|
215
|
+
const json = await requestCfApi(`/v3/service_offerings?per_page=1000&space_guids=${spaceGuid}`);
|
|
263
216
|
const serviceOffering = json?.resources?.find((resource) => resource.tags && tags.every((tag) => resource.tags?.includes(tag)));
|
|
264
217
|
return serviceOffering?.name ?? '';
|
|
265
218
|
}
|
|
@@ -274,9 +227,9 @@ async function getServiceNameByTags(spaceGuid, tags) {
|
|
|
274
227
|
* @param {ToolsLogger} logger - The logger.
|
|
275
228
|
* @returns {Promise<void>} The promise.
|
|
276
229
|
*/
|
|
277
|
-
async function createServices(yamlContent, initialServices, timestamp, spaceGuid, templatePathOverwrite, logger) {
|
|
230
|
+
export async function createServices(yamlContent, initialServices, timestamp, spaceGuid, templatePathOverwrite, logger) {
|
|
278
231
|
const excludeServices = new Set([...initialServices, 'portal', 'html5-apps-repo']);
|
|
279
|
-
const xsSecurityProjectName =
|
|
232
|
+
const xsSecurityProjectName = getProjectNameForXsSecurity(yamlContent, timestamp);
|
|
280
233
|
for (const resource of yamlContent.resources ?? []) {
|
|
281
234
|
if (!excludeServices.has(resource?.parameters?.service ?? '')) {
|
|
282
235
|
if (resource?.parameters?.service === 'xsuaa') {
|
|
@@ -306,7 +259,7 @@ async function createServices(yamlContent, initialServices, timestamp, spaceGuid
|
|
|
306
259
|
* @param {ToolsLogger} logger - The logger.
|
|
307
260
|
* @returns {Promise<ServiceInfo | null>} The service instance keys.
|
|
308
261
|
*/
|
|
309
|
-
async function getOrCreateServiceInstanceKeys(serviceInstanceQuery, logger) {
|
|
262
|
+
export async function getOrCreateServiceInstanceKeys(serviceInstanceQuery, logger) {
|
|
310
263
|
try {
|
|
311
264
|
const serviceInstances = await getServiceInstance(serviceInstanceQuery);
|
|
312
265
|
if (serviceInstances?.length > 0) {
|
|
@@ -320,7 +273,7 @@ async function getOrCreateServiceInstanceKeys(serviceInstanceQuery, logger) {
|
|
|
320
273
|
return null;
|
|
321
274
|
}
|
|
322
275
|
catch (e) {
|
|
323
|
-
const errorMessage =
|
|
276
|
+
const errorMessage = t('error.failedToGetServiceInstanceKeys', { error: e.message });
|
|
324
277
|
logger?.error(errorMessage);
|
|
325
278
|
throw new Error(errorMessage);
|
|
326
279
|
}
|
|
@@ -338,9 +291,9 @@ async function getServiceInstance(params) {
|
|
|
338
291
|
const uriParameters = parameters.length > 0 ? `?${parameters.join('&')}` : '';
|
|
339
292
|
const uri = `/v3/service_instances` + uriParameters;
|
|
340
293
|
try {
|
|
341
|
-
const json = await
|
|
294
|
+
const json = await requestCfApi(uri);
|
|
342
295
|
if (!json?.resources || !Array.isArray(json.resources)) {
|
|
343
|
-
throw new Error(
|
|
296
|
+
throw new Error(t('error.noValidJsonForServiceInstance'));
|
|
344
297
|
}
|
|
345
298
|
return json.resources.map((service) => ({
|
|
346
299
|
name: service.name,
|
|
@@ -348,7 +301,7 @@ async function getServiceInstance(params) {
|
|
|
348
301
|
}));
|
|
349
302
|
}
|
|
350
303
|
catch (e) {
|
|
351
|
-
throw new Error(
|
|
304
|
+
throw new Error(t('error.failedToGetServiceInstance', { uriParameters, error: e.message }));
|
|
352
305
|
}
|
|
353
306
|
}
|
|
354
307
|
/**
|
|
@@ -358,22 +311,22 @@ async function getServiceInstance(params) {
|
|
|
358
311
|
* @param {ToolsLogger} logger - The logger.
|
|
359
312
|
* @returns {Promise<ServiceKeys[]>} The service instance keys.
|
|
360
313
|
*/
|
|
361
|
-
async function getOrCreateServiceKeys(serviceInstance, logger) {
|
|
314
|
+
export async function getOrCreateServiceKeys(serviceInstance, logger) {
|
|
362
315
|
const serviceInstanceName = serviceInstance.name;
|
|
363
316
|
try {
|
|
364
|
-
const credentials = await
|
|
317
|
+
const credentials = await getServiceKeys(serviceInstance.guid, 'updated_at', logger);
|
|
365
318
|
if (credentials?.length > 0) {
|
|
366
319
|
return credentials;
|
|
367
320
|
}
|
|
368
321
|
else {
|
|
369
322
|
const serviceKeyName = serviceInstanceName + '_key';
|
|
370
323
|
logger?.log(`Creating service key '${serviceKeyName}' for service instance '${serviceInstanceName}'`);
|
|
371
|
-
await
|
|
372
|
-
return
|
|
324
|
+
await createServiceKey(serviceInstanceName, serviceKeyName);
|
|
325
|
+
return getServiceKeys(serviceInstance.guid, 'updated_at', logger);
|
|
373
326
|
}
|
|
374
327
|
}
|
|
375
328
|
catch (e) {
|
|
376
|
-
throw new Error(
|
|
329
|
+
throw new Error(t('error.failedToGetOrCreateServiceKeys', { serviceInstanceName, error: e.message }));
|
|
377
330
|
}
|
|
378
331
|
}
|
|
379
332
|
/**
|
|
@@ -383,8 +336,8 @@ async function getOrCreateServiceKeys(serviceInstance, logger) {
|
|
|
383
336
|
* @param {string} serviceName - The service name (e.g., 'xsuaa', 'hana').
|
|
384
337
|
* @returns {Promise<string[]>} The service tags.
|
|
385
338
|
*/
|
|
386
|
-
async function getServiceTags(spaceGuid, serviceName) {
|
|
387
|
-
const json = await
|
|
339
|
+
export async function getServiceTags(spaceGuid, serviceName) {
|
|
340
|
+
const json = await requestCfApi(`/v3/service_offerings?per_page=1000&space_guids=${spaceGuid}&names=${serviceName}`);
|
|
388
341
|
const serviceOffering = json?.resources?.find((resource) => resource.name === serviceName);
|
|
389
342
|
return serviceOffering?.tags ?? [];
|
|
390
343
|
}
|
|
@@ -398,7 +351,7 @@ async function getServiceTags(spaceGuid, serviceName) {
|
|
|
398
351
|
* @param {ToolsLogger} logger - Optional logger.
|
|
399
352
|
* @returns {Promise<ServiceKeyCredentialsWithTags | null>} Service key credentials with tags returned by the CF API.
|
|
400
353
|
*/
|
|
401
|
-
async function getServiceKeyCredentialsWithTags(spaceGuid, serviceName, serviceInstanceName, plan, logger) {
|
|
354
|
+
export async function getServiceKeyCredentialsWithTags(spaceGuid, serviceName, serviceInstanceName, plan, logger) {
|
|
402
355
|
try {
|
|
403
356
|
const tags = await getServiceTags(spaceGuid, serviceName);
|
|
404
357
|
const serviceInstances = await getServiceInstance({
|
package/dist/cf/services/cli.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isCfInstalled = isCfInstalled;
|
|
4
|
-
exports.getServiceKeys = getServiceKeys;
|
|
5
|
-
exports.createServiceKey = createServiceKey;
|
|
6
|
-
exports.updateServiceInstance = updateServiceInstance;
|
|
7
|
-
exports.requestCfApi = requestCfApi;
|
|
8
|
-
exports.checkAppExists = checkAppExists;
|
|
9
|
-
exports.pushApp = pushApp;
|
|
10
|
-
exports.enableSsh = enableSsh;
|
|
11
|
-
exports.restartApp = restartApp;
|
|
12
|
-
const cf_tools_1 = require("@sap/cf-tools");
|
|
13
|
-
const i18n_1 = require("../../i18n");
|
|
1
|
+
import { Cli, cfGetServiceKeys, eFilters } from '@sap/cf-tools';
|
|
2
|
+
import { t } from '../../i18n.js';
|
|
14
3
|
const ENV = { env: { 'CF_COLOR': 'false' } };
|
|
15
4
|
/**
|
|
16
5
|
* Checks if Cloud Foundry is installed.
|
|
@@ -18,16 +7,16 @@ const ENV = { env: { 'CF_COLOR': 'false' } };
|
|
|
18
7
|
* @param {ToolsLogger} logger - The logger.
|
|
19
8
|
* @returns {Promise<boolean>} True if CF is installed, false otherwise.
|
|
20
9
|
*/
|
|
21
|
-
async function isCfInstalled(logger) {
|
|
10
|
+
export async function isCfInstalled(logger) {
|
|
22
11
|
try {
|
|
23
|
-
const response = await
|
|
12
|
+
const response = await Cli.execute(['version'], ENV);
|
|
24
13
|
if (response.exitCode !== 0) {
|
|
25
14
|
throw new Error(response.stderr);
|
|
26
15
|
}
|
|
27
16
|
return true;
|
|
28
17
|
}
|
|
29
18
|
catch (e) {
|
|
30
|
-
logger.error(
|
|
19
|
+
logger.error(t('error.cfNotInstalled', { error: e.message }));
|
|
31
20
|
return false;
|
|
32
21
|
}
|
|
33
22
|
}
|
|
@@ -39,13 +28,13 @@ async function isCfInstalled(logger) {
|
|
|
39
28
|
* @param logger - Optional logger.
|
|
40
29
|
* @returns The service instance credentials sorted by the specified field (newest first).
|
|
41
30
|
*/
|
|
42
|
-
async function getServiceKeys(serviceInstanceGuid, sortBy = 'updated_at', logger) {
|
|
31
|
+
export async function getServiceKeys(serviceInstanceGuid, sortBy = 'updated_at', logger) {
|
|
43
32
|
try {
|
|
44
|
-
const resources = await
|
|
33
|
+
const resources = await cfGetServiceKeys({
|
|
45
34
|
filters: [
|
|
46
35
|
{
|
|
47
36
|
value: serviceInstanceGuid,
|
|
48
|
-
key:
|
|
37
|
+
key: eFilters.service_instance_guids
|
|
49
38
|
}
|
|
50
39
|
]
|
|
51
40
|
});
|
|
@@ -81,7 +70,7 @@ async function getServiceKeys(serviceInstanceGuid, sortBy = 'updated_at', logger
|
|
|
81
70
|
return filtered;
|
|
82
71
|
}
|
|
83
72
|
catch (e) {
|
|
84
|
-
throw new Error(
|
|
73
|
+
throw new Error(t('error.cfGetInstanceCredentialsFailed', { serviceInstanceGuid, error: e.message }));
|
|
85
74
|
}
|
|
86
75
|
}
|
|
87
76
|
/**
|
|
@@ -90,15 +79,15 @@ async function getServiceKeys(serviceInstanceGuid, sortBy = 'updated_at', logger
|
|
|
90
79
|
* @param {string} serviceInstanceName - The service instance name.
|
|
91
80
|
* @param {string} serviceKeyName - The service key name.
|
|
92
81
|
*/
|
|
93
|
-
async function createServiceKey(serviceInstanceName, serviceKeyName) {
|
|
82
|
+
export async function createServiceKey(serviceInstanceName, serviceKeyName) {
|
|
94
83
|
try {
|
|
95
|
-
const cliResult = await
|
|
84
|
+
const cliResult = await Cli.execute(['create-service-key', serviceInstanceName, serviceKeyName, '--wait'], ENV);
|
|
96
85
|
if (cliResult.exitCode !== 0) {
|
|
97
86
|
throw new Error(cliResult.stderr);
|
|
98
87
|
}
|
|
99
88
|
}
|
|
100
89
|
catch (e) {
|
|
101
|
-
throw new Error(
|
|
90
|
+
throw new Error(t('error.createServiceKeyFailed', { serviceInstanceName, error: e.message }));
|
|
102
91
|
}
|
|
103
92
|
}
|
|
104
93
|
/**
|
|
@@ -107,15 +96,15 @@ async function createServiceKey(serviceInstanceName, serviceKeyName) {
|
|
|
107
96
|
* @param {string} serviceInstanceName - The service instance name.
|
|
108
97
|
* @param {object} parameters - The configuration parameters to update.
|
|
109
98
|
*/
|
|
110
|
-
async function updateServiceInstance(serviceInstanceName, parameters) {
|
|
99
|
+
export async function updateServiceInstance(serviceInstanceName, parameters) {
|
|
111
100
|
try {
|
|
112
|
-
const cliResult = await
|
|
101
|
+
const cliResult = await Cli.execute(['update-service', serviceInstanceName, '-c', JSON.stringify(parameters), '--wait'], ENV);
|
|
113
102
|
if (cliResult.exitCode !== 0) {
|
|
114
103
|
throw new Error(cliResult.stderr);
|
|
115
104
|
}
|
|
116
105
|
}
|
|
117
106
|
catch (e) {
|
|
118
|
-
throw new Error(
|
|
107
|
+
throw new Error(t('error.failedToUpdateServiceInstance', { serviceInstanceName, error: e.message }));
|
|
119
108
|
}
|
|
120
109
|
}
|
|
121
110
|
/**
|
|
@@ -124,25 +113,25 @@ async function updateServiceInstance(serviceInstanceName, parameters) {
|
|
|
124
113
|
* @param {string} url - The URL.
|
|
125
114
|
* @returns {Promise<T>} The response.
|
|
126
115
|
*/
|
|
127
|
-
async function requestCfApi(url) {
|
|
116
|
+
export async function requestCfApi(url) {
|
|
128
117
|
try {
|
|
129
|
-
const response = await
|
|
118
|
+
const response = await Cli.execute(['curl', url], ENV);
|
|
130
119
|
if (response.exitCode === 0) {
|
|
131
120
|
// Check for empty response which typically indicates authentication issues
|
|
132
121
|
if (!response.stdout || response.stdout.trim() === '') {
|
|
133
|
-
throw new Error(
|
|
122
|
+
throw new Error(t('error.emptyCFAPIResponse'));
|
|
134
123
|
}
|
|
135
124
|
try {
|
|
136
125
|
return JSON.parse(response.stdout);
|
|
137
126
|
}
|
|
138
127
|
catch (e) {
|
|
139
|
-
throw new Error(
|
|
128
|
+
throw new Error(t('error.failedToParseCFAPIResponse', { error: e.message }));
|
|
140
129
|
}
|
|
141
130
|
}
|
|
142
131
|
throw new Error(response.stderr);
|
|
143
132
|
}
|
|
144
133
|
catch (e) {
|
|
145
|
-
throw new Error(
|
|
134
|
+
throw new Error(t('error.failedToRequestCFAPI', { error: e.message }));
|
|
146
135
|
}
|
|
147
136
|
}
|
|
148
137
|
/**
|
|
@@ -151,8 +140,8 @@ async function requestCfApi(url) {
|
|
|
151
140
|
* @param appName - CF app name.
|
|
152
141
|
* @returns True if the app exists.
|
|
153
142
|
*/
|
|
154
|
-
async function checkAppExists(appName) {
|
|
155
|
-
const result = await
|
|
143
|
+
export async function checkAppExists(appName) {
|
|
144
|
+
const result = await Cli.execute(['app', appName], ENV);
|
|
156
145
|
return result.exitCode === 0;
|
|
157
146
|
}
|
|
158
147
|
/**
|
|
@@ -162,10 +151,10 @@ async function checkAppExists(appName) {
|
|
|
162
151
|
* @param appPath - Local path to push.
|
|
163
152
|
* @param args - Additional cf push arguments.
|
|
164
153
|
*/
|
|
165
|
-
async function pushApp(appName, appPath, args = []) {
|
|
166
|
-
const result = await
|
|
154
|
+
export async function pushApp(appName, appPath, args = []) {
|
|
155
|
+
const result = await Cli.execute(['push', appName, '-p', appPath, ...args], ENV);
|
|
167
156
|
if (result.exitCode !== 0) {
|
|
168
|
-
throw new Error(
|
|
157
|
+
throw new Error(t('error.cfPushFailed', { appName, error: result.stderr }));
|
|
169
158
|
}
|
|
170
159
|
}
|
|
171
160
|
/**
|
|
@@ -173,10 +162,10 @@ async function pushApp(appName, appPath, args = []) {
|
|
|
173
162
|
*
|
|
174
163
|
* @param appName - CF app name.
|
|
175
164
|
*/
|
|
176
|
-
async function enableSsh(appName) {
|
|
177
|
-
const result = await
|
|
165
|
+
export async function enableSsh(appName) {
|
|
166
|
+
const result = await Cli.execute(['enable-ssh', appName], ENV);
|
|
178
167
|
if (result.exitCode !== 0) {
|
|
179
|
-
throw new Error(
|
|
168
|
+
throw new Error(t('error.cfEnableSshFailed', { appName, error: result.stderr }));
|
|
180
169
|
}
|
|
181
170
|
}
|
|
182
171
|
/**
|
|
@@ -184,10 +173,10 @@ async function enableSsh(appName) {
|
|
|
184
173
|
*
|
|
185
174
|
* @param appName - CF app name.
|
|
186
175
|
*/
|
|
187
|
-
async function restartApp(appName) {
|
|
188
|
-
const result = await
|
|
176
|
+
export async function restartApp(appName) {
|
|
177
|
+
const result = await Cli.execute(['restart', appName, '--strategy', 'rolling', '--no-wait'], ENV);
|
|
189
178
|
if (result.exitCode !== 0) {
|
|
190
|
-
throw new Error(
|
|
179
|
+
throw new Error(t('error.cfRestartFailed', { appName, error: result.stderr }));
|
|
191
180
|
}
|
|
192
181
|
}
|
|
193
182
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getBtpDestinations = getBtpDestinations;
|
|
37
|
-
const path = __importStar(require("node:path"));
|
|
38
|
-
const api_1 = require("./api");
|
|
39
|
-
const api_2 = require("../../btp/api");
|
|
40
|
-
const yaml_loader_1 = require("../project/yaml-loader");
|
|
41
|
-
const i18n_1 = require("../../i18n");
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { getOrCreateServiceInstanceKeys } from './api.js';
|
|
3
|
+
import { listBtpDestinations } from '../../btp/api.js';
|
|
4
|
+
import { getYamlContent } from '../project/yaml-loader.js';
|
|
5
|
+
import { t } from '../../i18n.js';
|
|
42
6
|
/**
|
|
43
7
|
* Finds the name of the destination service instance declared in the MTA project's mta.yaml.
|
|
44
8
|
*
|
|
@@ -48,15 +12,15 @@ const i18n_1 = require("../../i18n");
|
|
|
48
12
|
*/
|
|
49
13
|
function getDestinationServiceName(projectPath) {
|
|
50
14
|
try {
|
|
51
|
-
const yamlContent =
|
|
15
|
+
const yamlContent = getYamlContent(path.join(path.dirname(projectPath), 'mta.yaml'));
|
|
52
16
|
const name = yamlContent?.resources?.find((r) => r.parameters?.service === 'destination')?.name;
|
|
53
17
|
if (!name) {
|
|
54
|
-
throw new Error(
|
|
18
|
+
throw new Error(t('error.destinationServiceNotFoundInMtaYaml'));
|
|
55
19
|
}
|
|
56
20
|
return name;
|
|
57
21
|
}
|
|
58
22
|
catch (e) {
|
|
59
|
-
throw e instanceof Error ? e : new Error(
|
|
23
|
+
throw e instanceof Error ? e : new Error(t('error.destinationServiceNotFoundInMtaYaml'));
|
|
60
24
|
}
|
|
61
25
|
}
|
|
62
26
|
/**
|
|
@@ -67,13 +31,13 @@ function getDestinationServiceName(projectPath) {
|
|
|
67
31
|
* @param {string} projectPath - The root path of the CF app project.
|
|
68
32
|
* @returns {Promise<Destinations>} Map of destination name to Destination object.
|
|
69
33
|
*/
|
|
70
|
-
async function getBtpDestinations(projectPath) {
|
|
34
|
+
export async function getBtpDestinations(projectPath) {
|
|
71
35
|
const destinationServiceName = getDestinationServiceName(projectPath);
|
|
72
|
-
const serviceInfo = await
|
|
36
|
+
const serviceInfo = await getOrCreateServiceInstanceKeys({ names: [destinationServiceName] });
|
|
73
37
|
if (!serviceInfo?.serviceKeys?.length) {
|
|
74
|
-
throw new Error(
|
|
38
|
+
throw new Error(t('error.noServiceKeysFoundForDestination', { serviceInstanceName: destinationServiceName }));
|
|
75
39
|
}
|
|
76
40
|
const credentials = serviceInfo.serviceKeys[0].credentials;
|
|
77
|
-
return
|
|
41
|
+
return listBtpDestinations(credentials);
|
|
78
42
|
}
|
|
79
43
|
//# sourceMappingURL=destinations.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './api';
|
|
2
|
-
export * from './ssh';
|
|
3
|
-
export * from './cli';
|
|
4
|
-
export * from './destinations';
|
|
5
|
-
export * from './manifest';
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export * from './ssh.js';
|
|
3
|
+
export * from './cli.js';
|
|
4
|
+
export * from './destinations.js';
|
|
5
|
+
export * from './manifest.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api"), exports);
|
|
18
|
-
__exportStar(require("./ssh"), exports);
|
|
19
|
-
__exportStar(require("./cli"), exports);
|
|
20
|
-
__exportStar(require("./destinations"), exports);
|
|
21
|
-
__exportStar(require("./manifest"), exports);
|
|
1
|
+
export * from './api.js';
|
|
2
|
+
export * from './ssh.js';
|
|
3
|
+
export * from './cli.js';
|
|
4
|
+
export * from './destinations.js';
|
|
5
|
+
export * from './manifest.js';
|
|
22
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToolsLogger } from '@sap-ux/logger';
|
|
2
2
|
import type { Manifest } from '@sap-ux/project-access';
|
|
3
|
-
import type { IManifestService, DataSources } from '../../types';
|
|
3
|
+
import type { IManifestService, DataSources } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Service class for handling operations related to the manifest of a CF-deployed UI5 application.
|
|
6
6
|
* Extends the ABAP {@link ManifestService} API, but retrieves the manifest from the local
|