@trayio/cdk-cli 0.0.2 → 0.0.3-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.
Files changed (39) hide show
  1. package/INTRODUCTION.md +54 -0
  2. package/LICENSE.txt +22 -0
  3. package/README.md +146 -38
  4. package/bin/dev +0 -0
  5. package/dist/commands/add-operation.d.ts +10 -0
  6. package/dist/commands/add-operation.d.ts.map +1 -0
  7. package/dist/commands/add-operation.js +98 -0
  8. package/dist/commands/build.d.ts +8 -0
  9. package/dist/commands/build.d.ts.map +1 -0
  10. package/dist/commands/build.js +34 -0
  11. package/dist/commands/composite-operation-template.zip +0 -0
  12. package/dist/commands/connector-template.zip +0 -0
  13. package/dist/commands/deploy.d.ts +8 -0
  14. package/dist/commands/deploy.d.ts.map +1 -0
  15. package/dist/commands/deploy.js +87 -0
  16. package/dist/commands/deployment-status.d.ts +12 -0
  17. package/dist/commands/deployment-status.d.ts.map +1 -0
  18. package/dist/commands/deployment-status.js +78 -0
  19. package/dist/commands/deployment-status.test.d.ts +2 -0
  20. package/dist/commands/deployment-status.test.d.ts.map +1 -0
  21. package/dist/commands/deployment-status.test.js +82 -0
  22. package/dist/commands/http-operation-template.zip +0 -0
  23. package/dist/commands/import-openapi-spec.d.ts +10 -0
  24. package/dist/commands/import-openapi-spec.d.ts.map +1 -0
  25. package/dist/commands/import-openapi-spec.js +101 -0
  26. package/dist/commands/index.d.ts +2 -0
  27. package/dist/commands/index.d.ts.map +1 -0
  28. package/dist/commands/index.js +5 -0
  29. package/dist/commands/init.d.ts +12 -0
  30. package/dist/commands/init.d.ts.map +1 -0
  31. package/dist/commands/init.js +80 -0
  32. package/dist/commands/test.d.ts +12 -0
  33. package/dist/commands/test.d.ts.map +1 -0
  34. package/dist/commands/test.js +55 -0
  35. package/dist/utils/colorizeString.d.ts +5 -0
  36. package/dist/utils/colorizeString.d.ts.map +1 -0
  37. package/dist/utils/colorizeString.js +13 -0
  38. package/oclif.manifest.json +222 -6
  39. package/package.json +68 -68
@@ -0,0 +1,54 @@
1
+ # Connector Development Kit (CDK) CLI.
2
+
3
+ The CDK Command Line Interface (CLI) is a tool that is aimed at simplifying connector development using the CDK, for a complete list of all commands refer to the [README](README.md)
4
+
5
+
6
+ ## Installing the CLI
7
+
8
+ The CLI can be installed using npm:
9
+
10
+ ```
11
+ npm install -g @trayio/cdk-cli
12
+ ```
13
+
14
+ Once the installation is complete a `tray-cdk` command should be available.
15
+
16
+ ## Creating a connector
17
+
18
+ To create a connector, the `init` command is used:
19
+
20
+ ```
21
+ tray-cdk init -i
22
+ ```
23
+
24
+ It will only ask for the connector name as input, the `-i` flag is optional, it is to install dependencies of the connector project using npm, but the flag can be omitted to install dependencies using another building tool such as yarn after creating the project.
25
+
26
+ ## Building and testing the connector
27
+
28
+ When the connector project is created, it contains a sample operation that makes a request to a fake API, so it is recommended to build and test the connector after creating the project and installing the dependencies to make sure that the project builds properly and the runtime can execute operations.
29
+
30
+ To build and test the connector using the cli, only one command is necessary:
31
+
32
+ ```
33
+ tray-cdk test
34
+ ```
35
+
36
+ This will compile the project and run all the tests, this command uses npm to run the compile and test scripts from the default `package.json`, which could be run without the cli using a different build tool, this may be preferable if the connector is a subproject in a monorepo for example.
37
+
38
+ The test command can receive an operation name as an argument to test a single operation:
39
+
40
+ ```
41
+ tray-cdk test my-operation
42
+ ```
43
+
44
+ ## Adding an operation
45
+
46
+ The CLI can be used to add the skeleton of an operation, it is recommended to delete the operation created by the `init` command once it is verified that it works properly, and use the CLI to add new operations, as it will generate all the necessary files with the right names based on the new operation's name.
47
+
48
+ To add an operation:
49
+
50
+ ```
51
+ tray-cdk add-operation
52
+ ```
53
+
54
+ It will ask for the operation's name, and for the operation's implementation, which can be HTTP or Composite, more details about these types of implementations can be found in the CDK DSL package.
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Tray.io, Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,16 +1,11 @@
1
- # @trayio/connector-cli
1
+ # @trayio/cdk-cli
2
2
 
3
3
  A collection of CLI commands for connector development.
4
4
 
5
- # Contributing
6
-
7
- [Guide on contributing](./CONTRIBUTING.md)
8
-
9
5
  # Table of Contents
10
6
 
11
7
  <!-- toc -->
12
- * [@trayio/connector-cli](#trayioconnector-cli)
13
- * [Contributing](#contributing)
8
+ * [@trayio/cdk-cli](#trayiocdk-cli)
14
9
  * [Table of Contents](#table-of-contents)
15
10
  * [Usage](#usage)
16
11
  * [Commands](#commands)
@@ -21,13 +16,13 @@ A collection of CLI commands for connector development.
21
16
  <!-- usage -->
22
17
  ```sh-session
23
18
  $ npm install -g @trayio/cdk-cli
24
- $ cdk COMMAND
19
+ $ tray-cdk COMMAND
25
20
  running command...
26
- $ cdk (--version|-v)
27
- @trayio/cdk-cli/0.0.1 darwin-x64 node-v14.21.3
28
- $ cdk --help [COMMAND]
21
+ $ tray-cdk (--version|-v)
22
+ @trayio/cdk-cli/0.0.3-beta linux-x64 node-v18.19.0
23
+ $ tray-cdk --help [COMMAND]
29
24
  USAGE
30
- $ cdk COMMAND
25
+ $ tray-cdk COMMAND
31
26
  ...
32
27
  ```
33
28
  <!-- usagestop -->
@@ -35,59 +30,120 @@ USAGE
35
30
  # Commands
36
31
 
37
32
  <!-- commands -->
38
- * [`cdk autocomplete [SHELL]`](#cdk-autocomplete-shell)
39
- * [`cdk hello`](#cdk-hello)
40
- * [`cdk help [COMMANDS]`](#cdk-help-commands)
41
- * [`cdk version`](#cdk-version)
33
+ * [`tray-cdk`](#tray-cdk)
34
+ * [`tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]`](#tray-cdk-add-operation-operationname-operationtype)
35
+ * [`tray-cdk autocomplete [SHELL]`](#tray-cdk-autocomplete-shell)
36
+ * [`tray-cdk build`](#tray-cdk-build)
37
+ * [`tray-cdk deploy`](#tray-cdk-deploy)
38
+ * [`tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID`](#tray-cdk-deployment-status-connectorname-connectorversion-uuid)
39
+ * [`tray-cdk help [COMMANDS]`](#tray-cdk-help-commands)
40
+ * [`tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`](#tray-cdk-import-openapi-spec-openapispec-connectorname)
41
+ * [`tray-cdk init [CONNECTORNAME]`](#tray-cdk-init-connectorname)
42
+ * [`tray-cdk test [OPERATIONNAME]`](#tray-cdk-test-operationname)
43
+ * [`tray-cdk version`](#tray-cdk-version)
44
+
45
+ ## `tray-cdk`
46
+
47
+ ```
48
+ USAGE
49
+ $ tray-cdk
50
+ ```
51
+
52
+ ## `tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]`
53
+
54
+ Add an operation to connector project
55
+
56
+ ```
57
+ USAGE
58
+ $ tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]
42
59
 
43
- ## `cdk autocomplete [SHELL]`
60
+ ARGUMENTS
61
+ OPERATIONNAME Operation name
62
+ OPERATIONTYPE (http|composite) Operation type
44
63
 
45
- display autocomplete installation instructions
64
+ DESCRIPTION
65
+ Add an operation to connector project
66
+ ```
67
+
68
+ ## `tray-cdk autocomplete [SHELL]`
69
+
70
+ Display autocomplete installation instructions.
46
71
 
47
72
  ```
48
73
  USAGE
49
- $ cdk autocomplete [SHELL] [-r]
74
+ $ tray-cdk autocomplete [SHELL] [-r]
50
75
 
51
76
  ARGUMENTS
52
- SHELL shell type
77
+ SHELL (zsh|bash|powershell) Shell type
53
78
 
54
79
  FLAGS
55
80
  -r, --refresh-cache Refresh cache (ignores displaying instructions)
56
81
 
57
82
  DESCRIPTION
58
- display autocomplete installation instructions
83
+ Display autocomplete installation instructions.
59
84
 
60
85
  EXAMPLES
61
- $ cdk autocomplete
86
+ $ tray-cdk autocomplete
62
87
 
63
- $ cdk autocomplete bash
88
+ $ tray-cdk autocomplete bash
64
89
 
65
- $ cdk autocomplete zsh
90
+ $ tray-cdk autocomplete zsh
66
91
 
67
- $ cdk autocomplete --refresh-cache
92
+ $ tray-cdk autocomplete powershell
93
+
94
+ $ tray-cdk autocomplete --refresh-cache
68
95
  ```
69
96
 
70
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v2.1.9/src/commands/autocomplete/index.ts)_
97
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.5/src/commands/autocomplete/index.ts)_
71
98
 
72
- ## `cdk hello`
99
+ ## `tray-cdk build`
73
100
 
74
- Hello world
101
+ Builds a connector project
75
102
 
76
103
  ```
77
104
  USAGE
78
- $ cdk hello
105
+ $ tray-cdk build
106
+
107
+ DESCRIPTION
108
+ Builds a connector project
109
+ ```
110
+
111
+ ## `tray-cdk deploy`
112
+
113
+ Deploys a connector project
114
+
115
+ ```
116
+ USAGE
117
+ $ tray-cdk deploy
118
+
119
+ DESCRIPTION
120
+ Deploys a connector project
121
+ ```
122
+
123
+ ## `tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID`
124
+
125
+ Retrieves the status of a connector deployment
126
+
127
+ ```
128
+ USAGE
129
+ $ tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID
130
+
131
+ ARGUMENTS
132
+ CONNECTORNAME The name of the connector
133
+ CONNECTORVERSION The version of the connector
134
+ UUID The UUID of the deployment, this is included in the tray-cdk deploy output
79
135
 
80
136
  DESCRIPTION
81
- Hello world
137
+ Retrieves the status of a connector deployment
82
138
  ```
83
139
 
84
- ## `cdk help [COMMANDS]`
140
+ ## `tray-cdk help [COMMANDS]`
85
141
 
86
- Display help for cdk.
142
+ Display help for tray-cdk.
87
143
 
88
144
  ```
89
145
  USAGE
90
- $ cdk help [COMMANDS] [-n]
146
+ $ tray-cdk help [COMMANDS] [-n]
91
147
 
92
148
  ARGUMENTS
93
149
  COMMANDS Command to show help for.
@@ -96,16 +152,68 @@ FLAGS
96
152
  -n, --nested-commands Include all nested commands in the output.
97
153
 
98
154
  DESCRIPTION
99
- Display help for cdk.
155
+ Display help for tray-cdk.
100
156
  ```
101
157
 
102
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.9/src/commands/help.ts)_
158
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.12/src/commands/help.ts)_
159
+
160
+ ## `tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`
161
+
162
+ Create a connector from an OpenAPI specification: Command is still in BETA
163
+
164
+ ```
165
+ USAGE
166
+ $ tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]
167
+
168
+ ARGUMENTS
169
+ OPENAPISPEC Location of the OpenAPI specification file
170
+ CONNECTORNAME The name of the connector
171
+
172
+ DESCRIPTION
173
+ Create a connector from an OpenAPI specification: Command is still in BETA
174
+ ```
175
+
176
+ ## `tray-cdk init [CONNECTORNAME]`
177
+
178
+ Initialize a connector project
179
+
180
+ ```
181
+ USAGE
182
+ $ tray-cdk init [CONNECTORNAME] [-i]
183
+
184
+ ARGUMENTS
185
+ CONNECTORNAME Connector directory name to generate template files
186
+
187
+ FLAGS
188
+ -i, --install Runs `npm install` after successful generation
189
+
190
+ DESCRIPTION
191
+ Initialize a connector project
192
+ ```
193
+
194
+ ## `tray-cdk test [OPERATIONNAME]`
195
+
196
+ Build and test connector project or an operation
197
+
198
+ ```
199
+ USAGE
200
+ $ tray-cdk test [OPERATIONNAME] [-v]
201
+
202
+ ARGUMENTS
203
+ OPERATIONNAME Operation name to run the test against
204
+
205
+ FLAGS
206
+ -v, --verbose Logs the input and output of an operation, requires operation name argument to be specified
207
+
208
+ DESCRIPTION
209
+ Build and test connector project or an operation
210
+ ```
103
211
 
104
- ## `cdk version`
212
+ ## `tray-cdk version`
105
213
 
106
214
  ```
107
215
  USAGE
108
- $ cdk version [--json] [--verbose]
216
+ $ tray-cdk version [--json] [--verbose]
109
217
 
110
218
  FLAGS
111
219
  --verbose Show additional information about the CLI.
@@ -119,5 +227,5 @@ FLAG DESCRIPTIONS
119
227
  Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
120
228
  ```
121
229
 
122
- _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v1.3.3/src/commands/version.ts)_
230
+ _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.0.11/src/commands/version.ts)_
123
231
  <!-- commandsstop -->
package/bin/dev CHANGED
File without changes
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class AddOperation extends Command {
3
+ static description: string;
4
+ static args: {
5
+ operationName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
6
+ operationType: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=add-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-operation.d.ts","sourceRoot":"","sources":["../../src/commands/add-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,aAAa,CAAC;AAqB5C,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,OAAO;IAChD,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,IAAI;;;MAYT;IAEI,GAAG;CAyDT"}
@@ -0,0 +1,98 @@
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 inquirer_1 = __importDefault(require("inquirer"));
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
19
+ const StringExtensions_1 = require("@trayio/commons/string/StringExtensions");
20
+ const path_1 = __importDefault(require("path"));
21
+ const lodash_1 = require("lodash");
22
+ const isInSrcFolder = (currentDirectory) => {
23
+ const { base } = path_1.default.parse(currentDirectory);
24
+ return base === 'src';
25
+ };
26
+ const getConnectorName = (currentDirectory) => {
27
+ const { base } = path_1.default.parse(currentDirectory);
28
+ if (base === 'src') {
29
+ return path_1.default.basename(path_1.default.dirname(currentDirectory));
30
+ }
31
+ return base;
32
+ };
33
+ class AddOperation extends core_1.Command {
34
+ run() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const { args } = yield this.parse(AddOperation);
37
+ const promptRes = yield inquirer_1.default.prompt([
38
+ {
39
+ name: 'operationName',
40
+ message: 'Operation name',
41
+ type: 'input',
42
+ when: !args.operationName,
43
+ default: 'my-operation',
44
+ },
45
+ {
46
+ name: 'operationType',
47
+ message: 'Operation type',
48
+ type: 'list',
49
+ choices: [
50
+ { name: 'HTTP', value: 'http' },
51
+ { name: 'Composite', value: 'composite' },
52
+ ],
53
+ when: !args.operationType,
54
+ default: 'http',
55
+ },
56
+ ]);
57
+ const operationName = args.operationName || promptRes.operationName;
58
+ const operationNameKebabCase = (0, lodash_1.kebabCase)(operationName);
59
+ const operationNamePascalCase = StringExtensions_1.StringExtensions.pascalCase(operationName);
60
+ const operationNameCamelCase = (0, lodash_1.camelCase)(operationName);
61
+ const operationNameSnakeCase = (0, lodash_1.snakeCase)(operationName);
62
+ const currentDirectory = process.cwd();
63
+ const connectorNamePascalCase = StringExtensions_1.StringExtensions.pascalCase(getConnectorName(currentDirectory));
64
+ const operationType = args.operationType || promptRes.operationType;
65
+ const rootDir = __dirname;
66
+ const templatePath = operationType === 'http'
67
+ ? path_1.default.join(rootDir, 'http-operation-template.zip')
68
+ : path_1.default.join(rootDir, 'composite-operation-template.zip');
69
+ const generator = new NodeFsGenerator_1.NodeFsGenerator();
70
+ const targetPath = isInSrcFolder(currentDirectory)
71
+ ? currentDirectory
72
+ : path_1.default.join(currentDirectory, 'src');
73
+ yield generator.generate(templatePath, targetPath, {
74
+ operationNameKebabCase,
75
+ operationNamePascalCase,
76
+ operationNameCamelCase,
77
+ operationNameSnakeCase,
78
+ connectorNamePascalCase,
79
+ })();
80
+ this.log(chalk_1.default.bold(chalk_1.default.green(`Success! Added operation: ${operationNameKebabCase}`)));
81
+ });
82
+ }
83
+ }
84
+ AddOperation.description = 'Add an operation to connector project';
85
+ AddOperation.args = {
86
+ operationName: core_1.Args.string({
87
+ name: 'Operation name',
88
+ required: false,
89
+ description: 'Operation name',
90
+ }),
91
+ operationType: core_1.Args.string({
92
+ name: 'Operation type',
93
+ required: false,
94
+ description: 'Operation type',
95
+ options: ['http', 'composite'],
96
+ }),
97
+ };
98
+ exports.default = AddOperation;
@@ -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/commands/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"}
@@ -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/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAUtC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAAiC;IAEnD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CA2CT"}
@@ -0,0 +1,87 @@
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/axios/http/AxiosHttpClient");
43
+ const ConnectorDeploymentHttpClient_1 = require("@trayio/tray-client/connector/deployment/ConnectorDeploymentHttpClient");
44
+ const test_1 = __importDefault(require("./test"));
45
+ const build_1 = __importDefault(require("./build"));
46
+ class DeployConnector extends core_1.Command {
47
+ constructor() {
48
+ super(...arguments);
49
+ this.connectorDeployment = new ConnectorDeploymentHttpClient_1.ConnectorDeploymentHttpClient({
50
+ baseUrl: process.env.TRAY_API_URL,
51
+ }, new AxiosHttpClient_1.AxiosHttpClient());
52
+ }
53
+ run() {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ yield test_1.default.run([]);
56
+ yield build_1.default.run([]);
57
+ const currentDirectory = process.cwd();
58
+ const connectorZipPath = pathLib.join(currentDirectory, 'dist', 'connector.zip');
59
+ const TRAY_API_TOKEN = process.env.TRAY_API_TOKEN;
60
+ const zipFile = fse.readFileSync(connectorZipPath);
61
+ const sourceCode = Buffer.from(zipFile).toString('base64');
62
+ const connectorJsonPath = pathLib.join(currentDirectory, 'connector.json');
63
+ const connectorJson = fse.readJsonSync(connectorJsonPath);
64
+ const connectorName = connectorJson.name;
65
+ const connectorVersion = connectorJson.version;
66
+ const input = {
67
+ connectorName,
68
+ connectorVersion,
69
+ connectorSourceCode: sourceCode,
70
+ token: TRAY_API_TOKEN,
71
+ };
72
+ this.log('Connector Deploy Started');
73
+ const response = yield this.connectorDeployment.deployFromSourceCode(input);
74
+ if (response.isSuccess) {
75
+ this.log(chalk_1.default.bold(chalk_1.default.green(`Connector Deploy Request Sent`)));
76
+ this.log(`Deployment [${response.value.id}] is in progress`);
77
+ }
78
+ if (response.isFailure) {
79
+ this.log(chalk_1.default.bold(chalk_1.default.red(`Connector Deploy Failed`)));
80
+ this.log(response.error.message);
81
+ }
82
+ });
83
+ }
84
+ }
85
+ DeployConnector.description = 'Deploys a connector project';
86
+ DeployConnector.args = {};
87
+ exports.default = DeployConnector;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class GetDeploymentStatus extends Command {
3
+ static description: string;
4
+ static args: {
5
+ connectorName: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ connectorVersion: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
7
+ uuid: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
8
+ };
9
+ private connectorDeployment;
10
+ run(): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=deployment-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment-status.d.ts","sourceRoot":"","sources":["../../src/commands/deployment-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,aAAa,CAAC;AAMhD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;IACvD,MAAM,CAAC,WAAW,SAAoD;IAEtE,MAAM,CAAC,IAAI;;;;MAiBT;IAEF,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CAuDT"}