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
@@ -1,296 +1,18 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
- require_utils
4
- } from "./chunk-V3N3JEUF.mjs";
5
- import {
6
- __toESM,
7
- init_esm_shims
8
- } from "./chunk-QQ4A6DLD.mjs";
9
-
10
- // src/package-resolutions-updater.mjs
11
- init_esm_shims();
12
- var utils = __toESM(require_utils(), 1);
13
- import ansiColors from "ansi-colors";
14
- import * as dotenv from "dotenv";
15
- import fs from "fs";
16
- import https from "https";
17
- import os from "os";
18
- import path from "path";
19
- var projectDir = process.cwd();
20
- var envPath = path.join(projectDir, ".env");
21
- var args = utils.getArgs();
22
- if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
23
- var ACCESS_TOKEN = process.env.GITHUB_TOKEN || process.env.ACCESS_TOKEN;
24
- if (args.help || args.h) {
25
- showHelp();
26
- }
27
- function showHelp() {
28
- const helpText = `
29
- GitHub Package Resolutions Updater
30
- Usage:
31
- node src/package-resolutions-updater.mjs [options]
32
- Options:
33
- --help, -h Show this help message
34
- Description:
35
- 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.
36
- Features:
37
- - Parses GitHub URLs to extract repository owner, name, and branch.
38
- - Fetches the latest commit SHA across all branches using GitHub's API.
39
- - Replaces the old branch or commit in the URL with the latest SHA.
40
- - Overwrites package.json with the updated URLs.
41
- Requirements:
42
- - GitHub Personal Access Token (GITHUB_TOKEN) via .env
43
- - ESM support (type: "module" in package.json)
44
- - Node.js v18+ recommended
45
- Dependencies:
46
- - ansi-colors \u2013 for styled terminal output
47
- - dotenv \u2013 to load GitHub token from .env
48
- Examples:
49
- node src/package-resolutions-updater.mjs
50
- node src/package-resolutions-updater.mjs --help
51
-
52
- `;
53
- console.log(helpText);
54
- process.exit(0);
55
- }
56
- var specialPackageOverrides = [
57
- // SBG packages
58
- { pkg: "sbg-utility", branch: "sbg-utility", repo: "static-blog-generator", owner: "dimaslanjaka" },
59
- { pkg: "sbg-api", branch: "sbg-api", repo: "static-blog-generator", owner: "dimaslanjaka" },
60
- { pkg: "instant-indexing", branch: "instant-indexing", repo: "static-blog-generator", owner: "dimaslanjaka" },
61
- { pkg: "sbg-server", branch: "master", repo: "static-blog-generator", owner: "dimaslanjaka" },
62
- { pkg: "sbg-cli", branch: "master", repo: "static-blog-generator", owner: "dimaslanjaka" },
63
- { pkg: "static-blog-generator", branch: "master", repo: "static-blog-generator", owner: "dimaslanjaka" },
64
- // Hexo family
65
- { pkg: "hexo", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
66
- { pkg: "hexo-util", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
67
- { pkg: "warehouse", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
68
- { pkg: "hexo-server", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
69
- { pkg: "hexo-log", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
70
- { pkg: "hexo-front-matter", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
71
- { pkg: "hexo-cli", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
72
- { pkg: "hexo-asset-link", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
73
- { pkg: "hexo-post-parser", branch: "pre-release", repo: "hexo-post-parser", owner: "dimaslanjaka" },
74
- { pkg: "hexo-seo", branch: "pre-release", repo: "hexo-seo", owner: "dimaslanjaka" },
75
- { pkg: "hexo-is", branch: "master", repo: "hexo-is", owner: "dimaslanjaka" },
76
- { pkg: "markdown-it", branch: "master", repo: "markdown-it", owner: "dimaslanjaka" },
77
- { pkg: "hexo-renderers", branch: "pre-release", repo: "hexo-renderers", owner: "dimaslanjaka" },
78
- { pkg: "hexo-shortcodes", branch: "pre-release", repo: "hexo-shortcodes", owner: "dimaslanjaka" },
79
- { pkg: "google-news-sitemap", branch: "master", repo: "google-news-sitemap", owner: "dimaslanjaka" },
80
- { pkg: "git-command-helper", branch: "pre-release", repo: "git-command-helper", owner: "dimaslanjaka" },
81
- {
82
- pkg: "nodejs-package-types",
83
- branch: "main",
84
- repo: "nodejs-package-types",
85
- owner: "dimaslanjaka"
86
- },
87
- { pkg: "cross-spawn", branch: "private", repo: "node-cross-spawn", owner: "dimaslanjaka" },
88
- { pkg: "hexo-generator-redirect", branch: "master", repo: "hexo-generator-redirect", owner: "dimaslanjaka" },
89
- { pkg: "binary-collections", branch: "master", repo: "bin", owner: "dimaslanjaka" },
90
- { pkg: "@types/hexo", branch: "monorepo-v7", repo: "hexo", owner: "dimaslanjaka" },
91
- { pkg: "@types/git-command-helper", branch: "pre-release", repo: "git-command-helper", owner: "dimaslanjaka" }
92
- ];
93
- var pkgPath = path.join(process.cwd(), "package.json");
94
- var pkg;
95
- try {
96
- pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
97
- } catch (e) {
98
- console.error(ansiColors.red(`Failed to read package.json: ${e.message}`));
99
- process.exit(1);
100
- }
101
- var GITHUB_USER_AGENTS = [
102
- "octokit-rest.js/19.0.7",
103
- "GitHub CLI/2.40.0",
104
- "Mozilla/5.0 (compatible; GitHubCopilot/1.0)",
105
- "PostmanRuntime/7.32.3",
106
- "binary-collections-resolver/1.0 (+https://github.com/dimaslanjaka/bin)"
107
- ];
108
- var userAgentDir = path.join(os.tmpdir(), "nodejs");
109
- var userAgentFile = path.join(userAgentDir, "useragent.txt");
110
- var selectedUserAgent;
111
- try {
112
- if (!fs.existsSync(userAgentDir)) fs.mkdirSync(userAgentDir, { recursive: true });
113
- if (fs.existsSync(userAgentFile)) {
114
- const fileAgent = fs.readFileSync(userAgentFile, "utf-8").trim();
115
- if (GITHUB_USER_AGENTS.includes(fileAgent)) {
116
- selectedUserAgent = fileAgent;
117
- }
118
- }
119
- if (!selectedUserAgent) {
120
- selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
121
- fs.writeFileSync(userAgentFile, selectedUserAgent, "utf-8");
122
- }
123
- } catch (_e) {
124
- selectedUserAgent = GITHUB_USER_AGENTS[Math.floor(Math.random() * GITHUB_USER_AGENTS.length)];
125
- }
126
- function fetchJson(url) {
127
- const headers = {
128
- "User-Agent": selectedUserAgent,
129
- Accept: "application/vnd.github.v3+json",
130
- "X-GitHub-Api-Version": "2022-11-28",
131
- ...ACCESS_TOKEN ? { Authorization: `token ${ACCESS_TOKEN}` } : {}
132
- };
133
- return new Promise((resolve, reject) => {
134
- https.get(url, { headers }, (res) => {
135
- let data = "";
136
- res.on("data", (chunk) => data += chunk);
137
- res.on("end", () => {
138
- try {
139
- const json = JSON.parse(data);
140
- if (res.statusCode < 200 || res.statusCode >= 300) {
141
- return reject(
142
- new Error(`GitHub API Error ${res.statusCode}: ${json.message || "Unknown error"}
143
- URL: ${url}`)
144
- );
145
- }
146
- resolve(json);
147
- } catch {
148
- reject(new Error(`Invalid JSON from: ${url}`));
149
- }
150
- });
151
- }).on("error", reject);
152
- });
153
- }
154
- async function getLatestCommit(owner, repo, branch = "main") {
155
- var _a, _b, _c, _d;
156
- const url = `https://api.github.com/repos/${owner}/${repo}/commits/${branch}`;
157
- const json = await fetchJson(url);
158
- const sha = json.sha;
159
- 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);
160
- if (!sha || !dateStr) {
161
- console.log(json);
162
- throw new Error(`Missing SHA or date for ${owner}/${repo}@${branch}`);
163
- }
164
- return {
165
- owner,
166
- repo,
167
- branch,
168
- sha,
169
- date: new Date(dateStr).toISOString()
170
- };
171
- }
172
- async function getLatestCommitAcrossBranches(owner, repo) {
173
- const branches = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/branches`);
174
- const commits = await Promise.all(
175
- branches.map(async ({ name, commit }) => {
176
- var _a, _b, _c, _d;
177
- const commitSha = commit == null ? void 0 : commit.sha;
178
- if (!commitSha) {
179
- console.warn(`No commit SHA for '${owner}/${repo}' branch: ${name}`);
180
- return { branch: name, sha: "", date: /* @__PURE__ */ new Date(0) };
181
- }
182
- try {
183
- const commitData = await fetchJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}`);
184
- 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);
185
- const date = dateStr ? new Date(dateStr) : /* @__PURE__ */ new Date(0);
186
- return { branch: name, sha: commitData.sha, date };
187
- } catch (e) {
188
- console.warn(`Failed to fetch commit for ${name}: ${e.message}`);
189
- return { branch: name, sha: commitSha, date: /* @__PURE__ */ new Date(0) };
190
- }
191
- })
192
- );
193
- const latest = commits.reduce((a, b) => a.date > b.date ? a : b, { date: /* @__PURE__ */ new Date(0) });
194
- return {
195
- owner,
196
- repo,
197
- branch: latest.branch,
198
- sha: latest.sha,
199
- date: latest.date.toISOString()
200
- };
201
- }
202
- function replaceRawWithLatestHash(url, latestHash) {
203
- const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/(.+)$/);
204
- if (!match) throw new Error("Invalid GitHub raw URL");
205
- const [, owner, repo, _oldHash, path2] = match;
206
- return `https://github.com/${owner}/${repo}/raw/${latestHash}/${path2}`;
207
- }
208
- function parseGitHubUrl(url) {
209
- const ghRepoRoot = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/;
210
- const ghTreeOrBlob = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/(tree|blob)\/([^/]+(?:\/[^/]+)*)/;
211
- const ghRaw = /^https:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/([^/]+)(\/.+)?$/;
212
- const ghDotComRaw = /^https:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/([^/]+)\/.+/;
213
- let match;
214
- if (match = url.match(ghRaw)) {
215
- const [, owner, repo, branch] = match;
216
- return { owner, repo, branch, url };
217
- }
218
- if (match = url.match(ghDotComRaw)) {
219
- const [, owner, repo, branch] = match;
220
- return { owner, repo, branch, url };
221
- }
222
- if (match = url.match(ghTreeOrBlob)) {
223
- const [, owner, repo, , branchPath] = match;
224
- return { owner, repo, branch: branchPath, url };
225
- }
226
- if (match = url.match(ghRepoRoot)) {
227
- const [, owner, repo] = match;
228
- return { owner, repo, url };
229
- }
230
- throw new Error(`Unsupported GitHub URL: ${url}`);
231
- }
232
- (async () => {
233
- const entries = Object.entries(pkg.resolutions || {});
234
- if (entries.length === 0) {
235
- console.log(ansiColors.yellow("No resolutions found in package.json"));
236
- return;
237
- }
238
- console.log(`Processing ${entries.length} resolution(s)...`);
239
- const updates = [];
240
- for (const [currentPkgName, url] of entries) {
241
- let repo;
242
- try {
243
- repo = parseGitHubUrl(url);
244
- console.log(`\u2705 Valid GitHub URL for ${ansiColors.cyan(currentPkgName)}: ${url}`);
245
- } catch (error) {
246
- console.log(`\u23ED\uFE0F Skipping ${ansiColors.yellow(currentPkgName)}: ${error.message}`);
247
- continue;
248
- }
249
- try {
250
- const override = specialPackageOverrides.find((p) => p.pkg === currentPkgName);
251
- const latest = override ? await getLatestCommit(override.owner, override.repo, override.branch) : await getLatestCommitAcrossBranches(repo.owner, repo.repo);
252
- const new_url = replaceRawWithLatestHash(url, latest.sha);
253
- updates.push({
254
- currentPkgName,
255
- url,
256
- new_url,
257
- repo,
258
- latest
259
- });
260
- } catch (error) {
261
- console.log(`\u274C Failed to process ${ansiColors.red(currentPkgName)}: ${error.message}`);
262
- }
263
- }
264
- if (updates.length === 0) {
265
- console.log(ansiColors.yellow("No GitHub URLs were processed"));
266
- return;
267
- }
268
- console.log(`
269
- \u{1F4DD} Applying updates to ${updates.length} GitHub URL(s)...`);
270
- let changed = false;
271
- for (const { currentPkgName, url, new_url, repo, latest } of updates) {
272
- if (url !== new_url) {
273
- console.log(`
274
- ${ansiColors.cyan(currentPkgName)}:`);
275
- console.log(" from:", url.replace(repo.branch, ansiColors.red(repo.branch)));
276
- console.log(" to:", new_url.replace(latest.sha, ansiColors.green(latest.sha)));
277
- pkg.resolutions[currentPkgName] = new_url;
278
- changed = true;
279
- } else {
280
- console.log(`
281
- ${ansiColors.cyan(currentPkgName)}: ${ansiColors.gray("already up-to-date")}`);
282
- }
283
- }
284
- if (changed) {
285
- try {
286
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
287
- console.log(`
288
- \u2705 package.json updated successfully`);
289
- } catch (e) {
290
- console.error(ansiColors.red(`Failed to write package.json: ${e.message}`));
291
- process.exit(1);
292
- }
293
- } else {
294
- console.log(ansiColors.green("No changes to package.json were necessary."));
295
- }
296
- })();
3
+ fetchJson,
4
+ getLatestCommit,
5
+ getLatestCommitAcrossBranches,
6
+ parseGitHubUrl,
7
+ replaceRawWithLatestHash
8
+ } from "./chunk-XA3SNBPA.mjs";
9
+ import "./chunk-ID2WBTE2.mjs";
10
+ import "./chunk-Z6JLYU2J.mjs";
11
+ import "./chunk-QQ4A6DLD.mjs";
12
+ export {
13
+ fetchJson,
14
+ getLatestCommit,
15
+ getLatestCommitAcrossBranches,
16
+ parseGitHubUrl,
17
+ replaceRawWithLatestHash
18
+ };
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ // src/php-cs-fixer-staged.cjs
3
+ var { exec } = require("child_process");
4
+ var { spawn, spawnSync } = require("child_process");
5
+ var util = require("util");
6
+ var fs = require("fs");
7
+ var path = require("path");
8
+ var execP = util.promisify(exec);
9
+ function log(...args) {
10
+ console.log("[php-cs-fixer-staged]", ...args);
11
+ }
12
+ function isPathLike(p) {
13
+ return p.includes("/") || p.includes("\\\\") || p.includes(path.sep);
14
+ }
15
+ async function findPhpCsFixer() {
16
+ const candidates = ["php-cs-fixer", "vendor/bin/php-cs-fixer", "bin/php-cs-fixer", "tools/php-cs-fixer"];
17
+ for (const c of candidates) {
18
+ try {
19
+ let cmd;
20
+ let args;
21
+ if (isPathLike(c)) {
22
+ const resolved = path.resolve(process.cwd(), c);
23
+ if (!fs.existsSync(resolved)) continue;
24
+ if (process.platform === "win32") {
25
+ cmd = "php";
26
+ args = [resolved, "--version"];
27
+ } else {
28
+ cmd = resolved;
29
+ args = ["--version"];
30
+ }
31
+ } else {
32
+ cmd = c;
33
+ args = ["--version"];
34
+ }
35
+ const res = spawnSync(cmd, args, { encoding: "utf8" });
36
+ if (res && res.status === 0) return c;
37
+ } catch (_e) {
38
+ }
39
+ }
40
+ try {
41
+ const phar = path.resolve(process.cwd(), "php-cs-fixer.phar");
42
+ if (fs.existsSync(phar)) return phar;
43
+ } catch (_e) {
44
+ }
45
+ return null;
46
+ }
47
+ async function getStagedPhpFiles() {
48
+ try {
49
+ const { stdout } = await execP("git diff --name-only --cached --diff-filter=ACM");
50
+ return stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).filter((f) => f.toLowerCase().endsWith(".php"));
51
+ } catch (err) {
52
+ throw new Error("Failed to get staged files: " + err.message);
53
+ }
54
+ }
55
+ async function run() {
56
+ const files = await getStagedPhpFiles();
57
+ if (!files.length) {
58
+ log("No staged PHP files found. Nothing to do.");
59
+ return 0;
60
+ }
61
+ const bin = await findPhpCsFixer();
62
+ if (!bin) {
63
+ console.error("php-cs-fixer binary not found in PATH or common locations.");
64
+ console.error("Install php-cs-fixer or add it to PATH, or place it in vendor/bin/.");
65
+ return 2;
66
+ }
67
+ log("Running", bin, "on", files.length, "file(s)");
68
+ return new Promise((resolve) => {
69
+ let cmd;
70
+ let args;
71
+ if (isPathLike(bin)) {
72
+ const resolved = path.resolve(process.cwd(), bin);
73
+ if (process.platform === "win32") {
74
+ cmd = "php";
75
+ args = [resolved, "fix", ...files];
76
+ } else {
77
+ cmd = resolved;
78
+ args = ["fix", ...files];
79
+ }
80
+ } else {
81
+ cmd = bin;
82
+ args = ["fix", ...files];
83
+ }
84
+ const child = spawn(cmd, args, { stdio: "inherit", shell: false });
85
+ child.on("close", (code) => {
86
+ if (code === 0) {
87
+ log("php-cs-fixer completed successfully.");
88
+ } else {
89
+ console.error("php-cs-fixer exited with code", code);
90
+ }
91
+ resolve(code);
92
+ });
93
+ child.on("error", (err) => {
94
+ console.error("Failed to run php-cs-fixer:", err.message);
95
+ resolve(3);
96
+ });
97
+ });
98
+ }
99
+ if (require.main === module) {
100
+ run().then((code) => process.exit(code)).catch((err) => {
101
+ console.error(err);
102
+ process.exit(4);
103
+ });
104
+ }
105
+ module.exports = { run, getStagedPhpFiles };
@@ -0,0 +1,2 @@
1
+ export function run(): Promise<any>;
2
+ export function getStagedPhpFiles(): Promise<string[]>;
@@ -0,0 +1,117 @@
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/php-cs-fixer-staged.cjs
9
+ var require_php_cs_fixer_staged = __commonJS({
10
+ "src/php-cs-fixer-staged.cjs"(exports, module) {
11
+ init_esm_shims();
12
+ var { exec } = __require("child_process");
13
+ var { spawn, spawnSync } = __require("child_process");
14
+ var util = __require("util");
15
+ var fs = __require("fs");
16
+ var path = __require("path");
17
+ var execP = util.promisify(exec);
18
+ function log(...args) {
19
+ console.log("[php-cs-fixer-staged]", ...args);
20
+ }
21
+ function isPathLike(p) {
22
+ return p.includes("/") || p.includes("\\\\") || p.includes(path.sep);
23
+ }
24
+ async function findPhpCsFixer() {
25
+ const candidates = ["php-cs-fixer", "vendor/bin/php-cs-fixer", "bin/php-cs-fixer", "tools/php-cs-fixer"];
26
+ for (const c of candidates) {
27
+ try {
28
+ let cmd;
29
+ let args;
30
+ if (isPathLike(c)) {
31
+ const resolved = path.resolve(process.cwd(), c);
32
+ if (!fs.existsSync(resolved)) continue;
33
+ if (process.platform === "win32") {
34
+ cmd = "php";
35
+ args = [resolved, "--version"];
36
+ } else {
37
+ cmd = resolved;
38
+ args = ["--version"];
39
+ }
40
+ } else {
41
+ cmd = c;
42
+ args = ["--version"];
43
+ }
44
+ const res = spawnSync(cmd, args, { encoding: "utf8" });
45
+ if (res && res.status === 0) return c;
46
+ } catch (_e) {
47
+ }
48
+ }
49
+ try {
50
+ const phar = path.resolve(process.cwd(), "php-cs-fixer.phar");
51
+ if (fs.existsSync(phar)) return phar;
52
+ } catch (_e) {
53
+ }
54
+ return null;
55
+ }
56
+ async function getStagedPhpFiles() {
57
+ try {
58
+ const { stdout } = await execP("git diff --name-only --cached --diff-filter=ACM");
59
+ return stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).filter((f) => f.toLowerCase().endsWith(".php"));
60
+ } catch (err) {
61
+ throw new Error("Failed to get staged files: " + err.message);
62
+ }
63
+ }
64
+ async function run() {
65
+ const files = await getStagedPhpFiles();
66
+ if (!files.length) {
67
+ log("No staged PHP files found. Nothing to do.");
68
+ return 0;
69
+ }
70
+ const bin = await findPhpCsFixer();
71
+ if (!bin) {
72
+ console.error("php-cs-fixer binary not found in PATH or common locations.");
73
+ console.error("Install php-cs-fixer or add it to PATH, or place it in vendor/bin/.");
74
+ return 2;
75
+ }
76
+ log("Running", bin, "on", files.length, "file(s)");
77
+ return new Promise((resolve) => {
78
+ let cmd;
79
+ let args;
80
+ if (isPathLike(bin)) {
81
+ const resolved = path.resolve(process.cwd(), bin);
82
+ if (process.platform === "win32") {
83
+ cmd = "php";
84
+ args = [resolved, "fix", ...files];
85
+ } else {
86
+ cmd = resolved;
87
+ args = ["fix", ...files];
88
+ }
89
+ } else {
90
+ cmd = bin;
91
+ args = ["fix", ...files];
92
+ }
93
+ const child = spawn(cmd, args, { stdio: "inherit", shell: false });
94
+ child.on("close", (code) => {
95
+ if (code === 0) {
96
+ log("php-cs-fixer completed successfully.");
97
+ } else {
98
+ console.error("php-cs-fixer exited with code", code);
99
+ }
100
+ resolve(code);
101
+ });
102
+ child.on("error", (err) => {
103
+ console.error("Failed to run php-cs-fixer:", err.message);
104
+ resolve(3);
105
+ });
106
+ });
107
+ }
108
+ if (__require.main === module) {
109
+ run().then((code) => process.exit(code)).catch((err) => {
110
+ console.error(err);
111
+ process.exit(4);
112
+ });
113
+ }
114
+ module.exports = { run, getStagedPhpFiles };
115
+ }
116
+ });
117
+ export default require_php_cs_fixer_staged();
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
3
  var __esm = (fn, res) => function __init() {
3
4
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
@@ -67,31 +68,78 @@ var require_utils = __commonJS({
67
68
  }
68
69
  module2.exports.getArgs = getArgs2;
69
70
  function del(fullPath) {
70
- if (fs2.statSync(fullPath).isDirectory()) {
71
- const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
72
- for (let i = 0; i < subdir.length; i++) {
73
- del(subdir[i]);
71
+ try {
72
+ if (!fs2.existsSync(fullPath)) return;
73
+ const stat = fs2.lstatSync(fullPath);
74
+ if (stat.isSymbolicLink()) {
75
+ try {
76
+ fs2.unlinkSync(fullPath);
77
+ console.log("deleted symlink", fullPath);
78
+ } catch (e) {
79
+ console.log("failed delete symlink", fullPath, e && e.message);
80
+ }
81
+ return;
82
+ }
83
+ if (stat.isDirectory()) {
84
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
85
+ for (let i = 0; i < subdir.length; i++) {
86
+ del(subdir[i]);
87
+ }
88
+ try {
89
+ fs2.rmdirSync(fullPath);
90
+ console.log("deleted", fullPath);
91
+ } catch (e) {
92
+ try {
93
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
94
+ console.log("deleted", fullPath);
95
+ } catch (ee) {
96
+ console.log("failed delete", fullPath, ee && ee.message);
97
+ }
98
+ }
99
+ return;
74
100
  }
75
- } else {
76
101
  try {
77
- fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
102
+ fs2.unlinkSync(fullPath);
78
103
  console.log("deleted", fullPath);
79
- } catch (_) {
80
- console.log("failed delete", fullPath);
104
+ } catch (e) {
105
+ try {
106
+ fs2.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
107
+ console.log("deleted", fullPath);
108
+ } catch (ee) {
109
+ console.log("failed delete", fullPath, ee && ee.message);
110
+ }
81
111
  }
112
+ } catch (err) {
113
+ console.log("failed delete", fullPath, err && err.message);
82
114
  }
83
115
  }
84
116
  module2.exports.del = del;
85
117
  function delStream(globStream) {
86
118
  globStream.stream().on("data", (result) => {
87
119
  const fullPath = path2.resolve(process.cwd(), result);
88
- if (fs2.statSync(fullPath).isDirectory()) {
89
- const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
90
- for (let i = 0; i < subdir.length; i++) {
91
- del(subdir[i]);
120
+ try {
121
+ if (fs2.existsSync(fullPath)) {
122
+ const stat = fs2.lstatSync(fullPath);
123
+ if (stat.isSymbolicLink()) {
124
+ try {
125
+ fs2.unlinkSync(fullPath);
126
+ console.log("deleted symlink", fullPath);
127
+ } catch (e) {
128
+ console.log("failed delete symlink", fullPath, e && e.message);
129
+ }
130
+ return;
131
+ }
132
+ if (stat.isDirectory()) {
133
+ const subdir = fs2.readdirSync(fullPath).map((dirPath) => path2.resolve(fullPath, dirPath));
134
+ for (let i = 0; i < subdir.length; i++) {
135
+ del(subdir[i]);
136
+ }
137
+ }
92
138
  }
139
+ del(fullPath);
140
+ } catch (err) {
141
+ console.log("failed processing", fullPath, err && err.message);
93
142
  }
94
- del(fullPath);
95
143
  });
96
144
  }
97
145
  module2.exports.delStream = delStream;
@@ -149,7 +197,7 @@ var sbgUtil = require("sbg-utility");
149
197
  var dotenv = require("dotenv");
150
198
  var projectDir = process.cwd();
151
199
  var envPath = path.join(projectDir, ".env");
152
- if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
200
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath, quiet: true, override: true });
153
201
  var argv = getArgs();
154
202
  async function main() {
155
203
  let relativeOutputFile = "tmp/directory-structure.txt";
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_utils
4
- } from "./chunk-V3N3JEUF.mjs";
4
+ } from "./chunk-Z6JLYU2J.mjs";
5
5
  import {
6
6
  __commonJS,
7
7
  __require,
@@ -22,7 +22,7 @@ var require_print_directory_tree = __commonJS({
22
22
  var dotenv = __require("dotenv");
23
23
  var projectDir = process.cwd();
24
24
  var envPath = path.join(projectDir, ".env");
25
- if (fs.existsSync(envPath)) dotenv.config({ path: envPath });
25
+ if (fs.existsSync(envPath)) dotenv.config({ path: envPath, quiet: true, override: true });
26
26
  var argv = getArgs();
27
27
  async function main() {
28
28
  let relativeOutputFile = "tmp/directory-structure.txt";
@@ -7,4 +7,4 @@
7
7
  * @param {Boolean} hardlink If use hard link. Default to false.
8
8
  * @return {Object} [{ bounding: { w: 12, h: 19, x: 0, y: 1 }, points: [ { x: 1, y: 2, point: {} } ], identifier: 'blue', domainId: 1 } ]
9
9
  */
10
- export default function _default(tdArray: any[], indicator: Function, hardlink: boolean): any;
10
+ export default function _default(tdArray: any[], indicator: Function, hardlink: boolean): Object;
package/lib/ps/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var ChildProcess = require("child_process");
2
3
  var IS_WIN = require("./isWin").default;
3
4
  var TableParser = require("./table-parser");