@soybeanjs/changelog 0.4.0 → 0.4.4

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 CHANGED
@@ -15,8 +15,8 @@ import {
15
15
  getChangelogMarkdown,
16
16
  getTotalChangelogMarkdown,
17
17
  generateChangelog,
18
- generateTotalChangelog,
19
- } from "@soybeanjs/changelog";
18
+ generateTotalChangelog
19
+ } from '@soybeanjs/changelog';
20
20
 
21
21
  // get the changelog markdown by two git tags
22
22
  getChangelogMarkdown();
package/dist/index.d.ts CHANGED
@@ -89,8 +89,7 @@ interface ChangelogOption {
89
89
  emoji: boolean;
90
90
  /** The section titles */
91
91
  titles: {
92
- /** The title of breaking changes section */
93
- breakingChanges: string;
92
+ /** The title of breaking changes section */breakingChanges: string;
94
93
  };
95
94
  /** The output file path of the changelog */
96
95
  output: string;
@@ -121,7 +120,7 @@ declare function getChangelogMarkdown(options?: Partial<ChangelogOption>, showTi
121
120
  * Get the changelog markdown by the total git tags
122
121
  *
123
122
  * @param options The changelog options
124
- * @param showProgress Whither show the progress bar
123
+ * @param showProgress Whether show the progress bar
125
124
  */
126
125
  declare function getTotalChangelogMarkdown(options?: Partial<ChangelogOption>, showProgress?: boolean): Promise<string>;
127
126
  /**
package/dist/index.js CHANGED
@@ -222,26 +222,20 @@ function getHeaders(githubToken) {
222
222
  };
223
223
  }
224
224
  async function getResolvedAuthorLogin(github, commitHashes, email) {
225
+ const { repo, token } = github;
225
226
  let login = "";
227
+ if (!token) return login;
226
228
  try {
227
- login = (await ofetch(`https://ungh.cc/users/find/${email}`))?.user?.username || "";
229
+ login = (await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, { headers: getHeaders(token) })).items[0].login;
228
230
  } catch (e) {
229
231
  consola.log("e: ", e);
230
232
  }
231
233
  if (login) return login;
232
- const { repo, token } = github;
233
- if (!token) return login;
234
234
  if (commitHashes.length) try {
235
235
  login = (await ofetch(`https://api.github.com/repos/${repo}/commits/${commitHashes[0]}`, { headers: getHeaders(token) }))?.author?.login || "";
236
236
  } catch (e) {
237
237
  consola.log("e: ", e);
238
238
  }
239
- if (login) return login;
240
- try {
241
- login = (await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, { headers: getHeaders(token) })).items[0].login;
242
- } catch (e) {
243
- consola.log("e: ", e);
244
- }
245
239
  return login;
246
240
  }
247
241
  async function getGitCommitsAndResolvedAuthors(commits, github, resolvedLogins) {
@@ -430,11 +424,15 @@ function createContributorLine(contributors) {
430
424
  });
431
425
  return `${loginLine}\n${unLoginLine}`;
432
426
  }
433
- function generateMarkdown(params) {
427
+ async function generateMarkdown(params) {
434
428
  const { options, showTitle, contributors } = params;
435
429
  const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
436
430
  const lines = [];
437
- const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
431
+ let url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
432
+ if (!options.from) {
433
+ const mainBranch = await getGitMainBranchName();
434
+ url = `https://github.com/${options.github.repo}/compare/${options.to}...${mainBranch || "HEAD"}`;
435
+ }
438
436
  if (showTitle) {
439
437
  const date = options.tagDateMap.get(options.to) || dayjs().format("YYYY-MM-DD");
440
438
  let title = `## [${options.to}](${url})`;
@@ -500,7 +498,7 @@ async function getChangelogMarkdown(options, showTitle = true) {
500
498
  const resolvedLogins = /* @__PURE__ */ new Map();
501
499
  const { commits, contributors } = await getGitCommitsAndResolvedAuthors(gitCommits, opts.github, resolvedLogins);
502
500
  return {
503
- markdown: generateMarkdown({
501
+ markdown: await generateMarkdown({
504
502
  commits,
505
503
  options: opts,
506
504
  showTitle,
@@ -514,7 +512,7 @@ async function getChangelogMarkdown(options, showTitle = true) {
514
512
  * Get the changelog markdown by the total git tags
515
513
  *
516
514
  * @param options The changelog options
517
- * @param showProgress Whither show the progress bar
515
+ * @param showProgress Whether show the progress bar
518
516
  */
519
517
  async function getTotalChangelogMarkdown(options, showProgress = true) {
520
518
  const opts = await createOptions(options);
@@ -522,8 +520,8 @@ async function getTotalChangelogMarkdown(options, showProgress = true) {
522
520
  if (showProgress) bar = new SingleBar({ format: "generate total changelog: [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}" }, Presets.shades_classic);
523
521
  const tags = getFromToTags(opts.tags);
524
522
  if (tags.length === 0) {
525
- const { markdown: markdown$1 } = await getChangelogMarkdown(opts);
526
- return markdown$1;
523
+ const { markdown } = await getChangelogMarkdown(opts);
524
+ return markdown;
527
525
  }
528
526
  bar?.start(tags.length, 0);
529
527
  let markdown = "";
@@ -531,7 +529,7 @@ async function getTotalChangelogMarkdown(options, showProgress = true) {
531
529
  for await (const [index, tag] of tags.entries()) {
532
530
  const { from, to } = tag;
533
531
  const { commits, contributors } = await getGitCommitsAndResolvedAuthors(await getGitCommits(from, to), opts.github, resolvedLogins);
534
- markdown = `${generateMarkdown({
532
+ markdown = `${await generateMarkdown({
535
533
  commits,
536
534
  options: {
537
535
  ...opts,
package/package.json CHANGED
@@ -1,25 +1,28 @@
1
1
  {
2
2
  "name": "@soybeanjs/changelog",
3
- "type": "module",
4
- "version": "0.4.0",
3
+ "version": "0.4.4",
5
4
  "description": "generate changelog form git tags and commits for github",
5
+ "homepage": "https://github.com/soybeanjs/changelog",
6
+ "bugs": {
7
+ "url": "https://github.com/soybeanjs/changelog/issues"
8
+ },
9
+ "license": "MIT",
6
10
  "author": {
7
11
  "name": "Soybean",
8
12
  "email": "soybeanjs@outlook.com",
9
13
  "url": "https://github.com/soybeanjs"
10
14
  },
11
- "license": "MIT",
12
- "homepage": "https://github.com/soybeanjs/changelog",
13
15
  "repository": {
14
16
  "url": "https://github.com/soybeanjs/changelog.git"
15
17
  },
16
- "bugs": {
17
- "url": "https://github.com/soybeanjs/changelog/issues"
18
- },
19
- "publishConfig": {
20
- "registry": "https://registry.npmjs.org/"
21
- },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "type": "module",
22
22
  "sideEffects": false,
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
23
26
  "exports": {
24
27
  ".": {
25
28
  "types": "./dist/index.d.ts",
@@ -27,34 +30,27 @@
27
30
  "require": "./dist/index.js"
28
31
  }
29
32
  },
30
- "main": "./dist/index.js",
31
- "module": "./dist/index.js",
32
- "types": "./dist/index.d.ts",
33
- "files": [
34
- "dist"
35
- ],
36
- "engines": {
37
- "node": ">=18",
38
- "pnpm": ">=9"
33
+ "publishConfig": {
34
+ "registry": "https://registry.npmjs.org/"
39
35
  },
40
36
  "dependencies": {
41
- "@soybeanjs/eslint-config": "1.7.5",
42
37
  "cli-progress": "3.12.0",
43
38
  "convert-gitmoji": "0.1.5",
44
- "dayjs": "1.11.19",
39
+ "dayjs": "1.11.20",
45
40
  "execa": "9.6.1",
46
41
  "ofetch": "1.5.1",
47
- "semver": "7.7.3"
42
+ "semver": "7.7.4"
48
43
  },
49
44
  "devDependencies": {
50
- "@soybeanjs/cli": "1.4.1",
45
+ "@soybeanjs/cli": "1.6.1",
51
46
  "@types/cli-progress": "3.11.6",
52
- "@types/node": "25.0.3",
47
+ "@types/node": "25.5.0",
53
48
  "@types/semver": "7.7.1",
54
- "eslint": "9.39.2",
55
- "lint-staged": "16.2.7",
49
+ "lint-staged": "16.4.0",
50
+ "oxfmt": "^0.41.0",
51
+ "oxlint": "^1.56.0",
56
52
  "simple-git-hooks": "2.13.1",
57
- "tsdown": "0.18.2",
53
+ "tsdown": "0.21.4",
58
54
  "tsx": "4.21.0",
59
55
  "typescript": "5.9.3"
60
56
  },
@@ -63,17 +59,22 @@
63
59
  "pre-commit": "pnpm typecheck && pnpm lint-staged"
64
60
  },
65
61
  "lint-staged": {
66
- "*": "eslint --fix"
62
+ "*": "oxlint --fix && oxfmt"
63
+ },
64
+ "engines": {
65
+ "node": ">=18",
66
+ "pnpm": ">=9"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "tsdown && pnpm build-pkg",
70
70
  "build-pkg": "pnpm -r --filter='./packages/*' run build",
71
71
  "cleanup": "soy cleanup",
72
72
  "commit": "soy git-commit",
73
- "lint": "eslint . --fix",
73
+ "fmt": "oxfmt",
74
+ "lint": "oxlint --fix",
74
75
  "publish-pkg": "pnpm -r publish --access public",
75
76
  "release": "soy release",
76
77
  "typecheck": "tsc --noEmit --skipLibCheck",
77
- "update-pkg": "soy ncu"
78
+ "upkg": "soy ncu"
78
79
  }
79
80
  }