@logionsh/cli 0.1.1 → 0.1.2

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.
@@ -25,49 +25,14 @@ var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__
25
25
 
26
26
  // src/bin/logion.ts
27
27
  var import_node_child_process = require("child_process");
28
- var import_node_fs2 = __toESM(require("fs"));
29
-
30
- // src/lib/which.ts
31
28
  var import_node_fs = __toESM(require("fs"));
29
+ var import_node_os = __toESM(require("os"));
32
30
  var import_node_path = __toESM(require("path"));
33
- function candidatesForName(name) {
34
- if (process.platform !== "win32") {
35
- return [name];
36
- }
37
- const pathext = (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean);
38
- if (import_node_path.default.extname(name)) {
39
- return [name];
40
- }
41
- return [name, ...pathext.map((ext) => name + ext.toLowerCase())];
42
- }
43
- function which(name, options = {}) {
44
- const excluded = new Set(
45
- (options.excludeRealpaths ?? []).map((p) => import_node_fs.default.realpathSync.native(p))
46
- );
47
- const rawPath = process.env.PATH ?? "";
48
- const dirs = rawPath.split(import_node_path.default.delimiter).filter(Boolean);
49
- for (const dir of dirs) {
50
- for (const candidate of candidatesForName(name)) {
51
- const full = import_node_path.default.join(dir, candidate);
52
- try {
53
- const stat = import_node_fs.default.statSync(full);
54
- if (stat.isFile() && !excluded.has(import_node_fs.default.realpathSync.native(full))) {
55
- return full;
56
- }
57
- } catch {
58
- }
59
- }
60
- }
61
- return null;
62
- }
63
-
64
- // src/bin/logion.ts
65
- var target = which("logion", {
66
- excludeRealpaths: [import_node_fs2.default.realpathSync.native(__filename)]
67
- });
68
- if (!target) {
31
+ var managedVenvDir = import_node_path.default.join(import_node_os.default.homedir(), ".logion", "npm-managed-venv");
32
+ var target = process.platform === "win32" ? import_node_path.default.join(managedVenvDir, "Scripts", "logion.exe") : import_node_path.default.join(managedVenvDir, "bin", "logion");
33
+ if (!import_node_fs.default.existsSync(target)) {
69
34
  process.stderr.write(
70
- "logion binary not found. Reinstall with `npm install -g @logionsh/cli` or install directly via `pipx install logion-cli`.\n"
35
+ "logion binary not found in the npm-managed environment. Reinstall with `npm install -g @logionsh/cli` or rerun `npx @logionsh/cli`.\n"
71
36
  );
72
37
  process.exit(127);
73
38
  }
@@ -252,7 +252,6 @@ var HOME = import_node_os2.default.homedir();
252
252
  var LOGION_DIR2 = import_node_path3.default.join(HOME, ".logion");
253
253
  var MANAGED_VENV_DIR = import_node_path3.default.join(LOGION_DIR2, "npm-managed-venv");
254
254
  var MARKER_PATH = import_node_path3.default.join(LOGION_DIR2, "npm-wrapper-installer.json");
255
- var LOCAL_BIN = import_node_path3.default.join(HOME, ".local", "bin");
256
255
  var PLACEHOLDER_VERSION = "0.0.0-placeholder";
257
256
  function log(msg) {
258
257
  process.stderr.write(`[logion-postinstall] ${msg}
@@ -313,48 +312,15 @@ function venvBin(name) {
313
312
  }
314
313
  return import_node_path3.default.join(MANAGED_VENV_DIR, "bin", name);
315
314
  }
316
- function linkOrCopy(src, dest) {
317
- if (import_node_fs3.default.existsSync(dest)) {
318
- import_node_fs3.default.unlinkSync(dest);
319
- }
320
- try {
321
- import_node_fs3.default.symlinkSync(src, dest);
322
- } catch {
323
- import_node_fs3.default.copyFileSync(src, dest);
324
- }
325
- }
326
- function shimNamesFor(base) {
327
- return process.platform === "win32" ? [`${base}.exe`] : [base];
328
- }
329
315
  function installViaVenv(version, py) {
330
316
  log(`Installing logion-cli==${version} via managed venv...`);
331
- runChecked(py.cmd, [...py.args, "-m", "venv", MANAGED_VENV_DIR]);
317
+ runChecked(py.cmd, [...py.args, "-m", "venv", "--clear", MANAGED_VENV_DIR]);
332
318
  runChecked(venvBin("pip"), ["install", `logion-cli==${version}`]);
333
- import_node_fs3.default.mkdirSync(LOCAL_BIN, { recursive: true });
334
- for (const base of ["logion"]) {
335
- const src = venvBin(base);
336
- if (!import_node_fs3.default.existsSync(src)) {
337
- continue;
338
- }
339
- for (const destName of shimNamesFor(base)) {
340
- const dest = import_node_path3.default.join(LOCAL_BIN, destName);
341
- try {
342
- linkOrCopy(src, dest);
343
- } catch (error) {
344
- const msg = error instanceof Error ? error.message : String(error);
345
- log(
346
- `Warning: could not create shim ${dest}: ${msg}. Add ${LOCAL_BIN} to PATH manually.`
347
- );
348
- }
349
- }
350
- }
351
319
  }
352
- function verifyInstall(version) {
353
- const target = which("logion");
354
- if (!target) {
355
- log(
356
- "Warning: logion not on PATH yet. Ensure your installer's bin directory is exported."
357
- );
320
+ function verifyInstall(version, installer) {
321
+ const target = installer === "venv" ? venvBin("logion") : which("logion");
322
+ if (!target || !import_node_fs3.default.existsSync(target)) {
323
+ log("Warning: logion binary was not found after install.");
358
324
  return;
359
325
  }
360
326
  const r = (0, import_node_child_process2.spawnSync)(target, ["--version"], {
@@ -374,12 +340,6 @@ function pickInstaller(forced) {
374
340
  if (forced !== void 0 && forced.length > 0) {
375
341
  return null;
376
342
  }
377
- if (which("pipx")) {
378
- return "pipx";
379
- }
380
- if (which("uv")) {
381
- return "uv";
382
- }
383
343
  return "venv";
384
344
  }
385
345
  function maybePrintOnboardingPointer() {
@@ -410,9 +370,7 @@ function main() {
410
370
  "Error: Python 3.12+ not found. Install Python 3.12+ or set LOGION_NPM_PYTHON."
411
371
  );
412
372
  log("See: https://www.python.org/downloads/");
413
- log(
414
- "Or set LOGION_NPM_SKIP_INSTALL=1 and install manually: pipx install logion-cli"
415
- );
373
+ log("Or set LOGION_NPM_SKIP_INSTALL=1 to skip the Python CLI install.");
416
374
  process.exit(1);
417
375
  }
418
376
  log(`Using Python: ${py.cmd} ${py.args.join(" ")}`.trim());
@@ -430,7 +388,7 @@ function main() {
430
388
  installViaVenv(version, py);
431
389
  }
432
390
  writeMarker(installer, version);
433
- verifyInstall(version);
391
+ verifyInstall(version, installer);
434
392
  maybePrintOnboardingPointer();
435
393
  log(`Installed logion-cli ${version} via ${installer}.`);
436
394
  }
@@ -67,7 +67,6 @@ var HOME = import_node_os.default.homedir();
67
67
  var LOGION_DIR = import_node_path2.default.join(HOME, ".logion");
68
68
  var MANAGED_VENV_DIR = import_node_path2.default.join(LOGION_DIR, "npm-managed-venv");
69
69
  var MARKER_PATH = import_node_path2.default.join(LOGION_DIR, "npm-wrapper-installer.json");
70
- var LOCAL_BIN = import_node_path2.default.join(HOME, ".local", "bin");
71
70
  function log(msg) {
72
71
  process.stderr.write(`[logion-uninstall] ${msg}
73
72
  `);
@@ -98,28 +97,13 @@ function removeManagedVenv() {
98
97
  log(`Warning: could not remove managed venv: ${msg}`);
99
98
  }
100
99
  }
101
- function removeShims() {
102
- const names = process.platform === "win32" ? ["logion.exe", "logion.cmd"] : ["logion"];
103
- for (const name of names) {
104
- const link = import_node_path2.default.join(LOCAL_BIN, name);
105
- try {
106
- const stat = import_node_fs2.default.lstatSync(link);
107
- if (stat.isSymbolicLink() || stat.isFile()) {
108
- import_node_fs2.default.unlinkSync(link);
109
- }
110
- } catch {
111
- }
112
- }
113
- }
114
100
  function main() {
115
101
  const marker = readMarker();
116
102
  if (!marker) {
117
- removeShims();
118
103
  return;
119
104
  }
120
105
  if (marker.installer === "venv") {
121
106
  removeManagedVenv();
122
- removeShims();
123
107
  } else if (marker.installer === "pipx" && which("pipx")) {
124
108
  log("Uninstalling logion-cli via pipx...");
125
109
  tryRun("pipx", ["uninstall", "logion-cli"]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@logionsh/cli",
3
- "version": "0.1.1",
4
- "description": "Logion CLI — installs and shims the canonical Python logion-cli from PyPI.",
3
+ "version": "0.1.2",
4
+ "description": "Logion CLI — installs and runs the canonical Python logion-cli from a managed environment.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -65,5 +65,5 @@
65
65
  "typescript-eslint": "^8.20.0",
66
66
  "vitest": "^3.2.0"
67
67
  },
68
- "logionCliVersion": "0.1.1"
68
+ "logionCliVersion": "0.1.2"
69
69
  }