@savvy-web/changesets 0.1.0 → 0.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.
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ ContentStructureRule: ()=>ContentStructureRule,
28
+ HeadingHierarchyRule: ()=>HeadingHierarchyRule,
29
+ default: ()=>markdownlint,
30
+ RequiredSectionsRule: ()=>RequiredSectionsRule
31
+ });
32
+ function getHeadingLevel(heading) {
33
+ const sequence = heading.children.find((c)=>"atxHeadingSequence" === c.type);
34
+ return sequence ? sequence.text.length : 0;
35
+ }
36
+ function getHeadingText(heading) {
37
+ const textToken = heading.children.find((c)=>"atxHeadingText" === c.type);
38
+ return textToken ? textToken.text : "";
39
+ }
40
+ function hasContentBetween(tokens, currentIdx, nextIdx) {
41
+ for(let i = currentIdx + 1; i < nextIdx; i++){
42
+ const token = tokens[i];
43
+ if ("lineEnding" !== token.type && "lineEndingBlank" !== token.type) return true;
44
+ }
45
+ return false;
46
+ }
47
+ const ContentStructureRule = {
48
+ names: [
49
+ "changeset-content-structure",
50
+ "CSH003"
51
+ ],
52
+ description: "Sections must have content, code blocks need languages, list items need text",
53
+ tags: [
54
+ "changeset"
55
+ ],
56
+ parser: "micromark",
57
+ function: function(params, onError) {
58
+ const tokens = params.parsers.micromark.tokens;
59
+ const h2Indices = [];
60
+ for(let i = 0; i < tokens.length; i++)if ("atxHeading" === tokens[i].type && 2 === getHeadingLevel(tokens[i])) h2Indices.push(i);
61
+ for(let i = 0; i < h2Indices.length; i++){
62
+ const currentIdx = h2Indices[i];
63
+ const nextIdx = i + 1 < h2Indices.length ? h2Indices[i + 1] : tokens.length;
64
+ if (!hasContentBetween(tokens, currentIdx, nextIdx)) onError({
65
+ lineNumber: tokens[currentIdx].startLine,
66
+ detail: "Empty section: heading has no content before the next section or end of file"
67
+ });
68
+ }
69
+ for (const token of tokens){
70
+ if ("codeFenced" !== token.type) continue;
71
+ const openingFence = token.children.find((c)=>"codeFencedFence" === c.type);
72
+ const hasInfo = openingFence?.children.some((c)=>"codeFencedFenceInfo" === c.type) ?? false;
73
+ if (!hasInfo) onError({
74
+ lineNumber: token.startLine,
75
+ detail: "Code block is missing a language identifier"
76
+ });
77
+ }
78
+ for (const token of tokens){
79
+ if ("listOrdered" !== token.type && "listUnordered" !== token.type) continue;
80
+ const children = token.children;
81
+ for(let i = 0; i < children.length; i++){
82
+ if ("listItemPrefix" !== children[i].type) continue;
83
+ let hasContent = false;
84
+ for(let j = i + 1; j < children.length; j++){
85
+ if ("listItemPrefix" === children[j].type) break;
86
+ if ("content" === children[j].type) {
87
+ hasContent = true;
88
+ break;
89
+ }
90
+ }
91
+ if (!hasContent) onError({
92
+ lineNumber: children[i].startLine,
93
+ detail: "Empty list item"
94
+ });
95
+ }
96
+ }
97
+ }
98
+ };
99
+ const HeadingHierarchyRule = {
100
+ names: [
101
+ "changeset-heading-hierarchy",
102
+ "CSH001"
103
+ ],
104
+ description: "Heading hierarchy must start at h2 with no h1 or depth skips",
105
+ tags: [
106
+ "changeset"
107
+ ],
108
+ parser: "micromark",
109
+ function: function(params, onError) {
110
+ let prevDepth = 0;
111
+ for (const token of params.parsers.micromark.tokens){
112
+ if ("atxHeading" !== token.type) continue;
113
+ const depth = getHeadingLevel(token);
114
+ if (1 === depth) {
115
+ onError({
116
+ lineNumber: token.startLine,
117
+ detail: "h1 headings are not allowed in changeset files"
118
+ });
119
+ continue;
120
+ }
121
+ if (prevDepth > 0 && depth > prevDepth + 1) onError({
122
+ lineNumber: token.startLine,
123
+ detail: `Heading level skipped: expected h${prevDepth + 1} or lower, found h${depth}`
124
+ });
125
+ prevDepth = depth;
126
+ }
127
+ }
128
+ };
129
+ const BREAKING_CHANGES = {
130
+ heading: "Breaking Changes",
131
+ priority: 1,
132
+ commitTypes: [],
133
+ description: "Backward-incompatible changes"
134
+ };
135
+ const FEATURES = {
136
+ heading: "Features",
137
+ priority: 2,
138
+ commitTypes: [
139
+ "feat"
140
+ ],
141
+ description: "New functionality"
142
+ };
143
+ const BUG_FIXES = {
144
+ heading: "Bug Fixes",
145
+ priority: 3,
146
+ commitTypes: [
147
+ "fix"
148
+ ],
149
+ description: "Bug corrections"
150
+ };
151
+ const PERFORMANCE = {
152
+ heading: "Performance",
153
+ priority: 4,
154
+ commitTypes: [
155
+ "perf"
156
+ ],
157
+ description: "Performance improvements"
158
+ };
159
+ const DOCUMENTATION = {
160
+ heading: "Documentation",
161
+ priority: 5,
162
+ commitTypes: [
163
+ "docs"
164
+ ],
165
+ description: "Documentation changes"
166
+ };
167
+ const REFACTORING = {
168
+ heading: "Refactoring",
169
+ priority: 6,
170
+ commitTypes: [
171
+ "refactor"
172
+ ],
173
+ description: "Code restructuring"
174
+ };
175
+ const TESTS = {
176
+ heading: "Tests",
177
+ priority: 7,
178
+ commitTypes: [
179
+ "test"
180
+ ],
181
+ description: "Test additions or modifications"
182
+ };
183
+ const BUILD_SYSTEM = {
184
+ heading: "Build System",
185
+ priority: 8,
186
+ commitTypes: [
187
+ "build"
188
+ ],
189
+ description: "Build configuration changes"
190
+ };
191
+ const CI = {
192
+ heading: "CI",
193
+ priority: 9,
194
+ commitTypes: [
195
+ "ci"
196
+ ],
197
+ description: "Continuous integration changes"
198
+ };
199
+ const DEPENDENCIES = {
200
+ heading: "Dependencies",
201
+ priority: 10,
202
+ commitTypes: [
203
+ "deps"
204
+ ],
205
+ description: "Dependency updates"
206
+ };
207
+ const MAINTENANCE = {
208
+ heading: "Maintenance",
209
+ priority: 11,
210
+ commitTypes: [
211
+ "chore",
212
+ "style"
213
+ ],
214
+ description: "General maintenance"
215
+ };
216
+ const REVERTS = {
217
+ heading: "Reverts",
218
+ priority: 12,
219
+ commitTypes: [
220
+ "revert"
221
+ ],
222
+ description: "Reverted changes"
223
+ };
224
+ const OTHER = {
225
+ heading: "Other",
226
+ priority: 13,
227
+ commitTypes: [],
228
+ description: "Uncategorized changes"
229
+ };
230
+ const CATEGORIES = [
231
+ BREAKING_CHANGES,
232
+ FEATURES,
233
+ BUG_FIXES,
234
+ PERFORMANCE,
235
+ DOCUMENTATION,
236
+ REFACTORING,
237
+ TESTS,
238
+ BUILD_SYSTEM,
239
+ CI,
240
+ DEPENDENCIES,
241
+ MAINTENANCE,
242
+ REVERTS,
243
+ OTHER
244
+ ];
245
+ const headingToCategory = new Map(CATEGORIES.map((cat)=>[
246
+ cat.heading.toLowerCase(),
247
+ cat
248
+ ]));
249
+ const commitTypeToCategory = new Map();
250
+ for (const cat of CATEGORIES)for (const commitType of cat.commitTypes)commitTypeToCategory.set(commitType, cat);
251
+ function isValidHeading(heading) {
252
+ return headingToCategory.has(heading.toLowerCase());
253
+ }
254
+ function allHeadings() {
255
+ return CATEGORIES.map((cat)=>cat.heading);
256
+ }
257
+ const RequiredSectionsRule = {
258
+ names: [
259
+ "changeset-required-sections",
260
+ "CSH002"
261
+ ],
262
+ description: "Section headings must match known changeset categories",
263
+ tags: [
264
+ "changeset"
265
+ ],
266
+ parser: "micromark",
267
+ function: function(params, onError) {
268
+ for (const token of params.parsers.micromark.tokens){
269
+ if ("atxHeading" !== token.type) continue;
270
+ if (2 !== getHeadingLevel(token)) continue;
271
+ const text = getHeadingText(token);
272
+ if (!isValidHeading(text)) onError({
273
+ lineNumber: token.startLine,
274
+ detail: `Unknown section "${text}". Valid sections: ${allHeadings().join(", ")}`
275
+ });
276
+ }
277
+ }
278
+ };
279
+ const SilkChangesetsRules = [
280
+ HeadingHierarchyRule,
281
+ RequiredSectionsRule,
282
+ ContentStructureRule
283
+ ];
284
+ const markdownlint = SilkChangesetsRules;
285
+ exports.ContentStructureRule = __webpack_exports__.ContentStructureRule;
286
+ exports.HeadingHierarchyRule = __webpack_exports__.HeadingHierarchyRule;
287
+ exports.RequiredSectionsRule = __webpack_exports__.RequiredSectionsRule;
288
+ exports["default"] = __webpack_exports__["default"];
289
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
290
+ "ContentStructureRule",
291
+ "HeadingHierarchyRule",
292
+ "RequiredSectionsRule",
293
+ "default"
294
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
295
+ Object.defineProperty(exports, '__esModule', {
296
+ value: true
297
+ });
298
+
299
+
300
+ if (module.exports && module.exports.__esModule && 'default' in module.exports) {
301
+ var _def = module.exports.default;
302
+ if (_def !== null && _def !== undefined && (typeof _def === 'object' || typeof _def === 'function')) {
303
+ var _keys = Object.keys(module.exports);
304
+ for (var _i = 0; _i < _keys.length; _i++) {
305
+ var _key = _keys[_i];
306
+ if (_key !== 'default' && _key !== '__esModule' && !(_key in _def)) {
307
+ _def[_key] = module.exports[_key];
308
+ }
309
+ }
310
+ }
311
+ module.exports = _def;
312
+ }