@savvy-web/silk 1.3.10 → 1.3.11
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-changelog.cjs +371 -220
- package/changesets-changelog.d.cts +120 -29
- package/changesets-changelog.d.ts +120 -29
- package/changesets-markdownlint.cjs +371 -220
- package/changesets-markdownlint.d.cts +120 -29
- package/changesets-markdownlint.d.ts +120 -29
- package/package.json +11 -11
- package/packages/silk-effects/dist/dev/pkg/changesets/api/transformer.cjs +24 -30
- package/packages/silk-effects/dist/dev/pkg/changesets/api/transformer.js +24 -30
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/formatting.cjs +4 -10
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/formatting.js +4 -10
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getDependencyReleaseLine.cjs +13 -9
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getDependencyReleaseLine.js +13 -9
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getReleaseLine.cjs +8 -8
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getReleaseLine.js +8 -8
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/index.cjs +1 -1
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/index.js +1 -1
- package/packages/silk-effects/dist/dev/pkg/changesets/index.cjs +12 -2
- package/packages/silk-effects/dist/dev/pkg/changesets/index.js +9 -3
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/deduplicate-items.cjs +11 -9
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/deduplicate-items.js +11 -9
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.cjs +61 -0
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.js +61 -0
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/presets.cjs +1 -1
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/presets.js +1 -1
- package/packages/silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.cjs +68 -0
- package/packages/silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.js +66 -0
- package/packages/silk-effects/dist/dev/pkg/changesets/services/release-planner.cjs +44 -12
- package/packages/silk-effects/dist/dev/pkg/changesets/services/release-planner.js +45 -13
- package/tsconfig/node/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_version_blocks = require('../../utils/version-blocks.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.js
|
|
4
|
+
function buildNoteChildren(reason) {
|
|
5
|
+
if (reason.kind === "unspecified" || reason.triggers.length === 0) return [{
|
|
6
|
+
type: "text",
|
|
7
|
+
value: "Version-only release to keep workspace versions consistent; no changes to this package."
|
|
8
|
+
}];
|
|
9
|
+
const label = reason.kind === "fixed" ? "fixed version group" : "linked version group";
|
|
10
|
+
const children = [{
|
|
11
|
+
type: "text",
|
|
12
|
+
value: "Released in lockstep with "
|
|
13
|
+
}];
|
|
14
|
+
reason.triggers.forEach((trigger, index) => {
|
|
15
|
+
if (index > 0) children.push({
|
|
16
|
+
type: "text",
|
|
17
|
+
value: ", "
|
|
18
|
+
});
|
|
19
|
+
children.push({
|
|
20
|
+
type: "inlineCode",
|
|
21
|
+
value: `${trigger.name}@${trigger.version}`
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
children.push({
|
|
25
|
+
type: "text",
|
|
26
|
+
value: ` (${label}).`
|
|
27
|
+
});
|
|
28
|
+
return children;
|
|
29
|
+
}
|
|
30
|
+
const MaintenanceNotePlugin = (options) => {
|
|
31
|
+
return (tree) => {
|
|
32
|
+
const block = require_version_blocks.getVersionBlocks(tree).find((b) => require_version_blocks.getHeadingText(tree.children[b.headingIndex]) === options.version);
|
|
33
|
+
if (!block) return;
|
|
34
|
+
if (block.endIndex > block.startIndex) return;
|
|
35
|
+
const heading = {
|
|
36
|
+
type: "heading",
|
|
37
|
+
depth: 3,
|
|
38
|
+
children: [{
|
|
39
|
+
type: "text",
|
|
40
|
+
value: "Maintenance"
|
|
41
|
+
}]
|
|
42
|
+
};
|
|
43
|
+
const list = {
|
|
44
|
+
type: "list",
|
|
45
|
+
ordered: false,
|
|
46
|
+
spread: false,
|
|
47
|
+
children: [{
|
|
48
|
+
type: "listItem",
|
|
49
|
+
spread: false,
|
|
50
|
+
children: [{
|
|
51
|
+
type: "paragraph",
|
|
52
|
+
children: buildNoteChildren(options.reason)
|
|
53
|
+
}]
|
|
54
|
+
}]
|
|
55
|
+
};
|
|
56
|
+
tree.children.splice(block.startIndex, 0, heading, list);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.MaintenanceNotePlugin = MaintenanceNotePlugin;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getHeadingText, getVersionBlocks } from "../../utils/version-blocks.js";
|
|
2
|
+
|
|
3
|
+
//#region ../silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.js
|
|
4
|
+
function buildNoteChildren(reason) {
|
|
5
|
+
if (reason.kind === "unspecified" || reason.triggers.length === 0) return [{
|
|
6
|
+
type: "text",
|
|
7
|
+
value: "Version-only release to keep workspace versions consistent; no changes to this package."
|
|
8
|
+
}];
|
|
9
|
+
const label = reason.kind === "fixed" ? "fixed version group" : "linked version group";
|
|
10
|
+
const children = [{
|
|
11
|
+
type: "text",
|
|
12
|
+
value: "Released in lockstep with "
|
|
13
|
+
}];
|
|
14
|
+
reason.triggers.forEach((trigger, index) => {
|
|
15
|
+
if (index > 0) children.push({
|
|
16
|
+
type: "text",
|
|
17
|
+
value: ", "
|
|
18
|
+
});
|
|
19
|
+
children.push({
|
|
20
|
+
type: "inlineCode",
|
|
21
|
+
value: `${trigger.name}@${trigger.version}`
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
children.push({
|
|
25
|
+
type: "text",
|
|
26
|
+
value: ` (${label}).`
|
|
27
|
+
});
|
|
28
|
+
return children;
|
|
29
|
+
}
|
|
30
|
+
const MaintenanceNotePlugin = (options) => {
|
|
31
|
+
return (tree) => {
|
|
32
|
+
const block = getVersionBlocks(tree).find((b) => getHeadingText(tree.children[b.headingIndex]) === options.version);
|
|
33
|
+
if (!block) return;
|
|
34
|
+
if (block.endIndex > block.startIndex) return;
|
|
35
|
+
const heading = {
|
|
36
|
+
type: "heading",
|
|
37
|
+
depth: 3,
|
|
38
|
+
children: [{
|
|
39
|
+
type: "text",
|
|
40
|
+
value: "Maintenance"
|
|
41
|
+
}]
|
|
42
|
+
};
|
|
43
|
+
const list = {
|
|
44
|
+
type: "list",
|
|
45
|
+
ordered: false,
|
|
46
|
+
spread: false,
|
|
47
|
+
children: [{
|
|
48
|
+
type: "listItem",
|
|
49
|
+
spread: false,
|
|
50
|
+
children: [{
|
|
51
|
+
type: "paragraph",
|
|
52
|
+
children: buildNoteChildren(options.reason)
|
|
53
|
+
}]
|
|
54
|
+
}]
|
|
55
|
+
};
|
|
56
|
+
tree.children.splice(block.startIndex, 0, heading, list);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { MaintenanceNotePlugin };
|
|
@@ -3,13 +3,13 @@ const require_dependency_table_format = require('./rules/dependency-table-format
|
|
|
3
3
|
const require_heading_hierarchy = require('./rules/heading-hierarchy.cjs');
|
|
4
4
|
const require_required_sections = require('./rules/required-sections.cjs');
|
|
5
5
|
const require_uncategorized_content = require('./rules/uncategorized-content.cjs');
|
|
6
|
+
const require_aggregate_dependency_tables = require('./plugins/aggregate-dependency-tables.cjs');
|
|
6
7
|
const require_contributor_footnotes = require('./plugins/contributor-footnotes.cjs');
|
|
7
8
|
const require_deduplicate_items = require('./plugins/deduplicate-items.cjs');
|
|
8
9
|
const require_issue_link_refs = require('./plugins/issue-link-refs.cjs');
|
|
9
10
|
const require_merge_sections = require('./plugins/merge-sections.cjs');
|
|
10
11
|
const require_normalize_format = require('./plugins/normalize-format.cjs');
|
|
11
12
|
const require_reorder_sections = require('./plugins/reorder-sections.cjs');
|
|
12
|
-
const require_aggregate_dependency_tables = require('./plugins/aggregate-dependency-tables.cjs');
|
|
13
13
|
|
|
14
14
|
//#region ../silk-effects/dist/dev/pkg/changesets/remark/presets.js
|
|
15
15
|
/**
|
|
@@ -3,13 +3,13 @@ import { DependencyTableFormatRule } from "./rules/dependency-table-format.js";
|
|
|
3
3
|
import { HeadingHierarchyRule } from "./rules/heading-hierarchy.js";
|
|
4
4
|
import { RequiredSectionsRule } from "./rules/required-sections.js";
|
|
5
5
|
import { UncategorizedContentRule } from "./rules/uncategorized-content.js";
|
|
6
|
+
import { AggregateDependencyTablesPlugin } from "./plugins/aggregate-dependency-tables.js";
|
|
6
7
|
import { ContributorFootnotesPlugin } from "./plugins/contributor-footnotes.js";
|
|
7
8
|
import { DeduplicateItemsPlugin } from "./plugins/deduplicate-items.js";
|
|
8
9
|
import { IssueLinkRefsPlugin } from "./plugins/issue-link-refs.js";
|
|
9
10
|
import { MergeSectionsPlugin } from "./plugins/merge-sections.js";
|
|
10
11
|
import { NormalizeFormatPlugin } from "./plugins/normalize-format.js";
|
|
11
12
|
import { ReorderSectionsPlugin } from "./plugins/reorder-sections.js";
|
|
12
|
-
import { AggregateDependencyTablesPlugin } from "./plugins/aggregate-dependency-tables.js";
|
|
13
13
|
|
|
14
14
|
//#region ../silk-effects/dist/dev/pkg/changesets/remark/presets.js
|
|
15
15
|
/**
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const require_ChangesetConfig = require('../../services/ChangesetConfig.cjs');
|
|
2
|
+
let effect = require("effect");
|
|
3
|
+
|
|
4
|
+
//#region ../silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.js
|
|
5
|
+
/**
|
|
6
|
+
* A group co-member whose own changesets forced this release.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
const MaintenanceTriggerSchema = effect.Schema.Struct({
|
|
11
|
+
/** Package name of the triggering co-member. */
|
|
12
|
+
name: effect.Schema.String,
|
|
13
|
+
/** The co-member's new version in the same release plan. */
|
|
14
|
+
version: effect.Schema.String
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Why a package is releasing with no changesets of its own.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
const MaintenanceReasonSchema = effect.Schema.Struct({
|
|
22
|
+
/** Coupling that forced the release; `"unspecified"` when undetermined. */
|
|
23
|
+
kind: effect.Schema.Literal("fixed", "linked", "unspecified"),
|
|
24
|
+
/** Triggering co-members; empty for `"unspecified"`. */
|
|
25
|
+
triggers: effect.Schema.Array(MaintenanceTriggerSchema)
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Derive the {@link MaintenanceReason} for a release, or `undefined` when the
|
|
29
|
+
* release has its own changesets (not a maintenance release).
|
|
30
|
+
*
|
|
31
|
+
* @param release - The release to classify.
|
|
32
|
+
* @param plan - The full release plan (source of group co-members).
|
|
33
|
+
* @param config - Resolved changesets config (`fixed` / `linked` groups).
|
|
34
|
+
* @returns The reason, or `undefined` for releases with their own changesets.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Group entries are matched with {@link ChangesetConfig.matches} — exact names
|
|
38
|
+
* and trailing `"@scope/*"` prefixes only, a subset of the micromatch globs
|
|
39
|
+
* changesets accepts. A group entry using richer glob syntax (e.g. `"pkg-*"`)
|
|
40
|
+
* will not match here; the release then degrades gracefully to the
|
|
41
|
+
* `"unspecified"` fallback sentence instead of naming its triggers.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
function deriveMaintenanceReason(release, plan, config) {
|
|
46
|
+
if (release.changesets.length > 0) return void 0;
|
|
47
|
+
const groupKinds = [["fixed", config.fixed], ["linked", config.linked]];
|
|
48
|
+
for (const [kind, groups] of groupKinds) for (const group of groups) {
|
|
49
|
+
if (!group.some((pattern) => require_ChangesetConfig.ChangesetConfig.matches(release.name, pattern))) continue;
|
|
50
|
+
const triggers = plan.releases.filter((r) => r.name !== release.name && r.changesets.length > 0 && group.some((pattern) => require_ChangesetConfig.ChangesetConfig.matches(r.name, pattern))).map((r) => ({
|
|
51
|
+
name: r.name,
|
|
52
|
+
version: r.newVersion
|
|
53
|
+
}));
|
|
54
|
+
if (triggers.length > 0) return {
|
|
55
|
+
kind,
|
|
56
|
+
triggers
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
kind: "unspecified",
|
|
61
|
+
triggers: []
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.MaintenanceReasonSchema = MaintenanceReasonSchema;
|
|
67
|
+
exports.MaintenanceTriggerSchema = MaintenanceTriggerSchema;
|
|
68
|
+
exports.deriveMaintenanceReason = deriveMaintenanceReason;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ChangesetConfig } from "../../services/ChangesetConfig.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region ../silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.js
|
|
5
|
+
/**
|
|
6
|
+
* A group co-member whose own changesets forced this release.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
const MaintenanceTriggerSchema = Schema.Struct({
|
|
11
|
+
/** Package name of the triggering co-member. */
|
|
12
|
+
name: Schema.String,
|
|
13
|
+
/** The co-member's new version in the same release plan. */
|
|
14
|
+
version: Schema.String
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Why a package is releasing with no changesets of its own.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
const MaintenanceReasonSchema = Schema.Struct({
|
|
22
|
+
/** Coupling that forced the release; `"unspecified"` when undetermined. */
|
|
23
|
+
kind: Schema.Literal("fixed", "linked", "unspecified"),
|
|
24
|
+
/** Triggering co-members; empty for `"unspecified"`. */
|
|
25
|
+
triggers: Schema.Array(MaintenanceTriggerSchema)
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Derive the {@link MaintenanceReason} for a release, or `undefined` when the
|
|
29
|
+
* release has its own changesets (not a maintenance release).
|
|
30
|
+
*
|
|
31
|
+
* @param release - The release to classify.
|
|
32
|
+
* @param plan - The full release plan (source of group co-members).
|
|
33
|
+
* @param config - Resolved changesets config (`fixed` / `linked` groups).
|
|
34
|
+
* @returns The reason, or `undefined` for releases with their own changesets.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Group entries are matched with {@link ChangesetConfig.matches} — exact names
|
|
38
|
+
* and trailing `"@scope/*"` prefixes only, a subset of the micromatch globs
|
|
39
|
+
* changesets accepts. A group entry using richer glob syntax (e.g. `"pkg-*"`)
|
|
40
|
+
* will not match here; the release then degrades gracefully to the
|
|
41
|
+
* `"unspecified"` fallback sentence instead of naming its triggers.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
function deriveMaintenanceReason(release, plan, config) {
|
|
46
|
+
if (release.changesets.length > 0) return void 0;
|
|
47
|
+
const groupKinds = [["fixed", config.fixed], ["linked", config.linked]];
|
|
48
|
+
for (const [kind, groups] of groupKinds) for (const group of groups) {
|
|
49
|
+
if (!group.some((pattern) => ChangesetConfig.matches(release.name, pattern))) continue;
|
|
50
|
+
const triggers = plan.releases.filter((r) => r.name !== release.name && r.changesets.length > 0 && group.some((pattern) => ChangesetConfig.matches(r.name, pattern))).map((r) => ({
|
|
51
|
+
name: r.name,
|
|
52
|
+
version: r.newVersion
|
|
53
|
+
}));
|
|
54
|
+
if (triggers.length > 0) return {
|
|
55
|
+
kind,
|
|
56
|
+
triggers
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
kind: "unspecified",
|
|
61
|
+
triggers: []
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { MaintenanceReasonSchema, MaintenanceTriggerSchema, deriveMaintenanceReason };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_errors = require('../errors.cjs');
|
|
2
2
|
const require_transformer = require('../api/transformer.cjs');
|
|
3
3
|
const require_config_inspector = require('./config-inspector.cjs');
|
|
4
|
+
const require_maintenance_reason = require('./maintenance-reason.cjs');
|
|
4
5
|
const require_version_files = require('../utils/version-files.cjs');
|
|
5
6
|
const require_changesets_config_esm = require('../../../../../../../node_modules/.pnpm/@changesets_config@3.1.4/node_modules/@changesets/config/dist/changesets-config.esm.cjs');
|
|
6
7
|
const require_changesets_apply_release_plan_esm = require('../../../../../../../node_modules/.pnpm/@changesets_apply-release-plan@7.1.1/node_modules/@changesets/apply-release-plan/dist/changesets-apply-release-plan.esm.cjs');
|
|
@@ -113,6 +114,16 @@ function extractVersionBlock(changelog, version) {
|
|
|
113
114
|
}
|
|
114
115
|
return lines.slice(start, end).join("\n").trim();
|
|
115
116
|
}
|
|
117
|
+
/** Maintenance reasons for every changeset-less release in the plan, keyed by package name. */
|
|
118
|
+
function maintenanceReasons(plan, config) {
|
|
119
|
+
const reasons = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const r of plan.releases) {
|
|
121
|
+
if (r.type === "none") continue;
|
|
122
|
+
const reason = require_maintenance_reason.deriveMaintenanceReason(r, plan, config);
|
|
123
|
+
if (reason) reasons.set(r.name, reason);
|
|
124
|
+
}
|
|
125
|
+
return reasons;
|
|
126
|
+
}
|
|
116
127
|
/**
|
|
117
128
|
* Render a non-destructive preview by redirecting every write into a
|
|
118
129
|
* scope-managed temp directory (cleaned up automatically when the scope
|
|
@@ -134,6 +145,7 @@ function previewEffect(root, fs) {
|
|
|
134
145
|
reason: errMsg(e)
|
|
135
146
|
})
|
|
136
147
|
});
|
|
148
|
+
const reasonByName = maintenanceReasons(plan, config);
|
|
137
149
|
const preMode = plan.preState ? plan.preState.mode : null;
|
|
138
150
|
const changesets = plan.changesets.map((cs) => ({
|
|
139
151
|
id: cs.id,
|
|
@@ -202,8 +214,12 @@ function previewEffect(root, fs) {
|
|
|
202
214
|
if (!dir) continue;
|
|
203
215
|
const clPath = (0, node_path.join)(dir, "CHANGELOG.md");
|
|
204
216
|
if (!(yield* fs.exists(clPath))) continue;
|
|
217
|
+
const reason = reasonByName.get(r.name);
|
|
205
218
|
yield* effect.Effect.try({
|
|
206
|
-
try: () => require_transformer.ChangelogTransformer.transformFile(clPath
|
|
219
|
+
try: () => require_transformer.ChangelogTransformer.transformFile(clPath, reason ? { maintenance: {
|
|
220
|
+
version: r.newVersion,
|
|
221
|
+
reason
|
|
222
|
+
} } : void 0),
|
|
207
223
|
catch: (e) => new require_errors.ReleasePlanError({
|
|
208
224
|
phase: "preview",
|
|
209
225
|
reason: errMsg(e)
|
|
@@ -257,17 +273,33 @@ function applyEffect(root, dryRun, inspector, fs) {
|
|
|
257
273
|
newVersion: r.newVersion
|
|
258
274
|
}));
|
|
259
275
|
let touchedFiles = [];
|
|
260
|
-
if (!dryRun)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
276
|
+
if (!dryRun) {
|
|
277
|
+
const reasonByName = maintenanceReasons(plan, config);
|
|
278
|
+
const versionByPkgName = new Map(plan.releases.map((r) => [r.name, r.newVersion]));
|
|
279
|
+
const nameByDir = /* @__PURE__ */ new Map();
|
|
280
|
+
for (const p of packages.packages) nameByDir.set(p.dir, p.packageJson.name);
|
|
281
|
+
if (packages.root.packageJson.name) nameByDir.set(packages.root.dir, packages.root.packageJson.name);
|
|
282
|
+
touchedFiles = yield* effect.Effect.tryPromise({
|
|
283
|
+
try: async () => {
|
|
284
|
+
const touched = await require_changesets_apply_release_plan_esm.default(plan, packages, config);
|
|
285
|
+
for (const f of touched) {
|
|
286
|
+
if (!f.endsWith("CHANGELOG.md")) continue;
|
|
287
|
+
const pkgName = nameByDir.get((0, node_path.dirname)(f));
|
|
288
|
+
const reason = pkgName ? reasonByName.get(pkgName) : void 0;
|
|
289
|
+
const newVersion = pkgName ? versionByPkgName.get(pkgName) : void 0;
|
|
290
|
+
require_transformer.ChangelogTransformer.transformFile(f, reason && newVersion ? { maintenance: {
|
|
291
|
+
version: newVersion,
|
|
292
|
+
reason
|
|
293
|
+
} } : void 0);
|
|
294
|
+
}
|
|
295
|
+
return touched;
|
|
296
|
+
},
|
|
297
|
+
catch: (e) => new require_errors.ReleasePlanError({
|
|
298
|
+
phase: "apply",
|
|
299
|
+
reason: errMsg(e)
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
}
|
|
271
303
|
const newVersionByName = new Map(plan.releases.map((r) => [r.name, r.newVersion]));
|
|
272
304
|
const inspected = yield* inspector.inspect(root).pipe(effect.Effect.catchAll((error) => effect.Effect.logWarning(`Skipping versionFiles update: ${errMsg(error)}`).pipe(effect.Effect.as(null))));
|
|
273
305
|
let versionFileUpdates = [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReleasePlanError } from "../errors.js";
|
|
2
2
|
import { ChangelogTransformer } from "../api/transformer.js";
|
|
3
3
|
import { ConfigInspector } from "./config-inspector.js";
|
|
4
|
+
import { deriveMaintenanceReason } from "./maintenance-reason.js";
|
|
4
5
|
import { VersionFiles } from "../utils/version-files.js";
|
|
5
6
|
import { read } from "../../../../../../../node_modules/.pnpm/@changesets_config@3.1.4/node_modules/@changesets/config/dist/changesets-config.esm.js";
|
|
6
7
|
import applyReleasePlan from "../../../../../../../node_modules/.pnpm/@changesets_apply-release-plan@7.1.1/node_modules/@changesets/apply-release-plan/dist/changesets-apply-release-plan.esm.js";
|
|
@@ -8,7 +9,7 @@ import getReleasePlan from "../../../../../../../node_modules/.pnpm/@changesets_
|
|
|
8
9
|
import { getPackages } from "../../../../../../../node_modules/.pnpm/@manypkg_get-packages@3.1.0/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.js";
|
|
9
10
|
import { Context, Effect, Layer } from "effect";
|
|
10
11
|
import { FileSystem } from "@effect/platform";
|
|
11
|
-
import { isAbsolute, join, relative } from "node:path";
|
|
12
|
+
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
12
13
|
|
|
13
14
|
//#region ../silk-effects/dist/dev/pkg/changesets/services/release-planner.js
|
|
14
15
|
/**
|
|
@@ -113,6 +114,16 @@ function extractVersionBlock(changelog, version) {
|
|
|
113
114
|
}
|
|
114
115
|
return lines.slice(start, end).join("\n").trim();
|
|
115
116
|
}
|
|
117
|
+
/** Maintenance reasons for every changeset-less release in the plan, keyed by package name. */
|
|
118
|
+
function maintenanceReasons(plan, config) {
|
|
119
|
+
const reasons = /* @__PURE__ */ new Map();
|
|
120
|
+
for (const r of plan.releases) {
|
|
121
|
+
if (r.type === "none") continue;
|
|
122
|
+
const reason = deriveMaintenanceReason(r, plan, config);
|
|
123
|
+
if (reason) reasons.set(r.name, reason);
|
|
124
|
+
}
|
|
125
|
+
return reasons;
|
|
126
|
+
}
|
|
116
127
|
/**
|
|
117
128
|
* Render a non-destructive preview by redirecting every write into a
|
|
118
129
|
* scope-managed temp directory (cleaned up automatically when the scope
|
|
@@ -134,6 +145,7 @@ function previewEffect(root, fs) {
|
|
|
134
145
|
reason: errMsg(e)
|
|
135
146
|
})
|
|
136
147
|
});
|
|
148
|
+
const reasonByName = maintenanceReasons(plan, config);
|
|
137
149
|
const preMode = plan.preState ? plan.preState.mode : null;
|
|
138
150
|
const changesets = plan.changesets.map((cs) => ({
|
|
139
151
|
id: cs.id,
|
|
@@ -202,8 +214,12 @@ function previewEffect(root, fs) {
|
|
|
202
214
|
if (!dir) continue;
|
|
203
215
|
const clPath = join(dir, "CHANGELOG.md");
|
|
204
216
|
if (!(yield* fs.exists(clPath))) continue;
|
|
217
|
+
const reason = reasonByName.get(r.name);
|
|
205
218
|
yield* Effect.try({
|
|
206
|
-
try: () => ChangelogTransformer.transformFile(clPath
|
|
219
|
+
try: () => ChangelogTransformer.transformFile(clPath, reason ? { maintenance: {
|
|
220
|
+
version: r.newVersion,
|
|
221
|
+
reason
|
|
222
|
+
} } : void 0),
|
|
207
223
|
catch: (e) => new ReleasePlanError({
|
|
208
224
|
phase: "preview",
|
|
209
225
|
reason: errMsg(e)
|
|
@@ -257,17 +273,33 @@ function applyEffect(root, dryRun, inspector, fs) {
|
|
|
257
273
|
newVersion: r.newVersion
|
|
258
274
|
}));
|
|
259
275
|
let touchedFiles = [];
|
|
260
|
-
if (!dryRun)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
276
|
+
if (!dryRun) {
|
|
277
|
+
const reasonByName = maintenanceReasons(plan, config);
|
|
278
|
+
const versionByPkgName = new Map(plan.releases.map((r) => [r.name, r.newVersion]));
|
|
279
|
+
const nameByDir = /* @__PURE__ */ new Map();
|
|
280
|
+
for (const p of packages.packages) nameByDir.set(p.dir, p.packageJson.name);
|
|
281
|
+
if (packages.root.packageJson.name) nameByDir.set(packages.root.dir, packages.root.packageJson.name);
|
|
282
|
+
touchedFiles = yield* Effect.tryPromise({
|
|
283
|
+
try: async () => {
|
|
284
|
+
const touched = await applyReleasePlan(plan, packages, config);
|
|
285
|
+
for (const f of touched) {
|
|
286
|
+
if (!f.endsWith("CHANGELOG.md")) continue;
|
|
287
|
+
const pkgName = nameByDir.get(dirname(f));
|
|
288
|
+
const reason = pkgName ? reasonByName.get(pkgName) : void 0;
|
|
289
|
+
const newVersion = pkgName ? versionByPkgName.get(pkgName) : void 0;
|
|
290
|
+
ChangelogTransformer.transformFile(f, reason && newVersion ? { maintenance: {
|
|
291
|
+
version: newVersion,
|
|
292
|
+
reason
|
|
293
|
+
} } : void 0);
|
|
294
|
+
}
|
|
295
|
+
return touched;
|
|
296
|
+
},
|
|
297
|
+
catch: (e) => new ReleasePlanError({
|
|
298
|
+
phase: "apply",
|
|
299
|
+
reason: errMsg(e)
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
}
|
|
271
303
|
const newVersionByName = new Map(plan.releases.map((r) => [r.name, r.newVersion]));
|
|
272
304
|
const inspected = yield* inspector.inspect(root).pipe(Effect.catchAll((error) => Effect.logWarning(`Skipping versionFiles update: ${errMsg(error)}`).pipe(Effect.as(null))));
|
|
273
305
|
let versionFileUpdates = [];
|