binary-collections 2.0.11 → 2.0.12

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.
Files changed (225) hide show
  1. package/.opencode/package.json +5 -0
  2. package/binaries/rmx +15 -1
  3. package/binaries/rmx.cmd +12 -0
  4. package/binaries/test-cjs +9 -1
  5. package/binaries/test-cjs.cmd +16 -1
  6. package/binaries/test-esm +16 -0
  7. package/binaries/test-esm.cjs +178 -0
  8. package/binaries/test-esm.cmd +23 -0
  9. package/binaries/yarn-clean +1 -1
  10. package/binaries/yarn-clean.cmd +1 -1
  11. package/binaries/yarn-clean.py +33 -15
  12. package/binaries/yc +110 -0
  13. package/binaries/yc.cjs +178 -0
  14. package/lib/binary-collections/config.cjs +126 -0
  15. package/lib/binary-collections/config.mjs +7 -0
  16. package/lib/binary-collections/executeScript.cjs +19 -0
  17. package/lib/binary-collections/executeScript.d.cts +12 -0
  18. package/lib/binary-collections/executeScript.mjs +6 -0
  19. package/lib/binary-collections/findScript.cjs +284 -0
  20. package/lib/binary-collections/findScript.d.cts +12 -0
  21. package/lib/binary-collections/findScript.mjs +7 -0
  22. package/lib/binary-collections/listScript.cjs +266 -0
  23. package/lib/binary-collections/listScript.d.cts +19 -0
  24. package/lib/binary-collections/listScript.mjs +7 -0
  25. package/lib/binary-collections.cjs +224 -137
  26. package/lib/binary-collections.mjs +22 -282
  27. package/lib/changelog.cjs +2 -2
  28. package/lib/changelog.mjs +1 -1
  29. package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
  30. package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
  31. package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
  32. package/lib/chunk-6PU7BAHB.mjs +61 -0
  33. package/lib/chunk-C6D2TTYU.mjs +32 -0
  34. package/lib/chunk-FB2WKVJD.mjs +158 -0
  35. package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
  36. package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
  37. package/lib/chunk-H44UWUFY.mjs +105 -0
  38. package/lib/chunk-NCZPTKDV.mjs +79 -0
  39. package/lib/chunk-NGFK3EYW.mjs +28 -0
  40. package/lib/chunk-NVEG3LEZ.mjs +143 -0
  41. package/lib/chunk-OGXVGBRI.mjs +29 -0
  42. package/lib/chunk-OXV52GD5.mjs +62 -0
  43. package/lib/chunk-PXBMHE7O.mjs +35 -0
  44. package/lib/chunk-R5FJOR63.mjs +47 -0
  45. package/lib/chunk-SPTECFE5.mjs +180 -0
  46. package/lib/chunk-UXCFNAR6.mjs +55 -0
  47. package/lib/chunk-V2IBPCEV.mjs +39 -0
  48. package/lib/chunk-XPJGCDOD.mjs +14 -0
  49. package/lib/chunk-ZOWVMII3.mjs +228 -0
  50. package/lib/clean-github-actions-caches-cli.cjs +465 -0
  51. package/lib/clean-github-actions-caches-cli.d.cts +1 -0
  52. package/lib/clean-github-actions-caches-cli.mjs +56 -0
  53. package/lib/clean-github-actions-caches.cjs +149 -205
  54. package/lib/clean-github-actions-caches.d.cts +15 -1
  55. package/lib/clean-github-actions-caches.mjs +4 -130
  56. package/lib/cross-env/command.cjs +63 -0
  57. package/lib/cross-env/command.d.ts +8 -0
  58. package/lib/cross-env/command.js +45 -0
  59. package/lib/cross-env/command.mjs +9 -0
  60. package/lib/cross-env/index.cjs +178 -0
  61. package/lib/cross-env/index.d.ts +8 -0
  62. package/lib/cross-env/index.js +102 -0
  63. package/lib/cross-env/index.mjs +101 -0
  64. package/lib/cross-env/variable.cjs +60 -0
  65. package/lib/cross-env/variable.d.ts +7 -0
  66. package/lib/cross-env/variable.js +59 -0
  67. package/lib/cross-env/variable.mjs +9 -0
  68. package/lib/del-gradle.cjs +2 -2
  69. package/lib/del-gradle.js +8 -8
  70. package/lib/del-gradle.mjs +1 -1
  71. package/lib/del-node-modules.js +24 -24
  72. package/lib/del-ps.cjs +2 -2
  73. package/lib/del-ps.js +8 -8
  74. package/lib/del-ps.mjs +1 -1
  75. package/lib/del-yarn-caches.cjs +2 -2
  76. package/lib/del-yarn-caches.js +2 -2
  77. package/lib/del-yarn-caches.mjs +1 -1
  78. package/lib/file/copy-cli.cjs +92 -0
  79. package/lib/file/copy-cli.d.mts +1 -0
  80. package/lib/file/copy-cli.mjs +55 -0
  81. package/lib/file/copy.cjs +56 -0
  82. package/lib/file/copy.d.mts +1 -0
  83. package/lib/file/copy.mjs +8 -0
  84. package/lib/file/move-cli.cjs +91 -0
  85. package/lib/file/move-cli.d.mts +1 -0
  86. package/lib/file/move-cli.mjs +55 -0
  87. package/lib/file/move.cjs +55 -0
  88. package/lib/file/move.d.mts +1 -0
  89. package/lib/file/move.mjs +8 -0
  90. package/lib/find-node-modules-cli.js +1 -1
  91. package/lib/free-chatgpt.cjs +21 -15
  92. package/lib/free-chatgpt.js +10 -10
  93. package/lib/free-chatgpt.mjs +2 -2
  94. package/lib/git/user-config.cjs +2 -2
  95. package/lib/git/user-config.mjs +2 -2
  96. package/lib/git-diff-cli.cjs +188 -42
  97. package/lib/git-diff-cli.mjs +5 -4
  98. package/lib/git-diff.cjs +188 -42
  99. package/lib/git-diff.d.ts +2 -1
  100. package/lib/git-diff.js +91 -34
  101. package/lib/git-diff.mjs +5 -4
  102. package/lib/git-fix.cjs +2 -2
  103. package/lib/git-fix.mjs +2 -2
  104. package/lib/git-purge.cjs +2 -2
  105. package/lib/git-purge.mjs +1 -1
  106. package/lib/index.d.ts +1 -1
  107. package/lib/kill-night-crows.cjs +7 -7
  108. package/lib/kill-night-crows.mjs +7 -7
  109. package/lib/node-cache-cleaner/npm.cjs +65 -0
  110. package/lib/node-cache-cleaner/npm.d.ts +2 -0
  111. package/lib/node-cache-cleaner/npm.js +41 -0
  112. package/lib/node-cache-cleaner/npm.mjs +10 -0
  113. package/lib/node-cache-cleaner/npx.cjs +89 -0
  114. package/lib/node-cache-cleaner/npx.d.ts +4 -0
  115. package/lib/node-cache-cleaner/npx.js +82 -0
  116. package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
  117. package/lib/node-cache-cleaner/yarn.cjs +73 -0
  118. package/lib/node-cache-cleaner/yarn.d.ts +2 -0
  119. package/lib/node-cache-cleaner/yarn.js +62 -0
  120. package/lib/node-cache-cleaner/yarn.mjs +10 -0
  121. package/lib/node-cache-cleaner-cli.cjs +182 -0
  122. package/lib/node-cache-cleaner-cli.d.ts +2 -0
  123. package/lib/node-cache-cleaner-cli.js +60 -0
  124. package/lib/node-cache-cleaner-cli.mjs +56 -0
  125. package/lib/node-executor.cjs +91 -0
  126. package/lib/node-executor.d.cts +2 -0
  127. package/lib/node-executor.mjs +103 -0
  128. package/lib/npm-run-series.cjs +21 -28
  129. package/lib/npm-run-series.mjs +20 -6
  130. package/lib/package-resolutions-updater-cli.cjs +213 -128
  131. package/lib/package-resolutions-updater-cli.mjs +17 -39
  132. package/lib/package-resolutions-updater.cjs +204 -98
  133. package/lib/package-resolutions-updater.d.mts +20 -1
  134. package/lib/package-resolutions-updater.mjs +7 -5
  135. package/lib/print-directory-tree.cjs +2 -2
  136. package/lib/print-directory-tree.mjs +1 -1
  137. package/lib/ps/connected-domain.js +10 -10
  138. package/lib/ps/index.cjs +1 -1
  139. package/lib/ps/index.mjs +177 -171
  140. package/lib/ps/isWin.js +1 -1
  141. package/lib/ps/table-parser.js +6 -6
  142. package/lib/remove-module.cjs +2 -2
  143. package/lib/remove-module.mjs +1 -1
  144. package/lib/rm-node-module-cli.cjs +222 -0
  145. package/lib/rm-node-module-cli.d.cts +1 -0
  146. package/lib/rm-node-module-cli.mjs +89 -0
  147. package/lib/rm-node-modules.cjs +127 -0
  148. package/lib/rm-node-modules.d.cts +35 -0
  149. package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
  150. package/lib/rmpath.cjs +2 -2
  151. package/lib/rmpath.mjs +1 -1
  152. package/lib/submodule-install.cjs +47 -34
  153. package/lib/submodule-install.mjs +46 -33
  154. package/lib/submodule-remove-cli.cjs +1 -2
  155. package/lib/submodule-remove-cli.js +3 -3
  156. package/lib/submodule-remove-cli.mjs +1 -2
  157. package/lib/utils/chatgpt.cjs +19 -13
  158. package/lib/utils/chatgpt.js +94 -94
  159. package/lib/utils/chatgpt.mjs +1 -1
  160. package/lib/utils/findEnvFiles.cjs +28 -46
  161. package/lib/utils/findEnvFiles.d.cts +19 -0
  162. package/lib/utils/findEnvFiles.mjs +3 -5
  163. package/lib/utils/findWorkspaceRoot.js +4 -4
  164. package/lib/utils/index.cjs +2 -2
  165. package/lib/utils/index.mjs +1 -1
  166. package/lib/utils/isGithubTokenValid.js +7 -7
  167. package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
  168. package/lib/utils/isWindows.d.ts +5 -0
  169. package/lib/utils/isWindows.js +10 -0
  170. package/lib/utils/isWindows.mjs +8 -0
  171. package/lib/utils/runBash.cjs +53 -0
  172. package/lib/utils/runBash.d.cts +12 -0
  173. package/lib/utils/runBash.mjs +66 -0
  174. package/lib/yarn-per-branch-lock-installer.cjs +97 -0
  175. package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
  176. package/lib/yarn-per-branch-lock-installer.mjs +109 -0
  177. package/lib/yarn-reinstall.cjs +2 -2
  178. package/lib/yarn-reinstall.mjs +1 -1
  179. package/package.json +61 -52
  180. package/readme.html +784 -0
  181. package/readme.md +106 -218
  182. package/releases/readme.md +1 -1
  183. package/test/README.md +2 -2
  184. package/test-project/package.json +8 -2
  185. package/test-project/workspaces/workspace-a/package.json +135 -0
  186. package/test-project/workspaces/workspace-a/readme.md +20 -0
  187. package/test-project/workspaces/workspace-a/release/readme.md +42 -0
  188. package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
  189. package/test-project/workspaces/workspace-a/test/readme.md +12 -0
  190. package/test-project/workspaces/workspace-b/package.json +139 -0
  191. package/test-project/workspaces/workspace-b/readme.md +94 -0
  192. package/test-project/workspaces/workspace-b/requirements.txt +1 -0
  193. package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
  194. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
  195. package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
  196. package/tmp/rm-node-modules-test-project/package.json +17 -0
  197. package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
  198. package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
  199. package/tmp/test-repo/README.md +2 -35
  200. package/tmp/test-repo/package.json +13 -3
  201. package/docs-src/clean-github-actions-caches.md +0 -26
  202. package/docs-src/free-chatgpt.md +0 -26
  203. package/lib/binary-collections-config.cjs +0 -15
  204. package/lib/chunk-2CBJCW7E.mjs +0 -81
  205. package/lib/chunk-4UHL4WVN.mjs +0 -136
  206. package/lib/chunk-66PAU5PS.mjs +0 -31
  207. package/lib/chunk-6HHJRKFB.mjs +0 -59
  208. package/lib/chunk-7XTEJHOE.mjs +0 -193
  209. package/lib/chunk-FCDQGYBF.mjs +0 -136
  210. package/lib/chunk-GEYA2USY.mjs +0 -207
  211. package/lib/chunk-GJTGHXRA.mjs +0 -356
  212. package/lib/chunk-ID2WBTE2.mjs +0 -80
  213. package/lib/chunk-JXFOHKDM.mjs +0 -239
  214. package/lib/chunk-PDSXF5HY.mjs +0 -187
  215. package/lib/chunk-RWLXRTYP.mjs +0 -109
  216. package/lib/chunk-TOIVAQF7.mjs +0 -136
  217. package/lib/chunk-V5SKYJUB.mjs +0 -136
  218. package/lib/chunk-WSRETQCA.mjs +0 -59
  219. package/lib/chunk-YYLIQQKF.mjs +0 -31
  220. package/lib/ps/index.d.ts +0 -2
  221. package/lib/ps/index.js +0 -254
  222. package/lib/utils/findEnvFiles.d.ts +0 -8
  223. package/lib/utils/findEnvFiles.js +0 -121
  224. package/tmp/typedoc/readme.md +0 -320
  225. /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
@@ -1,26 +0,0 @@
1
- ## GitHub Actions Cache Cleaner
2
-
3
- Removes outdated GitHub Actions caches in the current repository, keeping only the newest cache for each prefix. Ensures safe cleanup by retaining the latest cache per group and authenticates using tokens from your .env file.
4
-
5
- ### Usage
6
-
7
- ```bash
8
- # use npx
9
- npx --yes binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches
10
-
11
- # use yarn dlx
12
- yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz clean-github-actions-caches
13
- ```
14
-
15
- ### Features
16
- - Authenticates using `ACCESS_TOKEN` or `GITHUB_TOKEN` from your `.env` file
17
- - Groups caches by prefix and deletes all but the latest for each group
18
- - Operates on the current repository (origin remote) and matches the working directory of your terminal
19
- - Safe: Only deletes caches older than the most recent per prefix
20
-
21
- ### Environment Setup
22
- 1. Add `ACCESS_TOKEN` or `GITHUB_TOKEN` to your `.env` file
23
- 2. Ensure you have access to the repository's cache management
24
-
25
- ### Source
26
- See [`src/clean-github-actions-caches.cjs`](../src/clean-github-actions-caches.cjs)
@@ -1,26 +0,0 @@
1
- # free-chatgpt.js
2
-
3
- Automates browser interaction with ChatGPT using Puppeteer, including login, question submission, and response retrieval. Supports session persistence via cookies and flexible question input.
4
-
5
- ## Usage
6
-
7
- ```bash
8
- # use npx
9
- npx --yes binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz free-chatgpt
10
-
11
- # use yarn dlx
12
- yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz free-chatgpt
13
- ```
14
-
15
- ### Argument Options
16
-
17
- - `--question, -q` The question to ask ChatGPT (default: "Hello, ChatGPT!")
18
- - `--qfile, -qf` Path to a file containing the question text
19
- - `--help, -h` Show help message
20
-
21
- ## Notes
22
-
23
- - Cookies are stored in `./tmp/cookies` for session reuse.
24
- - Responses are saved to `./tmp/response.txt`.
25
- - Requires access to `chat.openai.com` (firewall must allow connection).
26
- - Uses Puppeteer with stealth plugin to avoid bot detection.
@@ -1,15 +0,0 @@
1
- // src/binary-collections-config.cjs
2
- var path = require("path");
3
- require("dotenv").config({ path: path.join(process.cwd(), ".env"), quiet: true, override: true });
4
- function getTempDir() {
5
- return process.env.TEMP_DIR || path.join(process.cwd(), "tmp");
6
- }
7
- function getTempPath(...segments) {
8
- return path.join(getTempDir(), ...segments);
9
- }
10
- var TEMP_BASE_DIR = getTempDir();
11
- module.exports = {
12
- getTempDir,
13
- getTempPath,
14
- TEMP_BASE_DIR
15
- };
@@ -1,81 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_gitattributes
4
- } from "./chunk-PDSXF5HY.mjs";
5
- import {
6
- require_utils
7
- } from "./chunk-A3VUZEJK.mjs";
8
- import {
9
- __commonJS,
10
- __require,
11
- init_esm_shims
12
- } from "./chunk-QQ4A6DLD.mjs";
13
-
14
- // src/git/line-endings.cjs
15
- var require_line_endings = __commonJS({
16
- "src/git/line-endings.cjs"(exports, module) {
17
- init_esm_shims();
18
- var path = __require("upath");
19
- var fs = __require("fs");
20
- var { runGitCommand } = require_utils();
21
- var { updateGitAttributes } = require_gitattributes();
22
- function forceLfLineEndings() {
23
- console.log("\n=== Configuring LF Line Endings ===");
24
- runGitCommand(["config", "core.autocrlf", "false"], "Disable automatic CRLF conversion");
25
- runGitCommand(["config", "core.eol", "lf"], "Set end-of-line to LF");
26
- const gitattributesPath = path.join(process.cwd(), ".gitattributes");
27
- if (fs.existsSync(gitattributesPath)) {
28
- let content = fs.readFileSync(gitattributesPath, "utf8");
29
- if (!/^\*\s+text=auto\s+eol=lf/m.test(content)) {
30
- content = `* text=auto eol=lf
31
- ` + content;
32
- fs.writeFileSync(gitattributesPath, content);
33
- }
34
- }
35
- const desiredRules = [
36
- { pattern: "*", attributes: "text=auto eol=lf", priority: 1 },
37
- {
38
- pattern: "*.{cmd,bat,ps1,sh,cmd1,cmd2,bat1,bat2,vbs}",
39
- attributes: "text eol=crlf",
40
- priority: 2
41
- },
42
- {
43
- pattern: "*.{png,jpg,jpeg,gif,ico,svg,bmp,webp,avif,tiff,tif,psd,ai,eps,raw}",
44
- attributes: "binary",
45
- priority: 3
46
- },
47
- {
48
- pattern: "*.{zip,tar,gz,7z,rar,exe,dll,so,bin,jar,war,ear,apk,msi,deb,rpm,iso,img,dmg,pdf,mp3,mp4,mov,avi,mkv,flv,wmv,ogg,webm,wav,aac,m4a,otf,ttf,woff,woff2,eot}",
49
- attributes: "binary",
50
- priority: 3
51
- }
52
- ];
53
- const result = updateGitAttributes(gitattributesPath, desiredRules);
54
- if (result.error) {
55
- console.log(`[\u2717] Error updating .gitattributes: ${result.error}`);
56
- return;
57
- }
58
- if (result.conflicts.length > 0) {
59
- console.log("\n[!] Detected conflicts in .gitattributes:");
60
- result.conflicts.forEach((conflict) => {
61
- console.log(` ${conflict.pattern}: ${conflict.existing} -> ${conflict.proposed} (${conflict.action})`);
62
- });
63
- }
64
- if (result.success) {
65
- console.log(`[\u2713] ${result.message}:`);
66
- result.changes.forEach((change) => {
67
- console.log(` ${change.action}: ${change.pattern} ${change.attributes}`);
68
- });
69
- } else {
70
- console.log(`[i] ${result.message}`);
71
- }
72
- }
73
- module.exports = {
74
- forceLfLineEndings
75
- };
76
- }
77
- });
78
-
79
- export {
80
- require_line_endings
81
- };
@@ -1,136 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- runChatGpt
4
- } from "./chunk-GJTGHXRA.mjs";
5
- import {
6
- require_binary_collections_config
7
- } from "./chunk-66PAU5PS.mjs";
8
- import {
9
- require_utils
10
- } from "./chunk-Z6JLYU2J.mjs";
11
- import {
12
- __toESM,
13
- init_esm_shims
14
- } from "./chunk-QQ4A6DLD.mjs";
15
-
16
- // src/git-diff.js
17
- init_esm_shims();
18
- var import_binary_collections_config = __toESM(require_binary_collections_config(), 1);
19
- import { execSync } from "child_process";
20
- import fs from "fs-extra";
21
- import path from "upath";
22
- import { fileURLToPath } from "url";
23
- var import_utils = __toESM(require_utils(), 1);
24
- var __filename = fileURLToPath(import.meta.url);
25
- var __dirname = path.dirname(__filename);
26
- var DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("git-diff.txt");
27
- var GPT_DIFF_OUTPUT = (0, import_binary_collections_config.getTempPath)("gpt-question.txt");
28
- var CACHE_DIR = path.dirname(DIFF_OUTPUT);
29
- var DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), DIFF_OUTPUT);
30
- var GPT_DIFF_OUTPUT_RELATIVE = path.relative(process.cwd(), GPT_DIFF_OUTPUT);
31
- if (!fs.existsSync(CACHE_DIR)) {
32
- fs.mkdirSync(CACHE_DIR, { recursive: true });
33
- }
34
- function showHelp() {
35
- console.log("\u{1F4DD} Git Diff Helper");
36
- console.log("\u{1F4C4} Usage:");
37
- console.log(" \u{1F4C2} git-diff FILE Show staged diff of specified file");
38
- console.log(" \u{1F4C2} git-diff --staged-only Show staged diff of all files");
39
- console.log(" \u{1F4C2} git-diff -s | -S Same as --staged-only");
40
- console.log(" \u{1F4C2} git-diff --ai Run ChatGPT automation for commit message");
41
- console.log(" \u{1F4C2} git-diff --help | -h Show this help message");
42
- console.log("");
43
- console.log(`\u{1F4BE} Output is saved to: ${DIFF_OUTPUT_RELATIVE}`);
44
- console.log(`\u{1F916} GPT prompt is saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
45
- process.exit(0);
46
- }
47
- function runGitDiff(command, successMessage, errorMessage) {
48
- try {
49
- console.log(`\u{1F50D} [i] Running command: ${command}`);
50
- const result = execSync(command, {
51
- encoding: "utf8",
52
- maxBuffer: 1024 * 1024 * 10
53
- // 10MB buffer to handle large diffs
54
- });
55
- if (!result || result.trim() === "") {
56
- console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
57
- fs.writeFileSync(DIFF_OUTPUT, "# No changes found\n");
58
- console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
59
- return;
60
- }
61
- fs.writeFileSync(DIFF_OUTPUT, result);
62
- fs.writeFileSync(
63
- GPT_DIFF_OUTPUT,
64
- `Hello, ChatGPT!
65
- Can you create a conventional commit message by diff content below:
66
-
67
- \`\`\`${result}
68
- \`\`\`
69
-
70
- Give me result as codeblock with language "text" only.
71
-
72
- Thank you!`
73
- );
74
- console.log(`\u2705 ${successMessage}`);
75
- console.log(`\u{1F4BE} GPT diff prompt saved to "${GPT_DIFF_OUTPUT_RELATIVE}"`);
76
- } catch (error) {
77
- console.error(`\u274C ${errorMessage}`);
78
- console.error(`\u{1F4DD} Command: ${command}`);
79
- console.error(`\u26A0\uFE0F Error: ${error.message}`);
80
- if (error.message.includes("not a git repository")) {
81
- console.error("\u{1F6A7} Make sure you are in a git repository");
82
- }
83
- process.exit(1);
84
- }
85
- }
86
- async function mainGitDiff() {
87
- const args = (0, import_utils.getArgs)();
88
- const positional = args._ || [];
89
- if (args.help || args.h) {
90
- showHelp();
91
- }
92
- if (args["staged-only"] || args.s || args.S) {
93
- runGitDiff(
94
- "git --no-pager diff --staged",
95
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
96
- "Failed to save staged diff"
97
- );
98
- } else {
99
- const file = positional[0];
100
- if (!file) {
101
- runGitDiff(
102
- "git --no-pager diff",
103
- `Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
104
- "Failed to save all diff's"
105
- );
106
- } else {
107
- runGitDiff(
108
- `git --no-pager diff --cached -- "${file}"`,
109
- `Staged diff of "${file}" saved to "${DIFF_OUTPUT_RELATIVE}"`,
110
- `Failed to generate diff for "${file}"`
111
- );
112
- }
113
- }
114
- if (args.ai) {
115
- try {
116
- await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
117
- } catch (error) {
118
- console.error("\u274C Error running ChatGPT:", error.message);
119
- console.error("\u{1F4A1} Try running with visible browser mode or check if Chrome is installed");
120
- }
121
- } else {
122
- console.log("\u{1F4A1} Tip: Use --ai flag to generate commit message with ChatGPT");
123
- }
124
- }
125
- var git_diff_default = runGitDiff;
126
-
127
- export {
128
- DIFF_OUTPUT,
129
- GPT_DIFF_OUTPUT,
130
- CACHE_DIR,
131
- DIFF_OUTPUT_RELATIVE,
132
- GPT_DIFF_OUTPUT_RELATIVE,
133
- runGitDiff,
134
- mainGitDiff,
135
- git_diff_default
136
- };
@@ -1,31 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- __commonJS,
4
- __require,
5
- init_esm_shims
6
- } from "./chunk-QQ4A6DLD.mjs";
7
-
8
- // src/binary-collections-config.cjs
9
- var require_binary_collections_config = __commonJS({
10
- "src/binary-collections-config.cjs"(exports, module) {
11
- init_esm_shims();
12
- var path = __require("path");
13
- __require("dotenv").config({ path: path.join(process.cwd(), ".env") });
14
- function getTempDir() {
15
- return process.env.TEMP_DIR || path.join(process.cwd(), "tmp");
16
- }
17
- function getTempPath(...segments) {
18
- return path.join(getTempDir(), ...segments);
19
- }
20
- var TEMP_BASE_DIR = getTempDir();
21
- module.exports = {
22
- getTempDir,
23
- getTempPath,
24
- TEMP_BASE_DIR
25
- };
26
- }
27
- });
28
-
29
- export {
30
- require_binary_collections_config
31
- };
@@ -1,59 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- __commonJS,
4
- __require,
5
- init_esm_shims
6
- } from "./chunk-QQ4A6DLD.mjs";
7
-
8
- // src/submodule-remove.cjs
9
- var require_submodule_remove = __commonJS({
10
- "src/submodule-remove.cjs"(exports, module) {
11
- init_esm_shims();
12
- var { spawnAsync } = __require("cross-spawn");
13
- var path = __require("upath");
14
- var fs = __require("fs-extra");
15
- var dotenv = __require("dotenv");
16
- dotenv.config({ path: path.resolve(process.cwd(), ".env") });
17
- async function removeSubmodule(submodulePath) {
18
- try {
19
- await spawnAsync("git", ["submodule", "deinit", "-f", submodulePath], { stdio: "inherit" });
20
- } catch (error) {
21
- console.warn(`Warning: Could not deinitialize submodule "${submodulePath}". It may not exist.`);
22
- console.warn(error.message);
23
- }
24
- try {
25
- await spawnAsync("git", ["config", "--remove-section", `submodule.${submodulePath}`], { stdio: "inherit" });
26
- } catch (error) {
27
- console.warn(`Warning: Could not remove git config section for submodule "${submodulePath}". It may not exist.`);
28
- console.warn(error.message);
29
- }
30
- const gitModulesPath = path.resolve(".git", "modules", submodulePath);
31
- if (fs.existsSync(gitModulesPath)) {
32
- fs.rmSync(gitModulesPath, { recursive: true, force: true });
33
- console.log(`Removed .git/modules entry for submodule "${submodulePath}".`);
34
- } else {
35
- console.warn(`Warning: The path "${gitModulesPath}" does not exist. Skipping removal of .git/modules entry.`);
36
- }
37
- const gitmodulesPath = path.resolve(".gitmodules");
38
- if (fs.existsSync(gitmodulesPath)) {
39
- let gitmodulesContent = fs.readFileSync(gitmodulesPath, "utf-8");
40
- const submoduleSectionRegex = new RegExp(
41
- `\\[submodule "${submodulePath.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}"]([\\s\\S]*?)(?=\\[|$)`,
42
- "g"
43
- );
44
- gitmodulesContent = gitmodulesContent.replace(submoduleSectionRegex, "").trim();
45
- fs.writeFileSync(gitmodulesPath, gitmodulesContent);
46
- console.log(`Removed submodule "${submodulePath}" from .gitmodules.`);
47
- } else {
48
- console.warn(`Warning: The .gitmodules file does not exist. Skipping removal of submodule "${submodulePath}".`);
49
- }
50
- fs.rmSync(path.resolve(submodulePath), { recursive: true, force: true });
51
- console.log(`Submodule "${submodulePath}" has been removed.`);
52
- }
53
- module.exports = removeSubmodule;
54
- }
55
- });
56
-
57
- export {
58
- require_submodule_remove
59
- };
@@ -1,193 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import {
3
- require_utils
4
- } from "./chunk-Z6JLYU2J.mjs";
5
- import {
6
- __toESM,
7
- init_esm_shims
8
- } from "./chunk-QQ4A6DLD.mjs";
9
-
10
- // src/package-resolutions-updater.mjs
11
- init_esm_shims();
12
- var utils = __toESM(require_utils(), 1);
13
- import * as dotenv from "dotenv";
14
- import fs from "fs";
15
- import https from "https";
16
- import os from "os";
17
- import path from "path";
18
- var projectDir = process.cwd();
19
- var envPath = path.join(projectDir, ".env");
20
- var args = utils.getArgs();
21
- if (fs.existsSync(envPath)) dotenv.config({ path: envPath, quiet: true, override: true });
22
- var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
23
- if (args.help || args.h) {
24
- showHelp();
25
- }
26
- function showHelp() {
27
- const helpText = `
28
- GitHub Package Resolutions Updater
29
- Usage:
30
- node src/package-resolutions-updater.mjs [options]
31
- Options:
32
- --help, -h Show this help message
33
- Description:
34
- Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.
35
- Features:
36
- - Parses GitHub URLs to extract repository owner, name, and branch.
37
- - Fetches the latest commit SHA across all branches using GitHub's API.
38
- - Replaces the old branch or commit in the URL with the latest SHA.
39
- - Overwrites package.json with the updated URLs.
40
- Requirements:
41
- - GitHub Personal Access Token (GITHUB_TOKEN) via .env
42
- - ESM support (type: "module" in package.json)
43
- - Node.js v18+ recommended
44
- Dependencies:
45
- - ansi-colors \u2013 for styled terminal output
46
- - dotenv \u2013 to load GitHub token from .env
47
- Examples:
48
- node src/package-resolutions-updater.mjs
49
- node src/package-resolutions-updater.mjs --help
50
-
51
- `;
52
- console.log(helpText);
53
- process.exit(0);
54
- }
55
- var GITHUB_USER_AGENTS = [
56
- "octokit-rest.js/19.0.7",
57
- "GitHub CLI/2.40.0",
58
- "Mozilla/5.0 (compatible; GitHubCopilot/1.0)",
59
- "PostmanRuntime/7.32.3",
60
- "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
61
- ];
62
- var userAgentDir = path.join(os.tmpdir(), "nodejs");
63
- var userAgentFile = path.join(userAgentDir, "useragent.txt");
64
- var selectedUserAgent;
65
- try {
66
- if (!fs.existsSync(userAgentDir)) fs.mkdirSync(userAgentDir, { recursive: true });
67
- if (fs.existsSync(userAgentFile)) {
68
- const fileAgent = fs.readFileSync(userAgentFile, "utf-8").trim();
69
- if (GITHUB_USER_AGENTS.includes(fileAgent)) {
70
- selectedUserAgent = fileAgent;
71
- }
72
- }
73
- if (!selectedUserAgent) {
74
- selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
75
- fs.writeFileSync(userAgentFile, selectedUserAgent, "utf-8");
76
- }
77
- } catch (_e) {
78
- selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
79
- }
80
- function fetchJson(url) {
81
- const headers = {
82
- "User-Agent": selectedUserAgent,
83
- Accept: "application/vnd.github.v3+json",
84
- "X-GitHub-Api-Version": "2022-11-28",
85
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
86
- };
87
- return new Promise((resolve, reject) => {
88
- https.get(url, { headers }, (res) => {
89
- let data = "";
90
- res.on("data", (chunk) => data += chunk);
91
- res.on("end", () => {
92
- try {
93
- const json = JSON.parse(data);
94
- if (res.statusCode < 200 || res.statusCode >= 300) {
95
- return reject(
96
- new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
97
- URL: ${url}`)
98
- );
99
- }
100
- resolve(json);
101
- } catch {
102
- reject(new Error(`Invalid JSON from: ${url}`));
103
- }
104
- });
105
- }).on("error", reject);
106
- });
107
- }
108
- async function getLatestCommit(owner, repo, branch = "main") {
109
- var _a, _b, _c, _d;
110
- const url = `https://api.github.com/repos/${owner}/${repo}/commits/${branch}`;
111
- const json = await fetchJson(url);
112
- const sha = json.sha;
113
- const dateStr = ((_b = (_a = json.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = json.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
114
- if (!sha || !dateStr) {
115
- console.log(json);
116
- throw new Error(`Missing SHA or date for ${owner}/${repo}@${branch}`);
117
- }
118
- return {
119
- owner,
120
- repo,
121
- branch,
122
- sha,
123
- date: new Date(dateStr).toISOString()
124
- };
125
- }
126
- async function getLatestCommitAcrossBranches(owner, repo) {
127
- const branches = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/branches`);
128
- const commits = await Promise.all(
129
- branches.map(async ({ name, commit }) => {
130
- var _a, _b, _c, _d;
131
- const commitSha = commit == null ? void 0 : commit.sha;
132
- if (!commitSha) {
133
- console.warn(`No commit SHA for '${owner}/${repo}' branch: ${name}`);
134
- return { branch: name, sha: "", date: /* @__PURE__ */ new Date(0) };
135
- }
136
- try {
137
- const commitData = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}`);
138
- const dateStr = ((_b = (_a = commitData.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = commitData.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
139
- const date = dateStr ? new Date(dateStr) : /* @__PURE__ */ new Date(0);
140
- return { branch: name, sha: commitData.sha, date };
141
- } catch (e) {
142
- console.warn(`Failed to fetch commit for ${name}: ${e.message}`);
143
- return { branch: name, sha: commitSha, date: /* @__PURE__ */ new Date(0) };
144
- }
145
- })
146
- );
147
- const latest = commits.reduce((a, b) => a.date > b.date ? a : b, { date: /* @__PURE__ */ new Date(0) });
148
- return {
149
- owner,
150
- repo,
151
- branch: latest.branch,
152
- sha: latest.sha,
153
- date: latest.date.toISOString()
154
- };
155
- }
156
- function replaceRawWithLatestHash(url, latestHash) {
157
- const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/(.+)$/);
158
- if (!match) throw new Error("Invalid GitHub raw URL");
159
- const [, owner, repo, _oldHash, path2] = match;
160
- return `https://github.com/${owner}/${repo}/raw/${latestHash}/${path2}`;
161
- }
162
- function parseGitHubUrl(url) {
163
- const ghRepoRoot = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/;
164
- const ghTreeOrBlob = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/(tree|blob)\/([^/]+(?:\/[^/]+)*)/;
165
- const ghRaw = /^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)(\/.+)?$/;
166
- const ghDotComRaw = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/.+/;
167
- let match;
168
- if (match = url.match(ghRaw)) {
169
- const [, owner, repo, branch] = match;
170
- return { owner, repo, branch, url };
171
- }
172
- if (match = url.match(ghDotComRaw)) {
173
- const [, owner, repo, branch] = match;
174
- return { owner, repo, branch, url };
175
- }
176
- if (match = url.match(ghTreeOrBlob)) {
177
- const [, owner, repo, , branchPath] = match;
178
- return { owner, repo, branch: branchPath, url };
179
- }
180
- if (match = url.match(ghRepoRoot)) {
181
- const [, owner, repo] = match;
182
- return { owner, repo, url };
183
- }
184
- throw new Error(`Unsupported GitHub URL: ${url}`);
185
- }
186
-
187
- export {
188
- fetchJson,
189
- getLatestCommit,
190
- getLatestCommitAcrossBranches,
191
- replaceRawWithLatestHash,
192
- parseGitHubUrl
193
- };