Repository navigation
Handle packages with binaries - #192
Conversation
|
At my company, we've written a few CLI tools that are accessed via NPM scripts in each package. Bootstrapping did not factor this in and they would fail to run. |
|
|
||
| this.createLinkedDependency(linkSrc, linkDest, dependency.name, done); | ||
| this.createLinkedDependency(linkSrc, linkDest, dependency.name, (err) => { | ||
| const bin = dependency._package.bin; |
There was a problem hiding this comment.
This should check err at the beginning and call done(err) if it exists and stop
|
i'm noticing that the unit tests are non-deterministic, both locally and travis |
|
This is sorely needed! Anything I can do to help move this along? |
|
@paulyoung, this functionality is actually covered in PR #237 as well. |
| this.createLinkedDependency(linkSrc, linkDest, dependency.name, done); | ||
| this.createLinkedDependency(linkSrc, linkDest, dependency.name, (err) => { | ||
| if (!err && dependency._package.bin) { | ||
| const srcBinLocation = path.join(linkSrc, dependency._package.bin); |
There was a problem hiding this comment.
Would be nice to add a bin getter in src/Package.js for consistency. Then this could be:
const srcBinLocation = path.join(linkSrc, dependency.bin);There was a problem hiding this comment.
Actually, dependency.bin isn't guaranteed to be a string.
Could normalize inside the getter to always return an object. Else the logic here will need to account for that.
|
@gigabo This should do it. I also uncovered a potential issue with the
When a package is ignored while bootstrapping, it should be completely taken out of the equation. This update alters the previous behavior of not bootstrapping an ignored package, but still treating it as though it was part of the process. If a package is ignored, it should be treated as an external dependency. The updated unit test reflects this. |
Hmm... that's actually not what I'd naively expect. 😕 I'd expect "ignore package foo" to skip doing anything in |
|
@gigabo that's a good question. what exactly does ignore mean? my initial thought was that it doesn't get any of its dependencies "linked" in the bootstrap, but i'm not sure that makes sense. for example, check out this scenario:
i run bootstrap and ignore packageA, which means that packageA does not have a "linked" or installed version of packageB. meanwhile, i bootstrap packageC and "link" to packageA like normal. now, when i import packageA into packageC, packageB will not be imported as no form of it exists in under the new scenario, packageA would be installed as an external dependency of packageC and all would be well. i don't see much use for the it is a bit confusing to think about. once i realized how things would be bootstrapped when you ignore a package, i'm not sure the original way of doing it would actually work. |
|
@rygine - The behavior or |
|
@gigabo makes sense. amended the commit. |
Minor refactor of some methods for easier to read code using `async.series`
| const todoPackages = PackageUtilities.filterPackages(this.packages, ignore, true); | ||
|
|
||
| // Get a trimmed down graph that includes only those packages. | ||
| const filteredGraph = PackageUtilities.getPackageGraph(todoPackages); |
There was a problem hiding this comment.
this is slightly unrelated to the PR, but i moved the package filtering to the initialize method to mimic the behavior of lerna run for consistency.
There was a problem hiding this comment.
unrelated to the PR
Generally speaking, smaller more targeted PRs are easier to review and therefore tend to get merged more quickly.
This PR adds much needed functionality, but it has gone through a number of iterations that each included a different set of unrelated changes. These other changes may also be valuable, but it would be easier to consider them on their own merit if they were showcased in dedicated PRs.
There was a problem hiding this comment.
point taken. amended.
There was a problem hiding this comment.
Thanks, that makes it easier to read. 👍
| // if package has dependencies with binaries | ||
| if (depsWithBin.length) { | ||
| // symlink binaries | ||
| actions.push(cb => this.symlinkDependencyBinaries(pkg, depsWithBin, cb)); |
There was a problem hiding this comment.
I think the binaries should be linked before runPrepublishForPackage.
A package may have a prepublish script that uses a binary from a dependency.
* Added `symlink` method to FileSystemUtilities * Added `bin` property to Package * Updated bootstrap to factor in dependencies with multiple binaries * Added test for package with multiple binaries * Updated unit test for ignored package
|
@gigabo I addressed your comments with an amended commit. For future reference, should I continue to amend commits, or just make another one for things like this? |
From my perspective it's nice to have a new commit so I can see clearly what changed. PRs are typically squashed during merge, so it won't clutter the commit history on master. |
|
@hzoo, @thejameskyle - Anything else you'd like to see here? I want to use this! |
This is an attempt to get lerna#192 merged by trimming extraneous changes to slim down the diff. None of the following changes reflect _disapproval_ of the code in the original PR. This is pure change-set minimization. Changes: - Revert incidental code reorganization in: - `createLinkDependency` - `linkDependencies` - `createLinkedDependencyFiles` - Thin interface of `createBinaryLink` - Eliminate unused optional argument to `FileSystemUtilities.symlink` - Simplify `createBinaryLink` - Remove jsdoc comments The with this patch the diff against master is now pure addition.
This is an attempt to get @rygine's lerna#192 merged by trimming extraneous changes to slim down the diff. None of the following changes reflect _disapproval_ of the code in the original PR. This is pure change-set minimization. Changes: - Revert incidental code reorganization in: - `createLinkDependency` - `linkDependencies` - `createLinkedDependencyFiles` - Thin interface of `createBinaryLink` - Eliminate unused optional argument to `FileSystemUtilities.symlink` - Simplify `createBinaryLink` - Remove jsdoc comments The with this patch the diff against master is now pure addition.
This is an attempt to get @rygine's lerna#192 merged by trimming extraneous changes to slim down the diff and ease review. None of the following changes reflect _disapproval_ of the code in the original PR. This is pure change-set minimization. Changes: - Revert incidental code reorganization in: - `createLinkDependency` - `linkDependencies` - `createLinkedDependencyFiles` - Thin interface of `createBinaryLink` - Eliminate unused optional argument to `FileSystemUtilities.symlink` - Simplify `createBinaryLink` - Remove jsdoc comments With this patch the diff against master is now pure addition.
|
Taking #300 (comment) as a 👍 here. Thanks for sticking with this @rygine. This is a big improvement! |
This is an attempt to get @rygine's lerna#192 merged by trimming extraneous changes to slim down the diff and ease review. None of the following changes reflect _disapproval_ of the code in the original PR. This is pure change-set minimization. Changes: - Revert incidental code reorganization in: - `createLinkDependency` - `linkDependencies` - `createLinkedDependencyFiles` - Thin interface of `createBinaryLink` - Eliminate unused optional argument to `FileSystemUtilities.symlink` - Simplify `createBinaryLink` - Remove jsdoc comments With this patch the diff against master is now pure addition.
This is an attempt to get @rygine's #192 merged by trimming extraneous changes to slim down the diff and ease review. None of the following changes reflect _disapproval_ of the code in the original PR. This is pure change-set minimization. Changes: - Revert incidental code reorganization in: - `createLinkDependency` - `linkDependencies` - `createLinkedDependencyFiles` - Thin interface of `createBinaryLink` - Eliminate unused optional argument to `FileSystemUtilities.symlink` - Simplify `createBinaryLink` - Remove jsdoc comments With this patch the diff against master is now pure addition.
This picks up lerna/lerna#192 which lets us simplify our use of the CLI within the repo.
This picks up lerna/lerna#192 which lets us simplify our use of the CLI within the repo.
|
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Minor refactor of some methods for easier to read code using
async.series