@asyncapi/cli 0.25.1 → 0.25.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.
@@ -51,31 +51,33 @@ class Template extends base_1.default {
51
51
  };
52
52
  };
53
53
  }
54
- async run() {
55
- const { args, flags } = await this.parse(Template); // NOSONAR
56
- const asyncapi = args['asyncapi'];
57
- const template = args['template'];
58
- const output = flags.output || process.cwd();
59
- const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url']);
60
- const options = {
61
- forceWrite: flags['force-write'],
62
- install: flags.install,
63
- debug: flags.debug,
64
- templateParams: parsedFlags.params,
65
- noOverwriteGlobs: flags['no-overwrite'],
66
- mapBaseUrlToFolder: parsedFlags.mapBaseUrlToFolder,
67
- disabledHooks: parsedFlags.disableHooks,
68
- };
69
- const watchTemplate = flags['watch'];
70
- const genOption = {};
71
- if (flags['map-base-url']) {
72
- genOption.resolve = { resolve: this.getMapBaseUrlToFolderResolver(parsedFlags.mapBaseUrlToFolder) };
73
- }
74
- await this.generate(asyncapi, template, output, options, genOption);
75
- if (watchTemplate) {
76
- const watcherHandler = this.watcherHandler(asyncapi, template, output, options, genOption);
77
- await this.runWatchMode(asyncapi, template, output, watcherHandler);
78
- }
54
+ run() {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ const { args, flags } = yield this.parse(Template); // NOSONAR
57
+ const asyncapi = args['asyncapi'];
58
+ const template = args['template'];
59
+ const output = flags.output || process.cwd();
60
+ const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url']);
61
+ const options = {
62
+ forceWrite: flags['force-write'],
63
+ install: flags.install,
64
+ debug: flags.debug,
65
+ templateParams: parsedFlags.params,
66
+ noOverwriteGlobs: flags['no-overwrite'],
67
+ mapBaseUrlToFolder: parsedFlags.mapBaseUrlToFolder,
68
+ disabledHooks: parsedFlags.disableHooks,
69
+ };
70
+ const watchTemplate = flags['watch'];
71
+ const genOption = {};
72
+ if (flags['map-base-url']) {
73
+ genOption.resolve = { resolve: this.getMapBaseUrlToFolderResolver(parsedFlags.mapBaseUrlToFolder) };
74
+ }
75
+ yield this.generate(asyncapi, template, output, options, genOption);
76
+ if (watchTemplate) {
77
+ const watcherHandler = this.watcherHandler(asyncapi, template, output, options, genOption);
78
+ yield this.runWatchMode(asyncapi, template, output, watcherHandler);
79
+ }
80
+ });
79
81
  }
80
82
  parseFlags(disableHooks, params, mapBaseUrl) {
81
83
  return {
@@ -135,67 +137,71 @@ class Template extends base_1.default {
135
137
  }
136
138
  return mapBaseURLToFolder;
137
139
  }
138
- async generate(asyncapi, template, output, options, genOption) {
139
- let specification;
140
- try {
141
- specification = await (0, SpecificationFile_1.load)(asyncapi);
142
- }
143
- catch (err) {
144
- return this.error(new validation_error_1.ValidationError({
145
- type: 'invalid-file',
146
- filepath: asyncapi,
147
- }), { exit: 1 });
148
- }
149
- const generator = new generator_1.default(template, output || path_1.default.resolve(os_1.default.tmpdir(), 'asyncapi-generator'), options);
150
- core_1.CliUx.ux.action.start('Generation in progress. Keep calm and wait a bit');
151
- try {
152
- await generator.generateFromString(specification.text(), genOption);
153
- core_1.CliUx.ux.action.stop();
154
- }
155
- catch (err) {
156
- core_1.CliUx.ux.action.stop('done\n');
157
- throw new generator_error_1.GeneratorError(err);
158
- }
159
- console.log(`${yellow('Check out your shiny new generated files at ') + magenta(output) + yellow('.')}\n`);
140
+ generate(asyncapi, template, output, options, genOption) {
141
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
142
+ let specification;
143
+ try {
144
+ specification = yield (0, SpecificationFile_1.load)(asyncapi);
145
+ }
146
+ catch (err) {
147
+ return this.error(new validation_error_1.ValidationError({
148
+ type: 'invalid-file',
149
+ filepath: asyncapi,
150
+ }), { exit: 1 });
151
+ }
152
+ const generator = new generator_1.default(template, output || path_1.default.resolve(os_1.default.tmpdir(), 'asyncapi-generator'), options);
153
+ core_1.CliUx.ux.action.start('Generation in progress. Keep calm and wait a bit');
154
+ try {
155
+ yield generator.generateFromString(specification.text(), genOption);
156
+ core_1.CliUx.ux.action.stop();
157
+ }
158
+ catch (err) {
159
+ core_1.CliUx.ux.action.stop('done\n');
160
+ throw new generator_error_1.GeneratorError(err);
161
+ }
162
+ console.log(`${yellow('Check out your shiny new generated files at ') + magenta(output) + yellow('.')}\n`);
163
+ });
160
164
  }
161
- async runWatchMode(asyncapi, template, output, watchHandler) {
162
- const specification = await (0, SpecificationFile_1.load)(asyncapi);
163
- const watchDir = path_1.default.resolve(template);
164
- const outputPath = path_1.default.resolve(watchDir, output);
165
- const transpiledTemplatePath = path_1.default.resolve(watchDir, generator_1.default.TRANSPILED_TEMPLATE_LOCATION);
166
- const ignorePaths = [outputPath, transpiledTemplatePath];
167
- const specificationFile = specification.getFilePath();
168
- // Template name is needed as it is not always a part of the cli commad
169
- // There is a use case that you run generator from a root of the template with `./` path
170
- let templateName = '';
171
- try {
172
- // eslint-disable-next-line
173
- templateName = require(path_1.default.resolve(watchDir, 'package.json')).name;
174
- }
175
- catch (err) {
176
- // intentional
177
- }
178
- let watcher;
179
- if (specificationFile) { // is local AsyncAPI file
180
- this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)} and in the AsyncAPI file ${magenta(specificationFile)}`);
181
- watcher = new generator_2.Watcher([specificationFile, watchDir], ignorePaths);
182
- }
183
- else {
184
- this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)}`);
185
- watcher = new generator_2.Watcher(watchDir, ignorePaths);
186
- }
187
- // Must check template in its installation path in generator to use isLocalTemplate function
188
- if (!await (0, generator_2.isLocalTemplate)(path_1.default.resolve(generator_1.default.DEFAULT_TEMPLATES_DIR, templateName))) {
189
- this.warn(`WARNING: ${template} is a remote template. Changes may be lost on subsequent installations.`);
190
- }
191
- watcher.watch(watchHandler, (paths) => {
192
- this.error(`[WATCHER] Could not find the file path ${paths}, are you sure it still exists? If it has been deleted or moved please rerun the generator.`, {
193
- exit: 1,
165
+ runWatchMode(asyncapi, template, output, watchHandler) {
166
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
167
+ const specification = yield (0, SpecificationFile_1.load)(asyncapi);
168
+ const watchDir = path_1.default.resolve(template);
169
+ const outputPath = path_1.default.resolve(watchDir, output);
170
+ const transpiledTemplatePath = path_1.default.resolve(watchDir, generator_1.default.TRANSPILED_TEMPLATE_LOCATION);
171
+ const ignorePaths = [outputPath, transpiledTemplatePath];
172
+ const specificationFile = specification.getFilePath();
173
+ // Template name is needed as it is not always a part of the cli commad
174
+ // There is a use case that you run generator from a root of the template with `./` path
175
+ let templateName = '';
176
+ try {
177
+ // eslint-disable-next-line
178
+ templateName = require(path_1.default.resolve(watchDir, 'package.json')).name;
179
+ }
180
+ catch (err) {
181
+ // intentional
182
+ }
183
+ let watcher;
184
+ if (specificationFile) { // is local AsyncAPI file
185
+ this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)} and in the AsyncAPI file ${magenta(specificationFile)}`);
186
+ watcher = new generator_2.Watcher([specificationFile, watchDir], ignorePaths);
187
+ }
188
+ else {
189
+ this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)}`);
190
+ watcher = new generator_2.Watcher(watchDir, ignorePaths);
191
+ }
192
+ // Must check template in its installation path in generator to use isLocalTemplate function
193
+ if (!(yield (0, generator_2.isLocalTemplate)(path_1.default.resolve(generator_1.default.DEFAULT_TEMPLATES_DIR, templateName)))) {
194
+ this.warn(`WARNING: ${template} is a remote template. Changes may be lost on subsequent installations.`);
195
+ }
196
+ watcher.watch(watchHandler, (paths) => {
197
+ this.error(`[WATCHER] Could not find the file path ${paths}, are you sure it still exists? If it has been deleted or moved please rerun the generator.`, {
198
+ exit: 1,
199
+ });
194
200
  });
195
201
  });
196
202
  }
197
203
  watcherHandler(asyncapi, template, output, options, genOption) {
198
- return async (changedFiles) => {
204
+ return (changedFiles) => tslib_1.__awaiter(this, void 0, void 0, function* () {
199
205
  console.clear();
200
206
  console.log('[WATCHER] Change detected');
201
207
  for (const [, value] of Object.entries(changedFiles)) {
@@ -216,12 +222,12 @@ class Template extends base_1.default {
216
222
  this.log(`\t${magenta(value.path)} was ${eventText}`);
217
223
  }
218
224
  try {
219
- await this.generate(asyncapi, template, output, options, genOption);
225
+ yield this.generate(asyncapi, template, output, options, genOption);
220
226
  }
221
227
  catch (err) {
222
228
  throw new generator_error_1.GeneratorError(err);
223
229
  }
224
- };
230
+ });
225
231
  }
226
232
  }
227
233
  exports.default = Template;
@@ -4,9 +4,11 @@ const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
5
  const core_1 = require("@oclif/core");
6
6
  class Generate extends base_1.default {
7
- async run() {
8
- const help = new core_1.Help(this.config);
9
- help.showHelp(['generate', '--help']);
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(['generate', '--help']);
11
+ });
10
12
  }
11
13
  }
12
14
  exports.default = Generate;
@@ -17,90 +17,92 @@ var Languages;
17
17
  })(Languages || (Languages = {}));
18
18
  const possibleLanguageValues = Object.values(Languages).join(', ');
19
19
  class Models extends base_1.default {
20
- async run() {
21
- const passedArguments = await this.parse(Models);
22
- const { namespace, packageName, output } = passedArguments.flags;
23
- const { language, file } = passedArguments.args;
24
- const inputFile = await (0, SpecificationFile_1.load)(file) || await (0, SpecificationFile_1.load)();
25
- const parsedInput = await (0, parser_1.parse)(inputFile.text());
26
- modelina_1.Logger.setLogger({
27
- info: (message) => {
28
- this.log(message);
29
- },
30
- debug: (message) => {
31
- this.debug(message);
32
- },
33
- warn: (message) => {
34
- this.warn(message);
35
- },
36
- error: (message) => {
37
- this.error(message);
38
- },
39
- });
40
- let fileGenerator;
41
- let fileOptions = {};
42
- switch (language) {
43
- case Languages.typescript:
44
- fileGenerator = new modelina_1.TypeScriptFileGenerator();
45
- break;
46
- case Languages.csharp:
47
- if (namespace === undefined) {
48
- throw new Error('In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
49
- }
50
- fileGenerator = new modelina_1.CSharpFileGenerator();
51
- fileOptions = {
52
- namespace
53
- };
54
- break;
55
- case Languages.golang:
56
- if (packageName === undefined) {
57
- throw new Error('In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
58
- }
59
- fileGenerator = new modelina_1.GoFileGenerator();
60
- fileOptions = {
61
- packageName
62
- };
63
- break;
64
- case Languages.java:
65
- if (packageName === undefined) {
66
- throw new Error('In order to generate models to Java, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
67
- }
68
- fileGenerator = new modelina_1.JavaFileGenerator();
69
- fileOptions = {
70
- packageName
71
- };
72
- break;
73
- case Languages.javascript:
74
- fileGenerator = new modelina_1.JavaScriptFileGenerator();
75
- break;
76
- case Languages.dart:
77
- if (packageName === undefined) {
78
- throw new Error('In order to generate models to Dart, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
79
- }
80
- fileGenerator = new modelina_1.DartFileGenerator();
81
- fileOptions = {
82
- packageName
83
- };
84
- break;
85
- default:
86
- throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
87
- }
88
- let models;
89
- if (output) {
90
- models = await fileGenerator.generateToFiles(parsedInput, output, { ...fileOptions, });
91
- const generatedModels = models.map((model) => { return model.modelName; });
92
- this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`);
93
- }
94
- else {
95
- models = await fileGenerator.generateCompleteModels(parsedInput, { ...fileOptions });
96
- const generatedModels = models.map((model) => {
97
- return `
20
+ run() {
21
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
+ const passedArguments = yield this.parse(Models);
23
+ const { namespace, packageName, output } = passedArguments.flags;
24
+ const { language, file } = passedArguments.args;
25
+ const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
26
+ const parsedInput = yield (0, parser_1.parse)(inputFile.text());
27
+ modelina_1.Logger.setLogger({
28
+ info: (message) => {
29
+ this.log(message);
30
+ },
31
+ debug: (message) => {
32
+ this.debug(message);
33
+ },
34
+ warn: (message) => {
35
+ this.warn(message);
36
+ },
37
+ error: (message) => {
38
+ this.error(message);
39
+ },
40
+ });
41
+ let fileGenerator;
42
+ let fileOptions = {};
43
+ switch (language) {
44
+ case Languages.typescript:
45
+ fileGenerator = new modelina_1.TypeScriptFileGenerator();
46
+ break;
47
+ case Languages.csharp:
48
+ if (namespace === undefined) {
49
+ throw new Error('In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.');
50
+ }
51
+ fileGenerator = new modelina_1.CSharpFileGenerator();
52
+ fileOptions = {
53
+ namespace
54
+ };
55
+ break;
56
+ case Languages.golang:
57
+ if (packageName === undefined) {
58
+ throw new Error('In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
59
+ }
60
+ fileGenerator = new modelina_1.GoFileGenerator();
61
+ fileOptions = {
62
+ packageName
63
+ };
64
+ break;
65
+ case Languages.java:
66
+ if (packageName === undefined) {
67
+ throw new Error('In order to generate models to Java, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
68
+ }
69
+ fileGenerator = new modelina_1.JavaFileGenerator();
70
+ fileOptions = {
71
+ packageName
72
+ };
73
+ break;
74
+ case Languages.javascript:
75
+ fileGenerator = new modelina_1.JavaScriptFileGenerator();
76
+ break;
77
+ case Languages.dart:
78
+ if (packageName === undefined) {
79
+ throw new Error('In order to generate models to Dart, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.');
80
+ }
81
+ fileGenerator = new modelina_1.DartFileGenerator();
82
+ fileOptions = {
83
+ packageName
84
+ };
85
+ break;
86
+ default:
87
+ throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
88
+ }
89
+ let models;
90
+ if (output) {
91
+ models = yield fileGenerator.generateToFiles(parsedInput, output, Object.assign({}, fileOptions));
92
+ const generatedModels = models.map((model) => { return model.modelName; });
93
+ this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`);
94
+ }
95
+ else {
96
+ models = yield fileGenerator.generateCompleteModels(parsedInput, Object.assign({}, fileOptions));
97
+ const generatedModels = models.map((model) => {
98
+ return `
98
99
  ## Model name: ${model.modelName}
99
100
  ${model.result}
100
101
  `;
101
- });
102
- this.log(`Successfully generated the following models: ${generatedModels.join('\n')}`);
103
- }
102
+ });
103
+ this.log(`Successfully generated the following models: ${generatedModels.join('\n')}`);
104
+ }
105
+ });
104
106
  }
105
107
  }
106
108
  exports.default = Models;
@@ -11,107 +11,113 @@ 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
13
  class New extends base_1.default {
14
- async run() {
15
- const { flags } = await this.parse(New); // NOSONAR
16
- const isTTY = process.stdout.isTTY;
17
- if (!flags['no-tty'] && isTTY) {
18
- return this.runInteractive();
19
- }
20
- const fileName = flags['file-name'] || DEFAULT_ASYNCAPI_FILE_NAME;
21
- const template = flags['example'] || DEFAULT_ASYNCAPI_TEMPLATE;
22
- await this.createAsyncapiFile(fileName, template);
23
- if (flags.studio) {
24
- if (isTTY) {
25
- (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
14
+ run() {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const { flags } = yield this.parse(New); // NOSONAR
17
+ const isTTY = process.stdout.isTTY;
18
+ if (!flags['no-tty'] && isTTY) {
19
+ return this.runInteractive();
26
20
  }
27
- else {
28
- this.warn('Warning: --studio flag was passed but the terminal is not interactive. Ignoring...');
21
+ const fileName = flags['file-name'] || DEFAULT_ASYNCAPI_FILE_NAME;
22
+ const template = flags['example'] || DEFAULT_ASYNCAPI_TEMPLATE;
23
+ yield this.createAsyncapiFile(fileName, template);
24
+ if (flags.studio) {
25
+ if (isTTY) {
26
+ (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
27
+ }
28
+ else {
29
+ this.warn('Warning: --studio flag was passed but the terminal is not interactive. Ignoring...');
30
+ }
29
31
  }
30
- }
32
+ });
31
33
  }
32
34
  /* eslint-disable sonarjs/cognitive-complexity */
33
- async runInteractive() {
34
- const { flags } = await this.parse(New); // NOSONAR
35
- let fileName = flags['file-name'];
36
- let selectedTemplate = flags['example'];
37
- let openStudio = flags.studio;
38
- let examples = [];
39
- const questions = [];
40
- if (!fileName) {
41
- questions.push({
42
- name: 'filename',
43
- message: 'name of the file?',
44
- type: 'input',
45
- default: DEFAULT_ASYNCAPI_FILE_NAME,
46
- });
47
- }
48
- try {
49
- const exampleFiles = await readFile((0, path_1.resolve)(__dirname, '../../assets/examples/examples.json'), { encoding: 'utf8' });
50
- examples = JSON.parse(exampleFiles);
51
- }
52
- catch (error) {
53
- // no examples found
54
- }
55
- if (!selectedTemplate && examples.length > 0) {
56
- questions.push({
57
- name: 'use-example',
58
- message: 'would you like to start your new file from one of our examples?',
59
- type: 'confirm',
60
- default: true,
61
- });
62
- questions.push({
63
- type: 'list',
64
- name: 'selectedTemplate',
65
- message: 'What example would you like to use?',
66
- choices: examples,
67
- when: (answers) => {
68
- return answers['use-example'];
69
- },
70
- });
71
- }
72
- if (openStudio === undefined) {
73
- questions.push({
74
- name: 'studio',
75
- message: 'open in Studio?',
76
- type: 'confirm',
77
- default: true,
78
- });
79
- }
80
- if (questions.length) {
81
- const answers = await inquirer.prompt(questions);
35
+ runInteractive() {
36
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
37
+ const { flags } = yield this.parse(New); // NOSONAR
38
+ let fileName = flags['file-name'];
39
+ let selectedTemplate = flags['example'];
40
+ let openStudio = flags.studio;
41
+ let examples = [];
42
+ const questions = [];
82
43
  if (!fileName) {
83
- fileName = answers.filename;
44
+ questions.push({
45
+ name: 'filename',
46
+ message: 'name of the file?',
47
+ type: 'input',
48
+ default: DEFAULT_ASYNCAPI_FILE_NAME,
49
+ });
50
+ }
51
+ try {
52
+ const exampleFiles = yield readFile((0, path_1.resolve)(__dirname, '../../assets/examples/examples.json'), { encoding: 'utf8' });
53
+ examples = JSON.parse(exampleFiles);
84
54
  }
85
- if (!selectedTemplate) {
86
- selectedTemplate = answers.selectedTemplate;
55
+ catch (error) {
56
+ // no examples found
57
+ }
58
+ if (!selectedTemplate && examples.length > 0) {
59
+ questions.push({
60
+ name: 'use-example',
61
+ message: 'would you like to start your new file from one of our examples?',
62
+ type: 'confirm',
63
+ default: true,
64
+ });
65
+ questions.push({
66
+ type: 'list',
67
+ name: 'selectedTemplate',
68
+ message: 'What example would you like to use?',
69
+ choices: examples,
70
+ when: (answers) => {
71
+ return answers['use-example'];
72
+ },
73
+ });
87
74
  }
88
75
  if (openStudio === undefined) {
89
- openStudio = answers.studio;
76
+ questions.push({
77
+ name: 'studio',
78
+ message: 'open in Studio?',
79
+ type: 'confirm',
80
+ default: true,
81
+ });
82
+ }
83
+ if (questions.length) {
84
+ const answers = yield inquirer.prompt(questions);
85
+ if (!fileName) {
86
+ fileName = answers.filename;
87
+ }
88
+ if (!selectedTemplate) {
89
+ selectedTemplate = answers.selectedTemplate;
90
+ }
91
+ if (openStudio === undefined) {
92
+ openStudio = answers.studio;
93
+ }
90
94
  }
91
- }
92
- fileName = fileName || DEFAULT_ASYNCAPI_FILE_NAME;
93
- selectedTemplate = selectedTemplate || DEFAULT_ASYNCAPI_TEMPLATE;
94
- await this.createAsyncapiFile(fileName, selectedTemplate);
95
- if (openStudio) {
96
- (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
97
- }
95
+ fileName = fileName || DEFAULT_ASYNCAPI_FILE_NAME;
96
+ selectedTemplate = selectedTemplate || DEFAULT_ASYNCAPI_TEMPLATE;
97
+ yield this.createAsyncapiFile(fileName, selectedTemplate);
98
+ if (openStudio) {
99
+ (0, Studio_1.start)(fileName, flags.port || Studio_1.DEFAULT_PORT);
100
+ }
101
+ });
98
102
  }
99
- async createAsyncapiFile(fileName, selectedTemplate) {
100
- const asyncApiFile = await readFile((0, path_1.resolve)(__dirname, '../../assets/examples/', selectedTemplate), { encoding: 'utf8' });
101
- const fileNameHasFileExtension = fileName.includes('.');
102
- const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`;
103
- try {
104
- const content = await readFile(fileNameToWriteToDisk, { encoding: 'utf8' });
105
- if (content !== '') {
106
- console.log(`File ${fileNameToWriteToDisk} already exists. Ignoring...`);
107
- return;
103
+ createAsyncapiFile(fileName, selectedTemplate) {
104
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
105
+ const asyncApiFile = yield readFile((0, path_1.resolve)(__dirname, '../../assets/examples/', selectedTemplate), { encoding: 'utf8' });
106
+ const fileNameHasFileExtension = fileName.includes('.');
107
+ const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`;
108
+ try {
109
+ const content = yield readFile(fileNameToWriteToDisk, { encoding: 'utf8' });
110
+ if (content !== '') {
111
+ console.log(`File ${fileNameToWriteToDisk} already exists. Ignoring...`);
112
+ return;
113
+ }
114
+ }
115
+ catch (e) {
116
+ // File does not exist. Proceed creating it...
108
117
  }
109
- }
110
- catch (e) {
111
- // File does not exist. Proceed creating it...
112
- }
113
- await writeFile(fileNameToWriteToDisk, asyncApiFile, { encoding: 'utf8' });
114
- console.log(`Created file ${fileNameToWriteToDisk}...`);
118
+ yield writeFile(fileNameToWriteToDisk, asyncApiFile, { encoding: 'utf8' });
119
+ console.log(`Created file ${fileNameToWriteToDisk}...`);
120
+ });
115
121
  }
116
122
  }
117
123
  exports.default = New;
@@ -4,9 +4,11 @@ const tslib_1 = require("tslib");
4
4
  const base_1 = tslib_1.__importDefault(require("../../base"));
5
5
  const core_1 = require("@oclif/core");
6
6
  class Start extends base_1.default {
7
- async run() {
8
- const help = new core_1.Help(this.config);
9
- help.showHelp(['start', '--help']);
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(['start', '--help']);
11
+ });
10
12
  }
11
13
  }
12
14
  exports.default = Start;