binary-collections 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/package.json +5 -0
- package/binaries/rmx +15 -1
- package/binaries/rmx.cmd +12 -0
- package/binaries/test-cjs +9 -1
- package/binaries/test-cjs.cmd +16 -1
- package/binaries/test-esm +16 -0
- package/binaries/test-esm.cjs +178 -0
- package/binaries/test-esm.cmd +23 -0
- package/binaries/yarn-clean +1 -1
- package/binaries/yarn-clean.cmd +1 -1
- package/binaries/yarn-clean.py +33 -15
- package/binaries/yc +110 -0
- package/binaries/yc.cjs +178 -0
- package/lib/binary-collections/config.cjs +126 -0
- package/lib/binary-collections/config.mjs +7 -0
- package/lib/binary-collections/executeScript.cjs +19 -0
- package/lib/binary-collections/executeScript.d.cts +12 -0
- package/lib/binary-collections/executeScript.mjs +6 -0
- package/lib/binary-collections/findScript.cjs +284 -0
- package/lib/binary-collections/findScript.d.cts +12 -0
- package/lib/binary-collections/findScript.mjs +7 -0
- package/lib/binary-collections/listScript.cjs +266 -0
- package/lib/binary-collections/listScript.d.cts +19 -0
- package/lib/binary-collections/listScript.mjs +7 -0
- package/lib/binary-collections.cjs +224 -137
- package/lib/binary-collections.mjs +22 -282
- package/lib/changelog.cjs +2 -2
- package/lib/changelog.mjs +1 -1
- package/lib/{chunk-AJDD5DZM.mjs → chunk-2LSRSEXF.mjs} +1 -1
- package/lib/{chunk-Z6JLYU2J.mjs → chunk-5RTXZVCW.mjs} +2 -2
- package/lib/{chunk-XA3SNBPA.mjs → chunk-66KDU4TX.mjs} +93 -9
- package/lib/chunk-6PU7BAHB.mjs +61 -0
- package/lib/chunk-C6D2TTYU.mjs +32 -0
- package/lib/chunk-FB2WKVJD.mjs +158 -0
- package/lib/{chunk-NCXAP7AA.mjs → chunk-G5UUEWUO.mjs} +9 -5
- package/lib/{chunk-N436BNBK.mjs → chunk-GAGABICI.mjs} +19 -13
- package/lib/chunk-H44UWUFY.mjs +105 -0
- package/lib/chunk-NCZPTKDV.mjs +79 -0
- package/lib/chunk-NGFK3EYW.mjs +28 -0
- package/lib/chunk-NVEG3LEZ.mjs +143 -0
- package/lib/chunk-OGXVGBRI.mjs +29 -0
- package/lib/chunk-OXV52GD5.mjs +62 -0
- package/lib/chunk-PXBMHE7O.mjs +35 -0
- package/lib/chunk-R5FJOR63.mjs +47 -0
- package/lib/chunk-SPTECFE5.mjs +180 -0
- package/lib/chunk-UXCFNAR6.mjs +55 -0
- package/lib/chunk-V2IBPCEV.mjs +39 -0
- package/lib/chunk-XPJGCDOD.mjs +14 -0
- package/lib/chunk-ZOWVMII3.mjs +228 -0
- package/lib/clean-github-actions-caches-cli.cjs +465 -0
- package/lib/clean-github-actions-caches-cli.d.cts +1 -0
- package/lib/clean-github-actions-caches-cli.mjs +56 -0
- package/lib/clean-github-actions-caches.cjs +149 -205
- package/lib/clean-github-actions-caches.d.cts +15 -1
- package/lib/clean-github-actions-caches.mjs +4 -130
- package/lib/cross-env/command.cjs +63 -0
- package/lib/cross-env/command.d.ts +8 -0
- package/lib/cross-env/command.js +45 -0
- package/lib/cross-env/command.mjs +9 -0
- package/lib/cross-env/index.cjs +178 -0
- package/lib/cross-env/index.d.ts +8 -0
- package/lib/cross-env/index.js +102 -0
- package/lib/cross-env/index.mjs +101 -0
- package/lib/cross-env/variable.cjs +60 -0
- package/lib/cross-env/variable.d.ts +7 -0
- package/lib/cross-env/variable.js +59 -0
- package/lib/cross-env/variable.mjs +9 -0
- package/lib/del-gradle.cjs +2 -2
- package/lib/del-gradle.js +8 -8
- package/lib/del-gradle.mjs +1 -1
- package/lib/del-node-modules.js +24 -24
- package/lib/del-ps.cjs +2 -2
- package/lib/del-ps.js +8 -8
- package/lib/del-ps.mjs +1 -1
- package/lib/del-yarn-caches.cjs +2 -2
- package/lib/del-yarn-caches.js +2 -2
- package/lib/del-yarn-caches.mjs +1 -1
- package/lib/file/copy-cli.cjs +92 -0
- package/lib/file/copy-cli.d.mts +1 -0
- package/lib/file/copy-cli.mjs +55 -0
- package/lib/file/copy.cjs +56 -0
- package/lib/file/copy.d.mts +1 -0
- package/lib/file/copy.mjs +8 -0
- package/lib/file/move-cli.cjs +91 -0
- package/lib/file/move-cli.d.mts +1 -0
- package/lib/file/move-cli.mjs +55 -0
- package/lib/file/move.cjs +55 -0
- package/lib/file/move.d.mts +1 -0
- package/lib/file/move.mjs +8 -0
- package/lib/find-node-modules-cli.js +1 -1
- package/lib/free-chatgpt.cjs +21 -15
- package/lib/free-chatgpt.js +10 -10
- package/lib/free-chatgpt.mjs +2 -2
- package/lib/git/user-config.cjs +2 -2
- package/lib/git/user-config.mjs +2 -2
- package/lib/git-diff-cli.cjs +188 -42
- package/lib/git-diff-cli.mjs +5 -4
- package/lib/git-diff.cjs +188 -42
- package/lib/git-diff.d.ts +2 -1
- package/lib/git-diff.js +91 -34
- package/lib/git-diff.mjs +5 -4
- package/lib/git-fix.cjs +2 -2
- package/lib/git-fix.mjs +2 -2
- package/lib/git-purge.cjs +2 -2
- package/lib/git-purge.mjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/kill-night-crows.cjs +7 -7
- package/lib/kill-night-crows.mjs +7 -7
- package/lib/node-cache-cleaner/npm.cjs +65 -0
- package/lib/node-cache-cleaner/npm.d.ts +2 -0
- package/lib/node-cache-cleaner/npm.js +41 -0
- package/lib/node-cache-cleaner/npm.mjs +10 -0
- package/lib/node-cache-cleaner/npx.cjs +89 -0
- package/lib/node-cache-cleaner/npx.d.ts +4 -0
- package/lib/node-cache-cleaner/npx.js +82 -0
- package/lib/{ps/index.d.mjs → node-cache-cleaner/npx.mjs} +6 -5
- package/lib/node-cache-cleaner/yarn.cjs +73 -0
- package/lib/node-cache-cleaner/yarn.d.ts +2 -0
- package/lib/node-cache-cleaner/yarn.js +62 -0
- package/lib/node-cache-cleaner/yarn.mjs +10 -0
- package/lib/node-cache-cleaner-cli.cjs +182 -0
- package/lib/node-cache-cleaner-cli.d.ts +2 -0
- package/lib/node-cache-cleaner-cli.js +60 -0
- package/lib/node-cache-cleaner-cli.mjs +56 -0
- package/lib/node-executor.cjs +91 -0
- package/lib/node-executor.d.cts +2 -0
- package/lib/node-executor.mjs +103 -0
- package/lib/npm-run-series.cjs +21 -28
- package/lib/npm-run-series.mjs +20 -6
- package/lib/package-resolutions-updater-cli.cjs +213 -128
- package/lib/package-resolutions-updater-cli.mjs +17 -39
- package/lib/package-resolutions-updater.cjs +204 -98
- package/lib/package-resolutions-updater.d.mts +20 -1
- package/lib/package-resolutions-updater.mjs +7 -5
- package/lib/print-directory-tree.cjs +2 -2
- package/lib/print-directory-tree.mjs +1 -1
- package/lib/ps/connected-domain.js +10 -10
- package/lib/ps/index.cjs +1 -1
- package/lib/ps/index.mjs +177 -171
- package/lib/ps/isWin.js +1 -1
- package/lib/ps/table-parser.js +6 -6
- package/lib/remove-module.cjs +2 -2
- package/lib/remove-module.mjs +1 -1
- package/lib/rm-node-module-cli.cjs +222 -0
- package/lib/rm-node-module-cli.d.cts +1 -0
- package/lib/rm-node-module-cli.mjs +89 -0
- package/lib/rm-node-modules.cjs +127 -0
- package/lib/rm-node-modules.d.cts +35 -0
- package/lib/{binary-collections-config.mjs → rm-node-modules.mjs} +3 -3
- package/lib/rmpath.cjs +2 -2
- package/lib/rmpath.mjs +1 -1
- package/lib/submodule-install.cjs +47 -34
- package/lib/submodule-install.mjs +46 -33
- package/lib/submodule-remove-cli.cjs +1 -2
- package/lib/submodule-remove-cli.js +3 -3
- package/lib/submodule-remove-cli.mjs +1 -2
- package/lib/utils/chatgpt.cjs +19 -13
- package/lib/utils/chatgpt.js +94 -94
- package/lib/utils/chatgpt.mjs +1 -1
- package/lib/utils/findEnvFiles.cjs +28 -46
- package/lib/utils/findEnvFiles.d.cts +19 -0
- package/lib/utils/findEnvFiles.mjs +3 -5
- package/lib/utils/findWorkspaceRoot.js +4 -4
- package/lib/utils/index.cjs +2 -2
- package/lib/utils/index.mjs +1 -1
- package/lib/utils/isGithubTokenValid.js +7 -7
- package/lib/{ps/index.d.cjs → utils/isWindows.cjs} +17 -3
- package/lib/utils/isWindows.d.ts +5 -0
- package/lib/utils/isWindows.js +10 -0
- package/lib/utils/isWindows.mjs +8 -0
- package/lib/utils/runBash.cjs +53 -0
- package/lib/utils/runBash.d.cts +12 -0
- package/lib/utils/runBash.mjs +66 -0
- package/lib/yarn-per-branch-lock-installer.cjs +97 -0
- package/lib/yarn-per-branch-lock-installer.d.cts +2 -0
- package/lib/yarn-per-branch-lock-installer.mjs +109 -0
- package/lib/yarn-reinstall.cjs +2 -2
- package/lib/yarn-reinstall.mjs +1 -1
- package/package.json +61 -52
- package/readme.html +784 -0
- package/readme.md +106 -218
- package/releases/readme.md +1 -1
- package/test/README.md +2 -2
- package/test-project/package.json +8 -2
- package/test-project/workspaces/workspace-a/package.json +135 -0
- package/test-project/workspaces/workspace-a/readme.md +20 -0
- package/test-project/workspaces/workspace-a/release/readme.md +42 -0
- package/test-project/workspaces/workspace-a/test/demo/package.json +25 -0
- package/test-project/workspaces/workspace-a/test/readme.md +12 -0
- package/test-project/workspaces/workspace-b/package.json +139 -0
- package/test-project/workspaces/workspace-b/readme.md +94 -0
- package/test-project/workspaces/workspace-b/requirements.txt +1 -0
- package/test-project/workspaces/workspace-b/test/sample-project/package.json +7 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/package.json +96 -0
- package/test-project/workspaces/workspace-b/themes/hexo-theme-flowbite/readme.md +156 -0
- package/tmp/rm-node-modules-test-project/package.json +17 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-a/package.json +16 -0
- package/tmp/rm-node-modules-test-project/packages/workspace-b/package.json +16 -0
- package/tmp/test-repo/README.md +2 -35
- package/tmp/test-repo/package.json +13 -3
- package/docs-src/clean-github-actions-caches.md +0 -26
- package/docs-src/free-chatgpt.md +0 -26
- package/lib/binary-collections-config.cjs +0 -15
- package/lib/chunk-2CBJCW7E.mjs +0 -81
- package/lib/chunk-4UHL4WVN.mjs +0 -136
- package/lib/chunk-66PAU5PS.mjs +0 -31
- package/lib/chunk-6HHJRKFB.mjs +0 -59
- package/lib/chunk-7XTEJHOE.mjs +0 -193
- package/lib/chunk-FCDQGYBF.mjs +0 -136
- package/lib/chunk-GEYA2USY.mjs +0 -207
- package/lib/chunk-GJTGHXRA.mjs +0 -356
- package/lib/chunk-ID2WBTE2.mjs +0 -80
- package/lib/chunk-JXFOHKDM.mjs +0 -239
- package/lib/chunk-PDSXF5HY.mjs +0 -187
- package/lib/chunk-RWLXRTYP.mjs +0 -109
- package/lib/chunk-TOIVAQF7.mjs +0 -136
- package/lib/chunk-V5SKYJUB.mjs +0 -136
- package/lib/chunk-WSRETQCA.mjs +0 -59
- package/lib/chunk-YYLIQQKF.mjs +0 -31
- package/lib/ps/index.d.ts +0 -2
- package/lib/ps/index.js +0 -254
- package/lib/utils/findEnvFiles.d.ts +0 -8
- package/lib/utils/findEnvFiles.js +0 -121
- package/tmp/typedoc/readme.md +0 -320
- /package/lib/{binary-collections-config.d.cts → binary-collections/config.d.cts} +0 -0
package/lib/utils/index.cjs
CHANGED
|
@@ -70,7 +70,7 @@ function del(fullPath) {
|
|
|
70
70
|
try {
|
|
71
71
|
fs.rmdirSync(fullPath);
|
|
72
72
|
console.log("deleted", fullPath);
|
|
73
|
-
} catch (
|
|
73
|
+
} catch (_e) {
|
|
74
74
|
try {
|
|
75
75
|
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
76
76
|
console.log("deleted", fullPath);
|
|
@@ -83,7 +83,7 @@ function del(fullPath) {
|
|
|
83
83
|
try {
|
|
84
84
|
fs.unlinkSync(fullPath);
|
|
85
85
|
console.log("deleted", fullPath);
|
|
86
|
-
} catch (
|
|
86
|
+
} catch (_e) {
|
|
87
87
|
try {
|
|
88
88
|
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
89
89
|
console.log("deleted", fullPath);
|
package/lib/utils/index.mjs
CHANGED
|
@@ -22,18 +22,18 @@ const node_https_1 = __importDefault(require("node:https"));
|
|
|
22
22
|
*/
|
|
23
23
|
function isGitHubTokenValid(token) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (!token || typeof token !==
|
|
25
|
+
if (!token || typeof token !== 'string') {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
return new Promise((resolve) => {
|
|
29
29
|
const req = node_https_1.default.request({
|
|
30
|
-
hostname:
|
|
31
|
-
path:
|
|
32
|
-
method:
|
|
30
|
+
hostname: 'api.github.com',
|
|
31
|
+
path: '/user',
|
|
32
|
+
method: 'GET',
|
|
33
33
|
headers: {
|
|
34
34
|
Authorization: `Bearer ${token}`,
|
|
35
|
-
|
|
36
|
-
Accept:
|
|
35
|
+
'User-Agent': 'github-token-validator',
|
|
36
|
+
Accept: 'application/vnd.github+json'
|
|
37
37
|
}
|
|
38
38
|
}, (res) => {
|
|
39
39
|
// 200 = valid token
|
|
@@ -41,7 +41,7 @@ function isGitHubTokenValid(token) {
|
|
|
41
41
|
// consume response to avoid memory leak
|
|
42
42
|
res.resume();
|
|
43
43
|
});
|
|
44
|
-
req.on(
|
|
44
|
+
req.on('error', () => resolve(false));
|
|
45
45
|
req.end();
|
|
46
46
|
});
|
|
47
47
|
});
|
|
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
5
9
|
var __copyProps = (to, from, except, desc) => {
|
|
6
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -12,6 +16,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
16
|
};
|
|
13
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
18
|
|
|
15
|
-
// src/
|
|
16
|
-
var
|
|
17
|
-
|
|
19
|
+
// src/utils/isWindows.js
|
|
20
|
+
var isWindows_exports = {};
|
|
21
|
+
__export(isWindows_exports, {
|
|
22
|
+
isWindows: () => isWindows
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(isWindows_exports);
|
|
25
|
+
function isWindows() {
|
|
26
|
+
return process.platform === "win32" || /^(msys|cygwin)$/.test(process.env.OSTYPE || "");
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
isWindows
|
|
31
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWindows = isWindows;
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the current platform is Windows
|
|
6
|
+
* @returns {boolean} true if running on Windows, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
function isWindows() {
|
|
9
|
+
return process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE || '');
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/utils/runBash.cjs
|
|
2
|
+
var { spawn } = require("child_process");
|
|
3
|
+
var fs = require("fs");
|
|
4
|
+
var path = require("path");
|
|
5
|
+
function runBash(file, options = {}) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const env = { ...process.env, ...options.env || {} };
|
|
8
|
+
if (options.env) delete options.env;
|
|
9
|
+
const isWindows = process.platform === "win32";
|
|
10
|
+
if (isWindows) {
|
|
11
|
+
const candidates = [
|
|
12
|
+
"C:\\Program Files\\Git\\bin",
|
|
13
|
+
"C:\\Program Files\\Git\\usr\\bin",
|
|
14
|
+
"C:\\laragon\\bin\\git\\bin",
|
|
15
|
+
path.join(process.cwd(), "node_modules", ".bin"),
|
|
16
|
+
path.join(process.cwd(), "vendor", "bin"),
|
|
17
|
+
path.join(process.cwd(), "bin"),
|
|
18
|
+
path.join(process.cwd(), "venv", "Scripts"),
|
|
19
|
+
path.join(process.cwd(), ".venv", "Scripts")
|
|
20
|
+
].filter((dir) => fs.existsSync(dir));
|
|
21
|
+
if (candidates.length > 0) {
|
|
22
|
+
env.PATH = `${candidates.join(";")};${env.PATH}`;
|
|
23
|
+
} else {
|
|
24
|
+
return reject(
|
|
25
|
+
new Error("No suitable bash found on Windows. Please install Git Bash or WSL and ensure it's in your PATH.")
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const proc = spawn("bash", [file], {
|
|
30
|
+
shell: true,
|
|
31
|
+
env,
|
|
32
|
+
...options
|
|
33
|
+
});
|
|
34
|
+
let stdout = "";
|
|
35
|
+
let stderr = "";
|
|
36
|
+
proc.stdout.on("data", (data) => {
|
|
37
|
+
stdout += data.toString();
|
|
38
|
+
});
|
|
39
|
+
proc.stderr.on("data", (data) => {
|
|
40
|
+
stderr += data.toString();
|
|
41
|
+
});
|
|
42
|
+
proc.on("error", (err) => {
|
|
43
|
+
reject(err);
|
|
44
|
+
});
|
|
45
|
+
proc.on("close", (code) => {
|
|
46
|
+
const result = { code, stdout, stderr };
|
|
47
|
+
if (code === 0) return resolve(result);
|
|
48
|
+
return reject(result);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
module.exports = { runBash };
|
|
53
|
+
module.exports.default = runBash;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default runBash;
|
|
2
|
+
/**
|
|
3
|
+
* Run a bash script using spawn
|
|
4
|
+
* @param {string} file - path to bash file
|
|
5
|
+
* @param {import("child_process").SpawnOptions} options
|
|
6
|
+
* @returns {Promise<{code: number, stdout: string, stderr: string}>}
|
|
7
|
+
*/
|
|
8
|
+
export function runBash(file: string, options?: import("child_process").SpawnOptions): Promise<{
|
|
9
|
+
code: number;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
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/utils/runBash.cjs
|
|
9
|
+
var require_runBash = __commonJS({
|
|
10
|
+
"src/utils/runBash.cjs"(exports, module) {
|
|
11
|
+
init_esm_shims();
|
|
12
|
+
var { spawn } = __require("child_process");
|
|
13
|
+
var fs = __require("fs");
|
|
14
|
+
var path = __require("path");
|
|
15
|
+
function runBash(file, options = {}) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const env = { ...process.env, ...options.env || {} };
|
|
18
|
+
if (options.env) delete options.env;
|
|
19
|
+
const isWindows = process.platform === "win32";
|
|
20
|
+
if (isWindows) {
|
|
21
|
+
const candidates = [
|
|
22
|
+
"C:\\Program Files\\Git\\bin",
|
|
23
|
+
"C:\\Program Files\\Git\\usr\\bin",
|
|
24
|
+
"C:\\laragon\\bin\\git\\bin",
|
|
25
|
+
path.join(process.cwd(), "node_modules", ".bin"),
|
|
26
|
+
path.join(process.cwd(), "vendor", "bin"),
|
|
27
|
+
path.join(process.cwd(), "bin"),
|
|
28
|
+
path.join(process.cwd(), "venv", "Scripts"),
|
|
29
|
+
path.join(process.cwd(), ".venv", "Scripts")
|
|
30
|
+
].filter((dir) => fs.existsSync(dir));
|
|
31
|
+
if (candidates.length > 0) {
|
|
32
|
+
env.PATH = `${candidates.join(";")};${env.PATH}`;
|
|
33
|
+
} else {
|
|
34
|
+
return reject(
|
|
35
|
+
new Error("No suitable bash found on Windows. Please install Git Bash or WSL and ensure it's in your PATH.")
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const proc = spawn("bash", [file], {
|
|
40
|
+
shell: true,
|
|
41
|
+
env,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
44
|
+
let stdout = "";
|
|
45
|
+
let stderr = "";
|
|
46
|
+
proc.stdout.on("data", (data) => {
|
|
47
|
+
stdout += data.toString();
|
|
48
|
+
});
|
|
49
|
+
proc.stderr.on("data", (data) => {
|
|
50
|
+
stderr += data.toString();
|
|
51
|
+
});
|
|
52
|
+
proc.on("error", (err) => {
|
|
53
|
+
reject(err);
|
|
54
|
+
});
|
|
55
|
+
proc.on("close", (code) => {
|
|
56
|
+
const result = { code, stdout, stderr };
|
|
57
|
+
if (code === 0) return resolve(result);
|
|
58
|
+
return reject(result);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
module.exports = { runBash };
|
|
63
|
+
module.exports.default = runBash;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export default require_runBash();
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/yarn-per-branch-lock-installer.cjs
|
|
4
|
+
var { execSync, spawnSync } = require("child_process");
|
|
5
|
+
var fs = require("fs-extra");
|
|
6
|
+
var minimist = require("minimist");
|
|
7
|
+
function run(cmd, opts = {}) {
|
|
8
|
+
var _a;
|
|
9
|
+
try {
|
|
10
|
+
return execSync(cmd, {
|
|
11
|
+
encoding: "utf8",
|
|
12
|
+
stdio: "pipe",
|
|
13
|
+
...opts
|
|
14
|
+
}).trim();
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error(((_a = err.stderr) == null ? void 0 : _a.toString()) || err.message);
|
|
17
|
+
process.exit(err.status || 1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getBranchName() {
|
|
21
|
+
return run("git rev-parse --abbrev-ref HEAD");
|
|
22
|
+
}
|
|
23
|
+
function safeBranchName(name) {
|
|
24
|
+
return name.replace(/[\\/]/g, "-");
|
|
25
|
+
}
|
|
26
|
+
function findYarn() {
|
|
27
|
+
try {
|
|
28
|
+
const paths = run(process.platform === "win32" ? "where yarn" : "which yarn").split(/\r?\n/).filter(Boolean);
|
|
29
|
+
if (process.platform === "win32") {
|
|
30
|
+
return paths.find((p) => /\.cmd$/i.test(p)) || paths[0] || null;
|
|
31
|
+
}
|
|
32
|
+
return paths[0] || null;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function runYarn(yarnPath, args) {
|
|
38
|
+
const result = process.platform === "win32" ? spawnSync("cmd.exe", ["/d", "/s", "/c", yarnPath, ...args], {
|
|
39
|
+
stdio: "inherit"
|
|
40
|
+
}) : spawnSync(yarnPath, args, {
|
|
41
|
+
stdio: "inherit"
|
|
42
|
+
});
|
|
43
|
+
if (result.error) {
|
|
44
|
+
console.error(result.error.message);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
process.exitCode = result.status || 0;
|
|
48
|
+
}
|
|
49
|
+
function showHelp() {
|
|
50
|
+
console.log(`
|
|
51
|
+
Usage:
|
|
52
|
+
yarn-lock-sync [packages...]
|
|
53
|
+
|
|
54
|
+
Options:
|
|
55
|
+
-h, --help Show help
|
|
56
|
+
|
|
57
|
+
Examples:
|
|
58
|
+
yarn-lock-sync
|
|
59
|
+
yarn-lock-sync lodash axios
|
|
60
|
+
`);
|
|
61
|
+
}
|
|
62
|
+
function main() {
|
|
63
|
+
const argv = minimist(process.argv.slice(2), {
|
|
64
|
+
boolean: ["help"],
|
|
65
|
+
alias: {
|
|
66
|
+
h: "help"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
if (argv.help) {
|
|
70
|
+
showHelp();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const packages = argv._;
|
|
74
|
+
const branch = safeBranchName(getBranchName());
|
|
75
|
+
const yarnLock = "yarn.lock";
|
|
76
|
+
const branchLock = `yarn.${branch}.lock`;
|
|
77
|
+
const yarnPath = findYarn();
|
|
78
|
+
if (!yarnPath) {
|
|
79
|
+
console.error("Error: Yarn not found in PATH.");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
if (fs.existsSync(branchLock)) {
|
|
83
|
+
console.log(`Restoring ${branchLock} -> ${yarnLock}`);
|
|
84
|
+
fs.copyFileSync(branchLock, yarnLock);
|
|
85
|
+
} else {
|
|
86
|
+
console.log(`No ${branchLock} found`);
|
|
87
|
+
fs.removeSync(yarnLock);
|
|
88
|
+
}
|
|
89
|
+
const args = packages.length ? ["up", ...packages] : ["install"];
|
|
90
|
+
console.log(`Running: yarn ${args.join(" ")}`);
|
|
91
|
+
runYarn(yarnPath, args);
|
|
92
|
+
if (fs.existsSync(yarnLock)) {
|
|
93
|
+
console.log(`Saving ${yarnLock} -> ${branchLock}`);
|
|
94
|
+
fs.copyFileSync(yarnLock, branchLock);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
main();
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__commonJS,
|
|
5
|
+
__require,
|
|
6
|
+
init_esm_shims
|
|
7
|
+
} from "./chunk-QQ4A6DLD.mjs";
|
|
8
|
+
|
|
9
|
+
// src/yarn-per-branch-lock-installer.cjs
|
|
10
|
+
var require_yarn_per_branch_lock_installer = __commonJS({
|
|
11
|
+
"src/yarn-per-branch-lock-installer.cjs"() {
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
var { execSync, spawnSync } = __require("child_process");
|
|
14
|
+
var fs = __require("fs-extra");
|
|
15
|
+
var minimist = __require("minimist");
|
|
16
|
+
function run(cmd, opts = {}) {
|
|
17
|
+
var _a;
|
|
18
|
+
try {
|
|
19
|
+
return execSync(cmd, {
|
|
20
|
+
encoding: "utf8",
|
|
21
|
+
stdio: "pipe",
|
|
22
|
+
...opts
|
|
23
|
+
}).trim();
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error(((_a = err.stderr) == null ? void 0 : _a.toString()) || err.message);
|
|
26
|
+
process.exit(err.status || 1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function getBranchName() {
|
|
30
|
+
return run("git rev-parse --abbrev-ref HEAD");
|
|
31
|
+
}
|
|
32
|
+
function safeBranchName(name) {
|
|
33
|
+
return name.replace(/[\\/]/g, "-");
|
|
34
|
+
}
|
|
35
|
+
function findYarn() {
|
|
36
|
+
try {
|
|
37
|
+
const paths = run(process.platform === "win32" ? "where yarn" : "which yarn").split(/\r?\n/).filter(Boolean);
|
|
38
|
+
if (process.platform === "win32") {
|
|
39
|
+
return paths.find((p) => /\.cmd$/i.test(p)) || paths[0] || null;
|
|
40
|
+
}
|
|
41
|
+
return paths[0] || null;
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function runYarn(yarnPath, args) {
|
|
47
|
+
const result = process.platform === "win32" ? spawnSync("cmd.exe", ["/d", "/s", "/c", yarnPath, ...args], {
|
|
48
|
+
stdio: "inherit"
|
|
49
|
+
}) : spawnSync(yarnPath, args, {
|
|
50
|
+
stdio: "inherit"
|
|
51
|
+
});
|
|
52
|
+
if (result.error) {
|
|
53
|
+
console.error(result.error.message);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
process.exitCode = result.status || 0;
|
|
57
|
+
}
|
|
58
|
+
function showHelp() {
|
|
59
|
+
console.log(`
|
|
60
|
+
Usage:
|
|
61
|
+
yarn-lock-sync [packages...]
|
|
62
|
+
|
|
63
|
+
Options:
|
|
64
|
+
-h, --help Show help
|
|
65
|
+
|
|
66
|
+
Examples:
|
|
67
|
+
yarn-lock-sync
|
|
68
|
+
yarn-lock-sync lodash axios
|
|
69
|
+
`);
|
|
70
|
+
}
|
|
71
|
+
function main() {
|
|
72
|
+
const argv = minimist(process.argv.slice(2), {
|
|
73
|
+
boolean: ["help"],
|
|
74
|
+
alias: {
|
|
75
|
+
h: "help"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (argv.help) {
|
|
79
|
+
showHelp();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const packages = argv._;
|
|
83
|
+
const branch = safeBranchName(getBranchName());
|
|
84
|
+
const yarnLock = "yarn.lock";
|
|
85
|
+
const branchLock = `yarn.${branch}.lock`;
|
|
86
|
+
const yarnPath = findYarn();
|
|
87
|
+
if (!yarnPath) {
|
|
88
|
+
console.error("Error: Yarn not found in PATH.");
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
if (fs.existsSync(branchLock)) {
|
|
92
|
+
console.log(`Restoring ${branchLock} -> ${yarnLock}`);
|
|
93
|
+
fs.copyFileSync(branchLock, yarnLock);
|
|
94
|
+
} else {
|
|
95
|
+
console.log(`No ${branchLock} found`);
|
|
96
|
+
fs.removeSync(yarnLock);
|
|
97
|
+
}
|
|
98
|
+
const args = packages.length ? ["up", ...packages] : ["install"];
|
|
99
|
+
console.log(`Running: yarn ${args.join(" ")}`);
|
|
100
|
+
runYarn(yarnPath, args);
|
|
101
|
+
if (fs.existsSync(yarnLock)) {
|
|
102
|
+
console.log(`Saving ${yarnLock} -> ${branchLock}`);
|
|
103
|
+
fs.copyFileSync(yarnLock, branchLock);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
main();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
export default require_yarn_per_branch_lock_installer();
|
package/lib/yarn-reinstall.cjs
CHANGED
|
@@ -88,7 +88,7 @@ var require_utils = __commonJS({
|
|
|
88
88
|
try {
|
|
89
89
|
fs.rmdirSync(fullPath);
|
|
90
90
|
console.log("deleted", fullPath);
|
|
91
|
-
} catch (
|
|
91
|
+
} catch (_e) {
|
|
92
92
|
try {
|
|
93
93
|
fs.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
|
fs.unlinkSync(fullPath);
|
|
103
103
|
console.log("deleted", fullPath);
|
|
104
|
-
} catch (
|
|
104
|
+
} catch (_e) {
|
|
105
105
|
try {
|
|
106
106
|
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7e3 });
|
|
107
107
|
console.log("deleted", fullPath);
|