Skip to content

Commit b3bf002

Browse files
committed
chore: hopefully it just works
1 parent 991d8ae commit b3bf002

File tree

2 files changed

+9
-48
lines changed

2 files changed

+9
-48
lines changed

.changeset/spicy-chairs-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stacc/changeset-formatter": patch
3+
---
4+
5+
One for the road!

src/index.ts

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,13 @@ async function getReleaseLine(
1818
type: string,
1919
options: Record<string, any> | null
2020
) {
21-
console.log("[Debug] Processing changeset:", {
22-
summary: changeset.summary,
23-
commit: changeset.commit,
24-
PR: changeset.PR,
25-
});
26-
2721
if (!options || !options.repo) {
2822
throw new Error(
2923
'Please provide a repo to this changelog generator like this:\n"changelog": ["./changelog-format.js", { "repo": "org/repo" }]'
3024
);
3125
}
3226

3327
const repo: string = options.repo;
34-
console.log("[Debug] Using repo:", repo);
3528

3629
// Extract PR, commit, and users from the summary
3730
let prFromSummary: number | undefined;
@@ -43,15 +36,11 @@ async function getReleaseLine(
4336
const replacedChangelog = changeset.summary
4437
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
4538
let num = Number(pr);
46-
if (!isNaN(num)) {
47-
prFromSummary = num;
48-
console.log("[Debug] Found PR from summary:", prFromSummary);
49-
}
39+
if (!isNaN(num)) prFromSummary = num;
5040
return "";
5141
})
5242
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
5343
commitFromSummary = commit;
54-
console.log("[Debug] Found commit from summary:", commitFromSummary);
5544
return "";
5645
})
5746
.replace(
@@ -61,12 +50,10 @@ async function getReleaseLine(
6150
if (user && !usersFromSummary.includes(user)) {
6251
usersFromSummary.push(user);
6352
allAuthors.add(user);
64-
console.log("[Debug] Added author from summary:", user);
6553
}
6654
if (rest && !usersFromSummary.includes(rest)) {
6755
usersFromSummary.push(rest);
6856
allAuthors.add(rest);
69-
console.log("[Debug] Added additional author from summary:", rest);
7057
}
7158
return "";
7259
}
@@ -76,7 +63,6 @@ async function getReleaseLine(
7663
if (user && !usersFromSummary.includes(user)) {
7764
usersFromSummary.push(user);
7865
allAuthors.add(user);
79-
console.log("[Debug] Added single author from summary:", user);
8066
}
8167
return "";
8268
})
@@ -91,38 +77,33 @@ async function getReleaseLine(
9177
const githubInfo = await (async () => {
9278
try {
9379
if (prFromSummary !== undefined) {
94-
console.log("[Debug] Fetching PR info for:", prFromSummary);
9580
const { links, user } = await getInfoFromPullRequest({
9681
repo,
9782
pull: prFromSummary,
9883
});
9984
if (user && !hasAuthorOverride) {
10085
allAuthors.add(user);
101-
console.log("[Debug] Added author from PR:", user);
10286
}
10387
return { links, user };
10488
}
10589

10690
// Use commit from summary or from changeset
10791
const commitToFetchFrom = commitFromSummary || changeset.commit;
10892
if (commitToFetchFrom) {
109-
console.log("[Debug] Fetching commit info for:", commitToFetchFrom);
11093
const info = await getInfo({
11194
repo,
11295
commit: commitToFetchFrom,
11396
});
11497
if (info.user && !hasAuthorOverride) {
11598
allAuthors.add(info.user);
116-
console.log("[Debug] Added author from commit:", info.user);
11799
}
118100
return info;
119101
}
120102

121-
console.log("[Debug] No PR or commit info found");
122103
return { links: { commit: null, pull: null }, user: null };
123104
} catch (error) {
124105
const err = error as Error;
125-
console.warn("[Debug] Error getting GitHub info:", err.message);
106+
console.warn(`Error getting GitHub info: ${err.message}`);
126107
return { links: { commit: null, pull: null }, user: null };
127108
}
128109
})();
@@ -133,8 +114,6 @@ async function getReleaseLine(
133114
changeset.PR ||
134115
githubInfo.links?.pull?.match(/#(\d+)/)?.[1];
135116

136-
console.log("[Debug] Final PR number:", prNumber);
137-
138117
// Build the release line in the requested format
139118
let result = `- ${firstLine}`;
140119

@@ -146,7 +125,6 @@ async function getReleaseLine(
146125
result += "\n" + futureLines.map((line) => " " + line).join("\n");
147126
}
148127

149-
console.log("[Debug] Generated release line:", result);
150128
return result;
151129
}
152130

@@ -207,22 +185,14 @@ async function getDependencyReleaseLine(
207185

208186
// Function to get the credits section
209187
function getCreditsSection(): string {
210-
console.log(
211-
"[Debug] Generating credits section. Current authors:",
212-
Array.from(allAuthors)
213-
);
214-
215-
if (allAuthors.size === 0) {
216-
console.log("[Debug] No authors found, skipping credits section");
217-
return "";
218-
}
188+
if (allAuthors.size === 0) return "";
219189

220190
const authors = Array.from(allAuthors).sort();
221191
const authorLinks = authors.map((author) => `@${author}`);
222192

223193
if (authorLinks.length === 0) return "";
224194

225-
let credits = "\n\nCredits\n";
195+
let credits = "\n\n**Credits**\n";
226196
if (authorLinks.length === 1) {
227197
credits += `Huge thanks to ${authorLinks[0]} for helping!`;
228198
} else if (authorLinks.length === 2) {
@@ -234,11 +204,8 @@ function getCreditsSection(): string {
234204
)}, and ${lastAuthor} for helping!`;
235205
}
236206

237-
console.log("[Debug] Generated credits section:", credits);
238-
239207
// Clear the authors set for the next changelog
240208
allAuthors.clear();
241-
console.log("[Debug] Cleared authors set for next changelog");
242209

243210
return credits;
244211
}
@@ -249,36 +216,25 @@ const wrappedGetReleaseLine: ChangelogFunctions["getReleaseLine"] = async (
249216
type,
250217
opts
251218
) => {
252-
console.log("[Debug] wrappedGetReleaseLine called with opts:", opts);
253219
const result = await getReleaseLine(changeset as ChangesetWithPR, type, opts);
254220
// Add credits section if we have collected any authors
255221
if (allAuthors.size > 0) {
256-
console.log("[Debug] Adding credits section to release line");
257222
return result + getCreditsSection();
258223
}
259-
console.log("[Debug] No authors collected, skipping credits section");
260224
return result;
261225
};
262226

263227
const wrappedGetDependencyReleaseLine: ChangelogFunctions["getDependencyReleaseLine"] =
264228
async (changesets, dependencies, opts) => {
265-
console.log("[Debug] wrappedGetDependencyReleaseLine called with:", {
266-
changesetCount: changesets.length,
267-
dependencyCount: dependencies.length,
268-
opts,
269-
});
270-
271229
const result = await getDependencyReleaseLine(
272230
changesets,
273231
dependencies,
274232
opts
275233
);
276234
// Add credits section if we have collected any authors
277235
if (allAuthors.size > 0) {
278-
console.log("[Debug] Adding credits section to dependency release line");
279236
return result + getCreditsSection();
280237
}
281-
console.log("[Debug] No authors collected, skipping credits section");
282238
return result;
283239
};
284240

0 commit comments

Comments
 (0)