Skip to content
Open
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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"@commitlint/config-conventional": "17.3.0",
"@nx/eslint": "20.0.1",
"@nx/eslint-plugin": "20.0.1",
"@nx/jest": "20.0.1",
"@nx/node": "20.0.1",
"@nx/plugin": "20.0.1",
"@nx/workspace": "20.0.1",
"@nx/jest": "21",
"@nx/node": "21",
"@nx/plugin": "21",
"@nx/workspace": "21",
"@swc-node/register": "1.9.2",
"@swc/cli": "0.3.14",
"@swc/core": "1.5.7",
Expand All @@ -46,7 +46,7 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jsonc-eslint-parser": "^2.1.0",
"nx": "20.0.1",
"nx": "21",
"prettier": "2.8.0",
"semver": "7.5.4",
"ts-jest": "29.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/rust/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"generators": "./generators.json",
"executors": "./executors.json",
"dependencies": {
"@nx/devkit": ">= 19 < 21",
"@nx/devkit": ">= 19 < 23",
"@ltd/j-toml": "1.38.0",
"chalk": "^4.1.2",
"npm-run-path": "^4.0.1",
Expand Down
52 changes: 34 additions & 18 deletions packages/rust/src/generators/release-version/release-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ import {
resolveSemverSpecifierFromPrompt,
} from 'nx/src/command-line/release/utils/resolve-semver-specifier';
import { isValidSemverSpecifier } from 'nx/src/command-line/release/utils/semver';
import {
ReleaseVersionGeneratorResult,
VersionData,
deriveNewSemverVersion,
validReleaseVersionPrefixes,
} from 'nx/src/command-line/release/version';
import { validReleaseVersionPrefixes } from 'nx/src/command-line/release/version';
import { VersionData } from 'nx/src/command-line/release/utils/shared-legacy';
import { ReleaseVersionGeneratorResult } from 'nx/src/command-line/release/utils/shared-legacy';
import { deriveNewSemverVersion } from 'nx/src/command-line/release/version-legacy';
import { interpolate } from 'nx/src/tasks-runner/utils';
import { prerelease } from 'semver';
import {
Expand Down Expand Up @@ -171,6 +169,10 @@ To fix this you will either need to add a Cargo.toml file at that location, or c
releaseTagPattern,
{
projectName: project.name,
},
{
releaseTagPatternRequireSemver: true,
releaseTagPatternStrictPreid: false,
}
);
if (!latestMatchingGitTag) {
Expand Down Expand Up @@ -244,7 +246,7 @@ To fix this you will either need to add a Cargo.toml file at that location, or c
const affectedProjects =
options.releaseGroup.projectsRelationship === 'independent'
? [projectName]
: projects.map((p) => p.name);
: projects.map((p: { name: string }) => p.name);

// latestMatchingGitTag will be undefined if the current version was resolved from the disk fallback.
// In this case, we want to use the first commit as the ref to be consistent with the changelog command.
Expand Down Expand Up @@ -460,12 +462,14 @@ To fix this you will either need to add a Cargo.toml file at that location, or c
'Cargo.toml'
);

modifyCargoTable(
dependentPkg,
dependentProject.dependencyCollection,
dependentProject.target,
updatedDependencyData
);
if (updatedDependencyData && updatedDependencyData !== '') {
modifyCargoTable(
dependentPkg,
dependentProject.dependencyCollection,
dependentProject.target,
updatedDependencyData
);
}

tree.write(cargoTomlToUpdate, stringifyCargoToml(dependentPkg));
}
Expand Down Expand Up @@ -649,12 +653,24 @@ function resolveLocalPackageDependencies(
);
const dependencies = cargoToml.dependencies ?? {};
const devDependencies = cargoToml['dev-dependencies'] ?? {};
const findKeyForPackage = (
table: Record<string, any>,
pkgName: string
): string | null => {
for (const [k, v] of Object.entries(table)) {
if (typeof v === 'string') {
if (k === pkgName) return k;
} else if (v && typeof v === 'object') {
if (v.package === pkgName) return k;
if (!v.package && k === pkgName) return k;
}
}
return null;
};
const keyInDeps = findKeyForPackage(dependencies, depProject.name);
const keyInDevDeps = findKeyForPackage(devDependencies, depProject.name);
const dependencyCollection: 'dependencies' | 'dev-dependencies' | null =
dependencies[depProject.name]
? 'dependencies'
: devDependencies[depProject.name]
? 'dev-dependencies'
: null;
keyInDeps ? 'dependencies' : keyInDevDeps ? 'dev-dependencies' : null;
if (!dependencyCollection) {
throw new Error(
`The project "${projectNode.name}" does not have a local dependency on "${depProject.name}" in its Cargo.toml`
Expand Down
8 changes: 7 additions & 1 deletion packages/rust/src/models/cargo.toml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ export interface CargoToml {
package: any;
dependencies?: Record<
string,
string | { version: string; features?: string[]; optional?: boolean }
| string
| {
version: string;
features?: string[];
optional?: boolean;
package?: string;
}
>;
'dev-dependencies'?: Record<
string,
Expand Down
Loading