@effected/changesets 0.0.0-stage → 0.2.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.
package/index.d.ts ADDED
@@ -0,0 +1,483 @@
1
+ import { Effect, FileSystem, Option, Path, PlatformError, Result, Schema } from "effect";
2
+ import { InvalidVersionError } from "@effected/semver";
3
+ import { WorkspaceDiscovery, WorkspaceDiscoveryError, WorkspacePackage, WorkspaceRootNotFoundError } from "@effected/workspaces";
4
+ /**
5
+ * A semver bump a changeset can request: `patch`, `minor` or `major`.
6
+ *
7
+ * @public
8
+ */
9
+ export declare const BumpType: Schema.Literals<readonly ["patch", "minor", "major"]>;
10
+ /**
11
+ * The type of a `BumpType` value.
12
+ *
13
+ * @public
14
+ */
15
+ export type BumpType = typeof BumpType.Type;
16
+ /**
17
+ * What a changeset can say about a package: a {@link (BumpType:variable)}, or `none`, which names the package and
18
+ * moves no version.
19
+ *
20
+ * @public
21
+ */
22
+ export declare const ReleaseType: Schema.Literals<readonly ["patch", "minor", "major", "none"]>;
23
+ /**
24
+ * The type of a `ReleaseType` value.
25
+ *
26
+ * @public
27
+ */
28
+ export type ReleaseType = typeof ReleaseType.Type;
29
+ declare const ChangesetParseError_base: Schema.Class<ChangesetParseError, Schema.TaggedStruct<"ChangesetParseError", {
30
+ /** What was wrong with the file. */
31
+ readonly reason: Schema.String;
32
+ /** The 1-based line the problem was found on, when known. */
33
+ readonly line: Schema.optionalKey<Schema.Number>;
34
+ /** The changeset file name, when the file was read from `.changeset/`. */
35
+ readonly file: Schema.optionalKey<Schema.String>;
36
+ }>, import("effect/Cause").YieldableError>;
37
+ /**
38
+ * A changeset file could not be parsed: no front matter, a malformed YAML
39
+ * block, or a bump outside `patch | minor | major`.
40
+ *
41
+ * @public
42
+ */
43
+ export declare class ChangesetParseError extends ChangesetParseError_base {
44
+ get message(): string;
45
+ }
46
+ declare const ChangesetConfigError_base: Schema.Class<ChangesetConfigError, Schema.TaggedStruct<"ChangesetConfigError", {
47
+ /** `"missing"` when the file does not exist, otherwise what was wrong. */
48
+ readonly reason: Schema.String;
49
+ }>, import("effect/Cause").YieldableError>;
50
+ /**
51
+ * `.changeset/config.json` is missing, is not valid JSON, or does not match
52
+ * the documented shape.
53
+ *
54
+ * @public
55
+ */
56
+ export declare class ChangesetConfigError extends ChangesetConfigError_base {
57
+ get message(): string;
58
+ }
59
+ declare const UnknownPackageError_base: Schema.Class<UnknownPackageError, Schema.TaggedStruct<"UnknownPackageError", {
60
+ /** The package name the changeset gave. */
61
+ readonly packageName: Schema.String;
62
+ /** The changeset file that named it. */
63
+ readonly changeset: Schema.String;
64
+ }>, import("effect/Cause").YieldableError>;
65
+ /**
66
+ * A changeset names a package the workspace does not contain.
67
+ *
68
+ * @public
69
+ */
70
+ export declare class UnknownPackageError extends UnknownPackageError_base {
71
+ get message(): string;
72
+ }
73
+ declare const ChangesetConfig_base: Schema.Class<ChangesetConfig, Schema.Struct<{
74
+ /** The branch releases are cut against. Defaults to `main`. */
75
+ readonly baseBranch: Schema.withDecodingDefaultKey<Schema.String, never>;
76
+ /**
77
+ * Groups of packages that always release together at one version: when
78
+ * one bumps, every member does, by the group's highest bump, from the
79
+ * group's highest current version. Entries are globs over the
80
+ * workspace's names, with `!` negation applying in order.
81
+ */
82
+ readonly fixed: Schema.withDecodingDefaultKey<Schema.$Array<Schema.$Array<Schema.String>>, never>;
83
+ /**
84
+ * Groups of packages whose versions are kept in step: the members that
85
+ * release take the group's highest bump from its highest current version,
86
+ * and members with nothing to release stay out. Entries are globs, as in
87
+ * `fixed`.
88
+ */
89
+ readonly linked: Schema.withDecodingDefaultKey<Schema.$Array<Schema.$Array<Schema.String>>, never>;
90
+ /**
91
+ * Packages that never bump: globs over the workspace's package names, with
92
+ * `!` negation applying in order. A release plan can still list a matching
93
+ * package as `none` when it depends on something in the plan.
94
+ */
95
+ readonly ignore: Schema.withDecodingDefaultKey<Schema.$Array<Schema.String>, never>;
96
+ /**
97
+ * The smallest bump for which `changeset version` rewrites an internal
98
+ * dependency range. It is not the bump a dependent receives: a release plan
99
+ * always bumps a dependent `patch`.
100
+ */
101
+ readonly updateInternalDependencies: Schema.withDecodingDefaultKey<Schema.Literals<readonly ["patch", "minor"]>, never>;
102
+ /**
103
+ * Whether private packages are tagged and versioned. Both default to `false`,
104
+ * as `@changesets/config` has them, so a private package releases only when
105
+ * the file opts in. {@link ChangesetConfig.read} also takes the boolean form,
106
+ * which sets both.
107
+ */
108
+ readonly privatePackages: Schema.withDecodingDefaultKey<Schema.Struct<{
109
+ readonly tag: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
110
+ readonly version: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
111
+ }>, never>;
112
+ /** The publish access level. Defaults to `restricted`. */
113
+ readonly access: Schema.withDecodingDefaultKey<Schema.Literals<readonly ["public", "restricted"]>, never>;
114
+ /** `false`, `true` or a commit-message generator spec; carried as-is. */
115
+ readonly commit: Schema.withDecodingDefaultKey<Schema.Unknown, never>;
116
+ /**
117
+ * Every key of the file the schema does not model, such as `changelog` or
118
+ * `$schema`. A file key literally named `extra` is not carried: the field
119
+ * name is reserved.
120
+ */
121
+ readonly extra: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.Unknown>, never>;
122
+ }>, {}>;
123
+ /**
124
+ * The decoded `.changeset/config.json`, with the defaults changesets
125
+ * documents. Keys the schema does not model (`changelog`, `$schema`,
126
+ * `format`, ...) are kept on the instance rather than rejected.
127
+ *
128
+ * @public
129
+ */
130
+ export declare class ChangesetConfig extends ChangesetConfig_base {
131
+ /**
132
+ * Read and decode `<root>/.changeset/config.json`.
133
+ *
134
+ * Fails with {@link ChangesetConfigError} when the file is missing
135
+ * (`reason: "missing"`), is not JSON, or has a malformed value. Whether the
136
+ * repository is in pre-release mode is `.changeset/pre.json`, which
137
+ * {@link PreState.read} reads.
138
+ *
139
+ * @param root - The repository root.
140
+ */
141
+ static readonly read: (root: string) => Effect.Effect<ChangesetConfig, ChangesetConfigError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
142
+ }
143
+ declare const ParsedChangeset_base: Schema.Class<ParsedChangeset, Schema.Struct<{
144
+ /** Package name to requested release type, in file order. */
145
+ readonly releases: Schema.$ReadonlyMap<Schema.String, Schema.Literals<readonly ["patch", "minor", "major", "none"]>>;
146
+ /** The markdown after the front matter. */
147
+ readonly summary: Schema.String;
148
+ }>, {}>;
149
+ /**
150
+ * One parsed changeset: the packages it releases and its summary text.
151
+ *
152
+ * @public
153
+ */
154
+ export declare class ParsedChangeset extends ParsedChangeset_base {}
155
+ /**
156
+ * Parsing a changeset markdown file: YAML front matter mapping package names
157
+ * to release types, then the summary.
158
+ *
159
+ * @public
160
+ */
161
+ export declare class ChangesetFile {
162
+ /**
163
+ * Parse a changeset synchronously.
164
+ *
165
+ * @param text - The file contents.
166
+ * @returns A `Result` of the parsed changeset or a {@link ChangesetParseError}.
167
+ */
168
+ static parseSync(text: string): Result.Result<ParsedChangeset, ChangesetParseError>;
169
+ /**
170
+ * Parse a changeset; the `Effect` form of {@link ChangesetFile.parseSync}.
171
+ *
172
+ * @param text - The file contents.
173
+ */
174
+ static readonly parse: (text: string) => Effect.Effect<ParsedChangeset, ChangesetParseError, never>;
175
+ }
176
+ declare const PendingChangeset_base: Schema.Class<PendingChangeset, Schema.Struct<{
177
+ /**
178
+ * The file name, relative to `.changeset/`: `pre/<name>.md` for a
179
+ * changeset an earlier pre-release consumed.
180
+ */
181
+ readonly file: Schema.String;
182
+ /** Package name to requested release type, in file order. */
183
+ readonly releases: Schema.$ReadonlyMap<Schema.String, Schema.Literals<readonly ["patch", "minor", "major", "none"]>>;
184
+ /** The markdown after the front matter. */
185
+ readonly summary: Schema.String;
186
+ }>, {}>;
187
+ /**
188
+ * One pending changeset read from `.changeset/`.
189
+ *
190
+ * @public
191
+ */
192
+ export declare class PendingChangeset extends PendingChangeset_base {}
193
+ /**
194
+ * One changeset file {@link PendingChangesets.readSettled} could not read or
195
+ * parse.
196
+ *
197
+ * @public
198
+ */
199
+ interface PendingChangesetFailure {
200
+ /** The file name, relative to `.changeset/`, as a {@link PendingChangeset} names it. */
201
+ readonly file: string;
202
+ /** Why the file was skipped: it would not parse, or it would not read. */
203
+ readonly error: ChangesetParseError | PlatformError.PlatformError;
204
+ }
205
+ /**
206
+ * Every pending changeset that parsed, and every one that did not, from
207
+ * {@link PendingChangesets.readSettled}.
208
+ *
209
+ * @public
210
+ */
211
+ interface SettledChangesets {
212
+ /** The changesets that parsed, in the order {@link PendingChangesets.read} returns them. */
213
+ readonly changesets: ReadonlyArray<PendingChangeset>;
214
+ /** The files that did not, in the same order. */
215
+ readonly failures: ReadonlyArray<PendingChangesetFailure>;
216
+ }
217
+ /**
218
+ * Reading the pending changesets under a repository's `.changeset/`
219
+ * directory.
220
+ *
221
+ * @public
222
+ */
223
+ export declare class PendingChangesets {
224
+ /**
225
+ * Read every pending changeset under `<root>/.changeset/`, ordered by file
226
+ * name, then those under `<root>/.changeset/pre/`, which a pre-release
227
+ * keeps after consuming them, as `pre/<name>.md`. A readme in any case,
228
+ * `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, dotfiles and non-`.md` files are
229
+ * skipped; a missing directory answers `[]`.
230
+ *
231
+ * The read is all or nothing: the first file that does not read or parse
232
+ * fails it. {@link PendingChangesets.readSettled} reads the same files and
233
+ * skips a bad one instead.
234
+ *
235
+ * @param root - The repository root.
236
+ */
237
+ static readonly read: (root: string) => Effect.Effect<PendingChangeset[], ChangesetParseError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
238
+ /**
239
+ * Read the same files as {@link PendingChangesets.read}, in the same order,
240
+ * but skip a file that does not read or parse and report it in `failures`
241
+ * rather than failing the whole read. For a best-effort view of pending
242
+ * bumps; a versioning tool wants the strict {@link PendingChangesets.read}.
243
+ *
244
+ * Listing `.changeset/` or `.changeset/pre/` still fails the effect with a
245
+ * `PlatformError`, since then no file is known to be missing; a missing
246
+ * directory answers no changesets and no failures.
247
+ *
248
+ * @param root - The repository root.
249
+ */
250
+ static readonly readSettled: (root: string) => Effect.Effect<SettledChangesets, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
251
+ /**
252
+ * Synchronous {@link PendingChangesets.read} over `node:fs`, for callers
253
+ * that run before any Effect runtime exists.
254
+ *
255
+ * @param root - The repository root.
256
+ */
257
+ static readSync(root: string): Result.Result<ReadonlyArray<PendingChangeset>, ChangesetParseError | PlatformError.PlatformError>;
258
+ /**
259
+ * Synchronous {@link PendingChangesets.readSettled} over `node:fs`, for
260
+ * callers that run before any Effect runtime exists. Fails only when a
261
+ * directory cannot be listed.
262
+ *
263
+ * @param root - The repository root.
264
+ */
265
+ static readSettledSync(root: string): Result.Result<SettledChangesets, PlatformError.PlatformError>;
266
+ }
267
+ declare const PreState_base: Schema.Class<PreState, Schema.Struct<{
268
+ /** `pre` while pre-releasing, `exit` once `changeset pre exit` has run. */
269
+ readonly mode: Schema.Literals<readonly ["pre", "exit"]>;
270
+ /** The prerelease tag, such as `next` or `beta`. */
271
+ readonly tag: Schema.String;
272
+ /**
273
+ * The changesets an earlier pre-release consumed, by id (the file name
274
+ * without `.md`), as the older `pre.json` layout lists them. The current
275
+ * layout moves those files into `.changeset/pre/` instead.
276
+ */
277
+ readonly changesets: Schema.optionalKey<Schema.$Array<Schema.String>>;
278
+ }>, {}>;
279
+ /**
280
+ * The decoded `.changeset/pre.json`: the repository is in pre-release mode
281
+ * (`changeset pre enter <tag>`), or leaving it (`changeset pre exit`).
282
+ *
283
+ * @remarks
284
+ * In `pre` mode a release plan appends `-<tag>.<n>` to every bumped version
285
+ * and leaves out the changesets under `.changeset/pre/`, which an earlier
286
+ * pre-release already consumed. In `exit` mode those changesets count again,
287
+ * no suffix is appended, and every package still on a numbered prerelease
288
+ * bumps at least `patch`. The file's other keys are not kept.
289
+ *
290
+ * @public
291
+ */
292
+ export declare class PreState extends PreState_base {
293
+ /**
294
+ * Read `<root>/.changeset/pre.json`: `Option.none()` when the repository
295
+ * is not in pre-release mode.
296
+ *
297
+ * Fails with {@link ChangesetConfigError} when the file is not JSON or does
298
+ * not match the shape. Unlike `@changesets/pre`, it never rewrites an
299
+ * older-layout file or moves a changeset.
300
+ *
301
+ * @param root - The repository root.
302
+ */
303
+ static readonly read: (root: string) => Effect.Effect<Option.Option<PreState>, ChangesetConfigError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
304
+ }
305
+ declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
306
+ /** The package name. */
307
+ readonly name: Schema.String;
308
+ /** The bump, or `none` for a listed package whose version does not move. */
309
+ readonly type: Schema.Literals<readonly ["patch", "minor", "major", "none"]>;
310
+ /**
311
+ * The version the bump starts from: the workspace's version now, or for a
312
+ * member of a fixed or linked group, the group's highest.
313
+ */
314
+ readonly oldVersion: Schema.String;
315
+ /** The version after the release; equal to `oldVersion` when `type` is `none`. */
316
+ readonly newVersion: Schema.String;
317
+ /** The changeset files naming the package; empty for a package reached only as a dependent. */
318
+ readonly changesets: Schema.$Array<Schema.String>;
319
+ }>, {}>;
320
+ /**
321
+ * One package's place in a {@link ReleasePlan}.
322
+ *
323
+ * @public
324
+ */
325
+ export declare class PlannedRelease extends PlannedRelease_base {}
326
+ declare const ReleasePlan_base: Schema.Class<ReleasePlan, Schema.Struct<{
327
+ /** The planned releases, sorted by package name. */
328
+ readonly releases: Schema.$Array<typeof PlannedRelease>;
329
+ /**
330
+ * The changesets the plan was made from: every pending changeset, less, in
331
+ * pre mode, those an earlier pre-release consumed. A changelog written from
332
+ * the plan reads these, so it never re-derives which a pre-release consumed.
333
+ */
334
+ readonly changesets: Schema.$Array<typeof PendingChangeset>;
335
+ /** The pre-release state the plan was made in, when the repository has one. */
336
+ readonly preState: Schema.optionalKey<typeof PreState>;
337
+ }>, {}>;
338
+ /**
339
+ * What a set of pending changesets releases: the packages they name and the
340
+ * packages reached as dependents, sorted by name. A package neither named nor
341
+ * reached is absent.
342
+ *
343
+ * @remarks
344
+ * `@changesets/get-release-plan` is the authority on these rules, and
345
+ * `__test__/ReleasePlan.oracle.test.ts` holds this class to it. Its rules are
346
+ * not all the obvious ones:
347
+ *
348
+ * - A dependent bumps `patch` whatever `updateInternalDependencies` says. That
349
+ * option decides which ranges `changeset version` rewrites, not the bump.
350
+ * - An edge exists only for `workspace:*`, `workspace:^`, `workspace:~`, a
351
+ * `workspace:` path to the dependency, or a range the dependency's current
352
+ * version satisfies. `catalog:`, `link:`, `npm:` and an already-missed range
353
+ * draw no edge, so they never ripple. When several kinds name a dependency
354
+ * the last of `dependencies`, `devDependencies`, `peerDependencies`,
355
+ * `optionalDependencies` decides the edge, and a `link:` or `file:`
356
+ * devDependency is not considered.
357
+ * - Once an edge exists every kind naming the dependency is checked: one
358
+ * unsatisfied non-dev range bumps `patch`; only unsatisfied devDependency
359
+ * ranges list the package as `none`.
360
+ * - A changeset may name a package `none`. It is listed as `none` unless another changeset or a ripple gives it a
361
+ * real bump, and it ripples nothing.
362
+ * - A skipped package is ignored, private while `privatePackages.version` is
363
+ * off (its default), or version-less. Naming one in a changeset does nothing, and it never
364
+ * bumps, but it is still listed as `none` when it depends on anything in the
365
+ * plan, whether or not the range holds, and it carries that listing onward
366
+ * to its own skipped dependents. A `none` entry bumps nothing: its version
367
+ * does not move, so no range on it is checked, even with
368
+ * `updateInternalDependents` set to `always`.
369
+ * - `ignore` entries are globs over the workspace's names, with `!` negation
370
+ * applying in order. They are matched by `@effected/glob`, where the oracle
371
+ * uses picomatch; the two agree on every pattern a package name plausibly
372
+ * needs (`*`, `?`, `[ab]`, `{a,b}`, `@scope/*`, a leading `!`) and differ
373
+ * only on exotic ones: `(a|b)` is no group here, `!(a)` is a negation of the
374
+ * literal `(a)` rather than an extglob, and `x/**` does not match `x`.
375
+ * - A version is read as node-semver reads one: surrounding whitespace and a
376
+ * single leading `v` are dropped, so `v1.0.0` bumps to `1.0.1` and is still
377
+ * reported as `v1.0.0`, and a `v` before a version in a range is accepted.
378
+ * - A bump a prerelease is already heading for completes it, as `semver.inc`
379
+ * does: a `major` of `2.0.0-rc.1` is `2.0.0`, where `SemVerBump` answers
380
+ * `3.0.0`.
381
+ * - The options `bumpVersionsWithWorkspaceProtocolOnly` and
382
+ * `___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH.updateInternalDependents`
383
+ * are honoured from the config's `extra`.
384
+ * - A `fixed` group with any member releasing brings every member that is not
385
+ * skipped to the group's highest bump, from the group's highest current
386
+ * version: that is the `oldVersion` each member reports, not its own. A
387
+ * skipped member never releases, but its version still counts towards the
388
+ * highest. A `linked` group does the same for only the members that
389
+ * release. Ripples, `fixed` and `linked` repeat until none changes
390
+ * anything, so a dependent bumped by a ripple pulls its group along. Group
391
+ * entries are globs, as `ignore` is. A package in two groups of one kind,
392
+ * or in both a fixed and a linked group, fails with
393
+ * {@link ChangesetConfigError}, as the oracle refuses it.
394
+ * - In pre-release mode (a {@link PreState} with `mode: "pre"`) the
395
+ * changesets under `.changeset/pre/` were consumed by an earlier pre-release
396
+ * and are left out. Each bumped version gains `-<tag>.<n>`, where `n` is one
397
+ * more than the number in the package's current `-<tag>.<n>`, or `0` when it
398
+ * has none, and every member of a fixed or linked group takes the group's
399
+ * highest `n`. Dependents are checked against that prerelease version, which
400
+ * a plain range does not admit. In `exit` mode the consumed changesets count
401
+ * again, no suffix is added, and every package whose version carries a
402
+ * numbered prerelease bumps at least `patch`; those added bumps reach no
403
+ * dependent.
404
+ *
405
+ * Deliberate differences, each ruled:
406
+ *
407
+ * - A version-less package is not listed at all, where the oracle lists it
408
+ * with no versions, because a {@link PlannedRelease} states versions. In a
409
+ * fixed or linked group it is passed over when the group's highest version
410
+ * and pre-release number are found; the oracle fails on it.
411
+ * - A prerelease number that is not a number, such as `1.0.0-next.x`, fails
412
+ * with `InvalidVersionError` in pre-release mode; the oracle throws an
413
+ * internal error.
414
+ * - A version changesets cannot bump, such as `=1.2.0`, which npm's loose
415
+ * parse reads but strict `semver.inc` does not, fails with
416
+ * `InvalidVersionError` wherever it must be read. The oracle crashes on it
417
+ * in pre mode and in a releasing group, and plans a bump of it with no new
418
+ * version at all.
419
+ * - A `pre.json` with no `tag`, or with a `mode` other than `pre` or `exit`,
420
+ * fails {@link PreState.read} with {@link ChangesetConfigError}. The oracle
421
+ * plans the first with `-undefined.0` suffixes and treats the second as
422
+ * `pre`, both defects rather than behaviour.
423
+ * - An older-layout `pre.json` that lists consumed changesets by id is
424
+ * planned as if they were under `.changeset/pre/`, and nothing is written.
425
+ * The oracle moves them there while it plans, after reading them, so its
426
+ * first plan counts them in pre mode and every later one does not; versions,
427
+ * types and changeset ids here are its later plans', so in exit mode a
428
+ * consumed changeset is named `pre/<file>`, where the oracle moved it,
429
+ * though it was never moved.
430
+ * - Snapshot versions are not planned. `@changesets/get-release-plan` takes no
431
+ * snapshot input, so it cannot be the oracle for one, and a snapshot is a
432
+ * flag on `changeset version`, not a state a repository is in.
433
+ *
434
+ * @public
435
+ */
436
+ export declare class ReleasePlan extends ReleasePlan_base {
437
+ /**
438
+ * Assemble the plan from packages, changesets and a config, with no IO.
439
+ *
440
+ * Fails with {@link UnknownPackageError} when a changeset names a package
441
+ * `packages` lacks; with `InvalidVersionError` when a version it must read
442
+ * is not one node-semver reads, which is the version of a package that
443
+ * bumps, the versions of a releasing fixed or linked group's members, and,
444
+ * in pre-release mode, the version of every package not skipped and of every
445
+ * fixed or linked member; and with
446
+ * {@link ChangesetConfigError}
447
+ * when a package is in two fixed groups, two linked groups, or a group of
448
+ * each. What the oracle rejects outright and this does not check is planned,
449
+ * not refused: a changeset mixing skipped and released packages, a public
450
+ * package depending on a skipped one, and `privatePackages` with `tag` on
451
+ * and `version` off.
452
+ *
453
+ * @param input - The packages to plan, the pending changesets, the config
454
+ * and, in pre-release mode, the {@link PreState}. {@link ReleasePlan.read}
455
+ * decides whether the workspace root is one of the packages.
456
+ */
457
+ static assemble(input: {
458
+ readonly packages: ReadonlyArray<WorkspacePackage>;
459
+ readonly changesets: ReadonlyArray<PendingChangeset>;
460
+ readonly config: ChangesetConfig;
461
+ readonly pre?: PreState;
462
+ }): Result.Result<ReleasePlan, UnknownPackageError | ChangesetConfigError | InvalidVersionError>;
463
+ /**
464
+ * Discover the workspace's packages, read its config, pending changesets and
465
+ * `.changeset/pre.json`, and {@link ReleasePlan.assemble | assemble} the
466
+ * plan.
467
+ *
468
+ * `root` decides all three, whatever directory the `WorkspaceDiscovery` layer
469
+ * was built from. The workspace root package is left out while other packages
470
+ * exist. When there are none it is the package and is planned, including when
471
+ * `root` has only a `package.json` and no workspace file. The oracle refuses
472
+ * `packages: []` and patterns that match nothing; here they plan the root too,
473
+ * because discovery reports them the same way. A root listed in `packages:`
474
+ * alongside others stays out, where the oracle plans it. A root with a
475
+ * catalog-only workspace file answers for itself, where the oracle climbs to
476
+ * any enclosing workspace.
477
+ *
478
+ * @param root - The repository root.
479
+ */
480
+ static readonly read: (root: string) => Effect.Effect<ReleasePlan, ChangesetConfigError | ChangesetParseError | InvalidVersionError | PlatformError.PlatformError | UnknownPackageError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
481
+ }
482
+ export type { PendingChangesetFailure, SettledChangesets };
483
+ //# sourceMappingURL=index.d.ts.map
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { BumpType, ReleaseType } from "./BumpType.js";
2
+ import { ChangesetConfig } from "./ChangesetConfig.js";
3
+ import { ChangesetFile, ParsedChangeset } from "./ChangesetFile.js";
4
+ import { ChangesetConfigError, ChangesetParseError, UnknownPackageError } from "./errors.js";
5
+ import { PendingChangeset, PendingChangesets } from "./PendingChangesets.js";
6
+ import { PreState } from "./PreState.js";
7
+ import { PlannedRelease, ReleasePlan } from "./ReleasePlan.js";
8
+
9
+ export { BumpType, ChangesetConfig, ChangesetConfigError, ChangesetFile, ChangesetParseError, ParsedChangeset, PendingChangeset, PendingChangesets, PlannedRelease, PreState, ReleasePlan, ReleaseType, UnknownPackageError };
@@ -0,0 +1,37 @@
1
+ import { RULE_DOCS, headingAnchor } from "./docs.js";
2
+ import { LintRule } from "@effected/markdown-lint";
3
+
4
+ // src/internal/lint/content-structure.ts
5
+ const ContentStructure = LintRule.make({
6
+ names: ["changeset-content-structure", "CSH003"],
7
+ description: "Sections must have content, code blocks need languages, list items need text",
8
+ tags: ["changeset"],
9
+ information: RULE_DOCS.CSH003,
10
+ check: (context, report) => {
11
+ const children = context.root.children;
12
+ children.forEach((node, index) => {
13
+ if (node.type !== "heading" || node.depth !== 2) return;
14
+ const next = children[index + 1];
15
+ if (next === void 0 || next.type === "heading" && next.depth === 2) report(context.diagnostic({
16
+ at: headingAnchor(context.source, children, index),
17
+ detail: `Empty section: heading has no content before the next section or end of file. Add a list of changes (e.g., "- Added feature X") under this heading, or remove the empty heading. See: ${RULE_DOCS.CSH003}`
18
+ }));
19
+ });
20
+ const codes = [];
21
+ const items = [];
22
+ for (const node of children) if (node.type === "code" && node.fenceChar !== void 0 && (node.lang === void 0 || node.lang === "")) codes.push(context.diagnostic({
23
+ at: node,
24
+ detail: `Code block is missing a language identifier. Add a language after the opening fence (e.g., \`\`\`ts, \`\`\`json, \`\`\`bash). See: ${RULE_DOCS.CSH003}`
25
+ }));
26
+ else if (node.type === "list") for (const item of node.children) {
27
+ if (item.children.some((child) => child.type === "paragraph")) continue;
28
+ items.push(context.diagnostic({
29
+ at: item,
30
+ detail: `Empty list item. Each list item must contain descriptive text (e.g., "- Fixed login timeout issue"). See: ${RULE_DOCS.CSH003}`
31
+ }));
32
+ }
33
+ for (const finding of [...codes, ...items]) report(finding);
34
+ }
35
+ });
36
+
37
+ export { ContentStructure };
@@ -0,0 +1,117 @@
1
+ import { RULE_DOCS, VERSION_RE, headingAnchor, writtenText } from "./docs.js";
2
+ import { LintRule } from "@effected/markdown-lint";
3
+
4
+ // src/internal/lint/dependency-table-format.ts
5
+ const EM_DASH = "—";
6
+ const VALID_TYPES = [
7
+ "dependency",
8
+ "devDependency",
9
+ "peerDependency",
10
+ "optionalDependency",
11
+ "workspace",
12
+ "config",
13
+ "runtime",
14
+ "packageManager"
15
+ ];
16
+ const VALID_ACTIONS = [
17
+ "added",
18
+ "updated",
19
+ "removed"
20
+ ];
21
+ const EXPECTED_HEADERS = [
22
+ "dependency",
23
+ "type",
24
+ "action",
25
+ "from",
26
+ "to"
27
+ ];
28
+ /**
29
+ * A row's cells as written, escapes resolved, as systems' markdownlint rule
30
+ * reads them. GFM pads a short row to the header's width with zero-width
31
+ * cells at the row's end; those were not written and are not counted, so a
32
+ * short row reads as too few columns, as markdownlint sees it. An empty cell
33
+ * the author wrote sits before a pipe, so it is never at the row's end.
34
+ */
35
+ const cellsOf = (source, row) => {
36
+ const end = row.position.end.offset;
37
+ let written = row.children.length;
38
+ while (written > 0) {
39
+ const cell = row.children[written - 1];
40
+ if (cell === void 0 || cell.position.start.offset !== end || cell.position.end.offset !== end) break;
41
+ written--;
42
+ }
43
+ return row.children.slice(0, written).map((cell) => writtenText(source, cell).trim());
44
+ };
45
+ const DependencyTableFormat = LintRule.make({
46
+ names: ["changeset-dependency-table-format", "CSH005"],
47
+ description: "Dependencies section must contain a valid dependency table",
48
+ tags: ["changeset"],
49
+ information: RULE_DOCS.CSH005,
50
+ check: (context, report) => {
51
+ const children = context.root.children;
52
+ children.forEach((node, index) => {
53
+ if (node.type !== "heading" || node.depth !== 2) return;
54
+ if (writtenText(context.source, node).toLowerCase() !== "dependencies") return;
55
+ let table;
56
+ for (let next = index + 1; next < children.length; next++) {
57
+ const candidate = children[next];
58
+ if (candidate === void 0 || candidate.type === "heading") break;
59
+ if (candidate.type === "table") {
60
+ table = candidate;
61
+ break;
62
+ }
63
+ }
64
+ if (table === void 0 || table.type !== "table") {
65
+ report(context.diagnostic({
66
+ at: headingAnchor(context.source, children, index),
67
+ detail: `Dependencies section must contain a table, not a list or paragraph. See: ${RULE_DOCS.CSH005}`
68
+ }));
69
+ return;
70
+ }
71
+ const [header, ...rows] = table.children;
72
+ if (header === void 0) {
73
+ report(context.diagnostic({
74
+ at: table,
75
+ detail: `Dependencies table is missing a header row. See: ${RULE_DOCS.CSH005}`
76
+ }));
77
+ return;
78
+ }
79
+ const headers = cellsOf(context.source, header).map((cell) => cell.toLowerCase());
80
+ if (headers.length !== EXPECTED_HEADERS.length || !headers.every((cell, column) => cell === EXPECTED_HEADERS[column])) {
81
+ report(context.diagnostic({
82
+ at: header,
83
+ detail: `Dependencies table must have columns: Dependency, Type, Action, From, To. Got: ${headers.join(", ")}. See: ${RULE_DOCS.CSH005}`
84
+ }));
85
+ return;
86
+ }
87
+ if (rows.length === 0) {
88
+ report(context.diagnostic({
89
+ at: table,
90
+ detail: `Dependencies table must have at least one data row. See: ${RULE_DOCS.CSH005}`
91
+ }));
92
+ return;
93
+ }
94
+ for (const row of rows) {
95
+ const cells = cellsOf(context.source, row);
96
+ const at = (detail) => report(context.diagnostic({
97
+ at: row,
98
+ detail
99
+ }));
100
+ if (cells.length < 5) {
101
+ at(`Dependencies table row has too few columns (expected 5, got ${cells.length}). See: ${RULE_DOCS.CSH005}`);
102
+ continue;
103
+ }
104
+ const [dependency = "", type = "", action = "", from = "", to = ""] = cells;
105
+ if (dependency === "") at(`Dependencies table row has an empty 'Dependency' cell. See: ${RULE_DOCS.CSH005}`);
106
+ if (!VALID_TYPES.includes(type)) at(`Invalid dependency type '${type}'. Valid types are: ${VALID_TYPES.join(", ")}. See: ${RULE_DOCS.CSH005}`);
107
+ if (!VALID_ACTIONS.includes(action)) at(`Invalid dependency action '${action}'. Valid actions are: ${VALID_ACTIONS.join(", ")}. See: ${RULE_DOCS.CSH005}`);
108
+ if (from !== "" && !VERSION_RE.test(from)) at(`Invalid 'from' value '${from}'. Must be a semver string or em dash (${EM_DASH}). See: ${RULE_DOCS.CSH005}`);
109
+ if (to !== "" && !VERSION_RE.test(to)) at(`Invalid 'to' value '${to}'. Must be a semver string or em dash (${EM_DASH}). See: ${RULE_DOCS.CSH005}`);
110
+ if (action === "added" && from !== EM_DASH) at(`'from' must be '${EM_DASH}' when action is 'added' (got '${from}'). See: ${RULE_DOCS.CSH005}`);
111
+ if (action === "removed" && to !== EM_DASH) at(`'to' must be '${EM_DASH}' when action is 'removed' (got '${to}'). See: ${RULE_DOCS.CSH005}`);
112
+ }
113
+ });
114
+ }
115
+ });
116
+
117
+ export { DependencyTableFormat };