@sap-ux/deploy-config-generator-shared 0.0.10 → 0.0.12

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,4 +1,4 @@
1
1
  export { DeploymentGenerator } from './base/generator';
2
- export { initI18n, bail, handleErrorMessage, showOverwriteQuestion, ErrorMessages, ConnectedSystem } from './utils';
2
+ export { initI18n, bail, handleErrorMessage, showOverwriteQuestion, ErrorHandler, ERROR_TYPE, ConnectedSystem, mtaExecutable } from './utils';
3
3
  export { getConfirmConfigUpdatePrompt } from './prompts';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfirmConfigUpdatePrompt = exports.ErrorMessages = exports.showOverwriteQuestion = exports.handleErrorMessage = exports.bail = exports.initI18n = exports.DeploymentGenerator = void 0;
3
+ exports.getConfirmConfigUpdatePrompt = exports.mtaExecutable = exports.ERROR_TYPE = exports.ErrorHandler = exports.showOverwriteQuestion = exports.handleErrorMessage = exports.bail = exports.initI18n = exports.DeploymentGenerator = void 0;
4
4
  var generator_1 = require("./base/generator");
5
5
  Object.defineProperty(exports, "DeploymentGenerator", { enumerable: true, get: function () { return generator_1.DeploymentGenerator; } });
6
6
  var utils_1 = require("./utils");
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "initI18n", { enumerable: true, get: function ()
8
8
  Object.defineProperty(exports, "bail", { enumerable: true, get: function () { return utils_1.bail; } });
9
9
  Object.defineProperty(exports, "handleErrorMessage", { enumerable: true, get: function () { return utils_1.handleErrorMessage; } });
10
10
  Object.defineProperty(exports, "showOverwriteQuestion", { enumerable: true, get: function () { return utils_1.showOverwriteQuestion; } });
11
- Object.defineProperty(exports, "ErrorMessages", { enumerable: true, get: function () { return utils_1.ErrorMessages; } });
11
+ Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return utils_1.ErrorHandler; } });
12
+ Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function () { return utils_1.ERROR_TYPE; } });
13
+ Object.defineProperty(exports, "mtaExecutable", { enumerable: true, get: function () { return utils_1.mtaExecutable; } });
12
14
  var prompts_1 = require("./prompts");
13
15
  Object.defineProperty(exports, "getConfirmConfigUpdatePrompt", { enumerable: true, get: function () { return prompts_1.getConfirmConfigUpdatePrompt; } });
14
16
  //# sourceMappingURL=index.js.map
@@ -5,24 +5,15 @@
5
5
  }
6
6
  },
7
7
  "errors": {
8
- "abortSignal": "ABORT_SIGNAL",
9
- "cannotReadUi5Config": "Cannot read ui5.yaml: {{- reason}}",
8
+ "abortSignal": "Generator aborted",
10
9
  "capDeploymentNoMta": "The SAP Fiori application is within a CAP project and deployment should be configured as part of the CAP project. Please ensure you have a mta.yaml file defined for this project.",
11
10
  "fileDoesNotExist": "File does not exist: {{- filePath}}",
12
11
  "folderDoesNotExist": "Folder path does not exist: {{- filePath}}",
13
- "invalidClient": "[{{- client}}] is invalid. Enter blank or a value between 000-999",
14
- "invalidMtaId": "The ID can only contain letters, numbers, dashes, periods and underscores (but no spaces).",
15
- "invalidURL": "Invalid URL: [{{- input}}]",
16
- "mtaIdAlreadyExists": "A folder with same name already exist at {{- destinationRoot}}",
17
12
  "noAppName": "Could not determine app name from manifest",
18
- "noUi5Config": "Error: could not read ui5.yaml",
19
13
  "noBinary": "Cannot find the \"{{bin}}\" executable. Please add it to the path or use \"npm i -g {{pkg}}\" to install it.",
20
14
  "noManifest": "Error: could not read webapp/manifest.json",
21
- "noMta": "MTA ID cannot be empty",
22
- "noMtaId": "MTA ID cannot be empty",
23
- "noMtaInRoot": "Error: no {{mtaFileName}} in {{- root}}",
24
- "noPath": "Cannot find \"path\" in backend configuration in ui5.yaml",
25
- "unrecognizedTarget": "Unrecognized target: {{target}}"
15
+ "unrecognizedTarget": "Unrecognized target: {{target}}",
16
+ "unknownError": "Unknown error"
26
17
  },
27
18
  "debug": {
28
19
  "loggerInitialised": "LogWrapper initialized for DeploymentGenerator"
@@ -1,28 +1,29 @@
1
1
  import { type AppWizard } from '@sap-devx/yeoman-ui-types';
2
+ export declare enum ERROR_TYPE {
3
+ ABORT_SIGNAL = "ABORT_SIGNAL",
4
+ NO_MANIFEST = "NO_MANIFEST",
5
+ NO_APP_NAME = "NO_APP_NAME",
6
+ NO_UI5_CONFIG = "NO_UI5_CONFIG",
7
+ NO_CDS_BIN = "NO_CDS_BIN",
8
+ NO_MTA_BIN = "NO_MTA_BIN",
9
+ CAP_DEPLOYMENT_NO_MTA = "CAP_DEPLOYMENT_NO_MTA"
10
+ }
2
11
  /**
3
12
  * Error messages for the deploy configuration generator.
4
13
  */
5
- export declare class ErrorMessages {
14
+ export declare class ErrorHandler {
6
15
  private static readonly cannotFindBinary;
7
- static readonly abortSignal: string;
8
- static readonly noManifest: string;
9
- static readonly noAppName: string;
10
- static readonly noUI5Config: string;
11
- static readonly noCdsBin: string;
12
- static readonly noMtaBin: string;
13
- static readonly noMta: string;
14
- static readonly noPath: string;
15
- static readonly noMtaId: string;
16
- static readonly invalidMtaId: string;
17
- static readonly capDeploymentnoMta: string;
18
- static readonly mtaIdAlreadyExist: (destinationRoot: string) => string;
19
- static readonly noMtaInRoot: (root: string) => string;
16
+ /**
17
+ * Get the error message for the specified error type.
18
+ *
19
+ * @param errorType The error type for which the message may be returned
20
+ * @returns The error message for the specified error type
21
+ */
22
+ static getErrorMsgFromType(errorType?: ERROR_TYPE): string;
23
+ private static readonly _errorTypeToMsg;
20
24
  static readonly unrecognizedTarget: (target: string) => string;
21
- static readonly cannotReadUi5Config: (reason: string) => string;
22
25
  static readonly fileDoesNotExist: (filePath: string) => string;
23
26
  static readonly folderDoesNotExist: (filePath: string) => string;
24
- static readonly invalidClient: (client: string) => string;
25
- static readonly invalidURL: (input: string) => string;
26
27
  }
27
28
  /**
28
29
  * Bail out with an error message.
@@ -34,7 +35,12 @@ export declare function bail(errorMessage: string): void;
34
35
  * Handle error message, display it in the UI or throws an error in CLI.
35
36
  *
36
37
  * @param appWizard - AppWizard instance
37
- * @param errorMsg - Error message to be displayed
38
+ * @param error - error type or message
39
+ * @param error.errorType - error type
40
+ * @param error.errorMsg - error message
38
41
  */
39
- export declare function handleErrorMessage(appWizard: AppWizard, errorMsg: string): void;
42
+ export declare function handleErrorMessage(appWizard: AppWizard, { errorType, errorMsg }: {
43
+ errorType?: ERROR_TYPE;
44
+ errorMsg?: string;
45
+ }): void;
40
46
  //# sourceMappingURL=error-handler.d.ts.map
@@ -1,37 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleErrorMessage = exports.bail = exports.ErrorMessages = void 0;
3
+ exports.handleErrorMessage = exports.bail = exports.ErrorHandler = exports.ERROR_TYPE = void 0;
4
4
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
5
5
  const generator_1 = require("../base/generator");
6
6
  const i18n_1 = require("./i18n");
7
7
  const constants_1 = require("./constants");
8
8
  const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
9
+ var ERROR_TYPE;
10
+ (function (ERROR_TYPE) {
11
+ ERROR_TYPE["ABORT_SIGNAL"] = "ABORT_SIGNAL";
12
+ ERROR_TYPE["NO_MANIFEST"] = "NO_MANIFEST";
13
+ ERROR_TYPE["NO_APP_NAME"] = "NO_APP_NAME";
14
+ ERROR_TYPE["NO_UI5_CONFIG"] = "NO_UI5_CONFIG";
15
+ ERROR_TYPE["NO_CDS_BIN"] = "NO_CDS_BIN";
16
+ ERROR_TYPE["NO_MTA_BIN"] = "NO_MTA_BIN";
17
+ ERROR_TYPE["CAP_DEPLOYMENT_NO_MTA"] = "CAP_DEPLOYMENT_NO_MTA";
18
+ })(ERROR_TYPE || (exports.ERROR_TYPE = ERROR_TYPE = {}));
9
19
  /**
10
20
  * Error messages for the deploy configuration generator.
11
21
  */
12
- class ErrorMessages {
22
+ class ErrorHandler {
13
23
  static cannotFindBinary = (bin, pkg) => (0, i18n_1.t)('errors.noBinary', { bin, pkg });
14
- static abortSignal = (0, i18n_1.t)('errors.abortSignal');
15
- static noManifest = (0, i18n_1.t)('errors.noManifest');
16
- static noAppName = (0, i18n_1.t)('errors.noAppName');
17
- static noUI5Config = (0, i18n_1.t)('errors.noUi5Config');
18
- static noCdsBin = this.cannotFindBinary(constants_1.cdsExecutable, constants_1.cdsPkg);
19
- static noMtaBin = this.cannotFindBinary(constants_1.mtaExecutable, constants_1.mtaPkg);
20
- static noMta = (0, i18n_1.t)('errors.noMta');
21
- static noPath = (0, i18n_1.t)('errors.noPath');
22
- static noMtaId = (0, i18n_1.t)('errors.noMtaId');
23
- static invalidMtaId = (0, i18n_1.t)('errors.invalidMtaId');
24
- static capDeploymentnoMta = (0, i18n_1.t)('errors.capDeploymentNoMta');
25
- static mtaIdAlreadyExist = (destinationRoot) => (0, i18n_1.t)('errors.mtaIdAlreadyExists', { destinationRoot });
26
- static noMtaInRoot = (root) => (0, i18n_1.t)('errors.noMtaInRoot', { mtaFileName: constants_1.mtaYaml, root });
24
+ /**
25
+ * Get the error message for the specified error type.
26
+ *
27
+ * @param errorType The error type for which the message may be returned
28
+ * @returns The error message for the specified error type
29
+ */
30
+ static getErrorMsgFromType(errorType) {
31
+ if (errorType) {
32
+ return ErrorHandler._errorTypeToMsg[errorType]();
33
+ }
34
+ return (0, i18n_1.t)('errors.unknownError');
35
+ }
36
+ static _errorTypeToMsg = {
37
+ [ERROR_TYPE.ABORT_SIGNAL]: () => (0, i18n_1.t)('errors.abortSignal'),
38
+ [ERROR_TYPE.NO_MANIFEST]: () => (0, i18n_1.t)('errors.noManifest'),
39
+ [ERROR_TYPE.NO_APP_NAME]: () => (0, i18n_1.t)('errors.noAppName'),
40
+ [ERROR_TYPE.NO_UI5_CONFIG]: () => (0, i18n_1.t)('errors.noUi5Config'),
41
+ [ERROR_TYPE.NO_CDS_BIN]: () => ErrorHandler.cannotFindBinary(constants_1.cdsExecutable, constants_1.cdsPkg),
42
+ [ERROR_TYPE.NO_MTA_BIN]: () => ErrorHandler.cannotFindBinary(constants_1.mtaExecutable, constants_1.mtaPkg),
43
+ [ERROR_TYPE.CAP_DEPLOYMENT_NO_MTA]: () => (0, i18n_1.t)('errors.capDeploymentNoMta')
44
+ };
27
45
  static unrecognizedTarget = (target) => (0, i18n_1.t)('errors.unrecognizedTarget', { target });
28
- static cannotReadUi5Config = (reason) => (0, i18n_1.t)('errors.cannotReadUi5Config', { reason });
29
46
  static fileDoesNotExist = (filePath) => (0, i18n_1.t)('errors.fileDoesNotExist', { filePath });
30
47
  static folderDoesNotExist = (filePath) => (0, i18n_1.t)('errors.folderDoesNotExist', { filePath });
31
- static invalidClient = (client) => (0, i18n_1.t)('errors.invalidClient', { client });
32
- static invalidURL = (input) => (0, i18n_1.t)('errors.invalidURL', { input });
33
48
  }
34
- exports.ErrorMessages = ErrorMessages;
49
+ exports.ErrorHandler = ErrorHandler;
35
50
  /**
36
51
  * Bail out with an error message.
37
52
  *
@@ -45,15 +60,18 @@ exports.bail = bail;
45
60
  * Handle error message, display it in the UI or throws an error in CLI.
46
61
  *
47
62
  * @param appWizard - AppWizard instance
48
- * @param errorMsg - Error message to be displayed
63
+ * @param error - error type or message
64
+ * @param error.errorType - error type
65
+ * @param error.errorMsg - error message
49
66
  */
50
- function handleErrorMessage(appWizard, errorMsg) {
67
+ function handleErrorMessage(appWizard, { errorType, errorMsg }) {
68
+ const error = errorMsg ?? ErrorHandler.getErrorMsgFromType(errorType);
51
69
  if ((0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
52
- bail(errorMsg);
70
+ bail(error);
53
71
  }
54
72
  else {
55
- generator_1.DeploymentGenerator.logger?.debug(errorMsg);
56
- appWizard?.showError(errorMsg, yeoman_ui_types_1.MessageType.notification);
73
+ generator_1.DeploymentGenerator.logger?.debug(error);
74
+ appWizard?.showError(error, yeoman_ui_types_1.MessageType.notification);
57
75
  }
58
76
  }
59
77
  exports.handleErrorMessage = handleErrorMessage;
@@ -1,5 +1,6 @@
1
1
  export { t, initI18n } from './i18n';
2
2
  export { showOverwriteQuestion } from './conditions';
3
- export { ErrorMessages, bail, handleErrorMessage } from './error-handler';
3
+ export { ErrorHandler, ERROR_TYPE, bail, handleErrorMessage } from './error-handler';
4
+ export { mtaExecutable } from './constants';
4
5
  export * from './types';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -14,15 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.handleErrorMessage = exports.bail = exports.ErrorMessages = exports.showOverwriteQuestion = exports.initI18n = exports.t = void 0;
17
+ exports.mtaExecutable = exports.handleErrorMessage = exports.bail = exports.ERROR_TYPE = exports.ErrorHandler = exports.showOverwriteQuestion = exports.initI18n = exports.t = void 0;
18
18
  var i18n_1 = require("./i18n");
19
19
  Object.defineProperty(exports, "t", { enumerable: true, get: function () { return i18n_1.t; } });
20
20
  Object.defineProperty(exports, "initI18n", { enumerable: true, get: function () { return i18n_1.initI18n; } });
21
21
  var conditions_1 = require("./conditions");
22
22
  Object.defineProperty(exports, "showOverwriteQuestion", { enumerable: true, get: function () { return conditions_1.showOverwriteQuestion; } });
23
23
  var error_handler_1 = require("./error-handler");
24
- Object.defineProperty(exports, "ErrorMessages", { enumerable: true, get: function () { return error_handler_1.ErrorMessages; } });
24
+ Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return error_handler_1.ErrorHandler; } });
25
+ Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function () { return error_handler_1.ERROR_TYPE; } });
25
26
  Object.defineProperty(exports, "bail", { enumerable: true, get: function () { return error_handler_1.bail; } });
26
27
  Object.defineProperty(exports, "handleErrorMessage", { enumerable: true, get: function () { return error_handler_1.handleErrorMessage; } });
28
+ var constants_1 = require("./constants");
29
+ Object.defineProperty(exports, "mtaExecutable", { enumerable: true, get: function () { return constants_1.mtaExecutable; } });
27
30
  __exportStar(require("./types"), exports);
28
31
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/deploy-config-generator-shared",
3
3
  "description": "Commonly used shared functionality and types to support the deploy config generator.",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -20,7 +20,7 @@
20
20
  "@vscode-logging/logger": "2.0.0",
21
21
  "i18next": "20.6.1",
22
22
  "yeoman-generator": "5.10.0",
23
- "@sap-ux/fiori-generator-shared": "0.7.19",
23
+ "@sap-ux/fiori-generator-shared": "0.7.20",
24
24
  "@sap-ux/nodejs-utils": "0.1.4"
25
25
  },
26
26
  "devDependencies": {