@kud/soap-cli 3.0.6 → 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.
- package/dist/index.js +49 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ var getCaskInfo = async (caskName) => {
|
|
|
176
176
|
let appName = null;
|
|
177
177
|
for (const artifact of caskData.artifacts) {
|
|
178
178
|
if (artifact.app) {
|
|
179
|
-
appName = artifact.app[0];
|
|
179
|
+
appName = artifact.app[0] || null;
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -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.
|
|
246
|
+
console.log("3.0.9");
|
|
247
247
|
process.exit(0);
|
|
248
248
|
}
|
|
249
249
|
if (!firstArg || firstArg === "--help" || firstArg === "-h") {
|
|
@@ -346,18 +346,50 @@ try {
|
|
|
346
346
|
}
|
|
347
347
|
]);
|
|
348
348
|
if (!isAppFilesEmpty && deletedFilesWish && deletedFilesWish.length > 0) {
|
|
349
|
-
|
|
349
|
+
const skipped = [];
|
|
350
|
+
const moved = [];
|
|
351
|
+
for (const file of deletedFilesWish) {
|
|
352
|
+
try {
|
|
353
|
+
await trash(file);
|
|
354
|
+
moved.push(file);
|
|
355
|
+
} catch {
|
|
356
|
+
skipped.push(file);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
350
359
|
console.log("");
|
|
351
|
-
|
|
352
|
-
`Moved ${chalk.bold(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
360
|
+
if (moved.length > 0) {
|
|
361
|
+
signale.success(`Moved ${chalk.bold(moved.length)} file(s) to Trash:`);
|
|
362
|
+
moved.forEach((p) => console.log(` ${chalk.dim("\xB7")} ${chalk.dim(p)}`));
|
|
363
|
+
}
|
|
364
|
+
if (skipped.length > 0) {
|
|
365
|
+
console.log("");
|
|
366
|
+
signale.warn(
|
|
367
|
+
`Skipped ${chalk.bold(skipped.length)} file(s) \u2014 no permission (may require sudo):`
|
|
368
|
+
);
|
|
369
|
+
skipped.forEach((p) => console.log(` ${chalk.dim("\xB7")} ${chalk.dim(p)}`));
|
|
370
|
+
}
|
|
357
371
|
} else if (!isAppFilesEmpty) {
|
|
358
372
|
signale.info("No files selected \u2014 nothing moved to Trash.");
|
|
359
373
|
}
|
|
360
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
|
+
}
|
|
361
393
|
console.log("");
|
|
362
394
|
signale.pending("Running Homebrew uninstall\u2026");
|
|
363
395
|
await $2`brew uninstall --zap ${param}`;
|
|
@@ -365,14 +397,14 @@ try {
|
|
|
365
397
|
console.log("");
|
|
366
398
|
signale.success("Done.");
|
|
367
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");
|
|
368
402
|
console.log("");
|
|
369
|
-
signale.error(
|
|
370
|
-
error instanceof Error ? error.message : "An unexpected error occurred."
|
|
371
|
-
);
|
|
403
|
+
signale.error(message);
|
|
372
404
|
if (process.env.SOAP_DEBUG === "1") {
|
|
373
405
|
console.error(error);
|
|
374
406
|
}
|
|
375
|
-
if (isCask) {
|
|
407
|
+
if (isCask && !isPermissionError) {
|
|
376
408
|
const { forceUninstall } = await inquirer.prompt([
|
|
377
409
|
{
|
|
378
410
|
type: "confirm",
|
|
@@ -388,5 +420,9 @@ Force-run ${chalk.bold(`brew uninstall --zap --force ${param}`)}?`,
|
|
|
388
420
|
await $2`brew uninstall --zap --force ${param}`;
|
|
389
421
|
signale.success("Force uninstall complete.");
|
|
390
422
|
}
|
|
423
|
+
} else if (isCask && isPermissionError) {
|
|
424
|
+
signale.info(
|
|
425
|
+
"Re-run with an admin account to complete the Homebrew uninstall."
|
|
426
|
+
);
|
|
391
427
|
}
|
|
392
428
|
}
|