@trayio/cdk-cli 3.13.0 → 3.14.0-beta

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 CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @trayio/cdk-cli
19
19
  $ tray-cdk COMMAND
20
20
  running command...
21
21
  $ tray-cdk (--version|-v)
22
- @trayio/cdk-cli/3.13.0 linux-x64 node-v18.19.1
22
+ @trayio/cdk-cli/3.14.0-beta linux-x64 node-v18.19.1
23
23
  $ tray-cdk --help [COMMAND]
24
24
  USAGE
25
25
  $ tray-cdk COMMAND
@@ -39,6 +39,7 @@ USAGE
39
39
  * [`tray-cdk connector test [OPERATIONNAME]`](#tray-cdk-connector-test-operationname)
40
40
  * [`tray-cdk deployment create`](#tray-cdk-deployment-create)
41
41
  * [`tray-cdk deployment get [CONNECTORNAME] [CONNECTORVERSION] [UUID]`](#tray-cdk-deployment-get-connectorname-connectorversion-uuid)
42
+ * [`tray-cdk deployment publish`](#tray-cdk-deployment-publish)
42
43
  * [`tray-cdk help [COMMANDS]`](#tray-cdk-help-commands)
43
44
  * [`tray-cdk permissions add [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-add-connectorname-connectorversion)
44
45
  * [`tray-cdk permissions list [CONNECTORNAME] [CONNECTORVERSION]`](#tray-cdk-permissions-list-connectorname-connectorversion)
@@ -213,6 +214,18 @@ EXAMPLES
213
214
  $ tray-cdk deployment get my-connector 1.0 3f1de598-d405-4801-9eec-6fe79e8393d3 -t
214
215
  ```
215
216
 
217
+ ## `tray-cdk deployment publish`
218
+
219
+ Publishes a connector project (beta)
220
+
221
+ ```
222
+ USAGE
223
+ $ tray-cdk deployment publish
224
+
225
+ DESCRIPTION
226
+ Publishes a connector project (beta)
227
+ ```
228
+
216
229
  ## `tray-cdk help [COMMANDS]`
217
230
 
218
231
  Display help for tray-cdk.
@@ -65,10 +65,10 @@ class Create extends core_1.Command {
65
65
  if (response.isSuccess) {
66
66
  const { id } = response.value;
67
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.`));
68
+ core_1.ux.action.stop((0, colorizeString_1.warning)(`Connector ${connectorName} - ${connectorVersion} deployment is already in progress. Deployment ID: ${id}. Run "tray-cdk deployment get" to check the status.`));
69
69
  }
70
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.'));
71
+ core_1.ux.action.stop((0, colorizeString_1.success)(`Deployment created! The deployment may take a few minutes to complete. Run "tray-cdk deployment get" to check the status.`));
72
72
  this.log(`Connector ${connectorName} - ${connectorVersion} deployment is in progress. Deployment ID: ${id}.`);
73
73
  }
74
74
  }
@@ -61,7 +61,7 @@ describe('Create', () => {
61
61
  expect(test_1.default.run).toHaveBeenCalledWith([]);
62
62
  expect(build_1.default.run).toHaveBeenCalledWith([]);
63
63
  expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
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.'));
64
+ expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('Deployment created! The deployment may take a few minutes to complete. Run "tray-cdk deployment get" to check the status.'));
65
65
  expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector connectorName - 1.0 deployment is in progress. Deployment ID: some-id.'));
66
66
  });
67
67
  it('should inform user of repeatDeployment when deployment is already in progress', async () => {
@@ -74,7 +74,7 @@ describe('Create', () => {
74
74
  expect(test_1.default.run).toHaveBeenCalledWith([]);
75
75
  expect(build_1.default.run).toHaveBeenCalledWith([]);
76
76
  expect(startSpy).toHaveBeenCalledWith('Creating Connector Deployment');
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.`));
77
+ expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining(`Connector connectorName - 1.0 deployment is already in progress. Deployment ID: some-id. Run "tray-cdk deployment get" to check the status.`));
78
78
  });
79
79
  it('should error when the deployment fails', async () => {
80
80
  success = false;
@@ -0,0 +1,8 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Publish extends Command {
3
+ static description: string;
4
+ static args: {};
5
+ private connectorDeployment;
6
+ run(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/publish.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAa1C,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,OAAO;IAC3C,MAAM,CAAC,WAAW,SAA0C;IAE5D,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CAmET"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const pathLib = __importStar(require("path"));
30
+ const core_1 = require("@oclif/core");
31
+ const inquirer_1 = __importDefault(require("inquirer"));
32
+ const fse = __importStar(require("fs-extra"));
33
+ const AxiosHttpClient_1 = require("@trayio/axios/http/AxiosHttpClient");
34
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
35
+ const test_1 = __importDefault(require("../connector/test"));
36
+ const build_1 = __importDefault(require("../connector/build"));
37
+ const colorizeString_1 = require("../../utils/colorizeString");
38
+ const check_env_1 = require("../../utils/check-env");
39
+ class Publish extends core_1.Command {
40
+ static description = 'Publishes a connector project (beta)';
41
+ static args = {};
42
+ connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
43
+ baseUrl: process.env.TRAY_API_URL,
44
+ }, new AxiosHttpClient_1.AxiosHttpClient());
45
+ async run() {
46
+ (0, check_env_1.checkEnv)();
47
+ await test_1.default.run([]);
48
+ await build_1.default.run([]);
49
+ const currentDirectory = process.cwd();
50
+ const connectorZipPath = pathLib.join(currentDirectory, 'dist', 'connector.zip');
51
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
52
+ const zipFile = fse.readFileSync(connectorZipPath);
53
+ const sourceCode = Buffer.from(zipFile).toString('base64');
54
+ const connectorJsonPath = pathLib.join(currentDirectory, 'connector.json');
55
+ const connectorJson = fse.readJsonSync(connectorJsonPath);
56
+ const connectorName = connectorJson.name;
57
+ const connectorVersion = connectorJson.version;
58
+ const promptRes = await inquirer_1.default.prompt([
59
+ {
60
+ name: 'makePublic',
61
+ message: 'Make connector public?',
62
+ type: 'confirm',
63
+ // TODO: only ask this prompt for connector devs once draft is available to customers
64
+ // when: !isConnectorDev,
65
+ default: false,
66
+ },
67
+ ]);
68
+ const input = {
69
+ connectorName,
70
+ connectorVersion,
71
+ connectorSourceCode: sourceCode,
72
+ makePublic: promptRes.makePublic,
73
+ token: TRAY_API_TOKEN,
74
+ };
75
+ core_1.ux.action.start('Starting Connector Publishing\n');
76
+ const response = await this.connectorDeployment.publishFromSourceCode(input);
77
+ if (response.isSuccess) {
78
+ const { id } = response.value;
79
+ core_1.ux.action.stop((0, colorizeString_1.success)(`Publishing is in progress! This may take a few minutes to complete. Run "tray-cdk deployment get" to check the status.`));
80
+ this.log(`Connector ${connectorName} - ${connectorVersion} publishing is in progress. Deployment ID: ${id}.`);
81
+ }
82
+ if (response.isFailure) {
83
+ core_1.ux.action.stop((0, colorizeString_1.error)('There was an error trying to publish.'));
84
+ this.log(response.error.message);
85
+ }
86
+ }
87
+ }
88
+ exports.default = Publish;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=publish.unit.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publish.unit.test.d.ts","sourceRoot":"","sources":["../../../src/commands/deployment/publish.unit.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const stdout_stderr_1 = require("stdout-stderr");
7
+ const core_1 = require("@oclif/core");
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
10
+ const test_1 = __importDefault(require("../connector/test"));
11
+ const build_1 = __importDefault(require("../connector/build"));
12
+ const publish_1 = __importDefault(require("./publish"));
13
+ jest.mock('inquirer', () => ({
14
+ prompt: jest.fn(),
15
+ registerPrompt: jest.requireActual('inquirer').registerPrompt,
16
+ }));
17
+ jest.mock('fs-extra');
18
+ jest.mock('path');
19
+ jest.mock('../connector/test');
20
+ jest.mock('../connector/build');
21
+ jest.mock('@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient', () => ({
22
+ ConnectorDeploymentHttpClient: jest.fn(),
23
+ }));
24
+ jest.mock('fs-extra', () => ({
25
+ readFileSync: jest.fn().mockReturnValue(new ArrayBuffer(8)),
26
+ readJsonSync: jest.fn().mockReturnValue({
27
+ name: 'connectorName',
28
+ version: '1.0',
29
+ }),
30
+ }));
31
+ describe('Publish', () => {
32
+ const mockInquirer = inquirer_1.default;
33
+ let success = true;
34
+ let failure = false;
35
+ beforeEach(() => {
36
+ ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient.mockImplementation(() => ({
37
+ publishFromSourceCode: jest.fn().mockReturnValue({
38
+ isSuccess: success,
39
+ ...(success && {
40
+ value: {
41
+ id: 'some-id',
42
+ },
43
+ }),
44
+ isFailure: failure,
45
+ ...(failure && {
46
+ error: {
47
+ message: 'There was an error deploying the connector',
48
+ },
49
+ }),
50
+ }),
51
+ }));
52
+ });
53
+ beforeAll(() => {
54
+ mockInquirer.prompt.mockResolvedValue({
55
+ makePublic: true,
56
+ });
57
+ });
58
+ afterAll(() => {
59
+ jest.clearAllMocks();
60
+ });
61
+ it('should start publishing without errors', async () => {
62
+ success = true;
63
+ failure = false;
64
+ const startSpy = jest.spyOn(core_1.ux.action, 'start');
65
+ const stopSpy = jest.spyOn(core_1.ux.action, 'stop');
66
+ stdout_stderr_1.stdout.start();
67
+ await publish_1.default.run([]);
68
+ stdout_stderr_1.stdout.stop();
69
+ expect(test_1.default.run).toHaveBeenCalledWith([]);
70
+ expect(build_1.default.run).toHaveBeenCalledWith([]);
71
+ expect(startSpy).toHaveBeenCalledWith(expect.stringContaining('Starting Connector Publishing'));
72
+ expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('Publishing is in progress! This may take a few minutes to complete. Run "tray-cdk deployment get" to check the status.'));
73
+ expect(stdout_stderr_1.stdout.output).toEqual(expect.stringContaining('Connector connectorName - 1.0 publishing is in progress. Deployment ID: some-id.'));
74
+ });
75
+ it('should error when the publishing fails', async () => {
76
+ success = false;
77
+ failure = true;
78
+ const startSpy = jest.spyOn(core_1.ux.action, 'start');
79
+ const stopSpy = jest.spyOn(core_1.ux.action, 'stop');
80
+ await publish_1.default.run([]);
81
+ expect(test_1.default.run).toHaveBeenCalledWith([]);
82
+ expect(build_1.default.run).toHaveBeenCalledWith([]);
83
+ expect(startSpy).toHaveBeenCalledWith(expect.stringContaining('Starting Connector Publishing'));
84
+ expect(stopSpy).toHaveBeenCalledWith(expect.stringContaining('There was an error trying to publish.'));
85
+ });
86
+ });
@@ -253,6 +253,27 @@
253
253
  "get.js"
254
254
  ]
255
255
  },
256
+ "deployment:publish": {
257
+ "aliases": [],
258
+ "args": {},
259
+ "description": "Publishes a connector project (beta)",
260
+ "flags": {},
261
+ "hasDynamicHelp": false,
262
+ "hiddenAliases": [],
263
+ "id": "deployment:publish",
264
+ "pluginAlias": "@trayio/cdk-cli",
265
+ "pluginName": "@trayio/cdk-cli",
266
+ "pluginType": "core",
267
+ "strict": true,
268
+ "enableJsonFlag": false,
269
+ "isESM": false,
270
+ "relativePath": [
271
+ "dist",
272
+ "commands",
273
+ "deployment",
274
+ "publish.js"
275
+ ]
276
+ },
256
277
  "permissions:add": {
257
278
  "aliases": [],
258
279
  "args": {
@@ -343,5 +364,5 @@
343
364
  ]
344
365
  }
345
366
  },
346
- "version": "3.13.0"
367
+ "version": "3.14.0-beta"
347
368
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "3.13.0",
3
+ "version": "3.14.0-beta",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -19,12 +19,12 @@
19
19
  "@oclif/plugin-help": "6.0.12",
20
20
  "@oclif/plugin-version": "2.0.11",
21
21
  "@oclif/test": "3.1.12",
22
- "@trayio/axios": "3.13.0",
23
- "@trayio/cdk-build": "3.13.0",
24
- "@trayio/commons": "3.13.0",
25
- "@trayio/generator": "3.13.0",
26
- "@trayio/tray-client": "3.13.0",
27
- "@trayio/tray-openapi": "3.13.0",
22
+ "@trayio/axios": "3.14.0-beta",
23
+ "@trayio/cdk-build": "3.14.0-beta",
24
+ "@trayio/commons": "3.14.0-beta",
25
+ "@trayio/generator": "3.14.0-beta",
26
+ "@trayio/tray-client": "3.14.0-beta",
27
+ "@trayio/tray-openapi": "3.14.0-beta",
28
28
  "@types/inquirer": "8.2.6",
29
29
  "chalk": "4.1.2",
30
30
  "inquirer": "8.2.5"