@sap-ux/ui5-library-reference-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.
@@ -1,6 +1,6 @@
1
1
  import Generator from 'yeoman-generator';
2
2
  import { Prompts, AppWizard } from '@sap-devx/yeoman-ui-types';
3
- import type { UI5ReferenceLibGenerator } from './types';
3
+ import type { UI5ReferenceLibGenerator } from './types.js';
4
4
  import type { UI5LibraryReferenceAnswers } from '@sap-ux/ui5-library-reference-inquirer';
5
5
  /**
6
6
  * Generator for adding a UI5 library reference to a Fiori application.
@@ -1,25 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const yeoman_generator_1 = __importDefault(require("yeoman-generator"));
7
- const logger_1 = __importDefault(require("../utils/logger"));
8
- const constants_1 = require("../utils/constants");
9
- const vscode_1 = require("vscode");
10
- const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
11
- const ui5_library_reference_writer_1 = require("@sap-ux/ui5-library-reference-writer");
12
- const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
13
- const feature_toggle_1 = require("@sap-ux/feature-toggle");
14
- const ui5_library_reference_inquirer_1 = require("@sap-ux/ui5-library-reference-inquirer");
15
- const i18n_1 = require("../utils/i18n");
16
- const telemetryEvents_1 = require("../telemetryEvents");
1
+ import Generator from 'yeoman-generator';
2
+ import ReferenceLibGenLogger from '../utils/logger.js';
3
+ import { generatorTitle, prompts } from '../utils/constants.js';
4
+ import { workspace } from 'vscode';
5
+ import { Prompts, AppWizard, MessageType } from '@sap-devx/yeoman-ui-types';
6
+ import { generate } from '@sap-ux/ui5-library-reference-writer';
7
+ import { isExtensionInstalled, sendTelemetry, setYeomanEnvConflicterForce, TelemetryHelper, YUI_EXTENSION_ID, YUI_MIN_VER_FILES_GENERATED_MSG } from '@sap-ux/fiori-generator-shared';
8
+ import { isInternalFeaturesSettingEnabled } from '@sap-ux/feature-toggle';
9
+ import { prompt } from '@sap-ux/ui5-library-reference-inquirer';
10
+ import { t } from '../utils/i18n.js';
11
+ import { EventName } from '../telemetryEvents/index.js';
17
12
  /**
18
13
  * Generator for adding a UI5 library reference to a Fiori application.
19
14
  *
20
15
  * @extends Generator
21
16
  */
22
- class default_1 extends yeoman_generator_1.default {
17
+ export default class extends Generator {
23
18
  answers = {};
24
19
  prompts;
25
20
  appWizard;
@@ -34,11 +29,11 @@ class default_1 extends yeoman_generator_1.default {
34
29
  */
35
30
  constructor(args, opts) {
36
31
  super(args, opts);
37
- this.appWizard = opts.appWizard || yeoman_ui_types_1.AppWizard.create(opts);
32
+ this.appWizard = opts.appWizard || AppWizard.create(opts);
38
33
  this.vscode = opts.vscode;
39
- logger_1.default.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel);
40
- this.appWizard.setHeaderTitle(constants_1.generatorTitle);
41
- this.prompts = new yeoman_ui_types_1.Prompts(constants_1.prompts);
34
+ ReferenceLibGenLogger.configureLogging(this.options.logger, this.rootGeneratorName(), this.log, this.options.vscode, this.options.logLevel);
35
+ this.appWizard.setHeaderTitle(generatorTitle);
36
+ this.prompts = new Prompts(prompts);
42
37
  this.setPromptsCallback = (fn) => {
43
38
  if (this.prompts) {
44
39
  this.prompts.setCallback(fn);
@@ -46,15 +41,15 @@ class default_1 extends yeoman_generator_1.default {
46
41
  };
47
42
  }
48
43
  async initializing() {
49
- await fiori_generator_shared_1.TelemetryHelper.initTelemetrySettings({
44
+ await TelemetryHelper.initTelemetrySettings({
50
45
  consumerModule: {
51
46
  name: '@sap-ux/ui5-library-reference-sub-generator',
52
47
  version: this.rootGeneratorVersion()
53
48
  },
54
- internalFeature: (0, feature_toggle_1.isInternalFeaturesSettingEnabled)(),
49
+ internalFeature: isInternalFeaturesSettingEnabled(),
55
50
  watchTelemetrySettingStore: false
56
51
  });
57
- (0, fiori_generator_shared_1.setYeomanEnvConflicterForce)(this.env, true);
52
+ setYeomanEnvConflicterForce(this.env, true);
58
53
  }
59
54
  async prompting() {
60
55
  let inquirerAdaptor;
@@ -64,7 +59,7 @@ class default_1 extends yeoman_generator_1.default {
64
59
  else {
65
60
  inquirerAdaptor = this.env?.adapter;
66
61
  }
67
- const answers = await (0, ui5_library_reference_inquirer_1.prompt)(vscode_1.workspace.workspaceFolders, inquirerAdaptor);
62
+ const answers = await prompt(workspace.workspaceFolders, inquirerAdaptor);
68
63
  Object.assign(this.answers, answers);
69
64
  }
70
65
  async writing() {
@@ -81,30 +76,29 @@ class default_1 extends yeoman_generator_1.default {
81
76
  }
82
77
  try {
83
78
  if (this.answers.targetProjectFolder) {
84
- await (0, ui5_library_reference_writer_1.generate)(this.answers.targetProjectFolder, reuseLibConfigs, this.fs);
79
+ await generate(this.answers.targetProjectFolder, reuseLibConfigs, this.fs);
85
80
  }
86
81
  }
87
82
  catch (e) {
88
- logger_1.default.logger.error(e);
89
- throw new Error((0, i18n_1.t)('error.updatingApp'));
83
+ ReferenceLibGenLogger.logger.error(e);
84
+ throw new Error(t('error.updatingApp'));
90
85
  }
91
86
  }
92
87
  end() {
93
88
  try {
94
- if ((0, fiori_generator_shared_1.isExtensionInstalled)(this.vscode, fiori_generator_shared_1.YUI_EXTENSION_ID, fiori_generator_shared_1.YUI_MIN_VER_FILES_GENERATED_MSG)) {
95
- this.appWizard?.showInformation((0, i18n_1.t)('info.filesGenerated'), yeoman_ui_types_1.MessageType.notification);
89
+ if (isExtensionInstalled(this.vscode, YUI_EXTENSION_ID, YUI_MIN_VER_FILES_GENERATED_MSG)) {
90
+ this.appWizard?.showInformation(t('info.filesGenerated'), MessageType.notification);
96
91
  }
97
- const telemetryData = fiori_generator_shared_1.TelemetryHelper.createTelemetryData();
92
+ const telemetryData = TelemetryHelper.createTelemetryData();
98
93
  if (telemetryData) {
99
- (0, fiori_generator_shared_1.sendTelemetry)(telemetryEvents_1.EventName.LIB_REFERENCE_ADDED, telemetryData, this.answers.targetProjectFolder).catch((error) => {
100
- logger_1.default.logger.error((0, i18n_1.t)('error.telemetry', { error }));
94
+ sendTelemetry(EventName.LIB_REFERENCE_ADDED, telemetryData, this.answers.targetProjectFolder).catch((error) => {
95
+ ReferenceLibGenLogger.logger.error(t('error.telemetry', { error }));
101
96
  });
102
97
  }
103
98
  }
104
99
  catch (error) {
105
- logger_1.default.logger.error((0, i18n_1.t)('error.endPhase'));
100
+ ReferenceLibGenLogger.logger.error(t('error.endPhase'));
106
101
  }
107
102
  }
108
103
  }
109
- exports.default = default_1;
110
104
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventName = void 0;
4
1
  /**
5
2
  * Event names for telemetry for the reference library generator
6
3
  */
7
- var EventName;
4
+ export var EventName;
8
5
  (function (EventName) {
9
6
  EventName["LIB_REFERENCE_ADDED"] = "LIB_REFERENCE_ADDED";
10
- })(EventName || (exports.EventName = EventName = {}));
7
+ })(EventName || (EventName = {}));
11
8
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prompts = exports.generatorTitle = void 0;
4
- exports.generatorTitle = 'SAP Fiori Reusable Library';
5
- exports.prompts = [
1
+ export const generatorTitle = 'SAP Fiori Reusable Library';
2
+ export const prompts = [
6
3
  {
7
4
  name: 'Create a Reference',
8
5
  description: 'Add library reference to an SAP Fiori application'
@@ -1,25 +1,17 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.i18n = void 0;
7
- exports.initI18n = initI18n;
8
- exports.t = t;
9
- const i18next_1 = __importDefault(require("i18next"));
10
- const ui5_library_reference_sub_generator_i18n_json_1 = __importDefault(require("../translations/ui5-library-reference-sub-generator.i18n.json"));
1
+ import i18next from 'i18next';
2
+ import translations from '../translations/ui5-library-reference-sub-generator.i18n.json' with { type: 'json' };
11
3
  const ui5LibI18nNamespace = 'ui5-library-reference-sub-generator';
12
- exports.i18n = i18next_1.default.createInstance();
4
+ export const i18n = i18next.createInstance();
13
5
  /**
14
6
  * Initialize i18next with the translations for this module.
15
7
  */
16
- async function initI18n() {
17
- await exports.i18n.init({
8
+ export async function initI18n() {
9
+ await i18n.init({
18
10
  lng: 'en',
19
11
  fallbackLng: 'en',
20
12
  showSupportNotice: false
21
13
  });
22
- exports.i18n.addResourceBundle('en', ui5LibI18nNamespace, ui5_library_reference_sub_generator_i18n_json_1.default);
14
+ i18n.addResourceBundle('en', ui5LibI18nNamespace, translations);
23
15
  }
24
16
  /**
25
17
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -28,13 +20,11 @@ async function initI18n() {
28
20
  * @param options additional options
29
21
  * @returns {string} localized string stored for the given key
30
22
  */
31
- function t(key, options) {
23
+ export function t(key, options) {
32
24
  if (!options?.ns) {
33
25
  options = Object.assign(options ?? {}, { ns: ui5LibI18nNamespace });
34
26
  }
35
- return exports.i18n.t(key, options);
27
+ return i18n.t(key, options);
36
28
  }
37
- initI18n().catch(() => {
38
- // Needed for lint
39
- });
29
+ void initI18n().catch(() => undefined);
40
30
  //# sourceMappingURL=i18n.js.map
@@ -1,11 +1,9 @@
1
- "use strict";
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 ReferenceLibGenLogger {
8
- static _logger = fiori_generator_shared_1.DefaultLogger;
5
+ export default class ReferenceLibGenLogger {
6
+ static _logger = DefaultLogger;
9
7
  /**
10
8
  * Get the logger.
11
9
  *
@@ -32,9 +30,8 @@ class ReferenceLibGenLogger {
32
30
  * @param logLevel - the log level
33
31
  */
34
32
  static configureLogging(vscLogger, loggerName, yoLogger, vscode, logLevel) {
35
- const logWrapper = new fiori_generator_shared_1.LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
33
+ const logWrapper = new LogWrapper(loggerName, yoLogger, logLevel, vscLogger, vscode);
36
34
  ReferenceLibGenLogger.logger = logWrapper;
37
35
  }
38
36
  }
39
- exports.default = ReferenceLibGenLogger;
40
37
  //# sourceMappingURL=logger.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/ui5-library-reference-sub-generator",
3
3
  "description": "Generator for adding reference libraries to a project",
4
- "version": "0.2.7",
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/feature-toggle": "0.4.0",
26
- "@sap-ux/fiori-generator-shared": "0.15.6",
27
- "@sap-ux/project-access": "1.38.1",
28
- "@sap-ux/telemetry": "0.7.5",
29
- "@sap-ux/ui5-library-reference-inquirer": "0.5.7",
30
- "@sap-ux/ui5-library-reference-writer": "0.3.2"
26
+ "@sap-ux/feature-toggle": "1.0.0",
27
+ "@sap-ux/fiori-generator-shared": "1.0.1",
28
+ "@sap-ux/project-access": "2.0.1",
29
+ "@sap-ux/telemetry": "1.0.1",
30
+ "@sap-ux/ui5-library-reference-inquirer": "1.0.1",
31
+ "@sap-ux/ui5-library-reference-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/fs-extra": "11.0.4",
35
37
  "@types/yeoman-environment": "2.10.11",
@@ -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
  }