@chronus/chronus
Advanced tools
Comparing version 0.6.1 to 0.7.0
# @chronus/chronus | ||
## 0.7.0 | ||
### Features | ||
- Feature: New apply changes system that respect the change kinds names | ||
- Add new function to `@chornus/chronus/change` `readChangeDescriptions` that list all change descriptions in the workspace currently. | ||
## 0.6.1 | ||
@@ -4,0 +11,0 @@ |
export { resolveChangePath, resolveChangeRelativePath, resolveChangesDir } from "./common.js"; | ||
export { findChangeStatus } from "./find.js"; | ||
export { parseChangeDescription } from "./parse.js"; | ||
export { readChangeDescription } from "./read.js"; | ||
export { readChangeDescription, readChangeDescriptions } from "./read.js"; | ||
export type * from "./types.js"; | ||
export { printChangeDescription } from "./write.js"; | ||
//# sourceMappingURL=index.d.ts.map |
export { resolveChangePath, resolveChangeRelativePath, resolveChangesDir } from "./common.js"; | ||
export { findChangeStatus } from "./find.js"; | ||
export { parseChangeDescription } from "./parse.js"; | ||
export { readChangeDescription } from "./read.js"; | ||
export { readChangeDescription, readChangeDescriptions } from "./read.js"; | ||
export { printChangeDescription } from "./write.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -7,4 +7,5 @@ import type { ChronusHost } from "../utils/host.js"; | ||
} | ||
export declare function printChangeDescription(change: Omit<ChangeDescription, "id">, options?: PrintChangeDescriptionOptions): string; | ||
export declare function readChangeDescription(host: ChronusHost, workspace: ChronusWorkspace, filename: string): Promise<ChangeDescription>; | ||
/** Read all change descriptions */ | ||
export declare function readChangeDescriptions(host: ChronusHost, workspace: ChronusWorkspace): Promise<ChangeDescription[]>; | ||
//# sourceMappingURL=read.d.ts.map |
@@ -1,14 +0,4 @@ | ||
import { dump } from "js-yaml"; | ||
import { isDefined } from "../utils/misc-utils.js"; | ||
import { resolvePath } from "../utils/path-utils.js"; | ||
import { changesRelativeDir } from "./common.js"; | ||
import { parseChangeDescription } from "./parse.js"; | ||
export function printChangeDescription(change, options) { | ||
const frontMatter = { | ||
changeKind: change.changeKind.name, | ||
packages: change.packages, | ||
}; | ||
const frontMatterComment = options?.frontMatterComment && `# ${options?.frontMatterComment}`; | ||
return ["---", frontMatterComment, dump(frontMatter, { quotingType: '"' }).trimEnd(), "---", "", change.content] | ||
.filter(isDefined) | ||
.join("\n"); | ||
} | ||
export async function readChangeDescription(host, workspace, filename) { | ||
@@ -18,2 +8,8 @@ const file = await host.readFile(filename); | ||
} | ||
/** Read all change descriptions */ | ||
export async function readChangeDescriptions(host, workspace) { | ||
const changelogs = await host.glob(resolvePath(changesRelativeDir, "*.md"), { baseDir: workspace.path }); | ||
const changesets = await Promise.all(changelogs.map((x) => readChangeDescription(host, workspace, x))); | ||
return changesets; | ||
} | ||
//# sourceMappingURL=read.js.map |
@@ -1,8 +0,5 @@ | ||
import applyReleasePlan from "@changesets/apply-release-plan"; | ||
import { changesRelativeDir } from "../../change/common.js"; | ||
import { readChangeDescription } from "../../change/read.js"; | ||
import { deleteChangeDescription } from "../../change/write.js"; | ||
import { applyReleasePlan } from "../../apply-release-plan/index.js"; | ||
import { readChangeDescriptions } from "../../change/read.js"; | ||
import { assembleReleasePlan } from "../../release-plan/assemble-release-plan.js"; | ||
import { NodeChronusHost } from "../../utils/node-host.js"; | ||
import { resolvePath } from "../../utils/path-utils.js"; | ||
import { loadChronusWorkspace } from "../../workspace/load.js"; | ||
@@ -13,47 +10,9 @@ export async function applyChangesets(cwd, options) { | ||
const releasePlan = await resolveReleasePlan(host, workspace, options); | ||
const changeSetReleases = releasePlan.actions.map((x) => ({ | ||
...x, | ||
name: x.packageName, | ||
changesets: x.changes.map((y) => y.id), | ||
})); | ||
// Changeset will not bump the dependencies of ignored packages if there is not a release for it. Even though we are not changing the versions. | ||
const noopRelease = workspace.allPackages | ||
.filter((x) => !releasePlan.actions.some((y) => y.packageName === x.name)) | ||
.map((x) => ({ | ||
name: x.name, | ||
oldVersion: x.version, | ||
newVersion: x.version, | ||
changesets: [], | ||
type: "none", | ||
})); | ||
const changeSetReleasePlan = { | ||
changesets: releasePlan.changes.map(mapChangeToChangeset), | ||
releases: [...changeSetReleases, ...noopRelease], | ||
preState: undefined, | ||
}; | ||
const manyPkgs = { | ||
root: { dir: workspace.path }, | ||
tool: "pnpm", | ||
packages: workspace.allPackages.map((x) => ({ packageJson: x.manifest, name: x.name, dir: x.relativePath })), | ||
}; | ||
applyReleasePlan(changeSetReleasePlan, manyPkgs, undefined); | ||
for (const change of releasePlan.changes) { | ||
deleteChangeDescription(host, workspace, change); | ||
} | ||
await applyReleasePlan(host, workspace, releasePlan); | ||
} | ||
export async function resolveReleasePlan(host, workspace, options) { | ||
const changelogs = await host.glob(resolvePath(changesRelativeDir, "*.md"), { baseDir: workspace.path }); | ||
const changesets = await Promise.all(changelogs.map((x) => readChangeDescription(host, workspace, x))); | ||
const changesets = await readChangeDescriptions(host, workspace); | ||
const releasePlan = assembleReleasePlan(changesets, workspace, options); | ||
return releasePlan; | ||
} | ||
function mapChangeToChangeset(change) { | ||
return { | ||
id: change.id, | ||
summary: change.content, | ||
releases: change.packages.map((x) => { | ||
return { name: x, type: change.changeKind.versionType }; | ||
}), | ||
}; | ||
} | ||
//# sourceMappingURL=apply-changesets.js.map |
@@ -1,2 +0,2 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { VersionType } from "../types.js"; | ||
import type { WorkspaceType } from "../workspace-manager/types.js"; | ||
@@ -3,0 +3,0 @@ export interface ChronusUserConfig { |
@@ -1,3 +0,3 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { ChangeDescription } from "../change/types.js"; | ||
import type { VersionType } from "../types.js"; | ||
export interface ReleaseAction { | ||
@@ -4,0 +4,0 @@ readonly packageName: string; |
@@ -1,3 +0,3 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { VersionPolicy } from "../config/types.js"; | ||
import type { VersionType } from "../types.js"; | ||
export interface InternalReleaseAction { | ||
@@ -4,0 +4,0 @@ packageName: string; |
@@ -8,2 +8,3 @@ export * from "./errors.js"; | ||
export * from "./path-utils.js"; | ||
export type * from "./types.js"; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@chronus/chronus", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "chronus", | ||
@@ -29,10 +29,10 @@ "type": "module", | ||
"dependencies": { | ||
"@changesets/apply-release-plan": "^7.0.0", | ||
"globby": "^14.0.0", | ||
"globby": "^14.0.1", | ||
"js-yaml": "^4.1.0", | ||
"micromatch": "^4.0.5", | ||
"picocolors": "^1.0.0", | ||
"pluralize": "^8.0.0", | ||
"prettier": "^3.2.5", | ||
"prompts": "^2.4.2", | ||
"semver": "^7.5.4", | ||
"semver": "^7.6.0", | ||
"source-map-support": "^0.5.21", | ||
@@ -44,3 +44,2 @@ "vitest": "^1.2.2", | ||
"devDependencies": { | ||
"@changesets/types": "^6.0.0", | ||
"@types/cross-spawn": "^6.0.6", | ||
@@ -51,8 +50,9 @@ "@types/js-yaml": "^4.0.9", | ||
"@types/node-fetch": "^2.6.11", | ||
"@types/pluralize": "^0.0.33", | ||
"@types/prompts": "^2.4.9", | ||
"@types/semver": "^7.5.6", | ||
"@types/semver": "^7.5.7", | ||
"@types/xml2js": "^0.4.14", | ||
"@types/yargs": "^17.0.32", | ||
"@typescript-eslint/eslint-plugin": "^6.20.0", | ||
"@typescript-eslint/parser": "^6.20.0", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"cross-spawn": "^7.0.3", | ||
@@ -59,0 +59,0 @@ "eslint": "^8.56.0", |
export { resolveChangePath, resolveChangeRelativePath, resolveChangesDir } from "./common.js"; | ||
export { findChangeStatus } from "./find.js"; | ||
export { parseChangeDescription } from "./parse.js"; | ||
export { readChangeDescription } from "./read.js"; | ||
export { readChangeDescription, readChangeDescriptions } from "./read.js"; | ||
export type * from "./types.js"; | ||
export { printChangeDescription } from "./write.js"; |
@@ -1,7 +0,7 @@ | ||
import { dump } from "js-yaml"; | ||
import type { ChronusHost } from "../utils/host.js"; | ||
import { isDefined } from "../utils/misc-utils.js"; | ||
import { resolvePath } from "../utils/path-utils.js"; | ||
import type { ChronusWorkspace } from "../workspace/types.js"; | ||
import { changesRelativeDir } from "./common.js"; | ||
import { parseChangeDescription } from "./parse.js"; | ||
import type { ChangeDescription, ChangeDescriptionFrontMatter } from "./types.js"; | ||
import type { ChangeDescription } from "./types.js"; | ||
@@ -12,13 +12,2 @@ export interface PrintChangeDescriptionOptions { | ||
export function printChangeDescription(change: Omit<ChangeDescription, "id">, options?: PrintChangeDescriptionOptions) { | ||
const frontMatter: ChangeDescriptionFrontMatter = { | ||
changeKind: change.changeKind.name, | ||
packages: change.packages, | ||
}; | ||
const frontMatterComment = options?.frontMatterComment && `# ${options?.frontMatterComment}`; | ||
return ["---", frontMatterComment, dump(frontMatter, { quotingType: '"' }).trimEnd(), "---", "", change.content] | ||
.filter(isDefined) | ||
.join("\n"); | ||
} | ||
export async function readChangeDescription( | ||
@@ -32,1 +21,11 @@ host: ChronusHost, | ||
} | ||
/** Read all change descriptions */ | ||
export async function readChangeDescriptions( | ||
host: ChronusHost, | ||
workspace: ChronusWorkspace, | ||
): Promise<ChangeDescription[]> { | ||
const changelogs = await host.glob(resolvePath(changesRelativeDir, "*.md"), { baseDir: workspace.path }); | ||
const changesets = await Promise.all(changelogs.map((x) => readChangeDescription(host, workspace, x))); | ||
return changesets; | ||
} |
@@ -1,7 +0,3 @@ | ||
import applyReleasePlan from "@changesets/apply-release-plan"; | ||
import type { ReleasePlan as ChangesetReleasePlan, ComprehensiveRelease, NewChangeset } from "@changesets/types"; | ||
import { changesRelativeDir } from "../../change/common.js"; | ||
import { readChangeDescription } from "../../change/read.js"; | ||
import type { ChangeDescription } from "../../change/types.js"; | ||
import { deleteChangeDescription } from "../../change/write.js"; | ||
import { applyReleasePlan } from "../../apply-release-plan/index.js"; | ||
import { readChangeDescriptions } from "../../change/read.js"; | ||
import { assembleReleasePlan } from "../../release-plan/assemble-release-plan.js"; | ||
@@ -11,3 +7,2 @@ import type { ReleasePlan } from "../../release-plan/types.js"; | ||
import { NodeChronusHost } from "../../utils/node-host.js"; | ||
import { resolvePath } from "../../utils/path-utils.js"; | ||
import { loadChronusWorkspace } from "../../workspace/load.js"; | ||
@@ -24,32 +19,3 @@ import type { ChronusWorkspace } from "../../workspace/types.js"; | ||
const changeSetReleases = releasePlan.actions.map((x) => ({ | ||
...x, | ||
name: x.packageName, | ||
changesets: x.changes.map((y) => y.id), | ||
})); | ||
// Changeset will not bump the dependencies of ignored packages if there is not a release for it. Even though we are not changing the versions. | ||
const noopRelease: ComprehensiveRelease[] = workspace.allPackages | ||
.filter((x) => !releasePlan.actions.some((y) => y.packageName === x.name)) | ||
.map((x) => ({ | ||
name: x.name, | ||
oldVersion: x.version, | ||
newVersion: x.version, | ||
changesets: [], | ||
type: "none", | ||
})); | ||
const changeSetReleasePlan: ChangesetReleasePlan = { | ||
changesets: releasePlan.changes.map(mapChangeToChangeset), | ||
releases: [...changeSetReleases, ...noopRelease], | ||
preState: undefined, | ||
}; | ||
const manyPkgs = { | ||
root: { dir: workspace.path } as any, | ||
tool: "pnpm", | ||
packages: workspace.allPackages.map((x) => ({ packageJson: x.manifest as any, name: x.name, dir: x.relativePath })), | ||
} as const; | ||
applyReleasePlan(changeSetReleasePlan, manyPkgs, undefined); | ||
for (const change of releasePlan.changes) { | ||
deleteChangeDescription(host, workspace, change); | ||
} | ||
await applyReleasePlan(host, workspace, releasePlan); | ||
} | ||
@@ -62,4 +28,3 @@ | ||
): Promise<ReleasePlan> { | ||
const changelogs = await host.glob(resolvePath(changesRelativeDir, "*.md"), { baseDir: workspace.path }); | ||
const changesets = await Promise.all(changelogs.map((x) => readChangeDescription(host, workspace, x))); | ||
const changesets = await readChangeDescriptions(host, workspace); | ||
@@ -69,11 +34,1 @@ const releasePlan = assembleReleasePlan(changesets, workspace, options); | ||
} | ||
function mapChangeToChangeset(change: ChangeDescription): NewChangeset { | ||
return { | ||
id: change.id, | ||
summary: change.content, | ||
releases: change.packages.map((x) => { | ||
return { name: x, type: change.changeKind.versionType }; | ||
}), | ||
}; | ||
} |
@@ -1,4 +0,4 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import pc from "picocolors"; | ||
import type { ReleaseAction, ReleasePlan } from "../../release-plan/types.js"; | ||
import type { VersionType } from "../../types.js"; | ||
import { NodeChronusHost } from "../../utils/node-host.js"; | ||
@@ -5,0 +5,0 @@ import { loadChronusWorkspace } from "../../workspace/load.js"; |
@@ -1,2 +0,2 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { VersionType } from "../types.js"; | ||
import type { WorkspaceType } from "../workspace-manager/types.js"; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,1 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import { describe, expect, it } from "vitest"; | ||
@@ -6,2 +5,3 @@ import type { ChangeDescription } from "../change/types.js"; | ||
import type { ChronusResolvedConfig } from "../config/types.js"; | ||
import type { VersionType } from "../types.js"; | ||
import type { Package, PackageJson, Workspace } from "../workspace-manager/types.js"; | ||
@@ -8,0 +8,0 @@ import { createChronusWorkspace } from "../workspace/load.js"; |
@@ -1,3 +0,3 @@ | ||
import type { DependencyType, VersionType } from "@changesets/types"; | ||
import semverSatisfies from "semver/functions/satisfies.js"; | ||
import type { DependencyType, VersionType } from "../types.js"; | ||
import type { PackageJson } from "../workspace-manager/types.js"; | ||
@@ -4,0 +4,0 @@ import type { ChronusWorkspace } from "../workspace/types.js"; |
@@ -1,3 +0,3 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { VersionPolicy } from "../config/types.js"; | ||
import type { VersionType } from "../types.js"; | ||
@@ -4,0 +4,0 @@ export interface InternalReleaseAction { |
@@ -1,3 +0,3 @@ | ||
import type { VersionType } from "@changesets/types"; | ||
import type { ChangeDescription } from "../change/types.js"; | ||
import type { VersionType } from "../types.js"; | ||
@@ -4,0 +4,0 @@ export interface ReleaseAction { |
@@ -8,1 +8,2 @@ export * from "./errors.js"; | ||
export * from "./path-utils.js"; | ||
export type * from "./types.js"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
419741
297
6167
+ Addedpluralize@^8.0.0
+ Addedpluralize@8.0.0(transitive)
- Removed@babel/runtime@7.26.9(transitive)
- Removed@changesets/apply-release-plan@7.0.10(transitive)
- Removed@changesets/config@3.1.1(transitive)
- Removed@changesets/errors@0.2.0(transitive)
- Removed@changesets/get-dependents-graph@2.1.3(transitive)
- Removed@changesets/get-version-range-type@0.4.0(transitive)
- Removed@changesets/git@3.0.2(transitive)
- Removed@changesets/logger@0.1.1(transitive)
- Removed@changesets/should-skip-package@0.1.2(transitive)
- Removed@changesets/types@4.1.06.1.0(transitive)
- Removed@manypkg/find-root@1.1.0(transitive)
- Removed@manypkg/get-packages@1.1.3(transitive)
- Removed@types/node@12.20.55(transitive)
- Removedargparse@1.0.10(transitive)
- Removedarray-union@2.1.0(transitive)
- Removedbetter-path-resolve@1.0.0(transitive)
- Removeddetect-indent@6.1.0(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedextendable-error@0.1.7(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedfs-extra@7.0.18.1.0(transitive)
- Removedglobby@11.1.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedignore@5.3.2(transitive)
- Removedis-subdir@1.2.0(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedlodash.startcase@4.4.0(transitive)
- Removedoutdent@0.5.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpify@4.0.1(transitive)
- Removedprettier@2.8.8(transitive)
- Removedread-yaml-file@1.1.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedresolve-from@5.0.0(transitive)
- Removedslash@3.0.0(transitive)
- Removedspawndamnit@3.0.1(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)
Updatedglobby@^14.0.1
Updatedsemver@^7.6.0