Skip to content

Commit

Permalink
[rush-lib] prevent workspace dependencies in decoupledLocalDependenci…
Browse files Browse the repository at this point in the history
…es (microsoft#4853)

* prevent decoupled workspace dependencies

* Rush change

* Update common/changes/@microsoft/rush/jmaher-prevent-decoupled-workspace-deps_2024-07-30-15-46.json

Co-authored-by: Ian Clanton-Thuon <[email protected]>

* Update libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts

Co-authored-by: Ian Clanton-Thuon <[email protected]>

* PR Feedback

---------

Co-authored-by: James Maher <[email protected]>
Co-authored-by: Ian Clanton-Thuon <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent 4fcd163 commit f4a218d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Emit an error if a `workspace:` specifier is used in a dependency that is listed in `decoupledLocalDependencies`.",
"type": "none",
"packageName": "@microsoft/rush"
}
],
"packageName": "@microsoft/rush",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,20 @@ export class WorkspaceInstallManager extends BaseInstallManager {
shrinkwrapIsUpToDate = false;
continue;
}
} else if (dependencySpecifier.specifierType === DependencySpecifierType.Workspace) {
} else if (
dependencySpecifier.specifierType === DependencySpecifierType.Workspace &&
rushProject.decoupledLocalDependencies.has(name)
) {
// If the dependency is a local project that is decoupled, then we need to ensure that it is not specified
// as a workspace project. If it is, then we need to update the package.json to remove the workspace notation.
this._terminal.writeWarningLine(
`"${rushProject.packageName}" depends on package ${name}@${version}, but also lists it in ` +
`its "decoupledLocalDependencies" array. Either update the host project's package.json to use ` +
`a version from an external feed instead of "workspace:" notation, or remove the dependency from the ` +
`host project's "decoupledLocalDependencies" array in rush.json.`
);
throw new AlreadyReportedError();
} else if (!rushProject.decoupledLocalDependencies.has(name)) {
// Already specified as a local project. Allow the package manager to validate this
continue;
}
Expand Down

0 comments on commit f4a218d

Please sign in to comment.