@kud/soap-cli 3.0.8 → 3.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 (2) hide show
  1. package/dist/index.js +54 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -242,8 +242,9 @@ var rawArgs = process.argv.slice(2);
242
242
  var firstArg = rawArgs[0];
243
243
  var param = rawArgs.find((a) => !a.startsWith("-"));
244
244
  var yes = rawArgs.includes("--yes") || rawArgs.includes("-y");
245
+ var yesDangerously = rawArgs.includes("--yes-dangerously");
245
246
  if (firstArg === "--version" || firstArg === "-v") {
246
- console.log("3.0.8");
247
+ console.log("3.0.11");
247
248
  process.exit(0);
248
249
  }
249
250
  if (!firstArg || firstArg === "--help" || firstArg === "-h") {
@@ -271,6 +272,7 @@ if (!firstArg || firstArg === "--help" || firstArg === "-h") {
271
272
 
272
273
  ${chalk.bold("Flags:")}
273
274
  ${chalk.cyan("--yes")}, ${chalk.cyan("-y")} Skip all prompts (auto-select all files, auto-confirm brew uninstall)
275
+ ${chalk.cyan("--yes-dangerously")} Like --yes, but also auto-confirms sudo rm for root-owned files
274
276
 
275
277
  ${chalk.bold("Environment:")}
276
278
  ${chalk.yellow("SOAP_DEBUG=1")} Enable verbose shell output
@@ -364,14 +366,51 @@ try {
364
366
  if (skipped.length > 0) {
365
367
  console.log("");
366
368
  signale.warn(
367
- `Skipped ${chalk.bold(skipped.length)} file(s) \u2014 no permission (may require sudo):`
369
+ `${chalk.bold(skipped.length)} file(s) require root \u2014 could not move to Trash:`
368
370
  );
369
371
  skipped.forEach((p) => console.log(` ${chalk.dim("\xB7")} ${chalk.dim(p)}`));
372
+ const { sudoDelete } = yesDangerously ? { sudoDelete: true } : await inquirer.prompt([
373
+ {
374
+ type: "confirm",
375
+ name: "sudoDelete",
376
+ message: `Run ${chalk.bold("sudo rm")} on these files?`,
377
+ default: false
378
+ }
379
+ ]);
380
+ if (sudoDelete) {
381
+ console.log("");
382
+ for (const file of skipped) {
383
+ try {
384
+ await $2`sudo rm -rf ${file}`;
385
+ signale.success(`Deleted: ${chalk.dim(file)}`);
386
+ } catch {
387
+ signale.error(`Failed to delete: ${chalk.dim(file)}`);
388
+ }
389
+ }
390
+ }
370
391
  }
371
392
  } else if (!isAppFilesEmpty) {
372
393
  signale.info("No files selected \u2014 nothing moved to Trash.");
373
394
  }
374
395
  if (isCask && deletedCaskWish) {
396
+ const isAdmin = (await $2`id -Gn`).stdout.trim().split(" ").includes("admin");
397
+ if (!isAdmin && !yes) {
398
+ const { ready } = await inquirer.prompt([
399
+ {
400
+ type: "confirm",
401
+ name: "ready",
402
+ message: `This step requires admin rights and you don't appear to have them.
403
+ Can you become an admin before we proceed?`,
404
+ default: false
405
+ }
406
+ ]);
407
+ if (!ready) {
408
+ signale.info("Skipped Homebrew uninstall.");
409
+ console.log("");
410
+ signale.success("Done.");
411
+ process.exit(0);
412
+ }
413
+ }
375
414
  console.log("");
376
415
  signale.pending("Running Homebrew uninstall\u2026");
377
416
  await $2`brew uninstall --zap ${param}`;
@@ -379,14 +418,15 @@ try {
379
418
  console.log("");
380
419
  signale.success("Done.");
381
420
  } catch (error) {
421
+ const message = error instanceof Error ? error.message : "An unexpected error occurred.";
422
+ const isPermissionError = message.includes("sudoers") || message.includes("Permission denied");
423
+ const isCaskNotInstalled = message.includes("is not installed");
382
424
  console.log("");
383
- signale.error(
384
- error instanceof Error ? error.message : "An unexpected error occurred."
385
- );
425
+ signale.error(message);
386
426
  if (process.env.SOAP_DEBUG === "1") {
387
427
  console.error(error);
388
428
  }
389
- if (isCask) {
429
+ if (isCask && !isPermissionError && !isCaskNotInstalled) {
390
430
  const { forceUninstall } = await inquirer.prompt([
391
431
  {
392
432
  type: "confirm",
@@ -402,5 +442,13 @@ Force-run ${chalk.bold(`brew uninstall --zap --force ${param}`)}?`,
402
442
  await $2`brew uninstall --zap --force ${param}`;
403
443
  signale.success("Force uninstall complete.");
404
444
  }
445
+ } else if (isCask && isPermissionError) {
446
+ signale.info(
447
+ "Re-run with an admin account to complete the Homebrew uninstall."
448
+ );
449
+ } else if (isCask && isCaskNotInstalled) {
450
+ signale.info(
451
+ `Cask "${param}" is not registered in Homebrew \u2014 skipping brew uninstall.`
452
+ );
405
453
  }
406
454
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/soap-cli",
3
- "version": "3.0.8",
3
+ "version": "3.0.11",
4
4
  "description": "An app cleaner cli for macOS",
5
5
  "main": "dist/index.js",
6
6
  "bin": {