@kud/soap-cli 3.0.9 → 3.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/dist/index.js +31 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,7 +176,8 @@ var getCaskInfo = async (caskName) => {
|
|
|
176
176
|
let appName = null;
|
|
177
177
|
for (const artifact of caskData.artifacts) {
|
|
178
178
|
if (artifact.app) {
|
|
179
|
-
|
|
179
|
+
const raw = artifact.app[0] || null;
|
|
180
|
+
appName = raw ? raw.replace(/\.app$/i, "") : null;
|
|
180
181
|
break;
|
|
181
182
|
}
|
|
182
183
|
}
|
|
@@ -242,8 +243,9 @@ var rawArgs = process.argv.slice(2);
|
|
|
242
243
|
var firstArg = rawArgs[0];
|
|
243
244
|
var param = rawArgs.find((a) => !a.startsWith("-"));
|
|
244
245
|
var yes = rawArgs.includes("--yes") || rawArgs.includes("-y");
|
|
246
|
+
var yesDangerously = rawArgs.includes("--yes-dangerously");
|
|
245
247
|
if (firstArg === "--version" || firstArg === "-v") {
|
|
246
|
-
console.log("3.0.
|
|
248
|
+
console.log("3.0.12");
|
|
247
249
|
process.exit(0);
|
|
248
250
|
}
|
|
249
251
|
if (!firstArg || firstArg === "--help" || firstArg === "-h") {
|
|
@@ -271,6 +273,7 @@ if (!firstArg || firstArg === "--help" || firstArg === "-h") {
|
|
|
271
273
|
|
|
272
274
|
${chalk.bold("Flags:")}
|
|
273
275
|
${chalk.cyan("--yes")}, ${chalk.cyan("-y")} Skip all prompts (auto-select all files, auto-confirm brew uninstall)
|
|
276
|
+
${chalk.cyan("--yes-dangerously")} Like --yes, but also auto-confirms sudo rm for root-owned files
|
|
274
277
|
|
|
275
278
|
${chalk.bold("Environment:")}
|
|
276
279
|
${chalk.yellow("SOAP_DEBUG=1")} Enable verbose shell output
|
|
@@ -364,9 +367,28 @@ try {
|
|
|
364
367
|
if (skipped.length > 0) {
|
|
365
368
|
console.log("");
|
|
366
369
|
signale.warn(
|
|
367
|
-
|
|
370
|
+
`${chalk.bold(skipped.length)} file(s) require root \u2014 could not move to Trash:`
|
|
368
371
|
);
|
|
369
372
|
skipped.forEach((p) => console.log(` ${chalk.dim("\xB7")} ${chalk.dim(p)}`));
|
|
373
|
+
const { sudoDelete } = yesDangerously ? { sudoDelete: true } : await inquirer.prompt([
|
|
374
|
+
{
|
|
375
|
+
type: "confirm",
|
|
376
|
+
name: "sudoDelete",
|
|
377
|
+
message: `Run ${chalk.bold("sudo rm")} on these files?`,
|
|
378
|
+
default: false
|
|
379
|
+
}
|
|
380
|
+
]);
|
|
381
|
+
if (sudoDelete) {
|
|
382
|
+
console.log("");
|
|
383
|
+
for (const file of skipped) {
|
|
384
|
+
try {
|
|
385
|
+
await $2`sudo rm -rf ${file}`;
|
|
386
|
+
signale.success(`Deleted: ${chalk.dim(file)}`);
|
|
387
|
+
} catch {
|
|
388
|
+
signale.error(`Failed to delete: ${chalk.dim(file)}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
370
392
|
}
|
|
371
393
|
} else if (!isAppFilesEmpty) {
|
|
372
394
|
signale.info("No files selected \u2014 nothing moved to Trash.");
|
|
@@ -399,12 +421,13 @@ Can you become an admin before we proceed?`,
|
|
|
399
421
|
} catch (error) {
|
|
400
422
|
const message = error instanceof Error ? error.message : "An unexpected error occurred.";
|
|
401
423
|
const isPermissionError = message.includes("sudoers") || message.includes("Permission denied");
|
|
424
|
+
const isCaskNotInstalled = message.includes("is not installed");
|
|
402
425
|
console.log("");
|
|
403
426
|
signale.error(message);
|
|
404
427
|
if (process.env.SOAP_DEBUG === "1") {
|
|
405
428
|
console.error(error);
|
|
406
429
|
}
|
|
407
|
-
if (isCask && !isPermissionError) {
|
|
430
|
+
if (isCask && !isPermissionError && !isCaskNotInstalled) {
|
|
408
431
|
const { forceUninstall } = await inquirer.prompt([
|
|
409
432
|
{
|
|
410
433
|
type: "confirm",
|
|
@@ -424,5 +447,9 @@ Force-run ${chalk.bold(`brew uninstall --zap --force ${param}`)}?`,
|
|
|
424
447
|
signale.info(
|
|
425
448
|
"Re-run with an admin account to complete the Homebrew uninstall."
|
|
426
449
|
);
|
|
450
|
+
} else if (isCask && isCaskNotInstalled) {
|
|
451
|
+
signale.info(
|
|
452
|
+
`Cask "${param}" is not registered in Homebrew \u2014 skipping brew uninstall.`
|
|
453
|
+
);
|
|
427
454
|
}
|
|
428
455
|
}
|