-
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.
Expose release plan markdown summary function (#287)
- Loading branch information
1 parent
dad039b
commit 7470505
Showing
9 changed files
with
75 additions
and
42 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
.chronus/changes/expose-markdown-summary-2024-8-20-17-11-16.md
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,8 @@ | ||
--- | ||
# Change versionKind to one of: breaking, feature, fix, internal | ||
changeKind: feature | ||
packages: | ||
- "@chronus/chronus" | ||
--- | ||
|
||
[API] Expose function to get markdown summary of release plan |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"noEmit": true | ||
}, | ||
"include": ["./**/*.ts", "../packages/chronus/src/index.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
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,5 +1,6 @@ | ||
export type { AreaStatus, ChangeArea, ChangeStatus, PackageStatus } from "./change/find.js"; | ||
export { getWorkspaceStatus } from "./change/get-workspace-status.js"; | ||
export { renderReleasePlanAsMarkdown, resolveCurrentReleasePlan } from "./release-plan/index.js"; | ||
export { NodeChronusHost } from "./utils/node-host.js"; | ||
export { loadChronusWorkspace } from "./workspace/index.js"; | ||
export type { ChronusWorkspace } from "./workspace/types.js"; |
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,13 @@ | ||
import { type BumpVersionOptions, resolveReleasePlan } from "../cli/commands/bump-versions.js"; | ||
import type { ChronusHost } from "../utils/host.js"; | ||
import { loadChronusWorkspace } from "../workspace/load.js"; | ||
import type { ReleasePlan } from "./types.js"; | ||
|
||
export async function resolveCurrentReleasePlan( | ||
host: ChronusHost, | ||
cwd: string, | ||
options?: BumpVersionOptions, | ||
): Promise<ReleasePlan> { | ||
const workspace = await loadChronusWorkspace(host, cwd); | ||
return await resolveReleasePlan(host, workspace, options); | ||
} |
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,2 +1,4 @@ | ||
export { assembleReleasePlan } from "./assemble-release-plan.js"; | ||
export { resolveCurrentReleasePlan } from "./current.js"; | ||
export { renderReleasePlanAsMarkdown } from "./markdown.js"; | ||
export type * from "./types.js"; |
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,32 @@ | ||
import type { VersionType } from "../types.js"; | ||
import type { ReleaseAction, ReleasePlan } from "./types.js"; | ||
|
||
/** | ||
* Render a markdown summary of the given release plan | ||
*/ | ||
export async function renderReleasePlanAsMarkdown(releasePlan: ReleasePlan): Promise<string> { | ||
return [ | ||
"", | ||
"## Change summary:", | ||
"", | ||
...typeAsMarkdown(releasePlan.actions, "major"), | ||
"", | ||
...typeAsMarkdown(releasePlan.actions, "minor"), | ||
"", | ||
...typeAsMarkdown(releasePlan.actions, "patch"), | ||
"", | ||
].join("\n"); | ||
} | ||
|
||
function typeAsMarkdown(actions: ReleaseAction[], type: VersionType): string[] { | ||
const bold = (x: string) => `**${x}**`; | ||
const filteredActions = actions.filter((x) => x.type === type); | ||
if (filteredActions.length === 0) { | ||
return [`### ${"No"} packages to be bumped at ${bold(type)}`]; | ||
} else { | ||
return [ | ||
`### ${filteredActions.length} packages to be bumped at ${bold(type)}:`, | ||
...filteredActions.map((action) => `- ${action.packageName} \`${action.oldVersion}\` → \`${action.newVersion}\``), | ||
]; | ||
} | ||
} |