@savvy-web/silk 2.0.0 → 2.1.1
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 +7 -5
- package/changesets-changelog.cjs +109 -61
- package/changesets-changelog.d.cts +1 -1
- package/changesets-changelog.d.ts +1 -1
- package/changesets-changelog.js +54099 -1
- package/changesets-markdownlint.cjs +109 -61
- package/changesets-markdownlint.d.cts +1 -1
- package/changesets-markdownlint.d.ts +1 -1
- package/changesets-markdownlint.js +54099 -1
- package/package.json +5 -4
- package/tsconfig/node/dist/tsconfig.tsbuildinfo +1 -1
- package/_virtual/_rolldown/runtime.cjs +0 -45
- package/_virtual/_rolldown/runtime.js +0 -45
- package/packages/silk-effects/dist/dev/pkg/_virtual/_rolldown/runtime.cjs +0 -15
- package/packages/silk-effects/dist/dev/pkg/_virtual/_rolldown/runtime.js +0 -14
- package/packages/silk-effects/dist/dev/pkg/changesets/api/categories.cjs +0 -247
- package/packages/silk-effects/dist/dev/pkg/changesets/api/categories.js +0 -247
- package/packages/silk-effects/dist/dev/pkg/changesets/api/changelog.cjs +0 -134
- package/packages/silk-effects/dist/dev/pkg/changesets/api/changelog.js +0 -134
- package/packages/silk-effects/dist/dev/pkg/changesets/api/dependency-table.cjs +0 -163
- package/packages/silk-effects/dist/dev/pkg/changesets/api/dependency-table.js +0 -163
- package/packages/silk-effects/dist/dev/pkg/changesets/api/linter.cjs +0 -170
- package/packages/silk-effects/dist/dev/pkg/changesets/api/linter.js +0 -170
- package/packages/silk-effects/dist/dev/pkg/changesets/api/transformer.cjs +0 -134
- package/packages/silk-effects/dist/dev/pkg/changesets/api/transformer.js +0 -134
- package/packages/silk-effects/dist/dev/pkg/changesets/categories/index.cjs +0 -317
- package/packages/silk-effects/dist/dev/pkg/changesets/categories/index.js +0 -299
- package/packages/silk-effects/dist/dev/pkg/changesets/categories/types.cjs +0 -65
- package/packages/silk-effects/dist/dev/pkg/changesets/categories/types.js +0 -65
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/formatting.cjs +0 -114
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/formatting.js +0 -113
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getDependencyReleaseLine.cjs +0 -118
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getDependencyReleaseLine.js +0 -118
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getReleaseLine.cjs +0 -122
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/getReleaseLine.js +0 -122
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/index.cjs +0 -97
- package/packages/silk-effects/dist/dev/pkg/changesets/changelog/index.js +0 -97
- package/packages/silk-effects/dist/dev/pkg/changesets/constants.cjs +0 -43
- package/packages/silk-effects/dist/dev/pkg/changesets/constants.js +0 -42
- package/packages/silk-effects/dist/dev/pkg/changesets/errors.cjs +0 -386
- package/packages/silk-effects/dist/dev/pkg/changesets/errors.js +0 -371
- package/packages/silk-effects/dist/dev/pkg/changesets/index.cjs +0 -300
- package/packages/silk-effects/dist/dev/pkg/changesets/index.js +0 -179
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/index.cjs +0 -34
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/index.js +0 -29
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/content-structure.cjs +0 -98
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/content-structure.js +0 -98
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/dependency-table-format.cjs +0 -170
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/dependency-table-format.js +0 -170
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/heading-hierarchy.cjs +0 -61
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/heading-hierarchy.js +0 -61
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/required-sections.cjs +0 -54
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/required-sections.js +0 -54
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/uncategorized-content.cjs +0 -54
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/uncategorized-content.js +0 -54
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/utils.cjs +0 -31
- package/packages/silk-effects/dist/dev/pkg/changesets/markdownlint/rules/utils.js +0 -30
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/aggregate-dependency-tables.cjs +0 -47
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/aggregate-dependency-tables.js +0 -47
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/contributor-footnotes.cjs +0 -123
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/contributor-footnotes.js +0 -123
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/deduplicate-items.cjs +0 -32
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/deduplicate-items.js +0 -32
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/issue-link-refs.cjs +0 -59
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/issue-link-refs.js +0 -59
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.cjs +0 -61
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/maintenance-note.js +0 -61
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/merge-sections.cjs +0 -43
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/merge-sections.js +0 -43
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/normalize-format.cjs +0 -47
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/normalize-format.js +0 -47
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/reorder-sections.cjs +0 -34
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/plugins/reorder-sections.js +0 -34
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/presets.cjs +0 -120
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/presets.js +0 -119
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/content-structure.cjs +0 -22
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/content-structure.js +0 -22
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/dependency-table-format.cjs +0 -40
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/dependency-table-format.js +0 -40
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/heading-hierarchy.cjs +0 -19
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/heading-hierarchy.js +0 -19
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/required-sections.cjs +0 -17
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/required-sections.js +0 -17
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/uncategorized-content.cjs +0 -31
- package/packages/silk-effects/dist/dev/pkg/changesets/remark/rules/uncategorized-content.js +0 -31
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/changeset.cjs +0 -148
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/changeset.js +0 -145
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/dependency-table.cjs +0 -203
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/dependency-table.js +0 -198
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/git.cjs +0 -69
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/git.js +0 -68
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/github.cjs +0 -177
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/github.js +0 -174
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/options.cjs +0 -183
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/options.js +0 -181
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/package-scope.cjs +0 -129
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/package-scope.js +0 -127
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/primitives.cjs +0 -72
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/primitives.js +0 -71
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/release-plan.cjs +0 -62
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/release-plan.js +0 -56
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/version-files.cjs +0 -154
- package/packages/silk-effects/dist/dev/pkg/changesets/schemas/version-files.js +0 -150
- package/packages/silk-effects/dist/dev/pkg/changesets/services/branch-analyzer.cjs +0 -300
- package/packages/silk-effects/dist/dev/pkg/changesets/services/branch-analyzer.js +0 -294
- package/packages/silk-effects/dist/dev/pkg/changesets/services/changelog.cjs +0 -50
- package/packages/silk-effects/dist/dev/pkg/changesets/services/changelog.js +0 -49
- package/packages/silk-effects/dist/dev/pkg/changesets/services/config-inspector.cjs +0 -489
- package/packages/silk-effects/dist/dev/pkg/changesets/services/config-inspector.js +0 -481
- package/packages/silk-effects/dist/dev/pkg/changesets/services/deps-regen.cjs +0 -375
- package/packages/silk-effects/dist/dev/pkg/changesets/services/deps-regen.js +0 -371
- package/packages/silk-effects/dist/dev/pkg/changesets/services/github.cjs +0 -160
- package/packages/silk-effects/dist/dev/pkg/changesets/services/github.js +0 -157
- package/packages/silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.cjs +0 -68
- package/packages/silk-effects/dist/dev/pkg/changesets/services/maintenance-reason.js +0 -66
- package/packages/silk-effects/dist/dev/pkg/changesets/services/markdown.cjs +0 -87
- package/packages/silk-effects/dist/dev/pkg/changesets/services/markdown.js +0 -85
- package/packages/silk-effects/dist/dev/pkg/changesets/services/release-planner.cjs +0 -352
- package/packages/silk-effects/dist/dev/pkg/changesets/services/release-planner.js +0 -348
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/commit-parser.cjs +0 -81
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/commit-parser.js +0 -80
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/dep-diff.cjs +0 -111
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/dep-diff.js +0 -111
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/dependency-table.cjs +0 -351
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/dependency-table.js +0 -347
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/git.cjs +0 -51
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/git.js +0 -51
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/issue-refs.cjs +0 -102
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/issue-refs.js +0 -101
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/jsonpath.cjs +0 -178
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/jsonpath.js +0 -175
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/logger.cjs +0 -51
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/logger.js +0 -50
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/markdown-link.cjs +0 -59
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/markdown-link.js +0 -57
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/publishability.cjs +0 -50
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/publishability.js +0 -50
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/remark-pipeline.cjs +0 -81
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/remark-pipeline.js +0 -79
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/section-parser.cjs +0 -94
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/section-parser.js +0 -94
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/strip-frontmatter.cjs +0 -47
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/strip-frontmatter.js +0 -46
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/version-blocks.cjs +0 -110
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/version-blocks.js +0 -108
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/version-files.cjs +0 -336
- package/packages/silk-effects/dist/dev/pkg/changesets/utils/version-files.js +0 -336
- package/packages/silk-effects/dist/dev/pkg/changesets/vendor/github-info.cjs +0 -77
- package/packages/silk-effects/dist/dev/pkg/changesets/vendor/github-info.js +0 -77
- package/packages/silk-effects/dist/dev/pkg/errors/ChangesetConfigError.cjs +0 -21
- package/packages/silk-effects/dist/dev/pkg/errors/ChangesetConfigError.js +0 -21
- package/packages/silk-effects/dist/dev/pkg/schemas/VersioningSchemas.cjs +0 -101
- package/packages/silk-effects/dist/dev/pkg/schemas/VersioningSchemas.js +0 -99
- package/packages/silk-effects/dist/dev/pkg/services/ChangesetConfig.cjs +0 -81
- package/packages/silk-effects/dist/dev/pkg/services/ChangesetConfig.js +0 -80
- package/packages/silk-effects/dist/dev/pkg/services/ChangesetConfigReader.cjs +0 -109
- package/packages/silk-effects/dist/dev/pkg/services/ChangesetConfigReader.js +0 -108
- package/packages/silk-effects/dist/dev/pkg/services/SilkPublishability.cjs +0 -238
- package/packages/silk-effects/dist/dev/pkg/services/SilkPublishability.js +0 -236
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
const require_index = require('../../../../../../../node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.cjs');
|
|
2
|
-
const require_index$1 = require('../../../../../../../node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.cjs');
|
|
3
|
-
const require_index$2 = require('../../../../../../../node_modules/.pnpm/remark-stringify@11.0.0/node_modules/remark-stringify/lib/index.cjs');
|
|
4
|
-
const require_index$3 = require('../../../../../../../node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.cjs');
|
|
5
|
-
|
|
6
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/remark-pipeline.js
|
|
7
|
-
/**
|
|
8
|
-
* Create a unified processor configured with remark-parse, remark-gfm,
|
|
9
|
-
* and remark-stringify.
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Each call creates a fresh processor instance. The plugin chain is:
|
|
13
|
-
* 1. `remark-parse` — markdown to MDAST
|
|
14
|
-
* 2. `remark-gfm` — GitHub Flavored Markdown extensions (tables, etc.)
|
|
15
|
-
* 3. `remark-stringify` — MDAST back to markdown
|
|
16
|
-
*
|
|
17
|
-
* @privateRemarks
|
|
18
|
-
* Return type is intentionally inferred because the unified `Processor`
|
|
19
|
-
* generic signature is complex and parameterized by the plugin chain.
|
|
20
|
-
*
|
|
21
|
-
* @returns A configured unified processor
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
function createRemarkProcessor() {
|
|
26
|
-
return require_index$3.unified().use(require_index$1.default).use(require_index.default).use(require_index$2.default);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse a markdown string into an MDAST AST synchronously.
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* Uses {@link createRemarkProcessor} internally. The returned tree
|
|
33
|
-
* includes GFM extensions (tables, strikethrough, etc.) thanks to
|
|
34
|
-
* the remark-gfm plugin.
|
|
35
|
-
*
|
|
36
|
-
* @param content - Raw markdown string
|
|
37
|
-
* @returns The parsed MDAST root node
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
42
|
-
*
|
|
43
|
-
* const tree = parseMarkdown("## Version 1.0.0\n\nInitial release.");
|
|
44
|
-
* // tree.type === "root"
|
|
45
|
-
* // tree.children[0].type === "heading"
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
function parseMarkdown(content) {
|
|
51
|
-
return createRemarkProcessor().parse(content);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Stringify an MDAST AST back to a markdown string synchronously.
|
|
55
|
-
*
|
|
56
|
-
* @remarks
|
|
57
|
-
* Uses {@link createRemarkProcessor} internally. GFM constructs
|
|
58
|
-
* (tables, etc.) are serialized correctly thanks to the remark-gfm plugin.
|
|
59
|
-
*
|
|
60
|
-
* @param tree - The MDAST root node
|
|
61
|
-
* @returns The serialized markdown string
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { parseMarkdown, stringifyMarkdown } from "../utils/remark-pipeline.js";
|
|
66
|
-
*
|
|
67
|
-
* const tree = parseMarkdown("# Hello\n\nWorld.");
|
|
68
|
-
* const md = stringifyMarkdown(tree);
|
|
69
|
-
* // "# Hello\n\nWorld.\n"
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
function stringifyMarkdown(tree) {
|
|
75
|
-
return createRemarkProcessor().stringify(tree);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
exports.createRemarkProcessor = createRemarkProcessor;
|
|
80
|
-
exports.parseMarkdown = parseMarkdown;
|
|
81
|
-
exports.stringifyMarkdown = stringifyMarkdown;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import remarkGfm from "../../../../../../../node_modules/.pnpm/remark-gfm@4.0.1/node_modules/remark-gfm/lib/index.js";
|
|
2
|
-
import remarkParse from "../../../../../../../node_modules/.pnpm/remark-parse@11.0.0/node_modules/remark-parse/lib/index.js";
|
|
3
|
-
import remarkStringify from "../../../../../../../node_modules/.pnpm/remark-stringify@11.0.0/node_modules/remark-stringify/lib/index.js";
|
|
4
|
-
import { unified } from "../../../../../../../node_modules/.pnpm/unified@11.0.5/node_modules/unified/lib/index.js";
|
|
5
|
-
|
|
6
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/remark-pipeline.js
|
|
7
|
-
/**
|
|
8
|
-
* Create a unified processor configured with remark-parse, remark-gfm,
|
|
9
|
-
* and remark-stringify.
|
|
10
|
-
*
|
|
11
|
-
* @remarks
|
|
12
|
-
* Each call creates a fresh processor instance. The plugin chain is:
|
|
13
|
-
* 1. `remark-parse` — markdown to MDAST
|
|
14
|
-
* 2. `remark-gfm` — GitHub Flavored Markdown extensions (tables, etc.)
|
|
15
|
-
* 3. `remark-stringify` — MDAST back to markdown
|
|
16
|
-
*
|
|
17
|
-
* @privateRemarks
|
|
18
|
-
* Return type is intentionally inferred because the unified `Processor`
|
|
19
|
-
* generic signature is complex and parameterized by the plugin chain.
|
|
20
|
-
*
|
|
21
|
-
* @returns A configured unified processor
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
function createRemarkProcessor() {
|
|
26
|
-
return unified().use(remarkParse).use(remarkGfm).use(remarkStringify);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Parse a markdown string into an MDAST AST synchronously.
|
|
30
|
-
*
|
|
31
|
-
* @remarks
|
|
32
|
-
* Uses {@link createRemarkProcessor} internally. The returned tree
|
|
33
|
-
* includes GFM extensions (tables, strikethrough, etc.) thanks to
|
|
34
|
-
* the remark-gfm plugin.
|
|
35
|
-
*
|
|
36
|
-
* @param content - Raw markdown string
|
|
37
|
-
* @returns The parsed MDAST root node
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
42
|
-
*
|
|
43
|
-
* const tree = parseMarkdown("## Version 1.0.0\n\nInitial release.");
|
|
44
|
-
* // tree.type === "root"
|
|
45
|
-
* // tree.children[0].type === "heading"
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
50
|
-
function parseMarkdown(content) {
|
|
51
|
-
return createRemarkProcessor().parse(content);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Stringify an MDAST AST back to a markdown string synchronously.
|
|
55
|
-
*
|
|
56
|
-
* @remarks
|
|
57
|
-
* Uses {@link createRemarkProcessor} internally. GFM constructs
|
|
58
|
-
* (tables, etc.) are serialized correctly thanks to the remark-gfm plugin.
|
|
59
|
-
*
|
|
60
|
-
* @param tree - The MDAST root node
|
|
61
|
-
* @returns The serialized markdown string
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { parseMarkdown, stringifyMarkdown } from "../utils/remark-pipeline.js";
|
|
66
|
-
*
|
|
67
|
-
* const tree = parseMarkdown("# Hello\n\nWorld.");
|
|
68
|
-
* const md = stringifyMarkdown(tree);
|
|
69
|
-
* // "# Hello\n\nWorld.\n"
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @internal
|
|
73
|
-
*/
|
|
74
|
-
function stringifyMarkdown(tree) {
|
|
75
|
-
return createRemarkProcessor().stringify(tree);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
export { createRemarkProcessor, parseMarkdown, stringifyMarkdown };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const require_index = require('../categories/index.cjs');
|
|
2
|
-
const require_index$1 = require('../../../../../../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.cjs');
|
|
3
|
-
const require_remark_pipeline = require('./remark-pipeline.cjs');
|
|
4
|
-
|
|
5
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/section-parser.js
|
|
6
|
-
/**
|
|
7
|
-
* Parse a changeset summary into structured sections.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* The algorithm works in three steps:
|
|
11
|
-
* 1. Parse the summary markdown into an MDAST tree via {@link parseMarkdown}
|
|
12
|
-
* 2. Scan `tree.children` for h2 (`depth === 2`) headings, recording their
|
|
13
|
-
* indices
|
|
14
|
-
* 3. For each h2, extract the heading text, resolve it to a
|
|
15
|
-
* {@link SectionCategory} via `fromHeading()`, and collect all nodes
|
|
16
|
-
* between this h2 and the next h2 (or end of document) as the section
|
|
17
|
-
* content
|
|
18
|
-
*
|
|
19
|
-
* If the summary contains h2 (`##`) headings, they are mapped to categories
|
|
20
|
-
* via `fromHeading()`. Content between headings becomes the section content.
|
|
21
|
-
* Content before the first h2 becomes the preamble.
|
|
22
|
-
*
|
|
23
|
-
* If no h2 headings are present, the entire content is returned as the preamble
|
|
24
|
-
* with an empty sections array (backward-compatible flat-text mode).
|
|
25
|
-
*
|
|
26
|
-
* Unknown headings (those not recognized by `fromHeading()`) are silently
|
|
27
|
-
* skipped; validation of heading names is the responsibility of Layer 1
|
|
28
|
-
* (remark-lint).
|
|
29
|
-
*
|
|
30
|
-
* @param summary - The changeset summary markdown
|
|
31
|
-
* @returns Parsed sections and optional preamble
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { parseChangesetSections } from "../utils/section-parser.js";
|
|
36
|
-
*
|
|
37
|
-
* const result = parseChangesetSections("## Features\n\n- New API\n\n## Bug Fixes\n\n- Fixed crash");
|
|
38
|
-
* // result.sections.length === 2
|
|
39
|
-
* // result.sections[0].category === "Features"
|
|
40
|
-
* // result.preamble === undefined
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
function parseChangesetSections(summary) {
|
|
46
|
-
const tree = require_remark_pipeline.parseMarkdown(summary);
|
|
47
|
-
const h2Indices = [];
|
|
48
|
-
for (let i = 0; i < tree.children.length; i++) {
|
|
49
|
-
const node = tree.children[i];
|
|
50
|
-
if (node.type === "heading" && node.depth === 2) h2Indices.push(i);
|
|
51
|
-
}
|
|
52
|
-
if (h2Indices.length === 0) return {
|
|
53
|
-
preamble: summary.trim(),
|
|
54
|
-
sections: []
|
|
55
|
-
};
|
|
56
|
-
const result = { sections: [] };
|
|
57
|
-
if (h2Indices[0] > 0) result.preamble = stringifyAstSlice(tree.children.slice(0, h2Indices[0]));
|
|
58
|
-
for (let i = 0; i < h2Indices.length; i++) {
|
|
59
|
-
const headingIndex = h2Indices[i];
|
|
60
|
-
const headingNode = tree.children[headingIndex];
|
|
61
|
-
const headingText = require_index$1.toString(headingNode);
|
|
62
|
-
const nextIndex = i + 1 < h2Indices.length ? h2Indices[i + 1] : tree.children.length;
|
|
63
|
-
const content = stringifyAstSlice(tree.children.slice(headingIndex + 1, nextIndex));
|
|
64
|
-
const category = require_index.fromHeading(headingText);
|
|
65
|
-
if (category) result.sections.push({
|
|
66
|
-
category,
|
|
67
|
-
heading: headingText,
|
|
68
|
-
content
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Stringify a slice of MDAST nodes back to markdown.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* Wraps the nodes in a synthetic root node and delegates to
|
|
78
|
-
* {@link stringifyMarkdown}. Returns an empty string for empty slices.
|
|
79
|
-
*
|
|
80
|
-
* @param nodes - Array of MDAST content nodes
|
|
81
|
-
* @returns Trimmed markdown string, or empty string if no nodes
|
|
82
|
-
*
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
function stringifyAstSlice(nodes) {
|
|
86
|
-
if (nodes.length === 0) return "";
|
|
87
|
-
return require_remark_pipeline.stringifyMarkdown({
|
|
88
|
-
type: "root",
|
|
89
|
-
children: nodes
|
|
90
|
-
}).trim();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
exports.parseChangesetSections = parseChangesetSections;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { fromHeading } from "../categories/index.js";
|
|
2
|
-
import { toString } from "../../../../../../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js";
|
|
3
|
-
import { parseMarkdown, stringifyMarkdown } from "./remark-pipeline.js";
|
|
4
|
-
|
|
5
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/section-parser.js
|
|
6
|
-
/**
|
|
7
|
-
* Parse a changeset summary into structured sections.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* The algorithm works in three steps:
|
|
11
|
-
* 1. Parse the summary markdown into an MDAST tree via {@link parseMarkdown}
|
|
12
|
-
* 2. Scan `tree.children` for h2 (`depth === 2`) headings, recording their
|
|
13
|
-
* indices
|
|
14
|
-
* 3. For each h2, extract the heading text, resolve it to a
|
|
15
|
-
* {@link SectionCategory} via `fromHeading()`, and collect all nodes
|
|
16
|
-
* between this h2 and the next h2 (or end of document) as the section
|
|
17
|
-
* content
|
|
18
|
-
*
|
|
19
|
-
* If the summary contains h2 (`##`) headings, they are mapped to categories
|
|
20
|
-
* via `fromHeading()`. Content between headings becomes the section content.
|
|
21
|
-
* Content before the first h2 becomes the preamble.
|
|
22
|
-
*
|
|
23
|
-
* If no h2 headings are present, the entire content is returned as the preamble
|
|
24
|
-
* with an empty sections array (backward-compatible flat-text mode).
|
|
25
|
-
*
|
|
26
|
-
* Unknown headings (those not recognized by `fromHeading()`) are silently
|
|
27
|
-
* skipped; validation of heading names is the responsibility of Layer 1
|
|
28
|
-
* (remark-lint).
|
|
29
|
-
*
|
|
30
|
-
* @param summary - The changeset summary markdown
|
|
31
|
-
* @returns Parsed sections and optional preamble
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* import { parseChangesetSections } from "../utils/section-parser.js";
|
|
36
|
-
*
|
|
37
|
-
* const result = parseChangesetSections("## Features\n\n- New API\n\n## Bug Fixes\n\n- Fixed crash");
|
|
38
|
-
* // result.sections.length === 2
|
|
39
|
-
* // result.sections[0].category === "Features"
|
|
40
|
-
* // result.preamble === undefined
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
function parseChangesetSections(summary) {
|
|
46
|
-
const tree = parseMarkdown(summary);
|
|
47
|
-
const h2Indices = [];
|
|
48
|
-
for (let i = 0; i < tree.children.length; i++) {
|
|
49
|
-
const node = tree.children[i];
|
|
50
|
-
if (node.type === "heading" && node.depth === 2) h2Indices.push(i);
|
|
51
|
-
}
|
|
52
|
-
if (h2Indices.length === 0) return {
|
|
53
|
-
preamble: summary.trim(),
|
|
54
|
-
sections: []
|
|
55
|
-
};
|
|
56
|
-
const result = { sections: [] };
|
|
57
|
-
if (h2Indices[0] > 0) result.preamble = stringifyAstSlice(tree.children.slice(0, h2Indices[0]));
|
|
58
|
-
for (let i = 0; i < h2Indices.length; i++) {
|
|
59
|
-
const headingIndex = h2Indices[i];
|
|
60
|
-
const headingNode = tree.children[headingIndex];
|
|
61
|
-
const headingText = toString(headingNode);
|
|
62
|
-
const nextIndex = i + 1 < h2Indices.length ? h2Indices[i + 1] : tree.children.length;
|
|
63
|
-
const content = stringifyAstSlice(tree.children.slice(headingIndex + 1, nextIndex));
|
|
64
|
-
const category = fromHeading(headingText);
|
|
65
|
-
if (category) result.sections.push({
|
|
66
|
-
category,
|
|
67
|
-
heading: headingText,
|
|
68
|
-
content
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Stringify a slice of MDAST nodes back to markdown.
|
|
75
|
-
*
|
|
76
|
-
* @remarks
|
|
77
|
-
* Wraps the nodes in a synthetic root node and delegates to
|
|
78
|
-
* {@link stringifyMarkdown}. Returns an empty string for empty slices.
|
|
79
|
-
*
|
|
80
|
-
* @param nodes - Array of MDAST content nodes
|
|
81
|
-
* @returns Trimmed markdown string, or empty string if no nodes
|
|
82
|
-
*
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
function stringifyAstSlice(nodes) {
|
|
86
|
-
if (nodes.length === 0) return "";
|
|
87
|
-
return stringifyMarkdown({
|
|
88
|
-
type: "root",
|
|
89
|
-
children: nodes
|
|
90
|
-
}).trim();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
export { parseChangesetSections };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/strip-frontmatter.js
|
|
3
|
-
/**
|
|
4
|
-
* Utility for stripping YAML frontmatter from changeset files.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Changeset `.md` files produced by `\@changesets/cli` contain YAML
|
|
8
|
-
* frontmatter (delimited by `---`) specifying which packages are
|
|
9
|
-
* affected and their version bump types. This frontmatter must be
|
|
10
|
-
* removed before remark-lint processing, as remark-parse does not
|
|
11
|
-
* handle YAML frontmatter natively without `remark-frontmatter`.
|
|
12
|
-
*
|
|
13
|
-
* The regex used is non-greedy (`[\s\S]*?`) to match only the first
|
|
14
|
-
* frontmatter block and avoid stripping content after a second `---`
|
|
15
|
-
* delimiter that might appear in the document body.
|
|
16
|
-
*
|
|
17
|
-
* @see {@link ChangesetLinter} for the public API that uses frontmatter
|
|
18
|
-
* stripping during changeset validation
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Strip leading YAML frontmatter from a markdown string.
|
|
24
|
-
*
|
|
25
|
-
* Removes the `---\n...\n---\n` block at the start of the content.
|
|
26
|
-
* If no frontmatter is present, the content is returned as-is.
|
|
27
|
-
*
|
|
28
|
-
* @param content - Raw markdown string potentially containing frontmatter
|
|
29
|
-
* @returns The markdown content with frontmatter removed
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* import { stripFrontmatter } from "../utils/strip-frontmatter.js";
|
|
34
|
-
*
|
|
35
|
-
* const raw = "---\n\"pkg\": minor\n---\n\n## Features\n\n- New API";
|
|
36
|
-
* const body = stripFrontmatter(raw);
|
|
37
|
-
* // "\n## Features\n\n- New API"
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
function stripFrontmatter(content) {
|
|
43
|
-
return content.replace(/^---\n[\s\S]*?\n---\n?/, "");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
//#endregion
|
|
47
|
-
exports.stripFrontmatter = stripFrontmatter;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/strip-frontmatter.js
|
|
2
|
-
/**
|
|
3
|
-
* Utility for stripping YAML frontmatter from changeset files.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Changeset `.md` files produced by `\@changesets/cli` contain YAML
|
|
7
|
-
* frontmatter (delimited by `---`) specifying which packages are
|
|
8
|
-
* affected and their version bump types. This frontmatter must be
|
|
9
|
-
* removed before remark-lint processing, as remark-parse does not
|
|
10
|
-
* handle YAML frontmatter natively without `remark-frontmatter`.
|
|
11
|
-
*
|
|
12
|
-
* The regex used is non-greedy (`[\s\S]*?`) to match only the first
|
|
13
|
-
* frontmatter block and avoid stripping content after a second `---`
|
|
14
|
-
* delimiter that might appear in the document body.
|
|
15
|
-
*
|
|
16
|
-
* @see {@link ChangesetLinter} for the public API that uses frontmatter
|
|
17
|
-
* stripping during changeset validation
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Strip leading YAML frontmatter from a markdown string.
|
|
23
|
-
*
|
|
24
|
-
* Removes the `---\n...\n---\n` block at the start of the content.
|
|
25
|
-
* If no frontmatter is present, the content is returned as-is.
|
|
26
|
-
*
|
|
27
|
-
* @param content - Raw markdown string potentially containing frontmatter
|
|
28
|
-
* @returns The markdown content with frontmatter removed
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* import { stripFrontmatter } from "../utils/strip-frontmatter.js";
|
|
33
|
-
*
|
|
34
|
-
* const raw = "---\n\"pkg\": minor\n---\n\n## Features\n\n- New API";
|
|
35
|
-
* const body = stripFrontmatter(raw);
|
|
36
|
-
* // "\n## Features\n\n- New API"
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
function stripFrontmatter(content) {
|
|
42
|
-
return content.replace(/^---\n[\s\S]*?\n---\n?/, "");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { stripFrontmatter };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const require_index = require('../../../../../../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/version-blocks.js
|
|
4
|
-
/**
|
|
5
|
-
* Extract all version blocks from a CHANGELOG AST.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Scans `tree.children` linearly for h2-level headings. Each h2 starts
|
|
9
|
-
* a new version block whose content extends to the next h2 or the end
|
|
10
|
-
* of the document. The `endIndex` of each block is adjusted in a second
|
|
11
|
-
* pass to stop at the next block's `headingIndex`.
|
|
12
|
-
*
|
|
13
|
-
* h1 headings (typically the package name) are ignored and do not
|
|
14
|
-
* create version blocks.
|
|
15
|
-
*
|
|
16
|
-
* @param tree - The MDAST root node of a CHANGELOG document
|
|
17
|
-
* @returns Array of version blocks in document order
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { getVersionBlocks } from "../utils/version-blocks.js";
|
|
22
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
23
|
-
*
|
|
24
|
-
* const tree = parseMarkdown("# my-pkg\n\n## 1.1.0\n\nChanges.\n\n## 1.0.0\n\nInitial.");
|
|
25
|
-
* const blocks = getVersionBlocks(tree);
|
|
26
|
-
* // blocks.length === 2
|
|
27
|
-
* // blocks[0] covers "## 1.1.0" section
|
|
28
|
-
* // blocks[1] covers "## 1.0.0" section
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
function getVersionBlocks(tree) {
|
|
34
|
-
const blocks = [];
|
|
35
|
-
for (let i = 0; i < tree.children.length; i++) {
|
|
36
|
-
const node = tree.children[i];
|
|
37
|
-
if (node.type === "heading" && node.depth === 2) blocks.push({
|
|
38
|
-
headingIndex: i,
|
|
39
|
-
startIndex: i + 1,
|
|
40
|
-
endIndex: tree.children.length
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
for (let i = 0; i < blocks.length - 1; i++) blocks[i].endIndex = blocks[i + 1].headingIndex;
|
|
44
|
-
return blocks;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Extract h3 sections within a version block.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Iterates over the children of the given version block (from
|
|
51
|
-
* `block.startIndex` to `block.endIndex`). Each h3 heading starts
|
|
52
|
-
* a new section, and subsequent non-heading nodes are collected
|
|
53
|
-
* into that section's `contentNodes` array until the next h3 or
|
|
54
|
-
* the end of the block.
|
|
55
|
-
*
|
|
56
|
-
* Nodes before the first h3 within the block (e.g., a version
|
|
57
|
-
* summary paragraph) are not included in any section.
|
|
58
|
-
*
|
|
59
|
-
* @param tree - The MDAST root node of a CHANGELOG document
|
|
60
|
-
* @param block - The version block to extract sections from
|
|
61
|
-
* @returns Array of sections in document order
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { getVersionBlocks, getBlockSections } from "../utils/version-blocks.js";
|
|
66
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
67
|
-
*
|
|
68
|
-
* const tree = parseMarkdown("## 1.0.0\n\n### Features\n\n- New API\n\n### Bug Fixes\n\n- Fixed crash");
|
|
69
|
-
* const blocks = getVersionBlocks(tree);
|
|
70
|
-
* const sections = getBlockSections(tree, blocks[0]);
|
|
71
|
-
* // sections.length === 2
|
|
72
|
-
* // sections[0].heading text === "Features"
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
function getBlockSections(tree, block) {
|
|
78
|
-
const sections = [];
|
|
79
|
-
for (let i = block.startIndex; i < block.endIndex; i++) {
|
|
80
|
-
const node = tree.children[i];
|
|
81
|
-
if (node.type === "heading" && node.depth === 3) sections.push({
|
|
82
|
-
heading: node,
|
|
83
|
-
headingIndex: i,
|
|
84
|
-
contentNodes: []
|
|
85
|
-
});
|
|
86
|
-
else if (sections.length > 0) sections[sections.length - 1].contentNodes.push(node);
|
|
87
|
-
}
|
|
88
|
-
return sections;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get the plain text content of a heading node.
|
|
92
|
-
*
|
|
93
|
-
* @remarks
|
|
94
|
-
* Delegates to `mdast-util-to-string` to extract concatenated text
|
|
95
|
-
* from all inline children of the heading (handling bold, italic,
|
|
96
|
-
* code spans, etc.).
|
|
97
|
-
*
|
|
98
|
-
* @param heading - The MDAST heading node
|
|
99
|
-
* @returns The heading text content as a plain string
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
function getHeadingText(heading) {
|
|
104
|
-
return require_index.toString(heading);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
exports.getBlockSections = getBlockSections;
|
|
109
|
-
exports.getHeadingText = getHeadingText;
|
|
110
|
-
exports.getVersionBlocks = getVersionBlocks;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { toString } from "../../../../../../../node_modules/.pnpm/mdast-util-to-string@4.0.0/node_modules/mdast-util-to-string/lib/index.js";
|
|
2
|
-
|
|
3
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/utils/version-blocks.js
|
|
4
|
-
/**
|
|
5
|
-
* Extract all version blocks from a CHANGELOG AST.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Scans `tree.children` linearly for h2-level headings. Each h2 starts
|
|
9
|
-
* a new version block whose content extends to the next h2 or the end
|
|
10
|
-
* of the document. The `endIndex` of each block is adjusted in a second
|
|
11
|
-
* pass to stop at the next block's `headingIndex`.
|
|
12
|
-
*
|
|
13
|
-
* h1 headings (typically the package name) are ignored and do not
|
|
14
|
-
* create version blocks.
|
|
15
|
-
*
|
|
16
|
-
* @param tree - The MDAST root node of a CHANGELOG document
|
|
17
|
-
* @returns Array of version blocks in document order
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* import { getVersionBlocks } from "../utils/version-blocks.js";
|
|
22
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
23
|
-
*
|
|
24
|
-
* const tree = parseMarkdown("# my-pkg\n\n## 1.1.0\n\nChanges.\n\n## 1.0.0\n\nInitial.");
|
|
25
|
-
* const blocks = getVersionBlocks(tree);
|
|
26
|
-
* // blocks.length === 2
|
|
27
|
-
* // blocks[0] covers "## 1.1.0" section
|
|
28
|
-
* // blocks[1] covers "## 1.0.0" section
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
function getVersionBlocks(tree) {
|
|
34
|
-
const blocks = [];
|
|
35
|
-
for (let i = 0; i < tree.children.length; i++) {
|
|
36
|
-
const node = tree.children[i];
|
|
37
|
-
if (node.type === "heading" && node.depth === 2) blocks.push({
|
|
38
|
-
headingIndex: i,
|
|
39
|
-
startIndex: i + 1,
|
|
40
|
-
endIndex: tree.children.length
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
for (let i = 0; i < blocks.length - 1; i++) blocks[i].endIndex = blocks[i + 1].headingIndex;
|
|
44
|
-
return blocks;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Extract h3 sections within a version block.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* Iterates over the children of the given version block (from
|
|
51
|
-
* `block.startIndex` to `block.endIndex`). Each h3 heading starts
|
|
52
|
-
* a new section, and subsequent non-heading nodes are collected
|
|
53
|
-
* into that section's `contentNodes` array until the next h3 or
|
|
54
|
-
* the end of the block.
|
|
55
|
-
*
|
|
56
|
-
* Nodes before the first h3 within the block (e.g., a version
|
|
57
|
-
* summary paragraph) are not included in any section.
|
|
58
|
-
*
|
|
59
|
-
* @param tree - The MDAST root node of a CHANGELOG document
|
|
60
|
-
* @param block - The version block to extract sections from
|
|
61
|
-
* @returns Array of sections in document order
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { getVersionBlocks, getBlockSections } from "../utils/version-blocks.js";
|
|
66
|
-
* import { parseMarkdown } from "../utils/remark-pipeline.js";
|
|
67
|
-
*
|
|
68
|
-
* const tree = parseMarkdown("## 1.0.0\n\n### Features\n\n- New API\n\n### Bug Fixes\n\n- Fixed crash");
|
|
69
|
-
* const blocks = getVersionBlocks(tree);
|
|
70
|
-
* const sections = getBlockSections(tree, blocks[0]);
|
|
71
|
-
* // sections.length === 2
|
|
72
|
-
* // sections[0].heading text === "Features"
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @internal
|
|
76
|
-
*/
|
|
77
|
-
function getBlockSections(tree, block) {
|
|
78
|
-
const sections = [];
|
|
79
|
-
for (let i = block.startIndex; i < block.endIndex; i++) {
|
|
80
|
-
const node = tree.children[i];
|
|
81
|
-
if (node.type === "heading" && node.depth === 3) sections.push({
|
|
82
|
-
heading: node,
|
|
83
|
-
headingIndex: i,
|
|
84
|
-
contentNodes: []
|
|
85
|
-
});
|
|
86
|
-
else if (sections.length > 0) sections[sections.length - 1].contentNodes.push(node);
|
|
87
|
-
}
|
|
88
|
-
return sections;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get the plain text content of a heading node.
|
|
92
|
-
*
|
|
93
|
-
* @remarks
|
|
94
|
-
* Delegates to `mdast-util-to-string` to extract concatenated text
|
|
95
|
-
* from all inline children of the heading (handling bold, italic,
|
|
96
|
-
* code spans, etc.).
|
|
97
|
-
*
|
|
98
|
-
* @param heading - The MDAST heading node
|
|
99
|
-
* @returns The heading text content as a plain string
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
function getHeadingText(heading) {
|
|
104
|
-
return toString(heading);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
export { getBlockSections, getHeadingText, getVersionBlocks };
|