git-release-manager 0.0.0 → 0.0.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/src/config/defaultConfig.json +232 -0
- package/dist/src/config/index.js +86 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/types.js +3 -0
- package/dist/src/config/types.js.map +1 -0
- package/dist/src/core/app.js +218 -0
- package/dist/src/core/app.js.map +1 -0
- package/dist/src/core/types.js +3 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/git/commits.js +237 -0
- package/dist/src/git/commits.js.map +1 -0
- package/dist/src/git/context.js +95 -0
- package/dist/src/git/context.js.map +1 -0
- package/dist/src/index.js +89 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/main.js +22 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/output/writer.js +46 -0
- package/dist/src/output/writer.js.map +1 -0
- package/dist/src/sections/index.js +207 -0
- package/dist/src/sections/index.js.map +1 -0
- package/dist/src/templates/changelog.detailed.ejs +111 -0
- package/dist/src/templates/changelog.ejs +68 -0
- package/dist/src/templates/index.js +101 -0
- package/dist/src/templates/index.js.map +1 -0
- package/dist/src/utils/cli.js +3 -0
- package/dist/src/utils/cli.js.map +1 -0
- package/dist/src/utils/cmd.js +57 -0
- package/dist/src/utils/cmd.js.map +1 -0
- package/dist/src/utils/git-utils.js +278 -0
- package/dist/src/utils/git-utils.js.map +1 -0
- package/dist/src/utils/helpers.js +50 -0
- package/dist/src/utils/helpers.js.map +1 -0
- package/dist/test/config/loadConfigFile.test.js +94 -0
- package/dist/test/config/loadConfigFile.test.js.map +1 -0
- package/dist/test/config/readConfig.test.js +125 -0
- package/dist/test/config/readConfig.test.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listCommitsAsync = listCommitsAsync;
|
|
7
|
+
exports.getGitLogAsJson = getGitLogAsJson;
|
|
8
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const util_1 = __importDefault(require("util"));
|
|
11
|
+
const execPromise = util_1.default.promisify(child_process_1.exec);
|
|
12
|
+
const profileUrlCache = new Map();
|
|
13
|
+
function createCommitMessageRegex(commitTypes) {
|
|
14
|
+
if (!(commitTypes === null || commitTypes === void 0 ? void 0 : commitTypes.length))
|
|
15
|
+
return null;
|
|
16
|
+
const types = commitTypes.flatMap(commitType => commitType.terms);
|
|
17
|
+
const joinedTypes = types.map(type => type.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
18
|
+
return new RegExp(`^(${joinedTypes})(\\(.+\\))?[!+~?*]?:\\s.+$`);
|
|
19
|
+
}
|
|
20
|
+
function createLinkRegex(linkTypes) {
|
|
21
|
+
if (!(linkTypes === null || linkTypes === void 0 ? void 0 : linkTypes.length))
|
|
22
|
+
return null;
|
|
23
|
+
const terms = linkTypes.filter(linkType => linkType.terms).flatMap(linkType => linkType.terms || []);
|
|
24
|
+
const joinedTerms = terms.map(term => term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
25
|
+
return new RegExp(`(${joinedTerms}):?\\s#?(\\d+)`, "gi");
|
|
26
|
+
}
|
|
27
|
+
function createMentionRegex(mentionTypes) {
|
|
28
|
+
if (!(mentionTypes === null || mentionTypes === void 0 ? void 0 : mentionTypes.length))
|
|
29
|
+
return null;
|
|
30
|
+
const terms = mentionTypes.flatMap(mentionType => mentionType.terms);
|
|
31
|
+
const joinedTerms = terms.map(term => term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
32
|
+
return new RegExp(`(?:${joinedTerms}):\\s(.+)\\s<(.+)>`, "gi");
|
|
33
|
+
}
|
|
34
|
+
async function enrichCommit(commit, config) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36
|
+
const match = commit.message.match(/^(?<type>\w+)(\((?<scope>[^\)]+)\))?(?<modifier>[!+~?*])?:\s(?<summary>.+)$/);
|
|
37
|
+
const type = ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
|
|
38
|
+
const scope = ((_b = match === null || match === void 0 ? void 0 : match.groups) === null || _b === void 0 ? void 0 : _b.scope) || null;
|
|
39
|
+
const modifier = ((_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.modifier) || null;
|
|
40
|
+
const summary = ((_d = match === null || match === void 0 ? void 0 : match.groups) === null || _d === void 0 ? void 0 : _d.summary) || commit.message;
|
|
41
|
+
let description = ((_e = commit.body) === null || _e === void 0 ? void 0 : _e.trim()) || null;
|
|
42
|
+
const tagDescription = (description === null || description === void 0 ? void 0 : description.trim()) || "";
|
|
43
|
+
const tagRegex = /Tags:\s(.+)/i;
|
|
44
|
+
const labels = [];
|
|
45
|
+
const labelsMatch = tagDescription.match(tagRegex);
|
|
46
|
+
if (labelsMatch) {
|
|
47
|
+
labels.push(...labelsMatch[1].split(",").map(label => (label === null || label === void 0 ? void 0 : label.trim()) || ""));
|
|
48
|
+
description = ((_f = description === null || description === void 0 ? void 0 : description.replace(labelsMatch[0], "")) === null || _f === void 0 ? void 0 : _f.trim()) || null;
|
|
49
|
+
}
|
|
50
|
+
const mentionDescription = (description === null || description === void 0 ? void 0 : description.trim()) || "";
|
|
51
|
+
const mentionRegex = createMentionRegex(config.mentionTypes);
|
|
52
|
+
const mentions = [];
|
|
53
|
+
let mentionMatch;
|
|
54
|
+
if (mentionRegex) {
|
|
55
|
+
while ((mentionMatch = mentionRegex.exec(mentionDescription)) !== null) {
|
|
56
|
+
const matchedTerm = (_g = mentionMatch[0].split(":")[0]) === null || _g === void 0 ? void 0 : _g.trim();
|
|
57
|
+
const matchedType = config.mentionTypes.find(mentionType => mentionType.terms.includes(matchedTerm));
|
|
58
|
+
const profileUrl = await prepareProfileUrlsByEMail(((_h = mentionMatch[2]) === null || _h === void 0 ? void 0 : _h.trim()) || "");
|
|
59
|
+
if (matchedType) {
|
|
60
|
+
mentions.push({
|
|
61
|
+
type: matchedType.type,
|
|
62
|
+
title: matchedType.title,
|
|
63
|
+
name: ((_j = mentionMatch[1]) === null || _j === void 0 ? void 0 : _j.trim()) || "",
|
|
64
|
+
email: ((_k = mentionMatch[2]) === null || _k === void 0 ? void 0 : _k.trim()) || "",
|
|
65
|
+
profileUrl
|
|
66
|
+
});
|
|
67
|
+
description = ((_l = description === null || description === void 0 ? void 0 : description.replace(mentionMatch[0], "")) === null || _l === void 0 ? void 0 : _l.trim()) || null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const linkDescription = (description === null || description === void 0 ? void 0 : description.trim()) || "";
|
|
72
|
+
const linkRegex = createLinkRegex(config.linkTypes);
|
|
73
|
+
const links = [];
|
|
74
|
+
let linkMatch;
|
|
75
|
+
if (linkRegex) {
|
|
76
|
+
while ((linkMatch = linkRegex.exec(linkDescription)) !== null) {
|
|
77
|
+
const matchedTerm = (_m = linkMatch[1]) === null || _m === void 0 ? void 0 : _m.trim();
|
|
78
|
+
const matchedType = config.linkTypes.filter(linkType => linkType.terms).find(linkType => { var _a; return (_a = linkType.terms) === null || _a === void 0 ? void 0 : _a.includes(matchedTerm); });
|
|
79
|
+
if (matchedType) {
|
|
80
|
+
links.push({
|
|
81
|
+
type: matchedType.type,
|
|
82
|
+
title: matchedType.title,
|
|
83
|
+
id: parseInt(linkMatch[2], 10)
|
|
84
|
+
});
|
|
85
|
+
description = ((_o = description === null || description === void 0 ? void 0 : description.replace(linkMatch[0], "")) === null || _o === void 0 ? void 0 : _o.trim()) || null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const commitMessage = ((_p = commit.message) === null || _p === void 0 ? void 0 : _p.trim()) || "";
|
|
90
|
+
const processedIds = new Set(links.map(link => link.id));
|
|
91
|
+
config.linkTypes.forEach(linkType => {
|
|
92
|
+
var _a;
|
|
93
|
+
if (linkType.sign) {
|
|
94
|
+
const signRegex = new RegExp(`\\${linkType.sign[0]}(\\d+)`, "g");
|
|
95
|
+
let signMatch;
|
|
96
|
+
while ((signMatch = signRegex.exec(linkDescription)) !== null) {
|
|
97
|
+
const matchedId = parseInt(signMatch[1], 10);
|
|
98
|
+
if (processedIds.has(matchedId)) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!links.some(link => link.type === linkType.type && link.id === matchedId)) {
|
|
102
|
+
links.push({
|
|
103
|
+
type: linkType.type,
|
|
104
|
+
title: linkType.title,
|
|
105
|
+
id: matchedId
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
description = ((_a = description === null || description === void 0 ? void 0 : description.replace(signMatch[0], "")) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
109
|
+
}
|
|
110
|
+
while ((signMatch = signRegex.exec(commitMessage)) !== null) {
|
|
111
|
+
const matchedId = parseInt(signMatch[1], 10);
|
|
112
|
+
if (processedIds.has(matchedId)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (!links.some(link => link.type === linkType.type && link.id === matchedId)) {
|
|
116
|
+
links.push({
|
|
117
|
+
type: linkType.type,
|
|
118
|
+
title: linkType.title,
|
|
119
|
+
id: matchedId
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
const noteDescription = (description === null || description === void 0 ? void 0 : description.trim()) || "";
|
|
126
|
+
const notes = [];
|
|
127
|
+
const noteRegex = /(.*?):\s(.+)/g;
|
|
128
|
+
let noteMatch;
|
|
129
|
+
while ((noteMatch = noteRegex.exec(noteDescription)) !== null) {
|
|
130
|
+
notes.push({
|
|
131
|
+
type: noteMatch[1].toLowerCase(),
|
|
132
|
+
content: noteMatch[2]
|
|
133
|
+
});
|
|
134
|
+
description = ((_q = description === null || description === void 0 ? void 0 : description.replace(noteMatch[0], "")) === null || _q === void 0 ? void 0 : _q.trim()) || null;
|
|
135
|
+
}
|
|
136
|
+
const typeTitle = getTypeTitle(config.commitTypes, type);
|
|
137
|
+
const profileUrl = await prepareProfileUrlsByEMail(commit.authorEmail);
|
|
138
|
+
const commitContent = {
|
|
139
|
+
type,
|
|
140
|
+
typeTitle,
|
|
141
|
+
scope,
|
|
142
|
+
modifier,
|
|
143
|
+
summary,
|
|
144
|
+
description,
|
|
145
|
+
author: {
|
|
146
|
+
name: commit.authorName,
|
|
147
|
+
email: commit.authorEmail,
|
|
148
|
+
profileUrl
|
|
149
|
+
},
|
|
150
|
+
mentions,
|
|
151
|
+
links,
|
|
152
|
+
notes,
|
|
153
|
+
labels,
|
|
154
|
+
raw: commit,
|
|
155
|
+
files: []
|
|
156
|
+
};
|
|
157
|
+
return commitContent;
|
|
158
|
+
}
|
|
159
|
+
function getTypeTitle(commitTypes, type) {
|
|
160
|
+
const matchingType = commitTypes.find(ct => ct.terms.includes(type || ""));
|
|
161
|
+
return matchingType ? matchingType.title : "Other Changes";
|
|
162
|
+
}
|
|
163
|
+
async function prepareProfileUrlsByEMail(email) {
|
|
164
|
+
if (!email) {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
if (!profileUrlCache.has(email)) {
|
|
168
|
+
const profileUrl = ""; // await getGitHubProfileUrl(email, process.env.GITHUB_TOKEN);
|
|
169
|
+
profileUrlCache.set(email, profileUrl || `mailto:${email}`);
|
|
170
|
+
}
|
|
171
|
+
return profileUrlCache.get(email);
|
|
172
|
+
}
|
|
173
|
+
async function getGitHubProfileUrl(email, token) {
|
|
174
|
+
const url = `https://api.github.com/search/users?q=${email}`;
|
|
175
|
+
try {
|
|
176
|
+
const response = await fetch(url, {
|
|
177
|
+
headers: token ? {
|
|
178
|
+
Authorization: `token ${token}`
|
|
179
|
+
} : {}
|
|
180
|
+
});
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
console.error("API Request Failed:", response.statusText);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const data = await response.json();
|
|
186
|
+
if (data.total_count > 0 && data.items[0].html_url) {
|
|
187
|
+
return data.items[0].html_url;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
console.warn("No GitHub profile found for email:", email);
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.error("Error fetching GitHub profile:", error);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function listCommitsAsync(range, config) {
|
|
200
|
+
const commits = await getGitLogAsJson(range);
|
|
201
|
+
const commitMessageRegex = createCommitMessageRegex(config.commitTypes);
|
|
202
|
+
if (!commitMessageRegex) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
const filteredCommits = commits.filter(commit => commitMessageRegex.test(commit.message));
|
|
206
|
+
const commitList = await Promise.all(filteredCommits.map(async (commit) => {
|
|
207
|
+
const parsedCommit = await enrichCommit(commit, config);
|
|
208
|
+
const { stdout: filesOutput } = await execPromise(`git log --pretty=format:"" --no-commit-id --name-only -r ${parsedCommit.raw.hash}`);
|
|
209
|
+
const files = filesOutput.split('\n').filter(Boolean);
|
|
210
|
+
return {
|
|
211
|
+
...parsedCommit,
|
|
212
|
+
files
|
|
213
|
+
};
|
|
214
|
+
}));
|
|
215
|
+
return commitList;
|
|
216
|
+
}
|
|
217
|
+
async function getGitLogAsJson(range = null) {
|
|
218
|
+
const git = (0, simple_git_1.default)();
|
|
219
|
+
try {
|
|
220
|
+
const log = range ? await git.log([range]) : await git.log();
|
|
221
|
+
const jsonArray = log.all.map(commit => ({
|
|
222
|
+
hash: commit.hash,
|
|
223
|
+
shortHash: commit.hash.substring(0, 7),
|
|
224
|
+
message: commit.message,
|
|
225
|
+
body: commit.body,
|
|
226
|
+
authorName: commit.author_name,
|
|
227
|
+
authorEmail: commit.author_email,
|
|
228
|
+
date: commit.date
|
|
229
|
+
}));
|
|
230
|
+
return jsonArray;
|
|
231
|
+
}
|
|
232
|
+
catch (error) {
|
|
233
|
+
console.error("Error fetching git log:", error);
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=commits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../../../src/git/commits.ts"],"names":[],"mappings":";;;;;AA8VI,4CAAgB;AAChB,0CAAe;AA/VnB,4DAAmC;AACnC,iDAAqC;AACrC,gDAAwB;AAExB,MAAM,WAAW,GAAG,cAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AAgFzC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;AAElD,SAAS,wBAAwB,CAAC,WAAyB;IACvD,IAAI,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,CAAA;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7F,OAAO,IAAI,MAAM,CAAC,KAAK,WAAW,6BAA6B,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,eAAe,CAAC,SAAqB;IAC1C,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAA;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,KAAK,GAAG,SAAS,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od) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getGitContextAsync = getGitContextAsync;
|
|
7
|
+
exports.getBranchesAsync = getBranchesAsync;
|
|
8
|
+
exports.getCommitsAsync = getCommitsAsync;
|
|
9
|
+
exports.getStatusAsync = getStatusAsync;
|
|
10
|
+
exports.getTagsAsync = getTagsAsync;
|
|
11
|
+
exports.parseRemoteUrl = parseRemoteUrl;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const util_1 = __importDefault(require("util"));
|
|
14
|
+
const execPromise = util_1.default.promisify(child_process_1.exec);
|
|
15
|
+
async function getGitContextAsync() {
|
|
16
|
+
const [{ stdout: remoteUrl }, { stdout: name }] = await Promise.all([
|
|
17
|
+
execPromise("git config --get remote.origin.url"),
|
|
18
|
+
execPromise("git rev-parse --show-toplevel")
|
|
19
|
+
]);
|
|
20
|
+
const result = {
|
|
21
|
+
name: name.trim(),
|
|
22
|
+
path: name.trim(),
|
|
23
|
+
remote: parseRemoteUrl(remoteUrl.trim()),
|
|
24
|
+
branches: await getBranchesAsync(),
|
|
25
|
+
tags: await getTagsAsync(),
|
|
26
|
+
commits: await getCommitsAsync(),
|
|
27
|
+
status: await getStatusAsync()
|
|
28
|
+
};
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
const cleanList = (output) => (output === null || output === void 0 ? void 0 : output.split("\n").map((line) => line.trim()).filter(Boolean)) || [];
|
|
32
|
+
function parseRemoteUrl(remoteUrl) {
|
|
33
|
+
if (!remoteUrl)
|
|
34
|
+
return null;
|
|
35
|
+
const match = remoteUrl.match(/(?:https?:\/\/|git@)([\w.-]+)(?:[:\/])([\w.-]+)\/([\w.-]+?)(?:\.git)?$/i);
|
|
36
|
+
if (!match) {
|
|
37
|
+
throw new Error(`Could not parse remote URL: ${remoteUrl}`);
|
|
38
|
+
}
|
|
39
|
+
const [_, host, owner, repository] = match;
|
|
40
|
+
const repoUrl = `https://${host}/${owner}/${repository}`;
|
|
41
|
+
return { url: remoteUrl, host, owner, repository, repoUrl };
|
|
42
|
+
}
|
|
43
|
+
async function getBranchesAsync() {
|
|
44
|
+
const [{ stdout: current }, { stdout: merged }, { stdout: unmerged }] = await Promise.all([
|
|
45
|
+
execPromise("git branch --show-current"),
|
|
46
|
+
execPromise("git branch --merged"),
|
|
47
|
+
execPromise("git branch --no-merged")
|
|
48
|
+
]);
|
|
49
|
+
return {
|
|
50
|
+
current: current.trim(),
|
|
51
|
+
merged: cleanList(merged),
|
|
52
|
+
unmerged: cleanList(unmerged)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
async function getCommitsAsync() {
|
|
56
|
+
const [{ stdout: hash }, { stdout: shortHash }, { stdout: message }, { stdout: author }, { stdout: date }, { stdout: count }] = await Promise.all([
|
|
57
|
+
execPromise("git log -1 --pretty=format:'%H'"),
|
|
58
|
+
execPromise("git log -1 --pretty=format:'%h'"),
|
|
59
|
+
execPromise("git log -1 --pretty=format:'%s'"),
|
|
60
|
+
execPromise('git log -1 --pretty=format:"%an <%ae>"'),
|
|
61
|
+
execPromise("git log -1 --pretty=format:'%ad'"),
|
|
62
|
+
execPromise("git rev-list --count HEAD")
|
|
63
|
+
]);
|
|
64
|
+
return {
|
|
65
|
+
latest: {
|
|
66
|
+
hash: hash.trim(),
|
|
67
|
+
shortHash: shortHash.trim(),
|
|
68
|
+
message: message.trim(),
|
|
69
|
+
author: author.trim(),
|
|
70
|
+
date: date.trim()
|
|
71
|
+
},
|
|
72
|
+
count: parseInt(count.trim(), 10) || 0
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function getTagsAsync() {
|
|
76
|
+
const [{ stdout: latest }, { stdout: all }] = await Promise.all([
|
|
77
|
+
execPromise("git describe --tags"),
|
|
78
|
+
execPromise("git tag")
|
|
79
|
+
]);
|
|
80
|
+
return {
|
|
81
|
+
latest: latest.trim(),
|
|
82
|
+
all: cleanList(all)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function getStatusAsync() {
|
|
86
|
+
const [{ stdout: modifiedFiles }, { stdout: untrackedFiles }] = await Promise.all([
|
|
87
|
+
execPromise("git diff --name-only"),
|
|
88
|
+
execPromise("git ls-files --others --exclude-standard")
|
|
89
|
+
]);
|
|
90
|
+
return {
|
|
91
|
+
modifiedFiles: cleanList(modifiedFiles),
|
|
92
|
+
untrackedFiles: cleanList(untrackedFiles)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/git/context.ts"],"names":[],"mappings":";;;;;AA0JI,gDAAkB;AAClB,4CAAgB;AAChB,0CAAe;AACf,wCAAc;AACd,oCAAY;AACZ,wCAAc;AA/JlB,iDAAqC;AACrC,gDAAwB;AACxB,MAAM,WAAW,GAAG,cAAI,CAAC,SAAS,CAAC,oBAAI,CAAC,CAAC;AA+CzC,KAAK,UAAU,kBAAkB;IAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAChE,WAAW,CAAC,oCAAoC,CAAC;QACjD,WAAW,CAAC,+BAA+B,CAAC;KAC/C,CAAC,CAAC;IAEH,MAAM,MAAM,GAAe;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;QACjB,MAAM,EAAE,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACxC,QAAQ,EAAE,MAAM,gBAAgB,EAAE;QAClC,IAAI,EAAE,MAAM,YAAY,EAAE;QAC1B,OAAO,EAAE,MAAM,eAAe,EAAE;QAChC,MAAM,EAAE,MAAM,cAAc,EAAE;KACjC,CAAC;IAE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;AACN,CAAC;AAED,KAAK,UAAU,cAAc;IACzB,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC9E,WAAW,CAAC,sBAAsB,CAAC;QACnC,WAAW,CAAC,0CAA0C,CAAC;KAC1D,CAAC,CAAC;IAEH,OAAO;QACH,aAAa,EAAE,SAAS,CAAC,aAAa,CAAC;QACvC,cAAc,EAAE,SAAS,CAAC,cAAc,CAAC;KAC5C,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const main_1 = require("./main");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
// Read package.json
|
|
9
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../package.json'), 'utf8'));
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name(packageJson.name || 'changelog')
|
|
13
|
+
.description(packageJson.description || 'Changelog generator tool')
|
|
14
|
+
.version(packageJson.version || '0.0.0', '-v, --version', 'Show version number')
|
|
15
|
+
.helpOption('-h, --help', 'Show help information');
|
|
16
|
+
const validateOptions = (options) => {
|
|
17
|
+
const hasRange = !!options.range;
|
|
18
|
+
const hasPoint = !!options.point;
|
|
19
|
+
const hasFromOrTo = !!options.from || !!options.to;
|
|
20
|
+
if (hasRange && (hasPoint || hasFromOrTo)) {
|
|
21
|
+
console.error(`Error: The '--range' option cannot be used with '--from', '--to', or '--point'.`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
if (hasPoint && (hasRange || hasFromOrTo)) {
|
|
25
|
+
console.error(`Error: The '--point' option cannot be used with '--range', '--from', or '--to'.`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
if (hasFromOrTo && (hasRange || hasPoint)) {
|
|
29
|
+
console.error(`Error: '--from' and '--to' options cannot be used with '--range' or '--point'.`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
program //generate ai based conventional commit
|
|
34
|
+
.command('commit')
|
|
35
|
+
.description('Generate changelog')
|
|
36
|
+
.action(async (options) => {
|
|
37
|
+
try {
|
|
38
|
+
await (0, main_1.main)(options);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
program
|
|
46
|
+
.command('changelog')
|
|
47
|
+
.description('Generate changelog')
|
|
48
|
+
.option('--from <commit | tag | branch| date | reference>', 'Specify starting reference')
|
|
49
|
+
.option('--to <commit | tag | branch| date | reference>', 'Specify ending reference')
|
|
50
|
+
.option('--point <commit | tag | branch| date | reference>', 'Specify a single reference')
|
|
51
|
+
.option('--range <commit | tag | branch| date | reference>', 'Specify reference range')
|
|
52
|
+
.option('--mergeAll [boolean]', 'Merge all changes into one output')
|
|
53
|
+
.option('--config [string]', 'Custom config file path')
|
|
54
|
+
.option('--template [string]', 'Custom template file path')
|
|
55
|
+
.option('--output [string]', 'Custom Output file path')
|
|
56
|
+
.option('--environment [string]', 'Specific environment to use')
|
|
57
|
+
// .option('--separateFiles [boolean]', 'District changelogs into own files')
|
|
58
|
+
.action(async (options) => {
|
|
59
|
+
validateOptions(options);
|
|
60
|
+
if (options.mergeAll === undefined) {
|
|
61
|
+
options.mergeAll = false;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
await (0, main_1.main)(options);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
program
|
|
72
|
+
.command('version')
|
|
73
|
+
.description('Generate changelog')
|
|
74
|
+
.action(async (options) => {
|
|
75
|
+
try {
|
|
76
|
+
await (0, main_1.main)(options);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
program
|
|
84
|
+
.action(() => {
|
|
85
|
+
console.log('Please specify a command or use --help for usage information');
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
88
|
+
program.parse(process.argv);
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,iCAA8B;AAC9B,2BAAkC;AAClC,+BAA4B;AAS5B,oBAAoB;AACpB,MAAM,WAAW,GAAgB,IAAI,CAAC,KAAK,CACvC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,MAAM,CAAC,CAC9D,CAAC;AAGF,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACF,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC;KACrC,WAAW,CAAC,WAAW,CAAC,WAAW,IAAI,0BAA0B,CAAC;KAClE,OAAO,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,EAAE,eAAe,EAAE,qBAAqB,CAAC;KAC/E,UAAU,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;AAEvD,MAAM,eAAe,GAAG,CAAC,OAAgB,EAAE,EAAE;IACzC,MAAM,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACjC,MAAM,QAAQ,GAAG,CAAC,CAAC,OAAO,CAAC,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AE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC,CAAC,CAAC;AAEP,OAAO;KACF,MAAM,CAAC,GAAG,EAAE;IACT,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC;AAEP,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/src/main.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = void 0;
|
|
4
|
+
exports.main = main;
|
|
5
|
+
const app_1 = require("./core/app");
|
|
6
|
+
const index_1 = require("./config/index");
|
|
7
|
+
async function main(options) {
|
|
8
|
+
try {
|
|
9
|
+
const config = await (0, index_1.readConfig)(options === null || options === void 0 ? void 0 : options.config, options.environment);
|
|
10
|
+
await (0, app_1.run)(options, config);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// if (require.main === module) {
|
|
18
|
+
// main();
|
|
19
|
+
// }
|
|
20
|
+
var app_2 = require("./core/app");
|
|
21
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return app_2.run; } });
|
|
22
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;AAKA,oBAQC;AAZD,oCAAiC;AACjC,0CAA4C;AAGrC,KAAK,UAAU,IAAI,CAAC,OAAgB;IACvC,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAU,EAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;QACrE,MAAM,IAAA,SAAG,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;AACL,CAAC;AAED,iCAAiC;AACjC,cAAc;AACd,IAAI;AAEJ,kCAAiC;AAAxB,0FAAA,GAAG,OAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.writeOutput = writeOutput;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
function writeOutput(data, output) {
|
|
39
|
+
if (!output || output === "stdout") {
|
|
40
|
+
console.log(data);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
fs.writeFileSync(output, data + "\n");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/output/writer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,kCAMC;AARD,uCAAyB;AAEzB,SAAgB,WAAW,CAAC,IAAY,EAAE,MAAe;IACrD,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;SAAM,CAAC;QACJ,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1C,CAAC;AACL,CAAC"}
|