@savvy-web/changesets 0.4.2 → 0.5.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/README.md +16 -0
- package/cjs/changelog.cjs +131 -36
- package/cjs/changelog.d.cts +52 -3
- package/cjs/index.cjs +262 -42
- package/cjs/index.d.cts +1726 -175
- package/cjs/markdownlint.cjs +156 -2
- package/cjs/markdownlint.d.cts +127 -21
- package/cjs/remark.cjs +225 -9
- package/cjs/remark.d.cts +106 -37
- package/esm/160.js +45 -39
- package/esm/260.js +2 -1
- package/esm/273.js +2 -1
- package/esm/622.js +2 -2
- package/esm/{795.js → 725.js} +2 -5
- package/esm/855.js +5 -0
- package/esm/891.js +147 -0
- package/esm/bin/savvy-changesets.js +5 -3
- package/esm/changelog.d.ts +52 -3
- package/esm/index.d.ts +1726 -175
- package/esm/index.js +27 -5
- package/esm/markdownlint.d.ts +127 -21
- package/esm/markdownlint.js +152 -2
- package/esm/remark.d.ts +106 -37
- package/esm/remark.js +76 -3
- package/package.json +1 -1
- package/esm/689.js +0 -1
package/esm/remark.js
CHANGED
|
@@ -1,11 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseDependencyTable, serializeDependencyTable, collapseDependencyRows, sortDependencyRows } from "./891.js";
|
|
2
|
+
import { getHeadingText, NormalizeFormatPlugin, ContentStructureRule, HeadingHierarchyRule, ReorderSectionsPlugin, getVersionBlocks, getBlockSections, visit, UncategorizedContentRule, MergeSectionsPlugin, DeduplicateItemsPlugin, IssueLinkRefsPlugin, lintRule, ContributorFootnotesPlugin, RequiredSectionsRule } from "./622.js";
|
|
3
|
+
import { external_mdast_util_to_string_toString } from "./855.js";
|
|
4
|
+
import { RULE_DOCS } from "./260.js";
|
|
5
|
+
const AggregateDependencyTablesPlugin = ()=>(tree)=>{
|
|
6
|
+
const blocks = getVersionBlocks(tree);
|
|
7
|
+
for(let b = blocks.length - 1; b >= 0; b--){
|
|
8
|
+
const sections = getBlockSections(tree, blocks[b]);
|
|
9
|
+
const depSections = sections.filter((s)=>"dependencies" === getHeadingText(s.heading).toLowerCase());
|
|
10
|
+
if (0 === depSections.length) continue;
|
|
11
|
+
const allRows = [];
|
|
12
|
+
const legacyContent = [];
|
|
13
|
+
for (const section of depSections)for (const node of section.contentNodes)if ("table" === node.type) try {
|
|
14
|
+
const rows = parseDependencyTable(node);
|
|
15
|
+
allRows.push(...rows);
|
|
16
|
+
} catch {
|
|
17
|
+
legacyContent.push(node);
|
|
18
|
+
}
|
|
19
|
+
else legacyContent.push(node);
|
|
20
|
+
const collapsed = sortDependencyRows(collapseDependencyRows(allRows));
|
|
21
|
+
const indicesToRemove = [];
|
|
22
|
+
for (const section of depSections){
|
|
23
|
+
indicesToRemove.push(section.headingIndex);
|
|
24
|
+
for(let c = 0; c < section.contentNodes.length; c++)indicesToRemove.push(section.headingIndex + 1 + c);
|
|
25
|
+
}
|
|
26
|
+
indicesToRemove.sort((a, b)=>b - a);
|
|
27
|
+
for (const idx of indicesToRemove)tree.children.splice(idx, 1);
|
|
28
|
+
if (0 === collapsed.length && 0 === legacyContent.length) continue;
|
|
29
|
+
const insertAt = depSections[0].headingIndex;
|
|
30
|
+
const newNodes = [];
|
|
31
|
+
const heading = {
|
|
32
|
+
type: "heading",
|
|
33
|
+
depth: 3,
|
|
34
|
+
children: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
value: "Dependencies"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
};
|
|
41
|
+
newNodes.push(heading);
|
|
42
|
+
if (collapsed.length > 0) newNodes.push(serializeDependencyTable(collapsed));
|
|
43
|
+
newNodes.push(...legacyContent);
|
|
44
|
+
tree.children.splice(insertAt, 0, ...newNodes);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const EM_DASH = "\u2014";
|
|
48
|
+
const DependencyTableFormatRule = lintRule("remark-lint:changeset-dependency-table-format", (tree, file)=>{
|
|
49
|
+
visit(tree, "heading", (node, index)=>{
|
|
50
|
+
if (2 !== node.depth) return;
|
|
51
|
+
if ("dependencies" !== external_mdast_util_to_string_toString(node).toLowerCase()) return;
|
|
52
|
+
if (void 0 === index) return;
|
|
53
|
+
const content = [];
|
|
54
|
+
for(let i = index + 1; i < tree.children.length; i++){
|
|
55
|
+
const child = tree.children[i];
|
|
56
|
+
if ("heading" === child.type) break;
|
|
57
|
+
content.push(child);
|
|
58
|
+
}
|
|
59
|
+
const tables = content.filter((n)=>"table" === n.type);
|
|
60
|
+
if (0 === tables.length) return void file.message(`Dependencies section must contain a table, not a list or paragraph. See: ${RULE_DOCS.CSH005}`, node);
|
|
61
|
+
const table = tables[0];
|
|
62
|
+
try {
|
|
63
|
+
const rows = parseDependencyTable(table);
|
|
64
|
+
for (const row of rows){
|
|
65
|
+
if ("added" === row.action && row.from !== EM_DASH) file.message(`'from' must be '\u2014' when action is 'added' (got '${row.from}'). See: ${RULE_DOCS.CSH005}`, table);
|
|
66
|
+
if ("removed" === row.action && row.to !== EM_DASH) file.message(`'to' must be '\u2014' when action is 'removed' (got '${row.to}'). See: ${RULE_DOCS.CSH005}`, table);
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
file.message(`${error instanceof Error ? error.message : String(error)}. See: ${RULE_DOCS.CSH005}`, table);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
2
73
|
const SilkChangesetPreset = [
|
|
3
74
|
HeadingHierarchyRule,
|
|
4
75
|
RequiredSectionsRule,
|
|
5
76
|
ContentStructureRule,
|
|
6
|
-
UncategorizedContentRule
|
|
77
|
+
UncategorizedContentRule,
|
|
78
|
+
DependencyTableFormatRule
|
|
7
79
|
];
|
|
8
80
|
const SilkChangesetTransformPreset = [
|
|
81
|
+
AggregateDependencyTablesPlugin,
|
|
9
82
|
MergeSectionsPlugin,
|
|
10
83
|
ReorderSectionsPlugin,
|
|
11
84
|
DeduplicateItemsPlugin,
|
|
@@ -14,4 +87,4 @@ const SilkChangesetTransformPreset = [
|
|
|
14
87
|
NormalizeFormatPlugin
|
|
15
88
|
];
|
|
16
89
|
export { ContentStructureRule, ContributorFootnotesPlugin, DeduplicateItemsPlugin, HeadingHierarchyRule, IssueLinkRefsPlugin, MergeSectionsPlugin, NormalizeFormatPlugin, ReorderSectionsPlugin, RequiredSectionsRule, UncategorizedContentRule } from "./622.js";
|
|
17
|
-
export { SilkChangesetPreset, SilkChangesetTransformPreset };
|
|
90
|
+
export { AggregateDependencyTablesPlugin, DependencyTableFormatRule, SilkChangesetPreset, SilkChangesetTransformPreset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/changesets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Custom changelog formatter and markdown processing pipeline for the Silk Suite. Provides structured changeset sections, remark-based validation and transformation, and an Effect CLI.",
|
|
6
6
|
"keywords": [
|
package/esm/689.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toString as external_mdast_util_to_string_toString } from "mdast-util-to-string";
|