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(link): generate shims for missing 'bin' scripts #2059

Merged
merged 2 commits into from May 11, 2019
Merged

feat(link): generate shims for missing 'bin' scripts #2059

merged 2 commits into from May 11, 2019

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Apr 26, 2019

During the 'link' step, if a package's binary targets don't exist yet
they will fail to be symlinked, even if a later run xxx step would
have generated them. This is a situation that occurs in monorepos
containing build tools compiled from another language (e.g. TypeScript).

Simply adding the symlinks whether the target exists or not is not good
enough, as the symlink target needs to be chmod +xed, which is
lerna's/npm's responsibility.

Instead, if the target doesn't exist, generate a shim shell script that
will chmod and exec the intended target, similar to what would
happen on Windows normally.

Fixes #1444.

Motivation and Context

It solves an issue in our TypeScript-compiled monorepo that uses custom build tooling.

Also makes the behavior the same as if the packages had been published and pulled the packages from NPM independently.

How Has This Been Tested?

Added and ran integration test.

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)

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. not this one because some of the snapshot tests seem to depend on the formatting of git's output and the output on my machine was formatted differently.

Rico Huijbers and others added 2 commits April 26, 2019 14:19
During the 'link' step, if a package's binary targets don't exist yet
they will fail to be symlinked, even if a later `run xxx` step would
have generated them. This is a situation that occurs in monorepos
containing build tools compiled from another language (e.g. TypeScript).

Simply adding the symlinks whether the target exists or not is not good
enough, as the symlink target needs to be `chmod +x`ed, which is
lerna's/npm's responsibility.

Instead, if the target doesn't exist, generate a shim shell script that
will `chmod` and `exec` the intended target, similar to what would
happen on Windows normally.

Fixes #1444.
Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@evocateur evocateur merged commit 90acdde into lerna:master May 11, 2019
dgp1130 added a commit to dgp1130/bxpb that referenced this pull request May 24, 2020
Refs #1.

CI appears to be failing, due to a missing `packages/bxpb-protoc-plugin/bin/bxpb-protoc-plugin` file. This is weird to me as the file is directly checked in to source.

https://github.com/dgp1130/bxpb/runs/702931728

The symlink appears to work as expected after passing through a wrapper shell script from lerna/lerna#2059, and that script works correctly when used locally.

While doing some investigation, I noticed an NPM best practice of using `#!/usr/bin/env node` for the shebang line. I'm hoping GitHub actions just has the Node binary in a different location and printed a very bad error message. Only one way to find out!
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.

'lerna bootstrap' fails to symlink binaries which are generated during package build
2 participants