@savvy-web/silk 1.3.11 → 2.1.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 +7 -5
- package/changesets-changelog.cjs +39298 -96760
- package/changesets-changelog.d.cts +24 -14
- package/changesets-changelog.d.ts +24 -14
- package/changesets-changelog.js +54057 -1
- package/changesets-markdownlint.cjs +39295 -96757
- package/changesets-markdownlint.d.cts +24 -14
- package/changesets-markdownlint.d.ts +24 -14
- package/changesets-markdownlint.js +54057 -1
- package/package.json +6 -5
- 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 -338
- package/packages/silk-effects/dist/dev/pkg/changesets/services/release-planner.js +0 -334
- 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 -55
- package/packages/silk-effects/dist/dev/pkg/changesets/vendor/github-info.js +0 -55
- 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,170 +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
|
-
const require_content_structure = require('../remark/rules/content-structure.cjs');
|
|
6
|
-
const require_dependency_table_format = require('../remark/rules/dependency-table-format.cjs');
|
|
7
|
-
const require_heading_hierarchy = require('../remark/rules/heading-hierarchy.cjs');
|
|
8
|
-
const require_required_sections = require('../remark/rules/required-sections.cjs');
|
|
9
|
-
const require_uncategorized_content = require('../remark/rules/uncategorized-content.cjs');
|
|
10
|
-
const require_strip_frontmatter = require('../utils/strip-frontmatter.cjs');
|
|
11
|
-
let node_path = require("node:path");
|
|
12
|
-
let node_fs = require("node:fs");
|
|
13
|
-
|
|
14
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/api/linter.js
|
|
15
|
-
/**
|
|
16
|
-
* Class-based API wrapper for changeset linting.
|
|
17
|
-
*
|
|
18
|
-
* Provides a static class interface that runs all five remark-lint rules
|
|
19
|
-
* against changeset markdown files and returns structured diagnostics.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Static class for linting changeset markdown files.
|
|
25
|
-
*
|
|
26
|
-
* Runs the five remark-lint rules (heading-hierarchy, required-sections,
|
|
27
|
-
* content-structure, dependency-table-format, uncategorized-content) against
|
|
28
|
-
* changeset markdown and returns structured {@link LintMessage} diagnostics.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* This class implements the pre-validation layer of the three-layer
|
|
32
|
-
* pipeline. It validates that changeset markdown conforms to the
|
|
33
|
-
* expected structure before the changelog formatter processes it.
|
|
34
|
-
*
|
|
35
|
-
* YAML frontmatter (the `---` delimited block at the top of changeset
|
|
36
|
-
* files containing package bump declarations) is automatically stripped
|
|
37
|
-
* before validation, since frontmatter is managed by Changesets itself
|
|
38
|
-
* and is not part of the markdown structure being validated.
|
|
39
|
-
*
|
|
40
|
-
* The class provides three granularity levels:
|
|
41
|
-
*
|
|
42
|
-
* - {@link ChangesetLinter.validateContent} -- validate a markdown string directly
|
|
43
|
-
* - {@link ChangesetLinter.validateFile} -- validate a single file by path
|
|
44
|
-
* - {@link ChangesetLinter.validate} -- validate all changeset files in a directory
|
|
45
|
-
*
|
|
46
|
-
* @example Validate a single file and report errors
|
|
47
|
-
* ```typescript
|
|
48
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
49
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
50
|
-
*
|
|
51
|
-
* const messages: LintMessage[] = ChangesetLinter.validateFile(
|
|
52
|
-
* ".changeset/brave-pandas-learn.md",
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* if (messages.length > 0) {
|
|
56
|
-
* for (const msg of messages) {
|
|
57
|
-
* console.error(`${msg.file}:${msg.line}:${msg.column} [${msg.rule}] ${msg.message}`);
|
|
58
|
-
* }
|
|
59
|
-
* process.exitCode = 1;
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @example Validate all changesets in a directory
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
66
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
67
|
-
*
|
|
68
|
-
* const allMessages: LintMessage[] = ChangesetLinter.validate(".changeset");
|
|
69
|
-
*
|
|
70
|
-
* const errorsByFile = new Map<string, LintMessage[]>();
|
|
71
|
-
* for (const msg of allMessages) {
|
|
72
|
-
* const existing = errorsByFile.get(msg.file) ?? [];
|
|
73
|
-
* existing.push(msg);
|
|
74
|
-
* errorsByFile.set(msg.file, existing);
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* for (const [file, msgs] of errorsByFile) {
|
|
78
|
-
* console.error(`${file}: ${msgs.length} issue(s)`);
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example Validate markdown content directly (useful in tests)
|
|
83
|
-
* ```typescript
|
|
84
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
85
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
86
|
-
*
|
|
87
|
-
* const content = [
|
|
88
|
-
* "---",
|
|
89
|
-
* '"\@savvy-web/core": patch',
|
|
90
|
-
* "---",
|
|
91
|
-
* "",
|
|
92
|
-
* "## Bug Fixes",
|
|
93
|
-
* "",
|
|
94
|
-
* "Fixed an edge case in token validation.",
|
|
95
|
-
* ].join("\n");
|
|
96
|
-
*
|
|
97
|
-
* const messages: LintMessage[] = ChangesetLinter.validateContent(content);
|
|
98
|
-
* // messages.length === 0 (valid changeset)
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* @see {@link LintMessage} for the diagnostic message shape
|
|
102
|
-
* @see {@link Categories} for the valid section headings checked by the rules
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
|
-
var ChangesetLinter = class ChangesetLinter {
|
|
107
|
-
/* v8 ignore next -- private constructor prevents direct instantiation */
|
|
108
|
-
constructor() {}
|
|
109
|
-
/**
|
|
110
|
-
* Validate a single changeset file by path.
|
|
111
|
-
*
|
|
112
|
-
* @remarks
|
|
113
|
-
* Reads the file synchronously, strips YAML frontmatter, and runs all
|
|
114
|
-
* five lint rules. The file path is preserved in each returned
|
|
115
|
-
* {@link LintMessage} for error reporting.
|
|
116
|
-
*
|
|
117
|
-
* @param filePath - Absolute or relative path to the changeset `.md` file
|
|
118
|
-
* @returns Array of {@link LintMessage} diagnostics (empty if the file is valid)
|
|
119
|
-
*/
|
|
120
|
-
static validateFile(filePath) {
|
|
121
|
-
const raw = (0, node_fs.readFileSync)(filePath, "utf-8");
|
|
122
|
-
return ChangesetLinter.validateContent(raw, filePath);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validate a markdown string directly.
|
|
126
|
-
*
|
|
127
|
-
* @remarks
|
|
128
|
-
* Strips YAML frontmatter (if present) and runs all five lint rules
|
|
129
|
-
* against the remaining content. This method is useful for validating
|
|
130
|
-
* changeset content that is already in memory, such as in test suites
|
|
131
|
-
* or editor integrations.
|
|
132
|
-
*
|
|
133
|
-
* @param content - Raw markdown content (may include YAML frontmatter)
|
|
134
|
-
* @param filePath - File path for error reporting; defaults to `"<input>"`
|
|
135
|
-
* when validating in-memory content
|
|
136
|
-
* @returns Array of {@link LintMessage} diagnostics (empty if the content is valid)
|
|
137
|
-
*/
|
|
138
|
-
static validateContent(content, filePath = "<input>") {
|
|
139
|
-
const body = require_strip_frontmatter.stripFrontmatter(content);
|
|
140
|
-
return require_index$3.unified().use(require_index$1.default).use(require_index.default).use(require_index$2.default).use(require_heading_hierarchy.HeadingHierarchyRule).use(require_required_sections.RequiredSectionsRule).use(require_content_structure.ContentStructureRule).use(require_dependency_table_format.DependencyTableFormatRule).use(require_uncategorized_content.UncategorizedContentRule).processSync(body).messages.map((msg) => ({
|
|
141
|
-
file: filePath,
|
|
142
|
-
/* v8 ignore next 3 -- ruleId/line/column fallbacks; remark-lint always provides these */
|
|
143
|
-
rule: msg.ruleId ?? msg.source ?? "unknown",
|
|
144
|
-
line: msg.line ?? 1,
|
|
145
|
-
column: msg.column ?? 1,
|
|
146
|
-
message: msg.message
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Validate all changeset `.md` files in a directory.
|
|
151
|
-
*
|
|
152
|
-
* @remarks
|
|
153
|
-
* Scans the directory for `*.md` files (excluding `README.md`) and runs
|
|
154
|
-
* {@link ChangesetLinter.validateFile} on each. Results are aggregated
|
|
155
|
-
* into a single array. The directory is read synchronously.
|
|
156
|
-
*
|
|
157
|
-
* This is the method used by the Effect CLI's `lint` and `check`
|
|
158
|
-
* subcommands to validate the `.changeset/` directory.
|
|
159
|
-
*
|
|
160
|
-
* @param dir - Path to the directory containing changeset files
|
|
161
|
-
* (typically `.changeset/`)
|
|
162
|
-
* @returns Aggregated array of {@link LintMessage} diagnostics from all files
|
|
163
|
-
*/
|
|
164
|
-
static validate(dir) {
|
|
165
|
-
return (0, node_fs.readdirSync)(dir).filter((f) => f.endsWith(".md") && f !== "README.md").flatMap((filename) => ChangesetLinter.validateFile((0, node_path.join)(dir, filename)));
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
exports.ChangesetLinter = ChangesetLinter;
|
|
@@ -1,170 +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
|
-
import { ContentStructureRule } from "../remark/rules/content-structure.js";
|
|
6
|
-
import { DependencyTableFormatRule } from "../remark/rules/dependency-table-format.js";
|
|
7
|
-
import { HeadingHierarchyRule } from "../remark/rules/heading-hierarchy.js";
|
|
8
|
-
import { RequiredSectionsRule } from "../remark/rules/required-sections.js";
|
|
9
|
-
import { UncategorizedContentRule } from "../remark/rules/uncategorized-content.js";
|
|
10
|
-
import { stripFrontmatter } from "../utils/strip-frontmatter.js";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
13
|
-
|
|
14
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/api/linter.js
|
|
15
|
-
/**
|
|
16
|
-
* Class-based API wrapper for changeset linting.
|
|
17
|
-
*
|
|
18
|
-
* Provides a static class interface that runs all five remark-lint rules
|
|
19
|
-
* against changeset markdown files and returns structured diagnostics.
|
|
20
|
-
*
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Static class for linting changeset markdown files.
|
|
25
|
-
*
|
|
26
|
-
* Runs the five remark-lint rules (heading-hierarchy, required-sections,
|
|
27
|
-
* content-structure, dependency-table-format, uncategorized-content) against
|
|
28
|
-
* changeset markdown and returns structured {@link LintMessage} diagnostics.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* This class implements the pre-validation layer of the three-layer
|
|
32
|
-
* pipeline. It validates that changeset markdown conforms to the
|
|
33
|
-
* expected structure before the changelog formatter processes it.
|
|
34
|
-
*
|
|
35
|
-
* YAML frontmatter (the `---` delimited block at the top of changeset
|
|
36
|
-
* files containing package bump declarations) is automatically stripped
|
|
37
|
-
* before validation, since frontmatter is managed by Changesets itself
|
|
38
|
-
* and is not part of the markdown structure being validated.
|
|
39
|
-
*
|
|
40
|
-
* The class provides three granularity levels:
|
|
41
|
-
*
|
|
42
|
-
* - {@link ChangesetLinter.validateContent} -- validate a markdown string directly
|
|
43
|
-
* - {@link ChangesetLinter.validateFile} -- validate a single file by path
|
|
44
|
-
* - {@link ChangesetLinter.validate} -- validate all changeset files in a directory
|
|
45
|
-
*
|
|
46
|
-
* @example Validate a single file and report errors
|
|
47
|
-
* ```typescript
|
|
48
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
49
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
50
|
-
*
|
|
51
|
-
* const messages: LintMessage[] = ChangesetLinter.validateFile(
|
|
52
|
-
* ".changeset/brave-pandas-learn.md",
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* if (messages.length > 0) {
|
|
56
|
-
* for (const msg of messages) {
|
|
57
|
-
* console.error(`${msg.file}:${msg.line}:${msg.column} [${msg.rule}] ${msg.message}`);
|
|
58
|
-
* }
|
|
59
|
-
* process.exitCode = 1;
|
|
60
|
-
* }
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @example Validate all changesets in a directory
|
|
64
|
-
* ```typescript
|
|
65
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
66
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
67
|
-
*
|
|
68
|
-
* const allMessages: LintMessage[] = ChangesetLinter.validate(".changeset");
|
|
69
|
-
*
|
|
70
|
-
* const errorsByFile = new Map<string, LintMessage[]>();
|
|
71
|
-
* for (const msg of allMessages) {
|
|
72
|
-
* const existing = errorsByFile.get(msg.file) ?? [];
|
|
73
|
-
* existing.push(msg);
|
|
74
|
-
* errorsByFile.set(msg.file, existing);
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* for (const [file, msgs] of errorsByFile) {
|
|
78
|
-
* console.error(`${file}: ${msgs.length} issue(s)`);
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example Validate markdown content directly (useful in tests)
|
|
83
|
-
* ```typescript
|
|
84
|
-
* import { ChangesetLinter } from "\@savvy-web/changesets";
|
|
85
|
-
* import type { LintMessage } from "\@savvy-web/changesets";
|
|
86
|
-
*
|
|
87
|
-
* const content = [
|
|
88
|
-
* "---",
|
|
89
|
-
* '"\@savvy-web/core": patch',
|
|
90
|
-
* "---",
|
|
91
|
-
* "",
|
|
92
|
-
* "## Bug Fixes",
|
|
93
|
-
* "",
|
|
94
|
-
* "Fixed an edge case in token validation.",
|
|
95
|
-
* ].join("\n");
|
|
96
|
-
*
|
|
97
|
-
* const messages: LintMessage[] = ChangesetLinter.validateContent(content);
|
|
98
|
-
* // messages.length === 0 (valid changeset)
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* @see {@link LintMessage} for the diagnostic message shape
|
|
102
|
-
* @see {@link Categories} for the valid section headings checked by the rules
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
|
-
var ChangesetLinter = class ChangesetLinter {
|
|
107
|
-
/* v8 ignore next -- private constructor prevents direct instantiation */
|
|
108
|
-
constructor() {}
|
|
109
|
-
/**
|
|
110
|
-
* Validate a single changeset file by path.
|
|
111
|
-
*
|
|
112
|
-
* @remarks
|
|
113
|
-
* Reads the file synchronously, strips YAML frontmatter, and runs all
|
|
114
|
-
* five lint rules. The file path is preserved in each returned
|
|
115
|
-
* {@link LintMessage} for error reporting.
|
|
116
|
-
*
|
|
117
|
-
* @param filePath - Absolute or relative path to the changeset `.md` file
|
|
118
|
-
* @returns Array of {@link LintMessage} diagnostics (empty if the file is valid)
|
|
119
|
-
*/
|
|
120
|
-
static validateFile(filePath) {
|
|
121
|
-
const raw = readFileSync(filePath, "utf-8");
|
|
122
|
-
return ChangesetLinter.validateContent(raw, filePath);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Validate a markdown string directly.
|
|
126
|
-
*
|
|
127
|
-
* @remarks
|
|
128
|
-
* Strips YAML frontmatter (if present) and runs all five lint rules
|
|
129
|
-
* against the remaining content. This method is useful for validating
|
|
130
|
-
* changeset content that is already in memory, such as in test suites
|
|
131
|
-
* or editor integrations.
|
|
132
|
-
*
|
|
133
|
-
* @param content - Raw markdown content (may include YAML frontmatter)
|
|
134
|
-
* @param filePath - File path for error reporting; defaults to `"<input>"`
|
|
135
|
-
* when validating in-memory content
|
|
136
|
-
* @returns Array of {@link LintMessage} diagnostics (empty if the content is valid)
|
|
137
|
-
*/
|
|
138
|
-
static validateContent(content, filePath = "<input>") {
|
|
139
|
-
const body = stripFrontmatter(content);
|
|
140
|
-
return unified().use(remarkParse).use(remarkGfm).use(remarkStringify).use(HeadingHierarchyRule).use(RequiredSectionsRule).use(ContentStructureRule).use(DependencyTableFormatRule).use(UncategorizedContentRule).processSync(body).messages.map((msg) => ({
|
|
141
|
-
file: filePath,
|
|
142
|
-
/* v8 ignore next 3 -- ruleId/line/column fallbacks; remark-lint always provides these */
|
|
143
|
-
rule: msg.ruleId ?? msg.source ?? "unknown",
|
|
144
|
-
line: msg.line ?? 1,
|
|
145
|
-
column: msg.column ?? 1,
|
|
146
|
-
message: msg.message
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Validate all changeset `.md` files in a directory.
|
|
151
|
-
*
|
|
152
|
-
* @remarks
|
|
153
|
-
* Scans the directory for `*.md` files (excluding `README.md`) and runs
|
|
154
|
-
* {@link ChangesetLinter.validateFile} on each. Results are aggregated
|
|
155
|
-
* into a single array. The directory is read synchronously.
|
|
156
|
-
*
|
|
157
|
-
* This is the method used by the Effect CLI's `lint` and `check`
|
|
158
|
-
* subcommands to validate the `.changeset/` directory.
|
|
159
|
-
*
|
|
160
|
-
* @param dir - Path to the directory containing changeset files
|
|
161
|
-
* (typically `.changeset/`)
|
|
162
|
-
* @returns Aggregated array of {@link LintMessage} diagnostics from all files
|
|
163
|
-
*/
|
|
164
|
-
static validate(dir) {
|
|
165
|
-
return readdirSync(dir).filter((f) => f.endsWith(".md") && f !== "README.md").flatMap((filename) => ChangesetLinter.validateFile(join(dir, filename)));
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
export { ChangesetLinter };
|
|
@@ -1,134 +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
|
-
const require_maintenance_note = require('../remark/plugins/maintenance-note.cjs');
|
|
6
|
-
const require_presets = require('../remark/presets.cjs');
|
|
7
|
-
let node_fs = require("node:fs");
|
|
8
|
-
|
|
9
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/api/transformer.js
|
|
10
|
-
/**
|
|
11
|
-
* Class-based API wrapper for changelog transformation.
|
|
12
|
-
*
|
|
13
|
-
* Provides a static class interface that runs all remark transform
|
|
14
|
-
* plugins against CHANGELOG markdown content as the post-processing
|
|
15
|
-
* layer of the three-layer pipeline.
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Static class for post-processing CHANGELOG.md files.
|
|
21
|
-
*
|
|
22
|
-
* Implements the third layer of the three-layer pipeline by running
|
|
23
|
-
* the {@link SilkChangesetTransformPreset} plugins (currently seven) in a
|
|
24
|
-
* fixed order to clean up, normalize, and enhance changelog output produced
|
|
25
|
-
* by the formatter layer.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* See {@link SilkChangesetTransformPreset} for the ordered plugin list and
|
|
29
|
-
* the rationale behind each plugin's position.
|
|
30
|
-
*
|
|
31
|
-
* The transformer operates on the full CHANGELOG.md content (all versions),
|
|
32
|
-
* not just the latest release block. It is idempotent -- running it multiple
|
|
33
|
-
* times produces the same output.
|
|
34
|
-
*
|
|
35
|
-
* @example Transform changelog content in memory
|
|
36
|
-
* ```typescript
|
|
37
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
38
|
-
*
|
|
39
|
-
* const rawChangelog = [
|
|
40
|
-
* "# Changelog",
|
|
41
|
-
* "",
|
|
42
|
-
* "## 1.2.0",
|
|
43
|
-
* "",
|
|
44
|
-
* "### Features",
|
|
45
|
-
* "",
|
|
46
|
-
* "- Added new auth endpoint",
|
|
47
|
-
* "",
|
|
48
|
-
* "### Features",
|
|
49
|
-
* "",
|
|
50
|
-
* "- Added rate limiting",
|
|
51
|
-
* ].join("\n");
|
|
52
|
-
*
|
|
53
|
-
* const cleaned: string = ChangelogTransformer.transformContent(rawChangelog);
|
|
54
|
-
* // Duplicate "Features" sections are merged into one
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @example Transform a CHANGELOG.md file in-place
|
|
58
|
-
* ```typescript
|
|
59
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
60
|
-
*
|
|
61
|
-
* // Reads, transforms, and writes back to the same path
|
|
62
|
-
* ChangelogTransformer.transformFile("CHANGELOG.md");
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example Check for changes without writing (dry-run pattern)
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import { readFileSync } from "node:fs";
|
|
68
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
69
|
-
*
|
|
70
|
-
* const original: string = readFileSync("CHANGELOG.md", "utf-8");
|
|
71
|
-
* const transformed: string = ChangelogTransformer.transformContent(original);
|
|
72
|
-
*
|
|
73
|
-
* if (original !== transformed) {
|
|
74
|
-
* console.error("CHANGELOG.md needs transformation");
|
|
75
|
-
* process.exitCode = 1;
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @see {@link Categories} for the priority order used by ReorderSectionsPlugin
|
|
80
|
-
* @see {@link ChangesetLinter} for the pre-validation layer (layer 1)
|
|
81
|
-
* @see {@link Changelog} for the formatter layer (layer 2)
|
|
82
|
-
*
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
var ChangelogTransformer = class ChangelogTransformer {
|
|
86
|
-
/* v8 ignore next -- private constructor prevents direct instantiation */
|
|
87
|
-
constructor() {}
|
|
88
|
-
/**
|
|
89
|
-
* Transform CHANGELOG markdown content by running the
|
|
90
|
-
* {@link SilkChangesetTransformPreset} plugins.
|
|
91
|
-
*
|
|
92
|
-
* @remarks
|
|
93
|
-
* The input is parsed with `remark-parse` and `remark-gfm` (for table
|
|
94
|
-
* support), processed through every plugin in {@link SilkChangesetTransformPreset}
|
|
95
|
-
* in order, and stringified back to markdown. The operation is synchronous
|
|
96
|
-
* and idempotent.
|
|
97
|
-
*
|
|
98
|
-
* @param content - Raw CHANGELOG markdown string (may contain multiple
|
|
99
|
-
* version blocks, GFM tables, footnotes, and reference links)
|
|
100
|
-
* @param options - Optional transformation options, including maintenance note configuration
|
|
101
|
-
* @returns The transformed markdown string with dependency tables aggregated,
|
|
102
|
-
* sections merged, reordered, deduplicated, and normalized
|
|
103
|
-
*/
|
|
104
|
-
static transformContent(content, options) {
|
|
105
|
-
const processor = require_index$3.unified().use(require_index$1.default).use(require_index.default);
|
|
106
|
-
for (const plugin of require_presets.SilkChangesetTransformPreset) processor.use(plugin);
|
|
107
|
-
if (options?.maintenance) processor.use(require_maintenance_note.MaintenanceNotePlugin, options.maintenance);
|
|
108
|
-
processor.use(require_index$2.default);
|
|
109
|
-
const file = processor.processSync(content);
|
|
110
|
-
return String(file);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Transform a CHANGELOG file in-place.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* Reads the file synchronously, runs all transform plugins via
|
|
117
|
-
* {@link ChangelogTransformer.transformContent}, and writes the result
|
|
118
|
-
* back to the same path. The file is overwritten atomically (single
|
|
119
|
-
* `writeFileSync` call).
|
|
120
|
-
*
|
|
121
|
-
* This is the method used by the Effect CLI's `transform` subcommand
|
|
122
|
-
* when invoked without the `--dry-run` or `--check` flags.
|
|
123
|
-
*
|
|
124
|
-
* @param filePath - Absolute or relative path to the CHANGELOG.md file
|
|
125
|
-
* @param options - Optional transformation options, including maintenance note configuration
|
|
126
|
-
*/
|
|
127
|
-
static transformFile(filePath, options) {
|
|
128
|
-
const content = (0, node_fs.readFileSync)(filePath, "utf-8");
|
|
129
|
-
(0, node_fs.writeFileSync)(filePath, ChangelogTransformer.transformContent(content, options), "utf-8");
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
exports.ChangelogTransformer = ChangelogTransformer;
|
|
@@ -1,134 +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
|
-
import { MaintenanceNotePlugin } from "../remark/plugins/maintenance-note.js";
|
|
6
|
-
import { SilkChangesetTransformPreset } from "../remark/presets.js";
|
|
7
|
-
import { readFileSync, writeFileSync } from "node:fs";
|
|
8
|
-
|
|
9
|
-
//#region ../silk-effects/dist/dev/pkg/changesets/api/transformer.js
|
|
10
|
-
/**
|
|
11
|
-
* Class-based API wrapper for changelog transformation.
|
|
12
|
-
*
|
|
13
|
-
* Provides a static class interface that runs all remark transform
|
|
14
|
-
* plugins against CHANGELOG markdown content as the post-processing
|
|
15
|
-
* layer of the three-layer pipeline.
|
|
16
|
-
*
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Static class for post-processing CHANGELOG.md files.
|
|
21
|
-
*
|
|
22
|
-
* Implements the third layer of the three-layer pipeline by running
|
|
23
|
-
* the {@link SilkChangesetTransformPreset} plugins (currently seven) in a
|
|
24
|
-
* fixed order to clean up, normalize, and enhance changelog output produced
|
|
25
|
-
* by the formatter layer.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* See {@link SilkChangesetTransformPreset} for the ordered plugin list and
|
|
29
|
-
* the rationale behind each plugin's position.
|
|
30
|
-
*
|
|
31
|
-
* The transformer operates on the full CHANGELOG.md content (all versions),
|
|
32
|
-
* not just the latest release block. It is idempotent -- running it multiple
|
|
33
|
-
* times produces the same output.
|
|
34
|
-
*
|
|
35
|
-
* @example Transform changelog content in memory
|
|
36
|
-
* ```typescript
|
|
37
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
38
|
-
*
|
|
39
|
-
* const rawChangelog = [
|
|
40
|
-
* "# Changelog",
|
|
41
|
-
* "",
|
|
42
|
-
* "## 1.2.0",
|
|
43
|
-
* "",
|
|
44
|
-
* "### Features",
|
|
45
|
-
* "",
|
|
46
|
-
* "- Added new auth endpoint",
|
|
47
|
-
* "",
|
|
48
|
-
* "### Features",
|
|
49
|
-
* "",
|
|
50
|
-
* "- Added rate limiting",
|
|
51
|
-
* ].join("\n");
|
|
52
|
-
*
|
|
53
|
-
* const cleaned: string = ChangelogTransformer.transformContent(rawChangelog);
|
|
54
|
-
* // Duplicate "Features" sections are merged into one
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @example Transform a CHANGELOG.md file in-place
|
|
58
|
-
* ```typescript
|
|
59
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
60
|
-
*
|
|
61
|
-
* // Reads, transforms, and writes back to the same path
|
|
62
|
-
* ChangelogTransformer.transformFile("CHANGELOG.md");
|
|
63
|
-
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example Check for changes without writing (dry-run pattern)
|
|
66
|
-
* ```typescript
|
|
67
|
-
* import { readFileSync } from "node:fs";
|
|
68
|
-
* import { ChangelogTransformer } from "\@savvy-web/changesets";
|
|
69
|
-
*
|
|
70
|
-
* const original: string = readFileSync("CHANGELOG.md", "utf-8");
|
|
71
|
-
* const transformed: string = ChangelogTransformer.transformContent(original);
|
|
72
|
-
*
|
|
73
|
-
* if (original !== transformed) {
|
|
74
|
-
* console.error("CHANGELOG.md needs transformation");
|
|
75
|
-
* process.exitCode = 1;
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* @see {@link Categories} for the priority order used by ReorderSectionsPlugin
|
|
80
|
-
* @see {@link ChangesetLinter} for the pre-validation layer (layer 1)
|
|
81
|
-
* @see {@link Changelog} for the formatter layer (layer 2)
|
|
82
|
-
*
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
var ChangelogTransformer = class ChangelogTransformer {
|
|
86
|
-
/* v8 ignore next -- private constructor prevents direct instantiation */
|
|
87
|
-
constructor() {}
|
|
88
|
-
/**
|
|
89
|
-
* Transform CHANGELOG markdown content by running the
|
|
90
|
-
* {@link SilkChangesetTransformPreset} plugins.
|
|
91
|
-
*
|
|
92
|
-
* @remarks
|
|
93
|
-
* The input is parsed with `remark-parse` and `remark-gfm` (for table
|
|
94
|
-
* support), processed through every plugin in {@link SilkChangesetTransformPreset}
|
|
95
|
-
* in order, and stringified back to markdown. The operation is synchronous
|
|
96
|
-
* and idempotent.
|
|
97
|
-
*
|
|
98
|
-
* @param content - Raw CHANGELOG markdown string (may contain multiple
|
|
99
|
-
* version blocks, GFM tables, footnotes, and reference links)
|
|
100
|
-
* @param options - Optional transformation options, including maintenance note configuration
|
|
101
|
-
* @returns The transformed markdown string with dependency tables aggregated,
|
|
102
|
-
* sections merged, reordered, deduplicated, and normalized
|
|
103
|
-
*/
|
|
104
|
-
static transformContent(content, options) {
|
|
105
|
-
const processor = unified().use(remarkParse).use(remarkGfm);
|
|
106
|
-
for (const plugin of SilkChangesetTransformPreset) processor.use(plugin);
|
|
107
|
-
if (options?.maintenance) processor.use(MaintenanceNotePlugin, options.maintenance);
|
|
108
|
-
processor.use(remarkStringify);
|
|
109
|
-
const file = processor.processSync(content);
|
|
110
|
-
return String(file);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Transform a CHANGELOG file in-place.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* Reads the file synchronously, runs all transform plugins via
|
|
117
|
-
* {@link ChangelogTransformer.transformContent}, and writes the result
|
|
118
|
-
* back to the same path. The file is overwritten atomically (single
|
|
119
|
-
* `writeFileSync` call).
|
|
120
|
-
*
|
|
121
|
-
* This is the method used by the Effect CLI's `transform` subcommand
|
|
122
|
-
* when invoked without the `--dry-run` or `--check` flags.
|
|
123
|
-
*
|
|
124
|
-
* @param filePath - Absolute or relative path to the CHANGELOG.md file
|
|
125
|
-
* @param options - Optional transformation options, including maintenance note configuration
|
|
126
|
-
*/
|
|
127
|
-
static transformFile(filePath, options) {
|
|
128
|
-
const content = readFileSync(filePath, "utf-8");
|
|
129
|
-
writeFileSync(filePath, ChangelogTransformer.transformContent(content, options), "utf-8");
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
//#endregion
|
|
134
|
-
export { ChangelogTransformer };
|