@sap-ux/ui5-application-writer 0.15.0 → 0.16.1

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/index.js CHANGED
@@ -28,15 +28,16 @@ const ui5Libs_1 = require("./data/ui5Libs");
28
28
  * @returns {*} {Promise<Editor>} the updated memfs editor instance
29
29
  */
30
30
  function generate(basePath, ui5AppConfig, fs) {
31
- var _a;
31
+ var _a, _b;
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  if (!fs) {
34
34
  fs = mem_fs_editor_1.create(mem_fs_1.create());
35
35
  }
36
36
  const ui5App = data_1.mergeWithDefaults(ui5AppConfig);
37
37
  const tmplPath = path_1.join(__dirname, '..', 'templates');
38
+ const ignore = [((_a = ui5AppConfig.appOptions) === null || _a === void 0 ? void 0 : _a.typescript) ? '**/*.js' : '**/*.ts'];
38
39
  fs.copyTpl(path_1.join(tmplPath, 'core', '**/*.*'), path_1.join(basePath), ui5App, undefined, {
39
- globOptions: { dot: true },
40
+ globOptions: { dot: true, ignore },
40
41
  processDestinationPath: (filePath) => filePath.replace(/gitignore.tmpl/g, '.gitignore')
41
42
  });
42
43
  // ui5.yaml
@@ -44,7 +45,7 @@ function generate(basePath, ui5AppConfig, fs) {
44
45
  const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
45
46
  ui5Config.addFioriToolsProxydMiddleware({
46
47
  ui5: {
47
- url: (_a = ui5App.ui5) === null || _a === void 0 ? void 0 : _a.frameworkUrl
48
+ url: (_b = ui5App.ui5) === null || _b === void 0 ? void 0 : _b.frameworkUrl
48
49
  }
49
50
  });
50
51
  ui5Config.addFioriToolsAppReloadMiddleware();
@@ -78,7 +79,6 @@ function generate(basePath, ui5AppConfig, fs) {
78
79
  }
79
80
  });
80
81
  if (ui5App.appOptions.typescript) {
81
- fs.delete(path_1.join(basePath, 'webapp/Component.js'));
82
82
  ui5Config.addCustomMiddleware(ui5Libs_1.ui5TsMiddlewares);
83
83
  ui5Config.addCustomTasks(ui5Libs_1.ui5TsTasks);
84
84
  ui5LocalConfig.addCustomMiddleware(ui5Libs_1.ui5TsMiddlewares);
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.15.0",
12
+ "version": "0.16.1",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -1,173 +1,168 @@
1
1
  /*eslint-disable semi, no-console*/
2
2
  (function (sap) {
3
- var fioriToolsGetManifestLibs = function (manifestPath) {
4
- var url = manifestPath;
5
- var result = "";
6
- // SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
7
- var ui5Libs = [
8
- "sap.apf",
9
- "sap.base",
10
- "sap.chart",
11
- "sap.collaboration",
12
- "sap.f",
13
- "sap.fe",
14
- "sap.fileviewer",
15
- "sap.gantt",
16
- "sap.landvisz",
17
- "sap.m",
18
- "sap.ndc",
19
- "sap.ovp",
20
- "sap.rules",
21
- "sap.suite",
22
- "sap.tnt",
23
- "sap.ui",
24
- "sap.uiext",
25
- "sap.ushell",
26
- "sap.uxap",
27
- "sap.viz",
28
- "sap.webanalytics",
29
- "sap.zen"
30
- ];
31
- function getKeys(libOrComp,libOrCompKeysString) {
32
- Object.keys(libOrComp).forEach(function (libOrCompKey) {
33
- // ignore libs or Components that start with SAPUI5 delivered namespaces
34
- if (!ui5Libs.some(function (substring) { return libOrCompKey === substring || libOrCompKey.startsWith(substring + "."); })) {
35
- if (libOrCompKeysString.length > 0) {
36
- libOrCompKeysString = libOrCompKeysString + "," + libOrCompKey;
37
- } else {
38
- libOrCompKeysString = libOrCompKey;
39
- }
40
- }
41
- });
42
- return libOrCompKeysString;
43
- }
44
- return new Promise(function (resolve, reject) {
45
- $.ajax(url)
46
- .done(function (manifest) {
47
- if (manifest) {
48
- if (
49
- manifest["sap.ui5"] &&
50
- manifest["sap.ui5"].dependencies
51
- ) {
52
- if (manifest["sap.ui5"].dependencies.libs){
53
- result = getKeys(manifest["sap.ui5"].dependencies.libs, result)
54
- }
55
- if (manifest["sap.ui5"].dependencies.components){
56
- result = getKeys(manifest["sap.ui5"].dependencies.components, result)
57
- }
58
- }
3
+ var getKeys = function (libOrComp, libOrCompKeysString) {
4
+ // SAPUI5 delivered namespaces from https://ui5.sap.com/#/api/sap
5
+ var ui5Libs = [
6
+ "sap.apf",
7
+ "sap.base",
8
+ "sap.chart",
9
+ "sap.collaboration",
10
+ "sap.f",
11
+ "sap.fe",
12
+ "sap.fileviewer",
13
+ "sap.gantt",
14
+ "sap.landvisz",
15
+ "sap.m",
16
+ "sap.ndc",
17
+ "sap.ovp",
18
+ "sap.rules",
19
+ "sap.suite",
20
+ "sap.tnt",
21
+ "sap.ui",
22
+ "sap.uiext",
23
+ "sap.ushell",
24
+ "sap.uxap",
25
+ "sap.viz",
26
+ "sap.webanalytics",
27
+ "sap.zen"
28
+ ];
29
+ Object.keys(libOrComp).forEach(function (libOrCompKey) {
30
+ // ignore libs or Components that start with SAPUI5 delivered namespaces
59
31
  if (
60
- manifest["sap.ui5"] &&
61
- manifest["sap.ui5"].componentUsages
32
+ !ui5Libs.some(function (substring) {
33
+ return libOrCompKey === substring || libOrCompKey.startsWith(substring + ".");
34
+ })
62
35
  ) {
63
- result = getKeys(manifest["sap.ui5"].componentUsages, result)
36
+ if (libOrCompKeysString.length > 0) {
37
+ libOrCompKeysString = libOrCompKeysString + "," + libOrCompKey;
38
+ } else {
39
+ libOrCompKeysString = libOrCompKey;
40
+ }
64
41
  }
65
- }
66
- resolve(result);
67
- })
68
- .fail(function (error) {
69
- reject(new Error("Could not fetch manifest at '" + manifestPath));
70
42
  });
71
- });
72
- };
73
- /**
74
- * Registers the module paths for dependencies of the given component.
75
- * @param {string} manifestPath The the path to the app manifest path
76
- * for which the dependencies should be registered.
77
- * @returns {Promise} A promise which is resolved when the ajax request for
78
- * the app-index was successful and the module paths were registered.
79
- */
80
- sap.registerComponentDependencyPaths = function (manifestPath) {
81
- /*eslint-disable semi, consistent-return*/
82
- return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
83
- if (libs && libs.length > 0) {
84
- var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
85
- var sapClient = jQuery.sap.getUriParameters().get("sap-client");
86
- if (sapClient && sapClient.length === 3) {
87
- url = url + "&sap-client=" + sapClient;
43
+ return libOrCompKeysString;
44
+ };
45
+
46
+ var updateManifest = function (manifest) {
47
+ var result = "";
48
+ if (manifest) {
49
+ if (manifest["sap.ui5"] && manifest["sap.ui5"].dependencies) {
50
+ if (manifest["sap.ui5"].dependencies.libs) {
51
+ result = getKeys(manifest["sap.ui5"].dependencies.libs, result);
52
+ }
53
+ if (manifest["sap.ui5"].dependencies.components) {
54
+ result = getKeys(manifest["sap.ui5"].dependencies.components, result);
55
+ }
56
+ }
57
+ if (manifest["sap.ui5"] && manifest["sap.ui5"].componentUsages) {
58
+ result = getKeys(manifest["sap.ui5"].componentUsages, result);
59
+ }
88
60
  }
89
- return $.ajax(url).done(function (data) {
90
- if (data) {
91
- Object.keys(data).forEach(function (moduleDefinitionKey) {
92
- var moduleDefinition = data[moduleDefinitionKey];
93
- if (moduleDefinition && moduleDefinition.dependencies) {
94
- moduleDefinition.dependencies.forEach(function (dependency) {
95
- if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
96
- jQuery.sap.log.info(
97
- "Registering Library " +
98
- dependency.componentId +
99
- " from server " +
100
- dependency.url
101
- );
102
- jQuery.sap.registerModulePath(dependency.componentId, dependency.url);
103
- }
61
+ return result;
62
+ };
63
+
64
+ var fioriToolsGetManifestLibs = function (manifestPath) {
65
+ var url = manifestPath;
66
+ return new Promise(function (resolve, reject) {
67
+ $.ajax(url)
68
+ .done(function (manifest) {
69
+ resolve(updateManifest(manifest));
70
+ })
71
+ .fail(function () {
72
+ reject(new Error("Could not fetch manifest at '" + manifestPath));
104
73
  });
105
- }
74
+ });
75
+ };
76
+
77
+ var updateModuleDefinition = function (data) {
78
+ if (data) {
79
+ Object.keys(data).forEach(function (moduleDefinitionKey) {
80
+ var moduleDefinition = data[moduleDefinitionKey];
81
+ if (moduleDefinition && moduleDefinition.dependencies) {
82
+ moduleDefinition.dependencies.forEach(function (dependency) {
83
+ if (dependency.url && dependency.url.length > 0 && dependency.type === "UI5LIB") {
84
+ jQuery.sap.log.info(
85
+ "Registering Library " + dependency.componentId + " from server " + dependency.url
86
+ );
87
+ jQuery.sap.registerModulePath(dependency.componentId, dependency.url);
88
+ }
89
+ });
90
+ }
106
91
  });
107
- }
92
+ }
93
+ };
94
+
95
+ /**
96
+ * Registers the module paths for dependencies of the given component.
97
+ * @param {string} manifestPath The the path to the app manifest path
98
+ * for which the dependencies should be registered.
99
+ * @returns {Promise} A promise which is resolved when the ajax request for
100
+ * the app-index was successful and the module paths were registered.
101
+ */
102
+ sap.registerComponentDependencyPaths = function (manifestPath) {
103
+ /*eslint-disable semi, consistent-return*/
104
+ return fioriToolsGetManifestLibs(manifestPath).then(function (libs) {
105
+ if (libs && libs.length > 0) {
106
+ var url = "/sap/bc/ui2/app_index/ui5_app_info?id=" + libs;
107
+ var sapClient = jQuery.sap.getUriParameters().get("sap-client");
108
+ if (sapClient && sapClient.length === 3) {
109
+ url = url + "&sap-client=" + sapClient;
110
+ }
111
+ return $.ajax(url).done(updateModuleDefinition);
112
+ }
108
113
  });
109
- }
110
- });
111
- };
114
+ };
112
115
  })(sap);
113
116
 
114
117
  /*eslint-disable sap-browser-api-warning, sap-no-dom-access*/
115
118
  var scripts = document.getElementsByTagName("script");
116
- var currentScript = document.getElementById('locate-reuse-libs');
117
- if(!currentScript){
119
+ var currentScript = document.getElementById("locate-reuse-libs");
120
+ if (!currentScript) {
118
121
  currentScript = document.currentScript;
119
- };
122
+ }
120
123
  var manifestUri = currentScript.getAttribute("data-sap-ui-manifest-uri");
121
124
  var componentName = currentScript.getAttribute("data-sap-ui-componentName");
122
125
  var useMockserver = currentScript.getAttribute("data-sap-ui-use-mockserver");
123
- sap.registerComponentDependencyPaths(manifestUri)
124
- .catch(function (error) {
125
- jQuery.sap.log.error(error);
126
- })
127
- .finally(function () {
128
-
129
- // setting the app title with internationalization
130
- sap.ui.getCore().attachInit(function () {
131
- jQuery.sap.require("jquery.sap.resources");
132
- var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
133
- var oBundle = jQuery.sap.resources({
126
+ var bundleResources = function () {
127
+ jQuery.sap.require("jquery.sap.resources");
128
+ var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
129
+ var oBundle = jQuery.sap.resources({
134
130
  url: "i18n/i18n.properties",
135
131
  locale: sLocale
136
- });
137
- document.title = oBundle.getText("appTitle");
138
132
  });
133
+ document.title = oBundle.getText("appTitle");
134
+ };
135
+ sap.registerComponentDependencyPaths(manifestUri)
136
+ .catch(function (error) {
137
+ jQuery.sap.log.error(error);
138
+ })
139
+ .finally(function () {
140
+ // setting the app title with internationalization
141
+ sap.ui.getCore().attachInit(bundleResources);
139
142
 
140
- if (componentName && componentName.length > 0) {
141
- if (useMockserver && useMockserver === "true") {
142
- sap.ui.getCore().attachInit(function () {
143
- sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
144
- // set up test service for local testing
145
- server.init();
146
- // initialize the ushell sandbox component
147
- sap.ushell.Container.createRenderer().placeAt("content");
148
- });
149
- });
150
- } else {
151
- // Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
152
- sap.ui.require(["sap/ui/core/ComponentSupport"]);
143
+ if (componentName && componentName.length > 0) {
144
+ if (useMockserver && useMockserver === "true") {
145
+ sap.ui.getCore().attachInit(function () {
146
+ sap.ui.require([componentName.replace(/\./g, "/") + "/localService/mockserver"], function (server) {
147
+ // set up test service for local testing
148
+ server.init();
149
+ // initialize the ushell sandbox component
150
+ sap.ushell.Container.createRenderer().placeAt("content");
151
+ });
152
+ });
153
+ } else {
154
+ // Requiring the ComponentSupport module automatically executes the component initialisation for all declaratively defined components
155
+ sap.ui.require(["sap/ui/core/ComponentSupport"]);
153
156
 
154
- // setting the app title with the i18n text
155
- sap.ui.getCore().attachInit(function () {
156
- jQuery.sap.require("jquery.sap.resources");
157
- var sLocale = sap.ui.getCore().getConfiguration().getLanguage();
158
- var oBundle = jQuery.sap.resources({
159
- url: "i18n/i18n.properties",
160
- locale: sLocale
161
- });
162
- document.title = oBundle.getText("appTitle");
163
- });
164
- }
165
- } else {
166
- sap.ui.getCore().attachInit(function () {
167
- // initialize the ushell sandbox component
168
- sap.ushell.Container.createRenderer().placeAt("content");
169
- });
170
- }
171
- });
157
+ // setting the app title with the i18n text
158
+ sap.ui.getCore().attachInit(bundleResources);
159
+ }
160
+ } else {
161
+ sap.ui.getCore().attachInit(function () {
162
+ // initialize the ushell sandbox component
163
+ sap.ushell.Container.createRenderer().placeAt("content");
164
+ });
165
+ }
166
+ });
172
167
 
173
168
  sap.registerComponentDependencyPaths(manifestUri);
@@ -3,7 +3,7 @@
3
3
  "ts-typecheck": "tsc --noEmit"
4
4
  },
5
5
  "devDependencies": {
6
- "@types/openui5": "latest",
6
+ "@sapui5/ts-types-esm": "latest",
7
7
  "ui5-tooling-modules": "^0.6.0",
8
8
  "ui5-tooling-transpile": "^0.2.0",
9
9
  "typescript": "^4.6.3",
@@ -17,7 +17,8 @@
17
17
  "<%- app.id %>/*": [
18
18
  "webapp/*"
19
19
  ]
20
- }
20
+ },
21
+ "types": [ "@sapui5/ts-types-esm" ]
21
22
  },
22
23
  "include": [
23
24
  "webapp/**/*"