library-skills 0.0.4 → 0.0.5
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/ts/dist/cli.js +29 -5
- package/ts/dist/python-env.cjs +28 -4
- package/ts/dist/python-env.js +29 -5
package/package.json
CHANGED
package/ts/dist/cli.js
CHANGED
|
@@ -653,11 +653,11 @@ function isDirectory2(path) {
|
|
|
653
653
|
}
|
|
654
654
|
|
|
655
655
|
// ts/src/python-env.ts
|
|
656
|
-
import { readdirSync as readdirSync3, statSync as statSync3 } from "fs";
|
|
656
|
+
import { readFileSync as readFileSync3, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
|
|
657
657
|
import { dirname as dirname3, isAbsolute as isAbsolute2, join as join4, resolve as resolve3, sep } from "path";
|
|
658
658
|
function findProjectRoot(cwd) {
|
|
659
659
|
for (const directory of ancestors(cwd)) {
|
|
660
|
-
if (isFile(join4(directory, "pyproject.toml")) || isFile(join4(directory, "uv.lock")) ||
|
|
660
|
+
if (isFile(join4(directory, "pyproject.toml")) || isFile(join4(directory, "uv.lock")) || venvFromDotVenv(directory) !== null || isFile(join4(directory, "package.json")) || isDirectory3(join4(directory, "node_modules"))) {
|
|
661
661
|
return directory;
|
|
662
662
|
}
|
|
663
663
|
}
|
|
@@ -673,9 +673,9 @@ function findVenv(cwd = process.cwd()) {
|
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
for (const directory of ancestors(cwd)) {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
return
|
|
676
|
+
const venv = venvFromDotVenv(directory);
|
|
677
|
+
if (venv !== null) {
|
|
678
|
+
return venv;
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
const virtualEnv = process.env["VIRTUAL_ENV"];
|
|
@@ -719,6 +719,30 @@ function findNodeModules(cwd = process.cwd()) {
|
|
|
719
719
|
function isVenvDir(directory) {
|
|
720
720
|
return isFile(join4(directory, "pyvenv.cfg"));
|
|
721
721
|
}
|
|
722
|
+
function venvFromDotVenv(projectRoot) {
|
|
723
|
+
const dotVenv = join4(projectRoot, ".venv");
|
|
724
|
+
if (isDirectory3(dotVenv)) {
|
|
725
|
+
return isVenvDir(dotVenv) ? dotVenv : null;
|
|
726
|
+
}
|
|
727
|
+
if (isFile(dotVenv)) {
|
|
728
|
+
return readVenvRedirectFile(dotVenv);
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
function readVenvRedirectFile(path) {
|
|
733
|
+
let content;
|
|
734
|
+
try {
|
|
735
|
+
content = readFileSync3(path, "utf8");
|
|
736
|
+
} catch {
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
const redirect = content.split(/\r?\n/, 1)[0];
|
|
740
|
+
if (!redirect) {
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
const venv = isAbsolute2(redirect) ? redirect : join4(dirname3(path), redirect);
|
|
744
|
+
return isVenvDir(venv) ? venv : null;
|
|
745
|
+
}
|
|
722
746
|
function ancestors(start) {
|
|
723
747
|
const result = [];
|
|
724
748
|
let directory = resolve3(start);
|
package/ts/dist/python-env.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_node_fs = require("fs");
|
|
|
31
31
|
var import_node_path = require("path");
|
|
32
32
|
function findProjectRoot(cwd) {
|
|
33
33
|
for (const directory of ancestors(cwd)) {
|
|
34
|
-
if (isFile((0, import_node_path.join)(directory, "pyproject.toml")) || isFile((0, import_node_path.join)(directory, "uv.lock")) ||
|
|
34
|
+
if (isFile((0, import_node_path.join)(directory, "pyproject.toml")) || isFile((0, import_node_path.join)(directory, "uv.lock")) || venvFromDotVenv(directory) !== null || isFile((0, import_node_path.join)(directory, "package.json")) || isDirectory((0, import_node_path.join)(directory, "node_modules"))) {
|
|
35
35
|
return directory;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -47,9 +47,9 @@ function findVenv(cwd = process.cwd()) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
for (const directory of ancestors(cwd)) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
return
|
|
50
|
+
const venv = venvFromDotVenv(directory);
|
|
51
|
+
if (venv !== null) {
|
|
52
|
+
return venv;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
const virtualEnv = process.env["VIRTUAL_ENV"];
|
|
@@ -94,6 +94,30 @@ function findNodeModules(cwd = process.cwd()) {
|
|
|
94
94
|
function isVenvDir(directory) {
|
|
95
95
|
return isFile((0, import_node_path.join)(directory, "pyvenv.cfg"));
|
|
96
96
|
}
|
|
97
|
+
function venvFromDotVenv(projectRoot) {
|
|
98
|
+
const dotVenv = (0, import_node_path.join)(projectRoot, ".venv");
|
|
99
|
+
if (isDirectory(dotVenv)) {
|
|
100
|
+
return isVenvDir(dotVenv) ? dotVenv : null;
|
|
101
|
+
}
|
|
102
|
+
if (isFile(dotVenv)) {
|
|
103
|
+
return readVenvRedirectFile(dotVenv);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function readVenvRedirectFile(path) {
|
|
108
|
+
let content;
|
|
109
|
+
try {
|
|
110
|
+
content = (0, import_node_fs.readFileSync)(path, "utf8");
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const redirect = content.split(/\r?\n/, 1)[0];
|
|
115
|
+
if (!redirect) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const venv = (0, import_node_path.isAbsolute)(redirect) ? redirect : (0, import_node_path.join)((0, import_node_path.dirname)(path), redirect);
|
|
119
|
+
return isVenvDir(venv) ? venv : null;
|
|
120
|
+
}
|
|
97
121
|
function ancestors(start) {
|
|
98
122
|
const result = [];
|
|
99
123
|
let directory = (0, import_node_path.resolve)(start);
|
package/ts/dist/python-env.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// ts/src/python-env.ts
|
|
2
|
-
import { readdirSync, statSync } from "fs";
|
|
2
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
3
3
|
import { dirname, isAbsolute, join, resolve, sep } from "path";
|
|
4
4
|
function findProjectRoot(cwd) {
|
|
5
5
|
for (const directory of ancestors(cwd)) {
|
|
6
|
-
if (isFile(join(directory, "pyproject.toml")) || isFile(join(directory, "uv.lock")) ||
|
|
6
|
+
if (isFile(join(directory, "pyproject.toml")) || isFile(join(directory, "uv.lock")) || venvFromDotVenv(directory) !== null || isFile(join(directory, "package.json")) || isDirectory(join(directory, "node_modules"))) {
|
|
7
7
|
return directory;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -19,9 +19,9 @@ function findVenv(cwd = process.cwd()) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
for (const directory of ancestors(cwd)) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
return
|
|
22
|
+
const venv = venvFromDotVenv(directory);
|
|
23
|
+
if (venv !== null) {
|
|
24
|
+
return venv;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const virtualEnv = process.env["VIRTUAL_ENV"];
|
|
@@ -66,6 +66,30 @@ function findNodeModules(cwd = process.cwd()) {
|
|
|
66
66
|
function isVenvDir(directory) {
|
|
67
67
|
return isFile(join(directory, "pyvenv.cfg"));
|
|
68
68
|
}
|
|
69
|
+
function venvFromDotVenv(projectRoot) {
|
|
70
|
+
const dotVenv = join(projectRoot, ".venv");
|
|
71
|
+
if (isDirectory(dotVenv)) {
|
|
72
|
+
return isVenvDir(dotVenv) ? dotVenv : null;
|
|
73
|
+
}
|
|
74
|
+
if (isFile(dotVenv)) {
|
|
75
|
+
return readVenvRedirectFile(dotVenv);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function readVenvRedirectFile(path) {
|
|
80
|
+
let content;
|
|
81
|
+
try {
|
|
82
|
+
content = readFileSync(path, "utf8");
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const redirect = content.split(/\r?\n/, 1)[0];
|
|
87
|
+
if (!redirect) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const venv = isAbsolute(redirect) ? redirect : join(dirname(path), redirect);
|
|
91
|
+
return isVenvDir(venv) ? venv : null;
|
|
92
|
+
}
|
|
69
93
|
function ancestors(start) {
|
|
70
94
|
const result = [];
|
|
71
95
|
let directory = resolve(start);
|