@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.
package/cjs/index.cjs ADDED
@@ -0,0 +1,1302 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./src/categories/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
+ __webpack_require__.d(__webpack_exports__, {
5
+ Ar: ()=>MAINTENANCE,
6
+ CI: ()=>CI,
7
+ Fi: ()=>REFACTORING,
8
+ Gv: ()=>FEATURES,
9
+ JY: ()=>fromHeading,
10
+ KY: ()=>DEPENDENCIES,
11
+ Lr: ()=>isValidHeading,
12
+ N: ()=>BUILD_SYSTEM,
13
+ OH: ()=>resolveCommitType,
14
+ R6: ()=>CATEGORIES,
15
+ Rr: ()=>allHeadings,
16
+ Zs: ()=>OTHER,
17
+ cT: ()=>REVERTS,
18
+ iD: ()=>BREAKING_CHANGES,
19
+ l0: ()=>DOCUMENTATION,
20
+ mp: ()=>TESTS,
21
+ vZ: ()=>BUG_FIXES,
22
+ xe: ()=>PERFORMANCE
23
+ });
24
+ const BREAKING_CHANGES = {
25
+ heading: "Breaking Changes",
26
+ priority: 1,
27
+ commitTypes: [],
28
+ description: "Backward-incompatible changes"
29
+ };
30
+ const FEATURES = {
31
+ heading: "Features",
32
+ priority: 2,
33
+ commitTypes: [
34
+ "feat"
35
+ ],
36
+ description: "New functionality"
37
+ };
38
+ const BUG_FIXES = {
39
+ heading: "Bug Fixes",
40
+ priority: 3,
41
+ commitTypes: [
42
+ "fix"
43
+ ],
44
+ description: "Bug corrections"
45
+ };
46
+ const PERFORMANCE = {
47
+ heading: "Performance",
48
+ priority: 4,
49
+ commitTypes: [
50
+ "perf"
51
+ ],
52
+ description: "Performance improvements"
53
+ };
54
+ const DOCUMENTATION = {
55
+ heading: "Documentation",
56
+ priority: 5,
57
+ commitTypes: [
58
+ "docs"
59
+ ],
60
+ description: "Documentation changes"
61
+ };
62
+ const REFACTORING = {
63
+ heading: "Refactoring",
64
+ priority: 6,
65
+ commitTypes: [
66
+ "refactor"
67
+ ],
68
+ description: "Code restructuring"
69
+ };
70
+ const TESTS = {
71
+ heading: "Tests",
72
+ priority: 7,
73
+ commitTypes: [
74
+ "test"
75
+ ],
76
+ description: "Test additions or modifications"
77
+ };
78
+ const BUILD_SYSTEM = {
79
+ heading: "Build System",
80
+ priority: 8,
81
+ commitTypes: [
82
+ "build"
83
+ ],
84
+ description: "Build configuration changes"
85
+ };
86
+ const CI = {
87
+ heading: "CI",
88
+ priority: 9,
89
+ commitTypes: [
90
+ "ci"
91
+ ],
92
+ description: "Continuous integration changes"
93
+ };
94
+ const DEPENDENCIES = {
95
+ heading: "Dependencies",
96
+ priority: 10,
97
+ commitTypes: [
98
+ "deps"
99
+ ],
100
+ description: "Dependency updates"
101
+ };
102
+ const MAINTENANCE = {
103
+ heading: "Maintenance",
104
+ priority: 11,
105
+ commitTypes: [
106
+ "chore",
107
+ "style"
108
+ ],
109
+ description: "General maintenance"
110
+ };
111
+ const REVERTS = {
112
+ heading: "Reverts",
113
+ priority: 12,
114
+ commitTypes: [
115
+ "revert"
116
+ ],
117
+ description: "Reverted changes"
118
+ };
119
+ const OTHER = {
120
+ heading: "Other",
121
+ priority: 13,
122
+ commitTypes: [],
123
+ description: "Uncategorized changes"
124
+ };
125
+ const CATEGORIES = [
126
+ BREAKING_CHANGES,
127
+ FEATURES,
128
+ BUG_FIXES,
129
+ PERFORMANCE,
130
+ DOCUMENTATION,
131
+ REFACTORING,
132
+ TESTS,
133
+ BUILD_SYSTEM,
134
+ CI,
135
+ DEPENDENCIES,
136
+ MAINTENANCE,
137
+ REVERTS,
138
+ OTHER
139
+ ];
140
+ const headingToCategory = new Map(CATEGORIES.map((cat)=>[
141
+ cat.heading.toLowerCase(),
142
+ cat
143
+ ]));
144
+ const commitTypeToCategory = new Map();
145
+ for (const cat of CATEGORIES)for (const commitType of cat.commitTypes)commitTypeToCategory.set(commitType, cat);
146
+ function resolveCommitType(type, scope, breaking) {
147
+ if (breaking) return BREAKING_CHANGES;
148
+ if ("chore" === type && "deps" === scope) return DEPENDENCIES;
149
+ return commitTypeToCategory.get(type) ?? OTHER;
150
+ }
151
+ function fromHeading(heading) {
152
+ return headingToCategory.get(heading.toLowerCase());
153
+ }
154
+ function isValidHeading(heading) {
155
+ return headingToCategory.has(heading.toLowerCase());
156
+ }
157
+ function allHeadings() {
158
+ return CATEGORIES.map((cat)=>cat.heading);
159
+ }
160
+ },
161
+ "./src/changelog/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
162
+ __webpack_require__.d(__webpack_exports__, {
163
+ default: ()=>changelog
164
+ });
165
+ var external_effect_ = __webpack_require__("effect");
166
+ var schemas_options = __webpack_require__("./src/schemas/options.ts");
167
+ var services_github = __webpack_require__("./src/services/github.ts");
168
+ var markdown = __webpack_require__("./src/services/markdown.ts");
169
+ function logWarning(message, ...args) {
170
+ if ("u" > typeof process && "true" === process.env.GITHUB_ACTIONS) {
171
+ const text = args.length > 0 ? `${message} ${args.join(" ")}` : message;
172
+ console.warn(`::warning::${text}`);
173
+ } else console.warn(message, ...args);
174
+ }
175
+ function getDependencyReleaseLine(changesets, dependenciesUpdated, options) {
176
+ return external_effect_.Effect.gen(function*() {
177
+ if (0 === dependenciesUpdated.length) return "";
178
+ const github = yield* services_github.Xx;
179
+ let apiFailures = 0;
180
+ const totalWithCommit = changesets.filter((cs)=>cs.commit).length;
181
+ const commitLinks = yield* external_effect_.Effect.forEach(changesets, (cs)=>{
182
+ const commit = cs.commit;
183
+ if (!commit) return external_effect_.Effect.succeed(null);
184
+ return github.getInfo({
185
+ commit,
186
+ repo: options.repo
187
+ }).pipe(external_effect_.Effect.map((info)=>info.links.commit), external_effect_.Effect.catchAll((error)=>{
188
+ apiFailures++;
189
+ logWarning(`Failed to fetch GitHub info for commit ${commit}:`, String(error));
190
+ return external_effect_.Effect.succeed(`[\`${commit.substring(0, 7)}\`](https://github.com/${options.repo}/commit/${commit})`);
191
+ }));
192
+ }, {
193
+ concurrency: 10
194
+ });
195
+ if (apiFailures > 0) {
196
+ const successRate = ((totalWithCommit - apiFailures) / totalWithCommit * 100).toFixed(1);
197
+ logWarning(`GitHub API calls completed with ${apiFailures}/${totalWithCommit} failures (${successRate}% success rate)`);
198
+ }
199
+ const validLinks = commitLinks.filter(Boolean);
200
+ const changesetLink = validLinks.length > 0 ? `- Updated dependencies [${validLinks.join(", ")}]:` : "- Updated dependencies:";
201
+ const updatedDependenciesList = dependenciesUpdated.map((dep)=>` - ${dep.name}@${dep.newVersion}`);
202
+ return [
203
+ changesetLink,
204
+ ...updatedDependenciesList
205
+ ].join("\n");
206
+ });
207
+ }
208
+ var categories = __webpack_require__("./src/categories/index.ts");
209
+ var schemas_github = __webpack_require__("./src/schemas/github.ts");
210
+ const CONVENTIONAL_COMMIT_PATTERN = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)/;
211
+ function parseCommitMessage(message) {
212
+ const match = CONVENTIONAL_COMMIT_PATTERN.exec(message);
213
+ if (match) {
214
+ const [, type, scope, bang, description] = match;
215
+ const lines = message.split("\n");
216
+ const body = lines.slice(1).join("\n").trim();
217
+ const result = {
218
+ type,
219
+ description: description.trim()
220
+ };
221
+ if (scope) result.scope = scope;
222
+ if ("!" === bang) result.breaking = true;
223
+ if (body) result.body = body;
224
+ return result;
225
+ }
226
+ return {
227
+ description: message
228
+ };
229
+ }
230
+ const CLOSES_ISSUE_PATTERN = /closes?:?\s*#?(\d+(?:, *#?\d+)*)/i;
231
+ const FIXES_ISSUE_PATTERN = /fix(?:es)?:?\s*#?(\d+(?:, *#?\d+)*)/i;
232
+ const REFS_ISSUE_PATTERN = /refs?:?\s*#?(\d+(?:, *#?\d+)*)/i;
233
+ const ISSUE_NUMBER_SPLIT_PATTERN = /, */;
234
+ function extractIssueNumbers(pattern, message) {
235
+ const safeMessage = message.slice(0, 10000);
236
+ const match = pattern.exec(safeMessage);
237
+ if (!match?.[1]) return [];
238
+ return match[1].split(ISSUE_NUMBER_SPLIT_PATTERN).map((num)=>num.replace("#", "").trim());
239
+ }
240
+ function parseIssueReferences(commitMessage) {
241
+ return {
242
+ closes: extractIssueNumbers(CLOSES_ISSUE_PATTERN, commitMessage),
243
+ fixes: extractIssueNumbers(FIXES_ISSUE_PATTERN, commitMessage),
244
+ refs: extractIssueNumbers(REFS_ISSUE_PATTERN, commitMessage)
245
+ };
246
+ }
247
+ var external_mdast_util_to_string_ = __webpack_require__("mdast-util-to-string");
248
+ var remark_pipeline = __webpack_require__("./src/utils/remark-pipeline.ts");
249
+ function parseChangesetSections(summary) {
250
+ const tree = (0, remark_pipeline.Dd)(summary);
251
+ const h2Indices = [];
252
+ for(let i = 0; i < tree.children.length; i++){
253
+ const node = tree.children[i];
254
+ if ("heading" === node.type && 2 === node.depth) h2Indices.push(i);
255
+ }
256
+ if (0 === h2Indices.length) return {
257
+ preamble: summary.trim(),
258
+ sections: []
259
+ };
260
+ const result = {
261
+ sections: []
262
+ };
263
+ if (h2Indices[0] > 0) {
264
+ const preambleNodes = tree.children.slice(0, h2Indices[0]);
265
+ result.preamble = stringifyAstSlice(preambleNodes);
266
+ }
267
+ for(let i = 0; i < h2Indices.length; i++){
268
+ const headingIndex = h2Indices[i];
269
+ const headingNode = tree.children[headingIndex];
270
+ const headingText = (0, external_mdast_util_to_string_.toString)(headingNode);
271
+ const nextIndex = i + 1 < h2Indices.length ? h2Indices[i + 1] : tree.children.length;
272
+ const contentNodes = tree.children.slice(headingIndex + 1, nextIndex);
273
+ const content = stringifyAstSlice(contentNodes);
274
+ const category = (0, categories.JY)(headingText);
275
+ if (category) result.sections.push({
276
+ category,
277
+ heading: headingText,
278
+ content
279
+ });
280
+ }
281
+ return result;
282
+ }
283
+ function stringifyAstSlice(nodes) {
284
+ if (0 === nodes.length) return "";
285
+ const root = {
286
+ type: "root",
287
+ children: nodes
288
+ };
289
+ return (0, remark_pipeline.FH)(root).trim();
290
+ }
291
+ var markdown_link = __webpack_require__("./src/utils/markdown-link.ts");
292
+ const ISSUE_CATEGORIES = [
293
+ {
294
+ key: "closes",
295
+ label: "Closes"
296
+ },
297
+ {
298
+ key: "fixes",
299
+ label: "Fixes"
300
+ },
301
+ {
302
+ key: "refs",
303
+ label: "Refs"
304
+ }
305
+ ];
306
+ function formatChangelogEntry(entry, options) {
307
+ const parts = [];
308
+ if (entry.commit) {
309
+ const shortHash = entry.commit.substring(0, 7);
310
+ parts.push(`[\`${shortHash}\`](https://github.com/${options.repo}/commit/${entry.commit})`);
311
+ }
312
+ parts.push(entry.summary.trim());
313
+ const issueLinks = [];
314
+ for (const { key, label } of ISSUE_CATEGORIES){
315
+ const numbers = entry.issues[key];
316
+ if (numbers.length > 0) {
317
+ const links = numbers.map((num)=>`[#${num}](https://github.com/${options.repo}/issues/${num})`);
318
+ issueLinks.push(`${label}: ${links.join(", ")}`);
319
+ }
320
+ }
321
+ if (issueLinks.length > 0) parts.push(`\n\n${issueLinks.join(". ")}`);
322
+ return parts.join(" ");
323
+ }
324
+ function formatPRAndUserAttribution(pr, user, links) {
325
+ let prReference = "";
326
+ if (pr) if (links?.pull) {
327
+ const pullUrl = (0, markdown_link.W)(links.pull);
328
+ prReference = ` [#${String(pr)}](${pullUrl})`;
329
+ } else prReference = ` (#${String(pr)})`;
330
+ if (user) {
331
+ if (links?.user) {
332
+ const userUrl = (0, markdown_link.W)(links.user);
333
+ return `${prReference} Thanks [@${user}](${userUrl})!`;
334
+ }
335
+ return `${prReference} Thanks @${user}!`;
336
+ }
337
+ return prReference;
338
+ }
339
+ function getReleaseLine(changeset, versionType, options) {
340
+ return external_effect_.Effect.gen(function*() {
341
+ let commitInfo = null;
342
+ if (changeset.commit) {
343
+ const github = yield* services_github.Xx;
344
+ commitInfo = yield* github.getInfo({
345
+ commit: changeset.commit,
346
+ repo: options.repo
347
+ }).pipe(external_effect_.Effect.flatMap((raw)=>external_effect_.Schema.decodeUnknown(schemas_github.lo)(raw).pipe(external_effect_.Effect.map(()=>raw), external_effect_.Effect.catchAll(()=>external_effect_.Effect.succeed(raw)))), external_effect_.Effect.catchAll((error)=>{
348
+ logWarning("Could not fetch GitHub info for commit:", changeset.commit ?? "", String(error));
349
+ return external_effect_.Effect.succeed(null);
350
+ }));
351
+ }
352
+ const parsed = parseChangesetSections(changeset.summary);
353
+ const firstLine = changeset.summary.split("\n")[0];
354
+ const commitMsg = parseCommitMessage(firstLine);
355
+ const bodyText = changeset.summary.split("\n").slice(1).join("\n");
356
+ const issueRefs = parseIssueReferences(bodyText);
357
+ const attribution = commitInfo ? formatPRAndUserAttribution(commitInfo.pull ?? void 0, commitInfo.user ?? void 0, commitInfo.links) : "";
358
+ if (parsed.sections.length > 0) {
359
+ const lines = [];
360
+ if (parsed.preamble) {
361
+ lines.push(parsed.preamble);
362
+ lines.push("");
363
+ }
364
+ for (const section of parsed.sections){
365
+ lines.push(`### ${section.category.heading}`);
366
+ lines.push("");
367
+ const commitPrefix = changeset.commit ? `[\`${changeset.commit.substring(0, 7)}\`](https://github.com/${options.repo}/commit/${changeset.commit}) ` : "";
368
+ if (section.content) {
369
+ const contentLines = section.content.split("\n");
370
+ const firstContentLine = contentLines[0];
371
+ if (firstContentLine.startsWith("- ") || firstContentLine.startsWith("* ")) {
372
+ lines.push(`${firstContentLine.substring(0, 2)}${commitPrefix}${firstContentLine.substring(2)}`);
373
+ lines.push(...contentLines.slice(1));
374
+ } else lines.push(`- ${commitPrefix}${section.content}`);
375
+ }
376
+ lines.push("");
377
+ }
378
+ const result = lines.join("\n").trimEnd();
379
+ return `${result}${attribution}`;
380
+ }
381
+ const commitType = commitMsg.type ?? versionType;
382
+ const category = (0, categories.OH)(commitType, commitMsg.scope, commitMsg.breaking);
383
+ const entryInput = {
384
+ type: category.heading,
385
+ summary: changeset.summary,
386
+ issues: issueRefs,
387
+ ...changeset.commit ? {
388
+ commit: changeset.commit
389
+ } : {}
390
+ };
391
+ const entry = formatChangelogEntry(entryInput, {
392
+ repo: options.repo
393
+ });
394
+ return `- ${entry}${attribution}`;
395
+ });
396
+ }
397
+ const MainLayer = external_effect_.Layer.mergeAll(services_github.cH, markdown.Am);
398
+ const changelogFunctions = {
399
+ getReleaseLine: async (changeset, versionType, options)=>{
400
+ const program = external_effect_.Effect.gen(function*() {
401
+ const opts = yield* (0, schemas_options.jb)(options);
402
+ return yield* getReleaseLine(changeset, versionType, opts);
403
+ });
404
+ return external_effect_.Effect.runPromise(program.pipe(external_effect_.Effect.provide(MainLayer)));
405
+ },
406
+ getDependencyReleaseLine: async (changesets, dependenciesUpdated, options)=>{
407
+ const program = external_effect_.Effect.gen(function*() {
408
+ const opts = yield* (0, schemas_options.jb)(options);
409
+ return yield* getDependencyReleaseLine(changesets, dependenciesUpdated, opts);
410
+ });
411
+ return external_effect_.Effect.runPromise(program.pipe(external_effect_.Effect.provide(MainLayer)));
412
+ }
413
+ };
414
+ const changelog = changelogFunctions;
415
+ },
416
+ "./src/errors.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
417
+ __webpack_require__.d(__webpack_exports__, {
418
+ Gv: ()=>ChangesetValidationError,
419
+ OS: ()=>GitHubApiError,
420
+ TZ: ()=>GitHubApiErrorBase,
421
+ W4: ()=>ConfigurationErrorBase,
422
+ hL: ()=>ChangesetValidationErrorBase,
423
+ j1: ()=>ConfigurationError,
424
+ ww: ()=>MarkdownParseErrorBase,
425
+ zy: ()=>MarkdownParseError
426
+ });
427
+ var effect__rspack_import_0 = __webpack_require__("effect");
428
+ const ChangesetValidationErrorBase = effect__rspack_import_0.Data.TaggedError("ChangesetValidationError");
429
+ class ChangesetValidationError extends ChangesetValidationErrorBase {
430
+ get message() {
431
+ const prefix = this.file ? `${this.file}: ` : "";
432
+ const detail = this.issues.map((i)=>` - ${i.path}: ${i.message}`).join("\n");
433
+ return `${prefix}Changeset validation failed:\n${detail}`;
434
+ }
435
+ }
436
+ const GitHubApiErrorBase = effect__rspack_import_0.Data.TaggedError("GitHubApiError");
437
+ class GitHubApiError extends GitHubApiErrorBase {
438
+ get message() {
439
+ const status = this.statusCode ? ` (${this.statusCode})` : "";
440
+ return `GitHub API error during ${this.operation}${status}: ${this.reason}`;
441
+ }
442
+ get isRateLimited() {
443
+ return 403 === this.statusCode || 429 === this.statusCode;
444
+ }
445
+ get isRetryable() {
446
+ return void 0 !== this.statusCode && (this.statusCode >= 500 || this.isRateLimited);
447
+ }
448
+ }
449
+ const MarkdownParseErrorBase = effect__rspack_import_0.Data.TaggedError("MarkdownParseError");
450
+ class MarkdownParseError extends MarkdownParseErrorBase {
451
+ get message() {
452
+ const loc = this.line ? `:${this.line}${this.column ? `:${this.column}` : ""}` : "";
453
+ const src = this.source ? `${this.source}${loc}: ` : "";
454
+ return `${src}Markdown parse error: ${this.reason}`;
455
+ }
456
+ }
457
+ const ConfigurationErrorBase = effect__rspack_import_0.Data.TaggedError("ConfigurationError");
458
+ class ConfigurationError extends ConfigurationErrorBase {
459
+ get message() {
460
+ return `Configuration error (${this.field}): ${this.reason}`;
461
+ }
462
+ }
463
+ },
464
+ "./src/schemas/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
465
+ __webpack_require__.d(__webpack_exports__, {
466
+ OD: ()=>IssueNumberSchema,
467
+ Qo: ()=>UsernameSchema,
468
+ hY: ()=>UrlOrMarkdownLinkSchema,
469
+ lo: ()=>GitHubInfoSchema
470
+ });
471
+ var effect__rspack_import_0 = __webpack_require__("effect");
472
+ var _utils_markdown_link_js__rspack_import_2 = __webpack_require__("./src/utils/markdown-link.ts");
473
+ var _primitives_js__rspack_import_1 = __webpack_require__("./src/schemas/primitives.ts");
474
+ function isValidUrl(value) {
475
+ try {
476
+ new URL(value);
477
+ return true;
478
+ } catch {
479
+ return false;
480
+ }
481
+ }
482
+ const UsernameSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/, {
483
+ message: ()=>"Invalid GitHub username format"
484
+ }));
485
+ const IssueNumberSchema = _primitives_js__rspack_import_1.e.annotations({
486
+ title: "IssueNumber",
487
+ description: "GitHub issue or pull request number"
488
+ });
489
+ const UrlOrMarkdownLinkSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.filter((value)=>{
490
+ if (isValidUrl(value)) return true;
491
+ const match = _utils_markdown_link_js__rspack_import_2.o.exec(value);
492
+ return match?.[2] ? isValidUrl(match[2]) : false;
493
+ }, {
494
+ message: ()=>"Invalid URL or markdown link format"
495
+ }));
496
+ const GitHubInfoSchema = effect__rspack_import_0.Schema.Struct({
497
+ user: effect__rspack_import_0.Schema.optional(UsernameSchema),
498
+ pull: effect__rspack_import_0.Schema.optional(IssueNumberSchema),
499
+ links: effect__rspack_import_0.Schema.Struct({
500
+ commit: UrlOrMarkdownLinkSchema,
501
+ pull: effect__rspack_import_0.Schema.optional(UrlOrMarkdownLinkSchema),
502
+ user: effect__rspack_import_0.Schema.optional(UrlOrMarkdownLinkSchema)
503
+ })
504
+ });
505
+ },
506
+ "./src/schemas/options.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
507
+ __webpack_require__.d(__webpack_exports__, {
508
+ YL: ()=>ChangesetOptionsSchema,
509
+ jb: ()=>validateChangesetOptions,
510
+ s8: ()=>RepoSchema
511
+ });
512
+ var effect__rspack_import_0 = __webpack_require__("effect");
513
+ var _errors_js__rspack_import_1 = __webpack_require__("./src/errors.ts");
514
+ const REPO_PATTERN = /^[a-zA-Z0-9._-]+\/[a-zA-Z0-9._-]+$/;
515
+ const RepoSchema = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.pattern(REPO_PATTERN, {
516
+ message: ()=>'Repository must be in format "owner/repository" (e.g., "microsoft/vscode")'
517
+ }));
518
+ const ChangesetOptionsSchema = effect__rspack_import_0.Schema.Struct({
519
+ repo: RepoSchema,
520
+ commitLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
521
+ prLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
522
+ issueLinks: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Boolean),
523
+ issuePrefixes: effect__rspack_import_0.Schema.optional(effect__rspack_import_0.Schema.Array(effect__rspack_import_0.Schema.String))
524
+ });
525
+ function validateChangesetOptions(input) {
526
+ if (null == input) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
527
+ field: "options",
528
+ reason: 'Configuration is required. Add options to your changesets config:\n"changelog": ["@savvy-web/changesets", { "repo": "owner/repository" }]'
529
+ }));
530
+ if ("object" != typeof input) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
531
+ field: "options",
532
+ reason: "Configuration must be an object"
533
+ }));
534
+ const obj = input;
535
+ if (!("repo" in obj) || void 0 === obj.repo) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
536
+ field: "repo",
537
+ reason: 'Repository name is required. Add the "repo" option to your changesets config:\n"changelog": ["@savvy-web/changesets", { "repo": "owner/repository" }]'
538
+ }));
539
+ if ("string" == typeof obj.repo && !REPO_PATTERN.test(obj.repo)) return effect__rspack_import_0.Effect.fail(new _errors_js__rspack_import_1.j1({
540
+ field: "repo",
541
+ reason: `Invalid repository format: "${obj.repo}". Expected format is "owner/repository" (e.g., "microsoft/vscode")`
542
+ }));
543
+ return effect__rspack_import_0.Schema.decodeUnknown(ChangesetOptionsSchema)(input).pipe(effect__rspack_import_0.Effect.mapError((parseError)=>new _errors_js__rspack_import_1.j1({
544
+ field: "options",
545
+ reason: String(parseError)
546
+ })));
547
+ }
548
+ },
549
+ "./src/schemas/primitives.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
550
+ __webpack_require__.d(__webpack_exports__, {
551
+ e: ()=>PositiveInteger,
552
+ u: ()=>NonEmptyString
553
+ });
554
+ var effect__rspack_import_0 = __webpack_require__("effect");
555
+ const NonEmptyString = effect__rspack_import_0.Schema.String.pipe(effect__rspack_import_0.Schema.minLength(1));
556
+ const PositiveInteger = effect__rspack_import_0.Schema.Number.pipe(effect__rspack_import_0.Schema.int(), effect__rspack_import_0.Schema.positive());
557
+ },
558
+ "./src/services/github.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
559
+ __webpack_require__.d(__webpack_exports__, {
560
+ Xx: ()=>GitHubService,
561
+ wP: ()=>GitHubServiceBase,
562
+ e_: ()=>makeGitHubTest,
563
+ cH: ()=>GitHubLive
564
+ });
565
+ var external_effect_ = __webpack_require__("effect");
566
+ var errors = __webpack_require__("./src/errors.ts");
567
+ const get_github_info_namespaceObject = require("@changesets/get-github-info");
568
+ function getGitHubInfo(params) {
569
+ return external_effect_.Effect.tryPromise({
570
+ try: ()=>(0, get_github_info_namespaceObject.getInfo)({
571
+ commit: params.commit,
572
+ repo: params.repo
573
+ }),
574
+ catch: (error)=>new errors.OS({
575
+ operation: "getInfo",
576
+ reason: error instanceof Error ? error.message : String(error)
577
+ })
578
+ });
579
+ }
580
+ const _tag = external_effect_.Context.Tag("GitHubService");
581
+ const GitHubServiceBase = _tag();
582
+ class GitHubService extends GitHubServiceBase {
583
+ }
584
+ const GitHubLive = external_effect_.Layer.succeed(GitHubService, {
585
+ getInfo: getGitHubInfo
586
+ });
587
+ function makeGitHubTest(responses) {
588
+ return external_effect_.Layer.succeed(GitHubService, {
589
+ getInfo: (params)=>{
590
+ const info = responses.get(params.commit);
591
+ if (info) return external_effect_.Effect.succeed(info);
592
+ return external_effect_.Effect.fail(new errors.OS({
593
+ operation: "getInfo",
594
+ reason: `No mock response for commit ${params.commit}`
595
+ }));
596
+ }
597
+ });
598
+ }
599
+ },
600
+ "./src/services/markdown.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
601
+ __webpack_require__.d(__webpack_exports__, {
602
+ Am: ()=>MarkdownLive,
603
+ M4: ()=>MarkdownServiceBase,
604
+ Rl: ()=>MarkdownService
605
+ });
606
+ var effect__rspack_import_0 = __webpack_require__("effect");
607
+ var _utils_remark_pipeline_js__rspack_import_1 = __webpack_require__("./src/utils/remark-pipeline.ts");
608
+ const _tag = effect__rspack_import_0.Context.Tag("MarkdownService");
609
+ const MarkdownServiceBase = _tag();
610
+ class MarkdownService extends MarkdownServiceBase {
611
+ }
612
+ const MarkdownLive = effect__rspack_import_0.Layer.succeed(MarkdownService, {
613
+ parse: (content)=>effect__rspack_import_0.Effect.sync(()=>(0, _utils_remark_pipeline_js__rspack_import_1.Dd)(content)),
614
+ stringify: (tree)=>effect__rspack_import_0.Effect.sync(()=>(0, _utils_remark_pipeline_js__rspack_import_1.FH)(tree))
615
+ });
616
+ },
617
+ "./src/utils/markdown-link.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
618
+ __webpack_require__.d(__webpack_exports__, {
619
+ W: ()=>extractUrlFromMarkdown,
620
+ o: ()=>MARKDOWN_LINK_PATTERN
621
+ });
622
+ const MARKDOWN_LINK_PATTERN = /\[([^\]]+)\]\(([^)]+)\)/;
623
+ function extractUrlFromMarkdown(linkOrUrl) {
624
+ const match = MARKDOWN_LINK_PATTERN.exec(linkOrUrl);
625
+ return match ? match[2] : linkOrUrl;
626
+ }
627
+ },
628
+ "./src/utils/remark-pipeline.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
629
+ __webpack_require__.d(__webpack_exports__, {
630
+ Dd: ()=>parseMarkdown,
631
+ FH: ()=>stringifyMarkdown
632
+ });
633
+ var remark_gfm__rspack_import_0 = __webpack_require__("remark-gfm");
634
+ var remark_gfm__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(remark_gfm__rspack_import_0);
635
+ var remark_parse__rspack_import_1 = __webpack_require__("remark-parse");
636
+ var remark_parse__rspack_import_1_default = /*#__PURE__*/ __webpack_require__.n(remark_parse__rspack_import_1);
637
+ var remark_stringify__rspack_import_2 = __webpack_require__("remark-stringify");
638
+ var remark_stringify__rspack_import_2_default = /*#__PURE__*/ __webpack_require__.n(remark_stringify__rspack_import_2);
639
+ var unified__rspack_import_3 = __webpack_require__("unified");
640
+ function createRemarkProcessor() {
641
+ return (0, unified__rspack_import_3.unified)().use(remark_parse__rspack_import_1_default()).use(remark_gfm__rspack_import_0_default()).use(remark_stringify__rspack_import_2_default());
642
+ }
643
+ function parseMarkdown(content) {
644
+ const processor = createRemarkProcessor();
645
+ return processor.parse(content);
646
+ }
647
+ function stringifyMarkdown(tree) {
648
+ const processor = createRemarkProcessor();
649
+ return processor.stringify(tree);
650
+ }
651
+ },
652
+ effect (module) {
653
+ module.exports = require("effect");
654
+ },
655
+ "mdast-util-to-string" (module) {
656
+ module.exports = require("mdast-util-to-string");
657
+ },
658
+ "remark-gfm" (module) {
659
+ module.exports = require("remark-gfm");
660
+ },
661
+ "remark-parse" (module) {
662
+ module.exports = require("remark-parse");
663
+ },
664
+ "remark-stringify" (module) {
665
+ module.exports = require("remark-stringify");
666
+ },
667
+ unified (module) {
668
+ module.exports = require("unified");
669
+ }
670
+ };
671
+ var __webpack_module_cache__ = {};
672
+ function __webpack_require__(moduleId) {
673
+ var cachedModule = __webpack_module_cache__[moduleId];
674
+ if (void 0 !== cachedModule) return cachedModule.exports;
675
+ var module = __webpack_module_cache__[moduleId] = {
676
+ exports: {}
677
+ };
678
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
679
+ return module.exports;
680
+ }
681
+ (()=>{
682
+ __webpack_require__.n = (module)=>{
683
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
684
+ __webpack_require__.d(getter, {
685
+ a: getter
686
+ });
687
+ return getter;
688
+ };
689
+ })();
690
+ (()=>{
691
+ __webpack_require__.d = (exports1, definition)=>{
692
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
693
+ enumerable: true,
694
+ get: definition[key]
695
+ });
696
+ };
697
+ })();
698
+ (()=>{
699
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
700
+ })();
701
+ (()=>{
702
+ __webpack_require__.r = (exports1)=>{
703
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
704
+ value: 'Module'
705
+ });
706
+ Object.defineProperty(exports1, '__esModule', {
707
+ value: true
708
+ });
709
+ };
710
+ })();
711
+ var __webpack_exports__ = {};
712
+ (()=>{
713
+ __webpack_require__.r(__webpack_exports__);
714
+ __webpack_require__.d(__webpack_exports__, {
715
+ IssueNumberSchema: ()=>schemas_github.OD,
716
+ ChangelogServiceBase: ()=>ChangelogServiceBase,
717
+ UrlOrMarkdownLinkSchema: ()=>schemas_github.hY,
718
+ GitHubInfoSchema: ()=>schemas_github.lo,
719
+ GitHubServiceBase: ()=>github.wP,
720
+ GitHubApiErrorBase: ()=>errors.TZ,
721
+ ChangesetLinter: ()=>ChangesetLinter,
722
+ MarkdownServiceBase: ()=>markdown.M4,
723
+ ChangesetSchema: ()=>ChangesetSchema,
724
+ UsernameSchema: ()=>schemas_github.Qo,
725
+ ChangesetOptionsSchema: ()=>schemas_options.YL,
726
+ DependencyUpdateSchema: ()=>DependencyUpdateSchema,
727
+ VersionTypeSchema: ()=>VersionTypeSchema,
728
+ makeGitHubTest: ()=>github.e_,
729
+ ChangelogService: ()=>ChangelogService,
730
+ ChangesetSummarySchema: ()=>ChangesetSummarySchema,
731
+ MarkdownParseError: ()=>errors.zy,
732
+ PositiveInteger: ()=>primitives.e,
733
+ CommitHashSchema: ()=>CommitHashSchema,
734
+ ChangelogTransformer: ()=>ChangelogTransformer,
735
+ NonEmptyString: ()=>primitives.u,
736
+ ConfigurationError: ()=>errors.j1,
737
+ Categories: ()=>Categories,
738
+ Changelog: ()=>Changelog,
739
+ SectionCategorySchema: ()=>SectionCategorySchema,
740
+ DependencyTypeSchema: ()=>DependencyTypeSchema,
741
+ MarkdownService: ()=>markdown.Rl,
742
+ ChangesetValidationErrorBase: ()=>errors.hL,
743
+ ConfigurationErrorBase: ()=>errors.W4,
744
+ RepoSchema: ()=>schemas_options.s8,
745
+ GitHubApiError: ()=>errors.OS,
746
+ MarkdownParseErrorBase: ()=>errors.ww,
747
+ GitHubService: ()=>github.Xx,
748
+ GitHubLive: ()=>github.cH,
749
+ MarkdownLive: ()=>markdown.Am,
750
+ ChangesetValidationError: ()=>errors.Gv
751
+ });
752
+ var categories = __webpack_require__("./src/categories/index.ts");
753
+ class Categories {
754
+ static BREAKING_CHANGES = categories.iD;
755
+ static FEATURES = categories.Gv;
756
+ static BUG_FIXES = categories.vZ;
757
+ static PERFORMANCE = categories.xe;
758
+ static DOCUMENTATION = categories.l0;
759
+ static REFACTORING = categories.Fi;
760
+ static TESTS = categories.mp;
761
+ static BUILD_SYSTEM = categories.N;
762
+ static CI = categories.CI;
763
+ static DEPENDENCIES = categories.KY;
764
+ static MAINTENANCE = categories.Ar;
765
+ static REVERTS = categories.cT;
766
+ static OTHER = categories.Zs;
767
+ static ALL = categories.R6;
768
+ static fromCommitType(type, scope, breaking) {
769
+ return (0, categories.OH)(type, scope, breaking);
770
+ }
771
+ static fromHeading(heading) {
772
+ return (0, categories.JY)(heading);
773
+ }
774
+ static allHeadings() {
775
+ return (0, categories.Rr)();
776
+ }
777
+ static isValidHeading(heading) {
778
+ return (0, categories.Lr)(heading);
779
+ }
780
+ }
781
+ var changelog = __webpack_require__("./src/changelog/index.ts");
782
+ class Changelog {
783
+ static formatReleaseLine(changeset, versionType, options) {
784
+ return changelog["default"].getReleaseLine(changeset, versionType, options);
785
+ }
786
+ static formatDependencyReleaseLine(changesets, dependenciesUpdated, options) {
787
+ return changelog["default"].getDependencyReleaseLine(changesets, dependenciesUpdated, options);
788
+ }
789
+ }
790
+ const external_node_fs_namespaceObject = require("node:fs");
791
+ const external_node_path_namespaceObject = require("node:path");
792
+ var external_remark_parse_ = __webpack_require__("remark-parse");
793
+ var external_remark_parse_default = /*#__PURE__*/ __webpack_require__.n(external_remark_parse_);
794
+ var external_remark_stringify_ = __webpack_require__("remark-stringify");
795
+ var external_remark_stringify_default = /*#__PURE__*/ __webpack_require__.n(external_remark_stringify_);
796
+ var external_unified_ = __webpack_require__("unified");
797
+ var external_mdast_util_to_string_ = __webpack_require__("mdast-util-to-string");
798
+ const external_unified_lint_rule_namespaceObject = require("unified-lint-rule");
799
+ const external_unist_util_visit_namespaceObject = require("unist-util-visit");
800
+ const ContentStructureRule = (0, external_unified_lint_rule_namespaceObject.lintRule)("remark-lint:changeset-content-structure", (tree, file)=>{
801
+ (0, external_unist_util_visit_namespaceObject.visit)(tree, "heading", (node, index, parent)=>{
802
+ if (2 !== node.depth || null == parent || null == index) return;
803
+ const next = parent.children[index + 1];
804
+ if (!next || "heading" === next.type && 2 === next.depth) file.message("Empty section: heading has no content before the next section or end of file", node);
805
+ });
806
+ (0, external_unist_util_visit_namespaceObject.visit)(tree, "code", (node)=>{
807
+ if (!node.lang) file.message("Code block is missing a language identifier", node);
808
+ });
809
+ (0, external_unist_util_visit_namespaceObject.visit)(tree, "listItem", (node)=>{
810
+ const text = (0, external_mdast_util_to_string_.toString)(node).trim();
811
+ if (!text) file.message("Empty list item", node);
812
+ });
813
+ });
814
+ const HeadingHierarchyRule = (0, external_unified_lint_rule_namespaceObject.lintRule)("remark-lint:changeset-heading-hierarchy", (tree, file)=>{
815
+ let prevDepth = 0;
816
+ (0, external_unist_util_visit_namespaceObject.visit)(tree, "heading", (node)=>{
817
+ if (1 === node.depth) return void file.message("h1 headings are not allowed in changeset files", node);
818
+ if (prevDepth > 0 && node.depth > prevDepth + 1) file.message(`Heading level skipped: expected h${prevDepth + 1} or lower, found h${node.depth}`, node);
819
+ prevDepth = node.depth;
820
+ });
821
+ });
822
+ const RequiredSectionsRule = (0, external_unified_lint_rule_namespaceObject.lintRule)("remark-lint:changeset-required-sections", (tree, file)=>{
823
+ (0, external_unist_util_visit_namespaceObject.visit)(tree, "heading", (node)=>{
824
+ if (2 !== node.depth) return;
825
+ const text = (0, external_mdast_util_to_string_.toString)(node);
826
+ if (!(0, categories.Lr)(text)) file.message(`Unknown section "${text}". Valid sections: ${(0, categories.Rr)().join(", ")}`, node);
827
+ });
828
+ });
829
+ function stripFrontmatter(content) {
830
+ return content.replace(/^---\n[\s\S]*?\n---\n?/, "");
831
+ }
832
+ class ChangesetLinter {
833
+ static validateFile(filePath) {
834
+ const raw = (0, external_node_fs_namespaceObject.readFileSync)(filePath, "utf-8");
835
+ return ChangesetLinter.validateContent(raw, filePath);
836
+ }
837
+ static validateContent(content, filePath = "<input>") {
838
+ const body = stripFrontmatter(content);
839
+ const processor = (0, external_unified_.unified)().use(external_remark_parse_default()).use(external_remark_stringify_default()).use(HeadingHierarchyRule).use(RequiredSectionsRule).use(ContentStructureRule);
840
+ const file = processor.processSync(body);
841
+ return file.messages.map((msg)=>({
842
+ file: filePath,
843
+ rule: msg.ruleId ?? msg.source ?? "unknown",
844
+ line: msg.line ?? 1,
845
+ column: msg.column ?? 1,
846
+ message: msg.message
847
+ }));
848
+ }
849
+ static validate(dir) {
850
+ return (0, external_node_fs_namespaceObject.readdirSync)(dir).filter((f)=>f.endsWith(".md") && "README.md" !== f).flatMap((filename)=>ChangesetLinter.validateFile((0, external_node_path_namespaceObject.join)(dir, filename)));
851
+ }
852
+ }
853
+ var external_remark_gfm_ = __webpack_require__("remark-gfm");
854
+ var external_remark_gfm_default = /*#__PURE__*/ __webpack_require__.n(external_remark_gfm_);
855
+ function getVersionBlocks(tree) {
856
+ const blocks = [];
857
+ for(let i = 0; i < tree.children.length; i++){
858
+ const node = tree.children[i];
859
+ if ("heading" === node.type && 2 === node.depth) blocks.push({
860
+ headingIndex: i,
861
+ startIndex: i + 1,
862
+ endIndex: tree.children.length
863
+ });
864
+ }
865
+ for(let i = 0; i < blocks.length - 1; i++)blocks[i].endIndex = blocks[i + 1].headingIndex;
866
+ return blocks;
867
+ }
868
+ function getBlockSections(tree, block) {
869
+ const sections = [];
870
+ for(let i = block.startIndex; i < block.endIndex; i++){
871
+ const node = tree.children[i];
872
+ if ("heading" === node.type && 3 === node.depth) sections.push({
873
+ heading: node,
874
+ headingIndex: i,
875
+ contentNodes: []
876
+ });
877
+ else if (sections.length > 0) sections[sections.length - 1].contentNodes.push(node);
878
+ }
879
+ return sections;
880
+ }
881
+ function getHeadingText(heading) {
882
+ return (0, external_mdast_util_to_string_.toString)(heading);
883
+ }
884
+ const ATTRIBUTION_PLAIN_RE = /\s*Thanks @(\w[\w-]*)!$/;
885
+ function extractLinkedAttribution(children) {
886
+ if (children.length < 3) return;
887
+ const last = children[children.length - 1];
888
+ const secondLast = children[children.length - 2];
889
+ const thirdLast = children[children.length - 3];
890
+ if ("text" !== last.type || "!" !== last.value) return;
891
+ if ("link" !== secondLast.type) return;
892
+ const linkNode = secondLast;
893
+ if (1 !== linkNode.children.length || "text" !== linkNode.children[0].type) return;
894
+ const linkText = linkNode.children[0].value;
895
+ if (!linkText.startsWith("@")) return;
896
+ const username = linkText.slice(1);
897
+ if ("text" !== thirdLast.type) return;
898
+ const textNode = thirdLast;
899
+ if (!/\s*Thanks $/.test(textNode.value)) return;
900
+ return {
901
+ contributor: {
902
+ username,
903
+ url: linkNode.url
904
+ },
905
+ removeFrom: children.length - 3
906
+ };
907
+ }
908
+ const ContributorFootnotesPlugin = ()=>(tree)=>{
909
+ const blocks = getVersionBlocks(tree);
910
+ for(let b = blocks.length - 1; b >= 0; b--){
911
+ const block = blocks[b];
912
+ const contributors = new Map();
913
+ for(let i = block.startIndex; i < block.endIndex; i++){
914
+ const node = tree.children[i];
915
+ if ("list" === node.type) (0, external_unist_util_visit_namespaceObject.visit)(node, "paragraph", (para)=>{
916
+ const linked = extractLinkedAttribution(para.children);
917
+ if (linked) {
918
+ const key = linked.contributor.username.toLowerCase();
919
+ if (!contributors.has(key)) contributors.set(key, linked.contributor);
920
+ const textNode = para.children[linked.removeFrom];
921
+ textNode.value = textNode.value.replace(/\s*Thanks $/, "");
922
+ para.children.splice(linked.removeFrom + 1, 2);
923
+ if ("" === textNode.value) para.children.splice(linked.removeFrom, 1);
924
+ return;
925
+ }
926
+ const last = para.children[para.children.length - 1];
927
+ if (last?.type === "text") {
928
+ const textNode = last;
929
+ const match = textNode.value.match(ATTRIBUTION_PLAIN_RE);
930
+ if (match) {
931
+ const username = match[1];
932
+ const key = username.toLowerCase();
933
+ if (!contributors.has(key)) contributors.set(key, {
934
+ username,
935
+ url: void 0
936
+ });
937
+ textNode.value = textNode.value.replace(ATTRIBUTION_PLAIN_RE, "");
938
+ }
939
+ }
940
+ });
941
+ }
942
+ if (0 === contributors.size) continue;
943
+ const sorted = [
944
+ ...contributors.values()
945
+ ].sort((a, b)=>a.username.toLowerCase().localeCompare(b.username.toLowerCase()));
946
+ const phrasingChildren = [];
947
+ phrasingChildren.push({
948
+ type: "text",
949
+ value: "Thanks to "
950
+ });
951
+ for(let i = 0; i < sorted.length; i++){
952
+ const contrib = sorted[i];
953
+ if (i > 0 && sorted.length > 2) phrasingChildren.push({
954
+ type: "text",
955
+ value: ", "
956
+ });
957
+ if (i > 0 && i === sorted.length - 1) phrasingChildren.push({
958
+ type: "text",
959
+ value: 2 === sorted.length ? " and " : "and "
960
+ });
961
+ if (contrib.url) phrasingChildren.push({
962
+ type: "link",
963
+ url: contrib.url,
964
+ children: [
965
+ {
966
+ type: "text",
967
+ value: `@${contrib.username}`
968
+ }
969
+ ]
970
+ });
971
+ else phrasingChildren.push({
972
+ type: "text",
973
+ value: `@${contrib.username}`
974
+ });
975
+ }
976
+ phrasingChildren.push({
977
+ type: "text",
978
+ value: " for their contributions!"
979
+ });
980
+ const paragraph = {
981
+ type: "paragraph",
982
+ children: phrasingChildren
983
+ };
984
+ tree.children.splice(block.endIndex, 0, paragraph);
985
+ }
986
+ };
987
+ const DeduplicateItemsPlugin = ()=>(tree)=>{
988
+ const blocks = getVersionBlocks(tree);
989
+ for (const block of blocks){
990
+ const sections = getBlockSections(tree, block);
991
+ for (const section of sections)for (const node of section.contentNodes){
992
+ if ("list" !== node.type) continue;
993
+ const list = node;
994
+ const seen = new Set();
995
+ list.children = list.children.filter((item)=>{
996
+ const text = (0, external_mdast_util_to_string_.toString)(item);
997
+ if (seen.has(text)) return false;
998
+ seen.add(text);
999
+ return true;
1000
+ });
1001
+ }
1002
+ }
1003
+ tree.children = tree.children.filter((node)=>{
1004
+ if ("list" === node.type) return node.children.length > 0;
1005
+ return true;
1006
+ });
1007
+ };
1008
+ const ISSUE_RE = /^#\d+$/;
1009
+ const IssueLinkRefsPlugin = ()=>(tree)=>{
1010
+ const blocks = getVersionBlocks(tree);
1011
+ for(let b = blocks.length - 1; b >= 0; b--){
1012
+ const block = blocks[b];
1013
+ const definitions = new Map();
1014
+ for(let i = block.startIndex; i < block.endIndex; i++){
1015
+ const node = tree.children[i];
1016
+ (0, external_unist_util_visit_namespaceObject.visit)(node, "link", (linkNode, index, parent)=>{
1017
+ if (!parent || void 0 === index) return;
1018
+ if (1 !== linkNode.children.length || "text" !== linkNode.children[0].type) return;
1019
+ const text = linkNode.children[0].value;
1020
+ if (!ISSUE_RE.test(text)) return;
1021
+ const label = text;
1022
+ if (!definitions.has(label)) definitions.set(label, {
1023
+ label,
1024
+ url: linkNode.url
1025
+ });
1026
+ const ref = {
1027
+ type: "linkReference",
1028
+ identifier: label,
1029
+ label,
1030
+ referenceType: "full",
1031
+ children: [
1032
+ {
1033
+ type: "text",
1034
+ value: label
1035
+ }
1036
+ ]
1037
+ };
1038
+ parent.children[index] = ref;
1039
+ return external_unist_util_visit_namespaceObject.SKIP;
1040
+ });
1041
+ }
1042
+ if (0 === definitions.size) continue;
1043
+ const sorted = [
1044
+ ...definitions.values()
1045
+ ].sort((a, b)=>{
1046
+ const aNum = Number.parseInt(a.label.slice(1), 10);
1047
+ const bNum = Number.parseInt(b.label.slice(1), 10);
1048
+ return aNum - bNum;
1049
+ });
1050
+ const defNodes = sorted.map((def)=>({
1051
+ type: "definition",
1052
+ identifier: def.label,
1053
+ label: def.label,
1054
+ url: def.url
1055
+ }));
1056
+ tree.children.splice(block.endIndex, 0, ...defNodes);
1057
+ }
1058
+ };
1059
+ const MergeSectionsPlugin = ()=>(tree)=>{
1060
+ const blocks = getVersionBlocks(tree);
1061
+ for(let b = blocks.length - 1; b >= 0; b--){
1062
+ const sections = getBlockSections(tree, blocks[b]);
1063
+ if (sections.length <= 1) continue;
1064
+ const groups = new Map();
1065
+ for(let s = 0; s < sections.length; s++){
1066
+ const text = getHeadingText(sections[s].heading);
1067
+ const category = (0, categories.JY)(text);
1068
+ const key = category ? category.heading.toLowerCase() : text.toLowerCase();
1069
+ const existing = groups.get(key);
1070
+ if (existing) existing.push(s);
1071
+ else groups.set(key, [
1072
+ s
1073
+ ]);
1074
+ }
1075
+ const indicesToRemove = [];
1076
+ for (const indices of groups.values()){
1077
+ if (indices.length <= 1) continue;
1078
+ const target = sections[indices[0]];
1079
+ const targetEndIndex = target.headingIndex + 1 + target.contentNodes.length;
1080
+ const mergedContent = [];
1081
+ for(let d = 1; d < indices.length; d++){
1082
+ const dup = sections[indices[d]];
1083
+ mergedContent.push(...dup.contentNodes);
1084
+ indicesToRemove.push(dup.headingIndex);
1085
+ for(let c = 0; c < dup.contentNodes.length; c++)indicesToRemove.push(dup.headingIndex + 1 + c);
1086
+ }
1087
+ tree.children.splice(targetEndIndex, 0, ...mergedContent);
1088
+ const shift = mergedContent.length;
1089
+ for(let r = 0; r < indicesToRemove.length; r++)if (indicesToRemove[r] >= targetEndIndex) indicesToRemove[r] += shift;
1090
+ }
1091
+ indicesToRemove.sort((a, b)=>b - a);
1092
+ for (const idx of indicesToRemove)tree.children.splice(idx, 1);
1093
+ }
1094
+ };
1095
+ function isHeadingAtDepth(node, depths) {
1096
+ return "heading" === node.type && depths.includes(node.depth);
1097
+ }
1098
+ const NormalizeFormatPlugin = ()=>(tree)=>{
1099
+ const blocks = getVersionBlocks(tree);
1100
+ const indicesToRemove = new Set();
1101
+ for (const block of blocks)for(let i = block.startIndex; i < block.endIndex; i++){
1102
+ const node = tree.children[i];
1103
+ if ("list" === node.type && 0 === node.children.length) {
1104
+ indicesToRemove.add(i);
1105
+ continue;
1106
+ }
1107
+ if (!isHeadingAtDepth(node, [
1108
+ 3
1109
+ ])) continue;
1110
+ let hasContent = false;
1111
+ for(let j = i + 1; j < block.endIndex; j++){
1112
+ const next = tree.children[j];
1113
+ if ("paragraph" === next.type && "" === (0, external_mdast_util_to_string_.toString)(next).trim()) {
1114
+ indicesToRemove.add(j);
1115
+ continue;
1116
+ }
1117
+ if (isHeadingAtDepth(next, [
1118
+ 2,
1119
+ 3
1120
+ ])) break;
1121
+ hasContent = true;
1122
+ break;
1123
+ }
1124
+ if (!hasContent) indicesToRemove.add(i);
1125
+ }
1126
+ const sorted = [
1127
+ ...indicesToRemove
1128
+ ].sort((a, b)=>b - a);
1129
+ for (const idx of sorted)tree.children.splice(idx, 1);
1130
+ };
1131
+ const UNKNOWN_PRIORITY = 999;
1132
+ const ReorderSectionsPlugin = ()=>(tree)=>{
1133
+ const blocks = getVersionBlocks(tree);
1134
+ for(let b = blocks.length - 1; b >= 0; b--){
1135
+ const block = blocks[b];
1136
+ const sections = getBlockSections(tree, block);
1137
+ if (sections.length <= 1) continue;
1138
+ const preamble = [];
1139
+ for(let i = block.startIndex; i < block.endIndex; i++)if (i < sections[0].headingIndex) preamble.push(tree.children[i]);
1140
+ else break;
1141
+ const sorted = [
1142
+ ...sections
1143
+ ].sort((a, b)=>{
1144
+ const aPriority = (0, categories.JY)(getHeadingText(a.heading))?.priority ?? UNKNOWN_PRIORITY;
1145
+ const bPriority = (0, categories.JY)(getHeadingText(b.heading))?.priority ?? UNKNOWN_PRIORITY;
1146
+ return aPriority - bPriority;
1147
+ });
1148
+ const alreadySorted = sorted.every((s, i)=>s.headingIndex === sections[i].headingIndex);
1149
+ if (alreadySorted) continue;
1150
+ const newChildren = [
1151
+ ...preamble
1152
+ ];
1153
+ for (const section of sorted)newChildren.push(section.heading, ...section.contentNodes);
1154
+ const blockLength = block.endIndex - block.startIndex;
1155
+ tree.children.splice(block.startIndex, blockLength, ...newChildren);
1156
+ }
1157
+ };
1158
+ class ChangelogTransformer {
1159
+ static transformContent(content) {
1160
+ const processor = (0, external_unified_.unified)().use(external_remark_parse_default()).use(external_remark_gfm_default()).use(MergeSectionsPlugin).use(ReorderSectionsPlugin).use(DeduplicateItemsPlugin).use(ContributorFootnotesPlugin).use(IssueLinkRefsPlugin).use(NormalizeFormatPlugin).use(external_remark_stringify_default());
1161
+ const file = processor.processSync(content);
1162
+ return String(file);
1163
+ }
1164
+ static transformFile(filePath) {
1165
+ const content = (0, external_node_fs_namespaceObject.readFileSync)(filePath, "utf-8");
1166
+ const result = ChangelogTransformer.transformContent(content);
1167
+ (0, external_node_fs_namespaceObject.writeFileSync)(filePath, result, "utf-8");
1168
+ }
1169
+ }
1170
+ var external_effect_ = __webpack_require__("effect");
1171
+ const _tag = external_effect_.Context.Tag("ChangelogService");
1172
+ const ChangelogServiceBase = _tag();
1173
+ class ChangelogService extends ChangelogServiceBase {
1174
+ }
1175
+ var github = __webpack_require__("./src/services/github.ts");
1176
+ var markdown = __webpack_require__("./src/services/markdown.ts");
1177
+ var errors = __webpack_require__("./src/errors.ts");
1178
+ const SectionCategorySchema = external_effect_.Schema.Struct({
1179
+ heading: external_effect_.Schema.String,
1180
+ priority: external_effect_.Schema.Number,
1181
+ commitTypes: external_effect_.Schema.Array(external_effect_.Schema.String),
1182
+ description: external_effect_.Schema.String
1183
+ });
1184
+ const CommitHashSchema = external_effect_.Schema.String.pipe(external_effect_.Schema.pattern(/^[a-f0-9]{7,}$/, {
1185
+ message: ()=>"Commit hash must be at least 7 hexadecimal characters"
1186
+ }));
1187
+ const VersionTypeSchema = external_effect_.Schema.Literal("major", "minor", "patch", "none");
1188
+ var primitives = __webpack_require__("./src/schemas/primitives.ts");
1189
+ const ChangesetSummarySchema = external_effect_.Schema.String.pipe(external_effect_.Schema.minLength(1, {
1190
+ message: ()=>"Changeset summary cannot be empty"
1191
+ }), external_effect_.Schema.maxLength(1000, {
1192
+ message: ()=>"Changeset summary is too long"
1193
+ }));
1194
+ const ChangesetSchema = external_effect_.Schema.Struct({
1195
+ summary: ChangesetSummarySchema,
1196
+ id: external_effect_.Schema.String,
1197
+ commit: external_effect_.Schema.optional(CommitHashSchema)
1198
+ });
1199
+ const DependencyTypeSchema = external_effect_.Schema.Literal("dependencies", "devDependencies", "peerDependencies", "optionalDependencies");
1200
+ const DependencyUpdateSchema = external_effect_.Schema.Struct({
1201
+ name: primitives.u.annotations({
1202
+ message: ()=>"Package name cannot be empty"
1203
+ }),
1204
+ type: DependencyTypeSchema,
1205
+ oldVersion: external_effect_.Schema.String,
1206
+ newVersion: external_effect_.Schema.String
1207
+ });
1208
+ var schemas_github = __webpack_require__("./src/schemas/github.ts");
1209
+ var schemas_options = __webpack_require__("./src/schemas/options.ts");
1210
+ })();
1211
+ exports.Categories = __webpack_exports__.Categories;
1212
+ exports.Changelog = __webpack_exports__.Changelog;
1213
+ exports.ChangelogService = __webpack_exports__.ChangelogService;
1214
+ exports.ChangelogServiceBase = __webpack_exports__.ChangelogServiceBase;
1215
+ exports.ChangelogTransformer = __webpack_exports__.ChangelogTransformer;
1216
+ exports.ChangesetLinter = __webpack_exports__.ChangesetLinter;
1217
+ exports.ChangesetOptionsSchema = __webpack_exports__.ChangesetOptionsSchema;
1218
+ exports.ChangesetSchema = __webpack_exports__.ChangesetSchema;
1219
+ exports.ChangesetSummarySchema = __webpack_exports__.ChangesetSummarySchema;
1220
+ exports.ChangesetValidationError = __webpack_exports__.ChangesetValidationError;
1221
+ exports.ChangesetValidationErrorBase = __webpack_exports__.ChangesetValidationErrorBase;
1222
+ exports.CommitHashSchema = __webpack_exports__.CommitHashSchema;
1223
+ exports.ConfigurationError = __webpack_exports__.ConfigurationError;
1224
+ exports.ConfigurationErrorBase = __webpack_exports__.ConfigurationErrorBase;
1225
+ exports.DependencyTypeSchema = __webpack_exports__.DependencyTypeSchema;
1226
+ exports.DependencyUpdateSchema = __webpack_exports__.DependencyUpdateSchema;
1227
+ exports.GitHubApiError = __webpack_exports__.GitHubApiError;
1228
+ exports.GitHubApiErrorBase = __webpack_exports__.GitHubApiErrorBase;
1229
+ exports.GitHubInfoSchema = __webpack_exports__.GitHubInfoSchema;
1230
+ exports.GitHubLive = __webpack_exports__.GitHubLive;
1231
+ exports.GitHubService = __webpack_exports__.GitHubService;
1232
+ exports.GitHubServiceBase = __webpack_exports__.GitHubServiceBase;
1233
+ exports.IssueNumberSchema = __webpack_exports__.IssueNumberSchema;
1234
+ exports.MarkdownLive = __webpack_exports__.MarkdownLive;
1235
+ exports.MarkdownParseError = __webpack_exports__.MarkdownParseError;
1236
+ exports.MarkdownParseErrorBase = __webpack_exports__.MarkdownParseErrorBase;
1237
+ exports.MarkdownService = __webpack_exports__.MarkdownService;
1238
+ exports.MarkdownServiceBase = __webpack_exports__.MarkdownServiceBase;
1239
+ exports.NonEmptyString = __webpack_exports__.NonEmptyString;
1240
+ exports.PositiveInteger = __webpack_exports__.PositiveInteger;
1241
+ exports.RepoSchema = __webpack_exports__.RepoSchema;
1242
+ exports.SectionCategorySchema = __webpack_exports__.SectionCategorySchema;
1243
+ exports.UrlOrMarkdownLinkSchema = __webpack_exports__.UrlOrMarkdownLinkSchema;
1244
+ exports.UsernameSchema = __webpack_exports__.UsernameSchema;
1245
+ exports.VersionTypeSchema = __webpack_exports__.VersionTypeSchema;
1246
+ exports.makeGitHubTest = __webpack_exports__.makeGitHubTest;
1247
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
1248
+ "Categories",
1249
+ "Changelog",
1250
+ "ChangelogService",
1251
+ "ChangelogServiceBase",
1252
+ "ChangelogTransformer",
1253
+ "ChangesetLinter",
1254
+ "ChangesetOptionsSchema",
1255
+ "ChangesetSchema",
1256
+ "ChangesetSummarySchema",
1257
+ "ChangesetValidationError",
1258
+ "ChangesetValidationErrorBase",
1259
+ "CommitHashSchema",
1260
+ "ConfigurationError",
1261
+ "ConfigurationErrorBase",
1262
+ "DependencyTypeSchema",
1263
+ "DependencyUpdateSchema",
1264
+ "GitHubApiError",
1265
+ "GitHubApiErrorBase",
1266
+ "GitHubInfoSchema",
1267
+ "GitHubLive",
1268
+ "GitHubService",
1269
+ "GitHubServiceBase",
1270
+ "IssueNumberSchema",
1271
+ "MarkdownLive",
1272
+ "MarkdownParseError",
1273
+ "MarkdownParseErrorBase",
1274
+ "MarkdownService",
1275
+ "MarkdownServiceBase",
1276
+ "NonEmptyString",
1277
+ "PositiveInteger",
1278
+ "RepoSchema",
1279
+ "SectionCategorySchema",
1280
+ "UrlOrMarkdownLinkSchema",
1281
+ "UsernameSchema",
1282
+ "VersionTypeSchema",
1283
+ "makeGitHubTest"
1284
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
1285
+ Object.defineProperty(exports, '__esModule', {
1286
+ value: true
1287
+ });
1288
+
1289
+
1290
+ if (module.exports && module.exports.__esModule && 'default' in module.exports) {
1291
+ var _def = module.exports.default;
1292
+ if (_def !== null && _def !== undefined && (typeof _def === 'object' || typeof _def === 'function')) {
1293
+ var _keys = Object.keys(module.exports);
1294
+ for (var _i = 0; _i < _keys.length; _i++) {
1295
+ var _key = _keys[_i];
1296
+ if (_key !== 'default' && _key !== '__esModule' && !(_key in _def)) {
1297
+ _def[_key] = module.exports[_key];
1298
+ }
1299
+ }
1300
+ }
1301
+ module.exports = _def;
1302
+ }