@trayio/cdk-cli 0.8.0 → 0.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 CHANGED
@@ -24,7 +24,7 @@ $ npm install -g @trayio/cdk-cli
24
24
  $ tray-cdk COMMAND
25
25
  running command...
26
26
  $ tray-cdk (--version|-v)
27
- @trayio/cdk-cli/0.8.0 linux-x64 node-v18.17.1
27
+ @trayio/cdk-cli/0.9.0 linux-x64 node-v18.17.1
28
28
  $ tray-cdk --help [COMMAND]
29
29
  USAGE
30
30
  $ tray-cdk COMMAND
@@ -38,6 +38,8 @@ USAGE
38
38
  * [`tray-cdk`](#tray-cdk)
39
39
  * [`tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]`](#tray-cdk-add-operation-operationname-operationtype)
40
40
  * [`tray-cdk autocomplete [SHELL]`](#tray-cdk-autocomplete-shell)
41
+ * [`tray-cdk build`](#tray-cdk-build)
42
+ * [`tray-cdk deploy`](#tray-cdk-deploy)
41
43
  * [`tray-cdk help [COMMANDS]`](#tray-cdk-help-commands)
42
44
  * [`tray-cdk init [CONNECTORNAME]`](#tray-cdk-init-connectorname)
43
45
  * [`tray-cdk test [OPERATIONNAME]`](#tray-cdk-test-operationname)
@@ -95,6 +97,30 @@ EXAMPLES
95
97
 
96
98
  _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v2.1.9/src/commands/autocomplete/index.ts)_
97
99
 
100
+ ## `tray-cdk build`
101
+
102
+ Builds a connector project
103
+
104
+ ```
105
+ USAGE
106
+ $ tray-cdk build
107
+
108
+ DESCRIPTION
109
+ Builds a connector project
110
+ ```
111
+
112
+ ## `tray-cdk deploy`
113
+
114
+ Deploys a connector project
115
+
116
+ ```
117
+ USAGE
118
+ $ tray-cdk deploy
119
+
120
+ DESCRIPTION
121
+ Deploys a connector project
122
+ ```
123
+
98
124
  ## `tray-cdk help [COMMANDS]`
99
125
 
100
126
  Display help for tray-cdk.
@@ -0,0 +1,8 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class BuildConnector extends Command {
3
+ static description: string;
4
+ static args: {};
5
+ private connectorBuilder;
6
+ run(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,OAAO;IAClD,MAAM,CAAC,WAAW,SAAgC;IAElD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,gBAAgB,CAA0B;IAE5C,GAAG;CAMT"}
package/dist/build.js ADDED
@@ -0,0 +1,34 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const core_1 = require("@oclif/core");
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const ConnectorBuilder_1 = require("@trayio/cdk-build/connector/ConnectorBuilder");
18
+ class BuildConnector extends core_1.Command {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.connectorBuilder = new ConnectorBuilder_1.ConnectorBuilder();
22
+ }
23
+ run() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const currentDirectory = process.cwd();
26
+ this.log('Connector Build Started');
27
+ yield this.connectorBuilder.buildConnector(currentDirectory)();
28
+ this.log(chalk_1.default.bold(chalk_1.default.green(`Connector Build Finished`)));
29
+ });
30
+ }
31
+ }
32
+ BuildConnector.description = 'Builds a connector project';
33
+ BuildConnector.args = {};
34
+ exports.default = BuildConnector;
@@ -0,0 +1,8 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class DeployConnector extends Command {
3
+ static description: string;
4
+ static args: {};
5
+ private connectorDeployment;
6
+ run(): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQtC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAAiC;IAEnD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CAuCT"}
package/dist/deploy.js ADDED
@@ -0,0 +1,83 @@
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 __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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const core_1 = require("@oclif/core");
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ const pathLib = __importStar(require("path"));
41
+ const fse = __importStar(require("fs-extra"));
42
+ const AxiosHttpClient_1 = require("@trayio/tray-axios/http/AxiosHttpClient");
43
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
44
+ class DeployConnector extends core_1.Command {
45
+ constructor() {
46
+ super(...arguments);
47
+ this.connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
48
+ baseUrl: process.env.TRAY_API_URL,
49
+ }, new AxiosHttpClient_1.AxiosHttpClient());
50
+ }
51
+ run() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ const currentDirectory = process.cwd();
54
+ const connectorZipPath = pathLib.join(currentDirectory, 'dist', 'connector.zip');
55
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
56
+ const zipFile = fse.readFileSync(connectorZipPath);
57
+ const sourceCode = Buffer.from(zipFile).toString('base64');
58
+ const connectorJsonPath = pathLib.join(currentDirectory, 'connector.json');
59
+ const connectorJson = fse.readJsonSync(connectorJsonPath);
60
+ const connectorName = connectorJson.name;
61
+ const connectorVersion = connectorJson.version;
62
+ const input = {
63
+ connectorName,
64
+ connectorVersion,
65
+ connectorSourceCode: sourceCode,
66
+ token: TRAY_API_TOKEN,
67
+ };
68
+ this.log('Connector Deploy Started');
69
+ const response = yield this.connectorDeployment.deployFromSourceCode(input);
70
+ if (response.isSuccess) {
71
+ this.log(chalk_1.default.bold(chalk_1.default.green(`Connector Deploy Finished`)));
72
+ this.log(JSON.stringify(response));
73
+ }
74
+ if (response.isFailure) {
75
+ this.log(chalk_1.default.bold(chalk_1.default.red(`Connector Deploy Failed`)));
76
+ this.log(response.error.message);
77
+ }
78
+ });
79
+ }
80
+ }
81
+ DeployConnector.description = 'Deploys a connector project';
82
+ DeployConnector.args = {};
83
+ exports.default = DeployConnector;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.0",
2
+ "version": "0.9.0",
3
3
  "commands": {
4
4
  "add-operation": {
5
5
  "id": "add-operation",
@@ -27,6 +27,28 @@
27
27
  }
28
28
  }
29
29
  },
30
+ "build": {
31
+ "id": "build",
32
+ "description": "Builds a connector project",
33
+ "strict": true,
34
+ "pluginName": "@trayio/cdk-cli",
35
+ "pluginAlias": "@trayio/cdk-cli",
36
+ "pluginType": "core",
37
+ "aliases": [],
38
+ "flags": {},
39
+ "args": {}
40
+ },
41
+ "deploy": {
42
+ "id": "deploy",
43
+ "description": "Deploys a connector project",
44
+ "strict": true,
45
+ "pluginName": "@trayio/cdk-cli",
46
+ "pluginAlias": "@trayio/cdk-cli",
47
+ "pluginType": "core",
48
+ "aliases": [],
49
+ "flags": {},
50
+ "args": {}
51
+ },
30
52
  ".": {
31
53
  "id": ".",
32
54
  "pluginName": "@trayio/cdk-cli",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-cli",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A CLI for connector development",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -19,6 +19,9 @@
19
19
  "@oclif/plugin-help": "*",
20
20
  "@oclif/plugin-version": "*",
21
21
  "@oclif/test": "*",
22
+ "@trayio/cdk-build": "0.9.0",
23
+ "@trayio/tray-axios": "*",
24
+ "@trayio/tray-client": "0.9.0",
22
25
  "@trayio/tray-generator": "*",
23
26
  "@types/inquirer": "8.2.6",
24
27
  "chalk": "4.1.2",