@sap-ux/adp-tooling 0.13.1 → 0.13.4
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/manifest-service.js +1 -1
- package/dist/base/helper.d.ts +8 -8
- package/dist/base/helper.js +26 -18
- package/dist/preview/change-handler.js +2 -2
- package/dist/preview/routes-handler.js +8 -8
- package/dist/prompts/add-annotations-to-odata/index.js +2 -3
- package/dist/writer/inbound-navigation.js +2 -2
- package/package.json +5 -5
- package/templates/rta/ts-controller.ejs +1 -1
|
@@ -130,7 +130,7 @@ class ManifestService {
|
|
|
130
130
|
*/
|
|
131
131
|
async fetchMergedManifest(basePath, descriptorVariantId) {
|
|
132
132
|
const zip = new adm_zip_1.default();
|
|
133
|
-
const files = (0, helper_1.getWebappFiles)(basePath);
|
|
133
|
+
const files = await (0, helper_1.getWebappFiles)(basePath);
|
|
134
134
|
for (const file of files) {
|
|
135
135
|
zip.addFile(file.relativePath, Buffer.from(file.content, 'utf-8'));
|
|
136
136
|
}
|
package/dist/base/helper.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { DescriptorVariant, AdpPreviewConfig } from '../types';
|
|
|
5
5
|
*
|
|
6
6
|
* @param {string} basePath - The path to the adaptation project.
|
|
7
7
|
* @param {Editor} fs - The mem-fs editor instance.
|
|
8
|
-
* @returns {DescriptorVariant} The app descriptor variant.
|
|
8
|
+
* @returns {Promise<DescriptorVariant>} The app descriptor variant.
|
|
9
9
|
*/
|
|
10
|
-
export declare function getVariant(basePath: string, fs?: Editor): DescriptorVariant
|
|
10
|
+
export declare function getVariant(basePath: string, fs?: Editor): Promise<DescriptorVariant>;
|
|
11
11
|
/**
|
|
12
12
|
* Writes the updated variant content to the manifest.appdescr_variant file.
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@ export declare function getVariant(basePath: string, fs?: Editor): DescriptorVar
|
|
|
15
15
|
* @param {DescriptorVariant} variant - The descriptor variant object.
|
|
16
16
|
* @param {Editor} fs - The mem-fs editor instance.
|
|
17
17
|
*/
|
|
18
|
-
export declare function updateVariant(basePath: string, variant: DescriptorVariant, fs: Editor): void
|
|
18
|
+
export declare function updateVariant(basePath: string, variant: DescriptorVariant, fs: Editor): Promise<void>;
|
|
19
19
|
/**
|
|
20
20
|
* Checks if FLP configuration changes exist in the manifest.appdescr_variant.
|
|
21
21
|
*
|
|
@@ -23,10 +23,10 @@ export declare function updateVariant(basePath: string, variant: DescriptorVaria
|
|
|
23
23
|
* or `appdescr_app_addNewInbound` present in the content of the descriptor variant.
|
|
24
24
|
*
|
|
25
25
|
* @param {string} basePath - The base path of the project where the manifest.appdescr_variant is located.
|
|
26
|
-
* @returns {boolean} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
26
|
+
* @returns {Promise<boolean>} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
27
27
|
* @throws {Error} Throws an error if the variant could not be retrieved.
|
|
28
28
|
*/
|
|
29
|
-
export declare function flpConfigurationExists(basePath: string): boolean
|
|
29
|
+
export declare function flpConfigurationExists(basePath: string): Promise<boolean>;
|
|
30
30
|
/**
|
|
31
31
|
* Checks whether TypeScript is supported in the project by verifying the existence of `tsconfig.json`.
|
|
32
32
|
*
|
|
@@ -47,10 +47,10 @@ export declare function getAdpConfig(basePath: string, yamlPath: string): Promis
|
|
|
47
47
|
* Get all files in the webapp folder.
|
|
48
48
|
*
|
|
49
49
|
* @param {string} basePath - The path to the adaptation project.
|
|
50
|
-
* @returns {
|
|
50
|
+
* @returns {Promise<{ relativePath: string; content: string }[]>} The files in the webapp folder.
|
|
51
51
|
*/
|
|
52
|
-
export declare function getWebappFiles(basePath: string): {
|
|
52
|
+
export declare function getWebappFiles(basePath: string): Promise<{
|
|
53
53
|
relativePath: string;
|
|
54
54
|
content: string;
|
|
55
|
-
}[]
|
|
55
|
+
}[]>;
|
|
56
56
|
//# sourceMappingURL=helper.d.ts.map
|
package/dist/base/helper.js
CHANGED
|
@@ -8,19 +8,20 @@ exports.getAdpConfig = getAdpConfig;
|
|
|
8
8
|
exports.getWebappFiles = getWebappFiles;
|
|
9
9
|
const fs_1 = require("fs");
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
11
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
12
12
|
/**
|
|
13
13
|
* Get the app descriptor variant.
|
|
14
14
|
*
|
|
15
15
|
* @param {string} basePath - The path to the adaptation project.
|
|
16
16
|
* @param {Editor} fs - The mem-fs editor instance.
|
|
17
|
-
* @returns {DescriptorVariant} The app descriptor variant.
|
|
17
|
+
* @returns {Promise<DescriptorVariant>} The app descriptor variant.
|
|
18
18
|
*/
|
|
19
|
-
function getVariant(basePath, fs) {
|
|
19
|
+
async function getVariant(basePath, fs) {
|
|
20
|
+
const webappPath = await (0, project_access_1.getWebappPath)(basePath);
|
|
20
21
|
if (fs) {
|
|
21
|
-
return fs.readJSON((0, path_1.join)(
|
|
22
|
+
return fs.readJSON((0, path_1.join)(webappPath, project_access_1.FileName.ManifestAppDescrVar));
|
|
22
23
|
}
|
|
23
|
-
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(
|
|
24
|
+
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(webappPath, project_access_1.FileName.ManifestAppDescrVar), 'utf-8'));
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Writes the updated variant content to the manifest.appdescr_variant file.
|
|
@@ -29,8 +30,8 @@ function getVariant(basePath, fs) {
|
|
|
29
30
|
* @param {DescriptorVariant} variant - The descriptor variant object.
|
|
30
31
|
* @param {Editor} fs - The mem-fs editor instance.
|
|
31
32
|
*/
|
|
32
|
-
function updateVariant(basePath, variant, fs) {
|
|
33
|
-
fs.writeJSON((0, path_1.join)(
|
|
33
|
+
async function updateVariant(basePath, variant, fs) {
|
|
34
|
+
fs.writeJSON((0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), project_access_1.FileName.ManifestAppDescrVar), variant);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Checks if FLP configuration changes exist in the manifest.appdescr_variant.
|
|
@@ -39,12 +40,12 @@ function updateVariant(basePath, variant, fs) {
|
|
|
39
40
|
* or `appdescr_app_addNewInbound` present in the content of the descriptor variant.
|
|
40
41
|
*
|
|
41
42
|
* @param {string} basePath - The base path of the project where the manifest.appdescr_variant is located.
|
|
42
|
-
* @returns {boolean} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
43
|
+
* @returns {Promise<boolean>} Returns `true` if FLP configuration changes exist, otherwise `false`.
|
|
43
44
|
* @throws {Error} Throws an error if the variant could not be retrieved.
|
|
44
45
|
*/
|
|
45
|
-
function flpConfigurationExists(basePath) {
|
|
46
|
+
async function flpConfigurationExists(basePath) {
|
|
46
47
|
try {
|
|
47
|
-
const variant = getVariant(basePath);
|
|
48
|
+
const variant = await getVariant(basePath);
|
|
48
49
|
return variant.content?.some(({ changeType }) => changeType === 'appdescr_app_changeInbound' || changeType === 'appdescr_app_addNewInbound');
|
|
49
50
|
}
|
|
50
51
|
catch (error) {
|
|
@@ -71,12 +72,19 @@ function isTypescriptSupported(basePath, fs) {
|
|
|
71
72
|
*/
|
|
72
73
|
async function getAdpConfig(basePath, yamlPath) {
|
|
73
74
|
const ui5ConfigPath = (0, path_1.isAbsolute)(yamlPath) ? yamlPath : (0, path_1.join)(basePath, yamlPath);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
let ui5Conf;
|
|
76
|
+
let adp;
|
|
77
|
+
try {
|
|
78
|
+
ui5Conf = await (0, project_access_1.readUi5Yaml)((0, path_1.dirname)(ui5ConfigPath), (0, path_1.basename)(ui5ConfigPath));
|
|
79
|
+
const customMiddleware = ui5Conf.findCustomMiddleware('fiori-tools-preview') ??
|
|
80
|
+
ui5Conf.findCustomMiddleware('preview-middleware');
|
|
81
|
+
adp = customMiddleware?.configuration?.adp;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
// do nothing here
|
|
85
|
+
}
|
|
78
86
|
if (!adp) {
|
|
79
|
-
throw new Error(
|
|
87
|
+
throw new Error(`No system configuration found in ${(0, path_1.basename)(ui5ConfigPath)}`);
|
|
80
88
|
}
|
|
81
89
|
return adp;
|
|
82
90
|
}
|
|
@@ -84,10 +92,10 @@ async function getAdpConfig(basePath, yamlPath) {
|
|
|
84
92
|
* Get all files in the webapp folder.
|
|
85
93
|
*
|
|
86
94
|
* @param {string} basePath - The path to the adaptation project.
|
|
87
|
-
* @returns {
|
|
95
|
+
* @returns {Promise<{ relativePath: string; content: string }[]>} The files in the webapp folder.
|
|
88
96
|
*/
|
|
89
|
-
function getWebappFiles(basePath) {
|
|
90
|
-
const dir = (0,
|
|
97
|
+
async function getWebappFiles(basePath) {
|
|
98
|
+
const dir = await (0, project_access_1.getWebappPath)(basePath);
|
|
91
99
|
const files = [];
|
|
92
100
|
const getFilesRecursivelySync = (directory) => {
|
|
93
101
|
const dirents = (0, fs_1.readdirSync)(directory, { withFileTypes: true });
|
|
@@ -251,7 +251,7 @@ async function addAnnotationFile(basePath, projectRoot, change, fs, logger) {
|
|
|
251
251
|
serviceUrl: datasoruces[dataSourceId].uri,
|
|
252
252
|
fileName: (0, path_1.basename)(dataSource[annotationDataSourceKey].uri)
|
|
253
253
|
},
|
|
254
|
-
variant: (0, helper_1.getVariant)(projectRoot),
|
|
254
|
+
variant: await (0, helper_1.getVariant)(projectRoot),
|
|
255
255
|
isCommand: false
|
|
256
256
|
}, fs);
|
|
257
257
|
}
|
|
@@ -268,7 +268,7 @@ async function addAnnotationFile(basePath, projectRoot, change, fs, logger) {
|
|
|
268
268
|
* @returns Promise<ManifestService>
|
|
269
269
|
*/
|
|
270
270
|
async function getManifestService(basePath, logger) {
|
|
271
|
-
const variant = (0, helper_1.getVariant)(basePath);
|
|
271
|
+
const variant = await (0, helper_1.getVariant)(basePath);
|
|
272
272
|
const { target, ignoreCertErrors = false } = await (0, helper_1.getAdpConfig)(basePath, (0, path_1.join)(basePath, project_access_1.FileName.Ui5Yaml));
|
|
273
273
|
const provider = await (0, system_access_1.createAbapServiceProvider)(target, { ignoreCertErrors }, true, logger);
|
|
274
274
|
return await manifest_service_1.ManifestService.initMergedManifest(provider, basePath, variant, logger);
|
|
@@ -98,8 +98,8 @@ class RoutesHandler {
|
|
|
98
98
|
handleReadAllFragments = async (_, res, next) => {
|
|
99
99
|
try {
|
|
100
100
|
const files = await this.readAllFilesByGlob('/**/changes/fragments/*.fragment.xml');
|
|
101
|
-
const fileNames = files.map((
|
|
102
|
-
fragmentName:
|
|
101
|
+
const fileNames = files.map((file) => ({
|
|
102
|
+
fragmentName: file.getName()
|
|
103
103
|
}));
|
|
104
104
|
this.sendFilesResponse(res, {
|
|
105
105
|
fragments: fileNames,
|
|
@@ -121,8 +121,8 @@ class RoutesHandler {
|
|
|
121
121
|
handleReadAllControllers = async (_, res, next) => {
|
|
122
122
|
try {
|
|
123
123
|
const files = await this.readAllFilesByGlob('/**/changes/coding/*.js');
|
|
124
|
-
const fileNames = files.map((
|
|
125
|
-
controllerName:
|
|
124
|
+
const fileNames = files.map((file) => ({
|
|
125
|
+
controllerName: file.getName()
|
|
126
126
|
}));
|
|
127
127
|
this.sendFilesResponse(res, {
|
|
128
128
|
controllers: fileNames,
|
|
@@ -220,7 +220,7 @@ class RoutesHandler {
|
|
|
220
220
|
this.logger.debug(`Controller extension with name "${name}" already exists`);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
generateControllerFile(rootPath, filePath, name);
|
|
223
|
+
await generateControllerFile(rootPath, filePath, name);
|
|
224
224
|
const message = 'Controller extension created!';
|
|
225
225
|
res.status(201 /* HttpStatusCodes.CREATED */).send(message);
|
|
226
226
|
this.logger.debug(`Controller extension with name "${name}" was created`);
|
|
@@ -306,7 +306,7 @@ class RoutesHandler {
|
|
|
306
306
|
async getManifestService() {
|
|
307
307
|
const project = this.util.getProject();
|
|
308
308
|
const basePath = project.getRootPath();
|
|
309
|
-
const variant = (0, helper_1.getVariant)(basePath);
|
|
309
|
+
const variant = await (0, helper_1.getVariant)(basePath);
|
|
310
310
|
const { target, ignoreCertErrors = false } = await (0, helper_1.getAdpConfig)(basePath, path.join(basePath, project_access_1.FileName.Ui5Yaml));
|
|
311
311
|
const provider = await (0, system_access_1.createAbapServiceProvider)(target, { ignoreCertErrors }, true, this.logger);
|
|
312
312
|
return await manifest_service_1.ManifestService.initMergedManifest(provider, basePath, variant, this.logger);
|
|
@@ -324,8 +324,8 @@ exports.default = RoutesHandler;
|
|
|
324
324
|
* @param {string} name - The name of the controller extension (used in TypeScript templates).
|
|
325
325
|
* @throws {Error} Throws an error if rendering the template fails.
|
|
326
326
|
*/
|
|
327
|
-
function generateControllerFile(rootPath, filePath, name) {
|
|
328
|
-
const id = (0, helper_1.getVariant)(rootPath)?.id;
|
|
327
|
+
async function generateControllerFile(rootPath, filePath, name) {
|
|
328
|
+
const id = (await (0, helper_1.getVariant)(rootPath))?.id;
|
|
329
329
|
const isTsSupported = (0, helper_1.isTypescriptSupported)(rootPath);
|
|
330
330
|
const tmplFileName = isTsSupported ? "ts-controller.ejs" /* TemplateFileName.TSController */ : "controller.ejs" /* TemplateFileName.Controller */;
|
|
331
331
|
const tmplPath = path.join(__dirname, '../../templates/rta', tmplFileName);
|
|
@@ -55,7 +55,7 @@ function getPrompts(basePath, dataSources) {
|
|
|
55
55
|
},
|
|
56
56
|
default: '',
|
|
57
57
|
when: (answers) => answers.id !== '' && answers.fileSelectOption === 1 /* AnnotationFileSelectType.ExistingFile */,
|
|
58
|
-
validate: (value) => {
|
|
58
|
+
validate: async (value) => {
|
|
59
59
|
const validationResult = (0, project_input_validator_1.validateEmptyString)(value);
|
|
60
60
|
if (typeof validationResult === 'string') {
|
|
61
61
|
return validationResult;
|
|
@@ -64,8 +64,7 @@ function getPrompts(basePath, dataSources) {
|
|
|
64
64
|
if (!(0, fs_1.existsSync)(filePath)) {
|
|
65
65
|
return (0, i18n_1.t)('validators.fileDoesNotExist');
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(basePath, 'webapp', 'changes', 'annotations', fileName))) {
|
|
67
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), project_access_1.DirName.Changes, project_access_1.DirName.Annotations, (0, path_1.basename)(filePath)))) {
|
|
69
68
|
return (0, i18n_1.t)('validators.annotationFileAlreadyExists');
|
|
70
69
|
}
|
|
71
70
|
return true;
|
|
@@ -24,13 +24,13 @@ async function generateInboundConfig(basePath, config, fs) {
|
|
|
24
24
|
if (!fs) {
|
|
25
25
|
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
26
26
|
}
|
|
27
|
-
const variant = (0, __1.getVariant)(basePath, fs);
|
|
27
|
+
const variant = await (0, __1.getVariant)(basePath, fs);
|
|
28
28
|
if (!config?.inboundId) {
|
|
29
29
|
config.addInboundId = true;
|
|
30
30
|
config.inboundId = `${variant.id}.InboundID`;
|
|
31
31
|
}
|
|
32
32
|
(0, options_1.enhanceManifestChangeContentWithFlpConfig)(config, variant.id, variant.content);
|
|
33
|
-
(0, __1.updateVariant)(basePath, variant, fs);
|
|
33
|
+
await (0, __1.updateVariant)(basePath, variant, fs);
|
|
34
34
|
await updateI18n(basePath, variant.id, config, fs);
|
|
35
35
|
return fs;
|
|
36
36
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.13.
|
|
12
|
+
"version": "0.13.4",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"uuid": "10.0.0",
|
|
35
35
|
"@sap-ux/axios-extension": "1.18.6",
|
|
36
36
|
"@sap-ux/btp-utils": "1.0.1",
|
|
37
|
-
"@sap-ux/inquirer-common": "0.6.
|
|
37
|
+
"@sap-ux/inquirer-common": "0.6.22",
|
|
38
38
|
"@sap-ux/logger": "0.6.0",
|
|
39
|
-
"@sap-ux/project-access": "1.29.
|
|
39
|
+
"@sap-ux/project-access": "1.29.10",
|
|
40
40
|
"@sap-ux/project-input-validator": "0.3.4",
|
|
41
41
|
"@sap-ux/system-access": "0.5.31",
|
|
42
42
|
"@sap-ux/ui5-config": "0.26.2",
|
|
43
|
-
"@sap-ux/odata-service-writer": "0.26.
|
|
43
|
+
"@sap-ux/odata-service-writer": "0.26.5",
|
|
44
44
|
"@sap-ux/nodejs-utils": "0.1.7",
|
|
45
|
-
"@sap-ux/i18n": "0.2.
|
|
45
|
+
"@sap-ux/i18n": "0.2.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/adm-zip": "0.5.5",
|
|
@@ -11,7 +11,7 @@ export default class <%= name %> extends ControllerExtension {
|
|
|
11
11
|
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
|
|
12
12
|
* @memberOf <%= ns %>.<%= name %>
|
|
13
13
|
*/
|
|
14
|
-
onInit:
|
|
14
|
+
onInit(this: <%- name %>) {
|
|
15
15
|
const view = this.getView();
|
|
16
16
|
},
|
|
17
17
|
};
|