@sap-ux/ui5-application-writer 0.26.18 → 0.27.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.js +10 -13
- package/dist/data/ui5Libs.js +1 -1
- package/dist/data/validators.js +4 -5
- package/dist/i18n.js +11 -22
- package/dist/index.js +71 -88
- package/dist/options.js +48 -67
- package/package.json +4 -4
package/dist/data/defaults.js
CHANGED
|
@@ -40,16 +40,15 @@ exports.packageDefaults = packageDefaults;
|
|
|
40
40
|
* @returns {Partial<App>} the App instance
|
|
41
41
|
*/
|
|
42
42
|
function mergeApp(app) {
|
|
43
|
-
var _a, _b, _c, _d, _e;
|
|
44
43
|
return (0, mergeWith_1.default)({
|
|
45
44
|
version: '0.0.1',
|
|
46
45
|
title: (0, i18n_1.t)('text.defaultAppTitle', { id: app.id }),
|
|
47
46
|
description: (0, i18n_1.t)('text.defaultAppDescription', { id: app.id }),
|
|
48
47
|
baseComponent: "sap/ui/core/UIComponent" /* UI5_DEFAULT.BASE_COMPONENT */,
|
|
49
48
|
sourceTemplate: {
|
|
50
|
-
id:
|
|
51
|
-
version:
|
|
52
|
-
toolsId:
|
|
49
|
+
id: app.sourceTemplate?.id ?? '',
|
|
50
|
+
version: app.sourceTemplate?.version ?? '',
|
|
51
|
+
toolsId: app.sourceTemplate?.toolsId
|
|
53
52
|
}
|
|
54
53
|
}, app);
|
|
55
54
|
}
|
|
@@ -65,22 +64,21 @@ exports.defaultUI5Libs = ['sap.m', 'sap.ui.core'];
|
|
|
65
64
|
* @returns {UI5} the updated copy of UI5 instance (does not change `ui5`)
|
|
66
65
|
*/
|
|
67
66
|
function mergeUi5(ui5, options) {
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const framework = (_b = ui5.framework) !== null && _b !== void 0 ? _b : 'SAPUI5';
|
|
67
|
+
const version = ui5.version ?? "" /* UI5_DEFAULT.DEFAULT_UI5_VERSION */; // Undefined or null indicates the latest available should be used
|
|
68
|
+
const framework = ui5.framework ?? 'SAPUI5';
|
|
71
69
|
const defaultFrameworkUrl = framework === 'SAPUI5' ? "https://ui5.sap.com" /* UI5_DEFAULT.SAPUI5_CDN */ : "https://sdk.openui5.org" /* UI5_DEFAULT.OPENUI5_CDN */;
|
|
72
70
|
const merged = {
|
|
73
71
|
minUI5Version: getMinUI5Version(version, ui5.minUI5Version),
|
|
74
72
|
localVersion: getLocalVersion({ framework, version, localVersion: ui5.localVersion }),
|
|
75
73
|
version,
|
|
76
74
|
framework,
|
|
77
|
-
frameworkUrl:
|
|
75
|
+
frameworkUrl: ui5.frameworkUrl ?? defaultFrameworkUrl
|
|
78
76
|
};
|
|
79
77
|
merged.descriptorVersion = getManifestVersion(merged.minUI5Version, ui5.descriptorVersion);
|
|
80
78
|
merged.typesVersion =
|
|
81
|
-
|
|
79
|
+
ui5.typesVersion ?? (options?.typescript ? ui5_config_1.getEsmTypesVersion : ui5_config_1.getTypesVersion)(merged.minUI5Version);
|
|
82
80
|
merged.typesPackage = (0, ui5_config_1.getTypesPackage)(merged.typesVersion);
|
|
83
|
-
merged.ui5Theme =
|
|
81
|
+
merged.ui5Theme = ui5.ui5Theme ?? 'sap_fiori_3';
|
|
84
82
|
merged.ui5Libs = (0, ui5Libs_1.getUI5Libs)(ui5.ui5Libs);
|
|
85
83
|
return Object.assign({}, ui5, merged);
|
|
86
84
|
}
|
|
@@ -93,7 +91,7 @@ exports.mergeUi5 = mergeUi5;
|
|
|
93
91
|
* @returns minimum UI5 version for manifest
|
|
94
92
|
*/
|
|
95
93
|
function getMinUI5Version(ui5Version, minUI5Version) {
|
|
96
|
-
return minUI5Version
|
|
94
|
+
return minUI5Version ?? (ui5Version ? ui5Version : "1.60.0" /* UI5_DEFAULT.MIN_UI5_VERSION */);
|
|
97
95
|
}
|
|
98
96
|
/**
|
|
99
97
|
* Get the manifest descriptor version from the specified UI5 version.
|
|
@@ -105,7 +103,6 @@ function getMinUI5Version(ui5Version, minUI5Version) {
|
|
|
105
103
|
* @returns - the manifest descriptor version
|
|
106
104
|
*/
|
|
107
105
|
function getManifestVersion(ui5Version, manifestVersion) {
|
|
108
|
-
var _a;
|
|
109
106
|
const ui5SemVer = semver_1.default.coerce(ui5Version);
|
|
110
107
|
/**
|
|
111
108
|
* Finds the closest manifest version for the specified ui5 version. This is determined
|
|
@@ -147,7 +144,7 @@ function getManifestVersion(ui5Version, manifestVersion) {
|
|
|
147
144
|
}
|
|
148
145
|
return matchVersion;
|
|
149
146
|
};
|
|
150
|
-
return
|
|
147
|
+
return manifestVersion ?? (ui5SemVer && getClosestManifestVersion(ui5SemVer)) ?? "1.12.0" /* UI5_DEFAULT.MANIFEST_VERSION */;
|
|
151
148
|
}
|
|
152
149
|
/**
|
|
153
150
|
* If a specific local version is provided, use it, otherwise, sync with version but keep minimum versions in mind.
|
package/dist/data/ui5Libs.js
CHANGED
|
@@ -9,7 +9,7 @@ const defaults_1 = require("./defaults");
|
|
|
9
9
|
* @returns UI5 libs with defaults
|
|
10
10
|
*/
|
|
11
11
|
const getUI5Libs = (ui5Libs) => {
|
|
12
|
-
const libs = Array.isArray(ui5Libs) ? ui5Libs :
|
|
12
|
+
const libs = Array.isArray(ui5Libs) ? ui5Libs : ui5Libs?.split(',') || [];
|
|
13
13
|
return defaults_1.defaultUI5Libs.concat(libs).filter((value, index, self) => {
|
|
14
14
|
return self.indexOf(value) === index;
|
|
15
15
|
});
|
package/dist/data/validators.js
CHANGED
|
@@ -19,7 +19,7 @@ function validateAppId(appId) {
|
|
|
19
19
|
}
|
|
20
20
|
const match = appId.match(/["]/);
|
|
21
21
|
if (match) {
|
|
22
|
-
throw new Error((0, i18n_1.t)('error.disallowedCharacters', { propertyName: 'app.id', disallowedChars: `${match
|
|
22
|
+
throw new Error((0, i18n_1.t)('error.disallowedCharacters', { propertyName: 'app.id', disallowedChars: `${match?.join()}` }));
|
|
23
23
|
}
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
@@ -47,11 +47,10 @@ exports.validateUI5Version = validateUI5Version;
|
|
|
47
47
|
* @throws Error with validation message, if the ui5App is not valid
|
|
48
48
|
*/
|
|
49
49
|
function validate(ui5App) {
|
|
50
|
-
var _a, _b, _c;
|
|
51
50
|
return (validateAppId(ui5App.app.id) &&
|
|
52
|
-
validateUI5Version(
|
|
53
|
-
validateUI5Version(
|
|
54
|
-
validateUI5Version(
|
|
51
|
+
validateUI5Version(ui5App.ui5?.version) &&
|
|
52
|
+
validateUI5Version(ui5App.ui5?.localVersion) &&
|
|
53
|
+
validateUI5Version(ui5App.ui5?.minUI5Version));
|
|
55
54
|
}
|
|
56
55
|
exports.validate = validate;
|
|
57
56
|
//# sourceMappingURL=validators.js.map
|
package/dist/i18n.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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -19,19 +10,17 @@ const NS = 'ui5-application-writer';
|
|
|
19
10
|
/**
|
|
20
11
|
* Initialize i18next with the translations for this module.
|
|
21
12
|
*/
|
|
22
|
-
function initI18n() {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ns: [NS]
|
|
34
|
-
});
|
|
13
|
+
async function initI18n() {
|
|
14
|
+
await i18next_1.default.init({
|
|
15
|
+
resources: {
|
|
16
|
+
en: {
|
|
17
|
+
[NS]: ui5_application_writer_i18n_json_1.default
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
lng: 'en',
|
|
21
|
+
fallbackLng: 'en',
|
|
22
|
+
defaultNS: NS,
|
|
23
|
+
ns: [NS]
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
26
|
exports.initI18n = initI18n;
|
package/dist/index.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.isTypescriptEnabled = exports.enableTypescript = exports.generate = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
@@ -25,43 +16,40 @@ const options_1 = require("./options");
|
|
|
25
16
|
* @param fs - the memfs editor instance
|
|
26
17
|
* @returns the updated memfs editor instance
|
|
27
18
|
*/
|
|
28
|
-
function generate(basePath, ui5AppConfig, fs) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
async function generate(basePath, ui5AppConfig, fs) {
|
|
20
|
+
if (!fs) {
|
|
21
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
22
|
+
}
|
|
23
|
+
const ui5App = (0, data_1.mergeWithDefaults)(ui5AppConfig);
|
|
24
|
+
const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
|
|
25
|
+
const ignore = [ui5AppConfig.appOptions?.typescript ? '**/*.js' : '**/*.ts'];
|
|
26
|
+
if (ui5AppConfig.appOptions?.generateIndex === false) {
|
|
27
|
+
ignore.push('**/webapp/index.html');
|
|
28
|
+
}
|
|
29
|
+
fs.copyTpl((0, path_1.join)(tmplPath, 'core', '**/*.*'), (0, path_1.join)(basePath), ui5App, undefined, {
|
|
30
|
+
globOptions: { dot: true, ignore },
|
|
31
|
+
processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
|
|
32
|
+
});
|
|
33
|
+
// ui5.yaml
|
|
34
|
+
const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
|
|
35
|
+
const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
36
|
+
ui5Config.addFioriToolsProxydMiddleware({
|
|
37
|
+
ui5: {
|
|
38
|
+
url: ui5App.ui5?.frameworkUrl
|
|
39
39
|
}
|
|
40
|
-
fs.copyTpl((0, path_1.join)(tmplPath, 'core', '**/*.*'), (0, path_1.join)(basePath), ui5App, undefined, {
|
|
41
|
-
globOptions: { dot: true, ignore },
|
|
42
|
-
processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
|
|
43
|
-
});
|
|
44
|
-
// ui5.yaml
|
|
45
|
-
const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
|
|
46
|
-
const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
47
|
-
ui5Config.addFioriToolsProxydMiddleware({
|
|
48
|
-
ui5: {
|
|
49
|
-
url: (_c = ui5App.ui5) === null || _c === void 0 ? void 0 : _c.frameworkUrl
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
ui5Config.addFioriToolsAppReloadMiddleware();
|
|
53
|
-
// ui5-local.yaml
|
|
54
|
-
const ui5LocalConfigPath = (0, path_1.join)(basePath, 'ui5-local.yaml');
|
|
55
|
-
const ui5LocalConfig = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5LocalConfigPath));
|
|
56
|
-
ui5LocalConfig.addUI5Framework(ui5App.ui5.framework, ui5App.ui5.localVersion, ui5App.ui5.ui5Libs, ui5App.ui5.ui5Theme);
|
|
57
|
-
ui5LocalConfig.addFioriToolsAppReloadMiddleware();
|
|
58
|
-
// Add optional features
|
|
59
|
-
yield (0, options_1.applyOptionalFeatures)(ui5App, fs, basePath, tmplPath, [ui5Config, ui5LocalConfig]);
|
|
60
|
-
// write ui5 yamls
|
|
61
|
-
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
62
|
-
fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
|
|
63
|
-
return fs;
|
|
64
40
|
});
|
|
41
|
+
ui5Config.addFioriToolsAppReloadMiddleware();
|
|
42
|
+
// ui5-local.yaml
|
|
43
|
+
const ui5LocalConfigPath = (0, path_1.join)(basePath, 'ui5-local.yaml');
|
|
44
|
+
const ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(ui5LocalConfigPath));
|
|
45
|
+
ui5LocalConfig.addUI5Framework(ui5App.ui5.framework, ui5App.ui5.localVersion, ui5App.ui5.ui5Libs, ui5App.ui5.ui5Theme);
|
|
46
|
+
ui5LocalConfig.addFioriToolsAppReloadMiddleware();
|
|
47
|
+
// Add optional features
|
|
48
|
+
await (0, options_1.applyOptionalFeatures)(ui5App, fs, basePath, tmplPath, [ui5Config, ui5LocalConfig]);
|
|
49
|
+
// write ui5 yamls
|
|
50
|
+
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
51
|
+
fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
|
|
52
|
+
return fs;
|
|
65
53
|
}
|
|
66
54
|
exports.generate = generate;
|
|
67
55
|
/**
|
|
@@ -71,21 +59,19 @@ exports.generate = generate;
|
|
|
71
59
|
* @param fs - the memfs editor instance
|
|
72
60
|
* @returns true is the project is ready for typescript code
|
|
73
61
|
*/
|
|
74
|
-
function isTypescriptEnabled(basePath, fs) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return true;
|
|
88
|
-
});
|
|
62
|
+
async function isTypescriptEnabled(basePath, fs) {
|
|
63
|
+
if (!fs) {
|
|
64
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
65
|
+
}
|
|
66
|
+
// check middlewares and tasks
|
|
67
|
+
const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read((0, path_1.join)(basePath, 'ui5.yaml')));
|
|
68
|
+
if (!ui5Config.findCustomMiddleware(ui5Libs_1.ui5TSSupport.middleware.name)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (!ui5Config.findCustomTask(ui5Libs_1.ui5TSSupport.task.name)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
89
75
|
}
|
|
90
76
|
exports.isTypescriptEnabled = isTypescriptEnabled;
|
|
91
77
|
/**
|
|
@@ -95,36 +81,33 @@ exports.isTypescriptEnabled = isTypescriptEnabled;
|
|
|
95
81
|
* @param fs - the memfs editor instance
|
|
96
82
|
* @returns the updated memfs editor instance
|
|
97
83
|
*/
|
|
98
|
-
function enableTypescript(basePath, fs) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
84
|
+
async function enableTypescript(basePath, fs) {
|
|
85
|
+
if (!fs) {
|
|
86
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
87
|
+
}
|
|
88
|
+
const manifestPath = (0, path_1.join)(basePath, 'webapp/manifest.json');
|
|
89
|
+
const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
|
|
90
|
+
if (!fs.exists(manifestPath)) {
|
|
91
|
+
throw new Error(`Invalid project folder. Cannot find required file ${manifestPath}`);
|
|
92
|
+
}
|
|
93
|
+
if (!fs.exists(ui5ConfigPath)) {
|
|
94
|
+
throw new Error(`Invalid project folder. Cannot find required file ${ui5ConfigPath}`);
|
|
95
|
+
}
|
|
96
|
+
const manifest = fs.readJSON(manifestPath);
|
|
97
|
+
const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
98
|
+
const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
|
|
99
|
+
const typesVersion = (0, ui5_config_1.getEsmTypesVersion)(manifest['sap.ui5']?.dependencies?.minUI5Version);
|
|
100
|
+
const typesPackage = (0, ui5_config_1.getTypesPackage)(typesVersion);
|
|
101
|
+
const ui5App = {
|
|
102
|
+
app: manifest['sap.app'],
|
|
103
|
+
ui5: {
|
|
104
|
+
typesPackage,
|
|
105
|
+
typesVersion
|
|
108
106
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
|
|
114
|
-
const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
|
|
115
|
-
const typesVersion = (0, ui5_config_1.getEsmTypesVersion)((_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.minUI5Version);
|
|
116
|
-
const typesPackage = (0, ui5_config_1.getTypesPackage)(typesVersion);
|
|
117
|
-
const ui5App = {
|
|
118
|
-
app: manifest['sap.app'],
|
|
119
|
-
ui5: {
|
|
120
|
-
typesPackage,
|
|
121
|
-
typesVersion
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
yield (0, options_1.enableTypescript)({ basePath, fs, ui5Configs: [ui5Config], tmplPath, ui5App }, true);
|
|
125
|
-
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
126
|
-
return fs;
|
|
127
|
-
});
|
|
107
|
+
};
|
|
108
|
+
await (0, options_1.enableTypescript)({ basePath, fs, ui5Configs: [ui5Config], tmplPath, ui5App }, true);
|
|
109
|
+
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
110
|
+
return fs;
|
|
128
111
|
}
|
|
129
112
|
exports.enableTypescript = enableTypescript;
|
|
130
113
|
//# sourceMappingURL=index.js.map
|
package/dist/options.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.applyOptionalFeatures = exports.enableNpmPackageConsumption = exports.enableTypescript = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
@@ -25,38 +16,36 @@ const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
|
25
16
|
* @param input.basePath project base path
|
|
26
17
|
* @param input.tmplPath template basepath
|
|
27
18
|
*/
|
|
28
|
-
function copyTemplates(name, { ui5App, fs, basePath, tmplPath }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
19
|
+
async function copyTemplates(name, { ui5App, fs, basePath, tmplPath }) {
|
|
20
|
+
const optTmplDirPath = (0, path_1.join)(tmplPath, 'optional', `${name}`);
|
|
21
|
+
const optTmplFilePaths = await (0, project_access_1.getFilePaths)(optTmplDirPath);
|
|
22
|
+
optTmplFilePaths.forEach((optTmplFilePath) => {
|
|
23
|
+
const relPath = optTmplFilePath.replace(optTmplDirPath, '');
|
|
24
|
+
const outPath = (0, path_1.join)(basePath, relPath);
|
|
25
|
+
// Extend or add
|
|
26
|
+
if (!fs.exists(outPath)) {
|
|
27
|
+
fs.copyTpl(optTmplFilePath, outPath, ui5App, undefined, {
|
|
28
|
+
globOptions: { dot: true }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const add = JSON.parse((0, ejs_1.render)(fs.read(optTmplFilePath), ui5App, {}));
|
|
33
|
+
const existingFile = JSON.parse(fs.read(outPath));
|
|
34
|
+
const merged = (0, ui5_config_1.mergeObjects)(existingFile, add);
|
|
35
|
+
fs.writeJSON(outPath, merged);
|
|
36
|
+
}
|
|
48
37
|
});
|
|
49
38
|
}
|
|
50
39
|
/**
|
|
51
40
|
* Factory functions for applying optional features.
|
|
52
41
|
*/
|
|
53
42
|
const factories = {
|
|
54
|
-
codeAssist: (input) =>
|
|
55
|
-
eslint: (input) =>
|
|
56
|
-
loadReuseLibs: (input) =>
|
|
57
|
-
sapux: (input) =>
|
|
58
|
-
typescript: (input) =>
|
|
59
|
-
npmPackageConsumption: (input) =>
|
|
43
|
+
codeAssist: async (input) => await copyTemplates('codeAssist', input),
|
|
44
|
+
eslint: async (input) => await copyTemplates('eslint', input),
|
|
45
|
+
loadReuseLibs: async (input) => await copyTemplates('loadReuseLibs', input),
|
|
46
|
+
sapux: async (input) => await copyTemplates('sapux', input),
|
|
47
|
+
typescript: async (input) => await enableTypescript(input),
|
|
48
|
+
npmPackageConsumption: async (input) => await enableNpmPackageConsumption(input)
|
|
60
49
|
};
|
|
61
50
|
/**
|
|
62
51
|
* Enable typescript for the given input.
|
|
@@ -64,23 +53,20 @@ const factories = {
|
|
|
64
53
|
* @param input Input required to enable the optional typescript features
|
|
65
54
|
* @param keepOldComponent if set to true then the old Component.js will be renamed but kept.
|
|
66
55
|
*/
|
|
67
|
-
function enableTypescript(input, keepOldComponent = false) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
ui5Config.addCustomMiddleware([ui5Libs_1.ui5TSSupport.middleware]);
|
|
74
|
-
ui5Config.addCustomTasks([ui5Libs_1.ui5TSSupport.task]);
|
|
75
|
-
});
|
|
76
|
-
const compPath = (0, path_1.join)(input.basePath, 'webapp/Component.js');
|
|
77
|
-
if (keepOldComponent) {
|
|
78
|
-
input.fs.move(compPath, `${compPath}.old`);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
input.fs.delete(compPath);
|
|
82
|
-
}
|
|
56
|
+
async function enableTypescript(input, keepOldComponent = false) {
|
|
57
|
+
input.ui5App.app.baseComponent = input.ui5App.app.baseComponent ?? "sap/ui/core/UIComponent" /* UI5_DEFAULT.BASE_COMPONENT */;
|
|
58
|
+
await copyTemplates('typescript', input);
|
|
59
|
+
input.ui5Configs.forEach((ui5Config) => {
|
|
60
|
+
ui5Config.addCustomMiddleware([ui5Libs_1.ui5TSSupport.middleware]);
|
|
61
|
+
ui5Config.addCustomTasks([ui5Libs_1.ui5TSSupport.task]);
|
|
83
62
|
});
|
|
63
|
+
const compPath = (0, path_1.join)(input.basePath, 'webapp/Component.js');
|
|
64
|
+
if (keepOldComponent) {
|
|
65
|
+
input.fs.move(compPath, `${compPath}.old`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
input.fs.delete(compPath);
|
|
69
|
+
}
|
|
84
70
|
}
|
|
85
71
|
exports.enableTypescript = enableTypescript;
|
|
86
72
|
/**
|
|
@@ -88,13 +74,11 @@ exports.enableTypescript = enableTypescript;
|
|
|
88
74
|
*
|
|
89
75
|
* @param input Input required to enable the optional npm modules import
|
|
90
76
|
*/
|
|
91
|
-
function enableNpmPackageConsumption(input) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ui5Config.addCustomTasks([ui5Libs_1.ui5NPMSupport.task]);
|
|
97
|
-
});
|
|
77
|
+
async function enableNpmPackageConsumption(input) {
|
|
78
|
+
await copyTemplates('npmPackageConsumption', input);
|
|
79
|
+
input.ui5Configs.forEach((ui5Config) => {
|
|
80
|
+
ui5Config.addCustomMiddleware([ui5Libs_1.ui5NPMSupport.middleware]);
|
|
81
|
+
ui5Config.addCustomTasks([ui5Libs_1.ui5NPMSupport.task]);
|
|
98
82
|
});
|
|
99
83
|
}
|
|
100
84
|
exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
|
|
@@ -107,17 +91,14 @@ exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
|
|
|
107
91
|
* @param tmplPath template basepath
|
|
108
92
|
* @param ui5Configs available UI5 configs
|
|
109
93
|
*/
|
|
110
|
-
function applyOptionalFeatures(ui5App, fs, basePath, tmplPath, ui5Configs) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (value === true) {
|
|
116
|
-
yield ((_a = factories[key]) === null || _a === void 0 ? void 0 : _a.call(factories, { ui5App, fs, basePath, tmplPath, ui5Configs }));
|
|
117
|
-
}
|
|
94
|
+
async function applyOptionalFeatures(ui5App, fs, basePath, tmplPath, ui5Configs) {
|
|
95
|
+
if (ui5App.appOptions) {
|
|
96
|
+
for (const [key, value] of Object.entries(ui5App.appOptions)) {
|
|
97
|
+
if (value === true) {
|
|
98
|
+
await factories[key]?.({ ui5App, fs, basePath, tmplPath, ui5Configs });
|
|
118
99
|
}
|
|
119
100
|
}
|
|
120
|
-
}
|
|
101
|
+
}
|
|
121
102
|
}
|
|
122
103
|
exports.applyOptionalFeatures = applyOptionalFeatures;
|
|
123
104
|
//# sourceMappingURL=options.js.map
|
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": "0.27.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.
|
|
30
|
+
"@sap-ux/ui5-config": "0.23.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/ejs": "3.1.2",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@types/mem-fs-editor": "7.0.1",
|
|
38
38
|
"@types/semver": "7.5.2",
|
|
39
39
|
"fs-extra": "10.0.0",
|
|
40
|
-
"@sap-ux/eslint-plugin-fiori-tools": "0.
|
|
41
|
-
"@sap-ux/project-access": "1.
|
|
40
|
+
"@sap-ux/eslint-plugin-fiori-tools": "0.5.0",
|
|
41
|
+
"@sap-ux/project-access": "1.23.0"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=18.x"
|