@squiz/dxp-cli-next 5.2.0 → 5.3.0-develop.2

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/lib/auth/login.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const cli_color_1 = require("cli-color");
15
+ const cli_color_1 = __importDefault(require("cli-color"));
16
16
  const commander_1 = require("commander");
17
17
  const ApiService_1 = require("../ApiService");
18
18
  const ApplicationStore_1 = require("../ApplicationStore");
@@ -30,16 +30,29 @@ const loginCommand = new commander_1.Command('login')
30
30
  .addOption(new commander_1.Option('--tenant <tenantID>'))
31
31
  .configureOutput({
32
32
  outputError(str, write) {
33
- write((0, cli_color_1.red)(str));
33
+ write(cli_color_1.default.red(str));
34
34
  },
35
35
  })
36
36
  .action((options) => __awaiter(void 0, void 0, void 0, function* () {
37
- const credentials = yield getLoginCredentials(options.username, options.password);
38
- if (credentials == false) {
39
- console.log(''); // needed to not screw up line endings in terminal
40
- return;
37
+ try {
38
+ const credentials = yield getLoginCredentials(options.username, options.password);
39
+ if (credentials == false) {
40
+ console.log(''); // needed to not screw up line endings in terminal
41
+ return;
42
+ }
43
+ return yield handleLoginRequest(credentials, options);
44
+ }
45
+ catch (error) {
46
+ if (!!process.env.DEBUG && error.stack) {
47
+ loginCommand.error(error.stack);
48
+ }
49
+ if (error.message) {
50
+ loginCommand.error(cli_color_1.default.red(error.message));
51
+ }
52
+ else {
53
+ loginCommand.error(cli_color_1.default.red('An unknown error occurred'));
54
+ }
41
55
  }
42
- return handleLoginRequest(credentials, options);
43
56
  }));
44
57
  exports.default = loginCommand;
45
58
  function getLoginCredentials(optionalUsername, optionalPassword) {
@@ -108,10 +121,8 @@ function handleLoginRequest(login, options) {
108
121
  region: options.region,
109
122
  }));
110
123
  return;
111
- case 400:
112
- loginCommand.error(loginResponse.data.message);
113
124
  default:
114
- loginCommand.error('An error occurred during login');
125
+ throw new Error(`An error occurred during login ${loginResponse.data.message ? `"${loginResponse.data.message}"` : ''} (code: ${loginResponse.status})`.trim());
115
126
  }
116
127
  });
117
128
  }
package/lib/cmp/deploy.js CHANGED
@@ -42,19 +42,22 @@ const deployCommand = new commander_1.Command()
42
42
  return yield (0, component_cli_lib_1.uploadComponentFolder)(apiService.client, componentServiceUrl, source);
43
43
  }
44
44
  catch (error) {
45
- // console.error(error);
45
+ if (!!process.env.DEBUG && error.stack) {
46
+ deployCommand.error(error.stack);
47
+ }
46
48
  if (error instanceof ApiService_1.InvalidLoginSessionError) {
47
49
  deployCommand.error(cli_color_1.default.red('Login session expired. Please login again.'));
50
+ return;
48
51
  }
49
52
  if (error instanceof ApiService_1.InvalidTenantError) {
50
53
  deployCommand.error(cli_color_1.default.red('Cannot deploy to specified tenant'));
54
+ return;
51
55
  }
52
56
  if (error.message) {
53
57
  deployCommand.error(cli_color_1.default.red(error.message));
54
58
  }
55
59
  else {
56
- console.error(error);
57
- deployCommand.error('An unknown error occurred');
60
+ deployCommand.error(cli_color_1.default.red('An unknown error occurred'));
58
61
  }
59
62
  }
60
63
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/dxp-cli-next",
3
- "version": "5.2.0",
3
+ "version": "5.3.0-develop.2",
4
4
  "repository": {
5
5
  "url": "https://gitlab.squiz.net/developer-experience/dxp-cli-next"
6
6
  },
@@ -39,7 +39,7 @@
39
39
  "codecov"
40
40
  ],
41
41
  "dependencies": {
42
- "@squiz/component-cli-lib": "1.3.3",
42
+ "@squiz/component-cli-lib": "1.6.1-alpha.3",
43
43
  "axios": "1.1.3",
44
44
  "cli-color": "2.0.3",
45
45
  "commander": "9.4.0",