binary-collections 2.0.9 → 2.0.10

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 (253) hide show
  1. package/binaries/binary-executor.cjs +43 -0
  2. package/{bin → binaries}/clean-nodemodule +0 -0
  3. package/binaries/clean-nodemodule.cjs +43 -0
  4. package/binaries/clean-nodemodule.cmd +4 -0
  5. package/{bin → binaries}/clean-nodemodules +0 -0
  6. package/binaries/clean-nodemodules.cjs +43 -0
  7. package/binaries/clean-nodemodules.cmd +5 -0
  8. package/{bin → binaries}/dev +0 -0
  9. package/binaries/dev.cjs +43 -0
  10. package/{bin → binaries}/empty +0 -0
  11. package/binaries/empty.cjs +43 -0
  12. package/{bin → binaries}/git-reduce-size +0 -0
  13. package/binaries/git-reduce-size.cjs +43 -0
  14. package/binaries/javakill.cjs +43 -0
  15. package/{bin → binaries}/javakill.cmd +0 -0
  16. package/{bin → binaries}/kill-process +0 -0
  17. package/binaries/kill-process.cjs +43 -0
  18. package/binaries/nodekill.cjs +43 -0
  19. package/{bin → binaries}/nodekill.ps1 +0 -0
  20. package/{bin → binaries}/prod +0 -0
  21. package/binaries/prod.cjs +43 -0
  22. package/{bin → binaries}/rmfind +0 -0
  23. package/binaries/rmfind.cjs +43 -0
  24. package/{bin → binaries}/rmx +0 -0
  25. package/binaries/rmx.cjs +43 -0
  26. package/{bin → binaries}/submodule-token +0 -0
  27. package/binaries/submodule-token.cjs +43 -0
  28. package/docs-src/clean-github-actions-caches.md +26 -0
  29. package/docs-src/free-chatgpt.md +26 -0
  30. package/lib/binary-collections-config.cjs +3 -2
  31. package/lib/binary-collections-config.mjs +2 -2
  32. package/lib/binary-collections.cjs +452 -105
  33. package/lib/binary-collections.mjs +131 -84
  34. package/lib/changelog.cjs +3 -3
  35. package/lib/changelog.mjs +177 -171
  36. package/lib/chunk-4EWQC6GZ.mjs +382 -0
  37. package/lib/chunk-4ZI7BQKQ.mjs +381 -0
  38. package/lib/chunk-5J2BEPY5.mjs +83 -0
  39. package/lib/{chunk-4BYBVEYC.mjs → chunk-66PAU5PS.mjs} +5 -4
  40. package/lib/chunk-6HHJRKFB.mjs +59 -0
  41. package/lib/chunk-6S4NXESK.mjs +26 -0
  42. package/lib/{chunk-ZYAQRPUL.mjs → chunk-7YD7IPFF.mjs} +2 -2
  43. package/lib/{chunk-SH3L6HHV.mjs → chunk-A2JQXI5Z.mjs} +2 -2
  44. package/lib/{chunk-EGSSKVDH.mjs → chunk-A3VUZEJK.mjs} +1 -1
  45. package/lib/chunk-AGZYRDC2.mjs +323 -0
  46. package/lib/{chunk-VVEZVNIV.mjs → chunk-AI4CVPJ7.mjs} +6 -6
  47. package/lib/chunk-BDCHCWHD.mjs +136 -0
  48. package/lib/chunk-BEZKJ25G.mjs +140 -0
  49. package/lib/chunk-DI5MDPSN.mjs +386 -0
  50. package/lib/{chunk-ONIBBBQ3.mjs → chunk-E6FDDAOO.mjs} +4 -3
  51. package/lib/chunk-FKI7IEB5.mjs +172 -0
  52. package/lib/chunk-GJTGHXRA.mjs +356 -0
  53. package/lib/{chunk-YV7DO3YV.mjs → chunk-HLGOWBEO.mjs} +1 -1
  54. package/lib/chunk-HMRMTYZM.mjs +40 -0
  55. package/lib/chunk-HN52G2YL.mjs +305 -0
  56. package/lib/chunk-HO6GHCOB.mjs +385 -0
  57. package/lib/chunk-LEM5OMRP.mjs +384 -0
  58. package/lib/{chunk-YX5U7XDR.mjs → chunk-M3YIYRHT.mjs} +6 -5
  59. package/lib/chunk-O6SWBEOQ.mjs +81 -0
  60. package/lib/{chunk-JGR2NW6D.mjs → chunk-PDSXF5HY.mjs} +3 -3
  61. package/lib/{chunk-AASHBCRW.mjs → chunk-QQ4A6DLD.mjs} +8 -0
  62. package/lib/chunk-RCP7DHVY.mjs +190 -0
  63. package/lib/chunk-SBNDSKG5.mjs +136 -0
  64. package/lib/chunk-U6SO4QEV.mjs +320 -0
  65. package/lib/{chunk-APBWENF6.mjs → chunk-V3N3JEUF.mjs} +3 -3
  66. package/lib/chunk-XD6BJK6Q.mjs +351 -0
  67. package/lib/chunk-XVBFFVCJ.mjs +209 -0
  68. package/lib/chunk-YXSFGA2D.mjs +383 -0
  69. package/lib/clean-github-actions-caches.cjs +243 -148
  70. package/lib/clean-github-actions-caches.mjs +3 -2
  71. package/lib/del-gradle.cjs +2 -2
  72. package/lib/del-gradle.js +1 -1
  73. package/lib/del-gradle.mjs +2 -2
  74. package/lib/del-node-modules.cjs +2 -2
  75. package/lib/del-node-modules.js +1 -1
  76. package/lib/del-node-modules.mjs +2 -2
  77. package/lib/del-ps.cjs +29 -8
  78. package/lib/del-ps.js +2 -2
  79. package/lib/del-ps.mjs +7 -5
  80. package/lib/del-yarn-caches.cjs +26 -5
  81. package/lib/del-yarn-caches.js +38 -3
  82. package/lib/del-yarn-caches.mjs +6 -6
  83. package/lib/find-node-modules-cli.cjs +5 -4
  84. package/lib/find-node-modules-cli.js +1 -1
  85. package/lib/find-node-modules-cli.mjs +2 -2
  86. package/lib/find-node-modules.cjs +4 -3
  87. package/lib/{find-node-modules.d.ts → find-node-modules.d.cts} +1 -1
  88. package/lib/find-node-modules.mjs +2 -2
  89. package/lib/free-chatgpt.cjs +548 -0
  90. package/lib/free-chatgpt.js +51 -0
  91. package/lib/free-chatgpt.mjs +50 -0
  92. package/lib/git/gitattributes.cjs +1 -1
  93. package/lib/git/{gitattributes.d.mts → gitattributes.d.cts} +5 -7
  94. package/lib/git/gitattributes.mjs +2 -2
  95. package/lib/git/line-endings.cjs +297 -64
  96. package/lib/git/line-endings.mjs +4 -4
  97. package/lib/git/normalize.cjs +26 -36
  98. package/lib/git/normalize.mjs +2 -2
  99. package/lib/git/permissions.cjs +77 -11
  100. package/lib/git/permissions.mjs +3 -3
  101. package/lib/git/pull-strategy.cjs +76 -9
  102. package/lib/git/pull-strategy.mjs +3 -3
  103. package/lib/git/user-config.cjs +266 -83
  104. package/lib/git/user-config.mjs +4 -4
  105. package/lib/git/utils.cjs +40 -60
  106. package/lib/git/utils.mjs +2 -2
  107. package/lib/git-diff-cli.cjs +651 -0
  108. package/lib/git-diff-cli.d.ts +1 -0
  109. package/lib/git-diff-cli.js +15 -0
  110. package/lib/git-diff-cli.mjs +16 -0
  111. package/lib/git-diff.cjs +657 -58
  112. package/lib/git-diff.d.ts +38 -83
  113. package/lib/git-diff.js +152 -0
  114. package/lib/git-diff.mjs +23 -85
  115. package/lib/git-fix.cjs +685 -97
  116. package/lib/git-fix.mjs +14 -13
  117. package/lib/git-purge.cjs +3 -3
  118. package/lib/git-purge.d.cts +1 -0
  119. package/lib/git-purge.mjs +43 -37
  120. package/lib/index.cjs +7 -6
  121. package/lib/index.d.ts +1 -1
  122. package/lib/index.js +2 -5
  123. package/lib/index.mjs +4 -4
  124. package/lib/npm-run-series.cjs +3 -3
  125. package/lib/npm-run-series.mjs +42 -36
  126. package/lib/package-resolutions-updater.cjs +5 -5
  127. package/lib/package-resolutions-updater.mjs +266 -309
  128. package/lib/print-directory-tree.cjs +275 -210
  129. package/lib/print-directory-tree.mjs +2 -2
  130. package/lib/ps/connected-domain.cjs +25 -2
  131. package/lib/ps/connected-domain.d.ts +10 -2
  132. package/lib/ps/connected-domain.js +5 -2
  133. package/lib/ps/connected-domain.mjs +8 -4
  134. package/lib/ps/index.cjs +345 -322
  135. package/lib/ps/index.d.mjs +1 -1
  136. package/lib/ps/index.js +1 -1
  137. package/lib/ps/index.mjs +179 -182
  138. package/lib/ps/isWin.cjs +24 -1
  139. package/lib/ps/isWin.d.ts +1 -1
  140. package/lib/ps/isWin.js +3 -1
  141. package/lib/ps/isWin.mjs +8 -4
  142. package/lib/ps/table-parser.cjs +167 -159
  143. package/lib/ps/table-parser.d.ts +5 -0
  144. package/lib/ps/table-parser.js +10 -4
  145. package/lib/ps/table-parser.mjs +9 -5
  146. package/lib/remove-module.cjs +262 -0
  147. package/lib/remove-module.d.mts +1 -0
  148. package/lib/remove-module.mjs +111 -0
  149. package/lib/rmpath.cjs +274 -0
  150. package/lib/rmpath.d.mts +3 -0
  151. package/lib/rmpath.mjs +108 -0
  152. package/lib/submodule-install.cjs +264 -86
  153. package/lib/submodule-install.mjs +51 -3
  154. package/lib/submodule-remove-cli.cjs +103 -0
  155. package/lib/submodule-remove-cli.d.ts +1 -0
  156. package/lib/submodule-remove-cli.js +31 -0
  157. package/lib/submodule-remove-cli.mjs +28 -0
  158. package/lib/submodule-remove.cjs +43 -0
  159. package/lib/submodule-remove.d.cts +2 -0
  160. package/lib/submodule-remove.mjs +6 -0
  161. package/lib/utils/chatgpt.cjs +383 -0
  162. package/lib/utils/chatgpt.d.ts +31 -0
  163. package/lib/utils/chatgpt.js +541 -0
  164. package/lib/utils/chatgpt.mjs +8 -0
  165. package/lib/{utils.cjs → utils/index.cjs} +1 -1
  166. package/lib/{utils.mjs → utils/index.mjs} +2 -2
  167. package/lib/yarn-reinstall.cjs +172 -38
  168. package/lib/yarn-reinstall.mjs +2 -2
  169. package/package.json +91 -71
  170. package/readme.md +43 -69
  171. package/releases/readme.md +36 -0
  172. package/test/README.md +101 -0
  173. package/test/package.json +2 -1
  174. package/test-project/readme.md +26 -0
  175. package/tmp/test-repo/README.md +35 -0
  176. package/tmp/test-repo/package.json +1 -1
  177. package/tmp/typedoc/readme.md +320 -0
  178. package/bin/bash-dummy +0 -56
  179. package/bin/bash-dummy.cmd +0 -25
  180. package/bin/dir-tree.cmd +0 -7
  181. package/bin/git-diff +0 -4
  182. package/bin/git-diff.cmd +0 -7
  183. package/bin/git-fix +0 -36
  184. package/bin/git-fix.cmd +0 -7
  185. package/bin/rmpath +0 -70
  186. package/bin/submodule-install.txt +0 -118
  187. package/bin/submodule-remove +0 -46
  188. package/bin/submodule.txt +0 -172
  189. package/lib/binary-collections-config.d.mts +0 -18
  190. package/lib/binary-collections-config.js +0 -39
  191. package/lib/binary-collections.d.mts +0 -137
  192. package/lib/binary-collections.d.ts +0 -137
  193. package/lib/changelog.d.mts +0 -2
  194. package/lib/changelog.js +0 -226
  195. package/lib/chunk-DPKAJKFO.mjs +0 -171
  196. package/lib/chunk-G3THLIDT.mjs +0 -200
  197. package/lib/chunk-W3ENOM53.mjs +0 -18
  198. package/lib/clean-github-actions-caches.d.mts +0 -169
  199. package/lib/clean-github-actions-caches.d.ts +0 -169
  200. package/lib/del-gradle.d.mts +0 -2
  201. package/lib/del-node-modules.d.mts +0 -2
  202. package/lib/del-ps.d.mts +0 -2
  203. package/lib/del-yarn-caches.d.mts +0 -2
  204. package/lib/find-node-modules-cli.d.mts +0 -1
  205. package/lib/find-node-modules.d.mts +0 -13
  206. package/lib/find-node-modules.js +0 -53
  207. package/lib/git/line-endings.d.mts +0 -83
  208. package/lib/git/line-endings.d.ts +0 -83
  209. package/lib/git/normalize.d.mts +0 -43
  210. package/lib/git/normalize.d.ts +0 -43
  211. package/lib/git/permissions.d.mts +0 -17
  212. package/lib/git/permissions.d.ts +0 -17
  213. package/lib/git/pull-strategy.d.mts +0 -15
  214. package/lib/git/pull-strategy.d.ts +0 -15
  215. package/lib/git/user-config.d.mts +0 -105
  216. package/lib/git/user-config.d.ts +0 -105
  217. package/lib/git/utils.d.mts +0 -69
  218. package/lib/git/utils.d.ts +0 -69
  219. package/lib/git-diff.d.mts +0 -84
  220. package/lib/git-fix.d.mts +0 -141
  221. package/lib/git-fix.d.ts +0 -141
  222. package/lib/git-purge.d.mts +0 -2
  223. package/lib/git-purge.js +0 -59
  224. package/lib/index.d.mts +0 -1
  225. package/lib/npm-run-series.d.mts +0 -1
  226. package/lib/npm-run-series.d.ts +0 -2
  227. package/lib/npm-run-series.js +0 -86
  228. package/lib/package-resolutions-updater.d.ts +0 -352
  229. package/lib/print-directory-tree.d.mts +0 -234
  230. package/lib/print-directory-tree.d.ts +0 -234
  231. package/lib/ps/connected-domain.d.mts +0 -3
  232. package/lib/ps/index.d.d.mts +0 -26
  233. package/lib/ps/index.d.d.ts +0 -26
  234. package/lib/ps/index.d.mts +0 -26
  235. package/lib/ps/isWin.d.mts +0 -3
  236. package/lib/ps/table-parser.d.mts +0 -3
  237. package/lib/submodule-install.d.mts +0 -121
  238. package/lib/submodule-install.d.ts +0 -121
  239. package/lib/utils.d.mts +0 -40
  240. package/lib/utils.js +0 -181
  241. package/lib/yarn-reinstall.d.mts +0 -49
  242. package/lib/yarn-reinstall.d.ts +0 -49
  243. package/src/package-resolutions-updater.mjs +0 -350
  244. package/src/print-directory-tree.cjs +0 -234
  245. package/src/ps/index.js +0 -286
  246. package/src/yarn-reinstall.cjs +0 -49
  247. /package/{bin → binaries}/nodekill +0 -0
  248. /package/{bin → binaries}/nodekill.cmd +0 -0
  249. /package/lib/{binary-collections-config.d.ts → binary-collections-config.d.cts} +0 -0
  250. /package/lib/{changelog.d.ts → changelog.d.cts} +0 -0
  251. /package/lib/{git-purge.d.ts → free-chatgpt.d.ts} +0 -0
  252. /package/lib/{git-diff.d.cts → npm-run-series.d.cts} +0 -0
  253. /package/lib/{utils.d.ts → utils/index.d.cts} +0 -0
@@ -0,0 +1,548 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // node_modules/tsup/assets/cjs_shims.js
31
+ var init_cjs_shims = __esm({
32
+ "node_modules/tsup/assets/cjs_shims.js"() {
33
+ }
34
+ });
35
+
36
+ // src/utils/index.cjs
37
+ var require_utils = __commonJS({
38
+ "src/utils/index.cjs"(exports2, module2) {
39
+ init_cjs_shims();
40
+ var fs2 = require("fs");
41
+ var path2 = require("upath");
42
+ var argv2 = require("minimist")(process.argv.slice(2));
43
+ var { exec } = require("child_process");
44
+ var { URL: URL2 } = require("url");
45
+ var { promisify } = require("util");
46
+ var execAsync = promisify(exec);
47
+ async function parseGitRemotes() {
48
+ try {
49
+ const { stdout } = await execAsync("git remote -v");
50
+ const lines = stdout.split("\n");
51
+ const remotes = {};
52
+ lines.forEach((line) => {
53
+ const [name, url] = line.split(" ");
54
+ if (name && url) {
55
+ const [repoUrl] = url.split(" ");
56
+ try {
57
+ const parsedUrl = new URL2(repoUrl);
58
+ const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
59
+ if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
60
+ let repoPath = pathParts.join("/");
61
+ if (repoPath.endsWith(".git")) {
62
+ repoPath = repoPath.slice(0, -4);
63
+ }
64
+ remotes[name] = repoPath;
65
+ }
66
+ } catch (e) {
67
+ console.error("URL Parsing Error:", e.message);
68
+ }
69
+ }
70
+ });
71
+ return remotes;
72
+ } catch (error) {
73
+ console.error("Error:", error.message);
74
+ return {};
75
+ }
76
+ }
77
+ module2.exports.parseGitRemotes = parseGitRemotes;
78
+ function joinPathPreserveDriveLetter(...segments) {
79
+ let fullPath = require("path").join(...segments);
80
+ if (/^[a-z]:\\/.test(fullPath)) {
81
+ fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
82
+ }
83
+ return fullPath;
84
+ }
85
+ module2.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
86
+ function getArgs2() {
87
+ return argv2;
88
+ }
89
+ module2.exports.getArgs = getArgs2;
90
+ function del(fullPath) {
91
+ if (fs2.statSync(fullPath).isDirectory()) {
92
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
93
+ for (let i = 0; i < subdir.length; i++) {
94
+ del(subdir[i]);
95
+ }
96
+ } else {
97
+ try {
98
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
99
+ console.log("deleted", fullPath);
100
+ } catch (_) {
101
+ console.log("failed delete", fullPath);
102
+ }
103
+ }
104
+ }
105
+ module2.exports.del = del;
106
+ function delStream(globStream) {
107
+ globStream.stream().on("data", (result) => {
108
+ const fullPath = path2.resolve(process.cwd(), result);
109
+ if (fs2.statSync(fullPath).isDirectory()) {
110
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
111
+ for (let i = 0; i < subdir.length; i++) {
112
+ del(subdir[i]);
113
+ }
114
+ }
115
+ del(fullPath);
116
+ });
117
+ }
118
+ module2.exports.delStream = delStream;
119
+ function getFileTreeString(hashArray) {
120
+ const tree = {};
121
+ const hashMap = {};
122
+ for (const entry of hashArray) {
123
+ const [filePath, hash] = entry.split(" ");
124
+ hashMap[filePath] = hash;
125
+ const parts = filePath.split("/");
126
+ let current = tree;
127
+ for (let i = 0; i < parts.length; i++) {
128
+ const part = parts[i];
129
+ if (i === parts.length - 1) {
130
+ current[part] = null;
131
+ } else {
132
+ current[part] = current[part] || {};
133
+ current = current[part];
134
+ }
135
+ }
136
+ }
137
+ function printNode(node, prefix = "", parentPath = "") {
138
+ const keys = Object.keys(node).sort();
139
+ let lines = [];
140
+ keys.forEach((key, idx) => {
141
+ const isLast = idx === keys.length - 1;
142
+ const branch = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
143
+ const currentPath = parentPath ? parentPath + "/" + key : key;
144
+ if (node[key] === null) {
145
+ lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
146
+ } else {
147
+ lines.push(prefix + branch + key + "/");
148
+ lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "\u2502 "), currentPath));
149
+ }
150
+ });
151
+ return lines;
152
+ }
153
+ return printNode(tree, "", "").join("\n");
154
+ }
155
+ module2.exports.getFileTreeString = getFileTreeString;
156
+ var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
157
+ module2.exports.delay = delay;
158
+ }
159
+ });
160
+
161
+ // src/free-chatgpt.js
162
+ init_cjs_shims();
163
+
164
+ // src/utils/chatgpt.js
165
+ init_cjs_shims();
166
+ var import_fs_extra = __toESM(require("fs-extra"), 1);
167
+ var import_puppeteer_extra = __toESM(require("puppeteer-extra"), 1);
168
+ var import_puppeteer_extra_plugin_stealth = __toESM(require("puppeteer-extra-plugin-stealth"), 1);
169
+ var import_upath = __toESM(require("upath"), 1);
170
+ var COOKIE_DIR = import_upath.default.join(process.cwd(), "tmp", "cookies");
171
+ var DEFAULT_COOKIE_PATH = import_upath.default.join(COOKIE_DIR, "cookies.json");
172
+ import_fs_extra.default.ensureDirSync(COOKIE_DIR);
173
+ async function saveCookies(page, path2 = DEFAULT_COOKIE_PATH) {
174
+ const cookies = await page.cookies();
175
+ import_fs_extra.default.writeFileSync(path2, JSON.stringify(cookies, null, 2));
176
+ }
177
+ function getCookiePathForUrl(url) {
178
+ try {
179
+ const { hostname } = new URL(url);
180
+ return import_upath.default.join(COOKIE_DIR, `cookies_${hostname}.json`);
181
+ } catch {
182
+ return DEFAULT_COOKIE_PATH;
183
+ }
184
+ }
185
+ async function navigatePage(page, url) {
186
+ const cookiePath = getCookiePathForUrl(url);
187
+ const cookies = loadCookies(cookiePath);
188
+ if (cookies) {
189
+ await page.setCookie(...cookies);
190
+ }
191
+ await page.goto(url, { waitUntil: "networkidle0" });
192
+ await page.evaluate(() => {
193
+ window.__domStillUpdating = true;
194
+ if (window.__domObserver) {
195
+ window.__domObserver.disconnect();
196
+ }
197
+ window.__domObserver = new MutationObserver(() => {
198
+ window.__lastDomMutation = Date.now();
199
+ });
200
+ window.__lastDomMutation = Date.now();
201
+ window.__domObserver.observe(document.body, {
202
+ childList: true,
203
+ subtree: true,
204
+ attributes: true,
205
+ characterData: true
206
+ });
207
+ setTimeout(() => {
208
+ window.__domStillUpdating = false;
209
+ window.__domObserver.disconnect();
210
+ }, 3e4);
211
+ });
212
+ const waitForDomIdle = async (idleMs = 1e3, timeout = 1e4) => {
213
+ const start = Date.now();
214
+ while (Date.now() - start < timeout) {
215
+ const lastMutation = await page.evaluate(() => window.__lastDomMutation);
216
+ const idle = Date.now() - lastMutation;
217
+ if (idle >= idleMs) {
218
+ return true;
219
+ }
220
+ await new Promise((r) => setTimeout(r, 200));
221
+ }
222
+ throw new Error("DOM did not stabilize within timeout");
223
+ };
224
+ return { waitForDomIdle };
225
+ }
226
+ function loadCookies(cookieFilePath = DEFAULT_COOKIE_PATH) {
227
+ if (!import_fs_extra.default.existsSync(cookieFilePath)) return null;
228
+ return JSON.parse(import_fs_extra.default.readFileSync(cookieFilePath));
229
+ }
230
+ async function writeQuestion(page, question2) {
231
+ const questions = question2.split("\n");
232
+ const promptTextarea = await page.waitForSelector("#prompt-textarea", { timeout: 3e4 });
233
+ if (!promptTextarea) {
234
+ console.log(
235
+ "Cannot find the prompt input on the webpage. Please check whether you have access to chat.openai.com without logging in via your browser."
236
+ );
237
+ }
238
+ await page.evaluate(() => {
239
+ document.querySelector("#prompt-textarea").innerHTML = `<p></p>`;
240
+ });
241
+ if (questions.length === 1) {
242
+ await page.type("#prompt-textarea", questions[0], { delay: 100 });
243
+ return;
244
+ }
245
+ for (const q of questions) {
246
+ await page.type("#prompt-textarea", q, { delay: 100 });
247
+ if (q !== questions[questions.length - 1]) {
248
+ await page.keyboard.down("Shift");
249
+ await page.keyboard.press("Enter");
250
+ await page.keyboard.up("Shift");
251
+ }
252
+ }
253
+ }
254
+ async function clickSubmitButton(page) {
255
+ try {
256
+ const fruitjuiceSendButton = await page.evaluate(() => {
257
+ return document.querySelector('[data-testid="fruitjuice-send-button"]') !== null;
258
+ });
259
+ const sendButton = await page.evaluate(() => {
260
+ return document.querySelector('[data-testid="send-button"]') !== null;
261
+ });
262
+ if (fruitjuiceSendButton) {
263
+ await page.click('[data-testid="fruitjuice-send-button"]');
264
+ } else if (sendButton) {
265
+ await page.click('[data-testid="send-button"]');
266
+ } else {
267
+ console.log("Neither send button is present");
268
+ }
269
+ } catch (e) {
270
+ console.log(`Failed to click the send button: ${e}`);
271
+ }
272
+ }
273
+ var lastMessageId = null;
274
+ var messageCount = 0;
275
+ var is_streaming = false;
276
+ function sleep(ms) {
277
+ return new Promise((resolve) => setTimeout(resolve, ms));
278
+ }
279
+ async function waitForInitialResponse(page, timeout = 3e4) {
280
+ const startTime = Date.now();
281
+ while (Date.now() - startTime < timeout) {
282
+ const assistantMessages = await page.$$('[data-message-author-role="assistant"]');
283
+ const currentMessageCount = assistantMessages.length;
284
+ if (currentMessageCount > messageCount) {
285
+ const lastMessage = assistantMessages[assistantMessages.length - 1];
286
+ const isThinking = await lastMessage.$(".result-thinking");
287
+ if (!isThinking) {
288
+ lastMessageId = await page.evaluate((element) => element.getAttribute("data-message-id"), lastMessage);
289
+ messageCount = currentMessageCount;
290
+ return;
291
+ }
292
+ }
293
+ await sleep(100);
294
+ }
295
+ console.log("Timed out waiting for the initial response.");
296
+ }
297
+ async function handleStreamingResponse(page, outputFile = import_upath.default.join(process.cwd(), "tmp/response.txt")) {
298
+ let previousText = "";
299
+ let completeResponse = "";
300
+ let newContentDetected = false;
301
+ while (!newContentDetected) {
302
+ const assistantMessages = await page.$$('[data-message-author-role="assistant"]');
303
+ if (assistantMessages.length > 0) {
304
+ const lastMessage = assistantMessages[assistantMessages.length - 1];
305
+ const currentMessageId = await page.evaluate((element) => element.getAttribute("data-message-id"), lastMessage);
306
+ if (currentMessageId === lastMessageId) {
307
+ const currentText = await page.evaluate((element) => element.textContent, lastMessage);
308
+ console.log(`Current text: ${currentText}`);
309
+ if (currentText !== previousText) {
310
+ if (is_streaming) {
311
+ process.stdout.write(currentText.slice(previousText.length));
312
+ } else {
313
+ completeResponse += currentText.slice(previousText.length);
314
+ }
315
+ }
316
+ previousText = currentText;
317
+ const isStreaming = await lastMessage.$(".result-streaming");
318
+ if (!isStreaming) {
319
+ newContentDetected = true;
320
+ }
321
+ } else {
322
+ lastMessageId = currentMessageId;
323
+ }
324
+ }
325
+ await sleep(100);
326
+ }
327
+ if (!is_streaming) {
328
+ console.log(completeResponse.trim());
329
+ console.log("\n\n");
330
+ import_fs_extra.default.ensureDirSync(import_upath.default.dirname(outputFile));
331
+ import_fs_extra.default.writeFileSync(outputFile, completeResponse.trim());
332
+ console.log(`Response saved to ${outputFile}`);
333
+ }
334
+ }
335
+ async function isLoggedIn(page) {
336
+ const result = await page.evaluate(() => {
337
+ const loginButton = document.querySelector('[data-testid="login-button"]');
338
+ return !(loginButton && loginButton.offsetParent !== null);
339
+ });
340
+ return result === true;
341
+ }
342
+ async function createBrowser(browserOptions = {}) {
343
+ const defaultOptions = {
344
+ headless: false,
345
+ userDataDir: import_upath.default.join(process.cwd(), "tmp/puppeteer-profile"),
346
+ // Windows-specific options to handle browser launch issues
347
+ args: [
348
+ "--no-sandbox",
349
+ "--disable-setuid-sandbox",
350
+ "--disable-dev-shm-usage",
351
+ "--disable-accelerated-2d-canvas",
352
+ "--no-first-run",
353
+ "--no-zygote",
354
+ "--disable-gpu",
355
+ "--disable-background-timer-throttling",
356
+ "--disable-backgrounding-occluded-windows",
357
+ "--disable-renderer-backgrounding"
358
+ ],
359
+ ignoreDefaultArgs: ["--disable-extensions"],
360
+ ...process.platform === "win32" && {
361
+ // Additional Windows-specific options
362
+ executablePath: void 0
363
+ // Let Puppeteer find Chrome automatically
364
+ }
365
+ };
366
+ try {
367
+ return await import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)()).launch({ ...defaultOptions, ...browserOptions });
368
+ } catch (_error) {
369
+ console.error("Failed to launch browser with default options. Trying fallback options...");
370
+ try {
371
+ return await import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)()).launch({
372
+ headless: browserOptions.headless || false,
373
+ args: ["--no-sandbox", "--disable-setuid-sandbox"],
374
+ ignoreDefaultArgs: false,
375
+ ...browserOptions
376
+ });
377
+ } catch (fallbackError) {
378
+ console.error("Browser launch failed completely. Common solutions:");
379
+ console.error("1. Install Google Chrome if not installed");
380
+ console.error("2. Update Node.js to the latest version");
381
+ console.error("3. Try running: npm install puppeteer --force");
382
+ console.error("4. Check if antivirus is blocking browser launch");
383
+ throw new Error(`Browser launch failed: ${fallbackError.message}`);
384
+ }
385
+ }
386
+ }
387
+ async function loginToChatGpt() {
388
+ const browser = await createBrowser({ headless: false });
389
+ const page = (await browser.pages()).length > 0 ? (await browser.pages())[0] : await browser.newPage();
390
+ const url = "https://chat.openai.com";
391
+ const navigate = await navigatePage(page, url);
392
+ await navigate.waitForDomIdle(2e3, 1e4);
393
+ const loginButtonExists = await page.evaluate(() => {
394
+ return document.querySelector('[data-testid="login-button"]') !== null;
395
+ });
396
+ if (loginButtonExists) {
397
+ console.log("Login button found, clicking to log in...");
398
+ await page.click('[data-testid="login-button"]');
399
+ await page.waitForNavigation({ waitUntil: "networkidle0" });
400
+ console.log("Login process completed.");
401
+ } else {
402
+ console.log("No login required - user appears to be already logged in.");
403
+ }
404
+ }
405
+ async function runChatGpt(chatgptOptions = {}) {
406
+ const headless = chatgptOptions.headless !== void 0 ? chatgptOptions.headless : true;
407
+ const questionFile2 = chatgptOptions.questionFile;
408
+ let question2 = chatgptOptions.question;
409
+ const responseFile = chatgptOptions.responseFile || import_upath.default.join(process.cwd(), "tmp", "response.txt");
410
+ const noInputProvided = !question2 && !questionFile2;
411
+ const questionIsEmpty = question2 && question2.trim().length === 0;
412
+ const questionFileIsEmpty = questionFile2 && questionFile2.trim().length === 0;
413
+ if (noInputProvided || questionIsEmpty || questionFileIsEmpty) {
414
+ throw new Error("You must provide a question or a question file.");
415
+ }
416
+ let browser;
417
+ try {
418
+ browser = await createBrowser({ headless });
419
+ } catch (error) {
420
+ console.error("Error running ChatGPT:", error);
421
+ console.error("\nTroubleshooting steps:");
422
+ console.error("1. Make sure Google Chrome is installed");
423
+ console.error("2. Try running: yarn add puppeteer --force");
424
+ console.error("3. Check if your antivirus is blocking the browser");
425
+ console.error("4. Close any running Chrome instances and try again");
426
+ throw error;
427
+ }
428
+ const page = (await browser.pages()).length > 0 ? (await browser.pages())[0] : await browser.newPage();
429
+ try {
430
+ const url = "https://chat.openai.com";
431
+ const navigate = await navigatePage(page, url);
432
+ await navigate.waitForDomIdle(2e3, 15e3);
433
+ try {
434
+ const tempChatButton = await page.$('button[aria-label="Turn on temporary chat"]');
435
+ if (tempChatButton) {
436
+ await page.evaluate((el) => el.click(), tempChatButton);
437
+ console.log("Successfully clicked temporary chat button");
438
+ await navigate.waitForDomIdle(1e3, 1e4);
439
+ } else {
440
+ console.log("Temporary chat button not found, proceeding without it.");
441
+ }
442
+ } catch (error) {
443
+ console.log(`Failed to click temporary chat button: ${error.message}`);
444
+ }
445
+ if (question2) {
446
+ await writeQuestion(page, question2);
447
+ await clickSubmitButton(page);
448
+ await navigate.waitForDomIdle(1e3, 3e4);
449
+ await waitForInitialResponse(page);
450
+ await handleStreamingResponse(page, responseFile);
451
+ await saveCookies(page, getCookiePathForUrl(url));
452
+ } else if (questionFile2) {
453
+ await navigate.waitForDomIdle(2e3, 1e4);
454
+ const isUserLoggedIn = await isLoggedIn(page);
455
+ console.log(`Login status: ${isUserLoggedIn ? "Logged in" : "Not logged in"}`);
456
+ if (!isUserLoggedIn) {
457
+ console.log(
458
+ "Not logged in. Please log in to ChatGPT in the browser window, then close it and run the command again."
459
+ );
460
+ return loginToChatGpt();
461
+ }
462
+ const plusButtonExists = await page.evaluate(() => {
463
+ const button = document.querySelector('[data-testid="composer-plus-btn"]');
464
+ return button !== null;
465
+ });
466
+ if (plusButtonExists) {
467
+ await page.click('[data-testid="composer-plus-btn"]');
468
+ await sleep(500);
469
+ const menuItems = await page.$$('[role="menuitem"]');
470
+ let clicked = false;
471
+ for (const item of menuItems) {
472
+ const text = await page.evaluate((el) => el.innerText, item);
473
+ if (text && text.includes("Add photos") && text.includes("files")) {
474
+ await item.hover();
475
+ clicked = true;
476
+ break;
477
+ }
478
+ }
479
+ if (!clicked) {
480
+ console.log('Could not find the "Add photos & files" menu item.');
481
+ return;
482
+ }
483
+ try {
484
+ await sleep(1e3);
485
+ const fileInput = await page.waitForSelector('input[type="file"]', { timeout: 1e4 });
486
+ if (fileInput) {
487
+ console.log(`Uploading file: ${questionFile2}`);
488
+ await fileInput.uploadFile(questionFile2);
489
+ await navigate.waitForDomIdle(2e3, 15e3);
490
+ console.log("File uploaded successfully");
491
+ await clickSubmitButton(page);
492
+ await navigate.waitForDomIdle(1e3, 3e4);
493
+ await waitForInitialResponse(page);
494
+ await handleStreamingResponse(page, responseFile);
495
+ } else {
496
+ console.log("Could not find file input element");
497
+ }
498
+ } catch (error) {
499
+ console.log(`Error uploading file: ${error.message}`);
500
+ }
501
+ } else {
502
+ console.log('Could not find the [data-testid="composer-plus-btn"] button.');
503
+ }
504
+ }
505
+ } finally {
506
+ if (browser) {
507
+ await browser.close();
508
+ }
509
+ }
510
+ }
511
+
512
+ // src/free-chatgpt.js
513
+ var import_utils = __toESM(require_utils(), 1);
514
+ var argv = (0, import_utils.getArgs)();
515
+ if (argv.help || argv.h) {
516
+ console.log();
517
+ console.log("Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]");
518
+ console.log();
519
+ console.log("Options:");
520
+ console.log(' --question, -q The question to ask ChatGPT (default: "Hello, ChatGPT!")');
521
+ console.log(" --qfile, -qf Path to a file containing the question text");
522
+ console.log(" --help, -h Show this help message");
523
+ console.log();
524
+ console.log("Description:");
525
+ console.log(
526
+ " Automates browser interaction with ChatGPT, including login, question submission, and response retrieval."
527
+ );
528
+ console.log(" - Questions can be provided directly or loaded from a file.");
529
+ console.log(" - Cookies are saved to ./tmp/cookies for session persistence.");
530
+ console.log(" - Requires browser access to chat.openai.com and chatgpt.com (firewall must allow connection).");
531
+ console.log();
532
+ process.exit(0);
533
+ }
534
+ var question = argv.question || argv.q;
535
+ var questionFile = argv.qfile || argv.qf;
536
+ async function main() {
537
+ try {
538
+ await runChatGpt({
539
+ headless: false,
540
+ question,
541
+ questionFile
542
+ });
543
+ } catch (error) {
544
+ console.error("Error running ChatGPT:", error);
545
+ process.exit(1);
546
+ }
547
+ }
548
+ main();
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const chatgpt_js_1 = require("./utils/chatgpt.js");
13
+ const index_cjs_1 = require("./utils/index.cjs");
14
+ const argv = (0, index_cjs_1.getArgs)();
15
+ if (argv.help || argv.h) {
16
+ console.log();
17
+ console.log("Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]");
18
+ console.log();
19
+ console.log("Options:");
20
+ console.log(' --question, -q The question to ask ChatGPT (default: "Hello, ChatGPT!")');
21
+ console.log(" --qfile, -qf Path to a file containing the question text");
22
+ console.log(" --help, -h Show this help message");
23
+ console.log();
24
+ console.log("Description:");
25
+ console.log(" Automates browser interaction with ChatGPT, including login, question submission, and response retrieval.");
26
+ console.log(" - Questions can be provided directly or loaded from a file.");
27
+ console.log(" - Cookies are saved to ./tmp/cookies for session persistence.");
28
+ console.log(" - Requires browser access to chat.openai.com and chatgpt.com (firewall must allow connection).");
29
+ console.log();
30
+ process.exit(0);
31
+ }
32
+ /** @type {string|undefined} */
33
+ let question = argv.question || argv.q;
34
+ /** @type {string|undefined} */
35
+ const questionFile = argv.qfile || argv.qf;
36
+ function main() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ yield (0, chatgpt_js_1.runChatGpt)({
40
+ headless: false,
41
+ question,
42
+ questionFile
43
+ });
44
+ }
45
+ catch (error) {
46
+ console.error("Error running ChatGPT:", error);
47
+ process.exit(1);
48
+ }
49
+ });
50
+ }
51
+ main();
@@ -0,0 +1,50 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ runChatGpt
4
+ } from "./chunk-GJTGHXRA.mjs";
5
+ import {
6
+ require_utils
7
+ } from "./chunk-V3N3JEUF.mjs";
8
+ import {
9
+ __toESM,
10
+ init_esm_shims
11
+ } from "./chunk-QQ4A6DLD.mjs";
12
+
13
+ // src/free-chatgpt.js
14
+ init_esm_shims();
15
+ var import_utils = __toESM(require_utils(), 1);
16
+ var argv = (0, import_utils.getArgs)();
17
+ if (argv.help || argv.h) {
18
+ console.log();
19
+ console.log("Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]");
20
+ console.log();
21
+ console.log("Options:");
22
+ console.log(' --question, -q The question to ask ChatGPT (default: "Hello, ChatGPT!")');
23
+ console.log(" --qfile, -qf Path to a file containing the question text");
24
+ console.log(" --help, -h Show this help message");
25
+ console.log();
26
+ console.log("Description:");
27
+ console.log(
28
+ " Automates browser interaction with ChatGPT, including login, question submission, and response retrieval."
29
+ );
30
+ console.log(" - Questions can be provided directly or loaded from a file.");
31
+ console.log(" - Cookies are saved to ./tmp/cookies for session persistence.");
32
+ console.log(" - Requires browser access to chat.openai.com and chatgpt.com (firewall must allow connection).");
33
+ console.log();
34
+ process.exit(0);
35
+ }
36
+ var question = argv.question || argv.q;
37
+ var questionFile = argv.qfile || argv.qf;
38
+ async function main() {
39
+ try {
40
+ await runChatGpt({
41
+ headless: false,
42
+ question,
43
+ questionFile
44
+ });
45
+ } catch (error) {
46
+ console.error("Error running ChatGPT:", error);
47
+ process.exit(1);
48
+ }
49
+ }
50
+ main();
@@ -1,4 +1,4 @@
1
- // src/git/gitattributes.js
1
+ // src/git/gitattributes.cjs
2
2
  var fs = require("fs");
3
3
  function parseGitAttributes(gitattributesPath) {
4
4
  const rules = [];