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
Collaborator

@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.

@fahslaj fahslaj requested a review from JamesHenry Jul 6, 2022
@ThisIsMissEm
Copy link
Contributor

ThisIsMissEm commented Jul 6, 2022

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
Collaborator

@JamesHenry JamesHenry left a comment

@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

schemas/lerna-schema.json Outdated Show resolved Hide resolved
schemas/lerna-schema.json Outdated Show resolved Hide resolved
schemas/lerna-schema.json Outdated Show resolved Hide resolved
schemas/lerna-schema.json Outdated Show resolved Hide resolved
schemas/lerna-schema.json Outdated Show resolved Hide resolved
schemas/lerna-schema.json Outdated Show resolved Hide resolved
@JamesHenry
Copy link
Collaborator

JamesHenry commented Jul 7, 2022

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

@fahslaj
Copy link
Collaborator 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
Collaborator

JamesHenry 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.

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 Jul 7, 2022
@fahslaj
Copy link
Collaborator 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
14 checks passed
@JamesHenry JamesHenry changed the title chore: Add json schema for lerna.json feat: add json schema for lerna.json Jul 7, 2022
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