@sap-ux/project-input-validator 0.2.2 → 0.3.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.
@@ -89,7 +89,7 @@ exports.validateAppDescription = validateAppDescription;
89
89
  */
90
90
  function validateTransportRequestNumber(transportRequest, packageName) {
91
91
  const regex = /^[$LlTt]/;
92
- if (!regex.test(packageName) && !(transportRequest === null || transportRequest === void 0 ? void 0 : transportRequest.trim())) {
92
+ if (!regex.test(packageName) && !transportRequest?.trim()) {
93
93
  return (0, i18n_1.t)('deploy.abapTransportNumRequired');
94
94
  }
95
95
  else {
@@ -104,7 +104,7 @@ exports.validateTransportRequestNumber = validateTransportRequestNumber;
104
104
  * @returns true or error message
105
105
  */
106
106
  function validatePackage(input) {
107
- if (!(input === null || input === void 0 ? void 0 : input.trim())) {
107
+ if (!input?.trim()) {
108
108
  return (0, i18n_1.t)('deploy.abapPackageWarn');
109
109
  }
110
110
  else {
@@ -9,7 +9,7 @@ const i18n_1 = require("../i18n");
9
9
  * @returns true or error message
10
10
  */
11
11
  function validateClient(client) {
12
- const formattedInput = (client === null || client === void 0 ? void 0 : client.trim()) || '';
12
+ const formattedInput = client?.trim() || '';
13
13
  const isValid = formattedInput === '' || /^\d{3}$/.test(formattedInput);
14
14
  if (isValid) {
15
15
  return true;
@@ -30,7 +30,7 @@ function validateUrl(input) {
30
30
  const url = new URL(input);
31
31
  return !!url.protocol && !!url.host;
32
32
  }
33
- catch (_a) {
33
+ catch {
34
34
  return (0, i18n_1.t)('general.invalidUrl', { input });
35
35
  }
36
36
  }
package/dist/i18n.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const PROJECT_INPUT_VALIDATOR_NS = "project-input-validator";
3
3
  /**
4
4
  * Initialize i18next with the translations for this module.
5
5
  */
6
- export declare function initI18n(): Promise<void>;
6
+ export declare function initI18nProjectValidators(): Promise<void>;
7
7
  /**
8
8
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
9
9
  *
package/dist/i18n.js CHANGED
@@ -1,40 +1,19 @@
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
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.t = exports.initI18n = exports.PROJECT_INPUT_VALIDATOR_NS = void 0;
6
+ exports.t = exports.initI18nProjectValidators = exports.PROJECT_INPUT_VALIDATOR_NS = void 0;
16
7
  const i18next_1 = __importDefault(require("i18next"));
17
8
  const project_input_validator_i18n_json_1 = __importDefault(require("./translations/project-input-validator.i18n.json"));
18
9
  exports.PROJECT_INPUT_VALIDATOR_NS = 'project-input-validator';
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
- [exports.PROJECT_INPUT_VALIDATOR_NS]: project_input_validator_i18n_json_1.default
28
- }
29
- },
30
- lng: 'en',
31
- fallbackLng: 'en',
32
- defaultNS: exports.PROJECT_INPUT_VALIDATOR_NS,
33
- ns: [exports.PROJECT_INPUT_VALIDATOR_NS]
34
- });
35
- });
13
+ async function initI18nProjectValidators() {
14
+ await i18next_1.default.init({ lng: 'en', fallbackLng: 'en' }, () => i18next_1.default.addResourceBundle('en', exports.PROJECT_INPUT_VALIDATOR_NS, project_input_validator_i18n_json_1.default));
36
15
  }
37
- exports.initI18n = initI18n;
16
+ exports.initI18nProjectValidators = initI18nProjectValidators;
38
17
  /**
39
18
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
40
19
  *
@@ -43,13 +22,13 @@ exports.initI18n = initI18n;
43
22
  * @returns {string} localized string stored for the given key
44
23
  */
45
24
  function t(key, options) {
46
- if (!(options === null || options === void 0 ? void 0 : options.ns)) {
47
- options = Object.assign(options !== null && options !== void 0 ? options : {}, { ns: exports.PROJECT_INPUT_VALIDATOR_NS });
25
+ if (!options?.ns) {
26
+ options = Object.assign(options ?? {}, { ns: exports.PROJECT_INPUT_VALIDATOR_NS });
48
27
  }
49
28
  return i18next_1.default.t(key, options);
50
29
  }
51
30
  exports.t = t;
52
- initI18n().catch(() => {
31
+ initI18nProjectValidators().catch(() => {
53
32
  // needed by lint
54
33
  });
55
34
  //# sourceMappingURL=i18n.js.map
@@ -40,7 +40,7 @@
40
40
  "nameContainsSpecialCharacters": "Module name cannot contain special characters (\"~'!()*)",
41
41
  "nameNotUrlFriendly": "Module name can only contain URL-friendly characters",
42
42
  "invalidModuleName": "Invalid module name",
43
- "moduleAlreadyExists": "The folder: {{folderName}} already exists at the specified path"
43
+ "moduleAlreadyExists": "The module folder named: {{folderName}} already exists at the specified path"
44
44
  },
45
45
  "general": {
46
46
  "invalidUrl": "Invalid URL: [{{-input}}]",
@@ -112,14 +112,13 @@ exports.validateProjectFolder = validateProjectFolder;
112
112
  * @returns true if valid, otherwise an error message string for use in Inquirer validation functions
113
113
  */
114
114
  function validateModuleName(moduleName) {
115
- var _a, _b;
116
115
  if (/^[^a-zA-Z]/.test(moduleName)) {
117
116
  return (0, i18n_1.t)('ui5.moduleNameMustStartWithLetter');
118
117
  }
119
- if ((moduleName === null || moduleName === void 0 ? void 0 : moduleName.length) > 70) {
118
+ if (moduleName?.length > 70) {
120
119
  return (0, i18n_1.t)('ui5.nameTooLong', { length: 70 });
121
120
  }
122
- if ((moduleName === null || moduleName === void 0 ? void 0 : moduleName.length) < 3) {
121
+ if (moduleName?.length < 3) {
123
122
  return (0, i18n_1.t)('ui5.nameTooShort', { length: 3 });
124
123
  }
125
124
  // convert the validation strings from `validateNpmPackageName` to required texts
@@ -134,19 +133,19 @@ function validateModuleName(moduleName) {
134
133
  [moduleName + ' is a blocklisted name']: (0, i18n_1.t)('ui5.nameBlocklisted', { moduleName }),
135
134
  [moduleName + ' is a core module name']: (0, i18n_1.t)('ui5.nameIsCoreModule', { moduleName }),
136
135
  'name can no longer contain more than 214 characters': (0, i18n_1.t)('ui5.nameTooLong', { length: 214 }),
137
- 'name can no longer contain capital letters': (0, i18n_1.t)('ui5.INPUT_VALUE_CONTAINS_CAPITAL', {
136
+ 'name can no longer contain capital letters': (0, i18n_1.t)('ui5.inputValueContainsCapital', {
138
137
  promptName: 'Module'
139
138
  }),
140
- 'name can no longer contain special characters ("~\'!()*")': (0, i18n_1.t)('ui5.NAME_CONTAINS_SPECIAL_CHARACTERS'),
141
- 'name can only contain URL-friendly characters': (0, i18n_1.t)('ui5.NAME_NOT_URL_FRIENDLY')
139
+ 'name can no longer contain special characters ("~\'!()*")': (0, i18n_1.t)('ui5.nameContainsSpecialCharacters'),
140
+ 'name can only contain URL-friendly characters': (0, i18n_1.t)('ui5.nameNotUrlFriendly')
142
141
  };
143
142
  const valid = (0, validate_npm_package_name_1.default)(moduleName);
144
143
  if (valid.validForNewPackages && valid.validForOldPackages) {
145
144
  return true;
146
145
  }
147
- return [...((_a = valid.errors) !== null && _a !== void 0 ? _a : []), ...((_b = valid.warnings) !== null && _b !== void 0 ? _b : [])]
146
+ return [...(valid.errors ?? []), ...(valid.warnings ?? [])]
148
147
  .filter((msg) => !!msg)
149
- .map((msg) => { var _a; return (_a = messageMap[msg]) !== null && _a !== void 0 ? _a : (0, i18n_1.t)('ui5.invalidModuleName'); })
148
+ .map((msg) => messageMap[msg] ?? (0, i18n_1.t)('ui5.invalidModuleName'))
150
149
  .join(', ');
151
150
  }
152
151
  exports.validateModuleName = validateModuleName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-input-validator",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Library to validate Fiori project input formats",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,13 +14,13 @@
14
14
  "private": false,
15
15
  "main": "dist/index.js",
16
16
  "dependencies": {
17
- "i18next": "20.6.1",
17
+ "i18next": "23.5.1",
18
18
  "validate-npm-package-name": "5.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/validate-npm-package-name": "4.0.1",
22
22
  "@types/i18next": "13.0.0",
23
- "jest-extended": "3.2.4"
23
+ "jest-extended": "4.0.2"
24
24
  },
25
25
  "files": [
26
26
  "dist",