@trayio/cdk-cli 0.0.3 → 0.0.5-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/INTRODUCTION.md +54 -0
- package/LICENSE.txt +22 -0
- package/README.md +150 -46
- package/bin/dev +0 -0
- package/dist/commands/add-operation.d.ts +11 -0
- package/dist/commands/add-operation.d.ts.map +1 -0
- package/dist/commands/add-operation.js +102 -0
- package/dist/commands/add-operation.unit.test.d.ts +2 -0
- package/dist/commands/add-operation.unit.test.d.ts.map +1 -0
- package/dist/commands/add-operation.unit.test.js +119 -0
- package/dist/commands/build.d.ts +8 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +34 -0
- package/dist/commands/deploy.d.ts +8 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +90 -0
- package/dist/commands/deployment-status.d.ts +12 -0
- package/dist/commands/deployment-status.d.ts.map +1 -0
- package/dist/commands/deployment-status.js +78 -0
- package/dist/commands/deployment-status.unit.test.d.ts +2 -0
- package/dist/commands/deployment-status.unit.test.d.ts.map +1 -0
- package/dist/commands/deployment-status.unit.test.js +82 -0
- package/dist/commands/import-openapi-spec-tst.d.ts +10 -0
- package/dist/commands/import-openapi-spec-tst.d.ts.map +1 -0
- package/dist/commands/import-openapi-spec-tst.js +101 -0
- package/dist/commands/import-openapi-spec.d.ts +10 -0
- package/dist/commands/import-openapi-spec.d.ts.map +1 -0
- package/dist/commands/import-openapi-spec.js +101 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/init.d.ts +13 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +85 -0
- package/dist/commands/init.unit.test.d.ts +2 -0
- package/dist/commands/init.unit.test.d.ts.map +1 -0
- package/dist/commands/init.unit.test.js +127 -0
- package/dist/commands/test.d.ts +12 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +55 -0
- package/dist/templates/composite-operation-template.zip +0 -0
- package/dist/templates/connector-template.zip +0 -0
- package/dist/templates/http-operation-template.zip +0 -0
- package/dist/utils/check-env.d.ts +2 -0
- package/dist/utils/check-env.d.ts.map +1 -0
- package/dist/utils/check-env.js +35 -0
- package/dist/utils/check-env.unit.test.d.ts +2 -0
- package/dist/utils/check-env.unit.test.d.ts.map +1 -0
- package/dist/utils/check-env.unit.test.js +46 -0
- package/dist/utils/colorizeString.d.ts +5 -0
- package/dist/utils/colorizeString.d.ts.map +1 -0
- package/dist/utils/colorizeString.js +15 -0
- package/oclif.manifest.json +243 -16
- package/package.json +68 -53
package/INTRODUCTION.md
ADDED
|
@@ -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/
|
|
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/
|
|
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.
|
|
28
|
-
$ cdk --help [COMMAND]
|
|
21
|
+
$ tray-cdk (--version|-v)
|
|
22
|
+
@trayio/cdk-cli/0.0.5-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,80 +30,121 @@ USAGE
|
|
|
35
30
|
# Commands
|
|
36
31
|
|
|
37
32
|
<!-- commands -->
|
|
38
|
-
* [`cdk`](#cdk)
|
|
39
|
-
* [`cdk
|
|
40
|
-
* [`cdk
|
|
41
|
-
* [`cdk
|
|
42
|
-
* [`cdk
|
|
43
|
-
* [`cdk
|
|
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 import-openapi-spec-tst [OPENAPISPEC] [CONNECTORNAME]`](#tray-cdk-import-openapi-spec-tst-openapispec-connectorname)
|
|
42
|
+
* [`tray-cdk init [CONNECTORNAME]`](#tray-cdk-init-connectorname)
|
|
43
|
+
* [`tray-cdk test [OPERATIONNAME]`](#tray-cdk-test-operationname)
|
|
44
|
+
* [`tray-cdk version`](#tray-cdk-version)
|
|
45
|
+
|
|
46
|
+
## `tray-cdk`
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
USAGE
|
|
50
|
+
$ tray-cdk
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## `tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]`
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
Add an operation to connector project
|
|
46
56
|
|
|
47
57
|
```
|
|
48
58
|
USAGE
|
|
49
|
-
$ cdk
|
|
59
|
+
$ tray-cdk add-operation [OPERATIONNAME] [OPERATIONTYPE]
|
|
60
|
+
|
|
61
|
+
ARGUMENTS
|
|
62
|
+
OPERATIONNAME Operation name
|
|
63
|
+
OPERATIONTYPE (http|composite) Operation type
|
|
64
|
+
|
|
65
|
+
DESCRIPTION
|
|
66
|
+
Add an operation to connector project
|
|
50
67
|
```
|
|
51
68
|
|
|
52
|
-
## `cdk autocomplete [SHELL]`
|
|
69
|
+
## `tray-cdk autocomplete [SHELL]`
|
|
53
70
|
|
|
54
|
-
|
|
71
|
+
Display autocomplete installation instructions.
|
|
55
72
|
|
|
56
73
|
```
|
|
57
74
|
USAGE
|
|
58
|
-
$ cdk autocomplete [SHELL] [-r]
|
|
75
|
+
$ tray-cdk autocomplete [SHELL] [-r]
|
|
59
76
|
|
|
60
77
|
ARGUMENTS
|
|
61
|
-
SHELL
|
|
78
|
+
SHELL (zsh|bash|powershell) Shell type
|
|
62
79
|
|
|
63
80
|
FLAGS
|
|
64
81
|
-r, --refresh-cache Refresh cache (ignores displaying instructions)
|
|
65
82
|
|
|
66
83
|
DESCRIPTION
|
|
67
|
-
|
|
84
|
+
Display autocomplete installation instructions.
|
|
68
85
|
|
|
69
86
|
EXAMPLES
|
|
70
|
-
$ cdk autocomplete
|
|
87
|
+
$ tray-cdk autocomplete
|
|
71
88
|
|
|
72
|
-
$ cdk autocomplete bash
|
|
89
|
+
$ tray-cdk autocomplete bash
|
|
73
90
|
|
|
74
|
-
$ cdk autocomplete zsh
|
|
91
|
+
$ tray-cdk autocomplete zsh
|
|
75
92
|
|
|
76
|
-
$ cdk autocomplete
|
|
93
|
+
$ tray-cdk autocomplete powershell
|
|
94
|
+
|
|
95
|
+
$ tray-cdk autocomplete --refresh-cache
|
|
77
96
|
```
|
|
78
97
|
|
|
79
|
-
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/
|
|
98
|
+
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.5/src/commands/autocomplete/index.ts)_
|
|
80
99
|
|
|
81
|
-
## `cdk
|
|
100
|
+
## `tray-cdk build`
|
|
82
101
|
|
|
83
|
-
|
|
102
|
+
Builds a connector project
|
|
84
103
|
|
|
85
104
|
```
|
|
86
105
|
USAGE
|
|
87
|
-
$ cdk
|
|
106
|
+
$ tray-cdk build
|
|
88
107
|
|
|
89
108
|
DESCRIPTION
|
|
90
|
-
|
|
109
|
+
Builds a connector project
|
|
91
110
|
```
|
|
92
111
|
|
|
93
|
-
## `cdk
|
|
112
|
+
## `tray-cdk deploy`
|
|
94
113
|
|
|
95
|
-
|
|
114
|
+
Deploys a connector project
|
|
96
115
|
|
|
97
116
|
```
|
|
98
117
|
USAGE
|
|
99
|
-
$ cdk
|
|
118
|
+
$ tray-cdk deploy
|
|
100
119
|
|
|
101
120
|
DESCRIPTION
|
|
102
|
-
|
|
121
|
+
Deploys a connector project
|
|
103
122
|
```
|
|
104
123
|
|
|
105
|
-
## `cdk
|
|
124
|
+
## `tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID`
|
|
106
125
|
|
|
107
|
-
|
|
126
|
+
Retrieves the status of a connector deployment
|
|
108
127
|
|
|
109
128
|
```
|
|
110
129
|
USAGE
|
|
111
|
-
$ cdk
|
|
130
|
+
$ tray-cdk deployment-status CONNECTORNAME CONNECTORVERSION UUID
|
|
131
|
+
|
|
132
|
+
ARGUMENTS
|
|
133
|
+
CONNECTORNAME The name of the connector
|
|
134
|
+
CONNECTORVERSION The version of the connector
|
|
135
|
+
UUID The UUID of the deployment, this is included in the tray-cdk deploy output
|
|
136
|
+
|
|
137
|
+
DESCRIPTION
|
|
138
|
+
Retrieves the status of a connector deployment
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## `tray-cdk help [COMMANDS]`
|
|
142
|
+
|
|
143
|
+
Display help for tray-cdk.
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
USAGE
|
|
147
|
+
$ tray-cdk help [COMMANDS] [-n]
|
|
112
148
|
|
|
113
149
|
ARGUMENTS
|
|
114
150
|
COMMANDS Command to show help for.
|
|
@@ -117,16 +153,84 @@ FLAGS
|
|
|
117
153
|
-n, --nested-commands Include all nested commands in the output.
|
|
118
154
|
|
|
119
155
|
DESCRIPTION
|
|
120
|
-
Display help for cdk.
|
|
156
|
+
Display help for tray-cdk.
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.12/src/commands/help.ts)_
|
|
160
|
+
|
|
161
|
+
## `tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]`
|
|
162
|
+
|
|
163
|
+
Create a connector from an OpenAPI specification: Command is still in BETA
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
USAGE
|
|
167
|
+
$ tray-cdk import-openapi-spec [OPENAPISPEC] [CONNECTORNAME]
|
|
168
|
+
|
|
169
|
+
ARGUMENTS
|
|
170
|
+
OPENAPISPEC Location of the OpenAPI specification file
|
|
171
|
+
CONNECTORNAME The name of the connector
|
|
172
|
+
|
|
173
|
+
DESCRIPTION
|
|
174
|
+
Create a connector from an OpenAPI specification: Command is still in BETA
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## `tray-cdk import-openapi-spec-tst [OPENAPISPEC] [CONNECTORNAME]`
|
|
178
|
+
|
|
179
|
+
Create a connector from an OpenAPI specification: Command is still in BETA
|
|
180
|
+
|
|
121
181
|
```
|
|
182
|
+
USAGE
|
|
183
|
+
$ tray-cdk import-openapi-spec-tst [OPENAPISPEC] [CONNECTORNAME]
|
|
122
184
|
|
|
123
|
-
|
|
185
|
+
ARGUMENTS
|
|
186
|
+
OPENAPISPEC Location of the OpenAPI specification file
|
|
187
|
+
CONNECTORNAME The name of the connector
|
|
188
|
+
|
|
189
|
+
DESCRIPTION
|
|
190
|
+
Create a connector from an OpenAPI specification: Command is still in BETA
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## `tray-cdk init [CONNECTORNAME]`
|
|
194
|
+
|
|
195
|
+
Initialize a connector project
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
USAGE
|
|
199
|
+
$ tray-cdk init [CONNECTORNAME] [-i]
|
|
200
|
+
|
|
201
|
+
ARGUMENTS
|
|
202
|
+
CONNECTORNAME Connector directory name to generate template files
|
|
203
|
+
|
|
204
|
+
FLAGS
|
|
205
|
+
-i, --install Runs `npm install` after successful generation
|
|
206
|
+
|
|
207
|
+
DESCRIPTION
|
|
208
|
+
Initialize a connector project
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## `tray-cdk test [OPERATIONNAME]`
|
|
212
|
+
|
|
213
|
+
Build and test connector project or an operation
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
USAGE
|
|
217
|
+
$ tray-cdk test [OPERATIONNAME] [-v]
|
|
218
|
+
|
|
219
|
+
ARGUMENTS
|
|
220
|
+
OPERATIONNAME Operation name to run the test against
|
|
221
|
+
|
|
222
|
+
FLAGS
|
|
223
|
+
-v, --verbose Logs the input and output of an operation, requires operation name argument to be specified
|
|
224
|
+
|
|
225
|
+
DESCRIPTION
|
|
226
|
+
Build and test connector project or an operation
|
|
227
|
+
```
|
|
124
228
|
|
|
125
|
-
## `cdk version`
|
|
229
|
+
## `tray-cdk version`
|
|
126
230
|
|
|
127
231
|
```
|
|
128
232
|
USAGE
|
|
129
|
-
$ cdk version [--json] [--verbose]
|
|
233
|
+
$ tray-cdk version [--json] [--verbose]
|
|
130
234
|
|
|
131
235
|
FLAGS
|
|
132
236
|
--verbose Show additional information about the CLI.
|
|
@@ -140,5 +244,5 @@ FLAG DESCRIPTIONS
|
|
|
140
244
|
Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
|
|
141
245
|
```
|
|
142
246
|
|
|
143
|
-
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/
|
|
247
|
+
_See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.0.11/src/commands/version.ts)_
|
|
144
248
|
<!-- commandsstop -->
|
package/bin/dev
CHANGED
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
private generator;
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# 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;IAEF,OAAO,CAAC,SAAS,CAAyB;IAEpC,GAAG;CAqDT"}
|
|
@@ -0,0 +1,102 @@
|
|
|
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 NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
|
|
18
|
+
const StringExtensions_1 = require("@trayio/commons/string/StringExtensions");
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const lodash_1 = require("lodash");
|
|
21
|
+
const colorizeString_1 = require("../utils/colorizeString");
|
|
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
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.generator = new NodeFsGenerator_1.NodeFsGenerator();
|
|
37
|
+
}
|
|
38
|
+
run() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const { args } = yield this.parse(AddOperation);
|
|
41
|
+
const promptRes = yield inquirer_1.default.prompt([
|
|
42
|
+
{
|
|
43
|
+
name: 'operationName',
|
|
44
|
+
message: 'Operation name',
|
|
45
|
+
type: 'input',
|
|
46
|
+
when: !args.operationName,
|
|
47
|
+
default: 'my-operation',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'operationType',
|
|
51
|
+
message: 'Operation type',
|
|
52
|
+
type: 'list',
|
|
53
|
+
choices: [
|
|
54
|
+
{ name: 'HTTP', value: 'http' },
|
|
55
|
+
{ name: 'Composite', value: 'composite' },
|
|
56
|
+
],
|
|
57
|
+
when: !args.operationType,
|
|
58
|
+
default: 'http',
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
const operationName = args.operationName || promptRes.operationName;
|
|
62
|
+
const operationNameKebabCase = (0, lodash_1.kebabCase)(operationName);
|
|
63
|
+
const operationNamePascalCase = StringExtensions_1.StringExtensions.pascalCase(operationName);
|
|
64
|
+
const operationNameCamelCase = (0, lodash_1.camelCase)(operationName);
|
|
65
|
+
const operationNameSnakeCase = (0, lodash_1.snakeCase)(operationName);
|
|
66
|
+
const currentDirectory = process.cwd();
|
|
67
|
+
const connectorNamePascalCase = StringExtensions_1.StringExtensions.pascalCase(getConnectorName(currentDirectory));
|
|
68
|
+
const operationType = args.operationType || promptRes.operationType;
|
|
69
|
+
const rootDir = __dirname;
|
|
70
|
+
const templateDir = path_1.default.join(rootDir, '..', 'templates');
|
|
71
|
+
const templatePath = operationType === 'http'
|
|
72
|
+
? path_1.default.join(templateDir, 'http-operation-template.zip')
|
|
73
|
+
: path_1.default.join(templateDir, 'composite-operation-template.zip');
|
|
74
|
+
const targetPath = isInSrcFolder(currentDirectory)
|
|
75
|
+
? currentDirectory
|
|
76
|
+
: path_1.default.join(currentDirectory, 'src');
|
|
77
|
+
yield this.generator.generate(templatePath, targetPath, {
|
|
78
|
+
operationNameKebabCase,
|
|
79
|
+
operationNamePascalCase,
|
|
80
|
+
operationNameCamelCase,
|
|
81
|
+
operationNameSnakeCase,
|
|
82
|
+
connectorNamePascalCase,
|
|
83
|
+
})();
|
|
84
|
+
this.log((0, colorizeString_1.success)(`Success! Added operation: ${operationNameKebabCase}`));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
AddOperation.description = 'Add an operation to connector project';
|
|
89
|
+
AddOperation.args = {
|
|
90
|
+
operationName: core_1.Args.string({
|
|
91
|
+
name: 'Operation name',
|
|
92
|
+
required: false,
|
|
93
|
+
description: 'Operation name',
|
|
94
|
+
}),
|
|
95
|
+
operationType: core_1.Args.string({
|
|
96
|
+
name: 'Operation type',
|
|
97
|
+
required: false,
|
|
98
|
+
description: 'Operation type',
|
|
99
|
+
options: ['http', 'composite'],
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
exports.default = AddOperation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-operation.unit.test.d.ts","sourceRoot":"","sources":["../../src/commands/add-operation.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 stdout_stderr_1 = require("stdout-stderr");
|
|
16
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
17
|
+
const add_operation_1 = __importDefault(require("./add-operation"));
|
|
18
|
+
jest.mock('inquirer', () => ({
|
|
19
|
+
prompt: jest.fn(),
|
|
20
|
+
registerPrompt: jest.requireActual('inquirer').registerPrompt,
|
|
21
|
+
}));
|
|
22
|
+
describe('AddOperation', () => {
|
|
23
|
+
let operationName = 'my-operation';
|
|
24
|
+
let operationType = 'http';
|
|
25
|
+
const mockInquirer = inquirer_1.default;
|
|
26
|
+
beforeAll(() => {
|
|
27
|
+
mockInquirer.prompt.mockResolvedValue({
|
|
28
|
+
shouldContinue: true,
|
|
29
|
+
operationName,
|
|
30
|
+
operationType,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
beforeEach(() => { });
|
|
34
|
+
afterAll(() => {
|
|
35
|
+
jest.restoreAllMocks();
|
|
36
|
+
});
|
|
37
|
+
it('should prompt for operation name and type if not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const addOperation = new add_operation_1.default([], {});
|
|
39
|
+
const mockGenerate = jest
|
|
40
|
+
.fn()
|
|
41
|
+
.mockImplementation(() => jest.fn().mockResolvedValue(true));
|
|
42
|
+
addOperation['generator'] = {
|
|
43
|
+
generate: mockGenerate,
|
|
44
|
+
};
|
|
45
|
+
stdout_stderr_1.stdout.start();
|
|
46
|
+
yield addOperation.run();
|
|
47
|
+
stdout_stderr_1.stdout.stop();
|
|
48
|
+
expect(stdout_stderr_1.stdout.output).toContain('Success! Added operation: my-operation');
|
|
49
|
+
expect(mockInquirer.prompt).toBeCalledWith([
|
|
50
|
+
{
|
|
51
|
+
name: 'operationName',
|
|
52
|
+
message: 'Operation name',
|
|
53
|
+
type: 'input',
|
|
54
|
+
when: true,
|
|
55
|
+
default: 'my-operation',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'operationType',
|
|
59
|
+
message: 'Operation type',
|
|
60
|
+
type: 'list',
|
|
61
|
+
choices: [
|
|
62
|
+
{ name: 'HTTP', value: 'http' },
|
|
63
|
+
{ name: 'Composite', value: 'composite' },
|
|
64
|
+
],
|
|
65
|
+
when: true,
|
|
66
|
+
default: 'http',
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
expect(mockGenerate).toBeCalledWith(expect.stringContaining('modules/cdk-cli/src/templates/http-operation-template.zip'), expect.stringContaining('/src'), {
|
|
70
|
+
connectorNamePascalCase: 'TrayTypescriptSdk',
|
|
71
|
+
operationNameCamelCase: 'myOperation',
|
|
72
|
+
operationNameKebabCase: 'my-operation',
|
|
73
|
+
operationNamePascalCase: 'MyOperation',
|
|
74
|
+
operationNameSnakeCase: 'my_operation',
|
|
75
|
+
});
|
|
76
|
+
}));
|
|
77
|
+
it('should not prompt for operation name and type if provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
operationName = 'some-val';
|
|
79
|
+
operationType = 'http';
|
|
80
|
+
const addOperation = new add_operation_1.default([operationName, operationType], {});
|
|
81
|
+
const mockGenerate = jest
|
|
82
|
+
.fn()
|
|
83
|
+
.mockImplementation(() => jest.fn().mockResolvedValue(true));
|
|
84
|
+
addOperation['generator'] = {
|
|
85
|
+
generate: mockGenerate,
|
|
86
|
+
};
|
|
87
|
+
stdout_stderr_1.stdout.start();
|
|
88
|
+
yield addOperation.run();
|
|
89
|
+
stdout_stderr_1.stdout.stop();
|
|
90
|
+
expect(stdout_stderr_1.stdout.output).toContain('Success! Added operation: some-val');
|
|
91
|
+
expect(mockInquirer.prompt).toBeCalledWith([
|
|
92
|
+
{
|
|
93
|
+
name: 'operationName',
|
|
94
|
+
message: 'Operation name',
|
|
95
|
+
type: 'input',
|
|
96
|
+
when: false,
|
|
97
|
+
default: 'my-operation',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'operationType',
|
|
101
|
+
message: 'Operation type',
|
|
102
|
+
type: 'list',
|
|
103
|
+
choices: [
|
|
104
|
+
{ name: 'HTTP', value: 'http' },
|
|
105
|
+
{ name: 'Composite', value: 'composite' },
|
|
106
|
+
],
|
|
107
|
+
when: false,
|
|
108
|
+
default: 'http',
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
expect(mockGenerate).toBeCalledWith(expect.stringContaining('modules/cdk-cli/src/templates/http-operation-template.zip'), expect.stringContaining('/src'), {
|
|
112
|
+
connectorNamePascalCase: 'TrayTypescriptSdk',
|
|
113
|
+
operationNameCamelCase: 'someVal',
|
|
114
|
+
operationNameKebabCase: 'some-val',
|
|
115
|
+
operationNamePascalCase: 'SomeVal',
|
|
116
|
+
operationNameSnakeCase: 'some_val',
|
|
117
|
+
});
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAM,MAAM,aAAa,CAAC;AAW1C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,MAAM,CAAC,WAAW,SAAiC;IAEnD,MAAM,CAAC,IAAI,KAAM;IAEjB,OAAO,CAAC,mBAAmB,CAKzB;IAEI,GAAG;CA+CT"}
|