@sap-ux/app-config-writer 0.5.14 → 0.5.16
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/preview-config/index.js +2 -2
- package/dist/preview-config/prerequisites.d.ts +2 -1
- package/dist/preview-config/prerequisites.js +5 -1
- package/dist/preview-config/preview-files.d.ts +12 -2
- package/dist/preview-config/preview-files.js +37 -14
- package/dist/preview-config/ui5-yaml.d.ts +23 -4
- package/dist/preview-config/ui5-yaml.js +59 -13
- package/package.json +4 -4
|
@@ -25,7 +25,7 @@ async function convertToVirtualPreview(basePath, options) {
|
|
|
25
25
|
const fs = options.fs ?? (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
26
26
|
const logger = options.logger;
|
|
27
27
|
const convertTests = options.convertTests ?? false;
|
|
28
|
-
if (!(await (0, prerequisites_1.checkPrerequisites)(basePath, fs, logger))) {
|
|
28
|
+
if (!(await (0, prerequisites_1.checkPrerequisites)(basePath, fs, convertTests, logger))) {
|
|
29
29
|
throw Error('The prerequisites are not met. For more information, see the log messages above.');
|
|
30
30
|
}
|
|
31
31
|
if (!(await (0, prerequisites_1.getExplicitApprovalToAdjustFiles)())) {
|
|
@@ -38,7 +38,7 @@ async function convertToVirtualPreview(basePath, options) {
|
|
|
38
38
|
await (0, preview_files_1.renameDefaultTestFiles)(fs, basePath, logger);
|
|
39
39
|
await (0, ui5_yaml_1.updateDefaultTestConfig)(fs, basePath, logger);
|
|
40
40
|
}
|
|
41
|
-
await (0, preview_files_1.deleteNoLongerUsedFiles)(fs, basePath, logger);
|
|
41
|
+
await (0, preview_files_1.deleteNoLongerUsedFiles)(fs, basePath, convertTests, logger);
|
|
42
42
|
await (0, package_json_1.updateVariantsCreationScript)(fs, basePath, logger);
|
|
43
43
|
return fs;
|
|
44
44
|
}
|
|
@@ -8,10 +8,11 @@ import type { ToolsLogger } from '@sap-ux/logger';
|
|
|
8
8
|
*
|
|
9
9
|
* @param basePath - base path to be used for the conversion
|
|
10
10
|
* @param fs - file system reference
|
|
11
|
+
* @param convertTests - if set to true, then test suite and test runners fill be included in the conversion
|
|
11
12
|
* @param logger logger to report info to the user
|
|
12
13
|
* @returns indicator if the prerequisites are met
|
|
13
14
|
*/
|
|
14
|
-
export declare function checkPrerequisites(basePath: string, fs: Editor, logger?: ToolsLogger): Promise<boolean>;
|
|
15
|
+
export declare function checkPrerequisites(basePath: string, fs: Editor, convertTests?: boolean, logger?: ToolsLogger): Promise<boolean>;
|
|
15
16
|
/**
|
|
16
17
|
* Get the explicit approval form the user to do the conversion.
|
|
17
18
|
*
|
|
@@ -38,10 +38,11 @@ function isLowerThanMinimalVersion(packageJson, dependencyName, minVersionInfo,
|
|
|
38
38
|
*
|
|
39
39
|
* @param basePath - base path to be used for the conversion
|
|
40
40
|
* @param fs - file system reference
|
|
41
|
+
* @param convertTests - if set to true, then test suite and test runners fill be included in the conversion
|
|
41
42
|
* @param logger logger to report info to the user
|
|
42
43
|
* @returns indicator if the prerequisites are met
|
|
43
44
|
*/
|
|
44
|
-
async function checkPrerequisites(basePath, fs, logger) {
|
|
45
|
+
async function checkPrerequisites(basePath, fs, convertTests = false, logger) {
|
|
45
46
|
const packageJsonPath = (0, path_1.join)(basePath, 'package.json');
|
|
46
47
|
const packageJson = fs.readJSON(packageJsonPath);
|
|
47
48
|
let prerequisitesMet = true;
|
|
@@ -69,6 +70,9 @@ async function checkPrerequisites(basePath, fs, logger) {
|
|
|
69
70
|
logger?.error("Conversion from 'sap/ui/core/util/MockServer' is not supported. You must migrate from '@sap-ux/ui5-middleware-fe-mockserver'. For more information, see https://www.npmjs.com/package/@sap-ux/ui5-middleware-fe-mockserver.");
|
|
70
71
|
prerequisitesMet = false;
|
|
71
72
|
}
|
|
73
|
+
if (convertTests && (packageJson?.devDependencies?.['karma-ui5'] ?? packageJson?.dependencies?.['karma-ui5'])) {
|
|
74
|
+
logger?.warn("This app seems to use Karma as a test runner. Please note that the converter does not convert any Karma configuration files. Please update your karma configuration ('ui5.configPath' and 'ui5.testpage') according to the new virtual endpoints after the conversion.");
|
|
75
|
+
}
|
|
72
76
|
return prerequisitesMet;
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
@@ -6,10 +6,11 @@ import type { ToolsLogger } from '@sap-ux/logger';
|
|
|
6
6
|
* The corresponding file will be renamed from *.html to *_old.html.
|
|
7
7
|
*
|
|
8
8
|
* @param fs - file system reference
|
|
9
|
+
* @param basePath - base path to be used for the conversion
|
|
9
10
|
* @param path - file path to be used for the renaming
|
|
10
11
|
* @param logger logger to report info to the user
|
|
11
12
|
*/
|
|
12
|
-
export declare function renameSandbox(fs: Editor, path: string, logger?: ToolsLogger): Promise<void>;
|
|
13
|
+
export declare function renameSandbox(fs: Editor, basePath: string, path: string, logger?: ToolsLogger): Promise<void>;
|
|
13
14
|
/**
|
|
14
15
|
* Renames the default sandbox files.
|
|
15
16
|
*
|
|
@@ -36,7 +37,16 @@ export declare function renameDefaultTestFiles(fs: Editor, basePath: string, log
|
|
|
36
37
|
*
|
|
37
38
|
* @param fs - file system reference
|
|
38
39
|
* @param basePath - base path to be used for the conversion
|
|
40
|
+
* @param convertTests - indicator if test suite and test runner should be included in the conversion
|
|
41
|
+
* @param logger logger to report info to the user
|
|
42
|
+
*/
|
|
43
|
+
export declare function deleteNoLongerUsedFiles(fs: Editor, basePath: string, convertTests: boolean, logger?: ToolsLogger): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Deletes the given file.
|
|
46
|
+
*
|
|
47
|
+
* @param fs - file system reference
|
|
48
|
+
* @param files - files to be deleted
|
|
39
49
|
* @param logger logger to report info to the user
|
|
40
50
|
*/
|
|
41
|
-
export declare function
|
|
51
|
+
export declare function deleteFiles(fs: Editor, files: string[], logger?: ToolsLogger): Promise<void>;
|
|
42
52
|
//# sourceMappingURL=preview-files.d.ts.map
|
|
@@ -4,33 +4,36 @@ exports.renameSandbox = renameSandbox;
|
|
|
4
4
|
exports.renameDefaultSandboxes = renameDefaultSandboxes;
|
|
5
5
|
exports.renameDefaultTestFiles = renameDefaultTestFiles;
|
|
6
6
|
exports.deleteNoLongerUsedFiles = deleteNoLongerUsedFiles;
|
|
7
|
+
exports.deleteFiles = deleteFiles;
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const project_access_1 = require("@sap-ux/project-access");
|
|
9
10
|
const ui5_yaml_1 = require("./ui5-yaml");
|
|
10
|
-
const renameMessage = (
|
|
11
|
+
const renameMessage = (filePath) => `Renamed '${filePath}' to '${filePath.slice(0, -5)}_old.html'. This file is no longer needed for the virtual endpoints. If you have not modified this file, you can delete it. If you have modified this file, move the modified content to a custom init script for the preview middleware. For more information, see https://github.com/SAP/open-ux-tools/tree/main/packages/preview-middleware#migration.`;
|
|
11
12
|
/**
|
|
12
13
|
* Renames the sandbox file which is used in a given script.
|
|
13
14
|
*
|
|
14
15
|
* The corresponding file will be renamed from *.html to *_old.html.
|
|
15
16
|
*
|
|
16
17
|
* @param fs - file system reference
|
|
18
|
+
* @param basePath - base path to be used for the conversion
|
|
17
19
|
* @param path - file path to be used for the renaming
|
|
18
20
|
* @param logger logger to report info to the user
|
|
19
21
|
*/
|
|
20
|
-
async function renameSandbox(fs, path, logger) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
async function renameSandbox(fs, basePath, path, logger) {
|
|
23
|
+
const filePath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), path);
|
|
24
|
+
if (fs.exists(filePath)) {
|
|
25
|
+
fs.move(filePath, filePath.replace('.html', '_old.html'));
|
|
26
|
+
logger?.info(renameMessage(path));
|
|
24
27
|
}
|
|
25
28
|
else if (
|
|
26
29
|
//checks if there is a file with the same name which has already been deleted/renamed to _old.html
|
|
27
30
|
Object.keys(fs.dump(undefined, (file) => {
|
|
28
|
-
return file.history.includes(
|
|
31
|
+
return file.history.includes(filePath) && file.state !== 'deleted';
|
|
29
32
|
})).length === 0) {
|
|
30
|
-
logger?.debug(`The file '${
|
|
33
|
+
logger?.debug(`The file '${path}', has already been renamed. Skipping renaming.`);
|
|
31
34
|
}
|
|
32
35
|
else {
|
|
33
|
-
logger?.
|
|
36
|
+
logger?.debug(`The file '${path}', has not been found. Skipping renaming.`);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
@@ -46,7 +49,7 @@ async function renameSandbox(fs, path, logger) {
|
|
|
46
49
|
async function renameDefaultSandboxes(fs, basePath, logger) {
|
|
47
50
|
const defaultSandboxPaths = [(0, path_1.join)('test', 'flpSandbox.html'), (0, path_1.join)('test', 'flpSandboxMockserver.html')];
|
|
48
51
|
for (const path of defaultSandboxPaths) {
|
|
49
|
-
await renameSandbox(fs,
|
|
52
|
+
await renameSandbox(fs, basePath, path, logger);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
@@ -60,7 +63,7 @@ async function renameDefaultSandboxes(fs, basePath, logger) {
|
|
|
60
63
|
*/
|
|
61
64
|
async function renameDefaultTestFiles(fs, basePath, logger) {
|
|
62
65
|
for (const path of Object.values(ui5_yaml_1.TEST_CONFIG_DEFAULTS).map((config) => config.path)) {
|
|
63
|
-
await renameSandbox(fs,
|
|
66
|
+
await renameSandbox(fs, basePath, path, logger);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
@@ -68,11 +71,12 @@ async function renameDefaultTestFiles(fs, basePath, logger) {
|
|
|
68
71
|
*
|
|
69
72
|
* @param fs - file system reference
|
|
70
73
|
* @param basePath - base path to be used for the conversion
|
|
74
|
+
* @param convertTests - indicator if test suite and test runner should be included in the conversion
|
|
71
75
|
* @param logger logger to report info to the user
|
|
72
76
|
*/
|
|
73
|
-
async function deleteNoLongerUsedFiles(fs, basePath, logger) {
|
|
77
|
+
async function deleteNoLongerUsedFiles(fs, basePath, convertTests, logger) {
|
|
74
78
|
const webappTestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), 'test');
|
|
75
|
-
[
|
|
79
|
+
const files = [
|
|
76
80
|
(0, path_1.join)(webappTestPath, 'locate-reuse-libs.js'),
|
|
77
81
|
(0, path_1.join)(webappTestPath, 'changes_loader.js'),
|
|
78
82
|
(0, path_1.join)(webappTestPath, 'changes_loader.ts'),
|
|
@@ -82,10 +86,29 @@ async function deleteNoLongerUsedFiles(fs, basePath, logger) {
|
|
|
82
86
|
(0, path_1.join)(webappTestPath, 'flpSandbox.ts'),
|
|
83
87
|
(0, path_1.join)(webappTestPath, 'initFlpSandbox.js'),
|
|
84
88
|
(0, path_1.join)(webappTestPath, 'initFlpSandbox.ts')
|
|
85
|
-
]
|
|
89
|
+
];
|
|
90
|
+
if (convertTests) {
|
|
91
|
+
files.push((0, path_1.join)(webappTestPath, 'testsuite.qunit.js'));
|
|
92
|
+
files.push((0, path_1.join)(webappTestPath, 'testsuite.qunit.ts'));
|
|
93
|
+
files.push((0, path_1.join)(webappTestPath, 'integration', 'opaTests.qunit.js'));
|
|
94
|
+
files.push((0, path_1.join)(webappTestPath, 'integration', 'opaTests.qunit.ts'));
|
|
95
|
+
files.push((0, path_1.join)(webappTestPath, 'unit', 'unitTests.qunit.js'));
|
|
96
|
+
files.push((0, path_1.join)(webappTestPath, 'unit', 'unitTests.qunit.ts'));
|
|
97
|
+
}
|
|
98
|
+
await deleteFiles(fs, files, logger);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Deletes the given file.
|
|
102
|
+
*
|
|
103
|
+
* @param fs - file system reference
|
|
104
|
+
* @param files - files to be deleted
|
|
105
|
+
* @param logger logger to report info to the user
|
|
106
|
+
*/
|
|
107
|
+
async function deleteFiles(fs, files, logger) {
|
|
108
|
+
files.forEach((path) => {
|
|
86
109
|
if (fs.exists(path)) {
|
|
87
110
|
fs.delete(path);
|
|
88
|
-
logger?.info(`Deleted the '${(0, path_1.
|
|
111
|
+
logger?.info(`Deleted the '${(0, path_1.basename)(path)}' file. This file is no longer needed for the virtual endpoints.`);
|
|
89
112
|
}
|
|
90
113
|
});
|
|
91
114
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CustomMiddleware } from '@sap-ux/ui5-config';
|
|
2
2
|
import type { Editor } from 'mem-fs-editor';
|
|
3
|
-
import type { FlpConfig, MiddlewareConfig as PreviewConfig } from '@sap-ux/preview-middleware';
|
|
3
|
+
import type { FlpConfig, MiddlewareConfig as PreviewConfig, TestConfig } from '@sap-ux/preview-middleware';
|
|
4
4
|
import type { PreviewConfigOptions } from '../types';
|
|
5
5
|
import type { ToolsLogger } from '@sap-ux/logger';
|
|
6
6
|
type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType[number];
|
|
@@ -33,9 +33,10 @@ export declare function extractYamlConfigFileName(script: string): string;
|
|
|
33
33
|
* @param basePath - base path to be used for the conversion
|
|
34
34
|
* @param ui5Yaml - the name of the UI5 yaml configuration file
|
|
35
35
|
* @param script - the content of the script
|
|
36
|
+
* @param logger logger to report info to the user
|
|
36
37
|
* @param skipPreviewMiddlewareCreation - (default: false) indicator if the preview middleware creation should be skipped if no preview middleware is configured.
|
|
37
38
|
*/
|
|
38
|
-
export declare function processUi5YamlConfig(fs: Editor, basePath: string, ui5Yaml: string, script: string, skipPreviewMiddlewareCreation?: boolean): Promise<void>;
|
|
39
|
+
export declare function processUi5YamlConfig(fs: Editor, basePath: string, ui5Yaml: string, script: string, logger?: ToolsLogger, skipPreviewMiddlewareCreation?: boolean): Promise<void>;
|
|
39
40
|
/**
|
|
40
41
|
* Creates a preview middleware configuration.
|
|
41
42
|
*
|
|
@@ -44,17 +45,35 @@ export declare function processUi5YamlConfig(fs: Editor, basePath: string, ui5Ya
|
|
|
44
45
|
* @param previewMiddleware - the preview middleware configuration
|
|
45
46
|
* @param intent - the intent
|
|
46
47
|
* @param path - the flp path
|
|
48
|
+
* @param basePath - the base path
|
|
49
|
+
* @param fs - file system reference
|
|
50
|
+
* @param logger logger to report info to the user
|
|
47
51
|
* @returns the preview middleware configuration
|
|
48
52
|
*/
|
|
49
|
-
export declare function updatePreviewMiddlewareConfig(previewMiddleware: CustomMiddleware<PreviewConfigOptions>, intent: FlpConfig['intent'] | undefined, path: string | undefined): CustomMiddleware<PreviewConfigOptions
|
|
53
|
+
export declare function updatePreviewMiddlewareConfig(previewMiddleware: CustomMiddleware<PreviewConfigOptions>, intent: FlpConfig['intent'] | undefined, path: string | undefined, basePath: string, fs: Editor, logger?: ToolsLogger): Promise<CustomMiddleware<PreviewConfigOptions>>;
|
|
54
|
+
/**
|
|
55
|
+
* Sanitize the test script (*.qunit.[jt]s)
|
|
56
|
+
* If the OPA5 test script uses the JourneyRunner, it will be renamed and added as pattern to the respective UI5 yaml configuration.
|
|
57
|
+
* If the test script does not use the JourneyRunner, it will be deleted.
|
|
58
|
+
*
|
|
59
|
+
* @param fs - file system reference
|
|
60
|
+
* @param basePath - base path to be used
|
|
61
|
+
* @param path - the path to the test runner html file
|
|
62
|
+
* @param newConfig - the new test configuration
|
|
63
|
+
* @param logger logger to report info to the user
|
|
64
|
+
*/
|
|
65
|
+
export declare function sanitizeTestScript(fs: Editor, basePath: string, path: string, newConfig: TestConfig, logger?: ToolsLogger): Promise<void>;
|
|
50
66
|
/**
|
|
51
67
|
* Update the test configuration.
|
|
52
68
|
*
|
|
53
69
|
* @param testConfiguration - the test configuration
|
|
54
70
|
* @param path - the path
|
|
71
|
+
* @param basePath - the base path
|
|
72
|
+
* @param fs - file system reference
|
|
73
|
+
* @param logger logger to report info to the user
|
|
55
74
|
* @returns the updated test configuration
|
|
56
75
|
*/
|
|
57
|
-
export declare function updateTestConfig(testConfiguration: PreviewConfig['test'], path: string | undefined): PreviewConfig['test']
|
|
76
|
+
export declare function updateTestConfig(testConfiguration: PreviewConfig['test'], path: string | undefined, basePath: string, fs: Editor, logger?: ToolsLogger): Promise<PreviewConfig['test']>;
|
|
58
77
|
/**
|
|
59
78
|
* Updates the default test configurations in the 'ui5.yaml' in case no test config exists in any UI5 configuration file.
|
|
60
79
|
*
|
|
@@ -5,6 +5,7 @@ exports.isTestPath = isTestPath;
|
|
|
5
5
|
exports.extractYamlConfigFileName = extractYamlConfigFileName;
|
|
6
6
|
exports.processUi5YamlConfig = processUi5YamlConfig;
|
|
7
7
|
exports.updatePreviewMiddlewareConfig = updatePreviewMiddlewareConfig;
|
|
8
|
+
exports.sanitizeTestScript = sanitizeTestScript;
|
|
8
9
|
exports.updateTestConfig = updateTestConfig;
|
|
9
10
|
exports.updateDefaultTestConfig = updateDefaultTestConfig;
|
|
10
11
|
exports.updatePreviewMiddlewareConfigs = updatePreviewMiddlewareConfigs;
|
|
@@ -154,9 +155,10 @@ function extractYamlConfigFileName(script) {
|
|
|
154
155
|
* @param basePath - base path to be used for the conversion
|
|
155
156
|
* @param ui5Yaml - the name of the UI5 yaml configuration file
|
|
156
157
|
* @param script - the content of the script
|
|
158
|
+
* @param logger logger to report info to the user
|
|
157
159
|
* @param skipPreviewMiddlewareCreation - (default: false) indicator if the preview middleware creation should be skipped if no preview middleware is configured.
|
|
158
160
|
*/
|
|
159
|
-
async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, skipPreviewMiddlewareCreation = false) {
|
|
161
|
+
async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, logger, skipPreviewMiddlewareCreation = false) {
|
|
160
162
|
let ui5YamlConfig;
|
|
161
163
|
try {
|
|
162
164
|
ui5YamlConfig = await (0, project_access_1.readUi5Yaml)(basePath, ui5Yaml, fs, { validateSchema: true });
|
|
@@ -172,7 +174,7 @@ async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, skipPreviewMi
|
|
|
172
174
|
previewMiddleware = (0, ui5_yaml_1.createPreviewMiddlewareConfig)(fs, basePath);
|
|
173
175
|
}
|
|
174
176
|
const { path, intent } = (0, package_json_1.extractUrlDetails)(script);
|
|
175
|
-
previewMiddleware = updatePreviewMiddlewareConfig(previewMiddleware, intent, path);
|
|
177
|
+
previewMiddleware = await updatePreviewMiddlewareConfig(previewMiddleware, intent, path, basePath, fs, logger);
|
|
176
178
|
ui5YamlConfig.updateCustomMiddleware(previewMiddleware);
|
|
177
179
|
const yamlPath = (0, path_1.join)(basePath, ui5Yaml);
|
|
178
180
|
fs.write(yamlPath, ui5YamlConfig.toString());
|
|
@@ -185,9 +187,12 @@ async function processUi5YamlConfig(fs, basePath, ui5Yaml, script, skipPreviewMi
|
|
|
185
187
|
* @param previewMiddleware - the preview middleware configuration
|
|
186
188
|
* @param intent - the intent
|
|
187
189
|
* @param path - the flp path
|
|
190
|
+
* @param basePath - the base path
|
|
191
|
+
* @param fs - file system reference
|
|
192
|
+
* @param logger logger to report info to the user
|
|
188
193
|
* @returns the preview middleware configuration
|
|
189
194
|
*/
|
|
190
|
-
function updatePreviewMiddlewareConfig(previewMiddleware, intent, path) {
|
|
195
|
+
async function updatePreviewMiddlewareConfig(previewMiddleware, intent, path, basePath, fs, logger) {
|
|
191
196
|
const defaultIntent = `${DEFAULT_INTENT.object}-${DEFAULT_INTENT.action}`;
|
|
192
197
|
const newMiddlewareConfig = sanitizePreviewMiddleware(previewMiddleware);
|
|
193
198
|
//copy of configuration to avoid ending up with an empty configuration object in some cases
|
|
@@ -211,7 +216,7 @@ function updatePreviewMiddlewareConfig(previewMiddleware, intent, path) {
|
|
|
211
216
|
}
|
|
212
217
|
}
|
|
213
218
|
else if (isTestPath(path, configuration)) {
|
|
214
|
-
configuration.test = updateTestConfig(configuration.test, path);
|
|
219
|
+
configuration.test = await updateTestConfig(configuration.test, path, basePath, fs, logger);
|
|
215
220
|
writeConfig = true;
|
|
216
221
|
}
|
|
217
222
|
if (writeConfig) {
|
|
@@ -219,14 +224,49 @@ function updatePreviewMiddlewareConfig(previewMiddleware, intent, path) {
|
|
|
219
224
|
}
|
|
220
225
|
return newMiddlewareConfig;
|
|
221
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Sanitize the test script (*.qunit.[jt]s)
|
|
229
|
+
* If the OPA5 test script uses the JourneyRunner, it will be renamed and added as pattern to the respective UI5 yaml configuration.
|
|
230
|
+
* If the test script does not use the JourneyRunner, it will be deleted.
|
|
231
|
+
*
|
|
232
|
+
* @param fs - file system reference
|
|
233
|
+
* @param basePath - base path to be used
|
|
234
|
+
* @param path - the path to the test runner html file
|
|
235
|
+
* @param newConfig - the new test configuration
|
|
236
|
+
* @param logger logger to report info to the user
|
|
237
|
+
*/
|
|
238
|
+
async function sanitizeTestScript(fs, basePath, path, newConfig, logger) {
|
|
239
|
+
const jsTestScriptPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), path.replace('.html', '.js'));
|
|
240
|
+
const tsTestScriptPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath), path.replace('.html', '.ts'));
|
|
241
|
+
const testScriptPath = fs.exists(jsTestScriptPath) ? jsTestScriptPath : tsTestScriptPath;
|
|
242
|
+
if (fs.exists(testScriptPath)) {
|
|
243
|
+
const file = fs.read(testScriptPath);
|
|
244
|
+
const usesJourneyRunner = file.includes('sap/fe/test/JourneyRunner');
|
|
245
|
+
if (usesJourneyRunner) {
|
|
246
|
+
const filePathRenamed = testScriptPath.replace(/(\.([jt])s)$/, '.custom$1');
|
|
247
|
+
fs.move(testScriptPath, filePathRenamed);
|
|
248
|
+
newConfig.pattern = `/test/**/${(0, path_1.basename)(filePathRenamed)}`;
|
|
249
|
+
logger?.info(`Renamed '${(0, path_1.basename)(testScriptPath)}' to '${(0, path_1.basename)(filePathRenamed)}'. This file creates the JourneyRunner for OPA5 tests. As the handling of journey runners is not part of the virtual OPA5 test runner endpoint, this file has been renamed and added to the respective UI5 yaml configuration.`);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
await (0, preview_files_1.deleteFiles)(fs, [testScriptPath]);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
222
256
|
/**
|
|
223
257
|
* Update the test configuration.
|
|
224
258
|
*
|
|
225
259
|
* @param testConfiguration - the test configuration
|
|
226
260
|
* @param path - the path
|
|
261
|
+
* @param basePath - the base path
|
|
262
|
+
* @param fs - file system reference
|
|
263
|
+
* @param logger logger to report info to the user
|
|
227
264
|
* @returns the updated test configuration
|
|
228
265
|
*/
|
|
229
|
-
function updateTestConfig(testConfiguration, path) {
|
|
266
|
+
async function updateTestConfig(testConfiguration, path, basePath, fs, logger) {
|
|
267
|
+
const hasTestsuite = (config) => {
|
|
268
|
+
return config?.some((test) => test.framework === 'Testsuite') ?? false;
|
|
269
|
+
};
|
|
230
270
|
testConfiguration = testConfiguration ?? [];
|
|
231
271
|
let framework;
|
|
232
272
|
if (path?.includes('testsuite.qunit.html')) {
|
|
@@ -250,11 +290,17 @@ function updateTestConfig(testConfiguration, path) {
|
|
|
250
290
|
delete testConfig.path;
|
|
251
291
|
}
|
|
252
292
|
}
|
|
253
|
-
else if (path?.includes(defaultPath)) {
|
|
254
|
-
testConfiguration.push({ framework });
|
|
255
|
-
}
|
|
256
293
|
else {
|
|
257
|
-
|
|
294
|
+
const newConfig = {
|
|
295
|
+
framework,
|
|
296
|
+
...(path && defaultPath !== (path.startsWith('/') ? path : `/${path}`) && { path })
|
|
297
|
+
};
|
|
298
|
+
await sanitizeTestScript(fs, basePath, path ?? defaultPath, newConfig, logger);
|
|
299
|
+
testConfiguration.push({ ...newConfig });
|
|
300
|
+
if (!hasTestsuite(testConfiguration)) {
|
|
301
|
+
testConfiguration.push({ framework: 'Testsuite' });
|
|
302
|
+
logger?.info(`The test framework 'Testsuite' has been added because at least one test runner has been found.`);
|
|
303
|
+
}
|
|
258
304
|
}
|
|
259
305
|
return testConfiguration;
|
|
260
306
|
}
|
|
@@ -288,7 +334,7 @@ async function updateDefaultTestConfig(fs, basePath, logger) {
|
|
|
288
334
|
//do not touch existing test config
|
|
289
335
|
break;
|
|
290
336
|
}
|
|
291
|
-
previewMiddleware.configuration.test = updateTestConfig(previewMiddleware.configuration.test, defaultConfig.path);
|
|
337
|
+
previewMiddleware.configuration.test = await updateTestConfig(previewMiddleware.configuration.test, defaultConfig.path, basePath, fs, logger);
|
|
292
338
|
logger?.info(`The UI5 YAML configuration file 'ui5.yaml', has been updated to support the test framework '${defaultConfig.framework}'. Please consider transferring the test configuration to the UI5 YAML configuration file used for testing.`);
|
|
293
339
|
}
|
|
294
340
|
ui5YamlConfig.updateCustomMiddleware(previewMiddleware);
|
|
@@ -323,7 +369,7 @@ async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger
|
|
|
323
369
|
continue;
|
|
324
370
|
}
|
|
325
371
|
try {
|
|
326
|
-
await processUi5YamlConfig(fs, basePath, ui5Yaml, script);
|
|
372
|
+
await processUi5YamlConfig(fs, basePath, ui5Yaml, script, logger);
|
|
327
373
|
}
|
|
328
374
|
catch (error) {
|
|
329
375
|
logger?.warn(`Skipping script '${scriptName}', which refers to the UI5 YAML configuration file '${ui5Yaml}'. ${error.message}`);
|
|
@@ -331,7 +377,7 @@ async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger
|
|
|
331
377
|
}
|
|
332
378
|
const { path } = (0, package_json_1.extractUrlDetails)(script);
|
|
333
379
|
if (path) {
|
|
334
|
-
await (0, preview_files_1.renameSandbox)(fs,
|
|
380
|
+
await (0, preview_files_1.renameSandbox)(fs, basePath, path, logger);
|
|
335
381
|
}
|
|
336
382
|
(0, package_json_1.ensurePreviewMiddlewareDependency)(packageJson, fs, packageJsonPath);
|
|
337
383
|
logger?.info(`The UI5 YAML configuration file '${ui5Yaml}', has been updated according to script, '${scriptName}'.`);
|
|
@@ -339,7 +385,7 @@ async function updatePreviewMiddlewareConfigs(fs, basePath, convertTests, logger
|
|
|
339
385
|
for (const ui5Yaml of unprocessedUi5YamlFileNames) {
|
|
340
386
|
//at least adjust deprecated preview config of unused ui5 yaml configurations
|
|
341
387
|
try {
|
|
342
|
-
await processUi5YamlConfig(fs, basePath, ui5Yaml, '', true);
|
|
388
|
+
await processUi5YamlConfig(fs, basePath, ui5Yaml, '', logger, true);
|
|
343
389
|
}
|
|
344
390
|
catch (error) {
|
|
345
391
|
logger?.warn(`Skipping UI5 yaml configuration file '${ui5Yaml}'. ${error.mesage}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/app-config-writer",
|
|
3
3
|
"description": "Add or update configuration for SAP Fiori tools application",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.16",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"prompts": "2.4.2",
|
|
29
29
|
"semver": "7.6.3",
|
|
30
30
|
"@sap-ux/axios-extension": "1.18.1",
|
|
31
|
-
"@sap-ux/btp-utils": "0.17.2",
|
|
32
31
|
"@sap-ux/logger": "0.6.0",
|
|
33
|
-
"@sap-ux/project-access": "1.
|
|
32
|
+
"@sap-ux/project-access": "1.29.0",
|
|
34
33
|
"@sap-ux/store": "1.0.0",
|
|
34
|
+
"@sap-ux/btp-utils": "0.17.2",
|
|
35
35
|
"@sap-ux/ui5-config": "0.26.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/semver": "7.5.8",
|
|
43
43
|
"axios": "1.7.4",
|
|
44
44
|
"nock": "13.4.0",
|
|
45
|
-
"@sap-ux/preview-middleware": "0.16.
|
|
45
|
+
"@sap-ux/preview-middleware": "0.16.174"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=18.x"
|