@sap-ux/ui5-application-writer 0.14.4 → 0.15.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.
@@ -45,4 +45,11 @@ export declare const defaultUI5Libs: string[];
45
45
  * @returns {UI5} the updated copy of UI5 instance (does not change `ui5`)
46
46
  */
47
47
  export declare function mergeUi5(ui5: Partial<UI5>): UI5;
48
+ /**
49
+ * Retrieve the tag version of the @sap/ux-specification based on the given version.
50
+ *
51
+ * @param ui5Version UI5 version used in the project
52
+ * @returns version tag
53
+ */
54
+ export declare function getSpecTagVersion(ui5Version: string | undefined): string;
48
55
  //# sourceMappingURL=defaults.d.ts.map
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mergeUi5 = exports.defaultUI5Libs = exports.UI5_DEFAULT = exports.mergeApp = exports.mergePackages = exports.packageDefaults = void 0;
6
+ exports.getSpecTagVersion = exports.mergeUi5 = exports.defaultUI5Libs = exports.UI5_DEFAULT = exports.mergeApp = exports.mergePackages = exports.packageDefaults = void 0;
7
7
  const version_to_descriptor_mapping_json_1 = __importDefault(require("./version-to-descriptor-mapping.json")); // from https://github.com/SAP/ui5-manifest/blob/master/mapping.json
8
8
  const ui5Libs_1 = require("./ui5Libs");
9
9
  const semver_1 = __importDefault(require("semver"));
@@ -216,4 +216,23 @@ function getLocalVersion({ framework, version, localVersion }) {
216
216
  }
217
217
  return result;
218
218
  }
219
+ /**
220
+ * Retrieve the tag version of the @sap/ux-specification based on the given version.
221
+ *
222
+ * @param ui5Version UI5 version used in the project
223
+ * @returns version tag
224
+ */
225
+ function getSpecTagVersion(ui5Version) {
226
+ if (ui5Version) {
227
+ if (semver_1.default.valid(ui5Version)) {
228
+ return `UI5-${semver_1.default.major(ui5Version)}.${semver_1.default.minor(ui5Version)}`;
229
+ }
230
+ else if (ui5Version.includes('snapshot') && ui5Version.includes('.')) {
231
+ const snaphotVersion = ui5Version.split('snapshot-')[1];
232
+ return `UI5-${snaphotVersion}`;
233
+ }
234
+ }
235
+ return 'latest';
236
+ }
237
+ exports.getSpecTagVersion = getSpecTagVersion;
219
238
  //# sourceMappingURL=defaults.js.map
@@ -16,6 +16,9 @@ function mergeWithDefaults(ui5App) {
16
16
  ui5App.appOptions = ui5App.appOptions || {};
17
17
  ui5App.ui5 = defaults_1.mergeUi5(ui5App.ui5 || {});
18
18
  ui5App.package = defaults_1.mergePackages(defaults_1.packageDefaults(ui5App.package.version, ui5App.app.description), ui5App.package);
19
+ if (ui5App.appOptions.sapux) {
20
+ ui5App.package.devDependencies['@sap/ux-specification'] = defaults_1.getSpecTagVersion(ui5App.ui5.version);
21
+ }
19
22
  return ui5App;
20
23
  }
21
24
  exports.mergeWithDefaults = mergeWithDefaults;
@@ -5,4 +5,46 @@
5
5
  * @returns UI5 libs with defaults
6
6
  */
7
7
  export declare const getUI5Libs: (ui5Libs?: string | string[] | undefined) => string[];
8
+ /**
9
+ * UI5 tasks configurations required for TypeScript projects
10
+ */
11
+ export declare const ui5TsTasks: ({
12
+ name: string;
13
+ afterTask: string;
14
+ configuration: {
15
+ debug?: undefined;
16
+ removeConsoleStatements?: undefined;
17
+ transpileAsync?: undefined;
18
+ transpileTypeScript?: undefined;
19
+ };
20
+ } | {
21
+ name: string;
22
+ afterTask: string;
23
+ configuration: {
24
+ debug: boolean;
25
+ removeConsoleStatements: boolean;
26
+ transpileAsync: boolean;
27
+ transpileTypeScript: boolean;
28
+ };
29
+ })[];
30
+ /**
31
+ * UI5 middleware configurations required for TypeScript projects
32
+ */
33
+ export declare const ui5TsMiddlewares: ({
34
+ name: string;
35
+ afterMiddleware: string;
36
+ configuration: {
37
+ debug?: undefined;
38
+ transpileAsync?: undefined;
39
+ transpileTypeScript?: undefined;
40
+ };
41
+ } | {
42
+ name: string;
43
+ afterMiddleware: string;
44
+ configuration: {
45
+ debug: boolean;
46
+ transpileAsync: boolean;
47
+ transpileTypeScript: boolean;
48
+ };
49
+ })[];
8
50
  //# sourceMappingURL=ui5Libs.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUI5Libs = void 0;
3
+ exports.ui5TsMiddlewares = exports.ui5TsTasks = exports.getUI5Libs = void 0;
4
4
  const defaults_1 = require("./defaults");
5
5
  /**
6
6
  * Merges the specified ui5 libs with the defaults.
@@ -14,4 +14,43 @@ exports.getUI5Libs = (ui5Libs) => {
14
14
  return self.indexOf(value) === index;
15
15
  });
16
16
  };
17
+ /**
18
+ * UI5 tasks configurations required for TypeScript projects
19
+ */
20
+ exports.ui5TsTasks = [
21
+ {
22
+ name: 'ui5-tooling-modules-task',
23
+ afterTask: 'replaceVersion',
24
+ configuration: {}
25
+ },
26
+ {
27
+ name: 'ui5-tooling-transpile-task',
28
+ afterTask: 'replaceVersion',
29
+ configuration: {
30
+ debug: true,
31
+ removeConsoleStatements: true,
32
+ transpileAsync: true,
33
+ transpileTypeScript: true
34
+ }
35
+ }
36
+ ];
37
+ /**
38
+ * UI5 middleware configurations required for TypeScript projects
39
+ */
40
+ exports.ui5TsMiddlewares = [
41
+ {
42
+ name: 'ui5-tooling-modules-middleware',
43
+ afterMiddleware: 'compression',
44
+ configuration: {}
45
+ },
46
+ {
47
+ name: 'ui5-tooling-transpile-middleware',
48
+ afterMiddleware: 'compression',
49
+ configuration: {
50
+ debug: true,
51
+ transpileAsync: true,
52
+ transpileTypeScript: true
53
+ }
54
+ }
55
+ ];
17
56
  //# sourceMappingURL=ui5Libs.js.map
@@ -1,5 +1,10 @@
1
1
  {
2
- "latest": "1.40.0",
2
+ "latest": "1.45.0",
3
+ "1.105": "1.45.0",
4
+ "1.104": "1.44.0",
5
+ "1.103": "1.43.0",
6
+ "1.102": "1.42.0",
7
+ "1.101": "1.41.0",
3
8
  "1.100": "1.40.0",
4
9
  "1.99": "1.39.0",
5
10
  "1.98": "1.38.0",
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
+ import type { App, AppOptions, Package, UI5 } from './types';
2
3
  import { Ui5App } from './types';
3
4
  /**
4
5
  * Writes the template to the memfs editor instance.
@@ -10,5 +11,5 @@ import { Ui5App } from './types';
10
11
  */
11
12
  declare function generate(basePath: string, ui5AppConfig: Ui5App, fs?: Editor): Promise<Editor>;
12
13
  export { Ui5App, generate };
13
- export { App, Package, UI5 } from './types';
14
+ export { App, Package, UI5, AppOptions };
14
15
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ const json_merger_1 = require("json-merger");
18
18
  const ejs_1 = require("ejs");
19
19
  const files_1 = require("./files");
20
20
  const ui5_config_1 = require("@sap-ux/ui5-config");
21
+ const ui5Libs_1 = require("./data/ui5Libs");
21
22
  /**
22
23
  * Writes the template to the memfs editor instance.
23
24
  *
@@ -47,13 +48,11 @@ function generate(basePath, ui5AppConfig, fs) {
47
48
  }
48
49
  });
49
50
  ui5Config.addFioriToolsAppReloadMiddleware();
50
- fs.write(ui5ConfigPath, ui5Config.toString());
51
51
  // ui5-local.yaml
52
52
  const ui5LocalConfigPath = path_1.join(basePath, 'ui5-local.yaml');
53
53
  const ui5LocalConfig = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5LocalConfigPath));
54
54
  ui5LocalConfig.addUI5Framework(ui5App.ui5.framework, ui5App.ui5.localVersion, ui5App.ui5.ui5Libs, ui5App.ui5.ui5Theme);
55
55
  ui5LocalConfig.addFioriToolsAppReloadMiddleware();
56
- fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
57
56
  // Add optional features
58
57
  if (ui5App.appOptions) {
59
58
  Object.entries(ui5App.appOptions).forEach(([key, value]) => {
@@ -70,7 +69,7 @@ function generate(basePath, ui5AppConfig, fs) {
70
69
  });
71
70
  }
72
71
  else {
73
- const add = JSON.parse(ejs_1.render(fs === null || fs === void 0 ? void 0 : fs.read(optTmplFilePath), ui5App));
72
+ const add = JSON.parse(ejs_1.render(fs === null || fs === void 0 ? void 0 : fs.read(optTmplFilePath), ui5App, {}));
74
73
  const existingFile = JSON.parse(fs === null || fs === void 0 ? void 0 : fs.read(outPath));
75
74
  const merged = json_merger_1.mergeObjects([existingFile, add], { defaultArrayMergeOperation: 'concat' });
76
75
  fs === null || fs === void 0 ? void 0 : fs.writeJSON(outPath, merged);
@@ -78,7 +77,17 @@ function generate(basePath, ui5AppConfig, fs) {
78
77
  });
79
78
  }
80
79
  });
80
+ if (ui5App.appOptions.typescript) {
81
+ fs.delete(path_1.join(basePath, 'webapp/Component.js'));
82
+ ui5Config.addCustomMiddleware(ui5Libs_1.ui5TsMiddlewares);
83
+ ui5Config.addCustomTasks(ui5Libs_1.ui5TsTasks);
84
+ ui5LocalConfig.addCustomMiddleware(ui5Libs_1.ui5TsMiddlewares);
85
+ ui5LocalConfig.addCustomTasks(ui5Libs_1.ui5TsTasks);
86
+ }
81
87
  }
88
+ // write ui5 yamls
89
+ fs.write(ui5ConfigPath, ui5Config.toString());
90
+ fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
82
91
  return fs;
83
92
  });
84
93
  }
package/dist/types.d.ts CHANGED
@@ -51,7 +51,14 @@ export interface AppOptions {
51
51
  codeAssist: boolean;
52
52
  eslint: boolean;
53
53
  sapux: boolean;
54
+ /**
55
+ * Enables loading of re-use libs
56
+ */
54
57
  loadReuseLibs: boolean;
58
+ /**
59
+ * Enable Typescript support and generate all files in Typescript instead of Javascript
60
+ */
61
+ typescript: boolean;
55
62
  }
56
63
  export interface Ui5App {
57
64
  app: App;
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.14.4",
12
+ "version": "0.15.0",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -20,7 +20,7 @@
20
20
  "!dist/**/*.map"
21
21
  ],
22
22
  "dependencies": {
23
- "@sap-ux/ui5-config": "0.14.4",
23
+ "@sap-ux/ui5-config": "0.14.5",
24
24
  "ejs": "3.1.7",
25
25
  "mem-fs": "2.1.0",
26
26
  "mem-fs-editor": "9.4.0",
@@ -0,0 +1,4 @@
1
+ {
2
+ "ignore": ["**/*.d.ts"],
3
+ "presets": ["transform-ui5", "@babel/preset-typescript"]
4
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "root": true,
3
+ "env": {
4
+ "browser": true,
5
+ "es6": true,
6
+ "node": true
7
+ },
8
+ "extends": [
9
+ "eslint:recommended",
10
+ "plugin:@typescript-eslint/recommended",
11
+ "plugin:@typescript-eslint/recommended-requiring-type-checking"
12
+ ],
13
+ "ignorePatterns": [".eslintignore.js"],
14
+ "parser": "@typescript-eslint/parser",
15
+ "parserOptions": {
16
+ "project": ["./tsconfig.json"],
17
+ "tsconfigRootDir": ".",
18
+ "sourceType": "module"
19
+ },
20
+ "plugins": [
21
+ "@typescript-eslint"
22
+ ]
23
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "scripts": {
3
+ "ts-typecheck": "tsc --noEmit"
4
+ },
5
+ "devDependencies": {
6
+ "@types/openui5": "latest",
7
+ "ui5-tooling-modules": "^0.6.0",
8
+ "ui5-tooling-transpile": "^0.2.0",
9
+ "typescript": "^4.6.3",
10
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
11
+ "@typescript-eslint/parser": "^5.17.0"
12
+ },
13
+ "ui5": {
14
+ "dependencies": [
15
+ "ui5-tooling-modules",
16
+ "ui5-tooling-transpile"
17
+ ]
18
+ }
19
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2015",
4
+ "module": "es2015",
5
+ "skipLibCheck": true,
6
+ "preserveConstEnums": true,
7
+ "inlineSourceMap": true,
8
+ "allowJs": true,
9
+ "strict": true,
10
+ "strictNullChecks": true,
11
+ "strictPropertyInitialization": false,
12
+ "moduleResolution": "node",
13
+ "rootDir": "webapp",
14
+ "outDir": "./dist",
15
+ "baseUrl": "./",
16
+ "paths": {
17
+ "<%- app.id %>/*": [
18
+ "webapp/*"
19
+ ]
20
+ }
21
+ },
22
+ "include": [
23
+ "webapp/**/*"
24
+ ]
25
+ }
@@ -0,0 +1,24 @@
1
+ import UIComponent from "<%- app.baseComponent %>";
2
+
3
+ /**
4
+ * @namespace <%- app.id %>
5
+ */
6
+ export default class Component extends UIComponent {
7
+
8
+ public static metadata = {
9
+ manifest: "json"
10
+ };
11
+
12
+ /**
13
+ * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
14
+ * @public
15
+ * @override
16
+ */
17
+ public init() : void {
18
+ // call the base component's init function
19
+ super.init();
20
+
21
+ // enable routing
22
+ this.getRouter().initialize();
23
+ }
24
+ }