@toa.io/cli 0.20.0-alpha.0 → 0.20.0-alpha.2
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/package.json +7 -7
- package/readme.md +16 -0
- package/src/commands/call.js +20 -0
- package/src/commands/invoke.js +1 -1
- package/src/handlers/call.js +36 -0
- package/src/handlers/compose.js +1 -1
- package/src/handlers/serve.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/cli",
|
|
3
|
-
"version": "0.20.0-alpha.
|
|
3
|
+
"version": "0.20.0-alpha.2",
|
|
4
4
|
"description": "Toa CLI",
|
|
5
5
|
"author": "temich <tema.gurtovoy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/toa-io/toa#readme",
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"@toa.io/runtime": "*"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toa.io/console": "0.20.0-alpha.
|
|
26
|
-
"@toa.io/generic": "0.20.0-alpha.
|
|
27
|
-
"@toa.io/kubernetes": "0.20.0-alpha.
|
|
28
|
-
"@toa.io/norm": "0.20.0-alpha.
|
|
29
|
-
"@toa.io/yaml": "0.20.0-alpha.
|
|
25
|
+
"@toa.io/console": "0.20.0-alpha.2",
|
|
26
|
+
"@toa.io/generic": "0.20.0-alpha.2",
|
|
27
|
+
"@toa.io/kubernetes": "0.20.0-alpha.2",
|
|
28
|
+
"@toa.io/norm": "0.20.0-alpha.2",
|
|
29
|
+
"@toa.io/yaml": "0.20.0-alpha.2",
|
|
30
30
|
"dotenv": "16.1.1",
|
|
31
31
|
"find-up": "5.0.0",
|
|
32
32
|
"paseto": "3.1.4",
|
|
33
33
|
"yargs": "17.6.2"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "d6e8c5bdae26e2beb66f4d7f37f71a3494fe9fcb"
|
|
36
36
|
}
|
package/readme.md
CHANGED
|
@@ -26,6 +26,22 @@ Run composition.
|
|
|
26
26
|
|
|
27
27
|
> Note that your `localhost` it is accessible from a container as `host.docker.internal`.
|
|
28
28
|
|
|
29
|
+
### call
|
|
30
|
+
|
|
31
|
+
Call endpoint.
|
|
32
|
+
|
|
33
|
+
<dl>
|
|
34
|
+
<dt><code>toa call <endpont> [request]</code></dt>
|
|
35
|
+
<dd>
|
|
36
|
+
<code>endpoint</code> endpoint to call.<br/>
|
|
37
|
+
<code>request</code> Request object.<br/>
|
|
38
|
+
</dd>
|
|
39
|
+
</dl>
|
|
40
|
+
|
|
41
|
+
```shell
|
|
42
|
+
$ toa call dummies.dummy.create "{ input: { name: 'foo' } }"
|
|
43
|
+
```
|
|
44
|
+
|
|
29
45
|
### env
|
|
30
46
|
|
|
31
47
|
Export environment to a `.env` file.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { call } = require('../handlers/call')
|
|
4
|
+
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs
|
|
7
|
+
.positional('endpoint', {
|
|
8
|
+
type: 'string',
|
|
9
|
+
desc: 'Operation endpoint'
|
|
10
|
+
})
|
|
11
|
+
.positional('request', {
|
|
12
|
+
type: 'string',
|
|
13
|
+
desc: 'Request object'
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.command = 'call <endpoint> [request]'
|
|
18
|
+
exports.desc = 'Call operation'
|
|
19
|
+
exports.builder = builder
|
|
20
|
+
exports.handler = call
|
package/src/commands/invoke.js
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { Readable } = require('node:stream')
|
|
4
|
+
const boot = require('@toa.io/boot')
|
|
5
|
+
const yaml = require('@toa.io/yaml')
|
|
6
|
+
const { Locator } = require('@toa.io/core')
|
|
7
|
+
|
|
8
|
+
async function call (argv) {
|
|
9
|
+
const [operation, component, namespace = 'default'] = argv.endpoint.split('.').reverse()
|
|
10
|
+
const locator = new Locator(component, namespace)
|
|
11
|
+
const request = argv.request ? yaml.parse(argv.request) : {}
|
|
12
|
+
|
|
13
|
+
const remote = await boot.remote(locator)
|
|
14
|
+
await remote.connect()
|
|
15
|
+
|
|
16
|
+
let reply
|
|
17
|
+
let exception
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
reply = await remote.invoke(operation, request)
|
|
21
|
+
} catch (e) {
|
|
22
|
+
exception = e
|
|
23
|
+
} finally {
|
|
24
|
+
if (exception === undefined) {
|
|
25
|
+
if (reply instanceof Readable) {
|
|
26
|
+
for await (const chunk of reply) console.log(chunk)
|
|
27
|
+
} else console.log(reply)
|
|
28
|
+
} else console.error(exception)
|
|
29
|
+
|
|
30
|
+
await remote.disconnect()
|
|
31
|
+
|
|
32
|
+
if (exception !== undefined) process.exit(1)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.call = call
|
package/src/handlers/compose.js
CHANGED
package/src/handlers/serve.js
CHANGED
|
@@ -6,7 +6,7 @@ const { directory: { find } } = require('@toa.io/filesystem')
|
|
|
6
6
|
const { version } = require('@toa.io/runtime')
|
|
7
7
|
|
|
8
8
|
const serve = async (argv) => {
|
|
9
|
-
console.log('Runtime
|
|
9
|
+
console.log('Runtime', version)
|
|
10
10
|
|
|
11
11
|
argv.path = shortcuts.resolve(argv.path)
|
|
12
12
|
|