@effected/changesets 0.5.1 → 0.6.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/Ledger.js +200 -0
- package/PendingChangesets.js +68 -0
- package/RegistryVersions.js +50 -0
- package/ReleaseCause.js +30 -0
- package/ReleaseEdits.js +3 -0
- package/ReleaseManager.js +49 -0
- package/ReleasePlan.js +257 -20
- package/VersioningCheck.js +102 -0
- package/errors.js +188 -2
- package/index.d.ts +678 -10
- package/index.js +7 -2
- package/internal/pnpmPlan.js +610 -0
- package/internal/twins.js +21 -0
- package/package.json +4 -2
package/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { InvalidVersionError } from "@effected/semver";
|
|
14
14
|
import { WorkspaceDiscovery, WorkspaceDiscoveryError, WorkspacePackage, WorkspaceRootNotFoundError } from "@effected/workspaces";
|
|
15
|
-
import { Effect, FileSystem, Option, Path, PlatformError, Result, Schema } from "effect";
|
|
15
|
+
import { Context, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Schema } from "effect";
|
|
16
|
+
import { PnpmSettingsError, VersioningConfig } from "@effected/pnpm";
|
|
17
|
+
import { NpmConfig, NpmRegistry, RegistryReadError } from "@effected/npm";
|
|
16
18
|
declare const ChangesetParseError_base: Schema.Class<ChangesetParseError, Schema.TaggedStruct<"ChangesetParseError", {
|
|
17
19
|
/** What was wrong with the file. */
|
|
18
20
|
readonly reason: Schema.String;
|
|
@@ -48,15 +50,60 @@ declare const UnknownPackageError_base: Schema.Class<UnknownPackageError, Schema
|
|
|
48
50
|
readonly packageName: Schema.String;
|
|
49
51
|
/** The changeset file that named it. */
|
|
50
52
|
readonly changeset: Schema.String;
|
|
53
|
+
/** pnpm's code, when a pnpm plan raised the error. */
|
|
54
|
+
readonly code: Schema.optionalKey<Schema.Literal<"ERR_PNPM_VERSIONING_UNKNOWN_PACKAGE">>;
|
|
51
55
|
}>, import("effect/Cause").YieldableError>;
|
|
52
56
|
/**
|
|
53
57
|
* A changeset names a package the workspace does not contain.
|
|
54
58
|
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* `code` is present only when a `manager: "pnpm"` plan raised it, and is
|
|
61
|
+
* then pnpm's `ERR_PNPM_VERSIONING_UNKNOWN_PACKAGE` (`UnknownPackage`,
|
|
62
|
+
* `crates/versioning/src/error.rs`). A Changesets plan leaves it out: the
|
|
63
|
+
* Changesets CLI has no error codes. It is a stored field rather than a getter
|
|
64
|
+
* because the mode that raised the error is not otherwise on the error.
|
|
65
|
+
*
|
|
55
66
|
* @public
|
|
56
67
|
*/
|
|
57
68
|
export declare class UnknownPackageError extends UnknownPackageError_base {
|
|
58
69
|
get message(): string;
|
|
59
70
|
}
|
|
71
|
+
declare const AmbiguousPackageError_base: Schema.Class<AmbiguousPackageError, Schema.TaggedStruct<"AmbiguousPackageError", {
|
|
72
|
+
/** The package name at fault. */
|
|
73
|
+
readonly packageName: Schema.String;
|
|
74
|
+
/** The workspace-relative directories of the projects that publish it, in discovery order. */
|
|
75
|
+
readonly directories: Schema.$Array<Schema.String>;
|
|
76
|
+
/** The changeset file that named it; absent when a plan's twin releases were refused. */
|
|
77
|
+
readonly changeset: Schema.optionalKey<Schema.String>;
|
|
78
|
+
/** pnpm's code, when a pnpm plan raised the error for an intent. */
|
|
79
|
+
readonly code: Schema.optionalKey<Schema.Literal<"ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE">>;
|
|
80
|
+
}>, import("effect/Cause").YieldableError>;
|
|
81
|
+
/**
|
|
82
|
+
* A changeset names a package by a name that more than one workspace project
|
|
83
|
+
* publishes, so the name identifies none of them. Name the project by its
|
|
84
|
+
* `./`-prefixed workspace-relative directory instead.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* It arises two ways, and `changeset` tells them apart:
|
|
88
|
+
*
|
|
89
|
+
* - A pnpm plan's intent names a BARE name that several projects publish:
|
|
90
|
+
* pnpm's `AmbiguousPackage` for an intent. `changeset` names the file, and
|
|
91
|
+
* `code` is `ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE`. Under
|
|
92
|
+
* `manager: "pnpm"` the plan is keyed by directory, so a `./` key naming
|
|
93
|
+
* one of several same-named projects plans that project alone.
|
|
94
|
+
* - A name-keyed consumer of a plan ({@link ReleasePlan.edits},
|
|
95
|
+
* {@link ReleasePlan.breakingFloors}, {@link ReleasePlan.releasesByName})
|
|
96
|
+
* is handed a pnpm plan holding two releases with one name, which it cannot
|
|
97
|
+
* tell apart. `changeset` and `code` are absent: the refusal is the kit's,
|
|
98
|
+
* not pnpm's.
|
|
99
|
+
*
|
|
100
|
+
* A Changesets plan never raises it, so `code` is pnpm's whenever present.
|
|
101
|
+
*
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare class AmbiguousPackageError extends AmbiguousPackageError_base {
|
|
105
|
+
get message(): string;
|
|
106
|
+
}
|
|
60
107
|
declare const SnapshotPreModeError_base: Schema.Class<SnapshotPreModeError, Schema.TaggedStruct<"SnapshotPreModeError", {
|
|
61
108
|
/** The pre-release tag of the pre mode the repository is in. */
|
|
62
109
|
readonly preTag: Schema.String;
|
|
@@ -107,6 +154,113 @@ declare const MissingPackageError_base: Schema.Class<MissingPackageError, Schema
|
|
|
107
154
|
export declare class MissingPackageError extends MissingPackageError_base {
|
|
108
155
|
get message(): string;
|
|
109
156
|
}
|
|
157
|
+
declare const LedgerError_base: Schema.Class<LedgerError, Schema.TaggedStruct<"LedgerError", {
|
|
158
|
+
/** Which way the ledger was malformed. */
|
|
159
|
+
readonly code: Schema.Literals<readonly ["invalid-yaml", "not-a-mapping", "invalid-entry"]>;
|
|
160
|
+
/** What was wrong, naming the ledger key when one is at fault. */
|
|
161
|
+
readonly detail: Schema.String;
|
|
162
|
+
}>, import("effect/Cause").YieldableError>;
|
|
163
|
+
/**
|
|
164
|
+
* `.changeset/ledger.yaml` is not YAML, is not a mapping of releases, or has
|
|
165
|
+
* an entry that is neither a list of intent ids nor a `dir`/`intents` mapping.
|
|
166
|
+
*
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export declare class LedgerError extends LedgerError_base {
|
|
170
|
+
get message(): string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The `ERR_PNPM_*` code pnpm reports for each {@link VersioningError} reason,
|
|
174
|
+
* as its `VersioningError` enum declares them (`crates/versioning/src/error.rs`).
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
type VersioningErrorCode = "ERR_PNPM_VERSIONING_MAX_BUMP_EXCEEDED" | "ERR_PNPM_VERSIONING_UNRELEASABLE_PACKAGE" | "ERR_PNPM_VERSIONING_EPIC_OUT_OF_BAND" | "ERR_PNPM_VERSIONING_EPIC_UNKNOWN_LEAD" | "ERR_PNPM_VERSIONING_EPIC_OVERLAP" | "ERR_PNPM_VERSIONING_EPIC_FIXED_GROUP_CONFLICT" | "ERR_PNPM_VERSIONING_CONFLICTING_CONFIG" | "ERR_PNPM_VERSIONING_DUPLICATE_RELEASE" | "ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE" | "ERR_PNPM_INVALID_VERSIONING_LEDGER" | "ERR_PNPM_VERSIONING_INTERNAL_RANGE";
|
|
179
|
+
declare const VersioningError_base: Schema.Class<VersioningError, Schema.TaggedStruct<"VersioningError", {
|
|
180
|
+
/** Which of pnpm's refusals this is. */
|
|
181
|
+
readonly reason: Schema.Literals<readonly ["maxBumpExceeded", "unreleasablePackage", "epicOutOfBand", "epicUnknownLead", "epicOverlap", "epicFixedGroupConflict", "conflictingConfig", "duplicateRelease", "ambiguousPackage", "ambiguousLedgerEntry", "internalRange"]>;
|
|
182
|
+
/** The package at fault, by name, or the reference as written for `ambiguousPackage`. */
|
|
183
|
+
readonly package: Schema.optionalKey<Schema.String>;
|
|
184
|
+
/** The version the plan would release (`epicOutOfBand`, `duplicateRelease`). */
|
|
185
|
+
readonly version: Schema.optionalKey<Schema.String>;
|
|
186
|
+
/** The bump at fault: the release's effective bump, or the bump an intent asks for. */
|
|
187
|
+
readonly bump: Schema.optionalKey<Schema.Literals<readonly ["patch", "minor", "major"]>>;
|
|
188
|
+
/** The configured `versioning.maxBump`. */
|
|
189
|
+
readonly maxBump: Schema.optionalKey<Schema.Literals<readonly ["patch", "minor", "major"]>>;
|
|
190
|
+
/** What raised a release past `maxBump`: intent files, or its causes when no intent asks for the bump. */
|
|
191
|
+
readonly raisedBy: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
192
|
+
/** The epic's lead, as configured. */
|
|
193
|
+
readonly lead: Schema.optionalKey<Schema.String>;
|
|
194
|
+
/** The second epic's lead, for `epicOverlap`. */
|
|
195
|
+
readonly secondLead: Schema.optionalKey<Schema.String>;
|
|
196
|
+
/** The lead's major the band derives from: members live in `bandMajor*100` to `bandMajor*100+99`. */
|
|
197
|
+
readonly bandMajor: Schema.optionalKey<Schema.Number>;
|
|
198
|
+
/** The workspace-relative directories involved. */
|
|
199
|
+
readonly directories: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
200
|
+
/** The changeset (intent) file at fault, relative to `.changeset/`. */
|
|
201
|
+
readonly changeset: Schema.optionalKey<Schema.String>;
|
|
202
|
+
/** Where an ambiguous reference was written: a setting such as `versioning.fixed`, or the dependent package. */
|
|
203
|
+
readonly context: Schema.optionalKey<Schema.String>;
|
|
204
|
+
/** A fixed group, as configured. */
|
|
205
|
+
readonly group: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
206
|
+
/** The ledger key at fault, `name@version`. */
|
|
207
|
+
readonly ledgerKey: Schema.optionalKey<Schema.String>;
|
|
208
|
+
/** The internal dependency at fault, for `internalRange`. */
|
|
209
|
+
readonly dependency: Schema.optionalKey<Schema.Struct<{
|
|
210
|
+
readonly alias: Schema.String;
|
|
211
|
+
readonly field: Schema.String;
|
|
212
|
+
readonly specifier: Schema.String;
|
|
213
|
+
}>>;
|
|
214
|
+
}>, import("effect/Cause").YieldableError>;
|
|
215
|
+
/**
|
|
216
|
+
* pnpm's native versioning refuses the plan: a `versioning` rule in
|
|
217
|
+
* `pnpm-workspace.yaml` is broken by the plan, the configuration cannot be
|
|
218
|
+
* attributed to one project, or an intent asks for a release pnpm cannot make.
|
|
219
|
+
* Only {@link ReleasePlan.assemble} under `manager: "pnpm"` fails with it.
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* Each `reason` is one of pnpm's own refusals, and `code` is the
|
|
223
|
+
* `ERR_PNPM_*` code pnpm prints for it, so a caller comparing with
|
|
224
|
+
* `pnpm change status` compares codes:
|
|
225
|
+
*
|
|
226
|
+
* - `maxBumpExceeded`: a release moves further than `versioning.maxBump`
|
|
227
|
+
* allows, measured on the final plan (`package`, `bump`, `maxBump`,
|
|
228
|
+
* `raisedBy`: the intent files that ask for that bump, or the causes when
|
|
229
|
+
* none does).
|
|
230
|
+
* - `unreleasablePackage`: an intent asks for a real bump of a project that
|
|
231
|
+
* cannot release, because it is in `versioning.ignore`, has no version or
|
|
232
|
+
* has a non-semver one (`package`, `bump`, `changeset`). Name it `none`
|
|
233
|
+
* instead.
|
|
234
|
+
* - `epicOutOfBand`: an epic member's new major leaves the band of its lead
|
|
235
|
+
* (`package`, `version`, `lead`, `bandMajor`).
|
|
236
|
+
* - `epicUnknownLead`: an epic's `lead` names no releasable project (`lead`).
|
|
237
|
+
* - `epicOverlap`: a project is matched by two epics (`directories`, `lead`
|
|
238
|
+
* and `secondLead`).
|
|
239
|
+
* - `epicFixedGroupConflict`: a fixed group mixes epic members with projects
|
|
240
|
+
* outside the epic (`lead`, `directories`: the outsiders).
|
|
241
|
+
* - `conflictingConfig`: a fixed group's members are on different lanes
|
|
242
|
+
* (`group`, as written).
|
|
243
|
+
* - `duplicateRelease`: two same-named projects would release the same
|
|
244
|
+
* version (`package`, `version`, `directories`).
|
|
245
|
+
* - `ambiguousPackage`: a `versioning` setting, or a dependency, names a
|
|
246
|
+
* package more than one project publishes (`package`, `context`,
|
|
247
|
+
* `directories`). An intent naming one is {@link AmbiguousPackageError}.
|
|
248
|
+
* - `ambiguousLedgerEntry`: a bare-list ledger entry names a package more
|
|
249
|
+
* than one project publishes, so it cannot be attributed (`ledgerKey`,
|
|
250
|
+
* `package`, `directories`). Write it with a `dir`.
|
|
251
|
+
* - `internalRange`: with `enforceWorkspaceProtocol`, an internal production
|
|
252
|
+
* dependency is not a `workspace:` range (`package`, `dependency`).
|
|
253
|
+
*
|
|
254
|
+
* A lane named `main` is refused earlier, by `VersioningConfig`'s schema,
|
|
255
|
+
* and an unknown intent key is {@link UnknownPackageError}.
|
|
256
|
+
*
|
|
257
|
+
* @public
|
|
258
|
+
*/
|
|
259
|
+
export declare class VersioningError extends VersioningError_base {
|
|
260
|
+
/** The `ERR_PNPM_*` code pnpm reports for this refusal. */
|
|
261
|
+
get code(): VersioningErrorCode;
|
|
262
|
+
get message(): string;
|
|
263
|
+
}
|
|
110
264
|
declare const ChangesetConfig_base: Schema.Class<ChangesetConfig, Schema.Struct<{
|
|
111
265
|
/** The branch releases are cut against. Defaults to `main`. */
|
|
112
266
|
readonly baseBranch: Schema.withDecodingDefaultKey<Schema.String, never>;
|
|
@@ -236,6 +390,123 @@ export declare const ReleaseType: Schema.Literals<readonly ["patch", "minor", "m
|
|
|
236
390
|
* @public
|
|
237
391
|
*/
|
|
238
392
|
export type ReleaseType = typeof ReleaseType.Type;
|
|
393
|
+
/**
|
|
394
|
+
* How the ledger records an intent against one project: not at all, only at
|
|
395
|
+
* prerelease versions, or at a stable version. See {@link Ledger.consumption}.
|
|
396
|
+
*
|
|
397
|
+
* @public
|
|
398
|
+
*/
|
|
399
|
+
type Consumption = "none" | "prerelease-only" | "stable";
|
|
400
|
+
declare const LedgerEntry_base: Schema.Class<LedgerEntry, Schema.Struct<{
|
|
401
|
+
/** The package name; a scoped name keeps its `@scope/`. */
|
|
402
|
+
readonly name: Schema.String;
|
|
403
|
+
/** The released version, the part of the ledger key after its last `@`. */
|
|
404
|
+
readonly version: Schema.String;
|
|
405
|
+
/**
|
|
406
|
+
* The released project's workspace-relative directory as recorded, the
|
|
407
|
+
* engine's unit of identity. Absent on an entry written as a bare list of
|
|
408
|
+
* ids, which names no directory.
|
|
409
|
+
*/
|
|
410
|
+
readonly dir: Schema.optionalKey<Schema.String>;
|
|
411
|
+
/** The ids (file names without `.md`) of the intents the release consumed. */
|
|
412
|
+
readonly intents: Schema.$Array<Schema.String>;
|
|
413
|
+
}>, {}>;
|
|
414
|
+
/**
|
|
415
|
+
* One consumed release in the ledger: the package, the version it released,
|
|
416
|
+
* the project directory, and the ids of the intent files that release
|
|
417
|
+
* consumed.
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
*/
|
|
421
|
+
export declare class LedgerEntry extends LedgerEntry_base {}
|
|
422
|
+
declare const Ledger_base: Schema.Class<Ledger, Schema.Struct<{
|
|
423
|
+
/** Every release the ledger records, in file order. */
|
|
424
|
+
readonly entries: Schema.$Array<typeof LedgerEntry>;
|
|
425
|
+
}>, {}>;
|
|
426
|
+
/**
|
|
427
|
+
* The decoded `.changeset/ledger.yaml`: pnpm's committed, append-only record
|
|
428
|
+
* of which intent files each release consumed.
|
|
429
|
+
*
|
|
430
|
+
* @remarks
|
|
431
|
+
* pnpm does not delete an intent file when a release consumes it. The file
|
|
432
|
+
* stays until every project it names has released, so whether an intent is
|
|
433
|
+
* still pending is a per-project question: an intent is pending for a project
|
|
434
|
+
* exactly when no ledger entry for that project lists its id. Entries are
|
|
435
|
+
* matched to a project by `dir` (the engine's unit of identity, since package
|
|
436
|
+
* names may collide across projects, and a package may be renamed), never by
|
|
437
|
+
* the name in the key; only an entry written as a bare id list carries no
|
|
438
|
+
* `dir` and is matched by name. The file maps
|
|
439
|
+
* `<name>@<version>` to `{ dir, intents }` or to a bare list of ids; a key
|
|
440
|
+
* with no `@` after its first character is skipped, as pnpm skips it.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* import { Effect, Option } from "effect";
|
|
445
|
+
* import { Ledger } from "@effected/changesets";
|
|
446
|
+
*
|
|
447
|
+
* // `FileSystem` and `Path` come from the platform layer at the edge.
|
|
448
|
+
* const program = Ledger.read("/repo").pipe(
|
|
449
|
+
* Effect.map(Option.map((ledger) => ledger.consumed("calm-cats-resolve", "@example/core"))),
|
|
450
|
+
* );
|
|
451
|
+
* ```
|
|
452
|
+
*
|
|
453
|
+
* @public
|
|
454
|
+
*/
|
|
455
|
+
export declare class Ledger extends Ledger_base {
|
|
456
|
+
/**
|
|
457
|
+
* Parse the text of a ledger. A blank file is an empty ledger. Fails with
|
|
458
|
+
* {@link LedgerError} on text that is not YAML, a document that is not a
|
|
459
|
+
* mapping, or an entry of the wrong shape; never throws.
|
|
460
|
+
*
|
|
461
|
+
* @param text - The contents of `.changeset/ledger.yaml`.
|
|
462
|
+
*/
|
|
463
|
+
static parseResult(text: string): Result.Result<Ledger, LedgerError>;
|
|
464
|
+
/**
|
|
465
|
+
* Read `<root>/.changeset/ledger.yaml`: `Option.none()` when the file does
|
|
466
|
+
* not exist, which is the state of a repository pnpm has not yet released.
|
|
467
|
+
*
|
|
468
|
+
* Fails with {@link LedgerError} when the file is malformed.
|
|
469
|
+
*
|
|
470
|
+
* @param root - The repository root.
|
|
471
|
+
*/
|
|
472
|
+
static readonly read: (root: string) => Effect.Effect<Option.Option<Ledger>, LedgerError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
473
|
+
/**
|
|
474
|
+
* Whether a BARE-LIST entry for the package called `name` consumed the
|
|
475
|
+
* intent. As pnpm does, an entry that records a `dir` is never matched by
|
|
476
|
+
* the name in its key (a renamed or reused name would answer for the wrong
|
|
477
|
+
* project): use {@link Ledger.consumedDir} or {@link Ledger.consumption}
|
|
478
|
+
* for those. Only an entry written as a bare id list is matched by name.
|
|
479
|
+
*
|
|
480
|
+
* @param intent - The intent id: the file name without `.md`.
|
|
481
|
+
* @param name - The package name.
|
|
482
|
+
*/
|
|
483
|
+
consumed(intent: string, name: string): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Whether an ATTRIBUTED entry (one that records a `dir`) for the project in
|
|
486
|
+
* `dir` consumed the intent, at any version. `dir` is normalised as pnpm
|
|
487
|
+
* normalises it (backslashes to `/`, leading `./` and trailing `/` removed).
|
|
488
|
+
*
|
|
489
|
+
* @param intent - The intent id: the file name without `.md`.
|
|
490
|
+
* @param dir - The project's workspace-relative directory.
|
|
491
|
+
*/
|
|
492
|
+
consumedDir(intent: string, dir: string): boolean;
|
|
493
|
+
/**
|
|
494
|
+
* How the ledger records the intent against one project, as pnpm's
|
|
495
|
+
* `build_consumption_index` indexes it: an attributed entry counts for the
|
|
496
|
+
* project in its `dir`, a bare-list entry for the project its name resolves
|
|
497
|
+
* to (here, `project.name`). A version whose part before `+` contains `-` is
|
|
498
|
+
* a prerelease. `"stable"` when any matching entry is a stable version;
|
|
499
|
+
* otherwise `"prerelease-only"` when only prerelease entries list it;
|
|
500
|
+
* otherwise `"none"`.
|
|
501
|
+
*
|
|
502
|
+
* @param intent - The intent id: the file name without `.md`.
|
|
503
|
+
* @param project - The project's package name and workspace-relative directory.
|
|
504
|
+
*/
|
|
505
|
+
consumption(intent: string, project: {
|
|
506
|
+
readonly name: string;
|
|
507
|
+
readonly dir: string;
|
|
508
|
+
}): Consumption;
|
|
509
|
+
}
|
|
239
510
|
declare const PendingChangeset_base: Schema.Class<PendingChangeset, Schema.Struct<{
|
|
240
511
|
/**
|
|
241
512
|
* The file name, relative to `.changeset/`: `pre/<name>.md` for a
|
|
@@ -260,6 +531,18 @@ export declare class PendingChangeset extends PendingChangeset_base {
|
|
|
260
531
|
*/
|
|
261
532
|
get id(): string;
|
|
262
533
|
}
|
|
534
|
+
/**
|
|
535
|
+
* A workspace project as {@link PendingChangesets.unconsumed} resolves a
|
|
536
|
+
* release key against it: a `WorkspacePackage` satisfies it.
|
|
537
|
+
*
|
|
538
|
+
* @public
|
|
539
|
+
*/
|
|
540
|
+
interface ProjectRef {
|
|
541
|
+
/** The package name. */
|
|
542
|
+
readonly name: string;
|
|
543
|
+
/** The workspace-relative directory. */
|
|
544
|
+
readonly relativePath: string;
|
|
545
|
+
}
|
|
263
546
|
/**
|
|
264
547
|
* One changeset file {@link PendingChangesets.readSettled} could not read or
|
|
265
548
|
* parse.
|
|
@@ -305,6 +588,44 @@ export declare class PendingChangesets {
|
|
|
305
588
|
* @param root - The repository root.
|
|
306
589
|
*/
|
|
307
590
|
static readonly read: (root: string) => Effect.Effect<PendingChangeset[], ChangesetParseError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
591
|
+
/**
|
|
592
|
+
* The changesets still pending under pnpm's versioning, given its
|
|
593
|
+
* {@link Ledger}: pnpm leaves an intent file in place until every project
|
|
594
|
+
* it names has released, so each release key is dropped when the ledger
|
|
595
|
+
* records its project as having consumed this intent, and a changeset with
|
|
596
|
+
* no key left is dropped. The project is resolved as pnpm resolves it: a
|
|
597
|
+
* key starting `./` names a directory (normalised), any other key a package
|
|
598
|
+
* name that must resolve to exactly one of `packages`; a key that resolves
|
|
599
|
+
* to none, or to several, is kept, as pnpm's `is_release_consumed` keeps it,
|
|
600
|
+
* for the planner to refuse. Consumption is read through
|
|
601
|
+
* {@link Ledger.consumption}, matching an attributed entry by `dir` and a
|
|
602
|
+
* bare-list entry by name.
|
|
603
|
+
*
|
|
604
|
+
* A prerelease-only consumption (the intent listed only against a version
|
|
605
|
+
* such as `2.1.0-alpha.0`) also drops the key, since pnpm's
|
|
606
|
+
* `collect_pending_intents` (`plan/propagation.rs`) excludes every id in
|
|
607
|
+
* `all_ids`. pnpm still counts such an intent toward the project's stable
|
|
608
|
+
* bump and changelog at graduation (`collect_lane_consumed_intents`, same
|
|
609
|
+
* file); {@link PendingChangesets.laneConsumed} returns that set.
|
|
610
|
+
*
|
|
611
|
+
* @param changesets - The changesets {@link PendingChangesets.read} returned.
|
|
612
|
+
* @param ledger - The ledger to read consumption from.
|
|
613
|
+
* @param packages - The workspace packages, to resolve a key to a project.
|
|
614
|
+
*/
|
|
615
|
+
static unconsumed(changesets: ReadonlyArray<PendingChangeset>, ledger: Ledger, packages: ReadonlyArray<ProjectRef>): ReadonlyArray<PendingChangeset>;
|
|
616
|
+
/**
|
|
617
|
+
* The changesets, narrowed to the release keys whose project has consumed
|
|
618
|
+
* the intent ONLY at prerelease versions: pnpm's
|
|
619
|
+
* `collect_lane_consumed_intents` (`plan/propagation.rs`). They are not
|
|
620
|
+
* pending, but still count toward the project's cumulative bump and the
|
|
621
|
+
* stable changelog when it graduates. Keys are resolved as in
|
|
622
|
+
* {@link PendingChangesets.unconsumed}.
|
|
623
|
+
*
|
|
624
|
+
* @param changesets - The changesets {@link PendingChangesets.read} returned.
|
|
625
|
+
* @param ledger - The ledger to read consumption from.
|
|
626
|
+
* @param packages - The workspace packages, to resolve a key to a project.
|
|
627
|
+
*/
|
|
628
|
+
static laneConsumed(changesets: ReadonlyArray<PendingChangeset>, ledger: Ledger, packages: ReadonlyArray<ProjectRef>): ReadonlyArray<PendingChangeset>;
|
|
308
629
|
/**
|
|
309
630
|
* Read the same files as {@link PendingChangesets.read}, in the same order,
|
|
310
631
|
* but skip a file that does not read or parse and report it in `failures`
|
|
@@ -491,6 +812,61 @@ declare const BreakingFloor_base: Schema.Class<BreakingFloor, Schema.Struct<{
|
|
|
491
812
|
* @public
|
|
492
813
|
*/
|
|
493
814
|
export declare class BreakingFloor extends BreakingFloor_base {}
|
|
815
|
+
/**
|
|
816
|
+
* Where {@link (ReleaseManager:variable).detect} reads the environment from.
|
|
817
|
+
*
|
|
818
|
+
* @public
|
|
819
|
+
*/
|
|
820
|
+
interface ReleaseManagerDetectOptions {
|
|
821
|
+
/**
|
|
822
|
+
* The environment, as a plain record, handed to `PnpmSettings.load`. It
|
|
823
|
+
* matters only when `PNPM_CONFIG_WORKSPACE_DIR` names a workspace directory;
|
|
824
|
+
* the default is an empty record, so the answer never depends on the
|
|
825
|
+
* ambient process.
|
|
826
|
+
*/
|
|
827
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
828
|
+
/** The platform handed to `PnpmSettings.load`; it never changes the answer. Defaults to `"linux"`. */
|
|
829
|
+
readonly platform?: string;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* The tool that plans and applies a repository's releases: the Changesets
|
|
833
|
+
* CLI, or pnpm's own versioning.
|
|
834
|
+
*
|
|
835
|
+
* @remarks
|
|
836
|
+
* `detect` answers `"pnpm"` when the workspace's `pnpm-workspace.yaml` has a
|
|
837
|
+
* `versioning` block, or `.changeset/ledger.yaml` exists, and `"changesets"`
|
|
838
|
+
* otherwise. pnpm ignores `.changeset/pre.json` and `config.json` entirely, so
|
|
839
|
+
* their presence decides nothing: a `pre.json` beside a `versioning` key is
|
|
840
|
+
* still pnpm. A `versioning` block that does not decode fails with
|
|
841
|
+
* `PnpmSettingsError` rather than reading as absent. The value is both the
|
|
842
|
+
* schema of the two names and the namespace of `detect`.
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* ```ts
|
|
846
|
+
* import { Effect } from "effect";
|
|
847
|
+
* import { ReleaseManager } from "@effected/changesets";
|
|
848
|
+
*
|
|
849
|
+
* // `FileSystem` and `Path` come from the platform layer at the edge.
|
|
850
|
+
* const program = ReleaseManager.detect("/repo").pipe(Effect.map((manager) => manager === "pnpm"));
|
|
851
|
+
* ```
|
|
852
|
+
*
|
|
853
|
+
* @public
|
|
854
|
+
*/
|
|
855
|
+
export declare const ReleaseManager: Schema.Literals<readonly ["changesets", "pnpm"]> & {
|
|
856
|
+
/**
|
|
857
|
+
* Detect which tool plans the releases of the repository at `root`.
|
|
858
|
+
*
|
|
859
|
+
* @param root - The repository root, where `pnpm-workspace.yaml` and `.changeset/` live.
|
|
860
|
+
* @param options - The environment handed to `PnpmSettings.load`; see {@link ReleaseManagerDetectOptions}.
|
|
861
|
+
*/
|
|
862
|
+
detect: (root: string, options?: ReleaseManagerDetectOptions | undefined) => Effect.Effect<"changesets" | "pnpm", import("effect/PlatformError").PlatformError | PnpmSettingsError, FileSystem.FileSystem | Path.Path>;
|
|
863
|
+
};
|
|
864
|
+
/**
|
|
865
|
+
* The tool that plans a repository's releases.
|
|
866
|
+
*
|
|
867
|
+
* @public
|
|
868
|
+
*/
|
|
869
|
+
export type ReleaseManager = typeof ReleaseManager.Type;
|
|
494
870
|
/**
|
|
495
871
|
* The input for a snapshot plan, `changeset version --snapshot`'s parameters.
|
|
496
872
|
* {@link ReleasePlan.assemble} documents how each is read.
|
|
@@ -512,6 +888,14 @@ interface ReleaseSnapshot {
|
|
|
512
888
|
declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
|
|
513
889
|
/** The package name. */
|
|
514
890
|
readonly name: Schema.String;
|
|
891
|
+
/**
|
|
892
|
+
* The project's workspace-relative directory as pnpm spells it (no
|
|
893
|
+
* leading `./`, no trailing `/`, `""` for the workspace root). Present
|
|
894
|
+
* only in a `manager: "pnpm"` plan, which is keyed by directory, so two
|
|
895
|
+
* same-named projects can each have a release; a Changesets plan is keyed
|
|
896
|
+
* by name and leaves it out.
|
|
897
|
+
*/
|
|
898
|
+
readonly dir: Schema.optionalKey<Schema.String>;
|
|
515
899
|
/** The bump, or `none` for a listed package whose version does not move. */
|
|
516
900
|
readonly type: Schema.Literals<readonly ["patch", "minor", "major", "none"]>;
|
|
517
901
|
/**
|
|
@@ -519,7 +903,11 @@ declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
|
|
|
519
903
|
* member of a fixed or linked group, the group's highest.
|
|
520
904
|
*/
|
|
521
905
|
readonly oldVersion: Schema.String;
|
|
522
|
-
/**
|
|
906
|
+
/**
|
|
907
|
+
* The version after the release; equal to `oldVersion` when `type` is
|
|
908
|
+
* `none`, and in a pnpm plan for a first release, which publishes its
|
|
909
|
+
* manifest version as it is.
|
|
910
|
+
*/
|
|
523
911
|
readonly newVersion: Schema.String;
|
|
524
912
|
/**
|
|
525
913
|
* The ids of the changesets in the plan that name the package, as the
|
|
@@ -556,12 +944,30 @@ declare const PlannedRelease_base: Schema.Class<PlannedRelease, Schema.Struct<{
|
|
|
556
944
|
* ripple brings back, has an empty list.
|
|
557
945
|
* - A snapshot plan builds its releases exactly as a plain one does.
|
|
558
946
|
*
|
|
947
|
+
* In a pnpm plan the list is the intents the release consumes, the ids pnpm
|
|
948
|
+
* records in its ledger: those still pending, and, when it graduates off a
|
|
949
|
+
* lane, those its prereleases consumed.
|
|
950
|
+
*
|
|
559
951
|
* To tell a group or exit bump from a ripple, read `fixed` and `linked`
|
|
560
952
|
* and the plan's `preState`. To tell whether the package's own changeset
|
|
561
953
|
* set its type, compare `type` with the highest bump its listed changesets
|
|
562
954
|
* give it.
|
|
563
955
|
*/
|
|
564
956
|
readonly changesets: Schema.$Array<Schema.String>;
|
|
957
|
+
/**
|
|
958
|
+
* Why the package is in the plan, each cause once, in pnpm's order
|
|
959
|
+
* (`dependencies`, `epic`, `fixed`, `intent`).
|
|
960
|
+
*
|
|
961
|
+
* @remarks
|
|
962
|
+
* A pnpm plan reports the causes pnpm reports. A Changesets plan fills
|
|
963
|
+
* them from the paths its oracle has: `intent` for a release a changeset
|
|
964
|
+
* made (and for a prerelease completed on `exit`), `dependencies` for one
|
|
965
|
+
* a ripple made, which replaces the entry and its causes as the ripple
|
|
966
|
+
* replaces the release, and `fixed` for a member a fixed group added or
|
|
967
|
+
* moved. A `linked` group adds no cause. Decoding a value without the
|
|
968
|
+
* field gives `[]`.
|
|
969
|
+
*/
|
|
970
|
+
readonly causes: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.$Array<Schema.Literals<readonly ["dependencies", "epic", "fixed", "intent"]>>, never>>;
|
|
565
971
|
}>, {}>;
|
|
566
972
|
/**
|
|
567
973
|
* One package's place in a {@link ReleasePlan}.
|
|
@@ -751,10 +1157,63 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
751
1157
|
* suffix is never empty, so the oracle's quiet fallback to plain versions
|
|
752
1158
|
* on an empty suffix cannot happen here.
|
|
753
1159
|
*
|
|
1160
|
+
* With `manager: "pnpm"` the plan is pnpm's own, `assemble_release_plan`
|
|
1161
|
+
* from pnpm 12.20.0's `crates/versioning`, held to pnpm's recorded answers
|
|
1162
|
+
* (`__test__/fixtures/pnpm-native/`). `config` and `pre` are not read, since
|
|
1163
|
+
* pnpm reads neither file, and a changeset under `.changeset/pre/` is not an
|
|
1164
|
+
* intent. What it reads instead:
|
|
1165
|
+
*
|
|
1166
|
+
* - `versioning`: `pnpm-workspace.yaml`'s block. Lanes build `X.Y.Z-<lane>.N`,
|
|
1167
|
+
* the counter continuing while the stable target holds and resetting when
|
|
1168
|
+
* a bigger bump moves it (`2.1.0-alpha.1` plus a major is `3.0.0-alpha.0`);
|
|
1169
|
+
* a package off its lane graduates to the stable version its lane built,
|
|
1170
|
+
* but only when the intents that built it are still pending files the
|
|
1171
|
+
* ledger records under prerelease versions alone. `fixed` groups share
|
|
1172
|
+
* their highest version, bumped. Epic members keep their majors in the
|
|
1173
|
+
* lead's band, `M*100` to `M*100+99`, and re-base to the next band's floor
|
|
1174
|
+
* when the lead releases a new stable major. `ignore` takes a project out
|
|
1175
|
+
* of planning. `maxBump` caps the final plan's real version distance.
|
|
1176
|
+
* - `ledger`: which intents each project already consumed, matched by `dir`,
|
|
1177
|
+
* or by name for a bare-list entry.
|
|
1178
|
+
* - `published`: the registry seam, the project directories whose MANIFEST
|
|
1179
|
+
* version the registry already has (pnpm probes exactly that version, so
|
|
1180
|
+
* a newer published `latest` does not count). Absent, the first-release
|
|
1181
|
+
* rule is off and nothing debuts. Given, a public release whose directory
|
|
1182
|
+
* the set lacks is a first release: it keeps its manifest version (on a
|
|
1183
|
+
* lane, `<stable>-<lane>.0`) while still reporting its intent's bump and
|
|
1184
|
+
* consuming its intents, and the plan is made again, as `pnpm version -r`
|
|
1185
|
+
* makes it. A private project is never probed, so never debuts.
|
|
1186
|
+
* - `enforceWorkspaceProtocol`: refuse an internal production dependency
|
|
1187
|
+
* that is not a `workspace:` range, as `pnpm version -r` does. Off is
|
|
1188
|
+
* `pnpm change status`'s reading.
|
|
1189
|
+
*
|
|
1190
|
+
* The plan is keyed by project directory: each release has its `dir`, so two
|
|
1191
|
+
* same-named projects each release. A changeset may name a project by its
|
|
1192
|
+
* `./`-prefixed workspace-relative directory (`"./packages/b": patch`),
|
|
1193
|
+
* normalised as pnpm normalises one (backslashes to `/`, every leading `./`
|
|
1194
|
+
* and the trailing `/` removed, `./` alone being the root). A key that names
|
|
1195
|
+
* nothing fails {@link UnknownPackageError}, and a bare name that more than
|
|
1196
|
+
* one project publishes {@link AmbiguousPackageError}, both even for an
|
|
1197
|
+
* intent already consumed. A dependent ripples `patch` only through a
|
|
1198
|
+
* `workspace:` range the dependency's new version leaves, so a 1.x minor
|
|
1199
|
+
* stays inside `workspace:^` and a plain range never ripples;
|
|
1200
|
+
* devDependencies never do. Every other refusal is {@link VersioningError},
|
|
1201
|
+
* whose `code` is pnpm's.
|
|
1202
|
+
*
|
|
1203
|
+
* The default, `"changesets"`, is the Changesets CLI's reading: a `./` key is
|
|
1204
|
+
* an unknown package, as it is there.
|
|
1205
|
+
*
|
|
1206
|
+
* A snapshot under `manager: "pnpm"` is the engine's: every release becomes
|
|
1207
|
+
* `0.0.0-<suffix>`, with the suffix built from the snapshot alone as above
|
|
1208
|
+
* (`useCalculatedVersion` is not read), and bands and `maxBump` go
|
|
1209
|
+
* unchecked.
|
|
1210
|
+
*
|
|
754
1211
|
* @param input - The packages to plan, the pending changesets, the config
|
|
755
1212
|
* and, in pre-release mode, the {@link PreState}, and for a snapshot
|
|
756
|
-
* release the {@link ReleaseSnapshot}
|
|
757
|
-
*
|
|
1213
|
+
* release the {@link ReleaseSnapshot}; for a pnpm plan, its `versioning`,
|
|
1214
|
+
* `ledger`, `published` and `enforceWorkspaceProtocol`.
|
|
1215
|
+
* {@link ReleasePlan.read} decides whether the workspace root is one of the
|
|
1216
|
+
* packages.
|
|
758
1217
|
*/
|
|
759
1218
|
static assemble(input: {
|
|
760
1219
|
readonly packages: ReadonlyArray<WorkspacePackage>;
|
|
@@ -762,7 +1221,12 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
762
1221
|
readonly config: ChangesetConfig;
|
|
763
1222
|
readonly pre?: PreState;
|
|
764
1223
|
readonly snapshot?: ReleaseSnapshot;
|
|
765
|
-
|
|
1224
|
+
readonly manager?: ReleaseManager;
|
|
1225
|
+
readonly versioning?: VersioningConfig;
|
|
1226
|
+
readonly ledger?: Ledger;
|
|
1227
|
+
readonly published?: ReadonlySet<string>;
|
|
1228
|
+
readonly enforceWorkspaceProtocol?: boolean;
|
|
1229
|
+
}): Result.Result<ReleasePlan, UnknownPackageError | AmbiguousPackageError | ChangesetConfigError | InvalidVersionError | SnapshotPreModeError | SnapshotTemplateError | VersioningError>;
|
|
766
1230
|
/**
|
|
767
1231
|
* What `changeset version` writes for `plan`, as data: each manifest's new
|
|
768
1232
|
* `version` and rewritten dependency ranges, the changeset files it
|
|
@@ -832,6 +1296,14 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
832
1296
|
* writing caret ranges. A plan without a snapshot deletes that
|
|
833
1297
|
* `pre.json`; a caller reproducing the CLI keeps it.
|
|
834
1298
|
*
|
|
1299
|
+
* These are Changesets semantics, keyed by package name. pnpm applies its own
|
|
1300
|
+
* plans, writing `workspace:` ranges it never rewrites and the dependency
|
|
1301
|
+
* updates its plan carries, which a {@link PlannedRelease} does not; so a
|
|
1302
|
+
* `manager: "pnpm"` plan is read here as Changesets would apply it. A pnpm
|
|
1303
|
+
* plan holding two releases with one name (same-named projects) fails
|
|
1304
|
+
* {@link AmbiguousPackageError} listing their directories, since an edit
|
|
1305
|
+
* keyed by name would land both on one manifest.
|
|
1306
|
+
*
|
|
835
1307
|
* Fails with {@link MissingPackageError} when the plan releases a package
|
|
836
1308
|
* `packages` lacks, and with `InvalidVersionError` when a bounded range
|
|
837
1309
|
* must be bumped past a new version that is not a version, which a plan
|
|
@@ -845,7 +1317,7 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
845
1317
|
static edits(plan: ReleasePlan, input: {
|
|
846
1318
|
readonly packages: ReadonlyArray<WorkspacePackage>;
|
|
847
1319
|
readonly config: ChangesetConfig;
|
|
848
|
-
}): Result.Result<ReleaseEdits, MissingPackageError | InvalidVersionError>;
|
|
1320
|
+
}): Result.Result<ReleaseEdits, MissingPackageError | InvalidVersionError | AmbiguousPackageError>;
|
|
849
1321
|
/**
|
|
850
1322
|
* The releases in `plan` that stay on their own breaking line while a range
|
|
851
1323
|
* they publish crosses a dependency's breaking line. Nothing is written; a
|
|
@@ -887,6 +1359,9 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
887
1359
|
* dependent `patch` however far the dependency moves, so a dependency's
|
|
888
1360
|
* breaking release ripples as a patch of everything that peers on it.
|
|
889
1361
|
*
|
|
1362
|
+
* Keyed by package name, as {@link ReleasePlan.edits} is: a pnpm plan
|
|
1363
|
+
* holding two releases with one name fails {@link AmbiguousPackageError}.
|
|
1364
|
+
*
|
|
890
1365
|
* Fails as {@link ReleasePlan.edits} fails, which a plan
|
|
891
1366
|
* {@link ReleasePlan.assemble} made from the same packages never does.
|
|
892
1367
|
*
|
|
@@ -899,7 +1374,18 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
899
1374
|
static breakingFloors(plan: ReleasePlan, input: {
|
|
900
1375
|
readonly packages: ReadonlyArray<WorkspacePackage>;
|
|
901
1376
|
readonly config: ChangesetConfig;
|
|
902
|
-
}): Result.Result<ReadonlyArray<BreakingFloor>, MissingPackageError | InvalidVersionError>;
|
|
1377
|
+
}): Result.Result<ReadonlyArray<BreakingFloor>, MissingPackageError | InvalidVersionError | AmbiguousPackageError>;
|
|
1378
|
+
/**
|
|
1379
|
+
* The plan's releases keyed by package name, for a consumer that reads a
|
|
1380
|
+
* plan by name. A Changesets plan always has one release per name. A
|
|
1381
|
+
* `manager: "pnpm"` plan is keyed by directory and may release two
|
|
1382
|
+
* same-named projects; then this fails {@link AmbiguousPackageError} naming
|
|
1383
|
+
* the first such name and every directory releasing it, rather than letting
|
|
1384
|
+
* one release silently stand for both.
|
|
1385
|
+
*
|
|
1386
|
+
* @param plan - The plan to key.
|
|
1387
|
+
*/
|
|
1388
|
+
static releasesByName(plan: ReleasePlan): Result.Result<ReadonlyMap<string, PlannedRelease>, AmbiguousPackageError>;
|
|
903
1389
|
/**
|
|
904
1390
|
* Discover the workspace's packages, read its config, pending changesets and
|
|
905
1391
|
* `.changeset/pre.json`, and {@link ReleasePlan.assemble | assemble} the
|
|
@@ -925,13 +1411,37 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
925
1411
|
* calls `WorkspaceDiscovery`'s `refreshIn(root)` first, or the new plan
|
|
926
1412
|
* reads the versions the release replaced.
|
|
927
1413
|
*
|
|
1414
|
+
* In a repository `ReleaseManager.detect` calls pnpm's, the plan is pnpm's
|
|
1415
|
+
* (see {@link ReleasePlan.assemble}): every discovered project is planned,
|
|
1416
|
+
* the root included; the `versioning` block is read through `PnpmSettings`
|
|
1417
|
+
* and the ledger through {@link Ledger.read}; a `config.json` that is missing,
|
|
1418
|
+
* is not JSON or has a malformed value is the defaults, because pnpm plans
|
|
1419
|
+
* without the file (it feeds only {@link ReleasePlan.edits} and the
|
|
1420
|
+
* changelog); `pre.json` is not read. With a {@link RegistryVersions} provided,
|
|
1421
|
+
* the registry is asked whether each public release's manifest version is
|
|
1422
|
+
* published, and the ones it lacks are planned as first releases
|
|
1423
|
+
* ({@link ReleasePlan.assemble}'s `published`); a registry failure is
|
|
1424
|
+
* `RegistryReadError`, never read as unpublished. A snapshot never asks. It
|
|
1425
|
+
* also fails with `PnpmSettingsError` and {@link LedgerError}.
|
|
1426
|
+
*
|
|
1427
|
+
* The registry service is read with `Effect.serviceOption`, so it never
|
|
1428
|
+
* appears in `R` and nothing fails to compile when it is missing. Never
|
|
1429
|
+
* provide only the `WorkspaceDiscovery` and platform layers to a pnpm-native
|
|
1430
|
+
* repository and expect first releases: without
|
|
1431
|
+
* `RegistryVersions.layerFrom(config)` nothing is asked, no release debuts,
|
|
1432
|
+
* and a project that was never published plans a bump from its manifest
|
|
1433
|
+
* version (`1.0.0` to `1.1.0`) where `pnpm version -r` would publish
|
|
1434
|
+
* `1.0.0` itself; the plan reports success either way. Provide
|
|
1435
|
+
* `RegistryVersions.layerFrom(config)` (it requires `NpmRegistry`) whenever
|
|
1436
|
+
* the plan feeds a publish.
|
|
1437
|
+
*
|
|
928
1438
|
* @param directory - The workspace root, or a directory inside it.
|
|
929
1439
|
* @param options - `snapshot` plans a snapshot release, as
|
|
930
1440
|
* {@link ReleasePlan.assemble} describes.
|
|
931
1441
|
*/
|
|
932
1442
|
static readonly read: (directory: string, options?: {
|
|
933
1443
|
readonly snapshot?: ReleaseSnapshot | undefined;
|
|
934
|
-
} | undefined) => Effect.Effect<ReleasePlan, ChangesetConfigError | ChangesetParseError | InvalidVersionError | PlatformError.PlatformError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
|
|
1444
|
+
} | undefined) => Effect.Effect<ReleasePlan, AmbiguousPackageError | ChangesetConfigError | ChangesetParseError | InvalidVersionError | LedgerError | PlatformError.PlatformError | import("@effected/pnpm").PnpmSettingsError | import("@effected/npm").RegistryReadError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | VersioningError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
|
|
935
1445
|
/**
|
|
936
1446
|
* {@link ReleasePlan.read}, returning the plan with everything it was read
|
|
937
1447
|
* from, so a caller hands {@link ReleasePlan.edits} and `Changelog.entry`
|
|
@@ -945,7 +1455,7 @@ export declare class ReleasePlan extends ReleasePlan_base {
|
|
|
945
1455
|
*/
|
|
946
1456
|
static readonly readWithContext: (directory: string, options?: {
|
|
947
1457
|
readonly snapshot?: ReleaseSnapshot | undefined;
|
|
948
|
-
} | undefined) => Effect.Effect<ReleaseContext, ChangesetConfigError | ChangesetParseError | InvalidVersionError | PlatformError.PlatformError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
|
|
1458
|
+
} | undefined) => Effect.Effect<ReleaseContext, AmbiguousPackageError | ChangesetConfigError | ChangesetParseError | InvalidVersionError | LedgerError | PlatformError.PlatformError | import("@effected/pnpm").PnpmSettingsError | import("@effected/npm").RegistryReadError | SnapshotPreModeError | SnapshotTemplateError | UnknownPackageError | VersioningError | WorkspaceDiscoveryError | import("@effected/workspaces").WorkspacePatternError | WorkspaceRootNotFoundError, FileSystem.FileSystem | Path.Path | WorkspaceDiscovery>;
|
|
949
1459
|
}
|
|
950
1460
|
declare const ReleaseContext_base: Schema.Class<ReleaseContext, Schema.Struct<{
|
|
951
1461
|
/** The workspace root the plan was read from: the directory climbed to, not the one given. */
|
|
@@ -1399,5 +1909,163 @@ export declare class ChangesetFile {
|
|
|
1399
1909
|
*/
|
|
1400
1910
|
static readonly parse: (text: string) => Effect.Effect<ParsedChangeset, ChangesetParseError, never>;
|
|
1401
1911
|
}
|
|
1402
|
-
|
|
1912
|
+
/**
|
|
1913
|
+
* The {@link RegistryVersions} service shape.
|
|
1914
|
+
*
|
|
1915
|
+
* @public
|
|
1916
|
+
*/
|
|
1917
|
+
interface RegistryVersionsShape {
|
|
1918
|
+
/**
|
|
1919
|
+
* Whether the registry has exactly `name@version`.
|
|
1920
|
+
*
|
|
1921
|
+
* @remarks
|
|
1922
|
+
* `false` is the registry answering 404 for the package, or a version list
|
|
1923
|
+
* without `version`. A transport or status failure is the error, never
|
|
1924
|
+
* `false`: reading an outage as "unpublished" would plan a debut release of
|
|
1925
|
+
* a version that exists.
|
|
1926
|
+
*/
|
|
1927
|
+
readonly published: (name: string, version: string) => Effect.Effect<boolean, RegistryReadError>;
|
|
1928
|
+
}
|
|
1929
|
+
declare const RegistryVersions_base: Context.ServiceClass<RegistryVersions, "@effected/changesets/RegistryVersions", RegistryVersionsShape>;
|
|
1930
|
+
/**
|
|
1931
|
+
* The registry seam of first releases: is a project's manifest version
|
|
1932
|
+
* already published?
|
|
1933
|
+
*
|
|
1934
|
+
* @remarks
|
|
1935
|
+
* pnpm decides a first release by probing the registry for exactly the
|
|
1936
|
+
* manifest version (`package.versions.contains_key(current)`,
|
|
1937
|
+
* `crates/cli/src/cli_args/changelog.rs:322`), where only a 404 means
|
|
1938
|
+
* unpublished and any other failure propagates. {@link ReleasePlan.read} asks
|
|
1939
|
+
* this service for each public release when it is provided, and plans without
|
|
1940
|
+
* it, treating nothing as a first release, when it is not.
|
|
1941
|
+
*
|
|
1942
|
+
* A project that renames itself with `publishConfig.name` is probed under
|
|
1943
|
+
* that name, as pnpm does, so `ReleasePlan.read` passes the published name.
|
|
1944
|
+
*
|
|
1945
|
+
* @public
|
|
1946
|
+
*/
|
|
1947
|
+
export declare class RegistryVersions extends RegistryVersions_base {
|
|
1948
|
+
/**
|
|
1949
|
+
* The service over `NpmRegistry`, each package read from the registry and
|
|
1950
|
+
* with the credential `config` routes it to.
|
|
1951
|
+
*
|
|
1952
|
+
* @remarks
|
|
1953
|
+
* `NpmConfig.targetFor(name)` picks the package's own registry (`@scope:registry`)
|
|
1954
|
+
* and the credential npm would send for it, as pnpm's `registry_for` and
|
|
1955
|
+
* `auth_header_for_package` do (`changelog.rs:298-308`). Reading the default
|
|
1956
|
+
* registry anonymously instead would answer 404 for a scoped package on a
|
|
1957
|
+
* private registry, which reads as unpublished and debuts a version that
|
|
1958
|
+
* exists.
|
|
1959
|
+
*
|
|
1960
|
+
* A parameterized layer factory mints a fresh reference per call and layers
|
|
1961
|
+
* memoize by reference: bind the result to a `const` once, or the layer
|
|
1962
|
+
* builds twice.
|
|
1963
|
+
*
|
|
1964
|
+
* @param config - The resolved npm configuration, usually `NpmConfig.load`'s.
|
|
1965
|
+
*/
|
|
1966
|
+
static readonly layerFrom: (config: NpmConfig) => Layer.Layer<RegistryVersions, never, NpmRegistry>;
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Why a release is in a plan, pnpm's `ReleaseCause`
|
|
1970
|
+
* (`crates/versioning/src/plan.rs:56-68`): `intent`, a changeset naming it;
|
|
1971
|
+
* `dependencies`, a dependency it ripples from; `fixed`, a fixed group it
|
|
1972
|
+
* belongs to; `epic`, its epic lead crossing a major. The literals are listed
|
|
1973
|
+
* in pnpm's report order, the derived `Ord`, which is alphabetical.
|
|
1974
|
+
*
|
|
1975
|
+
* @public
|
|
1976
|
+
*/
|
|
1977
|
+
export declare const ReleaseCause: Schema.Literals<readonly ["dependencies", "epic", "fixed", "intent"]>;
|
|
1978
|
+
/**
|
|
1979
|
+
* The type of a `ReleaseCause` value.
|
|
1980
|
+
*
|
|
1981
|
+
* @public
|
|
1982
|
+
*/
|
|
1983
|
+
export type ReleaseCause = typeof ReleaseCause.Type;
|
|
1984
|
+
declare const EpicOutOfBand_base: Schema.Class<EpicOutOfBand, Schema.TaggedStruct<"EpicOutOfBand", {
|
|
1985
|
+
/** The epic's lead, as configured. */
|
|
1986
|
+
readonly epic: Schema.String;
|
|
1987
|
+
/** The member at fault, by name. */
|
|
1988
|
+
readonly package: Schema.String;
|
|
1989
|
+
/** The member's committed version. */
|
|
1990
|
+
readonly version: Schema.String;
|
|
1991
|
+
/** The member's committed major, the one outside the band. */
|
|
1992
|
+
readonly major: Schema.Number;
|
|
1993
|
+
/** The lead's major the band derives from: members live in `bandMajor*100` to `bandMajor*100+99`. */
|
|
1994
|
+
readonly bandMajor: Schema.Number;
|
|
1995
|
+
}>, {}>;
|
|
1996
|
+
/**
|
|
1997
|
+
* An epic member whose committed major is outside the band of its lead.
|
|
1998
|
+
*
|
|
1999
|
+
* @public
|
|
2000
|
+
*/
|
|
2001
|
+
export declare class EpicOutOfBand extends EpicOutOfBand_base {
|
|
2002
|
+
/** One line, as `pnpm change check` words it. */
|
|
2003
|
+
get message(): string;
|
|
2004
|
+
}
|
|
2005
|
+
declare const FixedOutOfStep_base: Schema.Class<FixedOutOfStep, Schema.TaggedStruct<"FixedOutOfStep", {
|
|
2006
|
+
/** The group, as written in `versioning.fixed`. */
|
|
2007
|
+
readonly group: Schema.$Array<Schema.String>;
|
|
2008
|
+
/** Each participating member and its committed version, in the group's order. */
|
|
2009
|
+
readonly versions: Schema.$Array<Schema.Struct<{
|
|
2010
|
+
readonly package: Schema.String;
|
|
2011
|
+
readonly version: Schema.String;
|
|
2012
|
+
}>>;
|
|
2013
|
+
}>, {}>;
|
|
2014
|
+
/**
|
|
2015
|
+
* A fixed group whose members do not share one version.
|
|
2016
|
+
*
|
|
2017
|
+
* @public
|
|
2018
|
+
*/
|
|
2019
|
+
export declare class FixedOutOfStep extends FixedOutOfStep_base {
|
|
2020
|
+
/** One line, as `pnpm change check` words it. */
|
|
2021
|
+
get message(): string;
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* A committed-version invariant the `versioning` block declares and the
|
|
2025
|
+
* workspace currently breaks.
|
|
2026
|
+
*
|
|
2027
|
+
* @public
|
|
2028
|
+
*/
|
|
2029
|
+
type VersioningViolation = EpicOutOfBand | FixedOutOfStep;
|
|
2030
|
+
/**
|
|
2031
|
+
* The check behind `pnpm change check`: are the committed versions where the
|
|
2032
|
+
* `versioning` block says they must be?
|
|
2033
|
+
*
|
|
2034
|
+
* @remarks
|
|
2035
|
+
* A port of `check_versioning_invariants`
|
|
2036
|
+
* (`.repos/pnpm/pnpm/crates/versioning/src/plan.rs:217`). It looks at no
|
|
2037
|
+
* intent and plans nothing: with no plan, an epic's band comes from its lead's
|
|
2038
|
+
* current major (a lead on `N.0.0-<lane>.x` is still in the band of `N-1`),
|
|
2039
|
+
* and every member is held to it; every fixed group must share one version.
|
|
2040
|
+
* The band rule is the one the planner enforces on new versions, read from the
|
|
2041
|
+
* same function, so the two cannot disagree.
|
|
2042
|
+
*
|
|
2043
|
+
* Every violation is returned, not the first: epic members in directory order
|
|
2044
|
+
* per epic, then fixed groups in declaration order. A `versioning` block pnpm
|
|
2045
|
+
* refuses (an ambiguous name, an unknown lead, overlapping epics) fails with
|
|
2046
|
+
* {@link VersioningError} before any version is looked at, as pnpm's does.
|
|
2047
|
+
*
|
|
2048
|
+
* @example
|
|
2049
|
+
* ```ts
|
|
2050
|
+
* import { VersioningCheck } from "@effected/changesets";
|
|
2051
|
+
* import { Result } from "effect";
|
|
2052
|
+
*
|
|
2053
|
+
* const found = VersioningCheck.check([], undefined);
|
|
2054
|
+
* console.log(Result.isSuccess(found) && found.success.length);
|
|
2055
|
+
* // => 0
|
|
2056
|
+
* ```
|
|
2057
|
+
*
|
|
2058
|
+
* @public
|
|
2059
|
+
*/
|
|
2060
|
+
export declare class VersioningCheck {
|
|
2061
|
+
private constructor();
|
|
2062
|
+
/**
|
|
2063
|
+
* Check `packages`' committed versions against `versioning`.
|
|
2064
|
+
*
|
|
2065
|
+
* @param packages - Every package of the workspace, the root included.
|
|
2066
|
+
* @param versioning - The `versioning` block, or none.
|
|
2067
|
+
*/
|
|
2068
|
+
static check(packages: ReadonlyArray<WorkspacePackage>, versioning: VersioningConfig | undefined): Result.Result<ReadonlyArray<VersioningViolation>, VersioningError>;
|
|
2069
|
+
}
|
|
2070
|
+
export type { ChangelogEntryOptions, ChangelogFunctions, Consumption, GetDependencyReleaseLine, GetReleaseLine, PendingChangesetFailure, ProjectRef, RegistryVersionsShape, ReleaseManagerDetectOptions, ReleaseSnapshot, SettledChangesets, VersioningErrorCode, VersioningViolation };
|
|
1403
2071
|
//# sourceMappingURL=index.d.ts.map
|