@soybeanjs/cli 0.5.0 → 0.5.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/README.md CHANGED
@@ -20,16 +20,18 @@ pnpm soy -h
20
20
 
21
21
  ## 命令介绍
22
22
 
23
- | 命令 | 作用 |
24
- | ----------------- | ---------------------------------------- |
25
- | help | 查看全部命令用法 |
26
- | git-commit | 生成符合 Angular 规范的 git 提交信息 |
27
- | git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
28
- | cleanup | 清空依赖和构建产物 |
29
- | cleanup-deep | 清空依赖和构建产物(包含 深层级) |
30
- | init-git-hooks | 初始化 simple-gi t-hooks 钩子 |
31
- | update-pkg | 升级依赖 |
32
- | prettier-format | prettier 格式化 |
23
+ | 命令 | 作用 |
24
+ | ----------------- | ------------------------------------------------------------------ |
25
+ | help | 查看全部命令用法 |
26
+ | git-commit | 生成符合 Angular 规范的 git 提交信息 |
27
+ | git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
28
+ | cleanup | 清空依赖和构建产物 |
29
+ | init-git-hooks | 初始化 simple-git-hooks 钩子 |
30
+ | update-pkg | 升级依赖 |
31
+ | prettier-format | prettier 格式化 |
32
+ | lint-staged | 执行 lint-staged |
33
+ | changelog | 根据两次 tag 生成 changelog (--total: 根据所有 tag 生成 changelog) |
34
+ | release | 发布:更新版本号、生成 changelog、提交代码 |
33
35
 
34
36
  ### prettier-format
35
37
 
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ const cliProgress__default = /*#__PURE__*/_interopDefaultCompat(cliProgress);
42
42
  const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
43
43
  const versionBumpp__default = /*#__PURE__*/_interopDefaultCompat(versionBumpp);
44
44
 
45
- const version = "0.5.0";
45
+ const version = "0.5.1";
46
46
 
47
47
  async function execCommand(cmd, args, options) {
48
48
  const { execa } = await import('execa');
@@ -7525,6 +7525,9 @@ function lintStaged() {
7525
7525
  execCommand("npx", ["lint-staged", "--config", "@soybeanjs/cli/lint-staged"], { stdio: "inherit" });
7526
7526
  }
7527
7527
 
7528
+ const VERSION_REG = /v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
7529
+ const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
7530
+
7528
7531
  async function getTotalGitTags() {
7529
7532
  const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
7530
7533
  const tags = tagStr.split("\n");
@@ -7538,13 +7541,12 @@ async function getTagDateMap() {
7538
7541
  "--simplify-by-decoration",
7539
7542
  "--pretty=format:%ci %d"
7540
7543
  ]);
7541
- const TAG_MARK = "(tag: ";
7544
+ const TAG_MARK = "tag: ";
7542
7545
  const map = /* @__PURE__ */ new Map();
7543
7546
  const dates = tagDateStr.split("\n").filter((item) => item.includes(TAG_MARK));
7544
7547
  dates.forEach((item) => {
7545
7548
  const [dateStr, tagStr] = item.split(TAG_MARK);
7546
- const date = dayjs__default(dateStr.trim()).format("YYYY-MM-DD");
7547
- const VERSION_REG = /v\d+\.\d+\.\d+/;
7549
+ const date = dayjs__default(dateStr).format("YYYY-MM-DD");
7548
7550
  const tag = tagStr.match(VERSION_REG)?.[0];
7549
7551
  if (tag && date) {
7550
7552
  map.set(tag.trim(), date);
@@ -7671,17 +7673,17 @@ function getHeaders(githubToken) {
7671
7673
  async function getResolvedAuthorLogin(params) {
7672
7674
  const { github, githubToken, commitHashes, email } = params;
7673
7675
  let login = "";
7674
- if (!githubToken) {
7675
- return login;
7676
- }
7677
7676
  try {
7678
- const data = await ofetch.ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`);
7679
- login = data.items[0].login;
7677
+ const data = await ofetch.ofetch(`https://ungh.cc/users/find/${email}`);
7678
+ login = data?.user?.username || "";
7680
7679
  } catch {
7681
7680
  }
7682
7681
  if (login) {
7683
7682
  return login;
7684
7683
  }
7684
+ if (!githubToken) {
7685
+ return login;
7686
+ }
7685
7687
  if (commitHashes.length) {
7686
7688
  try {
7687
7689
  const data = await ofetch.ofetch(`https://api.github.com/repos/${github}/commits/${commitHashes[0]}`, {
@@ -7691,6 +7693,16 @@ async function getResolvedAuthorLogin(params) {
7691
7693
  } catch (e) {
7692
7694
  }
7693
7695
  }
7696
+ if (login) {
7697
+ return login;
7698
+ }
7699
+ try {
7700
+ const data = await ofetch.ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, {
7701
+ headers: getHeaders(githubToken)
7702
+ });
7703
+ login = data.items[0].login;
7704
+ } catch (e) {
7705
+ }
7694
7706
  return login;
7695
7707
  }
7696
7708
  async function getGitCommitsAndResolvedAuthors(commits, github, githubToken, resolvedLogins) {
@@ -7795,8 +7807,13 @@ function formatSection(commits, sectionName, options) {
7795
7807
  });
7796
7808
  return lines;
7797
7809
  }
7810
+ function getUserGithub(userName) {
7811
+ const githubUrl = `https://github.com/${userName}`;
7812
+ return githubUrl;
7813
+ }
7798
7814
  function getGitUserAvatar(userName) {
7799
- const avatarUrl = `https://github.com/${userName}.png?size=48`;
7815
+ const githubUrl = getUserGithub(userName);
7816
+ const avatarUrl = `${githubUrl}.png?size=48`;
7800
7817
  return avatarUrl;
7801
7818
  }
7802
7819
  function createContributorLine(contributors) {
@@ -7807,25 +7824,26 @@ function createContributorLine(contributors) {
7807
7824
  if (!login) {
7808
7825
  let line = `[${name}](mailto:${email})`;
7809
7826
  if (index < contributors.length - 1) {
7810
- line += ", ";
7827
+ line += ",&nbsp;";
7811
7828
  }
7812
7829
  unloginLine += line;
7813
7830
  } else {
7831
+ const githubUrl = getUserGithub(login);
7814
7832
  const avatar = getGitUserAvatar(login);
7815
- loginLine += `![${login}](${avatar}) `;
7833
+ loginLine += `[![${login}](${avatar})](${githubUrl})&nbsp;&nbsp;`;
7816
7834
  }
7817
7835
  });
7818
7836
  return `${loginLine}
7819
7837
  ${unloginLine}`;
7820
7838
  }
7821
7839
  function generateMarkdown(params) {
7822
- const VERSION_REG = /v\d+\.\d+\.\d+/;
7823
7840
  const { commits, options, showTitle, contributors } = params;
7824
7841
  const lines = [];
7825
7842
  const url = `https://github.com/${options.github}/compare/${options.from}...${options.to}`;
7826
7843
  if (showTitle) {
7827
- const version = VERSION_REG.test(options.to) ? options.to : options.newVersion;
7828
- const date = options.tagDateMap.get(options.to);
7844
+ const isNewVersion = !VERSION_REG.test(options.to);
7845
+ const version = isNewVersion ? options.newVersion : options.to;
7846
+ const date = isNewVersion ? dayjs__default().format("YY-MM-DD") : options.tagDateMap.get(options.to);
7829
7847
  let title = `## [${version}](${url})`;
7830
7848
  if (date) {
7831
7849
  title += ` (${date})`;
@@ -7846,16 +7864,14 @@ function generateMarkdown(params) {
7846
7864
  lines.push("", `##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](${url})`);
7847
7865
  }
7848
7866
  if (showTitle) {
7849
- lines.push("", "### \u2764\uFE0F Contributors", "");
7867
+ lines.push("", "### &nbsp;&nbsp;&nbsp;\u2764\uFE0F Contributors", "");
7850
7868
  const contributorLine = createContributorLine(contributors);
7851
7869
  lines.push(contributorLine);
7852
7870
  }
7853
7871
  const md = convertGitmoji.convert(lines.join("\n").trim(), true);
7854
- const markdown = md.replace(/&nbsp;/g, "");
7855
- return markdown;
7872
+ return md;
7856
7873
  }
7857
7874
  async function isVersionInMarkdown(version, mdPath) {
7858
- const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+\]/g;
7859
7875
  let isIn = false;
7860
7876
  const md = await promises.readFile(mdPath, "utf8");
7861
7877
  if (md) {
package/dist/index.mjs CHANGED
@@ -17,7 +17,7 @@ import dayjs from 'dayjs';
17
17
  import { convert } from 'convert-gitmoji';
18
18
  import versionBumpp from 'bumpp';
19
19
 
20
- const version = "0.5.0";
20
+ const version = "0.5.1";
21
21
 
22
22
  async function execCommand(cmd, args, options) {
23
23
  const { execa } = await import('execa');
@@ -7500,6 +7500,9 @@ function lintStaged() {
7500
7500
  execCommand("npx", ["lint-staged", "--config", "@soybeanjs/cli/lint-staged"], { stdio: "inherit" });
7501
7501
  }
7502
7502
 
7503
+ const VERSION_REG = /v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
7504
+ const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
7505
+
7503
7506
  async function getTotalGitTags() {
7504
7507
  const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
7505
7508
  const tags = tagStr.split("\n");
@@ -7513,13 +7516,12 @@ async function getTagDateMap() {
7513
7516
  "--simplify-by-decoration",
7514
7517
  "--pretty=format:%ci %d"
7515
7518
  ]);
7516
- const TAG_MARK = "(tag: ";
7519
+ const TAG_MARK = "tag: ";
7517
7520
  const map = /* @__PURE__ */ new Map();
7518
7521
  const dates = tagDateStr.split("\n").filter((item) => item.includes(TAG_MARK));
7519
7522
  dates.forEach((item) => {
7520
7523
  const [dateStr, tagStr] = item.split(TAG_MARK);
7521
- const date = dayjs(dateStr.trim()).format("YYYY-MM-DD");
7522
- const VERSION_REG = /v\d+\.\d+\.\d+/;
7524
+ const date = dayjs(dateStr).format("YYYY-MM-DD");
7523
7525
  const tag = tagStr.match(VERSION_REG)?.[0];
7524
7526
  if (tag && date) {
7525
7527
  map.set(tag.trim(), date);
@@ -7646,17 +7648,17 @@ function getHeaders(githubToken) {
7646
7648
  async function getResolvedAuthorLogin(params) {
7647
7649
  const { github, githubToken, commitHashes, email } = params;
7648
7650
  let login = "";
7649
- if (!githubToken) {
7650
- return login;
7651
- }
7652
7651
  try {
7653
- const data = await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`);
7654
- login = data.items[0].login;
7652
+ const data = await ofetch(`https://ungh.cc/users/find/${email}`);
7653
+ login = data?.user?.username || "";
7655
7654
  } catch {
7656
7655
  }
7657
7656
  if (login) {
7658
7657
  return login;
7659
7658
  }
7659
+ if (!githubToken) {
7660
+ return login;
7661
+ }
7660
7662
  if (commitHashes.length) {
7661
7663
  try {
7662
7664
  const data = await ofetch(`https://api.github.com/repos/${github}/commits/${commitHashes[0]}`, {
@@ -7666,6 +7668,16 @@ async function getResolvedAuthorLogin(params) {
7666
7668
  } catch (e) {
7667
7669
  }
7668
7670
  }
7671
+ if (login) {
7672
+ return login;
7673
+ }
7674
+ try {
7675
+ const data = await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, {
7676
+ headers: getHeaders(githubToken)
7677
+ });
7678
+ login = data.items[0].login;
7679
+ } catch (e) {
7680
+ }
7669
7681
  return login;
7670
7682
  }
7671
7683
  async function getGitCommitsAndResolvedAuthors(commits, github, githubToken, resolvedLogins) {
@@ -7770,8 +7782,13 @@ function formatSection(commits, sectionName, options) {
7770
7782
  });
7771
7783
  return lines;
7772
7784
  }
7785
+ function getUserGithub(userName) {
7786
+ const githubUrl = `https://github.com/${userName}`;
7787
+ return githubUrl;
7788
+ }
7773
7789
  function getGitUserAvatar(userName) {
7774
- const avatarUrl = `https://github.com/${userName}.png?size=48`;
7790
+ const githubUrl = getUserGithub(userName);
7791
+ const avatarUrl = `${githubUrl}.png?size=48`;
7775
7792
  return avatarUrl;
7776
7793
  }
7777
7794
  function createContributorLine(contributors) {
@@ -7782,25 +7799,26 @@ function createContributorLine(contributors) {
7782
7799
  if (!login) {
7783
7800
  let line = `[${name}](mailto:${email})`;
7784
7801
  if (index < contributors.length - 1) {
7785
- line += ", ";
7802
+ line += ",&nbsp;";
7786
7803
  }
7787
7804
  unloginLine += line;
7788
7805
  } else {
7806
+ const githubUrl = getUserGithub(login);
7789
7807
  const avatar = getGitUserAvatar(login);
7790
- loginLine += `![${login}](${avatar}) `;
7808
+ loginLine += `[![${login}](${avatar})](${githubUrl})&nbsp;&nbsp;`;
7791
7809
  }
7792
7810
  });
7793
7811
  return `${loginLine}
7794
7812
  ${unloginLine}`;
7795
7813
  }
7796
7814
  function generateMarkdown(params) {
7797
- const VERSION_REG = /v\d+\.\d+\.\d+/;
7798
7815
  const { commits, options, showTitle, contributors } = params;
7799
7816
  const lines = [];
7800
7817
  const url = `https://github.com/${options.github}/compare/${options.from}...${options.to}`;
7801
7818
  if (showTitle) {
7802
- const version = VERSION_REG.test(options.to) ? options.to : options.newVersion;
7803
- const date = options.tagDateMap.get(options.to);
7819
+ const isNewVersion = !VERSION_REG.test(options.to);
7820
+ const version = isNewVersion ? options.newVersion : options.to;
7821
+ const date = isNewVersion ? dayjs().format("YY-MM-DD") : options.tagDateMap.get(options.to);
7804
7822
  let title = `## [${version}](${url})`;
7805
7823
  if (date) {
7806
7824
  title += ` (${date})`;
@@ -7821,16 +7839,14 @@ function generateMarkdown(params) {
7821
7839
  lines.push("", `##### &nbsp;&nbsp;&nbsp;&nbsp;[View changes on GitHub](${url})`);
7822
7840
  }
7823
7841
  if (showTitle) {
7824
- lines.push("", "### \u2764\uFE0F Contributors", "");
7842
+ lines.push("", "### &nbsp;&nbsp;&nbsp;\u2764\uFE0F Contributors", "");
7825
7843
  const contributorLine = createContributorLine(contributors);
7826
7844
  lines.push(contributorLine);
7827
7845
  }
7828
7846
  const md = convert(lines.join("\n").trim(), true);
7829
- const markdown = md.replace(/&nbsp;/g, "");
7830
- return markdown;
7847
+ return md;
7831
7848
  }
7832
7849
  async function isVersionInMarkdown(version, mdPath) {
7833
- const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+\]/g;
7834
7850
  let isIn = false;
7835
7851
  const md = await readFile(mdPath, "utf8");
7836
7852
  if (md) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "SoybeanJS's command line tools",
5
5
  "author": {
6
6
  "name": "Soybean",
@@ -61,7 +61,7 @@
61
61
  "commit-msg": "pnpm soy git-commit-verify",
62
62
  "pre-commit": "pnpm typecheck && pnpm soy lint-staged"
63
63
  },
64
- "github-token": "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",
64
+ "github-token": "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",
65
65
  "scripts": {
66
66
  "build": "pnpm typecheck && unbuild",
67
67
  "lint": "eslint . --fix",