fixmyslop 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/bin/fixmyslop.js +30 -17
  2. package/package.json +1 -1
package/bin/fixmyslop.js CHANGED
@@ -1,33 +1,46 @@
1
1
  #!/usr/bin/env node
2
- // Thin launcher: runs the FixMySlop Python CLI of the same version via uvx or pipx,
3
- // or an existing local install. No Python packaging knowledge required.
2
+ // Thin launcher: runs the FixMySlop Python CLI of the SAME version as this npm package —
3
+ // a matching local install if there is one, otherwise via uvx or pipx.
4
4
  "use strict";
5
5
  const { spawnSync } = require("node:child_process");
6
6
  const { version } = require("../package.json");
7
7
 
8
8
  const args = process.argv.slice(2);
9
+ const VERSION_PROBE =
10
+ "import importlib.metadata as m, sys; print(m.version('fixmyslop'))";
9
11
 
10
- function has(cmd, probe = ["--version"]) {
11
- const r = spawnSync(cmd, probe, { stdio: "ignore" });
12
- return r.status === 0;
12
+ function ok(cmd, probe) {
13
+ const r = spawnSync(cmd, probe, { encoding: "utf8" });
14
+ return r.status === 0 ? (r.stdout || "").trim() || "ok" : null;
13
15
  }
14
16
 
15
17
  function run(cmd, cmdArgs) {
16
18
  const r = spawnSync(cmd, cmdArgs, { stdio: "inherit" });
17
- if (r.error) return null;
19
+ if (r.error) return;
18
20
  process.exit(r.status ?? 1);
19
21
  }
20
22
 
21
- const python = ["python3", "python", "py"].find((p) => has(p, ["-c", "import fixmyslop"]));
22
-
23
- if (python) run(python, ["-m", "fixmyslop", ...args]);
24
- if (has("uvx")) run("uvx", [`fixmyslop@${version}`, ...args]);
25
- if (has("pipx")) run("pipx", ["run", "--spec", `fixmyslop==${version}`, "fixmyslop", ...args]);
23
+ let outdated = null;
24
+ for (const python of ["python3", "python", "py"]) {
25
+ const installed = ok(python, ["-c", VERSION_PROBE]);
26
+ if (installed === version) run(python, ["-m", "fixmyslop", ...args]);
27
+ if (installed && !outdated) outdated = { python, installed };
28
+ }
29
+ if (ok("uvx", ["--version"])) run("uvx", [`fixmyslop@${version}`, ...args]);
30
+ if (ok("pipx", ["--version"])) run("pipx", ["run", "--spec", `fixmyslop==${version}`, "fixmyslop", ...args]);
26
31
 
27
- console.error(
28
- "FixMySlop needs Python 3.10+ and one of these:\n" +
29
- " uv https://docs.astral.sh/uv/ (then `npx fixmyslop` just works)\n" +
30
- " pipx https://pipx.pypa.io/\n" +
31
- " or: pip install fixmyslop"
32
- );
32
+ if (outdated) {
33
+ console.error(
34
+ `Found fixmyslop ${outdated.installed}, but this launcher runs ${version}. Upgrade with:\n` +
35
+ ` ${outdated.python} -m pip install -U "fixmyslop==${version}"\n` +
36
+ "or install uv (https://docs.astral.sh/uv/) so npx can fetch the right version automatically."
37
+ );
38
+ } else {
39
+ console.error(
40
+ "FixMySlop needs Python 3.10+ and one of these:\n" +
41
+ " uv https://docs.astral.sh/uv/ (then `npx fixmyslop` just works)\n" +
42
+ " pipx https://pipx.pypa.io/\n" +
43
+ ` or: pip install "fixmyslop==${version}"`
44
+ );
45
+ }
33
46
  process.exit(127);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fixmyslop",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The slop linter for the AI-agent era: catch AI slop in UI and code in milliseconds, then let your agent fix it.",
5
5
  "bin": { "fixmyslop": "bin/fixmyslop.js" },
6
6
  "files": ["bin/", "README.md"],