binary-collections 2.0.8 → 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.
@@ -4,6 +4,8 @@ const { spawn } = require("child_process");
4
4
  const { glob } = require("glob");
5
5
  const path = require("path");
6
6
  const { getArgs } = require("./utils.js");
7
+ const pkgJson = require("../package.json");
8
+ const fs = require("fs");
7
9
  /**
8
10
  * Main binary-collections script that dynamically finds and executes other scripts
9
11
  * Usage: npx binary-collections <script-name> [...args]
@@ -47,10 +49,26 @@ function findScript(scriptName, searchDir = null) {
47
49
  ignore: ignorePatterns,
48
50
  absolute: true
49
51
  });
50
- // Return the first match if found
51
52
  if (files.length > 0) {
53
+ // Return the first match if found
52
54
  return files[0];
53
55
  }
56
+ else {
57
+ // If not found pick from pkg.bin[scriptName] when exist
58
+ if (pkgJson.bin[scriptName]) {
59
+ const find = [
60
+ path.join(searchDir, pkgJson.bin[scriptName]),
61
+ path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName])
62
+ ].filter((file) => fs.existsSync(file));
63
+ if (find.length > 0) {
64
+ return find[0];
65
+ }
66
+ else {
67
+ console.warn(`⚠️ Script "${scriptName}" not found in ${searchDir}.`);
68
+ console.warn(`🔍 Searched for: ${pattern} in ${searchDir}`);
69
+ }
70
+ }
71
+ }
54
72
  }
55
73
  catch (error) {
56
74
  console.error(`🔍 Error searching for script: ${error.message}`);
@@ -3,6 +3,8 @@ const { spawn } = require("child_process");
3
3
  const { glob } = require("glob");
4
4
  const path = require("path");
5
5
  const { getArgs } = require("./utils.js");
6
+ const pkgJson = require("../package.json");
7
+ const fs = require("fs");
6
8
 
7
9
  /**
8
10
  * Main binary-collections script that dynamically finds and executes other scripts
@@ -51,9 +53,23 @@ function findScript(scriptName, searchDir = null) {
51
53
  absolute: true
52
54
  });
53
55
 
54
- // Return the first match if found
55
56
  if (files.length > 0) {
57
+ // Return the first match if found
56
58
  return files[0];
59
+ } else {
60
+ // If not found pick from pkg.bin[scriptName] when exist
61
+ if (pkgJson.bin[scriptName]) {
62
+ const find = [
63
+ path.join(searchDir, pkgJson.bin[scriptName]),
64
+ path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName])
65
+ ].filter((file) => fs.existsSync(file));
66
+ if (find.length > 0) {
67
+ return find[0];
68
+ } else {
69
+ console.warn(`⚠️ Script "${scriptName}" not found in ${searchDir}.`);
70
+ console.warn(`🔍 Searched for: ${pattern} in ${searchDir}`);
71
+ }
72
+ }
57
73
  }
58
74
  } catch (error) {
59
75
  console.error(`🔍 Error searching for script: ${error.message}`);
@@ -3,6 +3,8 @@ const { spawn } = require("child_process");
3
3
  const { glob } = require("glob");
4
4
  const path = require("path");
5
5
  const { getArgs } = require("./utils.js");
6
+ const pkgJson = require("../package.json");
7
+ const fs = require("fs");
6
8
 
7
9
  /**
8
10
  * Main binary-collections script that dynamically finds and executes other scripts
@@ -51,9 +53,23 @@ function findScript(scriptName, searchDir = null) {
51
53
  absolute: true
52
54
  });
53
55
 
54
- // Return the first match if found
55
56
  if (files.length > 0) {
57
+ // Return the first match if found
56
58
  return files[0];
59
+ } else {
60
+ // If not found pick from pkg.bin[scriptName] when exist
61
+ if (pkgJson.bin[scriptName]) {
62
+ const find = [
63
+ path.join(searchDir, pkgJson.bin[scriptName]),
64
+ path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName])
65
+ ].filter((file) => fs.existsSync(file));
66
+ if (find.length > 0) {
67
+ return find[0];
68
+ } else {
69
+ console.warn(`⚠️ Script "${scriptName}" not found in ${searchDir}.`);
70
+ console.warn(`🔍 Searched for: ${pattern} in ${searchDir}`);
71
+ }
72
+ }
57
73
  }
58
74
  } catch (error) {
59
75
  console.error(`🔍 Error searching for script: ${error.message}`);
@@ -10,6 +10,183 @@ import {
10
10
  init_esm_shims
11
11
  } from "./chunk-AASHBCRW.mjs";
12
12
 
13
+ // package.json
14
+ var require_package = __commonJS({
15
+ "package.json"(exports, module) {
16
+ module.exports = {
17
+ name: "binary-collections",
18
+ version: "2.0.9",
19
+ description: "Utility to clean any programming caches and more",
20
+ keywords: [
21
+ "cache",
22
+ "cleaner",
23
+ "utility"
24
+ ],
25
+ homepage: "https://www.webmanajemen.com/",
26
+ bugs: {
27
+ url: "https://github.com/dimaslanjaka/bin/issues"
28
+ },
29
+ license: "MIT",
30
+ author: {
31
+ email: "dimaslanjaka@gmail.com",
32
+ name: "dimaslanjaka",
33
+ url: "https://webmanajemen.com"
34
+ },
35
+ main: "lib/index.js",
36
+ exports: {
37
+ ".": {
38
+ require: {
39
+ default: "./lib/index.cjs",
40
+ types: "./lib/index.d.ts"
41
+ },
42
+ import: {
43
+ default: "./lib/index.mjs",
44
+ types: "./lib/index.d.mts"
45
+ }
46
+ }
47
+ },
48
+ types: "lib/index.d.ts",
49
+ files: [
50
+ "bin",
51
+ "lib",
52
+ "index.js",
53
+ "!test",
54
+ "package.json"
55
+ ],
56
+ bin: {
57
+ "binary-collections": "lib/binary-collections.cjs",
58
+ "clean-github-actions-cache": "lib/clean-github-actions-caches.cjs",
59
+ "clean-github-actions-caches": "lib/clean-github-actions-caches.cjs",
60
+ "clean-nodemodule": "bin/clean-nodemodule",
61
+ "clean-nodemodules": "bin/clean-nodemodules",
62
+ "clear-gh-caches": "lib/clean-github-actions-caches.cjs",
63
+ "clear-github-actions-cache": "lib/clean-github-actions-caches.cjs",
64
+ "clear-github-actions-caches": "lib/clean-github-actions-caches.cjs",
65
+ "del-gradle": "lib/del-gradle.cjs",
66
+ "del-node-modules": "lib/del-node-modules.mjs",
67
+ "del-nodemodules": "lib/del-node-modules.cjs",
68
+ "del-ps": "lib/del-ps.cjs",
69
+ "del-yarn-caches": "lib/del-yarn-caches.mjs",
70
+ "del-yarncaches": "lib/del-yarn-caches.cjs",
71
+ dev: "bin/dev",
72
+ "dir-tree": "lib/print-directory-tree.cjs",
73
+ empty: "bin/empty",
74
+ "find-node-modules": "lib/find-node-modules.mjs",
75
+ "find-node-modules-cli": "lib/find-node-modules-cli.mjs",
76
+ "git-diff": "lib/git-diff.cjs",
77
+ "git-fix": "lib/git-fix.cjs",
78
+ "git-purge": "lib/git-purge.cjs",
79
+ "git-reduce-size": "bin/git-reduce-size",
80
+ index: "lib/index.mjs",
81
+ javakill: "bin/javakill.cmd",
82
+ "kill-process": "bin/kill-process",
83
+ nodekill: "bin/nodekill.ps1",
84
+ "npm-run-series": "lib/npm-run-series.cjs",
85
+ nrs: "lib/npm-run-series.cjs",
86
+ "package-resolutions-updater": "src/package-resolutions-updater.mjs",
87
+ "pkg-res-updater": "lib/package-resolutions-updater.cjs",
88
+ "pkg-resolutions-updater": "lib/package-resolutions-updater.cjs",
89
+ "print-directory-tree": "src/print-directory-tree.cjs",
90
+ "print-tree": "lib/print-directory-tree.cjs",
91
+ prod: "bin/prod",
92
+ rmfind: "bin/rmfind",
93
+ rmpath: "bin/rmpath",
94
+ rmx: "bin/rmx",
95
+ "run-s": "lib/npm-run-series.cjs",
96
+ "run-series": "lib/npm-run-series.cjs",
97
+ "submodule-install": "lib/submodule-install.cjs",
98
+ "submodule-remove": "bin/submodule-remove",
99
+ "submodule-token": "bin/submodule-token",
100
+ "yarn-reinstall": "src/yarn-reinstall.cjs"
101
+ },
102
+ scripts: {
103
+ "update:packer": "curl -L https://github.com/dimaslanjaka/nodejs-package-types/raw/main/packer.js > packer.js",
104
+ build: "node build.tsup.js && tsc -b tsconfig.build.json && npm run postbuild",
105
+ postbuild: "node -r ts-node/register -r dotenv/config build.js && yarn run pack",
106
+ "build:packages": "yarn workspaces foreach --worktree --no-private run build",
107
+ test: "npx jest --runInBand --forceExit",
108
+ "test:watch": "npm test --watch",
109
+ "test:coverage": "npm test --coverage",
110
+ "test:debug": "npm test -- --detectOpenHandles",
111
+ "test:nrs": "npm test -- nrs build:**",
112
+ pack: "node packer.js --yarn --filename=bin",
113
+ "update:ncu": "npx npm-check-updates -u -x jsdom,chalk,hexo,deepmerge-ts --enginesNode --root",
114
+ clean: "rimraf lib",
115
+ prepare: "husky"
116
+ },
117
+ repository: {
118
+ type: "git",
119
+ url: "git+https://github.com/dimaslanjaka/bin"
120
+ },
121
+ dependencies: {
122
+ axios: "^1.10.0",
123
+ dotenv: "^17.2.0",
124
+ execa: "^9.6.0",
125
+ "fs-extra": "^11.3.0",
126
+ "git-command-helper": "^2.0.2",
127
+ glob: "^11.0.3",
128
+ minimatch: "^10.0.3",
129
+ minimist: "^1.2.8",
130
+ "ps-node": "^0.1.6",
131
+ remove: "^0.1.5",
132
+ "sbg-utility": "^2.0.8",
133
+ upath: "^2.0.1",
134
+ yaml: "^2.8.0",
135
+ yarn: "^1.22.22"
136
+ },
137
+ devDependencies: {
138
+ "@babel/core": "^7.28.0",
139
+ "@babel/preset-env": "^7.28.0",
140
+ "@eslint/eslintrc": "^3.3.1",
141
+ "@eslint/js": "^9.30.1",
142
+ "@types/babel__core": "^7",
143
+ "@types/babel__preset-env": "^7",
144
+ "@types/eslint": "^9",
145
+ "@types/fs-extra": "^11.0.4",
146
+ "@types/jest": "^30.0.0",
147
+ "@types/minimist": "^1",
148
+ "@types/node": "^24.0.10",
149
+ "@types/prettier": "^3",
150
+ "@types/ps-node": "^0",
151
+ "@types/yargs": "^17",
152
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
153
+ "@typescript-eslint/parser": "^8.36.0",
154
+ "babel-jest": "^30.0.4",
155
+ "cross-env": "^7.0.3",
156
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
157
+ eslint: "^9.30.1",
158
+ "eslint-config-prettier": "^10.1.5",
159
+ "eslint-plugin-prettier": "^5.5.1",
160
+ globals: "^16.3.0",
161
+ husky: "^9.1.7",
162
+ jest: "^30.0.4",
163
+ "lint-staged": "^16.1.2",
164
+ prettier: "^3.6.2",
165
+ rimraf: "^6.0.1",
166
+ "ts-jest": "^29.4.0",
167
+ "ts-node": "^10.9.2",
168
+ tsup: "^8.5.0",
169
+ typescript: "^5.8.3"
170
+ },
171
+ optionalDependencies: {
172
+ "ansi-colors": "^4.1.3"
173
+ },
174
+ workspaces: [
175
+ "packages/*"
176
+ ],
177
+ directories: {
178
+ lib: "lib",
179
+ bin: "bin"
180
+ },
181
+ packageManager: "yarn@4.9.2",
182
+ resolutions: {
183
+ "sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/7696e66ab84f319909c5dab9054303e91f898454/packages/sbg-utility/release/sbg-utility.tgz",
184
+ "cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/80999ac7a7031a81e11ddb5fab0f8ba433041c98/release/cross-spawn.tgz"
185
+ }
186
+ };
187
+ }
188
+ });
189
+
13
190
  // src/binary-collections.cjs
14
191
  var require_binary_collections = __commonJS({
15
192
  "src/binary-collections.cjs"() {
@@ -18,6 +195,8 @@ var require_binary_collections = __commonJS({
18
195
  var { glob } = __require("glob");
19
196
  var path = __require("path");
20
197
  var { getArgs } = require_utils();
198
+ var pkgJson = require_package();
199
+ var fs = __require("fs");
21
200
  function showHelp() {
22
201
  console.log("\u{1F680} Binary Collections - Dynamic Script Runner");
23
202
  console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
@@ -55,6 +234,19 @@ var require_binary_collections = __commonJS({
55
234
  });
56
235
  if (files.length > 0) {
57
236
  return files[0];
237
+ } else {
238
+ if (pkgJson.bin[scriptName]) {
239
+ const find = [
240
+ path.join(searchDir, pkgJson.bin[scriptName]),
241
+ path.join(process.cwd(), "node_modules/binary-collections", pkgJson.bin[scriptName])
242
+ ].filter((file) => fs.existsSync(file));
243
+ if (find.length > 0) {
244
+ return find[0];
245
+ } else {
246
+ console.warn(`\u26A0\uFE0F Script "${scriptName}" not found in ${searchDir}.`);
247
+ console.warn(`\u{1F50D} Searched for: ${pattern} in ${searchDir}`);
248
+ }
249
+ }
58
250
  }
59
251
  } catch (error) {
60
252
  console.error(`\u{1F50D} Error searching for script: ${error.message}`);
@@ -0,0 +1,328 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+ var __commonJS = (cb, mod) => function __require() {
6
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
7
+ };
8
+
9
+ // node_modules/tsup/assets/cjs_shims.js
10
+ var init_cjs_shims = __esm({
11
+ "node_modules/tsup/assets/cjs_shims.js"() {
12
+ }
13
+ });
14
+
15
+ // src/utils.js
16
+ var require_utils = __commonJS({
17
+ "src/utils.js"(exports2, module2) {
18
+ init_cjs_shims();
19
+ var fs2 = require("fs");
20
+ var path2 = require("upath");
21
+ var argv = require("minimist")(process.argv.slice(2));
22
+ var { exec } = require("child_process");
23
+ var { URL: URL2 } = require("url");
24
+ var { promisify } = require("util");
25
+ var execAsync = promisify(exec);
26
+ async function parseGitRemotes() {
27
+ try {
28
+ const { stdout } = await execAsync("git remote -v");
29
+ const lines = stdout.split("\n");
30
+ const remotes = {};
31
+ lines.forEach((line) => {
32
+ const [name, url] = line.split(" ");
33
+ if (name && url) {
34
+ const [repoUrl] = url.split(" ");
35
+ try {
36
+ const parsedUrl = new URL2(repoUrl);
37
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
38
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
39
+ let repoPath = pathParts.join("/");
40
+ if (repoPath.endsWith(".git")) {
41
+ repoPath = repoPath.slice(0, -4);
42
+ }
43
+ remotes[name] = repoPath;
44
+ }
45
+ } catch (e) {
46
+ console.error("URL Parsing Error:", e.message);
47
+ }
48
+ }
49
+ });
50
+ return remotes;
51
+ } catch (error) {
52
+ console.error("Error:", error.message);
53
+ return {};
54
+ }
55
+ }
56
+ module2.exports.parseGitRemotes = parseGitRemotes;
57
+ function joinPathPreserveDriveLetter(...segments) {
58
+ let fullPath = require("path").join(...segments);
59
+ if (/^[a-z]:\\/.test(fullPath)) {
60
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
61
+ }
62
+ return fullPath;
63
+ }
64
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
65
+ function getArgs2() {
66
+ return argv;
67
+ }
68
+ module2.exports.getArgs = getArgs2;
69
+ function del(fullPath) {
70
+ if (fs2.statSync(fullPath).isDirectory()) {
71
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
72
+ for (let i = 0; i < subdir.length; i++) {
73
+ del(subdir[i]);
74
+ }
75
+ } else {
76
+ try {
77
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
78
+ console.log("deleted", fullPath);
79
+ } catch (_) {
80
+ console.log("failed delete", fullPath);
81
+ }
82
+ }
83
+ }
84
+ module2.exports.del = del;
85
+ function delStream(globStream) {
86
+ globStream.stream().on("data", (result) => {
87
+ const fullPath = path2.resolve(process.cwd(), result);
88
+ if (fs2.statSync(fullPath).isDirectory()) {
89
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
90
+ for (let i = 0; i < subdir.length; i++) {
91
+ del(subdir[i]);
92
+ }
93
+ }
94
+ del(fullPath);
95
+ });
96
+ }
97
+ module2.exports.delStream = delStream;
98
+ function getFileTreeString(hashArray) {
99
+ const tree = {};
100
+ const hashMap = {};
101
+ for (const entry of hashArray) {
102
+ const [filePath, hash] = entry.split(" ");
103
+ hashMap[filePath] = hash;
104
+ const parts = filePath.split("/");
105
+ let current = tree;
106
+ for (let i = 0; i < parts.length; i++) {
107
+ const part = parts[i];
108
+ if (i === parts.length - 1) {
109
+ current[part] = null;
110
+ } else {
111
+ current[part] = current[part] || {};
112
+ current = current[part];
113
+ }
114
+ }
115
+ }
116
+ function printNode(node, prefix = "", parentPath = "") {
117
+ const keys = Object.keys(node).sort();
118
+ let lines = [];
119
+ keys.forEach((key, idx) => {
120
+ const isLast = idx === keys.length - 1;
121
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
122
+ const currentPath = parentPath ? parentPath + "/" + key : key;
123
+ if (node[key] === null) {
124
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
125
+ } else {
126
+ lines.push(prefix + branch + key + "/");
127
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
128
+ }
129
+ });
130
+ return lines;
131
+ }
132
+ return printNode(tree, "", "").join("\n");
133
+ }
134
+ module2.exports.getFileTreeString = getFileTreeString;
135
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
136
+ module2.exports.delay = delay;
137
+ }
138
+ });
139
+
140
+ // src/changelog.js
141
+ init_cjs_shims();
142
+ var fs = require("fs");
143
+ var path = require("path");
144
+ var { EOL } = require("os");
145
+ var { getArgs } = require_utils();
146
+ var spawn = require("child_process").spawn;
147
+ var pkgPath = path.join(process.cwd(), "package.json");
148
+ if (!fs.existsSync(pkgPath)) {
149
+ throw new Error(`package.json not found at ${pkgPath}`);
150
+ }
151
+ var pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
152
+ var args = getArgs();
153
+ if (args.help || args.h) {
154
+ showHelp();
155
+ }
156
+ function showHelp() {
157
+ console.log(`
158
+ Usage: node changelog.js [options]
159
+ `);
160
+ console.log(`Options:`);
161
+ console.log(` --help, -h Show this help message and exit`);
162
+ console.log(`
163
+ Description:`);
164
+ console.log(` Generates a CHANGELOG.md file from git commit history.`);
165
+ console.log(` - Looks for version bumps and groups commits by version.`);
166
+ console.log(` - Skips dependabot and irrelevant commits.`);
167
+ console.log(` - Outputs the original git log to tmp/original.md for reference.`);
168
+ console.log(`
169
+ Example:`);
170
+ console.log(` node changelog.js`);
171
+ console.log(``);
172
+ }
173
+ var gitExec = (command) => new Promise((resolve, reject) => {
174
+ const thread = spawn("git", command, { stdio: ["inherit", "pipe", "pipe"] });
175
+ const stdOut = [];
176
+ const stdErr = [];
177
+ thread.stdout.on("data", (data) => {
178
+ stdOut.push(data.toString("utf8"));
179
+ });
180
+ thread.stderr.on("data", (data) => {
181
+ stdErr.push(data.toString("utf8"));
182
+ });
183
+ thread.on("close", () => {
184
+ if (stdErr.length) {
185
+ reject(stdErr.join(""));
186
+ return;
187
+ }
188
+ resolve(stdOut.join());
189
+ });
190
+ });
191
+ function extractVersions(str) {
192
+ const regex = /\bv?(\d+\.\d+\.\d+)\b/g;
193
+ const matches = [];
194
+ let match;
195
+ while ((match = regex.exec(str)) !== null) {
196
+ matches.push(match[1]);
197
+ }
198
+ return Array.from(new Set(matches));
199
+ }
200
+ (async () => {
201
+ const log = await gitExec([
202
+ "log",
203
+ "--reverse",
204
+ `--pretty=format:"=!=%h !|! %ad !|! %an !|! %cn !|! %s !|! %B !|! %d=!="`,
205
+ `--date=format:"%Y-%m-%d %H:%M:%S"`
206
+ ]);
207
+ let markdown = `## CHANGELOG of ${pkg.name}
208
+
209
+ `;
210
+ const repo = await gitExec(["remote", "get-url", "origin"]);
211
+ const repoUrl = repo.trim().replace(/\.git$/, "");
212
+ console.log(`Repository URL: ${repoUrl}`);
213
+ const matches = [...log.matchAll(/=!=(.*?)(?:=!=|=!=,)/gs)];
214
+ const results = matches.map((m) => m[1].trim());
215
+ const versionsCommits = {};
216
+ let currentVersionCommit = "";
217
+ for (const str of results) {
218
+ const splitx = str.split("!|!").map((s) => s.trim());
219
+ const o = {
220
+ hash: splitx[0] ? splitx[0] : "",
221
+ date: splitx[1] ? splitx[1].replace(/^"|"$/g, "") : "",
222
+ authorName: splitx[2] ? splitx[2] : "",
223
+ committerName: splitx[3] ? splitx[3] : "",
224
+ summary: splitx[4] ? splitx[4] : "",
225
+ message: splitx[5] ? splitx[5] : "",
226
+ ref: splitx[6] ? splitx[6] : ""
227
+ };
228
+ let isBumped = /chore\(bump\)|chore: release/i.test(o.summary) || /release/i.test(o.summary) || /tag: v/i.test(o.summary);
229
+ if (o.summary.trim().startsWith("v")) {
230
+ isBumped = true;
231
+ }
232
+ if (/^\d+\.\d+\.\d+$/.test(o.summary.trim())) {
233
+ isBumped = true;
234
+ }
235
+ if (o.summary.trim().startsWith("fix:")) {
236
+ isBumped = false;
237
+ }
238
+ if (isBumped && !extractVersions(o.summary).length > 0) isBumped = false;
239
+ if (o.hash && o.date && o.message) {
240
+ if (o.authorName === "dependabot[bot]") {
241
+ continue;
242
+ }
243
+ if (/^chore\(tarball\): update|merge pull request|merge branch|^migrate from|^update$|^update build from https?:\/\//i.test(
244
+ o.message
245
+ )) {
246
+ continue;
247
+ }
248
+ 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)) {
249
+ continue;
250
+ }
251
+ if (/initial commit/i.test(o.message)) {
252
+ versionsCommits["0.0.0"] = [];
253
+ currentVersionCommit = "0.0.0";
254
+ continue;
255
+ }
256
+ if (isBumped) {
257
+ console.log(`Detected version bump: ${o.summary}`);
258
+ const v = extractVersions(o.message).join(", ");
259
+ versionsCommits[v] = [];
260
+ currentVersionCommit = v;
261
+ } else {
262
+ if (!currentVersionCommit) {
263
+ throw new Error(`No current version commit set for message: ${o.message} (hash: ${o.hash})`);
264
+ }
265
+ const cleanMsg = o.message.replace(/["'\s,]+$/g, "");
266
+ const commitsArr = versionsCommits[currentVersionCommit];
267
+ const prevIdx = commitsArr.findIndex((entry) => {
268
+ const parts = entry.split(/\r?\n/);
269
+ let msgLine = "";
270
+ for (let i = 1; i < parts.length; i++) {
271
+ if (parts[i].trim() !== "") {
272
+ msgLine = parts[i].trim();
273
+ break;
274
+ }
275
+ }
276
+ return msgLine === cleanMsg;
277
+ });
278
+ let newEntry;
279
+ if (cleanMsg.includes("\n")) {
280
+ newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>)` + EOL + EOL + `${cleanMsg}`;
281
+ } else {
282
+ newEntry = `- [ _${o.date}_ ] [${o.hash}](<${repoUrl}/commit/${o.hash}>) ${cleanMsg}`;
283
+ }
284
+ if (prevIdx !== -1) {
285
+ commitsArr[prevIdx] = newEntry;
286
+ } else {
287
+ commitsArr.push(newEntry);
288
+ }
289
+ }
290
+ }
291
+ }
292
+ const versions = Object.keys(versionsCommits).sort((a, b) => {
293
+ const aParts = a.split(".").map(Number);
294
+ const bParts = b.split(".").map(Number);
295
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
296
+ const aPart = aParts[i] || 0;
297
+ const bPart = bParts[i] || 0;
298
+ if (aPart !== bPart) {
299
+ return bPart - aPart;
300
+ }
301
+ }
302
+ return 0;
303
+ });
304
+ for (const version of versions) {
305
+ if (versionsCommits[version].length > 0) {
306
+ markdown += `
307
+ ### ${version}
308
+
309
+ `;
310
+ markdown += versionsCommits[version].map((str) => {
311
+ const lines = str.trim().split(/\r?\n/);
312
+ return [lines[0], ...lines.slice(1).map((line) => " " + line)].join(EOL);
313
+ }).join(EOL);
314
+ } else {
315
+ markdown += `
316
+ ### ${version}
317
+
318
+ `;
319
+ markdown += `- No changes recorded for this version.
320
+ `;
321
+ }
322
+ }
323
+ fs.mkdirSync(path.join(__dirname, "tmp"), { recursive: true });
324
+ fs.writeFileSync(path.join(__dirname, "tmp/original.md"), log);
325
+ fs.writeFileSync(path.join(__dirname, "CHANGELOG.md"), markdown);
326
+ console.log(`Original log written to tmp/original.md`);
327
+ console.log(`Changelog updated successfully. You can find it at CHANGELOG.md`);
328
+ })();
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1 @@
1
+ export {};