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.
- package/.opencode/package.json +5 -0
- package/binaries/rmx +15 -1
- package/binaries/rmx.cmd +12 -0
- package/binaries/test-cjs +9 -1
- package/binaries/test-cjs.cmd +16 -1
- package/binaries/test-esm +16 -0
- package/binaries/test-esm.cjs +178 -0
- package/binaries/test-esm.cmd +23 -0
- package/binaries/yarn-clean +1 -1
- package/binaries/yarn-clean.cmd +1 -1
- package/binaries/yarn-clean.py +33 -15
- package/binaries/yc +110 -0
- package/binaries/yc.cjs +178 -0
- package/lib/binary-collections/config.cjs +126 -0
- package/lib/binary-collections/config.mjs +7 -0
- package/lib/binary-collections/executeScript.cjs +19 -0
- package/lib/binary-collections/executeScript.d.cts +12 -0
- package/lib/binary-collections/executeScript.mjs +6 -0
- package/lib/binary-collections/findScript.cjs +284 -0
- package/lib/binary-collections/findScript.d.cts +12 -0
- package/lib/binary-collections/findScript.mjs +7 -0
- package/lib/binary-collections/listScript.cjs +266 -0
- package/lib/binary-collections/listScript.d.cts +19 -0
- package/lib/binary-collections/listScript.mjs +7 -0
- package/lib/binary-collections.cjs +224 -137
- package/lib/binary-collections.mjs +22 -282
- package/lib/changelog.cjs +2 -2
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
- package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
- package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
- package/lib/chunk-6PU7BAHB.mjs +61 -0
- package/lib/chunk-C6D2TTYU.mjs +32 -0
- package/lib/chunk-FB2WKVJD.mjs +158 -0
- package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
- package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
- package/lib/chunk-H44UWUFY.mjs +105 -0
- package/lib/chunk-NCZPTKDV.mjs +79 -0
- package/lib/chunk-NGFK3EYW.mjs +28 -0
- package/lib/chunk-NVEG3LEZ.mjs +143 -0
- package/lib/chunk-OGXVGBRI.mjs +29 -0
- package/lib/chunk-OXV52GD5.mjs +62 -0
- package/lib/chunk-PXBMHE7O.mjs +35 -0
- package/lib/chunk-R5FJOR63.mjs +47 -0
- package/lib/chunk-SPTECFE5.mjs +180 -0
- package/lib/chunk-UXCFNAR6.mjs +55 -0
- package/lib/chunk-V2IBPCEV.mjs +39 -0
- package/lib/chunk-XPJGCDOD.mjs +14 -0
- package/lib/chunk-ZOWVMII3.mjs +228 -0
- package/lib/clean-github-actions-caches-cli.cjs +465 -0
- package/lib/clean-github-actions-caches-cli.d.cts +1 -0
- package/lib/clean-github-actions-caches-cli.mjs +56 -0
- package/lib/clean-github-actions-caches.cjs +149 -205
- package/lib/clean-github-actions-caches.d.cts +15 -1
- package/lib/clean-github-actions-caches.mjs +4 -130
- package/lib/cross-env/command.cjs +63 -0
- package/lib/cross-env/command.d.ts +8 -0
- package/lib/cross-env/command.js +45 -0
- package/lib/cross-env/command.mjs +9 -0
- package/lib/cross-env/index.cjs +178 -0
- package/lib/cross-env/index.d.ts +8 -0
- package/lib/cross-env/index.js +102 -0
- package/lib/cross-env/index.mjs +101 -0
- package/lib/cross-env/variable.cjs +60 -0
- package/lib/cross-env/variable.d.ts +7 -0
- package/lib/cross-env/variable.js +59 -0
- package/lib/cross-env/variable.mjs +9 -0
- package/lib/del-gradle.cjs +2 -2
- package/lib/del-gradle.js +8 -8
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.js +24 -24
- package/lib/del-ps.cjs +2 -2
- package/lib/del-ps.js +8 -8
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +2 -2
- package/lib/del-yarn-caches.js +2 -2
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/file/copy-cli.cjs +92 -0
- package/lib/file/copy-cli.d.mts +1 -0
- package/lib/file/copy-cli.mjs +55 -0
- package/lib/file/copy.cjs +56 -0
- package/lib/file/copy.d.mts +1 -0
- package/lib/file/copy.mjs +8 -0
- package/lib/file/move-cli.cjs +91 -0
- package/lib/file/move-cli.d.mts +1 -0
- package/lib/file/move-cli.mjs +55 -0
- package/lib/file/move.cjs +55 -0
- package/lib/file/move.d.mts +1 -0
- package/lib/file/move.mjs +8 -0
- package/lib/find-node-modules-cli.js +1 -1
- package/lib/free-chatgpt.cjs +21 -15
- package/lib/free-chatgpt.js +10 -10
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/user-config.cjs +2 -2
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +188 -42
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +188 -42
- package/lib/git-diff.d.ts +2 -1
- package/lib/git-diff.js +91 -34
- package/lib/git-diff.mjs +5 -4
- package/lib/git-fix.cjs +2 -2
- package/lib/git-fix.mjs +2 -2
- package/lib/git-purge.cjs +2 -2
- package/lib/git-purge.mjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/kill-night-crows.cjs +7 -7
- package/lib/kill-night-crows.mjs +7 -7
- package/lib/node-cache-cleaner/npm.cjs +65 -0
- package/lib/node-cache-cleaner/npm.d.ts +2 -0
- package/lib/node-cache-cleaner/npm.js +41 -0
- package/lib/node-cache-cleaner/npm.mjs +10 -0
- package/lib/node-cache-cleaner/npx.cjs +89 -0
- package/lib/node-cache-cleaner/npx.d.ts +4 -0
- package/lib/node-cache-cleaner/npx.js +82 -0
- package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
- package/lib/node-cache-cleaner/yarn.cjs +73 -0
- package/lib/node-cache-cleaner/yarn.d.ts +2 -0
- package/lib/node-cache-cleaner/yarn.js +62 -0
- package/lib/node-cache-cleaner/yarn.mjs +10 -0
- package/lib/node-cache-cleaner-cli.cjs +182 -0
- package/lib/node-cache-cleaner-cli.d.ts +2 -0
- package/lib/node-cache-cleaner-cli.js +60 -0
- package/lib/node-cache-cleaner-cli.mjs +56 -0
- package/lib/node-executor.cjs +91 -0
- package/lib/node-executor.d.cts +2 -0
- package/lib/node-executor.mjs +103 -0
- package/lib/npm-run-series.cjs +21 -28
- package/lib/npm-run-series.mjs +20 -6
- package/lib/package-resolutions-updater-cli.cjs +213 -128
- package/lib/package-resolutions-updater-cli.mjs +17 -39
- package/lib/package-resolutions-updater.cjs +204 -98
- package/lib/package-resolutions-updater.d.mts +20 -1
- package/lib/package-resolutions-updater.mjs +7 -5
- package/lib/print-directory-tree.cjs +2 -2
- package/lib/print-directory-tree.mjs +1 -1
- package/lib/ps/connected-domain.js +10 -10
- package/lib/ps/index.cjs +1 -1
- package/lib/ps/index.mjs +177 -171
- package/lib/ps/isWin.js +1 -1
- package/lib/ps/table-parser.js +6 -6
- package/lib/remove-module.cjs +2 -2
- package/lib/remove-module.mjs +1 -1
- package/lib/rm-node-module-cli.cjs +222 -0
- package/lib/rm-node-module-cli.d.cts +1 -0
- package/lib/rm-node-module-cli.mjs +89 -0
- package/lib/rm-node-modules.cjs +127 -0
- package/lib/rm-node-modules.d.cts +35 -0
- package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
- package/lib/rmpath.cjs +2 -2
- package/lib/rmpath.mjs +1 -1
- package/lib/submodule-install.cjs +47 -34
- package/lib/submodule-install.mjs +46 -33
- package/lib/submodule-remove-cli.cjs +1 -2
- package/lib/submodule-remove-cli.js +3 -3
- package/lib/submodule-remove-cli.mjs +1 -2
- package/lib/utils/chatgpt.cjs +19 -13
- package/lib/utils/chatgpt.js +94 -94
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +28 -46
- package/lib/utils/findEnvFiles.d.cts +19 -0
- package/lib/utils/findEnvFiles.mjs +3 -5
- package/lib/utils/findWorkspaceRoot.js +4 -4
- package/lib/utils/index.cjs +2 -2
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.js +7 -7
- package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
- package/lib/utils/isWindows.d.ts +5 -0
- package/lib/utils/isWindows.js +10 -0
- package/lib/utils/isWindows.mjs +8 -0
- package/lib/utils/runBash.cjs +53 -0
- package/lib/utils/runBash.d.cts +12 -0
- package/lib/utils/runBash.mjs +66 -0
- package/lib/yarn-per-branch-lock-installer.cjs +97 -0
- package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
- package/lib/yarn-per-branch-lock-installer.mjs +109 -0
- package/lib/yarn-reinstall.cjs +2 -2
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +61 -52
- package/readme.html +784 -0
- package/readme.md +106 -218
- package/releases/readme.md +1 -1
- package/test/README.md +2 -2
- package/test-project/package.json +8 -2
- package/test-project/workspaces/workspace-a/package.json +135 -0
- package/test-project/workspaces/workspace-a/readme.md +20 -0
- package/test-project/workspaces/workspace-a/release/readme.md +42 -0
- package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
- package/test-project/workspaces/workspace-a/test/readme.md +12 -0
- package/test-project/workspaces/workspace-b/package.json +139 -0
- package/test-project/workspaces/workspace-b/readme.md +94 -0
- package/test-project/workspaces/workspace-b/requirements.txt +1 -0
- package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
- package/tmp/rm-node-modules-test-project/package.json +17 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
- package/tmp/test-repo/README.md +2 -35
- package/tmp/test-repo/package.json +13 -3
- package/docs-src/clean-github-actions-caches.md +0 -26
- package/docs-src/free-chatgpt.md +0 -26
- package/lib/binary-collections-config.cjs +0 -15
- package/lib/chunk-2CBJCW7E.mjs +0 -81
- package/lib/chunk-4UHL4WVN.mjs +0 -136
- package/lib/chunk-66PAU5PS.mjs +0 -31
- package/lib/chunk-6HHJRKFB.mjs +0 -59
- package/lib/chunk-7XTEJHOE.mjs +0 -193
- package/lib/chunk-FCDQGYBF.mjs +0 -136
- package/lib/chunk-GEYA2USY.mjs +0 -207
- package/lib/chunk-GJTGHXRA.mjs +0 -356
- package/lib/chunk-ID2WBTE2.mjs +0 -80
- package/lib/chunk-JXFOHKDM.mjs +0 -239
- package/lib/chunk-PDSXF5HY.mjs +0 -187
- package/lib/chunk-RWLXRTYP.mjs +0 -109
- package/lib/chunk-TOIVAQF7.mjs +0 -136
- package/lib/chunk-V5SKYJUB.mjs +0 -136
- package/lib/chunk-WSRETQCA.mjs +0 -59
- package/lib/chunk-YYLIQQKF.mjs +0 -31
- package/lib/ps/index.d.ts +0 -2
- package/lib/ps/index.js +0 -254
- package/lib/utils/findEnvFiles.d.ts +0 -8
- package/lib/utils/findEnvFiles.js +0 -121
- package/tmp/typedoc/readme.md +0 -320
- /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
package/lib/free-chatgpt.cjs
CHANGED
|
@@ -109,7 +109,7 @@ var require_utils = __commonJS({
|
|
|
109
109
|
try {
|
|
110
110
|
fs2.rmdirSync(fullPath);
|
|
111
111
|
console.log("deleted", fullPath);
|
|
112
|
-
} catch (
|
|
112
|
+
} catch (_e) {
|
|
113
113
|
try {
|
|
114
114
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
115
115
|
console.log("deleted", fullPath);
|
|
@@ -122,7 +122,7 @@ var require_utils = __commonJS({
|
|
|
122
122
|
try {
|
|
123
123
|
fs2.unlinkSync(fullPath);
|
|
124
124
|
console.log("deleted", fullPath);
|
|
125
|
-
} catch (
|
|
125
|
+
} catch (_e) {
|
|
126
126
|
try {
|
|
127
127
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
128
128
|
console.log("deleted", fullPath);
|
|
@@ -326,7 +326,10 @@ async function writeQuestion(page, question2) {
|
|
|
326
326
|
async function clickSubmitButton(page) {
|
|
327
327
|
console.log("Attempting to click the submit button...");
|
|
328
328
|
try {
|
|
329
|
-
const userMessageCountBefore = await page.$$eval(
|
|
329
|
+
const userMessageCountBefore = await page.$$eval(
|
|
330
|
+
'[data-message-author-role="user"]',
|
|
331
|
+
(elements) => elements.length
|
|
332
|
+
);
|
|
330
333
|
const waitForSubmit = async (timeout = 5e3) => {
|
|
331
334
|
try {
|
|
332
335
|
await page.waitForFunction(
|
|
@@ -342,18 +345,21 @@ async function clickSubmitButton(page) {
|
|
|
342
345
|
return false;
|
|
343
346
|
}
|
|
344
347
|
};
|
|
345
|
-
await page.waitForFunction(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
348
|
+
await page.waitForFunction(
|
|
349
|
+
() => {
|
|
350
|
+
const candidates = [
|
|
351
|
+
document.querySelector('[data-testid="fruitjuice-send-button"]'),
|
|
352
|
+
document.querySelector("#composer-submit-button"),
|
|
353
|
+
document.querySelector('[data-testid="send-button"]')
|
|
354
|
+
].filter(Boolean);
|
|
355
|
+
return candidates.some((button) => {
|
|
356
|
+
const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
357
|
+
const isVisible = button.offsetParent !== null;
|
|
358
|
+
return !isDisabled && isVisible;
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
{ timeout: 5e3 }
|
|
362
|
+
).catch(() => {
|
|
357
363
|
});
|
|
358
364
|
const buttonDetails = await page.evaluate(() => {
|
|
359
365
|
const selectors = [
|
package/lib/free-chatgpt.js
CHANGED
|
@@ -14,18 +14,18 @@ const index_cjs_1 = require("./utils/index.cjs");
|
|
|
14
14
|
const argv = (0, index_cjs_1.getArgs)();
|
|
15
15
|
if (argv.help || argv.h) {
|
|
16
16
|
console.log();
|
|
17
|
-
console.log(
|
|
17
|
+
console.log('Usage: free-chatgpt.js [--question <text> | -q <text>] [--qfile <file> | -qf <file>] [--help | -h]');
|
|
18
18
|
console.log();
|
|
19
|
-
console.log(
|
|
19
|
+
console.log('Options:');
|
|
20
20
|
console.log(' --question, -q The question to ask ChatGPT (default: "Hello, ChatGPT!")');
|
|
21
|
-
console.log(
|
|
22
|
-
console.log(
|
|
21
|
+
console.log(' --qfile, -qf Path to a file containing the question text');
|
|
22
|
+
console.log(' --help, -h Show this help message');
|
|
23
23
|
console.log();
|
|
24
|
-
console.log(
|
|
25
|
-
console.log(
|
|
26
|
-
console.log(
|
|
27
|
-
console.log(
|
|
28
|
-
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
29
|
console.log();
|
|
30
30
|
process.exit(0);
|
|
31
31
|
}
|
|
@@ -43,7 +43,7 @@ function main() {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
console.error(
|
|
46
|
+
console.error('Error running ChatGPT:', error);
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
49
|
});
|
package/lib/free-chatgpt.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
runChatGpt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GAGABICI.mjs";
|
|
5
5
|
import {
|
|
6
6
|
require_utils
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5RTXZVCW.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__toESM,
|
|
10
10
|
init_esm_shims
|
package/lib/git/user-config.cjs
CHANGED
|
@@ -143,7 +143,7 @@ var require_utils2 = __commonJS({
|
|
|
143
143
|
try {
|
|
144
144
|
fs.rmdirSync(fullPath);
|
|
145
145
|
console.log("deleted", fullPath);
|
|
146
|
-
} catch (
|
|
146
|
+
} catch (_e) {
|
|
147
147
|
try {
|
|
148
148
|
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
149
149
|
console.log("deleted", fullPath);
|
|
@@ -156,7 +156,7 @@ var require_utils2 = __commonJS({
|
|
|
156
156
|
try {
|
|
157
157
|
fs.unlinkSync(fullPath);
|
|
158
158
|
console.log("deleted", fullPath);
|
|
159
|
-
} catch (
|
|
159
|
+
} catch (_e) {
|
|
160
160
|
try {
|
|
161
161
|
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
162
162
|
console.log("deleted", fullPath);
|
package/lib/git/user-config.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_user_config
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-2LSRSEXF.mjs";
|
|
5
5
|
import "../chunk-A3VUZEJK.mjs";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-5RTXZVCW.mjs";
|
|
7
7
|
import "../chunk-QQ4A6DLD.mjs";
|
|
8
8
|
export default require_user_config();
|
package/lib/git-diff-cli.cjs
CHANGED
|
@@ -37,12 +37,108 @@ var init_cjs_shims = __esm({
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
// src/
|
|
41
|
-
var
|
|
42
|
-
"src/
|
|
40
|
+
// src/utils/findEnvFiles.cjs
|
|
41
|
+
var require_findEnvFiles = __commonJS({
|
|
42
|
+
"src/utils/findEnvFiles.cjs"(exports2, module2) {
|
|
43
43
|
init_cjs_shims();
|
|
44
|
+
var fs3 = require("fs");
|
|
44
45
|
var path3 = require("path");
|
|
45
|
-
|
|
46
|
+
var glob = require("glob");
|
|
47
|
+
var DEFAULT_IGNORES = [
|
|
48
|
+
"**/node_modules/**",
|
|
49
|
+
"**/.git/**",
|
|
50
|
+
"**/.yarn/**",
|
|
51
|
+
"**/.pnpm/**",
|
|
52
|
+
"**/dist/**",
|
|
53
|
+
"**/build/**",
|
|
54
|
+
"**/coverage/**",
|
|
55
|
+
"**/vendor/**",
|
|
56
|
+
"**/tmp/**",
|
|
57
|
+
"**/.cache/**",
|
|
58
|
+
"**/assets/**",
|
|
59
|
+
"**/logs/**",
|
|
60
|
+
"**/output/**",
|
|
61
|
+
"**/public/**",
|
|
62
|
+
"**/static/**",
|
|
63
|
+
"**/temp/**",
|
|
64
|
+
"**/backup/**",
|
|
65
|
+
"**/backups/**",
|
|
66
|
+
"**/examples/**",
|
|
67
|
+
"**/docs/**",
|
|
68
|
+
"**/tests/**",
|
|
69
|
+
"**/__tests__/**",
|
|
70
|
+
"**/spec/**",
|
|
71
|
+
"**/__specs__/**",
|
|
72
|
+
"**/scripts/**",
|
|
73
|
+
"**/bin/**",
|
|
74
|
+
"**/hooks/**",
|
|
75
|
+
"**/config/**",
|
|
76
|
+
"**/configs/**",
|
|
77
|
+
"**/settings/**",
|
|
78
|
+
"**/.vscode/**",
|
|
79
|
+
"**/.idea/**"
|
|
80
|
+
];
|
|
81
|
+
function findEnvFiles(startDir = process.cwd(), filter) {
|
|
82
|
+
const found = /* @__PURE__ */ new Set();
|
|
83
|
+
function addFile(file) {
|
|
84
|
+
const normalized = path3.normalize(file);
|
|
85
|
+
if (typeof filter === "function" && !filter(normalized)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
found.add(normalized);
|
|
89
|
+
}
|
|
90
|
+
let current = path3.resolve(startDir);
|
|
91
|
+
while (true) {
|
|
92
|
+
const envPath = path3.join(current, ".env");
|
|
93
|
+
if (fs3.existsSync(envPath)) {
|
|
94
|
+
addFile(envPath);
|
|
95
|
+
}
|
|
96
|
+
const parent = path3.dirname(current);
|
|
97
|
+
if (parent === current) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
current = parent;
|
|
101
|
+
}
|
|
102
|
+
const files = glob.globSync("**/.env*", {
|
|
103
|
+
cwd: startDir,
|
|
104
|
+
absolute: true,
|
|
105
|
+
nodir: true,
|
|
106
|
+
ignore: DEFAULT_IGNORES
|
|
107
|
+
});
|
|
108
|
+
for (const file of files) {
|
|
109
|
+
addFile(file);
|
|
110
|
+
}
|
|
111
|
+
return [...found];
|
|
112
|
+
}
|
|
113
|
+
function findEnvWithToken(startDir = process.cwd(), tokenName = "GITHUB_TOKEN") {
|
|
114
|
+
const envFiles = findEnvFiles(startDir);
|
|
115
|
+
return envFiles.find((file) => {
|
|
116
|
+
try {
|
|
117
|
+
const content = fs3.readFileSync(file, "utf-8");
|
|
118
|
+
const regex = new RegExp(`^\\s*${tokenName}\\s*=`, "m");
|
|
119
|
+
return regex.test(content);
|
|
120
|
+
} catch (err) {
|
|
121
|
+
console.warn(`Failed to read ${file}: ${err instanceof Error ? err.message : String(err)}`);
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
module2.exports = {
|
|
127
|
+
DEFAULT_IGNORES,
|
|
128
|
+
findEnvFiles,
|
|
129
|
+
findEnvWithToken,
|
|
130
|
+
default: findEnvFiles
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// src/binary-collections/config.cjs
|
|
136
|
+
var require_config = __commonJS({
|
|
137
|
+
"src/binary-collections/config.cjs"(exports2, module2) {
|
|
138
|
+
init_cjs_shims();
|
|
139
|
+
var path3 = require("path");
|
|
140
|
+
var { findEnvWithToken } = require_findEnvFiles();
|
|
141
|
+
require("dotenv").config({ path: findEnvWithToken(), quiet: true, overwrite: true });
|
|
46
142
|
function getTempDir() {
|
|
47
143
|
return process.env.TEMP_DIR || path3.join(process.cwd(), "tmp");
|
|
48
144
|
}
|
|
@@ -133,7 +229,7 @@ var require_utils = __commonJS({
|
|
|
133
229
|
try {
|
|
134
230
|
fs3.rmdirSync(fullPath);
|
|
135
231
|
console.log("deleted", fullPath);
|
|
136
|
-
} catch (
|
|
232
|
+
} catch (_e) {
|
|
137
233
|
try {
|
|
138
234
|
fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
139
235
|
console.log("deleted", fullPath);
|
|
@@ -146,7 +242,7 @@ var require_utils = __commonJS({
|
|
|
146
242
|
try {
|
|
147
243
|
fs3.unlinkSync(fullPath);
|
|
148
244
|
console.log("deleted", fullPath);
|
|
149
|
-
} catch (
|
|
245
|
+
} catch (_e) {
|
|
150
246
|
try {
|
|
151
247
|
fs3.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
152
248
|
console.log("deleted", fullPath);
|
|
@@ -235,11 +331,13 @@ init_cjs_shims();
|
|
|
235
331
|
|
|
236
332
|
// src/git-diff.js
|
|
237
333
|
init_cjs_shims();
|
|
334
|
+
var import_ansi_colors = __toESM(require("ansi-colors"), 1);
|
|
238
335
|
var import_child_process = require("child_process");
|
|
239
336
|
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
337
|
+
var import_sbg_utility = require("sbg-utility");
|
|
240
338
|
var import_upath2 = __toESM(require("upath"), 1);
|
|
241
339
|
var import_url = require("url");
|
|
242
|
-
var
|
|
340
|
+
var import_config = __toESM(require_config(), 1);
|
|
243
341
|
|
|
244
342
|
// src/utils/chatgpt.js
|
|
245
343
|
init_cjs_shims();
|
|
@@ -358,7 +456,10 @@ async function writeQuestion(page, question) {
|
|
|
358
456
|
async function clickSubmitButton(page) {
|
|
359
457
|
console.log("Attempting to click the submit button...");
|
|
360
458
|
try {
|
|
361
|
-
const userMessageCountBefore = await page.$$eval(
|
|
459
|
+
const userMessageCountBefore = await page.$$eval(
|
|
460
|
+
'[data-message-author-role="user"]',
|
|
461
|
+
(elements) => elements.length
|
|
462
|
+
);
|
|
362
463
|
const waitForSubmit = async (timeout = 5e3) => {
|
|
363
464
|
try {
|
|
364
465
|
await page.waitForFunction(
|
|
@@ -374,18 +475,21 @@ async function clickSubmitButton(page) {
|
|
|
374
475
|
return false;
|
|
375
476
|
}
|
|
376
477
|
};
|
|
377
|
-
await page.waitForFunction(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
478
|
+
await page.waitForFunction(
|
|
479
|
+
() => {
|
|
480
|
+
const candidates = [
|
|
481
|
+
document.querySelector('[data-testid="fruitjuice-send-button"]'),
|
|
482
|
+
document.querySelector("#composer-submit-button"),
|
|
483
|
+
document.querySelector('[data-testid="send-button"]')
|
|
484
|
+
].filter(Boolean);
|
|
485
|
+
return candidates.some((button) => {
|
|
486
|
+
const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
487
|
+
const isVisible = button.offsetParent !== null;
|
|
488
|
+
return !isDisabled && isVisible;
|
|
489
|
+
});
|
|
490
|
+
},
|
|
491
|
+
{ timeout: 5e3 }
|
|
492
|
+
).catch(() => {
|
|
389
493
|
});
|
|
390
494
|
const buttonDetails = await page.evaluate(() => {
|
|
391
495
|
const selectors = [
|
|
@@ -751,20 +855,24 @@ async function runChatGpt(chatgptOptions = {}) {
|
|
|
751
855
|
var import_utils = __toESM(require_utils(), 1);
|
|
752
856
|
var __filename2 = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
753
857
|
var __dirname = import_upath2.default.dirname(__filename2);
|
|
754
|
-
var
|
|
755
|
-
var
|
|
858
|
+
var args = (0, import_utils.getArgs)();
|
|
859
|
+
var positional = args._ || [];
|
|
860
|
+
var FILENAME = (0, import_sbg_utility.md5)((positional[0] || "default") + JSON.stringify(args));
|
|
861
|
+
var DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/${FILENAME}.txt`);
|
|
862
|
+
var GPT_DIFF_OUTPUT = (0, import_config.getTempPath)(`git-diff/gpt-${FILENAME}.txt`);
|
|
756
863
|
var CACHE_DIR = import_upath2.default.dirname(DIFF_OUTPUT);
|
|
757
864
|
var DIFF_OUTPUT_RELATIVE = import_upath2.default.relative(process.cwd(), DIFF_OUTPUT);
|
|
758
865
|
var GPT_DIFF_OUTPUT_RELATIVE = import_upath2.default.relative(process.cwd(), GPT_DIFF_OUTPUT);
|
|
759
|
-
|
|
760
|
-
import_fs_extra2.default.mkdirSync(CACHE_DIR, { recursive: true });
|
|
761
|
-
}
|
|
866
|
+
import_fs_extra2.default.ensureDirSync(CACHE_DIR, { mode: 493 });
|
|
762
867
|
function showHelp() {
|
|
763
868
|
console.log("\u{1F4DD} Git Diff Helper");
|
|
764
869
|
console.log("\u{1F4C4} Usage:");
|
|
765
870
|
console.log(" \u{1F4C2} git-diff FILE Show staged diff of specified file");
|
|
766
871
|
console.log(" \u{1F4C2} git-diff --staged-only Show staged diff of all files");
|
|
767
872
|
console.log(" \u{1F4C2} git-diff -s | -S Same as --staged-only");
|
|
873
|
+
console.log(" \u{1F4C2} git-diff --unstaged FILE Show unstaged diff of specified file");
|
|
874
|
+
console.log(" \u{1F4C2} git-diff --unstaged Show unstaged diff of all files");
|
|
875
|
+
console.log(" \u{1F4C2} git-diff -u Same as --unstaged");
|
|
768
876
|
console.log(" \u{1F4C2} git-diff --ai Run ChatGPT automation for commit message");
|
|
769
877
|
console.log(" \u{1F4C2} git-diff --help | -h Show this help message");
|
|
770
878
|
console.log("");
|
|
@@ -781,13 +889,13 @@ function runGitDiff(command, successMessage, errorMessage) {
|
|
|
781
889
|
// 10MB buffer to handle large diffs
|
|
782
890
|
});
|
|
783
891
|
if (!result || result.trim() === "") {
|
|
784
|
-
console.log(`\u2139\uFE0F
|
|
785
|
-
|
|
892
|
+
console.log(`\u2139\uFE0F [i] No changes found for the specified criteria`);
|
|
893
|
+
(0, import_sbg_utility.writefile)(DIFF_OUTPUT, "# No changes found\n");
|
|
786
894
|
console.log(`\u2705 Empty diff saved to "${DIFF_OUTPUT_RELATIVE}"`);
|
|
787
|
-
return;
|
|
895
|
+
return false;
|
|
788
896
|
}
|
|
789
|
-
|
|
790
|
-
|
|
897
|
+
(0, import_sbg_utility.writefile)(DIFF_OUTPUT, result);
|
|
898
|
+
(0, import_sbg_utility.writefile)(
|
|
791
899
|
GPT_DIFF_OUTPUT,
|
|
792
900
|
`Hello, ChatGPT!
|
|
793
901
|
Can you create a conventional commit message by diff content below:
|
|
@@ -800,7 +908,8 @@ Give me result as codeblock with language "text" only.
|
|
|
800
908
|
Thank you!`
|
|
801
909
|
);
|
|
802
910
|
console.log(`\u2705 ${successMessage}`);
|
|
803
|
-
console.log(`\u{1F4BE} GPT diff prompt saved to "${GPT_DIFF_OUTPUT_RELATIVE}"`);
|
|
911
|
+
console.log(`\u{1F4BE} GPT diff prompt saved to "${import_ansi_colors.default.green(GPT_DIFF_OUTPUT_RELATIVE)}"`);
|
|
912
|
+
return true;
|
|
804
913
|
} catch (error) {
|
|
805
914
|
console.error(`\u274C ${errorMessage}`);
|
|
806
915
|
console.error(`\u{1F4DD} Command: ${command}`);
|
|
@@ -811,34 +920,71 @@ Thank you!`
|
|
|
811
920
|
process.exit(1);
|
|
812
921
|
}
|
|
813
922
|
}
|
|
923
|
+
function fileHasChanges(file, mode) {
|
|
924
|
+
const command = mode === "staged" ? `git diff --cached --quiet -- "${file}"` : `git diff --quiet -- "${file}"`;
|
|
925
|
+
try {
|
|
926
|
+
(0, import_child_process.execSync)(command, { stdio: "ignore" });
|
|
927
|
+
return false;
|
|
928
|
+
} catch (error) {
|
|
929
|
+
if (error.status === 1) {
|
|
930
|
+
return true;
|
|
931
|
+
}
|
|
932
|
+
throw error;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
814
935
|
async function mainGitDiff() {
|
|
815
|
-
const args = (0, import_utils.getArgs)();
|
|
816
|
-
const positional = args._ || [];
|
|
817
936
|
if (args.help || args.h) {
|
|
818
937
|
showHelp();
|
|
819
938
|
}
|
|
939
|
+
const useUnstaged = args.unstaged || args.u;
|
|
940
|
+
const fileFromFlag = typeof args.unstaged === "string" ? args.unstaged : typeof args.u === "string" ? args.u : null;
|
|
941
|
+
let hasDiff = false;
|
|
820
942
|
if (args["staged-only"] || args.s || args.S) {
|
|
821
|
-
runGitDiff(
|
|
943
|
+
hasDiff = runGitDiff(
|
|
822
944
|
"git --no-pager diff --staged",
|
|
823
|
-
`Full staged diff saved to "${DIFF_OUTPUT_RELATIVE}"`,
|
|
945
|
+
`Full staged diff saved to "${import_ansi_colors.default.green(DIFF_OUTPUT_RELATIVE)}"`,
|
|
824
946
|
"Failed to save staged diff"
|
|
825
947
|
);
|
|
826
948
|
} else {
|
|
827
|
-
const file = positional[0];
|
|
949
|
+
const file = positional[0] || fileFromFlag;
|
|
828
950
|
if (!file) {
|
|
829
|
-
|
|
951
|
+
const fullDiffModeLabel = useUnstaged ? "unstaged" : "unstaged";
|
|
952
|
+
hasDiff = runGitDiff(
|
|
830
953
|
"git --no-pager diff",
|
|
831
|
-
`Full
|
|
954
|
+
`Full ${fullDiffModeLabel} diff saved to "${import_ansi_colors.default.green(DIFF_OUTPUT_RELATIVE)}"`,
|
|
832
955
|
"Failed to save all diff's"
|
|
833
956
|
);
|
|
834
957
|
} else {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
958
|
+
let fileDiffMode = useUnstaged ? "unstaged" : "staged";
|
|
959
|
+
if (!useUnstaged && !fileHasChanges(file, "staged") && fileHasChanges(file, "unstaged")) {
|
|
960
|
+
fileDiffMode = "unstaged";
|
|
961
|
+
}
|
|
962
|
+
hasDiff = runGitDiff(
|
|
963
|
+
fileDiffMode === "unstaged" ? `git --no-pager diff -- "${file}"` : `git --no-pager diff --cached -- "${file}"`,
|
|
964
|
+
`${fileDiffMode[0].toUpperCase() + fileDiffMode.slice(1)} diff of "${file}" saved to "${import_ansi_colors.default.green(
|
|
965
|
+
DIFF_OUTPUT_RELATIVE
|
|
966
|
+
)}"`,
|
|
967
|
+
`Failed to generate ${fileDiffMode} diff for "${file}"`
|
|
839
968
|
);
|
|
840
969
|
}
|
|
841
970
|
}
|
|
971
|
+
if (hasDiff) {
|
|
972
|
+
const opencodePrompt = [
|
|
973
|
+
"",
|
|
974
|
+
"\u{1F916} OpenCode Prompt Helper",
|
|
975
|
+
"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",
|
|
976
|
+
"",
|
|
977
|
+
"\u{1F4C4} App Prompt:",
|
|
978
|
+
` Generate a conventional commit message from diff file: ${DIFF_OUTPUT}`,
|
|
979
|
+
"",
|
|
980
|
+
"\u{1F4BB} CLI Command:",
|
|
981
|
+
` opencode run "Generate a conventional commit message from diff file ${DIFF_OUTPUT}"`,
|
|
982
|
+
""
|
|
983
|
+
];
|
|
984
|
+
const opencodePromptPath = (0, import_config.getTempPath)(`git-diff/opencode-${FILENAME}.txt`);
|
|
985
|
+
(0, import_sbg_utility.writefile)(opencodePromptPath, opencodePrompt.join("\n"));
|
|
986
|
+
console.log(`\u{1F4A1} OpenCode prompt saved to "${import_ansi_colors.default.green(import_upath2.default.relative(process.cwd(), opencodePromptPath))}"`);
|
|
987
|
+
}
|
|
842
988
|
if (args.ai) {
|
|
843
989
|
try {
|
|
844
990
|
await runChatGpt({ headless: true, questionFile: GPT_DIFF_OUTPUT });
|
package/lib/git-diff-cli.mjs
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
mainGitDiff
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-SPTECFE5.mjs";
|
|
6
|
+
import "./chunk-G5UUEWUO.mjs";
|
|
7
|
+
import "./chunk-GAGABICI.mjs";
|
|
8
|
+
import "./chunk-H44UWUFY.mjs";
|
|
9
|
+
import "./chunk-5RTXZVCW.mjs";
|
|
9
10
|
import {
|
|
10
11
|
init_esm_shims
|
|
11
12
|
} from "./chunk-QQ4A6DLD.mjs";
|