forked from asyncapi/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate oclif/core to V3 (asyncapi#1228)
- Loading branch information
Showing
20 changed files
with
11,370 additions
and
60,101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,3 @@ oclif.settings.debug = true; | |
|
||
// Start the CLI | ||
oclif.run().then(oclif.flush).catch(oclif.Errors.handle) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ oclif.run() | |
const oclifHandler = require('@oclif/core/handle'); | ||
return oclifHandler(err.message); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ oclif.run() | |
const oclifHandler = require('@oclif/core/handle'); | ||
return oclifHandler(err.message); | ||
}); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET } from '@asyncapi/modelina'; | ||
import { Flags } from '@oclif/core'; | ||
import { Flags, Args } from '@oclif/core'; | ||
import { ConvertDocumentParserAPIVersion } from '@smoya/multi-parser'; | ||
import Command from '../../base'; | ||
import { load } from '../../models/SpecificationFile'; | ||
import { formatOutput, parse, validationFlags } from '../../parser'; | ||
import { formatOutput, parse, validationFlags, ValidateOptions } from '../../parser'; | ||
|
||
import { select, text, spinner, isCancel, cancel, intro } from '@clack/prompts'; | ||
import { green, inverse } from 'picocolors'; | ||
|
@@ -27,14 +27,11 @@ const possibleLanguageValues = Object.values(Languages).join(', '); | |
|
||
export default class Models extends Command { | ||
static description = 'Generates typed models'; | ||
static args = [ | ||
{ | ||
name: 'language', | ||
description: 'The language you want the typed models generated for.', | ||
options: Object.keys(Languages), | ||
}, | ||
{ name: 'file', description: 'Path or URL to the AsyncAPI document, or context-name' }, | ||
]; | ||
|
||
static args = { | ||
language: Args.string({description: 'The language you want the typed models generated for.', options: Object.keys(Languages), required: true}), | ||
file: Args.string({description: 'Path or URL to the AsyncAPI document, or context-name', required: true}), | ||
}; | ||
|
||
static flags = { | ||
help: Flags.help({ char: 'h' }), | ||
|
@@ -194,14 +191,14 @@ export default class Models extends Command { | |
if (inputFile.isAsyncAPI3()) { | ||
this.error('Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376'); | ||
} | ||
const { document, diagnostics ,status } = await parse(this, inputFile, flags); | ||
const { document, diagnostics ,status } = await parse(this, inputFile, flags as ValidateOptions); | ||
if (!document || status === 'invalid') { | ||
const severityErrors = diagnostics.filter((obj) => obj.severity === 0); | ||
this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${formatOutput(severityErrors,'stylish','error')}`); | ||
return; | ||
} | ||
// Modelina, atm, is not using @asyncapi/[email protected] but @asyncapi/[email protected], so it still uses Parser-API v1.0.0. | ||
|
||
// Modelina, atm, is not using @asyncapi/[email protected] but @asyncapi/[email protected], so it still uses Parser-API v1.0.0. | ||
// This call converts the parsed document object using @asyncapi/[email protected] (Parser-API v2) to a document compatible with the Parser-API version in use in @asyncapi/[email protected] (v1) | ||
// This is needed until https://github.com/asyncapi/modelina/issues/1493 gets fixed. | ||
const convertedDoc = ConvertDocumentParserAPIVersion(document.json(), 1); | ||
|
@@ -394,7 +391,7 @@ export default class Models extends Command { | |
if (!language) { | ||
language = await select({ | ||
message: 'Select the language you want to generate models for', | ||
options: Object.keys(Languages).map((key) => | ||
options: Object.keys(Languages).map((key) => | ||
({ value: key, label: key, hint: Languages[key as keyof typeof Languages] }) | ||
), | ||
}); | ||
|
@@ -434,7 +431,7 @@ export default class Models extends Command { | |
cancel(operationCancelled); | ||
this.exit(); | ||
} | ||
|
||
return { language, file, output: output || 'stdout' }; | ||
} | ||
} |
Oops, something went wrong.