@wrongstack/tools 0.7.8 → 0.8.0
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/dist/builtin.js +35 -31
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.js +50 -45
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/index.js +35 -31
- package/dist/index.js.map +1 -1
- package/dist/pack.js +35 -31
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import * as os from 'node:os';
|
|
|
8
8
|
import * as dns from 'node:dns/promises';
|
|
9
9
|
import * as net from 'node:net';
|
|
10
10
|
import * as fs13 from 'node:fs';
|
|
11
|
-
import { statSync, mkdirSync, writeFileSync
|
|
11
|
+
import { statSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { createRequire } from 'node:module';
|
|
13
13
|
import * as ts from 'typescript';
|
|
14
14
|
|
|
@@ -2758,8 +2758,8 @@ var jsonTool = {
|
|
|
2758
2758
|
};
|
|
2759
2759
|
}
|
|
2760
2760
|
};
|
|
2761
|
-
function query(data,
|
|
2762
|
-
const parts =
|
|
2761
|
+
function query(data, path18) {
|
|
2762
|
+
const parts = path18.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
2763
2763
|
let current = data;
|
|
2764
2764
|
for (const part of parts) {
|
|
2765
2765
|
if (current === null || current === void 0) return void 0;
|
|
@@ -4033,7 +4033,7 @@ async function dockerLogs(service, lines, filterRe, cwd, signal, since) {
|
|
|
4033
4033
|
});
|
|
4034
4034
|
}
|
|
4035
4035
|
var MAX_TAIL_LINES = 1e5;
|
|
4036
|
-
async function fileLogs(
|
|
4036
|
+
async function fileLogs(path18, lines, filterRe, stream) {
|
|
4037
4037
|
const { createInterface } = await import('node:readline');
|
|
4038
4038
|
const { createReadStream } = await import('node:fs');
|
|
4039
4039
|
const entries = [];
|
|
@@ -4042,7 +4042,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4042
4042
|
let writeIdx = 0;
|
|
4043
4043
|
let totalLines = 0;
|
|
4044
4044
|
const rl = createInterface({
|
|
4045
|
-
input: createReadStream(
|
|
4045
|
+
input: createReadStream(path18),
|
|
4046
4046
|
crlfDelay: Number.POSITIVE_INFINITY
|
|
4047
4047
|
});
|
|
4048
4048
|
for await (const line of rl) {
|
|
@@ -4063,7 +4063,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4063
4063
|
if (parsed) entries.push(parsed);
|
|
4064
4064
|
}
|
|
4065
4065
|
return {
|
|
4066
|
-
source:
|
|
4066
|
+
source: path18,
|
|
4067
4067
|
entries,
|
|
4068
4068
|
total: entries.length,
|
|
4069
4069
|
truncated: totalLines > effLines,
|
|
@@ -5515,6 +5515,7 @@ import (
|
|
|
5515
5515
|
"go/ast"
|
|
5516
5516
|
"go/parser"
|
|
5517
5517
|
"go/token"
|
|
5518
|
+
"io"
|
|
5518
5519
|
"os"
|
|
5519
5520
|
"strings"
|
|
5520
5521
|
)
|
|
@@ -5529,17 +5530,13 @@ type Sym struct {
|
|
|
5529
5530
|
}
|
|
5530
5531
|
|
|
5531
5532
|
func main() {
|
|
5532
|
-
|
|
5533
|
-
fmt.Print("[]")
|
|
5534
|
-
return
|
|
5535
|
-
}
|
|
5536
|
-
src, err := os.ReadFile(os.Args[1])
|
|
5533
|
+
src, err := io.ReadAll(os.Stdin)
|
|
5537
5534
|
if err != nil {
|
|
5538
5535
|
fmt.Print("[]")
|
|
5539
5536
|
return
|
|
5540
5537
|
}
|
|
5541
5538
|
fset := token.NewFileSet()
|
|
5542
|
-
node, err := parser.ParseFile(fset,
|
|
5539
|
+
node, err := parser.ParseFile(fset, "src.go", src, 0)
|
|
5543
5540
|
if err != nil {
|
|
5544
5541
|
fmt.Print("[]")
|
|
5545
5542
|
return
|
|
@@ -5683,7 +5680,7 @@ func formatMethods(fields []*ast.Field) string {
|
|
|
5683
5680
|
return formatFields(fields)
|
|
5684
5681
|
}
|
|
5685
5682
|
|
|
5686
|
-
func formatTypeParams(tp *ast.
|
|
5683
|
+
func formatTypeParams(tp *ast.FieldList) string {
|
|
5687
5684
|
if tp == nil || len(tp.List) == 0 {
|
|
5688
5685
|
return ""
|
|
5689
5686
|
}
|
|
@@ -5726,30 +5723,33 @@ func formatType(t ast.Expr) string {
|
|
|
5726
5723
|
return "chan " + formatType(v.Value)
|
|
5727
5724
|
case *ast.BasicLit:
|
|
5728
5725
|
return v.Value
|
|
5726
|
+
case *ast.IndexExpr:
|
|
5727
|
+
// Generic instantiation with one type arg, e.g. Logger[int].
|
|
5728
|
+
return formatType(v.X) + "[" + formatType(v.Index) + "]"
|
|
5729
|
+
case *ast.IndexListExpr:
|
|
5730
|
+
// Generic instantiation with multiple type args, e.g. Map[K, V].
|
|
5731
|
+
args := make([]string, len(v.Indices))
|
|
5732
|
+
for i, idx := range v.Indices {
|
|
5733
|
+
args[i] = formatType(idx)
|
|
5734
|
+
}
|
|
5735
|
+
return formatType(v.X) + "[" + strings.Join(args, ", ") + "]"
|
|
5729
5736
|
default:
|
|
5730
5737
|
return "?"
|
|
5731
5738
|
}
|
|
5732
5739
|
}
|
|
5733
5740
|
`;
|
|
5734
|
-
function syncGoParse(filePath,
|
|
5735
|
-
const tmpDir = path.join(
|
|
5741
|
+
function syncGoParse(filePath, content, lang) {
|
|
5742
|
+
const tmpDir = path.join(os.tmpdir(), "ws-go-parse");
|
|
5736
5743
|
try {
|
|
5737
5744
|
mkdirSync(tmpDir, { recursive: true });
|
|
5738
5745
|
const scriptPath = path.join(tmpDir, "parse.go");
|
|
5739
5746
|
writeFileSync(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
});
|
|
5747
|
-
} finally {
|
|
5748
|
-
try {
|
|
5749
|
-
unlinkSync(scriptPath);
|
|
5750
|
-
} catch {
|
|
5751
|
-
}
|
|
5752
|
-
}
|
|
5747
|
+
const stdout = execSync(`go run "${scriptPath}"`, {
|
|
5748
|
+
input: content,
|
|
5749
|
+
timeout: 15e3,
|
|
5750
|
+
encoding: "utf8",
|
|
5751
|
+
windowsHide: true
|
|
5752
|
+
});
|
|
5753
5753
|
if (!stdout.trim()) {
|
|
5754
5754
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
5755
5755
|
}
|
|
@@ -5986,7 +5986,11 @@ print(json.dumps([s.to_dict() for s in syms]))
|
|
|
5986
5986
|
`;
|
|
5987
5987
|
function syncPyParse(filePath, lang) {
|
|
5988
5988
|
try {
|
|
5989
|
-
const
|
|
5989
|
+
const tmpDir = path.join(os.tmpdir(), "ws-py-parse");
|
|
5990
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
5991
|
+
const scriptPath = path.join(tmpDir, "parse.py");
|
|
5992
|
+
writeFileSync(scriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
5993
|
+
const stdout = execSync(`python "${scriptPath}" "${filePath}"`, {
|
|
5990
5994
|
timeout: 15e3,
|
|
5991
5995
|
encoding: "utf8",
|
|
5992
5996
|
windowsHide: true
|
|
@@ -6044,8 +6048,8 @@ function tryNativeParse(file, content) {
|
|
|
6044
6048
|
const toolsDir = path.join(process.cwd(), "tools");
|
|
6045
6049
|
const crateDir = path.join(toolsDir, "syn-parser");
|
|
6046
6050
|
const tmpFile = path.join(crateDir, "src", "input.rs");
|
|
6047
|
-
const { writeFileSync:
|
|
6048
|
-
|
|
6051
|
+
const { writeFileSync: writeFileSync3 } = __require("node:fs");
|
|
6052
|
+
writeFileSync3(tmpFile, content, "utf8");
|
|
6049
6053
|
const result = spawnSync(
|
|
6050
6054
|
"cargo",
|
|
6051
6055
|
["run", "--manifest-path", path.join(toolsDir, "Cargo.toml")],
|