linter: package metadata and registration
When adding a new package, it's often easy to forget about the checklist we have in our docs (Adding a new package).
Let's implement a linter that will verify that all packages in our monorepo are registered in all required places and have the expected metadata in their package.json.
Acceptance criteria
- [ ] Add a new script to the top-level
bindirectory. This script should obtain a list of all packages known by lerna (see e.g. here) and run the following checks for each package: - [ ] The package has
LICENSEfile with the expected content (MIT license + npm package name) - [ ] The package has an entry in MONOREPO.md
- [ ] The package has an entry in CODEOWNERS
- [ ] Package's
package.jsonfile haspublishConfigwithaccessset topublic, see Make a scoped package public - [ ] Package's
package.jsonfile hasauthor,copyright.ownerandlicensefields set to correct values (let's usepackage.jsonin monorepo root as the source of truth) - [ ] Package's
package.jsonfile has correctrepositoryconfiguration, pointing to loopback-next at GitHub and includingdirectoryfield with a relative path inside our monorepo - [ ] Modify Travis CI task
code-lintto run the new script as part of our CI build.
@bajtos Hello, I started to implement this script. At the moment I'd finished license checker and found that docs folder(loopback-next/docs) doesn't contain LICENSE file although Lerna includes this folder as a package. Should I exclude the docs folder from checks or rather to add the LICENSE file in the docs folder?
And second question. Should the script take into account packages from the acceptance folder that are marked as private in the MONOREPO.md folder in the npm column? Those packages don't contain names (like @loopback/boot or @loopback/context) in the npm column, only _(private)_ . Can I take Package column value like [acceptance/extension-logging-fluentd] and compare it with the package folder location? Means the monorepo task will use 2 checks: as package name in column npm, and location in Package column?
Could you also provide desirable text in CODEOWNERS.md for apiconnect extension and sandbox example, please
Can I add Webstorm .idea folder to .gitignore?
@spirAde
Hello, I started to implement this script.
That's awesome! I am looking forward to review the pull request. Feel free to open it as soon as you have something worth sharing, we can implement the linter iteratively in baby steps.
found that docs folder(
loopback-next/docs) doesn't containLICENSEfile although Lerna includes this folder as a package. Should I exclude the docs folder from checks or rather to add theLICENSEfile in the docs folder?
Please add LICENSE file to the docs folder.
And second question. Should the script take into account packages from the
acceptance folderthat are marked asprivatein theMONOREPO.mdfolder in the npm column? Those packages don't contain names (like@loopback/bootor@loopback/context) in the npm column, only_(private)_. Can I takePackagecolumn value like[acceptance/extension-logging-fluentd]and compare it with the package folder location? Means the monorepo task will use 2 checks: as package name in column npm, and location in Package column?
I am afraid I don't understand what are you proposing :(
I think you will always need to read package metadata (e.g. acceptance/extension-logging-fluentd/package.json), for example to find out what is the npm package name. While you are reading name, you can also check private field and decide what should be in npm column in the table (npm package name or _(private)_.
Could you also provide desirable text in
CODEOWNERS.mdforapiconnect extensionandsandbox example, please
I asked the team to decide who should own the apiconnect extension and open a PR to update CODEOWNERS.
As for the sandbox example, that project does not need any dedicated code owner entry. Can you please add an exception to your linter to ignore the missing CODEOWNERS entry for this particular package?
Can I add Webstorm
.idea folderto.gitignore?
Do you commit .idea folders in other projects you are maintaining? If not, then can you please add .idea to your global git ignore file?
Personally, I have ~/.gitignore_global with the ignore rules and the following config in my ~.gitconfig:
[core]
excludesfile = /Users/bajtos/.gitignore_global
Having said that, I guess WebStorm is a pretty common IDE used by JS devs so there is no harm in setting up a gitignore file for it. Just make sure to open a standalone pull request for this change.