@toa.io/cli 1.0.0-alpha.0 → 1.0.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 +8 -7
- package/readme.md +7 -3
- package/src/commands/export/entity.js +26 -0
- package/src/commands/export/manifest.js +8 -1
- package/src/handlers/build.js +3 -3
- package/src/handlers/conceal.js +3 -2
- package/src/handlers/deploy.js +3 -3
- package/src/handlers/docker/build.js +1 -11
- package/src/handlers/docker/run.js +2 -2
- package/src/handlers/env.js +3 -3
- package/src/handlers/export/deployment.js +6 -6
- package/src/handlers/export/entity.js +27 -0
- package/src/handlers/export/images.js +6 -14
- package/src/handlers/export/manifest.js +8 -2
- package/src/handlers/push.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.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,16 @@
|
|
|
22
22
|
"@toa.io/runtime": "*"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@toa.io/console": "1.0.0-alpha.
|
|
26
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
27
|
-
"@toa.io/kubernetes": "1.0.0-alpha.
|
|
28
|
-
"@toa.io/norm": "1.0.0-alpha.
|
|
29
|
-
"@toa.io/
|
|
25
|
+
"@toa.io/console": "1.0.0-alpha.2",
|
|
26
|
+
"@toa.io/generic": "1.0.0-alpha.2",
|
|
27
|
+
"@toa.io/kubernetes": "1.0.0-alpha.2",
|
|
28
|
+
"@toa.io/norm": "1.0.0-alpha.2",
|
|
29
|
+
"@toa.io/operations": "1.0.0-alpha.2",
|
|
30
|
+
"@toa.io/yaml": "1.0.0-alpha.2",
|
|
30
31
|
"dotenv": "16.1.1",
|
|
31
32
|
"find-up": "5.0.0",
|
|
32
33
|
"paseto": "3.1.4",
|
|
33
34
|
"yargs": "17.6.2"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "7688e6e980a65c82ac2e459be4e355eebf406cd0"
|
|
36
37
|
}
|
package/readme.md
CHANGED
|
@@ -90,8 +90,7 @@ $ toa replay --title "should add numbers"
|
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
If the path is a Context root (containing `context.toa.yaml` file), samples for components within
|
|
93
|
-
the Context will be
|
|
94
|
-
found and replayed sequentially.
|
|
93
|
+
the Context will be found and replayed sequentially.
|
|
95
94
|
|
|
96
95
|
### export manifest
|
|
97
96
|
|
|
@@ -100,10 +99,15 @@ found and replayed sequentially.
|
|
|
100
99
|
<dd>Print normalized manifest.
|
|
101
100
|
|
|
102
101
|
<code>--path</code> path to component (default <code>.</code>)<br/>
|
|
103
|
-
<code>--error</code> print errors only
|
|
102
|
+
<code>--error</code> print errors only<br/>
|
|
103
|
+
<code>--output</code> output format (default <code>yaml</code>)
|
|
104
104
|
</dd>
|
|
105
105
|
</dl>
|
|
106
106
|
|
|
107
|
+
### export entity
|
|
108
|
+
|
|
109
|
+
Same as `exprot manifest` but outputs only the `entity`.
|
|
110
|
+
|
|
107
111
|
## Operations
|
|
108
112
|
|
|
109
113
|
> Some commands use current `kubectl` and `docker` context.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { manifest } = require('../../handlers/export/entity')
|
|
4
|
+
|
|
5
|
+
const builder = (yargs) => {
|
|
6
|
+
yargs
|
|
7
|
+
.option('path', {
|
|
8
|
+
alias: 'p',
|
|
9
|
+
group: 'Command options:',
|
|
10
|
+
type: 'string',
|
|
11
|
+
desc: 'Path to a component',
|
|
12
|
+
default: '.'
|
|
13
|
+
})
|
|
14
|
+
.option('output', {
|
|
15
|
+
alias: 'o',
|
|
16
|
+
group: 'Command options:',
|
|
17
|
+
choices: ['yaml', 'json'],
|
|
18
|
+
desc: 'Output format',
|
|
19
|
+
default: 'yaml'
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.command = 'entity'
|
|
24
|
+
exports.desc = 'Print entity'
|
|
25
|
+
exports.builder = builder
|
|
26
|
+
exports.handler = manifest
|
|
@@ -14,9 +14,16 @@ const builder = (yargs) => {
|
|
|
14
14
|
alias: 'p',
|
|
15
15
|
group: 'Command options:',
|
|
16
16
|
type: 'string',
|
|
17
|
-
desc: 'Path to component',
|
|
17
|
+
desc: 'Path to a component',
|
|
18
18
|
default: '.'
|
|
19
19
|
})
|
|
20
|
+
.option('output', {
|
|
21
|
+
alias: 'o',
|
|
22
|
+
group: 'Command options:',
|
|
23
|
+
choices: ['yaml', 'json'],
|
|
24
|
+
desc: 'Output format',
|
|
25
|
+
default: 'yaml'
|
|
26
|
+
})
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
exports.command = ['manifest', 'man']
|
package/src/handlers/build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const boot = require('@toa.io/boot')
|
|
4
|
-
|
|
5
3
|
const { context: find } = require('../util/find')
|
|
4
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
6
5
|
|
|
7
6
|
const build = async (argv) => {
|
|
8
7
|
const path = find(argv.path)
|
|
9
|
-
const
|
|
8
|
+
const factory = await Factory.create(path, argv.environment)
|
|
9
|
+
const registry = factory.registry()
|
|
10
10
|
|
|
11
11
|
await registry.build()
|
|
12
12
|
}
|
package/src/handlers/conceal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
3
4
|
const { secrets } = require('@toa.io/kubernetes')
|
|
4
|
-
const boot = require('@toa.io/boot')
|
|
5
5
|
const { context: find } = require('../util/find')
|
|
6
6
|
const { promptSecrets } = require('./env')
|
|
7
7
|
|
|
@@ -28,7 +28,8 @@ async function concealValue (argv) {
|
|
|
28
28
|
|
|
29
29
|
async function concealValues (argv) {
|
|
30
30
|
const path = find(argv.path)
|
|
31
|
-
const
|
|
31
|
+
const factory = await Factory.create(path, argv.environment)
|
|
32
|
+
const operator = factory.operator()
|
|
32
33
|
const variables = operator.variables()
|
|
33
34
|
const values = await promptSecrets(variables)
|
|
34
35
|
const groups = groupValues(values)
|
package/src/handlers/deploy.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
5
4
|
const { context: find } = require('../util/find')
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -10,7 +9,8 @@ const { context: find } = require('../util/find')
|
|
|
10
9
|
*/
|
|
11
10
|
const deploy = async (argv) => {
|
|
12
11
|
const path = find(argv.path)
|
|
13
|
-
const
|
|
12
|
+
const factory = await Factory.create(path, argv.environment)
|
|
13
|
+
const operator = factory.operator()
|
|
14
14
|
|
|
15
15
|
if (argv.dry === true) {
|
|
16
16
|
const options = {}
|
|
@@ -6,11 +6,6 @@ const { deployment: { Factory } } = require('@toa.io/operations')
|
|
|
6
6
|
|
|
7
7
|
const find = require('../../util/find')
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @param {string} contextPath
|
|
11
|
-
* @param {string[]} componentPatterns
|
|
12
|
-
* @return {Promise<string>}
|
|
13
|
-
*/
|
|
14
9
|
async function build (contextPath, componentPatterns) {
|
|
15
10
|
const context = await createContext(contextPath, componentPatterns)
|
|
16
11
|
const factory = new Factory(context)
|
|
@@ -23,14 +18,9 @@ async function build (contextPath, componentPatterns) {
|
|
|
23
18
|
return `${context.registry.base === undefined ? '' : context.registry.base + '/'}${context.name}/composition-${composition}`
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} contextPath
|
|
28
|
-
* @param {string[]} componentPatterns
|
|
29
|
-
* @return {Promise<toa.norm.Context>}
|
|
30
|
-
*/
|
|
31
21
|
async function createContext (contextPath, componentPatterns) {
|
|
32
22
|
const contextRoot = find.context(contextPath)
|
|
33
|
-
const context = await norm.context(contextRoot)
|
|
23
|
+
const context = await norm.context(contextRoot, 'docker')
|
|
34
24
|
const paths = componentPatterns.map((pattern) => find.components(pattern))
|
|
35
25
|
const components = await loadComponents(paths)
|
|
36
26
|
const rnd = newid().substring(0, 6)
|
|
@@ -27,11 +27,11 @@ async function run (repository, command, envFile) {
|
|
|
27
27
|
const args = ['run', '--rm', ...envArgs, id, 'sh', '-c', command]
|
|
28
28
|
const done = promex()
|
|
29
29
|
|
|
30
|
-
const running =
|
|
30
|
+
const running = spawn('docker', args, { stdio: 'inherit' })
|
|
31
31
|
|
|
32
32
|
running.on('exit', done.resolve)
|
|
33
33
|
|
|
34
|
-
await done
|
|
34
|
+
const code = await done
|
|
35
35
|
|
|
36
36
|
await execute(`docker rmi --force ${id}`)
|
|
37
37
|
}
|
package/src/handlers/env.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
const { join } = require('node:path')
|
|
4
4
|
const readline = require('node:readline/promises')
|
|
5
5
|
const { stdin: input, stdout: output } = require('node:process')
|
|
6
|
-
|
|
7
6
|
const dotenv = require('dotenv')
|
|
7
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
8
8
|
const { file } = require('@toa.io/filesystem')
|
|
9
|
-
const boot = require('@toa.io/boot')
|
|
10
9
|
const { context: find } = require('../util/find')
|
|
11
10
|
|
|
12
11
|
async function env (argv) {
|
|
13
12
|
const path = find(argv.path)
|
|
14
13
|
const filepath = join(path, argv.as)
|
|
15
|
-
const
|
|
14
|
+
const factory = await Factory.create(path, argv.environment)
|
|
15
|
+
const operator = factory.operator()
|
|
16
16
|
const variables = operator.variables()
|
|
17
17
|
const currentValues = await read(filepath)
|
|
18
18
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const boot = require('@toa.io/boot')
|
|
4
3
|
const { console } = require('@toa.io/console')
|
|
5
|
-
|
|
6
4
|
const { context: find } = require('../../util/find')
|
|
5
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* @param {{ path: string, target: string, environment?: string }} argv
|
|
10
9
|
* @returns {Promise<void>}
|
|
11
10
|
*/
|
|
12
11
|
const dump = async (argv) => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
12
|
+
const path = find(argv.path)
|
|
13
|
+
const factory = await Factory.create(path, argv.environment)
|
|
14
|
+
const operator = factory.operator()
|
|
15
|
+
const target = await operator.export(argv.target)
|
|
16
16
|
|
|
17
|
-
console.log(
|
|
17
|
+
console.log(target)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.dump = dump
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { component } = require('@toa.io/norm')
|
|
4
|
+
const { console } = require('@toa.io/console')
|
|
5
|
+
const yaml = require('@toa.io/yaml')
|
|
6
|
+
|
|
7
|
+
const { components: find } = require('../../util/find')
|
|
8
|
+
|
|
9
|
+
const print = async (argv) => {
|
|
10
|
+
const path = find(argv.path)
|
|
11
|
+
|
|
12
|
+
if (path === undefined) throw new Error(`No component found in ${argv.path}`)
|
|
13
|
+
|
|
14
|
+
const manifest = await component(path)
|
|
15
|
+
const entity = manifest.entity
|
|
16
|
+
|
|
17
|
+
if (entity === undefined)
|
|
18
|
+
return
|
|
19
|
+
|
|
20
|
+
const result = argv.output === 'json'
|
|
21
|
+
? JSON.stringify(entity, null, 2)
|
|
22
|
+
: yaml.dump(entity)
|
|
23
|
+
|
|
24
|
+
console.log(result)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.manifest = print
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const boot = require('@toa.io/boot')
|
|
4
3
|
const { console } = require('@toa.io/console')
|
|
5
|
-
|
|
6
4
|
const { context: find } = require('../../util/find')
|
|
5
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
7
6
|
|
|
8
7
|
const prepare = async (argv) => {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const path = find(argv.path)
|
|
9
|
+
const factory = await Factory.create(path, argv.environment)
|
|
10
|
+
const operator = factory.operator()
|
|
11
|
+
const target = await operator.prepare(argv.target)
|
|
12
12
|
|
|
13
|
-
console.log(
|
|
13
|
+
console.log(target)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// const prepare = async (argv) => {
|
|
17
|
-
// const context = find(argv.path)
|
|
18
|
-
// const registry = await boot.registry(context)
|
|
19
|
-
// const path = await registry.prepare(argv.target)
|
|
20
|
-
//
|
|
21
|
-
// console.log(path)
|
|
22
|
-
// }
|
|
23
|
-
|
|
24
16
|
exports.prepare = prepare
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { component } = require('@toa.io/norm')
|
|
4
|
-
const { dump } = require('@toa.io/yaml')
|
|
5
4
|
const { console } = require('@toa.io/console')
|
|
5
|
+
const yaml = require('@toa.io/yaml')
|
|
6
6
|
|
|
7
7
|
const { components: find } = require('../../util/find')
|
|
8
8
|
|
|
@@ -13,7 +13,13 @@ const print = async (argv) => {
|
|
|
13
13
|
|
|
14
14
|
const manifest = await component(path)
|
|
15
15
|
|
|
16
|
-
if (argv.error !== true)
|
|
16
|
+
if (argv.error !== true) {
|
|
17
|
+
const result = argv.output === 'json'
|
|
18
|
+
? JSON.stringify(manifest, null, 2)
|
|
19
|
+
: yaml.dump(manifest)
|
|
20
|
+
|
|
21
|
+
console.log(result)
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
exports.manifest = print
|
package/src/handlers/push.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const { deployment: { Factory } } = require('@toa.io/operations')
|
|
5
4
|
const { context: find } = require('../util/find')
|
|
6
5
|
|
|
7
6
|
const push = async (argv) => {
|
|
8
7
|
const path = find(argv.path)
|
|
9
|
-
const
|
|
8
|
+
const factory = await Factory.create(path)
|
|
9
|
+
const registry = factory.registry()
|
|
10
10
|
|
|
11
11
|
await registry.push()
|
|
12
12
|
}
|