@asyncapi/cli 0.9.2 → 0.11.0
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/lib/commands/new.js +3 -2
- package/lib/commands/start.d.ts +8 -0
- package/lib/commands/start.js +16 -0
- package/lib/help/CommandHelper.d.ts +5 -0
- package/lib/help/CommandHelper.js +59 -0
- package/lib/help/index.d.ts +8 -0
- package/lib/help/index.js +50 -0
- package/lib/models/SpecificationFile.js +5 -5
- package/oclif.manifest.json +1 -1
- package/package.json +16 -6
package/lib/commands/new.js
CHANGED
|
@@ -12,7 +12,7 @@ const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
|
|
|
12
12
|
const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
|
|
13
13
|
class New extends base_1.default {
|
|
14
14
|
async run() {
|
|
15
|
-
const { flags } = this.parse(New);
|
|
15
|
+
const { flags } = this.parse(New); // NOSONAR
|
|
16
16
|
const isTTY = process.stdout.isTTY;
|
|
17
17
|
if (!flags['no-tty'] && isTTY) {
|
|
18
18
|
return this.runInteractive();
|
|
@@ -29,8 +29,9 @@ class New extends base_1.default {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
/* eslint-disable sonarjs/cognitive-complexity */
|
|
32
33
|
async runInteractive() {
|
|
33
|
-
const { flags } = this.parse(New);
|
|
34
|
+
const { flags } = this.parse(New); // NOSONAR
|
|
34
35
|
let fileName = flags['file-name'];
|
|
35
36
|
let selectedTemplate = flags['example'];
|
|
36
37
|
let openStudio = flags.studio;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Start = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const command_1 = require("@oclif/command");
|
|
6
|
+
const base_1 = tslib_1.__importDefault(require("../base"));
|
|
7
|
+
class Start extends base_1.default {
|
|
8
|
+
async run() {
|
|
9
|
+
this._help();
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Start = Start;
|
|
13
|
+
Start.description = 'starts a new local instance of Studio';
|
|
14
|
+
Start.flags = {
|
|
15
|
+
help: command_1.flags.help({ char: 'h' })
|
|
16
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const command_1 = tslib_1.__importDefault(require("@oclif/plugin-help/lib/command"));
|
|
5
|
+
const list_1 = require("@oclif/plugin-help/lib/list");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const indent_string_1 = tslib_1.__importDefault(require("indent-string"));
|
|
8
|
+
const { underline, bold, dim } = chalk_1.default;
|
|
9
|
+
class CommandHelper extends command_1.default {
|
|
10
|
+
/* eslint-disable sonarjs/cognitive-complexity */
|
|
11
|
+
flags(flags) {
|
|
12
|
+
if (flags.length === 0) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const body = list_1.renderList(flags.map(flag => {
|
|
16
|
+
var _a;
|
|
17
|
+
let left = flag.helpLabel;
|
|
18
|
+
if (!left) {
|
|
19
|
+
const label = [];
|
|
20
|
+
if (flag.char) {
|
|
21
|
+
label.push(`-${flag.char[0]}`);
|
|
22
|
+
}
|
|
23
|
+
if (flag.name) {
|
|
24
|
+
if (flag.type === 'boolean' && flag.allowNo) {
|
|
25
|
+
label.push(`--[no-]${flag.name.trim()}`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
label.push(`--${flag.name.trim()}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
left = label.join(', ');
|
|
32
|
+
}
|
|
33
|
+
if (flag.type === 'option') {
|
|
34
|
+
let value = flag.helpValue || flag.name;
|
|
35
|
+
if (!flag.helpValue && flag.options) {
|
|
36
|
+
value = flag.options.join('|');
|
|
37
|
+
}
|
|
38
|
+
if (!value.includes('|')) {
|
|
39
|
+
value = underline(value);
|
|
40
|
+
}
|
|
41
|
+
left += `=${value}`;
|
|
42
|
+
}
|
|
43
|
+
let right = flag.description || '';
|
|
44
|
+
// `flag.default` is not always a string (typing bug), hence `toString()`
|
|
45
|
+
if (flag.type === 'option' && (flag.default || ((_a = flag.default) === null || _a === void 0 ? void 0 : _a.toString()) === '0')) {
|
|
46
|
+
right = `[default: ${flag.default}] ${right}`;
|
|
47
|
+
}
|
|
48
|
+
if (flag.required) {
|
|
49
|
+
right = `(required) ${right}`;
|
|
50
|
+
}
|
|
51
|
+
return [left, dim(right.trim())];
|
|
52
|
+
}), { stripAnsi: this.opts.stripAnsi, maxWidth: this.opts.maxWidth - 2 });
|
|
53
|
+
return [
|
|
54
|
+
bold('FLAGS'),
|
|
55
|
+
indent_string_1.default(body, 2),
|
|
56
|
+
].join('\n');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = CommandHelper;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Help from '@oclif/plugin-help';
|
|
2
|
+
import * as Config from '@oclif/config';
|
|
3
|
+
export default class CustomHelp extends Help {
|
|
4
|
+
showRootHelp(): void;
|
|
5
|
+
showTopicHelp(topic: Config.Topic): void;
|
|
6
|
+
showCommandHelp(command: Config.Command): void;
|
|
7
|
+
formatCommand(command: Config.Command): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const plugin_help_1 = tslib_1.__importDefault(require("@oclif/plugin-help"));
|
|
5
|
+
const CommandHelper_1 = tslib_1.__importDefault(require("./CommandHelper"));
|
|
6
|
+
class CustomHelp extends plugin_help_1.default {
|
|
7
|
+
showRootHelp() {
|
|
8
|
+
let rootCommands = this.sortedCommands;
|
|
9
|
+
console.log(this.formatRoot());
|
|
10
|
+
console.log('');
|
|
11
|
+
if (!this.opts.all) {
|
|
12
|
+
rootCommands = rootCommands.filter(c => !c.id.includes(':'));
|
|
13
|
+
}
|
|
14
|
+
if (rootCommands.length > 0) {
|
|
15
|
+
rootCommands = rootCommands.filter(c => c.id);
|
|
16
|
+
console.log(this.formatCommands(rootCommands));
|
|
17
|
+
console.log('');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
showTopicHelp(topic) {
|
|
21
|
+
const name = topic.name;
|
|
22
|
+
const depth = name.split(':').length;
|
|
23
|
+
const commands = this.sortedCommands.filter(c => c.id.startsWith(`${name}:`) && c.id.split(':').length === depth + 1);
|
|
24
|
+
console.log(this.formatTopic(topic));
|
|
25
|
+
if (commands.length > 0) {
|
|
26
|
+
console.log(this.formatCommands(commands));
|
|
27
|
+
console.log('');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
showCommandHelp(command) {
|
|
31
|
+
const name = command.id;
|
|
32
|
+
const depth = name.split(':').length;
|
|
33
|
+
const subCommands = this.sortedCommands.filter(c => c.id.startsWith(`${name}:`) && c.id.split(':').length === depth + 1);
|
|
34
|
+
const title = command.description && this.render(command.description).split('\n')[0];
|
|
35
|
+
if (title) {
|
|
36
|
+
console.log(`${title}\n`);
|
|
37
|
+
}
|
|
38
|
+
console.log(this.formatCommand(command));
|
|
39
|
+
console.log('');
|
|
40
|
+
if (subCommands.length > 0) {
|
|
41
|
+
console.log(this.formatCommands(subCommands));
|
|
42
|
+
console.log('');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
formatCommand(command) {
|
|
46
|
+
const help = new CommandHelper_1.default(command, this.config, this.opts);
|
|
47
|
+
return help.generate();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = CustomHelp;
|
|
@@ -39,14 +39,14 @@ async function load(filePathOrContextName) {
|
|
|
39
39
|
return await loadFromContext();
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
42
|
-
|
|
42
|
+
const autoDetectedSpecFile = await detectSpecFile();
|
|
43
|
+
if (autoDetectedSpecFile) {
|
|
44
|
+
return new SpecificationFile(autoDetectedSpecFile);
|
|
45
|
+
}
|
|
46
|
+
if (!filePathOrContextName || !autoDetectedSpecFile) {
|
|
43
47
|
throw e;
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
|
-
const autoDetectedSpecFile = await detectSpecFile();
|
|
47
|
-
if (autoDetectedSpecFile) {
|
|
48
|
-
return new SpecificationFile(autoDetectedSpecFile);
|
|
49
|
-
}
|
|
50
50
|
throw new specification_file_1.SpecificationFileNotFound();
|
|
51
51
|
}
|
|
52
52
|
exports.load = load;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.
|
|
1
|
+
{"version":"0.11.0","commands":{"config":{"id":"config","description":"access configs","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"new":{"id":"new","description":"creates a new asyncapi file","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"file-name":{"name":"file-name","type":"option","char":"n","description":"name of the file"},"example":{"name":"example","type":"option","char":"e","description":"name of the example to use"},"studio":{"name":"studio","type":"boolean","char":"s","description":"open in Studio","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio"},"no-tty":{"name":"no-tty","type":"boolean","description":"do not use an interactive terminal","allowNo":false}},"args":[]},"start":{"id":"start","description":"starts a new local instance of Studio","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"validate":{"id":"validate","description":"validate asyncapi file","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"spec-file","description":"spec path or context-name","required":false}]},"config:context":{"id":"config:context","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start:studio":{"id":"start:studio","description":"starts a new local instance of Studio","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"file":{"name":"file","type":"option","char":"f","description":"path to the AsyncAPI file to link with Studio"},"port":{"name":"port","type":"option","char":"p","description":"port in which to start Studio"}},"args":[]},"config:context:add":{"id":"config:context:add","description":"Add or modify a context in the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"context name","required":true},{"name":"spec-file-path","description":"file path of the spec file","required":true}]},"config:context:current":{"id":"config:context:current","description":"Shows the current context that is being used","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"config:context:list":{"id":"config:context:list","description":"List all the stored context in the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"config:context:remove":{"id":"config:context:remove","description":"Delete a context from the store","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"Name of the context to delete","required":true}]},"config:context:use":{"id":"config:context:use","description":"Set a context as current","pluginName":"@asyncapi/cli","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[{"name":"context-name","description":"name of the saved context","required":true}]}}}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/cli",
|
|
3
3
|
"description": "All in one CLI for all AsyncAPI tools",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/asyncapi/cli/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@asyncapi/parser": "^1.
|
|
12
|
-
"@asyncapi/studio": "^0.
|
|
11
|
+
"@asyncapi/parser": "^1.12.0",
|
|
12
|
+
"@asyncapi/studio": "^0.4.2",
|
|
13
13
|
"@fmvilas/oclif-plugin-spaced-commands": "^1.0.4",
|
|
14
14
|
"@oclif/command": "^1.8.0",
|
|
15
15
|
"@oclif/config": "^1.17.0",
|
|
@@ -19,10 +19,15 @@
|
|
|
19
19
|
"chokidar": "^3.5.2",
|
|
20
20
|
"inquirer": "^8.2.0",
|
|
21
21
|
"open": "^8.4.0",
|
|
22
|
+
"chalk": "^4.1.0",
|
|
23
|
+
"indent-string": "^4.0.0",
|
|
24
|
+
"lodash.template": "^4.4.0",
|
|
22
25
|
"reflect-metadata": "^0.1.13",
|
|
23
26
|
"request": "^2.88.2",
|
|
24
27
|
"serve-handler": "^6.1.3",
|
|
28
|
+
"strip-ansi": "^6.0.0",
|
|
25
29
|
"tslib": "^1.14.1",
|
|
30
|
+
"wrap-ansi": "^4.0.0",
|
|
26
31
|
"unzipper": "^0.10.11",
|
|
27
32
|
"ws": "^8.2.3"
|
|
28
33
|
},
|
|
@@ -34,9 +39,11 @@
|
|
|
34
39
|
"@semantic-release/npm": "^7.1.3",
|
|
35
40
|
"@semantic-release/release-notes-generator": "^9.0.2",
|
|
36
41
|
"@types/chai": "^4.2.21",
|
|
42
|
+
"@types/lodash.template": "^4.4.4",
|
|
37
43
|
"@types/mocha": "^5.2.7",
|
|
38
44
|
"@types/node": "^10.17.60",
|
|
39
45
|
"@types/serve-handler": "^6.1.1",
|
|
46
|
+
"@types/wrap-ansi": "^8.0.1",
|
|
40
47
|
"@typescript-eslint/eslint-plugin": "^4.28.4",
|
|
41
48
|
"@typescript-eslint/parser": "^4.28.4",
|
|
42
49
|
"acorn": "^8.5.0",
|
|
@@ -79,9 +86,9 @@
|
|
|
79
86
|
"commands": "./lib/commands",
|
|
80
87
|
"bin": "asyncapi",
|
|
81
88
|
"plugins": [
|
|
82
|
-
"@oclif/plugin-help",
|
|
83
89
|
"@fmvilas/oclif-plugin-spaced-commands"
|
|
84
|
-
]
|
|
90
|
+
],
|
|
91
|
+
"helpClass": "./lib/help"
|
|
85
92
|
},
|
|
86
93
|
"publishConfig": {
|
|
87
94
|
"access": "public"
|
|
@@ -107,6 +114,9 @@
|
|
|
107
114
|
"@semantic-release/github"
|
|
108
115
|
]
|
|
109
116
|
},
|
|
117
|
+
"optionalDependencies": {
|
|
118
|
+
"fsevents": "^2.3.2"
|
|
119
|
+
},
|
|
110
120
|
"repository": "asyncapi/cli",
|
|
111
121
|
"scripts": {
|
|
112
122
|
"build": "node scripts/fetch-asyncapi-example.js && tsc",
|
|
@@ -114,7 +124,7 @@
|
|
|
114
124
|
"dev": "tsc --watch",
|
|
115
125
|
"generate:assets": "npm run generate:readme:toc",
|
|
116
126
|
"generate:readme:toc": "markdown-toc -i README.md",
|
|
117
|
-
"lint": "eslint --max-warnings
|
|
127
|
+
"lint": "eslint --max-warnings 0 --config .eslintrc .",
|
|
118
128
|
"lint:fix": "eslint --max-warnings 5 --config .eslintrc . --fix",
|
|
119
129
|
"postpack": "rimraf oclif.manifest.json",
|
|
120
130
|
"prepack": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
|