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
chore(build): add Prettier to the project, expand on #168 #182
Conversation
- takes PR #168 and adresses all comments provided in the original PR - fixed npm lockfile that got broken by original PR, I took the same approach as the pnpm lock file update to fix the npm lock file update. Both updates are now very similar and easier to read - removed `preferred-pm` since I would prefer to not use any extra dependencies, and I think that also fixed the unit tests since they weren't being detected properly - added a prettier VSCode setting (setup) and also fixed couple of places where prettier wasn't doing a good job
@JacobSoderblom Thanks for your contributions |
Codecov Report
@@ Coverage Diff @@
## main #182 +/- ##
==========================================
+ Coverage 93.29% 93.31% +0.02%
==========================================
Files 134 134
Lines 3901 3911 +10
Branches 773 785 +12
==========================================
+ Hits 3639 3649 +10
Misses 262 262
Continue to review full report at Codecov.
|
- it will still work when undefined but it will speed up the process when `npmClient` is already specified in `lerna.json`, for example no need to try loading npm lock file when user defined `pnpm` as client
- found some issues with `workspace:` protocol when adding more use cases (ie `workspace:*`), it's not perfect but it should cover 95% of use cases. The case that I know won't work, but is rare, is if the user decide to switch from a workspace version (ie `workspace:^1.2.3`) to a fixed workspace (ie `workspace:^`) then it will end up updating it anyway, it's not a huge deal and won't break anything and running pnpm install will fix it, which is why I decided to add `--no-update-root-lock-file` flag)
c09d4ff
to
b912900
Compare
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.
Looks good! 🥇
I'll try to manage to test this locally today as well |
Any update? This is also for me the only blocker to try out lerna-lite 😄 |
@StarpTech it's currently in WIP, I don't think it will be until next week or even the week after, that I ship anything related to that... however you could easily use a temporary workaround for this via lifecycle script // preversion: Run BEFORE bumping the package version.
// version: Run AFTER bumping the package version, but BEFORE commit.
// postversion: Run AFTER bumping the package version, and AFTER commit. |
@ghiscoding thank you! The |
@StarpTech @JacobSoderblom |
Yes! If I don't scope it to a single package pnpm might throw an error that another workspace package refers to an invalid version. You can only run |
I gave a try with I'll still look at directly updating the lock file, so perhaps if I get both working then we could also have flags for both ways and let the developer choose. npm ERR! code ETARGET
npm ERR! notarget No matching version found for @lerna-lite/init@^1.4.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist. So basically the error comes from trying to retrieve {
"name": "@lerna-lite/cli",
"version": "1.4.1" // this line is ok
"devDependencies": {
"@lerna-lite/init": "^1.4.1" // this line throws, not found in registry
}
} |
Did you use npm or pnpm? |
that was with npm on Lerna-Lite project itself, but I imagine pnpm will do something similar, isn't it? |
No, pnpm should really just update the lock 😄 |
According to npm docs:
Maybe you need to operate in the workspace? https://docs.npmjs.com/cli/v8/commands/npm-install#workspace Looks like a bug or it's not the whole truth. |
It won't download any packages but it will check if they exist in the registry, perhaps that part is not mentioned which is probably the most significant lol. You're saying it doesn't do that with pnpm, could you double-check? So what I could do is add a flag in the |
Yes, but it takes some time.
Did you also try
In my opinion, updating the lock file should be part of the versioning commit because it belongs to the "versioning" process to ensure integrity. My use case is to version and publish together. |
ahh I didn't know about that offline option, dang there's so many flags... however after trying it over lunch, it doesn't seem to help and I'm pretty much getting the same error (with/without > npm install --workspaces --offline --package-lock-only
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @lerna-lite/init@^1.4.1.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist. ahhh I think it's because of what they say in the description
ohh but wait I found another command shrinkwrap and it does run without any error but that command has the side effect of deleting the lock file and renames it to
and this other description |
PNPM behaves correctly when all version constraints can be resolved with the local packages. |
@ghiscoding Did you try it with a pnpm monorepo? It must work. |
So finally. I tried it on a fresh pnpm monorepo with two packages. No errors. The local versions are used before looking at the registry. |
@StarpTech no I only tried with Lerna-Lite itself, I'd like to have a generic solution that works for all type (if possible). The approach might be different on each manager and that's ok too, if I do add that option it would be under a new flag that is disabled (opt-in), something along On the other hand, I'm still looking at updating the file itself, I found last night that pnpm maintainer is using its own custom version of and thanks for the quick project repro, this will be helpful |
As a lerna user, you have to specify |
yes the intention is to add a switch case on |
Sounds good! Would be happy to review your PR. |
@StarpTech I have a draft PR for the package manager client to update the lock file, I only tried within Lerna-Lite itself in dry-run, I did not try pnpm yet (neither yarn) but if you could take a look at the draft PR and provide any feedback then go ahead to PR #199 Note that I'm not sure if I'll keep working on modifying the pnpm lock file ourselves or just use that new PR to do the job, I think that I might keep both flag for at least npm but not sure about pnpm, if this new approach works better and is more reliable then I will just keep 1 approach. I'm not exactly sure how I'll unit test that though |
@ghiscoding I have a repro where NPM works fine like pnpm. Again as long as the version constraint match with the local packages, no error is thrown And according to npm/cli#3637 only npm@>=8.5.0 implemented it properly. |
@StarpTech |
pnpm-lock.yaml
, expand on #168
just for reference, since PR #199 got merged and is a better way of handling the pnpm lockfile update. I decided to transform the original PR #168 from @JacobSoderblom and keep only the code that adds Prettier to the project. This way I get to keep his great contributions to the project and his effort and contribution are not entirely lost. Thanks for this great contribution. I'm expecting to do a release in the coming 1 or 2 days. |
Description
takes PR #168 and addresses all comments provided in the original PR
Motivation and Context
preferred-pm
since I would prefer to not use any extra dependencies, and I think that also fixed the unit tests since they weren't being detected properlyno-update-root-lock-file
just in case this pnpm update causes issues, at least the user could disable itHow Has This Been Tested?
only local unit tests for now, we might need a bit more testing, need to validate with @JacobSoderblom
Types of changes
Checklist: