@sap-ux/ui5-application-writer 1.1.6 → 1.2.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.
@@ -1,4 +1,5 @@
1
- import type { App, AppOptions, Package, UI5 } from '../types';
1
+ import type { App, AppOptions, UI5 } from '../types';
2
+ import type { Package } from '@sap-ux/project-access';
2
3
  /**
3
4
  * Returns a package instance with default properties.
4
5
  *
@@ -25,11 +26,4 @@ export declare const defaultUI5Libs: string[];
25
26
  * @returns {UI5} the updated copy of UI5 instance (does not change `ui5`)
26
27
  */
27
28
  export declare function mergeUi5(ui5: Partial<UI5>, options?: Partial<AppOptions>): UI5;
28
- /**
29
- * Retrieve the tag version of the @sap/ux-specification based on the given version.
30
- *
31
- * @param ui5Version UI5 version used in the project
32
- * @returns version tag
33
- */
34
- export declare function getSpecTagVersion(ui5Version: string | undefined): string;
35
29
  //# sourceMappingURL=defaults.d.ts.map
@@ -3,7 +3,10 @@ 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.getSpecTagVersion = exports.mergeUi5 = exports.defaultUI5Libs = exports.mergeApp = exports.packageDefaults = void 0;
6
+ exports.defaultUI5Libs = void 0;
7
+ exports.packageDefaults = packageDefaults;
8
+ exports.mergeApp = mergeApp;
9
+ exports.mergeUi5 = mergeUi5;
7
10
  const ui5_config_1 = require("@sap-ux/ui5-config");
8
11
  const mapping_json_1 = __importDefault(require("@ui5/manifest/mapping.json")); // from https://github.com/SAP/ui5-manifest/blob/master/mapping.json
9
12
  const ui5Libs_1 = require("./ui5Libs");
@@ -43,7 +46,6 @@ function packageDefaults(version, description, isEdmxProjectType) {
43
46
  scripts: {}
44
47
  };
45
48
  }
46
- exports.packageDefaults = packageDefaults;
47
49
  /**
48
50
  * Returns an app instance merged with default properties.
49
51
  *
@@ -63,7 +65,6 @@ function mergeApp(app) {
63
65
  }
64
66
  }, app);
65
67
  }
66
- exports.mergeApp = mergeApp;
67
68
  // Required default libs
68
69
  exports.defaultUI5Libs = ['sap.m', 'sap.ui.core'];
69
70
  /**
@@ -96,7 +97,6 @@ function mergeUi5(ui5, options) {
96
97
  merged.ui5Libs = (0, ui5Libs_1.getUI5Libs)(ui5.ui5Libs);
97
98
  return Object.assign({}, ui5, merged);
98
99
  }
99
- exports.mergeUi5 = mergeUi5;
100
100
  /**
101
101
  * Gets the miminum UI5 version based on the specified version.
102
102
  *
@@ -190,23 +190,4 @@ function getLocalVersion({ framework, version, localVersion }) {
190
190
  return minVersion;
191
191
  }
192
192
  }
193
- /**
194
- * Retrieve the tag version of the @sap/ux-specification based on the given version.
195
- *
196
- * @param ui5Version UI5 version used in the project
197
- * @returns version tag
198
- */
199
- function getSpecTagVersion(ui5Version) {
200
- if (ui5Version) {
201
- if (semver_1.default.valid(ui5Version)) {
202
- return `UI5-${semver_1.default.major(ui5Version)}.${semver_1.default.minor(ui5Version)}`;
203
- }
204
- else if (ui5Version.includes('snapshot') && ui5Version.includes('.')) {
205
- const snaphotVersion = ui5Version.split('snapshot-')[1];
206
- return `UI5-${snaphotVersion}`;
207
- }
208
- }
209
- return 'latest';
210
- }
211
- exports.getSpecTagVersion = getSpecTagVersion;
212
193
  //# sourceMappingURL=defaults.js.map
@@ -1,4 +1,5 @@
1
- import type { App, UI5, AppOptions, Package, Ui5App } from '../types';
1
+ import type { App, UI5, AppOptions, Ui5App } from '../types';
2
+ import type { Package } from '@sap-ux/project-access';
2
3
  /**
3
4
  * Merges Ui5App instance with default properties.
4
5
  * Replaces undefined mandatory properties with default values.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeWithDefaults = void 0;
3
+ exports.mergeWithDefaults = mergeWithDefaults;
4
4
  const ui5_config_1 = require("@sap-ux/ui5-config");
5
5
  const defaults_1 = require("./defaults");
6
6
  const validators_1 = require("./validators");
@@ -23,12 +23,10 @@ function mergeWithDefaults(ui5App) {
23
23
  // Determine if the project type is 'EDMXBackend'.
24
24
  const isEdmxProjectType = ui5App.app.projectType === 'EDMXBackend';
25
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
28
- ui5App.package.devDependencies = ui5App.package.devDependencies || {};
29
- ui5App.package.devDependencies['@sap/ux-specification'] = (0, defaults_1.getSpecTagVersion)(ui5App.ui5.version);
26
+ if (!isEdmxProjectType) {
27
+ // sapuxLayer is not defined for cap projects
28
+ ui5App.package.sapuxLayer = undefined;
30
29
  }
31
30
  return ui5App;
32
31
  }
33
- exports.mergeWithDefaults = mergeWithDefaults;
34
32
  //# sourceMappingURL=index.js.map
@@ -3,7 +3,9 @@ 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.validate = exports.validateUI5Version = exports.validateAppId = void 0;
6
+ exports.validateAppId = validateAppId;
7
+ exports.validateUI5Version = validateUI5Version;
8
+ exports.validate = validate;
7
9
  const semver_1 = __importDefault(require("semver"));
8
10
  const i18n_1 = require("../i18n");
9
11
  /**
@@ -23,7 +25,6 @@ function validateAppId(appId) {
23
25
  }
24
26
  return true;
25
27
  }
26
- exports.validateAppId = validateAppId;
27
28
  /**
28
29
  * Validates by throwing if the specified version does not have a coercible semantic version.
29
30
  * Currently we have special handling for empty string and undefined otherwise see: https://github.com/npm/node-semver#coercion.
@@ -38,7 +39,6 @@ function validateUI5Version(version) {
38
39
  }
39
40
  return true;
40
41
  }
41
- exports.validateUI5Version = validateUI5Version;
42
42
  /**
43
43
  * Validates the specified ui5App.
44
44
  *
@@ -52,5 +52,4 @@ function validate(ui5App) {
52
52
  validateUI5Version(ui5App.ui5?.localVersion) &&
53
53
  validateUI5Version(ui5App.ui5?.minUI5Version));
54
54
  }
55
- exports.validate = validate;
56
55
  //# sourceMappingURL=validators.js.map
package/dist/i18n.js CHANGED
@@ -3,7 +3,8 @@ 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.t = exports.initI18n = void 0;
6
+ exports.initI18n = initI18n;
7
+ exports.t = t;
7
8
  const i18next_1 = __importDefault(require("i18next"));
8
9
  const ui5_application_writer_i18n_json_1 = __importDefault(require("./translations/ui5-application-writer.i18n.json"));
9
10
  const NS = 'ui5-application-writer';
@@ -23,7 +24,6 @@ async function initI18n() {
23
24
  ns: [NS]
24
25
  });
25
26
  }
26
- exports.initI18n = initI18n;
27
27
  /**
28
28
  * Helper function facading the call to i18next.
29
29
  *
@@ -34,7 +34,6 @@ exports.initI18n = initI18n;
34
34
  function t(key, options) {
35
35
  return i18next_1.default.t(key, options);
36
36
  }
37
- exports.t = t;
38
37
  initI18n().catch(() => {
39
38
  // Ignore any errors since the write will still work
40
39
  });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { App, AppOptions, Package, UI5 } from './types';
2
+ import type { App, AppOptions, UI5 } from './types';
3
+ import { type Package } from '@sap-ux/project-access';
3
4
  import { Ui5App } from './types';
4
5
  /**
5
6
  * Writes the template to the memfs editor instance.
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTypescriptEnabled = exports.enableTypescript = exports.generate = void 0;
3
+ exports.generate = generate;
4
+ exports.enableTypescript = enableTypescript;
5
+ exports.isTypescriptEnabled = isTypescriptEnabled;
4
6
  const path_1 = require("path");
5
7
  const mem_fs_1 = require("mem-fs");
6
8
  const mem_fs_editor_1 = require("mem-fs-editor");
@@ -54,6 +56,8 @@ async function generate(basePath, ui5AppConfig, fs) {
54
56
  });
55
57
  ui5Config.addFioriToolsAppReloadMiddleware();
56
58
  if (isEdmxProjectType) {
59
+ // add preview middleware to ui5Config
60
+ ui5Config.addFioriToolsPreviewMiddleware(ui5App.app.id, ui5App.ui5?.ui5Theme);
57
61
  const ui5LocalConfigPath = (0, path_1.join)(basePath, 'ui5-local.yaml');
58
62
  // write ui5-local.yaml only for non-CAP applications
59
63
  const ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(ui5LocalConfigPath));
@@ -61,6 +65,8 @@ async function generate(basePath, ui5AppConfig, fs) {
61
65
  ui5LocalConfig.addFioriToolsAppReloadMiddleware();
62
66
  // Add optional features
63
67
  await (0, options_1.applyOptionalFeatures)(ui5App, fs, basePath, tmplPath, [ui5Config, ui5LocalConfig]);
68
+ // add preview middleware to ui5LocalConfig
69
+ ui5LocalConfig.addFioriToolsPreviewMiddleware(ui5App.app.id, ui5App.ui5?.ui5Theme);
64
70
  // write ui5 local yaml
65
71
  fs.write(ui5LocalConfigPath, ui5LocalConfig.toString());
66
72
  }
@@ -72,7 +78,6 @@ async function generate(basePath, ui5AppConfig, fs) {
72
78
  fs.write(ui5ConfigPath, ui5Config.toString());
73
79
  return fs;
74
80
  }
75
- exports.generate = generate;
76
81
  /**
77
82
  * Check if Typescript is enabled for the given path.
78
83
  *
@@ -94,7 +99,6 @@ async function isTypescriptEnabled(basePath, fs) {
94
99
  }
95
100
  return true;
96
101
  }
97
- exports.isTypescriptEnabled = isTypescriptEnabled;
98
102
  /**
99
103
  * Enable typescript in an existing valid UI5 project.
100
104
  *
@@ -131,5 +135,4 @@ async function enableTypescript(basePath, fs) {
131
135
  fs.write(ui5ConfigPath, ui5Config.toString());
132
136
  return fs;
133
137
  }
134
- exports.enableTypescript = enableTypescript;
135
138
  //# sourceMappingURL=index.js.map
package/dist/options.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTemplateOptions = exports.applyOptionalFeatures = exports.enableNpmPackageConsumption = exports.enableTypescript = void 0;
3
+ exports.enableTypescript = enableTypescript;
4
+ exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
5
+ exports.applyOptionalFeatures = applyOptionalFeatures;
6
+ exports.getTemplateOptions = getTemplateOptions;
4
7
  const path_1 = require("path");
5
8
  const ejs_1 = require("ejs");
6
9
  const project_access_1 = require("@sap-ux/project-access");
@@ -72,7 +75,6 @@ async function enableTypescript(input, keepOldComponent = false) {
72
75
  input.fs.delete(compPath);
73
76
  }
74
77
  }
75
- exports.enableTypescript = enableTypescript;
76
78
  /**
77
79
  * Enable npm module import for the given input.
78
80
  *
@@ -85,7 +87,6 @@ async function enableNpmPackageConsumption(input) {
85
87
  ui5Config.addCustomTasks([ui5Libs_1.ui5NPMSupport.task]);
86
88
  });
87
89
  }
88
- exports.enableNpmPackageConsumption = enableNpmPackageConsumption;
89
90
  /**
90
91
  * Check if the ui5 app config requires optional features to be enabled and if yes, enable them.
91
92
  *
@@ -104,7 +105,6 @@ async function applyOptionalFeatures(ui5App, fs, basePath, tmplPath, ui5Configs)
104
105
  }
105
106
  }
106
107
  }
107
- exports.applyOptionalFeatures = applyOptionalFeatures;
108
108
  /**
109
109
  * Generates the resource URL based on the project type and ui5 framework details.
110
110
  *
@@ -129,5 +129,4 @@ function getTemplateOptions(isEdmxProjectType, frameworkUrl, version) {
129
129
  return url;
130
130
  }
131
131
  }
132
- exports.getTemplateOptions = getTemplateOptions;
133
132
  //# sourceMappingURL=options.js.map
package/dist/types.d.ts CHANGED
@@ -1,15 +1,4 @@
1
- import type { ProjectType } from '@sap-ux/project-access';
2
- export interface Package {
3
- name: string;
4
- version?: string;
5
- description?: string;
6
- scripts?: Record<string, string>;
7
- dependencies?: Record<string, string>;
8
- devDependencies?: Record<string, string>;
9
- ui5?: {
10
- dependencies?: string[];
11
- };
12
- }
1
+ import type { ProjectType, Package } from '@sap-ux/project-access';
13
2
  export interface App {
14
3
  id: string;
15
4
  /**
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": "1.1.6",
12
+ "version": "1.2.1",
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.24.1"
30
+ "@sap-ux/ui5-config": "0.25.0"
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.26.9"
41
+ "@sap-ux/project-access": "1.28.2"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=18.x"
@@ -9,6 +9,9 @@
9
9
  ],
10
10
  "main": "webapp/index.html",
11
11
  "dependencies": {},
12
- "devDependencies": <%- JSON.stringify(package.devDependencies, null, 8) -%>,
13
- "scripts": <%- JSON.stringify(package.scripts, null, 4) -%>
14
- }
12
+ "devDependencies": <%- JSON.stringify(package.devDependencies, null, 8).trim() -%>,
13
+ "scripts": <%- JSON.stringify(package.scripts, null, 4).trim() -%>
14
+ <% if (package.sapuxLayer) { %>
15
+ ,"sapuxLayer": "<%= package.sapuxLayer %>"
16
+ <% } %>
17
+ }