@sap-ux/odata-service-inquirer 2.13.10 → 2.14.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.js CHANGED
@@ -102,7 +102,8 @@ function getEntityRelatedPrompts(metadata, templateType, isCapService = false, p
102
102
  * @returns the prompt answers
103
103
  */
104
104
  async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI = false, connectedSystem) {
105
- if (adapter?.promptModule && promptOptions?.serviceSelection?.useAutoComplete) {
105
+ if (adapter?.promptModule &&
106
+ (promptOptions?.serviceSelection?.useAutoComplete ?? promptOptions?.capProject?.useAutoComplete)) {
106
107
  const pm = adapter.promptModule;
107
108
  pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
108
109
  }
@@ -14,15 +14,32 @@ const logger_helper_1 = __importDefault(require("../../logger-helper"));
14
14
  const prompt_helpers_1 = require("../../prompt-helpers");
15
15
  const inquirer_common_1 = require("@sap-ux/inquirer-common");
16
16
  const promises_1 = require("node:fs/promises");
17
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
18
+ const node_process_1 = require("node:process");
17
19
  exports.enterCapPathChoiceValue = 'enterCapPath';
18
20
  /**
19
- * Search for CAP projects in the specified paths.
21
+ * Searches for CAP project root paths from given paths, searching up to 2 parent levels if needed in CLI environment.
22
+ * Returns sorted paths with priority given to projects matching the original paths, and tracks duplicate folder names.
20
23
  *
21
- * @param paths - The paths used to search for CAP projects
24
+ * @param paths - Array of file system paths to search for CAP projects
22
25
  * @returns The CAP project paths and the number of folders with the same name
23
26
  */
24
27
  async function getCapProjectPaths(paths) {
25
28
  const capProjectRoots = await (0, project_access_1.findCapProjects)({ wsFolders: paths });
29
+ if (capProjectRoots.length === 0 && (0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
30
+ // If no CAP projects found, search parent directories (up to 2 levels)
31
+ const parentPath = (0, node_path_1.dirname)((0, node_process_1.cwd)());
32
+ const grandparentPath = (0, node_path_1.dirname)(parentPath);
33
+ // Second call is needed, since we don't want to traverse the whole fs
34
+ const capProjectsUp = await (0, project_access_1.findCapProjects)({
35
+ wsFolders: [parentPath, grandparentPath],
36
+ noTraversal: true
37
+ });
38
+ if (capProjectsUp.length > 0) {
39
+ // Add only the first found project from parent search, since we only want the current project's parent
40
+ capProjectRoots.push(capProjectsUp[0]);
41
+ }
42
+ }
26
43
  const capRootPaths = [];
27
44
  // Keep track of duplicate folder names to append the path to the name when displaying the choices
28
45
  const folderNameCount = new Map();
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLocalCapProjectPrompts = getLocalCapProjectPrompts;
4
+ const inquirer_common_1 = require("@sap-ux/inquirer-common");
4
5
  const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
5
6
  const project_access_1 = require("@sap-ux/project-access");
6
7
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
@@ -56,13 +57,14 @@ function getLocalCapProjectPrompts(promptOptions) {
56
57
  capChoices = await (0, cap_helpers_1.getCapProjectChoices)(promptOptions?.[types_1.promptNames.capProject]?.capSearchPaths ?? []);
57
58
  return capChoices?.length > 1;
58
59
  },
59
- type: 'list',
60
+ type: promptOptions?.[types_1.promptNames.capProject]?.useAutoComplete ? 'autocomplete' : 'list',
60
61
  name: types_1.promptNames.capProject,
61
62
  message: (0, i18n_1.t)('prompts.capProject.message'),
62
63
  default: () => {
63
64
  const defChoice = getDefaultCapChoice(capChoices, defaultCapPath);
64
65
  return defChoice;
65
66
  },
67
+ source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, capChoices),
66
68
  choices: () => capChoices,
67
69
  guiOptions: {
68
70
  applyDefaultWhenDirty: true,
package/dist/types.d.ts CHANGED
@@ -216,6 +216,11 @@ export type CapProjectPromptOptions = {
216
216
  * The default selected CAP project choice, this is used to pre-select a CAP project based on the CAP project path.
217
217
  */
218
218
  defaultChoice?: string;
219
+ /**
220
+ * Use autocomplete for project selection instead of list (CLI only).
221
+ * Note: inquirer-autocomplete-prompt module is used for this feature and has to be registered with the inquirer instance.
222
+ */
223
+ useAutoComplete?: boolean;
219
224
  };
220
225
  export type CapServicePromptOptions = {
221
226
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/odata-service-inquirer",
3
3
  "description": "Prompts module that can prompt users for inputs required for odata service writing",
4
- "version": "2.13.10",
4
+ "version": "2.14.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -31,14 +31,14 @@
31
31
  "os-name": "4.0.1",
32
32
  "@sap-ux/axios-extension": "1.25.6",
33
33
  "@sap-ux/btp-utils": "1.1.6",
34
- "@sap-ux/fiori-generator-shared": "0.13.49",
34
+ "@sap-ux/fiori-generator-shared": "0.13.50",
35
35
  "@sap-ux/guided-answers-helper": "0.4.2",
36
- "@sap-ux/telemetry": "0.6.51",
37
- "@sap-ux/inquirer-common": "0.10.8",
36
+ "@sap-ux/telemetry": "0.6.52",
37
+ "@sap-ux/inquirer-common": "0.10.9",
38
38
  "@sap-ux/logger": "0.8.0",
39
39
  "@sap-ux/nodejs-utils": "0.2.11",
40
- "@sap-ux/project-access": "1.33.1",
41
- "@sap-ux/project-input-validator": "0.6.41",
40
+ "@sap-ux/project-access": "1.33.2",
41
+ "@sap-ux/project-input-validator": "0.6.42",
42
42
  "@sap-ux/store": "1.4.2"
43
43
  },
44
44
  "devDependencies": {
@@ -48,12 +48,12 @@
48
48
  "@types/inquirer": "8.2.6",
49
49
  "@types/lodash": "4.14.202",
50
50
  "jest-extended": "6.0.0",
51
- "@sap-ux/fiori-generator-shared": "0.13.49",
52
- "@sap-ux/fiori-elements-writer": "2.8.32",
53
- "@sap-ux/fiori-freestyle-writer": "2.5.24",
51
+ "@sap-ux/fiori-generator-shared": "0.13.50",
52
+ "@sap-ux/fiori-elements-writer": "2.8.34",
53
+ "@sap-ux/fiori-freestyle-writer": "2.5.25",
54
54
  "@sap-ux/feature-toggle": "0.3.5",
55
- "@sap-ux/odata-service-writer": "0.29.4",
56
- "@sap-ux/cap-config-writer": "0.12.40"
55
+ "@sap-ux/odata-service-writer": "0.29.5",
56
+ "@sap-ux/cap-config-writer": "0.12.41"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"