@unito/integration-cli 0.55.5 → 0.56.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/src/commands/activity.js +1 -1
- package/dist/src/commands/dev.js +1 -1
- package/dist/src/commands/encrypt.js +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/invite.js +1 -1
- package/dist/src/commands/login.js +1 -1
- package/dist/src/commands/oauth2.js +1 -1
- package/dist/src/commands/publish.js +1 -1
- package/dist/src/commands/test.js +1 -1
- package/dist/src/commands/upgrade.js +1 -1
- package/dist/src/errors.d.ts +2 -1
- package/dist/src/errors.js +36 -36
- package/dist/test/commands/encrypt.test.js +2 -2
- package/dist/test/commands/publish.test.js +2 -2
- package/dist/test/errors.test.js +45 -40
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/src/commands/dev.js
CHANGED
|
@@ -14,7 +14,7 @@ class Dev extends baseCommand_1.BaseCommand {
|
|
|
14
14
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
15
15
|
async catch(error) {
|
|
16
16
|
/* istanbul ignore if */
|
|
17
|
-
if ((0, errors_1.handleError)(error)) {
|
|
17
|
+
if ((0, errors_1.handleError)(this, error)) {
|
|
18
18
|
this.exit(-1);
|
|
19
19
|
}
|
|
20
20
|
throw error;
|
|
@@ -12,7 +12,7 @@ class Upgrade extends baseCommand_1.BaseCommand {
|
|
|
12
12
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
13
13
|
/* istanbul ignore next */
|
|
14
14
|
async catch(error) {
|
|
15
|
-
if ((0, errors_1.handleError)(error)) {
|
|
15
|
+
if ((0, errors_1.handleError)(this, error)) {
|
|
16
16
|
this.exit(-1);
|
|
17
17
|
}
|
|
18
18
|
throw error;
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
1
2
|
export declare class NoIntegrationFoundError extends Error {
|
|
2
3
|
}
|
|
3
4
|
export declare class NoConfigurationFileError extends Error {
|
|
@@ -35,4 +36,4 @@ export declare class ConfigurationInvalid extends Error {
|
|
|
35
36
|
prettyDetails: string;
|
|
36
37
|
constructor(message: string, details: unknown, prettyDetails: string);
|
|
37
38
|
}
|
|
38
|
-
export declare function handleError(error: Error): boolean;
|
|
39
|
+
export declare function handleError(command: Command, error: Error): boolean;
|
package/dist/src/errors.js
CHANGED
|
@@ -71,87 +71,87 @@ class ConfigurationInvalid extends Error {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
exports.ConfigurationInvalid = ConfigurationInvalid;
|
|
74
|
-
function handleError(error) {
|
|
74
|
+
function handleError(command, error) {
|
|
75
75
|
/* istanbul ignore if */
|
|
76
76
|
if (core_1.ux.action.running) {
|
|
77
77
|
core_1.ux.action.stop(chalk_1.default.redBright('failed'));
|
|
78
78
|
}
|
|
79
79
|
let handled = false;
|
|
80
80
|
if (error instanceof NoIntegrationFoundError) {
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
command.logToStderr(chalk_1.default.redBright('Your directory does not seem to contain an integration :('));
|
|
82
|
+
command.logToStderr(`Make sure you are in the right directory and that you have a ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} file.`);
|
|
83
83
|
handled = true;
|
|
84
84
|
}
|
|
85
85
|
else if (error instanceof NoConfigurationFileError) {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
command.logToStderr(chalk_1.default.redBright('This command requires a configuration file for your integration :('));
|
|
87
|
+
command.logToStderr(`This file should be located at ${chalk_1.default.yellowBright(path_1.default.relative(process.cwd(), (0, configuration_1.getConfigurationPath)()))}.`);
|
|
88
88
|
handled = true;
|
|
89
89
|
}
|
|
90
90
|
else if (error instanceof MissingEnvironmentVariableError) {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
command.logToStderr(chalk_1.default.redBright('This command requires a variable which is missing from your environment :('));
|
|
92
|
+
command.logToStderr(`Make sure the environment variable ${chalk_1.default.yellowBright(error.message)} is defined.`);
|
|
93
93
|
handled = true;
|
|
94
94
|
}
|
|
95
95
|
else if (error instanceof ConfigurationMalformed) {
|
|
96
|
-
|
|
96
|
+
command.logToStderr(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} was found but its not a valid JSON file!`));
|
|
97
97
|
handled = true;
|
|
98
98
|
}
|
|
99
99
|
else if (error instanceof ConfigurationInvalid) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
command.logToStderr(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(configuration_1.DEFAULT_CONFIGURATION_NAME)} is invalid!`));
|
|
101
|
+
command.logToStderr();
|
|
102
|
+
command.logToStderr(error.prettyDetails);
|
|
103
103
|
handled = true;
|
|
104
104
|
}
|
|
105
105
|
else if (error instanceof NoRefreshTokenError) {
|
|
106
|
-
|
|
106
|
+
command.logToStderr(chalk_1.default.redBright('No refresh token found in your configuration file'));
|
|
107
107
|
handled = true;
|
|
108
108
|
}
|
|
109
109
|
else if (error instanceof FailedToRetrieveAccessTokenError) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
command.logToStderr(chalk_1.default.redBright('Failed to retrieve access token'));
|
|
111
|
+
command.logToStderr();
|
|
112
|
+
command.logToStderr(error.message);
|
|
113
113
|
handled = true;
|
|
114
114
|
}
|
|
115
115
|
else if (error instanceof InvalidRequestContentTypeError) {
|
|
116
|
-
|
|
116
|
+
command.logToStderr(chalk_1.default.redBright('Invalid request content type'));
|
|
117
117
|
handled = true;
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
command.logToStderr();
|
|
119
|
+
command.logToStderr(error.message);
|
|
120
120
|
}
|
|
121
121
|
else if (error instanceof integrationsPlatform_1.HttpError) {
|
|
122
122
|
handled = true;
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
command.logToStderr();
|
|
124
|
+
command.logToStderr((0, json_colorizer_1.default)(JSON.stringify(error.data, null, 2)));
|
|
125
125
|
}
|
|
126
126
|
else if (error instanceof MissingCredentialsError) {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
command.logToStderr();
|
|
128
|
+
command.logToStderr(chalk_1.default.redBright('The credentials are missing from your configuration file'));
|
|
129
129
|
handled = true;
|
|
130
130
|
}
|
|
131
131
|
else if (error instanceof MissingApiKey) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
command.logToStderr();
|
|
133
|
+
command.logToStderr(chalk_1.default.redBright('Your API key is not set!'));
|
|
134
|
+
command.logToStderr(`Make sure to run the ${chalk_1.default.yellowBright('login')} command first`);
|
|
135
135
|
handled = true;
|
|
136
136
|
}
|
|
137
137
|
else if (error instanceof AuthenticationFailed) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
command.logToStderr();
|
|
139
|
+
command.logToStderr(chalk_1.default.redBright('This command requires that you are logged to Unito!'));
|
|
140
|
+
command.logToStderr(`Make sure to run the ${chalk_1.default.yellowBright('login')} command first`);
|
|
141
141
|
handled = true;
|
|
142
142
|
}
|
|
143
143
|
else if (error instanceof DecryptionAuthenticationError) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
command.logToStderr();
|
|
145
|
+
command.logToStderr(chalk_1.default.yellowBright(`Your configuration contains encrypted ${error.encryptedEntityName}.`));
|
|
146
|
+
command.logToStderr('To use them locally, you must be authenticated to Unito.');
|
|
147
147
|
handled = true;
|
|
148
148
|
}
|
|
149
149
|
else if (error instanceof EntryDecryptionError) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
command.logToStderr();
|
|
151
|
+
command.logToStderr(chalk_1.default.yellowBright(`Error decrypting entry:`));
|
|
152
|
+
command.logToStderr(chalk_1.default.redBright(`${error.key}: ${error.value}`));
|
|
153
|
+
command.logToStderr();
|
|
154
|
+
command.logToStderr(`Make sure they were encrypted by the same environement (Currently targeting: ${error.environment}).`);
|
|
155
155
|
handled = true;
|
|
156
156
|
}
|
|
157
157
|
return handled;
|
|
@@ -53,12 +53,12 @@ describe('encrypt', () => {
|
|
|
53
53
|
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
54
54
|
});
|
|
55
55
|
test_1.test
|
|
56
|
-
.
|
|
56
|
+
.stderr()
|
|
57
57
|
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
58
58
|
.command(['encrypt'])
|
|
59
59
|
.exit(-1)
|
|
60
60
|
.it('missing api key', ctx => {
|
|
61
|
-
(0, test_1.expect)(ctx.
|
|
61
|
+
(0, test_1.expect)(ctx.stderr).to.contain('Your API key is not set!\nMake sure to run the login command first');
|
|
62
62
|
});
|
|
63
63
|
test_1.test
|
|
64
64
|
.stdout()
|
|
@@ -301,7 +301,7 @@ describe('Publish', () => {
|
|
|
301
301
|
(0, test_1.expect)(ctx.stdout).to.contain('Foo - Live Preview - 9c88');
|
|
302
302
|
});
|
|
303
303
|
test_1.test
|
|
304
|
-
.
|
|
304
|
+
.stderr()
|
|
305
305
|
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
306
306
|
.stub(IntegrationConfiguration, 'getConfiguration', () => ({}))
|
|
307
307
|
.stub(IntegrationsPlatform, 'getIntegrations', () => [])
|
|
@@ -309,7 +309,7 @@ describe('Publish', () => {
|
|
|
309
309
|
.command(['publish'])
|
|
310
310
|
.exit(-1)
|
|
311
311
|
.it('missing api key', ctx => {
|
|
312
|
-
(0, test_1.expect)(ctx.
|
|
312
|
+
(0, test_1.expect)(ctx.stderr).to.contain('Your API key is not set!\nMake sure to run the login command first');
|
|
313
313
|
});
|
|
314
314
|
test_1.test
|
|
315
315
|
.stdout()
|
package/dist/test/errors.test.js
CHANGED
|
@@ -4,93 +4,98 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const chai_1 = require("chai");
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
7
|
-
const core_1 = require("@oclif/core");
|
|
8
7
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
8
|
const errors_1 = require("../src/errors");
|
|
10
9
|
const configuration_1 = require("../src/resources/configuration");
|
|
10
|
+
const publish_1 = tslib_1.__importDefault(require("../src/commands/publish"));
|
|
11
11
|
describe('handleError', () => {
|
|
12
|
-
|
|
12
|
+
class DummyCommand extends publish_1.default {
|
|
13
|
+
logToStderr = () => { };
|
|
14
|
+
}
|
|
15
|
+
let command;
|
|
16
|
+
let stdErrStub;
|
|
13
17
|
beforeEach(() => {
|
|
14
|
-
|
|
18
|
+
command = new DummyCommand([], {});
|
|
19
|
+
stdErrStub = sinon_1.default.stub(command, 'logToStderr');
|
|
15
20
|
});
|
|
16
21
|
afterEach(() => {
|
|
17
22
|
sinon_1.default.restore();
|
|
18
23
|
});
|
|
19
24
|
it('should handle NoIntegrationFoundError', () => {
|
|
20
25
|
const error = new errors_1.NoIntegrationFoundError();
|
|
21
|
-
const handled = (0, errors_1.handleError)(error);
|
|
26
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
22
27
|
(0, chai_1.expect)(handled).to.be.true;
|
|
23
|
-
(0, chai_1.expect)(
|
|
24
|
-
(0, chai_1.expect)(
|
|
25
|
-
(0, chai_1.expect)(
|
|
28
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
29
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Your directory does not seem to contain an integration :('));
|
|
30
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.include('Make sure you are in the right directory');
|
|
26
31
|
});
|
|
27
32
|
it('should handle NoConfigurationFileError', () => {
|
|
28
33
|
const error = new errors_1.NoConfigurationFileError();
|
|
29
|
-
const handled = (0, errors_1.handleError)(error);
|
|
34
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
30
35
|
(0, chai_1.expect)(handled).to.be.true;
|
|
31
|
-
(0, chai_1.expect)(
|
|
32
|
-
(0, chai_1.expect)(
|
|
33
|
-
(0, chai_1.expect)(
|
|
36
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
37
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('This command requires a configuration file for your integration :('));
|
|
38
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(`This file should be located at ${chalk_1.default.yellowBright(path_1.default.relative(process.cwd(), (0, configuration_1.getConfigurationPath)()))}.`);
|
|
34
39
|
});
|
|
35
40
|
it('should handle MissingEnvironmentVariableError', () => {
|
|
36
41
|
const error = new errors_1.MissingEnvironmentVariableError('VAR_NAME');
|
|
37
|
-
const handled = (0, errors_1.handleError)(error);
|
|
42
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
38
43
|
(0, chai_1.expect)(handled).to.be.true;
|
|
39
|
-
(0, chai_1.expect)(
|
|
40
|
-
(0, chai_1.expect)(
|
|
41
|
-
(0, chai_1.expect)(
|
|
44
|
+
(0, chai_1.expect)(stdErrStub.calledTwice).to.be.true;
|
|
45
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('This command requires a variable which is missing from your environment :('));
|
|
46
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(`Make sure the environment variable ${chalk_1.default.yellowBright('VAR_NAME')} is defined.`);
|
|
42
47
|
});
|
|
43
48
|
it('should return false for unrecognized error', () => {
|
|
44
49
|
const error = new Error('Unrecognized error');
|
|
45
|
-
const handled = (0, errors_1.handleError)(error);
|
|
50
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
46
51
|
(0, chai_1.expect)(handled).to.be.false;
|
|
47
|
-
(0, chai_1.expect)(
|
|
52
|
+
(0, chai_1.expect)(stdErrStub.called).to.be.false;
|
|
48
53
|
});
|
|
49
54
|
it('should handle MissingEnvironmentVariableError', () => {
|
|
50
55
|
const error = new errors_1.ConfigurationInvalid('VAR_NAME', 'details', 'prettyDetails');
|
|
51
|
-
const handled = (0, errors_1.handleError)(error);
|
|
56
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
52
57
|
(0, chai_1.expect)(handled).to.be.true;
|
|
53
|
-
(0, chai_1.expect)(
|
|
54
|
-
(0, chai_1.expect)(
|
|
55
|
-
(0, chai_1.expect)(
|
|
58
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
59
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright(`Your ${chalk_1.default.yellowBright(path_1.default.basename((0, configuration_1.getConfigurationPath)()))} is invalid!`));
|
|
60
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('prettyDetails');
|
|
56
61
|
});
|
|
57
62
|
it('should handle NoRefreshTokenError', () => {
|
|
58
63
|
const error = new errors_1.NoRefreshTokenError();
|
|
59
|
-
const handled = (0, errors_1.handleError)(error);
|
|
64
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
60
65
|
(0, chai_1.expect)(handled).to.be.true;
|
|
61
|
-
(0, chai_1.expect)(
|
|
62
|
-
(0, chai_1.expect)(
|
|
66
|
+
(0, chai_1.expect)(stdErrStub.calledOnce).to.be.true;
|
|
67
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('No refresh token found in your configuration file'));
|
|
63
68
|
});
|
|
64
69
|
it('should handle FailedToRetrieveAccessTokenError', () => {
|
|
65
70
|
const error = new errors_1.FailedToRetrieveAccessTokenError('Credentials invalid');
|
|
66
|
-
const handled = (0, errors_1.handleError)(error);
|
|
71
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
67
72
|
(0, chai_1.expect)(handled).to.be.true;
|
|
68
|
-
(0, chai_1.expect)(
|
|
69
|
-
(0, chai_1.expect)(
|
|
70
|
-
(0, chai_1.expect)(
|
|
73
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
74
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Failed to retrieve access token'));
|
|
75
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('Credentials invalid');
|
|
71
76
|
});
|
|
72
77
|
it('should handle InvalidRequestContentTypeError', () => {
|
|
73
78
|
const error = new errors_1.InvalidRequestContentTypeError('Invalid content type');
|
|
74
|
-
const handled = (0, errors_1.handleError)(error);
|
|
79
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
75
80
|
(0, chai_1.expect)(handled).to.be.true;
|
|
76
|
-
(0, chai_1.expect)(
|
|
77
|
-
(0, chai_1.expect)(
|
|
78
|
-
(0, chai_1.expect)(
|
|
81
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
82
|
+
(0, chai_1.expect)(stdErrStub.firstCall.args[0]).to.equal(chalk_1.default.redBright('Invalid request content type'));
|
|
83
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('Invalid content type');
|
|
79
84
|
});
|
|
80
85
|
it('should handle DecryptionAuthenticationError', () => {
|
|
81
86
|
const error = new errors_1.DecryptionAuthenticationError('secrets');
|
|
82
|
-
const handled = (0, errors_1.handleError)(error);
|
|
87
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
83
88
|
(0, chai_1.expect)(handled).to.be.true;
|
|
84
|
-
(0, chai_1.expect)(
|
|
85
|
-
(0, chai_1.expect)(
|
|
86
|
-
(0, chai_1.expect)(
|
|
89
|
+
(0, chai_1.expect)(stdErrStub.calledThrice).to.be.true;
|
|
90
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(chalk_1.default.yellowBright('Your configuration contains encrypted secrets.'));
|
|
91
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal('To use them locally, you must be authenticated to Unito.');
|
|
87
92
|
});
|
|
88
93
|
it('should handle EntryDecryptionError', () => {
|
|
89
94
|
const error = new errors_1.EntryDecryptionError('key', 'value', 'staging');
|
|
90
|
-
const handled = (0, errors_1.handleError)(error);
|
|
95
|
+
const handled = (0, errors_1.handleError)(command, error);
|
|
91
96
|
(0, chai_1.expect)(handled).to.be.true;
|
|
92
|
-
(0, chai_1.expect)(
|
|
93
|
-
(0, chai_1.expect)(
|
|
94
|
-
(0, chai_1.expect)(
|
|
97
|
+
(0, chai_1.expect)(stdErrStub.called).to.be.true;
|
|
98
|
+
(0, chai_1.expect)(stdErrStub.secondCall.args[0]).to.equal(chalk_1.default.yellowBright('Error decrypting entry:'));
|
|
99
|
+
(0, chai_1.expect)(stdErrStub.thirdCall.args[0]).to.equal(chalk_1.default.redBright('key: value'));
|
|
95
100
|
});
|
|
96
101
|
});
|
package/oclif.manifest.json
CHANGED