@sap-ux/ui5-application-inquirer 0.6.2 → 0.6.4
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/prompts/prompt-helpers.d.ts +7 -0
- package/dist/prompts/prompt-helpers.js +23 -1
- package/dist/prompts/prompts.js +5 -4
- package/dist/prompts/validators.d.ts +7 -0
- package/dist/prompts/validators.js +18 -1
- package/dist/translations/ui5-application-inquirer.i18n.json +2 -1
- package/dist/types.d.ts +13 -0
- package/package.json +3 -3
|
@@ -34,4 +34,11 @@ export declare function isVersionIncluded(version: string, minVersion: string):
|
|
|
34
34
|
* @returns the updated questions
|
|
35
35
|
*/
|
|
36
36
|
export declare function hidePrompts(prompts: Record<promptNames, UI5ApplicationQuestion>, promptOptions?: UI5ApplicationPromptOptions, isCapProject?: boolean): UI5ApplicationQuestion[];
|
|
37
|
+
/**
|
|
38
|
+
* @param targetPath the target directory path.
|
|
39
|
+
* @param appName the application directory name.
|
|
40
|
+
* @param validateFioriAppFolder if true, validates the target path as a Fiori App project.
|
|
41
|
+
* @returns true if validated for Fiori App Project and Project Folder, false if appName length is less than 2. Otherwise appropriate validation message.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateTargetFolder(targetPath: string, appName: string, validateFioriAppFolder?: boolean): Promise<string | boolean>;
|
|
37
44
|
//# sourceMappingURL=prompt-helpers.d.ts.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hidePrompts = exports.isVersionIncluded = exports.defaultAppName = exports.appPathExists = void 0;
|
|
3
|
+
exports.validateTargetFolder = exports.hidePrompts = exports.isVersionIncluded = exports.defaultAppName = exports.appPathExists = void 0;
|
|
4
4
|
const ui5_info_1 = require("@sap-ux/ui5-info");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
8
|
const i18n_1 = require("../i18n");
|
|
9
9
|
const types_1 = require("../types");
|
|
10
|
+
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
11
|
+
const validators_1 = require("./validators");
|
|
10
12
|
/**
|
|
11
13
|
* Tests if a directory with the specified `appName` exists at the path specified by `targetPath`.
|
|
12
14
|
*
|
|
@@ -82,4 +84,24 @@ function hidePrompts(prompts, promptOptions, isCapProject) {
|
|
|
82
84
|
return questions;
|
|
83
85
|
}
|
|
84
86
|
exports.hidePrompts = hidePrompts;
|
|
87
|
+
/**
|
|
88
|
+
* @param targetPath the target directory path.
|
|
89
|
+
* @param appName the application directory name.
|
|
90
|
+
* @param validateFioriAppFolder if true, validates the target path as a Fiori App project.
|
|
91
|
+
* @returns true if validated for Fiori App Project and Project Folder, false if appName length is less than 2. Otherwise appropriate validation message.
|
|
92
|
+
*/
|
|
93
|
+
async function validateTargetFolder(targetPath, appName, validateFioriAppFolder) {
|
|
94
|
+
if (validateFioriAppFolder === true) {
|
|
95
|
+
const isFioriValid = await (0, validators_1.validateFioriAppProjectFolder)(targetPath);
|
|
96
|
+
if (isFioriValid !== true) {
|
|
97
|
+
return isFioriValid;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const isProjectValid = (0, project_input_validator_1.validateProjectFolder)(targetPath, appName);
|
|
101
|
+
if (isProjectValid !== true) {
|
|
102
|
+
return isProjectValid;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
exports.validateTargetFolder = validateTargetFolder;
|
|
85
107
|
//# sourceMappingURL=prompt-helpers.js.map
|
package/dist/prompts/prompts.js
CHANGED
|
@@ -32,7 +32,7 @@ function getQuestions(ui5Versions, promptOptions, capCdsInfo, isYUI = false) {
|
|
|
32
32
|
[types_1.promptNames.title]: getTitlePrompt(),
|
|
33
33
|
[types_1.promptNames.namespace]: getNamespacePrompt(appName),
|
|
34
34
|
[types_1.promptNames.description]: getDescriptionPrompt(),
|
|
35
|
-
[types_1.promptNames.targetFolder]: getTargetFolderPrompt(targetDir),
|
|
35
|
+
[types_1.promptNames.targetFolder]: getTargetFolderPrompt(targetDir, promptOptions?.[types_1.promptNames.targetFolder]?.validateFioriAppFolder),
|
|
36
36
|
[types_1.promptNames.ui5Version]: getUI5VersionPrompt(ui5Versions, promptOptions?.ui5Version),
|
|
37
37
|
[types_1.promptNames.addDeployConfig]: getAddDeployConfigPrompt(targetDir, promptOptions?.addDeployConfig, isCapProject),
|
|
38
38
|
[types_1.promptNames.addFlpConfig]: getAddFlpConfigPrompt(promptOptions?.addFlpConfig),
|
|
@@ -284,9 +284,10 @@ function getUI5VersionPrompt(ui5Versions = [], ui5VersionPromptOptions) {
|
|
|
284
284
|
* Gets the `targetFolder` prompt.
|
|
285
285
|
*
|
|
286
286
|
* @param targetDir provides a default value for the target folder path
|
|
287
|
+
* @param validateFioriAppFolder validates the target folder path as a Fiori app project
|
|
287
288
|
* @returns the `targetFolder` prompt
|
|
288
289
|
*/
|
|
289
|
-
function getTargetFolderPrompt(targetDir) {
|
|
290
|
+
function getTargetFolderPrompt(targetDir, validateFioriAppFolder) {
|
|
290
291
|
return {
|
|
291
292
|
type: 'input',
|
|
292
293
|
name: types_1.promptNames.targetFolder,
|
|
@@ -298,9 +299,9 @@ function getTargetFolderPrompt(targetDir) {
|
|
|
298
299
|
breadcrumb: (0, i18n_1.t)('prompts.appFolderPathBreadcrumb')
|
|
299
300
|
},
|
|
300
301
|
default: (answers) => answers.targetFolder || targetDir,
|
|
301
|
-
validate: (target, { name = '' }) => {
|
|
302
|
+
validate: async (target, { name = '' }) => {
|
|
302
303
|
if (name.length > 2) {
|
|
303
|
-
return (0,
|
|
304
|
+
return await (0, prompt_helpers_1.validateTargetFolder)(target, name, validateFioriAppFolder);
|
|
304
305
|
}
|
|
305
306
|
return false;
|
|
306
307
|
}
|
|
@@ -7,4 +7,11 @@
|
|
|
7
7
|
* @returns true, if valid, or a string message indicating the reason why the input is invalid
|
|
8
8
|
*/
|
|
9
9
|
export declare function validateAppName(appName: string, targetDir: string): boolean | string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the specified target path does not contain a Fiori project.
|
|
12
|
+
*
|
|
13
|
+
* @param targetDir the target directory path.
|
|
14
|
+
* @returns true, if not Fiori Project, or string message indicating that the path contains a Fiori project.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateFioriAppProjectFolder(targetDir: string): Promise<string | boolean>;
|
|
10
17
|
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateAppName = void 0;
|
|
3
|
+
exports.validateFioriAppProjectFolder = exports.validateAppName = void 0;
|
|
4
4
|
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
5
5
|
const prompt_helpers_1 = require("./prompt-helpers");
|
|
6
6
|
const i18n_1 = require("../i18n");
|
|
7
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
7
8
|
/**
|
|
8
9
|
* Returns true (valid) if the specified projectName is a valid module name
|
|
9
10
|
* and if an application folder (directory) at the specified path does not exist.
|
|
@@ -24,4 +25,20 @@ function validateAppName(appName, targetDir) {
|
|
|
24
25
|
return true;
|
|
25
26
|
}
|
|
26
27
|
exports.validateAppName = validateAppName;
|
|
28
|
+
/**
|
|
29
|
+
* Returns true if the specified target path does not contain a Fiori project.
|
|
30
|
+
*
|
|
31
|
+
* @param targetDir the target directory path.
|
|
32
|
+
* @returns true, if not Fiori Project, or string message indicating that the path contains a Fiori project.
|
|
33
|
+
*/
|
|
34
|
+
async function validateFioriAppProjectFolder(targetDir) {
|
|
35
|
+
const appRoot = await (0, project_access_1.findRootsForPath)(targetDir);
|
|
36
|
+
if (appRoot) {
|
|
37
|
+
return (0, i18n_1.t)('validators.folderContainsFioriApp', { path: appRoot.appRoot });
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.validateFioriAppProjectFolder = validateFioriAppProjectFolder;
|
|
27
44
|
//# sourceMappingURL=validators.js.map
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"appShowAdvancedOptionsHint": "Choosing 'No' will apply defaults"
|
|
36
36
|
},
|
|
37
37
|
"validators": {
|
|
38
|
-
"appFolderExistsAtPath": "A module with this name already exists in the folder: {{-path}}"
|
|
38
|
+
"appFolderExistsAtPath": "A module with this name already exists in the folder: {{-path}}",
|
|
39
|
+
"folderContainsFioriApp": "The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again."
|
|
39
40
|
},
|
|
40
41
|
"ui5VersionLabels": {
|
|
41
42
|
"maintained": "Maintained",
|
package/dist/types.d.ts
CHANGED
|
@@ -97,6 +97,19 @@ type TargetFolderPromptOptions = {
|
|
|
97
97
|
* Note that if a `default` option is also provided then this will be used instead of the `defaultValue` option.
|
|
98
98
|
*/
|
|
99
99
|
defaultValue?: string;
|
|
100
|
+
/**
|
|
101
|
+
* If set to `true`, the target folder prompt's validator will perform additional validation to
|
|
102
|
+
* determine if the specified target path is contained in an existing Fiori application project path, which is invalid.
|
|
103
|
+
*
|
|
104
|
+
* **Behavior**:
|
|
105
|
+
* - **CAP Projects**: Validates if the target folder is part of a CAP project with a supported Fiori app.
|
|
106
|
+
* - **Non-CAP Projects**: Checks for recognised SAP Fiori apps, such as Fiori elements or SAPUI5
|
|
107
|
+
* freestyle apps that have the correct structure and required dependencies.
|
|
108
|
+
* - **Validation Outcome**: Returns a validation message if the target folder meets the Fiori app criteria.
|
|
109
|
+
*
|
|
110
|
+
* If `false` or not provided, only ui5 project validation is performed without specific Fiori app checks.
|
|
111
|
+
*/
|
|
112
|
+
validateFioriAppFolder?: boolean;
|
|
100
113
|
};
|
|
101
114
|
type NamePromptOptions = {
|
|
102
115
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui5-application-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for UI5 application writing",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lodash": "4.17.21",
|
|
25
25
|
"semver": "7.5.4",
|
|
26
26
|
"@sap-ux/inquirer-common": "0.4.6",
|
|
27
|
-
"@sap-ux/project-access": "1.27.
|
|
27
|
+
"@sap-ux/project-access": "1.27.2",
|
|
28
28
|
"@sap-ux/project-input-validator": "0.3.3",
|
|
29
29
|
"@sap-ux/ui5-info": "0.8.1"
|
|
30
30
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/lodash": "4.14.202",
|
|
36
36
|
"@types/semver": "7.5.4",
|
|
37
37
|
"inquirer": "8.2.6",
|
|
38
|
-
"@sap-ux/cap-config-writer": "0.7.
|
|
38
|
+
"@sap-ux/cap-config-writer": "0.7.39"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=18.x"
|