@sap-ux/project-input-validator 0.2.3 → 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.
- package/dist/deploy/validators.js +2 -2
- package/dist/general/validators.js +2 -2
- package/dist/i18n.js +4 -15
- package/dist/ui5/validators.js +4 -5
- package/package.json +2 -2
|
@@ -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) && !
|
|
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 (!
|
|
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 =
|
|
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
|
|
33
|
+
catch {
|
|
34
34
|
return (0, i18n_1.t)('general.invalidUrl', { input });
|
|
35
35
|
}
|
|
36
36
|
}
|
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,10 +10,8 @@ exports.PROJECT_INPUT_VALIDATOR_NS = 'project-input-validator';
|
|
|
19
10
|
/**
|
|
20
11
|
* Initialize i18next with the translations for this module.
|
|
21
12
|
*/
|
|
22
|
-
function initI18nProjectValidators() {
|
|
23
|
-
|
|
24
|
-
yield 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));
|
|
25
|
-
});
|
|
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));
|
|
26
15
|
}
|
|
27
16
|
exports.initI18nProjectValidators = initI18nProjectValidators;
|
|
28
17
|
/**
|
|
@@ -33,8 +22,8 @@ exports.initI18nProjectValidators = initI18nProjectValidators;
|
|
|
33
22
|
* @returns {string} localized string stored for the given key
|
|
34
23
|
*/
|
|
35
24
|
function t(key, options) {
|
|
36
|
-
if (!
|
|
37
|
-
options = Object.assign(options
|
|
25
|
+
if (!options?.ns) {
|
|
26
|
+
options = Object.assign(options ?? {}, { ns: exports.PROJECT_INPUT_VALIDATOR_NS });
|
|
38
27
|
}
|
|
39
28
|
return i18next_1.default.t(key, options);
|
|
40
29
|
}
|
package/dist/ui5/validators.js
CHANGED
|
@@ -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 (
|
|
118
|
+
if (moduleName?.length > 70) {
|
|
120
119
|
return (0, i18n_1.t)('ui5.nameTooLong', { length: 70 });
|
|
121
120
|
}
|
|
122
|
-
if (
|
|
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
|
|
@@ -144,9 +143,9 @@ function validateModuleName(moduleName) {
|
|
|
144
143
|
if (valid.validForNewPackages && valid.validForOldPackages) {
|
|
145
144
|
return true;
|
|
146
145
|
}
|
|
147
|
-
return [...(
|
|
146
|
+
return [...(valid.errors ?? []), ...(valid.warnings ?? [])]
|
|
148
147
|
.filter((msg) => !!msg)
|
|
149
|
-
.map((msg) =>
|
|
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.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Library to validate Fiori project input formats",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/validate-npm-package-name": "4.0.1",
|
|
22
22
|
"@types/i18next": "13.0.0",
|
|
23
|
-
"jest-extended": "
|
|
23
|
+
"jest-extended": "4.0.2"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|