@sw-tsdk/plugin-connector 2.0.1-next.41 → 2.0.1-next.44

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
@@ -16,7 +16,7 @@ $ npm install -g @sw-tsdk/plugin-connector
16
16
  $ sw-tsdk-connector COMMAND
17
17
  running command...
18
18
  $ sw-tsdk-connector (--version)
19
- @sw-tsdk/plugin-connector/2.0.1-next.41+e3bd50c linux-x64 node-v16.17.1
19
+ @sw-tsdk/plugin-connector/2.0.1-next.44+e410fa1 linux-x64 node-v16.17.1
20
20
  $ sw-tsdk-connector --help [COMMAND]
21
21
  USAGE
22
22
  $ sw-tsdk-connector COMMAND
@@ -26,9 +26,10 @@ USAGE
26
26
  # Commands
27
27
  <!-- commands -->
28
28
  * [`sw-tsdk-connector action:add`](#sw-tsdk-connector-actionadd)
29
+ * [`sw-tsdk-connector action:generate:data`](#sw-tsdk-connector-actiongeneratedata)
29
30
  * [`sw-tsdk-connector action:input`](#sw-tsdk-connector-actioninput)
30
31
  * [`sw-tsdk-connector action:output`](#sw-tsdk-connector-actionoutput)
31
- * [`sw-tsdk-connector action:run`](#sw-tsdk-connector-actionrun)
32
+ * [`sw-tsdk-connector action:run:local`](#sw-tsdk-connector-actionrunlocal)
32
33
  * [`sw-tsdk-connector asset:add`](#sw-tsdk-connector-assetadd)
33
34
  * [`sw-tsdk-connector connector:build`](#sw-tsdk-connector-connectorbuild)
34
35
  * [`sw-tsdk-connector connector:create`](#sw-tsdk-connector-connectorcreate)
@@ -57,7 +58,29 @@ DESCRIPTION
57
58
  Update a connector action.
58
59
  ```
59
60
 
60
- _See code: [lib/commands/action/add.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/action/add.js)_
61
+ _See code: [lib/commands/action/add.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/action/add.js)_
62
+
63
+ ## `sw-tsdk-connector action:generate:data`
64
+
65
+ Use to test a task in an integration
66
+
67
+ ```
68
+ USAGE
69
+ $ sw-tsdk-connector action:generate:data --asset <value> [-h] [-n <value>] [--inputs <value>] [-d <value>]
70
+
71
+ FLAGS
72
+ -d, --directory=<value> [default: ./] current directory to mount
73
+ -h, --help Show CLI help.
74
+ -n, --name=<value> task name to run
75
+ --asset=<value> (required) [default: data/asset.json] asset json
76
+ --inputs=<value> Filename for JSON inputs, defaults to the task name under the data folder. ie:
77
+ data/my_task.json
78
+
79
+ DESCRIPTION
80
+ Use to test a task in an integration
81
+ ```
82
+
83
+ _See code: [lib/commands/action/generate/data.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/action/generate/data.js)_
61
84
 
62
85
  ## `sw-tsdk-connector action:input`
63
86
 
@@ -82,7 +105,7 @@ DESCRIPTION
82
105
  Update action input schema.
83
106
  ```
84
107
 
85
- _See code: [lib/commands/action/input.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/action/input.js)_
108
+ _See code: [lib/commands/action/input.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/action/input.js)_
86
109
 
87
110
  ## `sw-tsdk-connector action:output`
88
111
 
@@ -106,38 +129,35 @@ DESCRIPTION
106
129
  Update a connector action.
107
130
  ```
108
131
 
109
- _See code: [lib/commands/action/output.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/action/output.js)_
132
+ _See code: [lib/commands/action/output.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/action/output.js)_
110
133
 
111
- ## `sw-tsdk-connector action:run`
134
+ ## `sw-tsdk-connector action:run:local`
112
135
 
113
136
  Runs a connector action. (Defaults to current image version in local repository).
114
137
 
115
138
  ```
116
139
  USAGE
117
- $ sw-tsdk-connector action:run [-a <value>] [-d <value>] [--input-path <value>] [--output-path <value>]
118
- [--error-path <value>] [--asset-path <value>] [-i <value> | --build | --latest] [--template
119
- python_3.7|node_18|python_310_definition] [-f ] [-h]
140
+ $ sw-tsdk-connector action:run:local [-a <value>] [-d <value>] [--input-path <value>] [--output-path <value>]
141
+ [--error-path <value>] [--asset-path <value>] [--template python_3.7_swimlane|node_18|python_310_definition] [-f]
142
+ [-h]
120
143
 
121
144
  FLAGS
122
145
  -a, --action=<value> Action name to run
123
146
  -d, --directory=<value> [default: ./] Root directory of the repository.
124
147
  -f, --force-rebuild forces nocache on the image build
125
148
  -h, --help Show CLI help.
126
- -i, --image=<value> The connector image to run.
127
149
  --asset-path=<value> File to asset data JSON file, defaults to /data/asset.json
128
- --build Builds image and runs it.
129
150
  --error-path=<value> File to write the errors to, defaults to /data/<action>_error.json
130
151
  --input-path=<value> File to input data JSON file, defaults to /data/<action>.json
131
- --latest Use the latest release image from quay.
132
152
  --output-path=<value> File to write the outputs to, defaults to /data/<action>_output.json
133
153
  --template=<option> [default: python_310_definition] connector template
134
- <options: python_3.7|node_18|python_310_definition>
154
+ <options: python_3.7_swimlane|node_18|python_310_definition>
135
155
 
136
156
  DESCRIPTION
137
157
  Runs a connector action. (Defaults to current image version in local repository).
138
158
  ```
139
159
 
140
- _See code: [lib/commands/action/run.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/action/run.js)_
160
+ _See code: [lib/commands/action/run/local.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/action/run/local.js)_
141
161
 
142
162
  ## `sw-tsdk-connector asset:add`
143
163
 
@@ -157,7 +177,7 @@ DESCRIPTION
157
177
  Update a connector action.
158
178
  ```
159
179
 
160
- _See code: [lib/commands/asset/add.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/asset/add.js)_
180
+ _See code: [lib/commands/asset/add.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/asset/add.js)_
161
181
 
162
182
  ## `sw-tsdk-connector connector:build`
163
183
 
@@ -183,7 +203,7 @@ DESCRIPTION
183
203
  Builds a local docker image of the connector.
184
204
  ```
185
205
 
186
- _See code: [lib/commands/connector/build.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/build.js)_
206
+ _See code: [lib/commands/connector/build.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/build.js)_
187
207
 
188
208
  ## `sw-tsdk-connector connector:create`
189
209
 
@@ -215,7 +235,7 @@ DESCRIPTION
215
235
  Scaffold a new connector
216
236
  ```
217
237
 
218
- _See code: [lib/commands/connector/create.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/create.js)_
238
+ _See code: [lib/commands/connector/create.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/create.js)_
219
239
 
220
240
  ## `sw-tsdk-connector connector:create-source`
221
241
 
@@ -233,7 +253,7 @@ DESCRIPTION
233
253
  Generates 11x source from 10x
234
254
  ```
235
255
 
236
- _See code: [lib/commands/connector/create-source.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/create-source.js)_
256
+ _See code: [lib/commands/connector/create-source.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/create-source.js)_
237
257
 
238
258
  ## `sw-tsdk-connector connector:logo`
239
259
 
@@ -252,7 +272,7 @@ DESCRIPTION
252
272
  Update a connector.
253
273
  ```
254
274
 
255
- _See code: [lib/commands/connector/logo.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/logo.js)_
275
+ _See code: [lib/commands/connector/logo.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/logo.js)_
256
276
 
257
277
  ## `sw-tsdk-connector connector:save`
258
278
 
@@ -273,7 +293,7 @@ DESCRIPTION
273
293
  Save a docker image locally as .tar.gz
274
294
  ```
275
295
 
276
- _See code: [lib/commands/connector/save.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/save.js)_
296
+ _See code: [lib/commands/connector/save.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/save.js)_
277
297
 
278
298
  ## `sw-tsdk-connector connector:sign`
279
299
 
@@ -297,7 +317,7 @@ DESCRIPTION
297
317
  Builds a local docker image of the connector.
298
318
  ```
299
319
 
300
- _See code: [lib/commands/connector/sign.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/sign.js)_
320
+ _See code: [lib/commands/connector/sign.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/sign.js)_
301
321
 
302
322
  ## `sw-tsdk-connector connector:update`
303
323
 
@@ -317,7 +337,7 @@ DESCRIPTION
317
337
  Update a connector.
318
338
  ```
319
339
 
320
- _See code: [lib/commands/connector/update.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/update.js)_
340
+ _See code: [lib/commands/connector/update.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/update.js)_
321
341
 
322
342
  ## `sw-tsdk-connector connector:validate`
323
343
 
@@ -340,5 +360,5 @@ DESCRIPTION
340
360
  Use to validate an integration
341
361
  ```
342
362
 
343
- _See code: [lib/commands/connector/validate.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.41+e3bd50c/lib/commands/connector/validate.js)_
363
+ _See code: [lib/commands/connector/validate.js](https://github.com/swimlane/turbine-sdk/blob/v2.0.1-next.44+e410fa1/lib/commands/connector/validate.js)_
344
364
  <!-- commandsstop -->
@@ -0,0 +1,15 @@
1
+ import { Base } from '@sw-tsdk/core';
2
+ export declare class Data extends Base {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
7
+ asset: import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ inputs: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ directory: import("@oclif/core/lib/interfaces").OptionFlag<string>;
10
+ };
11
+ run(): Promise<void>;
12
+ private checkDirectoryAccess;
13
+ private chooseTask;
14
+ private static buildJsonFile;
15
+ }
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Data = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const core_2 = require("@sw-tsdk/core");
7
+ const fs_extra_1 = require("fs-extra");
8
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
9
+ const inquirer_autocomplete_prompt_1 = tslib_1.__importDefault(require("inquirer-autocomplete-prompt"));
10
+ const node_fs_1 = require("node:fs");
11
+ const node_path_1 = require("node:path");
12
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
13
+ const connector_1 = require("@sw-tsdk/connector");
14
+ // noinspection JSUnusedGlobalSymbols
15
+ class Data extends core_2.Base {
16
+ async run() {
17
+ const { flags } = await this.parse(Data);
18
+ const { asset, } = flags;
19
+ let { directory, name, inputs } = flags;
20
+ directory = (0, node_path_1.resolve)(directory || process.cwd());
21
+ await this.checkDirectoryAccess(directory);
22
+ if (!name) {
23
+ name = await this.chooseTask(directory);
24
+ inputs = `data/${name}.json`;
25
+ }
26
+ if (name.endsWith('.yaml')) {
27
+ name = name.slice(0, Math.max(0, name.length - 5));
28
+ }
29
+ if (!inputs) {
30
+ inputs = `data/${name}.json`;
31
+ }
32
+ core_1.CliUx.ux.log(`Starting run: ${name}...`);
33
+ try {
34
+ await node_fs_1.promises.access((0, node_path_1.join)(directory, 'connector/config', `${name}.yaml`));
35
+ }
36
+ catch (_a) {
37
+ this.error(`Invalid task: ${name}`);
38
+ return;
39
+ }
40
+ await Data.buildJsonFile(directory, 'asset', asset);
41
+ await Data.buildJsonFile(directory, name, inputs);
42
+ }
43
+ async checkDirectoryAccess(directory) {
44
+ directory = (0, node_path_1.resolve)(directory || process.cwd());
45
+ try {
46
+ await node_fs_1.promises.access(directory);
47
+ }
48
+ catch (_a) {
49
+ this.error(`Could not access ${directory}`);
50
+ }
51
+ }
52
+ async chooseTask(directory) {
53
+ inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
54
+ const manifests = await (0, connector_1.allManifests)(directory);
55
+ const actions = manifests.filter(x => (0, connector_1.isConnectorActionManifest)(x))
56
+ .sort((a, b) => a.name < b.name ? -1 : 1);
57
+ const answers = await inquirer_1.default.prompt([
58
+ {
59
+ type: 'autocomplete',
60
+ name: 'name',
61
+ message: 'Choose a task to run',
62
+ source: (_, input) => actions.filter(r => !input || r.name.includes(input)).map(r => r),
63
+ },
64
+ ]);
65
+ return answers.name;
66
+ }
67
+ static async buildJsonFile(directory, file, generatedFile) {
68
+ var _a;
69
+ const filePath = (0, node_path_1.resolve)((0, node_path_1.join)(directory, generatedFile));
70
+ if (await (0, core_2.fileExists)(filePath)) {
71
+ const answer = await inquirer_1.default.prompt([
72
+ {
73
+ type: 'confirm',
74
+ message: `Would you like to overwrite ${generatedFile}?`,
75
+ name: 'exists',
76
+ },
77
+ ]);
78
+ if (!answer.exists) {
79
+ return;
80
+ }
81
+ }
82
+ core_1.CliUx.ux.action.start(`Generating ${file}.json...`);
83
+ const content = await (0, fs_extra_1.readFile)(`connector/config/${file}.yaml`, 'utf8');
84
+ const json = js_yaml_1.default.load(content);
85
+ const values = {};
86
+ const { inputs } = json;
87
+ let key;
88
+ for (key in inputs.properties) {
89
+ if (Object.hasOwnProperty.call(inputs.properties, key)) {
90
+ const inputConfig = inputs.properties[key];
91
+ values[key] = ((_a = inputConfig === null || inputConfig === void 0 ? void 0 : inputConfig.examples) === null || _a === void 0 ? void 0 : _a[0]) || null;
92
+ }
93
+ }
94
+ await node_fs_1.promises.mkdir((0, node_path_1.dirname)(generatedFile), { recursive: true });
95
+ await (0, fs_extra_1.writeJson)(filePath, values, { spaces: 2, EOL: '\n' });
96
+ core_1.CliUx.ux.action.stop();
97
+ }
98
+ }
99
+ exports.Data = Data;
100
+ Data.description = 'Use to test a task in an integration';
101
+ Data.flags = Object.assign(Object.assign({}, core_2.Base.flags), { help: core_1.Flags.help({ char: 'h' }), name: core_1.Flags.string({ char: 'n', description: 'task name to run' }), asset: core_1.Flags.string({
102
+ description: 'asset json',
103
+ required: true,
104
+ default: 'data/asset.json',
105
+ }), inputs: core_1.Flags.string({
106
+ description: 'Filename for JSON inputs, defaults to the task name under the data folder. ie: data/my_task.json',
107
+ }), directory: core_1.Flags.string({
108
+ char: 'd',
109
+ description: 'current directory to mount',
110
+ default: './',
111
+ }) });
112
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../../../src/commands/action/generate/data.ts"],"names":[],"mappings":";;;;AAAA,sCAAwC;AACxC,wCAGsB;AACtB,uCAA4C;AAC5C,gEAA+B;AAC/B,wGAA6D;AAC7D,qCAAgC;AAChC,yCAAgD;AAChD,8DAA0B;AAC1B,kDAA0E;AAG1E,qCAAqC;AACrC,MAAa,IAAK,SAAQ,WAAI;IAuB5B,KAAK,CAAC,GAAG;QACP,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEtC,MAAM,EACJ,KAAK,GACN,GAAG,KAAK,CAAA;QAET,IAAI,EAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAC,GAAG,KAAK,CAAA;QACrC,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAC/C,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;QAE1C,IAA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C,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,EAC7B,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,kBAAkB,EAAC,CAAC,EAChE,KAAK,EAAE,YAAK,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,YAAY;QACzB,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,iBAAiB;KAC3B,CAAC,EACF,MAAM,EAAE,YAAK,CAAC,MAAM,CAAC;QACnB,WAAW,EACT,kGAAkG;KACrG,CAAC,EACF,SAAS,EAAE,YAAK,CAAC,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,4BAA4B;QACzC,OAAO,EAAE,IAAI;KACd,CAAC,IACF"}
@@ -0,0 +1,24 @@
1
+ import { Base } from '@sw-tsdk/core';
2
+ export declare class Image extends Base {
3
+ static description: string;
4
+ static hidden: boolean;
5
+ static flags: {
6
+ action: import("@oclif/core/lib/interfaces").OptionFlag<string>;
7
+ directory: import("@oclif/core/lib/interfaces").OptionFlag<string>;
8
+ 'input-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
+ 'output-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
+ 'error-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
+ 'asset-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
+ repository: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
13
+ version: import("@oclif/core/lib/interfaces").OptionFlag<string>;
14
+ platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
16
+ };
17
+ private docker;
18
+ private containerName;
19
+ run(): Promise<void>;
20
+ catch(error: Error & {
21
+ exitCode?: number;
22
+ }): Promise<void>;
23
+ cleanup(): Promise<void>;
24
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Image = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const core_2 = require("@sw-tsdk/core");
7
+ const node_path_1 = require("node:path");
8
+ const fs_extra_1 = require("fs-extra");
9
+ const docker_1 = require("@sw-tsdk/docker");
10
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
11
+ const slug_1 = tslib_1.__importDefault(require("slug"));
12
+ const docker_reference_1 = require("@swimlane/docker-reference");
13
+ const connector_1 = require("@sw-tsdk/connector");
14
+ // noinspection JSUnusedGlobalSymbols
15
+ class Image extends core_2.Base {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.docker = new docker_1.Docker();
19
+ }
20
+ async run() {
21
+ const { flags, } = await this.parse(Image);
22
+ let { directory, } = flags;
23
+ const { action, repository, version, } = flags;
24
+ directory = (0, node_path_1.resolve)(directory || node_process_1.default.cwd());
25
+ // ensure directory path
26
+ try {
27
+ await fs_extra_1.promises.access(directory);
28
+ }
29
+ catch (_a) {
30
+ this.error(`Could not access ${directory}`);
31
+ }
32
+ const inputPath = flags['input-path'] || (0, node_path_1.join)(directory, 'data', `${action}.json`);
33
+ const outputPath = flags['output-path'] || (0, node_path_1.join)(directory, 'data', `${action}_output.json`);
34
+ const errorPath = flags['error-path'] || (0, node_path_1.join)(directory, 'data', `${action}_error.txt`);
35
+ const assetPath = flags['asset-path'] || (0, node_path_1.join)(directory, 'data', 'asset.json');
36
+ if (!await (0, core_2.fileExists)(inputPath)) {
37
+ core_1.CliUx.ux.error(`Missing test data ${inputPath}`);
38
+ }
39
+ const asset = await (0, core_2.fileExists)(assetPath) ? await (0, fs_extra_1.readJson)(assetPath) : {};
40
+ // merge inputs and asset as 11.x sends it.
41
+ const inputs = JSON.stringify(Object.assign(await (0, fs_extra_1.readJson)(inputPath), asset));
42
+ // check that docker is running
43
+ core_1.CliUx.ux.action.start('Checking for docker...');
44
+ await this.docker.ping();
45
+ core_1.CliUx.ux.action.stop();
46
+ // Can run latest from quay, image provided, or default to the last built.
47
+ const image = `${repository}:${version}`;
48
+ core_1.CliUx.ux.action.start(`Pulling image ${image}...`);
49
+ await this.docker.pullImage(image);
50
+ await this.docker.pullImage('halverneus/static-file-server:latest');
51
+ core_1.CliUx.ux.action.stop();
52
+ await (0, fs_extra_1.ensureDir)((0, node_path_1.join)(directory, 'data', 'files'));
53
+ await fs_extra_1.promises.writeFile(outputPath, '{}');
54
+ await fs_extra_1.promises.writeFile(errorPath, '');
55
+ const containerReference = (0, docker_reference_1.parseQualifiedName)(image);
56
+ this.containerName = (0, slug_1.default)(containerReference.repository);
57
+ const cleanup = this.cleanup;
58
+ node_process_1.default.on('SIGINT', async function () {
59
+ await cleanup();
60
+ });
61
+ const environmentVars = Object.entries({
62
+ INPUTS: inputs,
63
+ IPC_API_URI: 'http://localhost:8080',
64
+ IPC_API_TOKEN: '',
65
+ }).map(([key, value]) => `${key}=${value !== null && value !== void 0 ? value : ''}`);
66
+ const createOptions = {
67
+ Env: environmentVars,
68
+ name: this.containerName,
69
+ AttachStdout: true,
70
+ AttachStderr: true,
71
+ Cmd: [action],
72
+ HostConfig: {
73
+ AutoRemove: true,
74
+ },
75
+ };
76
+ core_1.CliUx.ux.action.start('Executing...');
77
+ const outputFile = new connector_1.ContainerStdoutActionOutputTransform((0, fs_extra_1.createWriteStream)(outputPath));
78
+ const errorFile = await (0, fs_extra_1.createWriteStream)(errorPath);
79
+ const success = await this.docker.runImage(image, createOptions, outputFile, errorFile);
80
+ core_1.CliUx.ux.action.stop();
81
+ if (!success) {
82
+ core_1.Errors.exit(-1);
83
+ }
84
+ }
85
+ async catch(error) {
86
+ await this.cleanup();
87
+ throw error;
88
+ }
89
+ async cleanup() {
90
+ core_1.CliUx.ux.action.start('Removing stale containers...');
91
+ try {
92
+ await this.docker.deleteContainer('IPC_API');
93
+ }
94
+ catch (_a) { }
95
+ try {
96
+ await this.docker.deleteContainer(this.containerName);
97
+ }
98
+ catch (_b) { }
99
+ core_1.CliUx.ux.action.stop();
100
+ }
101
+ }
102
+ exports.Image = Image;
103
+ Image.description = 'Runs a connector action. (Defaults to current image version in local repository).';
104
+ Image.hidden = true;
105
+ Image.flags = Object.assign(Object.assign({}, core_2.Base.flags), { action: core_1.Flags.string({
106
+ char: 'a',
107
+ description: 'Action name to run',
108
+ required: true,
109
+ }), directory: core_1.Flags.string({
110
+ char: 'd',
111
+ description: 'Root directory of the repository.',
112
+ default: './',
113
+ }), 'input-path': core_1.Flags.string({
114
+ description: 'File to input data JSON file, defaults to /data/<action>.json',
115
+ }), 'output-path': core_1.Flags.string({
116
+ description: 'File to write the outputs to, defaults to /data/<action>_output.json',
117
+ }), 'error-path': core_1.Flags.string({
118
+ description: 'File to write the errors to, defaults to /data/<action>_error.json',
119
+ }), 'asset-path': core_1.Flags.string({
120
+ description: 'File to asset data JSON file, defaults to /data/asset.json',
121
+ }), repository: core_1.Flags.string({
122
+ char: 'r',
123
+ description: 'The connector image repository to run.',
124
+ }), version: core_1.Flags.string({
125
+ description: 'Use the latest release image from quay.',
126
+ default: 'latest',
127
+ }), platform: core_1.Flags.string({
128
+ hidden: true,
129
+ default: 'linux/amd64',
130
+ }), help: core_1.Flags.help({
131
+ char: 'h',
132
+ }) });
133
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../src/commands/action/run/image.ts"],"names":[],"mappings":";;;;AAAA,sCAAgD;AAChD,wCAA8C;AAC9C,yCAAuC;AACvC,uCAAyE;AACzE,4CAAqD;AACrD,wEAAkC;AAClC,wDAAuB;AACvB,iEAA6D;AAC7D,kDAAuE;AAEvE,qCAAqC;AACrC,MAAa,KAAM,SAAQ,WAAI;IAA/B;;QA4CU,WAAM,GAAW,IAAI,eAAM,EAAE,CAAA;IAkHvC,CAAC;IA/GC,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,GACN,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAE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KACvB,CAAC,EACF,IAAI,EAAE,YAAK,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,GAAG;KACV,CAAC,IACH"}
@@ -1,5 +1,5 @@
1
1
  import { Base } from '@sw-tsdk/core';
2
- export declare class Run extends Base {
2
+ export declare class Local extends Base {
3
3
  static description: string;
4
4
  static flags: {
5
5
  action: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
@@ -8,9 +8,6 @@ export declare class Run extends Base {
8
8
  'output-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
9
9
  'error-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
10
10
  'asset-path': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
11
- image: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
- latest: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
- build: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
11
  template: import("@oclif/core/lib/interfaces").OptionFlag<string>;
15
12
  'compile-override': import("@oclif/core/lib/interfaces").OptionFlag<string>;
16
13
  'runner-override': import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -19,5 +16,11 @@ export declare class Run extends Base {
19
16
  platform: import("@oclif/core/lib/interfaces").OptionFlag<string>;
20
17
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
21
18
  };
19
+ private docker;
20
+ private containerName;
22
21
  run(): Promise<void>;
22
+ catch(error: Error & {
23
+ exitCode?: number;
24
+ }): Promise<void>;
25
+ cleanup(): Promise<void>;
23
26
  }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Local = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const core_2 = require("@sw-tsdk/core");
7
+ const node_path_1 = require("node:path");
8
+ const fs_extra_1 = require("fs-extra");
9
+ const docker_1 = require("@sw-tsdk/docker");
10
+ const node_process_1 = tslib_1.__importDefault(require("node:process"));
11
+ const slug_1 = tslib_1.__importDefault(require("slug"));
12
+ const docker_reference_1 = require("@swimlane/docker-reference");
13
+ const connector_1 = require("@sw-tsdk/connector");
14
+ const common_1 = require("../../../common");
15
+ // noinspection JSUnusedGlobalSymbols
16
+ class Local extends core_2.Base {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.docker = new docker_1.Docker();
20
+ }
21
+ async run() {
22
+ const { flags, } = await this.parse(Local);
23
+ let { directory, } = flags;
24
+ let image = '';
25
+ const { template, action, 'compile-override': compileOverride, 'runner-override': runnerOverride, 'runtime-override': runtimeOverride, 'force-rebuild': nocache, platform, } = flags;
26
+ directory = (0, node_path_1.resolve)(directory || node_process_1.default.cwd());
27
+ // ensure directory path
28
+ try {
29
+ await fs_extra_1.promises.access(directory);
30
+ }
31
+ catch (_a) {
32
+ this.error(`Could not access ${directory}`);
33
+ }
34
+ // select action if not provided.
35
+ const actionToExecute = action || await (0, common_1.chooseAction)(directory);
36
+ const inputPath = flags['input-path'] || (0, node_path_1.join)(directory, 'data', `${actionToExecute}.json`);
37
+ const outputPath = flags['output-path'] || (0, node_path_1.join)(directory, 'data', `${actionToExecute}_output.json`);
38
+ const errorPath = flags['error-path'] || (0, node_path_1.join)(directory, 'data', `${actionToExecute}_error.txt`);
39
+ const assetPath = flags['asset-path'] || (0, node_path_1.join)(directory, 'data', 'asset.json');
40
+ if (!await (0, core_2.fileExists)(inputPath)) {
41
+ core_1.CliUx.ux.error(`Missing test data ${inputPath}`);
42
+ }
43
+ const asset = await (0, core_2.fileExists)(assetPath) ? await (0, fs_extra_1.readJson)(assetPath) : {};
44
+ // merge inputs and asset as 11.x sends it.
45
+ const inputs = JSON.stringify(Object.assign(await (0, fs_extra_1.readJson)(inputPath), asset));
46
+ // check that docker is running
47
+ core_1.CliUx.ux.action.start('Checking for docker...');
48
+ await this.docker.ping();
49
+ core_1.CliUx.ux.action.stop();
50
+ // Can run latest from quay, image provided, or default to the last built.
51
+ const connector = new connector_1.BuildConnector();
52
+ const result = await connector.build({
53
+ directory,
54
+ template,
55
+ compileOverride,
56
+ runnerOverride,
57
+ runtimeOverride,
58
+ nocache,
59
+ platform,
60
+ squash: false,
61
+ });
62
+ image = result.imageTag;
63
+ if (!image) {
64
+ core_1.CliUx.ux.error('No image to run, check command flags.');
65
+ return;
66
+ }
67
+ await (0, fs_extra_1.ensureDir)((0, node_path_1.join)(directory, 'data', 'files'));
68
+ await fs_extra_1.promises.writeFile(outputPath, '{}');
69
+ await fs_extra_1.promises.writeFile(errorPath, '');
70
+ const containerReference = (0, docker_reference_1.parseQualifiedName)(image);
71
+ this.containerName = (0, slug_1.default)(containerReference.repository);
72
+ const cleanup = this.cleanup;
73
+ node_process_1.default.on('SIGINT', async function () {
74
+ await cleanup();
75
+ });
76
+ const environmentVars = Object.entries({
77
+ INPUTS: inputs,
78
+ IPC_API_URI: 'http://localhost:8080',
79
+ IPC_API_TOKEN: '',
80
+ }).map(([key, value]) => `${key}=${value !== null && value !== void 0 ? value : ''}`);
81
+ const createOptions = {
82
+ Env: environmentVars,
83
+ name: this.containerName,
84
+ AttachStdout: true,
85
+ AttachStderr: true,
86
+ Cmd: [actionToExecute],
87
+ HostConfig: {
88
+ AutoRemove: true,
89
+ },
90
+ };
91
+ core_1.CliUx.ux.action.start('Executing...');
92
+ const outputFile = new connector_1.ContainerStdoutActionOutputTransform((0, fs_extra_1.createWriteStream)(outputPath));
93
+ const errorFile = await (0, fs_extra_1.createWriteStream)(errorPath);
94
+ const success = await this.docker.runImage(image, createOptions, outputFile, errorFile);
95
+ core_1.CliUx.ux.action.stop();
96
+ if (!success) {
97
+ core_1.Errors.exit(-1);
98
+ }
99
+ }
100
+ async catch(error) {
101
+ await this.cleanup();
102
+ throw error;
103
+ }
104
+ async cleanup() {
105
+ core_1.CliUx.ux.action.start('Removing stale containers...');
106
+ try {
107
+ await this.docker.deleteContainer('IPC_API');
108
+ }
109
+ catch (_a) { }
110
+ try {
111
+ await this.docker.deleteContainer(this.containerName);
112
+ }
113
+ catch (_b) { }
114
+ core_1.CliUx.ux.action.stop();
115
+ }
116
+ }
117
+ exports.Local = Local;
118
+ Local.description = 'Runs a connector action. (Defaults to current image version in local repository).';
119
+ Local.flags = Object.assign(Object.assign({}, core_2.Base.flags), { action: core_1.Flags.string({
120
+ char: 'a',
121
+ description: 'Action name to run',
122
+ }), directory: core_1.Flags.string({
123
+ char: 'd',
124
+ description: 'Root directory of the repository.',
125
+ default: './',
126
+ }), 'input-path': core_1.Flags.string({
127
+ description: 'File to input data JSON file, defaults to /data/<action>.json',
128
+ }), 'output-path': core_1.Flags.string({
129
+ description: 'File to write the outputs to, defaults to /data/<action>_output.json',
130
+ }), 'error-path': core_1.Flags.string({
131
+ description: 'File to write the errors to, defaults to /data/<action>_error.json',
132
+ }), 'asset-path': core_1.Flags.string({
133
+ description: 'File to asset data JSON file, defaults to /data/asset.json',
134
+ }), template: core_1.Flags.string({
135
+ description: 'connector template',
136
+ options: ['python_3.7_swimlane', 'node_18', 'python_310_definition'],
137
+ default: 'python_310_definition',
138
+ }), 'compile-override': core_1.Flags.string({
139
+ hidden: true,
140
+ default: 'Compile.Dockerfile',
141
+ }), 'runner-override': core_1.Flags.string({
142
+ hidden: true,
143
+ default: 'Runner.Dockerfile',
144
+ }), 'runtime-override': core_1.Flags.string({
145
+ hidden: true,
146
+ }), 'force-rebuild': core_1.Flags.boolean({
147
+ char: 'f',
148
+ description: 'forces nocache on the image build',
149
+ }), platform: core_1.Flags.string({
150
+ hidden: true,
151
+ default: 'linux/amd64',
152
+ }), help: core_1.Flags.help({
153
+ char: 'h',
154
+ }) });
155
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/commands/action/run/local.ts"],"names":[],"mappings":";;;;AAAA,sCAAgD;AAChD,wCAA8C;AAC9C,yCAAuC;AACvC,uCAAyE;AACzE,4CAAqD;AACrD,wEAAkC;AAClC,wDAAuB;AACvB,iEAA6D;AAC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F,CAAC,EACF,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,oEAAoE;KAClF,CAAC,EACF,YAAY,EAAE,YAAK,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,4DAA4D;KAC1E,CAAC,EACF,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACrB,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,CAAC,qBAAqB,EAAE,SAAS,EAAE,uBAAuB,CAAC;QACpE,OAAO,EAAE,uBAAuB;KACjC,CAAC,EACF,kBAAkB,EAAE,YAAK,CAAC,MAAM,CAAC;QAC/B,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,oBAAoB;KAC9B,CAAC,EACF,iBAAiB,EAAE,YAAK,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,mBAAmB;KAC7B,CAAC,EACF,kBAAkB,EAAE,YAAK,CAAC,MAAM,CAAC;QAC/B,MAAM,EAAE,IAAI;KACb,CAAC,EACF,eAAe,EAAE,YAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,EAAE,GAAG;QACT,WAAW,EAAE,mCAAmC;KACjD,CAAC,EACF,QAAQ,EAAE,YAAK,CAAC,MAAM,CAAC;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,aAAa;KACvB,CAAC,EACF,IAAI,EAAE,YAAK,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,GAAG;KACV,CAAC,IACH"}
@@ -1 +1 @@
1
- {"version":"2.0.1-next.41+e3bd50c","commands":{"action:add":{"id":"action:add","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"template":{"name":"template","type":"option","char":"t","description":"action template to scaffold","multiple":false,"options":["node_18","python_310_definition","python_3.7_swimlane"],"default":"python_310_definition"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:input":{"id":"action:input","description":"Update action input schema.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"amend":{"name":"amend","type":"boolean","description":"Merge with existing schema.","allowNo":false},"action-config-path":{"name":"action-config-path","type":"option","description":"Override path to action configuration file. Defaults to /connector/config/actions/<action>.yaml","multiple":false},"input-path":{"name":"input-path","type":"option","description":"Relative path to the output data JSON file, defaults to the task name under the data folder. ie: /data/<taskName>_output.json","multiple":false,"dependsOn":["update-output-schema"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:output":{"id":"action:output","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"action-config-path":{"name":"action-config-path","type":"option","description":"Override path to action configuration file. Defaults to /connector/config/<action>.yaml","multiple":false},"amend":{"name":"amend","type":"boolean","description":"Merge with existing schema.","allowNo":false},"output-path":{"name":"output-path","type":"option","description":"Relative path to the output data JSON file, defaults to the task name under the data folder. ie: /data/<taskName>_output.json","multiple":false,"dependsOn":["update-output-schema"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:run":{"id":"action:run","description":"Runs a connector action. (Defaults to current image version in local repository).","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"input-path":{"name":"input-path","type":"option","description":"File to input data JSON file, defaults to /data/<action>.json","multiple":false},"output-path":{"name":"output-path","type":"option","description":"File to write the outputs to, defaults to /data/<action>_output.json","multiple":false},"error-path":{"name":"error-path","type":"option","description":"File to write the errors to, defaults to /data/<action>_error.json","multiple":false},"asset-path":{"name":"asset-path","type":"option","description":"File to asset data JSON file, defaults to /data/asset.json","multiple":false},"image":{"name":"image","type":"option","char":"i","description":"The connector image to run.","multiple":false,"exclusive":["build","latest"]},"latest":{"name":"latest","type":"boolean","description":"Use the latest release image from quay.","allowNo":false,"exclusive":["build","image"]},"build":{"name":"build","type":"boolean","description":"Builds image and runs it.","allowNo":false,"exclusive":["latest","image"]},"template":{"name":"template","type":"option","description":"connector template","multiple":false,"options":["python_3.7","node_18","python_310_definition"],"default":"python_310_definition"},"compile-override":{"name":"compile-override","type":"option","hidden":true,"multiple":false,"default":"Compile.Dockerfile"},"runner-override":{"name":"runner-override","type":"option","hidden":true,"multiple":false,"default":"Runner.Dockerfile"},"runtime-override":{"name":"runtime-override","type":"option","hidden":true,"multiple":false,"dependsOn":["build"]},"force-rebuild":{"name":"force-rebuild","type":"boolean","char":"f","description":"forces nocache on the image build","allowNo":false,"dependsOn":["build"]},"platform":{"name":"platform","type":"option","hidden":true,"multiple":false,"default":"linux/amd64"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"asset:add":{"id":"asset:add","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"scheme":{"name":"scheme","type":"option","char":"s","description":"asset template to scaffold","multiple":false,"options":["custom","apikey","client_credentials","basic","bearer"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:build":{"id":"connector:build","description":"Builds a local docker image of the connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"template":{"name":"template","type":"option","description":"connector language","required":true,"multiple":false,"options":["python_3.7_swimlane","node_18","python_310_definition"],"default":"python_310_definition"},"compile-override":{"name":"compile-override","type":"option","hidden":true,"multiple":false,"default":"Compile.Dockerfile"},"runner-override":{"name":"runner-override","type":"option","hidden":true,"multiple":false,"default":"Runner.Dockerfile"},"runtime-override":{"name":"runtime-override","type":"option","hidden":true,"multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"save":{"name":"save","type":"boolean","description":"saves docker image as tar in local directory.","allowNo":false},"squash":{"name":"squash","type":"boolean","description":"squashes the docker layers.","hidden":true,"allowNo":false},"force-rebuild":{"name":"force-rebuild","type":"boolean","char":"f","description":"forces nocache on the image build","allowNo":false},"platform":{"name":"platform","type":"option","hidden":true,"multiple":false,"default":"linux/amd64"},"signing-password":{"name":"signing-password","type":"option","description":"password used for the private key","multiple":false,"dependsOn":["save"],"default":""},"key-name":{"name":"key-name","type":"option","description":"name used for the key (default: username)","required":true,"multiple":false,"dependsOn":["save"]},"skip-upload":{"name":"skip-upload","type":"boolean","hidden":true,"allowNo":false,"dependsOn":["save"]},"registry":{"name":"registry","type":"option","description":"registry to use for signing","multiple":false,"dependsOn":["save"],"default":"localhost:5000"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:create-source":{"id":"connector:create-source","description":"Generates 11x source from 10x","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:create":{"id":"connector:create","description":"Scaffold a new connector","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory for where to store connectors, the connector directory will be generated.","multiple":false,"default":"./"},"template":{"name":"template","type":"option","char":"t","description":"connector template to scaffold","multiple":false,"options":["node_18","python_310_definition","python_3.7_swimlane"],"default":"python_310_definition"},"skip-repo":{"name":"skip-repo","type":"boolean","description":"skips the repository creation process","allowNo":false},"clientId":{"name":"clientId","type":"option","char":"c","description":"client id of the authentication app","hidden":true,"multiple":false,"default":"0d418a5615c458b0b593"},"vendor":{"name":"vendor","type":"option","description":"Vendor (e.g. CrowdStrike)","multiple":false},"product":{"name":"product","type":"option","description":"Product (e.g. Falcon)","multiple":false},"keywords":{"name":"keywords","type":"option","description":"Please enter keyword (Comma-Separated)","multiple":false},"description":{"name":"description","type":"option","description":"Description (e.g. CrowdStrike Host Query API)","multiple":false},"logoPath":{"name":"logoPath","type":"option","description":"URL or absolute path to logo file","multiple":false},"author":{"name":"author","type":"option","description":"Connector Author","multiple":false},"authorEmail":{"name":"authorEmail","type":"option","description":"Connector Author Email","multiple":false},"homepage":{"name":"homepage","type":"option","description":"Connector Author Support URL","multiple":false},"repo-base-template":{"name":"repo-base-template","type":"option","char":"t","description":"github base template override to create repo from.","hidden":true,"multiple":false,"default":"connector-python-definition-template"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:logo":{"id":"connector:logo","description":"Update a connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the connector folder.","multiple":false,"default":"."},"path":{"name":"path","type":"option","char":"p","description":"path or URL to product logo in PNG format.","required":true,"multiple":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:save":{"id":"connector:save","description":"Save a docker image locally as .tar.gz","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repo.","multiple":false,"default":"."},"output":{"name":"output","type":"option","char":"o","description":"output file to where to store the image.","required":true,"multiple":false},"image":{"name":"image","type":"option","char":"i","description":"image to save.","required":true,"multiple":false},"skip-pull":{"name":"skip-pull","type":"boolean","char":"s","description":"skips pulling the image","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:sign":{"id":"connector:sign","description":"Builds a local docker image of the connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"image":{"name":"image","type":"option","description":"image name to sign","required":true,"multiple":false},"signing-password":{"name":"signing-password","type":"option","description":"password used for the private key","multiple":false,"default":""},"save":{"name":"save","type":"boolean","description":"saves docker image as tar in local directory.","allowNo":false},"key-name":{"name":"key-name","type":"option","description":"name used for the key (default: username)","required":true,"multiple":false},"skip-upload":{"name":"skip-upload","type":"boolean","hidden":true,"allowNo":false},"registry":{"name":"registry","type":"option","description":"registry to use for signing","multiple":false,"default":"localhost:5000"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:update":{"id":"connector:update","description":"Update a connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the connector folder.","multiple":false,"default":"."},"version":{"name":"version","type":"option","char":"v","description":"new version of the connector.","multiple":false},"manifest-path":{"name":"manifest-path","type":"option","char":"f","description":"connector manifest path relative to directory.","multiple":false,"default":"/connector/connector.yaml"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:validate":{"id":"connector:validate","description":"Use to validate an integration","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"image":{"name":"image","type":"option","char":"i","description":"image to use","multiple":false},"connector":{"name":"connector","type":"option","char":"c","description":"connector to validate (relative to directory)","required":true,"multiple":false,"default":"connector"},"signed":{"name":"signed","type":"boolean","description":"validates a signed connector","allowNo":false},"key":{"name":"key","type":"option","description":"public key for verfication","multiple":false,"dependsOn":["signed"],"exclusive":["skip-verification"]},"skip-pull":{"name":"skip-pull","type":"boolean","char":"s","description":"skips pulling the image","allowNo":false},"directory":{"name":"directory","type":"option","char":"d","description":"current directory to mount","multiple":false,"default":"./"}},"args":[]}}}
1
+ {"version":"2.0.1-next.44+e410fa1","commands":{"action:add":{"id":"action:add","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"template":{"name":"template","type":"option","char":"t","description":"action template to scaffold","multiple":false,"options":["node_18","python_310_definition","python_3.7_swimlane"],"default":"python_310_definition"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:input":{"id":"action:input","description":"Update action input schema.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"amend":{"name":"amend","type":"boolean","description":"Merge with existing schema.","allowNo":false},"action-config-path":{"name":"action-config-path","type":"option","description":"Override path to action configuration file. Defaults to /connector/config/actions/<action>.yaml","multiple":false},"input-path":{"name":"input-path","type":"option","description":"Relative path to the output data JSON file, defaults to the task name under the data folder. ie: /data/<taskName>_output.json","multiple":false,"dependsOn":["update-output-schema"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:output":{"id":"action:output","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"action-config-path":{"name":"action-config-path","type":"option","description":"Override path to action configuration file. Defaults to /connector/config/<action>.yaml","multiple":false},"amend":{"name":"amend","type":"boolean","description":"Merge with existing schema.","allowNo":false},"output-path":{"name":"output-path","type":"option","description":"Relative path to the output data JSON file, defaults to the task name under the data folder. ie: /data/<taskName>_output.json","multiple":false,"dependsOn":["update-output-schema"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"asset:add":{"id":"asset:add","description":"Update a connector action.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"scheme":{"name":"scheme","type":"option","char":"s","description":"asset template to scaffold","multiple":false,"options":["custom","apikey","client_credentials","basic","bearer"]},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:build":{"id":"connector:build","description":"Builds a local docker image of the connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"template":{"name":"template","type":"option","description":"connector language","required":true,"multiple":false,"options":["python_3.7_swimlane","node_18","python_310_definition"],"default":"python_310_definition"},"compile-override":{"name":"compile-override","type":"option","hidden":true,"multiple":false,"default":"Compile.Dockerfile"},"runner-override":{"name":"runner-override","type":"option","hidden":true,"multiple":false,"default":"Runner.Dockerfile"},"runtime-override":{"name":"runtime-override","type":"option","hidden":true,"multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"save":{"name":"save","type":"boolean","description":"saves docker image as tar in local directory.","allowNo":false},"squash":{"name":"squash","type":"boolean","description":"squashes the docker layers.","hidden":true,"allowNo":false},"force-rebuild":{"name":"force-rebuild","type":"boolean","char":"f","description":"forces nocache on the image build","allowNo":false},"platform":{"name":"platform","type":"option","hidden":true,"multiple":false,"default":"linux/amd64"},"signing-password":{"name":"signing-password","type":"option","description":"password used for the private key","multiple":false,"dependsOn":["save"],"default":""},"key-name":{"name":"key-name","type":"option","description":"name used for the key (default: username)","required":true,"multiple":false,"dependsOn":["save"]},"skip-upload":{"name":"skip-upload","type":"boolean","hidden":true,"allowNo":false,"dependsOn":["save"]},"registry":{"name":"registry","type":"option","description":"registry to use for signing","multiple":false,"dependsOn":["save"],"default":"localhost:5000"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:create-source":{"id":"connector:create-source","description":"Generates 11x source from 10x","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:create":{"id":"connector:create","description":"Scaffold a new connector","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory for where to store connectors, the connector directory will be generated.","multiple":false,"default":"./"},"template":{"name":"template","type":"option","char":"t","description":"connector template to scaffold","multiple":false,"options":["node_18","python_310_definition","python_3.7_swimlane"],"default":"python_310_definition"},"skip-repo":{"name":"skip-repo","type":"boolean","description":"skips the repository creation process","allowNo":false},"clientId":{"name":"clientId","type":"option","char":"c","description":"client id of the authentication app","hidden":true,"multiple":false,"default":"0d418a5615c458b0b593"},"vendor":{"name":"vendor","type":"option","description":"Vendor (e.g. CrowdStrike)","multiple":false},"product":{"name":"product","type":"option","description":"Product (e.g. Falcon)","multiple":false},"keywords":{"name":"keywords","type":"option","description":"Please enter keyword (Comma-Separated)","multiple":false},"description":{"name":"description","type":"option","description":"Description (e.g. CrowdStrike Host Query API)","multiple":false},"logoPath":{"name":"logoPath","type":"option","description":"URL or absolute path to logo file","multiple":false},"author":{"name":"author","type":"option","description":"Connector Author","multiple":false},"authorEmail":{"name":"authorEmail","type":"option","description":"Connector Author Email","multiple":false},"homepage":{"name":"homepage","type":"option","description":"Connector Author Support URL","multiple":false},"repo-base-template":{"name":"repo-base-template","type":"option","char":"t","description":"github base template override to create repo from.","hidden":true,"multiple":false,"default":"connector-python-definition-template"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:logo":{"id":"connector:logo","description":"Update a connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the connector folder.","multiple":false,"default":"."},"path":{"name":"path","type":"option","char":"p","description":"path or URL to product logo in PNG format.","required":true,"multiple":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:save":{"id":"connector:save","description":"Save a docker image locally as .tar.gz","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repo.","multiple":false,"default":"."},"output":{"name":"output","type":"option","char":"o","description":"output file to where to store the image.","required":true,"multiple":false},"image":{"name":"image","type":"option","char":"i","description":"image to save.","required":true,"multiple":false},"skip-pull":{"name":"skip-pull","type":"boolean","char":"s","description":"skips pulling the image","allowNo":false},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:sign":{"id":"connector:sign","description":"Builds a local docker image of the connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the repository.","multiple":false,"default":"./"},"image":{"name":"image","type":"option","description":"image name to sign","required":true,"multiple":false},"signing-password":{"name":"signing-password","type":"option","description":"password used for the private key","multiple":false,"default":""},"save":{"name":"save","type":"boolean","description":"saves docker image as tar in local directory.","allowNo":false},"key-name":{"name":"key-name","type":"option","description":"name used for the key (default: username)","required":true,"multiple":false},"skip-upload":{"name":"skip-upload","type":"boolean","hidden":true,"allowNo":false},"registry":{"name":"registry","type":"option","description":"registry to use for signing","multiple":false,"default":"localhost:5000"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:update":{"id":"connector:update","description":"Update a connector.","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"directory":{"name":"directory","type":"option","char":"d","description":"root directory of the connector folder.","multiple":false,"default":"."},"version":{"name":"version","type":"option","char":"v","description":"new version of the connector.","multiple":false},"manifest-path":{"name":"manifest-path","type":"option","char":"f","description":"connector manifest path relative to directory.","multiple":false,"default":"/connector/connector.yaml"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"connector:validate":{"id":"connector:validate","description":"Use to validate an integration","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"image":{"name":"image","type":"option","char":"i","description":"image to use","multiple":false},"connector":{"name":"connector","type":"option","char":"c","description":"connector to validate (relative to directory)","required":true,"multiple":false,"default":"connector"},"signed":{"name":"signed","type":"boolean","description":"validates a signed connector","allowNo":false},"key":{"name":"key","type":"option","description":"public key for verfication","multiple":false,"dependsOn":["signed"],"exclusive":["skip-verification"]},"skip-pull":{"name":"skip-pull","type":"boolean","char":"s","description":"skips pulling the image","allowNo":false},"directory":{"name":"directory","type":"option","char":"d","description":"current directory to mount","multiple":false,"default":"./"}},"args":[]},"action:generate:data":{"id":"action:generate:data","description":"Use to test a task in an integration","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false},"name":{"name":"name","type":"option","char":"n","description":"task name to run","multiple":false},"asset":{"name":"asset","type":"option","description":"asset json","required":true,"multiple":false,"default":"data/asset.json"},"inputs":{"name":"inputs","type":"option","description":"Filename for JSON inputs, defaults to the task name under the data folder. ie: data/my_task.json","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"current directory to mount","multiple":false,"default":"./"}},"args":[]},"action:run:image":{"id":"action:run:image","description":"Runs a connector action. (Defaults to current image version in local repository).","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","hidden":true,"aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","required":true,"multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"input-path":{"name":"input-path","type":"option","description":"File to input data JSON file, defaults to /data/<action>.json","multiple":false},"output-path":{"name":"output-path","type":"option","description":"File to write the outputs to, defaults to /data/<action>_output.json","multiple":false},"error-path":{"name":"error-path","type":"option","description":"File to write the errors to, defaults to /data/<action>_error.json","multiple":false},"asset-path":{"name":"asset-path","type":"option","description":"File to asset data JSON file, defaults to /data/asset.json","multiple":false},"repository":{"name":"repository","type":"option","char":"r","description":"The connector image repository to run.","multiple":false},"version":{"name":"version","type":"option","description":"Use the latest release image from quay.","multiple":false,"default":"latest"},"platform":{"name":"platform","type":"option","hidden":true,"multiple":false,"default":"linux/amd64"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]},"action:run:local":{"id":"action:run:local","description":"Runs a connector action. (Defaults to current image version in local repository).","strict":true,"pluginName":"@sw-tsdk/plugin-connector","pluginAlias":"@sw-tsdk/plugin-connector","pluginType":"core","aliases":[],"flags":{"action":{"name":"action","type":"option","char":"a","description":"Action name to run","multiple":false},"directory":{"name":"directory","type":"option","char":"d","description":"Root directory of the repository.","multiple":false,"default":"./"},"input-path":{"name":"input-path","type":"option","description":"File to input data JSON file, defaults to /data/<action>.json","multiple":false},"output-path":{"name":"output-path","type":"option","description":"File to write the outputs to, defaults to /data/<action>_output.json","multiple":false},"error-path":{"name":"error-path","type":"option","description":"File to write the errors to, defaults to /data/<action>_error.json","multiple":false},"asset-path":{"name":"asset-path","type":"option","description":"File to asset data JSON file, defaults to /data/asset.json","multiple":false},"template":{"name":"template","type":"option","description":"connector template","multiple":false,"options":["python_3.7_swimlane","node_18","python_310_definition"],"default":"python_310_definition"},"compile-override":{"name":"compile-override","type":"option","hidden":true,"multiple":false,"default":"Compile.Dockerfile"},"runner-override":{"name":"runner-override","type":"option","hidden":true,"multiple":false,"default":"Runner.Dockerfile"},"runtime-override":{"name":"runtime-override","type":"option","hidden":true,"multiple":false},"force-rebuild":{"name":"force-rebuild","type":"boolean","char":"f","description":"forces nocache on the image build","allowNo":false},"platform":{"name":"platform","type":"option","hidden":true,"multiple":false,"default":"linux/amd64"},"help":{"name":"help","type":"boolean","char":"h","description":"Show CLI help.","allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -5,10 +5,10 @@
5
5
  },
6
6
  "dependencies": {
7
7
  "@oclif/core": "1.16.4",
8
- "@sw-tsdk/common": "^2.0.1-next.41+e3bd50c",
9
- "@sw-tsdk/connector": "^2.0.1-next.41+e3bd50c",
10
- "@sw-tsdk/core": "^2.0.1-next.41+e3bd50c",
11
- "@sw-tsdk/docker": "^2.0.1-next.41+e3bd50c",
8
+ "@sw-tsdk/common": "^2.0.1-next.44+e410fa1",
9
+ "@sw-tsdk/connector": "^2.0.1-next.44+e410fa1",
10
+ "@sw-tsdk/core": "^2.0.1-next.44+e410fa1",
11
+ "@sw-tsdk/docker": "^2.0.1-next.44+e410fa1",
12
12
  "@swimlane/connector-interfaces": "1.8.5-rc3",
13
13
  "@swimlane/cosign": "1.3.1",
14
14
  "@swimlane/docker-reference": "0.0.15",
@@ -22,6 +22,7 @@
22
22
  "noop-stream": "1.0.0",
23
23
  "npmlog": "6.0.1",
24
24
  "semver": "7.3.6",
25
+ "slug": "5.3.0",
25
26
  "snake-case": "3.0.4",
26
27
  "tslib": "2.3.1"
27
28
  },
@@ -86,6 +87,6 @@
86
87
  "posttest": "yarn lint",
87
88
  "dev:setup": "npm link"
88
89
  },
89
- "version": "2.0.1-next.41+e3bd50c",
90
- "gitHead": "e3bd50c20ff86123b9133fa06bdb78b0edc1e49a"
90
+ "version": "2.0.1-next.44+e410fa1",
91
+ "gitHead": "e410fa11ed2857f3d01ccefc73fd791503ec5573"
91
92
  }
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Run = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@oclif/core");
6
- const core_2 = require("@sw-tsdk/core");
7
- const node_path_1 = require("node:path");
8
- const fs_extra_1 = require("fs-extra");
9
- const docker_1 = require("@sw-tsdk/docker");
10
- const node_process_1 = tslib_1.__importDefault(require("node:process"));
11
- const connector_1 = require("@sw-tsdk/connector");
12
- const common_1 = require("../../common");
13
- // noinspection JSUnusedGlobalSymbols
14
- class Run extends core_2.Base {
15
- async run() {
16
- const { flags, } = await this.parse(Run);
17
- let { directory, image, 'input-path': inputPath, 'output-path': outputPath, 'error-path': errorPath, 'asset-path': assetPath, action, } = flags;
18
- const { build, latest, template, 'compile-override': compileOverride, 'runner-override': runnerOverride, 'runtime-override': runtimeOverride, 'force-rebuild': nocache, platform, } = flags;
19
- directory = (0, node_path_1.resolve)(directory || node_process_1.default.cwd());
20
- // ensure directory path
21
- try {
22
- await fs_extra_1.promises.access(directory);
23
- }
24
- catch (_a) {
25
- this.error(`Could not access ${directory}`);
26
- }
27
- // select action if not provided.
28
- if (!action) {
29
- action = await (0, common_1.chooseAction)(directory);
30
- }
31
- inputPath = inputPath || (0, node_path_1.join)(directory, 'data', `${action}.json`);
32
- outputPath = outputPath || (0, node_path_1.join)(directory, 'data', `${action}_output.json`);
33
- errorPath = errorPath || (0, node_path_1.join)(directory, 'data', `${action}_error.txt`);
34
- assetPath = assetPath || (0, node_path_1.join)(directory, 'data', 'asset.json');
35
- // merge inputs and asset as 11.x sends it.
36
- const inputs = JSON.stringify(Object.assign(await (0, fs_extra_1.readJson)(inputPath), await (0, fs_extra_1.readJson)(assetPath)));
37
- const manifests = await (0, connector_1.allManifests)(directory);
38
- const connector = manifests.find(m => (0, connector_1.isConnectorManifest)(m));
39
- // check that docker is running
40
- const docker = new docker_1.Docker();
41
- core_1.CliUx.ux.action.start('Checking for docker...');
42
- await docker.ping();
43
- core_1.CliUx.ux.action.stop();
44
- // Can run latest from quay, image provided, or default to the last built.
45
- if (build) {
46
- const connector = new connector_1.BuildConnector();
47
- const result = await connector.build({
48
- directory,
49
- template,
50
- compileOverride,
51
- runnerOverride,
52
- runtimeOverride,
53
- nocache,
54
- platform,
55
- squash: false,
56
- });
57
- image = result.imageTag;
58
- }
59
- else if (latest) {
60
- image = `${connector.meta.imageRepository}:latest`;
61
- await docker.pullImage(image);
62
- }
63
- else if (!image) {
64
- core_1.CliUx.ux.error('No image to run, check command flags.');
65
- }
66
- await (0, fs_extra_1.ensureDir)((0, node_path_1.join)(directory, 'data'));
67
- await fs_extra_1.promises.writeFile(outputPath, '{}');
68
- await fs_extra_1.promises.writeFile(errorPath, '');
69
- const environmentVars = [`INPUTS=${inputs}`];
70
- const createOptions = {
71
- Env: environmentVars,
72
- name: action,
73
- AttachStdout: true,
74
- AttachStderr: true,
75
- Cmd: [action],
76
- HostConfig: {
77
- AutoRemove: true,
78
- },
79
- };
80
- core_1.CliUx.ux.action.start('Executing...');
81
- const outputFile = await (0, fs_extra_1.createWriteStream)(outputPath);
82
- const errorFile = await (0, fs_extra_1.createWriteStream)(errorPath);
83
- const success = await docker.runImage(image, createOptions, outputFile, errorFile);
84
- core_1.CliUx.ux.action.stop();
85
- if (!success) {
86
- core_1.Errors.exit(-1);
87
- }
88
- }
89
- }
90
- exports.Run = Run;
91
- Run.description = 'Runs a connector action. (Defaults to current image version in local repository).';
92
- Run.flags = Object.assign(Object.assign({}, core_2.Base.flags), { action: core_1.Flags.string({
93
- char: 'a',
94
- description: 'Action name to run',
95
- }), directory: core_1.Flags.string({
96
- char: 'd',
97
- description: 'Root directory of the repository.',
98
- default: './',
99
- }), 'input-path': core_1.Flags.string({
100
- description: 'File to input data JSON file, defaults to /data/<action>.json',
101
- }), 'output-path': core_1.Flags.string({
102
- description: 'File to write the outputs to, defaults to /data/<action>_output.json',
103
- }), 'error-path': core_1.Flags.string({
104
- description: 'File to write the errors to, defaults to /data/<action>_error.json',
105
- }), 'asset-path': core_1.Flags.string({
106
- description: 'File to asset data JSON file, defaults to /data/asset.json',
107
- }), image: core_1.Flags.string({
108
- char: 'i',
109
- description: 'The connector image to run.',
110
- exclusive: ['build', 'latest'],
111
- }), latest: core_1.Flags.boolean({
112
- description: 'Use the latest release image from quay.',
113
- default: false,
114
- exclusive: ['build', 'image'],
115
- }), build: core_1.Flags.boolean({
116
- description: 'Builds image and runs it.',
117
- default: false,
118
- exclusive: ['latest', 'image'],
119
- }), template: core_1.Flags.string({
120
- description: 'connector template',
121
- options: ['python_3.7', 'node_18', 'python_310_definition'],
122
- default: 'python_310_definition',
123
- }), 'compile-override': core_1.Flags.string({
124
- hidden: true,
125
- default: 'Compile.Dockerfile',
126
- }), 'runner-override': core_1.Flags.string({
127
- hidden: true,
128
- default: 'Runner.Dockerfile',
129
- }), 'runtime-override': core_1.Flags.string({
130
- hidden: true,
131
- dependsOn: ['build'],
132
- }), 'force-rebuild': core_1.Flags.boolean({
133
- char: 'f',
134
- description: 'forces nocache on the image build',
135
- dependsOn: ['build'],
136
- }), platform: core_1.Flags.string({
137
- hidden: true,
138
- default: 'linux/amd64',
139
- }), help: core_1.Flags.help({
140
- char: 'h',
141
- }) });
142
- //# sourceMappingURL=run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/action/run.ts"],"names":[],"mappings":";;;;AAAA,sCAAgD;AAChD,wCAAkC;AAClC,yCAAuC;AACvC,uCAAyE;AACzE,4CAAqD;AACrD,wEAAkC;AAClC,kDAAoF;AAEpF,yCAAyC;AAEzC,qCAAqC;AACrC,MAAa,GAAI,SAAQ,WAAI;IAwE3B,KAAK,CAAC,GAAG;QACP,MAAM,EACJ,KAAK,GACN,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAEzB,IAAI,EACF,SAAS,EACT,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,aAAa,EAAE,UAAU,EACzB,YAAY,EAAE,SAAS,EACvB,YAAY,EAAE,SAAS,EACvB,MAAM,GACP,GAAG,KAAK,CAAA;QAET,MAAM,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,kBAAkB,EAAE,eAAe,EACnC,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,eAAe,EAAE,OAAO,EACxB,QAAQ,GACT,GAAG,KAAK,CAAA;QAET,SAAS,GAAG,IAAA,mBAAO,EAAC,SAAS,IAAI,sBAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAE/C,wBAAwB;QACxB,IAAI;YACF,MAAM,mBAAQ,CAAC,MAAM,CAAC,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