githublogen 0.1.2 → 0.1.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
@@ -47,8 +47,3 @@ You can put a configuration file in the project root, named as `githublogen.conf
47
47
  ```bash
48
48
  npx githublogen --dry
49
49
  ```
50
-
51
-
52
-
53
-
54
-
package/dist/cli.cjs CHANGED
@@ -20,7 +20,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
20
20
 
21
21
  const cac__default = /*#__PURE__*/_interopDefaultCompat(cac);
22
22
 
23
- const version = "0.1.2";
23
+ const version = "0.1.4";
24
24
 
25
25
  const cli = cac__default("githublogen");
26
26
  cli.version(version).option("-t, --token <path>", "GitHub Token").option("--from <ref>", "From tag").option("--to <ref>", "To tag").option("--github <path>", "GitHub Repository, e.g. soybeanjs/githublogen").option("--name <name>", "Name of the release").option("--contributors", "Show contributors section").option("--prerelease", "Mark release as prerelease").option("-d, --draft", "Mark release as draft").option("--output <path>", "Output to file instead of sending to GitHub").option("--capitalize", "Should capitalize for each comment message").option("--emoji", "Use emojis in section titles", { default: true }).option("--group", "Nest commit messages under their scopes").option("--dry", "Dry run").help();
@@ -42,6 +42,10 @@ cli.command("").action(async (args) => {
42
42
  return;
43
43
  }
44
44
  if (typeof config.output === "string") {
45
+ const pushUrl = index.getGitPushUrl(config.repo, config.tokens.github);
46
+ if (!pushUrl) {
47
+ return;
48
+ }
45
49
  let changelogMD;
46
50
  const changelogPrefix = "# Changelog";
47
51
  if (fs.existsSync(config.output)) {
@@ -70,9 +74,12 @@ ${changelog}
70
74
  `;
71
75
  }
72
76
  await fs.promises.writeFile(config.output, changelogMD);
77
+ const { email = "unknow@unknow.com", name = "unknow" } = commits[0]?.author || {};
78
+ await execa.execa("git", ["config", "--global", "user.email", `"${email}"`]);
79
+ await execa.execa("git", ["config", "--global", "user.name", `"${name}"`]);
73
80
  await execa.execa("git", ["add", "."]);
74
- await execa.execa("git", ["commit", "-m", "docs(projects): CHANGELOG.md"], { cwd });
75
- await execa.execa("git", ["push"], { cwd });
81
+ await execa.execa("git", ["commit", "-m", '"docs(projects): CHANGELOG.md"'], { cwd });
82
+ await execa.execa("git", ["push", pushUrl], { cwd });
76
83
  }
77
84
  if (!await index.hasTagOnGitHub(config.to, config)) {
78
85
  console.error(kolorist.yellow(`Current ref "${kolorist.bold(config.to)}" is not available as tags on GitHub. Release skipped.`));
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import { existsSync, promises } from 'node:fs';
3
3
  import { dim, bold, cyan, blue, yellow, red } from 'kolorist';
4
4
  import { execa } from 'execa';
5
5
  import cac from 'cac';
6
- import { generate, hasTagOnGitHub, isRepoShallow, sendRelease } from './index.mjs';
6
+ import { generate, getGitPushUrl, hasTagOnGitHub, isRepoShallow, sendRelease } from './index.mjs';
7
7
  import 'ohmyfetch';
8
8
  import 'convert-gitmoji';
9
9
  import 'node:module';
@@ -14,7 +14,7 @@ import 'node:path';
14
14
  import 'node:v8';
15
15
  import 'node:util';
16
16
 
17
- const version = "0.1.2";
17
+ const version = "0.1.4";
18
18
 
19
19
  const cli = cac("githublogen");
20
20
  cli.version(version).option("-t, --token <path>", "GitHub Token").option("--from <ref>", "From tag").option("--to <ref>", "To tag").option("--github <path>", "GitHub Repository, e.g. soybeanjs/githublogen").option("--name <name>", "Name of the release").option("--contributors", "Show contributors section").option("--prerelease", "Mark release as prerelease").option("-d, --draft", "Mark release as draft").option("--output <path>", "Output to file instead of sending to GitHub").option("--capitalize", "Should capitalize for each comment message").option("--emoji", "Use emojis in section titles", { default: true }).option("--group", "Nest commit messages under their scopes").option("--dry", "Dry run").help();
@@ -36,6 +36,10 @@ cli.command("").action(async (args) => {
36
36
  return;
37
37
  }
38
38
  if (typeof config.output === "string") {
39
+ const pushUrl = getGitPushUrl(config.repo, config.tokens.github);
40
+ if (!pushUrl) {
41
+ return;
42
+ }
39
43
  let changelogMD;
40
44
  const changelogPrefix = "# Changelog";
41
45
  if (existsSync(config.output)) {
@@ -64,9 +68,12 @@ ${changelog}
64
68
  `;
65
69
  }
66
70
  await promises.writeFile(config.output, changelogMD);
71
+ const { email = "unknow@unknow.com", name = "unknow" } = commits[0]?.author || {};
72
+ await execa("git", ["config", "--global", "user.email", `"${email}"`]);
73
+ await execa("git", ["config", "--global", "user.name", `"${name}"`]);
67
74
  await execa("git", ["add", "."]);
68
- await execa("git", ["commit", "-m", "docs(projects): CHANGELOG.md"], { cwd });
69
- await execa("git", ["push"], { cwd });
75
+ await execa("git", ["commit", "-m", '"docs(projects): CHANGELOG.md"'], { cwd });
76
+ await execa("git", ["push", pushUrl], { cwd });
70
77
  }
71
78
  if (!await hasTagOnGitHub(config.to, config)) {
72
79
  console.error(yellow(`Current ref "${bold(config.to)}" is not available as tags on GitHub. Release skipped.`));
package/dist/index.cjs CHANGED
@@ -248,6 +248,11 @@ async function getGitDiff(from, to = "HEAD") {
248
248
  function getGitRemoteURL(cwd, remote = "origin") {
249
249
  return execCommand("git", [`--work-tree=${cwd}`, "remote", "get-url", remote]);
250
250
  }
251
+ function getGitPushUrl(config, token) {
252
+ if (!token)
253
+ return null;
254
+ return `https://${token}@${config.domain}/${config.repo}`;
255
+ }
251
256
 
252
257
  function normalizeWindowsPath(input = "") {
253
258
  if (!input || !input.includes("\\")) {
@@ -8428,6 +8433,7 @@ exports.getCurrentGitBranch = getCurrentGitBranch;
8428
8433
  exports.getFirstGitCommit = getFirstGitCommit;
8429
8434
  exports.getGitDiff = getGitDiff;
8430
8435
  exports.getGitHubRepo = getGitHubRepo;
8436
+ exports.getGitPushUrl = getGitPushUrl;
8431
8437
  exports.getGitRemoteURL = getGitRemoteURL;
8432
8438
  exports.getLastGitTag = getLastGitTag;
8433
8439
  exports.hasTagOnGitHub = hasTagOnGitHub;
package/dist/index.d.ts CHANGED
@@ -124,6 +124,7 @@ declare function getFirstGitCommit(): Promise<string>;
124
124
  declare function isPrerelease(version: string): boolean;
125
125
  declare function getGitDiff(from: string | undefined, to?: string): Promise<RawGitCommit[]>;
126
126
  declare function getGitRemoteURL(cwd: string, remote?: string): Promise<string>;
127
+ declare function getGitPushUrl(config: RepoConfig, token?: string): string | null;
127
128
 
128
129
  declare function generateMarkdown(commits: Commit[], options: ResolvedChangelogOptions): string;
129
130
  declare function generateChangelog(commits: Commit[], config: ResolvedChangelogOptions): Promise<string>;
@@ -140,4 +141,4 @@ declare function resolveConfig(cwd: string, options: ChangelogOptions): Promise<
140
141
  declare function parseGitCommit(commit: RawGitCommit, config: ChangelogConfig): GitCommit | null;
141
142
  declare function parseCommits(commits: RawGitCommit[], config: ChangelogConfig): GitCommit[];
142
143
 
143
- export { AuthorInfo, ChangelogConfig, ChangelogOptions, Commit, GitCommit, GitCommitAuthor, GithubOptions, GithubRelease, RawGitCommit, Reference, RepoConfig, RepoProvider, ResolvedChangelogOptions, SemverBumpType, generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
144
+ export { AuthorInfo, ChangelogConfig, ChangelogOptions, Commit, GitCommit, GitCommitAuthor, GithubOptions, GithubRelease, RawGitCommit, Reference, RepoConfig, RepoProvider, ResolvedChangelogOptions, SemverBumpType, generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitPushUrl, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
package/dist/index.mjs CHANGED
@@ -238,6 +238,11 @@ async function getGitDiff(from, to = "HEAD") {
238
238
  function getGitRemoteURL(cwd, remote = "origin") {
239
239
  return execCommand("git", [`--work-tree=${cwd}`, "remote", "get-url", remote]);
240
240
  }
241
+ function getGitPushUrl(config, token) {
242
+ if (!token)
243
+ return null;
244
+ return `https://${token}@${config.domain}/${config.repo}`;
245
+ }
241
246
 
242
247
  function normalizeWindowsPath(input = "") {
243
248
  if (!input || !input.includes("\\")) {
@@ -8411,4 +8416,4 @@ async function generate(cwd, options) {
8411
8416
  return { config: resolved, md, commits, changelog };
8412
8417
  }
8413
8418
 
8414
- export { generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
8419
+ export { generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitPushUrl, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "githublogen",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "sideEffects": false,
6
6
  "author": {
7
7
  "name": "SoybeanJS",