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
23 changes: 23 additions & 0 deletions .yarn/versions/a292aff0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": minor
"@yarnpkg/plugin-version": minor

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ describe(`Commands`, () => {
),
);


const alternatives = [
[`implicit`, `1.0.0`, true],
[`implicit range`, `^1.0.0`, true],
Expand Down Expand Up @@ -220,6 +221,55 @@ describe(`Commands`, () => {
},
),
);

test(
`it should update the dependencies (${name}) to exact matches`,
makeTemporaryEnv(
{
private: true,
workspaces: [
`packages/*`,
],
},
async ({path, run}) => {
const pkgA = ppath.join(path, `packages/pkg-a`);
const pkgB = ppath.join(path, `packages/pkg-b`);

await xfs.mkdirpPromise(pkgA);
await xfs.mkdirpPromise(pkgB);

await xfs.writeJsonPromise(ppath.join(pkgA, Filename.manifest), {
name: `pkg-a`,
version: `1.0.0`,
dependencies: {
[`pkg-b`]: dependency,
},
});

await xfs.writeJsonPromise(ppath.join(pkgB, Filename.manifest), {
name: `pkg-b`,
version: `1.0.0`,
});

await run(`version`, `patch`, `--deferred`, {
cwd: pkgB,
});

await run(`version`, `apply`, `--all`, `--exact`);

await expect(xfs.readJsonPromise(ppath.join(pkgA, Filename.manifest))).resolves.toMatchObject({
version: `1.0.0`,
dependencies: {
[`pkg-b`]: dependency.replace(/1\.0\.0/, `1.0.1`).replace(/\^/, ``),
},
});

await expect(xfs.readJsonPromise(ppath.join(pkgB, Filename.manifest))).resolves.toMatchObject({
version: `1.0.1`,
});
},
),
);
}
});
});
6 changes: 5 additions & 1 deletion packages/plugin-version/sources/commands/version/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export default class VersionApplyCommand extends BaseCommand {
tolerateBoolean: true,
});

exact = Option.Boolean(`--exact`, false, {
description: `Use the exact version of each package, removes any range. Useful for nightly releases where the range might match another version.`,
});

recursive = Option.Boolean(`-R,--recursive`, {
description: `Release the transitive workspaces as well`,
});
Expand Down Expand Up @@ -104,7 +108,7 @@ export default class VersionApplyCommand extends BaseCommand {
return;
}

versionUtils.applyReleases(project, filteredReleases, {report});
versionUtils.applyReleases(project, filteredReleases, {report, exact: this.exact});

if (!this.dryRun) {
if (!prerelease) {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-version/sources/versionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export function applyStrategy(version: string | null, strategy: string) {
return nextVersion;
}

export function applyReleases(project: Project, newVersions: Map<Workspace, string>, {report}: {report: Report}) {
export function applyReleases(project: Project, newVersions: Map<Workspace, string>, {report, exact}: {report: Report, exact?: boolean}) {
const allDependents: Map<Workspace, Array<[
Workspace,
AllDependencies,
Expand Down Expand Up @@ -465,7 +465,7 @@ export function applyReleases(project: Project, newVersions: Map<Workspace, stri
continue;
}

let newRange = `${parsed[1]}${newVersion}`;
let newRange = exact ? `${newVersion}` : `${parsed[1]}${newVersion}`;
if (useWorkspaceProtocol)
newRange = `${WorkspaceResolver.protocol}${newRange}`;

Expand Down
Loading