@sap-ux/adp-tooling 0.14.1 → 0.14.3
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.
|
@@ -208,6 +208,9 @@ class AdpPreview {
|
|
|
208
208
|
if ((0, change_handler_1.isAddXMLChange)(change)) {
|
|
209
209
|
(0, change_handler_1.addXmlFragment)(this.util.getProject().getSourcePath(), change, fs, logger, additionalChangeInfo);
|
|
210
210
|
}
|
|
211
|
+
if ((0, change_handler_1.isCodeExtChange)(change)) {
|
|
212
|
+
await (0, change_handler_1.addControllerExtension)(this.util.getProject().getRootPath(), this.util.getProject().getSourcePath(), change, fs, logger);
|
|
213
|
+
}
|
|
211
214
|
if ((0, change_handler_1.isAddAnnotationChange)(change)) {
|
|
212
215
|
await (0, change_handler_1.addAnnotationFile)(this.util.getProject().getSourcePath(), this.util.getProject().getRootPath(), change, fs, logger);
|
|
213
216
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
-
import type { AddXMLChange, CommonChangeProperties, AnnotationFileChange, CommonAdditionalChangeInfoProperties } from '../types';
|
|
2
|
+
import type { AddXMLChange, CommonChangeProperties, CodeExtChange, AnnotationFileChange, CommonAdditionalChangeInfoProperties } from '../types';
|
|
3
3
|
import type { Logger } from '@sap-ux/logger';
|
|
4
4
|
/**
|
|
5
5
|
* A mapping object that defines how to extract change content data from changes based on their type.
|
|
@@ -29,6 +29,13 @@ export declare function tryFixChange(change: CommonChangeProperties, logger: Log
|
|
|
29
29
|
* indicating the change is of type `AddXMLChange`.
|
|
30
30
|
*/
|
|
31
31
|
export declare function isAddXMLChange(change: CommonChangeProperties): change is AddXMLChange;
|
|
32
|
+
/**
|
|
33
|
+
* Determines whether a given change is of type `codeExt`.
|
|
34
|
+
*
|
|
35
|
+
* @param {CommonChangeProperties} change - The change object to check.
|
|
36
|
+
* @returns {boolean} `true` if the `changeType` is `codeExt`, indicating the change is of type `codeExtChange`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isCodeExtChange(change: CommonChangeProperties): change is CodeExtChange;
|
|
32
39
|
/**
|
|
33
40
|
* Determines whether a given change is of type `AnnotationFileChange`.
|
|
34
41
|
*
|
|
@@ -47,12 +54,22 @@ export declare function isAddAnnotationChange(change: CommonChangeProperties): c
|
|
|
47
54
|
* @param {CommonAdditionalChangeInfoProperties} additionalChangeInfo - Optional extended change properties.
|
|
48
55
|
*/
|
|
49
56
|
export declare function addXmlFragment(basePath: string, change: AddXMLChange, fs: Editor, logger: Logger, additionalChangeInfo?: CommonAdditionalChangeInfoProperties): void;
|
|
57
|
+
/**
|
|
58
|
+
* Asynchronously adds an controller extension to the project if it doesn't already exist.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} rootPath - The root path of the project.
|
|
61
|
+
* @param {string} basePath - The base path of the project.
|
|
62
|
+
* @param {CodeExtChange} change - The change data, including the fragment path.
|
|
63
|
+
* @param {Editor} fs - The mem-fs-editor instance.
|
|
64
|
+
* @param {Logger} logger - The logging instance.
|
|
65
|
+
*/
|
|
66
|
+
export declare function addControllerExtension(rootPath: string, basePath: string, change: CodeExtChange, fs: Editor, logger: Logger): Promise<void>;
|
|
50
67
|
/**
|
|
51
68
|
* Asynchronously adds an XML fragment to the project if it doesn't already exist.
|
|
52
69
|
*
|
|
53
70
|
* @param {string} basePath - The base path of the project.
|
|
54
71
|
* @param {string} projectRoot - The root path of the project.
|
|
55
|
-
* @param {
|
|
72
|
+
* @param {AnnotationFileChange} change - The change data, including the fragment path.
|
|
56
73
|
* @param {Editor} fs - The mem-fs-editor instance.
|
|
57
74
|
* @param {Logger} logger - The logging instance.
|
|
58
75
|
*/
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.moduleNameContentMap = void 0;
|
|
4
4
|
exports.tryFixChange = tryFixChange;
|
|
5
5
|
exports.isAddXMLChange = isAddXMLChange;
|
|
6
|
+
exports.isCodeExtChange = isCodeExtChange;
|
|
6
7
|
exports.isAddAnnotationChange = isAddAnnotationChange;
|
|
7
8
|
exports.addXmlFragment = addXmlFragment;
|
|
9
|
+
exports.addControllerExtension = addControllerExtension;
|
|
8
10
|
exports.addAnnotationFile = addAnnotationFile;
|
|
9
11
|
const path_1 = require("path");
|
|
10
12
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -183,6 +185,15 @@ function tryFixChange(change, logger) {
|
|
|
183
185
|
function isAddXMLChange(change) {
|
|
184
186
|
return change.changeType === 'addXML' || change.changeType === 'addXMLAtExtensionPoint';
|
|
185
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Determines whether a given change is of type `codeExt`.
|
|
190
|
+
*
|
|
191
|
+
* @param {CommonChangeProperties} change - The change object to check.
|
|
192
|
+
* @returns {boolean} `true` if the `changeType` is `codeExt`, indicating the change is of type `codeExtChange`.
|
|
193
|
+
*/
|
|
194
|
+
function isCodeExtChange(change) {
|
|
195
|
+
return change.changeType === 'codeExt';
|
|
196
|
+
}
|
|
186
197
|
/**
|
|
187
198
|
* Determines whether a given change is of type `AnnotationFileChange`.
|
|
188
199
|
*
|
|
@@ -225,12 +236,41 @@ function addXmlFragment(basePath, change, fs, logger, additionalChangeInfo) {
|
|
|
225
236
|
logger.error(`Failed to create XML Fragment "${fragmentPath}": ${error}`);
|
|
226
237
|
}
|
|
227
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Asynchronously adds an controller extension to the project if it doesn't already exist.
|
|
241
|
+
*
|
|
242
|
+
* @param {string} rootPath - The root path of the project.
|
|
243
|
+
* @param {string} basePath - The base path of the project.
|
|
244
|
+
* @param {CodeExtChange} change - The change data, including the fragment path.
|
|
245
|
+
* @param {Editor} fs - The mem-fs-editor instance.
|
|
246
|
+
* @param {Logger} logger - The logging instance.
|
|
247
|
+
*/
|
|
248
|
+
async function addControllerExtension(rootPath, basePath, change, fs, logger) {
|
|
249
|
+
const { codeRef } = change.content;
|
|
250
|
+
const isTsSupported = (0, helper_1.isTypescriptSupported)(rootPath, fs);
|
|
251
|
+
const fileName = (0, path_1.basename)(codeRef, '.js');
|
|
252
|
+
const fullName = `${fileName}.${isTsSupported ? 'ts' : 'js'}`;
|
|
253
|
+
const tmplFileName = isTsSupported ? "ts-controller.ejs" /* TemplateFileName.TSController */ : "controller.ejs" /* TemplateFileName.Controller */;
|
|
254
|
+
const tmplPath = (0, path_1.join)(__dirname, '../../templates/rta', tmplFileName);
|
|
255
|
+
try {
|
|
256
|
+
const text = fs.read(tmplPath);
|
|
257
|
+
const id = (await (0, helper_1.getVariant)(rootPath))?.id;
|
|
258
|
+
const extensionPath = `${id}.${fileName}`;
|
|
259
|
+
const templateData = isTsSupported ? { name: fileName, ns: id } : { extensionPath };
|
|
260
|
+
const template = (0, ejs_1.render)(text, templateData);
|
|
261
|
+
fs.write((0, path_1.join)(basePath, project_access_1.DirName.Changes, project_access_1.DirName.Coding, fullName), template);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
logger.error(`Failed to create controller extension "${codeRef}": ${error}`);
|
|
265
|
+
throw new Error(`Failed to create controller extension: ${error.message}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
228
268
|
/**
|
|
229
269
|
* Asynchronously adds an XML fragment to the project if it doesn't already exist.
|
|
230
270
|
*
|
|
231
271
|
* @param {string} basePath - The base path of the project.
|
|
232
272
|
* @param {string} projectRoot - The root path of the project.
|
|
233
|
-
* @param {
|
|
273
|
+
* @param {AnnotationFileChange} change - The change data, including the fragment path.
|
|
234
274
|
* @param {Editor} fs - The mem-fs-editor instance.
|
|
235
275
|
* @param {Logger} logger - The logging instance.
|
|
236
276
|
*/
|
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.14.
|
|
12
|
+
"version": "0.14.3",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"@sap-ux/axios-extension": "1.21.0",
|
|
36
36
|
"@sap-ux/btp-utils": "1.1.0",
|
|
37
37
|
"@sap-ux/inquirer-common": "0.7.1",
|
|
38
|
-
"@sap-ux/project-access": "1.30.1",
|
|
39
38
|
"@sap-ux/logger": "0.7.0",
|
|
39
|
+
"@sap-ux/project-access": "1.30.1",
|
|
40
40
|
"@sap-ux/project-input-validator": "0.6.1",
|
|
41
41
|
"@sap-ux/system-access": "0.6.0",
|
|
42
42
|
"@sap-ux/ui5-config": "0.28.1",
|
|
43
|
-
"@sap-ux/odata-service-writer": "0.27.
|
|
43
|
+
"@sap-ux/odata-service-writer": "0.27.2",
|
|
44
44
|
"@sap-ux/nodejs-utils": "0.2.0",
|
|
45
45
|
"@sap-ux/i18n": "0.3.0",
|
|
46
46
|
"@sap-ux/store": "1.1.0"
|