@asyncapi/cli 0.38.0 → 0.39.1
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.d.ts → new/file.d.ts} +2 -3
- package/lib/commands/{new.js → new/file.js} +10 -11
- package/lib/commands/new/glee.d.ts +10 -0
- package/lib/commands/new/glee.js +56 -0
- package/lib/commands/new/index.d.ts +3 -0
- package/lib/commands/new/index.js +7 -0
- package/lib/commands/new/project.d.ts +5 -0
- package/lib/commands/new/project.js +11 -0
- package/oclif.manifest.json +161 -54
- package/package.json +4 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Command from '
|
|
2
|
-
export default class
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class NewFile extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static flags: {
|
|
5
5
|
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
@@ -9,7 +9,6 @@ export default class New extends Command {
|
|
|
9
9
|
port: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined>;
|
|
10
10
|
'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
11
|
};
|
|
12
|
-
static args: never[];
|
|
13
12
|
run(): Promise<void>;
|
|
14
13
|
runInteractive(): Promise<void>;
|
|
15
14
|
createAsyncapiFile(fileName: string, selectedTemplate: string): Promise<void>;
|
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const base_1 = tslib_1.__importDefault(require("
|
|
6
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
7
7
|
const inquirer = tslib_1.__importStar(require("inquirer"));
|
|
8
|
-
const Studio_1 = require("
|
|
8
|
+
const Studio_1 = require("../../models/Studio");
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const { writeFile, readFile } = fs_1.promises;
|
|
11
11
|
const DEFAULT_ASYNCAPI_FILE_NAME = 'asyncapi.yaml';
|
|
12
12
|
const DEFAULT_ASYNCAPI_TEMPLATE = 'default-example.yaml';
|
|
13
|
-
class
|
|
13
|
+
class NewFile extends base_1.default {
|
|
14
14
|
run() {
|
|
15
15
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { flags } = yield this.parse(
|
|
16
|
+
const { flags } = yield this.parse(NewFile); // NOSONAR
|
|
17
17
|
const isTTY = process.stdout.isTTY;
|
|
18
18
|
if (!flags['no-tty'] && isTTY) {
|
|
19
19
|
return this.runInteractive();
|
|
@@ -34,7 +34,7 @@ class New extends base_1.default {
|
|
|
34
34
|
/* eslint-disable sonarjs/cognitive-complexity */
|
|
35
35
|
runInteractive() {
|
|
36
36
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const { flags } = yield this.parse(
|
|
37
|
+
const { flags } = yield this.parse(NewFile); // NOSONAR
|
|
38
38
|
let fileName = flags['file-name'];
|
|
39
39
|
let selectedTemplate = flags['example'];
|
|
40
40
|
let openStudio = flags.studio;
|
|
@@ -102,12 +102,12 @@ class New extends base_1.default {
|
|
|
102
102
|
}
|
|
103
103
|
createAsyncapiFile(fileName, selectedTemplate) {
|
|
104
104
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
const asyncApiFile = yield readFile((0, path_1.resolve)(__dirname, '
|
|
105
|
+
const asyncApiFile = yield readFile((0, path_1.resolve)(__dirname, '../../../assets/examples/', selectedTemplate), { encoding: 'utf8' });
|
|
106
106
|
const fileNameHasFileExtension = fileName.includes('.');
|
|
107
107
|
const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`;
|
|
108
108
|
try {
|
|
109
109
|
const content = yield readFile(fileNameToWriteToDisk, { encoding: 'utf8' });
|
|
110
|
-
if (content !==
|
|
110
|
+
if (content !== undefined) {
|
|
111
111
|
console.log(`File ${fileNameToWriteToDisk} already exists. Ignoring...`);
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
@@ -120,9 +120,9 @@ class New extends base_1.default {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
exports.default =
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
exports.default = NewFile;
|
|
124
|
+
NewFile.description = 'Creates a new asyncapi file';
|
|
125
|
+
NewFile.flags = {
|
|
126
126
|
help: core_1.Flags.help({ char: 'h' }),
|
|
127
127
|
'file-name': core_1.Flags.string({ char: 'n', description: 'name of the file' }),
|
|
128
128
|
example: core_1.Flags.string({ char: 'e', description: 'name of the example to use' }),
|
|
@@ -130,4 +130,3 @@ New.flags = {
|
|
|
130
130
|
port: core_1.Flags.integer({ char: 'p', description: 'port in which to start Studio' }),
|
|
131
131
|
'no-tty': core_1.Flags.boolean({ description: 'do not use an interactive terminal' }),
|
|
132
132
|
};
|
|
133
|
-
New.args = [];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Command from '../../base';
|
|
2
|
+
export default class NewGlee extends Command {
|
|
3
|
+
static description: string;
|
|
4
|
+
protected commandName: string;
|
|
5
|
+
static flags: {
|
|
6
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
7
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const base_1 = tslib_1.__importDefault(require("../../base"));
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
|
+
class NewGlee extends base_1.default {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.commandName = 'glee';
|
|
13
|
+
}
|
|
14
|
+
run() {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const { flags } = yield this.parse(NewGlee); // NOSONAR
|
|
17
|
+
const projectName = flags.name;
|
|
18
|
+
const PROJECT_DIRECTORY = (0, path_1.join)(process.cwd(), projectName);
|
|
19
|
+
const GLEE_TEMPLATES_DIRECTORY = (0, path_1.resolve)(__dirname, '../../../create-glee-app/templates/default');
|
|
20
|
+
try {
|
|
21
|
+
yield fs_1.promises.mkdir(PROJECT_DIRECTORY);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
switch (err.code) {
|
|
25
|
+
case 'EEXIST':
|
|
26
|
+
this.error(`Unable to create the project. We tried to use "${projectName}" as the directory of your new project but it already exists (${PROJECT_DIRECTORY}). Please specify a different name for the new project. For example, run the following command instead:\n\n asyncapi new ${this.commandName} --name ${projectName}-1\n`);
|
|
27
|
+
break;
|
|
28
|
+
case 'EACCES':
|
|
29
|
+
this.error(`Unable to create the project. We tried to access the "${PROJECT_DIRECTORY}" directory but it was not possible due to file access permissions. Please check the write permissions of your current working directory ("${process.cwd()}").`);
|
|
30
|
+
break;
|
|
31
|
+
case 'EPERM':
|
|
32
|
+
this.error(`Unable to create the project. We tried to create the "${PROJECT_DIRECTORY}" directory but the operation requires elevated privileges. Please check the privileges for your current user.`);
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
this.error(`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
yield fs_extra_1.default.copy(GLEE_TEMPLATES_DIRECTORY, PROJECT_DIRECTORY);
|
|
40
|
+
yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/env`, `${PROJECT_DIRECTORY}/.env`);
|
|
41
|
+
yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/gitignore`, `${PROJECT_DIRECTORY}/.gitignore`);
|
|
42
|
+
yield fs_1.promises.rename(`${PROJECT_DIRECTORY}/README-template.md`, `${PROJECT_DIRECTORY}/README.md`);
|
|
43
|
+
this.log(`Your project "${projectName}" has been created successfully!\n\nNext steps:\n\n cd ${projectName}\n npm install\n npm run dev\n\nAlso, you can already open the project in your favorite editor and start tweaking it.`);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
this.error(`Unable to create the project. Please check the following message for further info about the error:\n\n${err}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = NewGlee;
|
|
52
|
+
NewGlee.description = 'Creates a new Glee project';
|
|
53
|
+
NewGlee.flags = {
|
|
54
|
+
help: core_1.Flags.help({ char: 'h' }),
|
|
55
|
+
name: core_1.Flags.string({ char: 'n', description: 'name of the project', default: 'project' }),
|
|
56
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const glee_1 = tslib_1.__importDefault(require("./glee"));
|
|
5
|
+
class NewProject extends glee_1.default {
|
|
6
|
+
constructor(argv, config) {
|
|
7
|
+
super(argv, config);
|
|
8
|
+
this.commandName = 'project';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.default = NewProject;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.39.1",
|
|
3
3
|
"commands": {
|
|
4
4
|
"bundle": {
|
|
5
5
|
"id": "bundle",
|
|
@@ -195,59 +195,6 @@
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
},
|
|
198
|
-
"new": {
|
|
199
|
-
"id": "new",
|
|
200
|
-
"description": "Creates a new asyncapi file",
|
|
201
|
-
"strict": true,
|
|
202
|
-
"pluginName": "@asyncapi/cli",
|
|
203
|
-
"pluginAlias": "@asyncapi/cli",
|
|
204
|
-
"pluginType": "core",
|
|
205
|
-
"aliases": [],
|
|
206
|
-
"flags": {
|
|
207
|
-
"help": {
|
|
208
|
-
"name": "help",
|
|
209
|
-
"type": "boolean",
|
|
210
|
-
"char": "h",
|
|
211
|
-
"description": "Show CLI help.",
|
|
212
|
-
"allowNo": false
|
|
213
|
-
},
|
|
214
|
-
"file-name": {
|
|
215
|
-
"name": "file-name",
|
|
216
|
-
"type": "option",
|
|
217
|
-
"char": "n",
|
|
218
|
-
"description": "name of the file",
|
|
219
|
-
"multiple": false
|
|
220
|
-
},
|
|
221
|
-
"example": {
|
|
222
|
-
"name": "example",
|
|
223
|
-
"type": "option",
|
|
224
|
-
"char": "e",
|
|
225
|
-
"description": "name of the example to use",
|
|
226
|
-
"multiple": false
|
|
227
|
-
},
|
|
228
|
-
"studio": {
|
|
229
|
-
"name": "studio",
|
|
230
|
-
"type": "boolean",
|
|
231
|
-
"char": "s",
|
|
232
|
-
"description": "open in Studio",
|
|
233
|
-
"allowNo": false
|
|
234
|
-
},
|
|
235
|
-
"port": {
|
|
236
|
-
"name": "port",
|
|
237
|
-
"type": "option",
|
|
238
|
-
"char": "p",
|
|
239
|
-
"description": "port in which to start Studio",
|
|
240
|
-
"multiple": false
|
|
241
|
-
},
|
|
242
|
-
"no-tty": {
|
|
243
|
-
"name": "no-tty",
|
|
244
|
-
"type": "boolean",
|
|
245
|
-
"description": "do not use an interactive terminal",
|
|
246
|
-
"allowNo": false
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
"args": {}
|
|
250
|
-
},
|
|
251
198
|
"optimize": {
|
|
252
199
|
"id": "optimize",
|
|
253
200
|
"description": "optimize asyncapi specification file",
|
|
@@ -680,6 +627,166 @@
|
|
|
680
627
|
}
|
|
681
628
|
}
|
|
682
629
|
},
|
|
630
|
+
"new:file": {
|
|
631
|
+
"id": "new:file",
|
|
632
|
+
"description": "Creates a new asyncapi file",
|
|
633
|
+
"strict": true,
|
|
634
|
+
"pluginName": "@asyncapi/cli",
|
|
635
|
+
"pluginAlias": "@asyncapi/cli",
|
|
636
|
+
"pluginType": "core",
|
|
637
|
+
"aliases": [],
|
|
638
|
+
"flags": {
|
|
639
|
+
"help": {
|
|
640
|
+
"name": "help",
|
|
641
|
+
"type": "boolean",
|
|
642
|
+
"char": "h",
|
|
643
|
+
"description": "Show CLI help.",
|
|
644
|
+
"allowNo": false
|
|
645
|
+
},
|
|
646
|
+
"file-name": {
|
|
647
|
+
"name": "file-name",
|
|
648
|
+
"type": "option",
|
|
649
|
+
"char": "n",
|
|
650
|
+
"description": "name of the file",
|
|
651
|
+
"multiple": false
|
|
652
|
+
},
|
|
653
|
+
"example": {
|
|
654
|
+
"name": "example",
|
|
655
|
+
"type": "option",
|
|
656
|
+
"char": "e",
|
|
657
|
+
"description": "name of the example to use",
|
|
658
|
+
"multiple": false
|
|
659
|
+
},
|
|
660
|
+
"studio": {
|
|
661
|
+
"name": "studio",
|
|
662
|
+
"type": "boolean",
|
|
663
|
+
"char": "s",
|
|
664
|
+
"description": "open in Studio",
|
|
665
|
+
"allowNo": false
|
|
666
|
+
},
|
|
667
|
+
"port": {
|
|
668
|
+
"name": "port",
|
|
669
|
+
"type": "option",
|
|
670
|
+
"char": "p",
|
|
671
|
+
"description": "port in which to start Studio",
|
|
672
|
+
"multiple": false
|
|
673
|
+
},
|
|
674
|
+
"no-tty": {
|
|
675
|
+
"name": "no-tty",
|
|
676
|
+
"type": "boolean",
|
|
677
|
+
"description": "do not use an interactive terminal",
|
|
678
|
+
"allowNo": false
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
"args": {}
|
|
682
|
+
},
|
|
683
|
+
"new:glee": {
|
|
684
|
+
"id": "new:glee",
|
|
685
|
+
"description": "Creates a new Glee project",
|
|
686
|
+
"strict": true,
|
|
687
|
+
"pluginName": "@asyncapi/cli",
|
|
688
|
+
"pluginAlias": "@asyncapi/cli",
|
|
689
|
+
"pluginType": "core",
|
|
690
|
+
"aliases": [],
|
|
691
|
+
"flags": {
|
|
692
|
+
"help": {
|
|
693
|
+
"name": "help",
|
|
694
|
+
"type": "boolean",
|
|
695
|
+
"char": "h",
|
|
696
|
+
"description": "Show CLI help.",
|
|
697
|
+
"allowNo": false
|
|
698
|
+
},
|
|
699
|
+
"name": {
|
|
700
|
+
"name": "name",
|
|
701
|
+
"type": "option",
|
|
702
|
+
"char": "n",
|
|
703
|
+
"description": "name of the project",
|
|
704
|
+
"multiple": false,
|
|
705
|
+
"default": "project"
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
"args": {}
|
|
709
|
+
},
|
|
710
|
+
"new": {
|
|
711
|
+
"id": "new",
|
|
712
|
+
"description": "Creates a new asyncapi file",
|
|
713
|
+
"strict": true,
|
|
714
|
+
"pluginName": "@asyncapi/cli",
|
|
715
|
+
"pluginAlias": "@asyncapi/cli",
|
|
716
|
+
"pluginType": "core",
|
|
717
|
+
"aliases": [],
|
|
718
|
+
"flags": {
|
|
719
|
+
"help": {
|
|
720
|
+
"name": "help",
|
|
721
|
+
"type": "boolean",
|
|
722
|
+
"char": "h",
|
|
723
|
+
"description": "Show CLI help.",
|
|
724
|
+
"allowNo": false
|
|
725
|
+
},
|
|
726
|
+
"file-name": {
|
|
727
|
+
"name": "file-name",
|
|
728
|
+
"type": "option",
|
|
729
|
+
"char": "n",
|
|
730
|
+
"description": "name of the file",
|
|
731
|
+
"multiple": false
|
|
732
|
+
},
|
|
733
|
+
"example": {
|
|
734
|
+
"name": "example",
|
|
735
|
+
"type": "option",
|
|
736
|
+
"char": "e",
|
|
737
|
+
"description": "name of the example to use",
|
|
738
|
+
"multiple": false
|
|
739
|
+
},
|
|
740
|
+
"studio": {
|
|
741
|
+
"name": "studio",
|
|
742
|
+
"type": "boolean",
|
|
743
|
+
"char": "s",
|
|
744
|
+
"description": "open in Studio",
|
|
745
|
+
"allowNo": false
|
|
746
|
+
},
|
|
747
|
+
"port": {
|
|
748
|
+
"name": "port",
|
|
749
|
+
"type": "option",
|
|
750
|
+
"char": "p",
|
|
751
|
+
"description": "port in which to start Studio",
|
|
752
|
+
"multiple": false
|
|
753
|
+
},
|
|
754
|
+
"no-tty": {
|
|
755
|
+
"name": "no-tty",
|
|
756
|
+
"type": "boolean",
|
|
757
|
+
"description": "do not use an interactive terminal",
|
|
758
|
+
"allowNo": false
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
"args": {}
|
|
762
|
+
},
|
|
763
|
+
"new:project": {
|
|
764
|
+
"id": "new:project",
|
|
765
|
+
"description": "Creates a new Glee project",
|
|
766
|
+
"strict": true,
|
|
767
|
+
"pluginName": "@asyncapi/cli",
|
|
768
|
+
"pluginAlias": "@asyncapi/cli",
|
|
769
|
+
"pluginType": "core",
|
|
770
|
+
"aliases": [],
|
|
771
|
+
"flags": {
|
|
772
|
+
"help": {
|
|
773
|
+
"name": "help",
|
|
774
|
+
"type": "boolean",
|
|
775
|
+
"char": "h",
|
|
776
|
+
"description": "Show CLI help.",
|
|
777
|
+
"allowNo": false
|
|
778
|
+
},
|
|
779
|
+
"name": {
|
|
780
|
+
"name": "name",
|
|
781
|
+
"type": "option",
|
|
782
|
+
"char": "n",
|
|
783
|
+
"description": "name of the project",
|
|
784
|
+
"multiple": false,
|
|
785
|
+
"default": "project"
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
"args": {}
|
|
789
|
+
},
|
|
683
790
|
"start": {
|
|
684
791
|
"id": "start",
|
|
685
792
|
"description": "Start asyncapi studio",
|
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": "0.
|
|
4
|
+
"version": "0.39.1",
|
|
5
5
|
"author": "@asyncapi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"asyncapi": "./bin/run"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@asyncapi/converter": "^1.2.0",
|
|
13
13
|
"@asyncapi/diff": "^0.4.1",
|
|
14
14
|
"@asyncapi/generator": "^1.9.17",
|
|
15
|
-
"@asyncapi/modelina": "^1.3.
|
|
15
|
+
"@asyncapi/modelina": "^1.3.3",
|
|
16
16
|
"@asyncapi/optimizer": "^0.1.18",
|
|
17
17
|
"@asyncapi/parser": "2.0.0-next-major.16",
|
|
18
18
|
"@asyncapi/studio": "^0.17.3",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"ajv": "^8.12.0",
|
|
24
24
|
"chalk": "^4.1.0",
|
|
25
25
|
"chokidar": "^3.5.2",
|
|
26
|
+
"fs-extra": "^11.1.0",
|
|
26
27
|
"indent-string": "^4.0.0",
|
|
27
28
|
"inquirer": "^8.2.0",
|
|
28
29
|
"lodash.template": "^4.4.0",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@swc/core": "^1.3.2",
|
|
50
51
|
"@swc/jest": "^0.2.22",
|
|
51
52
|
"@types/chai": "^4.3.3",
|
|
53
|
+
"@types/fs-extra": "^11.0.1",
|
|
52
54
|
"@types/inquirer": "^8.1.3",
|
|
53
55
|
"@types/jest": "^29.0.3",
|
|
54
56
|
"@types/lodash.template": "^4.4.4",
|