@shivaedev/changesets 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +69 -2
  4. package/dist/applyRelease.d.ts +16 -0
  5. package/dist/applyRelease.d.ts.map +1 -0
  6. package/dist/applyRelease.js +55 -0
  7. package/dist/applyRelease.js.map +1 -0
  8. package/dist/check.d.ts +6 -0
  9. package/dist/check.d.ts.map +1 -0
  10. package/dist/check.js +69 -0
  11. package/dist/check.js.map +1 -0
  12. package/dist/cli.d.ts +3 -0
  13. package/dist/cli.d.ts.map +1 -0
  14. package/dist/cli.js +29 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/collectChangelog.d.ts +3 -0
  17. package/dist/collectChangelog.d.ts.map +1 -0
  18. package/dist/collectChangelog.js +17 -0
  19. package/dist/collectChangelog.js.map +1 -0
  20. package/dist/config.d.ts +14 -0
  21. package/dist/config.d.ts.map +1 -0
  22. package/dist/config.js +4 -0
  23. package/dist/config.js.map +1 -0
  24. package/dist/error.d.ts +13 -0
  25. package/dist/error.d.ts.map +1 -0
  26. package/dist/error.js +15 -0
  27. package/dist/error.js.map +1 -0
  28. package/dist/model.d.ts +68 -0
  29. package/dist/model.d.ts.map +1 -0
  30. package/dist/model.js +22 -0
  31. package/dist/model.js.map +1 -0
  32. package/dist/parser.d.ts +8 -0
  33. package/dist/parser.d.ts.map +1 -0
  34. package/dist/parser.js +30 -0
  35. package/dist/parser.js.map +1 -0
  36. package/dist/planner.d.ts +20 -0
  37. package/dist/planner.d.ts.map +1 -0
  38. package/dist/planner.js +71 -0
  39. package/dist/planner.js.map +1 -0
  40. package/dist/readHistory.d.ts +27 -0
  41. package/dist/readHistory.d.ts.map +1 -0
  42. package/dist/readHistory.js +37 -0
  43. package/dist/readHistory.js.map +1 -0
  44. package/dist/sections.d.ts +9 -0
  45. package/dist/sections.d.ts.map +1 -0
  46. package/dist/sections.js +36 -0
  47. package/dist/sections.js.map +1 -0
  48. package/dist/workspace.d.ts +37 -0
  49. package/dist/workspace.d.ts.map +1 -0
  50. package/dist/workspace.js +87 -0
  51. package/dist/workspace.js.map +1 -0
  52. package/docs/north-star.md +7 -0
  53. package/docs/roadmap.md +16 -0
  54. package/package.json +112 -3
  55. package/src/applyRelease.ts +64 -0
  56. package/src/check.ts +106 -0
  57. package/src/cli.ts +36 -0
  58. package/src/collectChangelog.ts +27 -0
  59. package/src/config.ts +16 -0
  60. package/src/error.ts +20 -0
  61. package/src/model.ts +38 -0
  62. package/src/parser.ts +33 -0
  63. package/src/planner.ts +73 -0
  64. package/src/readHistory.ts +38 -0
  65. package/src/sections.ts +40 -0
  66. package/src/workspace.ts +109 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-10-18
4
+
5
+ ### Added
6
+
7
+ - Plan and apply workspace releases from root changesets with explicit bumps, grouped release notes and transitive published dependents.
8
+ - Validate pending changesets and reproduce collected releases from manifests while protecting released history and later pending changes.
9
+ - Run repository release hooks as typed Effect functions through the CLI or the plan, apply and check Effect APIs.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShivaeDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,70 @@
1
- # Temporary Holding Version
1
+ # @shivaedev/changesets
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Turn explicit change notes into a reproducible workspace release. See every version bump, include published dependents, and check the collected notes against their original inputs after a squash merge.
4
+
5
+ ## One plan for the release
6
+
7
+ Authors record the packages and bumps they intend. The release tool carries that intent through versions and grouped changelogs.
8
+
9
+ ```markdown
10
+ ---
11
+ "@acme/core": minor
12
+ "@acme/client": patch
13
+ ---
14
+
15
+ ### Added
16
+
17
+ - Keep a draft when its query refreshes.
18
+ ```
19
+
20
+ ```text
21
+ @acme/client: 0.4.0 -> 0.4.1 (patch)
22
+ @acme/core: 0.2.3 -> 0.3.0 (minor)
23
+ ```
24
+
25
+ ## Use changesets
26
+
27
+ Put changes in one repository-root `.changeset/` directory, with a unique `.md` filename per change. Frontmatter is a flat YAML mapping from package names to explicit `patch`, `minor` or `major` bumps; quoted and bare scalars and comments are supported. One file can name several packages. Under the frontmatter, write Markdown list entries beneath `### Added`, `### Changed`, `### Fixed` or `### Breaking`. Indented continuation lines belong to the preceding entry. `README.md` is reserved for directory instructions.
28
+
29
+ The planner takes the highest requested bump for each package. Every published workspace dependent receives at least a patch, transitively, through dependencies, optional dependencies and peers. Private and development-only dependents do not receive an automatic release. A `major` bump on a `0.x` version fails: use `minor` for breaking changes before 1.0. Package versions must be stable `major.minor.patch` versions.
30
+
31
+ ### Configure the repository
32
+
33
+ By default, package directories are `packages/*` and `examples/*`. Override them in `.changeset/changesets.config.ts` with relative directory paths or `parent/*` patterns. Hooks receive the release plan and run after collection. They are Effect functions with filesystem access and typed `ChangesetError` or platform failures.
34
+
35
+ ```ts
36
+ import { Effect, FileSystem } from "effect";
37
+ import { defineConfig } from "@shivaedev/changesets/config.ts";
38
+
39
+ export default defineConfig({
40
+ packages: ["packages/*"],
41
+ hooks: [({ root, plan }) => Effect.gen(function* () {
42
+ const fs = yield* FileSystem.FileSystem;
43
+ const versions = Object.fromEntries(plan.releases.map(release => [release.name, release.to]));
44
+ yield* fs.writeFileString(`${root}/published-versions.json`, JSON.stringify(versions));
45
+ })],
46
+ });
47
+ ```
48
+
49
+ ### Plan, apply and check
50
+
51
+ ```sh
52
+ changesets plan
53
+ changesets plan --json
54
+ changesets apply
55
+ changesets check origin/main
56
+ ```
57
+
58
+ `plan --json` prints the typed `ReleasePlan`: the exact changeset filenames and text, plus each release's name, directory, previous version, next version and bump. The default output is a human summary. Planning does not write files.
59
+
60
+ `apply` computes the current plan, bumps `package.json` versions, prepends changelog entries dated in UTC, writes `.changeset/release.json`, deletes consumed files and runs hooks in order. Changelog sections use Added, Changed, Fixed, Breaking order, with changesets sorted by filename. Dependents without their own entries receive a dependency release note. Workspace wildcard dependency declarations remain intact; exact, caret and tilde references to released workspace packages advance to their next versions. Other range forms require an explicit supported declaration before applying. An empty plan writes nothing.
61
+
62
+ `check [base-ref]` checks pending files and the diff from the merge base with `HEAD`. Its default base is `origin/main`, falling back to `main`. Fetch history or pass a known base when neither exists. The release manifest records all inputs, including changesets added and consumed within the same diff. Validation reproduces the plan and changelogs, rejects changed release inputs, retained consumed files, missing dependents, changes to released history and changelog edits without a bump. Changesets outside the manifest remain pending and must remain unchanged if they existed at the base. Keep the manifest in version control.
63
+
64
+ Hook failures are returned through Effect; collection has already written its files at that point. Review or restore the release diff before retrying after a hook failure.
65
+
66
+ ### Effect API
67
+
68
+ Import `planRelease(root, config?)` and `summarizePlan(plan)` from `@shivaedev/changesets/planner.ts`, `applyRelease(root, config?)` from `/applyRelease.ts`, and `checkRepository(root, config?, baseRef?)` from `/check.ts`. Provide `FileSystem.FileSystem` to the filesystem operations. `/model.ts` defines the plan schemas and types; `/error.ts` defines `ChangesetError`. `@shivaedev/changesets/parser.ts` exports the pure `parseChangeset({ name, text })` parser. The CLI loads `.changeset/changesets.config.ts`; callers of the Effect API pass config directly.
69
+
70
+ Install with `pnpm add -D @shivaedev/changesets effect @effect/platform-node @effect/platform-node-shared`. Node.js 24 or later runs the CLI and TypeScript config. Publishing remains the repository's job.
@@ -0,0 +1,16 @@
1
+ import { Effect, FileSystem } from "effect";
2
+ import type { ChangesetConfig } from "#config.ts";
3
+ export declare const applyRelease: (root: string, config?: ChangesetConfig | undefined) => Effect.Effect<{
4
+ readonly changesets: readonly {
5
+ readonly name: string;
6
+ readonly text: string;
7
+ }[];
8
+ readonly releases: readonly {
9
+ readonly bump: "major" | "minor" | "patch";
10
+ readonly directory: string;
11
+ readonly from: string;
12
+ readonly name: string;
13
+ readonly to: string;
14
+ }[];
15
+ }, import("#error.ts").ChangesetError | import("effect/PlatformError").PlatformError, FileSystem.FileSystem>;
16
+ //# sourceMappingURL=applyRelease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyRelease.d.ts","sourceRoot":"","sources":["../src/applyRelease.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA8BlD,eAAO,MAAM,YAAY;;;;;;;;;;;;4GA8BvB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { join } from "node:path";
2
+ import { Clock, Effect, FileSystem } from "effect";
3
+ import { collectChangelog } from "#collectChangelog.ts";
4
+ import { attempt, requireThat } from "#error.ts";
5
+ import { computePlan } from "#planner.ts";
6
+ import { readWorkspace } from "#workspace.ts";
7
+ function updatedPackage(pkg, plan, version) {
8
+ const json = { ...pkg.json, version };
9
+ for (const key of ["dependencies", "optionalDependencies", "peerDependencies"]) {
10
+ const dependencies = pkg.manifest[key];
11
+ if (dependencies !== undefined) {
12
+ json[key] = Object.fromEntries(Object.entries(dependencies).map(([name, range]) => {
13
+ const target = plan.releases.find((release) => release.name === name);
14
+ if (target === undefined || ["workspace:*", "workspace:^", "workspace:~"].includes(range)) {
15
+ return [name, range];
16
+ }
17
+ const match = /^(?<prefix>(?:workspace:)?[~^]?)\d+\.\d+\.\d+$/u.exec(range);
18
+ requireThat(match !== null, `${pkg.manifest.name}: replace ${name}'s ${range} range with an exact version, ^version, ~version or workspace:* before applying a release.`);
19
+ const prefix = match?.groups?.prefix ?? "";
20
+ return [name, `${prefix}${target.to}`];
21
+ }));
22
+ }
23
+ }
24
+ return `${JSON.stringify(json, null, "\t")}\n`;
25
+ }
26
+ export const applyRelease = Effect.fn("Changesets.applyRelease")(function* (root, config = {}) {
27
+ const fs = yield* FileSystem.FileSystem;
28
+ const workspace = yield* readWorkspace(root, config);
29
+ const plan = yield* attempt(() => computePlan(workspace.packages, workspace.changesets));
30
+ if (plan.releases.length === 0) {
31
+ return plan;
32
+ }
33
+ const date = new Date(yield* Clock.currentTimeMillis).toISOString().slice(0, 10);
34
+ const writes = yield* attempt(() => plan.releases.flatMap((release) => {
35
+ const pkg = workspace.packages.find((candidate) => candidate.manifest.name === release.name);
36
+ if (pkg === undefined) {
37
+ throw new Error(`Package ${release.name} disappeared while applying.`);
38
+ }
39
+ return [
40
+ { path: join(root, release.directory, "package.json"), text: updatedPackage(pkg, plan, release.to) },
41
+ { path: join(root, release.directory, "CHANGELOG.md"), text: collectChangelog(pkg.changelog, release, plan, date) },
42
+ ];
43
+ }));
44
+ const manifest = { date, plan };
45
+ for (const write of writes) {
46
+ yield* fs.writeFileString(write.path, write.text);
47
+ }
48
+ yield* fs.writeFileString(join(root, ".changeset/release.json"), `${JSON.stringify(manifest, null, "\t")}\n`);
49
+ yield* Effect.forEach(plan.changesets, (source) => fs.remove(join(root, ".changeset", source.name)));
50
+ for (const hook of config.hooks ?? []) {
51
+ yield* hook({ plan, root });
52
+ }
53
+ return plan;
54
+ });
55
+ //# sourceMappingURL=applyRelease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyRelease.js","sourceRoot":"","sources":["../src/applyRelease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,SAAS,cAAc,CAAC,GAAqB,EAAE,IAAiB,EAAE,OAAe;IAChF,MAAM,IAAI,GAA4B,EAAE,GAAG,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;IAC/D,KAAK,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,sBAAsB,EAAE,kBAAkB,CAAU,EAAE,CAAC;QACzF,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAC7B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;gBAClD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;gBACtE,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,aAAa,EAAE,aAA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AC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9G,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrG,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Effect } from "effect";
2
+ import type { ChangesetConfig } from "#config.ts";
3
+ import type { Workspace } from "#model.ts";
4
+ export declare function validateDiff(before: Workspace, after: Workspace): void;
5
+ export declare const checkRepository: (root: string, config?: ChangesetConfig | undefined, reference?: string | undefined) => Effect.Effect<void, import("#error.ts").ChangesetError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
6
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,KAAK,EAAU,SAAS,EAAE,MAAM,WAAW,CAAC;AAkCnD,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CA4DtE;AAED,eAAO,MAAM,eAAe,wOAK1B,CAAC"}
package/dist/check.js ADDED
@@ -0,0 +1,69 @@
1
+ import { Effect } from "effect";
2
+ import { collectChangelog } from "#collectChangelog.ts";
3
+ import { attempt, requireThat } from "#error.ts";
4
+ import { computePlan } from "#planner.ts";
5
+ import { readHistory } from "#readHistory.ts";
6
+ import { isChangeset, readWorkspace } from "#workspace.ts";
7
+ function same(left, right) {
8
+ return JSON.stringify(left) === JSON.stringify(right);
9
+ }
10
+ function validateInputs(before, pending, consumed) {
11
+ requireThat(new Set(consumed.map((source) => source.name)).size === consumed.length && consumed.every((source) => isChangeset(source.name)), "Release manifest changeset names must be unique .md filenames; restore the manifest generated by changesets apply.");
12
+ for (const source of consumed) {
13
+ requireThat(!pending.some((item) => item.name === source.name), `${source.name}: consumed changesets must be deleted; remove .changeset/${source.name}.`);
14
+ const previous = before.find((item) => item.name === source.name);
15
+ requireThat(previous === undefined || previous.text === source.text, `${source.name}: release inputs changed; restore the original changeset text and rerun changesets apply.`);
16
+ }
17
+ for (const source of before) {
18
+ const preserved = [...pending, ...consumed].find((item) => item.name === source.name);
19
+ requireThat(preserved?.text === source.text, `${source.name}: keep pending changesets unchanged or consume them unchanged in .changeset/release.json; add a new file for later changes.`);
20
+ }
21
+ }
22
+ export function validateDiff(before, after) {
23
+ for (const old of before.packages) {
24
+ requireThat(after.packages.some((pkg) => pkg.manifest.name === old.manifest.name), `${old.manifest.name}: restore the package and its released history before checking releases.`);
25
+ }
26
+ const bumped = after.packages.filter((pkg) => {
27
+ const old = before.packages.find((candidate) => candidate.manifest.name === pkg.manifest.name);
28
+ const firstRelease = after.release?.plan.releases.find((candidate) => candidate.name === pkg.manifest.name);
29
+ return old === undefined
30
+ ? firstRelease !== undefined && firstRelease.from !== pkg.manifest.version
31
+ : old.manifest.version !== pkg.manifest.version;
32
+ });
33
+ if (bumped.length === 0) {
34
+ requireThat(same(before.release, after.release), ".changeset/release.json changes only with a release; restore it and run changesets apply.");
35
+ validateInputs(before.changesets, after.changesets, []);
36
+ for (const pkg of after.packages) {
37
+ const old = before.packages.find((candidate) => candidate.manifest.name === pkg.manifest.name);
38
+ requireThat(old === undefined || old.changelog === pkg.changelog, `${pkg.manifest.name}: CHANGELOG.md changes require a version bump; add .changeset/<name>.md and run changesets apply.`);
39
+ }
40
+ return;
41
+ }
42
+ const manifest = after.release;
43
+ requireThat(manifest !== undefined && !same(before.release, manifest), "A release needs .changeset/release.json; restore versions and run changesets apply.");
44
+ if (manifest === undefined) {
45
+ return;
46
+ }
47
+ validateInputs(before.changesets, after.changesets, manifest.plan.changesets);
48
+ const packages = after.packages.map((pkg) => {
49
+ const old = before.packages.find((candidate) => candidate.manifest.name === pkg.manifest.name);
50
+ const version = old?.manifest.version ?? manifest.plan.releases.find((candidate) => candidate.name === pkg.manifest.name)?.from ?? pkg.manifest.version;
51
+ return { ...pkg, manifest: { ...pkg.manifest, version } };
52
+ });
53
+ const plan = computePlan(packages, manifest.plan.changesets);
54
+ requireThat(plan.releases.length > 0 && same(plan, manifest.plan), "Release manifest does not match the changeset plan; restore versions and rerun changesets apply, including published dependents.");
55
+ for (const pkg of after.packages) {
56
+ const old = before.packages.find((candidate) => candidate.manifest.name === pkg.manifest.name);
57
+ const release = plan.releases.find((candidate) => candidate.name === pkg.manifest.name);
58
+ requireThat(pkg.manifest.version === (release?.to ?? old?.manifest.version ?? pkg.manifest.version), `${pkg.manifest.name}: version differs from the release plan; restore versions and rerun changesets apply.`);
59
+ const expected = release === undefined ? (old?.changelog ?? pkg.changelog) : collectChangelog(old?.changelog ?? "# Changelog\n", release, plan, manifest.date);
60
+ requireThat(pkg.changelog === expected, `${pkg.manifest.name}: release notes differ from changesets apply; restore released history and regenerate the release from unchanged inputs.`);
61
+ }
62
+ }
63
+ export const checkRepository = Effect.fn("Changesets.checkRepository")(function* (root, config = {}, reference) {
64
+ const after = yield* readWorkspace(root, config);
65
+ yield* attempt(() => computePlan(after.packages, after.changesets));
66
+ const before = yield* readHistory(root, config, reference);
67
+ yield* attempt(() => validateDiff(before, after));
68
+ });
69
+ //# sourceMappingURL=check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../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CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import process from "node:process";
3
+ import { NodeFileSystem, NodeRuntime } from "@effect/platform-node";
4
+ import { Console, Effect } from "effect";
5
+ import { applyRelease } from "#applyRelease.ts";
6
+ import { checkRepository } from "#check.ts";
7
+ import { ChangesetError } from "#error.ts";
8
+ import { planRelease, summarizePlan } from "#planner.ts";
9
+ import { loadConfig } from "#workspace.ts";
10
+ const program = Effect.gen(function* () {
11
+ const [command, argument, ...extra] = process.argv.slice(2);
12
+ if (!["plan", "apply", "check"].includes(command ?? "")
13
+ || extra.length > 0
14
+ || (argument !== undefined && command !== "check" && !(command === "plan" && argument === "--json"))) {
15
+ return yield* new ChangesetError({ message: "Use changesets plan [--json], changesets apply, or changesets check [base-ref]." });
16
+ }
17
+ const root = process.cwd();
18
+ const config = yield* loadConfig(root);
19
+ if (command === "check") {
20
+ yield* checkRepository(root, config, argument);
21
+ yield* Console.log("Changesets and release notes are valid.");
22
+ }
23
+ else {
24
+ const plan = yield* command === "apply" ? applyRelease(root, config) : planRelease(root, config);
25
+ yield* Console.log(argument === "--json" ? JSON.stringify(plan, null, 2) : summarizePlan(plan));
26
+ }
27
+ });
28
+ NodeRuntime.runMain(program.pipe(Effect.tapError((error) => Console.error(error.message)), Effect.provide(NodeFileSystem.layer)), { disableErrorReporting: true });
29
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,cAA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OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACP,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACjG,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IACjG,CAAC;AACF,CAAC,CAAC,CAAC;AACH,WAAW,CAAC,OAAO,CAClB,OAAO,CAAC,IAAI,CACX,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EACxD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CACpC,EACD,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Release, ReleasePlan } from "#model.ts";
2
+ export declare function collectChangelog(previous: string, release: Release, plan: ReleasePlan, date: string): string;
3
+ //# sourceMappingURL=collectChangelog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectChangelog.d.ts","sourceRoot":"","sources":["../src/collectChangelog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAItD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB5G"}
@@ -0,0 +1,17 @@
1
+ import { requireThat } from "#error.ts";
2
+ import { parseChangeset } from "#parser.ts";
3
+ import { renderEntries } from "#sections.ts";
4
+ export function collectChangelog(previous, release, plan, date) {
5
+ const timestamp = Date.parse(`${date}T00:00:00Z`);
6
+ requireThat(/^\d{4}-\d{2}-\d{2}$/u.test(date) && Number.isFinite(timestamp) && new Date(timestamp).toISOString().slice(0, 10) === date, "Use a valid UTC YYYY-MM-DD release date in .changeset/release.json; rerun changesets apply.");
7
+ requireThat(previous.startsWith("# Changelog\n") && !/^## Unreleased\s*$/mu.test(previous), `${release.name}: use a '# Changelog' title and move Unreleased notes into .changeset/*.md.`);
8
+ requireThat(!new RegExp(`^## ${release.to.replaceAll(".", "\\.")}(?: - |$)`, "mu").test(previous), `${release.name}: version ${release.to} already has notes; restore the package version and rerun changesets apply.`);
9
+ const entries = plan.changesets.flatMap((source) => {
10
+ const changeset = parseChangeset(source);
11
+ return Object.hasOwn(changeset.packages, release.name) ? changeset.entries : [];
12
+ });
13
+ const dependencyNotes = entries.length === 0 ? [{ section: "Changed", text: "- Release with updated workspace dependencies." }] : [];
14
+ const history = previous.slice("# Changelog\n".length).trimStart();
15
+ return `# Changelog\n\n## ${release.to} - ${date}\n\n${renderEntries([...entries, ...dependencyNotes])}${history === "" ? "" : `\n${history}`}`;
16
+ }
17
+ //# sourceMappingURL=collectChangelog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectChangelog.js","sourceRoot":"","sources":["../src/collectChangelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,OAAgB,EAAE,IAAiB,EAAE,IAAY;IACnG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC;IAClD,WAAW,CACV,s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MAAM,IAAI,OAAO,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,eAAe,CAAC,CAAC,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,EAAE,CAAC;AACjJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Effect, FileSystem, PlatformError } from "effect";
2
+ import type { ChangesetError } from "#error.ts";
3
+ import type { ReleasePlan } from "#model.ts";
4
+ export interface HookContext {
5
+ readonly plan: ReleasePlan;
6
+ readonly root: string;
7
+ }
8
+ export type ReleaseHook = (context: HookContext) => Effect.Effect<void, ChangesetError | PlatformError.PlatformError, FileSystem.FileSystem>;
9
+ export interface ChangesetConfig {
10
+ readonly hooks?: readonly ReleaseHook[];
11
+ readonly packages?: readonly string[];
12
+ }
13
+ export declare function defineConfig(config: ChangesetConfig): ChangesetConfig;
14
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,aAAa,CAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;AAC7I,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AACD,wBAAgB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAErE"}
package/dist/config.js ADDED
@@ -0,0 +1,4 @@
1
+ export function defineConfig(config) {
2
+ return config;
3
+ }
4
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,YAAY,CAAC,MAAuB;IACnD,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Effect } from "effect";
2
+ declare const ChangesetError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "ChangesetError";
4
+ } & Readonly<A>;
5
+ export declare class ChangesetError extends ChangesetError_base<{
6
+ readonly message: string;
7
+ readonly cause?: unknown;
8
+ }> {
9
+ }
10
+ export declare function attempt<A>(evaluate: () => A): Effect.Effect<A, ChangesetError, never>;
11
+ export declare function requireThat(condition: boolean, message: string): void;
12
+ export {};
13
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEtC,qBAAa,cAAe,SAAQ,oBAAmC;IACtE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;CAAG;AAEL,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,2CAM3C;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrE"}
package/dist/error.js ADDED
@@ -0,0 +1,15 @@
1
+ import { Data, Effect } from "effect";
2
+ export class ChangesetError extends Data.TaggedError("ChangesetError") {
3
+ }
4
+ export function attempt(evaluate) {
5
+ return Effect.try({
6
+ catch: (cause) => cause instanceof ChangesetError ? cause : new ChangesetError({ cause, message: cause instanceof Error ? cause.message : String(cause) }),
7
+ try: evaluate,
8
+ });
9
+ }
10
+ export function requireThat(condition, message) {
11
+ if (!condition) {
12
+ throw new ChangesetError({ message });
13
+ }
14
+ }
15
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAGnE;CAAG;AAEL,MAAM,UAAU,OAAO,CAAI,QAAiB;IAC3C,OAAO,MAAM,CAAC,GAAG,CAAC;QACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,KAAK,YAAY,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACzI,GAAG,EAAE,QAAQ;KACb,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAkB,EAAE,OAAe;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;AACF,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { Schema } from "effect";
2
+ export declare const Bump: Schema.Literals<readonly ["patch", "minor", "major"]>;
3
+ export type Bump = typeof Bump.Type;
4
+ export declare const Source: Schema.Struct<{
5
+ readonly name: Schema.String;
6
+ readonly text: Schema.String;
7
+ }>;
8
+ export type Source = typeof Source.Type;
9
+ export declare const PackageManifest: Schema.Struct<{
10
+ readonly dependencies: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
11
+ readonly name: Schema.String;
12
+ readonly optionalDependencies: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
13
+ readonly peerDependencies: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
14
+ readonly private: Schema.optional<Schema.Boolean>;
15
+ readonly version: Schema.String;
16
+ }>;
17
+ export type PackageManifest = typeof PackageManifest.Type;
18
+ export interface WorkspacePackage {
19
+ readonly changelog: string;
20
+ readonly directory: string;
21
+ readonly json: Readonly<Record<string, unknown>>;
22
+ readonly manifest: PackageManifest;
23
+ }
24
+ export declare const Release: Schema.Struct<{
25
+ readonly bump: Schema.Literals<readonly ["patch", "minor", "major"]>;
26
+ readonly directory: Schema.String;
27
+ readonly from: Schema.String;
28
+ readonly name: Schema.String;
29
+ readonly to: Schema.String;
30
+ }>;
31
+ export type Release = typeof Release.Type;
32
+ export declare const ReleasePlan: Schema.Struct<{
33
+ readonly changesets: Schema.$Array<Schema.Struct<{
34
+ readonly name: Schema.String;
35
+ readonly text: Schema.String;
36
+ }>>;
37
+ readonly releases: Schema.$Array<Schema.Struct<{
38
+ readonly bump: Schema.Literals<readonly ["patch", "minor", "major"]>;
39
+ readonly directory: Schema.String;
40
+ readonly from: Schema.String;
41
+ readonly name: Schema.String;
42
+ readonly to: Schema.String;
43
+ }>>;
44
+ }>;
45
+ export type ReleasePlan = typeof ReleasePlan.Type;
46
+ export declare const ReleaseManifest: Schema.Struct<{
47
+ readonly date: Schema.String;
48
+ readonly plan: Schema.Struct<{
49
+ readonly changesets: Schema.$Array<Schema.Struct<{
50
+ readonly name: Schema.String;
51
+ readonly text: Schema.String;
52
+ }>>;
53
+ readonly releases: Schema.$Array<Schema.Struct<{
54
+ readonly bump: Schema.Literals<readonly ["patch", "minor", "major"]>;
55
+ readonly directory: Schema.String;
56
+ readonly from: Schema.String;
57
+ readonly name: Schema.String;
58
+ readonly to: Schema.String;
59
+ }>>;
60
+ }>;
61
+ }>;
62
+ export type ReleaseManifest = typeof ReleaseManifest.Type;
63
+ export interface Workspace {
64
+ readonly changesets: readonly Source[];
65
+ readonly packages: readonly WorkspacePackage[];
66
+ readonly release: ReleaseManifest | undefined;
67
+ }
68
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,eAAO,MAAM,IAAI,uDAA+C,CAAC;AACjE,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AACpC,eAAO,MAAM,MAAM;;;EAA8D,CAAC;AAClF,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAExC,eAAO,MAAM,eAAe;;;;;;;EAO1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAC1D,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;CACnC;AACD,eAAO,MAAM,OAAO;;;;;;EAMlB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAC1C,eAAO,MAAM,WAAW;;;;;;;;;;;;EAAuF,CAAC;AAChH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAClD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAA4D,CAAC;AACzF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAC1D,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,SAAS,CAAC;CAC9C"}
package/dist/model.js ADDED
@@ -0,0 +1,22 @@
1
+ import { Schema } from "effect";
2
+ export const Bump = Schema.Literals(["patch", "minor", "major"]);
3
+ export const Source = Schema.Struct({ name: Schema.String, text: Schema.String });
4
+ const Versions = Schema.Record(Schema.String, Schema.String);
5
+ export const PackageManifest = Schema.Struct({
6
+ dependencies: Schema.optional(Versions),
7
+ name: Schema.String,
8
+ optionalDependencies: Schema.optional(Versions),
9
+ peerDependencies: Schema.optional(Versions),
10
+ private: Schema.optional(Schema.Boolean),
11
+ version: Schema.String,
12
+ });
13
+ export const Release = Schema.Struct({
14
+ bump: Bump,
15
+ directory: Schema.String,
16
+ from: Schema.String,
17
+ name: Schema.String,
18
+ to: Schema.String,
19
+ });
20
+ export const ReleasePlan = Schema.Struct({ changesets: Schema.Array(Source), releases: Schema.Array(Release) });
21
+ export const ReleaseManifest = Schema.Struct({ date: Schema.String, plan: ReleasePlan });
22
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CA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4
+ readonly entries: readonly Entry[];
5
+ readonly packages: Readonly<Record<string, Bump>>;
6
+ }
7
+ export declare function parseChangeset(source: Source): Changeset;
8
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAa,MAAM,cAAc,CAAC;AACrD,MAAM,WAAW,SAAU,SAAQ,MAAM;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;CAClD;AAOD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAkBxD"}
package/dist/parser.js ADDED
@@ -0,0 +1,30 @@
1
+ import { Schema } from "effect";
2
+ import { requireThat } from "#error.ts";
3
+ import { Bump } from "#model.ts";
4
+ import { parseBody } from "#sections.ts";
5
+ function scalar(value) {
6
+ if (value.startsWith('"')) {
7
+ return Schema.decodeUnknownSync(Schema.fromJsonString(Schema.String))(value);
8
+ }
9
+ return value.startsWith("'") && value.endsWith("'") ? value.slice(1, -1).replaceAll("''", "'") : value;
10
+ }
11
+ export function parseChangeset(source) {
12
+ const match = /^---\n(?<header>[\s\S]*?)\n---\n(?<body>[\s\S]*)$/u.exec(source.text.replaceAll("\r\n", "\n"));
13
+ requireThat(match !== null, `${source.name}: add YAML frontmatter between --- lines, mapping package names to patch, minor or major.`);
14
+ const packages = {};
15
+ for (const line of (match?.groups?.header ?? "").split("\n")) {
16
+ if (line.trim() === "" || line.trimStart().startsWith("#")) {
17
+ continue;
18
+ }
19
+ const mapping = /^\s*(?<name>"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s:'"{}[\],#]+)\s*:\s*(?<bump>"[^"]*"|'[^']*'|[^\s#]+)\s*(?:#.*)?$/u.exec(line);
20
+ requireThat(mapping !== null, `${source.name}: use one YAML package: bump mapping per line, for example '"@scope/pkg": minor'.`);
21
+ const name = scalar(mapping?.groups?.name ?? "");
22
+ const bump = scalar(mapping?.groups?.bump ?? "");
23
+ requireThat(name !== "" && !Object.hasOwn(packages, name), `${source.name}: name each package once in frontmatter.`);
24
+ requireThat(Schema.is(Bump)(bump), `${source.name}: ${name} needs an explicit patch, minor or major bump.`);
25
+ packages[name] = Schema.decodeUnknownSync(Bump)(bump);
26
+ }
27
+ requireThat(Object.keys(packages).length > 0, `${source.name}: name at least one package and its explicit bump in frontmatter.`);
28
+ return { ...source, entries: parseBody(source.name, match?.groups?.body ?? ""), packages };
29
+ }
30
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,IAAI,EAAe,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAc,SAAS,EAAE,MAAM,cAAc,CAAC;AAKrD,SAAS,MAAM,CAAC,KAAa;IAC5B,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC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C,IAAI,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,mEAAmE,CAAC,CAAC;IACjI,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC5F,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Effect } from "effect";
2
+ import type { ChangesetConfig } from "#config.ts";
3
+ import type { PackageManifest, ReleasePlan, Source, WorkspacePackage } from "#model.ts";
4
+ export declare function publishedDependencies(manifest: PackageManifest): readonly string[];
5
+ export declare function computePlan(packages: readonly WorkspacePackage[], sources: readonly Source[]): ReleasePlan;
6
+ export declare function summarizePlan(plan: ReleasePlan): string;
7
+ export declare const planRelease: (root: string, config?: ChangesetConfig | undefined) => Effect.Effect<{
8
+ readonly changesets: readonly {
9
+ readonly name: string;
10
+ readonly text: string;
11
+ }[];
12
+ readonly releases: readonly {
13
+ readonly bump: "major" | "minor" | "patch";
14
+ readonly directory: string;
15
+ readonly from: string;
16
+ readonly name: string;
17
+ readonly to: string;
18
+ }[];
19
+ }, import("#error.ts").ChangesetError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
20
+ //# sourceMappingURL=planner.d.ts.map