-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: migrate oclif/core to V3 #1228
Merged
asyncapi-bot
merged 2 commits into
asyncapi:master
from
Amzani:samz/oclif-core-v3-migration
May 15, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we update the rest of oclif dependencies too? Or not really necessary for the main purpose of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily, I put it in draft as there is an issue with the binary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this can be done incrementally