Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,48 @@ To fix this you will either need to add a Cargo.toml file at that location, or c
}
`);
});

it(`should not throw with project without cargo.toml and even when filtering to a subset of projects which do not include those dependents`, async () => {
// Add project without Cargo.toml
const projectWithoutCargoToml = 'project-without-cargoToml';
projectGraph.nodes[projectWithoutCargoToml] = {
name: projectWithoutCargoToml,
type: 'lib',
data: {
root: `libs/${projectWithoutCargoToml}`,
},
};
projectGraph.dependencies[projectWithoutCargoToml] = [
{
target: projectWithoutCargoToml,
source: 'project-with-dependency-on-my-pkg',
type: 'static',
},
];
tree.write(
`libs/${projectWithoutCargoToml}/package.json`,
JSON.stringify({ name: projectWithoutCargoToml, version: '0.0.1' })
);

await releaseVersionGenerator(tree, {
projects: [projectGraph.nodes['my-lib']], // version only my-lib
projectGraph,
specifier: '9.9.9', // user CLI specifier override set, no prompting should occur
currentVersionResolver: 'disk',
specifierSource: 'prompt',
releaseGroup: createReleaseGroup('independent'),
});

expect(parseCargoTomlWithTree(tree, 'libs/my-lib', 'my-lib'))
.toMatchInlineSnapshot(`
Object {
"package": Object {
"name": "my-lib",
"version": "9.9.9",
},
}
`);
});
});
});

Expand Down
23 changes: 19 additions & 4 deletions packages/rust/src/generators/release-version/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,17 +588,32 @@ function resolveLocalPackageDependencies(
filteredProjects: ProjectGraphProjectNode[],
projectNameToPackageRootMap: Map<string, string>,
resolvePackageRoot: (projectNode: ProjectGraphProjectNode) => string,
includeAll = false
includeDependents = false
): Record<string, LocalPackageDependency[]> {
const localPackageDependencies: Record<string, LocalPackageDependency[]> = {};
const filteredProjectsSet = new Set<string>();

// Recursively retrieves all dependents for a given project
function addDeps(projectName: string, seen: Set<string>) {
if (seen.has(projectName)) return;
seen.add(projectName);
Object.values(projectGraph.dependencies)
.filter((deps) => deps.some((d) => d.target === projectName))
.flatMap((deps) => deps.map((d) => d.source))
.forEach((d) => addDeps(d, seen));
}

filteredProjects.forEach((p) => addDeps(p.name, filteredProjectsSet));

const projects = includeAll
? Object.values(projectGraph.nodes)
const projects = includeDependents
? [...filteredProjectsSet]
.map((dep) => projectGraph.nodes[dep])
.filter(Boolean)
: filteredProjects;

for (const projectNode of projects) {
// Ensure that the packageRoot is resolved for the project and added to the map for later use
if (includeAll) {
if (includeDependents) {
fillPackageRootMap(
projectNameToPackageRootMap,
projectNode,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.79.0"
channel = "1.80.0"
targets = ["wasm32-wasip1-threads"]
profile = "default"