@sap-ux/ui5-library-sub-generator 0.2.7 → 1.0.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/generators/app/defaults.js +6 -9
- package/generators/app/index.d.ts +1 -1
- package/generators/app/index.js +37 -43
- package/generators/app/types.js +1 -2
- package/generators/utils/constants.js +3 -6
- package/generators/utils/eventHook.js +6 -13
- package/generators/utils/i18n.js +8 -17
- package/generators/utils/index.d.ts +3 -3
- package/generators/utils/index.js +3 -23
- package/generators/utils/logger.js +4 -7
- package/package.json +12 -10
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultAuthor = exports.defaultUi5Version = exports.defaultFramework = exports.defaultNamespace = exports.defaultLibraryName = void 0;
|
|
4
|
-
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
1
|
+
import { minUI5VersionForLocalDev } from '@sap-ux/ui5-info';
|
|
5
2
|
// Default values for the UI5 library writer
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
export const defaultLibraryName = 'library1';
|
|
4
|
+
export const defaultNamespace = 'com.myorg';
|
|
5
|
+
export const defaultFramework = 'SAPUI5';
|
|
6
|
+
export const defaultUi5Version = minUI5VersionForLocalDev;
|
|
7
|
+
export const defaultAuthor = 'Fiori tools';
|
|
11
8
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Generator from 'yeoman-generator';
|
|
2
2
|
import { AppWizard, Prompts } from '@sap-devx/yeoman-ui-types';
|
|
3
3
|
import { type UI5LibraryAnswers } from '@sap-ux/ui5-library-inquirer';
|
|
4
|
-
import type { Ui5LibGenerator } from './types';
|
|
4
|
+
import type { Ui5LibGenerator } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Generator for creating a new UI5 library.
|
|
7
7
|
*
|
package/generators/app/index.js
CHANGED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
|
|
14
|
-
const defaults_1 = require("./defaults");
|
|
15
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
16
|
-
const ui5_library_writer_1 = require("@sap-ux/ui5-library-writer");
|
|
17
|
-
const ui5_library_inquirer_1 = require("@sap-ux/ui5-library-inquirer");
|
|
1
|
+
import Generator from 'yeoman-generator';
|
|
2
|
+
import { AppWizard, Prompts } from '@sap-devx/yeoman-ui-types';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import ReuseLibGenLogger from '../utils/logger.js';
|
|
5
|
+
import { t, prompts, runPostLibGenHook, generatorTitle } from '../utils/index.js';
|
|
6
|
+
import { writeApplicationInfoSettings } from '@sap-ux/fiori-tools-settings';
|
|
7
|
+
import { platform } from 'node:os';
|
|
8
|
+
import { CommandRunner } from '@sap-ux/nodejs-utils';
|
|
9
|
+
import { defaultAuthor, defaultFramework, defaultLibraryName, defaultNamespace, defaultUi5Version } from './defaults.js';
|
|
10
|
+
import { isCli, getDefaultTargetFolder } from '@sap-ux/fiori-generator-shared';
|
|
11
|
+
import { generate } from '@sap-ux/ui5-library-writer';
|
|
12
|
+
import { prompt } from '@sap-ux/ui5-library-inquirer';
|
|
18
13
|
/**
|
|
19
14
|
* Generator for creating a new UI5 library.
|
|
20
15
|
*
|
|
21
16
|
* @extends Generator
|
|
22
17
|
*/
|
|
23
|
-
class
|
|
18
|
+
export default class extends Generator {
|
|
24
19
|
answers = {};
|
|
25
20
|
prompts;
|
|
26
21
|
appWizard;
|
|
@@ -36,12 +31,12 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
36
31
|
*/
|
|
37
32
|
constructor(args, opts) {
|
|
38
33
|
super(args, opts);
|
|
39
|
-
this.appWizard =
|
|
34
|
+
this.appWizard = AppWizard.create(opts);
|
|
40
35
|
this.vscode = opts.vscode;
|
|
41
|
-
|
|
42
|
-
this.targetFolder =
|
|
43
|
-
this.appWizard.setHeaderTitle(
|
|
44
|
-
this.prompts = new
|
|
36
|
+
ReuseLibGenLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel);
|
|
37
|
+
this.targetFolder = getDefaultTargetFolder(this.options.vscode) ?? process.cwd();
|
|
38
|
+
this.appWizard.setHeaderTitle(generatorTitle);
|
|
39
|
+
this.prompts = new Prompts(prompts);
|
|
45
40
|
this.setPromptsCallback = (fn) => {
|
|
46
41
|
if (this.prompts) {
|
|
47
42
|
this.prompts.setCallback(fn);
|
|
@@ -49,7 +44,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
49
44
|
};
|
|
50
45
|
}
|
|
51
46
|
async prompting() {
|
|
52
|
-
const promptCli =
|
|
47
|
+
const promptCli = isCli();
|
|
53
48
|
let inquirerAdaptor;
|
|
54
49
|
if (this.env?.adapter?.actualAdapter) {
|
|
55
50
|
inquirerAdaptor = this.env.adapter.actualAdapter;
|
|
@@ -57,7 +52,7 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
57
52
|
else {
|
|
58
53
|
inquirerAdaptor = this.env?.adapter;
|
|
59
54
|
}
|
|
60
|
-
const answers = await
|
|
55
|
+
const answers = await prompt({
|
|
61
56
|
targetFolder: this.targetFolder,
|
|
62
57
|
includeSeparators: !promptCli,
|
|
63
58
|
useAutocomplete: promptCli
|
|
@@ -66,47 +61,46 @@ class default_1 extends yeoman_generator_1.default {
|
|
|
66
61
|
}
|
|
67
62
|
async writing() {
|
|
68
63
|
const ui5Lib = {
|
|
69
|
-
libraryName: this.answers.libraryName ??
|
|
70
|
-
namespace: this.answers.namespace ??
|
|
71
|
-
framework:
|
|
72
|
-
frameworkVersion: this.answers.ui5Version ??
|
|
73
|
-
author:
|
|
64
|
+
libraryName: this.answers.libraryName ?? defaultLibraryName,
|
|
65
|
+
namespace: this.answers.namespace ?? defaultNamespace,
|
|
66
|
+
framework: defaultFramework,
|
|
67
|
+
frameworkVersion: this.answers.ui5Version ?? defaultUi5Version,
|
|
68
|
+
author: defaultAuthor,
|
|
74
69
|
typescript: this.answers.enableTypescript
|
|
75
70
|
};
|
|
76
71
|
if (this.answers.targetFolder) {
|
|
77
72
|
this.targetFolder = this.answers.targetFolder;
|
|
78
|
-
this.projectPath =
|
|
73
|
+
this.projectPath = join(this.targetFolder, `${this.answers.namespace}.${this.answers.libraryName}`);
|
|
79
74
|
}
|
|
80
75
|
try {
|
|
81
|
-
await
|
|
82
|
-
|
|
76
|
+
await generate(this.targetFolder, ui5Lib, this.fs);
|
|
77
|
+
writeApplicationInfoSettings(this.projectPath);
|
|
83
78
|
}
|
|
84
79
|
catch (e) {
|
|
85
|
-
|
|
86
|
-
throw new Error(
|
|
80
|
+
ReuseLibGenLogger.logger.error(e);
|
|
81
|
+
throw new Error(t('error.generatingUi5Lib'));
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
async install() {
|
|
90
85
|
if (!this.options.skipInstall) {
|
|
91
86
|
try {
|
|
92
|
-
const runner = new
|
|
93
|
-
const npm =
|
|
94
|
-
|
|
87
|
+
const runner = new CommandRunner();
|
|
88
|
+
const npm = platform() === 'win32' ? 'npm.cmd' : 'npm';
|
|
89
|
+
ReuseLibGenLogger.logger.info(t('info.installingDependencies'));
|
|
95
90
|
await runner.run(npm, ['install'], { cwd: this.projectPath });
|
|
96
|
-
|
|
91
|
+
ReuseLibGenLogger.logger.info(t('info.dependenciesInstalled'));
|
|
97
92
|
}
|
|
98
93
|
catch (error) {
|
|
99
|
-
|
|
94
|
+
ReuseLibGenLogger.logger.error(error || t('error.unknown'));
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
}
|
|
103
98
|
async end() {
|
|
104
|
-
|
|
105
|
-
await
|
|
99
|
+
ReuseLibGenLogger.logger.info(t('info.openingAppInfo'));
|
|
100
|
+
await runPostLibGenHook({
|
|
106
101
|
path: this.projectPath,
|
|
107
102
|
vscodeInstance: this.vscode
|
|
108
103
|
});
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
|
-
exports.default = default_1;
|
|
112
106
|
//# sourceMappingURL=index.js.map
|
package/generators/app/types.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.UI5_LIB_GEN = 'UI5_LIB_GEN';
|
|
5
|
-
exports.generatorTitle = 'SAP Fiori Reusable Library';
|
|
6
|
-
exports.prompts = [
|
|
1
|
+
export const UI5_LIB_GEN = 'UI5_LIB_GEN';
|
|
2
|
+
export const generatorTitle = 'SAP Fiori Reusable Library';
|
|
3
|
+
export const prompts = [
|
|
7
4
|
{
|
|
8
5
|
name: 'Generate UI5 Library',
|
|
9
6
|
description: 'Create a Reusable Library for use in SAP Fiori applications'
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.POST_LIB_GEN_COMMAND = void 0;
|
|
7
|
-
exports.runPostLibGenHook = runPostLibGenHook;
|
|
8
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
9
|
-
const i18n_1 = require("./i18n");
|
|
10
|
-
exports.POST_LIB_GEN_COMMAND = 'sap.ux.library.generated.handler';
|
|
1
|
+
import ReuseLibGenLogger from './logger.js';
|
|
2
|
+
import { t } from './i18n.js';
|
|
3
|
+
export const POST_LIB_GEN_COMMAND = 'sap.ux.library.generated.handler';
|
|
11
4
|
/**
|
|
12
5
|
* Executes post library generation command : 'sap.ux.library.generated.handler'.
|
|
13
6
|
*
|
|
14
7
|
* @param context LibContext
|
|
15
8
|
*/
|
|
16
|
-
async function runPostLibGenHook(context) {
|
|
9
|
+
export async function runPostLibGenHook(context) {
|
|
17
10
|
try {
|
|
18
|
-
await context.vscodeInstance?.commands?.executeCommand?.(
|
|
11
|
+
await context.vscodeInstance?.commands?.executeCommand?.(POST_LIB_GEN_COMMAND, {
|
|
19
12
|
fsPath: context.path
|
|
20
13
|
});
|
|
21
14
|
}
|
|
22
15
|
catch (e) {
|
|
23
|
-
|
|
16
|
+
ReuseLibGenLogger.logger.error(t('error.postLibGenHook', { error: e }));
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
19
|
//# sourceMappingURL=eventHook.js.map
|
package/generators/utils/i18n.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.i18n = void 0;
|
|
7
|
-
exports.t = t;
|
|
8
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
9
|
-
const ui5_lib_generator_i18n_json_1 = __importDefault(require("../translations/ui5-lib-generator.i18n.json"));
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
import translations from '../translations/ui5-lib-generator.i18n.json' with { type: 'json' };
|
|
10
3
|
const ui5LibGeneratorNs = 'ui5-lib-generator';
|
|
11
|
-
|
|
4
|
+
export const i18n = i18next.createInstance();
|
|
12
5
|
/**
|
|
13
6
|
* Initialize i18next with the translations for this module.
|
|
14
7
|
*/
|
|
15
8
|
async function initI18n() {
|
|
16
|
-
await
|
|
9
|
+
await i18n.init({
|
|
17
10
|
lng: 'en',
|
|
18
11
|
fallbackLng: 'en',
|
|
19
12
|
showSupportNotice: false
|
|
20
13
|
});
|
|
21
|
-
|
|
14
|
+
i18n.addResourceBundle('en', ui5LibGeneratorNs, translations);
|
|
22
15
|
}
|
|
23
16
|
/**
|
|
24
17
|
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
|
@@ -27,13 +20,11 @@ async function initI18n() {
|
|
|
27
20
|
* @param options additional options
|
|
28
21
|
* @returns {string} localized string stored for the given key
|
|
29
22
|
*/
|
|
30
|
-
function t(key, options) {
|
|
23
|
+
export function t(key, options) {
|
|
31
24
|
if (!options?.ns) {
|
|
32
25
|
options = Object.assign(options ?? {}, { ns: ui5LibGeneratorNs });
|
|
33
26
|
}
|
|
34
|
-
return
|
|
27
|
+
return i18n.t(key, options);
|
|
35
28
|
}
|
|
36
|
-
initI18n().catch(() =>
|
|
37
|
-
// Needed for lint
|
|
38
|
-
});
|
|
29
|
+
void initI18n().catch(() => undefined);
|
|
39
30
|
//# sourceMappingURL=i18n.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './i18n';
|
|
2
|
-
export { prompts, generatorTitle } from './constants';
|
|
3
|
-
export { runPostLibGenHook } from './eventHook';
|
|
1
|
+
export * from './i18n.js';
|
|
2
|
+
export { prompts, generatorTitle } from './constants.js';
|
|
3
|
+
export { runPostLibGenHook } from './eventHook.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.runPostLibGenHook = exports.generatorTitle = exports.prompts = void 0;
|
|
18
|
-
__exportStar(require("./i18n"), exports);
|
|
19
|
-
var constants_1 = require("./constants");
|
|
20
|
-
Object.defineProperty(exports, "prompts", { enumerable: true, get: function () { return constants_1.prompts; } });
|
|
21
|
-
Object.defineProperty(exports, "generatorTitle", { enumerable: true, get: function () { return constants_1.generatorTitle; } });
|
|
22
|
-
var eventHook_1 = require("./eventHook");
|
|
23
|
-
Object.defineProperty(exports, "runPostLibGenHook", { enumerable: true, get: function () { return eventHook_1.runPostLibGenHook; } });
|
|
1
|
+
export * from './i18n.js';
|
|
2
|
+
export { prompts, generatorTitle } from './constants.js';
|
|
3
|
+
export { runPostLibGenHook } from './eventHook.js';
|
|
24
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
1
|
+
import { DefaultLogger, LogWrapper } from '@sap-ux/fiori-generator-shared';
|
|
4
2
|
/**
|
|
5
3
|
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
6
4
|
*/
|
|
7
|
-
class ReuseLibGenLogger {
|
|
8
|
-
static _logger =
|
|
5
|
+
export default class ReuseLibGenLogger {
|
|
6
|
+
static _logger = DefaultLogger;
|
|
9
7
|
/**
|
|
10
8
|
* Get the logger.
|
|
11
9
|
*
|
|
@@ -32,9 +30,8 @@ class ReuseLibGenLogger {
|
|
|
32
30
|
* @param logLevel - the log level
|
|
33
31
|
*/
|
|
34
32
|
static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel) {
|
|
35
|
-
const logWrapper = new
|
|
33
|
+
const logWrapper = new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
|
|
36
34
|
ReuseLibGenLogger.logger = logWrapper;
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
exports.default = ReuseLibGenLogger;
|
|
40
37
|
//# sourceMappingURL=logger.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-library-sub-generator",
|
|
3
3
|
"description": "Generator for creating UI5 libraries",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"main": "generators/app/index.js",
|
|
15
16
|
"files": [
|
|
@@ -22,14 +23,15 @@
|
|
|
22
23
|
"@sap-devx/yeoman-ui-types": "1.25.0",
|
|
23
24
|
"i18next": "25.10.10",
|
|
24
25
|
"yeoman-generator": "5.10.0",
|
|
25
|
-
"@sap-ux/fiori-
|
|
26
|
-
"@sap-ux/fiori-
|
|
27
|
-
"@sap-ux/ui5-
|
|
28
|
-
"@sap-ux/
|
|
29
|
-
"@sap-ux/
|
|
30
|
-
"@sap-ux/ui5-library-writer": "0.
|
|
26
|
+
"@sap-ux/fiori-tools-settings": "1.0.0",
|
|
27
|
+
"@sap-ux/fiori-generator-shared": "1.0.1",
|
|
28
|
+
"@sap-ux/ui5-info": "1.0.0",
|
|
29
|
+
"@sap-ux/ui5-library-inquirer": "1.0.1",
|
|
30
|
+
"@sap-ux/nodejs-utils": "1.0.0",
|
|
31
|
+
"@sap-ux/ui5-library-writer": "1.0.1"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
34
|
+
"@jest/globals": "30.3.0",
|
|
33
35
|
"@jest/types": "30.3.0",
|
|
34
36
|
"@types/mem-fs-editor": "7.0.1",
|
|
35
37
|
"@types/yeoman-environment": "2.10.11",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"mem-fs-editor": "9.4.0",
|
|
41
43
|
"rimraf": "6.1.3",
|
|
42
44
|
"yeoman-test": "6.3.0",
|
|
43
|
-
"@sap-ux/jest-file-matchers": "0.
|
|
45
|
+
"@sap-ux/jest-file-matchers": "1.0.0"
|
|
44
46
|
},
|
|
45
47
|
"engines": {
|
|
46
48
|
"node": ">=22.x"
|
|
@@ -51,8 +53,8 @@
|
|
|
51
53
|
"watch": "tsc --watch",
|
|
52
54
|
"lint": "eslint",
|
|
53
55
|
"lint:fix": "eslint --fix",
|
|
54
|
-
"test": "jest --ci --forceExit --detectOpenHandles --colors",
|
|
55
|
-
"test-u": "jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
56
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors",
|
|
57
|
+
"test-u": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",
|
|
56
58
|
"link": "pnpm link --global",
|
|
57
59
|
"unlink": "pnpm unlink --global"
|
|
58
60
|
}
|