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

fix(core): prevent validation error in version/publish with workspace: prefix #3322

Merged
merged 1 commit into from Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 0 additions & 33 deletions core/package-graph/__tests__/package-graph.test.js
Expand Up @@ -300,31 +300,6 @@ describe("PackageGraph", () => {
`"Package specification \\"test-1@^1.1.0\\" could not be resolved within the workspace. To reference a non-matching, remote version of a local dependency, remove the 'workspace:' prefix."`
);
});

it("throws an error when sibling package does not exist in the workspace, regardless of version specification", () => {
const packages = [
new Package(
{
name: "test-1",
version: "1.0.0",
},
"/test/test-1"
),
new Package(
{
name: "test-2",
version: "1.0.0",
dependencies: {
"test-3": "workspace:^1.0.0",
},
},
"/test/test-2"
),
];
expect(() => new PackageGraph(packages)).toThrowErrorMatchingInlineSnapshot(
`"Package specification \\"test-3@^1.0.0\\" could not be resolved within the workspace. To use the 'workspace:' protocol, ensure that a package with name \\"test-3\\" exists in the current workspace."`
);
});
});
});

Expand Down Expand Up @@ -621,14 +596,6 @@ Set {
});
});

// eslint-disable-next-line no-unused-vars
function deepInspect(obj) {
// jest console mutilates console.dir() options argument,
// so sidestep it by requiring the non-shimmed method directly.
// eslint-disable-next-line global-require
require("console").dir(obj, { depth: 10, compact: false });
}

function topoPackages() {
return [
{
Expand Down
7 changes: 0 additions & 7 deletions core/package-graph/index.js
Expand Up @@ -73,13 +73,6 @@ class PackageGraph extends Map {
fullWorkspaceSpec = spec;
spec = spec.replace(/^workspace:/, "");

if (!depNode) {
throw new ValidationError(
"EWORKSPACE",
`Package specification "${depName}@${spec}" could not be resolved within the workspace. To use the 'workspace:' protocol, ensure that a package with name "${depName}" exists in the current workspace.`
);
}

// replace aliases (https://pnpm.io/workspaces#referencing-workspace-packages-through-aliases)
if (spec === "*" || spec === "^" || spec === "~") {
workspaceAlias = spec;
Expand Down