@kud/soap-cli 3.0.8 → 3.0.9

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 +27 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -243,7 +243,7 @@ var firstArg = rawArgs[0];
243
243
  var param = rawArgs.find((a) => !a.startsWith("-"));
244
244
  var yes = rawArgs.includes("--yes") || rawArgs.includes("-y");
245
245
  if (firstArg === "--version" || firstArg === "-v") {
246
- console.log("3.0.8");
246
+ console.log("3.0.9");
247
247
  process.exit(0);
248
248
  }
249
249
  if (!firstArg || firstArg === "--help" || firstArg === "-h") {
@@ -372,6 +372,24 @@ try {
372
372
  signale.info("No files selected \u2014 nothing moved to Trash.");
373
373
  }
374
374
  if (isCask && deletedCaskWish) {
375
+ const isAdmin = (await $2`id -Gn`).stdout.trim().split(" ").includes("admin");
376
+ if (!isAdmin && !yes) {
377
+ const { ready } = await inquirer.prompt([
378
+ {
379
+ type: "confirm",
380
+ name: "ready",
381
+ message: `This step requires admin rights and you don't appear to have them.
382
+ Can you become an admin before we proceed?`,
383
+ default: false
384
+ }
385
+ ]);
386
+ if (!ready) {
387
+ signale.info("Skipped Homebrew uninstall.");
388
+ console.log("");
389
+ signale.success("Done.");
390
+ process.exit(0);
391
+ }
392
+ }
375
393
  console.log("");
376
394
  signale.pending("Running Homebrew uninstall\u2026");
377
395
  await $2`brew uninstall --zap ${param}`;
@@ -379,14 +397,14 @@ try {
379
397
  console.log("");
380
398
  signale.success("Done.");
381
399
  } catch (error) {
400
+ const message = error instanceof Error ? error.message : "An unexpected error occurred.";
401
+ const isPermissionError = message.includes("sudoers") || message.includes("Permission denied");
382
402
  console.log("");
383
- signale.error(
384
- error instanceof Error ? error.message : "An unexpected error occurred."
385
- );
403
+ signale.error(message);
386
404
  if (process.env.SOAP_DEBUG === "1") {
387
405
  console.error(error);
388
406
  }
389
- if (isCask) {
407
+ if (isCask && !isPermissionError) {
390
408
  const { forceUninstall } = await inquirer.prompt([
391
409
  {
392
410
  type: "confirm",
@@ -402,5 +420,9 @@ Force-run ${chalk.bold(`brew uninstall --zap --force ${param}`)}?`,
402
420
  await $2`brew uninstall --zap --force ${param}`;
403
421
  signale.success("Force uninstall complete.");
404
422
  }
423
+ } else if (isCask && isPermissionError) {
424
+ signale.info(
425
+ "Re-run with an admin account to complete the Homebrew uninstall."
426
+ );
405
427
  }
406
428
  }
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.9",
4
4
  "description": "An app cleaner cli for macOS",
5
5
  "main": "dist/index.js",
6
6
  "bin": {