binary-collections 2.0.7 → 2.0.9
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/bin/dir-tree.cmd +7 -0
- package/bin/git-diff +4 -0
- package/bin/git-diff.cmd +5 -2
- package/bin/{git-fix-encoding → git-fix} +1 -4
- package/bin/git-fix.cmd +7 -0
- package/bin/nodekill +0 -0
- package/bin/nodekill.ps1 +0 -0
- package/bin/{submodule → submodule.txt} +0 -0
- package/lib/binary-collections-config.cjs +14 -0
- package/lib/binary-collections-config.d.mts +18 -0
- package/lib/binary-collections-config.d.ts +16 -0
- package/lib/binary-collections-config.js +39 -0
- package/lib/binary-collections-config.mjs +6 -0
- package/lib/binary-collections.cjs +123 -0
- package/lib/binary-collections.d.cts +2 -0
- package/lib/binary-collections.d.mts +137 -0
- package/lib/binary-collections.d.ts +137 -0
- package/lib/binary-collections.mjs +300 -0
- package/lib/changelog.cjs +328 -0
- package/lib/changelog.d.mts +2 -0
- package/lib/changelog.d.ts +1 -0
- package/lib/changelog.js +226 -0
- package/lib/changelog.mjs +199 -0
- package/lib/chunk-4BYBVEYC.mjs +30 -0
- package/lib/{chunk-FB6YIQYR.mjs → chunk-AASHBCRW.mjs} +17 -2
- package/lib/chunk-APBWENF6.mjs +135 -0
- package/lib/{chunk-4LEXWIIF.mjs → chunk-DPKAJKFO.mjs} +2 -4
- package/lib/chunk-EGSSKVDH.mjs +66 -0
- package/lib/{chunk-3LOB2P54.mjs → chunk-G3THLIDT.mjs} +3 -5
- package/lib/chunk-JGR2NW6D.mjs +187 -0
- package/lib/chunk-ONIBBBQ3.mjs +108 -0
- package/lib/chunk-SH3L6HHV.mjs +27 -0
- package/lib/chunk-VVEZVNIV.mjs +81 -0
- package/lib/{chunk-JL32QDSH.mjs → chunk-W3ENOM53.mjs} +2 -4
- package/lib/chunk-YV7DO3YV.mjs +48 -0
- package/lib/{chunk-BSD5CIRU.mjs → chunk-YX5U7XDR.mjs} +11 -5
- package/lib/chunk-ZYAQRPUL.mjs +28 -0
- package/lib/clean-github-actions-caches.cjs +162 -0
- package/lib/clean-github-actions-caches.d.cts +1 -0
- package/lib/clean-github-actions-caches.d.mts +169 -0
- package/lib/clean-github-actions-caches.d.ts +169 -0
- package/lib/clean-github-actions-caches.mjs +132 -0
- package/lib/del-gradle.cjs +87 -3
- package/lib/del-gradle.js +1 -1
- package/lib/del-gradle.mjs +4 -6
- package/lib/del-node-modules.cjs +86 -2
- package/lib/del-node-modules.mjs +3 -5
- package/lib/del-ps.cjs +89 -5
- package/lib/del-ps.js +2 -2
- package/lib/del-ps.mjs +6 -8
- package/lib/del-yarn-caches.cjs +86 -2
- package/lib/del-yarn-caches.mjs +3 -5
- package/lib/find-node-modules-cli.cjs +8 -0
- package/lib/find-node-modules-cli.mjs +2 -3
- package/lib/find-node-modules.cjs +8 -0
- package/lib/find-node-modules.d.mts +3 -0
- package/lib/find-node-modules.d.ts +3 -0
- package/lib/find-node-modules.js +12 -0
- package/lib/find-node-modules.mjs +2 -3
- package/lib/git/gitattributes.cjs +171 -0
- package/lib/git/gitattributes.d.mts +35 -0
- package/lib/git/gitattributes.d.ts +33 -0
- package/lib/git/gitattributes.js +223 -0
- package/lib/git/gitattributes.mjs +6 -0
- package/lib/git/line-endings.cjs +74 -0
- package/lib/git/line-endings.d.cts +7 -0
- package/lib/git/line-endings.d.mts +83 -0
- package/lib/git/line-endings.d.ts +83 -0
- package/lib/git/line-endings.mjs +8 -0
- package/lib/git/normalize.cjs +42 -0
- package/lib/git/normalize.d.cts +6 -0
- package/lib/git/normalize.d.mts +43 -0
- package/lib/git/normalize.d.ts +43 -0
- package/lib/git/normalize.mjs +6 -0
- package/lib/git/permissions.cjs +15 -0
- package/lib/git/permissions.d.cts +6 -0
- package/lib/git/permissions.d.mts +17 -0
- package/lib/git/permissions.d.ts +17 -0
- package/lib/git/permissions.mjs +7 -0
- package/lib/git/pull-strategy.cjs +13 -0
- package/lib/git/pull-strategy.d.cts +5 -0
- package/lib/git/pull-strategy.d.mts +15 -0
- package/lib/git/pull-strategy.d.ts +15 -0
- package/lib/git/pull-strategy.mjs +7 -0
- package/lib/git/user-config.cjs +100 -0
- package/lib/git/user-config.d.cts +10 -0
- package/lib/git/user-config.d.mts +105 -0
- package/lib/git/user-config.d.ts +105 -0
- package/lib/git/user-config.mjs +8 -0
- package/lib/git/utils.cjs +70 -0
- package/lib/git/utils.d.cts +20 -0
- package/lib/git/utils.d.mts +69 -0
- package/lib/git/utils.d.ts +69 -0
- package/lib/git/utils.mjs +6 -0
- package/lib/git-diff.cjs +23 -24
- package/lib/git-diff.d.mts +25 -28
- package/lib/git-diff.d.ts +25 -28
- package/lib/git-diff.mjs +32 -27
- package/lib/git-fix.cjs +129 -0
- package/lib/git-fix.d.cts +2 -0
- package/lib/git-fix.d.mts +141 -0
- package/lib/git-fix.d.ts +141 -0
- package/lib/git-fix.mjs +151 -0
- package/lib/git-purge.cjs +86 -2
- package/lib/git-purge.mjs +3 -5
- package/lib/index.cjs +8 -0
- package/lib/index.mjs +3 -5
- package/lib/npm-run-series.cjs +140 -1
- package/lib/npm-run-series.js +2 -1
- package/lib/npm-run-series.mjs +7 -5
- package/lib/package-resolutions-updater.cjs +447 -0
- package/lib/package-resolutions-updater.d.mts +1 -0
- package/lib/package-resolutions-updater.d.ts +352 -0
- package/lib/package-resolutions-updater.mjs +339 -0
- package/lib/print-directory-tree.cjs +241 -0
- package/lib/print-directory-tree.d.cts +1 -0
- package/lib/print-directory-tree.d.mts +234 -0
- package/lib/print-directory-tree.d.ts +234 -0
- package/lib/print-directory-tree.mjs +182 -0
- package/lib/ps/connected-domain.mjs +2 -3
- package/lib/ps/index.cjs +3 -3
- package/lib/ps/index.d.mjs +1 -2
- package/lib/ps/index.js +6 -3
- package/lib/ps/index.mjs +9 -11
- package/lib/ps/isWin.mjs +2 -3
- package/lib/ps/table-parser.mjs +3 -4
- package/lib/submodule-install.cjs +18 -35
- package/lib/submodule-install.d.mts +17 -37
- package/lib/submodule-install.d.ts +17 -37
- package/lib/submodule-install.mjs +21 -29
- package/lib/utils.cjs +86 -2
- package/lib/utils.d.mts +29 -9
- package/lib/utils.d.ts +28 -8
- package/lib/utils.js +139 -8
- package/lib/utils.mjs +2 -3
- package/lib/yarn-reinstall.cjs +9 -7
- package/lib/yarn-reinstall.d.mts +12 -8
- package/lib/yarn-reinstall.d.ts +12 -8
- package/lib/yarn-reinstall.mjs +14 -10
- package/package.json +109 -80
- package/readme.md +74 -11
- package/src/package-resolutions-updater.mjs +350 -0
- package/src/print-directory-tree.cjs +234 -0
- package/src/ps/index.js +4 -3
- package/src/yarn-reinstall.cjs +49 -0
- package/test-project/package.json +16 -0
- package/tmp/test-repo/package.json +7 -0
- package/bin/git-fix-encoding.cmd +0 -6
- package/lib/chunk-OKYLF2MU.mjs +0 -53
- package/lib/chunk-VXZQNLPU.mjs +0 -23
- package/lib/package-resolutions.cjs +0 -28
- package/lib/package-resolutions.d.mts +0 -25
- package/lib/package-resolutions.d.ts +0 -25
- package/lib/package-resolutions.mjs +0 -31
- /package/bin/{submodule-install → submodule-install.txt} +0 -0
package/lib/changelog.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const { EOL } = require("os");
|
|
13
|
+
const { getArgs } = require("./utils");
|
|
14
|
+
const spawn = require("child_process").spawn;
|
|
15
|
+
const pkgPath = path.join(process.cwd(), "package.json");
|
|
16
|
+
if (!fs.existsSync(pkgPath)) {
|
|
17
|
+
throw new Error(`package.json not found at ${pkgPath}`);
|
|
18
|
+
}
|
|
19
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
20
|
+
const args = getArgs();
|
|
21
|
+
// Show help if no arguments or --help/-h is passed
|
|
22
|
+
if (args.help || args.h) {
|
|
23
|
+
showHelp();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Prints help information for the changelog script.
|
|
27
|
+
*/
|
|
28
|
+
function showHelp() {
|
|
29
|
+
console.log(`\nUsage: node changelog.js [options]\n`);
|
|
30
|
+
console.log(`Options:`);
|
|
31
|
+
console.log(` --help, -h Show this help message and exit`);
|
|
32
|
+
console.log(`\nDescription:`);
|
|
33
|
+
console.log(` Generates a CHANGELOG.md file from git commit history.`);
|
|
34
|
+
console.log(` - Looks for version bumps and groups commits by version.`);
|
|
35
|
+
console.log(` - Skips dependabot and irrelevant commits.`);
|
|
36
|
+
console.log(` - Outputs the original git log to tmp/original.md for reference.`);
|
|
37
|
+
console.log(`\nExample:`);
|
|
38
|
+
console.log(` node changelog.js`);
|
|
39
|
+
console.log(``);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* git
|
|
43
|
+
* @param {string[]} command
|
|
44
|
+
* @returns {Promise<string>}
|
|
45
|
+
*/
|
|
46
|
+
const gitExec = (command) => new Promise((resolve, reject) => {
|
|
47
|
+
const thread = spawn("git", command, { stdio: ["inherit", "pipe", "pipe"] });
|
|
48
|
+
const stdOut = [];
|
|
49
|
+
const stdErr = [];
|
|
50
|
+
thread.stdout.on("data", (data) => {
|
|
51
|
+
stdOut.push(data.toString("utf8"));
|
|
52
|
+
});
|
|
53
|
+
thread.stderr.on("data", (data) => {
|
|
54
|
+
stdErr.push(data.toString("utf8"));
|
|
55
|
+
});
|
|
56
|
+
thread.on("close", () => {
|
|
57
|
+
if (stdErr.length) {
|
|
58
|
+
reject(stdErr.join(""));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
resolve(stdOut.join());
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Extracts all version numbers in X.X.X format from a multiline string.
|
|
66
|
+
* @param {string} str
|
|
67
|
+
* @returns {string[]}
|
|
68
|
+
*/
|
|
69
|
+
function extractVersions(str) {
|
|
70
|
+
const regex = /\bv?(\d+\.\d+\.\d+)\b/g;
|
|
71
|
+
const matches = [];
|
|
72
|
+
let match;
|
|
73
|
+
while ((match = regex.exec(str)) !== null) {
|
|
74
|
+
matches.push(match[1]);
|
|
75
|
+
}
|
|
76
|
+
return Array.from(new Set(matches));
|
|
77
|
+
}
|
|
78
|
+
// Git log format used:
|
|
79
|
+
// %h - Abbreviated commit hash
|
|
80
|
+
// %ad - Author date (formatted as "YYYY-MM-DD HH:MM:SS")
|
|
81
|
+
// %B - Raw body (commit message)
|
|
82
|
+
// %d - Ref names (branch, tag, etc.)
|
|
83
|
+
// Fields are separated by " !|! "
|
|
84
|
+
// Example: --pretty=format:"%h !|! %ad !|! %B %d" --date=format:"%Y-%m-%d %H:%M:%S"
|
|
85
|
+
// `--pretty=format:"%h !|! %ad !|! %B %d"`, `--date=format:"%Y-%m-%d %H:%M:%S"`
|
|
86
|
+
// Now includes author and committer name/email in the log format
|
|
87
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const log = yield gitExec([
|
|
89
|
+
"log",
|
|
90
|
+
"--reverse",
|
|
91
|
+
`--pretty=format:"=!=%h !|! %ad !|! %an !|! %cn !|! %s !|! %B !|! %d=!="`,
|
|
92
|
+
`--date=format:"%Y-%m-%d %H:%M:%S"`
|
|
93
|
+
]);
|
|
94
|
+
let markdown = `## CHANGELOG of ${pkg.name}\n\n`;
|
|
95
|
+
const repo = yield gitExec(["remote", "get-url", "origin"]);
|
|
96
|
+
const repoUrl = repo.trim().replace(/\.git$/, "");
|
|
97
|
+
console.log(`Repository URL: ${repoUrl}`);
|
|
98
|
+
const matches = [...log.matchAll(/=!=(.*?)(?:=!=|=!=,)/gs)];
|
|
99
|
+
const results = matches.map((m) => m[1].trim());
|
|
100
|
+
/** @type {Record<string, string[]>} */
|
|
101
|
+
const versionsCommits = {};
|
|
102
|
+
let currentVersionCommit = "";
|
|
103
|
+
for (const str of results) {
|
|
104
|
+
const splitx = str.split("!|!").map((s) => s.trim());
|
|
105
|
+
// Now splitx: [hash, date, authorName, committerName, summary, message, ref]
|
|
106
|
+
const o = {
|
|
107
|
+
hash: splitx[0] ? splitx[0] : "",
|
|
108
|
+
date: splitx[1] ? splitx[1].replace(/^"|"$/g, "") : "",
|
|
109
|
+
authorName: splitx[2] ? splitx[2] : "",
|
|
110
|
+
committerName: splitx[3] ? splitx[3] : "",
|
|
111
|
+
summary: splitx[4] ? splitx[4] : "",
|
|
112
|
+
message: splitx[5] ? splitx[5] : "",
|
|
113
|
+
ref: splitx[6] ? splitx[6] : ""
|
|
114
|
+
};
|
|
115
|
+
let isBumped = /chore\(bump\)|chore: release/i.test(o.summary) || /release/i.test(o.summary) || /tag: v/i.test(o.summary);
|
|
116
|
+
if (o.summary.trim().startsWith("v")) {
|
|
117
|
+
isBumped = true; // Treat any commit starting with 'v' as a version bump
|
|
118
|
+
}
|
|
119
|
+
if (/^\d+\.\d+\.\d+$/.test(o.summary.trim())) {
|
|
120
|
+
isBumped = true; // Treat commits with version format as version bumps
|
|
121
|
+
}
|
|
122
|
+
if (o.summary.trim().startsWith("fix:")) {
|
|
123
|
+
isBumped = false; // Do not treat 'fix:' commits as version bumps
|
|
124
|
+
}
|
|
125
|
+
if (isBumped && !extractVersions(o.summary).length > 0)
|
|
126
|
+
isBumped = false; // Ensure we have a version in the summary
|
|
127
|
+
if (o.hash && o.date && o.message) {
|
|
128
|
+
// Skip commits by dependabot[bot]
|
|
129
|
+
if (o.authorName === "dependabot[bot]") {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
// Skip commits by regex
|
|
133
|
+
if (/^chore\(tarball\): update|merge pull request|merge branch|^migrate from|^update$|^update build from https?:\/\//i.test(o.message)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
// Skip build summary messages like "Build Tue Dec 27 20:18:29 UTC 2022"
|
|
137
|
+
if (/^Build\s+\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\w+\s+\d{4}$/i.test(o.summary)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (/initial commit/i.test(o.message)) {
|
|
141
|
+
versionsCommits["0.0.0"] = [];
|
|
142
|
+
currentVersionCommit = "0.0.0";
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (isBumped) {
|
|
146
|
+
console.log(`Detected version bump: ${o.summary}`);
|
|
147
|
+
const v = extractVersions(o.message).join(", ");
|
|
148
|
+
versionsCommits[v] = [];
|
|
149
|
+
currentVersionCommit = v;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (!currentVersionCommit) {
|
|
153
|
+
throw new Error(`No current version commit set for message: ${o.message} (hash: ${o.hash})`);
|
|
154
|
+
}
|
|
155
|
+
// Remove all trailing quotes, spaces, and commas from message
|
|
156
|
+
const cleanMsg = o.message.replace(/["'\s,]+$/g, "");
|
|
157
|
+
// Overwrite previous entry if message is duplicated (keep latest hash)
|
|
158
|
+
const commitsArr = versionsCommits[currentVersionCommit];
|
|
159
|
+
// Find index of previous entry with the same message (message is now on the line after the metadata)
|
|
160
|
+
const prevIdx = commitsArr.findIndex((entry) => {
|
|
161
|
+
// Extract the message part (after the first empty line)
|
|
162
|
+
const parts = entry.split(/\r?\n/);
|
|
163
|
+
// Find the first non-empty line after the metadata line
|
|
164
|
+
let msgLine = "";
|
|
165
|
+
for (let i = 1; i < parts.length; i++) {
|
|
166
|
+
if (parts[i].trim() !== "") {
|
|
167
|
+
msgLine = parts[i].trim();
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return msgLine === cleanMsg;
|
|
172
|
+
});
|
|
173
|
+
// Add changelog entry without author/committer info
|
|
174
|
+
let newEntry;
|
|
175
|
+
if (cleanMsg.includes("\n")) {
|
|
176
|
+
// Multiline message: put message on new line
|
|
177
|
+
newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>)` + EOL + EOL + `${cleanMsg}`;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// Single line message: put message on same line
|
|
181
|
+
newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>) ${cleanMsg}`;
|
|
182
|
+
}
|
|
183
|
+
if (prevIdx !== -1) {
|
|
184
|
+
// Overwrite previous occurrence with the latest hash/date
|
|
185
|
+
commitsArr[prevIdx] = newEntry;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
commitsArr.push(newEntry);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Iterate versionsCommits in reverse order
|
|
194
|
+
const versions = Object.keys(versionsCommits).sort((a, b) => {
|
|
195
|
+
const aParts = a.split(".").map(Number);
|
|
196
|
+
const bParts = b.split(".").map(Number);
|
|
197
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
198
|
+
const aPart = aParts[i] || 0; // Default to 0 if part is missing
|
|
199
|
+
const bPart = bParts[i] || 0; // Default to 0 if part is missing
|
|
200
|
+
if (aPart !== bPart) {
|
|
201
|
+
return bPart - aPart; // Sort in descending order
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return 0; // They are equal
|
|
205
|
+
});
|
|
206
|
+
for (const version of versions) {
|
|
207
|
+
if (versionsCommits[version].length > 0) {
|
|
208
|
+
markdown += `\n### ${version}\n\n`;
|
|
209
|
+
markdown += versionsCommits[version]
|
|
210
|
+
.map((str) => {
|
|
211
|
+
const lines = str.trim().split(/\r?\n/);
|
|
212
|
+
return [lines[0], ...lines.slice(1).map((line) => " " + line)].join(EOL);
|
|
213
|
+
})
|
|
214
|
+
.join(EOL);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
markdown += `\n### ${version}\n\n`;
|
|
218
|
+
markdown += `- No changes recorded for this version.\n`;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
fs.mkdirSync(path.join(__dirname, "tmp"), { recursive: true });
|
|
222
|
+
fs.writeFileSync(path.join(__dirname, "tmp/original.md"), log);
|
|
223
|
+
fs.writeFileSync(path.join(__dirname, "CHANGELOG.md"), markdown);
|
|
224
|
+
console.log(`Original log written to tmp/original.md`);
|
|
225
|
+
console.log(`Changelog updated successfully. You can find it at CHANGELOG.md`);
|
|
226
|
+
}))();
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_utils
|
|
4
|
+
} from "./chunk-APBWENF6.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__dirname,
|
|
7
|
+
__require,
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
10
|
+
|
|
11
|
+
// src/changelog.js
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
var fs = __require("fs");
|
|
14
|
+
var path = __require("path");
|
|
15
|
+
var { EOL } = __require("os");
|
|
16
|
+
var { getArgs } = require_utils();
|
|
17
|
+
var spawn = __require("child_process").spawn;
|
|
18
|
+
var pkgPath = path.join(process.cwd(), "package.json");
|
|
19
|
+
if (!fs.existsSync(pkgPath)) {
|
|
20
|
+
throw new Error(`package.json not found at ${pkgPath}`);
|
|
21
|
+
}
|
|
22
|
+
var pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
23
|
+
var args = getArgs();
|
|
24
|
+
if (args.help || args.h) {
|
|
25
|
+
showHelp();
|
|
26
|
+
}
|
|
27
|
+
function showHelp() {
|
|
28
|
+
console.log(`
|
|
29
|
+
Usage: node changelog.js [options]
|
|
30
|
+
`);
|
|
31
|
+
console.log(`Options:`);
|
|
32
|
+
console.log(` --help, -h Show this help message and exit`);
|
|
33
|
+
console.log(`
|
|
34
|
+
Description:`);
|
|
35
|
+
console.log(` Generates a CHANGELOG.md file from git commit history.`);
|
|
36
|
+
console.log(` - Looks for version bumps and groups commits by version.`);
|
|
37
|
+
console.log(` - Skips dependabot and irrelevant commits.`);
|
|
38
|
+
console.log(` - Outputs the original git log to tmp/original.md for reference.`);
|
|
39
|
+
console.log(`
|
|
40
|
+
Example:`);
|
|
41
|
+
console.log(` node changelog.js`);
|
|
42
|
+
console.log(``);
|
|
43
|
+
}
|
|
44
|
+
var gitExec = (command) => new Promise((resolve, reject) => {
|
|
45
|
+
const thread = spawn("git", command, { stdio: ["inherit", "pipe", "pipe"] });
|
|
46
|
+
const stdOut = [];
|
|
47
|
+
const stdErr = [];
|
|
48
|
+
thread.stdout.on("data", (data) => {
|
|
49
|
+
stdOut.push(data.toString("utf8"));
|
|
50
|
+
});
|
|
51
|
+
thread.stderr.on("data", (data) => {
|
|
52
|
+
stdErr.push(data.toString("utf8"));
|
|
53
|
+
});
|
|
54
|
+
thread.on("close", () => {
|
|
55
|
+
if (stdErr.length) {
|
|
56
|
+
reject(stdErr.join(""));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
resolve(stdOut.join());
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
function extractVersions(str) {
|
|
63
|
+
const regex = /\bv?(\d+\.\d+\.\d+)\b/g;
|
|
64
|
+
const matches = [];
|
|
65
|
+
let match;
|
|
66
|
+
while ((match = regex.exec(str)) !== null) {
|
|
67
|
+
matches.push(match[1]);
|
|
68
|
+
}
|
|
69
|
+
return Array.from(new Set(matches));
|
|
70
|
+
}
|
|
71
|
+
(async () => {
|
|
72
|
+
const log = await gitExec([
|
|
73
|
+
"log",
|
|
74
|
+
"--reverse",
|
|
75
|
+
`--pretty=format:"=!=%h !|! %ad !|! %an !|! %cn !|! %s !|! %B !|! %d=!="`,
|
|
76
|
+
`--date=format:"%Y-%m-%d %H:%M:%S"`
|
|
77
|
+
]);
|
|
78
|
+
let markdown = `## CHANGELOG of ${pkg.name}
|
|
79
|
+
|
|
80
|
+
`;
|
|
81
|
+
const repo = await gitExec(["remote", "get-url", "origin"]);
|
|
82
|
+
const repoUrl = repo.trim().replace(/\.git$/, "");
|
|
83
|
+
console.log(`Repository URL: ${repoUrl}`);
|
|
84
|
+
const matches = [...log.matchAll(/=!=(.*?)(?:=!=|=!=,)/gs)];
|
|
85
|
+
const results = matches.map((m) => m[1].trim());
|
|
86
|
+
const versionsCommits = {};
|
|
87
|
+
let currentVersionCommit = "";
|
|
88
|
+
for (const str of results) {
|
|
89
|
+
const splitx = str.split("!|!").map((s) => s.trim());
|
|
90
|
+
const o = {
|
|
91
|
+
hash: splitx[0] ? splitx[0] : "",
|
|
92
|
+
date: splitx[1] ? splitx[1].replace(/^"|"$/g, "") : "",
|
|
93
|
+
authorName: splitx[2] ? splitx[2] : "",
|
|
94
|
+
committerName: splitx[3] ? splitx[3] : "",
|
|
95
|
+
summary: splitx[4] ? splitx[4] : "",
|
|
96
|
+
message: splitx[5] ? splitx[5] : "",
|
|
97
|
+
ref: splitx[6] ? splitx[6] : ""
|
|
98
|
+
};
|
|
99
|
+
let isBumped = /chore\(bump\)|chore: release/i.test(o.summary) || /release/i.test(o.summary) || /tag: v/i.test(o.summary);
|
|
100
|
+
if (o.summary.trim().startsWith("v")) {
|
|
101
|
+
isBumped = true;
|
|
102
|
+
}
|
|
103
|
+
if (/^\d+\.\d+\.\d+$/.test(o.summary.trim())) {
|
|
104
|
+
isBumped = true;
|
|
105
|
+
}
|
|
106
|
+
if (o.summary.trim().startsWith("fix:")) {
|
|
107
|
+
isBumped = false;
|
|
108
|
+
}
|
|
109
|
+
if (isBumped && !extractVersions(o.summary).length > 0) isBumped = false;
|
|
110
|
+
if (o.hash && o.date && o.message) {
|
|
111
|
+
if (o.authorName === "dependabot[bot]") {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (/^chore\(tarball\): update|merge pull request|merge branch|^migrate from|^update$|^update build from https?:\/\//i.test(
|
|
115
|
+
o.message
|
|
116
|
+
)) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (/^Build\s+\w{3}\s+\w{3}\s+\d{1,2}\s+\d{2}:\d{2}:\d{2}\s+\w+\s+\d{4}$/i.test(o.summary)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (/initial commit/i.test(o.message)) {
|
|
123
|
+
versionsCommits["0.0.0"] = [];
|
|
124
|
+
currentVersionCommit = "0.0.0";
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (isBumped) {
|
|
128
|
+
console.log(`Detected version bump: ${o.summary}`);
|
|
129
|
+
const v = extractVersions(o.message).join(", ");
|
|
130
|
+
versionsCommits[v] = [];
|
|
131
|
+
currentVersionCommit = v;
|
|
132
|
+
} else {
|
|
133
|
+
if (!currentVersionCommit) {
|
|
134
|
+
throw new Error(`No current version commit set for message: ${o.message} (hash: ${o.hash})`);
|
|
135
|
+
}
|
|
136
|
+
const cleanMsg = o.message.replace(/["'\s,]+$/g, "");
|
|
137
|
+
const commitsArr = versionsCommits[currentVersionCommit];
|
|
138
|
+
const prevIdx = commitsArr.findIndex((entry) => {
|
|
139
|
+
const parts = entry.split(/\r?\n/);
|
|
140
|
+
let msgLine = "";
|
|
141
|
+
for (let i = 1; i < parts.length; i++) {
|
|
142
|
+
if (parts[i].trim() !== "") {
|
|
143
|
+
msgLine = parts[i].trim();
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return msgLine === cleanMsg;
|
|
148
|
+
});
|
|
149
|
+
let newEntry;
|
|
150
|
+
if (cleanMsg.includes("\n")) {
|
|
151
|
+
newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>)` + EOL + EOL + `${cleanMsg}`;
|
|
152
|
+
} else {
|
|
153
|
+
newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>) ${cleanMsg}`;
|
|
154
|
+
}
|
|
155
|
+
if (prevIdx !== -1) {
|
|
156
|
+
commitsArr[prevIdx] = newEntry;
|
|
157
|
+
} else {
|
|
158
|
+
commitsArr.push(newEntry);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const versions = Object.keys(versionsCommits).sort((a, b) => {
|
|
164
|
+
const aParts = a.split(".").map(Number);
|
|
165
|
+
const bParts = b.split(".").map(Number);
|
|
166
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
167
|
+
const aPart = aParts[i] || 0;
|
|
168
|
+
const bPart = bParts[i] || 0;
|
|
169
|
+
if (aPart !== bPart) {
|
|
170
|
+
return bPart - aPart;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return 0;
|
|
174
|
+
});
|
|
175
|
+
for (const version of versions) {
|
|
176
|
+
if (versionsCommits[version].length > 0) {
|
|
177
|
+
markdown += `
|
|
178
|
+
### ${version}
|
|
179
|
+
|
|
180
|
+
`;
|
|
181
|
+
markdown += versionsCommits[version].map((str) => {
|
|
182
|
+
const lines = str.trim().split(/\r?\n/);
|
|
183
|
+
return [lines[0], ...lines.slice(1).map((line) => " " + line)].join(EOL);
|
|
184
|
+
}).join(EOL);
|
|
185
|
+
} else {
|
|
186
|
+
markdown += `
|
|
187
|
+
### ${version}
|
|
188
|
+
|
|
189
|
+
`;
|
|
190
|
+
markdown += `- No changes recorded for this version.
|
|
191
|
+
`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
fs.mkdirSync(path.join(__dirname, "tmp"), { recursive: true });
|
|
195
|
+
fs.writeFileSync(path.join(__dirname, "tmp/original.md"), log);
|
|
196
|
+
fs.writeFileSync(path.join(__dirname, "CHANGELOG.md"), markdown);
|
|
197
|
+
console.log(`Original log written to tmp/original.md`);
|
|
198
|
+
console.log(`Changelog updated successfully. You can find it at CHANGELOG.md`);
|
|
199
|
+
})();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
__commonJS,
|
|
4
|
+
__require,
|
|
5
|
+
init_esm_shims
|
|
6
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
7
|
+
|
|
8
|
+
// src/binary-collections-config.js
|
|
9
|
+
var require_binary_collections_config = __commonJS({
|
|
10
|
+
"src/binary-collections-config.js"(exports, module) {
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
var path = __require("path");
|
|
13
|
+
function getTempDir() {
|
|
14
|
+
return process.env.TEMP_DIR || "tmp";
|
|
15
|
+
}
|
|
16
|
+
function getTempPath(...segments) {
|
|
17
|
+
return path.join(getTempDir(), ...segments);
|
|
18
|
+
}
|
|
19
|
+
var TEMP_BASE_DIR = getTempDir();
|
|
20
|
+
module.exports = {
|
|
21
|
+
getTempDir,
|
|
22
|
+
getTempPath,
|
|
23
|
+
TEMP_BASE_DIR
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
require_binary_collections_config
|
|
30
|
+
};
|
|
@@ -34,9 +34,24 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
mod
|
|
35
35
|
));
|
|
36
36
|
|
|
37
|
+
// node_modules/tsup/assets/esm_shims.js
|
|
38
|
+
import path from "path";
|
|
39
|
+
import { fileURLToPath } from "url";
|
|
40
|
+
var getFilename, getDirname, __dirname, __filename;
|
|
41
|
+
var init_esm_shims = __esm({
|
|
42
|
+
"node_modules/tsup/assets/esm_shims.js"() {
|
|
43
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
44
|
+
getDirname = () => path.dirname(getFilename());
|
|
45
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
46
|
+
__filename = /* @__PURE__ */ getFilename();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
37
50
|
export {
|
|
38
51
|
__require,
|
|
39
|
-
__esm,
|
|
40
52
|
__commonJS,
|
|
41
|
-
__toESM
|
|
53
|
+
__toESM,
|
|
54
|
+
__dirname,
|
|
55
|
+
__filename,
|
|
56
|
+
init_esm_shims
|
|
42
57
|
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
__commonJS,
|
|
4
|
+
__require,
|
|
5
|
+
init_esm_shims
|
|
6
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
7
|
+
|
|
8
|
+
// src/utils.js
|
|
9
|
+
var require_utils = __commonJS({
|
|
10
|
+
"src/utils.js"(exports, module) {
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
var fs = __require("fs");
|
|
13
|
+
var path = __require("upath");
|
|
14
|
+
var argv = __require("minimist")(process.argv.slice(2));
|
|
15
|
+
var { exec } = __require("child_process");
|
|
16
|
+
var { URL } = __require("url");
|
|
17
|
+
var { promisify } = __require("util");
|
|
18
|
+
var execAsync = promisify(exec);
|
|
19
|
+
async function parseGitRemotes() {
|
|
20
|
+
try {
|
|
21
|
+
const { stdout } = await execAsync("git remote -v");
|
|
22
|
+
const lines = stdout.split("\n");
|
|
23
|
+
const remotes = {};
|
|
24
|
+
lines.forEach((line) => {
|
|
25
|
+
const [name, url] = line.split(" ");
|
|
26
|
+
if (name && url) {
|
|
27
|
+
const [repoUrl] = url.split(" ");
|
|
28
|
+
try {
|
|
29
|
+
const parsedUrl = new URL(repoUrl);
|
|
30
|
+
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
31
|
+
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
32
|
+
let repoPath = pathParts.join("/");
|
|
33
|
+
if (repoPath.endsWith(".git")) {
|
|
34
|
+
repoPath = repoPath.slice(0, -4);
|
|
35
|
+
}
|
|
36
|
+
remotes[name] = repoPath;
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error("URL Parsing Error:", e.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return remotes;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Error:", error.message);
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
module.exports.parseGitRemotes = parseGitRemotes;
|
|
50
|
+
function joinPathPreserveDriveLetter(...segments) {
|
|
51
|
+
let fullPath = __require("path").join(...segments);
|
|
52
|
+
if (/^[a-z]:\\/.test(fullPath)) {
|
|
53
|
+
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
54
|
+
}
|
|
55
|
+
return fullPath;
|
|
56
|
+
}
|
|
57
|
+
module.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
|
|
58
|
+
function getArgs() {
|
|
59
|
+
return argv;
|
|
60
|
+
}
|
|
61
|
+
module.exports.getArgs = getArgs;
|
|
62
|
+
function del(fullPath) {
|
|
63
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
64
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
65
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
66
|
+
del(subdir[i]);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
try {
|
|
70
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
71
|
+
console.log("deleted", fullPath);
|
|
72
|
+
} catch (_) {
|
|
73
|
+
console.log("failed delete", fullPath);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
module.exports.del = del;
|
|
78
|
+
function delStream(globStream) {
|
|
79
|
+
globStream.stream().on("data", (result) => {
|
|
80
|
+
const fullPath = path.resolve(process.cwd(), result);
|
|
81
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
82
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
83
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
84
|
+
del(subdir[i]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
del(fullPath);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
module.exports.delStream = delStream;
|
|
91
|
+
function getFileTreeString(hashArray) {
|
|
92
|
+
const tree = {};
|
|
93
|
+
const hashMap = {};
|
|
94
|
+
for (const entry of hashArray) {
|
|
95
|
+
const [filePath, hash] = entry.split(" ");
|
|
96
|
+
hashMap[filePath] = hash;
|
|
97
|
+
const parts = filePath.split("/");
|
|
98
|
+
let current = tree;
|
|
99
|
+
for (let i = 0; i < parts.length; i++) {
|
|
100
|
+
const part = parts[i];
|
|
101
|
+
if (i === parts.length - 1) {
|
|
102
|
+
current[part] = null;
|
|
103
|
+
} else {
|
|
104
|
+
current[part] = current[part] || {};
|
|
105
|
+
current = current[part];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function printNode(node, prefix = "", parentPath = "") {
|
|
110
|
+
const keys = Object.keys(node).sort();
|
|
111
|
+
let lines = [];
|
|
112
|
+
keys.forEach((key, idx) => {
|
|
113
|
+
const isLast = idx === keys.length - 1;
|
|
114
|
+
const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
115
|
+
const currentPath = parentPath ? parentPath + "/" + key : key;
|
|
116
|
+
if (node[key] === null) {
|
|
117
|
+
lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
|
|
118
|
+
} else {
|
|
119
|
+
lines.push(prefix + branch + key + "/");
|
|
120
|
+
lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return lines;
|
|
124
|
+
}
|
|
125
|
+
return printNode(tree, "", "").join("\n");
|
|
126
|
+
}
|
|
127
|
+
module.exports.getFileTreeString = getFileTreeString;
|
|
128
|
+
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
129
|
+
module.exports.delay = delay;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
require_utils
|
|
135
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
+
__commonJS,
|
|
3
4
|
init_esm_shims
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import {
|
|
6
|
-
__commonJS
|
|
7
|
-
} from "./chunk-FB6YIQYR.mjs";
|
|
5
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
8
6
|
|
|
9
7
|
// src/ps/connected-domain.js
|
|
10
8
|
var require_connected_domain = __commonJS({
|