@trayio/cdk-cli 4.16.2 → 4.16.3
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/4.16.
|
|
22
|
+
@trayio/cdk-cli/4.16.3 linux-x64 node-v18.20.2
|
|
23
23
|
$ tray-cdk --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ tray-cdk COMMAND
|
|
@@ -126,12 +126,16 @@ Create a connector from an OpenAPI specification: Command is still in BETA
|
|
|
126
126
|
|
|
127
127
|
```
|
|
128
128
|
USAGE
|
|
129
|
-
$ tray-cdk connector import [OPENAPISPEC] [CONNECTORNAME]
|
|
129
|
+
$ tray-cdk connector import [OPENAPISPEC] [CONNECTORNAME] [--skipInstall] [--skipLinting]
|
|
130
130
|
|
|
131
131
|
ARGUMENTS
|
|
132
132
|
OPENAPISPEC Location of the OpenAPI specification file
|
|
133
133
|
CONNECTORNAME The name of the connector
|
|
134
134
|
|
|
135
|
+
FLAGS
|
|
136
|
+
--skipInstall Skips NPM install after generating the connector, useful if you want to manually install dependencies
|
|
137
|
+
--skipLinting Skips linting after generating the connector, useful if you want to manually fix linting errors
|
|
138
|
+
|
|
135
139
|
DESCRIPTION
|
|
136
140
|
Create a connector from an OpenAPI specification: Command is still in BETA
|
|
137
141
|
```
|
|
@@ -5,6 +5,10 @@ export default class Import extends Command {
|
|
|
5
5
|
openApiSpec: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
6
6
|
connectorName: import("@oclif/core/lib/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
7
7
|
};
|
|
8
|
+
static flags: {
|
|
9
|
+
skipInstall: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
skipLinting: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
};
|
|
8
12
|
run(): Promise<void>;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/commands/connector/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/commands/connector/import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAmB,MAAM,aAAa,CAAC;AAWvD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IAC1C,MAAM,CAAC,WAAW,SAC4D;IAE9E,MAAM,CAAC,IAAI;;;MAWT;IAEF,MAAM,CAAC,KAAK;;;MASV;IAEI,GAAG;CAiGT"}
|
|
@@ -29,11 +29,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const core_1 = require("@oclif/core");
|
|
30
30
|
const OpenApiSchemaImporter_1 = require("@trayio/tray-openapi/OpenApiSchemaImporter");
|
|
31
31
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
32
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
33
32
|
const NodeFsGenerator_1 = require("@trayio/generator/generator/NodeFsGenerator");
|
|
34
33
|
const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage");
|
|
35
34
|
const E = __importStar(require("fp-ts/Either"));
|
|
36
35
|
const stream_1 = require("stream");
|
|
36
|
+
const child_process_1 = require("child_process");
|
|
37
|
+
const lodash_1 = require("lodash");
|
|
38
|
+
const colorizeString_1 = require("../../utils/colorizeString");
|
|
37
39
|
class Import extends core_1.Command {
|
|
38
40
|
static description = 'Create a connector from an OpenAPI specification: Command is still in BETA';
|
|
39
41
|
static args = {
|
|
@@ -48,8 +50,16 @@ class Import extends core_1.Command {
|
|
|
48
50
|
description: 'The name of the connector',
|
|
49
51
|
}),
|
|
50
52
|
};
|
|
53
|
+
static flags = {
|
|
54
|
+
skipInstall: core_1.Flags.boolean({
|
|
55
|
+
description: 'Skips NPM install after generating the connector, useful if you want to manually install dependencies',
|
|
56
|
+
}),
|
|
57
|
+
skipLinting: core_1.Flags.boolean({
|
|
58
|
+
description: 'Skips linting after generating the connector, useful if you want to manually fix linting errors',
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
51
61
|
async run() {
|
|
52
|
-
const { args } = await this.parse(Import);
|
|
62
|
+
const { args, flags } = await this.parse(Import);
|
|
53
63
|
const promptRes = await inquirer_1.default.prompt([
|
|
54
64
|
{
|
|
55
65
|
name: 'openApiSpec',
|
|
@@ -71,19 +81,50 @@ class Import extends core_1.Command {
|
|
|
71
81
|
const connectorName = promptRes.connectorName || args.connectorName;
|
|
72
82
|
const result = await openApiSchemaImporter.buildConnector(openApiSpec, connectorName)();
|
|
73
83
|
if (E.isLeft(result)) {
|
|
74
|
-
this.log(
|
|
84
|
+
this.log((0, colorizeString_1.error)(`Error occurred while importing connector: ${result.left.message}`));
|
|
75
85
|
}
|
|
76
86
|
else {
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
if (result.right.errors.length >= result.right.successes.length) {
|
|
88
|
+
this.log((0, colorizeString_1.warning)(`Added connector: ${connectorName}`));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
this.log((0, colorizeString_1.success)(`Success! Added connector: ${connectorName}`));
|
|
92
|
+
}
|
|
93
|
+
this.log((0, colorizeString_1.success)(`Generated ${result.right.successes.length} Connector Operations`));
|
|
79
94
|
if (result.right.errors.length) {
|
|
80
|
-
this.log(
|
|
95
|
+
this.log((0, colorizeString_1.error)(`Failed to generate ${result.right.errors.length} Connector Operations, errors can be found in the errors.json file`));
|
|
81
96
|
await fileStorage.write({
|
|
82
97
|
key: 'errors.json',
|
|
83
98
|
content: stream_1.Readable.from(JSON.stringify(result.right.errors)),
|
|
84
99
|
metadata: { name: 'errors.json', size: 0 },
|
|
85
100
|
})();
|
|
86
101
|
}
|
|
102
|
+
if (!flags.skipInstall) {
|
|
103
|
+
try {
|
|
104
|
+
core_1.ux.action.start((0, colorizeString_1.info)('Installing npm dependencies...'));
|
|
105
|
+
(0, child_process_1.execSync)(`cd ${(0, lodash_1.kebabCase)(connectorName)} && npm install`, {
|
|
106
|
+
stdio: 'inherit',
|
|
107
|
+
});
|
|
108
|
+
core_1.ux.action.stop();
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (e instanceof Error) {
|
|
112
|
+
this.error(new Error(e.message));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (!flags.skipLinting) {
|
|
116
|
+
try {
|
|
117
|
+
core_1.ux.action.start((0, colorizeString_1.info)('Linting Source Code...'));
|
|
118
|
+
(0, child_process_1.execSync)(`cd ${(0, lodash_1.kebabCase)(connectorName)} && npm run lint:fix`, {
|
|
119
|
+
stdio: 'inherit',
|
|
120
|
+
});
|
|
121
|
+
core_1.ux.action.stop();
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
this.log((0, colorizeString_1.error)('Unable to fix any linting errors automatically, please manually fix any linting errors'));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
87
128
|
}
|
|
88
129
|
}
|
|
89
130
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -89,7 +89,20 @@
|
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
91
|
"description": "Create a connector from an OpenAPI specification: Command is still in BETA",
|
|
92
|
-
"flags": {
|
|
92
|
+
"flags": {
|
|
93
|
+
"skipInstall": {
|
|
94
|
+
"description": "Skips NPM install after generating the connector, useful if you want to manually install dependencies",
|
|
95
|
+
"name": "skipInstall",
|
|
96
|
+
"allowNo": false,
|
|
97
|
+
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"skipLinting": {
|
|
100
|
+
"description": "Skips linting after generating the connector, useful if you want to manually fix linting errors",
|
|
101
|
+
"name": "skipLinting",
|
|
102
|
+
"allowNo": false,
|
|
103
|
+
"type": "boolean"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
93
106
|
"hasDynamicHelp": false,
|
|
94
107
|
"hiddenAliases": [],
|
|
95
108
|
"id": "connector:import",
|
|
@@ -417,5 +430,5 @@
|
|
|
417
430
|
]
|
|
418
431
|
}
|
|
419
432
|
},
|
|
420
|
-
"version": "4.16.
|
|
433
|
+
"version": "4.16.3"
|
|
421
434
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-cli",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.3",
|
|
4
4
|
"description": "A CLI for connector development",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"@oclif/plugin-plugins": "^5",
|
|
21
21
|
"@oclif/plugin-version": "2.0.11",
|
|
22
22
|
"@oclif/test": "3.1.12",
|
|
23
|
-
"@trayio/axios": "4.16.
|
|
24
|
-
"@trayio/cdk-build": "4.16.
|
|
25
|
-
"@trayio/commons": "4.16.
|
|
26
|
-
"@trayio/generator": "4.16.
|
|
27
|
-
"@trayio/tray-client": "4.16.
|
|
28
|
-
"@trayio/tray-openapi": "4.16.
|
|
23
|
+
"@trayio/axios": "4.16.3",
|
|
24
|
+
"@trayio/cdk-build": "4.16.3",
|
|
25
|
+
"@trayio/commons": "4.16.3",
|
|
26
|
+
"@trayio/generator": "4.16.3",
|
|
27
|
+
"@trayio/tray-client": "4.16.3",
|
|
28
|
+
"@trayio/tray-openapi": "4.16.3",
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"inquirer": "8.2.6"
|
|
31
31
|
},
|