@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
|
@@ -7,8 +7,8 @@ const project_access_1 = require("@sap-ux/project-access");
|
|
|
7
7
|
* A mapping object that defines how to extract change content data from changes based on their type.
|
|
8
8
|
*/
|
|
9
9
|
exports.moduleNameContentMap = {
|
|
10
|
-
codeExt: (change) =>
|
|
11
|
-
addXML: (change) =>
|
|
10
|
+
codeExt: (change) => (change.content?.codeRef ?? '').replace('.js', ''),
|
|
11
|
+
addXML: (change) => change.content?.fragmentPath ?? ''
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Sets the moduleName property of the provided change to also support old changes with newer UI5 versions.
|
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -46,6 +37,9 @@ const project_access_1 = require("@sap-ux/project-access");
|
|
|
46
37
|
* @description Handles API Routes
|
|
47
38
|
*/
|
|
48
39
|
class RoutesHandler {
|
|
40
|
+
project;
|
|
41
|
+
util;
|
|
42
|
+
logger;
|
|
49
43
|
/**
|
|
50
44
|
* Constructor taking project as input.
|
|
51
45
|
*
|
|
@@ -57,152 +51,6 @@ class RoutesHandler {
|
|
|
57
51
|
this.project = project;
|
|
58
52
|
this.util = util;
|
|
59
53
|
this.logger = logger;
|
|
60
|
-
/**
|
|
61
|
-
* Handler for reading all fragment files from the workspace.
|
|
62
|
-
*
|
|
63
|
-
* @param _ Request
|
|
64
|
-
* @param res Response
|
|
65
|
-
* @param next Next Function
|
|
66
|
-
*/
|
|
67
|
-
this.handleReadAllFragments = (_, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
try {
|
|
69
|
-
const files = yield this.readAllFilesByGlob('/**/changes/fragments/*.fragment.xml');
|
|
70
|
-
const fileNames = files.map((f) => ({
|
|
71
|
-
fragmentName: f.getName()
|
|
72
|
-
}));
|
|
73
|
-
this.sendFilesResponse(res, {
|
|
74
|
-
fragments: fileNames,
|
|
75
|
-
message: `${fileNames.length} fragments found in the project workspace.`
|
|
76
|
-
});
|
|
77
|
-
this.logger.debug(`Read fragments ${JSON.stringify(fileNames)}`);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
this.handleErrorMessage(res, next, e);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
/**
|
|
84
|
-
* Handler for reading all controller extension files from the workspace.
|
|
85
|
-
*
|
|
86
|
-
* @param _ Request
|
|
87
|
-
* @param res Response
|
|
88
|
-
* @param next Next Function
|
|
89
|
-
*/
|
|
90
|
-
this.handleReadAllControllers = (_, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
try {
|
|
92
|
-
const files = yield this.readAllFilesByGlob('/**/changes/coding/*.js');
|
|
93
|
-
const fileNames = files.map((f) => ({
|
|
94
|
-
controllerName: f.getName()
|
|
95
|
-
}));
|
|
96
|
-
this.sendFilesResponse(res, {
|
|
97
|
-
controllers: fileNames,
|
|
98
|
-
message: `${fileNames.length} controllers found in the project workspace.`
|
|
99
|
-
});
|
|
100
|
-
this.logger.debug(`Read controllers ${JSON.stringify(fileNames)}`);
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
this.handleErrorMessage(res, next, e);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
/**
|
|
107
|
-
* Handler for retrieving existing controller extension data from the workspace.
|
|
108
|
-
*
|
|
109
|
-
* @param req Request
|
|
110
|
-
* @param res Response
|
|
111
|
-
* @param next Next Function
|
|
112
|
-
*/
|
|
113
|
-
this.handleGetControllerExtensionData = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
try {
|
|
115
|
-
const params = req.params;
|
|
116
|
-
const controllerName = (0, sanitize_filename_1.default)(params.controllerName);
|
|
117
|
-
const codeExtFiles = yield this.readAllFilesByGlob('/**/changes/*_codeExt.change');
|
|
118
|
-
let controllerPathFromRoot = '';
|
|
119
|
-
let controllerExists = false;
|
|
120
|
-
let controllerPath = '';
|
|
121
|
-
let changeFilePath = '';
|
|
122
|
-
const project = this.util.getProject();
|
|
123
|
-
const sourcePath = project.getSourcePath();
|
|
124
|
-
const projectName = project.getName();
|
|
125
|
-
const getPath = (projectPath, fileName, folder = project_access_1.DirName.Coding) => path.join(projectPath, project_access_1.DirName.Changes, folder, fileName).split(path.sep).join(path.posix.sep);
|
|
126
|
-
for (const file of codeExtFiles) {
|
|
127
|
-
const fileStr = yield file.getString();
|
|
128
|
-
const change = JSON.parse(fileStr);
|
|
129
|
-
if (change.selector.controllerName === controllerName) {
|
|
130
|
-
const fileName = change.content.codeRef.replace('coding/', '');
|
|
131
|
-
controllerPath = getPath(sourcePath, fileName);
|
|
132
|
-
controllerPathFromRoot = getPath(projectName, fileName);
|
|
133
|
-
changeFilePath = getPath(projectName, file.getName(), '');
|
|
134
|
-
controllerExists = true;
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (controllerExists && !fs.existsSync(controllerPath)) {
|
|
139
|
-
const errorMsg = `Please delete the change file at "${changeFilePath}" and retry creating the controller extension.`;
|
|
140
|
-
this.logger.debug(errorMsg);
|
|
141
|
-
res.status(404 /* HttpStatusCodes.NOT_FOUND */).send({ message: errorMsg });
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const isRunningInBAS = (0, btp_utils_1.isAppStudio)();
|
|
145
|
-
this.sendFilesResponse(res, {
|
|
146
|
-
controllerExists,
|
|
147
|
-
controllerPath: os.platform() === 'win32' ? `/${controllerPath}` : controllerPath,
|
|
148
|
-
controllerPathFromRoot,
|
|
149
|
-
isRunningInBAS
|
|
150
|
-
});
|
|
151
|
-
this.logger.debug(controllerExists
|
|
152
|
-
? `Controller exists at '${controllerPath}'`
|
|
153
|
-
: `Controller with controllerName '${controllerName}' does not exist`);
|
|
154
|
-
}
|
|
155
|
-
catch (e) {
|
|
156
|
-
this.handleErrorMessage(res, next, e);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
/**
|
|
160
|
-
* Handler for writing a controller extension file to the workspace.
|
|
161
|
-
*
|
|
162
|
-
* @param req Request
|
|
163
|
-
* @param res Response
|
|
164
|
-
* @param next Next Function
|
|
165
|
-
*/
|
|
166
|
-
this.handleWriteControllerExt = (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
try {
|
|
168
|
-
const data = req.body;
|
|
169
|
-
const controllerExtName = (0, sanitize_filename_1.default)(data.controllerName);
|
|
170
|
-
const projectId = data.projectId;
|
|
171
|
-
const sourcePath = this.util.getProject().getSourcePath();
|
|
172
|
-
if (!controllerExtName) {
|
|
173
|
-
res.status(400 /* HttpStatusCodes.BAD_REQUEST */).send('Controller extension name was not provided!');
|
|
174
|
-
this.logger.debug('Bad request. Controller extension name was not provided!');
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const fullPath = path.join(sourcePath, project_access_1.DirName.Changes, project_access_1.DirName.Coding);
|
|
178
|
-
const filePath = path.join(fullPath, `${controllerExtName}.js`);
|
|
179
|
-
if (!fs.existsSync(fullPath)) {
|
|
180
|
-
fs.mkdirSync(fullPath, { recursive: true });
|
|
181
|
-
}
|
|
182
|
-
if (fs.existsSync(filePath)) {
|
|
183
|
-
res.status(409 /* HttpStatusCodes.CONFLICT */).send(`Controller extension with name "${controllerExtName}" already exists`);
|
|
184
|
-
this.logger.debug(`Controller extension with name "${controllerExtName}" already exists`);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
const controllerExtPath = `${projectId}.${controllerExtName}`;
|
|
188
|
-
const controllerTemplateFilePath = path.join(__dirname, '../../templates/rta', "controller.ejs" /* TemplateFileName.Controller */);
|
|
189
|
-
(0, ejs_1.renderFile)(controllerTemplateFilePath, { controllerExtPath }, {}, (err, str) => {
|
|
190
|
-
if (err) {
|
|
191
|
-
throw new Error('Error rendering template: ' + err.message);
|
|
192
|
-
}
|
|
193
|
-
fs.writeFileSync(filePath, str, { encoding: 'utf8' });
|
|
194
|
-
});
|
|
195
|
-
const message = 'Controller extension created!';
|
|
196
|
-
res.status(201 /* HttpStatusCodes.CREATED */).send(message);
|
|
197
|
-
this.logger.debug(`Controller extension with name "${controllerExtName}" was created`);
|
|
198
|
-
}
|
|
199
|
-
catch (e) {
|
|
200
|
-
const sanitizedMsg = (0, sanitize_filename_1.default)(e.message);
|
|
201
|
-
this.logger.error(sanitizedMsg);
|
|
202
|
-
res.status(500 /* HttpStatusCodes.INTERNAL_SERVER_ERROR */).send(sanitizedMsg);
|
|
203
|
-
next(e);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
54
|
}
|
|
207
55
|
/**
|
|
208
56
|
* Reads files from workspace by given search pattern.
|
|
@@ -210,10 +58,8 @@ class RoutesHandler {
|
|
|
210
58
|
* @param pattern Search pattern
|
|
211
59
|
* @returns Array of files
|
|
212
60
|
*/
|
|
213
|
-
readAllFilesByGlob(pattern) {
|
|
214
|
-
return
|
|
215
|
-
return this.project.byGlob(pattern);
|
|
216
|
-
});
|
|
61
|
+
async readAllFilesByGlob(pattern) {
|
|
62
|
+
return this.project.byGlob(pattern);
|
|
217
63
|
}
|
|
218
64
|
/**
|
|
219
65
|
* Sends response with data to the client.
|
|
@@ -239,6 +85,152 @@ class RoutesHandler {
|
|
|
239
85
|
res.status(500 /* HttpStatusCodes.INTERNAL_SERVER_ERROR */).send({ message: sanitizedMsg });
|
|
240
86
|
next(e);
|
|
241
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Handler for reading all fragment files from the workspace.
|
|
90
|
+
*
|
|
91
|
+
* @param _ Request
|
|
92
|
+
* @param res Response
|
|
93
|
+
* @param next Next Function
|
|
94
|
+
*/
|
|
95
|
+
handleReadAllFragments = async (_, res, next) => {
|
|
96
|
+
try {
|
|
97
|
+
const files = await this.readAllFilesByGlob('/**/changes/fragments/*.fragment.xml');
|
|
98
|
+
const fileNames = files.map((f) => ({
|
|
99
|
+
fragmentName: f.getName()
|
|
100
|
+
}));
|
|
101
|
+
this.sendFilesResponse(res, {
|
|
102
|
+
fragments: fileNames,
|
|
103
|
+
message: `${fileNames.length} fragments found in the project workspace.`
|
|
104
|
+
});
|
|
105
|
+
this.logger.debug(`Read fragments ${JSON.stringify(fileNames)}`);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
this.handleErrorMessage(res, next, e);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Handler for reading all controller extension files from the workspace.
|
|
113
|
+
*
|
|
114
|
+
* @param _ Request
|
|
115
|
+
* @param res Response
|
|
116
|
+
* @param next Next Function
|
|
117
|
+
*/
|
|
118
|
+
handleReadAllControllers = async (_, res, next) => {
|
|
119
|
+
try {
|
|
120
|
+
const files = await this.readAllFilesByGlob('/**/changes/coding/*.js');
|
|
121
|
+
const fileNames = files.map((f) => ({
|
|
122
|
+
controllerName: f.getName()
|
|
123
|
+
}));
|
|
124
|
+
this.sendFilesResponse(res, {
|
|
125
|
+
controllers: fileNames,
|
|
126
|
+
message: `${fileNames.length} controllers found in the project workspace.`
|
|
127
|
+
});
|
|
128
|
+
this.logger.debug(`Read controllers ${JSON.stringify(fileNames)}`);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
this.handleErrorMessage(res, next, e);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Handler for retrieving existing controller extension data from the workspace.
|
|
136
|
+
*
|
|
137
|
+
* @param req Request
|
|
138
|
+
* @param res Response
|
|
139
|
+
* @param next Next Function
|
|
140
|
+
*/
|
|
141
|
+
handleGetControllerExtensionData = async (req, res, next) => {
|
|
142
|
+
try {
|
|
143
|
+
const params = req.params;
|
|
144
|
+
const controllerName = (0, sanitize_filename_1.default)(params.controllerName);
|
|
145
|
+
const codeExtFiles = await this.readAllFilesByGlob('/**/changes/*_codeExt.change');
|
|
146
|
+
let controllerPathFromRoot = '';
|
|
147
|
+
let controllerExists = false;
|
|
148
|
+
let controllerPath = '';
|
|
149
|
+
let changeFilePath = '';
|
|
150
|
+
const project = this.util.getProject();
|
|
151
|
+
const sourcePath = project.getSourcePath();
|
|
152
|
+
const projectName = project.getName();
|
|
153
|
+
const getPath = (projectPath, fileName, folder = project_access_1.DirName.Coding) => path.join(projectPath, project_access_1.DirName.Changes, folder, fileName).split(path.sep).join(path.posix.sep);
|
|
154
|
+
for (const file of codeExtFiles) {
|
|
155
|
+
const fileStr = await file.getString();
|
|
156
|
+
const change = JSON.parse(fileStr);
|
|
157
|
+
if (change.selector.controllerName === controllerName) {
|
|
158
|
+
const fileName = change.content.codeRef.replace('coding/', '');
|
|
159
|
+
controllerPath = getPath(sourcePath, fileName);
|
|
160
|
+
controllerPathFromRoot = getPath(projectName, fileName);
|
|
161
|
+
changeFilePath = getPath(projectName, file.getName(), '');
|
|
162
|
+
controllerExists = true;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (controllerExists && !fs.existsSync(controllerPath)) {
|
|
167
|
+
const errorMsg = `Please delete the change file at "${changeFilePath}" and retry creating the controller extension.`;
|
|
168
|
+
this.logger.debug(errorMsg);
|
|
169
|
+
res.status(404 /* HttpStatusCodes.NOT_FOUND */).send({ message: errorMsg });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const isRunningInBAS = (0, btp_utils_1.isAppStudio)();
|
|
173
|
+
this.sendFilesResponse(res, {
|
|
174
|
+
controllerExists,
|
|
175
|
+
controllerPath: os.platform() === 'win32' ? `/${controllerPath}` : controllerPath,
|
|
176
|
+
controllerPathFromRoot,
|
|
177
|
+
isRunningInBAS
|
|
178
|
+
});
|
|
179
|
+
this.logger.debug(controllerExists
|
|
180
|
+
? `Controller exists at '${controllerPath}'`
|
|
181
|
+
: `Controller with controllerName '${controllerName}' does not exist`);
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
this.handleErrorMessage(res, next, e);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Handler for writing a controller extension file to the workspace.
|
|
189
|
+
*
|
|
190
|
+
* @param req Request
|
|
191
|
+
* @param res Response
|
|
192
|
+
* @param next Next Function
|
|
193
|
+
*/
|
|
194
|
+
handleWriteControllerExt = async (req, res, next) => {
|
|
195
|
+
try {
|
|
196
|
+
const data = req.body;
|
|
197
|
+
const controllerExtName = (0, sanitize_filename_1.default)(data.controllerName);
|
|
198
|
+
const projectId = data.projectId;
|
|
199
|
+
const sourcePath = this.util.getProject().getSourcePath();
|
|
200
|
+
if (!controllerExtName) {
|
|
201
|
+
res.status(400 /* HttpStatusCodes.BAD_REQUEST */).send('Controller extension name was not provided!');
|
|
202
|
+
this.logger.debug('Bad request. Controller extension name was not provided!');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const fullPath = path.join(sourcePath, project_access_1.DirName.Changes, project_access_1.DirName.Coding);
|
|
206
|
+
const filePath = path.join(fullPath, `${controllerExtName}.js`);
|
|
207
|
+
if (!fs.existsSync(fullPath)) {
|
|
208
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
209
|
+
}
|
|
210
|
+
if (fs.existsSync(filePath)) {
|
|
211
|
+
res.status(409 /* HttpStatusCodes.CONFLICT */).send(`Controller extension with name "${controllerExtName}" already exists`);
|
|
212
|
+
this.logger.debug(`Controller extension with name "${controllerExtName}" already exists`);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const controllerExtPath = `${projectId}.${controllerExtName}`;
|
|
216
|
+
const controllerTemplateFilePath = path.join(__dirname, '../../templates/rta', "controller.ejs" /* TemplateFileName.Controller */);
|
|
217
|
+
(0, ejs_1.renderFile)(controllerTemplateFilePath, { controllerExtPath }, {}, (err, str) => {
|
|
218
|
+
if (err) {
|
|
219
|
+
throw new Error('Error rendering template: ' + err.message);
|
|
220
|
+
}
|
|
221
|
+
fs.writeFileSync(filePath, str, { encoding: 'utf8' });
|
|
222
|
+
});
|
|
223
|
+
const message = 'Controller extension created!';
|
|
224
|
+
res.status(201 /* HttpStatusCodes.CREATED */).send(message);
|
|
225
|
+
this.logger.debug(`Controller extension with name "${controllerExtName}" was created`);
|
|
226
|
+
}
|
|
227
|
+
catch (e) {
|
|
228
|
+
const sanitizedMsg = (0, sanitize_filename_1.default)(e.message);
|
|
229
|
+
this.logger.error(sanitizedMsg);
|
|
230
|
+
res.status(500 /* HttpStatusCodes.INTERNAL_SERVER_ERROR */).send(sanitizedMsg);
|
|
231
|
+
next(e);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
242
234
|
}
|
|
243
235
|
exports.default = RoutesHandler;
|
|
244
236
|
//# sourceMappingURL=routes-handler.js.map
|
|
@@ -6,6 +6,14 @@ const writers_1 = require("./writers");
|
|
|
6
6
|
* Handles the creation of a writer instance based on the generator type.
|
|
7
7
|
*/
|
|
8
8
|
class WriterFactory {
|
|
9
|
+
static writers = new Map([
|
|
10
|
+
["appdescr_app_addAnnotationsToOData" /* ChangeType.ADD_ANNOTATIONS_TO_ODATA */, writers_1.AnnotationsWriter],
|
|
11
|
+
["appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */, writers_1.ComponentUsagesWriter],
|
|
12
|
+
["appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */, writers_1.ComponentUsagesWriter],
|
|
13
|
+
["appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */, writers_1.NewModelWriter],
|
|
14
|
+
["appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, writers_1.DataSourceWriter],
|
|
15
|
+
["appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */, writers_1.InboundWriter]
|
|
16
|
+
]);
|
|
9
17
|
/**
|
|
10
18
|
* Creates an instance of a writer based on the specified generator type.
|
|
11
19
|
*
|
|
@@ -24,12 +32,4 @@ class WriterFactory {
|
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
exports.WriterFactory = WriterFactory;
|
|
27
|
-
WriterFactory.writers = new Map([
|
|
28
|
-
["appdescr_app_addAnnotationsToOData" /* ChangeType.ADD_ANNOTATIONS_TO_ODATA */, writers_1.AnnotationsWriter],
|
|
29
|
-
["appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */, writers_1.ComponentUsagesWriter],
|
|
30
|
-
["appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */, writers_1.ComponentUsagesWriter],
|
|
31
|
-
["appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */, writers_1.NewModelWriter],
|
|
32
|
-
["appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, writers_1.DataSourceWriter],
|
|
33
|
-
["appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */, writers_1.InboundWriter]
|
|
34
|
-
]);
|
|
35
35
|
//# sourceMappingURL=writer-factory.js.map
|
|
@@ -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
|
};
|
|
@@ -19,6 +10,8 @@ const change_utils_1 = require("../../../base/change-utils");
|
|
|
19
10
|
* Handles the creation and writing of annotations data changes for a project.
|
|
20
11
|
*/
|
|
21
12
|
class AnnotationsWriter {
|
|
13
|
+
fs;
|
|
14
|
+
projectPath;
|
|
22
15
|
/**
|
|
23
16
|
* @param {Editor} fs - The filesystem editor instance.
|
|
24
17
|
* @param {string} projectPath - The root path of the project.
|
|
@@ -35,7 +28,7 @@ class AnnotationsWriter {
|
|
|
35
28
|
*/
|
|
36
29
|
constructContent(data) {
|
|
37
30
|
const { isInternalUsage, annotation: { dataSource, fileName } } = data;
|
|
38
|
-
const annotationFileNameWithoutExtension = fileName
|
|
31
|
+
const annotationFileNameWithoutExtension = fileName?.toLocaleLowerCase().replace('.xml', '');
|
|
39
32
|
const annotationNameSpace = isInternalUsage
|
|
40
33
|
? `annotation.${annotationFileNameWithoutExtension}`
|
|
41
34
|
: `customer.annotation.${annotationFileNameWithoutExtension}`;
|
|
@@ -66,13 +59,11 @@ class AnnotationsWriter {
|
|
|
66
59
|
* @param {AnnotationsData} data - The annotations data containing all the necessary information to construct and write the change.
|
|
67
60
|
* @returns {Promise<void>} A promise that resolves when the change writing process is completed.
|
|
68
61
|
*/
|
|
69
|
-
write(data) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(0, change_utils_1.writeAnnotationChange)(this.projectPath, data, change, this.fs);
|
|
75
|
-
});
|
|
62
|
+
async write(data) {
|
|
63
|
+
data.annotation.fileName = this.getAnnotationFileName(data);
|
|
64
|
+
const content = this.constructContent(data);
|
|
65
|
+
const change = (0, change_utils_1.getChange)(data.projectData, data.timestamp, content, "appdescr_app_addAnnotationsToOData" /* ChangeType.ADD_ANNOTATIONS_TO_ODATA */);
|
|
66
|
+
(0, change_utils_1.writeAnnotationChange)(this.projectPath, data, change, this.fs);
|
|
76
67
|
}
|
|
77
68
|
}
|
|
78
69
|
exports.AnnotationsWriter = AnnotationsWriter;
|
|
@@ -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.ComponentUsagesWriter = void 0;
|
|
13
4
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -16,6 +7,8 @@ const change_utils_1 = require("../../../base/change-utils");
|
|
|
16
7
|
* Handles the creation and writing of component usages data changes for a project.
|
|
17
8
|
*/
|
|
18
9
|
class ComponentUsagesWriter {
|
|
10
|
+
fs;
|
|
11
|
+
projectPath;
|
|
19
12
|
/**
|
|
20
13
|
* @param {Editor} fs - The filesystem editor instance.
|
|
21
14
|
* @param {string} projectPath - The root path of the project.
|
|
@@ -69,19 +62,17 @@ class ComponentUsagesWriter {
|
|
|
69
62
|
* @param {ComponentUsagesData} data - The component usages data containing all the necessary information to construct and write the change.
|
|
70
63
|
* @returns {Promise<void>} A promise that resolves when the change writing process is completed.
|
|
71
64
|
*/
|
|
72
|
-
write(data) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
});
|
|
65
|
+
async write(data) {
|
|
66
|
+
const componentUsagesContent = this.constructContent(data);
|
|
67
|
+
const libRefContent = this.constructLibContent(data);
|
|
68
|
+
const shouldAddLibRef = libRefContent !== undefined;
|
|
69
|
+
const compUsagesChange = (0, change_utils_1.getChange)(data.projectData, data.timestamp, componentUsagesContent, "appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */);
|
|
70
|
+
(0, change_utils_1.writeChangeToFolder)(this.projectPath, compUsagesChange, `id_${data.timestamp}_addComponentUsages.change`, this.fs, project_access_1.DirName.Manifest);
|
|
71
|
+
if (shouldAddLibRef) {
|
|
72
|
+
data.timestamp += 1;
|
|
73
|
+
const refLibChange = (0, change_utils_1.getChange)(data.projectData, data.timestamp, libRefContent, "appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */);
|
|
74
|
+
(0, change_utils_1.writeChangeToFolder)(this.projectPath, refLibChange, `id_${data.timestamp}_addLibraries.change`, this.fs, project_access_1.DirName.Manifest);
|
|
75
|
+
}
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
78
|
exports.ComponentUsagesWriter = ComponentUsagesWriter;
|
|
@@ -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.DataSourceWriter = void 0;
|
|
13
4
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -16,6 +7,8 @@ const change_utils_1 = require("../../../base/change-utils");
|
|
|
16
7
|
* Handles the creation and writing of data source data changes for a project.
|
|
17
8
|
*/
|
|
18
9
|
class DataSourceWriter {
|
|
10
|
+
fs;
|
|
11
|
+
projectPath;
|
|
19
12
|
/**
|
|
20
13
|
* @param {Editor} fs - The filesystem editor instance.
|
|
21
14
|
* @param {string} projectPath - The root path of the project.
|
|
@@ -58,23 +51,20 @@ class DataSourceWriter {
|
|
|
58
51
|
* @param {DataSourceData} data - The change data source data containing all the necessary information to construct and write the change.
|
|
59
52
|
* @returns {Promise<void>} A promise that resolves when the change writing process is completed.
|
|
60
53
|
*/
|
|
61
|
-
write(data) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(0, change_utils_1.writeChangeToFolder)(this.projectPath, annotationChange, `id_${annotationTs}_changeDataSource.change`, this.fs, project_access_1.DirName.Manifest);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
54
|
+
async write(data) {
|
|
55
|
+
const { variant, dataSources, answers } = data;
|
|
56
|
+
const { id, uri, maxAge, annotationUri } = answers;
|
|
57
|
+
const annotationId = dataSources[id].settings?.annotations?.[0];
|
|
58
|
+
const timestamp = Date.now();
|
|
59
|
+
const content = this.constructContent(id, uri, maxAge);
|
|
60
|
+
const change = (0, change_utils_1.getChange)(variant, timestamp, content, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */);
|
|
61
|
+
(0, change_utils_1.writeChangeToFolder)(this.projectPath, change, `id_${timestamp}_changeDataSource.change`, this.fs, project_access_1.DirName.Manifest);
|
|
62
|
+
if (annotationId && annotationUri) {
|
|
63
|
+
const annotationContent = this.constructContent(annotationId, annotationUri);
|
|
64
|
+
const annotationTs = timestamp + 1;
|
|
65
|
+
const annotationChange = (0, change_utils_1.getChange)(variant, annotationTs, annotationContent, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */);
|
|
66
|
+
(0, change_utils_1.writeChangeToFolder)(this.projectPath, annotationChange, `id_${annotationTs}_changeDataSource.change`, this.fs, project_access_1.DirName.Manifest);
|
|
67
|
+
}
|
|
78
68
|
}
|
|
79
69
|
}
|
|
80
70
|
exports.DataSourceWriter = DataSourceWriter;
|
|
@@ -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.InboundWriter = void 0;
|
|
13
4
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -16,6 +7,8 @@ const change_utils_1 = require("../../../base/change-utils");
|
|
|
16
7
|
* Handles the creation and writing of inbound data changes for a project.
|
|
17
8
|
*/
|
|
18
9
|
class InboundWriter {
|
|
10
|
+
fs;
|
|
11
|
+
projectPath;
|
|
19
12
|
/**
|
|
20
13
|
* @param {Editor} fs - The filesystem editor instance.
|
|
21
14
|
* @param {string} projectPath - The root path of the project.
|
|
@@ -78,11 +71,14 @@ class InboundWriter {
|
|
|
78
71
|
*/
|
|
79
72
|
getModifiedData(data) {
|
|
80
73
|
const { title, subTitle, icon } = data.flp;
|
|
81
|
-
return
|
|
74
|
+
return {
|
|
75
|
+
...data,
|
|
76
|
+
flp: {
|
|
82
77
|
title: (0, change_utils_1.getParsedPropertyValue)(title),
|
|
83
78
|
subTitle: (0, change_utils_1.getParsedPropertyValue)(subTitle),
|
|
84
79
|
icon: (0, change_utils_1.getParsedPropertyValue)(icon)
|
|
85
|
-
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
86
82
|
}
|
|
87
83
|
/**
|
|
88
84
|
* Writes the inbound data change to the project based on the provided data.
|
|
@@ -90,22 +86,20 @@ class InboundWriter {
|
|
|
90
86
|
* @param {InboundData} data - The inbound data containing all the necessary information to construct and write the change.
|
|
91
87
|
* @returns {Promise<void>} A promise that resolves when the change writing process is completed.
|
|
92
88
|
*/
|
|
93
|
-
write(data) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.getEnhancedContent(answers, changeWithInboundId.content);
|
|
105
|
-
}
|
|
106
|
-
(0, change_utils_1.writeChangeToFile)(filePath, changeWithInboundId, this.fs);
|
|
89
|
+
async write(data) {
|
|
90
|
+
const answers = this.getModifiedData(data);
|
|
91
|
+
const { changeWithInboundId, filePath } = (0, change_utils_1.findChangeWithInboundId)(this.projectPath, answers.inboundId);
|
|
92
|
+
if (!changeWithInboundId) {
|
|
93
|
+
const content = this.constructContent(answers);
|
|
94
|
+
const change = (0, change_utils_1.getChange)(data.projectData, data.timestamp, content, "appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */);
|
|
95
|
+
(0, change_utils_1.writeChangeToFolder)(this.projectPath, change, `id_${data.timestamp}_changeInbound.change`, this.fs, project_access_1.DirName.Manifest);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
if (changeWithInboundId.content) {
|
|
99
|
+
this.getEnhancedContent(answers, changeWithInboundId.content);
|
|
107
100
|
}
|
|
108
|
-
|
|
101
|
+
(0, change_utils_1.writeChangeToFile)(filePath, changeWithInboundId, this.fs);
|
|
102
|
+
}
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
exports.InboundWriter = InboundWriter;
|