Skip to content
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: add json schema for lerna.json #3229

Merged
merged 7 commits into from Jul 7, 2022

Conversation

fahslaj
Copy link
Contributor

@fahslaj fahslaj commented Jul 6, 2022

Adds a json schema for lerna.json.

Motivation and Context

This change improves the developer experience of Lerna. Now, when modifying lerna.json, users can see what properties are valid and a brief description of what they do (taken from the lerna command options documentation).

Note: All options for commands (as described in the command docs) are valid configuration options in lerna.json. They can be provided at three levels, in order of priority:

  1. Command line inline option
  2. lerna.json, under a specific command
  3. Top level of lerna.json

The json schema for lerna.json supports supplying options at both level 2 and 3 above.

How Has This Been Tested?

I tested the schema by changing lerna.json in this repo and observing (in my editor) the metadata from the schema. I did not manually test every configuration option for every command. I obtained the metadata from the configuration code for each of the Lerna commands (command.js), with some input from the docs.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (change that has absolutely no effect on users)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ThisIsMissEm
Copy link
Contributor

I might be wrong, but I think you'd also want the schema to be published as part of the lerna website somehow, such that it can be referred to via uri instead of relative file path.

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fahslaj The source for this should be within the lerna package so that it is published and can be referenced by other workspaces not just the lerna repo itself. I had already done that on the initial branch: main...lerna-json-schema

Please also add the reference to the schema as part of lerna create as I had done on that branch.

NOTE: one thing I hadn't yet done on there was update the files array in the lerna package's package.json, you will need to do that as well please

@JamesHenry
Copy link
Member

Ok there are so many newlines, I'm guessing they are actually not random? 😅

@fahslaj
Copy link
Contributor Author

fahslaj commented Jul 7, 2022

Ok there are so many newlines, I'm guessing they are actually not random? 😅

Yes, they are not random. I put a new line between the filter options, global options, and command specific options to make it slightly more readable.

@JamesHenry
Copy link
Member

Ok there are so many newlines, I'm guessing they are actually not random? 😅

Yes, they are not random. I put a new line between the filter options, global options, and command specific options to make it slightly more readable.

Ah ok fair enough, shame we can't force it to stay like that over time, but then again hopefully this shouldn't need too many major updates anyway!

@fahslaj fahslaj requested a review from JamesHenry July 7, 2022 17:47
@fahslaj
Copy link
Contributor Author

fahslaj commented Jul 7, 2022

I have moved the lerna-schema.json inside of core/lerna. It will now be published with the lerna package. Running lerna init will generate lerna.json with the correct schema reference to node_modules/.../lerna-schema.json. End users with existing lerna workspaces will need to add the schema reference themselves.

@JamesHenry JamesHenry merged commit 5075eae into lerna:main Jul 7, 2022
@JamesHenry JamesHenry changed the title chore: Add json schema for lerna.json feat: add json schema for lerna.json Jul 7, 2022
@fahslaj fahslaj deleted the lerna-json-schema branch January 5, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants