@sap-ux/ui5-library-writer 0.3.50 → 0.4.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.
@@ -9,14 +9,20 @@ const validators_1 = require("./validators");
9
9
  * @returns {UI5LibInput} - a new UI5LibInput instance with all required defaults set
10
10
  */
11
11
  function mergeWithDefaults(libConfig) {
12
- var _a;
13
12
  (0, validators_1.validate)(libConfig);
14
13
  const libraryNamespace = `${libConfig.namespace}.${libConfig.libraryName}`;
15
- const author = (_a = libConfig.author) !== null && _a !== void 0 ? _a : 'UX Tools';
16
- const libInput = Object.assign(Object.assign({}, libConfig), { author, namespaceURI: libConfig.namespace.split('.').join('/'), libraryNamespace, libraryNamespaceURI: libraryNamespace.split('.').join('/'), libraryBasepath: libraryNamespace
14
+ const author = libConfig.author ?? 'UX Tools';
15
+ const libInput = {
16
+ ...libConfig,
17
+ author,
18
+ namespaceURI: libConfig.namespace.split('.').join('/'),
19
+ libraryNamespace,
20
+ libraryNamespaceURI: libraryNamespace.split('.').join('/'),
21
+ libraryBasepath: libraryNamespace
17
22
  .split('.')
18
23
  .map((_) => '..')
19
- .join('/') + '/' });
24
+ .join('/') + '/'
25
+ };
20
26
  return libInput;
21
27
  }
22
28
  exports.mergeWithDefaults = mergeWithDefaults;
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-library-writer';
19
10
  /**
20
11
  * Initialize i18next with the translations for this module.
21
12
  */
22
- function initI18n() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- yield i18next_1.default.init({
25
- resources: {
26
- en: {
27
- [NS]: ui5_library_writer_i18n_json_1.default
28
- }
29
- },
30
- lng: 'en',
31
- fallbackLng: 'en',
32
- defaultNS: NS,
33
- ns: [NS]
34
- });
13
+ async function initI18n() {
14
+ await i18next_1.default.init({
15
+ resources: {
16
+ en: {
17
+ [NS]: ui5_library_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
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -27,28 +18,26 @@ const data_1 = require("./data");
27
18
  * @param fs - the memfs editor instance
28
19
  * @returns the updated memfs editor instance
29
20
  */
30
- function generate(basePath, ui5LibConfig, fs) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const reuseLib = (0, cloneDeep_1.default)(ui5LibConfig);
33
- if (!fs) {
34
- fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
35
- }
36
- const libInput = (0, data_1.mergeWithDefaults)(ui5LibConfig);
37
- basePath = (0, path_1.join)(basePath, libInput.libraryNamespace);
38
- const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
39
- const ignore = [reuseLib.typescript ? '**/*.js' : '**/*.ts'];
40
- fs.copyTpl((0, path_1.join)(tmplPath, 'common', '**/*.*'), basePath, libInput, undefined, {
41
- globOptions: { dot: true, ignore },
42
- processDestinationPath: (filePath) => filePath
43
- .replace('baselibrary', libInput.libraryNamespaceURI)
44
- .replace(/gitignore.tmpl/g, '.gitignore')
45
- .replace(/karma.conf.tmpl/g, 'karma.conf.js')
46
- });
47
- if (reuseLib.typescript) {
48
- yield (0, options_1.enableTypescript)(libInput, basePath, tmplPath, fs);
49
- }
50
- return fs;
21
+ async function generate(basePath, ui5LibConfig, fs) {
22
+ const reuseLib = (0, cloneDeep_1.default)(ui5LibConfig);
23
+ if (!fs) {
24
+ fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
25
+ }
26
+ const libInput = (0, data_1.mergeWithDefaults)(ui5LibConfig);
27
+ basePath = (0, path_1.join)(basePath, libInput.libraryNamespace);
28
+ const tmplPath = (0, path_1.join)(__dirname, '..', 'templates');
29
+ const ignore = [reuseLib.typescript ? '**/*.js' : '**/*.ts'];
30
+ fs.copyTpl((0, path_1.join)(tmplPath, 'common', '**/*.*'), basePath, libInput, undefined, {
31
+ globOptions: { dot: true, ignore },
32
+ processDestinationPath: (filePath) => filePath
33
+ .replace('baselibrary', libInput.libraryNamespaceURI)
34
+ .replace(/gitignore.tmpl/g, '.gitignore')
35
+ .replace(/karma.conf.tmpl/g, 'karma.conf.js')
51
36
  });
37
+ if (reuseLib.typescript) {
38
+ await (0, options_1.enableTypescript)(libInput, basePath, tmplPath, fs);
39
+ }
40
+ return fs;
52
41
  }
53
42
  exports.generate = generate;
54
43
  //# sourceMappingURL=index.js.map
@@ -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.enableTypescript = void 0;
13
4
  const ejs_1 = require("ejs");
@@ -23,65 +14,67 @@ const semver_1 = require("semver");
23
14
  * @param tmplPath - the template path
24
15
  * @param fs - the memfs editor instance
25
16
  */
26
- function enableTypescript(libInput, basePath, tmplPath, fs) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const tsTmplDirPath = (0, path_1.join)(tmplPath, 'optional', 'typescript');
29
- const tsTmplFilePaths = yield (0, project_access_1.getFilePaths)(tsTmplDirPath);
30
- const tsLibInput = Object.assign(Object.assign({}, libInput), { tsTypes: getTypePackageFor(libInput.framework, libInput.frameworkVersion), tsTypesVersion: libInput.frameworkVersion });
31
- tsTmplFilePaths.forEach((tsTmplFilePath) => {
32
- const relPath = tsTmplFilePath.replace(tsTmplDirPath, '');
33
- const outPath = (0, path_1.join)(basePath, relPath);
34
- // Extend or add
35
- if (!fs.exists(outPath)) {
36
- fs.copyTpl(tsTmplFilePath, outPath, tsLibInput, undefined, {
37
- globOptions: { dot: true }
38
- });
39
- }
40
- else {
41
- const add = JSON.parse((0, ejs_1.render)(fs.read(tsTmplFilePath), tsLibInput, {}));
42
- const existingFile = JSON.parse(fs.read(outPath));
43
- const merged = (0, ui5_config_1.mergeObjects)(existingFile, add);
44
- fs.writeJSON(outPath, merged);
45
- }
46
- });
47
- // ui5 yaml
48
- const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
49
- const ui5Config = yield ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
50
- ui5Config.updateCustomMiddleware({
51
- name: 'fiori-tools-appreload',
52
- afterMiddleware: 'compression',
53
- configuration: {
54
- path: 'src',
55
- port: 35729,
56
- delay: 300
57
- }
58
- });
59
- ui5Config.updateCustomMiddleware({
60
- name: 'ui5-tooling-transpile-middleware',
61
- afterMiddleware: 'compression',
17
+ async function enableTypescript(libInput, basePath, tmplPath, fs) {
18
+ const tsTmplDirPath = (0, path_1.join)(tmplPath, 'optional', 'typescript');
19
+ const tsTmplFilePaths = await (0, project_access_1.getFilePaths)(tsTmplDirPath);
20
+ const tsLibInput = {
21
+ ...libInput,
22
+ tsTypes: getTypePackageFor(libInput.framework, libInput.frameworkVersion),
23
+ tsTypesVersion: libInput.frameworkVersion
24
+ };
25
+ tsTmplFilePaths.forEach((tsTmplFilePath) => {
26
+ const relPath = tsTmplFilePath.replace(tsTmplDirPath, '');
27
+ const outPath = (0, path_1.join)(basePath, relPath);
28
+ // Extend or add
29
+ if (!fs.exists(outPath)) {
30
+ fs.copyTpl(tsTmplFilePath, outPath, tsLibInput, undefined, {
31
+ globOptions: { dot: true }
32
+ });
33
+ }
34
+ else {
35
+ const add = JSON.parse((0, ejs_1.render)(fs.read(tsTmplFilePath), tsLibInput, {}));
36
+ const existingFile = JSON.parse(fs.read(outPath));
37
+ const merged = (0, ui5_config_1.mergeObjects)(existingFile, add);
38
+ fs.writeJSON(outPath, merged);
39
+ }
40
+ });
41
+ // ui5 yaml
42
+ const ui5ConfigPath = (0, path_1.join)(basePath, 'ui5.yaml');
43
+ const ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(ui5ConfigPath));
44
+ ui5Config.updateCustomMiddleware({
45
+ name: 'fiori-tools-appreload',
46
+ afterMiddleware: 'compression',
47
+ configuration: {
48
+ path: 'src',
49
+ port: 35729,
50
+ delay: 300
51
+ }
52
+ });
53
+ ui5Config.updateCustomMiddleware({
54
+ name: 'ui5-tooling-transpile-middleware',
55
+ afterMiddleware: 'compression',
56
+ configuration: {
57
+ debug: true,
58
+ transformModulesToUI5: {
59
+ overridesToOverride: true
60
+ },
61
+ excludePatterns: ['/Component-preload.js']
62
+ }
63
+ });
64
+ ui5Config.addCustomTasks([
65
+ {
66
+ name: 'ui5-tooling-transpile-task',
67
+ afterTask: 'replaceVersion',
62
68
  configuration: {
63
69
  debug: true,
64
70
  transformModulesToUI5: {
65
71
  overridesToOverride: true
66
- },
67
- excludePatterns: ['/Component-preload.js']
68
- }
69
- });
70
- ui5Config.addCustomTasks([
71
- {
72
- name: 'ui5-tooling-transpile-task',
73
- afterTask: 'replaceVersion',
74
- configuration: {
75
- debug: true,
76
- transformModulesToUI5: {
77
- overridesToOverride: true
78
- }
79
72
  }
80
73
  }
81
- ]);
82
- // write ts ui5 yaml
83
- fs.write(ui5ConfigPath, ui5Config.toString());
84
- });
74
+ }
75
+ ]);
76
+ // write ts ui5 yaml
77
+ fs.write(ui5ConfigPath, ui5Config.toString());
85
78
  }
86
79
  exports.enableTypescript = enableTypescript;
87
80
  /**
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-library-writer"
11
11
  },
12
- "version": "0.3.50",
12
+ "version": "0.4.0",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -29,9 +29,9 @@
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "semver": "7.5.4",
32
- "@sap-ux/project-access": "1.22.4",
33
- "@sap-ux/ui5-application-writer": "0.26.18",
34
- "@sap-ux/ui5-config": "0.22.10"
32
+ "@sap-ux/project-access": "1.23.0",
33
+ "@sap-ux/ui5-application-writer": "0.27.0",
34
+ "@sap-ux/ui5-config": "0.23.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/ejs": "3.1.2",
@@ -41,7 +41,7 @@
41
41
  "@types/mem-fs": "1.1.2",
42
42
  "fs-extra": "10.0.0",
43
43
  "@types/semver": "7.5.2",
44
- "@sap-ux/eslint-plugin-fiori-tools": "0.4.2"
44
+ "@sap-ux/eslint-plugin-fiori-tools": "0.5.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc --build",