@sap-ux/project-input-validator 0.6.1 → 0.6.3
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/{ui5 → general}/project-path-validators.d.ts +9 -6
- package/dist/{ui5 → general}/project-path-validators.js +20 -10
- package/dist/general/validators.d.ts +8 -0
- package/dist/general/validators.js +17 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/translations/project-input-validator.i18n.json +4 -3
- package/package.json +2 -2
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validates whether the specified target path is suitable for creating
|
|
2
|
+
* Validates whether the specified target path is suitable for creating an SAP Fiori project App project.
|
|
3
3
|
* The function performs the following checks:
|
|
4
4
|
*
|
|
5
5
|
* 1. **CAP Project Check:** If `validateFioriAppFolder` is true, it checks if the target path is part of an existing CAP project.
|
|
6
6
|
* - Uses `findCapProjectRoot()` and `getCapProjectType()` to verify the presence of a CAP project.
|
|
7
7
|
* - Returns an error message if a CAP project is detected.
|
|
8
8
|
*
|
|
9
|
-
* 2. **Fiori App Project Check:** If `validateFioriAppFolder` is true, it checks if the target path contains
|
|
10
|
-
* - Uses `findRootsForPath()` to determine if
|
|
11
|
-
* - Returns a success message if a valid Fiori app root is found, otherwise returns true.
|
|
9
|
+
* 2. **Fiori App Project Check:** If `validateFioriAppFolder` is true, it checks if the target path contains an SAP Fiori project.
|
|
10
|
+
* - Uses `findRootsForPath()` to determine if an SAP Fiori project application root exists.
|
|
11
|
+
* - Returns a success message if a valid SAP Fiori app root is found, otherwise returns true.
|
|
12
12
|
*
|
|
13
13
|
* 3. **General Project Folder Check:**
|
|
14
14
|
* - Uses `validateProjectFolder()` to verify if the provided target path exists.
|
|
15
15
|
* - Ensures the target folder does not already contain a subfolder with the intended project name.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* 4. **Windows Path Length Validation:**
|
|
18
|
+
* - Validates the combined path length of the target directory and application name against the Windows max path length limit (256 characters).
|
|
19
|
+
*
|
|
20
|
+
* @param targetPath - The target directory path where the SAP Fiori app is to be created.
|
|
18
21
|
* @param appName - The application directory name.
|
|
19
|
-
* @param validateFioriAppFolder - If true, validates the target path as
|
|
22
|
+
* @param validateFioriAppFolder - If true, validates the target path as an SAP Fiori App project folder.
|
|
20
23
|
* @returns A boolean value `true` if all validations pass; otherwise, an error message.
|
|
21
24
|
*/
|
|
22
25
|
export declare function validateFioriAppTargetFolder(targetPath: string, appName: string, validateFioriAppFolder?: boolean): Promise<string | boolean>;
|
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateFioriAppTargetFolder = validateFioriAppTargetFolder;
|
|
4
4
|
const project_access_1 = require("@sap-ux/project-access");
|
|
5
|
-
const
|
|
5
|
+
const path_1 = require("path");
|
|
6
6
|
const i18n_1 = require("../i18n");
|
|
7
|
+
const validators_1 = require("../ui5/validators");
|
|
8
|
+
const validators_2 = require("./validators");
|
|
7
9
|
/**
|
|
8
|
-
* Returns true if the specified target path does not contain
|
|
10
|
+
* Returns true if the specified target path does not contain an SAP Fiori project.
|
|
9
11
|
*
|
|
10
12
|
* @param targetDir the target directory path.
|
|
11
|
-
* @returns true, if not Fiori Project, or string message indicating that the path contains
|
|
13
|
+
* @returns true, if not Fiori Project, or string message indicating that the path contains an SAP Fiori project.
|
|
12
14
|
*/
|
|
13
15
|
async function validateFioriAppProjectFolder(targetDir) {
|
|
14
16
|
// Check if the target directory contains a CAP project
|
|
15
17
|
if (!!(await (0, project_access_1.findCapProjectRoot)(targetDir, false)) || !!(await (0, project_access_1.getCapProjectType)(targetDir))) {
|
|
16
18
|
return (0, i18n_1.t)('ui5.folderContainsCapApp');
|
|
17
19
|
}
|
|
18
|
-
// Check if the target directory contains
|
|
20
|
+
// Check if the target directory contains an SAP Fiori project
|
|
19
21
|
const appRoot = await (0, project_access_1.findRootsForPath)(targetDir);
|
|
20
22
|
if (appRoot) {
|
|
21
23
|
return (0, i18n_1.t)('ui5.folderContainsFioriApp', { path: appRoot.appRoot });
|
|
@@ -25,24 +27,27 @@ async function validateFioriAppProjectFolder(targetDir) {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
|
-
* Validates whether the specified target path is suitable for creating
|
|
30
|
+
* Validates whether the specified target path is suitable for creating an SAP Fiori project App project.
|
|
29
31
|
* The function performs the following checks:
|
|
30
32
|
*
|
|
31
33
|
* 1. **CAP Project Check:** If `validateFioriAppFolder` is true, it checks if the target path is part of an existing CAP project.
|
|
32
34
|
* - Uses `findCapProjectRoot()` and `getCapProjectType()` to verify the presence of a CAP project.
|
|
33
35
|
* - Returns an error message if a CAP project is detected.
|
|
34
36
|
*
|
|
35
|
-
* 2. **Fiori App Project Check:** If `validateFioriAppFolder` is true, it checks if the target path contains
|
|
36
|
-
* - Uses `findRootsForPath()` to determine if
|
|
37
|
-
* - Returns a success message if a valid Fiori app root is found, otherwise returns true.
|
|
37
|
+
* 2. **Fiori App Project Check:** If `validateFioriAppFolder` is true, it checks if the target path contains an SAP Fiori project.
|
|
38
|
+
* - Uses `findRootsForPath()` to determine if an SAP Fiori project application root exists.
|
|
39
|
+
* - Returns a success message if a valid SAP Fiori app root is found, otherwise returns true.
|
|
38
40
|
*
|
|
39
41
|
* 3. **General Project Folder Check:**
|
|
40
42
|
* - Uses `validateProjectFolder()` to verify if the provided target path exists.
|
|
41
43
|
* - Ensures the target folder does not already contain a subfolder with the intended project name.
|
|
42
44
|
*
|
|
43
|
-
*
|
|
45
|
+
* 4. **Windows Path Length Validation:**
|
|
46
|
+
* - Validates the combined path length of the target directory and application name against the Windows max path length limit (256 characters).
|
|
47
|
+
*
|
|
48
|
+
* @param targetPath - The target directory path where the SAP Fiori app is to be created.
|
|
44
49
|
* @param appName - The application directory name.
|
|
45
|
-
* @param validateFioriAppFolder - If true, validates the target path as
|
|
50
|
+
* @param validateFioriAppFolder - If true, validates the target path as an SAP Fiori App project folder.
|
|
46
51
|
* @returns A boolean value `true` if all validations pass; otherwise, an error message.
|
|
47
52
|
*/
|
|
48
53
|
async function validateFioriAppTargetFolder(targetPath, appName, validateFioriAppFolder) {
|
|
@@ -56,6 +61,11 @@ async function validateFioriAppTargetFolder(targetPath, appName, validateFioriAp
|
|
|
56
61
|
if (isProjectValid !== true) {
|
|
57
62
|
return isProjectValid;
|
|
58
63
|
}
|
|
64
|
+
// Windows path length validation
|
|
65
|
+
const winPathResult = (0, validators_2.validateWindowsPathLength)((0, path_1.join)(targetPath, appName), (0, i18n_1.t)(`general.windowsFolderPathTooLong`));
|
|
66
|
+
if (winPathResult !== true) {
|
|
67
|
+
return winPathResult;
|
|
68
|
+
}
|
|
59
69
|
return true;
|
|
60
70
|
}
|
|
61
71
|
//# sourceMappingURL=project-path-validators.js.map
|
|
@@ -58,4 +58,12 @@ export declare function validateJSON(value: string): boolean | string;
|
|
|
58
58
|
* @returns {boolean} True if validation passes, or an error message if validation fails.
|
|
59
59
|
*/
|
|
60
60
|
export declare function validateSpecialChars(value: string, regexp?: string): boolean | string;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if the combined Windows path length exceeds the default limit (256 characters).
|
|
63
|
+
*
|
|
64
|
+
* @param basePath The base path (e.g., target folder or mtaPath) + the name, ID, or additional segment to be appended
|
|
65
|
+
* @param errorMessage The error message to be returned if the path is too long. Use `{length}` as a placeholder for the actual length.
|
|
66
|
+
* @returns true if valid, or the error message if too long
|
|
67
|
+
*/
|
|
68
|
+
export declare function validateWindowsPathLength(basePath: string, errorMessage: string): true | string;
|
|
61
69
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -8,6 +8,7 @@ exports.validateMaxLength = validateMaxLength;
|
|
|
8
8
|
exports.validateAllowedCharacters = validateAllowedCharacters;
|
|
9
9
|
exports.validateJSON = validateJSON;
|
|
10
10
|
exports.validateSpecialChars = validateSpecialChars;
|
|
11
|
+
exports.validateWindowsPathLength = validateWindowsPathLength;
|
|
11
12
|
const i18n_1 = require("../i18n");
|
|
12
13
|
/**
|
|
13
14
|
* SAP client number is either empty or 3 digit string.
|
|
@@ -127,4 +128,20 @@ function validateSpecialChars(value, regexp = '^[a-zA-Z0-9_$.\\-]+$') {
|
|
|
127
128
|
}
|
|
128
129
|
return (0, i18n_1.t)('general.invalidValueForSpecialChars');
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Checks if the combined Windows path length exceeds the default limit (256 characters).
|
|
133
|
+
*
|
|
134
|
+
* @param basePath The base path (e.g., target folder or mtaPath) + the name, ID, or additional segment to be appended
|
|
135
|
+
* @param errorMessage The error message to be returned if the path is too long. Use `{length}` as a placeholder for the actual length.
|
|
136
|
+
* @returns true if valid, or the error message if too long
|
|
137
|
+
*/
|
|
138
|
+
function validateWindowsPathLength(basePath, errorMessage) {
|
|
139
|
+
if (process.platform === 'win32') {
|
|
140
|
+
const combinedLength = `${basePath}`.length;
|
|
141
|
+
if (combinedLength >= 256) {
|
|
142
|
+
return errorMessage.replace('{{length}}', combinedLength.toString());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
130
147
|
//# sourceMappingURL=validators.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './deploy/validators';
|
|
2
2
|
export * from './ui5/validators';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './general/project-path-validators';
|
|
4
4
|
export * from './general/validators';
|
|
5
5
|
export * from './adp/validators';
|
|
6
6
|
export * from './flp/validators';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.addi18nResourceBundle = void 0;
|
|
18
18
|
__exportStar(require("./deploy/validators"), exports);
|
|
19
19
|
__exportStar(require("./ui5/validators"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./general/project-path-validators"), exports);
|
|
21
21
|
__exportStar(require("./general/validators"), exports);
|
|
22
22
|
__exportStar(require("./adp/validators"), exports);
|
|
23
23
|
__exportStar(require("./flp/validators"), exports);
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"invalidModuleName": "Invalid module name",
|
|
43
43
|
"moduleAlreadyExists": "The module folder named: {{folderName}} already exists at the specified path",
|
|
44
44
|
"appFolderExistsAtPath": "A module with this name already exists in the folder: {{-path}}",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
45
|
+
"folderContainsCapApp": "The selected project folder is part of an existing CAP project. This application must therefore use the local CAP project as the data source.",
|
|
46
|
+
"folderContainsFioriApp": "The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again."
|
|
47
47
|
},
|
|
48
48
|
"general": {
|
|
49
49
|
"invalidUrl": "Invalid URL: [{{-input}}]",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"invalidJSON": "Invalid JSON",
|
|
54
54
|
"invalidValueForSpecialChars": "Input must contain only Latin alphanumeric characters or the following symbols: '-','_','$' and '.'",
|
|
55
55
|
"maxLength": "Maximum length: {{maxLength}} characters",
|
|
56
|
-
"supportedFormats": "Only alphanumeric and '{{allowedCharacters}}' characters are allowed"
|
|
56
|
+
"supportedFormats": "Only alphanumeric and '{{allowedCharacters}}' characters are allowed",
|
|
57
|
+
"windowsFolderPathTooLong": "The combined length {{length}} of the target folder and module name exceeds the default Windows path length. This can cause issues with project generation."
|
|
57
58
|
},
|
|
58
59
|
"adp": {
|
|
59
60
|
"projectNameUppercaseError": "The name cannot contain uppercase letters.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/project-input-validator",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Library to validate Fiori project input formats",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"i18next": "23.5.1",
|
|
18
18
|
"validate-npm-package-name": "5.0.0",
|
|
19
|
-
"@sap-ux/project-access": "1.30.
|
|
19
|
+
"@sap-ux/project-access": "1.30.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/validate-npm-package-name": "4.0.1",
|