@savvy-web/silk-effects 7.5.2 → 8.0.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/changesets/api/changelog.js +10 -5
- package/changesets/changelog/getReleaseLine.js +2 -5
- package/changesets/changelog/index.js +39 -19
- package/changesets/index.js +5 -2
- package/changesets/utils/logger.js +47 -20
- package/index.d.ts +171 -1336
- package/index.js +2 -10
- package/lint/cli/sections.js +1 -1
- package/package.json +15 -13
- package/services/BiomeSchemaSync.js +3 -3
- package/services/ChangesetConfigReader.js +3 -4
- package/services/ConfigDiscovery.js +2 -2
- package/services/SilkPublishability.js +2 -3
- package/services/SilkWorkspaceAnalyzer.js +2 -3
- package/errors/BiomeSyncError.js +0 -22
- package/errors/ChangesetConfigError.js +0 -21
- package/errors/ConfigNotFoundError.js +0 -22
- package/errors/PublishTargetBindingError.js +0 -30
- package/errors/WorkspaceAnalysisError.js +0 -22
- package/pr-body/body.js +0 -145
- package/pr-body/diagnostics.js +0 -104
- package/pr-body/index.js +0 -22
- package/pr-body/linked-issue.js +0 -44
- package/pr-body/markers.js +0 -103
- package/pr-body/references.js +0 -157
- package/pr-body/region.js +0 -105
- package/schemas/SavvyInstallSection.js +0 -232
- package/schemas/SavvySections.js +0 -194
- package/schemas/VersioningSchemas.js +0 -87
- package/schemas/WorkspaceAnalysisSchemas.js +0 -209
- package/utils/TrailingSlash.js +0 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { makeChangelogFunctions } from "../changelog/index.js";
|
|
2
2
|
|
|
3
3
|
//#region src/changesets/api/changelog.ts
|
|
4
4
|
/**
|
|
@@ -103,10 +103,13 @@ var Changelog = class {
|
|
|
103
103
|
* @param versionType - The semantic version bump type (`"major"`, `"minor"`, or `"patch"`)
|
|
104
104
|
* @param options - Configuration object; must include `repo` in `"owner/repo"` format.
|
|
105
105
|
* Pass `null` to use defaults (no GitHub link resolution).
|
|
106
|
+
* @param logMode - How a failed GitHub lookup is reported (`"stderr"` when omitted);
|
|
107
|
+
* the host reads its own environment and passes `"github"` / `"silent"` — this
|
|
108
|
+
* engine never does. See `ChangesetLogMode`.
|
|
106
109
|
* @returns A promise resolving to the formatted markdown string
|
|
107
110
|
*/
|
|
108
|
-
static async formatReleaseLine(changeset, versionType, options) {
|
|
109
|
-
return
|
|
111
|
+
static async formatReleaseLine(changeset, versionType, options, logMode) {
|
|
112
|
+
return makeChangelogFunctions(logMode === void 0 ? {} : { logMode }).getReleaseLine(changeset, versionType, options);
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
115
|
* Format dependency update release lines into a markdown table.
|
|
@@ -121,11 +124,13 @@ var Changelog = class {
|
|
|
121
124
|
* old/new versions and package metadata
|
|
122
125
|
* @param options - Configuration object; must include `repo` in `"owner/repo"` format.
|
|
123
126
|
* Pass `null` to use defaults.
|
|
127
|
+
* @param logMode - How a failed GitHub lookup is reported (`"stderr"` when omitted);
|
|
128
|
+
* see {@link Changelog.formatReleaseLine}.
|
|
124
129
|
* @returns A promise resolving to the formatted markdown string containing
|
|
125
130
|
* the dependency update table
|
|
126
131
|
*/
|
|
127
|
-
static async formatDependencyReleaseLine(changesets, dependenciesUpdated, options) {
|
|
128
|
-
return
|
|
132
|
+
static async formatDependencyReleaseLine(changesets, dependenciesUpdated, options, logMode) {
|
|
133
|
+
return makeChangelogFunctions(logMode === void 0 ? {} : { logMode }).getDependencyReleaseLine(changesets, dependenciesUpdated, options);
|
|
129
134
|
}
|
|
130
135
|
};
|
|
131
136
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { resolveCommitType } from "../categories/index.js";
|
|
2
2
|
import { GitHubService } from "../services/github.js";
|
|
3
|
+
import { logWarning } from "../utils/logger.js";
|
|
3
4
|
import { parseMarkdown, stringifyMarkdown } from "../utils/remark-pipeline.js";
|
|
4
5
|
import { GitHubInfoSchema } from "../schemas/github.js";
|
|
5
6
|
import { parseCommitMessage } from "../utils/commit-parser.js";
|
|
6
7
|
import { parseIssueReferences } from "../utils/issue-refs.js";
|
|
7
|
-
import { logWarning } from "../utils/logger.js";
|
|
8
8
|
import { parseChangesetSections } from "../utils/section-parser.js";
|
|
9
9
|
import { formatChangelogEntry, formatPRAndUserAttribution } from "./formatting.js";
|
|
10
10
|
import { Effect, Schema } from "effect";
|
|
@@ -177,10 +177,7 @@ function getReleaseLine(changeset, versionType, options) {
|
|
|
177
177
|
if (changeset.commit) commitInfo = yield* (yield* GitHubService).getInfo({
|
|
178
178
|
commit: changeset.commit,
|
|
179
179
|
repo: options.repo
|
|
180
|
-
}).pipe(Effect.flatMap((raw) => Schema.decodeUnknownEffect(GitHubInfoSchema)(raw).pipe(Effect.map(() => raw), Effect.catch(() => Effect.succeed(raw)))), Effect.catch((error) =>
|
|
181
|
-
logWarning("Could not fetch GitHub info for commit:", changeset.commit ?? "", String(error));
|
|
182
|
-
return Effect.succeed(null);
|
|
183
|
-
}));
|
|
180
|
+
}).pipe(Effect.flatMap((raw) => Schema.decodeUnknownEffect(GitHubInfoSchema)(raw).pipe(Effect.map(() => raw), Effect.catch(() => Effect.succeed(raw)))), Effect.catch((error) => logWarning("Could not fetch GitHub info for commit:", changeset.commit ?? "", String(error)).pipe(Effect.as(null))));
|
|
184
181
|
const parsed = parseChangesetSections(changeset.summary);
|
|
185
182
|
const firstLine = changeset.summary.split("\n")[0];
|
|
186
183
|
const commitMsg = parseCommitMessage(firstLine);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateChangesetOptions } from "../schemas/options.js";
|
|
2
2
|
import { GitHubService } from "../services/github.js";
|
|
3
|
+
import { ChangesetLogMode } from "../utils/logger.js";
|
|
3
4
|
import { getDependencyReleaseLine } from "./getDependencyReleaseLine.js";
|
|
4
5
|
import { getReleaseLine } from "./getReleaseLine.js";
|
|
5
6
|
import { Effect } from "effect";
|
|
@@ -67,31 +68,50 @@ import { Effect } from "effect";
|
|
|
67
68
|
*/
|
|
68
69
|
const MainLayer = GitHubService.layer;
|
|
69
70
|
/**
|
|
70
|
-
* Changesets
|
|
71
|
+
* Build a Changesets `ChangelogFunctions` implementation bound to a warning
|
|
72
|
+
* mode.
|
|
71
73
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* This module is engine code and reads no environment; the host that installs
|
|
76
|
+
* the functions (the `\@savvy-web/changelog` package under the changesets CLI)
|
|
77
|
+
* decides the mode from its own `process.env` and passes it here. Each method
|
|
78
|
+
* validates options, runs the corresponding Effect program with the merged
|
|
79
|
+
* service layer and the chosen {@link ChangesetLogMode}, and returns a
|
|
80
|
+
* `Promise<string>`.
|
|
76
81
|
*
|
|
77
|
-
* @
|
|
82
|
+
* @param options - The warning mode to provide
|
|
83
|
+
* @returns A `ChangelogFunctions` object for `.changeset/config.json`
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
78
86
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
87
|
+
function makeChangelogFunctions(options = {}) {
|
|
88
|
+
const run = (program) => {
|
|
89
|
+
const provided = program.pipe(Effect.provide(MainLayer));
|
|
90
|
+
return Effect.runPromise(options.logMode === void 0 ? provided : provided.pipe(Effect.provideService(ChangesetLogMode, options.logMode)));
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
getReleaseLine: async (changeset, versionType, options) => run(Effect.gen(function* () {
|
|
82
94
|
const opts = yield* validateChangesetOptions(options);
|
|
83
95
|
return yield* getReleaseLine(changeset, versionType, opts);
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => {
|
|
88
|
-
const program = Effect.gen(function* () {
|
|
96
|
+
})),
|
|
97
|
+
getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => run(Effect.gen(function* () {
|
|
89
98
|
const opts = yield* validateChangesetOptions(options);
|
|
90
99
|
return yield* getDependencyReleaseLine(changesets, dependenciesUpdated, opts);
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
}))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Changesets API `ChangelogFunctions` implementation with the default warning
|
|
105
|
+
* mode (`"stderr"`).
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Equivalent to `makeChangelogFunctions()`. A host that runs under GitHub
|
|
109
|
+
* Actions or a test runner should call {@link makeChangelogFunctions} with the
|
|
110
|
+
* mode it detects instead.
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
const changelogFunctions = makeChangelogFunctions();
|
|
95
115
|
|
|
96
116
|
//#endregion
|
|
97
|
-
export { changelogFunctions as default };
|
|
117
|
+
export { changelogFunctions as default, makeChangelogFunctions };
|
package/changesets/index.js
CHANGED
|
@@ -5,11 +5,12 @@ import { JsonPathSchema, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema
|
|
|
5
5
|
import { GlobSchema, PackageScopeSchema, PackagesRecordSchema } from "./schemas/package-scope.js";
|
|
6
6
|
import { ChangesetOptionsSchema, RepoSchema } from "./schemas/options.js";
|
|
7
7
|
import { GitHubService, makeGitHubTest } from "./services/github.js";
|
|
8
|
+
import { ChangesetLogMode } from "./utils/logger.js";
|
|
8
9
|
import { NonEmptyString, PositiveInteger } from "./schemas/primitives.js";
|
|
9
10
|
import { DependencyActionSchema, DependencyTableRowSchema, DependencyTableSchema, DependencyTableTypeSchema, VERSION_RE, VersionOrEmptySchema } from "./schemas/dependency-table.js";
|
|
10
11
|
import { serializeDependencyTableToMarkdown } from "./utils/dependency-table.js";
|
|
11
12
|
import { GitHubInfoSchema, IssueNumberSchema, UrlOrMarkdownLinkSchema, UsernameSchema } from "./schemas/github.js";
|
|
12
|
-
import changelogFunctions from "./changelog/index.js";
|
|
13
|
+
import changelogFunctions, { makeChangelogFunctions } from "./changelog/index.js";
|
|
13
14
|
import { Changelog } from "./api/changelog.js";
|
|
14
15
|
import { DependencyTable } from "./api/dependency-table.js";
|
|
15
16
|
import { ContentStructureRule } from "./remark/rules/content-structure.js";
|
|
@@ -66,6 +67,7 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
|
|
|
66
67
|
ChangelogTransformer: () => ChangelogTransformer,
|
|
67
68
|
ChangesetIOError: () => ChangesetIOError,
|
|
68
69
|
ChangesetLinter: () => ChangesetLinter,
|
|
70
|
+
ChangesetLogMode: () => ChangesetLogMode,
|
|
69
71
|
ChangesetOptionsSchema: () => ChangesetOptionsSchema,
|
|
70
72
|
ChangesetPreviewSchema: () => ChangesetPreviewSchema,
|
|
71
73
|
ChangesetSchema: () => ChangesetSchema,
|
|
@@ -152,6 +154,7 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
|
|
|
152
154
|
isPureDependencyChangeset: () => isPureDependencyChangeset,
|
|
153
155
|
listPublishablePackageNames: () => listPublishablePackageNames,
|
|
154
156
|
makeBranchAnalyzerTest: () => makeBranchAnalyzerTest,
|
|
157
|
+
makeChangelogFunctions: () => makeChangelogFunctions,
|
|
155
158
|
makeConfigInspectorTest: () => makeConfigInspectorTest,
|
|
156
159
|
makeDepsRegenDefault: () => makeDepsRegenDefault,
|
|
157
160
|
makeGitHubTest: () => makeGitHubTest,
|
|
@@ -162,4 +165,4 @@ var changesets_exports = /* @__PURE__ */ __exportAll({
|
|
|
162
165
|
});
|
|
163
166
|
|
|
164
167
|
//#endregion
|
|
165
|
-
export { AggregateDependencyTablesPlugin, AppliedReleaseEntrySchema, AppliedReleaseSchema, BranchAnalysisSchema, BranchAnalyzer, BranchFileEntrySchema, BumpTypeSchema, Categories, Changelog, ChangelogService, ChangelogTransformer, ChangesetIOError, ChangesetLinter, ChangesetOptionsSchema, ChangesetPreviewSchema, ChangesetSchema, ChangesetSummarySchema, ChangesetValidationError, ClassificationReasonSchema, ClassificationSchema, CoexistingChangesetSchema, CommitHashSchema, ConfigInspector, ConfigurationError, ContentStructureRule, ContributorFootnotesPlugin, DeduplicateItemsPlugin, DependencyActionSchema, DependencyTable, DependencyTableFormatRule, DependencyTableRowSchema, DependencyTableSchema, DependencyTableTypeSchema, DependencyTypeSchema, DependencyUpdateSchema, DepsRegen, DepsRegenDefault, FileStatusSchema, GitError, GitHubApiError, GitHubInfoSchema, GitHubService, GlobSchema, HeadingHierarchyRule, InspectedConfigSchema, IssueLinkRefsPlugin, IssueNumberSchema, JsonPathSchema, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, MaintenanceNotePlugin, MaintenanceReasonSchema, MaintenanceTriggerSchema, MarkdownParseError, ContentStructureRule$1 as MarkdownlintContentStructureRule, DependencyTableFormatRule$1 as MarkdownlintDependencyTableFormatRule, HeadingHierarchyRule$1 as MarkdownlintHeadingHierarchyRule, RequiredSectionsRule$1 as MarkdownlintRequiredSectionsRule, UncategorizedContentRule$1 as MarkdownlintUncategorizedContentRule, MergeSectionsPlugin, NonEmptyString, NormalizeFormatPlugin, PackageScopeSchema, PackagesRecordSchema, PendingChangesetSchema, PositiveInteger, PreviewReleaseSchema, RegenDiffRowSchema, RegenPlanSchema, RegenResultSchema, ReleasePlanError, ReleasePlanner, ReorderSectionsPlugin, RepoSchema, RequiredSectionsRule, ResolvedPackageScopeSchema, ResolvedVersionFileSchema, SectionCategorySchema, SilkChangesetPreset, SilkChangesetTransformPreset, SilkChangesetsRules, UncategorizedContentRule, UrlOrMarkdownLinkSchema, UsernameSchema, VERSION_RE, VersionFileConfigSchema, VersionFileError, VersionFileUpdateRecordSchema, VersionFiles, VersionFilesSchema, VersionOrEmptySchema, VersionTypeSchema, changelogFunctions, changesets_exports, computeWorkspaceDependencyDiffs, deriveMaintenanceReason, gitMergeBase, isPureDependencyChangeset, listPublishablePackageNames, makeBranchAnalyzerTest, makeConfigInspectorTest, makeDepsRegenDefault, makeGitHubTest, makeReleasePlannerTest, parseChangesetPackages, serializeDependencyTableToMarkdown, vanillaChangelogFunctions };
|
|
168
|
+
export { AggregateDependencyTablesPlugin, AppliedReleaseEntrySchema, AppliedReleaseSchema, BranchAnalysisSchema, BranchAnalyzer, BranchFileEntrySchema, BumpTypeSchema, Categories, Changelog, ChangelogService, ChangelogTransformer, ChangesetIOError, ChangesetLinter, ChangesetLogMode, ChangesetOptionsSchema, ChangesetPreviewSchema, ChangesetSchema, ChangesetSummarySchema, ChangesetValidationError, ClassificationReasonSchema, ClassificationSchema, CoexistingChangesetSchema, CommitHashSchema, ConfigInspector, ConfigurationError, ContentStructureRule, ContributorFootnotesPlugin, DeduplicateItemsPlugin, DependencyActionSchema, DependencyTable, DependencyTableFormatRule, DependencyTableRowSchema, DependencyTableSchema, DependencyTableTypeSchema, DependencyTypeSchema, DependencyUpdateSchema, DepsRegen, DepsRegenDefault, FileStatusSchema, GitError, GitHubApiError, GitHubInfoSchema, GitHubService, GlobSchema, HeadingHierarchyRule, InspectedConfigSchema, IssueLinkRefsPlugin, IssueNumberSchema, JsonPathSchema, LegacyVersionFileConfigSchema, LegacyVersionFilesSchema, MaintenanceNotePlugin, MaintenanceReasonSchema, MaintenanceTriggerSchema, MarkdownParseError, ContentStructureRule$1 as MarkdownlintContentStructureRule, DependencyTableFormatRule$1 as MarkdownlintDependencyTableFormatRule, HeadingHierarchyRule$1 as MarkdownlintHeadingHierarchyRule, RequiredSectionsRule$1 as MarkdownlintRequiredSectionsRule, UncategorizedContentRule$1 as MarkdownlintUncategorizedContentRule, MergeSectionsPlugin, NonEmptyString, NormalizeFormatPlugin, PackageScopeSchema, PackagesRecordSchema, PendingChangesetSchema, PositiveInteger, PreviewReleaseSchema, RegenDiffRowSchema, RegenPlanSchema, RegenResultSchema, ReleasePlanError, ReleasePlanner, ReorderSectionsPlugin, RepoSchema, RequiredSectionsRule, ResolvedPackageScopeSchema, ResolvedVersionFileSchema, SectionCategorySchema, SilkChangesetPreset, SilkChangesetTransformPreset, SilkChangesetsRules, UncategorizedContentRule, UrlOrMarkdownLinkSchema, UsernameSchema, VERSION_RE, VersionFileConfigSchema, VersionFileError, VersionFileUpdateRecordSchema, VersionFiles, VersionFilesSchema, VersionOrEmptySchema, VersionTypeSchema, changelogFunctions, changesets_exports, computeWorkspaceDependencyDiffs, deriveMaintenanceReason, gitMergeBase, isPureDependencyChangeset, listPublishablePackageNames, makeBranchAnalyzerTest, makeChangelogFunctions, makeConfigInspectorTest, makeDepsRegenDefault, makeGitHubTest, makeReleasePlannerTest, parseChangesetPackages, serializeDependencyTableToMarkdown, vanillaChangelogFunctions };
|
|
@@ -1,37 +1,64 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
|
|
1
3
|
//#region src/changesets/utils/logger.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
5
|
+
* Warning output for changelog generation, parameterised by a
|
|
6
|
+
* {@link ChangesetLogMode} reference instead of an ambient environment read.
|
|
4
7
|
*
|
|
5
8
|
* @remarks
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* This module is engine code shared by every front end, so it must not read
|
|
10
|
+
* `process` — a `process.env` read here would bake one host's environment
|
|
11
|
+
* into every other. The mode is a `Context.Reference` with a default of
|
|
12
|
+
* `"stderr"`; a front end that knows it runs under GitHub Actions or a test
|
|
13
|
+
* runner provides `"github"` or `"silent"` from its own `process.env` read.
|
|
11
14
|
*
|
|
12
|
-
* @
|
|
13
|
-
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The reference that selects the {@link ChangesetLogModeValue}.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Defaults to `"stderr"` when no front end provides it, so a program that
|
|
22
|
+
* never touches the reference still reports. Provide with
|
|
23
|
+
* `Layer.succeed(ChangesetLogMode, "github")` or
|
|
24
|
+
* `Effect.provideService(ChangesetLogMode, "silent")`.
|
|
14
25
|
*
|
|
15
26
|
* @example
|
|
16
27
|
* ```typescript
|
|
17
|
-
* import {
|
|
28
|
+
* import { Effect } from "effect";
|
|
29
|
+
* import { Changesets } from "\@savvy-web/silk-effects";
|
|
18
30
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* // Locally: console.warn("Duplicate dependency entry", "effect@3.19.0")
|
|
31
|
+
* const mode = process.env.GITHUB_ACTIONS === "true" ? "github" : "stderr";
|
|
32
|
+
* program.pipe(Effect.provideService(Changesets.ChangesetLogMode, mode));
|
|
22
33
|
* ```
|
|
23
34
|
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
const ChangesetLogMode = Context.Reference("@savvy-web/silk-effects/Changesets/ChangesetLogMode", { defaultValue: () => "stderr" });
|
|
38
|
+
/**
|
|
39
|
+
* Log a warning message according to the {@link ChangesetLogMode} in context.
|
|
40
|
+
*
|
|
41
|
+
* @param message - The warning message
|
|
42
|
+
* @param args - Additional arguments (concatenated with a space in `"github"` mode)
|
|
43
|
+
* @returns An `Effect` that never fails
|
|
44
|
+
*
|
|
24
45
|
* @internal
|
|
25
46
|
*/
|
|
26
47
|
function logWarning(message, ...args) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
return Effect.gen(function* () {
|
|
49
|
+
switch (yield* ChangesetLogMode) {
|
|
50
|
+
case "silent": return;
|
|
51
|
+
case "github": {
|
|
52
|
+
const text = args.length > 0 ? `${message} ${args.join(" ")}` : message;
|
|
53
|
+
console.warn(`::warning::${text}`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
case "stderr":
|
|
57
|
+
console.warn(message, ...args);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
34
61
|
}
|
|
35
62
|
|
|
36
63
|
//#endregion
|
|
37
|
-
export { logWarning };
|
|
64
|
+
export { ChangesetLogMode, logWarning };
|