@soybeanjs/changelog 0.4.0 → 0.4.3

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/dist/index.d.ts CHANGED
@@ -121,7 +121,7 @@ declare function getChangelogMarkdown(options?: Partial<ChangelogOption>, showTi
121
121
  * Get the changelog markdown by the total git tags
122
122
  *
123
123
  * @param options The changelog options
124
- * @param showProgress Whither show the progress bar
124
+ * @param showProgress Whether show the progress bar
125
125
  */
126
126
  declare function getTotalChangelogMarkdown(options?: Partial<ChangelogOption>, showProgress?: boolean): Promise<string>;
127
127
  /**
package/dist/index.js CHANGED
@@ -430,11 +430,15 @@ function createContributorLine(contributors) {
430
430
  });
431
431
  return `${loginLine}\n${unLoginLine}`;
432
432
  }
433
- function generateMarkdown(params) {
433
+ async function generateMarkdown(params) {
434
434
  const { options, showTitle, contributors } = params;
435
435
  const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
436
436
  const lines = [];
437
- const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
437
+ let url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
438
+ if (!options.from) {
439
+ const mainBranch = await getGitMainBranchName();
440
+ url = `https://github.com/${options.github.repo}/compare/${options.to}...${mainBranch || "HEAD"}`;
441
+ }
438
442
  if (showTitle) {
439
443
  const date = options.tagDateMap.get(options.to) || dayjs().format("YYYY-MM-DD");
440
444
  let title = `## [${options.to}](${url})`;
@@ -500,7 +504,7 @@ async function getChangelogMarkdown(options, showTitle = true) {
500
504
  const resolvedLogins = /* @__PURE__ */ new Map();
501
505
  const { commits, contributors } = await getGitCommitsAndResolvedAuthors(gitCommits, opts.github, resolvedLogins);
502
506
  return {
503
- markdown: generateMarkdown({
507
+ markdown: await generateMarkdown({
504
508
  commits,
505
509
  options: opts,
506
510
  showTitle,
@@ -514,7 +518,7 @@ async function getChangelogMarkdown(options, showTitle = true) {
514
518
  * Get the changelog markdown by the total git tags
515
519
  *
516
520
  * @param options The changelog options
517
- * @param showProgress Whither show the progress bar
521
+ * @param showProgress Whether show the progress bar
518
522
  */
519
523
  async function getTotalChangelogMarkdown(options, showProgress = true) {
520
524
  const opts = await createOptions(options);
@@ -531,7 +535,7 @@ async function getTotalChangelogMarkdown(options, showProgress = true) {
531
535
  for await (const [index, tag] of tags.entries()) {
532
536
  const { from, to } = tag;
533
537
  const { commits, contributors } = await getGitCommitsAndResolvedAuthors(await getGitCommits(from, to), opts.github, resolvedLogins);
534
- markdown = `${generateMarkdown({
538
+ markdown = `${await generateMarkdown({
535
539
  commits,
536
540
  options: {
537
541
  ...opts,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soybeanjs/changelog",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.3",
5
5
  "description": "generate changelog form git tags and commits for github",
6
6
  "author": {
7
7
  "name": "Soybean",