githublogen 0.1.4 → 0.1.5
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/cli.cjs +3 -2
- package/dist/cli.mjs +4 -3
- package/dist/index.cjs +7 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +7 -3
- package/package.json +1 -1
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.
|
|
23
|
+
const version = "0.1.5";
|
|
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();
|
|
@@ -75,11 +75,12 @@ ${changelog}
|
|
|
75
75
|
}
|
|
76
76
|
await fs.promises.writeFile(config.output, changelogMD);
|
|
77
77
|
const { email = "unknow@unknow.com", name = "unknow" } = commits[0]?.author || {};
|
|
78
|
+
const branchMain = await index.getGitMainBranchName();
|
|
78
79
|
await execa.execa("git", ["config", "--global", "user.email", `"${email}"`]);
|
|
79
80
|
await execa.execa("git", ["config", "--global", "user.name", `"${name}"`]);
|
|
80
81
|
await execa.execa("git", ["add", "."]);
|
|
81
82
|
await execa.execa("git", ["commit", "-m", '"docs(projects): CHANGELOG.md"'], { cwd });
|
|
82
|
-
await execa.execa("git", ["push", pushUrl], { cwd });
|
|
83
|
+
await execa.execa("git", ["push", pushUrl, `HEAD:${branchMain}`], { cwd });
|
|
83
84
|
}
|
|
84
85
|
if (!await index.hasTagOnGitHub(config.to, config)) {
|
|
85
86
|
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, getGitPushUrl, hasTagOnGitHub, isRepoShallow, sendRelease } from './index.mjs';
|
|
6
|
+
import { generate, getGitPushUrl, getGitMainBranchName, 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.
|
|
17
|
+
const version = "0.1.5";
|
|
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();
|
|
@@ -69,11 +69,12 @@ ${changelog}
|
|
|
69
69
|
}
|
|
70
70
|
await promises.writeFile(config.output, changelogMD);
|
|
71
71
|
const { email = "unknow@unknow.com", name = "unknow" } = commits[0]?.author || {};
|
|
72
|
+
const branchMain = await getGitMainBranchName();
|
|
72
73
|
await execa("git", ["config", "--global", "user.email", `"${email}"`]);
|
|
73
74
|
await execa("git", ["config", "--global", "user.name", `"${name}"`]);
|
|
74
75
|
await execa("git", ["add", "."]);
|
|
75
76
|
await execa("git", ["commit", "-m", '"docs(projects): CHANGELOG.md"'], { cwd });
|
|
76
|
-
await execa("git", ["push", pushUrl], { cwd });
|
|
77
|
+
await execa("git", ["push", pushUrl, `HEAD:${branchMain}`], { cwd });
|
|
77
78
|
}
|
|
78
79
|
if (!await hasTagOnGitHub(config.to, config)) {
|
|
79
80
|
console.error(yellow(`Current ref "${bold(config.to)}" is not available as tags on GitHub. Release skipped.`));
|
package/dist/index.cjs
CHANGED
|
@@ -193,10 +193,14 @@ async function getGitHubRepo() {
|
|
|
193
193
|
}
|
|
194
194
|
return `${match[1]}/${match[2]}`;
|
|
195
195
|
}
|
|
196
|
+
async function getGitMainBranchName() {
|
|
197
|
+
const main = await execCommand("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
198
|
+
return main;
|
|
199
|
+
}
|
|
196
200
|
async function getCurrentGitBranch() {
|
|
197
201
|
const result1 = await execCommand("git", ["tag", "--points-at", "HEAD"]);
|
|
198
|
-
const
|
|
199
|
-
return result1 ||
|
|
202
|
+
const main = getGitMainBranchName();
|
|
203
|
+
return result1 || main;
|
|
200
204
|
}
|
|
201
205
|
async function isRepoShallow() {
|
|
202
206
|
return (await execCommand("git", ["rev-parse", "--is-shallow-repository"])).trim() === "true";
|
|
@@ -8433,6 +8437,7 @@ exports.getCurrentGitBranch = getCurrentGitBranch;
|
|
|
8433
8437
|
exports.getFirstGitCommit = getFirstGitCommit;
|
|
8434
8438
|
exports.getGitDiff = getGitDiff;
|
|
8435
8439
|
exports.getGitHubRepo = getGitHubRepo;
|
|
8440
|
+
exports.getGitMainBranchName = getGitMainBranchName;
|
|
8436
8441
|
exports.getGitPushUrl = getGitPushUrl;
|
|
8437
8442
|
exports.getGitRemoteURL = getGitRemoteURL;
|
|
8438
8443
|
exports.getLastGitTag = getLastGitTag;
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,7 @@ declare function resolveAuthors(commits: Commit[], options: ChangelogOptions): P
|
|
|
116
116
|
declare function hasTagOnGitHub(tag: string, options: ChangelogOptions): Promise<boolean>;
|
|
117
117
|
|
|
118
118
|
declare function getGitHubRepo(): Promise<string>;
|
|
119
|
+
declare function getGitMainBranchName(): Promise<string>;
|
|
119
120
|
declare function getCurrentGitBranch(): Promise<string>;
|
|
120
121
|
declare function isRepoShallow(): Promise<boolean>;
|
|
121
122
|
declare function getLastGitTag(delta?: number): Promise<string>;
|
|
@@ -141,4 +142,4 @@ declare function resolveConfig(cwd: string, options: ChangelogOptions): Promise<
|
|
|
141
142
|
declare function parseGitCommit(commit: RawGitCommit, config: ChangelogConfig): GitCommit | null;
|
|
142
143
|
declare function parseCommits(commits: RawGitCommit[], config: ChangelogConfig): GitCommit[];
|
|
143
144
|
|
|
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 };
|
|
145
|
+
export { AuthorInfo, ChangelogConfig, ChangelogOptions, Commit, GitCommit, GitCommitAuthor, GithubOptions, GithubRelease, RawGitCommit, Reference, RepoConfig, RepoProvider, ResolvedChangelogOptions, SemverBumpType, generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitMainBranchName, getGitPushUrl, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
|
package/dist/index.mjs
CHANGED
|
@@ -183,10 +183,14 @@ async function getGitHubRepo() {
|
|
|
183
183
|
}
|
|
184
184
|
return `${match[1]}/${match[2]}`;
|
|
185
185
|
}
|
|
186
|
+
async function getGitMainBranchName() {
|
|
187
|
+
const main = await execCommand("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
188
|
+
return main;
|
|
189
|
+
}
|
|
186
190
|
async function getCurrentGitBranch() {
|
|
187
191
|
const result1 = await execCommand("git", ["tag", "--points-at", "HEAD"]);
|
|
188
|
-
const
|
|
189
|
-
return result1 ||
|
|
192
|
+
const main = getGitMainBranchName();
|
|
193
|
+
return result1 || main;
|
|
190
194
|
}
|
|
191
195
|
async function isRepoShallow() {
|
|
192
196
|
return (await execCommand("git", ["rev-parse", "--is-shallow-repository"])).trim() === "true";
|
|
@@ -8416,4 +8420,4 @@ async function generate(cwd, options) {
|
|
|
8416
8420
|
return { config: resolved, md, commits, changelog };
|
|
8417
8421
|
}
|
|
8418
8422
|
|
|
8419
|
-
export { generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitPushUrl, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
|
|
8423
|
+
export { generate, generateChangelog, generateMarkdown, getCurrentGitBranch, getFirstGitCommit, getGitDiff, getGitHubRepo, getGitMainBranchName, getGitPushUrl, getGitRemoteURL, getLastGitTag, hasTagOnGitHub, isPrerelease, isRefGitTag, isRepoShallow, parseCommits, parseGitCommit, resolveAuthorInfo, resolveAuthors, resolveConfig, sendRelease };
|