@auis/cli 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/install.mjs +26 -2
package/package.json
CHANGED
package/src/install.mjs
CHANGED
|
@@ -517,7 +517,27 @@ function restore(root, artifact, surgical) {
|
|
|
517
517
|
return "edited";
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
-
|
|
520
|
+
/**
|
|
521
|
+
* True when the host's lockfile still names the kit. It happens when init could
|
|
522
|
+
* not install (the install failed, or --no-install) and the person ran it
|
|
523
|
+
* afterwards, as init told them to: the lockfile changed after init, so the
|
|
524
|
+
* manifest holds nothing to restore it from.
|
|
525
|
+
*/
|
|
526
|
+
function lockfileNamesKit(root, packageManager) {
|
|
527
|
+
for (const file of LOCKFILES[packageManager ?? "npm"] ?? []) {
|
|
528
|
+
const bytes = readMaybe(abs(root, file));
|
|
529
|
+
if (bytes && bytes.includes(KIT_PACKAGE)) return true;
|
|
530
|
+
}
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export async function uninstall({
|
|
535
|
+
directory = ".",
|
|
536
|
+
install = true,
|
|
537
|
+
purge = false,
|
|
538
|
+
force = false,
|
|
539
|
+
run = exec,
|
|
540
|
+
} = {}) {
|
|
521
541
|
const root = path.resolve(directory);
|
|
522
542
|
const manifest = readManifest(root);
|
|
523
543
|
if (!manifest) {
|
|
@@ -599,9 +619,13 @@ export async function uninstall({ directory = ".", install = true, purge = false
|
|
|
599
619
|
}
|
|
600
620
|
}
|
|
601
621
|
|
|
622
|
+
// The dependency is gone from package.json by now, so an install drops the
|
|
623
|
+
// kit's entries from a lockfile init never got to record.
|
|
624
|
+
if (!needsInstall && lockfileNamesKit(root, manifest.packageManager)) needsInstall = true;
|
|
625
|
+
|
|
602
626
|
if (needsInstall && install) {
|
|
603
627
|
const pm = manifest.packageManager ?? "npm";
|
|
604
|
-
const { ok } = await
|
|
628
|
+
const { ok } = await run(pm, ["install"], { cwd: root, inherit: true });
|
|
605
629
|
if (ok) step("lockfile", color.dim(`${pm} install`));
|
|
606
630
|
else warn(`${pm} install failed — run it yourself to drop ${manifest.kit?.package ?? KIT_PACKAGE} from the lockfile.`);
|
|
607
631
|
}
|