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.
Files changed (165) hide show
  1. package/.puppeterrc.cjs +25 -0
  2. package/binaries/binary-executor.cjs +138 -3
  3. package/binaries/clean-nodemodule.cjs +138 -3
  4. package/binaries/clean-nodemodules.cjs +138 -3
  5. package/binaries/dev.cjs +138 -3
  6. package/binaries/empty.cjs +138 -3
  7. package/binaries/git-reduce-size.cjs +138 -3
  8. package/binaries/javakill.cjs +138 -3
  9. package/binaries/kill-night-crows.bat +7 -0
  10. package/binaries/kill-night-crows.ps1 +172 -0
  11. package/binaries/kill-process.cjs +138 -3
  12. package/binaries/nodekill.cjs +138 -3
  13. package/binaries/prod.cjs +138 -3
  14. package/binaries/py +111 -0
  15. package/binaries/py.cjs +178 -0
  16. package/binaries/py.cmd +49 -0
  17. package/binaries/rmfind.cjs +138 -3
  18. package/binaries/rmx.cjs +138 -3
  19. package/binaries/submodule-token.cjs +138 -3
  20. package/binaries/test-cjs +10 -0
  21. package/binaries/test-cjs.cjs +178 -0
  22. package/binaries/test-cjs.cmd +11 -0
  23. package/binaries/yarn-clean +32 -0
  24. package/binaries/yarn-clean.cjs +178 -0
  25. package/binaries/yarn-clean.cmd +30 -0
  26. package/binaries/yarn-clean.py +148 -0
  27. package/lib/binary-collections-config.cjs +1 -1
  28. package/lib/binary-collections-config.mjs +1 -1
  29. package/lib/binary-collections.cjs +167 -106
  30. package/lib/binary-collections.mjs +108 -94
  31. package/lib/changelog.cjs +61 -13
  32. package/lib/changelog.mjs +1 -1
  33. package/lib/{chunk-AI4CVPJ7.mjs → chunk-2CBJCW7E.mjs} +4 -4
  34. package/lib/chunk-34IQDTLZ.mjs +27 -0
  35. package/lib/chunk-3HFFECCI.mjs +27 -0
  36. package/lib/{chunk-SBNDSKG5.mjs → chunk-4UHL4WVN.mjs} +1 -1
  37. package/lib/chunk-7XTEJHOE.mjs +193 -0
  38. package/lib/chunk-AJDD5DZM.mjs +109 -0
  39. package/lib/chunk-BZWVHODJ.mjs +62 -0
  40. package/lib/{chunk-BEZKJ25G.mjs → chunk-FCDQGYBF.mjs} +5 -9
  41. package/lib/chunk-GEYA2USY.mjs +207 -0
  42. package/lib/chunk-ID2WBTE2.mjs +80 -0
  43. package/lib/chunk-JXFOHKDM.mjs +239 -0
  44. package/lib/{chunk-DI5MDPSN.mjs → chunk-N436BNBK.mjs} +192 -64
  45. package/lib/chunk-NCXAP7AA.mjs +31 -0
  46. package/lib/chunk-PDN26I7O.mjs +188 -0
  47. package/lib/{chunk-E6FDDAOO.mjs → chunk-RWLXRTYP.mjs} +1 -1
  48. package/lib/{chunk-BDCHCWHD.mjs → chunk-TOIVAQF7.mjs} +4 -4
  49. package/lib/chunk-V5SKYJUB.mjs +136 -0
  50. package/lib/{chunk-HMRMTYZM.mjs → chunk-WSRETQCA.mjs} +21 -2
  51. package/lib/chunk-XA3SNBPA.mjs +184 -0
  52. package/lib/chunk-YYLIQQKF.mjs +31 -0
  53. package/lib/{chunk-V3N3JEUF.mjs → chunk-Z6JLYU2J.mjs} +60 -13
  54. package/lib/{chunk-O6SWBEOQ.mjs → chunk-ZDMWBSYF.mjs} +2 -2
  55. package/lib/clean-github-actions-caches.cjs +63 -15
  56. package/lib/clean-github-actions-caches.mjs +3 -3
  57. package/lib/del-gradle.cjs +61 -13
  58. package/lib/del-gradle.js +1 -0
  59. package/lib/del-gradle.mjs +1 -1
  60. package/lib/del-node-modules.cjs +143 -148
  61. package/lib/del-node-modules.js +210 -14
  62. package/lib/del-node-modules.mjs +148 -17
  63. package/lib/del-ps.cjs +61 -13
  64. package/lib/del-ps.js +1 -0
  65. package/lib/del-ps.mjs +1 -1
  66. package/lib/del-yarn-caches.cjs +61 -13
  67. package/lib/del-yarn-caches.mjs +1 -1
  68. package/lib/find-node-modules-cli.js +1 -0
  69. package/lib/free-chatgpt.cjs +253 -47
  70. package/lib/free-chatgpt.mjs +2 -2
  71. package/lib/git/gitattributes.cjs +1 -0
  72. package/lib/git/gitattributes.d.cts +7 -2
  73. package/lib/git/gitattributes.mjs +1 -1
  74. package/lib/git/line-endings.cjs +2 -1
  75. package/lib/git/line-endings.mjs +2 -2
  76. package/lib/git/undo-commit-cli.cjs +110 -0
  77. package/lib/git/undo-commit-cli.d.ts +1 -0
  78. package/lib/git/undo-commit-cli.js +4 -0
  79. package/lib/git/undo-commit-cli.mjs +14 -0
  80. package/lib/git/undo-commit.cjs +81 -0
  81. package/lib/git/undo-commit.d.cts +1 -0
  82. package/lib/git/undo-commit.mjs +7 -0
  83. package/lib/git/undo-staged-cli.cjs +110 -0
  84. package/lib/git/undo-staged-cli.d.ts +1 -0
  85. package/lib/git/undo-staged-cli.js +4 -0
  86. package/lib/git/undo-staged-cli.mjs +14 -0
  87. package/lib/git/undo-staged.cjs +81 -0
  88. package/lib/git/undo-staged.d.cts +1 -0
  89. package/lib/git/undo-staged.mjs +7 -0
  90. package/lib/git/user-config.cjs +61 -14
  91. package/lib/git/user-config.mjs +2 -2
  92. package/lib/git-diff-cli.cjs +255 -49
  93. package/lib/git-diff-cli.d.ts +1 -0
  94. package/lib/git-diff-cli.js +1 -0
  95. package/lib/git-diff-cli.mjs +5 -4
  96. package/lib/git-diff.cjs +254 -49
  97. package/lib/git-diff.mjs +4 -4
  98. package/lib/git-fix.cjs +64 -16
  99. package/lib/git-fix.mjs +10 -10
  100. package/lib/git-purge.cjs +61 -13
  101. package/lib/git-purge.mjs +1 -1
  102. package/lib/kill-night-crows.cjs +87 -0
  103. package/lib/kill-night-crows.d.mts +1 -0
  104. package/lib/kill-night-crows.mjs +65 -0
  105. package/lib/npm-run-series.cjs +60 -13
  106. package/lib/npm-run-series.mjs +1 -1
  107. package/lib/package-resolutions-updater-cli.cjs +560 -0
  108. package/lib/package-resolutions-updater-cli.d.mts +1 -0
  109. package/lib/package-resolutions-updater-cli.mjs +124 -0
  110. package/lib/package-resolutions-updater.cjs +174 -154
  111. package/lib/package-resolutions-updater.d.mts +32 -1
  112. package/lib/package-resolutions-updater.mjs +16 -294
  113. package/lib/php-cs-fixer-staged.cjs +105 -0
  114. package/lib/php-cs-fixer-staged.d.cts +2 -0
  115. package/lib/php-cs-fixer-staged.mjs +117 -0
  116. package/lib/print-directory-tree.cjs +62 -14
  117. package/lib/print-directory-tree.mjs +2 -2
  118. package/lib/ps/connected-domain.d.ts +1 -1
  119. package/lib/ps/index.js +1 -0
  120. package/lib/remove-module.cjs +61 -13
  121. package/lib/remove-module.mjs +1 -1
  122. package/lib/rmpath.cjs +63 -15
  123. package/lib/rmpath.mjs +2 -2
  124. package/lib/submodule-install.cjs +62 -15
  125. package/lib/submodule-install.mjs +3 -3
  126. package/lib/submodule-remove-cli.cjs +5 -1
  127. package/lib/submodule-remove-cli.mjs +1 -1
  128. package/lib/submodule-remove.cjs +4 -1
  129. package/lib/submodule-remove.mjs +1 -1
  130. package/lib/utils/chatgpt.cjs +192 -34
  131. package/lib/utils/chatgpt.js +210 -43
  132. package/lib/utils/chatgpt.mjs +1 -1
  133. package/lib/utils/findEnvFiles.cjs +107 -0
  134. package/lib/utils/findEnvFiles.d.ts +8 -0
  135. package/lib/utils/findEnvFiles.js +121 -0
  136. package/lib/utils/findEnvFiles.mjs +8 -0
  137. package/lib/utils/findWorkspaceRoot.cjs +70 -0
  138. package/lib/utils/findWorkspaceRoot.d.ts +9 -0
  139. package/lib/utils/findWorkspaceRoot.js +57 -0
  140. package/lib/utils/findWorkspaceRoot.mjs +40 -0
  141. package/lib/utils/index.cjs +60 -13
  142. package/lib/utils/index.mjs +1 -1
  143. package/lib/utils/isGithubTokenValid.cjs +64 -0
  144. package/lib/utils/isGithubTokenValid.d.ts +7 -0
  145. package/lib/utils/isGithubTokenValid.js +48 -0
  146. package/lib/utils/isGithubTokenValid.mjs +36 -0
  147. package/lib/yarn-reinstall.cjs +61 -13
  148. package/lib/yarn-reinstall.mjs +1 -1
  149. package/package.json +107 -93
  150. package/readme.md +33 -34
  151. package/releases/readme.md +1 -1
  152. package/requirements.txt +1 -0
  153. package/lib/chunk-4EWQC6GZ.mjs +0 -382
  154. package/lib/chunk-4ZI7BQKQ.mjs +0 -381
  155. package/lib/chunk-5J2BEPY5.mjs +0 -83
  156. package/lib/chunk-AGZYRDC2.mjs +0 -323
  157. package/lib/chunk-HN52G2YL.mjs +0 -305
  158. package/lib/chunk-HO6GHCOB.mjs +0 -385
  159. package/lib/chunk-LEM5OMRP.mjs +0 -384
  160. package/lib/chunk-RCP7DHVY.mjs +0 -190
  161. package/lib/chunk-U6SO4QEV.mjs +0 -320
  162. package/lib/chunk-XD6BJK6Q.mjs +0 -351
  163. package/lib/chunk-YXSFGA2D.mjs +0 -383
  164. package/lib/git/gitattributes.d.ts +0 -33
  165. package/lib/git/gitattributes.js +0 -223
@@ -0,0 +1,109 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ require_utils as require_utils2
4
+ } from "./chunk-A3VUZEJK.mjs";
5
+ import {
6
+ require_utils
7
+ } from "./chunk-Z6JLYU2J.mjs";
8
+ import {
9
+ __commonJS,
10
+ __require,
11
+ init_esm_shims
12
+ } from "./chunk-QQ4A6DLD.mjs";
13
+
14
+ // src/git/user-config.cjs
15
+ var require_user_config = __commonJS({
16
+ "src/git/user-config.cjs"(exports, module) {
17
+ init_esm_shims();
18
+ var gch = __require("git-command-helper");
19
+ var { runGitCommand, runGitCommandOutput } = require_utils2();
20
+ var { getArgs } = require_utils();
21
+ __require("dotenv").config({ path: __require("path").join(process.cwd(), ".env"), quiet: true });
22
+ function configureGitUser(cliUser = null, cliEmail = null, options = {}) {
23
+ console.log("\n=== Configuring Git User ===");
24
+ let username, email;
25
+ if (cliUser && cliEmail) {
26
+ username = cliUser.trim();
27
+ email = cliEmail.trim();
28
+ console.log("[i] Using CLI-provided user configuration");
29
+ } else {
30
+ username = process.env.GITHUB_USER ? process.env.GITHUB_USER.trim() : void 0;
31
+ email = process.env.GITHUB_EMAIL ? process.env.GITHUB_EMAIL.trim() : void 0;
32
+ if (username || email) {
33
+ console.log("[i] Using environment variable user configuration");
34
+ }
35
+ }
36
+ if (!username && !email) {
37
+ console.log("[i] No Git user configuration needed (no CLI args or environment variables set)");
38
+ return;
39
+ }
40
+ if (username) {
41
+ const success = runGitCommand(["config", "user.name", username], `Set Git username to "${username}"`);
42
+ if (!success) {
43
+ console.log("[i] Failed to set Git username, but continuing...");
44
+ }
45
+ } else {
46
+ console.log("[i] No username provided, skipping username configuration");
47
+ }
48
+ if (email) {
49
+ const success = runGitCommand(["config", "user.email", email], `Set Git email to "${email}"`);
50
+ if (!success) {
51
+ console.log("[i] Failed to set Git email, but continuing...");
52
+ }
53
+ } else {
54
+ console.log("[i] No email provided, skipping email configuration");
55
+ }
56
+ if (username || email) {
57
+ console.log("[\u2713] Git user configuration completed");
58
+ }
59
+ if (username) {
60
+ const remoteUrl = runGitCommandOutput(["remote", "get-url", "origin"], "Fetching remote URL for verification");
61
+ if (remoteUrl) {
62
+ console.log(`[i] Remote URL: ${remoteUrl}`);
63
+ const parsedUrl = gch.parseGitHubUrl(remoteUrl);
64
+ if (parsedUrl && parsedUrl.owner && username && parsedUrl.owner.toLowerCase() !== username.toLowerCase()) {
65
+ console.warn(
66
+ `
67
+ [!] The GitHub remote owner ("${parsedUrl.owner}") does not match the configured username ("${username}").`
68
+ );
69
+ console.warn(`[!] If this is not intentional, consider updating the remote URL to use your username.`);
70
+ console.warn(`[!] Example: git remote set-url origin https://github.com/${username}/<repo>.git
71
+ `);
72
+ const args = getArgs();
73
+ const updateRemote = options.updateRemote || args["update-remote"] === true;
74
+ if (updateRemote) {
75
+ let newUrl = remoteUrl;
76
+ if (/^https:\/\//.test(remoteUrl)) {
77
+ newUrl = remoteUrl.replace(/https:\/\/(?:[^@]+@)?github.com/, `https://${username}@github.com`);
78
+ } else if (/^git@github.com:/.test(remoteUrl)) {
79
+ console.warn(
80
+ `[!] For SSH remotes, set your SSH config or use HTTPS with username if you want to change authentication user.`
81
+ );
82
+ return;
83
+ }
84
+ if (newUrl !== remoteUrl) {
85
+ const updated = runGitCommand(["remote", "set-url", "origin", newUrl], `Set origin to ${newUrl}`);
86
+ if (updated) {
87
+ console.log(`[\u2713] Remote URL updated to: ${newUrl}`);
88
+ } else {
89
+ console.warn(`[!] Failed to update remote URL. Please update it manually if needed.`);
90
+ }
91
+ } else {
92
+ console.log(`[i] Remote URL does not use HTTPS or already contains the username.`);
93
+ }
94
+ } else {
95
+ console.log(`[i] Remote URL not changed. Use --update-remote to update automatically.`);
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ module.exports = {
102
+ configureGitUser
103
+ };
104
+ }
105
+ });
106
+
107
+ export {
108
+ require_user_config
109
+ };
@@ -0,0 +1,62 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ __commonJS,
4
+ __require,
5
+ init_esm_shims
6
+ } from "./chunk-QQ4A6DLD.mjs";
7
+
8
+ // src/submodule-remove.cjs
9
+ var require_submodule_remove = __commonJS({
10
+ "src/submodule-remove.cjs"(exports, module) {
11
+ init_esm_shims();
12
+ var { spawnAsync } = __require("cross-spawn");
13
+ var path = __require("upath");
14
+ var fs = __require("fs-extra");
15
+ var dotenv = __require("dotenv");
16
+ var envPath = path.resolve(process.cwd(), ".env");
17
+ if (fs.existsSync(envPath)) {
18
+ dotenv.config({ path: envPath, override: true, quiet: true });
19
+ }
20
+ async function removeSubmodule(submodulePath) {
21
+ try {
22
+ await spawnAsync("git", ["submodule", "deinit", "-f", submodulePath], { stdio: "inherit" });
23
+ } catch (error) {
24
+ console.warn(`Warning: Could not deinitialize submodule "${submodulePath}". It may not exist.`);
25
+ console.warn(error.message);
26
+ }
27
+ try {
28
+ await spawnAsync("git", ["config", "--remove-section", `submodule.${submodulePath}`], { stdio: "inherit" });
29
+ } catch (error) {
30
+ console.warn(`Warning: Could not remove git config section for submodule "${submodulePath}". It may not exist.`);
31
+ console.warn(error.message);
32
+ }
33
+ const gitModulesPath = path.resolve(".git", "modules", submodulePath);
34
+ if (fs.existsSync(gitModulesPath)) {
35
+ fs.rmSync(gitModulesPath, { recursive: true, force: true });
36
+ console.log(`Removed .git/modules entry for submodule "${submodulePath}".`);
37
+ } else {
38
+ console.warn(`Warning: The path "${gitModulesPath}" does not exist. Skipping removal of .git/modules entry.`);
39
+ }
40
+ const gitmodulesPath = path.resolve(".gitmodules");
41
+ if (fs.existsSync(gitmodulesPath)) {
42
+ let gitmodulesContent = fs.readFileSync(gitmodulesPath, "utf-8");
43
+ const submoduleSectionRegex = new RegExp(
44
+ `\\[submodule "${submodulePath.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}"]([\\s\\S]*?)(?=\\[|$)`,
45
+ "g"
46
+ );
47
+ gitmodulesContent = gitmodulesContent.replace(submoduleSectionRegex, "").trim();
48
+ fs.writeFileSync(gitmodulesPath, gitmodulesContent);
49
+ console.log(`Removed submodule "${submodulePath}" from .gitmodules.`);
50
+ } else {
51
+ console.warn(`Warning: The .gitmodules file does not exist. Skipping removal of submodule "${submodulePath}".`);
52
+ }
53
+ fs.rmSync(path.resolve(submodulePath), { recursive: true, force: true });
54
+ console.log(`Submodule "${submodulePath}" has been removed.`);
55
+ }
56
+ module.exports = removeSubmodule;
57
+ }
58
+ });
59
+
60
+ export {
61
+ require_submodule_remove
62
+ };
@@ -1,13 +1,13 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  runChatGpt
4
- } from "./chunk-GJTGHXRA.mjs";
4
+ } from "./chunk-N436BNBK.mjs";
5
5
  import {
6
6
  require_binary_collections_config
7
- } from "./chunk-66PAU5PS.mjs";
7
+ } from "./chunk-YYLIQQKF.mjs";
8
8
  import {
9
9
  require_utils
10
- } from "./chunk-V3N3JEUF.mjs";
10
+ } from "./chunk-Z6JLYU2J.mjs";
11
11
  import {
12
12
  __toESM,
13
13
  init_esm_shims
@@ -17,8 +17,8 @@ import {
17
17
  init_esm_shims();
18
18
  var import_binary_collections_config = __toESM(require_binary_collections_config(), 1);
19
19
  import { execSync } from "child_process";
20
- import fs from "fs";
21
- import path from "path";
20
+ import fs from "fs-extra";
21
+ import path from "upath";
22
22
  import { fileURLToPath } from "url";
23
23
  var import_utils = __toESM(require_utils(), 1);
24
24
  var __filename = fileURLToPath(import.meta.url);
@@ -117,13 +117,9 @@ async function mainGitDiff() {
117
117
  } catch (error) {
118
118
  console.error("\u274C Error running ChatGPT:", error.message);
119
119
  console.error("\u{1F4A1} Try running with visible browser mode or check if Chrome is installed");
120
- console.error(`\u{1F4C1} The diff has been saved to: ${DIFF_OUTPUT_RELATIVE}`);
121
- console.error(`\u{1F4C1} GPT prompt saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
122
120
  }
123
121
  } else {
124
122
  console.log("\u{1F4A1} Tip: Use --ai flag to generate commit message with ChatGPT");
125
- console.log(`\u{1F4C1} Diff saved to: ${DIFF_OUTPUT_RELATIVE}`);
126
- console.log(`\u{1F4C1} GPT prompt saved to: ${GPT_DIFF_OUTPUT_RELATIVE}`);
127
123
  }
128
124
  }
129
125
  var git_diff_default = runGitDiff;
@@ -0,0 +1,207 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ findEnvFiles
4
+ } from "./chunk-ID2WBTE2.mjs";
5
+ import {
6
+ require_utils
7
+ } from "./chunk-Z6JLYU2J.mjs";
8
+ import {
9
+ __toESM,
10
+ init_esm_shims
11
+ } from "./chunk-QQ4A6DLD.mjs";
12
+
13
+ // src/package-resolutions-updater.mjs
14
+ init_esm_shims();
15
+ var utils = __toESM(require_utils(), 1);
16
+ import * as dotenv from "dotenv";
17
+ import fs from "fs";
18
+ import https from "https";
19
+ import os from "os";
20
+ import path from "path";
21
+ var projectDir = process.cwd();
22
+ var envPath = path.join(projectDir, ".env");
23
+ var args = utils.getArgs();
24
+ if (!fs.existsSync(envPath)) {
25
+ const envFiles = findEnvFiles(projectDir, (file) => {
26
+ const content = fs.readFileSync(file, "utf-8");
27
+ return /GITHUB_TOKEN|ACCESS_TOKEN/.test(content);
28
+ });
29
+ if (envFiles.length > 0) {
30
+ envPath = envFiles[0];
31
+ }
32
+ }
33
+ if (fs.existsSync(envPath)) {
34
+ dotenv.config({ path: envPath, quiet: true, override: true });
35
+ }
36
+ var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
37
+ if (args.help || args.h) {
38
+ showHelp();
39
+ }
40
+ function showHelp() {
41
+ const helpText = `
42
+ GitHub Package Resolutions Updater
43
+ Usage:
44
+ node src/package-resolutions-updater.mjs [options]
45
+ Options:
46
+ --help, -h Show this help message
47
+ Description:
48
+ Updates the commit hashes in package.json's 'resolutions' field for GitHub tarball URLs to point to the latest commit SHA of the corresponding repository and branch.
49
+ Features:
50
+ - Parses GitHub URLs to extract repository owner, name, and branch.
51
+ - Fetches the latest commit SHA across all branches using GitHub's API.
52
+ - Replaces the old branch or commit in the URL with the latest SHA.
53
+ - Overwrites package.json with the updated URLs.
54
+ Requirements:
55
+ - GitHub Personal Access Token (GITHUB_TOKEN) via .env
56
+ - ESM support (type: "module" in package.json)
57
+ - Node.js v18+ recommended
58
+ Dependencies:
59
+ - ansi-colors \u2013 for styled terminal output
60
+ - dotenv \u2013 to load GitHub token from .env
61
+ Examples:
62
+ node src/package-resolutions-updater.mjs
63
+ node src/package-resolutions-updater.mjs --help
64
+
65
+ `;
66
+ console.log(helpText);
67
+ process.exit(0);
68
+ }
69
+ var GITHUB_USER_AGENTS = [
70
+ "octokit-rest.js/19.0.7",
71
+ "GitHub CLI/2.40.0",
72
+ "Mozilla/5.0 (compatible; GitHubCopilot/1.0)",
73
+ "PostmanRuntime/7.32.3",
74
+ "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
75
+ ];
76
+ var userAgentDir = path.join(os.tmpdir(), "nodejs");
77
+ var userAgentFile = path.join(userAgentDir, "useragent.txt");
78
+ var selectedUserAgent;
79
+ try {
80
+ if (!fs.existsSync(userAgentDir)) fs.mkdirSync(userAgentDir, { recursive: true });
81
+ if (fs.existsSync(userAgentFile)) {
82
+ const fileAgent = fs.readFileSync(userAgentFile, "utf-8").trim();
83
+ if (GITHUB_USER_AGENTS.includes(fileAgent)) {
84
+ selectedUserAgent = fileAgent;
85
+ }
86
+ }
87
+ if (!selectedUserAgent) {
88
+ selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
89
+ fs.writeFileSync(userAgentFile, selectedUserAgent, "utf-8");
90
+ }
91
+ } catch (_e) {
92
+ selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
93
+ }
94
+ function fetchJson(url) {
95
+ const headers = {
96
+ "User-Agent": selectedUserAgent,
97
+ Accept: "application/vnd.github.v3+json",
98
+ "X-GitHub-Api-Version": "2022-11-28",
99
+ ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
100
+ };
101
+ return new Promise((resolve, reject) => {
102
+ https.get(url, { headers }, (res) => {
103
+ let data = "";
104
+ res.on("data", (chunk) => data += chunk);
105
+ res.on("end", () => {
106
+ try {
107
+ const json = JSON.parse(data);
108
+ if (res.statusCode < 200 || res.statusCode >= 300) {
109
+ return reject(
110
+ new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
111
+ URL: ${url}`)
112
+ );
113
+ }
114
+ resolve(json);
115
+ } catch {
116
+ reject(new Error(`Invalid JSON from: ${url}`));
117
+ }
118
+ });
119
+ }).on("error", reject);
120
+ });
121
+ }
122
+ async function getLatestCommit(owner, repo, branch = "main") {
123
+ var _a, _b, _c, _d;
124
+ const url = `https://api.github.com/repos/${owner}/${repo}/commits/${branch}`;
125
+ const json = await fetchJson(url);
126
+ const sha = json.sha;
127
+ const dateStr = ((_b = (_a = json.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = json.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
128
+ if (!sha || !dateStr) {
129
+ console.log(json);
130
+ throw new Error(`Missing SHA or date for ${owner}/${repo}@${branch}`);
131
+ }
132
+ return {
133
+ owner,
134
+ repo,
135
+ branch,
136
+ sha,
137
+ date: new Date(dateStr).toISOString()
138
+ };
139
+ }
140
+ async function getLatestCommitAcrossBranches(owner, repo) {
141
+ const branches = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/branches`);
142
+ const commits = await Promise.all(
143
+ branches.map(async ({ name, commit }) => {
144
+ var _a, _b, _c, _d;
145
+ const commitSha = commit == null ? void 0 : commit.sha;
146
+ if (!commitSha) {
147
+ console.warn(`No commit SHA for '${owner}/${repo}' branch: ${name}`);
148
+ return { branch: name, sha: "", date: /* @__PURE__ */ new Date(0) };
149
+ }
150
+ try {
151
+ const commitData = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}`);
152
+ const dateStr = ((_b = (_a = commitData.commit) == null ? void 0 : _a.committer) == null ? void 0 : _b.date) || ((_d = (_c = commitData.commit) == null ? void 0 : _c.author) == null ? void 0 : _d.date);
153
+ const date = dateStr ? new Date(dateStr) : /* @__PURE__ */ new Date(0);
154
+ return { branch: name, sha: commitData.sha, date };
155
+ } catch (e) {
156
+ console.warn(`Failed to fetch commit for ${name}: ${e.message}`);
157
+ return { branch: name, sha: commitSha, date: /* @__PURE__ */ new Date(0) };
158
+ }
159
+ })
160
+ );
161
+ const latest = commits.reduce((a, b) => a.date > b.date ? a : b, { date: /* @__PURE__ */ new Date(0) });
162
+ return {
163
+ owner,
164
+ repo,
165
+ branch: latest.branch,
166
+ sha: latest.sha,
167
+ date: latest.date.toISOString()
168
+ };
169
+ }
170
+ function replaceRawWithLatestHash(url, latestHash) {
171
+ const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/(.+)$/);
172
+ if (!match) throw new Error("Invalid GitHub raw URL");
173
+ const [, owner, repo, _oldHash, path2] = match;
174
+ return `https://github.com/${owner}/${repo}/raw/${latestHash}/${path2}`;
175
+ }
176
+ function parseGitHubUrl(url) {
177
+ const ghRepoRoot = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/;
178
+ const ghTreeOrBlob = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/(tree|blob)\/([^/]+(?:\/[^/]+)*)/;
179
+ const ghRaw = /^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)(\/.+)?$/;
180
+ const ghDotComRaw = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/.+$/;
181
+ let match;
182
+ if (match = url.match(ghRaw)) {
183
+ const [, owner, repo, branch] = match;
184
+ return { owner, repo, branch, url };
185
+ }
186
+ if (match = url.match(ghDotComRaw)) {
187
+ const [, owner, repo, branch] = match;
188
+ return { owner, repo, branch, url };
189
+ }
190
+ if (match = url.match(ghTreeOrBlob)) {
191
+ const [, owner, repo, , branchPath] = match;
192
+ return { owner, repo, branch: branchPath, url };
193
+ }
194
+ if (match = url.match(ghRepoRoot)) {
195
+ const [, owner, repo] = match;
196
+ return { owner, repo, url };
197
+ }
198
+ throw new Error(`Unsupported GitHub URL: ${url}`);
199
+ }
200
+
201
+ export {
202
+ fetchJson,
203
+ getLatestCommit,
204
+ getLatestCommitAcrossBranches,
205
+ replaceRawWithLatestHash,
206
+ parseGitHubUrl
207
+ };
@@ -0,0 +1,80 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import {
3
+ init_esm_shims
4
+ } from "./chunk-QQ4A6DLD.mjs";
5
+
6
+ // src/utils/findEnvFiles.js
7
+ init_esm_shims();
8
+ import fs from "fs";
9
+ import path from "path";
10
+ import * as glob from "glob";
11
+ var DEFAULT_IGNORES = [
12
+ "**/node_modules/**",
13
+ "**/.git/**",
14
+ "**/.yarn/**",
15
+ "**/.pnpm/**",
16
+ "**/dist/**",
17
+ "**/build/**",
18
+ "**/coverage/**",
19
+ "**/vendor/**",
20
+ "**/tmp/**",
21
+ "**/.cache/**",
22
+ "**/assets/**",
23
+ "**/logs/**",
24
+ "**/output/**",
25
+ "**/public/**",
26
+ "**/static/**",
27
+ "**/temp/**",
28
+ "**/backup/**",
29
+ "**/backups/**",
30
+ "**/examples/**",
31
+ "**/docs/**",
32
+ "**/tests/**",
33
+ "**/__tests__/**",
34
+ "**/spec/**",
35
+ "**/__specs__/**",
36
+ "**/scripts/**",
37
+ "**/bin/**",
38
+ "**/hooks/**",
39
+ "**/config/**",
40
+ "**/configs/**",
41
+ "**/settings/**",
42
+ "**/.vscode/**",
43
+ "**/.idea/**"
44
+ ];
45
+ function findEnvFiles(startDir = process.cwd(), filter) {
46
+ const found = /* @__PURE__ */ new Set();
47
+ function addFile(file) {
48
+ const normalized = path.normalize(file);
49
+ if (typeof filter === "function" && !filter(normalized)) {
50
+ return;
51
+ }
52
+ found.add(normalized);
53
+ }
54
+ let current = path.resolve(startDir);
55
+ while (true) {
56
+ const envPath = path.join(current, ".env");
57
+ if (fs.existsSync(envPath)) {
58
+ addFile(envPath);
59
+ }
60
+ const parent = path.dirname(current);
61
+ if (parent === current) {
62
+ break;
63
+ }
64
+ current = parent;
65
+ }
66
+ const files = glob.globSync("**/.env*", {
67
+ cwd: startDir,
68
+ absolute: true,
69
+ nodir: true,
70
+ ignore: DEFAULT_IGNORES
71
+ });
72
+ for (const file of files) {
73
+ addFile(file);
74
+ }
75
+ return [...found];
76
+ }
77
+
78
+ export {
79
+ findEnvFiles
80
+ };