@effected/changesets 0.2.0 → 0.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Effect, FileSystem, Option, Path, PlatformError, Result, Schema } from "effect";
2
- import { InvalidVersionError } from "@effected/semver";
3
2
  import { WorkspaceDiscovery, WorkspaceDiscoveryError, WorkspacePackage, WorkspaceRootNotFoundError } from "@effected/workspaces";
3
+ import { InvalidVersionError } from "@effected/semver";
4
4
  /**
5
5
  * A semver bump a changeset can request: `patch`, `minor` or `major`.
6
6
  *
@@ -70,6 +70,56 @@ declare const UnknownPackageError_base: Schema.Class<UnknownPackageError, Schema
70
70
  export declare class UnknownPackageError extends UnknownPackageError_base {
71
71
  get message(): string;
72
72
  }
73
+ declare const SnapshotPreModeError_base: Schema.Class<SnapshotPreModeError, Schema.TaggedStruct<"SnapshotPreModeError", {
74
+ /** The pre-release tag of the pre mode the repository is in. */
75
+ readonly preTag: Schema.String;
76
+ }>, import("effect/Cause").YieldableError>;
77
+ /**
78
+ * A snapshot release was asked for while `.changeset/pre.json` has the
79
+ * repository in pre mode. `changeset version --snapshot` refuses the same
80
+ * way; leave pre mode (`changeset pre exit`) first.
81
+ *
82
+ * @public
83
+ */
84
+ export declare class SnapshotPreModeError extends SnapshotPreModeError_base {
85
+ get message(): string;
86
+ }
87
+ declare const SnapshotTemplateError_base: Schema.Class<SnapshotTemplateError, Schema.TaggedStruct<"SnapshotTemplateError", {
88
+ /** The template that could not be filled. */
89
+ readonly template: Schema.String;
90
+ /** The placeholder at fault. */
91
+ readonly placeholder: Schema.Literals<readonly ["commit", "commit-short", "tag"]>;
92
+ /** Which of the two refusals this is. */
93
+ readonly kind: Schema.Literals<readonly ["missingValue", "missingPlaceholder"]>;
94
+ }>, import("effect/Cause").YieldableError>;
95
+ /**
96
+ * A snapshot prerelease template could not be filled, for one of the two
97
+ * reasons `@changesets/assemble-release-plan` refuses one:
98
+ *
99
+ * - `missingValue`: the template uses `{commit}`, `{commit-short}` or `{tag}`
100
+ * and the snapshot gave no value for it.
101
+ * - `missingPlaceholder`: the snapshot gave a tag and the template has no
102
+ * `{tag}` to put it in.
103
+ *
104
+ * @public
105
+ */
106
+ export declare class SnapshotTemplateError extends SnapshotTemplateError_base {
107
+ get message(): string;
108
+ }
109
+ declare const MissingPackageError_base: Schema.Class<MissingPackageError, Schema.TaggedStruct<"MissingPackageError", {
110
+ /** The package the plan releases. */
111
+ readonly packageName: Schema.String;
112
+ }>, import("effect/Cause").YieldableError>;
113
+ /**
114
+ * A release plan names a package the packages given to
115
+ * {@link ReleasePlan.edits} do not contain: the plan was made from a
116
+ * different workspace than the one being edited.
117
+ *
118
+ * @public
119
+ */
120
+ export declare class MissingPackageError extends MissingPackageError_base {
121
+ get message(): string;
122
+ }
73
123
  declare const ChangesetConfig_base: Schema.Class<ChangesetConfig, Schema.Struct<{
74
124
  /** The branch releases are cut against. Defaults to `main`. */
75
125
  readonly baseBranch: Schema.withDecodingDefaultKey<Schema.String, never>;
@@ -114,16 +164,50 @@ declare const ChangesetConfig_base: Schema.Class<ChangesetConfig, Schema.Struct<
114
164
  /** `false`, `true` or a commit-message generator spec; carried as-is. */
115
165
  readonly commit: Schema.withDecodingDefaultKey<Schema.Unknown, never>;
116
166
  /**
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
167
+ * The changelog generator, as the file writes it: `false` for none, a
168
+ * module id, or a `[moduleId, options]` pair. Defaults to
169
+ * `"@changesets/cli/changelog"`, the written default `@changesets/config`
170
+ * fills in.
171
+ *
172
+ * It is kept as written, not normalised: `@changesets/config` turns a bare
173
+ * id into `[id, null]`, and a caller wanting that form maps the string
174
+ * itself. Resolving and loading the module is the caller's job; this
175
+ * package only names it.
176
+ *
177
+ * Decoding accepts every shape `@changesets/config` accepts. A tuple longer
178
+ * than two keeps its first two elements, as the oracle does. The options
179
+ * element is carried as `unknown`, so a non-object there decodes here
180
+ * though the oracle rejects it: validating the options is the generator's
181
+ * concern.
182
+ */
183
+ readonly changelog: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.Union<readonly [Schema.Literal<false>, Schema.String, Schema.decodeTo<Schema.Tuple<readonly [Schema.String, Schema.Unknown]>, Schema.TupleWithRest<Schema.Tuple<readonly [Schema.String, Schema.Unknown]>, readonly [Schema.Unknown]>, never, never>]>, never>>;
184
+ /**
185
+ * Options for `changeset version --snapshot`.
186
+ *
187
+ * - `useCalculatedVersion` bases a snapshot version on the version the plan
188
+ * calculates rather than `0.0.0`. Defaults to `false`.
189
+ * - `prereleaseTemplate` replaces the default `<tag>-<datetime>` suffix.
190
+ * It may use `{tag}`, `{commit}`, `{commit-short}`, `{timestamp}` and `{datetime}`. Absent
191
+ * when the file sets none, which is also `@changesets/config`'s default;
192
+ * an empty string is rejected, as the oracle rejects it.
193
+ *
194
+ * Defaults to `{ useCalculatedVersion: false }`.
195
+ */
196
+ readonly snapshot: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.Struct<{
197
+ readonly useCalculatedVersion: Schema.withDecodingDefaultKey<Schema.Boolean, never>;
198
+ readonly prereleaseTemplate: Schema.optionalKey<Schema.String>;
199
+ }>, never>>;
200
+ /**
201
+ * Every key of the file the schema does not model, such as `$schema` or
202
+ * `format`. A file key literally named `extra` is not carried: the field
119
203
  * name is reserved.
120
204
  */
121
205
  readonly extra: Schema.withDecodingDefaultKey<Schema.$Record<Schema.String, Schema.Unknown>, never>;
122
206
  }>, {}>;
123
207
  /**
124
208
  * 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.
209
+ * documents. Keys the schema does not model (`$schema`, `format`,
210
+ * `changedFilePatterns`, ...) are kept on `extra` rather than rejected.
127
211
  *
128
212
  * @public
129
213
  */
@@ -140,39 +224,6 @@ export declare class ChangesetConfig extends ChangesetConfig_base {
140
224
  */
141
225
  static readonly read: (root: string) => Effect.Effect<ChangesetConfig, ChangesetConfigError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
142
226
  }
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
227
  declare const PendingChangeset_base: Schema.Class<PendingChangeset, Schema.Struct<{
177
228
  /**
178
229
  * The file name, relative to `.changeset/`: `pre/<name>.md` for a
@@ -181,7 +232,7 @@ declare const PendingChangeset_base: Schema.Class<PendingChangeset, Schema.Struc
181
232
  readonly file: Schema.String;
182
233
  /** Package name to requested release type, in file order. */
183
234
  readonly releases: Schema.$ReadonlyMap<Schema.String, Schema.Literals<readonly ["patch", "minor", "major", "none"]>>;
184
- /** The markdown after the front matter. */
235
+ /** The markdown after the front matter, trimmed as `@changesets/parse` trims it. */
185
236
  readonly summary: Schema.String;
186
237
  }>, {}>;
187
238
  /**
@@ -189,7 +240,14 @@ declare const PendingChangeset_base: Schema.Class<PendingChangeset, Schema.Struc
189
240
  *
190
241
  * @public
191
242
  */
192
- export declare class PendingChangeset extends PendingChangeset_base {}
243
+ export declare class PendingChangeset extends PendingChangeset_base {
244
+ /**
245
+ * The changeset's id, as `@changesets/read` gives it: `file` without
246
+ * `.md`, so `pre/<name>` for one an earlier pre-release consumed. A
247
+ * `PlannedRelease`'s `changesets` lists these.
248
+ */
249
+ get id(): string;
250
+ }
193
251
  /**
194
252
  * One changeset file {@link PendingChangesets.readSettled} could not read or
195
253
  * parse.
@@ -302,6 +360,103 @@ export declare class PreState extends PreState_base {
302
360
  */
303
361
  static readonly read: (root: string) => Effect.Effect<Option.Option<PreState>, ChangesetConfigError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
304
362
  }
363
+ declare const RangeEdit_base: Schema.Class<RangeEdit, Schema.Struct<{
364
+ /** The manifest field holding the range. */
365
+ readonly kind: Schema.Literals<readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"]>;
366
+ /** The dependency's package name: the key under `kind`. */
367
+ readonly dependency: Schema.String;
368
+ /** The specifier as the manifest has it now. */
369
+ readonly from: Schema.String;
370
+ /** The specifier the release writes. */
371
+ readonly to: Schema.String;
372
+ }>, {}>;
373
+ /**
374
+ * One dependency range a release rewrites in a manifest.
375
+ *
376
+ * @public
377
+ */
378
+ export declare class RangeEdit extends RangeEdit_base {}
379
+ declare const ManifestEdit_base: Schema.Class<ManifestEdit, Schema.Struct<{
380
+ /** The package name. */
381
+ readonly name: Schema.String;
382
+ /** The absolute path of the `package.json` to edit. */
383
+ readonly packageJsonPath: Schema.String;
384
+ /**
385
+ * The `version` the release writes. Absent when the version does not move:
386
+ * a `none` entry, or the workspace root, whose ranges alone are edited.
387
+ */
388
+ readonly version: Schema.optionalKey<Schema.String>;
389
+ /** The dependency ranges the release rewrites, in the order `changeset version` edits them. */
390
+ readonly ranges: Schema.$Array<typeof RangeEdit>;
391
+ }>, {}>;
392
+ /**
393
+ * What a release changes in one `package.json`.
394
+ *
395
+ * @public
396
+ */
397
+ export declare class ManifestEdit extends ManifestEdit_base {}
398
+ declare const ChangesetMove_base: Schema.Class<ChangesetMove, Schema.Struct<{
399
+ /** The file now, relative to `.changeset/`. */
400
+ readonly from: Schema.String;
401
+ /** Where it goes, relative to `.changeset/`: `pre/<file>`. */
402
+ readonly to: Schema.String;
403
+ }>, {}>;
404
+ /**
405
+ * A pending changeset a pre-release consumes: `changeset version` in pre mode
406
+ * moves it under `.changeset/pre/` rather than deleting it.
407
+ *
408
+ * The caller creates `.changeset/pre/` first when it does not exist, as
409
+ * `changeset version` does (`mkdir -p`): a plain rename into a missing
410
+ * directory fails on the first pre-release.
411
+ *
412
+ * @public
413
+ */
414
+ export declare class ChangesetMove extends ChangesetMove_base {}
415
+ declare const ReleaseEdits_base: Schema.Class<ReleaseEdits, Schema.Struct<{
416
+ /**
417
+ * One entry per `package.json` that changes, in plan order with the
418
+ * workspace root last. A manifest nothing changes in is left out, and so is
419
+ * an edit that would write the value already there.
420
+ */
421
+ readonly manifests: Schema.$Array<typeof ManifestEdit>;
422
+ /** The changeset files to delete, relative to `.changeset/`. */
423
+ readonly deleteChangesets: Schema.$Array<Schema.String>;
424
+ /** The changeset files to move under `.changeset/pre/`; only ever non-empty in pre mode. */
425
+ readonly moveChangesets: Schema.$Array<typeof ChangesetMove>;
426
+ /**
427
+ * `.changeset/pre.json` as the release leaves it. Absent when the release
428
+ * leaves no `pre.json`: the plan had none, or it was in `exit` mode and is
429
+ * not a snapshot, so the file is deleted. When present it equals the
430
+ * plan's {@link PreState}: `changeset version` never rewrites the file.
431
+ */
432
+ readonly preState: Schema.optionalKey<typeof PreState>;
433
+ }>, {}>;
434
+ /**
435
+ * Everything `changeset version` writes for a {@link ReleasePlan}, as data,
436
+ * CHANGELOG files aside. {@link ReleasePlan.edits} computes it; the caller
437
+ * does the IO.
438
+ *
439
+ * @public
440
+ */
441
+ export declare class ReleaseEdits extends ReleaseEdits_base {}
442
+ /**
443
+ * The input for a snapshot plan, `changeset version --snapshot`'s parameters.
444
+ * {@link ReleasePlan.assemble} documents how each is read.
445
+ *
446
+ * @public
447
+ */
448
+ interface ReleaseSnapshot {
449
+ /** The snapshot's name, `--snapshot <tag>`. An empty string is no tag. */
450
+ readonly tag?: string | undefined;
451
+ /** The commit `{commit}` and `{commit-short}` fill in. An empty string is no commit. */
452
+ readonly commit?: string | undefined;
453
+ /** The moment `{timestamp}` and `{datetime}` are taken from, so assembly reads no clock. */
454
+ readonly timestamp: Date;
455
+ /** Overrides the config's `snapshot.useCalculatedVersion` when set. */
456
+ readonly useCalculatedVersion?: boolean | undefined;
457
+ /** Overrides the config's `snapshot.prereleaseTemplate` when set; an empty string is the default suffix. */
458
+ readonly prereleaseTemplate?: string | undefined;
459
+ }
305
460
  declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
306
461
  /** The package name. */
307
462
  readonly name: Schema.String;
@@ -314,7 +469,46 @@ declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
314
469
  readonly oldVersion: Schema.String;
315
470
  /** The version after the release; equal to `oldVersion` when `type` is `none`. */
316
471
  readonly newVersion: Schema.String;
317
- /** The changeset files naming the package; empty for a package reached only as a dependent. */
472
+ /**
473
+ * The ids of the changesets in the plan that name the package, as the
474
+ * oracle lists them: each {@link PendingChangeset.id}, the file name
475
+ * without `.md` (`pre/<name>` for one an earlier pre-release consumed).
476
+ * The plan's own `changesets` holds the changesets themselves.
477
+ *
478
+ * @remarks
479
+ * An empty list always means the package's bump does not come from a
480
+ * changeset of its own in this plan. It is reached as a dependent, pulled
481
+ * into a `fixed` group, or completed from a prerelease on `exit`. The
482
+ * converse does not hold: a non-empty list does not mean the package's own
483
+ * changeset set its bump. Every path that builds a release:
484
+ *
485
+ * - A changeset naming the package, `none` included, lists its id. A
486
+ * package named only `none` keeps the id while it stays `none`.
487
+ * - A ripple into a package not yet in the plan, or into a `none` entry,
488
+ * replaces it with a new release whose list is empty. So a package one
489
+ * changeset named `none` and a dependency then bumped has an empty list,
490
+ * as the oracle answers (`explicit-none-rippled`). A ripple never
491
+ * touches a package already releasing.
492
+ * - A `fixed` group adds a missing member with an empty list, and raises
493
+ * an existing member's type, including a `none` entry's, keeping its
494
+ * list. A raised member can therefore list only a changeset that named
495
+ * it `none`, or a smaller bump than the type it ends with.
496
+ * - A `linked` group raises only members already releasing and keeps
497
+ * their lists.
498
+ * - On `exit`, a package still on a numbered prerelease that is not in
499
+ * the plan is added `patch` with an empty list. A `none` entry is raised
500
+ * to `patch` and keeps its list.
501
+ * - In pre mode the changesets an earlier pre-release consumed are not in
502
+ * the plan. So the list names only this pre-release's new changesets,
503
+ * and a package whose own changesets were all consumed, and which a
504
+ * ripple brings back, has an empty list.
505
+ * - A snapshot plan builds its releases exactly as a plain one does.
506
+ *
507
+ * To tell a group or exit bump from a ripple, read `fixed` and `linked`
508
+ * and the plan's `preState`. To tell whether the package's own changeset
509
+ * set its type, compare `type` with the highest bump its listed changesets
510
+ * give it.
511
+ */
318
512
  readonly changesets: Schema.$Array<Schema.String>;
319
513
  }>, {}>;
320
514
  /**
@@ -334,6 +528,12 @@ declare const ReleasePlan_base: Schema.Class<ReleasePlan, Schema.Struct<{
334
528
  readonly changesets: Schema.$Array<typeof PendingChangeset>;
335
529
  /** The pre-release state the plan was made in, when the repository has one. */
336
530
  readonly preState: Schema.optionalKey<typeof PreState>;
531
+ /**
532
+ * Whether this is a snapshot release's plan, made with a `snapshot` input.
533
+ * {@link ReleasePlan.edits} reads it: a snapshot pins dependents exactly
534
+ * and leaves an `exit`-mode `pre.json` in place.
535
+ */
536
+ readonly snapshot: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.Boolean, never>>;
337
537
  }>, {}>;
338
538
  /**
339
539
  * What a set of pending changesets releases: the packages they name and the
@@ -401,6 +601,13 @@ declare const ReleasePlan_base: Schema.Class<ReleasePlan, Schema.Struct<{
401
601
  * again, no suffix is added, and every package whose version carries a
402
602
  * numbered prerelease bumps at least `patch`; those added bumps reach no
403
603
  * dependent.
604
+ * - A snapshot plan (`changeset version --snapshot`, whose oracle is
605
+ * `@changesets/assemble-release-plan`'s snapshot argument) plans the same
606
+ * releases and only rewrites each bumped `newVersion` to
607
+ * `<base>-<suffix>`. `<base>` is `0.0.0`, or with `useCalculatedVersion` the
608
+ * version the plan would otherwise give. A `none` entry keeps its version,
609
+ * and dependents are still checked against the calculated version, not the
610
+ * snapshot one. {@link ReleasePlan.assemble} has the suffix rules.
404
611
  *
405
612
  * Deliberate differences, each ruled:
406
613
  *
@@ -411,6 +618,10 @@ declare const ReleasePlan_base: Schema.Class<ReleasePlan, Schema.Struct<{
411
618
  * - A prerelease number that is not a number, such as `1.0.0-next.x`, fails
412
619
  * with `InvalidVersionError` in pre-release mode; the oracle throws an
413
620
  * internal error.
621
+ * - A Ruby-style `~>` range (`~>1.0.0`), which node-semver reads as `~`,
622
+ * is not a range here: `@effected/semver` rejects it. It draws no edge,
623
+ * so it never ripples, where the oracle bumps the dependent once the
624
+ * range is left, and {@link ReleasePlan.edits} never rewrites it.
414
625
  * - A version changesets cannot bump, such as `=1.2.0`, which npm's loose
415
626
  * parse reads but strict `semver.inc` does not, fails with
416
627
  * `InvalidVersionError` wherever it must be read. The oracle crashes on it
@@ -427,9 +638,8 @@ declare const ReleasePlan_base: Schema.Class<ReleasePlan, Schema.Struct<{
427
638
  * types and changeset ids here are its later plans', so in exit mode a
428
639
  * consumed changeset is named `pre/<file>`, where the oracle moved it,
429
640
  * 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.
641
+ * - An empty snapshot `tag` or `commit` is no value at all; see
642
+ * {@link ReleasePlan.assemble}.
433
643
  *
434
644
  * @public
435
645
  */
@@ -445,39 +655,643 @@ export declare class ReleasePlan extends ReleasePlan_base {
445
655
  * fixed or linked member; and with
446
656
  * {@link ChangesetConfigError}
447
657
  * 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,
658
+ * each. A snapshot adds {@link SnapshotPreModeError} and
659
+ * {@link SnapshotTemplateError}, described below. What the oracle rejects outright and this does not check is planned,
449
660
  * not refused: a changeset mixing skipped and released packages, a public
450
661
  * package depending on a skipped one, and `privatePackages` with `tag` on
451
662
  * and `version` off.
452
663
  *
664
+ * With `snapshot`, the plan is a snapshot release's, matching
665
+ * `@changesets/assemble-release-plan` given the same snapshot argument:
666
+ *
667
+ * - It fails {@link SnapshotPreModeError} when `pre` is in `pre` mode.
668
+ * The oracle itself plans one; the refusal is `changeset version`'s,
669
+ * which never reaches the oracle. In `exit` mode a snapshot is planned.
670
+ * - `useCalculatedVersion` and `prereleaseTemplate` come from
671
+ * `config.snapshot` unless the snapshot overrides them. An empty
672
+ * `prereleaseTemplate` override is the default suffix, as an empty
673
+ * `--snapshot-prerelease-template` is.
674
+ * - With no template the suffix is `<tag>-<datetime>`, or `<datetime>`
675
+ * with no tag. A template may use `{tag}`, `{commit}`,
676
+ * `{commit-short}` (its first seven characters), `{timestamp}` (epoch
677
+ * milliseconds) and `{datetime}` (`YYYYMMDDHHmmss`, UTC), all taken from
678
+ * `snapshot.timestamp`, never the clock. It fails
679
+ * {@link SnapshotTemplateError} when it uses `{tag}`, `{commit}` or
680
+ * `{commit-short}` with no value, or omits `{tag}` while a tag is given.
681
+ * Placeholders are filled in that order, each over the last one's
682
+ * output, as the oracle fills them.
683
+ * - The suffix is not checked as semver, any more than the oracle checks
684
+ * it: `--snapshot pr#123` gives `0.0.0-pr#123-<datetime>`.
685
+ * - An invalid `timestamp` Date throws `RangeError`, as
686
+ * `Date.prototype.toISOString` does: it is a programmer error, not a
687
+ * planning failure.
688
+ *
689
+ * An empty `tag` or `commit` is treated as absent.
690
+ * `changeset version --snapshot` never passes `""` to the oracle: an empty `--snapshot` value
691
+ * is falsy there, so it plans no snapshot at all, and a bare `--snapshot`
692
+ * passes no tag. Called directly with `tag: ""`, the oracle fills `{tag}`
693
+ * with nothing and refuses a template without `{tag}`, while
694
+ * `@changesets/apply-release-plan` reads the same `""` as "not a snapshot"
695
+ * and writes caret ranges. With no template the two readings give the same
696
+ * version; with one, this follows the bare `--snapshot` reading, so a
697
+ * template with `{tag}` fails `missingValue` and one without it succeeds.
698
+ * Because every value that can fill a placeholder is then non-empty, the
699
+ * suffix is never empty, so the oracle's quiet fallback to plain versions
700
+ * on an empty suffix cannot happen here.
701
+ *
453
702
  * @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.
703
+ * and, in pre-release mode, the {@link PreState}, and for a snapshot
704
+ * release the {@link ReleaseSnapshot}. {@link ReleasePlan.read} decides
705
+ * whether the workspace root is one of the packages.
456
706
  */
457
707
  static assemble(input: {
458
708
  readonly packages: ReadonlyArray<WorkspacePackage>;
459
709
  readonly changesets: ReadonlyArray<PendingChangeset>;
460
710
  readonly config: ChangesetConfig;
461
711
  readonly pre?: PreState;
462
- }): Result.Result<ReleasePlan, UnknownPackageError | ChangesetConfigError | InvalidVersionError>;
712
+ readonly snapshot?: ReleaseSnapshot;
713
+ }): Result.Result<ReleasePlan, UnknownPackageError | ChangesetConfigError | InvalidVersionError | SnapshotPreModeError | SnapshotTemplateError>;
714
+ /**
715
+ * What `changeset version` writes for `plan`, as data: each manifest's new
716
+ * `version` and rewritten dependency ranges, the changeset files it
717
+ * deletes or, in pre mode, moves under `.changeset/pre/`, and the
718
+ * `pre.json` it leaves. CHANGELOG files are not covered. Nothing is
719
+ * written; the caller applies the {@link ReleaseEdits}.
720
+ *
721
+ * `@changesets/apply-release-plan` is the oracle, and
722
+ * `__test__/ReleaseEdits.oracle.test.ts` compares it on disk. Its rules:
723
+ *
724
+ * - Every planned package's manifest gets its new `version`, and so does
725
+ * nothing else. Only planned packages and the workspace root (marked
726
+ * `isRootWorkspace` among `packages`) have their ranges rewritten: a
727
+ * package outside the plan keeps a range on a released dependency, even
728
+ * one the new version leaves.
729
+ * - A range on a released dependency (not a `none` entry) is rewritten in
730
+ * `dependencies`, `devDependencies`, `peerDependencies` and
731
+ * `optionalDependencies` alike when the new version leaves it, or, while
732
+ * it still holds, when the release's bump is at least
733
+ * `updateInternalDependencies`. A held `peerDependencies` range instead
734
+ * follows `onlyUpdatePeerDependentsWhenOutOfRange` (from the config's
735
+ * `extra`): rewritten unless it is on.
736
+ * - `workspace:*`, `workspace:^`, `workspace:~` and a `workspace:` path are
737
+ * never rewritten: they follow the dependency on their own. A
738
+ * `workspace:<range>` is rewritten and keeps its `workspace:` prefix.
739
+ * `file:`, `link:`, `catalog:`, `npm:` and any non-range specifier are
740
+ * never rewritten, and under `bumpVersionsWithWorkspaceProtocolOnly`
741
+ * neither is a plain range.
742
+ * - A range that matches every version (`*`, `x`, `>=0.0.0`, or a `||`
743
+ * with such a part) is rewritten only to a prerelease version.
744
+ * - The new range is the old one's leading operator (`^`, `~`, `>=`, `<=`,
745
+ * `>`, or none) before the new version. A range of exactly two
746
+ * comparators written with both `>` and `<` becomes `>=<new>` with its
747
+ * upper bound kept while the new version satisfies it, else
748
+ * `<<new bumped again>>`, in the order it was written. In a snapshot
749
+ * plan every rewritten range is the exact new version.
750
+ * - Each changeset in the plan is deleted, or in pre mode moved to
751
+ * `pre/<file>`, unless it names a skipped package (ignored, private
752
+ * while `privatePackages.version` is off, or version-less), which leaves
753
+ * it in place.
754
+ * - `pre.json` is deleted in `exit` mode unless the plan is a snapshot,
755
+ * and otherwise left as it is.
756
+ * - A pre-release consumes a changeset by moving its file to
757
+ * `.changeset/pre/`, never by listing its id in `pre.json`: the current
758
+ * layout has no such list, so in pre mode `preState` is the plan's own,
759
+ * unchanged, and the consumed files are `moveChangesets`. That is the
760
+ * directory {@link PendingChangesets.read} reads back as `pre/<file>`.
761
+ *
762
+ * Deliberate differences, each ruled:
763
+ *
764
+ * - An edit that would write the value already there is left out, and so
765
+ * is a manifest with nothing to change; the oracle rewrites the same
766
+ * value. The files end the same.
767
+ * - The oracle only deletes a changeset file it finds on disk; the edits
768
+ * name every consumed changeset, since the plan was read from them. An
769
+ * older-layout `pre.json`'s listed changeset is named as the plan names
770
+ * it (`pre/<file>` in exit mode), where the oracle had moved it while
771
+ * reading; the file itself is still at `<file>`. Neither does this
772
+ * migrate that `pre.json`, which the oracle rewrites as it reads.
773
+ * - A `~>` range is never rewritten, where the oracle rewrites it as `~`:
774
+ * `@effected/semver` rejects the Ruby-style operator, so it is not a
775
+ * range here. It never ripples in {@link ReleasePlan.assemble} either.
776
+ * - `changeset version --snapshot ""` is a third state no plan here
777
+ * holds. The CLI plans no snapshot for an empty value, but hands the
778
+ * `""` to `apply-release-plan`, which then keeps an `exit`-mode
779
+ * `pre.json` (it deletes one only when the snapshot is `null`) while
780
+ * writing caret ranges. A plan without a snapshot deletes that
781
+ * `pre.json`; a caller reproducing the CLI keeps it.
782
+ *
783
+ * Fails with {@link MissingPackageError} when the plan releases a package
784
+ * `packages` lacks, and with `InvalidVersionError` when a bounded range
785
+ * must be bumped past a new version that is not a version, which a plan
786
+ * {@link ReleasePlan.assemble} made never has.
787
+ *
788
+ * @param plan - The plan to apply.
789
+ * @param input - Every package of the workspace, the root included, as
790
+ * `WorkspaceDiscovery.listPackagesIn` lists them, and the config the plan
791
+ * was made with.
792
+ */
793
+ static edits(plan: ReleasePlan, input: {
794
+ readonly packages: ReadonlyArray<WorkspacePackage>;
795
+ readonly config: ChangesetConfig;
796
+ }): Result.Result<ReleaseEdits, MissingPackageError | InvalidVersionError>;
463
797
  /**
464
798
  * Discover the workspace's packages, read its config, pending changesets and
465
799
  * `.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:`
800
+ * plan. {@link ReleasePlan.readWithContext} reads the same plan and also
801
+ * returns the packages and config it was made from.
802
+ *
803
+ * `directory` may be the workspace root or any directory inside it: the
804
+ * root is found by climbing, as `@changesets/get-release-plan` climbs, to
805
+ * the nearest workspace root, or with none to the nearest `package.json`.
806
+ * That root decides the config, the changesets and `pre.json`, whatever
807
+ * directory the `WorkspaceDiscovery` layer was built from. The workspace
808
+ * root package is left out while other packages exist. When there are
809
+ * none it is the package and is planned, including when the root has only
810
+ * a `package.json` and no workspace file. The oracle refuses `packages: []`
811
+ * and patterns that match nothing; here they plan the root too, because
812
+ * discovery reports them the same way. A root listed in `packages:`
474
813
  * 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.
814
+ * catalog-only workspace file answers for itself, where the oracle climbs
815
+ * to any enclosing workspace.
477
816
  *
478
- * @param root - The repository root.
817
+ * `WorkspaceDiscovery` memoizes each root's packages for the layer's
818
+ * lifetime. A long-lived host that plans again after applying a release
819
+ * calls `WorkspaceDiscovery`'s `refreshIn(root)` first, or the new plan
820
+ * reads the versions the release replaced.
821
+ *
822
+ * @param directory - The workspace root, or a directory inside it.
823
+ * @param options - `snapshot` plans a snapshot release, as
824
+ * {@link ReleasePlan.assemble} describes.
825
+ */
826
+ static readonly read: (directory: string, options?: {
827
+ readonly snapshot?: ReleaseSnapshot | undefined;
828
+ } | undefined) => Effect.Effect<ReleasePlan, ChangesetConfigError | ChangesetParseError | InvalidVersionError | PlatformError.PlatformError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
829
+ /**
830
+ * {@link ReleasePlan.read}, returning the plan with everything it was read
831
+ * from, so a caller hands {@link ReleasePlan.edits} and `Changelog.entry`
832
+ * exactly the packages and config the plan was made with instead of
833
+ * discovering them again.
834
+ *
835
+ * @param directory - The workspace root, or a directory inside it.
836
+ * @param options - `snapshot` plans a snapshot release, as
837
+ * {@link ReleasePlan.assemble} describes.
838
+ * @returns a {@link ReleaseContext}. It fails as {@link ReleasePlan.read} does.
839
+ */
840
+ static readonly readWithContext: (directory: string, options?: {
841
+ readonly snapshot?: ReleaseSnapshot | undefined;
842
+ } | undefined) => Effect.Effect<ReleaseContext, ChangesetConfigError | ChangesetParseError | InvalidVersionError | PlatformError.PlatformError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
843
+ }
844
+ declare const ReleaseContext_base: Schema.Class<ReleaseContext, Schema.Struct<{
845
+ /** The workspace root the plan was read from: the directory climbed to, not the one given. */
846
+ readonly root: Schema.String;
847
+ /** The plan. */
848
+ readonly plan: typeof ReleasePlan;
849
+ /**
850
+ * Every package of the workspace, the root included, as
851
+ * {@link ReleasePlan.edits} and `Changelog.entry` take them. For a
852
+ * repository with no workspace file it is the one root package.
479
853
  */
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>;
854
+ readonly packages: Schema.$Array<typeof WorkspacePackage>;
855
+ /** The config the plan was made with. */
856
+ readonly config: typeof ChangesetConfig;
857
+ }>, {}>;
858
+ /**
859
+ * A {@link ReleasePlan} with what {@link ReleasePlan.readWithContext} read it
860
+ * from.
861
+ *
862
+ * @example
863
+ * ```ts
864
+ * import { ReleasePlan } from "@effected/changesets";
865
+ * import { Effect } from "effect";
866
+ *
867
+ * const program = Effect.gen(function* () {
868
+ * const { plan, packages, config } = yield* ReleasePlan.readWithContext("/repo/packages/a");
869
+ * return yield* Effect.fromResult(ReleasePlan.edits(plan, { packages, config }));
870
+ * });
871
+ * ```
872
+ *
873
+ * @public
874
+ */
875
+ export declare class ReleaseContext extends ReleaseContext_base {}
876
+ /**
877
+ * A bump as a changelog module receives it: `@changesets/types`'
878
+ * `VersionType`.
879
+ *
880
+ * @public
881
+ */
882
+ export declare const VersionType: Schema.Literals<readonly ["major", "minor", "patch", "none"]>;
883
+ /**
884
+ * The decoded type of {@link (VersionType:variable)}.
885
+ *
886
+ * @public
887
+ */
888
+ export type VersionType = typeof VersionType.Type;
889
+ /**
890
+ * A changeset as a changelog module receives it: `@changesets/types`'
891
+ * `NewChangeset`. `id` is the file name without `.md` (`pre/<name>` for one
892
+ * under `.changeset/pre/`), and `summary` is the text after the front matter,
893
+ * trimmed.
894
+ *
895
+ * @public
896
+ */
897
+ export declare const NewChangeset: Schema.Struct<{
898
+ readonly summary: Schema.mutableKey<Schema.String>;
899
+ readonly releases: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
900
+ readonly name: Schema.mutableKey<Schema.String>;
901
+ readonly type: Schema.mutableKey<Schema.Literals<readonly ["major", "minor", "patch", "none"]>>;
902
+ }>>>>;
903
+ readonly id: Schema.mutableKey<Schema.String>;
904
+ }>;
905
+ /**
906
+ * The decoded type of {@link (NewChangeset:variable)}.
907
+ *
908
+ * @public
909
+ */
910
+ export type NewChangeset = typeof NewChangeset.Type;
911
+ /**
912
+ * {@link (NewChangeset:variable)} with the commit that added the file, when the caller
913
+ * supplied one: `@changesets/types`' `NewChangesetWithCommit`.
914
+ *
915
+ * @public
916
+ */
917
+ export declare const NewChangesetWithCommit: Schema.Struct<{
918
+ readonly summary: Schema.mutableKey<Schema.String>;
919
+ readonly releases: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.Struct<{
920
+ readonly name: Schema.mutableKey<Schema.String>;
921
+ readonly type: Schema.mutableKey<Schema.Literals<readonly ["major", "minor", "patch", "none"]>>;
922
+ }>>>>;
923
+ readonly id: Schema.mutableKey<Schema.String>;
924
+ readonly commit: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
925
+ }>;
926
+ /**
927
+ * The decoded type of {@link (NewChangesetWithCommit:variable)}.
928
+ *
929
+ * @public
930
+ */
931
+ export type NewChangesetWithCommit = typeof NewChangesetWithCommit.Type;
932
+ /**
933
+ * A planned release as a changelog module receives one:
934
+ * `@changesets/types`' `ComprehensiveRelease`. `changesets` holds ids, as
935
+ * {@link (NewChangeset:variable)} does. Only a `none` entry may lack its versions.
936
+ *
937
+ * @public
938
+ */
939
+ export declare const ComprehensiveRelease: Schema.Union<readonly [Schema.Struct<{
940
+ readonly name: Schema.mutableKey<Schema.String>;
941
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
942
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
943
+ readonly newVersion: Schema.mutableKey<Schema.String>;
944
+ readonly type: Schema.mutableKey<Schema.Literal<"major">>;
945
+ }>, Schema.Struct<{
946
+ readonly name: Schema.mutableKey<Schema.String>;
947
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
948
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
949
+ readonly newVersion: Schema.mutableKey<Schema.String>;
950
+ readonly type: Schema.mutableKey<Schema.Literal<"minor">>;
951
+ }>, Schema.Struct<{
952
+ readonly name: Schema.mutableKey<Schema.String>;
953
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
954
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
955
+ readonly newVersion: Schema.mutableKey<Schema.String>;
956
+ readonly type: Schema.mutableKey<Schema.Literal<"patch">>;
957
+ }>, Schema.Struct<{
958
+ name: Schema.mutableKey<Schema.String>;
959
+ changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
960
+ type: Schema.mutableKey<Schema.Literal<"none">>;
961
+ oldVersion: Schema.mutableKey<Schema.UndefinedOr<Schema.String>>;
962
+ newVersion: Schema.mutableKey<Schema.UndefinedOr<Schema.String>>;
963
+ }>]>;
964
+ /**
965
+ * The decoded type of {@link (ComprehensiveRelease:variable)}.
966
+ *
967
+ * @public
968
+ */
969
+ export type ComprehensiveRelease = typeof ComprehensiveRelease.Type;
970
+ /**
971
+ * A manifest as a changelog module receives one: `@changesets/types`'
972
+ * `PackageJSON`. It is open: a key it does not name decodes and is kept,
973
+ * because a manifest carries far more than these, and a module may read any
974
+ * of them. `publishConfig` is open the same way for its `<scope>:registry`
975
+ * keys.
976
+ *
977
+ * @public
978
+ */
979
+ export declare const PackageJSON: Schema.StructWithRest<Schema.Struct<{
980
+ readonly name: Schema.mutableKey<Schema.String>;
981
+ readonly version: Schema.mutableKey<Schema.String>;
982
+ readonly dependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
983
+ readonly peerDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
984
+ readonly devDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
985
+ readonly optionalDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
986
+ readonly resolutions: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
987
+ readonly private: Schema.mutableKey<Schema.optionalKey<Schema.Boolean>>;
988
+ readonly publishConfig: Schema.mutableKey<Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
989
+ readonly access: Schema.mutableKey<Schema.optionalKey<Schema.Literals<readonly ["public", "restricted"]>>>;
990
+ readonly directory: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
991
+ readonly registry: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
992
+ }>, readonly [Schema.$Record<Schema.TemplateLiteral<readonly [Schema.String, ":registry"]>, Schema.String>]>>>;
993
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
994
+ /**
995
+ * The decoded type of {@link (PackageJSON:variable)}.
996
+ *
997
+ * @public
998
+ */
999
+ export type PackageJSON = typeof PackageJSON.Type;
1000
+ /**
1001
+ * A release with its package, as `getDependencyReleaseLine` receives the
1002
+ * dependencies a package's release updated: `@changesets/types`'
1003
+ * `ModCompWithPackage`. `dir` is the package's absolute directory.
1004
+ *
1005
+ * `relativeDir`, the directory relative to the workspace root, is optional
1006
+ * here and absent from `@changesets/types`' type, but `apply-release-plan`
1007
+ * passes it and so does {@link Changelog.entry}, so it is modelled and a
1008
+ * decode keeps it. An optional extra key leaves the two types mutually
1009
+ * assignable. Other unknown keys are dropped: this schema cannot be open the
1010
+ * way {@link (PackageJSON:variable)} is, because `@changesets/types` declares these
1011
+ * members as interfaces, which are not assignable to an index signature.
1012
+ *
1013
+ * @public
1014
+ */
1015
+ export declare const ModCompWithPackage: Schema.Union<readonly [Schema.Struct<{
1016
+ readonly name: Schema.mutableKey<Schema.String>;
1017
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
1018
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
1019
+ readonly newVersion: Schema.mutableKey<Schema.String>;
1020
+ readonly packageJson: Schema.mutableKey<Schema.StructWithRest<Schema.Struct<{
1021
+ readonly name: Schema.mutableKey<Schema.String>;
1022
+ readonly version: Schema.mutableKey<Schema.String>;
1023
+ readonly dependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1024
+ readonly peerDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1025
+ readonly devDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1026
+ readonly optionalDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1027
+ readonly resolutions: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1028
+ readonly private: Schema.mutableKey<Schema.optionalKey<Schema.Boolean>>;
1029
+ readonly publishConfig: Schema.mutableKey<Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1030
+ readonly access: Schema.mutableKey<Schema.optionalKey<Schema.Literals<readonly ["public", "restricted"]>>>;
1031
+ readonly directory: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1032
+ readonly registry: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1033
+ }>, readonly [Schema.$Record<Schema.TemplateLiteral<readonly [Schema.String, ":registry"]>, Schema.String>]>>>;
1034
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
1035
+ readonly dir: Schema.mutableKey<Schema.String>;
1036
+ readonly relativeDir: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1037
+ readonly type: Schema.mutableKey<Schema.Literal<"major">>;
1038
+ }>, Schema.Struct<{
1039
+ readonly name: Schema.mutableKey<Schema.String>;
1040
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
1041
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
1042
+ readonly newVersion: Schema.mutableKey<Schema.String>;
1043
+ readonly packageJson: Schema.mutableKey<Schema.StructWithRest<Schema.Struct<{
1044
+ readonly name: Schema.mutableKey<Schema.String>;
1045
+ readonly version: Schema.mutableKey<Schema.String>;
1046
+ readonly dependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1047
+ readonly peerDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1048
+ readonly devDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1049
+ readonly optionalDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1050
+ readonly resolutions: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1051
+ readonly private: Schema.mutableKey<Schema.optionalKey<Schema.Boolean>>;
1052
+ readonly publishConfig: Schema.mutableKey<Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1053
+ readonly access: Schema.mutableKey<Schema.optionalKey<Schema.Literals<readonly ["public", "restricted"]>>>;
1054
+ readonly directory: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1055
+ readonly registry: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1056
+ }>, readonly [Schema.$Record<Schema.TemplateLiteral<readonly [Schema.String, ":registry"]>, Schema.String>]>>>;
1057
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
1058
+ readonly dir: Schema.mutableKey<Schema.String>;
1059
+ readonly relativeDir: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1060
+ readonly type: Schema.mutableKey<Schema.Literal<"minor">>;
1061
+ }>, Schema.Struct<{
1062
+ readonly name: Schema.mutableKey<Schema.String>;
1063
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
1064
+ readonly oldVersion: Schema.mutableKey<Schema.String>;
1065
+ readonly newVersion: Schema.mutableKey<Schema.String>;
1066
+ readonly packageJson: Schema.mutableKey<Schema.StructWithRest<Schema.Struct<{
1067
+ readonly name: Schema.mutableKey<Schema.String>;
1068
+ readonly version: Schema.mutableKey<Schema.String>;
1069
+ readonly dependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1070
+ readonly peerDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1071
+ readonly devDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1072
+ readonly optionalDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1073
+ readonly resolutions: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1074
+ readonly private: Schema.mutableKey<Schema.optionalKey<Schema.Boolean>>;
1075
+ readonly publishConfig: Schema.mutableKey<Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1076
+ readonly access: Schema.mutableKey<Schema.optionalKey<Schema.Literals<readonly ["public", "restricted"]>>>;
1077
+ readonly directory: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1078
+ readonly registry: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1079
+ }>, readonly [Schema.$Record<Schema.TemplateLiteral<readonly [Schema.String, ":registry"]>, Schema.String>]>>>;
1080
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
1081
+ readonly dir: Schema.mutableKey<Schema.String>;
1082
+ readonly relativeDir: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1083
+ readonly type: Schema.mutableKey<Schema.Literal<"patch">>;
1084
+ }>, Schema.Struct<{
1085
+ readonly name: Schema.mutableKey<Schema.String>;
1086
+ readonly changesets: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.String>>>;
1087
+ readonly type: Schema.mutableKey<Schema.Literal<"none">>;
1088
+ readonly oldVersion: Schema.mutableKey<Schema.UndefinedOr<Schema.String>>;
1089
+ readonly newVersion: Schema.mutableKey<Schema.UndefinedOr<Schema.String>>;
1090
+ readonly packageJson: Schema.mutableKey<Schema.StructWithRest<Schema.Struct<{
1091
+ readonly name: Schema.mutableKey<Schema.String>;
1092
+ readonly version: Schema.mutableKey<Schema.String>;
1093
+ readonly dependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1094
+ readonly peerDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1095
+ readonly devDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1096
+ readonly optionalDependencies: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1097
+ readonly resolutions: Schema.mutableKey<Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>>;
1098
+ readonly private: Schema.mutableKey<Schema.optionalKey<Schema.Boolean>>;
1099
+ readonly publishConfig: Schema.mutableKey<Schema.optionalKey<Schema.StructWithRest<Schema.Struct<{
1100
+ readonly access: Schema.mutableKey<Schema.optionalKey<Schema.Literals<readonly ["public", "restricted"]>>>;
1101
+ readonly directory: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1102
+ readonly registry: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1103
+ }>, readonly [Schema.$Record<Schema.TemplateLiteral<readonly [Schema.String, ":registry"]>, Schema.String>]>>>;
1104
+ }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
1105
+ readonly dir: Schema.mutableKey<Schema.String>;
1106
+ readonly relativeDir: Schema.mutableKey<Schema.optionalKey<Schema.String>>;
1107
+ }>]>;
1108
+ /**
1109
+ * The decoded type of {@link (ModCompWithPackage:variable)}.
1110
+ *
1111
+ * @public
1112
+ */
1113
+ export type ModCompWithPackage = typeof ModCompWithPackage.Type;
1114
+ /**
1115
+ * Renders one changeset's line in a package's changelog block:
1116
+ * `@changesets/types`' `GetReleaseLine`.
1117
+ *
1118
+ * @public
1119
+ */
1120
+ type GetReleaseLine = (changeset: NewChangesetWithCommit, type: VersionType, changelogOpts: null | Record<string, unknown>) => string | Promise<string>;
1121
+ /**
1122
+ * Renders the line for the dependencies a package's release updated:
1123
+ * `@changesets/types`' `GetDependencyReleaseLine`.
1124
+ *
1125
+ * @public
1126
+ */
1127
+ type GetDependencyReleaseLine = (changesets: NewChangesetWithCommit[], dependenciesUpdated: ModCompWithPackage[], changelogOpts: null | Record<string, unknown>) => string | Promise<string>;
1128
+ /**
1129
+ * A changelog module: `@changesets/types`' `ChangelogFunctions`,
1130
+ * structurally identical, so one module loads under `@changesets/cli` and
1131
+ * here alike. `__test__/Changelog.types.test.ts` holds the identity both ways.
1132
+ * Functions are not schemas; their parameters are the schema types above.
1133
+ *
1134
+ * @public
1135
+ */
1136
+ type ChangelogFunctions = {
1137
+ getReleaseLine: GetReleaseLine;
1138
+ getDependencyReleaseLine: GetDependencyReleaseLine;
1139
+ };
1140
+ declare const ChangelogError_base: Schema.Class<ChangelogError, Schema.TaggedStruct<"ChangelogError", {
1141
+ /** The package whose block was being rendered. */
1142
+ readonly packageName: Schema.String;
1143
+ /** What the module threw. */
1144
+ readonly cause: Schema.Defect;
1145
+ }>, import("effect/Cause").YieldableError>;
1146
+ /**
1147
+ * A changelog module's function threw or rejected while rendering a
1148
+ * package's block.
1149
+ *
1150
+ * @public
1151
+ */
1152
+ export declare class ChangelogError extends ChangelogError_base {
1153
+ get message(): string;
1154
+ }
1155
+ /**
1156
+ * The inputs {@link Changelog.entry} reads besides the plan and the release.
1157
+ *
1158
+ * @public
1159
+ */
1160
+ interface ChangelogEntryOptions {
1161
+ /** Every package of the workspace, as given to {@link ReleasePlan.edits}. */
1162
+ readonly packages: ReadonlyArray<WorkspacePackage>;
1163
+ /** The config the plan was made with. */
1164
+ readonly config: ChangesetConfig;
1165
+ /**
1166
+ * The commit that added each changeset, keyed by the changeset's `file`
1167
+ * as {@link PendingChangeset} names it. A changeset with none is passed
1168
+ * with no `commit`. Finding them (`changeset version` asks git) is the
1169
+ * caller's job.
1170
+ */
1171
+ readonly commits?: ReadonlyMap<string, string> | undefined;
1172
+ /**
1173
+ * The options passed to each function as `changelogOpts`. Defaults to the
1174
+ * second element of `config.changelog` when it is a pair, else `null`.
1175
+ */
1176
+ readonly changelogOptions?: null | Record<string, unknown> | undefined;
1177
+ }
1178
+ /**
1179
+ * CHANGELOG assembly for a {@link ReleasePlan}, matching
1180
+ * `@changesets/apply-release-plan`.
1181
+ *
1182
+ * @remarks
1183
+ * This package never loads a changelog module. The caller resolves and
1184
+ * imports the module `config.changelog` names (or any other) and passes its
1185
+ * {@link ChangelogFunctions}; formatting the result (`changeset version`
1186
+ * runs prettier or another formatter over it) and writing the file are the
1187
+ * caller's too.
1188
+ *
1189
+ * Neither function reads `config.changelog` to decide whether to run:
1190
+ * {@link Changelog.entry} renders whatever functions it is given. A caller
1191
+ * whose config says `changelog: false` writes no changelog, as
1192
+ * `changeset version` writes none, and so does not call it.
1193
+ *
1194
+ * @public
1195
+ */
1196
+ export declare class Changelog {
1197
+ /**
1198
+ * Render `release`'s changelog block, the text `changeset version` inserts
1199
+ * into its `CHANGELOG.md`: `Option.none()` for a `none` entry, which gets
1200
+ * no block.
1201
+ *
1202
+ * As `apply-release-plan`'s `getChangelogEntry` does:
1203
+ *
1204
+ * - Each changeset in the plan naming the package with a real bump gets
1205
+ * `getReleaseLine`, under that bump's heading, in the plan's changeset
1206
+ * order.
1207
+ * - `getDependencyReleaseLine` is called once, always, and its line goes
1208
+ * last under `Patch Changes`. It gets the plan's releases (`none`
1209
+ * entries included) that the package's `dependencies` (else
1210
+ * `peerDependencies`) range would be updated for, by the rule
1211
+ * {@link ReleasePlan.edits} applies, with a `workspace:` path counting
1212
+ * when it points at the dependency, and the changesets behind them.
1213
+ * - The block is `## <newVersion>` then `### Major Changes`,
1214
+ * `### Minor Changes` and `### Patch Changes`, each only when it has a
1215
+ * non-empty line, blank-line separated; a line's own leading and
1216
+ * trailing newlines widen the gap to it, up to one blank line. With no
1217
+ * lines at all the block is `## <newVersion>` and
1218
+ * `No changes in this release.`
1219
+ * - Every function is called before any is awaited, as the oracle calls
1220
+ * them.
1221
+ *
1222
+ * A module's `packageJson` is the dependency's whole manifest as
1223
+ * discovery read it (`WorkspacePackage.manifestRecord`), before this
1224
+ * release's version, as the oracle passes it.
1225
+ *
1226
+ * Difference, ruled: a changeset with no commit in `options.commits` has
1227
+ * no `commit` key, where the oracle sets it to `undefined`.
1228
+ *
1229
+ * Fails with {@link ChangelogError} when a function throws or rejects,
1230
+ * with {@link MissingPackageError} when a release names a package
1231
+ * `options.packages` lacks, and with {@link ChangesetConfigError} when
1232
+ * the options element of `config.changelog` is neither an object nor
1233
+ * `null` and no `changelogOptions` override is given.
1234
+ *
1235
+ * @param plan - The plan the release belongs to.
1236
+ * @param release - The release whose block to render.
1237
+ * @param functions - The changelog module.
1238
+ * @param options - The workspace's packages, the config, the commits and
1239
+ * the module's options.
1240
+ */
1241
+ static readonly entry: (plan: ReleasePlan, release: PlannedRelease, functions: ChangelogFunctions, options: ChangelogEntryOptions) => Effect.Effect<Option.Option<string>, ChangelogError | ChangesetConfigError | MissingPackageError, never>;
1242
+ /**
1243
+ * Insert a block from {@link Changelog.entry} into a `CHANGELOG.md`'s
1244
+ * text, as `apply-release-plan`'s `updateChangelog` does, and return the
1245
+ * new text.
1246
+ *
1247
+ * - An empty `existing` (pass `""` for a file that does not exist) becomes
1248
+ * `# <packageName>`, a blank line, and the block.
1249
+ * - Otherwise the block goes before the first version heading (a `#` to
1250
+ * `######` heading starting with `<n>.<n>`), followed by a blank line.
1251
+ * - A file with no version heading gets the block after its first line,
1252
+ * which is where `# <packageName>` sits in a file changesets started;
1253
+ * a one-line file gets it appended.
1254
+ *
1255
+ * The block is trimmed and ends with one newline.
1256
+ *
1257
+ * @param existing - The changelog's current text, or `""`.
1258
+ * @param block - The block to insert.
1259
+ * @param packageName - The package name, for a new file's heading.
1260
+ */
1261
+ static insert(existing: string, block: string, packageName: string): string;
1262
+ }
1263
+ declare const ParsedChangeset_base: Schema.Class<ParsedChangeset, Schema.Struct<{
1264
+ /** Package name to requested release type, in file order. */
1265
+ readonly releases: Schema.$ReadonlyMap<Schema.String, Schema.Literals<readonly ["patch", "minor", "major", "none"]>>;
1266
+ /** The markdown after the front matter, trimmed as `@changesets/parse` trims it. */
1267
+ readonly summary: Schema.String;
1268
+ }>, {}>;
1269
+ /**
1270
+ * One parsed changeset: the packages it releases and its summary text.
1271
+ *
1272
+ * @public
1273
+ */
1274
+ export declare class ParsedChangeset extends ParsedChangeset_base {}
1275
+ /**
1276
+ * Parsing a changeset markdown file: YAML front matter mapping package names
1277
+ * to release types, then the summary.
1278
+ *
1279
+ * @public
1280
+ */
1281
+ export declare class ChangesetFile {
1282
+ /**
1283
+ * Parse a changeset synchronously.
1284
+ *
1285
+ * @param text - The file contents.
1286
+ * @returns A `Result` of the parsed changeset or a {@link ChangesetParseError}.
1287
+ */
1288
+ static parseSync(text: string): Result.Result<ParsedChangeset, ChangesetParseError>;
1289
+ /**
1290
+ * Parse a changeset; the `Effect` form of {@link ChangesetFile.parseSync}.
1291
+ *
1292
+ * @param text - The file contents.
1293
+ */
1294
+ static readonly parse: (text: string) => Effect.Effect<ParsedChangeset, ChangesetParseError, never>;
481
1295
  }
482
- export type { PendingChangesetFailure, SettledChangesets };
1296
+ export type { ChangelogEntryOptions, ChangelogFunctions, GetDependencyReleaseLine, GetReleaseLine, PendingChangesetFailure, ReleaseSnapshot, SettledChangesets };
483
1297
  //# sourceMappingURL=index.d.ts.map