-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Tweak * Progress * Create cleanup-for-use-2024-0-29-16-47-4.md * basic tests
- Loading branch information
1 parent
86246ee
commit 4f62a90
Showing
12 changed files
with
561 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@chronus/chronus": minor | ||
--- | ||
|
||
Add ability to specify base branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
baseBranch: main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { resolveConfig } from "../config/parse.js"; | ||
import { createGitSourceControl } from "../source-control/git.js"; | ||
import { NodechronusHost } from "../utils/node-host.js"; | ||
import { createPnpmWorkspaceManager } from "../workspace-manager/pnpm.js"; | ||
import { findChangeStatus } from "./find.js"; | ||
|
||
export async function getWorkspaceStatus(root: string) { | ||
const host = NodechronusHost; | ||
const config = await resolveConfig(host, root); | ||
const pnpm = createPnpmWorkspaceManager(host); | ||
const workspace = await pnpm.load(root); | ||
const sourceControl = createGitSourceControl(workspace.path); | ||
const status = await findChangeStatus(host, sourceControl, workspace); | ||
const status = await findChangeStatus(host, sourceControl, workspace, config); | ||
return status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
packages/chronus/src/release-plan/assemble-release-plan.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import type { NewChangeset, VersionType } from "@changesets/types"; | ||
import { describe, expect, it } from "vitest"; | ||
import type { ChronusConfig } from "../config/types.js"; | ||
import type { Workspace } from "../workspace-manager/types.js"; | ||
import { assembleReleasePlan } from "./assemble-release-plan.js"; | ||
|
||
describe("Assemble Release Plan", () => { | ||
let idCounter = 0; | ||
function makeChangeset(pkg: string, type: VersionType): NewChangeset { | ||
const id = String(idCounter++); | ||
return { id, summary: `Changeset ${id}`, releases: [{ name: pkg, type }] }; | ||
} | ||
const workspace: Workspace = { | ||
path: "/", | ||
packages: [ | ||
{ name: "pkg-a", manifest: {}, relativePath: "packages/pkg-a", version: "1.0.0" }, | ||
{ name: "pkg-b", manifest: {}, relativePath: "packages/pkg-b", version: "1.0.0" }, | ||
{ name: "pkg-c", manifest: {}, relativePath: "packages/pkg-c", version: "1.0.0" }, | ||
], | ||
}; | ||
|
||
const baseConfig: ChronusConfig = { baseBranch: "main" }; | ||
|
||
describe("bumps package independently", () => { | ||
it("only packages with changeset ", () => { | ||
const plan = assembleReleasePlan([makeChangeset("pkg-a", "minor")], workspace, baseConfig); | ||
expect(plan.actions).toHaveLength(1); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
}); | ||
|
||
describe("picks the heighest version type", () => { | ||
it("major", () => { | ||
const plan = assembleReleasePlan( | ||
[makeChangeset("pkg-a", "patch"), makeChangeset("pkg-a", "minor"), makeChangeset("pkg-a", "major")], | ||
workspace, | ||
baseConfig, | ||
); | ||
expect(plan.actions).toHaveLength(1); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "2.0.0" }); | ||
}); | ||
it("minor", () => { | ||
const plan = assembleReleasePlan( | ||
[makeChangeset("pkg-a", "patch"), makeChangeset("pkg-a", "minor")], | ||
workspace, | ||
baseConfig, | ||
); | ||
expect(plan.actions).toHaveLength(1); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
}); | ||
}); | ||
|
||
it("each package with changeset gets bumped accordingly", () => { | ||
const plan = assembleReleasePlan( | ||
[makeChangeset("pkg-a", "minor"), makeChangeset("pkg-b", "patch")], | ||
workspace, | ||
baseConfig, | ||
); | ||
expect(plan.actions).toHaveLength(2); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
expect(plan.actions[1]).toMatchObject({ packageName: "pkg-b", oldVersion: "1.0.0", newVersion: "1.0.1" }); | ||
}); | ||
}); | ||
|
||
describe("lockStepVersioning", () => { | ||
const lockStepConfig: ChronusConfig = { | ||
...baseConfig, | ||
versionPolicies: [{ name: "lockStep", type: "lockstep", step: "minor", packages: ["pkg-a", "pkg-b"] }], | ||
}; | ||
|
||
it("bumps all packages in the lockstep if one changed", () => { | ||
const plan = assembleReleasePlan([makeChangeset("pkg-a", "minor")], workspace, lockStepConfig); | ||
expect(plan.actions).toHaveLength(2); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
expect(plan.actions[1]).toMatchObject({ packageName: "pkg-b", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
}); | ||
|
||
it("bumps all packages in the lockstep of the step regardless of what changesets says (higher)", () => { | ||
const plan = assembleReleasePlan( | ||
[makeChangeset("pkg-a", "minor"), makeChangeset("pkg-a", "major")], | ||
workspace, | ||
lockStepConfig, | ||
); | ||
expect(plan.actions).toHaveLength(2); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
expect(plan.actions[1]).toMatchObject({ packageName: "pkg-b", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
}); | ||
|
||
it("bumps all packages in the lockstep of the step regardless of what changesets says (lower)", () => { | ||
const plan = assembleReleasePlan( | ||
[makeChangeset("pkg-a", "patch"), makeChangeset("pkg-a", "patch")], | ||
workspace, | ||
lockStepConfig, | ||
); | ||
expect(plan.actions).toHaveLength(2); | ||
expect(plan.actions[0]).toMatchObject({ packageName: "pkg-a", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
expect(plan.actions[1]).toMatchObject({ packageName: "pkg-b", oldVersion: "1.0.0", newVersion: "1.1.0" }); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.