Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Conversation

@isaacs
Copy link
Contributor

@isaacs isaacs commented Mar 30, 2021

Support arborist.buildIdealTree({ add: [pkg], workspaces: ['list', 'of', 'names'] }) to add dependencies to the workspaces, instead of to the root project.

Also fixes the bug where npm ls reports workspace links as extraneous, even though they are clearly not extraneous.

Based on #257, land that first.

isaacs added 14 commits March 26, 2021 09:33
This causes major problems when moving links and targets between trees.
When we move the link from one tree to another, it pulls its target,
out, meaning that the target ends up becoming orphaned.

Say there is a matching link and target in two different trees, A and B,
and we want to replace the link and target in one tree with the link and
target in another.

If we move the target A to tree B first, then it replaces the target B,
and link B is updated to point to it.

Then, we move link A to tree B, replacing link B.  To do that, we move
link B out of tree B, which _takes target B with it_, leaving the ported
link A without a target in tree B.
This also corrects an issue where manually updating the package.json
file would sometimes not be reified properly, if a new link target
matches the one that was formerly reified.
Fixes sorting incorrectly when a dependency is set to an empty string
This is in preparation for the use case where explicitRequests includes
edges from nodes other than the project root, so that we can add deps
to workspaces.
This is really important for debugging when "have workspaces been loaded
yet" is a relevant consideration.
@isaacs isaacs requested review from nlf and ruyadorno March 30, 2021 19:49
Copy link
Contributor

@nlf nlf left a comment

Choose a reason for hiding this comment

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

shoulder surfed while this was being done, changes make sense, a couple of super super tiny nits but functionally i think this is what we want 👍

// used by Reify mixin
const _force = Symbol.for('force')
const _explicitRequests = Symbol.for('explicitRequests')
const _explicitRequests = Symbol('explicitRequests')
Copy link
Contributor

Choose a reason for hiding this comment

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

total nit, but it probably makes sense to move this up to the private symbols above since it's no longer "used by Reify mixin"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good point.

const _getBundlesByDepth = Symbol('getBundlesByDepth')
const _registryResolved = Symbol('registryResolved')
const _addNodeToTrashList = Symbol('addNodeToTrashList')
const _workspaces = Symbol.for('workspaces')
Copy link
Contributor

Choose a reason for hiding this comment

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

again, nit, but this should be below in the "defined by Ideal mixin"

@nlf
Copy link
Contributor

nlf commented Mar 31, 2021

checked on the one test failure, it was a socket timeout in the mock registry server which is.. interesting, but nothing of concern.

@wraithgar
Copy link
Member

Will this require us to pass in all workspaces if we want all workspaces acted on? The cli treats an empty array as "all workspaces" currently.

I would say no, and hope that once we are crossing the line here to another module it should be very explicit, but just wanted to make sure we're all on the same page here.

@nlf
Copy link
Contributor

nlf commented Mar 31, 2021

i feel like we should require passing in all of the workspaces by name to arborist, let the cli do that resolution since it needs to do it for other commands anyway. better to have that code live in one place imo

@isaacs
Copy link
Contributor Author

isaacs commented Apr 1, 2021

The way you tell Arborist to act on all workspaces is you give it an array with the name of all the workspaces in it.

If you don't provide a workspaces array, then it'll add/remove to/from the root package, and reify everything.

@isaacs isaacs closed this in 040b6c3 Apr 1, 2021
@wraithgar wraithgar deleted the isaacs/reify-add-to-workspaces branch April 22, 2021 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants