@savvy-web/silk-effects 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -300,6 +300,30 @@ var GitError = class extends GitErrorBase {
300
300
  return `git command failed in ${this.cwd}: ${this.command}\n${this.reason}`;
301
301
  }
302
302
  };
303
+ /**
304
+ * Base class for {@link ReleasePlanError}.
305
+ *
306
+ * @privateRemarks
307
+ * Required export for api-extractor (anonymous Data.TaggedError base). Do not delete.
308
+ *
309
+ * @internal
310
+ */
311
+ const ReleasePlanErrorBase = Data.TaggedError("ReleasePlanError");
312
+ /**
313
+ * Release planning, preview, or apply failure.
314
+ *
315
+ * @remarks
316
+ * Wraps any failure from the underlying `@changesets/*` machinery
317
+ * (`getReleasePlan`, `applyReleasePlan`, config resolution) into a typed
318
+ * Effect error, tagged with the phase that failed.
319
+ *
320
+ * @public
321
+ */
322
+ var ReleasePlanError = class extends ReleasePlanErrorBase {
323
+ get message() {
324
+ return `Release plan error (${this.phase}): ${this.reason}`;
325
+ }
326
+ };
303
327
 
304
328
  //#endregion
305
- export { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, VersionFileError, VersionFileErrorBase };
329
+ export { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, ReleasePlanError, ReleasePlanErrorBase, VersionFileError, VersionFileErrorBase };
@@ -1,6 +1,6 @@
1
1
  import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
2
  import { Categories } from "./api/categories.js";
3
- import { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, VersionFileError, VersionFileErrorBase } from "./errors.js";
3
+ import { ChangesetValidationError, ChangesetValidationErrorBase, ConfigurationError, ConfigurationErrorBase, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, MarkdownParseError, MarkdownParseErrorBase, ReleasePlanError, ReleasePlanErrorBase, VersionFileError, VersionFileErrorBase } from "./errors.js";
4
4
  import { JsonPathSchema, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, VersionFileConfigSchema, VersionFilesSchema } from "./schemas/version-files.js";
5
5
  import { GlobSchema, PackageScopeSchema, PackagesRecordSchema } from "./schemas/package-scope.js";
6
6
  import { ChangesetOptionsSchema, RepoSchema } from "./schemas/options.js";
@@ -28,13 +28,15 @@ import { ChangelogTransformer } from "./api/transformer.js";
28
28
  import { ClassificationReasonSchema, ClassificationSchema, ConfigInspector, ConfigInspectorBase, ConfigInspectorLive, InspectedConfigSchema, ResolvedPackageScopeSchema, ResolvedVersionFileSchema, makeConfigInspectorTest } from "./services/config-inspector.js";
29
29
  import { BranchAnalysisSchema, BranchAnalyzer, BranchAnalyzerBase, BranchAnalyzerLive, BranchFileEntrySchema, FileStatusSchema, makeBranchAnalyzerTest } from "./services/branch-analyzer.js";
30
30
  import { ChangelogService, ChangelogServiceBase } from "./services/changelog.js";
31
+ import { VersionFiles } from "./utils/version-files.js";
32
+ import { ReleasePlanner, ReleasePlannerBase, ReleasePlannerLive, makeReleasePlannerTest } from "./services/release-planner.js";
31
33
  import { WorkspaceSnapshotReader, WorkspaceSnapshotReaderBase, WorkspaceSnapshotReaderLive } from "./services/workspace-snapshot.js";
32
34
  import { SectionCategorySchema } from "./categories/types.js";
33
35
  import { CommitHashSchema, VersionTypeSchema } from "./schemas/git.js";
34
36
  import { ChangesetSchema, ChangesetSummarySchema, DependencyTypeSchema, DependencyUpdateSchema } from "./schemas/changeset.js";
37
+ import { AppliedReleaseEntrySchema, AppliedReleaseSchema, BumpTypeSchema, ChangesetPreviewSchema, PendingChangesetSchema, PreviewReleaseSchema, VersionFileUpdateRecordSchema } from "./schemas/release-plan.js";
35
38
  import { computeWorkspaceDependencyDiffs } from "./utils/dep-diff.js";
36
39
  import { listPublishablePackageNames } from "./utils/publishability.js";
37
- import { VersionFiles } from "./utils/version-files.js";
38
40
  import { gitMergeBase, snapshotFromWorktree } from "./utils/worktree-snapshot.js";
39
41
  import { ContentStructureRule as ContentStructureRule$1 } from "./markdownlint/rules/content-structure.js";
40
42
  import { DependencyTableFormatRule } from "./markdownlint/rules/dependency-table-format.js";
@@ -49,11 +51,14 @@ import { SilkChangesetPreset, SilkChangesetTransformPreset } from "./remark/pres
49
51
  //#region src/changesets/index.ts
50
52
  var changesets_exports = /* @__PURE__ */ __exportAll({
51
53
  AggregateDependencyTablesPlugin: () => AggregateDependencyTablesPlugin,
54
+ AppliedReleaseEntrySchema: () => AppliedReleaseEntrySchema,
55
+ AppliedReleaseSchema: () => AppliedReleaseSchema,
52
56
  BranchAnalysisSchema: () => BranchAnalysisSchema,
53
57
  BranchAnalyzer: () => BranchAnalyzer,
54
58
  BranchAnalyzerBase: () => BranchAnalyzerBase,
55
59
  BranchAnalyzerLive: () => BranchAnalyzerLive,
56
60
  BranchFileEntrySchema: () => BranchFileEntrySchema,
61
+ BumpTypeSchema: () => BumpTypeSchema,
57
62
  Categories: () => Categories,
58
63
  Changelog: () => Changelog,
59
64
  ChangelogService: () => ChangelogService,
@@ -61,6 +66,7 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
61
66
  ChangelogTransformer: () => ChangelogTransformer,
62
67
  ChangesetLinter: () => ChangesetLinter,
63
68
  ChangesetOptionsSchema: () => ChangesetOptionsSchema,
69
+ ChangesetPreviewSchema: () => ChangesetPreviewSchema,
64
70
  ChangesetSchema: () => ChangesetSchema,
65
71
  ChangesetSummarySchema: () => ChangesetSummarySchema,
66
72
  ChangesetValidationError: () => ChangesetValidationError,
@@ -116,7 +122,14 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
116
122
  NormalizeFormatPlugin: () => NormalizeFormatPlugin,
117
123
  PackageScopeSchema: () => PackageScopeSchema,
118
124
  PackagesRecordSchema: () => PackagesRecordSchema,
125
+ PendingChangesetSchema: () => PendingChangesetSchema,
119
126
  PositiveInteger: () => PositiveInteger,
127
+ PreviewReleaseSchema: () => PreviewReleaseSchema,
128
+ ReleasePlanError: () => ReleasePlanError,
129
+ ReleasePlanErrorBase: () => ReleasePlanErrorBase,
130
+ ReleasePlanner: () => ReleasePlanner,
131
+ ReleasePlannerBase: () => ReleasePlannerBase,
132
+ ReleasePlannerLive: () => ReleasePlannerLive,
120
133
  ReorderSectionsPlugin: () => ReorderSectionsPlugin,
121
134
  RepoSchema: () => RepoSchema,
122
135
  RequiredSectionsRule: () => RequiredSectionsRule,
@@ -132,6 +145,7 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
132
145
  VersionFileConfigSchema: () => VersionFileConfigSchema,
133
146
  VersionFileError: () => VersionFileError,
134
147
  VersionFileErrorBase: () => VersionFileErrorBase,
148
+ VersionFileUpdateRecordSchema: () => VersionFileUpdateRecordSchema,
135
149
  VersionFiles: () => VersionFiles,
136
150
  VersionFilesSchema: () => VersionFilesSchema,
137
151
  VersionOrEmptySchema: () => VersionOrEmptySchema,
@@ -146,6 +160,7 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
146
160
  makeBranchAnalyzerTest: () => makeBranchAnalyzerTest,
147
161
  makeConfigInspectorTest: () => makeConfigInspectorTest,
148
162
  makeGitHubTest: () => makeGitHubTest,
163
+ makeReleasePlannerTest: () => makeReleasePlannerTest,
149
164
  serializeDependencyTableToMarkdown: () => serializeDependencyTableToMarkdown,
150
165
  snapshotFromWorktree: () => snapshotFromWorktree
151
166
  });
@@ -0,0 +1,57 @@
1
+ import { Schema } from "effect";
2
+
3
+ //#region src/changesets/schemas/release-plan.ts
4
+ /**
5
+ * Result schemas for the {@link ReleasePlanner} service — the structured
6
+ * preview of pending releases and the result of a native apply.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ /** A semantic-version bump level (the `"none"` plan type is filtered out upstream). @public */
11
+ const BumpTypeSchema = Schema.Literal("major", "minor", "patch");
12
+ /** One package's previewed release: version transition + rendered changelog block. @public */
13
+ const PreviewReleaseSchema = Schema.Struct({
14
+ name: Schema.String,
15
+ type: BumpTypeSchema,
16
+ oldVersion: Schema.String,
17
+ newVersion: Schema.String,
18
+ changesetIds: Schema.Array(Schema.String),
19
+ changelogEntry: Schema.String
20
+ }).annotations({ identifier: "PreviewRelease" });
21
+ /** A parsed pending changeset (id + summary + the packages it bumps). @public */
22
+ const PendingChangesetSchema = Schema.Struct({
23
+ id: Schema.String,
24
+ summary: Schema.String,
25
+ releases: Schema.Array(Schema.Struct({
26
+ name: Schema.String,
27
+ type: BumpTypeSchema
28
+ }))
29
+ }).annotations({ identifier: "PendingChangeset" });
30
+ /** Read-only preview of what the next release would produce. @public */
31
+ const ChangesetPreviewSchema = Schema.Struct({
32
+ preMode: Schema.NullOr(Schema.Literal("exit", "pre")),
33
+ releases: Schema.Array(PreviewReleaseSchema),
34
+ changesets: Schema.Array(PendingChangesetSchema)
35
+ }).annotations({ identifier: "ChangesetPreview" });
36
+ /** One applied package release (version transition). @public */
37
+ const AppliedReleaseEntrySchema = Schema.Struct({
38
+ name: Schema.String,
39
+ type: BumpTypeSchema,
40
+ oldVersion: Schema.String,
41
+ newVersion: Schema.String
42
+ }).annotations({ identifier: "AppliedReleaseEntry" });
43
+ /** A single versionFiles update applied (or planned, when dry). @public */
44
+ const VersionFileUpdateRecordSchema = Schema.Struct({
45
+ filePath: Schema.String,
46
+ version: Schema.String
47
+ }).annotations({ identifier: "VersionFileUpdateRecord" });
48
+ /** Result of {@link ReleasePlanner.apply}. @public */
49
+ const AppliedReleaseSchema = Schema.Struct({
50
+ dryRun: Schema.Boolean,
51
+ touchedFiles: Schema.Array(Schema.String),
52
+ releases: Schema.Array(AppliedReleaseEntrySchema),
53
+ versionFileUpdates: Schema.Array(VersionFileUpdateRecordSchema)
54
+ }).annotations({ identifier: "AppliedRelease" });
55
+
56
+ //#endregion
57
+ export { AppliedReleaseEntrySchema, AppliedReleaseSchema, BumpTypeSchema, ChangesetPreviewSchema, PendingChangesetSchema, PreviewReleaseSchema, VersionFileUpdateRecordSchema };
@@ -0,0 +1,252 @@
1
+ import { ReleasePlanError } from "../errors.js";
2
+ import { ChangelogTransformer } from "../api/transformer.js";
3
+ import { ConfigInspector } from "./config-inspector.js";
4
+ import { VersionFiles } from "../utils/version-files.js";
5
+ import { Context, Effect, Layer } from "effect";
6
+ import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
7
+ import { isAbsolute, join, relative } from "node:path";
8
+ import { tmpdir } from "node:os";
9
+ import applyReleasePlan from "@changesets/apply-release-plan";
10
+ import { read } from "@changesets/config";
11
+ import getReleasePlan from "@changesets/get-release-plan";
12
+ import { getPackages } from "@manypkg/get-packages";
13
+
14
+ //#region src/changesets/services/release-planner.ts
15
+ /**
16
+ * `ReleasePlanner` service — drive the genuine changesets release engine to
17
+ * compute a plan, render a read-only preview, or natively apply a release.
18
+ *
19
+ * @remarks
20
+ * `preview` and `apply` both run the real `@changesets/apply-release-plan`;
21
+ * `preview` redirects every write into a throwaway temp directory by handing
22
+ * the engine a `@manypkg`-shaped `Packages` object whose `dir`s point at temp,
23
+ * then reads the generated CHANGELOG blocks back. No changesets-internal logic
24
+ * (e.g. `getChangelogEntry`) is re-implemented.
25
+ *
26
+ * @packageDocumentation
27
+ */
28
+ /** Single workspace-discovery seam; swap to an Effect-native stack later here. */
29
+ const buildPackages = (root) => getPackages(root);
30
+ const errMsg = (e) => e instanceof Error ? e.message : String(e);
31
+ const _tag = Context.Tag("ReleasePlanner");
32
+ /**
33
+ * Base class for {@link ReleasePlanner}.
34
+ *
35
+ * @privateRemarks Required export for api-extractor (anonymous Context.Tag base). Do not delete.
36
+ * @internal
37
+ */
38
+ const ReleasePlannerBase = _tag();
39
+ /** Effect service tag for the release planner. @public */
40
+ var ReleasePlanner = class extends ReleasePlannerBase {};
41
+ /** Build the service shape over a resolved {@link ConfigInspector}. */
42
+ function makeShape(inspector) {
43
+ const plan = (root) => Effect.tryPromise({
44
+ try: () => getReleasePlan(root),
45
+ catch: (e) => new ReleasePlanError({
46
+ phase: "plan",
47
+ reason: errMsg(e)
48
+ })
49
+ });
50
+ const preview = (root) => Effect.tryPromise({
51
+ try: () => previewImpl(root),
52
+ catch: (e) => new ReleasePlanError({
53
+ phase: "preview",
54
+ reason: errMsg(e)
55
+ })
56
+ });
57
+ const apply = (root, options) => applyEffect(root, options?.dryRun ?? false, inspector);
58
+ return {
59
+ plan,
60
+ preview,
61
+ apply
62
+ };
63
+ }
64
+ /** Production layer. Requires {@link ConfigInspector} (used by `apply`). @public */
65
+ const ReleasePlannerLive = Layer.effect(ReleasePlanner, Effect.gen(function* () {
66
+ return makeShape(yield* ConfigInspector);
67
+ }));
68
+ /**
69
+ * Test factory — supply fixed results for any subset of methods. Unsupplied
70
+ * methods fail with a `ReleasePlanError`.
71
+ *
72
+ * @public
73
+ */
74
+ function makeReleasePlannerTest(fixed) {
75
+ const fail = (phase) => Effect.fail(new ReleasePlanError({
76
+ phase,
77
+ reason: "not provided in test layer"
78
+ }));
79
+ return Layer.succeed(ReleasePlanner, {
80
+ plan: () => fixed.plan ? Effect.succeed(fixed.plan) : fail("plan"),
81
+ preview: () => fixed.preview ? Effect.succeed(fixed.preview) : fail("preview"),
82
+ apply: () => fixed.apply ? Effect.succeed(fixed.apply) : fail("apply")
83
+ });
84
+ }
85
+ /** Extract the `## <version>` block (down to the next H2 or EOF) from a changelog. */
86
+ function extractVersionBlock(changelog, version) {
87
+ const lines = changelog.split("\n");
88
+ const start = lines.findIndex((l) => l.trim() === `## ${version}`);
89
+ if (start === -1) return "";
90
+ let end = lines.length;
91
+ for (let i = start + 1; i < lines.length; i++) if (/^## /.test(lines[i])) {
92
+ end = i;
93
+ break;
94
+ }
95
+ return lines.slice(start, end).join("\n").trim();
96
+ }
97
+ async function previewImpl(root) {
98
+ const [plan, packages] = await Promise.all([getReleasePlan(root), buildPackages(root)]);
99
+ const config = await read(root, packages);
100
+ const preMode = plan.preState ? plan.preState.mode : null;
101
+ const changesets = plan.changesets.map((cs) => ({
102
+ id: cs.id,
103
+ summary: cs.summary,
104
+ releases: cs.releases.filter((r) => r.type !== "none").map((r) => ({
105
+ name: r.name,
106
+ type: r.type
107
+ }))
108
+ }));
109
+ const releasesToRender = plan.releases.filter((r) => r.type !== "none");
110
+ if (releasesToRender.length === 0) return {
111
+ preMode,
112
+ releases: [],
113
+ changesets
114
+ };
115
+ const tempRoot = mkdtempSync(join(tmpdir(), "silk-preview-"));
116
+ try {
117
+ const mapDir = (dir) => {
118
+ const rel = relative(packages.root.dir, dir);
119
+ if (rel.startsWith("..") || isAbsolute(rel)) throw new Error(`Package directory is outside the workspace root: ${dir}`);
120
+ return join(tempRoot, rel);
121
+ };
122
+ const tempPackages = {
123
+ tool: packages.tool,
124
+ root: {
125
+ ...packages.root,
126
+ dir: tempRoot,
127
+ packageJson: structuredClone(packages.root.packageJson)
128
+ },
129
+ packages: packages.packages.map((p) => ({
130
+ ...p,
131
+ dir: mapDir(p.dir),
132
+ packageJson: structuredClone(p.packageJson)
133
+ }))
134
+ };
135
+ mkdirSync(join(tempRoot, ".changeset"), { recursive: true });
136
+ cpSync(join(root, "package.json"), join(tempRoot, "package.json"));
137
+ const preJson = join(root, ".changeset", "pre.json");
138
+ if (existsSync(preJson)) cpSync(preJson, join(tempRoot, ".changeset", "pre.json"));
139
+ for (const p of packages.packages) {
140
+ const tDir = mapDir(p.dir);
141
+ mkdirSync(tDir, { recursive: true });
142
+ cpSync(join(p.dir, "package.json"), join(tDir, "package.json"));
143
+ const realCl = join(p.dir, "CHANGELOG.md");
144
+ if (existsSync(realCl)) cpSync(realCl, join(tDir, "CHANGELOG.md"));
145
+ }
146
+ const rootCl = join(packages.root.dir, "CHANGELOG.md");
147
+ if (existsSync(rootCl)) cpSync(rootCl, join(tempRoot, "CHANGELOG.md"));
148
+ await applyReleasePlan(plan, tempPackages, config, void 0, root);
149
+ const dirByName = /* @__PURE__ */ new Map();
150
+ for (const p of tempPackages.packages) dirByName.set(p.packageJson.name, p.dir);
151
+ if (tempPackages.root.packageJson.name) dirByName.set(tempPackages.root.packageJson.name, tempRoot);
152
+ const releases = [];
153
+ for (const r of releasesToRender) {
154
+ const dir = dirByName.get(r.name);
155
+ if (!dir) continue;
156
+ const clPath = join(dir, "CHANGELOG.md");
157
+ if (!existsSync(clPath)) continue;
158
+ ChangelogTransformer.transformFile(clPath);
159
+ const content = readFileSync(clPath, "utf-8");
160
+ releases.push({
161
+ name: r.name,
162
+ type: r.type,
163
+ oldVersion: r.oldVersion,
164
+ newVersion: r.newVersion,
165
+ changesetIds: [...r.changesets],
166
+ changelogEntry: extractVersionBlock(content, r.newVersion)
167
+ });
168
+ }
169
+ return {
170
+ preMode,
171
+ releases,
172
+ changesets
173
+ };
174
+ } finally {
175
+ rmSync(tempRoot, {
176
+ recursive: true,
177
+ force: true
178
+ });
179
+ }
180
+ }
181
+ /** Re-read a package's version from disk (post-bump) to feed versionFiles. */
182
+ function diskVersion(workspaceDir, fallback) {
183
+ try {
184
+ return JSON.parse(readFileSync(join(workspaceDir, "package.json"), "utf-8")).version ?? fallback;
185
+ } catch {
186
+ return fallback;
187
+ }
188
+ }
189
+ function applyEffect(root, dryRun, inspector) {
190
+ return Effect.gen(function* () {
191
+ const { plan, packages, config } = yield* Effect.tryPromise({
192
+ try: async () => {
193
+ const [plan, packages] = await Promise.all([getReleasePlan(root), buildPackages(root)]);
194
+ return {
195
+ plan,
196
+ packages,
197
+ config: await read(root, packages)
198
+ };
199
+ },
200
+ catch: (e) => new ReleasePlanError({
201
+ phase: "apply",
202
+ reason: errMsg(e)
203
+ })
204
+ });
205
+ const releases = plan.releases.filter((r) => r.type !== "none").map((r) => ({
206
+ name: r.name,
207
+ type: r.type,
208
+ oldVersion: r.oldVersion,
209
+ newVersion: r.newVersion
210
+ }));
211
+ let touchedFiles = [];
212
+ if (!dryRun) touchedFiles = yield* Effect.tryPromise({
213
+ try: async () => {
214
+ const touched = await applyReleasePlan(plan, packages, config);
215
+ for (const f of touched) if (f.endsWith("CHANGELOG.md")) ChangelogTransformer.transformFile(f);
216
+ return touched;
217
+ },
218
+ catch: (e) => new ReleasePlanError({
219
+ phase: "apply",
220
+ reason: errMsg(e)
221
+ })
222
+ });
223
+ const newVersionByName = new Map(plan.releases.map((r) => [r.name, r.newVersion]));
224
+ const inspected = yield* inspector.inspect(root).pipe(Effect.catchAll((error) => Effect.logWarning(`Skipping versionFiles update: ${errMsg(error)}`).pipe(Effect.as(null))));
225
+ let versionFileUpdates = [];
226
+ if (inspected) versionFileUpdates = yield* Effect.try({
227
+ try: () => {
228
+ const scopes = inspected.packages.filter((p) => p.versionFiles.length > 0).map((p) => {
229
+ const fresh = dryRun ? newVersionByName.get(p.name) ?? p.version : diskVersion(p.workspaceDir, p.version);
230
+ return fresh !== p.version ? {
231
+ ...p,
232
+ version: fresh
233
+ } : p;
234
+ });
235
+ return scopes.length > 0 ? VersionFiles.processResolvedVersionFiles(scopes, dryRun) : [];
236
+ },
237
+ catch: (e) => new ReleasePlanError({
238
+ phase: "apply",
239
+ reason: errMsg(e)
240
+ })
241
+ });
242
+ return {
243
+ dryRun,
244
+ touchedFiles,
245
+ releases,
246
+ versionFileUpdates
247
+ };
248
+ });
249
+ }
250
+
251
+ //#endregion
252
+ export { ReleasePlanner, ReleasePlannerBase, ReleasePlannerLive, makeReleasePlannerTest };
package/index.d.ts CHANGED
@@ -305,6 +305,11 @@ type Changeset$1 = {
305
305
  type NewChangeset = Changeset$1 & {
306
306
  id: string;
307
307
  };
308
+ type ReleasePlan = {
309
+ changesets: NewChangeset[];
310
+ releases: ComprehensiveRelease[];
311
+ preState: PreState | undefined;
312
+ };
308
313
  type PackageJSON = {
309
314
  name: string;
310
315
  version: string;
@@ -343,6 +348,14 @@ type ChangelogFunctions = {
343
348
  getReleaseLine: GetReleaseLine;
344
349
  getDependencyReleaseLine: GetDependencyReleaseLine;
345
350
  };
351
+ type PreState = {
352
+ mode: "pre" | "exit";
353
+ tag: string;
354
+ initialVersions: {
355
+ [pkgName: string]: string;
356
+ };
357
+ changesets: string[];
358
+ };
346
359
  //#endregion
347
360
  //#region src/changesets/api/changelog.d.ts
348
361
  /**
@@ -2482,6 +2495,33 @@ declare class GitError extends GitErrorBase<{
2482
2495
  }> {
2483
2496
  get message(): string;
2484
2497
  }
2498
+ /**
2499
+ * Base class for {@link ReleasePlanError}.
2500
+ *
2501
+ * @privateRemarks
2502
+ * Required export for api-extractor (anonymous Data.TaggedError base). Do not delete.
2503
+ *
2504
+ * @internal
2505
+ */
2506
+ declare const ReleasePlanErrorBase: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
2507
+ readonly _tag: "ReleasePlanError";
2508
+ } & Readonly<A>;
2509
+ /**
2510
+ * Release planning, preview, or apply failure.
2511
+ *
2512
+ * @remarks
2513
+ * Wraps any failure from the underlying `@changesets/*` machinery
2514
+ * (`getReleasePlan`, `applyReleasePlan`, config resolution) into a typed
2515
+ * Effect error, tagged with the phase that failed.
2516
+ *
2517
+ * @public
2518
+ */
2519
+ declare class ReleasePlanError extends ReleasePlanErrorBase<{
2520
+ /** The phase that failed. */readonly phase: "plan" | "preview" | "apply"; /** Human-readable failure reason. */
2521
+ readonly reason: string;
2522
+ }> {
2523
+ get message(): string;
2524
+ }
2485
2525
  //#endregion
2486
2526
  //#region src/errors/ChangesetConfigError.d.ts
2487
2527
  declare const ChangesetConfigError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
@@ -3422,6 +3462,120 @@ declare const ChangelogServiceBase: Context.TagClass<ChangelogService, "Changelo
3422
3462
  */
3423
3463
  declare class ChangelogService extends ChangelogServiceBase {}
3424
3464
  //#endregion
3465
+ //#region src/changesets/schemas/release-plan.d.ts
3466
+ /** A semantic-version bump level (the `"none"` plan type is filtered out upstream). @public */
3467
+ declare const BumpTypeSchema: Schema.Literal<["major", "minor", "patch"]>;
3468
+ /** A semantic-version bump level. @public */
3469
+ type BumpType = Schema.Schema.Type<typeof BumpTypeSchema>;
3470
+ /** One package's previewed release: version transition + rendered changelog block. @public */
3471
+ declare const PreviewReleaseSchema: Schema.Struct<{
3472
+ name: typeof Schema.String;
3473
+ type: Schema.Literal<["major", "minor", "patch"]>;
3474
+ oldVersion: typeof Schema.String;
3475
+ newVersion: typeof Schema.String;
3476
+ changesetIds: Schema.Array$<typeof Schema.String>;
3477
+ changelogEntry: typeof Schema.String;
3478
+ }>;
3479
+ /** One package's previewed release. @public */
3480
+ type PreviewRelease = Schema.Schema.Type<typeof PreviewReleaseSchema>;
3481
+ /** A parsed pending changeset (id + summary + the packages it bumps). @public */
3482
+ declare const PendingChangesetSchema: Schema.Struct<{
3483
+ id: typeof Schema.String;
3484
+ summary: typeof Schema.String;
3485
+ releases: Schema.Array$<Schema.Struct<{
3486
+ name: typeof Schema.String;
3487
+ type: Schema.Literal<["major", "minor", "patch"]>;
3488
+ }>>;
3489
+ }>;
3490
+ /** A parsed pending changeset. @public */
3491
+ type PendingChangeset = Schema.Schema.Type<typeof PendingChangesetSchema>;
3492
+ /** Read-only preview of what the next release would produce. @public */
3493
+ declare const ChangesetPreviewSchema: Schema.Struct<{
3494
+ preMode: Schema.NullOr<Schema.Literal<["exit", "pre"]>>;
3495
+ releases: Schema.Array$<Schema.Struct<{
3496
+ name: typeof Schema.String;
3497
+ type: Schema.Literal<["major", "minor", "patch"]>;
3498
+ oldVersion: typeof Schema.String;
3499
+ newVersion: typeof Schema.String;
3500
+ changesetIds: Schema.Array$<typeof Schema.String>;
3501
+ changelogEntry: typeof Schema.String;
3502
+ }>>;
3503
+ changesets: Schema.Array$<Schema.Struct<{
3504
+ id: typeof Schema.String;
3505
+ summary: typeof Schema.String;
3506
+ releases: Schema.Array$<Schema.Struct<{
3507
+ name: typeof Schema.String;
3508
+ type: Schema.Literal<["major", "minor", "patch"]>;
3509
+ }>>;
3510
+ }>>;
3511
+ }>;
3512
+ /** Read-only preview of what the next release would produce. @public */
3513
+ type ChangesetPreview = Schema.Schema.Type<typeof ChangesetPreviewSchema>;
3514
+ /** One applied package release (version transition). @public */
3515
+ declare const AppliedReleaseEntrySchema: Schema.Struct<{
3516
+ name: typeof Schema.String;
3517
+ type: Schema.Literal<["major", "minor", "patch"]>;
3518
+ oldVersion: typeof Schema.String;
3519
+ newVersion: typeof Schema.String;
3520
+ }>;
3521
+ /** A single versionFiles update applied (or planned, when dry). @public */
3522
+ declare const VersionFileUpdateRecordSchema: Schema.Struct<{
3523
+ filePath: typeof Schema.String;
3524
+ version: typeof Schema.String;
3525
+ }>;
3526
+ /** Result of {@link ReleasePlanner.apply}. @public */
3527
+ declare const AppliedReleaseSchema: Schema.Struct<{
3528
+ dryRun: typeof Schema.Boolean;
3529
+ touchedFiles: Schema.Array$<typeof Schema.String>;
3530
+ releases: Schema.Array$<Schema.Struct<{
3531
+ name: typeof Schema.String;
3532
+ type: Schema.Literal<["major", "minor", "patch"]>;
3533
+ oldVersion: typeof Schema.String;
3534
+ newVersion: typeof Schema.String;
3535
+ }>>;
3536
+ versionFileUpdates: Schema.Array$<Schema.Struct<{
3537
+ filePath: typeof Schema.String;
3538
+ version: typeof Schema.String;
3539
+ }>>;
3540
+ }>;
3541
+ /** Result of a native apply. @public */
3542
+ type AppliedRelease = Schema.Schema.Type<typeof AppliedReleaseSchema>;
3543
+ //#endregion
3544
+ //#region src/changesets/services/release-planner.d.ts
3545
+ /** The `ReleasePlanner` service surface. @public */
3546
+ interface ReleasePlannerShape {
3547
+ /** Compute the in-memory release plan (read-only). */
3548
+ readonly plan: (root: string) => Effect.Effect<ReleasePlan, ReleasePlanError>;
3549
+ /** Render a non-destructive preview of the next release. */
3550
+ readonly preview: (root: string) => Effect.Effect<ChangesetPreview, ReleasePlanError>;
3551
+ /** Natively apply the release (destructive unless `dryRun`). */
3552
+ readonly apply: (root: string, options?: {
3553
+ readonly dryRun?: boolean;
3554
+ }) => Effect.Effect<AppliedRelease, ReleasePlanError>;
3555
+ }
3556
+ /**
3557
+ * Base class for {@link ReleasePlanner}.
3558
+ *
3559
+ * @privateRemarks Required export for api-extractor (anonymous Context.Tag base). Do not delete.
3560
+ * @internal
3561
+ */
3562
+ declare const ReleasePlannerBase: Context.TagClass<ReleasePlanner, "ReleasePlanner", ReleasePlannerShape>;
3563
+ /** Effect service tag for the release planner. @public */
3564
+ declare class ReleasePlanner extends ReleasePlannerBase {}
3565
+ /** Production layer. Requires {@link ConfigInspector} (used by `apply`). @public */
3566
+ declare const ReleasePlannerLive: Layer.Layer<ReleasePlanner, never, ConfigInspector>;
3567
+ /**
3568
+ * Test factory — supply fixed results for any subset of methods. Unsupplied
3569
+ * methods fail with a `ReleasePlanError`.
3570
+ *
3571
+ * @public
3572
+ */
3573
+ declare function makeReleasePlannerTest(fixed: {
3574
+ readonly plan?: ReleasePlan;
3575
+ readonly preview?: ChangesetPreview;
3576
+ readonly apply?: AppliedRelease;
3577
+ }): Layer.Layer<ReleasePlanner>;
3578
+ //#endregion
3425
3579
  //#region src/changesets/services/workspace-snapshot.d.ts
3426
3580
  /**
3427
3581
  * One workspace package as it existed at a specific git ref.
@@ -5090,7 +5244,7 @@ declare const RequiredSectionsRule: import("unified-lint-rule").Plugin<Root, unk
5090
5244
  //#region src/changesets/remark/rules/uncategorized-content.d.ts
5091
5245
  declare const UncategorizedContentRule: import("unified-lint-rule").Plugin<Root, unknown>;
5092
5246
  declare namespace index_d_exports {
5093
- export { AggregateDependencyTablesPlugin, BranchAnalysis, BranchAnalysisSchema, BranchAnalyzer, BranchAnalyzerBase, BranchAnalyzerLive, BranchAnalyzerShape, BranchFileEntry, BranchFileEntrySchema, Categories, Changelog, ChangelogService, ChangelogServiceBase, ChangelogServiceShape, ChangelogTransformer, Changeset, ChangesetLinter, ChangesetOptions, ChangesetOptionsSchema, ChangesetSchema, ChangesetSummarySchema, ChangesetValidationError, ChangesetValidationErrorBase, Classification, ClassificationReason, ClassificationReasonSchema, ClassificationSchema, CommitHashSchema, ConfigInspector, ConfigInspectorBase, ConfigInspectorLive, ConfigInspectorShape, ConfigurationError, ConfigurationErrorBase, ContentStructureRule, ContributorFootnotesPlugin, DeduplicateItemsPlugin, DependencyAction, DependencyActionSchema, DependencyTable, DependencyTableFormatRule, DependencyTableRow, DependencyTableRowSchema, DependencyTableSchema, DependencyTableType, DependencyTableTypeSchema, DependencyType, DependencyTypeSchema, DependencyUpdate, DependencyUpdateSchema, FileStatus, FileStatusSchema, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, GitHubCommitInfo, GitHubInfo, GitHubInfoSchema, GitHubLive, GitHubService, GitHubServiceBase, GitHubServiceShape, GlobSchema, HeadingHierarchyRule, InspectedConfig, InspectedConfigSchema, IssueLinkRefsPlugin, IssueNumberSchema, JsonPathSchema, LegacyVersionFileConfig, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, LintMessage, MarkdownLive, MarkdownParseError, MarkdownParseErrorBase, MarkdownService, MarkdownServiceBase, MarkdownServiceShape, ContentStructureRule$1 as MarkdownlintContentStructureRule, DependencyTableFormatRule$1 as MarkdownlintDependencyTableFormatRule, HeadingHierarchyRule$1 as MarkdownlintHeadingHierarchyRule, RequiredSectionsRule$1 as MarkdownlintRequiredSectionsRule, UncategorizedContentRule$1 as MarkdownlintUncategorizedContentRule, MergeSectionsPlugin, NonEmptyString, NormalizeFormatPlugin, PackageScope, PackageScopeSchema, PackagesRecordSchema, PositiveInteger, ReorderSectionsPlugin, RepoSchema, RequiredSectionsRule, ResolvedPackageScope, ResolvedPackageScopeSchema, ResolvedVersionFile, ResolvedVersionFileSchema, SectionCategory, SectionCategorySchema, SilkChangesetPreset, SilkChangesetTransformPreset, SilkChangesetsRules, UncategorizedContentRule, UrlOrMarkdownLinkSchema, UsernameSchema, VersionFileConfig, VersionFileConfigSchema, VersionFileError, VersionFileErrorBase, VersionFileUpdate, VersionFiles, VersionFilesSchema, VersionOrEmptySchema, VersionType, VersionTypeSchema, WorkspaceDependencyDiff, WorkspaceSnapshot, WorkspaceSnapshotReader, WorkspaceSnapshotReaderBase, WorkspaceSnapshotReaderLive, WorkspaceSnapshotReaderShape, WorkspaceVersion, changelogFunctions, computeWorkspaceDependencyDiffs, gitMergeBase, listPublishablePackageNames, makeBranchAnalyzerTest, makeConfigInspectorTest, makeGitHubTest, serializeDependencyTableToMarkdown, snapshotFromWorktree };
5247
+ export { AggregateDependencyTablesPlugin, AppliedRelease, AppliedReleaseEntrySchema, AppliedReleaseSchema, BranchAnalysis, BranchAnalysisSchema, BranchAnalyzer, BranchAnalyzerBase, BranchAnalyzerLive, BranchAnalyzerShape, BranchFileEntry, BranchFileEntrySchema, BumpType, BumpTypeSchema, Categories, Changelog, ChangelogService, ChangelogServiceBase, ChangelogServiceShape, ChangelogTransformer, Changeset, ChangesetLinter, ChangesetOptions, ChangesetOptionsSchema, ChangesetPreview, ChangesetPreviewSchema, ChangesetSchema, ChangesetSummarySchema, ChangesetValidationError, ChangesetValidationErrorBase, Classification, ClassificationReason, ClassificationReasonSchema, ClassificationSchema, CommitHashSchema, ConfigInspector, ConfigInspectorBase, ConfigInspectorLive, ConfigInspectorShape, ConfigurationError, ConfigurationErrorBase, ContentStructureRule, ContributorFootnotesPlugin, DeduplicateItemsPlugin, DependencyAction, DependencyActionSchema, DependencyTable, DependencyTableFormatRule, DependencyTableRow, DependencyTableRowSchema, DependencyTableSchema, DependencyTableType, DependencyTableTypeSchema, DependencyType, DependencyTypeSchema, DependencyUpdate, DependencyUpdateSchema, FileStatus, FileStatusSchema, GitError, GitErrorBase, GitHubApiError, GitHubApiErrorBase, GitHubCommitInfo, GitHubInfo, GitHubInfoSchema, GitHubLive, GitHubService, GitHubServiceBase, GitHubServiceShape, GlobSchema, HeadingHierarchyRule, InspectedConfig, InspectedConfigSchema, IssueLinkRefsPlugin, IssueNumberSchema, JsonPathSchema, LegacyVersionFileConfig, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, LintMessage, MarkdownLive, MarkdownParseError, MarkdownParseErrorBase, MarkdownService, MarkdownServiceBase, MarkdownServiceShape, ContentStructureRule$1 as MarkdownlintContentStructureRule, DependencyTableFormatRule$1 as MarkdownlintDependencyTableFormatRule, HeadingHierarchyRule$1 as MarkdownlintHeadingHierarchyRule, RequiredSectionsRule$1 as MarkdownlintRequiredSectionsRule, UncategorizedContentRule$1 as MarkdownlintUncategorizedContentRule, MergeSectionsPlugin, NonEmptyString, NormalizeFormatPlugin, PackageScope, PackageScopeSchema, PackagesRecordSchema, PendingChangeset, PendingChangesetSchema, PositiveInteger, PreviewRelease, PreviewReleaseSchema, ReleasePlanError, ReleasePlanErrorBase, ReleasePlanner, ReleasePlannerBase, ReleasePlannerLive, ReleasePlannerShape, ReorderSectionsPlugin, RepoSchema, RequiredSectionsRule, ResolvedPackageScope, ResolvedPackageScopeSchema, ResolvedVersionFile, ResolvedVersionFileSchema, SectionCategory, SectionCategorySchema, SilkChangesetPreset, SilkChangesetTransformPreset, SilkChangesetsRules, UncategorizedContentRule, UrlOrMarkdownLinkSchema, UsernameSchema, VersionFileConfig, VersionFileConfigSchema, VersionFileError, VersionFileErrorBase, VersionFileUpdate, VersionFileUpdateRecordSchema, VersionFiles, VersionFilesSchema, VersionOrEmptySchema, VersionType, VersionTypeSchema, WorkspaceDependencyDiff, WorkspaceSnapshot, WorkspaceSnapshotReader, WorkspaceSnapshotReaderBase, WorkspaceSnapshotReaderLive, WorkspaceSnapshotReaderShape, WorkspaceVersion, changelogFunctions, computeWorkspaceDependencyDiffs, gitMergeBase, listPublishablePackageNames, makeBranchAnalyzerTest, makeConfigInspectorTest, makeGitHubTest, makeReleasePlannerTest, serializeDependencyTableToMarkdown, snapshotFromWorktree };
5094
5248
  }
5095
5249
  //#endregion
5096
5250
  //#region src/commitlint/config/schema.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/silk-effects",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "description": "Shared Effect library for Silk Suite conventions",
6
6
  "homepage": "https://github.com/savvy-web/systems/tree/main/packages/silk-effects",
@@ -28,7 +28,11 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
+ "@changesets/apply-release-plan": "^7.1.1",
32
+ "@changesets/config": "^3.1.4",
31
33
  "@changesets/get-github-info": "^0.8.0",
34
+ "@changesets/get-release-plan": "^4.0.16",
35
+ "@manypkg/get-packages": "^1.1.3",
32
36
  "jsonc-effect": "^0.2.1",
33
37
  "mdast-util-heading-range": "^4.0.0",
34
38
  "mdast-util-to-string": "^4.0.0",