@sap-ux/app-config-writer 0.7.2 → 0.7.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/flp-embedded-config/index.d.ts +18 -0
- package/dist/flp-embedded-config/index.js +110 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/package.json +7 -7
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Editor } from 'mem-fs-editor';
|
|
2
|
+
import type { ToolsLogger } from '@sap-ux/logger';
|
|
3
|
+
export declare const DEFAULT_FLP_PATH = "sap/bc/ui5_ui5/ui2/ushell/shells/abap/Fiorilaunchpad.html";
|
|
4
|
+
/**
|
|
5
|
+
* Generates the FLP Embedded Mode configuration for a Fiori app:
|
|
6
|
+
* - adds the `start-embedded` npm script to package.json
|
|
7
|
+
* - creates flp.yaml based on the existing ui5.yaml
|
|
8
|
+
*
|
|
9
|
+
* @param basePath - root of the project (where package.json is)
|
|
10
|
+
* @param bspApplication - BSP application name of the deployed app
|
|
11
|
+
* @param flpPath - FLP URL path (defaults to the standard ABAP FLP path)
|
|
12
|
+
* @param yamlPath - path to the ui5.yaml to use as base (defaults to ui5.yaml in basePath)
|
|
13
|
+
* @param fs - optional mem-fs editor instance
|
|
14
|
+
* @param logger - optional logger
|
|
15
|
+
* @returns mem-fs editor instance with modified/created files
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateFlpEmbeddedConfig(basePath: string, bspApplication: string, flpPath?: string, yamlPath?: string, fs?: Editor, logger?: ToolsLogger): Promise<Editor>;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_FLP_PATH = void 0;
|
|
4
|
+
exports.generateFlpEmbeddedConfig = generateFlpEmbeddedConfig;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
7
|
+
const mem_fs_1 = require("mem-fs");
|
|
8
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
9
|
+
exports.DEFAULT_FLP_PATH = 'sap/bc/ui5_ui5/ui2/ushell/shells/abap/Fiorilaunchpad.html';
|
|
10
|
+
/**
|
|
11
|
+
* Generates the FLP Embedded Mode configuration for a Fiori app:
|
|
12
|
+
* - adds the `start-embedded` npm script to package.json
|
|
13
|
+
* - creates flp.yaml based on the existing ui5.yaml
|
|
14
|
+
*
|
|
15
|
+
* @param basePath - root of the project (where package.json is)
|
|
16
|
+
* @param bspApplication - BSP application name of the deployed app
|
|
17
|
+
* @param flpPath - FLP URL path (defaults to the standard ABAP FLP path)
|
|
18
|
+
* @param yamlPath - path to the ui5.yaml to use as base (defaults to ui5.yaml in basePath)
|
|
19
|
+
* @param fs - optional mem-fs editor instance
|
|
20
|
+
* @param logger - optional logger
|
|
21
|
+
* @returns mem-fs editor instance with modified/created files
|
|
22
|
+
*/
|
|
23
|
+
async function generateFlpEmbeddedConfig(basePath, bspApplication, flpPath = exports.DEFAULT_FLP_PATH, yamlPath = project_access_1.FileName.Ui5Yaml, fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)()), logger) {
|
|
24
|
+
const bspApp = bspApplication.trim().toLowerCase();
|
|
25
|
+
if (!bspApp) {
|
|
26
|
+
throw new Error('Mandatory parameter bspApplication is missing.');
|
|
27
|
+
}
|
|
28
|
+
if (await (0, project_access_1.isCapProject)(basePath)) {
|
|
29
|
+
throw new Error('CAP projects are not supported for FLP Embedded Mode configuration.');
|
|
30
|
+
}
|
|
31
|
+
const resolvedYamlPath = (0, node_path_1.join)(basePath, yamlPath);
|
|
32
|
+
if (!fs.exists(resolvedYamlPath)) {
|
|
33
|
+
throw new Error(`Configuration file ${resolvedYamlPath} not found. Please provide a valid path`);
|
|
34
|
+
}
|
|
35
|
+
addStartEmbeddedScript(fs, basePath, flpPath, logger);
|
|
36
|
+
await addFlpYaml(fs, basePath, yamlPath, bspApp, logger);
|
|
37
|
+
return fs;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Adds the start-embedded npm script to package.json.
|
|
41
|
+
* Prepends `ui5 build` so dist/ is always built before fiori run starts,
|
|
42
|
+
* avoiding issues where --clean-dest in the build script deletes dist/ and
|
|
43
|
+
* kills the file watcher mid-rebuild.
|
|
44
|
+
*
|
|
45
|
+
* @param fs - mem-fs editor instance
|
|
46
|
+
* @param basePath - project root
|
|
47
|
+
* @param flpPath - FLP URL path
|
|
48
|
+
* @param logger - optional logger
|
|
49
|
+
*/
|
|
50
|
+
function addStartEmbeddedScript(fs, basePath, flpPath, logger) {
|
|
51
|
+
const packageJsonPath = (0, node_path_1.join)(basePath, project_access_1.FileName.Package);
|
|
52
|
+
const packageJson = fs.readJSON(packageJsonPath);
|
|
53
|
+
if (!packageJson) {
|
|
54
|
+
throw new Error(`File 'package.json' not found at ${basePath}`);
|
|
55
|
+
}
|
|
56
|
+
packageJson.scripts ??= {};
|
|
57
|
+
packageJson.scripts['start-embedded'] =
|
|
58
|
+
`ui5 build && fiori run --config ./flp.yaml --open "${flpPath}?sap-ushell-nocb=true"`;
|
|
59
|
+
fs.writeJSON(packageJsonPath, packageJson);
|
|
60
|
+
logger?.debug(`Script 'start-embedded' written to 'package.json'.`);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates flp.yaml based on the existing ui5.yaml, adding servestatic middleware
|
|
64
|
+
* and configuring appreload and proxy middlewares.
|
|
65
|
+
*
|
|
66
|
+
* @param fs - mem-fs editor instance
|
|
67
|
+
* @param basePath - project root
|
|
68
|
+
* @param yamlFileName - relative path to the source ui5.yaml (e.g. 'ui5.yaml')
|
|
69
|
+
* @param bspApplication - BSP application name (lowercase)
|
|
70
|
+
* @param logger - optional logger
|
|
71
|
+
*/
|
|
72
|
+
async function addFlpYaml(fs, basePath, yamlFileName, bspApplication, logger) {
|
|
73
|
+
const flpYamlPath = (0, node_path_1.join)(basePath, 'flp.yaml');
|
|
74
|
+
const ui5Config = await (0, project_access_1.readUi5Yaml)(basePath, yamlFileName, fs);
|
|
75
|
+
const metadata = ui5Config.getMetadata();
|
|
76
|
+
if (!metadata?.name) {
|
|
77
|
+
throw new Error(`The configuration file '${yamlFileName}' is missing a 'metadata.name' field.`);
|
|
78
|
+
}
|
|
79
|
+
const appModule = metadata.name.replaceAll('.', '/');
|
|
80
|
+
const DIST = 'dist';
|
|
81
|
+
const paths = [{ path: '/**/' + bspApplication, src: DIST }];
|
|
82
|
+
if (appModule !== bspApplication) {
|
|
83
|
+
paths.push({ path: '/**/' + appModule, src: DIST });
|
|
84
|
+
}
|
|
85
|
+
ui5Config.setConfiguration({ paths: { webapp: DIST } });
|
|
86
|
+
const appreloadMiddleware = ui5Config.findCustomMiddleware('fiori-tools-appreload');
|
|
87
|
+
if (appreloadMiddleware) {
|
|
88
|
+
ui5Config.updateCustomMiddleware({
|
|
89
|
+
...appreloadMiddleware,
|
|
90
|
+
configuration: { ...appreloadMiddleware.configuration, path: DIST }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const proxyMiddleware = ui5Config.findCustomMiddleware('fiori-tools-proxy');
|
|
94
|
+
if (proxyMiddleware) {
|
|
95
|
+
ui5Config.updateCustomMiddleware({
|
|
96
|
+
...proxyMiddleware,
|
|
97
|
+
configuration: { ...proxyMiddleware.configuration, bsp: bspApplication }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
ui5Config.addCustomMiddleware([
|
|
101
|
+
{
|
|
102
|
+
name: 'fiori-tools-servestatic',
|
|
103
|
+
beforeMiddleware: 'fiori-tools-proxy',
|
|
104
|
+
configuration: { paths }
|
|
105
|
+
}
|
|
106
|
+
]);
|
|
107
|
+
fs.write(flpYamlPath, ui5Config.toString());
|
|
108
|
+
logger?.debug(`'flp.yaml' written.`);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { generateInboundNavigationConfig, readManifest } from './navigation-conf
|
|
|
5
5
|
export { generateVariantsConfig } from './variants-config';
|
|
6
6
|
export { convertToVirtualPreview } from './preview-config';
|
|
7
7
|
export { enableCardGeneratorConfig } from './cards-config';
|
|
8
|
+
export { generateFlpEmbeddedConfig, DEFAULT_FLP_PATH } from './flp-embedded-config';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableCardGeneratorConfig = exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.convertEslintConfig = exports.generateEslintConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
|
|
3
|
+
exports.DEFAULT_FLP_PATH = exports.generateFlpEmbeddedConfig = exports.enableCardGeneratorConfig = exports.convertToVirtualPreview = exports.generateVariantsConfig = exports.readManifest = exports.generateInboundNavigationConfig = exports.convertEslintConfig = exports.generateEslintConfig = exports.generateSmartLinksConfig = exports.includeTestRunnersPrompt = exports.simulatePrompt = exports.getSmartLinksTargetFromPrompt = void 0;
|
|
4
4
|
var prompt_1 = require("./prompt");
|
|
5
5
|
Object.defineProperty(exports, "getSmartLinksTargetFromPrompt", { enumerable: true, get: function () { return prompt_1.getSmartLinksTargetFromPrompt; } });
|
|
6
6
|
Object.defineProperty(exports, "simulatePrompt", { enumerable: true, get: function () { return prompt_1.simulatePrompt; } });
|
|
@@ -19,4 +19,7 @@ var preview_config_1 = require("./preview-config");
|
|
|
19
19
|
Object.defineProperty(exports, "convertToVirtualPreview", { enumerable: true, get: function () { return preview_config_1.convertToVirtualPreview; } });
|
|
20
20
|
var cards_config_1 = require("./cards-config");
|
|
21
21
|
Object.defineProperty(exports, "enableCardGeneratorConfig", { enumerable: true, get: function () { return cards_config_1.enableCardGeneratorConfig; } });
|
|
22
|
+
var flp_embedded_config_1 = require("./flp-embedded-config");
|
|
23
|
+
Object.defineProperty(exports, "generateFlpEmbeddedConfig", { enumerable: true, get: function () { return flp_embedded_config_1.generateFlpEmbeddedConfig; } });
|
|
24
|
+
Object.defineProperty(exports, "DEFAULT_FLP_PATH", { enumerable: true, get: function () { return flp_embedded_config_1.DEFAULT_FLP_PATH; } });
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
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.7.
|
|
4
|
+
"version": "0.7.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"prompts": "2.4.2",
|
|
29
29
|
"semver": "7.7.4",
|
|
30
30
|
"cross-spawn": "7.0.6",
|
|
31
|
-
"@sap-ux/axios-extension": "1.26.
|
|
32
|
-
"@sap-ux/ui5-application-writer": "1.9.
|
|
33
|
-
"@sap-ux/btp-utils": "1.2.
|
|
31
|
+
"@sap-ux/axios-extension": "1.26.1",
|
|
32
|
+
"@sap-ux/ui5-application-writer": "1.9.1",
|
|
33
|
+
"@sap-ux/btp-utils": "1.2.1",
|
|
34
34
|
"@sap-ux/logger": "0.9.0",
|
|
35
|
-
"@sap-ux/project-access": "1.38.
|
|
35
|
+
"@sap-ux/project-access": "1.38.1",
|
|
36
36
|
"@sap-ux/store": "1.6.0",
|
|
37
|
-
"@sap-ux/ui5-config": "0.31.
|
|
37
|
+
"@sap-ux/ui5-config": "0.31.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/ejs": "3.1.5",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/cross-spawn": "6.0.6",
|
|
46
46
|
"axios": "1.16.0",
|
|
47
47
|
"nock": "14.0.11",
|
|
48
|
-
"@sap-ux/preview-middleware": "0.26.
|
|
48
|
+
"@sap-ux/preview-middleware": "0.26.8"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=22.x"
|