@sap-ux/odata-service-inquirer 0.3.11 → 0.4.1

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.
@@ -1,20 +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
- var __asyncValues = (this && this.__asyncValues) || function (o) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var m = o[Symbol.asyncIterator], i;
14
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
- };
18
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
19
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
4
  };
@@ -32,24 +16,21 @@ exports.enterCapPathChoiceValue = 'enterCapPath';
32
16
  * @param paths - The paths used to search for CAP projects
33
17
  * @returns The CAP project paths and the number of folders with the same name
34
18
  */
35
- function getCapProjectPaths(paths) {
36
- var _a;
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const capProjectRoots = yield (0, project_access_1.findCapProjects)({ wsFolders: paths });
39
- const capRootPaths = [];
40
- // Keep track of duplicate folder names to append the path to the name when displaying the choices
41
- const folderNameCount = new Map();
42
- for (const root of capProjectRoots) {
43
- const folderName = (0, path_1.basename)(root);
44
- capRootPaths.push({ folderName, path: root });
45
- folderNameCount.set(folderName, ((_a = folderNameCount.get(folderName)) !== null && _a !== void 0 ? _a : 0) + 1);
46
- }
47
- capRootPaths.sort((a, b) => a.folderName.localeCompare(b.folderName));
48
- return {
49
- capProjectPaths: capRootPaths,
50
- folderCounts: folderNameCount
51
- };
52
- });
19
+ async function getCapProjectPaths(paths) {
20
+ const capProjectRoots = await (0, project_access_1.findCapProjects)({ wsFolders: paths });
21
+ const capRootPaths = [];
22
+ // Keep track of duplicate folder names to append the path to the name when displaying the choices
23
+ const folderNameCount = new Map();
24
+ for (const root of capProjectRoots) {
25
+ const folderName = (0, path_1.basename)(root);
26
+ capRootPaths.push({ folderName, path: root });
27
+ folderNameCount.set(folderName, (folderNameCount.get(folderName) ?? 0) + 1);
28
+ }
29
+ capRootPaths.sort((a, b) => a.folderName.localeCompare(b.folderName));
30
+ return {
31
+ capProjectPaths: capRootPaths,
32
+ folderCounts: folderNameCount
33
+ };
53
34
  }
54
35
  /**
55
36
  * Search for CAP projects in the specified paths and create prompt choices from the results.
@@ -58,40 +39,24 @@ function getCapProjectPaths(paths) {
58
39
  * @param paths - The paths used to search for CAP projects
59
40
  * @returns The CAP project prompt choices
60
41
  */
61
- function getCapProjectChoices(paths) {
62
- var _a, e_1, _b, _c;
63
- var _d;
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const { capProjectPaths, folderCounts } = yield getCapProjectPaths(paths);
66
- const capChoices = [];
67
- try {
68
- for (var _e = true, capProjectPaths_1 = __asyncValues(capProjectPaths), capProjectPaths_1_1; capProjectPaths_1_1 = yield capProjectPaths_1.next(), _a = capProjectPaths_1_1.done, !_a; _e = true) {
69
- _c = capProjectPaths_1_1.value;
70
- _e = false;
71
- const capProjectPath = _c;
72
- const customCapPaths = yield (0, project_access_1.getCapCustomPaths)(capProjectPath.path);
73
- const folderCount = (_d = folderCounts.get(capProjectPath.folderName)) !== null && _d !== void 0 ? _d : 1;
74
- capChoices.push({
75
- name: `${capProjectPath.folderName}${folderCount > 1 ? ' (' + capProjectPath.path + ')' : ''}`,
76
- value: Object.assign(capProjectPath, customCapPaths)
77
- });
78
- }
79
- }
80
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
81
- finally {
82
- try {
83
- if (!_e && !_a && (_b = capProjectPaths_1.return)) yield _b.call(capProjectPaths_1);
84
- }
85
- finally { if (e_1) throw e_1.error; }
42
+ async function getCapProjectChoices(paths) {
43
+ const { capProjectPaths, folderCounts } = await getCapProjectPaths(paths);
44
+ const capChoices = [];
45
+ for await (const capProjectPath of capProjectPaths) {
46
+ const customCapPaths = await (0, project_access_1.getCapCustomPaths)(capProjectPath.path);
47
+ const folderCount = folderCounts.get(capProjectPath.folderName) ?? 1;
48
+ capChoices.push({
49
+ name: `${capProjectPath.folderName}${folderCount > 1 ? ' (' + capProjectPath.path + ')' : ''}`,
50
+ value: Object.assign(capProjectPath, customCapPaths)
51
+ });
52
+ }
53
+ return [
54
+ ...capChoices,
55
+ {
56
+ name: (0, i18n_1.t)('prompts.capProject.enterCapPathChoiceName'),
57
+ value: exports.enterCapPathChoiceValue
86
58
  }
87
- return [
88
- ...capChoices,
89
- {
90
- name: (0, i18n_1.t)('prompts.capProject.enterCapPathChoiceName'),
91
- value: exports.enterCapPathChoiceValue
92
- }
93
- ];
94
- });
59
+ ];
95
60
  }
96
61
  exports.getCapProjectChoices = getCapProjectChoices;
97
62
  /**
@@ -105,16 +70,15 @@ exports.getCapProjectChoices = getCapProjectChoices;
105
70
  * @returns a cap service choice
106
71
  */
107
72
  function createCapServiceChoice(capModel, serviceInfo, projectPath, appPath, cdsVersionInfo) {
108
- var _a, _b, _c;
109
- const srvDef = (_a = capModel.definitions) === null || _a === void 0 ? void 0 : _a[serviceInfo.name];
73
+ const srvDef = capModel.definitions?.[serviceInfo.name];
110
74
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
111
- const serviceFilePath = (_b = srvDef === null || srvDef === void 0 ? void 0 : srvDef.$location) === null || _b === void 0 ? void 0 : _b.file;
75
+ const serviceFilePath = srvDef?.$location?.file;
112
76
  logger_helper_1.default.logger.debug(`Cap service def: ${JSON.stringify(srvDef)}`);
113
77
  logger_helper_1.default.logger.debug(`Cap service def $location.file: ${JSON.stringify(serviceFilePath)}`);
114
78
  // Find the source path for the service definition file, we cannot resolve '../' path segments as
115
79
  // we have no idea where the cwd was when the cds compiler was run. Remove the '../' or '..\\' path segments so the relative path can
116
80
  // be resolved against the project root. This is a workaround until cds provides the correct path in the service info.
117
- const absServicePath = (_c = capModel.$sources) === null || _c === void 0 ? void 0 : _c.find((source) => source.indexOf(serviceFilePath.replace(/\.\.\\\\|\.\.\\|\.\.\//g, '')) > -1);
81
+ const absServicePath = capModel.$sources?.find((source) => source.indexOf(serviceFilePath.replace(/\.\.\\\\|\.\.\\|\.\.\//g, '')) > -1);
118
82
  logger_helper_1.default.logger.debug(`Source file path for service: ${serviceInfo.name}: ${absServicePath}`);
119
83
  if (absServicePath && (0, path_1.isAbsolute)(absServicePath)) {
120
84
  let serviceCdsFilePath = (0, path_1.relative)(projectPath, absServicePath);
@@ -147,50 +111,48 @@ function createCapServiceChoice(capModel, serviceInfo, projectPath, appPath, cds
147
111
  * @param capProjectPaths - The CAP project paths
148
112
  * @returns The CAP project service choices
149
113
  */
150
- function getCapServiceChoices(capProjectPaths) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- logger_helper_1.default.logger.debug(`getCapServiceChoices: ${JSON.stringify(capProjectPaths)}`);
153
- if (!capProjectPaths) {
154
- return [];
155
- }
114
+ async function getCapServiceChoices(capProjectPaths) {
115
+ logger_helper_1.default.logger.debug(`getCapServiceChoices: ${JSON.stringify(capProjectPaths)}`);
116
+ if (!capProjectPaths) {
117
+ return [];
118
+ }
119
+ try {
120
+ let capServices = [];
121
+ let capModel;
122
+ let capCdsVersionInfo;
156
123
  try {
157
- let capServices = [];
158
- let capModel;
159
- let capCdsVersionInfo;
160
- try {
161
- // Workaround for missing clear cache functionality in `getCapModelAnsdServices`, this resets the cds.resolve.cache.
162
- // If this is not done then errors can be thrown where out-of-processs changes to the files system have occurred
163
- yield (0, project_access_1.getCdsRoots)(capProjectPaths.path, true);
164
- // Load the CAP model and services
165
- const { model, services, cdsVersionInfo } = yield (0, project_access_1.getCapModelAndServices)({
166
- projectRoot: capProjectPaths.path,
167
- logger: logger_helper_1.default.logger
168
- });
169
- capServices = services;
170
- capModel = model;
171
- capCdsVersionInfo = cdsVersionInfo;
172
- }
173
- catch (error) {
174
- prompt_helpers_1.errorHandler.logErrorMsgs(error);
175
- logger_helper_1.default.logger.error((0, i18n_1.t)('errors.capModelAndServicesLoadError', { error: error === null || error === void 0 ? void 0 : error.message }));
176
- return [];
177
- }
178
- // We need the relative service definitions file paths (.cds) for the generated annotation file
179
- const projectPath = capProjectPaths.path;
180
- const appPath = capProjectPaths.app;
181
- logger_helper_1.default.logger.debug(`CDS model source paths: ${JSON.stringify(capModel.$sources)}`);
182
- const serviceChoices = capServices
183
- .map((service) => {
184
- return createCapServiceChoice(capModel, service, projectPath, appPath, capCdsVersionInfo);
185
- })
186
- .filter((service) => !!service); // filter undefined entries
187
- return serviceChoices !== null && serviceChoices !== void 0 ? serviceChoices : [];
124
+ // Workaround for missing clear cache functionality in `getCapModelAnsdServices`, this resets the cds.resolve.cache.
125
+ // If this is not done then errors can be thrown where out-of-processs changes to the files system have occurred
126
+ await (0, project_access_1.getCdsRoots)(capProjectPaths.path, true);
127
+ // Load the CAP model and services
128
+ const { model, services, cdsVersionInfo } = await (0, project_access_1.getCapModelAndServices)({
129
+ projectRoot: capProjectPaths.path,
130
+ logger: logger_helper_1.default.logger
131
+ });
132
+ capServices = services;
133
+ capModel = model;
134
+ capCdsVersionInfo = cdsVersionInfo;
188
135
  }
189
- catch (err) {
190
- prompt_helpers_1.errorHandler.logErrorMsgs(err);
136
+ catch (error) {
137
+ prompt_helpers_1.errorHandler.logErrorMsgs(error);
138
+ logger_helper_1.default.logger.error((0, i18n_1.t)('errors.capModelAndServicesLoadError', { error: error?.message }));
139
+ return [];
191
140
  }
192
- return [];
193
- });
141
+ // We need the relative service definitions file paths (.cds) for the generated annotation file
142
+ const projectPath = capProjectPaths.path;
143
+ const appPath = capProjectPaths.app;
144
+ logger_helper_1.default.logger.debug(`CDS model source paths: ${JSON.stringify(capModel.$sources)}`);
145
+ const serviceChoices = capServices
146
+ .map((service) => {
147
+ return createCapServiceChoice(capModel, service, projectPath, appPath, capCdsVersionInfo);
148
+ })
149
+ .filter((service) => !!service); // filter undefined entries
150
+ return serviceChoices ?? [];
151
+ }
152
+ catch (err) {
153
+ prompt_helpers_1.errorHandler.logErrorMsgs(err);
154
+ }
155
+ return [];
194
156
  }
195
157
  exports.getCapServiceChoices = getCapServiceChoices;
196
158
  /**
@@ -199,21 +161,19 @@ exports.getCapServiceChoices = getCapServiceChoices;
199
161
  * @param capService - The CAP service
200
162
  * @returns The edmx metadata for the CAP service
201
163
  */
202
- function getCapEdmx(capService) {
203
- return __awaiter(this, void 0, void 0, function* () {
204
- if (!capService.urlPath) {
205
- const errorMsg = (0, i18n_1.t)('errors.capServiceUrlPathNotDefined', { serviceName: capService.serviceName });
206
- prompt_helpers_1.errorHandler.logErrorMsgs(errorMsg);
207
- return undefined;
208
- }
209
- try {
210
- return yield (0, project_access_1.readCapServiceMetadataEdmx)(capService.projectPath, capService.urlPath, 'v4');
211
- }
212
- catch (error) {
213
- prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.cannotReadCapServiceMetadata', { serviceName: capService.serviceName }));
214
- logger_helper_1.default.logger.error(error);
215
- }
216
- });
164
+ async function getCapEdmx(capService) {
165
+ if (!capService.urlPath) {
166
+ const errorMsg = (0, i18n_1.t)('errors.capServiceUrlPathNotDefined', { serviceName: capService.serviceName });
167
+ prompt_helpers_1.errorHandler.logErrorMsgs(errorMsg);
168
+ return undefined;
169
+ }
170
+ try {
171
+ return await (0, project_access_1.readCapServiceMetadataEdmx)(capService.projectPath, capService.urlPath, 'v4');
172
+ }
173
+ catch (error) {
174
+ prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.cannotReadCapServiceMetadata', { serviceName: capService.serviceName }));
175
+ logger_helper_1.default.logger.error(error);
176
+ }
217
177
  }
218
178
  exports.getCapEdmx = getCapEdmx;
219
179
  //# sourceMappingURL=cap-helpers.js.map
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getLocalCapProjectPrompts = void 0;
13
4
  const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
@@ -49,21 +40,19 @@ function getDefaultCapChoice(capChoices, defaultChoicePath) {
49
40
  * @returns the prompt used to provide input for selecting a CAP project
50
41
  */
51
42
  function getLocalCapProjectPrompts(promptOptions) {
52
- var _a, _b;
53
43
  let capChoices = [];
54
- const defaultCapPath = (_a = promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions[types_1.promptNames.capProject]) === null || _a === void 0 ? void 0 : _a.defaultChoice;
55
- const defaultCapService = (_b = promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions[types_1.promptNames.capService]) === null || _b === void 0 ? void 0 : _b.defaultChoice;
44
+ const defaultCapPath = promptOptions?.[types_1.promptNames.capProject]?.defaultChoice;
45
+ const defaultCapService = promptOptions?.[types_1.promptNames.capService]?.defaultChoice;
56
46
  let selectedCapProject;
57
47
  let capServiceChoices;
58
48
  let defaultServiceIndex = 0;
59
49
  utils_1.PromptState.reset();
60
50
  const prompts = [
61
51
  {
62
- when: () => __awaiter(this, void 0, void 0, function* () {
63
- var _c, _d;
64
- capChoices = yield (0, cap_helpers_1.getCapProjectChoices)((_d = (_c = promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions[types_1.promptNames.capProject]) === null || _c === void 0 ? void 0 : _c.capSearchPaths) !== null && _d !== void 0 ? _d : []);
65
- return (capChoices === null || capChoices === void 0 ? void 0 : capChoices.length) > 1;
66
- }),
52
+ when: async () => {
53
+ capChoices = await (0, cap_helpers_1.getCapProjectChoices)(promptOptions?.[types_1.promptNames.capProject]?.capSearchPaths ?? []);
54
+ return capChoices?.length > 1;
55
+ },
67
56
  type: 'list',
68
57
  name: types_1.promptNames.capProject,
69
58
  message: (0, i18n_1.t)('prompts.capProject.message'),
@@ -79,7 +68,7 @@ function getLocalCapProjectPrompts(promptOptions) {
79
68
  }
80
69
  },
81
70
  {
82
- when: (answers) => capChoices.length === 1 || (answers === null || answers === void 0 ? void 0 : answers.capProject) === cap_helpers_1.enterCapPathChoiceValue,
71
+ when: (answers) => capChoices.length === 1 || answers?.capProject === cap_helpers_1.enterCapPathChoiceValue,
83
72
  type: 'input',
84
73
  guiType: 'folder-browser',
85
74
  name: types_2.capInternalPromptNames.capProjectPath,
@@ -90,41 +79,39 @@ function getLocalCapProjectPrompts(promptOptions) {
90
79
  }
91
80
  },
92
81
  guiOptions: { mandatory: true, breadcrumb: (0, i18n_1.t)('prompts.capProject.breadcrumb') },
93
- validate: (projectPath) => __awaiter(this, void 0, void 0, function* () {
94
- const validCapPath = yield (0, validators_1.validateCapPath)(projectPath);
82
+ validate: async (projectPath) => {
83
+ const validCapPath = await (0, validators_1.validateCapPath)(projectPath);
95
84
  // Load the cap paths if the path is valid
96
85
  if (validCapPath === true) {
97
- selectedCapProject = Object.assign({ path: projectPath }, yield (0, project_access_1.getCapCustomPaths)(projectPath));
86
+ selectedCapProject = Object.assign({ path: projectPath }, await (0, project_access_1.getCapCustomPaths)(projectPath));
98
87
  return true;
99
88
  }
100
89
  selectedCapProject = undefined;
101
90
  return validCapPath;
102
- })
91
+ }
103
92
  },
104
93
  {
105
- when: (answers) => __awaiter(this, void 0, void 0, function* () {
106
- if (typeof (answers === null || answers === void 0 ? void 0 : answers.capProject) === 'object') {
94
+ when: async (answers) => {
95
+ if (typeof answers?.capProject === 'object') {
107
96
  selectedCapProject = answers.capProject;
108
97
  }
109
98
  if (selectedCapProject) {
110
- capServiceChoices = yield (0, cap_helpers_1.getCapServiceChoices)(selectedCapProject);
99
+ capServiceChoices = await (0, cap_helpers_1.getCapServiceChoices)(selectedCapProject);
111
100
  return true;
112
101
  }
113
102
  return false;
114
- }),
103
+ },
115
104
  type: 'list',
116
105
  name: types_1.promptNames.capService,
117
106
  message: (0, i18n_1.t)('prompts.capService.message'),
118
107
  choices: () => {
119
108
  if (defaultCapService) {
120
109
  // Find the cap service, qualified by the provided project path
121
- defaultServiceIndex = capServiceChoices === null || capServiceChoices === void 0 ? void 0 : capServiceChoices.findIndex((choice) => {
122
- var _a, _b;
123
- // project path is an extra validation that the prompt options for each
124
- // of `defaultCapProject` and `defaultCapService` are compatible
125
- return ((_a = choice.value) === null || _a === void 0 ? void 0 : _a.projectPath) === (defaultCapService === null || defaultCapService === void 0 ? void 0 : defaultCapService.projectPath) &&
126
- ((_b = choice.value) === null || _b === void 0 ? void 0 : _b.serviceName) === (defaultCapService === null || defaultCapService === void 0 ? void 0 : defaultCapService.serviceName);
127
- });
110
+ defaultServiceIndex = capServiceChoices?.findIndex((choice) =>
111
+ // project path is an extra validation that the prompt options for each
112
+ // of `defaultCapProject` and `defaultCapService` are compatible
113
+ choice.value?.projectPath === defaultCapService?.projectPath &&
114
+ choice.value?.serviceName === defaultCapService?.serviceName);
128
115
  }
129
116
  return capServiceChoices;
130
117
  },
@@ -134,15 +121,15 @@ function getLocalCapProjectPrompts(promptOptions) {
134
121
  breadcrumb: true
135
122
  },
136
123
  default: () => {
137
- return (capServiceChoices === null || capServiceChoices === void 0 ? void 0 : capServiceChoices.length) > 1 ? defaultServiceIndex : 0;
124
+ return capServiceChoices?.length > 1 ? defaultServiceIndex : 0;
138
125
  },
139
- validate: (capService) => __awaiter(this, void 0, void 0, function* () {
126
+ validate: async (capService) => {
140
127
  const errMsg = prompt_helpers_1.errorHandler.getErrorMsg(undefined, true);
141
128
  if (errMsg) {
142
129
  return errMsg;
143
130
  }
144
131
  if (capService) {
145
- utils_1.PromptState.odataService.metadata = yield (0, cap_helpers_1.getCapEdmx)(capService);
132
+ utils_1.PromptState.odataService.metadata = await (0, cap_helpers_1.getCapEdmx)(capService);
146
133
  utils_1.PromptState.odataService.servicePath = capService.urlPath;
147
134
  utils_1.PromptState.odataService.odataVersion = odata_service_writer_1.OdataVersion.v4;
148
135
  return utils_1.PromptState.odataService.metadata !== undefined
@@ -150,19 +137,19 @@ function getLocalCapProjectPrompts(promptOptions) {
150
137
  : (0, i18n_1.t)('prompts.validationMessages.metadataInvalid');
151
138
  }
152
139
  return false;
153
- })
140
+ }
154
141
  }
155
142
  ];
156
143
  if ((0, utils_1.getHostEnvironment)() === types_1.hostEnvironment.cli) {
157
144
  prompts.push({
158
- when: (answers) => __awaiter(this, void 0, void 0, function* () {
159
- if (answers === null || answers === void 0 ? void 0 : answers.capService) {
160
- utils_1.PromptState.odataService.metadata = yield (0, cap_helpers_1.getCapEdmx)(answers === null || answers === void 0 ? void 0 : answers.capService);
161
- utils_1.PromptState.odataService.servicePath = answers === null || answers === void 0 ? void 0 : answers.capService.urlPath;
145
+ when: async (answers) => {
146
+ if (answers?.capService) {
147
+ utils_1.PromptState.odataService.metadata = await (0, cap_helpers_1.getCapEdmx)(answers?.capService);
148
+ utils_1.PromptState.odataService.servicePath = answers?.capService.urlPath;
162
149
  utils_1.PromptState.odataService.odataVersion = odata_service_writer_1.OdataVersion.v4;
163
150
  }
164
151
  return false;
165
- }),
152
+ },
166
153
  name: types_2.capInternalPromptNames.capCliStateSetter
167
154
  });
168
155
  }
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.validateCapPath = void 0;
13
4
  const project_access_1 = require("@sap-ux/project-access");
@@ -18,18 +9,16 @@ const i18n_1 = require("../../../i18n");
18
9
  * @param capProjectPath - The path to the CAP project
19
10
  * @returns A boolean indicating if the path is a valid CAP project or an error message
20
11
  */
21
- function validateCapPath(capProjectPath) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (capProjectPath) {
24
- try {
25
- return !!(yield (0, project_access_1.getCapProjectType)(capProjectPath)) || (0, i18n_1.t)('prompts.validationMessages.capProjectNotFound');
26
- }
27
- catch (err) {
28
- return (0, i18n_1.t)('prompts.validationMessages.capProjectNotFound');
29
- }
12
+ async function validateCapPath(capProjectPath) {
13
+ if (capProjectPath) {
14
+ try {
15
+ return !!(await (0, project_access_1.getCapProjectType)(capProjectPath)) || (0, i18n_1.t)('prompts.validationMessages.capProjectNotFound');
30
16
  }
31
- return false;
32
- });
17
+ catch (err) {
18
+ return (0, i18n_1.t)('prompts.validationMessages.capProjectNotFound');
19
+ }
20
+ }
21
+ return false;
33
22
  }
34
23
  exports.validateCapPath = validateCapPath;
35
24
  //# sourceMappingURL=validators.js.map
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getMetadataFileQuestion = void 0;
13
4
  const i18n_1 = require("../../../i18n");
@@ -27,9 +18,9 @@ function getMetadataFileQuestion(promptOptions) {
27
18
  name: types_1.promptNames.metadataFilePath,
28
19
  guiOptions: { mandatory: true, breadcrumb: true },
29
20
  message: (0, i18n_1.t)('prompts.metadataFile.message'),
30
- validate: (path) => __awaiter(this, void 0, void 0, function* () {
21
+ validate: async (path) => {
31
22
  utils_1.PromptState.reset();
32
- const validateResult = yield (0, validators_1.validateMetadataFile)(path, promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.requiredOdataVersion);
23
+ const validateResult = await (0, validators_1.validateMetadataFile)(path, promptOptions?.requiredOdataVersion);
33
24
  if (typeof validateResult === 'string' || typeof validateResult === 'boolean') {
34
25
  return validateResult;
35
26
  }
@@ -39,7 +30,7 @@ function getMetadataFileQuestion(promptOptions) {
39
30
  utils_1.PromptState.odataService.servicePath = (0, i18n_1.t)('prompts.metadataFile.placeholder_odata_service_url'); // Dummy path used by v4 preview server middleware
40
31
  }
41
32
  return true;
42
- })
33
+ }
43
34
  };
44
35
  return metadataFileQuestion;
45
36
  }
@@ -6,40 +6,31 @@
6
6
  * @param odataVersion
7
7
  * @returns
8
8
  */
9
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
- return new (P || (P = Promise))(function (resolve, reject) {
12
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
- step((generator = generator.apply(thisArg, _arguments || [])).next());
16
- });
17
- };
18
9
  Object.defineProperty(exports, "__esModule", { value: true });
19
10
  exports.validateMetadataFile = void 0;
20
11
  const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
21
12
  const promises_1 = require("fs/promises");
22
13
  const validators_1 = require("../../validators");
23
14
  const i18n_1 = require("../../../i18n");
24
- const validateMetadataFile = (path, odataVersion) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const validateMetadataFile = async (path, odataVersion) => {
25
16
  if (!path) {
26
17
  return false;
27
18
  }
28
19
  try {
29
- const metadata = yield (0, promises_1.readFile)(path, 'utf-8');
20
+ const metadata = await (0, promises_1.readFile)(path, 'utf-8');
30
21
  metadata.replace(/ & /g, ' & ');
31
22
  const { validationMsg, version } = (0, validators_1.validateODataVersion)(metadata, odataVersion);
32
23
  if (validationMsg) {
33
24
  return validationMsg;
34
25
  }
35
26
  return {
36
- version: version !== null && version !== void 0 ? version : odata_service_writer_1.OdataVersion.v4,
27
+ version: version ?? odata_service_writer_1.OdataVersion.v4,
37
28
  metadata
38
29
  };
39
30
  }
40
31
  catch (error) {
41
32
  return (0, i18n_1.t)('prompts.validationMessages.metadataFilePathNotValid');
42
33
  }
43
- });
34
+ };
44
35
  exports.validateMetadataFile = validateMetadataFile;
45
36
  //# sourceMappingURL=validators.js.map