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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_rm_node_modules
|
|
4
|
+
} from "./chunk-NVEG3LEZ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__commonJS,
|
|
7
|
+
__require,
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-QQ4A6DLD.mjs";
|
|
10
|
+
|
|
11
|
+
// src/rm-node-module-cli.cjs
|
|
12
|
+
var require_rm_node_module_cli = __commonJS({
|
|
13
|
+
"src/rm-node-module-cli.cjs"() {
|
|
14
|
+
init_esm_shims();
|
|
15
|
+
var path = __require("upath");
|
|
16
|
+
var fs = __require("fs-extra");
|
|
17
|
+
var minimist = __require("minimist");
|
|
18
|
+
var glob = __require("glob");
|
|
19
|
+
var ansiColors = __require("ansi-colors");
|
|
20
|
+
var { cleanUp } = require_rm_node_modules();
|
|
21
|
+
var argv = minimist(process.argv.slice(2), {
|
|
22
|
+
boolean: ["h", "help", "force"],
|
|
23
|
+
alias: {
|
|
24
|
+
h: "help"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (argv.help) {
|
|
28
|
+
console.log(`
|
|
29
|
+
rm-node-modules
|
|
30
|
+
|
|
31
|
+
Usage:
|
|
32
|
+
rm-node-modules [options]
|
|
33
|
+
|
|
34
|
+
Examples:
|
|
35
|
+
node src/rm-node-module-cli.cjs
|
|
36
|
+
node src/rm-node-module-cli.cjs --force
|
|
37
|
+
npx binary-collections rm-node-modules
|
|
38
|
+
npx binary-collections rm-node-modules --force
|
|
39
|
+
|
|
40
|
+
Options:
|
|
41
|
+
-h, --help Show this help message
|
|
42
|
+
--force Actually delete node_modules (default is dry-run mode)
|
|
43
|
+
|
|
44
|
+
Description:
|
|
45
|
+
Removes node_modules subfolders by first-letter in parallel to speed up
|
|
46
|
+
deletions. By default runs in dry-run mode (shows what would be deleted).
|
|
47
|
+
Pass --force to actually perform deletion.
|
|
48
|
+
The script writes a temporary shell script and executes it; the
|
|
49
|
+
temporary script is removed after completion. On Windows, this requires a
|
|
50
|
+
Unix-compatible shell in PATH (e.g., Git Bash or WSL).
|
|
51
|
+
`);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
async function main() {
|
|
55
|
+
if (!argv.workspace) {
|
|
56
|
+
await cleanUp(process.cwd(), { dryRun: !argv.force });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const pkgJsonPath = path.resolve(process.cwd(), argv.workspace, "package.json");
|
|
60
|
+
if (!fs.existsSync(pkgJsonPath)) {
|
|
61
|
+
console.error(`Error: package.json not found in workspace directory: ${ansiColors.red(argv.workspace)}`);
|
|
62
|
+
process.exitCode = 1;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const workspaces = (JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8")).workspaces || []).flatMap((workspace) => {
|
|
66
|
+
return glob.sync(workspace, {
|
|
67
|
+
cwd: process.cwd(),
|
|
68
|
+
absolute: true,
|
|
69
|
+
ignore: ["**/node_modules/**", "**/dist/**", "**/build/**"]
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
for (const workspacePath of workspaces) {
|
|
73
|
+
if (fs.existsSync(path.join(workspacePath, "package.json"))) {
|
|
74
|
+
console.log(`Cleaning node_modules in workspace: ${ansiColors.cyan(workspacePath)}`);
|
|
75
|
+
await cleanUp(workspacePath, { dryRun: !argv.force });
|
|
76
|
+
} else {
|
|
77
|
+
console.warn(
|
|
78
|
+
`Warning: No package.json found in workspace path: ${ansiColors.yellow(workspacePath)}, skipping...`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
main().catch((e) => {
|
|
84
|
+
console.error(ansiColors.red(e instanceof Error ? e.stack || e.message : String(e)));
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
export default require_rm_node_module_cli();
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// src/rm-node-modules.cjs
|
|
2
|
+
var fs = require("fs-extra");
|
|
3
|
+
var path = require("upath");
|
|
4
|
+
var ansiColors = require("ansi-colors");
|
|
5
|
+
var child_process = require("child_process");
|
|
6
|
+
var os = require("os");
|
|
7
|
+
function generateBashScript(options = {}) {
|
|
8
|
+
const { dryRun = true } = options;
|
|
9
|
+
return `
|
|
10
|
+
#!/bin/bash
|
|
11
|
+
|
|
12
|
+
set -u
|
|
13
|
+
|
|
14
|
+
cwd="$(pwd)"
|
|
15
|
+
max_jobs=4
|
|
16
|
+
DRY_RUN=${dryRun ? "true" : "false"}
|
|
17
|
+
|
|
18
|
+
cleanup_letter() {
|
|
19
|
+
local letter="$1"
|
|
20
|
+
|
|
21
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
22
|
+
echo "Would remove: node_modules/\${letter}*"
|
|
23
|
+
echo "Would remove: node_modules/@types/\${letter}*"
|
|
24
|
+
echo "Would remove: node_modules/@\${letter}*"
|
|
25
|
+
else
|
|
26
|
+
rm -rf "\${cwd}/node_modules/\${letter}"*
|
|
27
|
+
echo "Removed: node_modules/\${letter}*"
|
|
28
|
+
|
|
29
|
+
rm -rf "\${cwd}/node_modules/@types/\${letter}"*
|
|
30
|
+
echo "Removed: node_modules/@types/\${letter}*"
|
|
31
|
+
|
|
32
|
+
rm -rf "\${cwd}/node_modules/@\${letter}"*
|
|
33
|
+
echo "Removed: node_modules/@\${letter}*"
|
|
34
|
+
fi
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export -f cleanup_letter
|
|
38
|
+
export cwd
|
|
39
|
+
export DRY_RUN
|
|
40
|
+
|
|
41
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
42
|
+
echo "Dry-run mode (pass --force to actually delete)"
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "Cleaning \${cwd}/node_modules..."
|
|
46
|
+
|
|
47
|
+
running=0
|
|
48
|
+
|
|
49
|
+
for letter in {a..z}; do
|
|
50
|
+
cleanup_letter "$letter" &
|
|
51
|
+
|
|
52
|
+
((running++))
|
|
53
|
+
|
|
54
|
+
# limit concurrent jobs
|
|
55
|
+
if (( running >= max_jobs )); then
|
|
56
|
+
wait -n
|
|
57
|
+
((running--))
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
wait
|
|
62
|
+
|
|
63
|
+
# final full cleanup (ensure nothing left behind)
|
|
64
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
65
|
+
echo "Would remove: node_modules (final cleanup)"
|
|
66
|
+
else
|
|
67
|
+
rm -rf "\${cwd}/node_modules"
|
|
68
|
+
echo "Removed: node_modules (final cleanup)"
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
if [ "$DRY_RUN" = "true" ]; then
|
|
72
|
+
echo "Done (dry-run). Run with --force to delete for real."
|
|
73
|
+
else
|
|
74
|
+
echo "Done cleaning node_modules."
|
|
75
|
+
fi
|
|
76
|
+
`.trim();
|
|
77
|
+
}
|
|
78
|
+
async function cleanUp(rootDir, options = {}) {
|
|
79
|
+
const { dryRun = true } = options;
|
|
80
|
+
const nodeModulesDir = path.join(rootDir, "node_modules");
|
|
81
|
+
const script = generateBashScript({ dryRun });
|
|
82
|
+
const tmpDir = os.tmpdir();
|
|
83
|
+
const name = `rm-node-modules-${Date.now()}-${Math.random().toString(36).slice(2)}.sh`;
|
|
84
|
+
const scriptPath = path.join(tmpDir, name);
|
|
85
|
+
try {
|
|
86
|
+
fs.writeFileSync(scriptPath, script, { encoding: "utf8" });
|
|
87
|
+
try {
|
|
88
|
+
fs.chmodSync(scriptPath, 493);
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
const result = child_process.spawnSync("bash", [scriptPath], {
|
|
92
|
+
cwd: rootDir,
|
|
93
|
+
env: process.env,
|
|
94
|
+
encoding: "utf8",
|
|
95
|
+
shell: false
|
|
96
|
+
});
|
|
97
|
+
if (result.stdout) process.stdout.write(result.stdout);
|
|
98
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
99
|
+
if (result.error) {
|
|
100
|
+
try {
|
|
101
|
+
console.warn(
|
|
102
|
+
ansiColors.yellow(`bash execution failed: ${result.error.message}. Falling back to Node removal.`)
|
|
103
|
+
);
|
|
104
|
+
console.log(`Cleaning ${ansiColors.cyan(nodeModulesDir)}...`);
|
|
105
|
+
fs.rmSync(nodeModulesDir, { recursive: true, force: true });
|
|
106
|
+
console.log(`Removed: ${ansiColors.green("node_modules (final cleanup)")}`);
|
|
107
|
+
console.log("Done cleaning node_modules.");
|
|
108
|
+
return {
|
|
109
|
+
code: 0,
|
|
110
|
+
stdout: result.stdout || "",
|
|
111
|
+
stderr: (result.stderr || "") + `
|
|
112
|
+
${result.error.stack || result.error.message}`
|
|
113
|
+
};
|
|
114
|
+
} catch (e) {
|
|
115
|
+
return { code: 1, stdout: result.stdout || "", stderr: (result.stderr || "") + `
|
|
116
|
+
${e.stack || e.message}` };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return { code: result.status ?? 0, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };
|
|
120
|
+
} finally {
|
|
121
|
+
try {
|
|
122
|
+
if (fs.existsSync(scriptPath)) fs.unlinkSync(scriptPath);
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
module.exports = { generateBashScript, cleanUp };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate bash script for node_modules cleanup
|
|
3
|
+
* @param {Object} options
|
|
4
|
+
* @param {boolean} options.dryRun - If true, only print what would be deleted
|
|
5
|
+
* @returns {string} - The bash script
|
|
6
|
+
*/
|
|
7
|
+
export function generateBashScript(options?: {
|
|
8
|
+
dryRun: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
/**
|
|
11
|
+
* Create and run a temporary bash script to remove `node_modules` contents.
|
|
12
|
+
*
|
|
13
|
+
* The script is written into `rootDir` and executed via `runBash`. A list of
|
|
14
|
+
* created temporary scripts is stored in a cache file under the OS temp
|
|
15
|
+
* directory so they can be removed after execution. When running with
|
|
16
|
+
* `spawnOptions.stdio === 'inherit'`, the child process uses the parent's
|
|
17
|
+
* stdio and the returned `stdout`/`stderr` may be empty; prefer `'pipe'` in
|
|
18
|
+
* tests when you need to assert against output.
|
|
19
|
+
*
|
|
20
|
+
* @async
|
|
21
|
+
* @param {string} rootDir - Directory where the cleanup script will be created and executed.
|
|
22
|
+
* @param {Object} [options]
|
|
23
|
+
* @param {boolean} [options.dryRun=true] - If true, the generated script will only print what would be deleted.
|
|
24
|
+
* @param {import('child_process').SpawnOptions} [options.spawnOptions] - Options forwarded to the underlying `spawn` call (via `runBash`).
|
|
25
|
+
* @returns {Promise<{code: number, stdout: string, stderr: string}>} Resolves with the result object returned by `runBash`.
|
|
26
|
+
* @throws {Error|Object} Throws for internal failures or rejects with the `runBash` result when the process exits non-zero.
|
|
27
|
+
*/
|
|
28
|
+
export function cleanUp(rootDir: string, options?: {
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
spawnOptions?: import("child_process").SpawnOptions;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
code: number;
|
|
33
|
+
stdout: string;
|
|
34
|
+
stderr: string;
|
|
35
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
require_rm_node_modules
|
|
4
|
+
} from "./chunk-NVEG3LEZ.mjs";
|
|
5
5
|
import "./chunk-QQ4A6DLD.mjs";
|
|
6
|
-
export default
|
|
6
|
+
export default require_rm_node_modules();
|
package/lib/rmpath.cjs
CHANGED
|
@@ -117,7 +117,7 @@ var require_utils = __commonJS({
|
|
|
117
117
|
try {
|
|
118
118
|
fs2.rmdirSync(fullPath);
|
|
119
119
|
console.log("deleted", fullPath);
|
|
120
|
-
} catch (
|
|
120
|
+
} catch (_e) {
|
|
121
121
|
try {
|
|
122
122
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
123
123
|
console.log("deleted", fullPath);
|
|
@@ -130,7 +130,7 @@ var require_utils = __commonJS({
|
|
|
130
130
|
try {
|
|
131
131
|
fs2.unlinkSync(fullPath);
|
|
132
132
|
console.log("deleted", fullPath);
|
|
133
|
-
} catch (
|
|
133
|
+
} catch (_e) {
|
|
134
134
|
try {
|
|
135
135
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
136
136
|
console.log("deleted", fullPath);
|
package/lib/rmpath.mjs
CHANGED
|
@@ -88,7 +88,7 @@ var require_utils = __commonJS({
|
|
|
88
88
|
try {
|
|
89
89
|
fs2.rmdirSync(fullPath);
|
|
90
90
|
console.log("deleted", fullPath);
|
|
91
|
-
} catch (
|
|
91
|
+
} catch (_e) {
|
|
92
92
|
try {
|
|
93
93
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
94
94
|
console.log("deleted", fullPath);
|
|
@@ -101,7 +101,7 @@ var require_utils = __commonJS({
|
|
|
101
101
|
try {
|
|
102
102
|
fs2.unlinkSync(fullPath);
|
|
103
103
|
console.log("deleted", fullPath);
|
|
104
|
-
} catch (
|
|
104
|
+
} catch (_e) {
|
|
105
105
|
try {
|
|
106
106
|
fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
107
107
|
console.log("deleted", fullPath);
|
|
@@ -227,15 +227,19 @@ if (VISITED_SUBMODULES.includes(CURRENT_PATH)) {
|
|
|
227
227
|
VISITED_SUBMODULES.push(CURRENT_PATH);
|
|
228
228
|
process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
|
|
229
229
|
console.log(`Installing submodules at ${ROOT}`);
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"^submodule\\..*\\.path$"
|
|
238
|
-
|
|
230
|
+
var ROOT_GITMODULES = path.join(REPO_PATH, ".gitmodules");
|
|
231
|
+
if (!fs.existsSync(ROOT_GITMODULES) || fs.statSync(ROOT_GITMODULES).size === 0) {
|
|
232
|
+
console.log(`No valid .gitmodules found at ${ROOT_GITMODULES}. Skipping submodule processing.`);
|
|
233
|
+
process.exit(0);
|
|
234
|
+
}
|
|
235
|
+
var submoduleList = [];
|
|
236
|
+
try {
|
|
237
|
+
const output = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get-regexp", "^submodule\\..*\\.path$"]);
|
|
238
|
+
submoduleList = output.split("\n").filter(Boolean);
|
|
239
|
+
} catch (err) {
|
|
240
|
+
console.log("No submodules found or .gitmodules invalid. Skipping.", err);
|
|
241
|
+
process.exit(0);
|
|
242
|
+
}
|
|
239
243
|
for (const line of submoduleList) {
|
|
240
244
|
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
241
245
|
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
@@ -244,11 +248,14 @@ for (const line of submoduleList) {
|
|
|
244
248
|
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
245
249
|
}
|
|
246
250
|
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
247
|
-
const URL2 = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
248
|
-
let BRANCH
|
|
251
|
+
const URL2 = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
252
|
+
let BRANCH;
|
|
249
253
|
try {
|
|
250
|
-
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
251
|
-
|
|
254
|
+
BRANCH = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
255
|
+
if (!BRANCH) BRANCH = "master";
|
|
256
|
+
} catch (err) {
|
|
257
|
+
console.log(`Error occurred while fetching branch for submodule ${NAME}:`, err);
|
|
258
|
+
BRANCH = "master";
|
|
252
259
|
}
|
|
253
260
|
console.log(`Submodule: ${color.cyan(NAME)}`);
|
|
254
261
|
console.log(` Location: ${color.magenta(MODULE_PATH)}`);
|
|
@@ -264,19 +271,27 @@ for (const line of submoduleList) {
|
|
|
264
271
|
continue;
|
|
265
272
|
}
|
|
266
273
|
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
267
|
-
console.warn(`Submodule directory
|
|
274
|
+
console.warn(`Submodule directory missing. Attempting manual clone...`);
|
|
268
275
|
try {
|
|
269
276
|
runGit(["clone", "--branch", BRANCH, URL2, RELATIVE_MODULE_PATH]);
|
|
270
277
|
} catch (e) {
|
|
271
|
-
console.error(`Manual clone failed
|
|
278
|
+
console.error(`Manual clone failed: ${e.message}`);
|
|
272
279
|
continue;
|
|
273
280
|
}
|
|
274
281
|
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
275
|
-
console.error(`
|
|
282
|
+
console.error(`Still missing after clone: ${RELATIVE_MODULE_PATH}`);
|
|
276
283
|
continue;
|
|
277
284
|
}
|
|
278
285
|
}
|
|
279
286
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
287
|
+
if (!fs.existsSync(GIT_MODULES)) {
|
|
288
|
+
console.log(`No .gitmodules in ${RELATIVE_MODULE_PATH}. Skipping nested processing.`);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (fs.statSync(GIT_MODULES).size === 0) {
|
|
292
|
+
console.log(`Empty .gitmodules in ${RELATIVE_MODULE_PATH}. Skipping nested processing.`);
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
280
295
|
if (ACCESS_TOKEN) {
|
|
281
296
|
let URL_WITH_TOKEN;
|
|
282
297
|
let repoInfo;
|
|
@@ -291,27 +306,25 @@ for (const line of submoduleList) {
|
|
|
291
306
|
repoInfo = urlObj.pathname.substring(1);
|
|
292
307
|
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
293
308
|
}
|
|
294
|
-
if (URL_WITH_TOKEN
|
|
295
|
-
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH}
|
|
309
|
+
if (URL_WITH_TOKEN) {
|
|
310
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH}`);
|
|
296
311
|
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
297
312
|
}
|
|
298
313
|
}
|
|
299
314
|
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
300
315
|
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
process.exit(result.status);
|
|
314
|
-
}
|
|
316
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
317
|
+
const env = Object.assign({}, process.env, {
|
|
318
|
+
VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
|
|
319
|
+
});
|
|
320
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
|
|
321
|
+
stdio: "inherit",
|
|
322
|
+
env,
|
|
323
|
+
cwd: RELATIVE_MODULE_PATH
|
|
324
|
+
});
|
|
325
|
+
if (result.status !== 0) {
|
|
326
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
327
|
+
process.exit(result.status);
|
|
315
328
|
}
|
|
316
329
|
}
|
|
317
330
|
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
require_utils
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5RTXZVCW.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__commonJS,
|
|
8
8
|
__filename,
|
|
@@ -54,15 +54,19 @@ var require_submodule_install = __commonJS({
|
|
|
54
54
|
VISITED_SUBMODULES.push(CURRENT_PATH);
|
|
55
55
|
process.env.VISITED_SUBMODULES = VISITED_SUBMODULES.join(path.delimiter);
|
|
56
56
|
console.log(`Installing submodules at ${ROOT}`);
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"^submodule\\..*\\.path$"
|
|
65
|
-
|
|
57
|
+
var ROOT_GITMODULES = path.join(REPO_PATH, ".gitmodules");
|
|
58
|
+
if (!fs.existsSync(ROOT_GITMODULES) || fs.statSync(ROOT_GITMODULES).size === 0) {
|
|
59
|
+
console.log(`No valid .gitmodules found at ${ROOT_GITMODULES}. Skipping submodule processing.`);
|
|
60
|
+
process.exit(0);
|
|
61
|
+
}
|
|
62
|
+
var submoduleList = [];
|
|
63
|
+
try {
|
|
64
|
+
const output = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get-regexp", "^submodule\\..*\\.path$"]);
|
|
65
|
+
submoduleList = output.split("\n").filter(Boolean);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.log("No submodules found or .gitmodules invalid. Skipping.", err);
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
66
70
|
for (const line of submoduleList) {
|
|
67
71
|
const [KEY, MODULE_PATH] = line.trim().split(/\s+/);
|
|
68
72
|
const RELATIVE_MODULE_PATH = path.join(ROOT, MODULE_PATH);
|
|
@@ -71,11 +75,14 @@ var require_submodule_install = __commonJS({
|
|
|
71
75
|
fs.rmSync(RELATIVE_MODULE_PATH, { recursive: true, force: true });
|
|
72
76
|
}
|
|
73
77
|
const NAME = KEY.match(/^submodule\.(.*)\.path$/)[1];
|
|
74
|
-
const URL = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
75
|
-
let BRANCH
|
|
78
|
+
const URL = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get", `submodule.${NAME}.url`]).trim();
|
|
79
|
+
let BRANCH;
|
|
76
80
|
try {
|
|
77
|
-
BRANCH = runGit(["config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
78
|
-
|
|
81
|
+
BRANCH = runGit(["-C", REPO_PATH, "config", "-f", ".gitmodules", "--get", `submodule.${NAME}.branch`]).trim();
|
|
82
|
+
if (!BRANCH) BRANCH = "master";
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.log(`Error occurred while fetching branch for submodule ${NAME}:`, err);
|
|
85
|
+
BRANCH = "master";
|
|
79
86
|
}
|
|
80
87
|
console.log(`Submodule: ${color.cyan(NAME)}`);
|
|
81
88
|
console.log(` Location: ${color.magenta(MODULE_PATH)}`);
|
|
@@ -91,19 +98,27 @@ var require_submodule_install = __commonJS({
|
|
|
91
98
|
continue;
|
|
92
99
|
}
|
|
93
100
|
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
94
|
-
console.warn(`Submodule directory
|
|
101
|
+
console.warn(`Submodule directory missing. Attempting manual clone...`);
|
|
95
102
|
try {
|
|
96
103
|
runGit(["clone", "--branch", BRANCH, URL, RELATIVE_MODULE_PATH]);
|
|
97
104
|
} catch (e) {
|
|
98
|
-
console.error(`Manual clone failed
|
|
105
|
+
console.error(`Manual clone failed: ${e.message}`);
|
|
99
106
|
continue;
|
|
100
107
|
}
|
|
101
108
|
if (!fs.existsSync(RELATIVE_MODULE_PATH)) {
|
|
102
|
-
console.error(`
|
|
109
|
+
console.error(`Still missing after clone: ${RELATIVE_MODULE_PATH}`);
|
|
103
110
|
continue;
|
|
104
111
|
}
|
|
105
112
|
}
|
|
106
113
|
const GIT_MODULES = path.join(RELATIVE_MODULE_PATH, ".gitmodules");
|
|
114
|
+
if (!fs.existsSync(GIT_MODULES)) {
|
|
115
|
+
console.log(`No .gitmodules in ${RELATIVE_MODULE_PATH}. Skipping nested processing.`);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (fs.statSync(GIT_MODULES).size === 0) {
|
|
119
|
+
console.log(`Empty .gitmodules in ${RELATIVE_MODULE_PATH}. Skipping nested processing.`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
107
122
|
if (ACCESS_TOKEN) {
|
|
108
123
|
let URL_WITH_TOKEN;
|
|
109
124
|
let repoInfo;
|
|
@@ -118,27 +133,25 @@ var require_submodule_install = __commonJS({
|
|
|
118
133
|
repoInfo = urlObj.pathname.substring(1);
|
|
119
134
|
URL_WITH_TOKEN = `${urlObj.protocol}//${ACCESS_TOKEN}@${urlObj.host}${urlObj.pathname}`;
|
|
120
135
|
}
|
|
121
|
-
if (URL_WITH_TOKEN
|
|
122
|
-
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH}
|
|
136
|
+
if (URL_WITH_TOKEN) {
|
|
137
|
+
console.log(`Apply token for ${repoInfo} at ${MODULE_PATH}`);
|
|
123
138
|
runGit(["-C", RELATIVE_MODULE_PATH, "remote", "set-url", "origin", URL_WITH_TOKEN]);
|
|
124
139
|
}
|
|
125
140
|
}
|
|
126
141
|
runGit(["-C", RELATIVE_MODULE_PATH, "fetch", "--all"]);
|
|
127
142
|
runGit(["-C", RELATIVE_MODULE_PATH, "pull", "origin", BRANCH, "-X", "theirs"]);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
process.exit(result.status);
|
|
141
|
-
}
|
|
143
|
+
console.log(`${MODULE_PATH} has submodules`);
|
|
144
|
+
const env = Object.assign({}, process.env, {
|
|
145
|
+
VISITED_SUBMODULES: process.env.VISITED_SUBMODULES + path.delimiter + path.resolve(RELATIVE_MODULE_PATH)
|
|
146
|
+
});
|
|
147
|
+
const result = spawnSync("node", [__filename, "-cwd", RELATIVE_MODULE_PATH], {
|
|
148
|
+
stdio: "inherit",
|
|
149
|
+
env,
|
|
150
|
+
cwd: RELATIVE_MODULE_PATH
|
|
151
|
+
});
|
|
152
|
+
if (result.status !== 0) {
|
|
153
|
+
console.error(`Recursive submodule failed for ${RELATIVE_MODULE_PATH}`);
|
|
154
|
+
process.exit(result.status);
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
runGit(["-C", REPO_PATH, "submodule", "update", "--init", "--recursive"]);
|
|
@@ -99,8 +99,7 @@ if (!submodulePath) {
|
|
|
99
99
|
process.exit(1);
|
|
100
100
|
}
|
|
101
101
|
if (!import_fs_extra.default.existsSync(import_upath.default.resolve(submodulePath))) {
|
|
102
|
-
console.
|
|
103
|
-
process.exit(1);
|
|
102
|
+
console.warn(`Error: The path "${submodulePath}" does not exist, continue deinitialization and cleanup steps.`);
|
|
104
103
|
}
|
|
105
104
|
(async () => {
|
|
106
105
|
await (0, import_submodule_remove.default)(submodulePath);
|
|
@@ -19,12 +19,12 @@ const submodule_remove_cjs_1 = __importDefault(require("./submodule-remove.cjs")
|
|
|
19
19
|
const args = (0, minimist_1.default)(process.argv.slice(2));
|
|
20
20
|
const submodulePath = args._[0];
|
|
21
21
|
if (!submodulePath) {
|
|
22
|
-
console.error(
|
|
22
|
+
console.error('Usage: node submodule-remove.cjs <submodule-path>');
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
if (!fs_extra_1.default.existsSync(upath_1.default.resolve(submodulePath))) {
|
|
26
|
-
console.
|
|
27
|
-
process.exit(1);
|
|
26
|
+
console.warn(`Error: The path "${submodulePath}" does not exist, continue deinitialization and cleanup steps.`);
|
|
27
|
+
// process.exit(1);
|
|
28
28
|
}
|
|
29
29
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
yield (0, submodule_remove_cjs_1.default)(submodulePath);
|
|
@@ -20,8 +20,7 @@ if (!submodulePath) {
|
|
|
20
20
|
process.exit(1);
|
|
21
21
|
}
|
|
22
22
|
if (!fs.existsSync(path.resolve(submodulePath))) {
|
|
23
|
-
console.
|
|
24
|
-
process.exit(1);
|
|
23
|
+
console.warn(`Error: The path "${submodulePath}" does not exist, continue deinitialization and cleanup steps.`);
|
|
25
24
|
}
|
|
26
25
|
(async () => {
|
|
27
26
|
await (0, import_submodule_remove.default)(submodulePath);
|
package/lib/utils/chatgpt.cjs
CHANGED
|
@@ -147,7 +147,10 @@ async function writeQuestion(page, question) {
|
|
|
147
147
|
async function clickSubmitButton(page) {
|
|
148
148
|
console.log("Attempting to click the submit button...");
|
|
149
149
|
try {
|
|
150
|
-
const userMessageCountBefore = await page.$$eval(
|
|
150
|
+
const userMessageCountBefore = await page.$$eval(
|
|
151
|
+
'[data-message-author-role="user"]',
|
|
152
|
+
(elements) => elements.length
|
|
153
|
+
);
|
|
151
154
|
const waitForSubmit = async (timeout = 5e3) => {
|
|
152
155
|
try {
|
|
153
156
|
await page.waitForFunction(
|
|
@@ -163,18 +166,21 @@ async function clickSubmitButton(page) {
|
|
|
163
166
|
return false;
|
|
164
167
|
}
|
|
165
168
|
};
|
|
166
|
-
await page.waitForFunction(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
await page.waitForFunction(
|
|
170
|
+
() => {
|
|
171
|
+
const candidates = [
|
|
172
|
+
document.querySelector('[data-testid="fruitjuice-send-button"]'),
|
|
173
|
+
document.querySelector("#composer-submit-button"),
|
|
174
|
+
document.querySelector('[data-testid="send-button"]')
|
|
175
|
+
].filter(Boolean);
|
|
176
|
+
return candidates.some((button) => {
|
|
177
|
+
const isDisabled = button.disabled || button.getAttribute("aria-disabled") === "true";
|
|
178
|
+
const isVisible = button.offsetParent !== null;
|
|
179
|
+
return !isDisabled && isVisible;
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
{ timeout: 5e3 }
|
|
183
|
+
).catch(() => {
|
|
178
184
|
});
|
|
179
185
|
const buttonDetails = await page.evaluate(() => {
|
|
180
186
|
const selectors = [
|