@sap-ux/project-input-validator 0.3.4 → 0.4.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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './deploy/validators';
2
2
  export * from './ui5/validators';
3
+ export * from './ui5/project-path-validators';
3
4
  export * from './general/validators';
4
5
  export * from './adp/validators';
5
6
  export * from './flp/validators';
package/dist/index.js CHANGED
@@ -17,6 +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("./ui5/project-path-validators"), exports);
20
21
  __exportStar(require("./general/validators"), exports);
21
22
  __exportStar(require("./adp/validators"), exports);
22
23
  __exportStar(require("./flp/validators"), exports);
@@ -40,7 +40,10 @@
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 module folder named: {{folderName}} already exists at the specified path"
43
+ "moduleAlreadyExists": "The module folder named: {{folderName}} already exists at the specified path",
44
+ "appFolderExistsAtPath": "A module with this name already exists in the folder: {{-path}}",
45
+ "folderContainsFioriApp": "The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again.",
46
+ "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."
44
47
  },
45
48
  "general": {
46
49
  "invalidUrl": "Invalid URL: [{{-input}}]",
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param targetPath the target directory path.
3
+ * @param appName the application directory name.
4
+ * @param validateFioriAppFolder if true, validates the target path as a Fiori App project.
5
+ * @returns true if validated for Fiori App Project and Project Folder. Otherwise appropriate validation message.
6
+ */
7
+ export declare function validateTargetFolderForFioriApp(targetPath: string, appName: string, validateFioriAppFolder?: boolean): Promise<string | boolean>;
8
+ //# sourceMappingURL=project-path-validators.d.ts.map
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateTargetFolderForFioriApp = validateTargetFolderForFioriApp;
4
+ const project_access_1 = require("@sap-ux/project-access");
5
+ const validators_1 = require("./validators");
6
+ const i18n_1 = require("../i18n");
7
+ /**
8
+ * Returns true if the specified target path does not contain a Fiori project.
9
+ *
10
+ * @param targetDir the target directory path.
11
+ * @returns true, if not Fiori Project, or string message indicating that the path contains a Fiori project.
12
+ */
13
+ async function validateFioriAppProjectFolder(targetDir) {
14
+ // Check if the target directory contains a CAP project
15
+ if (!!(await (0, project_access_1.findCapProjectRoot)(targetDir, false)) || !!(await (0, project_access_1.getCapProjectType)(targetDir))) {
16
+ return (0, i18n_1.t)('ui5.folderContainsCapApp');
17
+ }
18
+ // Check if the target directory contains a Fiori project
19
+ const appRoot = await (0, project_access_1.findRootsForPath)(targetDir);
20
+ if (appRoot) {
21
+ return (0, i18n_1.t)('ui5.folderContainsFioriApp', { path: appRoot.appRoot });
22
+ }
23
+ else {
24
+ return true;
25
+ }
26
+ }
27
+ /**
28
+ * @param targetPath the target directory path.
29
+ * @param appName the application directory name.
30
+ * @param validateFioriAppFolder if true, validates the target path as a Fiori App project.
31
+ * @returns true if validated for Fiori App Project and Project Folder. Otherwise appropriate validation message.
32
+ */
33
+ async function validateTargetFolderForFioriApp(targetPath, appName, validateFioriAppFolder) {
34
+ if (validateFioriAppFolder === true) {
35
+ const isFioriValid = await validateFioriAppProjectFolder(targetPath);
36
+ if (isFioriValid !== true) {
37
+ return isFioriValid;
38
+ }
39
+ }
40
+ const isProjectValid = (0, validators_1.validateProjectFolder)(targetPath, appName);
41
+ if (isProjectValid !== true) {
42
+ return isProjectValid;
43
+ }
44
+ return true;
45
+ }
46
+ //# sourceMappingURL=project-path-validators.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-input-validator",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Library to validate Fiori project input formats",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,8 @@
15
15
  "main": "dist/index.js",
16
16
  "dependencies": {
17
17
  "i18next": "23.5.1",
18
- "validate-npm-package-name": "5.0.0"
18
+ "validate-npm-package-name": "5.0.0",
19
+ "@sap-ux/project-access": "1.29.18"
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/validate-npm-package-name": "4.0.1",