-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
--sync-workspace-lock issue #877
Comments
I don't use Husky and don't have much knowledge about it, all I know is that below is what the npm lock file update runs. This flag was created to sync the lock file and that's all it should do. I added this flag to replace the previous and often failing implementation that tried to modify the lock file directly, the new sync flag is simply calling whichever package manager is installed to do the synching of the lock file (we should always rely on the package manager instead of trying to modify the lock file ourselves which is a bad idea). It does accept extra npm arguments if that helps. lerna-lite/packages/version/src/lib/update-lockfile-version.ts Lines 161 to 181 in 3204e06
Looking at the Version command, the sync seems to happen before the lerna-lite/packages/version/src/version-command.ts Lines 782 to 793 in 3204e06
Then the lerna-lite/packages/version/src/version-command.ts Lines 836 to 862 in 3204e06
So I don't know what your problem is since I don't use that kind of scripts on my side and I can't provide much more info. The only suggestion I could give is to look at the available version Lifecycle Scripts and maybe use a different one if that helps, otherwise I have no idea. Another suggestion might be to change the logs to in my case I don't need to use this sync flag because I use the EDIT Actually someone did install Husky for conventional commits checks in one of my project and I also had to set (ref release.yml) - name: Lerna Version 🏷️
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true
HUSKY: 0
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
pnpm whoami
pnpm exec ${{ env.LERNA_VERSION_QUERY }} |
Hi @ghiscoding many thanks for your quick and detailed response! I investigated a little bit and basically the problem is that I bypassed the issue moving HUSKY env var in the parent scope and now even setting "syncWorkspaceLock: true", when Lerna runs Anyway, looking at the original Lerna code: it is running |
hmm there is actually a CLI option |
Side note and as mentioned above you could also add the ignore script yourself via the {
"command": {
"version": {
"npmClientArgs": ["--ignore-scripts"]
}
} that is until I have time to add the other skip script run option. or you could also contribute the missing option 😉 |
Hi @ghiscoding, as I said, I already solved my problem but I will keep in mind this as future reference! |
latest release v3.6.0 will no longer run scripts when npm install runs, the behavior is now the same as Lerna and if you want to run the scripts then the new option |
Describe the bug
A short overview first:
I have a"postinstall" script that runs "husky install" (Husky is npm package).
Using Husky, I run a script on the git "pre-commit" hook that checks the name of the branch and fails the commit in case the branch name is not formatted as expected (branch "main" fails the script).
When I merge a branch on "main", the pipeline:
Everything works as expected as long as I don't set
syncWorkspaceLock: true
in lerna.json (I use npm).Setting the flag to true, Lerna fails to commit because the "pre-commit" hook is triggered and the script throws an error because the branch name is "main".
Expectation
As suggested by the docs, I should use syncWorkspaceLock: true and Lerna should be able to commit.
Reproduction
Should be possible to reproduce the issue following my bug description.
Lerna config and logs
lerna.json
lerna-debug.log
Environment Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Pro
Memory: 258.52 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
Browsers:
Chrome: 125.0.6422.176
Safari: 17.5
npmPackages:
@lerna-lite/cli: ^3.5.1 => 3.5.1
@lerna-lite/run: ^3.5.1 => 3.5.1
@lerna-lite/version: ^3.5.2 => 3.5.2
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: