@trayio/cdk-cli 3.8.0 → 3.9.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/README.md +1 -1
- package/dist/commands/connector/add-operation.js +61 -75
- package/dist/commands/connector/add-operation.unit.test.js +6 -15
- package/dist/commands/connector/build.js +8 -22
- package/dist/commands/connector/import.js +49 -60
- package/dist/commands/connector/init.js +52 -66
- package/dist/commands/connector/init.unit.test.js +13 -19
- package/dist/commands/connector/test.js +31 -42
- package/dist/commands/deployment/create.js +38 -52
- package/dist/commands/deployment/create.unit.test.js +24 -28
- package/dist/commands/deployment/get.js +115 -129
- package/dist/commands/deployment/get.unit.test.js +35 -39
- package/dist/commands/permissions/add.js +137 -155
- package/dist/commands/permissions/add.unit.test.js +6 -15
- package/dist/commands/permissions/list.js +75 -89
- package/dist/commands/permissions/list.unit.test.js +20 -24
- package/oclif.manifest.json +1 -1
- package/package.json +7 -7
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -17,39 +8,37 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
8
|
const lodash_1 = require("lodash");
|
|
18
9
|
const child_process_1 = require("child_process");
|
|
19
10
|
class Test extends core_1.Command {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
11
|
+
static description = 'Build and test connector project or an operation';
|
|
12
|
+
static args = {
|
|
13
|
+
operationName: core_1.Args.string({
|
|
14
|
+
name: 'Operation name',
|
|
15
|
+
required: false,
|
|
16
|
+
description: 'Operation name to run the test against',
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
static flags = {
|
|
20
|
+
verbose: core_1.Flags.boolean({
|
|
21
|
+
char: 'v',
|
|
22
|
+
description: 'Logs the input and output of an operation, requires operation name argument to be specified',
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
async run() {
|
|
26
|
+
const { args, flags } = await this.parse(Test);
|
|
27
|
+
const operationNameSnakeCase = (0, lodash_1.snakeCase)(args.operationName);
|
|
28
|
+
this.log(chalk_1.default.bold(chalk_1.default.gray('Running npm compile...')));
|
|
29
|
+
(0, child_process_1.execSync)('npm run compile', { stdio: 'inherit' });
|
|
30
|
+
if (operationNameSnakeCase) {
|
|
31
|
+
const verboseFlag = flags.verbose ? '-- --verbose=true' : '';
|
|
32
|
+
this.log(chalk_1.default.bold(chalk_1.default.gray(`Running test for ${operationNameSnakeCase}...`)));
|
|
33
|
+
(0, child_process_1.execSync)(`npm run test ./src/${operationNameSnakeCase}/handler.test.ts ${verboseFlag}`, {
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
this.log(chalk_1.default.bold(chalk_1.default.gray('Running npm test...')));
|
|
39
|
+
(0, child_process_1.execSync)('npm run test', { stdio: 'inherit' });
|
|
40
|
+
}
|
|
41
|
+
this.log(chalk_1.default.bold(chalk_1.default.green('Tests ran successfully')));
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
|
-
Test.description = 'Build and test connector project or an operation';
|
|
42
|
-
Test.args = {
|
|
43
|
-
operationName: core_1.Args.string({
|
|
44
|
-
name: 'Operation name',
|
|
45
|
-
required: false,
|
|
46
|
-
description: 'Operation name to run the test against',
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
Test.flags = {
|
|
50
|
-
verbose: core_1.Flags.boolean({
|
|
51
|
-
char: 'v',
|
|
52
|
-
description: 'Logs the input and output of an operation, requires operation name argument to be specified',
|
|
53
|
-
}),
|
|
54
|
-
};
|
|
55
44
|
exports.default = Test;
|
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -45,51 +36,46 @@ const build_1 = __importDefault(require("../connector/build"));
|
|
|
45
36
|
const colorizeString_1 = require("../../utils/colorizeString");
|
|
46
37
|
const check_env_1 = require("../../utils/check-env");
|
|
47
38
|
class Create extends core_1.Command {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
if (response.
|
|
77
|
-
|
|
78
|
-
if (response.value.repeatDeployment === true) {
|
|
79
|
-
core_1.ux.action.stop((0, colorizeString_1.warning)(`Connector ${connectorName} - ${connectorVersion} deployment is already in progress. Deployment ID: ${id}. Please check for the status using 'tray-cdk deployment get' command.`));
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
core_1.ux.action.stop((0, colorizeString_1.success)('Deployment created! The deployment may take a few minutes to complete. Use `tray-cdk deployment get` to check the status.'));
|
|
83
|
-
this.log(`Connector ${connectorName} - ${connectorVersion} deployment is in progress. Deployment ID: ${id}.`);
|
|
84
|
-
}
|
|
39
|
+
static description = 'Creates a new deployment for a connector project';
|
|
40
|
+
static args = {};
|
|
41
|
+
connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
|
|
42
|
+
baseUrl: process.env.TRAY_API_URL,
|
|
43
|
+
}, new AxiosHttpClient_1.AxiosHttpClient());
|
|
44
|
+
async run() {
|
|
45
|
+
(0, check_env_1.checkEnv)();
|
|
46
|
+
await test_1.default.run([]);
|
|
47
|
+
await build_1.default.run([]);
|
|
48
|
+
const currentDirectory = process.cwd();
|
|
49
|
+
const connectorZipPath = pathLib.join(currentDirectory, 'dist', 'connector.zip');
|
|
50
|
+
const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
|
|
51
|
+
const zipFile = fse.readFileSync(connectorZipPath);
|
|
52
|
+
const sourceCode = Buffer.from(zipFile).toString('base64');
|
|
53
|
+
const connectorJsonPath = pathLib.join(currentDirectory, 'connector.json');
|
|
54
|
+
const connectorJson = fse.readJsonSync(connectorJsonPath);
|
|
55
|
+
const connectorName = connectorJson.name;
|
|
56
|
+
const connectorVersion = connectorJson.version;
|
|
57
|
+
const input = {
|
|
58
|
+
connectorName,
|
|
59
|
+
connectorVersion,
|
|
60
|
+
connectorSourceCode: sourceCode,
|
|
61
|
+
token: TRAY_API_TOKEN,
|
|
62
|
+
};
|
|
63
|
+
core_1.ux.action.start('Creating Connector Deployment');
|
|
64
|
+
const response = await this.connectorDeployment.deployFromSourceCode(input);
|
|
65
|
+
if (response.isSuccess) {
|
|
66
|
+
const { id } = response.value;
|
|
67
|
+
if (response.value.repeatDeployment === true) {
|
|
68
|
+
core_1.ux.action.stop((0, colorizeString_1.warning)(`Connector ${connectorName} - ${connectorVersion} deployment is already in progress. Deployment ID: ${id}. Please check for the status using 'tray-cdk deployment get' command.`));
|
|
85
69
|
}
|
|
86
|
-
|
|
87
|
-
core_1.ux.action.stop((0, colorizeString_1.
|
|
88
|
-
this.log(
|
|
70
|
+
else {
|
|
71
|
+
core_1.ux.action.stop((0, colorizeString_1.success)('Deployment created! The deployment may take a few minutes to complete. Use `tray-cdk deployment get` to check the status.'));
|
|
72
|
+
this.log(`Connector ${connectorName} - ${connectorVersion} deployment is in progress. Deployment ID: ${id}.`);
|
|
89
73
|
}
|
|
90
|
-
}
|
|
74
|
+
}
|
|
75
|
+
if (response.isFailure) {
|
|
76
|
+
core_1.ux.action.stop((0, colorizeString_1.error)('There was an error creating the deployment.'));
|
|
77
|
+
this.log(response.error.message);
|
|
78
|
+
}
|
|
91
79
|
}
|
|
92
80
|
}
|
|
93
|
-
Create.description = 'Creates a new deployment for a connector project';
|
|
94
|
-
Create.args = {};
|
|
95
81
|
exports.default = Create;
|
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -38,58 +29,63 @@ describe('Create', () => {
|
|
|
38
29
|
let repeatDeployment = false;
|
|
39
30
|
beforeEach(() => {
|
|
40
31
|
ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient.mockImplementation(() => ({
|
|
41
|
-
deployFromSourceCode: jest.fn().mockReturnValue(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
deployFromSourceCode: jest.fn().mockReturnValue({
|
|
33
|
+
isSuccess: success,
|
|
34
|
+
...(success && {
|
|
35
|
+
value: {
|
|
36
|
+
id: 'some-id',
|
|
37
|
+
repeatDeployment,
|
|
38
|
+
},
|
|
39
|
+
}),
|
|
40
|
+
isFailure: failure,
|
|
41
|
+
...(failure && {
|
|
42
|
+
error: {
|
|
43
|
+
message: 'There was an error deploying the connector',
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
}),
|
|
51
47
|
}));
|
|
52
48
|
});
|
|
53
49
|
afterAll(() => {
|
|
54
50
|
jest.clearAllMocks();
|
|
55
51
|
});
|
|
56
|
-
it('should create a deployment without errors', () =>
|
|
52
|
+
it('should create a deployment without errors', async () => {
|
|
57
53
|
success = true;
|
|
58
54
|
failure = false;
|
|
59
55
|
repeatDeployment = false;
|
|
60
56
|
const startSpy = jest.spyOn(core_1.ux.action, 'start');
|
|
61
57
|
const stopSpy = jest.spyOn(core_1.ux.action, 'stop');
|
|
62
58
|
stdout_stderr_1.stdout.start();
|
|
63
|
-
|
|
59
|
+
await create_1.default.run([]);
|
|
64
60
|
stdout_stderr_1.stdout.stop();
|
|
65
61
|
expect(test_1.default.run).toHaveBeenCalledWith([]);
|
|
66
62
|
expect(build_1.default.run).toHaveBeenCalledWith([]);
|
|
67
63
|
expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
|
|
68
64
|
expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('Deployment created! The deployment may take a few minutes to complete. Use `tray-cdk deployment get` to check the status.'));
|
|
69
65
|
expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector connectorName - 1.0 deployment is in progress. Deployment ID: some-id.'));
|
|
70
|
-
})
|
|
71
|
-
it('should inform user of repeatDeployment when deployment is already in progress', () =>
|
|
66
|
+
});
|
|
67
|
+
it('should inform user of repeatDeployment when deployment is already in progress', async () => {
|
|
72
68
|
success = true;
|
|
73
69
|
failure = false;
|
|
74
70
|
repeatDeployment = true;
|
|
75
71
|
const startSpy = jest.spyOn(core_1.ux.action, 'start');
|
|
76
72
|
const stopSpy = jest.spyOn(core_1.ux.action, 'stop');
|
|
77
|
-
|
|
73
|
+
await create_1.default.run([]);
|
|
78
74
|
expect(test_1.default.run).toHaveBeenCalledWith([]);
|
|
79
75
|
expect(build_1.default.run).toHaveBeenCalledWith([]);
|
|
80
76
|
expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
|
|
81
77
|
expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining(`Connector connectorName - 1.0 deployment is already in progress. Deployment ID: some-id. Please check for the status using 'tray-cdk deployment get' command.`));
|
|
82
|
-
})
|
|
83
|
-
it('should error when the deployment fails', () =>
|
|
78
|
+
});
|
|
79
|
+
it('should error when the deployment fails', async () => {
|
|
84
80
|
success = false;
|
|
85
81
|
failure = true;
|
|
86
82
|
repeatDeployment = false;
|
|
87
83
|
const startSpy = jest.spyOn(core_1.ux.action, 'start');
|
|
88
84
|
const stopSpy = jest.spyOn(core_1.ux.action, 'stop');
|
|
89
|
-
|
|
85
|
+
await create_1.default.run([]);
|
|
90
86
|
expect(test_1.default.run).toHaveBeenCalledWith([]);
|
|
91
87
|
expect(build_1.default.run).toHaveBeenCalledWith([]);
|
|
92
88
|
expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
|
|
93
89
|
expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('There was an error creating the deployment.'));
|
|
94
|
-
})
|
|
90
|
+
});
|
|
95
91
|
});
|
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
26
|
const core_1 = require("@oclif/core");
|
|
36
27
|
const pathLib = __importStar(require("path"));
|
|
@@ -42,129 +33,124 @@ const uuid_1 = require("uuid");
|
|
|
42
33
|
const colorizeString_1 = require("../../utils/colorizeString");
|
|
43
34
|
const check_env_1 = require("../../utils/check-env");
|
|
44
35
|
class Get extends core_1.Command {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
36
|
+
static description = 'Retrieves the status of a connector deployment';
|
|
37
|
+
static args = {
|
|
38
|
+
connectorName: core_1.Args.string({
|
|
39
|
+
name: 'Connector Name',
|
|
40
|
+
required: false,
|
|
41
|
+
description: 'The name of the connector',
|
|
42
|
+
}),
|
|
43
|
+
connectorVersion: core_1.Args.string({
|
|
44
|
+
name: 'Connector Version',
|
|
45
|
+
required: false,
|
|
46
|
+
description: 'The version of the connector',
|
|
47
|
+
}),
|
|
48
|
+
uuid: core_1.Args.string({
|
|
49
|
+
name: 'Deployment UUID',
|
|
50
|
+
required: false,
|
|
51
|
+
description: 'The UUID of the deployment, this is included in the tray-cdk deploy output',
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
static flags = {
|
|
55
|
+
tail: core_1.Flags.boolean({
|
|
56
|
+
char: 't',
|
|
57
|
+
description: 'Enables the command to run until the deployment is complete with either a success or failure.',
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
static examples = [
|
|
61
|
+
`<%= config.bin %> <%= command.id %>`,
|
|
62
|
+
`<%= config.bin %> <%= command.id %> --tail`,
|
|
63
|
+
`<%= config.bin %> <%= command.id %> -t`,
|
|
64
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0`,
|
|
65
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0 --tail`,
|
|
66
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0 -t`,
|
|
67
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3`,
|
|
68
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 --tail`,
|
|
69
|
+
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 -t`,
|
|
70
|
+
];
|
|
71
|
+
connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
|
|
72
|
+
baseUrl: process.env.TRAY_API_URL,
|
|
73
|
+
}, new AxiosHttpClient_1.AxiosHttpClient());
|
|
74
|
+
generateConnectorDeploymentId = (connectorName, connectorVersion) => (0, uuid_1.v5)(`${connectorName}-${connectorVersion}`, uuid_1.v5.URL);
|
|
75
|
+
pollConnectorDeploymentStatus = async (connectorName, connectorVersion, id, token) => {
|
|
76
|
+
const input = {
|
|
77
|
+
connectorName,
|
|
78
|
+
connectorVersion,
|
|
79
|
+
id,
|
|
80
|
+
token,
|
|
81
81
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
token: TRAY_API_TOKEN,
|
|
82
|
+
const response = await this.connectorDeployment.get(input);
|
|
83
|
+
if (response.isSuccess &&
|
|
84
|
+
response.value.deploymentStatus === ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying) {
|
|
85
|
+
await new Promise((resolve) => {
|
|
86
|
+
setTimeout(resolve, 5000);
|
|
87
|
+
});
|
|
88
|
+
return this.pollConnectorDeploymentStatus(connectorName, connectorVersion, id, token);
|
|
89
|
+
}
|
|
90
|
+
return response;
|
|
91
|
+
};
|
|
92
|
+
getLocalConnectorInfo = () => {
|
|
93
|
+
const currentDirectory = process.cwd();
|
|
94
|
+
const connectorJsonPath = pathLib.join(currentDirectory, 'connector.json');
|
|
95
|
+
try {
|
|
96
|
+
const connectorJson = fse.readJsonSync(connectorJsonPath);
|
|
97
|
+
return {
|
|
98
|
+
name: connectorJson.name,
|
|
99
|
+
version: connectorJson.version,
|
|
101
100
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
throw new Error(`Connector JSON file not found in the current directory. Please provide the connector name and version as arguments`);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
async run() {
|
|
107
|
+
(0, check_env_1.checkEnv)();
|
|
108
|
+
const { args, flags } = await this.parse(Get);
|
|
109
|
+
const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
|
|
110
|
+
if (!args.connectorName || !args.connectorVersion) {
|
|
111
|
+
core_1.ux.action.start('No arguments provided, attempting to use local connector');
|
|
112
|
+
const { name, version } = this.getLocalConnectorInfo();
|
|
113
|
+
args.connectorName = name;
|
|
114
|
+
args.connectorVersion = version;
|
|
115
|
+
core_1.ux.action.stop(`Local connector found. Name: ${name}, Version: ${version}`);
|
|
116
|
+
}
|
|
117
|
+
const input = {
|
|
118
|
+
connectorName: args.connectorName,
|
|
119
|
+
connectorVersion: args.connectorVersion,
|
|
120
|
+
id: args.uuid ||
|
|
121
|
+
this.generateConnectorDeploymentId(args.connectorName, args.connectorVersion),
|
|
122
|
+
token: TRAY_API_TOKEN,
|
|
123
|
+
};
|
|
124
|
+
let response;
|
|
125
|
+
if (flags.tail) {
|
|
126
|
+
core_1.ux.action.start(`Checking the connector deployment status with tailing`);
|
|
127
|
+
response = await this.pollConnectorDeploymentStatus(input.connectorName, input.connectorVersion, input.id, input.token);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
core_1.ux.action.start(`Checking the connector deployment status`);
|
|
131
|
+
response = await this.connectorDeployment.get(input);
|
|
132
|
+
}
|
|
133
|
+
core_1.ux.action.stop();
|
|
134
|
+
if (response.isSuccess) {
|
|
135
|
+
switch (response.value.deploymentStatus) {
|
|
136
|
+
case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deploying:
|
|
137
|
+
this.log((0, colorizeString_1.info)(`Connector is currently being deployed, this could take a few minutes. Please check the connector status again later.`));
|
|
138
|
+
break;
|
|
139
|
+
case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Deployed:
|
|
140
|
+
this.log((0, colorizeString_1.success)(`Connector Deployed Successfully! 🎉 🎉 🎉`));
|
|
141
|
+
break;
|
|
142
|
+
case ConnectorDeploymentApi_1.ConnectorDeploymentStatus.Failed:
|
|
143
|
+
this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
|
|
147
|
+
break;
|
|
131
148
|
}
|
|
132
|
-
}
|
|
149
|
+
}
|
|
150
|
+
if (response.isFailure) {
|
|
151
|
+
this.log((0, colorizeString_1.error)(`Connector Deploy Failed, please try again or contact support`));
|
|
152
|
+
this.log(response.error.message);
|
|
153
|
+
}
|
|
133
154
|
}
|
|
134
155
|
}
|
|
135
|
-
Get.description = 'Retrieves the status of a connector deployment';
|
|
136
|
-
Get.args = {
|
|
137
|
-
connectorName: core_1.Args.string({
|
|
138
|
-
name: 'Connector Name',
|
|
139
|
-
required: false,
|
|
140
|
-
description: 'The name of the connector',
|
|
141
|
-
}),
|
|
142
|
-
connectorVersion: core_1.Args.string({
|
|
143
|
-
name: 'Connector Version',
|
|
144
|
-
required: false,
|
|
145
|
-
description: 'The version of the connector',
|
|
146
|
-
}),
|
|
147
|
-
uuid: core_1.Args.string({
|
|
148
|
-
name: 'Deployment UUID',
|
|
149
|
-
required: false,
|
|
150
|
-
description: 'The UUID of the deployment, this is included in the tray-cdk deploy output',
|
|
151
|
-
}),
|
|
152
|
-
};
|
|
153
|
-
Get.flags = {
|
|
154
|
-
tail: core_1.Flags.boolean({
|
|
155
|
-
char: 't',
|
|
156
|
-
description: 'Enables the command to run until the deployment is complete with either a success or failure.',
|
|
157
|
-
}),
|
|
158
|
-
};
|
|
159
|
-
Get.examples = [
|
|
160
|
-
`<%= config.bin %> <%= command.id %>`,
|
|
161
|
-
`<%= config.bin %> <%= command.id %> --tail`,
|
|
162
|
-
`<%= config.bin %> <%= command.id %> -t`,
|
|
163
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0`,
|
|
164
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0 --tail`,
|
|
165
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0 -t`,
|
|
166
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3`,
|
|
167
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 --tail`,
|
|
168
|
-
`<%= config.bin %> <%= command.id %> my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 -t`,
|
|
169
|
-
];
|
|
170
156
|
exports.default = Get;
|