@logionsh/cli 0.1.0 → 0.1.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/README.md CHANGED
@@ -22,7 +22,7 @@ On install, the postinstall hook:
22
22
 
23
23
  1. Finds a working Python 3.12+.
24
24
  2. Installs `logion-cli==<pinned-version>` from PyPI via `pipx`/`uv`/venv.
25
- 3. Shims the `logion` and `lgn` binaries onto your PATH.
25
+ 3. Shims the `logion` binary onto your PATH.
26
26
 
27
27
  The pinned PyPI version is baked into the npm tarball at publish
28
28
  time, so `npm install -g @logionsh/cli@0.3.0` always installs the
@@ -25,6 +25,7 @@ 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"));
28
29
 
29
30
  // src/lib/which.ts
30
31
  var import_node_fs = __toESM(require("fs"));
@@ -39,7 +40,10 @@ function candidatesForName(name) {
39
40
  }
40
41
  return [name, ...pathext.map((ext) => name + ext.toLowerCase())];
41
42
  }
42
- function which(name) {
43
+ function which(name, options = {}) {
44
+ const excluded = new Set(
45
+ (options.excludeRealpaths ?? []).map((p) => import_node_fs.default.realpathSync.native(p))
46
+ );
43
47
  const rawPath = process.env.PATH ?? "";
44
48
  const dirs = rawPath.split(import_node_path.default.delimiter).filter(Boolean);
45
49
  for (const dir of dirs) {
@@ -47,7 +51,7 @@ function which(name) {
47
51
  const full = import_node_path.default.join(dir, candidate);
48
52
  try {
49
53
  const stat = import_node_fs.default.statSync(full);
50
- if (stat.isFile()) {
54
+ if (stat.isFile() && !excluded.has(import_node_fs.default.realpathSync.native(full))) {
51
55
  return full;
52
56
  }
53
57
  } catch {
@@ -58,7 +62,9 @@ function which(name) {
58
62
  }
59
63
 
60
64
  // src/bin/logion.ts
61
- var target = which("logion");
65
+ var target = which("logion", {
66
+ excludeRealpaths: [import_node_fs2.default.realpathSync.native(__filename)]
67
+ });
62
68
  if (!target) {
63
69
  process.stderr.write(
64
70
  "logion binary not found. Reinstall with `npm install -g @logionsh/cli` or install directly via `pipx install logion-cli`.\n"
@@ -44,7 +44,10 @@ function candidatesForName(name) {
44
44
  }
45
45
  return [name, ...pathext.map((ext) => name + ext.toLowerCase())];
46
46
  }
47
- function which(name) {
47
+ function which(name, options = {}) {
48
+ const excluded = new Set(
49
+ (options.excludeRealpaths ?? []).map((p) => import_node_fs.default.realpathSync.native(p))
50
+ );
48
51
  const rawPath = process.env.PATH ?? "";
49
52
  const dirs = rawPath.split(import_node_path.default.delimiter).filter(Boolean);
50
53
  for (const dir of dirs) {
@@ -52,7 +55,7 @@ function which(name) {
52
55
  const full = import_node_path.default.join(dir, candidate);
53
56
  try {
54
57
  const stat = import_node_fs.default.statSync(full);
55
- if (stat.isFile()) {
58
+ if (stat.isFile() && !excluded.has(import_node_fs.default.realpathSync.native(full))) {
56
59
  return full;
57
60
  }
58
61
  } catch {
@@ -328,7 +331,7 @@ function installViaVenv(version, py) {
328
331
  runChecked(py.cmd, [...py.args, "-m", "venv", MANAGED_VENV_DIR]);
329
332
  runChecked(venvBin("pip"), ["install", `logion-cli==${version}`]);
330
333
  import_node_fs3.default.mkdirSync(LOCAL_BIN, { recursive: true });
331
- for (const base of ["logion", "lgn"]) {
334
+ for (const base of ["logion"]) {
332
335
  const src = venvBin(base);
333
336
  if (!import_node_fs3.default.existsSync(src)) {
334
337
  continue;
@@ -41,7 +41,10 @@ function candidatesForName(name) {
41
41
  }
42
42
  return [name, ...pathext.map((ext) => name + ext.toLowerCase())];
43
43
  }
44
- function which(name) {
44
+ function which(name, options = {}) {
45
+ const excluded = new Set(
46
+ (options.excludeRealpaths ?? []).map((p) => import_node_fs.default.realpathSync.native(p))
47
+ );
45
48
  const rawPath = process.env.PATH ?? "";
46
49
  const dirs = rawPath.split(import_node_path.default.delimiter).filter(Boolean);
47
50
  for (const dir of dirs) {
@@ -49,7 +52,7 @@ function which(name) {
49
52
  const full = import_node_path.default.join(dir, candidate);
50
53
  try {
51
54
  const stat = import_node_fs.default.statSync(full);
52
- if (stat.isFile()) {
55
+ if (stat.isFile() && !excluded.has(import_node_fs.default.realpathSync.native(full))) {
53
56
  return full;
54
57
  }
55
58
  } catch {
@@ -96,7 +99,7 @@ function removeManagedVenv() {
96
99
  }
97
100
  }
98
101
  function removeShims() {
99
- const names = process.platform === "win32" ? ["logion.exe", "lgn.exe", "logion.cmd", "lgn.cmd"] : ["logion", "lgn"];
102
+ const names = process.platform === "win32" ? ["logion.exe", "logion.cmd"] : ["logion"];
100
103
  for (const name of names) {
101
104
  const link = import_node_path2.default.join(LOCAL_BIN, name);
102
105
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logionsh/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Logion CLI — installs and shims the canonical Python logion-cli from PyPI.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,8 +19,7 @@
19
19
  "agent"
20
20
  ],
21
21
  "bin": {
22
- "logion": "dist/bin/logion.js",
23
- "lgn": "dist/bin/lgn.js"
22
+ "logion": "dist/bin/logion.js"
24
23
  },
25
24
  "scripts": {
26
25
  "build": "tsup",
@@ -66,5 +65,5 @@
66
65
  "typescript-eslint": "^8.20.0",
67
66
  "vitest": "^3.2.0"
68
67
  },
69
- "logionCliVersion": "0.1.0"
68
+ "logionCliVersion": "0.1.1"
70
69
  }
package/dist/bin/lgn.js DELETED
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
- // If the importer is in node compatibility mode or this is not an ESM
19
- // file that has been converted to a CommonJS file using a Babel-
20
- // compatible transform (i.e. "__esModule" has not been set), then set
21
- // "default" to the CommonJS "module.exports" for node compatibility.
22
- isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
23
- mod
24
- ));
25
-
26
- // src/bin/lgn.ts
27
- var import_node_child_process = require("child_process");
28
-
29
- // src/lib/which.ts
30
- var import_node_fs = __toESM(require("fs"));
31
- var import_node_path = __toESM(require("path"));
32
- function candidatesForName(name) {
33
- if (process.platform !== "win32") {
34
- return [name];
35
- }
36
- const pathext = (process.env.PATHEXT ?? ".EXE;.CMD;.BAT;.COM").split(";").filter(Boolean);
37
- if (import_node_path.default.extname(name)) {
38
- return [name];
39
- }
40
- return [name, ...pathext.map((ext) => name + ext.toLowerCase())];
41
- }
42
- function which(name) {
43
- const rawPath = process.env.PATH ?? "";
44
- const dirs = rawPath.split(import_node_path.default.delimiter).filter(Boolean);
45
- for (const dir of dirs) {
46
- for (const candidate of candidatesForName(name)) {
47
- const full = import_node_path.default.join(dir, candidate);
48
- try {
49
- const stat = import_node_fs.default.statSync(full);
50
- if (stat.isFile()) {
51
- return full;
52
- }
53
- } catch {
54
- }
55
- }
56
- }
57
- return null;
58
- }
59
-
60
- // src/bin/lgn.ts
61
- var target = which("lgn") ?? which("logion");
62
- if (!target) {
63
- process.stderr.write(
64
- "lgn/logion binary not found. Reinstall with `npm install -g @logionsh/cli` or install directly via `pipx install logion-cli`.\n"
65
- );
66
- process.exit(127);
67
- }
68
- var r = (0, import_node_child_process.spawnSync)(target, process.argv.slice(2), { stdio: "inherit" });
69
- if (r.error) {
70
- process.stderr.write(`${r.error.message}
71
- `);
72
- process.exit(1);
73
- }
74
- process.exit(r.status ?? 1);