@sap-ux/ui5-library-writer 0.3.50 → 0.4.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/data/index.js +10 -4
- package/dist/i18n.js +11 -22
- package/dist/index.js +19 -30
- package/dist/options/typescript.js +55 -62
- package/package.json +5 -5
package/dist/data/index.js
CHANGED
|
@@ -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 =
|
|
16
|
-
const libInput =
|
|
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
|
-
|
|
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_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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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.
|
|
12
|
+
"version": "0.4.1",
|
|
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.
|
|
33
|
-
"@sap-ux/ui5-application-writer": "0.
|
|
34
|
-
"@sap-ux/ui5-config": "0.
|
|
32
|
+
"@sap-ux/project-access": "1.24.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.
|
|
44
|
+
"@sap-ux/eslint-plugin-fiori-tools": "0.5.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsc --build",
|