@sap-ux/preview-middleware 0.15.8 → 0.16.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/config.js +85 -107
- package/dist/base/flex.js +14 -26
- package/dist/base/flp.js +130 -135
- package/dist/base/test.js +2 -3
- package/dist/client/flp/init.js +193 -255
- package/dist/client/flp/init.ts +2 -2
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +21 -32
- package/dist/ui5/middleware.js +23 -36
- package/package.json +12 -12
package/dist/base/flp.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.initAdp = exports.FlpSandbox = void 0;
|
|
13
4
|
const mem_fs_1 = require("mem-fs");
|
|
@@ -35,6 +26,15 @@ const DEFAULT_LIVERELOAD_PORT = 35729;
|
|
|
35
26
|
* Class handling preview of a sandbox FLP.
|
|
36
27
|
*/
|
|
37
28
|
class FlpSandbox {
|
|
29
|
+
project;
|
|
30
|
+
utils;
|
|
31
|
+
logger;
|
|
32
|
+
onChangeRequest;
|
|
33
|
+
templateConfig;
|
|
34
|
+
config;
|
|
35
|
+
rta;
|
|
36
|
+
test;
|
|
37
|
+
router;
|
|
38
38
|
/**
|
|
39
39
|
* Constructor setting defaults and keeping reference to workspace resources.
|
|
40
40
|
*
|
|
@@ -68,35 +68,31 @@ class FlpSandbox {
|
|
|
68
68
|
* @param componentId optional componentId e.g. for adaptation projects
|
|
69
69
|
* @param resources optional additional resource mappings
|
|
70
70
|
*/
|
|
71
|
-
init(manifest, componentId, resources = {}) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
yield this.addRoutesForAdditionalApps();
|
|
97
|
-
this.logger.info(`Initialized for app ${id}`);
|
|
98
|
-
this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
|
|
99
|
-
});
|
|
71
|
+
async init(manifest, componentId, resources = {}) {
|
|
72
|
+
this.createFlexHandler();
|
|
73
|
+
this.config.libs ??= await this.hasLocateReuseLibsScript();
|
|
74
|
+
const id = manifest['sap.app'].id;
|
|
75
|
+
this.templateConfig = (0, config_1.createFlpTemplateConfig)(this.config, manifest);
|
|
76
|
+
await (0, config_1.addApp)(this.templateConfig, manifest, {
|
|
77
|
+
componentId,
|
|
78
|
+
target: resources[componentId ?? id] ?? this.templateConfig.basePath,
|
|
79
|
+
local: '.',
|
|
80
|
+
intent: this.config.intent
|
|
81
|
+
}, this.logger);
|
|
82
|
+
this.addStandardRoutes();
|
|
83
|
+
if (this.rta) {
|
|
84
|
+
this.rta.options ??= {};
|
|
85
|
+
this.rta.options.baseId = componentId ?? id;
|
|
86
|
+
this.rta.options.appName = id;
|
|
87
|
+
this.addEditorRoutes(this.rta);
|
|
88
|
+
}
|
|
89
|
+
if (this.test) {
|
|
90
|
+
this.addTestRoutes(this.test.filter((config) => config.framework !== 'Testsuite'), id);
|
|
91
|
+
this.createTestSuite(this.test);
|
|
92
|
+
}
|
|
93
|
+
await this.addRoutesForAdditionalApps();
|
|
94
|
+
this.logger.info(`Initialized for app ${id}`);
|
|
95
|
+
this.logger.debug(`Configured apps: ${JSON.stringify(this.templateConfig.apps)}`);
|
|
100
96
|
}
|
|
101
97
|
/**
|
|
102
98
|
* Generates the FLP sandbox for an editor.
|
|
@@ -106,18 +102,23 @@ class FlpSandbox {
|
|
|
106
102
|
* @returns FLP sandbox html
|
|
107
103
|
*/
|
|
108
104
|
generateSandboxForEditor(rta, editor) {
|
|
109
|
-
var _a;
|
|
110
105
|
const defaultGenerator = editor.developerMode
|
|
111
106
|
? '@sap-ux/control-property-editor'
|
|
112
107
|
: '@sap-ux/preview-middleware';
|
|
113
|
-
const config =
|
|
108
|
+
const config = { ...this.templateConfig };
|
|
114
109
|
/* sap.ui.rta needs to be added to the list of preload libs for variants management and adaptation projects */
|
|
115
110
|
if (!config.ui5.libs.includes('sap.ui.rta')) {
|
|
116
111
|
const libs = config.ui5.libs.split(',');
|
|
117
112
|
libs.push('sap.ui.rta');
|
|
118
113
|
config.ui5.libs = libs.join(',');
|
|
119
114
|
}
|
|
120
|
-
config.flex =
|
|
115
|
+
config.flex = {
|
|
116
|
+
layer: rta.layer,
|
|
117
|
+
...rta.options,
|
|
118
|
+
generator: editor.generator ?? defaultGenerator,
|
|
119
|
+
developerMode: editor.developerMode === true,
|
|
120
|
+
pluginScript: editor.pluginScript
|
|
121
|
+
};
|
|
121
122
|
if (editor.developerMode === true) {
|
|
122
123
|
config.ui5.bootstrapOptions = serializeUi5Configuration(DEVELOPER_MODE_CONFIG);
|
|
123
124
|
}
|
|
@@ -130,16 +131,14 @@ class FlpSandbox {
|
|
|
130
131
|
* @param rta runtime authoring configuration
|
|
131
132
|
*/
|
|
132
133
|
addEditorRoutes(rta) {
|
|
133
|
-
var _a;
|
|
134
134
|
const cpe = (0, path_1.dirname)(require.resolve('@sap-ux/control-property-editor-sources'));
|
|
135
135
|
for (const editor of rta.editors) {
|
|
136
136
|
let previewUrl = editor.path;
|
|
137
137
|
if (editor.developerMode) {
|
|
138
138
|
previewUrl = `${previewUrl}.inner.html`;
|
|
139
|
-
|
|
140
|
-
this.router.get(editor.path, (_req, res) =>
|
|
141
|
-
|
|
142
|
-
const scenario = (_b = rta.options) === null || _b === void 0 ? void 0 : _b.scenario;
|
|
139
|
+
editor.pluginScript ??= 'open/ux/preview/client/cpe/init';
|
|
140
|
+
this.router.get(editor.path, async (_req, res) => {
|
|
141
|
+
const scenario = rta.options?.scenario;
|
|
143
142
|
let templatePreviewUrl = `${previewUrl}?sap-ui-xx-viewCache=false&fiori-tools-rta-mode=forAdaptation&sap-ui-rta-skip-flex-validation=true&sap-ui-xx-condense-changes=true#${this.config.intent.object}-${this.config.intent.action}`;
|
|
144
143
|
if (scenario === 'ADAPTATION_PROJECT') {
|
|
145
144
|
templatePreviewUrl = templatePreviewUrl.replace('?', `?sap-ui-layer=${rta.layer}&`);
|
|
@@ -148,17 +147,17 @@ class FlpSandbox {
|
|
|
148
147
|
const envPort = process.env.FIORI_TOOLS_LIVERELOAD_PORT;
|
|
149
148
|
let livereloadPort = envPort ? parseInt(envPort, 10) : DEFAULT_LIVERELOAD_PORT;
|
|
150
149
|
livereloadPort = isNaN(livereloadPort) ? DEFAULT_LIVERELOAD_PORT : livereloadPort;
|
|
151
|
-
const envLivereloadUrl = (0, btp_utils_1.isAppStudio)() ?
|
|
150
|
+
const envLivereloadUrl = (0, btp_utils_1.isAppStudio)() ? await (0, btp_utils_1.exposePort)(livereloadPort) : undefined;
|
|
152
151
|
const html = (0, ejs_1.render)(template, {
|
|
153
152
|
previewUrl: templatePreviewUrl,
|
|
154
|
-
telemetry:
|
|
155
|
-
appName:
|
|
153
|
+
telemetry: rta.options?.telemetry ?? false,
|
|
154
|
+
appName: rta.options?.appName,
|
|
156
155
|
scenario,
|
|
157
156
|
livereloadPort,
|
|
158
157
|
livereloadUrl: envLivereloadUrl
|
|
159
158
|
});
|
|
160
159
|
this.sendResponse(res, 'text/html', 200, html);
|
|
161
|
-
})
|
|
160
|
+
});
|
|
162
161
|
let path = (0, path_1.dirname)(editor.path);
|
|
163
162
|
if (!path.endsWith('/')) {
|
|
164
163
|
path = `${path}/`;
|
|
@@ -178,9 +177,9 @@ class FlpSandbox {
|
|
|
178
177
|
// register static client sources
|
|
179
178
|
this.router.use(config_1.PREVIEW_URL.client.url, (0, express_1.static)(config_1.PREVIEW_URL.client.local));
|
|
180
179
|
// add route for the sandbox.html
|
|
181
|
-
this.router.get(this.config.path, ((_req, res, next) =>
|
|
180
|
+
this.router.get(this.config.path, (async (_req, res, next) => {
|
|
182
181
|
// inform the user if a html file exists on the filesystem
|
|
183
|
-
const file =
|
|
182
|
+
const file = await this.project.byPath(this.config.path);
|
|
184
183
|
if (file) {
|
|
185
184
|
this.logger.info(`HTML file returned at ${this.config.path} is loaded from the file system.`);
|
|
186
185
|
next();
|
|
@@ -190,49 +189,44 @@ class FlpSandbox {
|
|
|
190
189
|
const html = (0, ejs_1.render)(template, this.templateConfig);
|
|
191
190
|
this.sendResponse(res, 'text/html', 200, html);
|
|
192
191
|
}
|
|
193
|
-
}))
|
|
192
|
+
}));
|
|
194
193
|
}
|
|
195
194
|
/**
|
|
196
195
|
* Try finding a locate-reuse-libs script in the project.
|
|
197
196
|
*
|
|
198
197
|
* @returns the location of the locate-reuse-libs script or undefined.
|
|
199
198
|
*/
|
|
200
|
-
hasLocateReuseLibsScript() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return files.length > 0;
|
|
204
|
-
});
|
|
199
|
+
async hasLocateReuseLibsScript() {
|
|
200
|
+
const files = await this.project.byGlob('**/locate-reuse-libs.js');
|
|
201
|
+
return files.length > 0;
|
|
205
202
|
}
|
|
206
203
|
/**
|
|
207
204
|
* Add additional routes for apps also to be shown in the local FLP.
|
|
208
205
|
*/
|
|
209
|
-
addRoutesForAdditionalApps() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.router.use(app.target, (0, express_1.static)((0, path_1.join)(app.local, 'webapp')));
|
|
217
|
-
this.logger.info(`Serving additional application at ${app.target} from ${app.local}`);
|
|
218
|
-
}
|
|
219
|
-
else if (app.componentId) {
|
|
220
|
-
manifest = {
|
|
221
|
-
'sap.app': {
|
|
222
|
-
id: app.componentId,
|
|
223
|
-
title: app.intent ? `${app.intent.object}-${app.intent.action}` : app.componentId
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
if (manifest) {
|
|
228
|
-
yield (0, config_1.addApp)(this.templateConfig, manifest, app, this.logger);
|
|
229
|
-
this.logger.info(`Adding additional intent: ${(_a = app.intent) === null || _a === void 0 ? void 0 : _a.object}-${(_b = app.intent) === null || _b === void 0 ? void 0 : _b.action}`);
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
this.logger.info(`Invalid application config for route ${app.target} because neither componentId nor local folder provided.`);
|
|
233
|
-
}
|
|
206
|
+
async addRoutesForAdditionalApps() {
|
|
207
|
+
for (const app of this.config.apps) {
|
|
208
|
+
let manifest;
|
|
209
|
+
if (app.local) {
|
|
210
|
+
manifest = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(app.local, 'webapp/manifest.json'), 'utf-8'));
|
|
211
|
+
this.router.use(app.target, (0, express_1.static)((0, path_1.join)(app.local, 'webapp')));
|
|
212
|
+
this.logger.info(`Serving additional application at ${app.target} from ${app.local}`);
|
|
234
213
|
}
|
|
235
|
-
|
|
214
|
+
else if (app.componentId) {
|
|
215
|
+
manifest = {
|
|
216
|
+
'sap.app': {
|
|
217
|
+
id: app.componentId,
|
|
218
|
+
title: app.intent ? `${app.intent.object}-${app.intent.action}` : app.componentId
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (manifest) {
|
|
223
|
+
await (0, config_1.addApp)(this.templateConfig, manifest, app, this.logger);
|
|
224
|
+
this.logger.info(`Adding additional intent: ${app.intent?.object}-${app.intent?.action}`);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
this.logger.info(`Invalid application config for route ${app.target} because neither componentId nor local folder provided.`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
236
230
|
}
|
|
237
231
|
/**
|
|
238
232
|
* Create required routes for flex.
|
|
@@ -241,24 +235,24 @@ class FlpSandbox {
|
|
|
241
235
|
const fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
242
236
|
const api = `${config_1.PREVIEW_URL.api}/changes`;
|
|
243
237
|
this.router.use(api, (0, express_1.json)());
|
|
244
|
-
this.router.get(api, ((_req, res) =>
|
|
245
|
-
const changes =
|
|
238
|
+
this.router.get(api, (async (_req, res) => {
|
|
239
|
+
const changes = await (0, flex_1.readChanges)(this.project, this.logger);
|
|
246
240
|
if (this.onChangeRequest) {
|
|
247
241
|
for (const change of Object.values(changes)) {
|
|
248
|
-
|
|
242
|
+
await this.onChangeRequest('read', change, fs, this.logger);
|
|
249
243
|
}
|
|
250
244
|
}
|
|
251
245
|
this.sendResponse(res, 'application/json', 200, JSON.stringify(changes));
|
|
252
|
-
}))
|
|
253
|
-
this.router.post(api, ((req, res) =>
|
|
246
|
+
}));
|
|
247
|
+
this.router.post(api, (async (req, res) => {
|
|
254
248
|
try {
|
|
255
249
|
const change = req.body;
|
|
256
250
|
if (this.onChangeRequest) {
|
|
257
|
-
|
|
251
|
+
await this.onChangeRequest('write', change, fs, this.logger);
|
|
258
252
|
}
|
|
259
253
|
const { success, message } = (0, flex_1.writeChange)(change, this.utils.getProject().getSourcePath(), fs, this.logger);
|
|
260
254
|
if (success) {
|
|
261
|
-
fs.commit(() => this.sendResponse(res, 'text/plain', 200, message
|
|
255
|
+
fs.commit(() => this.sendResponse(res, 'text/plain', 200, message ?? ''));
|
|
262
256
|
}
|
|
263
257
|
else {
|
|
264
258
|
this.sendResponse(res, 'text/plain', 400, 'INVALID_DATA');
|
|
@@ -267,12 +261,12 @@ class FlpSandbox {
|
|
|
267
261
|
catch (error) {
|
|
268
262
|
this.sendResponse(res, 'text/plain', 500, error.message);
|
|
269
263
|
}
|
|
270
|
-
}))
|
|
271
|
-
this.router.delete(api, ((req, res) =>
|
|
264
|
+
}));
|
|
265
|
+
this.router.delete(api, (async (req, res) => {
|
|
272
266
|
try {
|
|
273
267
|
const { success, message } = (0, flex_1.deleteChange)(req.body, this.utils.getProject().getSourcePath(), this.logger);
|
|
274
268
|
if (success) {
|
|
275
|
-
this.sendResponse(res, 'text/plain', 200, message
|
|
269
|
+
this.sendResponse(res, 'text/plain', 200, message ?? '');
|
|
276
270
|
}
|
|
277
271
|
else {
|
|
278
272
|
this.sendResponse(res, 'text/plain', 400, 'INVALID_DATA');
|
|
@@ -281,7 +275,7 @@ class FlpSandbox {
|
|
|
281
275
|
catch (error) {
|
|
282
276
|
this.sendResponse(res, 'text/plain', 500, error.message);
|
|
283
277
|
}
|
|
284
|
-
}))
|
|
278
|
+
}));
|
|
285
279
|
}
|
|
286
280
|
/**
|
|
287
281
|
* If it is part of TestConfig, create a test suite for the test configurations.
|
|
@@ -303,7 +297,7 @@ class FlpSandbox {
|
|
|
303
297
|
const initTemplate = (0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../templates/test/testsuite.qunit.js'), 'utf-8');
|
|
304
298
|
const config = (0, test_1.mergeTestConfigDefaults)(testsuiteConfig);
|
|
305
299
|
this.logger.debug(`Add route for ${config.path}`);
|
|
306
|
-
this.router.get(config.path, ((_req, res) =>
|
|
300
|
+
this.router.get(config.path, (async (_req, res) => {
|
|
307
301
|
this.logger.debug(`Serving test route: ${config.path}`);
|
|
308
302
|
const templateConfig = {
|
|
309
303
|
basePath: this.templateConfig.basePath,
|
|
@@ -311,7 +305,7 @@ class FlpSandbox {
|
|
|
311
305
|
};
|
|
312
306
|
const html = (0, ejs_1.render)(testsuite, templateConfig);
|
|
313
307
|
this.sendResponse(res, 'text/html', 200, html);
|
|
314
|
-
}))
|
|
308
|
+
}));
|
|
315
309
|
if (testsuiteConfig.init !== undefined) {
|
|
316
310
|
this.logger.debug(`Skip serving testsuite init script in favor of provided script: ${testsuiteConfig.init}`);
|
|
317
311
|
return;
|
|
@@ -325,9 +319,9 @@ class FlpSandbox {
|
|
|
325
319
|
testPaths.push(path_1.posix.relative(path_1.posix.dirname(config.path), mergedConfig.path));
|
|
326
320
|
}
|
|
327
321
|
this.logger.debug(`Add route for ${config.init}`);
|
|
328
|
-
this.router.get(config.init, ((_req, res, next) =>
|
|
329
|
-
const files =
|
|
330
|
-
if (
|
|
322
|
+
this.router.get(config.init, (async (_req, res, next) => {
|
|
323
|
+
const files = await this.project.byGlob(config.init.replace('.js', '.[jt]s'));
|
|
324
|
+
if (files?.length > 0) {
|
|
331
325
|
this.logger.warn(`Script returned at ${config.path} is loaded from the file system.`);
|
|
332
326
|
next();
|
|
333
327
|
}
|
|
@@ -339,7 +333,7 @@ class FlpSandbox {
|
|
|
339
333
|
const js = (0, ejs_1.render)(initTemplate, templateConfig);
|
|
340
334
|
this.sendResponse(res, 'application/javascript', 200, js);
|
|
341
335
|
}
|
|
342
|
-
}))
|
|
336
|
+
}));
|
|
343
337
|
}
|
|
344
338
|
/**
|
|
345
339
|
* Send a response with the given content type, status and body.
|
|
@@ -372,9 +366,9 @@ class FlpSandbox {
|
|
|
372
366
|
const config = (0, test_1.mergeTestConfigDefaults)(testConfig);
|
|
373
367
|
this.logger.debug(`Add route for ${config.path}`);
|
|
374
368
|
// add route for the *.qunit.html
|
|
375
|
-
this.router.get(config.path, ((_req, res, next) =>
|
|
369
|
+
this.router.get(config.path, (async (_req, res, next) => {
|
|
376
370
|
this.logger.debug(`Serving test route: ${config.path}`);
|
|
377
|
-
const file =
|
|
371
|
+
const file = await this.project.byPath(config.path);
|
|
378
372
|
if (file) {
|
|
379
373
|
this.logger.warn(`HTML file returned at ${config.path} is loaded from the file system.`);
|
|
380
374
|
next();
|
|
@@ -384,27 +378,27 @@ class FlpSandbox {
|
|
|
384
378
|
const html = (0, ejs_1.render)(htmlTemplate, templateConfig);
|
|
385
379
|
this.sendResponse(res, 'text/html', 200, html);
|
|
386
380
|
}
|
|
387
|
-
}))
|
|
381
|
+
}));
|
|
388
382
|
if (testConfig.init !== undefined) {
|
|
389
383
|
this.logger.debug(`Skip serving test init script in favor of provided script: ${testConfig.init}`);
|
|
390
384
|
continue;
|
|
391
385
|
}
|
|
392
386
|
// add route for the init file
|
|
393
387
|
this.logger.debug(`Add route for ${config.init}`);
|
|
394
|
-
this.router.get(config.init, ((_req, res, next) =>
|
|
388
|
+
this.router.get(config.init, (async (_req, res, next) => {
|
|
395
389
|
this.logger.debug(`Serving test init script: ${config.init}`);
|
|
396
|
-
const files =
|
|
397
|
-
if (
|
|
390
|
+
const files = await this.project.byGlob(config.init.replace('.js', '.[jt]s'));
|
|
391
|
+
if (files?.length > 0) {
|
|
398
392
|
this.logger.warn(`Script returned at ${config.path} is loaded from the file system.`);
|
|
399
393
|
next();
|
|
400
394
|
}
|
|
401
395
|
else {
|
|
402
|
-
const testFiles =
|
|
396
|
+
const testFiles = await this.project.byGlob(config.pattern);
|
|
403
397
|
const templateConfig = { tests: (0, test_1.generateImportList)(ns, testFiles) };
|
|
404
398
|
const js = (0, ejs_1.render)(initTemplate, templateConfig);
|
|
405
399
|
this.sendResponse(res, 'application/javascript', 200, js);
|
|
406
400
|
}
|
|
407
|
-
}))
|
|
401
|
+
}));
|
|
408
402
|
}
|
|
409
403
|
}
|
|
410
404
|
}
|
|
@@ -442,34 +436,35 @@ function serializeUi5Configuration(config) {
|
|
|
442
436
|
* @param util middleware utilities provided by the UI5 CLI
|
|
443
437
|
* @param logger logger instance
|
|
444
438
|
*/
|
|
445
|
-
function initAdp(rootProject, config, flp, util, logger) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
flp.rta.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
439
|
+
async function initAdp(rootProject, config, flp, util, logger) {
|
|
440
|
+
const appVariant = await rootProject.byPath('/manifest.appdescr_variant');
|
|
441
|
+
if (appVariant) {
|
|
442
|
+
const adp = new adp_tooling_1.AdpPreview(config, rootProject, util, logger);
|
|
443
|
+
const variant = JSON.parse(await appVariant.getString());
|
|
444
|
+
const layer = await adp.init(variant);
|
|
445
|
+
if (flp.rta) {
|
|
446
|
+
flp.rta.layer = layer;
|
|
447
|
+
flp.rta.options = {
|
|
448
|
+
...flp.rta.options,
|
|
449
|
+
projectId: variant.id,
|
|
450
|
+
scenario: 'ADAPTATION_PROJECT'
|
|
451
|
+
};
|
|
452
|
+
for (const editor of flp.rta.editors) {
|
|
453
|
+
editor.pluginScript ??= 'open/ux/preview/client/adp/init';
|
|
459
454
|
}
|
|
460
|
-
const descriptor = adp.descriptor;
|
|
461
|
-
descriptor.asyncHints.requests = [];
|
|
462
|
-
const { name, manifest } = descriptor;
|
|
463
|
-
yield flp.init(manifest, name, adp.resources);
|
|
464
|
-
flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
|
|
465
|
-
flp.addOnChangeRequestHandler(adp.onChangeRequest.bind(adp));
|
|
466
|
-
flp.router.use((0, express_1.json)());
|
|
467
|
-
adp.addApis(flp.router);
|
|
468
455
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
|
|
456
|
+
const descriptor = adp.descriptor;
|
|
457
|
+
descriptor.asyncHints.requests = [];
|
|
458
|
+
const { name, manifest } = descriptor;
|
|
459
|
+
await flp.init(manifest, name, adp.resources);
|
|
460
|
+
flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
|
|
461
|
+
flp.addOnChangeRequestHandler(adp.onChangeRequest.bind(adp));
|
|
462
|
+
flp.router.use((0, express_1.json)());
|
|
463
|
+
adp.addApis(flp.router);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
throw new Error('ADP configured but no manifest.appdescr_variant found.');
|
|
467
|
+
}
|
|
473
468
|
}
|
|
474
469
|
exports.initAdp = initAdp;
|
|
475
470
|
//# sourceMappingURL=flp.js.map
|
package/dist/base/test.js
CHANGED
|
@@ -28,9 +28,8 @@ const DEFAULTS = {
|
|
|
28
28
|
* @returns merged test configuration
|
|
29
29
|
*/
|
|
30
30
|
function mergeTestConfigDefaults(config) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const merged = Object.assign(Object.assign({}, defaults), config);
|
|
31
|
+
const defaults = DEFAULTS[config.framework.toLowerCase()] ?? {};
|
|
32
|
+
const merged = { ...defaults, ...config };
|
|
34
33
|
if (!merged.path.startsWith('/')) {
|
|
35
34
|
merged.path = `/${merged.path}`;
|
|
36
35
|
}
|