@sap-ux/ui5-application-writer 0.27.1 → 1.0.0
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/data/defaults.d.ts +2 -1
- package/dist/data/defaults.js +18 -7
- package/dist/data/index.js +5 -2
- package/dist/index.js +30 -9
- package/dist/options.d.ts +11 -0
- package/dist/options.js +31 -2
- package/dist/types.d.ts +13 -0
- package/package.json +3 -3
- package/templates/core/webapp/index.html +1 -1
package/dist/data/defaults.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import type { App, AppOptions, Package, UI5 } from '../types';
|
|
|
4
4
|
*
|
|
5
5
|
* @param {string} [version] - the package version
|
|
6
6
|
* @param {string} [description] - the package description
|
|
7
|
+
* @param {boolean} [isEdmxProjectType] - whether the project type is Edmx or CAP
|
|
7
8
|
* @returns {Partial<Package>} the package instance
|
|
8
9
|
*/
|
|
9
|
-
export declare function packageDefaults(version?: string, description?: string): Partial<Package>;
|
|
10
|
+
export declare function packageDefaults(version?: string, description?: string, isEdmxProjectType?: boolean): Partial<Package>;
|
|
10
11
|
/**
|
|
11
12
|
* Returns an app instance merged with default properties.
|
|
12
13
|
*
|
package/dist/data/defaults.js
CHANGED
|
@@ -15,22 +15,33 @@ const mergeWith_1 = __importDefault(require("lodash/mergeWith"));
|
|
|
15
15
|
*
|
|
16
16
|
* @param {string} [version] - the package version
|
|
17
17
|
* @param {string} [description] - the package description
|
|
18
|
+
* @param {boolean} [isEdmxProjectType] - whether the project type is Edmx or CAP
|
|
18
19
|
* @returns {Partial<Package>} the package instance
|
|
19
20
|
*/
|
|
20
|
-
function packageDefaults(version, description) {
|
|
21
|
-
|
|
21
|
+
function packageDefaults(version, description, isEdmxProjectType) {
|
|
22
|
+
const defaults = {
|
|
22
23
|
version: version || '0.0.1',
|
|
23
24
|
description: description || '',
|
|
24
25
|
devDependencies: {
|
|
25
26
|
'@ui5/cli': '^3.0.0',
|
|
26
27
|
'@sap/ux-ui5-tooling': '1'
|
|
27
|
-
},
|
|
28
|
-
scripts: {
|
|
29
|
-
start: 'ui5 serve --config=ui5.yaml --open index.html',
|
|
30
|
-
'start-local': 'ui5 serve --config=ui5-local.yaml --open index.html',
|
|
31
|
-
build: 'ui5 build --config=ui5.yaml --clean-dest --dest dist'
|
|
32
28
|
}
|
|
33
29
|
};
|
|
30
|
+
if (isEdmxProjectType) {
|
|
31
|
+
// Add scripts for non-CAP projects
|
|
32
|
+
return {
|
|
33
|
+
...defaults,
|
|
34
|
+
scripts: {
|
|
35
|
+
start: 'ui5 serve --config=ui5.yaml --open index.html',
|
|
36
|
+
'start-local': 'ui5 serve --config=ui5-local.yaml --open index.html',
|
|
37
|
+
build: 'ui5 build --config=ui5.yaml --clean-dest --dest dist'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
...defaults,
|
|
43
|
+
scripts: {}
|
|
44
|
+
};
|
|
34
45
|
}
|
|
35
46
|
exports.packageDefaults = packageDefaults;
|
|
36
47
|
/**
|
package/dist/data/index.js
CHANGED
|
@@ -20,8 +20,11 @@ function mergeWithDefaults(ui5App) {
|
|
|
20
20
|
ui5App.appOptions.codeAssist = false;
|
|
21
21
|
}
|
|
22
22
|
ui5App.ui5 = (0, defaults_1.mergeUi5)(ui5App.ui5 || {}, ui5App.appOptions);
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// Determine if the project type is 'EDMXBackend'.
|
|
24
|
+
const isEdmxProjectType = ui5App.app.projectType === 'EDMXBackend';
|
|
25
|
+
ui5App.package = (0, ui5_config_1.mergeObjects)((0, defaults_1.packageDefaults)(ui5App.package.version, ui5App.app.description, isEdmxProjectType), ui5App.package);
|
|
26
|
+
if (ui5App.appOptions.sapux && isEdmxProjectType) {
|
|
27
|
+
// Add @sap/ux-specification to devDependencies only for non-CAP projects
|
|
25
28
|
ui5App.package.devDependencies = ui5App.package.devDependencies || {};
|
|
26
29
|
ui5App.package.devDependencies['@sap/ux-specification'] = (0, defaults_1.getSpecTagVersion)(ui5App.ui5.version);
|
|
27
30
|
}
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,20 @@ async function generate(basePath, ui5AppConfig, fs) {
|
|
|
26
26
|
if (ui5AppConfig.appOptions?.generateIndex === false) {
|
|
27
27
|
ignore.push('**/webapp/index.html');
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const isEdmxProjectType = ui5AppConfig.app.projectType === 'EDMXBackend';
|
|
30
|
+
if (!isEdmxProjectType) {
|
|
31
|
+
// ignore the ui5-local.yaml file for CAP applications
|
|
32
|
+
ignore.push('**/ui5-local.yaml');
|
|
33
|
+
// ignore the .gitignore.tmpl file for CAP applications
|
|
34
|
+
ignore.push('**/gitignore.tmpl');
|
|
35
|
+
}
|
|
36
|
+
// Determine the UI5 resource URL based on project type and UI5 framework details
|
|
37
|
+
const ui5ResourceUrl = (0, options_1.getTemplateOptions)(isEdmxProjectType, ui5App.ui5?.frameworkUrl, ui5App.ui5?.version);
|
|
38
|
+
const templateOptions = {
|
|
39
|
+
...ui5App,
|
|
40
|
+
ui5ResourceUrl
|
|
41
|
+
};
|
|
42
|
+
fs.copyTpl((0, path_1.join)(tmplPath, 'core', '**/*.*'), (0, path_1.join)(basePath), templateOptions, undefined, {
|
|
30
43
|
globOptions: { dot: true, ignore },
|
|
31
44
|
processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
|
|
32
45
|
});
|
|
@@ -40,15 +53,23 @@ async function generate(basePath, ui5AppConfig, fs) {
|
|
|
40
53
|
});
|
|
41
54
|
ui5Config.addFioriToolsAppReloadMiddleware();
|
|
42
55
|
// ui5-local.yaml
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
if (isEdmxProjectType) {
|
|
57
|
+
const ui5LocalConfigPath = (0, path_1.join)(basePath, 'ui5-local.yaml');
|
|
58
|
+
// write ui5-local.yaml only for non-CAP applications
|
|
59
|
+
const ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(ui5LocalConfigPath));
|
|
60
|
+
ui5LocalConfig.addUI5Framework(ui5App.ui5.framework, ui5App.ui5.localVersion, ui5App.ui5.ui5Libs, ui5App.ui5.ui5Theme);
|
|
61
|
+
ui5LocalConfig.addFioriToolsAppReloadMiddleware();
|
|
62
|
+
// Add optional features
|
|
63
|
+
await (0, options_1.applyOptionalFeatures)(ui5App, fs, basePath, tmplPath, [ui5Config, ui5LocalConfig]);
|
|
64
|
+
// write ui5 local yaml
|
|
65
|
+
fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// Add optional features
|
|
69
|
+
await (0, options_1.applyOptionalFeatures)(ui5App, fs, basePath, tmplPath, [ui5Config]);
|
|
70
|
+
}
|
|
71
|
+
// write ui5 yaml
|
|
50
72
|
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
51
|
-
fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
|
|
52
73
|
return fs;
|
|
53
74
|
}
|
|
54
75
|
exports.generate = generate;
|
package/dist/options.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
2
|
import type { Ui5App } from './types';
|
|
3
3
|
import type { UI5Config } from '@sap-ux/ui5-config';
|
|
4
|
+
import type { ProjectType } from '@sap-ux/project-access';
|
|
4
5
|
/**
|
|
5
6
|
* Input required to enable optional features.
|
|
6
7
|
*/
|
|
@@ -9,6 +10,7 @@ export interface FeatureInput {
|
|
|
9
10
|
app: {
|
|
10
11
|
id: string;
|
|
11
12
|
baseComponent?: string;
|
|
13
|
+
projectType?: ProjectType;
|
|
12
14
|
};
|
|
13
15
|
};
|
|
14
16
|
fs: Editor;
|
|
@@ -39,4 +41,13 @@ export declare function enableNpmPackageConsumption(input: FeatureInput): Promis
|
|
|
39
41
|
* @param ui5Configs available UI5 configs
|
|
40
42
|
*/
|
|
41
43
|
export declare function applyOptionalFeatures(ui5App: Ui5App, fs: Editor, basePath: string, tmplPath: string, ui5Configs: UI5Config[]): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Generates the resource URL based on the project type and ui5 framework details.
|
|
46
|
+
*
|
|
47
|
+
* @param {boolean} isEdmxProjectType Indicates if the project type is Edmx or CAP.
|
|
48
|
+
* @param {string} [frameworkUrl] URL of the ui5 framework.
|
|
49
|
+
* @param {string} [version] version of the ui5 framework.
|
|
50
|
+
* @returns {string} - The constructed resource URL based on project type.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getTemplateOptions(isEdmxProjectType: boolean, frameworkUrl?: string, version?: string): string;
|
|
42
53
|
//# sourceMappingURL=options.d.ts.map
|
package/dist/options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyOptionalFeatures = exports.enableNpmPackageConsumption = exports.enableTypescript = void 0;
|
|
3
|
+
exports.getTemplateOptions = exports.applyOptionalFeatures = exports.enableNpmPackageConsumption = exports.enableTypescript = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const ejs_1 = require("ejs");
|
|
6
6
|
const project_access_1 = require("@sap-ux/project-access");
|
|
@@ -43,7 +43,11 @@ const factories = {
|
|
|
43
43
|
codeAssist: async (input) => await copyTemplates('codeAssist', input),
|
|
44
44
|
eslint: async (input) => await copyTemplates('eslint', input),
|
|
45
45
|
loadReuseLibs: async (input) => await copyTemplates('loadReuseLibs', input),
|
|
46
|
-
sapux: async (input) =>
|
|
46
|
+
sapux: async (input) => {
|
|
47
|
+
if (input.ui5App.app.projectType === 'EDMXBackend') {
|
|
48
|
+
await copyTemplates('sapux', input);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
47
51
|
typescript: async (input) => await enableTypescript(input),
|
|
48
52
|
npmPackageConsumption: async (input) => await enableNpmPackageConsumption(input)
|
|
49
53
|
};
|
|
@@ -101,4 +105,29 @@ async function applyOptionalFeatures(ui5App, fs, basePath, tmplPath, ui5Configs)
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
exports.applyOptionalFeatures = applyOptionalFeatures;
|
|
108
|
+
/**
|
|
109
|
+
* Generates the resource URL based on the project type and ui5 framework details.
|
|
110
|
+
*
|
|
111
|
+
* @param {boolean} isEdmxProjectType Indicates if the project type is Edmx or CAP.
|
|
112
|
+
* @param {string} [frameworkUrl] URL of the ui5 framework.
|
|
113
|
+
* @param {string} [version] version of the ui5 framework.
|
|
114
|
+
* @returns {string} - The constructed resource URL based on project type.
|
|
115
|
+
*/
|
|
116
|
+
function getTemplateOptions(isEdmxProjectType, frameworkUrl, version) {
|
|
117
|
+
const resourcePath = 'resources/sap-ui-core.js';
|
|
118
|
+
if (isEdmxProjectType || !frameworkUrl) {
|
|
119
|
+
// Use relative path for Edmx projects or if frameworkUrl is not available
|
|
120
|
+
return resourcePath;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// return the full URL for CAP projects
|
|
124
|
+
let url = frameworkUrl;
|
|
125
|
+
if (version) {
|
|
126
|
+
url += `/${version}`;
|
|
127
|
+
}
|
|
128
|
+
url += `/${resourcePath}`;
|
|
129
|
+
return url;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.getTemplateOptions = getTemplateOptions;
|
|
104
133
|
//# sourceMappingURL=options.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProjectType } from '@sap-ux/project-access';
|
|
1
2
|
export interface Package {
|
|
2
3
|
name: string;
|
|
3
4
|
version?: string;
|
|
@@ -11,6 +12,18 @@ export interface Package {
|
|
|
11
12
|
}
|
|
12
13
|
export interface App {
|
|
13
14
|
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The type of project being processed.
|
|
17
|
+
* For projects of type 'CAPJava' or 'CAPNodejs':
|
|
18
|
+
* - Exclude `ui5-local.yaml` and `.gitignore` from the template.
|
|
19
|
+
* - Update `package.json` to include only the script `deploy-config`.
|
|
20
|
+
* - Use full URLs to determine resource URLs in `webapp/index.html` and `flpSandbox.html`.
|
|
21
|
+
* For projects of type 'EDMXBackend':
|
|
22
|
+
* - Include `ui5-local.yaml` and `.gitignore` in the template.
|
|
23
|
+
* - Update `package.json` to include the following scripts: start, start-local, build, start-noflp, start-mock, int-test, deploy, and sap-ux.
|
|
24
|
+
* - Include relative URLs to determine resource URLs in `webapp/index.html` and `flpSandbox.html`.
|
|
25
|
+
*/
|
|
26
|
+
projectType: ProjectType;
|
|
14
27
|
version?: string;
|
|
15
28
|
title?: string;
|
|
16
29
|
description?: string;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-application-writer"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "1.0.0",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"mem-fs": "2.1.0",
|
|
28
28
|
"mem-fs-editor": "9.4.0",
|
|
29
29
|
"semver": "7.5.4",
|
|
30
|
-
"@sap-ux/ui5-config": "0.23.
|
|
30
|
+
"@sap-ux/ui5-config": "0.23.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/ejs": "3.1.2",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/semver": "7.5.2",
|
|
39
39
|
"fs-extra": "10.0.0",
|
|
40
40
|
"@sap-ux/eslint-plugin-fiori-tools": "0.5.0",
|
|
41
|
-
"@sap-ux/project-access": "1.25.
|
|
41
|
+
"@sap-ux/project-access": "1.25.4"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=18.x"
|