@asyncapi/cli 2.16.0 → 2.16.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/README.md CHANGED
@@ -12,6 +12,7 @@ CLI to work with your AsyncAPI files. Currently under development, we are workin
12
12
 
13
13
  - [Installation](#installation)
14
14
  - [Usage](#usage)
15
+ - [Github Action](#github-action)
15
16
  - [Contributing](#contributing)
16
17
  * [Set up development environment](#set-up-development-environment)
17
18
  * [Command Structure and Patterns](#command-structure-and-patterns)
@@ -25,6 +26,9 @@ Learn how to install the AsyncAPI CLI by following the instructions in the [inst
25
26
  ## Usage
26
27
  The [usage guide](/docs/usage.md) provides information about different ways to use the CLI.
27
28
 
29
+ ## Github Action
30
+
31
+ The AsyncAPI CLI can be used as a GitHub Action. You can find more information in the [GitHub Action guide](https://www.asyncapi.com/docs/tools/cli/github-action).
28
32
 
29
33
  ## Contributing
30
34
 
@@ -1825,9 +1825,10 @@
1825
1825
  }
1826
1826
  },
1827
1827
  "node_modules/@jsep-plugin/regex": {
1828
- "version": "1.0.3",
1829
- "resolved": "https://registry.npmjs.org/@jsep-plugin/regex/-/regex-1.0.3.tgz",
1830
- "integrity": "sha512-XfZgry4DwEZvSFtS/6Y+R48D7qJYJK6R9/yJFyUFHCIUMEEHuJ4X95TDgJp5QkmzfLYvapMPzskV5HpIDrREug==",
1828
+ "version": "1.0.4",
1829
+ "resolved": "https://registry.npmjs.org/@jsep-plugin/regex/-/regex-1.0.4.tgz",
1830
+ "integrity": "sha512-q7qL4Mgjs1vByCaTnDFcBnV9HS7GVPJX5vyVoCgZHNSC9rjwIlmbXG5sUuorR5ndfHAIlJ8pVStxvjXHbNvtUg==",
1831
+ "license": "MIT",
1831
1832
  "engines": {
1832
1833
  "node": ">= 10.16.0"
1833
1834
  },
@@ -1836,9 +1837,10 @@
1836
1837
  }
1837
1838
  },
1838
1839
  "node_modules/@jsep-plugin/ternary": {
1839
- "version": "1.1.3",
1840
- "resolved": "https://registry.npmjs.org/@jsep-plugin/ternary/-/ternary-1.1.3.tgz",
1841
- "integrity": "sha512-qtLGzCNzPVJ3kdH6/zoLWDPjauHIKiLSBAR71Wa0+PWvGA8wODUQvRgxtpUA5YqAYL3CQ8S4qXhd/9WuWTZirg==",
1840
+ "version": "1.1.4",
1841
+ "resolved": "https://registry.npmjs.org/@jsep-plugin/ternary/-/ternary-1.1.4.tgz",
1842
+ "integrity": "sha512-ck5wiqIbqdMX6WRQztBL7ASDty9YLgJ3sSAK5ZpBzXeySvFGCzIvM6UiAI4hTZ22fEcYQVV/zhUbNscggW+Ukg==",
1843
+ "license": "MIT",
1842
1844
  "engines": {
1843
1845
  "node": ">= 10.16.0"
1844
1846
  },
@@ -1977,34 +1979,35 @@
1977
1979
  }
1978
1980
  },
1979
1981
  "node_modules/@stoplight/spectral-core": {
1980
- "version": "1.18.3",
1981
- "resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.18.3.tgz",
1982
- "integrity": "sha512-YY8x7X2SWJIhGTLPol+eFiQpWPz0D0mJdkK2i4A0QJG68KkNhypP6+JBC7/Kz3XWjqr0L/RqAd+N5cQLPOKZGQ==",
1982
+ "version": "1.19.4",
1983
+ "resolved": "https://registry.npmjs.org/@stoplight/spectral-core/-/spectral-core-1.19.4.tgz",
1984
+ "integrity": "sha512-8hnZXfssTlV99SKo8J8BwMt5LsiBFHkCh0V3P7j8IPcCNl//bpG92U4TpYy7AwmUms/zCLX7sxNQC6AZ+bkfzg==",
1985
+ "license": "Apache-2.0",
1983
1986
  "dependencies": {
1984
1987
  "@stoplight/better-ajv-errors": "1.0.3",
1985
1988
  "@stoplight/json": "~3.21.0",
1986
1989
  "@stoplight/path": "1.3.2",
1987
1990
  "@stoplight/spectral-parsers": "^1.0.0",
1988
- "@stoplight/spectral-ref-resolver": "^1.0.0",
1989
- "@stoplight/spectral-runtime": "^1.0.0",
1991
+ "@stoplight/spectral-ref-resolver": "^1.0.4",
1992
+ "@stoplight/spectral-runtime": "^1.1.2",
1990
1993
  "@stoplight/types": "~13.6.0",
1991
1994
  "@types/es-aggregate-error": "^1.0.2",
1992
1995
  "@types/json-schema": "^7.0.11",
1993
- "ajv": "^8.6.0",
1996
+ "ajv": "^8.17.1",
1994
1997
  "ajv-errors": "~3.0.0",
1995
1998
  "ajv-formats": "~2.1.0",
1996
1999
  "es-aggregate-error": "^1.0.7",
1997
- "jsonpath-plus": "7.1.0",
2000
+ "jsonpath-plus": "10.2.0",
1998
2001
  "lodash": "~4.17.21",
1999
2002
  "lodash.topath": "^4.5.2",
2000
2003
  "minimatch": "3.1.2",
2001
- "nimma": "0.2.2",
2002
- "pony-cause": "^1.0.0",
2003
- "simple-eval": "1.0.0",
2004
- "tslib": "^2.3.0"
2004
+ "nimma": "0.2.3",
2005
+ "pony-cause": "^1.1.1",
2006
+ "simple-eval": "1.0.1",
2007
+ "tslib": "^2.8.1"
2005
2008
  },
2006
2009
  "engines": {
2007
- "node": "^12.20 || >= 14.13"
2010
+ "node": "^16.20 || ^18.18 || >= 20.17"
2008
2011
  }
2009
2012
  },
2010
2013
  "node_modules/@stoplight/spectral-core/node_modules/@stoplight/types": {
@@ -2019,18 +2022,11 @@
2019
2022
  "node": "^12.20 || >=14.13"
2020
2023
  }
2021
2024
  },
2022
- "node_modules/@stoplight/spectral-core/node_modules/jsonpath-plus": {
2023
- "version": "7.1.0",
2024
- "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-7.1.0.tgz",
2025
- "integrity": "sha512-gTaNRsPWO/K2KY6MrqaUFClF9kmuM6MFH5Dhg1VYDODgFbByw1yb7xu3hrViE/sz+dGOeMWgCzwUwQtAnCTE9g==",
2026
- "engines": {
2027
- "node": ">=12.0.0"
2028
- }
2029
- },
2030
2025
  "node_modules/@stoplight/spectral-core/node_modules/tslib": {
2031
- "version": "2.6.3",
2032
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
2033
- "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ=="
2026
+ "version": "2.8.1",
2027
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
2028
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
2029
+ "license": "0BSD"
2034
2030
  },
2035
2031
  "node_modules/@stoplight/spectral-formats": {
2036
2032
  "version": "1.6.0",
@@ -2357,9 +2353,10 @@
2357
2353
  }
2358
2354
  },
2359
2355
  "node_modules/astring": {
2360
- "version": "1.8.6",
2361
- "resolved": "https://registry.npmjs.org/astring/-/astring-1.8.6.tgz",
2362
- "integrity": "sha512-ISvCdHdlTDlH5IpxQJIex7BWBywFWgjJSVdwst+/iQCoEYnyOaQ95+X1JGshuBjGp6nxKUy1jMgE3zPqN7fQdg==",
2356
+ "version": "1.9.0",
2357
+ "resolved": "https://registry.npmjs.org/astring/-/astring-1.9.0.tgz",
2358
+ "integrity": "sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==",
2359
+ "license": "MIT",
2363
2360
  "bin": {
2364
2361
  "astring": "bin/astring"
2365
2362
  }
@@ -3315,9 +3312,10 @@
3315
3312
  }
3316
3313
  },
3317
3314
  "node_modules/jsep": {
3318
- "version": "1.3.9",
3319
- "resolved": "https://registry.npmjs.org/jsep/-/jsep-1.3.9.tgz",
3320
- "integrity": "sha512-i1rBX5N7VPl0eYb6+mHNp52sEuaS2Wi8CDYx1X5sn9naevL78+265XJqy1qENEk7mRKwS06NHpUqiBwR7qeodw==",
3315
+ "version": "1.4.0",
3316
+ "resolved": "https://registry.npmjs.org/jsep/-/jsep-1.4.0.tgz",
3317
+ "integrity": "sha512-B7qPcEVE3NVkmSJbaYxvv4cHkVW7DQsZz13pUMrfS8z8Q/BuShN+gcTXrUlPiGqM2/t/EEaI030bpxMqY8gMlw==",
3318
+ "license": "MIT",
3321
3319
  "engines": {
3322
3320
  "node": ">= 10.16.0"
3323
3321
  }
@@ -3355,13 +3353,14 @@
3355
3353
  "integrity": "sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w=="
3356
3354
  },
3357
3355
  "node_modules/jsonpath-plus": {
3358
- "version": "10.1.0",
3359
- "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-10.1.0.tgz",
3360
- "integrity": "sha512-gHfV1IYqH8uJHYVTs8BJX1XKy2/rR93+f8QQi0xhx95aCiXn1ettYAd5T+7FU6wfqyDoX/wy0pm/fL3jOKJ9Lg==",
3356
+ "version": "10.2.0",
3357
+ "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-10.2.0.tgz",
3358
+ "integrity": "sha512-T9V+8iNYKFL2n2rF+w02LBOT2JjDnTjioaNFrxRy0Bv1y/hNsqR/EBK7Ojy2ythRHwmz2cRIls+9JitQGZC/sw==",
3359
+ "license": "MIT",
3361
3360
  "dependencies": {
3362
- "@jsep-plugin/assignment": "^1.2.1",
3363
- "@jsep-plugin/regex": "^1.0.3",
3364
- "jsep": "^1.3.9"
3361
+ "@jsep-plugin/assignment": "^1.3.0",
3362
+ "@jsep-plugin/regex": "^1.0.4",
3363
+ "jsep": "^1.4.0"
3365
3364
  },
3366
3365
  "bin": {
3367
3366
  "jsonpath": "bin/jsonpath-cli.js",
@@ -3400,7 +3399,8 @@
3400
3399
  "node_modules/lodash.topath": {
3401
3400
  "version": "4.5.2",
3402
3401
  "resolved": "https://registry.npmjs.org/lodash.topath/-/lodash.topath-4.5.2.tgz",
3403
- "integrity": "sha512-1/W4dM+35DwvE/iEd1M9ekewOSTlpFekhw9mhAtrwjVqUr83/ilQiyAvmg4tVX7Unkcfl1KC+i9WdaT4B6aQcg=="
3402
+ "integrity": "sha512-1/W4dM+35DwvE/iEd1M9ekewOSTlpFekhw9mhAtrwjVqUr83/ilQiyAvmg4tVX7Unkcfl1KC+i9WdaT4B6aQcg==",
3403
+ "license": "MIT"
3404
3404
  },
3405
3405
  "node_modules/loose-envify": {
3406
3406
  "version": "1.4.0",
@@ -3438,9 +3438,10 @@
3438
3438
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
3439
3439
  },
3440
3440
  "node_modules/nimma": {
3441
- "version": "0.2.2",
3442
- "resolved": "https://registry.npmjs.org/nimma/-/nimma-0.2.2.tgz",
3443
- "integrity": "sha512-V52MLl7BU+tH2Np9tDrIXK8bql3MVUadnMIl/0/oZSGC9keuro0O9UUv9QKp0aMvtN8HRew4G7byY7H4eWsxaQ==",
3441
+ "version": "0.2.3",
3442
+ "resolved": "https://registry.npmjs.org/nimma/-/nimma-0.2.3.tgz",
3443
+ "integrity": "sha512-1ZOI8J+1PKKGceo/5CT5GfQOG6H8I2BencSK06YarZ2wXwH37BSSUWldqJmMJYA5JfqDqffxDXynt6f11AyKcA==",
3444
+ "license": "Apache-2.0",
3444
3445
  "dependencies": {
3445
3446
  "@jsep-plugin/regex": "^1.0.1",
3446
3447
  "@jsep-plugin/ternary": "^1.0.2",
@@ -3451,19 +3452,10 @@
3451
3452
  "node": "^12.20 || >=14.13"
3452
3453
  },
3453
3454
  "optionalDependencies": {
3454
- "jsonpath-plus": "^6.0.1",
3455
+ "jsonpath-plus": "^6.0.1 || ^10.1.0",
3455
3456
  "lodash.topath": "^4.5.2"
3456
3457
  }
3457
3458
  },
3458
- "node_modules/nimma/node_modules/jsonpath-plus": {
3459
- "version": "6.0.1",
3460
- "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-6.0.1.tgz",
3461
- "integrity": "sha512-EvGovdvau6FyLexFH2OeXfIITlgIbgZoAZe3usiySeaIDm5QS+A10DKNpaPBBqqRSZr2HN6HVNXxtwUAr2apEw==",
3462
- "optional": true,
3463
- "engines": {
3464
- "node": ">=10.0.0"
3465
- }
3466
- },
3467
3459
  "node_modules/node-fetch": {
3468
3460
  "version": "2.6.7",
3469
3461
  "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
@@ -3809,11 +3801,12 @@
3809
3801
  }
3810
3802
  },
3811
3803
  "node_modules/simple-eval": {
3812
- "version": "1.0.0",
3813
- "resolved": "https://registry.npmjs.org/simple-eval/-/simple-eval-1.0.0.tgz",
3814
- "integrity": "sha512-kpKJR+bqTscgC0xuAl2xHN6bB12lHjC2DCUfqjAx19bQyO3R2EVLOurm3H9AUltv/uFVcSCVNc6faegR+8NYLw==",
3804
+ "version": "1.0.1",
3805
+ "resolved": "https://registry.npmjs.org/simple-eval/-/simple-eval-1.0.1.tgz",
3806
+ "integrity": "sha512-LH7FpTAkeD+y5xQC4fzS+tFtaNlvt3Ib1zKzvhjv/Y+cioV4zIuw4IZr2yhRLu67CWL7FR9/6KXKnjRoZTvGGQ==",
3807
+ "license": "MIT",
3815
3808
  "dependencies": {
3816
- "jsep": "^1.1.2"
3809
+ "jsep": "^1.3.6"
3817
3810
  },
3818
3811
  "engines": {
3819
3812
  "node": ">=12"
@@ -6,6 +6,7 @@ const base_1 = tslib_1.__importDefault(require("../../core/base"));
6
6
  const fs_1 = require("fs");
7
7
  const os_1 = require("os");
8
8
  const analytics_flags_1 = require("../../core/flags/config/analytics.flags");
9
+ const picocolors_1 = require("picocolors");
9
10
  const { readFile, writeFile } = fs_1.promises;
10
11
  class Analytics extends base_1.default {
11
12
  run() {
@@ -25,7 +26,7 @@ class Analytics extends base_1.default {
25
26
  this.metricsMetadata.analytics_enabled = flags.enable;
26
27
  }
27
28
  else if (!flags.status) {
28
- this.log('\nPlease append the "--disable" flag to the command in case you prefer to disable analytics, or use the "--enable" flag if you want to enable analytics back again. In case you do not know the analytics current status, then you can append the "--status" flag to be aware of it.\n');
29
+ this.log(`\nPlease append the ${(0, picocolors_1.blueBright)('--disable')} flag to the command if you prefer to disable analytics, or use the ${(0, picocolors_1.blueBright)('--enable')} flag if you want to enable analytics again. To check the current analytics status, use the ${(0, picocolors_1.blueBright)('--status')} flag.\n`);
29
30
  return;
30
31
  }
31
32
  yield writeFile(analyticsConfigFile, JSON.stringify(analyticsConfigFileContent), { encoding: 'utf8' });
@@ -34,7 +35,7 @@ class Analytics extends base_1.default {
34
35
  this.log('\nAnalytics are enabled.\n');
35
36
  }
36
37
  else {
37
- this.log('\nAnalytics are disabled. Please append the "--enable" flag to the command in case you prefer to enable analytics.\n');
38
+ this.log(`\n${(0, picocolors_1.redBright)('Analytics are disabled.')} To enable analytics, use the ${(0, picocolors_1.blueBright)('--enable')} flag.\n`);
38
39
  }
39
40
  this.metricsMetadata.analytics_status_checked = flags.status;
40
41
  }
@@ -42,13 +43,13 @@ class Analytics extends base_1.default {
42
43
  catch (e) {
43
44
  switch (e.code) {
44
45
  case 'ENOENT':
45
- this.error(`Unable to access the analytics configuration file. We tried to access the ".asyncapi-analytics" file in in the path "${analyticsConfigFile}" but the file could not be found.`);
46
+ this.error(`Unable to access the analytics configuration file. We tried to access the ${(0, picocolors_1.blueBright)('.asyncapi-analytics')} file in the path "${(0, picocolors_1.blueBright)(analyticsConfigFile)}" but the file could not be found.`);
46
47
  break;
47
48
  case 'EEXIST':
48
- this.error(`Unable to update the analytics configuration file. We tried to update your ".asyncapi-analytics" file in the path "${analyticsConfigFile}" but the file does not exist.`);
49
+ this.error(`Unable to update the analytics configuration file. We tried to update your ".asyncapi-analytics" file in the path "${(0, picocolors_1.blueBright)(analyticsConfigFile)}" but the file does not exist.`);
49
50
  break;
50
51
  default:
51
- this.error(`Unable to change your analytics configuration. Please check the following message for further info about the error:\n\n${e}`);
52
+ this.error(`Unable to change your analytics configuration. Please check the following message for further info about the error:\n\n${(0, picocolors_1.redBright)(e)}`);
52
53
  }
53
54
  }
54
55
  });
@@ -6,6 +6,7 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
6
6
  const Context_1 = require("../../../core/models/Context");
7
7
  const context_error_1 = require("../../../core/errors/context-error");
8
8
  const context_flags_1 = require("../../../core/flags/config/context.flags");
9
+ const picocolors_1 = require("picocolors");
9
10
  class ContextAdd extends base_1.default {
10
11
  run() {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -15,16 +16,15 @@ class ContextAdd extends base_1.default {
15
16
  const setAsCurrent = flags['set-current'];
16
17
  try {
17
18
  yield (0, Context_1.addContext)(contextName, specFilePath);
18
- this.log(`Added context "${contextName}".\n\nYou can set it as your current context: asyncapi config context use ${contextName}\nYou can use this context when needed by passing ${contextName} as a parameter: asyncapi validate ${contextName}`);
19
+ this.log(`🎉 Context ${(0, picocolors_1.blueBright)(contextName)} added successfully!\nYou can set it as your current context:\n ${(0, picocolors_1.blueBright)('asyncapi')} ${(0, picocolors_1.blueBright)('config')} ${(0, picocolors_1.blueBright)('context')} ${(0, picocolors_1.blueBright)('use')} ${(0, picocolors_1.blueBright)(contextName)}\nYou can use this context when needed by passing ${(0, picocolors_1.blueBright)(contextName)} as a parameter:\n ${(0, picocolors_1.blueBright)('asyncapi')} ${(0, picocolors_1.blueBright)('validate')} ${(0, picocolors_1.blueBright)(contextName)}`);
19
20
  if (setAsCurrent) {
20
21
  yield (0, Context_1.setCurrentContext)(contextName);
21
- this.log(`The newly added context "${contextName}", is set as your current context!`);
22
+ this.log(`\nThe newly added context, ${(0, picocolors_1.blueBright)(contextName)}, is set as your current context!`);
22
23
  }
23
24
  }
24
25
  catch (e) {
25
26
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
26
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
27
- return;
27
+ this.error(`Unable to add context. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.`);
28
28
  }
29
29
  throw e;
30
30
  }
@@ -5,6 +5,7 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
5
5
  const Context_1 = require("../../../core/models/Context");
6
6
  const context_error_1 = require("../../../core/errors/context-error");
7
7
  const global_flags_1 = require("../../../core/flags/global.flags");
8
+ const picocolors_1 = require("picocolors");
8
9
  class ContextCurrent extends base_1.default {
9
10
  run() {
10
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -14,22 +15,19 @@ class ContextCurrent extends base_1.default {
14
15
  }
15
16
  catch (e) {
16
17
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
17
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
18
- return;
18
+ this.error(`Unable to show current context. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.`);
19
19
  }
20
20
  else if (e instanceof context_error_1.ContextFileEmptyError) {
21
- this.log(`Context file "${Context_1.CONTEXT_FILE_PATH}" is empty.`);
22
- return;
21
+ this.error(`Context file ${(0, picocolors_1.blueBright)(Context_1.CONTEXT_FILE_PATH)} is empty.`);
23
22
  }
24
23
  else if (e instanceof context_error_1.ContextNotFoundError ||
25
24
  (fileContent && !fileContent.current)) {
26
- this.log('No context is set as current. Run "asyncapi config context" to see all available options.');
27
- return;
25
+ this.error(`No context is set as current.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context')} to see all available options.`);
28
26
  }
29
27
  throw e;
30
28
  }
31
29
  if (fileContent) {
32
- this.log(`${fileContent.current}: ${fileContent.context}`);
30
+ this.log(`${(0, picocolors_1.blueBright)(fileContent.current)}: ${fileContent.context}`);
33
31
  }
34
32
  });
35
33
  }
@@ -6,6 +6,7 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
6
6
  const Context_1 = require("../../../core/models/Context");
7
7
  const context_error_1 = require("../../../core/errors/context-error");
8
8
  const global_flags_1 = require("../../../core/flags/global.flags");
9
+ const picocolors_1 = require("picocolors");
9
10
  class ContextEdit extends base_1.default {
10
11
  run() {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -14,16 +15,14 @@ class ContextEdit extends base_1.default {
14
15
  const newSpecFilePath = args['new-spec-file-path'];
15
16
  try {
16
17
  yield (0, Context_1.editContext)(contextName, newSpecFilePath);
17
- this.log(`Edited context "${contextName}".\n\nYou can set it as your current context: asyncapi config context use ${contextName}\nYou can use this context when needed by passing ${contextName} as a parameter: asyncapi validate ${contextName}`);
18
+ this.log(`🎉 Context ${(0, picocolors_1.blueBright)(contextName)} edited successfully!\nYou can set it as your current context:\n ${(0, picocolors_1.blueBright)('asyncapi')} ${(0, picocolors_1.blueBright)('config')} ${(0, picocolors_1.blueBright)('context')} ${(0, picocolors_1.blueBright)('use')} ${(0, picocolors_1.blueBright)(contextName)}\nYou can use this context when needed by passing ${(0, picocolors_1.blueBright)(contextName)} as a parameter:\n ${(0, picocolors_1.blueBright)('asyncapi')} ${(0, picocolors_1.blueBright)('validate')} ${(0, picocolors_1.blueBright)(contextName)}`);
18
19
  }
19
20
  catch (e) {
20
21
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
21
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
22
- return;
22
+ this.error(`Unable to edit context. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.`);
23
23
  }
24
24
  else if (e instanceof context_error_1.ContextFileEmptyError) {
25
- this.log(`Context file "${Context_1.CONTEXT_FILE_PATH}" is empty.`);
26
- return;
25
+ this.error(`Context file ${(0, picocolors_1.blueBright)(Context_1.CONTEXT_FILE_PATH)} is empty.`);
27
26
  }
28
27
  throw e;
29
28
  }
@@ -5,13 +5,14 @@ const core_1 = require("@oclif/core");
5
5
  const base_1 = tslib_1.__importDefault(require("../../../core/base"));
6
6
  const Context_1 = require("../../../core/models/Context");
7
7
  const global_flags_1 = require("../../../core/flags/global.flags");
8
+ const picocolors_1 = require("picocolors");
8
9
  class ContextInit extends base_1.default {
9
10
  run() {
10
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
12
  const { args } = yield this.parse(ContextInit);
12
13
  const contextFilePath = args['context-file-path'];
13
14
  const contextWritePath = yield (0, Context_1.initContext)(contextFilePath);
14
- this.log(`Initialized context ${contextWritePath}`);
15
+ this.log(`🎉 Context initialized at ${(0, picocolors_1.blueBright)(contextWritePath)}`);
15
16
  });
16
17
  }
17
18
  }
@@ -19,9 +20,9 @@ exports.default = ContextInit;
19
20
  ContextInit.description = 'Initialize context';
20
21
  ContextInit.flags = (0, global_flags_1.helpFlag)();
21
22
  ContextInit.contextFilePathMessage = `Specify directory in which context file should be created:
22
- - current directory : asyncapi config context init . (default)
23
- - root of current repository : asyncapi config context init ./
24
- - user's home directory : asyncapi config context init ~`;
23
+ - current directory : ${(0, picocolors_1.blueBright)('asyncapi config context init .')}(default)
24
+ - root of current repository : ${(0, picocolors_1.blueBright)('asyncapi config context init ./ ')}
25
+ - user's home directory : ${(0, picocolors_1.blueBright)('asyncapi config context init ~`')}`;
25
26
  ContextInit.args = {
26
27
  'context-file-path': core_1.Args.string({ description: `${ContextInit.contextFilePathMessage}`, required: false })
27
28
  };
@@ -5,24 +5,25 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
5
5
  const Context_1 = require("../../../core/models/Context");
6
6
  const context_error_1 = require("../../../core/errors/context-error");
7
7
  const global_flags_1 = require("../../../core/flags/global.flags");
8
+ const picocolors_1 = require("picocolors");
8
9
  class ContextList extends base_1.default {
9
10
  run() {
10
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
12
  try {
12
13
  const fileContent = yield (0, Context_1.loadContextFile)();
13
14
  if (yield (0, Context_1.isContextFileEmpty)(fileContent)) {
14
- this.log(`Context file "${Context_1.CONTEXT_FILE_PATH}" is empty.`);
15
+ this.log(`Context file ${(0, picocolors_1.blueBright)(Context_1.CONTEXT_FILE_PATH)} is empty.`);
15
16
  return;
16
17
  }
17
18
  if (fileContent) {
18
19
  for (const [contextName, filePath] of Object.entries(fileContent.store)) {
19
- this.log(`${contextName}: ${filePath}`);
20
+ this.log(`${(0, picocolors_1.blueBright)(contextName)}: ${filePath}`);
20
21
  }
21
22
  }
22
23
  }
23
24
  catch (e) {
24
25
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
25
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
26
+ this.log(`Unable to list contexts. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.\n`);
26
27
  return;
27
28
  }
28
29
  throw e;
@@ -6,6 +6,7 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
6
6
  const Context_1 = require("../../../core/models/Context");
7
7
  const context_error_1 = require("../../../core/errors/context-error");
8
8
  const global_flags_1 = require("../../../core/flags/global.flags");
9
+ const picocolors_1 = require("picocolors");
9
10
  class ContextRemove extends base_1.default {
10
11
  run() {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -13,16 +14,14 @@ class ContextRemove extends base_1.default {
13
14
  const contextName = args['context-name'];
14
15
  try {
15
16
  yield (0, Context_1.removeContext)(contextName);
16
- this.log(`${contextName} successfully deleted`);
17
+ this.log(`Context ${(0, picocolors_1.blueBright)(contextName)} removed successfully!\n`);
17
18
  }
18
19
  catch (e) {
19
20
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
20
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
21
- return;
21
+ this.error(`Unable to remove context. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.`);
22
22
  }
23
23
  else if (e instanceof context_error_1.ContextFileEmptyError) {
24
- this.log(`Context file "${Context_1.CONTEXT_FILE_PATH}" is empty.`);
25
- return;
24
+ this.error(`Context file ${(0, picocolors_1.blueBright)(Context_1.CONTEXT_FILE_PATH)} is empty.`);
26
25
  }
27
26
  throw e;
28
27
  }
@@ -6,6 +6,7 @@ const base_1 = tslib_1.__importDefault(require("../../../core/base"));
6
6
  const Context_1 = require("../../../core/models/Context");
7
7
  const context_error_1 = require("../../../core/errors/context-error");
8
8
  const global_flags_1 = require("../../../core/flags/global.flags");
9
+ const picocolors_1 = require("picocolors");
9
10
  class ContextUse extends base_1.default {
10
11
  run() {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -13,15 +14,14 @@ class ContextUse extends base_1.default {
13
14
  const contextName = args['context-name'];
14
15
  try {
15
16
  yield (0, Context_1.setCurrentContext)(contextName);
16
- this.log(`${contextName} is set as current`);
17
+ this.log(`Context ${(0, picocolors_1.blueBright)(contextName)} is now set as current.`);
17
18
  }
18
19
  catch (e) {
19
20
  if (e instanceof (context_error_1.MissingContextFileError || context_error_1.ContextFileWrongFormatError)) {
20
- this.log('You have no context file configured. Run "asyncapi config context init" to initialize it.');
21
- return;
21
+ this.error(`Unable to set the current context. You have no context file configured.\nRun ${(0, picocolors_1.blueBright)('asyncapi config context init')} to initialize it.`);
22
22
  }
23
23
  else if (e instanceof context_error_1.ContextFileEmptyError) {
24
- this.log(`Context file "${Context_1.CONTEXT_FILE_PATH}" is empty.`);
24
+ this.error(`Context file ${(0, picocolors_1.blueBright)(Context_1.CONTEXT_FILE_PATH)} is empty.`);
25
25
  return;
26
26
  }
27
27
  throw e;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../core/base"));
5
5
  const global_flags_1 = require("../../core/flags/global.flags");
6
+ const picocolors_1 = require("picocolors");
6
7
  class Versions extends base_1.default {
7
8
  run() {
8
9
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -29,7 +30,7 @@ class Versions extends base_1.default {
29
30
  }
30
31
  }
31
32
  // Showing information available with `--version` flag.
32
- this.log(this.config.userAgent);
33
+ this.log((0, picocolors_1.gray)(`\n${this.config.userAgent}\n`));
33
34
  // Iteration through the array containing all dependencies '@asyncapi/*'
34
35
  // along with their versions.
35
36
  for (let i = 0; i < dependencies.length; i++) {
@@ -47,7 +48,7 @@ class Versions extends base_1.default {
47
48
  this.log(` └${dependency}\n`);
48
49
  }
49
50
  }
50
- this.log(`Repository: ${this.config.pjson.homepage}`);
51
+ this.log(`Repository: ${(0, picocolors_1.blueBright)(this.config.pjson.homepage)}`);
51
52
  });
52
53
  }
53
54
  }
@@ -109,6 +109,7 @@ class NewFile extends base_1.default {
109
109
  fileName = fileName || DEFAULT_ASYNCAPI_FILE_NAME;
110
110
  selectedTemplate = selectedTemplate || DEFAULT_ASYNCAPI_TEMPLATE;
111
111
  yield this.createAsyncapiFile(fileName, selectedTemplate);
112
+ fileName = fileName.includes('.') ? fileName : `${fileName}.yaml`;
112
113
  if (openStudio) {
113
114
  (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
114
115
  }
@@ -1,3 +1,5 @@
1
- import File from './file';
2
- export default class New extends File {
1
+ import Command from '../../core/base';
2
+ export default class New extends Command {
3
+ static readonly description = "Create a new AsyncAPI project, specification files, or templates for clients and applications.";
4
+ run(): Promise<void>;
3
5
  }
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const file_1 = tslib_1.__importDefault(require("./file"));
5
- class New extends file_1.default {
4
+ const base_1 = tslib_1.__importDefault(require("../../core/base"));
5
+ const core_1 = require("@oclif/core");
6
+ class New extends base_1.default {
7
+ run() {
8
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
+ const help = new core_1.Help(this.config);
10
+ help.showHelp(['new', '--help']);
11
+ });
12
+ }
6
13
  }
7
14
  exports.default = New;
15
+ New.description = 'Create a new AsyncAPI project, specification files, or templates for clients and applications.';
@@ -106,10 +106,11 @@ function start(filePath, port = exports.DEFAULT_PORT) {
106
106
  });
107
107
  server.listen(port, () => {
108
108
  const url = `http://localhost:${port}?liveServer=${port}&studio-version=${package_json_1.version}`;
109
- console.log(`Studio is now running at ${url}.`);
110
- console.log(`You can open this URL in your web browser, and if needed, press ${(0, picocolors_1.gray)('Ctrl + C')} to stop the process.`);
109
+ console.log(`🎉 Connected to Live Server running at ${(0, picocolors_1.blueBright)(url)}.`);
110
+ console.log(`🌐 Open this URL in your web browser: ${(0, picocolors_1.blueBright)(url)}`);
111
+ console.log(`🛑 If needed, press ${(0, picocolors_1.redBright)('Ctrl + C')} to stop the process.`);
111
112
  if (filePath) {
112
- console.log(`Watching changes on file ${filePath}`);
113
+ console.log(`👁️ Watching changes on file ${(0, picocolors_1.blueBright)(filePath)}`);
113
114
  }
114
115
  else {
115
116
  console.warn('Warning: No file was provided, and we couldn\'t find a default file (like "asyncapi.yaml" or "asyncapi.json") in the current folder. Starting Studio with a blank workspace.');
@@ -1337,63 +1337,15 @@
1337
1337
  "new": {
1338
1338
  "aliases": [],
1339
1339
  "args": {},
1340
- "description": "Creates a new asyncapi file",
1341
- "examples": [
1342
- "asyncapi new\t - start creation of a file in interactive mode",
1343
- "asyncapi new --file-name=my-asyncapi.yaml --example=default-example.yaml --no-tty\t - create a new file with a specific name, using one of the examples and without interactive mode"
1344
- ],
1345
- "flags": {
1346
- "help": {
1347
- "char": "h",
1348
- "description": "Show CLI help.",
1349
- "name": "help",
1350
- "allowNo": false,
1351
- "type": "boolean"
1352
- },
1353
- "file-name": {
1354
- "char": "n",
1355
- "description": "name of the file",
1356
- "name": "file-name",
1357
- "hasDynamicHelp": false,
1358
- "multiple": false,
1359
- "type": "option"
1360
- },
1361
- "example": {
1362
- "char": "e",
1363
- "description": "name of the example to use. Available examples are:\n\t - simple-asyncapi.yml\n\t - adeo-kafka-request-reply-asyncapi.yml\n\t - anyof-asyncapi.yml\n\t - application-headers-asyncapi.yml\n\t - correlation-id-asyncapi.yml\n\t - websocket-gemini-asyncapi.yml\n\t - gitter-streaming-asyncapi.yml\n\t - kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml\n\t - kraken-websocket-request-reply-multiple-channels-asyncapi.yml\n\t - mercure-asyncapi.yml\n\t - not-asyncapi.yml\n\t - operation-security-asyncapi.yml\n\t - oneof-asyncapi.yml\n\t - rpc-client-asyncapi.yml\n\t - rpc-server-asyncapi.yml\n\t - slack-rtm-asyncapi.yml\n\t - tutorial.yml\n\t - streetlights-kafka-asyncapi.yml\n\t - streetlights-operation-security-asyncapi.yml\n\t - streetlights-mqtt-asyncapi.yml",
1364
- "name": "example",
1365
- "hasDynamicHelp": false,
1366
- "multiple": false,
1367
- "type": "option"
1368
- },
1369
- "studio": {
1370
- "char": "s",
1371
- "description": "open in Studio",
1372
- "name": "studio",
1373
- "allowNo": false,
1374
- "type": "boolean"
1375
- },
1376
- "port": {
1377
- "char": "p",
1378
- "description": "port in which to start Studio",
1379
- "name": "port",
1380
- "hasDynamicHelp": false,
1381
- "multiple": false,
1382
- "type": "option"
1383
- },
1384
- "no-tty": {
1385
- "description": "do not use an interactive terminal",
1386
- "name": "no-tty",
1387
- "allowNo": false,
1388
- "type": "boolean"
1389
- }
1390
- },
1340
+ "description": "Create a new AsyncAPI project, specification files, or templates for clients and applications.",
1341
+ "flags": {},
1391
1342
  "hasDynamicHelp": false,
1392
1343
  "hiddenAliases": [],
1393
1344
  "id": "new",
1394
1345
  "pluginAlias": "@asyncapi/cli",
1395
1346
  "pluginName": "@asyncapi/cli",
1396
1347
  "pluginType": "core",
1348
+ "strict": true,
1397
1349
  "isESM": false,
1398
1350
  "relativePath": [
1399
1351
  "lib",
@@ -1685,7 +1637,7 @@
1685
1637
  "aliases": [],
1686
1638
  "args": {
1687
1639
  "context-file-path": {
1688
- "description": "Specify directory in which context file should be created:\n - current directory : asyncapi config context init . (default)\n - root of current repository : asyncapi config context init ./\n - user's home directory : asyncapi config context init ~",
1640
+ "description": "Specify directory in which context file should be created:\n - current directory : \u001b[94masyncapi config context init .\u001b[39m(default)\n - root of current repository : \u001b[94masyncapi config context init ./ \u001b[39m\n - user's home directory : \u001b[94masyncapi config context init ~`\u001b[39m",
1689
1641
  "name": "context-file-path",
1690
1642
  "required": false
1691
1643
  }
@@ -1707,7 +1659,7 @@
1707
1659
  "pluginName": "@asyncapi/cli",
1708
1660
  "pluginType": "core",
1709
1661
  "strict": true,
1710
- "contextFilePathMessage": "Specify directory in which context file should be created:\n - current directory : asyncapi config context init . (default)\n - root of current repository : asyncapi config context init ./\n - user's home directory : asyncapi config context init ~",
1662
+ "contextFilePathMessage": "Specify directory in which context file should be created:\n - current directory : \u001b[94masyncapi config context init .\u001b[39m(default)\n - root of current repository : \u001b[94masyncapi config context init ./ \u001b[39m\n - user's home directory : \u001b[94masyncapi config context init ~`\u001b[39m",
1711
1663
  "isESM": false,
1712
1664
  "relativePath": [
1713
1665
  "lib",
@@ -1817,5 +1769,5 @@
1817
1769
  ]
1818
1770
  }
1819
1771
  },
1820
- "version": "2.16.0"
1772
+ "version": "2.16.2"
1821
1773
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asyncapi/cli",
3
3
  "description": "All in one CLI for all AsyncAPI tools",
4
- "version": "2.16.0",
4
+ "version": "2.16.2",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -106,6 +106,9 @@
106
106
  "oclif": {
107
107
  "commands": "./lib/commands",
108
108
  "bin": "asyncapi",
109
+ "additionalVersionFlags": [
110
+ "--v"
111
+ ],
109
112
  "hooks": {
110
113
  "command_not_found": [
111
114
  "./lib/hooks/command_not_found/myhook"