binary-collections 2.0.6 → 2.0.8
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/bin/dir-tree.cmd +7 -0
- package/bin/git-diff +4 -0
- package/bin/git-diff.cmd +7 -0
- package/bin/{git-fix-encoding → git-fix} +1 -4
- package/bin/git-fix.cmd +7 -0
- package/bin/nodekill +0 -0
- package/bin/nodekill.cmd +0 -0
- package/bin/{submodule-install → submodule-install.txt} +0 -0
- package/bin/{submodule → submodule.txt} +0 -0
- package/lib/binary-collections-config.cjs +14 -0
- package/lib/binary-collections-config.d.mts +18 -0
- package/lib/binary-collections-config.d.ts +16 -0
- package/lib/binary-collections-config.js +39 -0
- package/lib/binary-collections-config.mjs +6 -0
- package/lib/binary-collections.cjs +105 -0
- package/lib/binary-collections.d.cts +2 -0
- package/lib/binary-collections.d.mts +121 -0
- package/lib/binary-collections.d.ts +121 -0
- package/lib/binary-collections.mjs +108 -0
- package/lib/chunk-4BYBVEYC.mjs +30 -0
- package/lib/chunk-AASHBCRW.mjs +57 -0
- package/lib/chunk-APBWENF6.mjs +135 -0
- package/lib/{chunk-M4IBUK4H.mjs → chunk-DPKAJKFO.mjs} +2 -4
- package/lib/chunk-EGSSKVDH.mjs +66 -0
- package/lib/{chunk-GA4DDV65.mjs → chunk-G3THLIDT.mjs} +3 -5
- package/lib/chunk-JGR2NW6D.mjs +187 -0
- package/lib/chunk-ONIBBBQ3.mjs +108 -0
- package/lib/chunk-SH3L6HHV.mjs +27 -0
- package/lib/chunk-VVEZVNIV.mjs +81 -0
- package/lib/{chunk-E75HJFJO.mjs → chunk-W3ENOM53.mjs} +2 -4
- package/lib/chunk-YV7DO3YV.mjs +48 -0
- package/lib/chunk-YX5U7XDR.mjs +58 -0
- package/lib/chunk-ZYAQRPUL.mjs +28 -0
- package/lib/clean-github-actions-caches.cjs +162 -0
- package/lib/clean-github-actions-caches.d.cts +1 -0
- package/lib/clean-github-actions-caches.d.mts +169 -0
- package/lib/clean-github-actions-caches.d.ts +169 -0
- package/lib/clean-github-actions-caches.mjs +132 -0
- package/lib/del-gradle.cjs +99 -15
- package/lib/del-gradle.d.ts +1 -2
- package/lib/del-gradle.js +12 -69
- package/lib/del-gradle.mjs +4 -6
- package/lib/del-node-modules.cjs +98 -14
- package/lib/del-node-modules.d.ts +1 -2
- package/lib/del-node-modules.js +11 -68
- package/lib/del-node-modules.mjs +3 -5
- package/lib/del-ps.cjs +98 -627
- package/lib/del-ps.d.ts +1 -2
- package/lib/del-ps.js +27 -702
- package/lib/del-ps.mjs +7 -12
- package/lib/del-yarn-caches.cjs +98 -14
- package/lib/del-yarn-caches.d.ts +1 -2
- package/lib/del-yarn-caches.js +6 -63
- package/lib/del-yarn-caches.mjs +3 -5
- package/lib/find-node-modules-cli.cjs +67 -0
- package/lib/find-node-modules-cli.d.mts +1 -0
- package/lib/find-node-modules-cli.d.ts +2 -0
- package/lib/find-node-modules-cli.js +3 -0
- package/lib/find-node-modules-cli.mjs +13 -0
- package/lib/find-node-modules.cjs +39 -9
- package/lib/find-node-modules.d.mts +12 -1
- package/lib/find-node-modules.d.ts +12 -2
- package/lib/find-node-modules.js +53 -12
- package/lib/find-node-modules.mjs +4 -19
- package/lib/git/gitattributes.cjs +171 -0
- package/lib/git/gitattributes.d.mts +35 -0
- package/lib/git/gitattributes.d.ts +33 -0
- package/lib/git/gitattributes.js +223 -0
- package/lib/git/gitattributes.mjs +6 -0
- package/lib/git/line-endings.cjs +74 -0
- package/lib/git/line-endings.d.cts +7 -0
- package/lib/git/line-endings.d.mts +83 -0
- package/lib/git/line-endings.d.ts +83 -0
- package/lib/git/line-endings.mjs +8 -0
- package/lib/git/normalize.cjs +42 -0
- package/lib/git/normalize.d.cts +6 -0
- package/lib/git/normalize.d.mts +43 -0
- package/lib/git/normalize.d.ts +43 -0
- package/lib/git/normalize.mjs +6 -0
- package/lib/git/permissions.cjs +15 -0
- package/lib/git/permissions.d.cts +6 -0
- package/lib/git/permissions.d.mts +17 -0
- package/lib/git/permissions.d.ts +17 -0
- package/lib/git/permissions.mjs +7 -0
- package/lib/git/pull-strategy.cjs +13 -0
- package/lib/git/pull-strategy.d.cts +5 -0
- package/lib/git/pull-strategy.d.mts +15 -0
- package/lib/git/pull-strategy.d.ts +15 -0
- package/lib/git/pull-strategy.mjs +7 -0
- package/lib/git/user-config.cjs +100 -0
- package/lib/git/user-config.d.cts +10 -0
- package/lib/git/user-config.d.mts +105 -0
- package/lib/git/user-config.d.ts +105 -0
- package/lib/git/user-config.mjs +8 -0
- package/lib/git/utils.cjs +70 -0
- package/lib/git/utils.d.cts +20 -0
- package/lib/git/utils.d.mts +69 -0
- package/lib/git/utils.d.ts +69 -0
- package/lib/git/utils.mjs +6 -0
- package/lib/git-diff.cjs +73 -0
- package/lib/git-diff.d.cts +2 -0
- package/lib/git-diff.d.mts +84 -0
- package/lib/git-diff.d.ts +84 -0
- package/lib/git-diff.mjs +88 -0
- package/lib/git-fix.cjs +129 -0
- package/lib/git-fix.d.cts +2 -0
- package/lib/git-fix.d.mts +141 -0
- package/lib/git-fix.d.ts +141 -0
- package/lib/git-fix.mjs +151 -0
- package/lib/git-purge.cjs +92 -621
- package/lib/git-purge.d.ts +1 -2
- package/lib/git-purge.js +53 -698
- package/lib/git-purge.mjs +4 -9
- package/lib/index.cjs +99 -1
- package/lib/index.d.mts +1 -2
- package/lib/index.d.ts +2 -2
- package/lib/index.js +8 -2
- package/lib/index.mjs +10 -3
- package/lib/npm-run-series.cjs +140 -1
- package/lib/npm-run-series.d.ts +1 -0
- package/lib/npm-run-series.js +81 -56
- package/lib/npm-run-series.mjs +7 -5
- package/lib/package-resolutions-updater.cjs +274 -0
- package/lib/package-resolutions-updater.d.mts +1 -0
- package/lib/package-resolutions-updater.d.ts +326 -0
- package/lib/package-resolutions-updater.mjs +316 -0
- package/lib/print-directory-tree.cjs +241 -0
- package/lib/print-directory-tree.d.cts +1 -0
- package/lib/print-directory-tree.d.mts +234 -0
- package/lib/print-directory-tree.d.ts +234 -0
- package/lib/print-directory-tree.mjs +182 -0
- package/lib/ps/connected-domain.cjs +0 -0
- package/lib/ps/connected-domain.d.ts +1 -2
- package/lib/ps/connected-domain.js +196 -150
- package/lib/ps/connected-domain.mjs +2 -3
- package/lib/ps/index.cjs +3 -3
- package/lib/ps/index.d.mjs +1 -2
- package/lib/ps/index.d.ts +2 -26
- package/lib/ps/index.js +233 -535
- package/lib/ps/index.mjs +9 -11
- package/lib/ps/isWin.cjs +0 -0
- package/lib/ps/isWin.d.ts +1 -2
- package/lib/ps/isWin.js +1 -2
- package/lib/ps/isWin.mjs +2 -3
- package/lib/ps/table-parser.cjs +0 -0
- package/lib/ps/table-parser.d.ts +1 -3
- package/lib/ps/table-parser.js +254 -345
- package/lib/ps/table-parser.mjs +3 -4
- package/lib/submodule-install.cjs +100 -0
- package/lib/submodule-install.d.cts +2 -0
- package/lib/submodule-install.d.mts +121 -0
- package/lib/submodule-install.d.ts +121 -0
- package/lib/submodule-install.mjs +107 -0
- package/lib/utils.cjs +98 -14
- package/lib/utils.d.mts +29 -9
- package/lib/utils.d.ts +30 -14
- package/lib/utils.js +173 -27
- package/lib/utils.mjs +2 -3
- package/lib/yarn-reinstall.cjs +44 -0
- package/lib/yarn-reinstall.d.cts +1 -0
- package/lib/yarn-reinstall.d.mts +49 -0
- package/lib/yarn-reinstall.d.ts +49 -0
- package/lib/yarn-reinstall.mjs +54 -0
- package/package.json +126 -99
- package/readme.md +238 -50
- package/src/package-resolutions-updater.mjs +325 -0
- package/src/print-directory-tree.cjs +234 -0
- package/src/ps/index.js +4 -3
- package/src/yarn-reinstall.cjs +49 -0
- package/test-project/package.json +16 -0
- package/tmp/test-repo/package.json +7 -0
- package/bin/git-fix-encoding.cmd +0 -6
- package/eslint.config.cjs +0 -97
- package/lib/chunk-7MSZ52XC.mjs +0 -14
- package/lib/chunk-AVDT32AY.mjs +0 -20
- package/lib/chunk-LPLPQBYP.mjs +0 -53
- package/lib/chunk-S4SJ7SDW.mjs +0 -625
- package/lib/package-resolutions.cjs +0 -28
- package/lib/package-resolutions.d.mts +0 -25
- package/lib/package-resolutions.d.ts +0 -25
- package/lib/package-resolutions.js +0 -28
- package/lib/package-resolutions.mjs +0 -31
- package/lib/ps/index.d.js +0 -17
package/lib/utils.js
CHANGED
|
@@ -1,35 +1,181 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const path = require("upath");
|
|
12
|
+
const argv = require("minimist")(process.argv.slice(2));
|
|
13
|
+
const { exec } = require("child_process");
|
|
14
|
+
const { URL } = require("url");
|
|
15
|
+
const { promisify } = require("util");
|
|
16
|
+
/**
|
|
17
|
+
* Promisified version of Node.js exec function for async shell command execution.
|
|
18
|
+
* @type {(command: string) => Promise<{ stdout: string, stderr: string }>}
|
|
19
|
+
*/
|
|
20
|
+
const execAsync = promisify(exec);
|
|
21
|
+
function parseGitRemotes() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
try {
|
|
24
|
+
// Run the `git remote -v` command
|
|
25
|
+
const { stdout } = yield execAsync("git remote -v");
|
|
26
|
+
// Split the output into lines
|
|
27
|
+
const lines = stdout.split("\n");
|
|
28
|
+
// Object to hold the remotes
|
|
29
|
+
const remotes = {};
|
|
30
|
+
// Process each line
|
|
31
|
+
lines.forEach((line) => {
|
|
32
|
+
const [name, url] = line.split("\t");
|
|
33
|
+
if (name && url) {
|
|
34
|
+
const [repoUrl] = url.split(" ");
|
|
35
|
+
try {
|
|
36
|
+
// Parse the URL
|
|
37
|
+
const parsedUrl = new URL(repoUrl);
|
|
38
|
+
// Extract the path from the URL
|
|
39
|
+
const pathParts = parsedUrl.pathname.split("/").filter(Boolean);
|
|
40
|
+
// Check if the URL is from GitHub and has the username/repo format
|
|
41
|
+
if (parsedUrl.hostname === "github.com" && pathParts.length === 2) {
|
|
42
|
+
// Remove the `.git` suffix if present
|
|
43
|
+
let repoPath = pathParts.join("/");
|
|
44
|
+
if (repoPath.endsWith(".git")) {
|
|
45
|
+
repoPath = repoPath.slice(0, -4); // Remove the `.git` suffix
|
|
46
|
+
}
|
|
47
|
+
remotes[name] = repoPath;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error("URL Parsing Error:", e.message);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return remotes;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error("Error:", error.message);
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
module.exports.parseGitRemotes = parseGitRemotes;
|
|
64
|
+
/**
|
|
65
|
+
* Joins all given path segments together and normalizes the resulting path.
|
|
66
|
+
* Preserves the case of the drive letter on Windows.
|
|
67
|
+
*
|
|
68
|
+
* @param {...string} segments Path segments to join.
|
|
69
|
+
* @returns {string} Normalized path with drive letter case preserved.
|
|
70
|
+
*/
|
|
71
|
+
function joinPathPreserveDriveLetter(...segments) {
|
|
72
|
+
let fullPath = require("path").join(...segments);
|
|
73
|
+
// Check if the path starts with a drive letter (e.g., C:\)
|
|
74
|
+
if (/^[a-z]:\\/.test(fullPath)) {
|
|
75
|
+
// Convert the drive letter to uppercase
|
|
76
|
+
fullPath = fullPath.charAt(0).toUpperCase() + fullPath.slice(1);
|
|
77
|
+
}
|
|
78
|
+
return fullPath;
|
|
79
|
+
}
|
|
80
|
+
module.exports.joinPathPreserveDriveLetter = joinPathPreserveDriveLetter;
|
|
81
|
+
/**
|
|
82
|
+
* Returns parsed command line arguments using minimist.
|
|
83
|
+
* @returns {import('minimist').ParsedArgs} Parsed command line arguments
|
|
84
|
+
*/
|
|
4
85
|
function getArgs() {
|
|
5
|
-
|
|
86
|
+
return argv;
|
|
6
87
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
88
|
+
module.exports.getArgs = getArgs;
|
|
89
|
+
/**
|
|
90
|
+
* Recursively deletes a file or directory at the given path.
|
|
91
|
+
* @param {string} fullPath Absolute path to the file or directory to delete.
|
|
92
|
+
*/
|
|
93
|
+
function del(fullPath) {
|
|
10
94
|
if (fs.statSync(fullPath).isDirectory()) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
95
|
+
// delete all files each package directory
|
|
96
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
97
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
98
|
+
del(subdir[i]);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
try {
|
|
103
|
+
fs.rmSync(fullPath, { recursive: true, force: true, retryDelay: 7000 });
|
|
104
|
+
console.log("deleted", fullPath);
|
|
105
|
+
}
|
|
106
|
+
catch (_) {
|
|
107
|
+
console.log("failed delete", fullPath);
|
|
108
|
+
}
|
|
15
109
|
}
|
|
16
|
-
del(fullPath);
|
|
17
|
-
});
|
|
18
110
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
111
|
+
module.exports.del = del;
|
|
112
|
+
/**
|
|
113
|
+
* Handles a glob stream to delete matched files and directories recursively.
|
|
114
|
+
* @param {glob.Glob} globStream Glob stream object.
|
|
115
|
+
*/
|
|
116
|
+
function delStream(globStream) {
|
|
117
|
+
globStream.stream().on("data", (result) => {
|
|
118
|
+
const fullPath = path.resolve(process.cwd(), result);
|
|
119
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
120
|
+
// delete all files each package directory
|
|
121
|
+
const subdir = fs.readdirSync(fullPath).map((dirPath) => path.resolve(fullPath, dirPath));
|
|
122
|
+
for (let i = 0; i < subdir.length; i++) {
|
|
123
|
+
del(subdir[i]);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
del(fullPath);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
module.exports.delStream = delStream;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a directory/file tree string from an array of file paths and hashes.
|
|
132
|
+
* @param {string[]} hashArray Array of strings in the format 'relative/path/to/file hash'.
|
|
133
|
+
* @returns {string} Directory/file tree as a string, with file hashes.
|
|
134
|
+
*/
|
|
135
|
+
function getFileTreeString(hashArray) {
|
|
136
|
+
const tree = {};
|
|
137
|
+
// Map file paths to hashes for quick lookup
|
|
138
|
+
const hashMap = {};
|
|
139
|
+
for (const entry of hashArray) {
|
|
140
|
+
const [filePath, hash] = entry.split(" ");
|
|
141
|
+
hashMap[filePath] = hash;
|
|
142
|
+
const parts = filePath.split("/");
|
|
143
|
+
let current = tree;
|
|
144
|
+
for (let i = 0; i < parts.length; i++) {
|
|
145
|
+
const part = parts[i];
|
|
146
|
+
if (i === parts.length - 1) {
|
|
147
|
+
current[part] = null; // file
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
current[part] = current[part] || {};
|
|
151
|
+
current = current[part];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
24
154
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
155
|
+
function printNode(node, prefix = "", parentPath = "") {
|
|
156
|
+
const keys = Object.keys(node).sort();
|
|
157
|
+
let lines = [];
|
|
158
|
+
keys.forEach((key, idx) => {
|
|
159
|
+
const isLast = idx === keys.length - 1;
|
|
160
|
+
const branch = isLast ? "└── " : "├── ";
|
|
161
|
+
const currentPath = parentPath ? parentPath + "/" + key : key;
|
|
162
|
+
if (node[key] === null) {
|
|
163
|
+
lines.push(prefix + branch + key + " [" + (hashMap[currentPath] || "") + "]");
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
lines.push(prefix + branch + key + "/");
|
|
167
|
+
lines = lines.concat(printNode(node[key], prefix + (isLast ? " " : "│ "), currentPath));
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
return lines;
|
|
31
171
|
}
|
|
32
|
-
|
|
172
|
+
return printNode(tree, "", "").join("\n");
|
|
33
173
|
}
|
|
34
|
-
|
|
35
|
-
|
|
174
|
+
module.exports.getFileTreeString = getFileTreeString;
|
|
175
|
+
/**
|
|
176
|
+
* Creates an async delay for the specified number of milliseconds.
|
|
177
|
+
* @param {number} ms Number of milliseconds to delay.
|
|
178
|
+
* @returns {Promise<void>} Promise that resolves after the specified delay.
|
|
179
|
+
*/
|
|
180
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
181
|
+
module.exports.delay = delay;
|
package/lib/utils.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
require_utils
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-AVDT32AY.mjs";
|
|
4
|
+
} from "./chunk-APBWENF6.mjs";
|
|
5
|
+
import "./chunk-AASHBCRW.mjs";
|
|
7
6
|
export default require_utils();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
const { getArgs } = require("./utils.js");
|
|
4
|
+
const args = getArgs();
|
|
5
|
+
const positional = args._ || [];
|
|
6
|
+
if (positional.length === 0) {
|
|
7
|
+
console.error("Usage: yarn-reinstall <packageName> [--dev|-D|--peer|-P|--optional|-O]");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const packageName = positional[0];
|
|
11
|
+
const flags = positional.slice(1).concat(Object.keys(args)
|
|
12
|
+
.filter((k) => k !== "_" && args[k] === true)
|
|
13
|
+
.map((k) => `--${k}`));
|
|
14
|
+
if (!packageName) {
|
|
15
|
+
console.error("Please provide a package name.");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
// Remove and add commands
|
|
19
|
+
const removeCmd = `yarn remove ${packageName}`;
|
|
20
|
+
const addCmd = `yarn add ${packageName} ${flags.join(" ")}`.trim();
|
|
21
|
+
try {
|
|
22
|
+
// Check if the package is installed before removing
|
|
23
|
+
let isInstalled = false;
|
|
24
|
+
try {
|
|
25
|
+
const listOutput = execSync(`yarn list --pattern "${packageName}" --depth=0`, { encoding: "utf8" });
|
|
26
|
+
isInstalled = listOutput.includes(packageName + "@");
|
|
27
|
+
}
|
|
28
|
+
catch (_e) {
|
|
29
|
+
// If yarn list fails, assume not installed
|
|
30
|
+
isInstalled = false;
|
|
31
|
+
}
|
|
32
|
+
if (isInstalled) {
|
|
33
|
+
console.log(`Running: ${removeCmd}`);
|
|
34
|
+
execSync(removeCmd, { stdio: "inherit" });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.warn(`Package "${packageName}" was not installed or not referenced, skipping remove.`);
|
|
38
|
+
}
|
|
39
|
+
console.log(`Running: ${addCmd}`);
|
|
40
|
+
execSync(addCmd, { stdio: "inherit" });
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
process.exit(err.status || 1);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { getArgs } = require("./utils.js");
|
|
3
|
+
const args = getArgs();
|
|
4
|
+
const positional = args._ || [];
|
|
5
|
+
|
|
6
|
+
if (positional.length === 0) {
|
|
7
|
+
console.error("Usage: yarn-reinstall <packageName> [--dev|-D|--peer|-P|--optional|-O]");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const packageName = positional[0];
|
|
12
|
+
const flags = positional.slice(1).concat(
|
|
13
|
+
Object.keys(args)
|
|
14
|
+
.filter((k) => k !== "_" && args[k] === true)
|
|
15
|
+
.map((k) => `--${k}`)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!packageName) {
|
|
19
|
+
console.error("Please provide a package name.");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Remove and add commands
|
|
24
|
+
const removeCmd = `yarn remove ${packageName}`;
|
|
25
|
+
const addCmd = `yarn add ${packageName} ${flags.join(" ")}`.trim();
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// Check if the package is installed before removing
|
|
29
|
+
let isInstalled = false;
|
|
30
|
+
try {
|
|
31
|
+
const listOutput = execSync(`yarn list --pattern "${packageName}" --depth=0`, { encoding: "utf8" });
|
|
32
|
+
isInstalled = listOutput.includes(packageName + "@");
|
|
33
|
+
} catch (_e) {
|
|
34
|
+
// If yarn list fails, assume not installed
|
|
35
|
+
isInstalled = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isInstalled) {
|
|
39
|
+
console.log(`Running: ${removeCmd}`);
|
|
40
|
+
execSync(removeCmd, { stdio: "inherit" });
|
|
41
|
+
} else {
|
|
42
|
+
console.warn(`Package "${packageName}" was not installed or not referenced, skipping remove.`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(`Running: ${addCmd}`);
|
|
46
|
+
execSync(addCmd, { stdio: "inherit" });
|
|
47
|
+
} catch (err) {
|
|
48
|
+
process.exit(err.status || 1);
|
|
49
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const { getArgs } = require("./utils.js");
|
|
3
|
+
const args = getArgs();
|
|
4
|
+
const positional = args._ || [];
|
|
5
|
+
|
|
6
|
+
if (positional.length === 0) {
|
|
7
|
+
console.error("Usage: yarn-reinstall <packageName> [--dev|-D|--peer|-P|--optional|-O]");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const packageName = positional[0];
|
|
12
|
+
const flags = positional.slice(1).concat(
|
|
13
|
+
Object.keys(args)
|
|
14
|
+
.filter((k) => k !== "_" && args[k] === true)
|
|
15
|
+
.map((k) => `--${k}`)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!packageName) {
|
|
19
|
+
console.error("Please provide a package name.");
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Remove and add commands
|
|
24
|
+
const removeCmd = `yarn remove ${packageName}`;
|
|
25
|
+
const addCmd = `yarn add ${packageName} ${flags.join(" ")}`.trim();
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// Check if the package is installed before removing
|
|
29
|
+
let isInstalled = false;
|
|
30
|
+
try {
|
|
31
|
+
const listOutput = execSync(`yarn list --pattern "${packageName}" --depth=0`, { encoding: "utf8" });
|
|
32
|
+
isInstalled = listOutput.includes(packageName + "@");
|
|
33
|
+
} catch (_e) {
|
|
34
|
+
// If yarn list fails, assume not installed
|
|
35
|
+
isInstalled = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isInstalled) {
|
|
39
|
+
console.log(`Running: ${removeCmd}`);
|
|
40
|
+
execSync(removeCmd, { stdio: "inherit" });
|
|
41
|
+
} else {
|
|
42
|
+
console.warn(`Package "${packageName}" was not installed or not referenced, skipping remove.`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(`Running: ${addCmd}`);
|
|
46
|
+
execSync(addCmd, { stdio: "inherit" });
|
|
47
|
+
} catch (err) {
|
|
48
|
+
process.exit(err.status || 1);
|
|
49
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
require_utils
|
|
4
|
+
} from "./chunk-APBWENF6.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__commonJS,
|
|
7
|
+
__require,
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-AASHBCRW.mjs";
|
|
10
|
+
|
|
11
|
+
// src/yarn-reinstall.cjs
|
|
12
|
+
var require_yarn_reinstall = __commonJS({
|
|
13
|
+
"src/yarn-reinstall.cjs"() {
|
|
14
|
+
init_esm_shims();
|
|
15
|
+
var { execSync } = __require("child_process");
|
|
16
|
+
var { getArgs } = require_utils();
|
|
17
|
+
var args = getArgs();
|
|
18
|
+
var positional = args._ || [];
|
|
19
|
+
if (positional.length === 0) {
|
|
20
|
+
console.error("Usage: yarn-reinstall <packageName> [--dev|-D|--peer|-P|--optional|-O]");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
var packageName = positional[0];
|
|
24
|
+
var flags = positional.slice(1).concat(
|
|
25
|
+
Object.keys(args).filter((k) => k !== "_" && args[k] === true).map((k) => `--${k}`)
|
|
26
|
+
);
|
|
27
|
+
if (!packageName) {
|
|
28
|
+
console.error("Please provide a package name.");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
var removeCmd = `yarn remove ${packageName}`;
|
|
32
|
+
var addCmd = `yarn add ${packageName} ${flags.join(" ")}`.trim();
|
|
33
|
+
try {
|
|
34
|
+
let isInstalled = false;
|
|
35
|
+
try {
|
|
36
|
+
const listOutput = execSync(`yarn list --pattern "${packageName}" --depth=0`, { encoding: "utf8" });
|
|
37
|
+
isInstalled = listOutput.includes(packageName + "@");
|
|
38
|
+
} catch (_e) {
|
|
39
|
+
isInstalled = false;
|
|
40
|
+
}
|
|
41
|
+
if (isInstalled) {
|
|
42
|
+
console.log(`Running: ${removeCmd}`);
|
|
43
|
+
execSync(removeCmd, { stdio: "inherit" });
|
|
44
|
+
} else {
|
|
45
|
+
console.warn(`Package "${packageName}" was not installed or not referenced, skipping remove.`);
|
|
46
|
+
}
|
|
47
|
+
console.log(`Running: ${addCmd}`);
|
|
48
|
+
execSync(addCmd, { stdio: "inherit" });
|
|
49
|
+
} catch (err) {
|
|
50
|
+
process.exit(err.status || 1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export default require_yarn_reinstall();
|