-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
tool list command added json flag to output packages in json format #11165
Conversation
Implements feature request meteor#406 by allowing to type a --json option and let the tree output be in JSON format. The entries consist of the package name as key and either String value (version number + top-level or expanded-above) or an Object with the following properties: - version (String) - always - local (Boolean) - only if true when package is built from source - weak (Boolean) - only if true - newerVersion (String) - only if exists - dependencies (Object) - only if > 0 and not all weak In order to also support a more detailed output, there is a --details option. If it's active, the following properties are added, too: - earliestCompatibleVersion (String) - always - debugOnly (Boolean) - only if true - prodOnly (Boolean) - only if true - testOnly (Boolean) - only if true - containsPlugins (Boolean) - only if true - lastUpdated (Date-String) - always - published (Date-String) - always
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.
This is great, just a small suggestion to avoid repetition.
In order to avoid repitition we use a single source of suffixes for the list --tree and list --json commands.
We want at least test, that there is a minimal integrity with these commands when running the arguments parsing tests.
@jankapunkt do you have a docs PR as well? |
tools/cli/commands-packages.js
Outdated
Console.info(JSON.stringify(jsonOut)) | ||
// we can't use Console here, because it pretty prints the output with | ||
// a wrap at 80 chars per line, which causes the json to break if details | ||
// options is active and the package descriptions exceed the limit | ||
console.info(JSON.stringify(jsonOut)); |
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.
You can use Console.noWrap
to not wrap the text:
meteor/tools/console/console.js
Lines 23 to 30 in 5b51149
/// - Console.noWrap: anything else that you don't want line-wrapped. | |
/// | |
/// Here is a contrived example: | |
/// Console.info( | |
/// "For more information, please run", Console.command("meteor show"), | |
/// "or check out the new releases at", Console.url("www.meteor.com"), | |
/// "or look at", Console.path(filepath), ". You are currently running", | |
/// "Console.noWrap("Meteor version 1.5") + "."); |
@filipenevola not yet but I can add one today |
@jankapunkt please add here when you have the docs PR ready |
The optional flags were not documented. This adds the flags, including those (--json, --details), added via meteor/meteor#11165
@filipenevola the docs PR is here: meteor/docs#685 |
The optional flags were not documented. This adds the flags, including those (--json, --details), added via meteor/meteor#11165
Implements feature request #406 by allowing to type a
--json
option and let the tree output be in JSON format. The entries consist of the package name as key and either String value (version number + top-level or expanded-above) or an Object with the following properties:In order to also support a more detailed output, there is a --details option. If it's active, the following properties are added, too:
How it works / reproduction
path/to/meteor add meteortesting:mocha
to simulate an external dependencypath/to/meteor list --json
It should output the following JSON:
path/to/meteor list --json --weak
It should output the following JSON:
path/to/meteor list --json --weak --details
It should output the following JSON:
Backwards compatibility
This implementation does not alter the behaviour of
meteor list
ormeteor list --tree
. Any detected alteration of their behaviour is unintended.Tests
I am still unsure, where to add tests, since there are not really tests for this command found, besides for the plain
meteor list
command. Any hint would be appreciated.Outlook
Could include deprecation flag from #11162 if this is implemented in order to maximize potential CI implementations that scan packages and projects.