@asyncapi/cli 1.8.4 → 1.9.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/base.js CHANGED
@@ -8,6 +8,7 @@ const path_1 = require("path");
8
8
  const fs_extra_1 = require("fs-extra");
9
9
  const fs_1 = require("fs");
10
10
  const uuid_1 = require("uuid");
11
+ const os_1 = require("os");
11
12
  const { readFile, writeFile } = fs_1.promises;
12
13
  class DiscardSink {
13
14
  send() {
@@ -109,7 +110,7 @@ class default_1 extends core_1.Command {
109
110
  recorderFromEnv(prefix) {
110
111
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
111
112
  let sink = new DiscardSink();
112
- const analyticsConfigFile = (0, path_1.join)(process.cwd(), '.asyncapi-analytics');
113
+ const analyticsConfigFile = (0, path_1.join)((0, os_1.homedir)(), '.asyncapi-analytics');
113
114
  if (!(0, fs_extra_1.existsSync)(analyticsConfigFile)) {
114
115
  yield writeFile(analyticsConfigFile, JSON.stringify({ analyticsEnabled: 'true', infoMessageShown: 'false', userID: (0, uuid_1.v4)() }), { encoding: 'utf8' });
115
116
  }
@@ -128,7 +129,7 @@ class default_1 extends core_1.Command {
128
129
  // NODE_ENV set to `production` in bin/run_bin, which is specified in 'bin' package.json section
129
130
  sink = new asyncapi_adoption_metrics_1.NewRelicSink(process.env.ASYNCAPI_METRICS_NEWRELIC_KEY || 'eu01xx73a8521047150dd9414f6aedd2FFFFNRAL');
130
131
  if (analyticsConfigFileContent.infoMessageShown === 'false') {
131
- this.log('\nAsyncAPI anonymously tracks command executions to improve the specification and tools, ensuring no sensitive data reaches our servers. It aids in comprehending how AsyncAPI tools are used and adopted, facilitating ongoing improvements to our specifications and tools.\n\nTo disable tracking, please run the following command:\n asyncapi config analytics --disable\n\nOnce disabled, if you want to enable tracking back again then run:\n asyncapi config analytics --enable');
132
+ this.log('\nAsyncAPI anonymously tracks command executions to improve the specification and tools, ensuring no sensitive data reaches our servers. It aids in comprehending how AsyncAPI tools are used and adopted, facilitating ongoing improvements to our specifications and tools.\n\nTo disable tracking, please run the following command:\n asyncapi config analytics --disable\n\nOnce disabled, if you want to enable tracking back again then run:\n asyncapi config analytics --enable\n');
132
133
  analyticsConfigFileContent.infoMessageShown = 'true';
133
134
  yield writeFile(analyticsConfigFile, JSON.stringify(analyticsConfigFileContent), { encoding: 'utf8' });
134
135
  }
@@ -5,12 +5,13 @@ const core_1 = require("@oclif/core");
5
5
  const path_1 = require("path");
6
6
  const base_1 = tslib_1.__importDefault(require("../../base"));
7
7
  const fs_1 = require("fs");
8
+ const os_1 = require("os");
8
9
  const { readFile, writeFile } = fs_1.promises;
9
10
  class Analytics extends base_1.default {
10
11
  run() {
11
12
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
13
  const { flags } = yield this.parse(Analytics);
13
- const analyticsConfigFile = (0, path_1.join)(process.cwd(), '.asyncapi-analytics');
14
+ const analyticsConfigFile = (0, path_1.join)((0, os_1.homedir)(), '.asyncapi-analytics');
14
15
  try {
15
16
  const analyticsConfigFileContent = JSON.parse(yield readFile((0, path_1.resolve)(analyticsConfigFile), { encoding: 'utf8' }));
16
17
  if (flags.disable) {
@@ -30,7 +31,7 @@ class Analytics extends base_1.default {
30
31
  catch (e) {
31
32
  switch (e.code) {
32
33
  case 'ENOENT':
33
- this.error(`Unable to access the analytics configuration file. We tried to access the ".asyncapi-analytics" file in your current working directory ("${process.cwd()}") but the file could not be found.`);
34
+ this.error(`Unable to access the analytics configuration file. We tried to access the ".asyncapi-analytics" file in your user's home directory ("${(0, os_1.homedir)()}") but the file could not be found.`);
34
35
  break;
35
36
  case 'EEXIST':
36
37
  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.`);
@@ -7,6 +7,7 @@ export default class Template extends Command {
7
7
  static flags: {
8
8
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
9
9
  'disable-hook': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined>;
10
+ 'no-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
11
  install: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
12
  debug: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
13
  'no-overwrite': import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined>;
@@ -19,10 +20,10 @@ export default class Template extends Command {
19
20
  static args: {
20
21
  name: string;
21
22
  description: string;
22
- required: boolean;
23
23
  }[];
24
24
  parser: Parser;
25
25
  run(): Promise<void>;
26
+ private parseArgs;
26
27
  private parseFlags;
27
28
  private paramParser;
28
29
  private disableHooksParser;
@@ -15,10 +15,8 @@ const generator_2 = require("../../utils/generator");
15
15
  const validation_error_1 = require("../../errors/validation-error");
16
16
  const generator_error_1 = require("../../errors/generator-error");
17
17
  const parser_1 = require("@asyncapi/parser");
18
- const red = (text) => `\x1b[31m${text}\x1b[0m`;
19
- const magenta = (text) => `\x1b[35m${text}\x1b[0m`;
20
- const yellow = (text) => `\x1b[33m${text}\x1b[0m`;
21
- const green = (text) => `\x1b[32m${text}\x1b[0m`;
18
+ const prompts_1 = require("@clack/prompts");
19
+ const picocolors_1 = require("picocolors");
22
20
  const templatesNotSupportingV3 = {
23
21
  '@asyncapi/minimaltemplate': 'some link',
24
22
  '@asyncapi/dotnet-nats-template': 'https://github.com/asyncapi/dotnet-nats-template/issues/384',
@@ -78,9 +76,16 @@ class Template extends base_1.default {
78
76
  run() {
79
77
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
80
78
  const { args, flags } = yield this.parse(Template); // NOSONAR
81
- const asyncapi = args['asyncapi'];
82
- const template = args['template'];
83
- const output = flags.output || process.cwd();
79
+ const interactive = !flags['no-interactive'];
80
+ let { asyncapi, template } = args;
81
+ let output = flags.output;
82
+ if (interactive) {
83
+ (0, prompts_1.intro)((0, picocolors_1.inverse)('AsyncAPI Generator'));
84
+ const parsedArgs = yield this.parseArgs(args, output);
85
+ asyncapi = parsedArgs.asyncapi;
86
+ template = parsedArgs.template;
87
+ output = parsedArgs.output;
88
+ }
84
89
  const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url']);
85
90
  const options = {
86
91
  forceWrite: flags['force-write'],
@@ -105,13 +110,63 @@ class Template extends base_1.default {
105
110
  this.error(`${template} template does not support AsyncAPI v3 documents, please checkout ${v3IssueLink}`);
106
111
  }
107
112
  }
108
- yield this.generate(asyncapi, template, output, options, genOption);
113
+ yield this.generate(asyncapi, template, output, options, genOption, interactive);
109
114
  if (watchTemplate) {
110
- const watcherHandler = this.watcherHandler(asyncapi, template, output, options, genOption);
115
+ const watcherHandler = this.watcherHandler(asyncapi, template, output, options, genOption, interactive);
111
116
  yield this.runWatchMode(asyncapi, template, output, watcherHandler);
112
117
  }
113
118
  });
114
119
  }
120
+ parseArgs(args, output) {
121
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
122
+ let asyncapi = args['asyncapi'];
123
+ let template = args['template'];
124
+ const cancellationMessage = 'Operation cancelled';
125
+ if (!asyncapi) {
126
+ asyncapi = yield (0, prompts_1.text)({
127
+ message: 'Please provide the path to the AsyncAPI document',
128
+ placeholder: 'asyncapi.yaml',
129
+ defaultValue: 'asyncapi.yaml',
130
+ validate(value) {
131
+ if (!value) {
132
+ return 'The path to the AsyncAPI document is required';
133
+ }
134
+ else if (!fs_1.default.existsSync(value)) {
135
+ return 'The file does not exist';
136
+ }
137
+ }
138
+ });
139
+ }
140
+ if ((0, prompts_1.isCancel)(asyncapi)) {
141
+ this.error(cancellationMessage, { exit: 1 });
142
+ }
143
+ if (!template) {
144
+ template = yield (0, prompts_1.text)({
145
+ message: 'Please provide the name of the generator template',
146
+ placeholder: '@asyncapi/html-template',
147
+ defaultValue: '@asyncapi/html-template',
148
+ });
149
+ }
150
+ if (!output) {
151
+ output = (yield (0, prompts_1.text)({
152
+ message: 'Please provide the output directory',
153
+ placeholder: './docs',
154
+ validate(value) {
155
+ if (!value) {
156
+ return 'The output directory is required';
157
+ }
158
+ else if (typeof value !== 'string') {
159
+ return 'The output directory must be a string';
160
+ }
161
+ }
162
+ }));
163
+ }
164
+ if ((0, prompts_1.isCancel)(output) || (0, prompts_1.isCancel)(template)) {
165
+ this.error(cancellationMessage, { exit: 1 });
166
+ }
167
+ return { asyncapi, template, output };
168
+ });
169
+ }
115
170
  parseFlags(disableHooks, params, mapBaseUrl) {
116
171
  return {
117
172
  params: this.paramParser(params),
@@ -170,7 +225,7 @@ class Template extends base_1.default {
170
225
  }
171
226
  return mapBaseURLToFolder;
172
227
  }
173
- generate(asyncapi, template, output, options, genOption) {
228
+ generate(asyncapi, template, output, options, genOption, interactive = true) {
174
229
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
175
230
  let specification;
176
231
  try {
@@ -183,16 +238,16 @@ class Template extends base_1.default {
183
238
  }), { exit: 1 });
184
239
  }
185
240
  const generator = new generator_1.default(template, output || path_1.default.resolve(os_1.default.tmpdir(), 'asyncapi-generator'), options);
186
- core_1.CliUx.ux.action.start('Generation in progress. Keep calm and wait a bit');
241
+ const s = interactive ? (0, prompts_1.spinner)() : { start: () => null, stop: (string) => console.log(string) };
242
+ s.start('Generation in progress. Keep calm and wait a bit');
187
243
  try {
188
244
  yield generator.generateFromString(specification.text(), genOption);
189
- core_1.CliUx.ux.action.stop();
190
245
  }
191
246
  catch (err) {
192
- core_1.CliUx.ux.action.stop('done\n');
247
+ s.stop('Generation failed');
193
248
  throw new generator_error_1.GeneratorError(err);
194
249
  }
195
- console.log(`${yellow('Check out your shiny new generated files at ') + magenta(output) + yellow('.')}\n`);
250
+ s.stop(`${(0, picocolors_1.yellow)('Check out your shiny new generated files at ') + (0, picocolors_1.magenta)(output) + (0, picocolors_1.yellow)('.')}\n`);
196
251
  });
197
252
  }
198
253
  runWatchMode(asyncapi, template, output, watchHandler) {
@@ -215,11 +270,11 @@ class Template extends base_1.default {
215
270
  }
216
271
  let watcher;
217
272
  if (specificationFile) { // is local AsyncAPI file
218
- this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)} and in the AsyncAPI file ${magenta(specificationFile)}`);
273
+ this.log(`[WATCHER] Watching for changes in the template directory ${(0, picocolors_1.magenta)(watchDir)} and in the AsyncAPI file ${(0, picocolors_1.magenta)(specificationFile)}`);
219
274
  watcher = new generator_2.Watcher([specificationFile, watchDir], ignorePaths);
220
275
  }
221
276
  else {
222
- this.log(`[WATCHER] Watching for changes in the template directory ${magenta(watchDir)}`);
277
+ this.log(`[WATCHER] Watching for changes in the template directory ${(0, picocolors_1.magenta)(watchDir)}`);
223
278
  watcher = new generator_2.Watcher(watchDir, ignorePaths);
224
279
  }
225
280
  // Must check template in its installation path in generator to use isLocalTemplate function
@@ -233,7 +288,7 @@ class Template extends base_1.default {
233
288
  });
234
289
  });
235
290
  }
236
- watcherHandler(asyncapi, template, output, options, genOption) {
291
+ watcherHandler(asyncapi, template, output, options, genOption, interactive) {
237
292
  return (changedFiles) => tslib_1.__awaiter(this, void 0, void 0, function* () {
238
293
  console.clear();
239
294
  console.log('[WATCHER] Change detected');
@@ -241,21 +296,21 @@ class Template extends base_1.default {
241
296
  let eventText;
242
297
  switch (value.eventType) {
243
298
  case 'changed':
244
- eventText = green(value.eventType);
299
+ eventText = (0, picocolors_1.green)(value.eventType);
245
300
  break;
246
301
  case 'removed':
247
- eventText = red(value.eventType);
302
+ eventText = (0, picocolors_1.red)(value.eventType);
248
303
  break;
249
304
  case 'renamed':
250
- eventText = yellow(value.eventType);
305
+ eventText = (0, picocolors_1.yellow)(value.eventType);
251
306
  break;
252
307
  default:
253
- eventText = yellow(value.eventType);
308
+ eventText = (0, picocolors_1.yellow)(value.eventType);
254
309
  }
255
- this.log(`\t${magenta(value.path)} was ${eventText}`);
310
+ this.log(`\t${(0, picocolors_1.magenta)(value.path)} was ${eventText}`);
256
311
  }
257
312
  try {
258
- yield this.generate(asyncapi, template, output, options, genOption);
313
+ yield this.generate(asyncapi, template, output, options, genOption, interactive);
259
314
  }
260
315
  catch (err) {
261
316
  throw new generator_error_1.GeneratorError(err);
@@ -275,6 +330,11 @@ Template.flags = {
275
330
  description: 'Disable a specific hook type or hooks from a given hook type',
276
331
  multiple: true
277
332
  }),
333
+ 'no-interactive': core_1.Flags.boolean({
334
+ description: 'Disable interactive mode and run with the provided flags.',
335
+ required: false,
336
+ default: false,
337
+ }),
278
338
  install: core_1.Flags.boolean({
279
339
  char: 'i',
280
340
  default: false,
@@ -307,6 +367,6 @@ Template.flags = {
307
367
  }),
308
368
  };
309
369
  Template.args = [
310
- { name: 'asyncapi', description: '- Local path, url or context-name pointing to AsyncAPI file', required: true },
311
- { name: 'template', description: '- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template', required: true }
370
+ { name: 'asyncapi', description: '- Local path, url or context-name pointing to AsyncAPI file' },
371
+ { name: 'template', description: '- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template' },
312
372
  ];
@@ -5,11 +5,9 @@ export default class Models extends Command {
5
5
  name: string;
6
6
  description: string;
7
7
  options: string[];
8
- required: boolean;
9
8
  } | {
10
9
  name: string;
11
10
  description: string;
12
- required: boolean;
13
11
  options?: undefined;
14
12
  })[];
15
13
  static flags: {
@@ -17,6 +15,7 @@ export default class Models extends Command {
17
15
  'diagnostics-format': import("@oclif/core/lib/interfaces").OptionFlag<import("@stoplight/spectral-cli/dist/services/config").OutputFormat>;
18
16
  'fail-severity': import("@oclif/core/lib/interfaces").OptionFlag<import("../../parser").SeverityKind>;
19
17
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
18
+ 'no-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
19
  output: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
21
20
  /**
22
21
  * TypeScript specific options
@@ -54,4 +53,5 @@ export default class Models extends Command {
54
53
  csharpSystemJson: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
55
54
  };
56
55
  run(): Promise<void>;
56
+ private parseArgs;
57
57
  }
@@ -7,6 +7,8 @@ const multi_parser_1 = require("@smoya/multi-parser");
7
7
  const base_1 = tslib_1.__importDefault(require("../../base"));
8
8
  const SpecificationFile_1 = require("../../models/SpecificationFile");
9
9
  const parser_1 = require("../../parser");
10
+ const prompts_1 = require("@clack/prompts");
11
+ const picocolors_1 = require("picocolors");
10
12
  var Languages;
11
13
  (function (Languages) {
12
14
  Languages["typescript"] = "typescript";
@@ -27,8 +29,17 @@ class Models extends base_1.default {
27
29
  run() {
28
30
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
29
31
  const { args, flags } = yield this.parse(Models);
30
- const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, tsMarshalling, tsExampleInstance, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, javaIncludeComments, javaJackson, javaConstraints, output } = flags;
31
- const { language, file } = args;
32
+ const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, tsMarshalling, tsExampleInstance, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, javaIncludeComments, javaJackson, javaConstraints } = flags;
33
+ let { language, file } = args;
34
+ let output = flags.output || 'stdout';
35
+ const interactive = !flags['no-interactive'];
36
+ if (!interactive) {
37
+ (0, prompts_1.intro)((0, picocolors_1.inverse)('AsyncAPI Generate Models'));
38
+ const parsedArgs = yield this.parseArgs(args, output);
39
+ language = parsedArgs.language;
40
+ file = parsedArgs.file;
41
+ output = parsedArgs.output;
42
+ }
32
43
  const inputFile = (yield (0, SpecificationFile_1.load)(file)) || (yield (0, SpecificationFile_1.load)());
33
44
  if (inputFile.isAsyncAPI3()) {
34
45
  this.error('Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376');
@@ -202,20 +213,64 @@ class Models extends base_1.default {
202
213
  default:
203
214
  throw new Error(`Could not determine generator for language ${language}, are you using one of the following values ${possibleLanguageValues}?`);
204
215
  }
205
- if (output) {
216
+ const s = (0, prompts_1.spinner)();
217
+ s.start('Generating models...');
218
+ if (output !== 'stdout') {
206
219
  const models = yield fileGenerator.generateToFiles(convertedDoc, output, Object.assign({}, fileOptions));
207
220
  const generatedModels = models.map((model) => { return model.modelName; });
208
- this.log(`Successfully generated the following models: ${generatedModels.join(', ')}`);
221
+ s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${generatedModels.join(', ')}`));
209
222
  return;
210
223
  }
211
224
  const models = yield fileGenerator.generateCompleteModels(convertedDoc, Object.assign({}, fileOptions));
212
225
  const generatedModels = models.map((model) => {
213
226
  return `
214
- ## Model name: ${model.modelName}
215
- ${model.result}
216
- `;
227
+ ## Model name: ${model.modelName}
228
+ ${model.result}
229
+ `;
217
230
  });
218
- this.log(`Successfully generated the following models: ${generatedModels.join('\n')}`);
231
+ s.stop((0, picocolors_1.green)(`Successfully generated the following models: ${generatedModels.join('\n')}`));
232
+ });
233
+ }
234
+ parseArgs(args, output) {
235
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
236
+ let { language, file } = args;
237
+ let askForOutput = false;
238
+ const operationCancelled = 'Operation cancelled by the user.';
239
+ if (!language) {
240
+ language = yield (0, prompts_1.select)({
241
+ message: 'Select the language you want to generate models for',
242
+ options: Object.keys(Languages).map((key) => ({ value: key, label: key, hint: Languages[key] })),
243
+ });
244
+ askForOutput = true;
245
+ }
246
+ if ((0, prompts_1.isCancel)(language)) {
247
+ (0, prompts_1.cancel)(operationCancelled);
248
+ this.exit();
249
+ }
250
+ if (!file) {
251
+ file = yield (0, prompts_1.text)({
252
+ message: 'Enter the path or URL to the AsyncAPI document',
253
+ defaultValue: 'asyncapi.yaml',
254
+ placeholder: 'asyncapi.yaml',
255
+ });
256
+ askForOutput = true;
257
+ }
258
+ if ((0, prompts_1.isCancel)(file)) {
259
+ (0, prompts_1.cancel)(operationCancelled);
260
+ this.exit();
261
+ }
262
+ if (!output && askForOutput) {
263
+ output = (yield (0, prompts_1.text)({
264
+ message: 'Enter the output directory or stdout to write the models to',
265
+ defaultValue: 'stdout',
266
+ placeholder: 'stdout',
267
+ }));
268
+ }
269
+ if ((0, prompts_1.isCancel)(output)) {
270
+ (0, prompts_1.cancel)(operationCancelled);
271
+ this.exit();
272
+ }
273
+ return { language, file, output: output || 'stdout' };
219
274
  });
220
275
  }
221
276
  }
@@ -226,11 +281,14 @@ Models.args = [
226
281
  name: 'language',
227
282
  description: 'The language you want the typed models generated for.',
228
283
  options: Object.keys(Languages),
229
- required: true
230
284
  },
231
- { name: 'file', description: 'Path or URL to the AsyncAPI document, or context-name', required: true },
285
+ { name: 'file', description: 'Path or URL to the AsyncAPI document, or context-name' },
232
286
  ];
233
- Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), output: core_1.Flags.string({
287
+ Models.flags = Object.assign({ help: core_1.Flags.help({ char: 'h' }), 'no-interactive': core_1.Flags.boolean({
288
+ description: 'Disable interactive mode and run with the provided flags.',
289
+ required: false,
290
+ default: false,
291
+ }), output: core_1.Flags.string({
234
292
  char: 'o',
235
293
  description: 'The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.',
236
294
  required: false
@@ -111,27 +111,27 @@ exports.default = SpecificationFile;
111
111
  /* eslint-disable sonarjs/cognitive-complexity */
112
112
  function load(filePathOrContextName, loadType) {
113
113
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
114
- if (filePathOrContextName) {
115
- if (loadType === null || loadType === void 0 ? void 0 : loadType.file) {
114
+ try {
115
+ if (filePathOrContextName) {
116
+ if (loadType === null || loadType === void 0 ? void 0 : loadType.file) {
117
+ return Specification.fromFile(filePathOrContextName);
118
+ }
119
+ if (loadType === null || loadType === void 0 ? void 0 : loadType.context) {
120
+ return loadFromContext(filePathOrContextName);
121
+ }
122
+ if (loadType === null || loadType === void 0 ? void 0 : loadType.url) {
123
+ return Specification.fromURL(filePathOrContextName);
124
+ }
125
+ const type = yield nameType(filePathOrContextName);
126
+ if (type === TYPE_CONTEXT_NAME) {
127
+ return loadFromContext(filePathOrContextName);
128
+ }
129
+ if (type === TYPE_URL) {
130
+ return Specification.fromURL(filePathOrContextName);
131
+ }
132
+ yield fileExists(filePathOrContextName);
116
133
  return Specification.fromFile(filePathOrContextName);
117
134
  }
118
- if (loadType === null || loadType === void 0 ? void 0 : loadType.context) {
119
- return loadFromContext(filePathOrContextName);
120
- }
121
- if (loadType === null || loadType === void 0 ? void 0 : loadType.url) {
122
- return Specification.fromURL(filePathOrContextName);
123
- }
124
- const type = yield nameType(filePathOrContextName);
125
- if (type === TYPE_CONTEXT_NAME) {
126
- return loadFromContext(filePathOrContextName);
127
- }
128
- if (type === TYPE_URL) {
129
- return Specification.fromURL(filePathOrContextName);
130
- }
131
- yield fileExists(filePathOrContextName);
132
- return Specification.fromFile(filePathOrContextName);
133
- }
134
- try {
135
135
  return yield loadFromContext();
136
136
  }
137
137
  catch (e) {
@@ -497,13 +497,11 @@
497
497
  "args": {
498
498
  "asyncapi": {
499
499
  "description": "- Local path, url or context-name pointing to AsyncAPI file",
500
- "name": "asyncapi",
501
- "required": true
500
+ "name": "asyncapi"
502
501
  },
503
502
  "template": {
504
503
  "description": "- Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template",
505
- "name": "template",
506
- "required": true
504
+ "name": "template"
507
505
  }
508
506
  },
509
507
  "description": "Generates whatever you want using templates compatible with AsyncAPI Generator.",
@@ -526,6 +524,13 @@
526
524
  "multiple": true,
527
525
  "type": "option"
528
526
  },
527
+ "no-interactive": {
528
+ "description": "Disable interactive mode and run with the provided flags.",
529
+ "name": "no-interactive",
530
+ "required": false,
531
+ "allowNo": false,
532
+ "type": "boolean"
533
+ },
529
534
  "install": {
530
535
  "char": "i",
531
536
  "description": "Installs the template and its dependencies (defaults to false)",
@@ -637,13 +642,11 @@
637
642
  "kotlin",
638
643
  "php",
639
644
  "cplusplus"
640
- ],
641
- "required": true
645
+ ]
642
646
  },
643
647
  "file": {
644
648
  "description": "Path or URL to the AsyncAPI document, or context-name",
645
- "name": "file",
646
- "required": true
649
+ "name": "file"
647
650
  }
648
651
  },
649
652
  "description": "Generates typed models",
@@ -655,6 +658,13 @@
655
658
  "allowNo": false,
656
659
  "type": "boolean"
657
660
  },
661
+ "no-interactive": {
662
+ "description": "Disable interactive mode and run with the provided flags.",
663
+ "name": "no-interactive",
664
+ "required": false,
665
+ "allowNo": false,
666
+ "type": "boolean"
667
+ },
658
668
  "output": {
659
669
  "char": "o",
660
670
  "description": "The output directory where the models should be written to. Omitting this flag will write the models to `stdout`.",
@@ -1081,65 +1091,6 @@
1081
1091
  "index.js"
1082
1092
  ]
1083
1093
  },
1084
- "new:project": {
1085
- "aliases": [],
1086
- "args": {},
1087
- "description": "Creates a new Glee project",
1088
- "flags": {
1089
- "help": {
1090
- "char": "h",
1091
- "description": "Show CLI help.",
1092
- "name": "help",
1093
- "allowNo": false,
1094
- "type": "boolean"
1095
- },
1096
- "name": {
1097
- "char": "n",
1098
- "description": "Name of the Project",
1099
- "name": "name",
1100
- "default": "project",
1101
- "hasDynamicHelp": false,
1102
- "multiple": false,
1103
- "type": "option"
1104
- },
1105
- "template": {
1106
- "char": "t",
1107
- "description": "Name of the Template",
1108
- "name": "template",
1109
- "default": "default",
1110
- "hasDynamicHelp": false,
1111
- "multiple": false,
1112
- "type": "option"
1113
- },
1114
- "file": {
1115
- "char": "f",
1116
- "description": "The path to the AsyncAPI file for generating a Glee project.",
1117
- "name": "file",
1118
- "hasDynamicHelp": false,
1119
- "multiple": false,
1120
- "type": "option"
1121
- },
1122
- "force-write": {
1123
- "description": "Force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)",
1124
- "name": "force-write",
1125
- "allowNo": false,
1126
- "type": "boolean"
1127
- }
1128
- },
1129
- "hasDynamicHelp": false,
1130
- "hiddenAliases": [],
1131
- "id": "new:project",
1132
- "pluginAlias": "@asyncapi/cli",
1133
- "pluginName": "@asyncapi/cli",
1134
- "pluginType": "core",
1135
- "isESM": false,
1136
- "relativePath": [
1137
- "lib",
1138
- "commands",
1139
- "new",
1140
- "project.js"
1141
- ]
1142
- },
1143
1094
  "start": {
1144
1095
  "aliases": [],
1145
1096
  "args": {},
@@ -1478,5 +1429,5 @@
1478
1429
  ]
1479
1430
  }
1480
1431
  },
1481
- "version": "1.8.4"
1432
+ "version": "1.9.1"
1482
1433
  }
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": "1.8.4",
4
+ "version": "1.9.1",
5
5
  "author": "@asyncapi",
6
6
  "bin": {
7
7
  "asyncapi": "./bin/run_bin"
@@ -16,15 +16,16 @@
16
16
  "@asyncapi/modelina": "^3.4.5",
17
17
  "@asyncapi/openapi-schema-parser": "^3.0.21",
18
18
  "@asyncapi/optimizer": "^0.2.7",
19
- "@asyncapi/parser": "^3.0.13",
19
+ "@asyncapi/parser": "^3.0.14",
20
20
  "@asyncapi/protobuf-schema-parser": "^3.2.11",
21
21
  "@asyncapi/raml-dt-schema-parser": "^4.0.14",
22
22
  "@asyncapi/studio": "^0.20.0",
23
+ "@clack/prompts": "^0.7.0",
23
24
  "@oclif/core": "^1.26.2",
24
25
  "@oclif/errors": "^1.3.6",
25
26
  "@oclif/plugin-not-found": "^2.3.22",
26
- "@smoya/asyncapi-adoption-metrics": "^2.4.4",
27
- "@smoya/multi-parser": "^5.0.6",
27
+ "@smoya/asyncapi-adoption-metrics": "^2.4.7",
28
+ "@smoya/multi-parser": "^5.0.7",
28
29
  "@stoplight/spectral-cli": "6.9.0",
29
30
  "ajv": "^8.12.0",
30
31
  "chalk": "^4.1.0",
@@ -38,6 +39,7 @@
38
39
  "node-fetch": "^2.0.0",
39
40
  "oclif": "^4.2.0",
40
41
  "open": "^8.4.0",
42
+ "picocolors": "^1.0.0",
41
43
  "reflect-metadata": "^0.1.13",
42
44
  "request": "^2.88.2",
43
45
  "serve-handler": "^6.1.3",
@@ -1,5 +0,0 @@
1
- import { Config } from '@oclif/core';
2
- import NewGlee from './glee';
3
- export default class NewProject extends NewGlee {
4
- constructor(argv: string[], config: Config);
5
- }
@@ -1,11 +0,0 @@
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;