@effected/changesets 0.0.0-stage → 0.1.0

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