@sap-ux/adp-tooling 0.11.13 → 0.12.2
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/base/abap.js +21 -33
- package/dist/base/change-utils.js +3 -5
- package/dist/base/prompt.js +137 -154
- package/dist/i18n.js +13 -24
- package/dist/preview/adp-preview.js +58 -62
- package/dist/preview/change-handler.js +2 -2
- package/dist/preview/routes-handler.js +151 -159
- package/dist/writer/changes/writer-factory.js +8 -8
- package/dist/writer/changes/writers/annotations-writer.js +8 -17
- package/dist/writer/changes/writers/component-usages-writer.js +13 -22
- package/dist/writer/changes/writers/data-source-writer.js +16 -26
- package/dist/writer/changes/writers/inbound-writer.js +20 -26
- package/dist/writer/changes/writers/new-model-writer.js +6 -15
- package/dist/writer/editors.js +7 -18
- package/dist/writer/index.js +50 -66
- package/dist/writer/options.js +15 -17
- package/dist/writer/project-utils.js +26 -40
- package/package.json +9 -9
package/dist/base/abap.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getManifest = void 0;
|
|
13
4
|
const system_access_1 = require("@sap-ux/system-access");
|
|
@@ -20,32 +11,29 @@ const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
|
20
11
|
* @param {ToolsLogger} logger - The logger.
|
|
21
12
|
* @returns {Promise<Manifest>} The manifest.
|
|
22
13
|
*/
|
|
23
|
-
function getManifest(appId, adpConfig, logger) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
async function getManifest(appId, adpConfig, logger) {
|
|
15
|
+
const provider = await (0, system_access_1.createAbapServiceProvider)(adpConfig.target, {
|
|
16
|
+
ignoreCertErrors: adpConfig.ignoreCertErrors ?? false
|
|
17
|
+
}, true, logger);
|
|
18
|
+
const appInfo = (await provider.getAppIndex().getAppInfo(appId))[appId];
|
|
19
|
+
const manifestUrl = appInfo.manifestUrl ?? appInfo.manifest;
|
|
20
|
+
if (!manifestUrl) {
|
|
21
|
+
throw new Error('Manifest URL not found');
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await provider.get(manifestUrl);
|
|
25
|
+
return JSON.parse(response.data);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if ((0, axios_extension_1.isAxiosError)(error)) {
|
|
29
|
+
logger.error('Manifest fetching failed');
|
|
33
30
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return JSON.parse(response.data);
|
|
31
|
+
else {
|
|
32
|
+
logger.error('Manifest parsing error: Manifest is not in expected format.');
|
|
37
33
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
logger.error('Manifest parsing error: Manifest is not in expected format.');
|
|
44
|
-
}
|
|
45
|
-
logger.debug(error);
|
|
46
|
-
throw error;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
34
|
+
logger.debug(error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
49
37
|
}
|
|
50
38
|
exports.getManifest = getManifest;
|
|
51
39
|
//# sourceMappingURL=abap.js.map
|
|
@@ -17,7 +17,6 @@ const project_access_1 = require("@sap-ux/project-access");
|
|
|
17
17
|
* @returns {void}
|
|
18
18
|
*/
|
|
19
19
|
function writeAnnotationChange(projectPath, data, change, fs) {
|
|
20
|
-
var _a;
|
|
21
20
|
try {
|
|
22
21
|
const { timestamp, annotation } = data;
|
|
23
22
|
const changeFileName = `id_${timestamp}_addAnnotationsToOData.change`;
|
|
@@ -26,13 +25,13 @@ function writeAnnotationChange(projectPath, data, change, fs) {
|
|
|
26
25
|
const annotationsFolderPath = path_1.default.join(changesFolderPath, project_access_1.DirName.Annotations);
|
|
27
26
|
writeChangeToFile(changeFilePath, change, fs);
|
|
28
27
|
if (!annotation.filePath) {
|
|
29
|
-
fs.write(path_1.default.join(annotationsFolderPath,
|
|
28
|
+
fs.write(path_1.default.join(annotationsFolderPath, annotation.fileName ?? ''), '');
|
|
30
29
|
}
|
|
31
30
|
else {
|
|
32
31
|
const { filePath, fileName } = annotation;
|
|
33
32
|
const selectedDir = path_1.default.dirname(filePath);
|
|
34
33
|
if (selectedDir !== annotationsFolderPath) {
|
|
35
|
-
fs.copy(filePath, path_1.default.join(annotationsFolderPath, fileName
|
|
34
|
+
fs.copy(filePath, path_1.default.join(annotationsFolderPath, fileName ?? ''));
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -127,7 +126,6 @@ exports.getParsedPropertyValue = getParsedPropertyValue;
|
|
|
127
126
|
* @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory.
|
|
128
127
|
*/
|
|
129
128
|
function findChangeWithInboundId(projectPath, inboundId) {
|
|
130
|
-
var _a;
|
|
131
129
|
let changeObj;
|
|
132
130
|
let filePath = '';
|
|
133
131
|
const pathToInboundChangeFiles = path_1.default.join(projectPath, project_access_1.DirName.Webapp, project_access_1.DirName.Changes, project_access_1.DirName.Manifest);
|
|
@@ -142,7 +140,7 @@ function findChangeWithInboundId(projectPath, inboundId) {
|
|
|
142
140
|
for (const file of files) {
|
|
143
141
|
const pathToFile = path_1.default.join(pathToInboundChangeFiles, file.name);
|
|
144
142
|
const change = JSON.parse((0, fs_1.readFileSync)(pathToFile, 'utf-8'));
|
|
145
|
-
if (
|
|
143
|
+
if (change.content?.inboundId === inboundId) {
|
|
146
144
|
changeObj = change;
|
|
147
145
|
filePath = pathToFile;
|
|
148
146
|
break;
|
package/dist/base/prompt.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -23,86 +14,83 @@ const helper_1 = require("./helper");
|
|
|
23
14
|
* @param logger optional logger instance
|
|
24
15
|
* @returns a configuration for the adp writer
|
|
25
16
|
*/
|
|
26
|
-
function promptGeneratorInput(defaults, logger) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return 'New adaptation id (prefix "customer" will be automatically added to the id):';
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return 'New adaptation id:';
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
initial: defaults.id,
|
|
58
|
-
format: (input) => {
|
|
59
|
-
if (layer === 'CUSTOMER_BASE' && !input.startsWith('customer.')) {
|
|
60
|
-
return `customer.${input}`;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return input;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
|
|
17
|
+
async function promptGeneratorInput(defaults, logger) {
|
|
18
|
+
defaults = defaults ?? {};
|
|
19
|
+
const { target, apps, layer, customConfig } = await promptTarget(defaults, logger);
|
|
20
|
+
const app = await (0, prompts_1.default)([
|
|
21
|
+
{
|
|
22
|
+
type: 'autocomplete',
|
|
23
|
+
name: 'reference',
|
|
24
|
+
message: 'Original application:',
|
|
25
|
+
initial: defaults.reference,
|
|
26
|
+
choices: apps.map((app) => ({
|
|
27
|
+
title: `${app['sap.app/title']} (${(app['sap.fiori/registrationIds'] ?? []).join(',')})`,
|
|
28
|
+
value: app['sap.app/id']
|
|
29
|
+
})),
|
|
30
|
+
suggest: (input, choices) => Promise.resolve(choices.filter((i) => i.title.includes(input)))
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'text',
|
|
34
|
+
name: 'id',
|
|
35
|
+
message: (_prev) => {
|
|
36
|
+
if (layer === 'CUSTOMER_BASE') {
|
|
37
|
+
return 'New adaptation id (prefix "customer" will be automatically added to the id):';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return 'New adaptation id:';
|
|
41
|
+
}
|
|
67
42
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
type: 'text',
|
|
77
|
-
name: 'package',
|
|
78
|
-
message: 'Deployment package:',
|
|
79
|
-
initial: (_a = defaults.package) !== null && _a !== void 0 ? _a : '$TMP',
|
|
80
|
-
validate: (input) => (input === null || input === void 0 ? void 0 : input.length) > 0
|
|
43
|
+
initial: defaults.id,
|
|
44
|
+
format: (input) => {
|
|
45
|
+
if (layer === 'CUSTOMER_BASE' && !input.startsWith('customer.')) {
|
|
46
|
+
return `customer.${input}`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return input;
|
|
50
|
+
}
|
|
81
51
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
52
|
+
validate: (input) => input?.length > 0
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
name: 'title',
|
|
57
|
+
message: 'Application title:'
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
const deploy = await (0, prompts_1.default)([
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
name: 'package',
|
|
64
|
+
message: 'Deployment package:',
|
|
65
|
+
initial: defaults.package ?? '$TMP',
|
|
66
|
+
validate: (input) => input?.length > 0
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'text',
|
|
70
|
+
name: 'transport',
|
|
71
|
+
message: 'Transport request (optional):',
|
|
72
|
+
initial: defaults.transport
|
|
73
|
+
}
|
|
74
|
+
]);
|
|
75
|
+
const options = await (0, prompts_1.default)([
|
|
76
|
+
{
|
|
77
|
+
type: 'confirm',
|
|
78
|
+
name: 'fioriTools',
|
|
79
|
+
message: 'Enable Fiori tools?',
|
|
80
|
+
initial: defaults.ft !== false,
|
|
81
|
+
validate: (input) => input?.length > 0
|
|
82
|
+
}
|
|
83
|
+
]);
|
|
84
|
+
return {
|
|
85
|
+
app: {
|
|
86
|
+
...app,
|
|
87
|
+
layer
|
|
88
|
+
},
|
|
89
|
+
target,
|
|
90
|
+
options,
|
|
91
|
+
deploy,
|
|
92
|
+
customConfig
|
|
93
|
+
};
|
|
106
94
|
}
|
|
107
95
|
exports.promptGeneratorInput = promptGeneratorInput;
|
|
108
96
|
/**
|
|
@@ -112,51 +100,49 @@ exports.promptGeneratorInput = promptGeneratorInput;
|
|
|
112
100
|
* @param logger logger instance
|
|
113
101
|
* @returns apps, layer, target url and client
|
|
114
102
|
*/
|
|
115
|
-
function promptTarget(defaults, logger) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
103
|
+
async function promptTarget(defaults, logger) {
|
|
104
|
+
let count = 0;
|
|
105
|
+
let target = { url: defaults.url, client: defaults.client };
|
|
106
|
+
while (count < 3) {
|
|
107
|
+
try {
|
|
108
|
+
count++;
|
|
109
|
+
target = await (0, prompts_1.default)([
|
|
110
|
+
{
|
|
111
|
+
type: 'text',
|
|
112
|
+
name: 'url',
|
|
113
|
+
message: 'Target system url:',
|
|
114
|
+
initial: target.url,
|
|
115
|
+
validate: helper_1.isNotEmptyString,
|
|
116
|
+
format: (input) => input.trim()
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'text',
|
|
120
|
+
name: 'client',
|
|
121
|
+
message: 'Client (optional):',
|
|
122
|
+
initial: target.client,
|
|
123
|
+
validate: helper_1.isValidSapClient
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
const systemInfo = await fetchSystemInformation(target, defaults.ignoreCertErrors, logger);
|
|
127
|
+
return { target, ...systemInfo };
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
logger.error('Error while fetching system information. Please check your input.');
|
|
131
|
+
logger.debug(error.message);
|
|
132
|
+
if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
|
|
133
|
+
logger.error('If you are using a self-signed certificate, please use the --ignore-cert-errors flag.');
|
|
134
|
+
const confirm = await (0, prompts_1.default)([
|
|
131
135
|
{
|
|
132
|
-
type: '
|
|
133
|
-
name: '
|
|
134
|
-
message: '
|
|
135
|
-
initial: target.client,
|
|
136
|
-
validate: helper_1.isValidSapClient
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
name: 'ignoreCertErrors',
|
|
138
|
+
message: 'Do you want to ignore certificate errors?'
|
|
137
139
|
}
|
|
138
140
|
]);
|
|
139
|
-
|
|
140
|
-
return Object.assign({ target }, systemInfo);
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
logger.error('Error while fetching system information. Please check your input.');
|
|
144
|
-
logger.debug(error.message);
|
|
145
|
-
if (error.code === 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY') {
|
|
146
|
-
logger.error('If you are using a self-signed certificate, please use the --ignore-cert-errors flag.');
|
|
147
|
-
const confirm = yield (0, prompts_1.default)([
|
|
148
|
-
{
|
|
149
|
-
type: 'confirm',
|
|
150
|
-
name: 'ignoreCertErrors',
|
|
151
|
-
message: 'Do you want to ignore certificate errors?'
|
|
152
|
-
}
|
|
153
|
-
]);
|
|
154
|
-
defaults.ignoreCertErrors = confirm.ignoreCertErrors;
|
|
155
|
-
}
|
|
141
|
+
defaults.ignoreCertErrors = confirm.ignoreCertErrors;
|
|
156
142
|
}
|
|
157
143
|
}
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
}
|
|
145
|
+
throw new Error('Unable to fetch system information.');
|
|
160
146
|
}
|
|
161
147
|
exports.promptTarget = promptTarget;
|
|
162
148
|
/**
|
|
@@ -167,33 +153,30 @@ exports.promptTarget = promptTarget;
|
|
|
167
153
|
* @param logger logger instance
|
|
168
154
|
* @returns app index and layer
|
|
169
155
|
*/
|
|
170
|
-
function fetchSystemInformation(target, ignoreCertErrors, logger) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
environment: (_a = ato.operationsType) !== null && _a !== void 0 ? _a : 'P',
|
|
182
|
-
safeMode: true
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
logger.info(`Target layer: ${layer}`);
|
|
186
|
-
logger.info('Fetching list of available applications... (it can take a moment)');
|
|
187
|
-
const appIndex = provider.getAppIndex();
|
|
188
|
-
const searchParams = {
|
|
189
|
-
'sap.ui/technology': 'UI5',
|
|
190
|
-
'sap.app/type': 'application'
|
|
191
|
-
};
|
|
192
|
-
if (customConfig.adp.environment === 'C') {
|
|
193
|
-
searchParams['sap.fiori/cloudDevAdaptationStatus'] = 'released';
|
|
156
|
+
async function fetchSystemInformation(target, ignoreCertErrors, logger) {
|
|
157
|
+
const provider = await (0, system_access_1.createAbapServiceProvider)(target, {
|
|
158
|
+
ignoreCertErrors
|
|
159
|
+
}, true, logger);
|
|
160
|
+
logger.info('Fetching system information...');
|
|
161
|
+
const ato = await provider.getAtoInfo();
|
|
162
|
+
const layer = ato.tenantType === 'SAP' ? 'VENDOR' : 'CUSTOMER_BASE';
|
|
163
|
+
const customConfig = {
|
|
164
|
+
adp: {
|
|
165
|
+
environment: ato.operationsType ?? 'P',
|
|
166
|
+
safeMode: true
|
|
194
167
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
168
|
+
};
|
|
169
|
+
logger.info(`Target layer: ${layer}`);
|
|
170
|
+
logger.info('Fetching list of available applications... (it can take a moment)');
|
|
171
|
+
const appIndex = provider.getAppIndex();
|
|
172
|
+
const searchParams = {
|
|
173
|
+
'sap.ui/technology': 'UI5',
|
|
174
|
+
'sap.app/type': 'application'
|
|
175
|
+
};
|
|
176
|
+
if (customConfig.adp.environment === 'C') {
|
|
177
|
+
searchParams['sap.fiori/cloudDevAdaptationStatus'] = 'released';
|
|
178
|
+
}
|
|
179
|
+
const apps = await appIndex.search(searchParams, ['sap.app/id', 'sap.app/title', 'sap.fiori/registrationIds']);
|
|
180
|
+
return { apps, layer, customConfig };
|
|
198
181
|
}
|
|
199
182
|
//# sourceMappingURL=prompt.js.map
|
package/dist/i18n.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -21,19 +12,17 @@ const adpI18nNamespace = 'adp-tooling';
|
|
|
21
12
|
*
|
|
22
13
|
* @returns {Promise<void>} A promise that resolves when the i18n initialization is completed.
|
|
23
14
|
*/
|
|
24
|
-
function initI18n() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
ns: [adpI18nNamespace]
|
|
36
|
-
});
|
|
15
|
+
async function initI18n() {
|
|
16
|
+
await i18next_1.default.init({
|
|
17
|
+
resources: {
|
|
18
|
+
en: {
|
|
19
|
+
[adpI18nNamespace]: adp_tooling_i18n_json_1.default
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
lng: 'en',
|
|
23
|
+
fallbackLng: 'en',
|
|
24
|
+
defaultNS: adpI18nNamespace,
|
|
25
|
+
ns: [adpI18nNamespace]
|
|
37
26
|
});
|
|
38
27
|
}
|
|
39
28
|
exports.initI18n = initI18n;
|
|
@@ -45,8 +34,8 @@ exports.initI18n = initI18n;
|
|
|
45
34
|
* @returns {string} Localized string stored for the given key.
|
|
46
35
|
*/
|
|
47
36
|
function t(key, options) {
|
|
48
|
-
if (!
|
|
49
|
-
options = Object.assign(options
|
|
37
|
+
if (!options?.ns) {
|
|
38
|
+
options = Object.assign(options ?? {}, { ns: adpI18nNamespace });
|
|
50
39
|
}
|
|
51
40
|
return i18next_1.default.t(key, options);
|
|
52
41
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -21,6 +12,18 @@ const change_handler_1 = require("./change-handler");
|
|
|
21
12
|
* Instance of an adaptation project handling requests and data transformation.
|
|
22
13
|
*/
|
|
23
14
|
class AdpPreview {
|
|
15
|
+
config;
|
|
16
|
+
project;
|
|
17
|
+
util;
|
|
18
|
+
logger;
|
|
19
|
+
/**
|
|
20
|
+
* Merged descriptor variant with reference app manifest
|
|
21
|
+
*/
|
|
22
|
+
mergedDescriptor;
|
|
23
|
+
/**
|
|
24
|
+
* Routes handler class to handle API requests
|
|
25
|
+
*/
|
|
26
|
+
routesHandler;
|
|
24
27
|
/**
|
|
25
28
|
* @returns merged manifest.
|
|
26
29
|
*/
|
|
@@ -41,8 +44,7 @@ class AdpPreview {
|
|
|
41
44
|
[this.mergedDescriptor.name]: this.mergedDescriptor.url
|
|
42
45
|
};
|
|
43
46
|
this.mergedDescriptor.asyncHints.libs.forEach((lib) => {
|
|
44
|
-
|
|
45
|
-
if ((_a = lib.url) === null || _a === void 0 ? void 0 : _a.url) {
|
|
47
|
+
if (lib.url?.url) {
|
|
46
48
|
resources[lib.name] = lib.url.url;
|
|
47
49
|
}
|
|
48
50
|
});
|
|
@@ -73,21 +75,19 @@ class AdpPreview {
|
|
|
73
75
|
* @param descriptorVariant descriptor variant from the project
|
|
74
76
|
* @returns the UI5 flex layer for which editing is enabled
|
|
75
77
|
*/
|
|
76
|
-
init(descriptorVariant) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return descriptorVariant.layer;
|
|
90
|
-
});
|
|
78
|
+
async init(descriptorVariant) {
|
|
79
|
+
const provider = await (0, system_access_1.createAbapServiceProvider)(this.config.target, { ignoreCertErrors: this.config.ignoreCertErrors }, true, this.logger);
|
|
80
|
+
const lrep = provider.getLayeredRepository();
|
|
81
|
+
const zip = new adm_zip_1.default();
|
|
82
|
+
const files = await this.project.byGlob('**/*.*');
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
zip.addFile(file.getPath().substring(1), await file.getBuffer());
|
|
85
|
+
}
|
|
86
|
+
const buffer = zip.toBuffer();
|
|
87
|
+
// fetch a merged descriptor from the backend
|
|
88
|
+
await lrep.getCsrfToken();
|
|
89
|
+
this.mergedDescriptor = (await lrep.mergeAppDescriptorVariant(buffer))[descriptorVariant.id];
|
|
90
|
+
return descriptorVariant.layer;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
93
|
* Proxy for the merged application manifest.json and blocking of preload files.
|
|
@@ -96,27 +96,25 @@ class AdpPreview {
|
|
|
96
96
|
* @param res outgoing response object
|
|
97
97
|
* @param next next middleware that is to be called if the request cannot be handled
|
|
98
98
|
*/
|
|
99
|
-
proxy(req, res, next) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
async proxy(req, res, next) {
|
|
100
|
+
if (req.path === '/manifest.json') {
|
|
101
|
+
res.status(200);
|
|
102
|
+
res.send(JSON.stringify(this.descriptor.manifest, undefined, 2));
|
|
103
|
+
}
|
|
104
|
+
else if (req.path === '/Component-preload.js') {
|
|
105
|
+
res.status(404).send();
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// check if the requested file exists in the file system (replace .js with .* for typescript)
|
|
109
|
+
const files = await this.project.byGlob(req.path.replace('.js', '.*'));
|
|
110
|
+
if (files.length === 1) {
|
|
111
|
+
// redirect to the exposed path so that other middlewares can handle it
|
|
112
|
+
res.redirect(302, req.path);
|
|
107
113
|
}
|
|
108
114
|
else {
|
|
109
|
-
|
|
110
|
-
const files = yield this.project.byGlob(req.path.replace('.js', '.*'));
|
|
111
|
-
if (files.length === 1) {
|
|
112
|
-
// redirect to the exposed path so that other middlewares can handle it
|
|
113
|
-
res.redirect(302, req.path);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
next();
|
|
117
|
-
}
|
|
115
|
+
next();
|
|
118
116
|
}
|
|
119
|
-
}
|
|
117
|
+
}
|
|
120
118
|
}
|
|
121
119
|
/**
|
|
122
120
|
* Add additional APIs to the router that are required for adaptation projects only.
|
|
@@ -160,24 +158,22 @@ class AdpPreview {
|
|
|
160
158
|
* @param {Logger} logger - An instance of a logging interface for message logging.
|
|
161
159
|
* @returns {Promise<void>} A promise that resolves when the change request has been processed.
|
|
162
160
|
*/
|
|
163
|
-
onChangeRequest(type, change, fs, logger) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
});
|
|
161
|
+
async onChangeRequest(type, change, fs, logger) {
|
|
162
|
+
switch (type) {
|
|
163
|
+
case 'read':
|
|
164
|
+
if (change_handler_1.moduleNameContentMap[change.changeType] && !change.moduleName) {
|
|
165
|
+
(0, change_handler_1.tryFixChange)(change, logger);
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
case 'write':
|
|
169
|
+
if ((0, change_handler_1.isAddXMLChange)(change)) {
|
|
170
|
+
(0, change_handler_1.addXmlFragment)(this.util.getProject().getSourcePath(), change, fs, logger);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
// no need to handle delete changes
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
181
177
|
}
|
|
182
178
|
}
|
|
183
179
|
exports.AdpPreview = AdpPreview;
|