binary-collections 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.puppeterrc.cjs +25 -0
- package/binaries/binary-executor.cjs +138 -3
- package/binaries/clean-nodemodule.cjs +138 -3
- package/binaries/clean-nodemodules.cjs +138 -3
- package/binaries/dev.cjs +138 -3
- package/binaries/empty.cjs +138 -3
- package/binaries/git-reduce-size.cjs +138 -3
- package/binaries/javakill.cjs +138 -3
- package/binaries/kill-night-crows.bat +7 -0
- package/binaries/kill-night-crows.ps1 +172 -0
- package/binaries/kill-process.cjs +138 -3
- package/binaries/nodekill.cjs +138 -3
- package/binaries/prod.cjs +138 -3
- package/binaries/py +111 -0
- package/binaries/py.cjs +178 -0
- package/binaries/py.cmd +49 -0
- package/binaries/rmfind.cjs +138 -3
- package/binaries/rmx.cjs +138 -3
- package/binaries/submodule-token.cjs +138 -3
- package/binaries/test-cjs +10 -0
- package/binaries/test-cjs.cjs +178 -0
- package/binaries/test-cjs.cmd +11 -0
- package/binaries/yarn-clean +32 -0
- package/binaries/yarn-clean.cjs +178 -0
- package/binaries/yarn-clean.cmd +30 -0
- package/binaries/yarn-clean.py +148 -0
- package/lib/binary-collections-config.cjs +1 -1
- package/lib/binary-collections-config.mjs +1 -1
- package/lib/binary-collections.cjs +167 -106
- package/lib/binary-collections.mjs +108 -94
- package/lib/changelog.cjs +61 -13
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
- package/lib/chunk-34IQDTLZ.mjs +27 -0
- package/lib/chunk-3HFFECCI.mjs +27 -0
- package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
- package/lib/chunk-7XTEJHOE.mjs +193 -0
- package/lib/chunk-AJDD5DZM.mjs +109 -0
- package/lib/chunk-BZWVHODJ.mjs +62 -0
- package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
- package/lib/chunk-GEYA2USY.mjs +207 -0
- package/lib/chunk-ID2WBTE2.mjs +80 -0
- package/lib/chunk-JXFOHKDM.mjs +239 -0
- package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
- package/lib/chunk-NCXAP7AA.mjs +31 -0
- package/lib/chunk-PDN26I7O.mjs +188 -0
- package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
- package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
- package/lib/chunk-V5SKYJUB.mjs +136 -0
- package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
- package/lib/chunk-XA3SNBPA.mjs +184 -0
- package/lib/chunk-YYLIQQKF.mjs +31 -0
- package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
- package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
- package/lib/clean-github-actions-caches.cjs +63 -15
- package/lib/clean-github-actions-caches.mjs +3 -3
- package/lib/del-gradle.cjs +61 -13
- package/lib/del-gradle.js +1 -0
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.cjs +143 -148
- package/lib/del-node-modules.js +210 -14
- package/lib/del-node-modules.mjs +148 -17
- package/lib/del-ps.cjs +61 -13
- package/lib/del-ps.js +1 -0
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +61 -13
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/find-node-modules-cli.js +1 -0
- package/lib/free-chatgpt.cjs +253 -47
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/gitattributes.cjs +1 -0
- package/lib/git/gitattributes.d.cts +7 -2
- package/lib/git/gitattributes.mjs +1 -1
- package/lib/git/line-endings.cjs +2 -1
- package/lib/git/line-endings.mjs +2 -2
- package/lib/git/undo-commit-cli.cjs +110 -0
- package/lib/git/undo-commit-cli.d.ts +1 -0
- package/lib/git/undo-commit-cli.js +4 -0
- package/lib/git/undo-commit-cli.mjs +14 -0
- package/lib/git/undo-commit.cjs +81 -0
- package/lib/git/undo-commit.d.cts +1 -0
- package/lib/git/undo-commit.mjs +7 -0
- package/lib/git/undo-staged-cli.cjs +110 -0
- package/lib/git/undo-staged-cli.d.ts +1 -0
- package/lib/git/undo-staged-cli.js +4 -0
- package/lib/git/undo-staged-cli.mjs +14 -0
- package/lib/git/undo-staged.cjs +81 -0
- package/lib/git/undo-staged.d.cts +1 -0
- package/lib/git/undo-staged.mjs +7 -0
- package/lib/git/user-config.cjs +61 -14
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +255 -49
- package/lib/git-diff-cli.d.ts +1 -0
- package/lib/git-diff-cli.js +1 -0
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +254 -49
- package/lib/git-diff.mjs +4 -4
- package/lib/git-fix.cjs +64 -16
- package/lib/git-fix.mjs +10 -10
- package/lib/git-purge.cjs +61 -13
- package/lib/git-purge.mjs +1 -1
- package/lib/kill-night-crows.cjs +87 -0
- package/lib/kill-night-crows.d.mts +1 -0
- package/lib/kill-night-crows.mjs +65 -0
- package/lib/npm-run-series.cjs +60 -13
- package/lib/npm-run-series.mjs +1 -1
- package/lib/package-resolutions-updater-cli.cjs +560 -0
- package/lib/package-resolutions-updater-cli.d.mts +1 -0
- package/lib/package-resolutions-updater-cli.mjs +124 -0
- package/lib/package-resolutions-updater.cjs +174 -154
- package/lib/package-resolutions-updater.d.mts +32 -1
- package/lib/package-resolutions-updater.mjs +16 -294
- package/lib/php-cs-fixer-staged.cjs +105 -0
- package/lib/php-cs-fixer-staged.d.cts +2 -0
- package/lib/php-cs-fixer-staged.mjs +117 -0
- package/lib/print-directory-tree.cjs +62 -14
- package/lib/print-directory-tree.mjs +2 -2
- package/lib/ps/connected-domain.d.ts +1 -1
- package/lib/ps/index.js +1 -0
- package/lib/remove-module.cjs +61 -13
- package/lib/remove-module.mjs +1 -1
- package/lib/rmpath.cjs +63 -15
- package/lib/rmpath.mjs +2 -2
- package/lib/submodule-install.cjs +62 -15
- package/lib/submodule-install.mjs +3 -3
- package/lib/submodule-remove-cli.cjs +5 -1
- package/lib/submodule-remove-cli.mjs +1 -1
- package/lib/submodule-remove.cjs +4 -1
- package/lib/submodule-remove.mjs +1 -1
- package/lib/utils/chatgpt.cjs +192 -34
- package/lib/utils/chatgpt.js +210 -43
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +107 -0
- package/lib/utils/findEnvFiles.d.ts +8 -0
- package/lib/utils/findEnvFiles.js +121 -0
- package/lib/utils/findEnvFiles.mjs +8 -0
- package/lib/utils/findWorkspaceRoot.cjs +70 -0
- package/lib/utils/findWorkspaceRoot.d.ts +9 -0
- package/lib/utils/findWorkspaceRoot.js +57 -0
- package/lib/utils/findWorkspaceRoot.mjs +40 -0
- package/lib/utils/index.cjs +60 -13
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.cjs +64 -0
- package/lib/utils/isGithubTokenValid.d.ts +7 -0
- package/lib/utils/isGithubTokenValid.js +48 -0
- package/lib/utils/isGithubTokenValid.mjs +36 -0
- package/lib/yarn-reinstall.cjs +61 -13
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +107 -93
- package/readme.md +33 -34
- package/releases/readme.md +1 -1
- package/requirements.txt +1 -0
- package/lib/chunk-4EWQC6GZ.mjs +0 -382
- package/lib/chunk-4ZI7BQKQ.mjs +0 -381
- package/lib/chunk-5J2BEPY5.mjs +0 -83
- package/lib/chunk-AGZYRDC2.mjs +0 -323
- package/lib/chunk-HN52G2YL.mjs +0 -305
- package/lib/chunk-HO6GHCOB.mjs +0 -385
- package/lib/chunk-LEM5OMRP.mjs +0 -384
- package/lib/chunk-RCP7DHVY.mjs +0 -190
- package/lib/chunk-U6SO4QEV.mjs +0 -320
- package/lib/chunk-XD6BJK6Q.mjs +0 -351
- package/lib/chunk-YXSFGA2D.mjs +0 -383
- package/lib/git/gitattributes.d.ts +0 -33
- package/lib/git/gitattributes.js +0 -223
package/lib/git-diff-cli.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,7 +32,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
32
|
var getImportMetaUrl, importMetaUrl;
|
|
32
33
|
var init_cjs_shims = __esm({
|
|
33
34
|
"node_modules/tsup/assets/cjs_shims.js"() {
|
|
34
|
-
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src
|
|
35
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
35
36
|
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
36
37
|
}
|
|
37
38
|
});
|
|
@@ -41,7 +42,7 @@ var require_binary_collections_config = __commonJS({
|
|
|
41
42
|
"src/binary-collections-config.cjs"(exports2, module2) {
|
|
42
43
|
init_cjs_shims();
|
|
43
44
|
var path3 = require("path");
|
|
44
|
-
require("dotenv").config({ path: path3.join(process.cwd(), ".env") });
|
|
45
|
+
require("dotenv").config({ path: path3.join(process.cwd(), ".env"), quiet: true, override: true });
|
|
45
46
|
function getTempDir() {
|
|
46
47
|
return process.env.TEMP_DIR || path3.join(process.cwd(), "tmp");
|
|
47
48
|
}
|
|
@@ -112,31 +113,78 @@ var require_utils = __commonJS({
|
|
|
112
113
|
}
|
|
113
114
|
module2.exports.getArgs = getArgs2;
|
|
114
115
|
function del(fullPath) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
try {
|
|
117
|
+
if (!fs3.existsSync(fullPath)) return;
|
|
118
|
+
const stat = fs3.lstatSync(fullPath);
|
|
119
|
+
if (stat.isSymbolicLink()) {
|
|
120
|
+
try {
|
|
121
|
+
fs3.unlinkSync(fullPath);
|
|
122
|
+
console.log("deleted symlink", fullPath);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
125
|
+
}
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (stat.isDirectory()) {
|
|
129
|
+
const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
|
|
130
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
131
|
+
del(subdir[i]);
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
fs3.rmdirSync(fullPath);
|
|
135
|
+
console.log("deleted", fullPath);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
try {
|
|
138
|
+
fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
139
|
+
console.log("deleted", fullPath);
|
|
140
|
+
} catch (ee) {
|
|
141
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
119
145
|
}
|
|
120
|
-
} else {
|
|
121
146
|
try {
|
|
122
|
-
fs3.
|
|
147
|
+
fs3.unlinkSync(fullPath);
|
|
123
148
|
console.log("deleted", fullPath);
|
|
124
|
-
} catch (
|
|
125
|
-
|
|
149
|
+
} catch (e) {
|
|
150
|
+
try {
|
|
151
|
+
fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
152
|
+
console.log("deleted", fullPath);
|
|
153
|
+
} catch (ee) {
|
|
154
|
+
console.log("failed delete", fullPath, ee && ee.message);
|
|
155
|
+
}
|
|
126
156
|
}
|
|
157
|
+
} catch (err) {
|
|
158
|
+
console.log("failed delete", fullPath, err && err.message);
|
|
127
159
|
}
|
|
128
160
|
}
|
|
129
161
|
module2.exports.del = del;
|
|
130
162
|
function delStream(globStream) {
|
|
131
163
|
globStream.stream().on("data", (result) => {
|
|
132
164
|
const fullPath = path3.resolve(process.cwd(), result);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
165
|
+
try {
|
|
166
|
+
if (fs3.existsSync(fullPath)) {
|
|
167
|
+
const stat = fs3.lstatSync(fullPath);
|
|
168
|
+
if (stat.isSymbolicLink()) {
|
|
169
|
+
try {
|
|
170
|
+
fs3.unlinkSync(fullPath);
|
|
171
|
+
console.log("deleted symlink", fullPath);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
console.log("failed delete symlink", fullPath, e && e.message);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (stat.isDirectory()) {
|
|
178
|
+
const subdir = fs3.readdirSync(fullPath).map((dirPath) => path3.resolve(fullPath, dirPath));
|
|
179
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
180
|
+
del(subdir[i]);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
137
183
|
}
|
|
184
|
+
del(fullPath);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
console.log("failed processing", fullPath, err && err.message);
|
|
138
187
|
}
|
|
139
|
-
del(fullPath);
|
|
140
188
|
});
|
|
141
189
|
}
|
|
142
190
|
module2.exports.delStream = delStream;
|
|
@@ -201,7 +249,17 @@ var import_puppeteer_extra_plugin_stealth = __toESM(require("puppeteer-extra-plu
|
|
|
201
249
|
var import_upath = __toESM(require("upath"), 1);
|
|
202
250
|
var COOKIE_DIR = import_upath.default.join(process.cwd(), "tmp", "cookies");
|
|
203
251
|
var DEFAULT_COOKIE_PATH = import_upath.default.join(COOKIE_DIR, "cookies.json");
|
|
252
|
+
var NAVIGATION_TIMEOUT_MS = 9e4;
|
|
253
|
+
var NETWORK_IDLE_TIMEOUT_MS = 15e3;
|
|
254
|
+
var MAX_INLINE_QUESTION_FILE_BYTES = 2 * 1024;
|
|
204
255
|
import_fs_extra.default.ensureDirSync(COOKIE_DIR);
|
|
256
|
+
async function gotoWithFallback(page, url) {
|
|
257
|
+
await page.goto(url, { waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
|
|
258
|
+
try {
|
|
259
|
+
await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
205
263
|
async function saveCookies(page, path3 = DEFAULT_COOKIE_PATH) {
|
|
206
264
|
const cookies = await page.cookies();
|
|
207
265
|
import_fs_extra.default.writeFileSync(path3, JSON.stringify(cookies, null, 2));
|
|
@@ -220,7 +278,7 @@ async function navigatePage(page, url) {
|
|
|
220
278
|
if (cookies) {
|
|
221
279
|
await page.setCookie(...cookies);
|
|
222
280
|
}
|
|
223
|
-
await page
|
|
281
|
+
await gotoWithFallback(page, url);
|
|
224
282
|
await page.evaluate(() => {
|
|
225
283
|
window.__domStillUpdating = true;
|
|
226
284
|
if (window.__domObserver) {
|
|
@@ -260,46 +318,151 @@ function loadCookies(cookieFilePath = DEFAULT_COOKIE_PATH) {
|
|
|
260
318
|
return JSON.parse(import_fs_extra.default.readFileSync(cookieFilePath));
|
|
261
319
|
}
|
|
262
320
|
async function writeQuestion(page, question) {
|
|
263
|
-
const questions = question.split("\n");
|
|
264
321
|
const promptTextarea = await page.waitForSelector("#prompt-textarea", { timeout: 3e4 });
|
|
265
322
|
if (!promptTextarea) {
|
|
266
323
|
console.log(
|
|
267
324
|
"Cannot find the prompt input on the webpage. Please check whether you have access to chat.openai.com without logging in via your browser."
|
|
268
325
|
);
|
|
269
|
-
}
|
|
270
|
-
await page.evaluate(() => {
|
|
271
|
-
document.querySelector("#prompt-textarea").innerHTML = `<p></p>`;
|
|
272
|
-
});
|
|
273
|
-
if (questions.length === 1) {
|
|
274
|
-
await page.type("#prompt-textarea", questions[0], { delay: 100 });
|
|
275
326
|
return;
|
|
276
327
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
await page.keyboard.press("Enter");
|
|
282
|
-
await page.keyboard.up("Shift");
|
|
328
|
+
await page.evaluate((text) => {
|
|
329
|
+
const promptEl = document.querySelector("#prompt-textarea");
|
|
330
|
+
if (!promptEl) {
|
|
331
|
+
return;
|
|
283
332
|
}
|
|
333
|
+
promptEl.focus();
|
|
334
|
+
promptEl.innerHTML = "";
|
|
335
|
+
const lines = String(text).split("\n");
|
|
336
|
+
for (const line of lines) {
|
|
337
|
+
const p = document.createElement("p");
|
|
338
|
+
p.textContent = line;
|
|
339
|
+
promptEl.appendChild(p);
|
|
340
|
+
}
|
|
341
|
+
promptEl.dispatchEvent(new InputEvent("beforeinput", { bubbles: true, inputType: "insertFromPaste", data: text }));
|
|
342
|
+
promptEl.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertFromPaste", data: text }));
|
|
343
|
+
promptEl.dispatchEvent(new Event("change", { bubbles: true }));
|
|
344
|
+
}, question);
|
|
345
|
+
const hasPromptText = await page.evaluate(() => {
|
|
346
|
+
const promptEl = document.querySelector("#prompt-textarea");
|
|
347
|
+
return Boolean(promptEl && promptEl.textContent && promptEl.textContent.trim().length > 0);
|
|
348
|
+
});
|
|
349
|
+
if (!hasPromptText) {
|
|
350
|
+
console.log("Prompt state not updated by DOM injection. Falling back to keyboard insertText.");
|
|
351
|
+
await promptTextarea.click({ clickCount: 1 });
|
|
352
|
+
await page.keyboard.down("Control");
|
|
353
|
+
await page.keyboard.press("KeyA");
|
|
354
|
+
await page.keyboard.up("Control");
|
|
355
|
+
await page.keyboard.insertText(question);
|
|
284
356
|
}
|
|
285
357
|
}
|
|
286
358
|
async function clickSubmitButton(page) {
|
|
359
|
+
console.log("Attempting to click the submit button...");
|
|
287
360
|
try {
|
|
288
|
-
const
|
|
289
|
-
|
|
361
|
+
const userMessageCountBefore = await page.$$eval('[data-message-author-role="user"]', (elements) => elements.length);
|
|
362
|
+
const waitForSubmit = async (timeout = 5e3) => {
|
|
363
|
+
try {
|
|
364
|
+
await page.waitForFunction(
|
|
365
|
+
(previousCount) => {
|
|
366
|
+
const currentCount = document.querySelectorAll('[data-message-author-role="user"]').length;
|
|
367
|
+
return currentCount > previousCount;
|
|
368
|
+
},
|
|
369
|
+
{ timeout },
|
|
370
|
+
userMessageCountBefore
|
|
371
|
+
);
|
|
372
|
+
return true;
|
|
373
|
+
} catch {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
await page.waitForFunction(() => {
|
|
378
|
+
const candidates = [
|
|
379
|
+
document.querySelector('[data-testid="fruitjuice-send-button"]'),
|
|
380
|
+
document.querySelector("#composer-submit-button"),
|
|
381
|
+
document.querySelector('[data-testid="send-button"]')
|
|
382
|
+
].filter(Boolean);
|
|
383
|
+
return candidates.some((button) => {
|
|
384
|
+
const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
385
|
+
const isVisible = button.offsetParent !== null;
|
|
386
|
+
return !isDisabled && isVisible;
|
|
387
|
+
});
|
|
388
|
+
}, { timeout: 5e3 }).catch(() => {
|
|
290
389
|
});
|
|
291
|
-
const
|
|
292
|
-
|
|
390
|
+
const buttonDetails = await page.evaluate(() => {
|
|
391
|
+
const selectors = [
|
|
392
|
+
'[data-testid="fruitjuice-send-button"]',
|
|
393
|
+
"#composer-submit-button",
|
|
394
|
+
'[data-testid="send-button"]'
|
|
395
|
+
];
|
|
396
|
+
const details = selectors.map((selector) => {
|
|
397
|
+
const el = document.querySelector(selector);
|
|
398
|
+
const exists = Boolean(el);
|
|
399
|
+
const disabled = exists ? Boolean(el.disabled || el.getAttribute("aria-disabled") === "true") : null;
|
|
400
|
+
const visible = exists ? el.offsetParent !== null : null;
|
|
401
|
+
return { selector, exists, disabled, visible };
|
|
402
|
+
});
|
|
403
|
+
return details;
|
|
293
404
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
console.log(
|
|
405
|
+
console.log(`Submit button details: ${JSON.stringify(buttonDetails)}`);
|
|
406
|
+
const clickable = buttonDetails.find((item) => item.exists && item.visible && item.disabled === false);
|
|
407
|
+
const selectedSelector = clickable ? clickable.selector : null;
|
|
408
|
+
if (selectedSelector) {
|
|
409
|
+
await page.click(selectedSelector);
|
|
410
|
+
console.log(`Clicked submit button selector: ${selectedSelector}`);
|
|
411
|
+
if (await waitForSubmit(5e3)) {
|
|
412
|
+
console.log("Submission detected after selector click.");
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
const forcedClickWorked = await page.evaluate((selector) => {
|
|
416
|
+
const el = document.querySelector(selector);
|
|
417
|
+
if (!el) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
el.click();
|
|
421
|
+
return true;
|
|
422
|
+
}, selectedSelector);
|
|
423
|
+
if (forcedClickWorked) {
|
|
424
|
+
console.log(`Forced DOM click on selector: ${selectedSelector}`);
|
|
425
|
+
if (await waitForSubmit(5e3)) {
|
|
426
|
+
console.log("Submission detected after forced DOM click.");
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
console.log("Submit button path did not submit. Trying Enter key fallback on prompt.");
|
|
432
|
+
await page.focus("#prompt-textarea");
|
|
433
|
+
await page.keyboard.press("Enter");
|
|
434
|
+
if (await waitForSubmit(5e3)) {
|
|
435
|
+
console.log("Submission detected after Enter key fallback.");
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
const didRequestSubmit = await page.evaluate(() => {
|
|
439
|
+
const prompt = document.querySelector("#prompt-textarea");
|
|
440
|
+
if (!prompt) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
const form = prompt.closest("form");
|
|
444
|
+
if (!form) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
if (typeof form.requestSubmit === "function") {
|
|
448
|
+
form.requestSubmit();
|
|
449
|
+
} else {
|
|
450
|
+
form.submit();
|
|
451
|
+
}
|
|
452
|
+
return true;
|
|
453
|
+
});
|
|
454
|
+
if (didRequestSubmit) {
|
|
455
|
+
console.log("Triggered form submit fallback.");
|
|
456
|
+
if (await waitForSubmit(5e3)) {
|
|
457
|
+
console.log("Submission detected after form submit fallback.");
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
300
460
|
}
|
|
461
|
+
console.log("Failed to submit prompt after all strategies.");
|
|
462
|
+
return false;
|
|
301
463
|
} catch (e) {
|
|
302
464
|
console.log(`Failed to click the send button: ${e}`);
|
|
465
|
+
return false;
|
|
303
466
|
}
|
|
304
467
|
}
|
|
305
468
|
var lastMessageId = null;
|
|
@@ -372,11 +535,15 @@ async function isLoggedIn(page) {
|
|
|
372
535
|
return result === true;
|
|
373
536
|
}
|
|
374
537
|
async function createBrowser(browserOptions = {}) {
|
|
538
|
+
const windowsChromeExecutable = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
|
|
539
|
+
const hasWindowsChrome = process.platform === "win32" && import_fs_extra.default.existsSync(windowsChromeExecutable);
|
|
375
540
|
const defaultOptions = {
|
|
376
541
|
headless: false,
|
|
542
|
+
defaultViewport: null,
|
|
377
543
|
userDataDir: import_upath.default.join(process.cwd(), "tmp/puppeteer-profile"),
|
|
378
544
|
// Windows-specific options to handle browser launch issues
|
|
379
545
|
args: [
|
|
546
|
+
"--start-maximized",
|
|
380
547
|
"--no-sandbox",
|
|
381
548
|
"--disable-setuid-sandbox",
|
|
382
549
|
"--disable-dev-shm-usage",
|
|
@@ -389,10 +556,9 @@ async function createBrowser(browserOptions = {}) {
|
|
|
389
556
|
"--disable-renderer-backgrounding"
|
|
390
557
|
],
|
|
391
558
|
ignoreDefaultArgs: ["--disable-extensions"],
|
|
392
|
-
...
|
|
393
|
-
//
|
|
394
|
-
executablePath:
|
|
395
|
-
// Let Puppeteer find Chrome automatically
|
|
559
|
+
...hasWindowsChrome && {
|
|
560
|
+
// Prefer local Chrome installation when present on Windows.
|
|
561
|
+
executablePath: windowsChromeExecutable
|
|
396
562
|
}
|
|
397
563
|
};
|
|
398
564
|
try {
|
|
@@ -402,8 +568,12 @@ async function createBrowser(browserOptions = {}) {
|
|
|
402
568
|
try {
|
|
403
569
|
return await import_puppeteer_extra.default.use((0, import_puppeteer_extra_plugin_stealth.default)()).launch({
|
|
404
570
|
headless: browserOptions.headless || false,
|
|
405
|
-
|
|
571
|
+
defaultViewport: null,
|
|
572
|
+
args: ["--start-maximized", "--no-sandbox", "--disable-setuid-sandbox"],
|
|
406
573
|
ignoreDefaultArgs: false,
|
|
574
|
+
...hasWindowsChrome && {
|
|
575
|
+
executablePath: windowsChromeExecutable
|
|
576
|
+
},
|
|
407
577
|
...browserOptions
|
|
408
578
|
});
|
|
409
579
|
} catch (fallbackError) {
|
|
@@ -428,7 +598,11 @@ async function loginToChatGpt() {
|
|
|
428
598
|
if (loginButtonExists) {
|
|
429
599
|
console.log("Login button found, clicking to log in...");
|
|
430
600
|
await page.click('[data-testid="login-button"]');
|
|
431
|
-
await page.waitForNavigation({ waitUntil: "
|
|
601
|
+
await page.waitForNavigation({ waitUntil: "domcontentloaded", timeout: NAVIGATION_TIMEOUT_MS });
|
|
602
|
+
try {
|
|
603
|
+
await page.waitForNetworkIdle({ idleTime: 1e3, timeout: NETWORK_IDLE_TIMEOUT_MS });
|
|
604
|
+
} catch {
|
|
605
|
+
}
|
|
432
606
|
console.log("Login process completed.");
|
|
433
607
|
} else {
|
|
434
608
|
console.log("No login required - user appears to be already logged in.");
|
|
@@ -438,6 +612,7 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
438
612
|
const headless = chatgptOptions.headless !== void 0 ? chatgptOptions.headless : true;
|
|
439
613
|
const questionFile = chatgptOptions.questionFile;
|
|
440
614
|
let question = chatgptOptions.question;
|
|
615
|
+
let shouldUploadQuestionFile = Boolean(questionFile);
|
|
441
616
|
const responseFile = chatgptOptions.responseFile || import_upath.default.join(process.cwd(), "tmp", "response.txt");
|
|
442
617
|
const noInputProvided = !question && !questionFile;
|
|
443
618
|
const questionIsEmpty = question && question.trim().length === 0;
|
|
@@ -445,6 +620,22 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
445
620
|
if (noInputProvided || questionIsEmpty || questionFileIsEmpty) {
|
|
446
621
|
throw new Error("You must provide a question or a question file.");
|
|
447
622
|
}
|
|
623
|
+
if (!question && questionFile) {
|
|
624
|
+
if (!import_fs_extra.default.existsSync(questionFile)) {
|
|
625
|
+
throw new Error(`Question file does not exist: ${questionFile}`);
|
|
626
|
+
}
|
|
627
|
+
const questionFileStats = import_fs_extra.default.statSync(questionFile);
|
|
628
|
+
if (questionFileStats.size <= MAX_INLINE_QUESTION_FILE_BYTES) {
|
|
629
|
+
question = import_fs_extra.default.readFileSync(questionFile, "utf8").trim();
|
|
630
|
+
if (!question) {
|
|
631
|
+
throw new Error("Question file is empty.");
|
|
632
|
+
}
|
|
633
|
+
shouldUploadQuestionFile = false;
|
|
634
|
+
console.log(
|
|
635
|
+
`Question file is ${questionFileStats.size} bytes (<= ${MAX_INLINE_QUESTION_FILE_BYTES}). Sending as text prompt.`
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
448
639
|
let browser;
|
|
449
640
|
try {
|
|
450
641
|
browser = await createBrowser({ headless });
|
|
@@ -457,7 +648,16 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
457
648
|
console.error("4. Close any running Chrome instances and try again");
|
|
458
649
|
throw error;
|
|
459
650
|
}
|
|
460
|
-
const
|
|
651
|
+
const allPages = await browser.pages();
|
|
652
|
+
const page = allPages.length > 0 ? allPages[0] : await browser.newPage();
|
|
653
|
+
await page.bringToFront();
|
|
654
|
+
if (allPages.length > 1) {
|
|
655
|
+
for (const p of allPages) {
|
|
656
|
+
if (p !== page) {
|
|
657
|
+
await p.close();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
461
661
|
try {
|
|
462
662
|
const url = "https://chat.openai.com";
|
|
463
663
|
const navigate = await navigatePage(page, url);
|
|
@@ -476,12 +676,15 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
476
676
|
}
|
|
477
677
|
if (question) {
|
|
478
678
|
await writeQuestion(page, question);
|
|
479
|
-
await clickSubmitButton(page);
|
|
679
|
+
const didSubmit = await clickSubmitButton(page);
|
|
680
|
+
if (!didSubmit) {
|
|
681
|
+
throw new Error("Prompt was not submitted. The composer button may be disabled or blocked.");
|
|
682
|
+
}
|
|
480
683
|
await navigate.waitForDomIdle(1e3, 3e4);
|
|
481
684
|
await waitForInitialResponse(page);
|
|
482
685
|
await handleStreamingResponse(page, responseFile);
|
|
483
686
|
await saveCookies(page, getCookiePathForUrl(url));
|
|
484
|
-
} else if (questionFile) {
|
|
687
|
+
} else if (shouldUploadQuestionFile && questionFile) {
|
|
485
688
|
await navigate.waitForDomIdle(2e3, 1e4);
|
|
486
689
|
const isUserLoggedIn = await isLoggedIn(page);
|
|
487
690
|
console.log(`Login status: ${isUserLoggedIn ? "Logged in" : "Not logged in"}`);
|
|
@@ -520,7 +723,10 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
520
723
|
await fileInput.uploadFile(questionFile);
|
|
521
724
|
await navigate.waitForDomIdle(2e3, 15e3);
|
|
522
725
|
console.log("File uploaded successfully");
|
|
523
|
-
await clickSubmitButton(page);
|
|
726
|
+
const didSubmit = await clickSubmitButton(page);
|
|
727
|
+
if (!didSubmit) {
|
|
728
|
+
throw new Error("Prompt was not submitted after file upload.");
|
|
729
|
+
}
|
|
524
730
|
await navigate.waitForDomIdle(1e3, 3e4);
|
|
525
731
|
await waitForInitialResponse(page);
|
|
526
732
|
await handleStreamingResponse(page, responseFile);
|
package/lib/git-diff-cli.d.ts
CHANGED
package/lib/git-diff-cli.js
CHANGED
package/lib/git-diff-cli.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
3
|
import {
|
|
3
4
|
mainGitDiff
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-FCDQGYBF.mjs";
|
|
6
|
+
import "./chunk-N436BNBK.mjs";
|
|
7
|
+
import "./chunk-YYLIQQKF.mjs";
|
|
8
|
+
import "./chunk-Z6JLYU2J.mjs";
|
|
8
9
|
import {
|
|
9
10
|
init_esm_shims
|
|
10
11
|
} from "./chunk-QQ4A6DLD.mjs";
|