@toa.io/cli 0.1.1-dev.3 → 0.2.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/cli",
3
- "version": "0.1.1-dev.3",
3
+ "version": "0.2.0-dev.3+8334154",
4
4
  "description": "Toa CLI",
5
5
  "author": "temich <tema.gurtovoy@gmail.com>",
6
6
  "homepage": "https://github.com/toa-io/toa#readme",
@@ -11,10 +11,7 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/toa-io/toa/issues"
13
13
  },
14
- "main": "package.json",
15
- "bin": {
16
- "toa": "bin/toa"
17
- },
14
+ "main": "src/program.js",
18
15
  "publishConfig": {
19
16
  "access": "public"
20
17
  },
@@ -25,5 +22,5 @@
25
22
  "find-up": "5.0.0",
26
23
  "yargs": "17.2.1"
27
24
  },
28
- "gitHead": "8f1e4d0fd8defeb7cb59ae0e8cc291c6e7623abc"
25
+ "gitHead": "8334154c1b8a8268ad90adfb15b43a876459014f"
29
26
  }
@@ -9,10 +9,14 @@ const builder = (yargs) => {
9
9
  desc: 'Path to context',
10
10
  default: '.'
11
11
  })
12
- .usage('Usage: toa deploy export /path/to/context')
12
+ .positional('target', {
13
+ type: 'string',
14
+ desc: 'Export target path'
15
+ })
16
+ .usage('Usage: toa deploy export /path/to/context /export/path')
13
17
  }
14
18
 
15
- exports.command = 'export [path]'
16
- exports.desc = 'Export context deployment'
19
+ exports.command = 'export [path] [target]'
20
+ exports.desc = 'Export context deployment chart'
17
21
  exports.builder = builder
18
22
  exports.handler = dump
@@ -9,6 +9,14 @@ const builder = (yargs) => {
9
9
  desc: 'Path to context',
10
10
  default: '.'
11
11
  })
12
+ .option('dry', {
13
+ boolean: true,
14
+ desc: 'Dry run'
15
+ })
16
+ .option('no-wait', {
17
+ boolean: true,
18
+ desc: 'Disable waiting for deployment ready state'
19
+ })
12
20
  .usage('Usage: toa deploy /path/to/context')
13
21
  .commandDir('./deploy')
14
22
  }
@@ -5,7 +5,10 @@ const boot = require('@toa.io/boot')
5
5
  const { manifest: find } = require('../util/find')
6
6
 
7
7
  async function compose (argv) {
8
- const paths = [...new Set(argv.paths.map(find))]
8
+ const paths = find(argv.paths)
9
+
10
+ if (paths === undefined) throw new Error(`No components found in ${argv.paths}`)
11
+
9
12
  const composition = await boot.composition(paths, argv)
10
13
 
11
14
  await composition.connect()
@@ -8,7 +8,7 @@ const { context: find } = require('../../util/find')
8
8
  const dump = async (argv) => {
9
9
  const context = find(argv.path)
10
10
  const deployment = await boot.deployment(context)
11
- const path = await deployment.export()
11
+ const path = await deployment.export(argv.target)
12
12
 
13
13
  console.log(path)
14
14
  }
@@ -5,10 +5,15 @@ const boot = require('@toa.io/boot')
5
5
  const { context: find } = require('../util/find')
6
6
 
7
7
  const deploy = async (argv) => {
8
- const context = find(argv.path)
9
- const deployment = await boot.deployment(context)
8
+ const path = find(argv.path)
9
+ const deployment = await boot.deployment(path)
10
10
 
11
- await deployment.install()
11
+ const options = {
12
+ wait: argv['no-wait'] !== true,
13
+ dry: argv.dry === true
14
+ }
15
+
16
+ await deployment.install(options)
12
17
  }
13
18
 
14
19
  exports.deploy = deploy
package/src/program.js CHANGED
@@ -6,19 +6,18 @@ const { console } = require('@toa.io/gears')
6
6
  const { version } = require('../package.json')
7
7
 
8
8
  yargs(process.argv.slice(2))
9
+ .parserConfiguration({
10
+ 'boolean-negation': false
11
+ })
9
12
  .middleware((argv) => {
10
- if (argv.log === undefined) {
11
- if (process.env.TOA_ENV === 'dev') argv.log = 'info'
12
- else argv.log = 'warn'
13
- }
13
+ if (argv.log === undefined) argv.log = 'info'
14
14
 
15
15
  console.level(argv.log)
16
16
  })
17
17
  .fail((msg, err) => {
18
18
  const actual = err || new Error(msg)
19
19
 
20
- if (process.env.TOA_ENV === 'dev') console.log(actual)
21
- else console.error(actual.message)
20
+ console.error(process.env.TOA_ENV === 'local' ? actual : actual.message)
22
21
 
23
22
  process.exit(actual.exitCode > 0 ? actual.exitCode : 1)
24
23
  })
package/src/util/find.js CHANGED
@@ -4,11 +4,17 @@ const { dirname, resolve } = require('node:path')
4
4
  const findUp = require('find-up')
5
5
 
6
6
  const find = (from = '.', filename) => {
7
- const path = findUp.sync(filename, { cwd: resolve(process.cwd(), from) })
7
+ if (from instanceof Array) {
8
+ const found = new Set(from.map((path) => find(path, filename)))
9
+
10
+ found.delete(undefined)
8
11
 
9
- if (path === undefined) throw new Error(`File ${filename} not found in ${from}`)
12
+ return found.size > 0 ? [...found] : undefined
13
+ }
14
+
15
+ const path = findUp.sync(filename, { cwd: resolve(process.cwd(), from) })
10
16
 
11
- return dirname(path)
17
+ return path === undefined ? undefined : dirname(path)
12
18
  }
13
19
 
14
20
  const manifest = (from = '.') => find(from, MANIFEST)
package/bin/toa DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict'
3
-
4
- require('../src/program')