@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/pack.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as fs11 from 'node:fs/promises';
|
|
|
7
7
|
import { stat } from 'node:fs/promises';
|
|
8
8
|
import { createRequire } from 'node:module';
|
|
9
9
|
import * as fs from 'node:fs';
|
|
10
|
-
import { statSync, mkdirSync, writeFileSync
|
|
10
|
+
import { statSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import * as ts from 'typescript';
|
|
12
12
|
import * as dns from 'node:dns/promises';
|
|
13
13
|
import * as net from 'node:net';
|
|
@@ -1487,6 +1487,7 @@ import (
|
|
|
1487
1487
|
"go/ast"
|
|
1488
1488
|
"go/parser"
|
|
1489
1489
|
"go/token"
|
|
1490
|
+
"io"
|
|
1490
1491
|
"os"
|
|
1491
1492
|
"strings"
|
|
1492
1493
|
)
|
|
@@ -1501,17 +1502,13 @@ type Sym struct {
|
|
|
1501
1502
|
}
|
|
1502
1503
|
|
|
1503
1504
|
func main() {
|
|
1504
|
-
|
|
1505
|
-
fmt.Print("[]")
|
|
1506
|
-
return
|
|
1507
|
-
}
|
|
1508
|
-
src, err := os.ReadFile(os.Args[1])
|
|
1505
|
+
src, err := io.ReadAll(os.Stdin)
|
|
1509
1506
|
if err != nil {
|
|
1510
1507
|
fmt.Print("[]")
|
|
1511
1508
|
return
|
|
1512
1509
|
}
|
|
1513
1510
|
fset := token.NewFileSet()
|
|
1514
|
-
node, err := parser.ParseFile(fset,
|
|
1511
|
+
node, err := parser.ParseFile(fset, "src.go", src, 0)
|
|
1515
1512
|
if err != nil {
|
|
1516
1513
|
fmt.Print("[]")
|
|
1517
1514
|
return
|
|
@@ -1655,7 +1652,7 @@ func formatMethods(fields []*ast.Field) string {
|
|
|
1655
1652
|
return formatFields(fields)
|
|
1656
1653
|
}
|
|
1657
1654
|
|
|
1658
|
-
func formatTypeParams(tp *ast.
|
|
1655
|
+
func formatTypeParams(tp *ast.FieldList) string {
|
|
1659
1656
|
if tp == nil || len(tp.List) == 0 {
|
|
1660
1657
|
return ""
|
|
1661
1658
|
}
|
|
@@ -1698,30 +1695,33 @@ func formatType(t ast.Expr) string {
|
|
|
1698
1695
|
return "chan " + formatType(v.Value)
|
|
1699
1696
|
case *ast.BasicLit:
|
|
1700
1697
|
return v.Value
|
|
1698
|
+
case *ast.IndexExpr:
|
|
1699
|
+
// Generic instantiation with one type arg, e.g. Logger[int].
|
|
1700
|
+
return formatType(v.X) + "[" + formatType(v.Index) + "]"
|
|
1701
|
+
case *ast.IndexListExpr:
|
|
1702
|
+
// Generic instantiation with multiple type args, e.g. Map[K, V].
|
|
1703
|
+
args := make([]string, len(v.Indices))
|
|
1704
|
+
for i, idx := range v.Indices {
|
|
1705
|
+
args[i] = formatType(idx)
|
|
1706
|
+
}
|
|
1707
|
+
return formatType(v.X) + "[" + strings.Join(args, ", ") + "]"
|
|
1701
1708
|
default:
|
|
1702
1709
|
return "?"
|
|
1703
1710
|
}
|
|
1704
1711
|
}
|
|
1705
1712
|
`;
|
|
1706
|
-
function syncGoParse(filePath,
|
|
1707
|
-
const tmpDir = path.join(
|
|
1713
|
+
function syncGoParse(filePath, content, lang) {
|
|
1714
|
+
const tmpDir = path.join(os.tmpdir(), "ws-go-parse");
|
|
1708
1715
|
try {
|
|
1709
1716
|
mkdirSync(tmpDir, { recursive: true });
|
|
1710
1717
|
const scriptPath = path.join(tmpDir, "parse.go");
|
|
1711
1718
|
writeFileSync(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
});
|
|
1719
|
-
} finally {
|
|
1720
|
-
try {
|
|
1721
|
-
unlinkSync(scriptPath);
|
|
1722
|
-
} catch {
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1719
|
+
const stdout = execSync(`go run "${scriptPath}"`, {
|
|
1720
|
+
input: content,
|
|
1721
|
+
timeout: 15e3,
|
|
1722
|
+
encoding: "utf8",
|
|
1723
|
+
windowsHide: true
|
|
1724
|
+
});
|
|
1725
1725
|
if (!stdout.trim()) {
|
|
1726
1726
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1727
1727
|
}
|
|
@@ -1958,7 +1958,11 @@ print(json.dumps([s.to_dict() for s in syms]))
|
|
|
1958
1958
|
`;
|
|
1959
1959
|
function syncPyParse(filePath, lang) {
|
|
1960
1960
|
try {
|
|
1961
|
-
const
|
|
1961
|
+
const tmpDir = path.join(os.tmpdir(), "ws-py-parse");
|
|
1962
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
1963
|
+
const scriptPath = path.join(tmpDir, "parse.py");
|
|
1964
|
+
writeFileSync(scriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1965
|
+
const stdout = execSync(`python "${scriptPath}" "${filePath}"`, {
|
|
1962
1966
|
timeout: 15e3,
|
|
1963
1967
|
encoding: "utf8",
|
|
1964
1968
|
windowsHide: true
|
|
@@ -2016,8 +2020,8 @@ function tryNativeParse(file, content) {
|
|
|
2016
2020
|
const toolsDir = path.join(process.cwd(), "tools");
|
|
2017
2021
|
const crateDir = path.join(toolsDir, "syn-parser");
|
|
2018
2022
|
const tmpFile = path.join(crateDir, "src", "input.rs");
|
|
2019
|
-
const { writeFileSync:
|
|
2020
|
-
|
|
2023
|
+
const { writeFileSync: writeFileSync3 } = __require("node:fs");
|
|
2024
|
+
writeFileSync3(tmpFile, content, "utf8");
|
|
2021
2025
|
const result = spawnSync(
|
|
2022
2026
|
"cargo",
|
|
2023
2027
|
["run", "--manifest-path", path.join(toolsDir, "Cargo.toml")],
|
|
@@ -4674,8 +4678,8 @@ var jsonTool = {
|
|
|
4674
4678
|
};
|
|
4675
4679
|
}
|
|
4676
4680
|
};
|
|
4677
|
-
function query(data,
|
|
4678
|
-
const parts =
|
|
4681
|
+
function query(data, path18) {
|
|
4682
|
+
const parts = path18.replace(/\[(\d+)\]/g, ".$1").split(".").filter(Boolean);
|
|
4679
4683
|
let current = data;
|
|
4680
4684
|
for (const part of parts) {
|
|
4681
4685
|
if (current === null || current === void 0) return void 0;
|
|
@@ -4929,7 +4933,7 @@ async function dockerLogs(service, lines, filterRe, cwd, signal, since) {
|
|
|
4929
4933
|
});
|
|
4930
4934
|
}
|
|
4931
4935
|
var MAX_TAIL_LINES = 1e5;
|
|
4932
|
-
async function fileLogs(
|
|
4936
|
+
async function fileLogs(path18, lines, filterRe, stream) {
|
|
4933
4937
|
const { createInterface } = await import('node:readline');
|
|
4934
4938
|
const { createReadStream } = await import('node:fs');
|
|
4935
4939
|
const entries = [];
|
|
@@ -4938,7 +4942,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4938
4942
|
let writeIdx = 0;
|
|
4939
4943
|
let totalLines = 0;
|
|
4940
4944
|
const rl = createInterface({
|
|
4941
|
-
input: createReadStream(
|
|
4945
|
+
input: createReadStream(path18),
|
|
4942
4946
|
crlfDelay: Number.POSITIVE_INFINITY
|
|
4943
4947
|
});
|
|
4944
4948
|
for await (const line of rl) {
|
|
@@ -4959,7 +4963,7 @@ async function fileLogs(path17, lines, filterRe, stream) {
|
|
|
4959
4963
|
if (parsed) entries.push(parsed);
|
|
4960
4964
|
}
|
|
4961
4965
|
return {
|
|
4962
|
-
source:
|
|
4966
|
+
source: path18,
|
|
4963
4967
|
entries,
|
|
4964
4968
|
total: entries.length,
|
|
4965
4969
|
truncated: totalLines > effLines,
|