@effected/changesets 0.5.0 → 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 +5 -3
package/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BumpType } from "./BumpType.js";
|
|
1
2
|
import { Schema } from "effect";
|
|
2
3
|
|
|
3
4
|
// src/errors.ts
|
|
@@ -35,19 +36,66 @@ reason: Schema.String }) {
|
|
|
35
36
|
/**
|
|
36
37
|
* A changeset names a package the workspace does not contain.
|
|
37
38
|
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* `code` is present only when a `manager: "pnpm"` plan raised it, and is
|
|
41
|
+
* then pnpm's `ERR_PNPM_VERSIONING_UNKNOWN_PACKAGE` (`UnknownPackage`,
|
|
42
|
+
* `crates/versioning/src/error.rs`). A Changesets plan leaves it out: the
|
|
43
|
+
* Changesets CLI has no error codes. It is a stored field rather than a getter
|
|
44
|
+
* because the mode that raised the error is not otherwise on the error.
|
|
45
|
+
*
|
|
38
46
|
* @public
|
|
39
47
|
*/
|
|
40
48
|
var UnknownPackageError = class extends Schema.TaggedError()("UnknownPackageError", {
|
|
41
49
|
/** The package name the changeset gave. */
|
|
42
50
|
packageName: Schema.String,
|
|
43
51
|
/** The changeset file that named it. */
|
|
44
|
-
changeset: Schema.String
|
|
52
|
+
changeset: Schema.String,
|
|
53
|
+
/** pnpm's code, when a pnpm plan raised the error. */
|
|
54
|
+
code: Schema.optionalKey(Schema.Literal("ERR_PNPM_VERSIONING_UNKNOWN_PACKAGE"))
|
|
45
55
|
}) {
|
|
46
56
|
get message() {
|
|
47
57
|
return `Changeset ${this.changeset} names ${this.packageName}, which is not in the workspace`;
|
|
48
58
|
}
|
|
49
59
|
};
|
|
50
60
|
/**
|
|
61
|
+
* A changeset names a package by a name that more than one workspace project
|
|
62
|
+
* publishes, so the name identifies none of them. Name the project by its
|
|
63
|
+
* `./`-prefixed workspace-relative directory instead.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* It arises two ways, and `changeset` tells them apart:
|
|
67
|
+
*
|
|
68
|
+
* - A pnpm plan's intent names a BARE name that several projects publish:
|
|
69
|
+
* pnpm's `AmbiguousPackage` for an intent. `changeset` names the file, and
|
|
70
|
+
* `code` is `ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE`. Under
|
|
71
|
+
* `manager: "pnpm"` the plan is keyed by directory, so a `./` key naming
|
|
72
|
+
* one of several same-named projects plans that project alone.
|
|
73
|
+
* - A name-keyed consumer of a plan ({@link ReleasePlan.edits},
|
|
74
|
+
* {@link ReleasePlan.breakingFloors}, {@link ReleasePlan.releasesByName})
|
|
75
|
+
* is handed a pnpm plan holding two releases with one name, which it cannot
|
|
76
|
+
* tell apart. `changeset` and `code` are absent: the refusal is the kit's,
|
|
77
|
+
* not pnpm's.
|
|
78
|
+
*
|
|
79
|
+
* A Changesets plan never raises it, so `code` is pnpm's whenever present.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
var AmbiguousPackageError = class extends Schema.TaggedError()("AmbiguousPackageError", {
|
|
84
|
+
/** The package name at fault. */
|
|
85
|
+
packageName: Schema.String,
|
|
86
|
+
/** The workspace-relative directories of the projects that publish it, in discovery order. */
|
|
87
|
+
directories: Schema.Array(Schema.String),
|
|
88
|
+
/** The changeset file that named it; absent when a plan's twin releases were refused. */
|
|
89
|
+
changeset: Schema.optionalKey(Schema.String),
|
|
90
|
+
/** pnpm's code, when a pnpm plan raised the error for an intent. */
|
|
91
|
+
code: Schema.optionalKey(Schema.Literal("ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE"))
|
|
92
|
+
}) {
|
|
93
|
+
get message() {
|
|
94
|
+
const dirs = this.directories.map((dir) => `./${dir}`).join(", ");
|
|
95
|
+
return this.changeset === void 0 ? `The release plan releases ${this.packageName} from ${this.directories.length} projects (${dirs}), which a name-keyed consumer cannot tell apart` : `Changeset ${this.changeset} names ${this.packageName}, which ${this.directories.length} projects publish (${dirs}); name one by its ./ directory`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
51
99
|
* A snapshot release was asked for while `.changeset/pre.json` has the
|
|
52
100
|
* repository in pre mode. `changeset version --snapshot` refuses the same
|
|
53
101
|
* way; leave pre mode (`changeset pre exit`) first.
|
|
@@ -102,5 +150,143 @@ packageName: Schema.String }) {
|
|
|
102
150
|
return `The release plan releases ${this.packageName}, which is not among the packages given`;
|
|
103
151
|
}
|
|
104
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* `.changeset/ledger.yaml` is not YAML, is not a mapping of releases, or has
|
|
155
|
+
* an entry that is neither a list of intent ids nor a `dir`/`intents` mapping.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
var LedgerError = class extends Schema.TaggedError()("LedgerError", {
|
|
160
|
+
/** Which way the ledger was malformed. */
|
|
161
|
+
code: Schema.Literals([
|
|
162
|
+
"invalid-yaml",
|
|
163
|
+
"not-a-mapping",
|
|
164
|
+
"invalid-entry"
|
|
165
|
+
]),
|
|
166
|
+
/** What was wrong, naming the ledger key when one is at fault. */
|
|
167
|
+
detail: Schema.String
|
|
168
|
+
}) {
|
|
169
|
+
get message() {
|
|
170
|
+
return `Invalid release ledger: ${this.detail}`;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
/** The reasons, in one list: `VersioningError`'s `reason` schema and the code table both read it. */
|
|
174
|
+
const VERSIONING_REASONS = [
|
|
175
|
+
"maxBumpExceeded",
|
|
176
|
+
"unreleasablePackage",
|
|
177
|
+
"epicOutOfBand",
|
|
178
|
+
"epicUnknownLead",
|
|
179
|
+
"epicOverlap",
|
|
180
|
+
"epicFixedGroupConflict",
|
|
181
|
+
"conflictingConfig",
|
|
182
|
+
"duplicateRelease",
|
|
183
|
+
"ambiguousPackage",
|
|
184
|
+
"ambiguousLedgerEntry",
|
|
185
|
+
"internalRange"
|
|
186
|
+
];
|
|
187
|
+
/** Exactly one code per reason: `satisfies` refuses a missing or an extra key. */
|
|
188
|
+
const VERSIONING_CODES = {
|
|
189
|
+
maxBumpExceeded: "ERR_PNPM_VERSIONING_MAX_BUMP_EXCEEDED",
|
|
190
|
+
unreleasablePackage: "ERR_PNPM_VERSIONING_UNRELEASABLE_PACKAGE",
|
|
191
|
+
epicOutOfBand: "ERR_PNPM_VERSIONING_EPIC_OUT_OF_BAND",
|
|
192
|
+
epicUnknownLead: "ERR_PNPM_VERSIONING_EPIC_UNKNOWN_LEAD",
|
|
193
|
+
epicOverlap: "ERR_PNPM_VERSIONING_EPIC_OVERLAP",
|
|
194
|
+
epicFixedGroupConflict: "ERR_PNPM_VERSIONING_EPIC_FIXED_GROUP_CONFLICT",
|
|
195
|
+
conflictingConfig: "ERR_PNPM_VERSIONING_CONFLICTING_CONFIG",
|
|
196
|
+
duplicateRelease: "ERR_PNPM_VERSIONING_DUPLICATE_RELEASE",
|
|
197
|
+
ambiguousPackage: "ERR_PNPM_VERSIONING_AMBIGUOUS_PACKAGE",
|
|
198
|
+
ambiguousLedgerEntry: "ERR_PNPM_INVALID_VERSIONING_LEDGER",
|
|
199
|
+
internalRange: "ERR_PNPM_VERSIONING_INTERNAL_RANGE"
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* pnpm's native versioning refuses the plan: a `versioning` rule in
|
|
203
|
+
* `pnpm-workspace.yaml` is broken by the plan, the configuration cannot be
|
|
204
|
+
* attributed to one project, or an intent asks for a release pnpm cannot make.
|
|
205
|
+
* Only {@link ReleasePlan.assemble} under `manager: "pnpm"` fails with it.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* Each `reason` is one of pnpm's own refusals, and `code` is the
|
|
209
|
+
* `ERR_PNPM_*` code pnpm prints for it, so a caller comparing with
|
|
210
|
+
* `pnpm change status` compares codes:
|
|
211
|
+
*
|
|
212
|
+
* - `maxBumpExceeded`: a release moves further than `versioning.maxBump`
|
|
213
|
+
* allows, measured on the final plan (`package`, `bump`, `maxBump`,
|
|
214
|
+
* `raisedBy`: the intent files that ask for that bump, or the causes when
|
|
215
|
+
* none does).
|
|
216
|
+
* - `unreleasablePackage`: an intent asks for a real bump of a project that
|
|
217
|
+
* cannot release, because it is in `versioning.ignore`, has no version or
|
|
218
|
+
* has a non-semver one (`package`, `bump`, `changeset`). Name it `none`
|
|
219
|
+
* instead.
|
|
220
|
+
* - `epicOutOfBand`: an epic member's new major leaves the band of its lead
|
|
221
|
+
* (`package`, `version`, `lead`, `bandMajor`).
|
|
222
|
+
* - `epicUnknownLead`: an epic's `lead` names no releasable project (`lead`).
|
|
223
|
+
* - `epicOverlap`: a project is matched by two epics (`directories`, `lead`
|
|
224
|
+
* and `secondLead`).
|
|
225
|
+
* - `epicFixedGroupConflict`: a fixed group mixes epic members with projects
|
|
226
|
+
* outside the epic (`lead`, `directories`: the outsiders).
|
|
227
|
+
* - `conflictingConfig`: a fixed group's members are on different lanes
|
|
228
|
+
* (`group`, as written).
|
|
229
|
+
* - `duplicateRelease`: two same-named projects would release the same
|
|
230
|
+
* version (`package`, `version`, `directories`).
|
|
231
|
+
* - `ambiguousPackage`: a `versioning` setting, or a dependency, names a
|
|
232
|
+
* package more than one project publishes (`package`, `context`,
|
|
233
|
+
* `directories`). An intent naming one is {@link AmbiguousPackageError}.
|
|
234
|
+
* - `ambiguousLedgerEntry`: a bare-list ledger entry names a package more
|
|
235
|
+
* than one project publishes, so it cannot be attributed (`ledgerKey`,
|
|
236
|
+
* `package`, `directories`). Write it with a `dir`.
|
|
237
|
+
* - `internalRange`: with `enforceWorkspaceProtocol`, an internal production
|
|
238
|
+
* dependency is not a `workspace:` range (`package`, `dependency`).
|
|
239
|
+
*
|
|
240
|
+
* A lane named `main` is refused earlier, by `VersioningConfig`'s schema,
|
|
241
|
+
* and an unknown intent key is {@link UnknownPackageError}.
|
|
242
|
+
*
|
|
243
|
+
* @public
|
|
244
|
+
*/
|
|
245
|
+
var VersioningError = class extends Schema.TaggedError()("VersioningError", {
|
|
246
|
+
/** Which of pnpm's refusals this is. */
|
|
247
|
+
reason: Schema.Literals(VERSIONING_REASONS),
|
|
248
|
+
/** The package at fault, by name, or the reference as written for `ambiguousPackage`. */
|
|
249
|
+
package: Schema.optionalKey(Schema.String),
|
|
250
|
+
/** The version the plan would release (`epicOutOfBand`, `duplicateRelease`). */
|
|
251
|
+
version: Schema.optionalKey(Schema.String),
|
|
252
|
+
/** The bump at fault: the release's effective bump, or the bump an intent asks for. */
|
|
253
|
+
bump: Schema.optionalKey(BumpType),
|
|
254
|
+
/** The configured `versioning.maxBump`. */
|
|
255
|
+
maxBump: Schema.optionalKey(BumpType),
|
|
256
|
+
/** What raised a release past `maxBump`: intent files, or its causes when no intent asks for the bump. */
|
|
257
|
+
raisedBy: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
258
|
+
/** The epic's lead, as configured. */
|
|
259
|
+
lead: Schema.optionalKey(Schema.String),
|
|
260
|
+
/** The second epic's lead, for `epicOverlap`. */
|
|
261
|
+
secondLead: Schema.optionalKey(Schema.String),
|
|
262
|
+
/** The lead's major the band derives from: members live in `bandMajor*100` to `bandMajor*100+99`. */
|
|
263
|
+
bandMajor: Schema.optionalKey(Schema.Number),
|
|
264
|
+
/** The workspace-relative directories involved. */
|
|
265
|
+
directories: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
266
|
+
/** The changeset (intent) file at fault, relative to `.changeset/`. */
|
|
267
|
+
changeset: Schema.optionalKey(Schema.String),
|
|
268
|
+
/** Where an ambiguous reference was written: a setting such as `versioning.fixed`, or the dependent package. */
|
|
269
|
+
context: Schema.optionalKey(Schema.String),
|
|
270
|
+
/** A fixed group, as configured. */
|
|
271
|
+
group: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
272
|
+
/** The ledger key at fault, `name@version`. */
|
|
273
|
+
ledgerKey: Schema.optionalKey(Schema.String),
|
|
274
|
+
/** The internal dependency at fault, for `internalRange`. */
|
|
275
|
+
dependency: Schema.optionalKey(Schema.Struct({
|
|
276
|
+
alias: Schema.String,
|
|
277
|
+
field: Schema.String,
|
|
278
|
+
specifier: Schema.String
|
|
279
|
+
}))
|
|
280
|
+
}) {
|
|
281
|
+
/** The `ERR_PNPM_*` code pnpm reports for this refusal. */
|
|
282
|
+
get code() {
|
|
283
|
+
return VERSIONING_CODES[this.reason];
|
|
284
|
+
}
|
|
285
|
+
get message() {
|
|
286
|
+
const dirs = (this.directories ?? []).map((dir) => `./${dir}`).join(", ");
|
|
287
|
+
const band = this.bandMajor === void 0 ? "" : `${this.bandMajor * 100}-${this.bandMajor * 100 + 99}`;
|
|
288
|
+
return this.reason === "maxBumpExceeded" ? `The release plan bumps ${this.package} by ${this.bump}, but versioning.maxBump caps releases at ${this.maxBump}; raised by ${(this.raisedBy ?? []).join(", ")}` : this.reason === "unreleasablePackage" ? `Changeset ${this.changeset} requests a ${this.bump} release of ${this.package}, which cannot release (ignored, version-less or not semver); remove the entry or change it to "none"` : this.reason === "epicOutOfBand" ? `The release plan takes ${this.package} to ${this.version}, outside the band ${band} of the epic led by "${this.lead}"` : this.reason === "epicUnknownLead" ? `versioning.epics lead "${this.lead}" is not a releasable workspace project` : this.reason === "epicOverlap" ? `${dirs} is matched by two epics (leads "${this.lead}" and "${this.secondLead}")` : this.reason === "epicFixedGroupConflict" ? `A fixed group straddles the epic led by "${this.lead}": it also holds ${dirs}` : this.reason === "conflictingConfig" ? `The fixed group [${(this.group ?? []).join(", ")}] mixes packages on different lanes` : this.reason === "duplicateRelease" ? `Two projects both release ${this.package}@${this.version}: ${dirs}` : this.reason === "ambiguousPackage" ? `${this.context} names ${this.package}, which matches several projects: ${dirs}; reference the project by directory` : this.reason === "ambiguousLedgerEntry" ? `The ledger entry ${this.ledgerKey} names ${this.package}, which matches several projects (${dirs}); give it a "dir"` : `Package ${this.package} declares ${this.dependency?.alias} in ${this.dependency?.field} as "${this.dependency?.specifier}"; internal dependencies must use the workspace: protocol`;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
105
291
|
|
|
106
|
-
export { ChangesetConfigError, ChangesetParseError, MissingPackageError, SnapshotPreModeError, SnapshotTemplateError, UnknownPackageError };
|
|
292
|
+
export { AmbiguousPackageError, ChangesetConfigError, ChangesetParseError, LedgerError, MissingPackageError, SnapshotPreModeError, SnapshotTemplateError, UnknownPackageError, VersioningError };
|