open-classify 0.9.2 → 0.9.3
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/bin/open-classify.mjs +44 -9
- package/package.json +1 -1
package/bin/open-classify.mjs
CHANGED
|
@@ -160,6 +160,8 @@ function parseUninstallFlags(args) {
|
|
|
160
160
|
yes: false,
|
|
161
161
|
dryRun: false,
|
|
162
162
|
force: false,
|
|
163
|
+
keepPackage: false,
|
|
164
|
+
packageManager: null,
|
|
163
165
|
classifierDir: "classifiers",
|
|
164
166
|
};
|
|
165
167
|
|
|
@@ -168,6 +170,9 @@ function parseUninstallFlags(args) {
|
|
|
168
170
|
if (arg === "--yes" || arg === "-y") flags.yes = true;
|
|
169
171
|
else if (arg === "--dry-run") flags.dryRun = true;
|
|
170
172
|
else if (arg === "--force") flags.force = true;
|
|
173
|
+
else if (arg === "--keep-package") flags.keepPackage = true;
|
|
174
|
+
else if (arg === "--package-manager" && args[i + 1]) flags.packageManager = args[++i];
|
|
175
|
+
else if (arg.startsWith("--package-manager=")) flags.packageManager = arg.split("=")[1];
|
|
171
176
|
else if (arg === "--classifier-dir" && args[i + 1]) flags.classifierDir = args[++i];
|
|
172
177
|
else if (arg.startsWith("--classifier-dir=")) flags.classifierDir = arg.split("=")[1];
|
|
173
178
|
}
|
|
@@ -182,9 +187,10 @@ Commands:
|
|
|
182
187
|
init [options] Scaffold open-classify.config.json and classifiers/ in the
|
|
183
188
|
current directory. Re-run safe: existing files are skipped.
|
|
184
189
|
|
|
185
|
-
uninstall Remove open-classify scaffold
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
uninstall Remove the open-classify scaffold and uninstall the
|
|
191
|
+
package. Use --force to also delete active/custom
|
|
192
|
+
classifiers, --keep-package to leave the npm dependency
|
|
193
|
+
in place.
|
|
188
194
|
|
|
189
195
|
doctor Check that the install, config, Ollama, and classifiers are
|
|
190
196
|
all working. Exits non-zero on failure.
|
|
@@ -205,6 +211,8 @@ Options for init:
|
|
|
205
211
|
Options for uninstall:
|
|
206
212
|
--dry-run Preview what would be removed; don't delete anything
|
|
207
213
|
--force Remove the whole classifiers/ directory
|
|
214
|
+
--keep-package Don't run the package manager uninstall step
|
|
215
|
+
--package-manager <m> npm | pnpm | yarn | bun (default: auto-detect)
|
|
208
216
|
--classifier-dir <p> Directory for classifiers (default: ./classifiers)
|
|
209
217
|
--yes, -y Accept all prompts (CI mode)
|
|
210
218
|
|
|
@@ -546,12 +554,21 @@ function showDiffs(conflicts, cwd, classifierDir, config = DEFAULT_CONFIG) {
|
|
|
546
554
|
// uninstall
|
|
547
555
|
// ---------------------------------------------------------------------------
|
|
548
556
|
|
|
549
|
-
async function runUninstall({ cwd, yes, dryRun, force, classifierDir }) {
|
|
557
|
+
async function runUninstall({ cwd, yes, dryRun, force, keepPackage, packageManager, classifierDir }) {
|
|
550
558
|
const resolvedClassifierDir = resolve(cwd, classifierDir);
|
|
551
559
|
const plan = planUninstall(cwd, { classifierDir: resolvedClassifierDir, force });
|
|
552
560
|
|
|
553
|
-
|
|
554
|
-
|
|
561
|
+
const pkgPath = join(cwd, "package.json");
|
|
562
|
+
let pkg = null;
|
|
563
|
+
if (existsSync(pkgPath)) {
|
|
564
|
+
try { pkg = JSON.parse(readFileSync(pkgPath, "utf8")); } catch { pkg = null; }
|
|
565
|
+
}
|
|
566
|
+
const packageInstalled = pkg !== null && isOpenClassifyDep(pkg);
|
|
567
|
+
const willRemovePackage = !keepPackage && packageInstalled;
|
|
568
|
+
const pm = packageManager || detectPackageManager(cwd);
|
|
569
|
+
|
|
570
|
+
if (plan.toRemove.length === 0 && !willRemovePackage) {
|
|
571
|
+
process.stdout.write("Nothing to remove — no open-classify scaffold or dependency found.\n");
|
|
555
572
|
if (plan.toSkip.length > 0) {
|
|
556
573
|
process.stdout.write("\nSkipped active/custom classifier dirs:\n");
|
|
557
574
|
for (const p of plan.toSkip) process.stdout.write(` ${p}\n`);
|
|
@@ -560,8 +577,11 @@ async function runUninstall({ cwd, yes, dryRun, force, classifierDir }) {
|
|
|
560
577
|
return;
|
|
561
578
|
}
|
|
562
579
|
|
|
563
|
-
process.stdout.write(`\nThe following
|
|
580
|
+
process.stdout.write(`\nThe following will be removed from ${cwd}:\n\n`);
|
|
564
581
|
for (const p of plan.toRemove) process.stdout.write(` ${p}\n`);
|
|
582
|
+
if (willRemovePackage) {
|
|
583
|
+
process.stdout.write(` open-classify (via ${pm} uninstall)\n`);
|
|
584
|
+
}
|
|
565
585
|
|
|
566
586
|
if (plan.toSkip.length > 0) {
|
|
567
587
|
process.stdout.write("\nSkipped active/custom classifier dirs:\n");
|
|
@@ -569,6 +589,10 @@ async function runUninstall({ cwd, yes, dryRun, force, classifierDir }) {
|
|
|
569
589
|
process.stdout.write("\nUse --force to remove the whole classifiers/ directory.\n");
|
|
570
590
|
}
|
|
571
591
|
|
|
592
|
+
if (keepPackage && packageInstalled) {
|
|
593
|
+
process.stdout.write("\nKeeping the open-classify package (--keep-package).\n");
|
|
594
|
+
}
|
|
595
|
+
|
|
572
596
|
if (dryRun) {
|
|
573
597
|
process.stdout.write("\n(dry run — nothing removed)\n");
|
|
574
598
|
return;
|
|
@@ -584,8 +608,19 @@ async function runUninstall({ cwd, yes, dryRun, force, classifierDir }) {
|
|
|
584
608
|
|
|
585
609
|
process.stdout.write("\n");
|
|
586
610
|
for (const action of plan.actions) action();
|
|
587
|
-
|
|
588
|
-
|
|
611
|
+
if (plan.toRemove.length > 0) {
|
|
612
|
+
process.stdout.write("\n✓ removed open-classify scaffold\n");
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (willRemovePackage) {
|
|
616
|
+
process.stdout.write(`\n Running: ${pm} uninstall open-classify\n\n`);
|
|
617
|
+
const result = spawnSync(pm, ["uninstall", "open-classify"], { cwd, stdio: "inherit" });
|
|
618
|
+
if (result.status !== 0) {
|
|
619
|
+
process.stderr.write(`\n✖ Package uninstall failed. Run manually: ${pm} uninstall open-classify\n`);
|
|
620
|
+
process.exit(1);
|
|
621
|
+
}
|
|
622
|
+
process.stdout.write("\n✓ removed open-classify package\n");
|
|
623
|
+
}
|
|
589
624
|
}
|
|
590
625
|
|
|
591
626
|
function planUninstall(cwd, { classifierDir, force }) {
|