tidewave 0.5.5 → 0.7.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/CHANGELOG.md +11 -0
- package/README.md +86 -23
- package/dist/cli/index.js +306 -106
- package/dist/core.d.ts +15 -6
- package/dist/http/handlers/config.d.ts +3 -2
- package/dist/http/index.d.ts +7 -3
- package/dist/http/security.d.ts +0 -8
- package/dist/logger/console-patch.d.ts +5 -0
- package/dist/logger/tidewave-log-record-processor.d.ts +1 -1
- package/dist/logger/tidewave-logger.d.ts +37 -0
- package/dist/logger/tidewave-span-processor.d.ts +2 -2
- package/dist/next-js/handler.d.ts +1 -0
- package/dist/next-js/handler.js +379 -456
- package/dist/next-js/instrumentation.d.ts +2 -7
- package/dist/next-js/instrumentation.js +138 -119
- package/dist/resolution/formatters.d.ts +2 -2
- package/dist/resolution/index.d.ts +1 -2
- package/dist/resolution/symbol-finder.d.ts +2 -2
- package/dist/resolution/utils.d.ts +1 -0
- package/dist/tanstack.d.ts +1 -0
- package/dist/tanstack.js +181 -0
- package/dist/vite-plugin.d.ts +0 -1
- package/dist/vite-plugin.js +368 -463
- package/package.json +13 -5
- package/dist/http/handlers/shell.d.ts +0 -6
- package/dist/logger/circular-buffer.d.ts +0 -54
- package/dist/logger/instrumentation.d.ts +0 -2
package/dist/cli/index.js
CHANGED
|
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
8
13
|
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
9
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
22
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
23
|
for (let key of __getOwnPropNames(mod))
|
|
12
24
|
if (!__hasOwnProp.call(to, key))
|
|
13
25
|
__defProp(to, key, {
|
|
14
|
-
get: (
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
15
27
|
enumerable: true
|
|
16
28
|
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
17
31
|
return to;
|
|
18
32
|
};
|
|
19
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __returnValue = (v) => v;
|
|
35
|
+
function __exportSetter(name, newValue) {
|
|
36
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
37
|
+
}
|
|
20
38
|
var __export = (target, all) => {
|
|
21
39
|
for (var name in all)
|
|
22
40
|
__defProp(target, name, {
|
|
23
41
|
get: all[name],
|
|
24
42
|
enumerable: true,
|
|
25
43
|
configurable: true,
|
|
26
|
-
set: (
|
|
44
|
+
set: __exportSetter.bind(all, name)
|
|
27
45
|
});
|
|
28
46
|
};
|
|
29
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -5835,9 +5853,10 @@ var init_zod = __esm(() => {
|
|
|
5835
5853
|
});
|
|
5836
5854
|
|
|
5837
5855
|
// src/tools.ts
|
|
5838
|
-
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module path in format 'module:symbol[#method|.method]'. Supports local files, dependencies, and Node.js builtins.
|
|
5856
|
+
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module/file path, optionally with symbol in format 'module[:symbol[#method|.method]]'. Supports local files, dependencies, and Node.js builtins.
|
|
5839
5857
|
|
|
5840
5858
|
Module reference format:
|
|
5859
|
+
- module - List all symbols in the module (file-level documentation)
|
|
5841
5860
|
- module:symbol - Extract a top-level symbol
|
|
5842
5861
|
- module:Class#method - Extract an instance method
|
|
5843
5862
|
- module:Class.method - Extract a static method
|
|
@@ -5845,6 +5864,8 @@ Module reference format:
|
|
|
5845
5864
|
- node:Class.method - Extract a global/builtin static method
|
|
5846
5865
|
|
|
5847
5866
|
Examples:
|
|
5867
|
+
- src/types.ts (list all symbols in file)
|
|
5868
|
+
- lodash (list all symbols in dependency)
|
|
5848
5869
|
- src/types.ts:SymbolInfo (local file symbol)
|
|
5849
5870
|
- lodash:isEmpty (dependency function)
|
|
5850
5871
|
- react:Component#render (instance method)
|
|
@@ -5852,7 +5873,8 @@ Examples:
|
|
|
5852
5873
|
var init_tools = __esm(() => {
|
|
5853
5874
|
init_zod();
|
|
5854
5875
|
projectEvalDescription = `
|
|
5855
|
-
Evaluates JavaScript/TypeScript code
|
|
5876
|
+
Evaluates JavaScript/TypeScript code within your project's build tool
|
|
5877
|
+
(or server for full-stack applications).
|
|
5856
5878
|
|
|
5857
5879
|
The current NodeJS version is: ${process.version}
|
|
5858
5880
|
|
|
@@ -5861,7 +5883,7 @@ including to test the behaviour of a function or to debug
|
|
|
5861
5883
|
something. The tool also returns anything written to standard
|
|
5862
5884
|
output. DO NOT use shell tools to evaluate JavaScript/TypeScript code.
|
|
5863
5885
|
|
|
5864
|
-
Imports are allowed only as the form of dynamic imports with async/await
|
|
5886
|
+
Imports are allowed only as the form of dynamic imports with async/await:
|
|
5865
5887
|
const path = await import('node:path');
|
|
5866
5888
|
`;
|
|
5867
5889
|
projectEvalInputSchema = exports_external.object({
|
|
@@ -5887,7 +5909,26 @@ Defaults to 30000 (30 seconds).`),
|
|
|
5887
5909
|
docs: {
|
|
5888
5910
|
mcp: {
|
|
5889
5911
|
name: "get_docs",
|
|
5890
|
-
description:
|
|
5912
|
+
description: `Extract TypeScript/JavaScript documentation and type information. Works for modules in the current project, dependencies, and builtin node modules.
|
|
5913
|
+
|
|
5914
|
+
Reference format determines what is returned:
|
|
5915
|
+
|
|
5916
|
+
• "module" - Returns file overview and lists all exported symbols with their kinds, line numbers, and brief documentation. Use this to discover what's available in a module.
|
|
5917
|
+
|
|
5918
|
+
• "module:symbol" - Returns detailed documentation for a specific top-level symbol including its type signature, full documentation, JSDoc tags, and source location.
|
|
5919
|
+
|
|
5920
|
+
• "module:Class.staticMethod" - Returns detailed documentation for a static method or property of a class or object.
|
|
5921
|
+
|
|
5922
|
+
• "module:Class#instanceMethod" - Returns detailed documentation for an instance method or property of a class.
|
|
5923
|
+
|
|
5924
|
+
Examples:
|
|
5925
|
+
- "src/types.ts" → Lists all exported symbols in the file
|
|
5926
|
+
- "lodash" → Lists all symbols exported from lodash
|
|
5927
|
+
- "src/types.ts:SymbolInfo" → Full docs for SymbolInfo interface
|
|
5928
|
+
- "react:Component#render" → Docs for React Component's render method
|
|
5929
|
+
- "node:Math.max" → Docs for Math.max static method
|
|
5930
|
+
|
|
5931
|
+
Start with module-only references to explore, then drill into specific symbols for detailed information.`,
|
|
5891
5932
|
inputSchema: docsInputSchema
|
|
5892
5933
|
},
|
|
5893
5934
|
cli: {
|
|
@@ -5936,7 +5977,7 @@ Defaults to 30000 (30 seconds).`),
|
|
|
5936
5977
|
logs: {
|
|
5937
5978
|
mcp: {
|
|
5938
5979
|
name: "get_logs",
|
|
5939
|
-
description: "Retrieve application logs
|
|
5980
|
+
description: "Retrieve application logs within your project's build tool (or server for full-stack applications). Supports filtering by level, time, and pattern matching.",
|
|
5940
5981
|
inputSchema: getLogsInputSchema
|
|
5941
5982
|
}
|
|
5942
5983
|
}
|
|
@@ -5952,6 +5993,9 @@ function isResolveError(result) {
|
|
|
5952
5993
|
function isExtractError(result) {
|
|
5953
5994
|
return result != null && "error" in result;
|
|
5954
5995
|
}
|
|
5996
|
+
function isFileInfo(result) {
|
|
5997
|
+
return result != null && "exports" in result && Array.isArray(result.exports);
|
|
5998
|
+
}
|
|
5955
5999
|
function resolveError(specifier, source) {
|
|
5956
6000
|
return {
|
|
5957
6001
|
success: false,
|
|
@@ -6150,6 +6194,8 @@ function getSymbolKind(symbol) {
|
|
|
6150
6194
|
return "property";
|
|
6151
6195
|
if (flags & ts2.SymbolFlags.Method)
|
|
6152
6196
|
return "method";
|
|
6197
|
+
if (flags & ts2.SymbolFlags.EnumMember)
|
|
6198
|
+
return "enum member";
|
|
6153
6199
|
if (flags & ts2.SymbolFlags.Enum)
|
|
6154
6200
|
return "enum";
|
|
6155
6201
|
if (flags & ts2.SymbolFlags.Module)
|
|
@@ -6170,6 +6216,27 @@ function getSymbolKind(symbol) {
|
|
|
6170
6216
|
}
|
|
6171
6217
|
return "unknown";
|
|
6172
6218
|
}
|
|
6219
|
+
function getFileOverview(sourceFile) {
|
|
6220
|
+
const leadingComments = ts2.getLeadingCommentRanges(sourceFile.text, 0);
|
|
6221
|
+
if (!leadingComments || leadingComments.length === 0) {
|
|
6222
|
+
return;
|
|
6223
|
+
}
|
|
6224
|
+
for (const comment of leadingComments) {
|
|
6225
|
+
const commentText = sourceFile.text.slice(comment.pos, comment.end);
|
|
6226
|
+
const fileoverviewMatch = commentText.match(/@fileoverview\s+([\s\S]*?)(?=@\w+|$)/);
|
|
6227
|
+
const fileMatch = commentText.match(/@file\s+([\s\S]*?)(?=@\w+|$)/);
|
|
6228
|
+
const match = fileoverviewMatch || fileMatch;
|
|
6229
|
+
if (match && match[1]) {
|
|
6230
|
+
const overviewText = match[1].split(`
|
|
6231
|
+
`).map((line) => line.replace(/^\s*\*\s?/, "").trim()).filter((line) => line.length > 0).join(`
|
|
6232
|
+
`).trim();
|
|
6233
|
+
if (overviewText) {
|
|
6234
|
+
return overviewText;
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
}
|
|
6238
|
+
return;
|
|
6239
|
+
}
|
|
6173
6240
|
var init_utils = () => {};
|
|
6174
6241
|
|
|
6175
6242
|
// src/resolution/formatters.ts
|
|
@@ -6266,7 +6333,7 @@ function getTypeString(checker, symbol, type) {
|
|
|
6266
6333
|
}
|
|
6267
6334
|
return defaultTypeString;
|
|
6268
6335
|
}
|
|
6269
|
-
function
|
|
6336
|
+
function formatSymbolInfo(info) {
|
|
6270
6337
|
const output = [];
|
|
6271
6338
|
output.push(`
|
|
6272
6339
|
${info.name}`);
|
|
@@ -6293,7 +6360,36 @@ ${info.name}`);
|
|
|
6293
6360
|
return output.join(`
|
|
6294
6361
|
`);
|
|
6295
6362
|
}
|
|
6296
|
-
|
|
6363
|
+
function formatFileInfo(info) {
|
|
6364
|
+
const output = [];
|
|
6365
|
+
output.push(`
|
|
6366
|
+
File: ${info.path}`);
|
|
6367
|
+
output.push("");
|
|
6368
|
+
if (info.overview) {
|
|
6369
|
+
output.push("Overview:");
|
|
6370
|
+
output.push(info.overview);
|
|
6371
|
+
output.push("");
|
|
6372
|
+
}
|
|
6373
|
+
output.push(`Symbols (${info.exportCount} total):`);
|
|
6374
|
+
output.push("");
|
|
6375
|
+
for (const exp of info.exports) {
|
|
6376
|
+
output.push(`${exp.name} (${exp.kind}) - line ${exp.line}`);
|
|
6377
|
+
if (exp.documentation) {
|
|
6378
|
+
output.push(exp.documentation);
|
|
6379
|
+
}
|
|
6380
|
+
}
|
|
6381
|
+
return output.join(`
|
|
6382
|
+
`);
|
|
6383
|
+
}
|
|
6384
|
+
function formatOutput(info) {
|
|
6385
|
+
if (isFileInfo(info)) {
|
|
6386
|
+
return formatFileInfo(info);
|
|
6387
|
+
}
|
|
6388
|
+
return formatSymbolInfo(info);
|
|
6389
|
+
}
|
|
6390
|
+
var init_formatters = __esm(() => {
|
|
6391
|
+
init_core();
|
|
6392
|
+
});
|
|
6297
6393
|
|
|
6298
6394
|
// src/resolution/symbol-finder.ts
|
|
6299
6395
|
import ts4 from "typescript";
|
|
@@ -6370,7 +6466,12 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
6370
6466
|
return createExtractError("TYPE_ERROR", `Symbol '${symbol.getName()}' has no declarations`);
|
|
6371
6467
|
}
|
|
6372
6468
|
const targetDeclaration = declaration || symbol.declarations[0];
|
|
6373
|
-
|
|
6469
|
+
let type;
|
|
6470
|
+
if (symbol.flags & (ts4.SymbolFlags.Interface | ts4.SymbolFlags.TypeAlias)) {
|
|
6471
|
+
type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
6472
|
+
} else {
|
|
6473
|
+
type = checker.getTypeOfSymbolAtLocation(symbol, targetDeclaration);
|
|
6474
|
+
}
|
|
6374
6475
|
const symbolName = symbol.getName();
|
|
6375
6476
|
let targetSymbol = symbol;
|
|
6376
6477
|
let targetType = type;
|
|
@@ -6384,11 +6485,27 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
6384
6485
|
targetType = checker.getTypeOfSymbolAtLocation(staticMember, staticMember.valueDeclaration);
|
|
6385
6486
|
name = `${symbolName}.${member}`;
|
|
6386
6487
|
} else {
|
|
6387
|
-
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'`);
|
|
6488
|
+
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'. Available: ${staticMembers.map((m) => m.getName()).join(", ")}`);
|
|
6388
6489
|
}
|
|
6389
6490
|
} else {
|
|
6390
6491
|
let instanceType;
|
|
6391
|
-
if (symbol.flags & ts4.SymbolFlags.
|
|
6492
|
+
if (symbol.flags & ts4.SymbolFlags.Interface) {
|
|
6493
|
+
instanceType = type;
|
|
6494
|
+
const instanceMembers = checker.getPropertiesOfType(instanceType);
|
|
6495
|
+
const instanceMember = instanceMembers.find((s) => s.getName() === member);
|
|
6496
|
+
if (instanceMember) {
|
|
6497
|
+
targetSymbol = instanceMember;
|
|
6498
|
+
const memberDecl = instanceMember.valueDeclaration || instanceMember.declarations?.[0];
|
|
6499
|
+
if (memberDecl) {
|
|
6500
|
+
targetType = checker.getTypeOfSymbolAtLocation(instanceMember, memberDecl);
|
|
6501
|
+
} else {
|
|
6502
|
+
targetType = checker.getTypeOfSymbol(instanceMember);
|
|
6503
|
+
}
|
|
6504
|
+
name = `${symbolName}#${member}`;
|
|
6505
|
+
} else {
|
|
6506
|
+
return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on interface '${symbolName}'. Available: ${instanceMembers.map((m) => m.getName()).join(", ")}`);
|
|
6507
|
+
}
|
|
6508
|
+
} else if (symbol.flags & ts4.SymbolFlags.Class) {
|
|
6392
6509
|
instanceType = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
6393
6510
|
const constructSignatures = instanceType.getConstructSignatures();
|
|
6394
6511
|
if (constructSignatures.length > 0) {
|
|
@@ -6472,6 +6589,9 @@ var init_symbol_finder = __esm(() => {
|
|
|
6472
6589
|
import ts5 from "typescript";
|
|
6473
6590
|
import path4 from "node:path";
|
|
6474
6591
|
function parseModulePath(modulePath) {
|
|
6592
|
+
if (!modulePath || modulePath.trim() === "") {
|
|
6593
|
+
return createExtractError("INVALID_REQUEST", "Module path is required");
|
|
6594
|
+
}
|
|
6475
6595
|
let module;
|
|
6476
6596
|
let symbolPath;
|
|
6477
6597
|
if (modulePath.startsWith("node:")) {
|
|
@@ -6480,12 +6600,22 @@ function parseModulePath(modulePath) {
|
|
|
6480
6600
|
module = `node:${baseSymbol}`;
|
|
6481
6601
|
symbolPath = nodeSymbol;
|
|
6482
6602
|
} else {
|
|
6483
|
-
const
|
|
6484
|
-
if (
|
|
6485
|
-
|
|
6603
|
+
const colonIndex = modulePath.indexOf(":");
|
|
6604
|
+
if (colonIndex === -1) {
|
|
6605
|
+
module = modulePath;
|
|
6606
|
+
symbolPath = undefined;
|
|
6607
|
+
} else if (colonIndex === 0) {
|
|
6608
|
+
return createExtractError("INVALID_REQUEST", 'Module path is required before ":"');
|
|
6609
|
+
} else {
|
|
6610
|
+
module = modulePath.substring(0, colonIndex);
|
|
6611
|
+
symbolPath = modulePath.substring(colonIndex + 1);
|
|
6612
|
+
if (!symbolPath || symbolPath.trim() === "") {
|
|
6613
|
+
return createExtractError("INVALID_REQUEST", 'Symbol name is required after ":"');
|
|
6614
|
+
}
|
|
6486
6615
|
}
|
|
6487
|
-
|
|
6488
|
-
|
|
6616
|
+
}
|
|
6617
|
+
if (!symbolPath) {
|
|
6618
|
+
return { module, symbol: undefined, member: undefined, isStatic: false };
|
|
6489
6619
|
}
|
|
6490
6620
|
if (symbolPath.includes("#")) {
|
|
6491
6621
|
const [symbol, member] = symbolPath.split("#");
|
|
@@ -6503,6 +6633,37 @@ function parseModulePath(modulePath) {
|
|
|
6503
6633
|
}
|
|
6504
6634
|
return { module, symbol: symbolPath, member: undefined, isStatic: false };
|
|
6505
6635
|
}
|
|
6636
|
+
function getExportSummaries(moduleSymbol, sourceFile, checker) {
|
|
6637
|
+
if (!moduleSymbol) {
|
|
6638
|
+
return [];
|
|
6639
|
+
}
|
|
6640
|
+
try {
|
|
6641
|
+
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
6642
|
+
const summaries = [];
|
|
6643
|
+
for (const exp of exports) {
|
|
6644
|
+
const name = exp.getName();
|
|
6645
|
+
const kind = getSymbolKind(exp);
|
|
6646
|
+
const decl = exp.valueDeclaration ?? exp.declarations?.[0];
|
|
6647
|
+
let line = 0;
|
|
6648
|
+
if (decl) {
|
|
6649
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(decl.getStart());
|
|
6650
|
+
line = pos.line + 1;
|
|
6651
|
+
}
|
|
6652
|
+
const fullDoc = ts5.displayPartsToString(exp.getDocumentationComment(checker));
|
|
6653
|
+
const briefDoc = fullDoc.split(`
|
|
6654
|
+
`)[0]?.trim();
|
|
6655
|
+
summaries.push({
|
|
6656
|
+
name,
|
|
6657
|
+
kind,
|
|
6658
|
+
line,
|
|
6659
|
+
documentation: briefDoc || undefined
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6662
|
+
return summaries.sort((a, b) => a.line - b.line);
|
|
6663
|
+
} catch {
|
|
6664
|
+
return [];
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6506
6667
|
async function extractDocs(modulePath) {
|
|
6507
6668
|
const options = { prefix: process.cwd() };
|
|
6508
6669
|
const parseResult = parseModulePath(modulePath);
|
|
@@ -6525,6 +6686,22 @@ async function extractDocs(modulePath) {
|
|
|
6525
6686
|
}
|
|
6526
6687
|
const { sourceFile, program: program2 } = resolvedModule;
|
|
6527
6688
|
const checker = program2.getTypeChecker();
|
|
6689
|
+
if (symbol === undefined) {
|
|
6690
|
+
const overview = getFileOverview(sourceFile);
|
|
6691
|
+
const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
6692
|
+
const exports = getExportSummaries(moduleSymbol, sourceFile, checker);
|
|
6693
|
+
let relativePath = sourceFile.fileName;
|
|
6694
|
+
const cwd = process.cwd();
|
|
6695
|
+
if (relativePath.startsWith(cwd)) {
|
|
6696
|
+
relativePath = path4.relative(cwd, relativePath);
|
|
6697
|
+
}
|
|
6698
|
+
return {
|
|
6699
|
+
path: relativePath,
|
|
6700
|
+
overview,
|
|
6701
|
+
exportCount: exports.length,
|
|
6702
|
+
exports
|
|
6703
|
+
};
|
|
6704
|
+
}
|
|
6528
6705
|
let targetSymbol;
|
|
6529
6706
|
if (isGlobalModule) {
|
|
6530
6707
|
const actualSymbolName = module.startsWith("node:") ? module.slice(5) : module;
|
|
@@ -6545,9 +6722,11 @@ async function extractDocs(modulePath) {
|
|
|
6545
6722
|
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
6546
6723
|
const exportSymbol = exports.find((exp) => exp.getName() === symbol);
|
|
6547
6724
|
if (exportSymbol) {
|
|
6548
|
-
if (exportSymbol.
|
|
6725
|
+
if (exportSymbol.flags & ts5.SymbolFlags.Alias) {
|
|
6726
|
+
targetSymbol = checker.getAliasedSymbol(exportSymbol);
|
|
6727
|
+
} else if (exportSymbol.valueDeclaration && (ts5.isFunctionDeclaration(exportSymbol.valueDeclaration) || ts5.isClassDeclaration(exportSymbol.valueDeclaration) || ts5.isVariableDeclaration(exportSymbol.valueDeclaration) || ts5.isEnumDeclaration(exportSymbol.valueDeclaration))) {
|
|
6549
6728
|
targetSymbol = exportSymbol;
|
|
6550
|
-
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias)) {
|
|
6729
|
+
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias | ts5.SymbolFlags.Enum)) {
|
|
6551
6730
|
targetSymbol = exportSymbol;
|
|
6552
6731
|
} else {
|
|
6553
6732
|
targetSymbol = findSymbolInJavaScriptFile(sourceFile, checker, symbol);
|
|
@@ -6588,6 +6767,15 @@ async function getSourceLocation(reference) {
|
|
|
6588
6767
|
};
|
|
6589
6768
|
}
|
|
6590
6769
|
const { module, symbol, member, isStatic } = parseResult;
|
|
6770
|
+
if (!symbol) {
|
|
6771
|
+
return {
|
|
6772
|
+
success: false,
|
|
6773
|
+
error: {
|
|
6774
|
+
code: "INVALID_SPECIFIER",
|
|
6775
|
+
message: "Symbol reference required for source location lookup"
|
|
6776
|
+
}
|
|
6777
|
+
};
|
|
6778
|
+
}
|
|
6591
6779
|
const config2 = loadTsConfig(options.prefix);
|
|
6592
6780
|
let resolvedModule = resolveModule(module, config2.options);
|
|
6593
6781
|
let isGlobalModule = false;
|
|
@@ -6708,6 +6896,7 @@ var init_resolution = __esm(() => {
|
|
|
6708
6896
|
init_core();
|
|
6709
6897
|
init_module_resolver();
|
|
6710
6898
|
init_symbol_finder();
|
|
6899
|
+
init_utils();
|
|
6711
6900
|
init_formatters();
|
|
6712
6901
|
});
|
|
6713
6902
|
|
|
@@ -6787,18 +6976,21 @@ var init_src = __esm(() => {
|
|
|
6787
6976
|
});
|
|
6788
6977
|
|
|
6789
6978
|
// package.json
|
|
6790
|
-
var name = "tidewave", version = "0.
|
|
6979
|
+
var name = "tidewave", version = "0.7.0", package_default;
|
|
6791
6980
|
var init_package = __esm(() => {
|
|
6792
6981
|
package_default = {
|
|
6793
6982
|
name,
|
|
6794
6983
|
version,
|
|
6795
|
-
description: "Tidewave for JavaScript
|
|
6984
|
+
description: "Tidewave for JavaScript (Next.js, TanStack, Vite)",
|
|
6796
6985
|
keywords: [
|
|
6797
6986
|
"typescript",
|
|
6798
6987
|
"documentation",
|
|
6799
6988
|
"mcp",
|
|
6800
6989
|
"cli",
|
|
6801
|
-
"tidewave"
|
|
6990
|
+
"tidewave",
|
|
6991
|
+
"next",
|
|
6992
|
+
"vite",
|
|
6993
|
+
"tanstack"
|
|
6802
6994
|
],
|
|
6803
6995
|
homepage: "https://tidewave.ai",
|
|
6804
6996
|
repository: {
|
|
@@ -6835,6 +7027,11 @@ var init_package = __esm(() => {
|
|
|
6835
7027
|
import: "./dist/next-js/instrumentation.js",
|
|
6836
7028
|
require: "./dist/next-js/instrumentation.js"
|
|
6837
7029
|
},
|
|
7030
|
+
"./tanstack": {
|
|
7031
|
+
types: "./dist/tanstack.d.ts",
|
|
7032
|
+
import: "./dist/tanstack.js",
|
|
7033
|
+
require: "./dist/tanstack.js"
|
|
7034
|
+
},
|
|
6838
7035
|
"./package.json": "./package.json"
|
|
6839
7036
|
},
|
|
6840
7037
|
files: [
|
|
@@ -6845,7 +7042,7 @@ var init_package = __esm(() => {
|
|
|
6845
7042
|
],
|
|
6846
7043
|
scripts: {
|
|
6847
7044
|
dist: "bun run clean && bun run build:js && bun run build:types",
|
|
6848
|
-
"build:js": "bun build --outdir dist --root src --external typescript --external child_process --external module --external @opentelemetry/api --external @opentelemetry/sdk-logs --external @opentelemetry/sdk-trace-base src/next-js/handler.ts src/next-js/instrumentation.ts src/vite-plugin.ts src/evaluation/eval_worker.ts src/cli/index.ts --target node",
|
|
7045
|
+
"build:js": "bun build --outdir dist --root src --external typescript --external child_process --external module --external @opentelemetry/api --external @opentelemetry/sdk-logs --external @opentelemetry/sdk-trace-base src/next-js/handler.ts src/next-js/instrumentation.ts src/vite-plugin.ts src/tanstack.ts src/evaluation/eval_worker.ts src/cli/index.ts --target node",
|
|
6849
7046
|
"build:types": "tsc -p tsconfig.declarations.json",
|
|
6850
7047
|
dev: "bun run src/cli/index.ts",
|
|
6851
7048
|
test: "bun test",
|
|
@@ -6884,7 +7081,7 @@ var init_package = __esm(() => {
|
|
|
6884
7081
|
next: "^15.5.3",
|
|
6885
7082
|
prettier: "^3.4.2",
|
|
6886
7083
|
vite: "^7.1.5",
|
|
6887
|
-
vitest: "^
|
|
7084
|
+
vitest: "^4.1.8"
|
|
6888
7085
|
},
|
|
6889
7086
|
peerDependencies: {
|
|
6890
7087
|
typescript: "^5"
|
|
@@ -7957,10 +8154,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
7957
8154
|
}
|
|
7958
8155
|
return output;
|
|
7959
8156
|
}
|
|
7960
|
-
var ucs2encode = function
|
|
8157
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
7961
8158
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
7962
8159
|
};
|
|
7963
|
-
var basicToDigit = function
|
|
8160
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
7964
8161
|
if (codePoint - 48 < 10) {
|
|
7965
8162
|
return codePoint - 22;
|
|
7966
8163
|
}
|
|
@@ -7972,10 +8169,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
7972
8169
|
}
|
|
7973
8170
|
return base;
|
|
7974
8171
|
};
|
|
7975
|
-
var digitToBasic = function
|
|
8172
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
7976
8173
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
7977
8174
|
};
|
|
7978
|
-
var adapt = function
|
|
8175
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
7979
8176
|
var k = 0;
|
|
7980
8177
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
7981
8178
|
delta += floor(delta / numPoints);
|
|
@@ -7984,7 +8181,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
7984
8181
|
}
|
|
7985
8182
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
7986
8183
|
};
|
|
7987
|
-
var decode = function
|
|
8184
|
+
var decode = function decode2(input) {
|
|
7988
8185
|
var output = [];
|
|
7989
8186
|
var inputLength = input.length;
|
|
7990
8187
|
var i = 0;
|
|
@@ -8032,7 +8229,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8032
8229
|
}
|
|
8033
8230
|
return String.fromCodePoint.apply(String, output);
|
|
8034
8231
|
};
|
|
8035
|
-
var encode = function
|
|
8232
|
+
var encode = function encode2(input) {
|
|
8036
8233
|
var output = [];
|
|
8037
8234
|
input = ucs2decode(input);
|
|
8038
8235
|
var inputLength = input.length;
|
|
@@ -8146,12 +8343,12 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8146
8343
|
}
|
|
8147
8344
|
return output.join("");
|
|
8148
8345
|
};
|
|
8149
|
-
var toUnicode = function
|
|
8346
|
+
var toUnicode = function toUnicode2(input) {
|
|
8150
8347
|
return mapDomain(input, function(string) {
|
|
8151
8348
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
8152
8349
|
});
|
|
8153
8350
|
};
|
|
8154
|
-
var toASCII = function
|
|
8351
|
+
var toASCII = function toASCII2(input) {
|
|
8155
8352
|
return mapDomain(input, function(string) {
|
|
8156
8353
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
8157
8354
|
});
|
|
@@ -8548,13 +8745,13 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8548
8745
|
var handler = {
|
|
8549
8746
|
scheme: "http",
|
|
8550
8747
|
domainHost: true,
|
|
8551
|
-
parse: function
|
|
8748
|
+
parse: function parse2(components, options) {
|
|
8552
8749
|
if (!components.host) {
|
|
8553
8750
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
8554
8751
|
}
|
|
8555
8752
|
return components;
|
|
8556
8753
|
},
|
|
8557
|
-
serialize: function
|
|
8754
|
+
serialize: function serialize2(components, options) {
|
|
8558
8755
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
8559
8756
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
8560
8757
|
components.port = undefined;
|
|
@@ -8577,7 +8774,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8577
8774
|
var handler$2 = {
|
|
8578
8775
|
scheme: "ws",
|
|
8579
8776
|
domainHost: true,
|
|
8580
|
-
parse: function
|
|
8777
|
+
parse: function parse2(components, options) {
|
|
8581
8778
|
var wsComponents = components;
|
|
8582
8779
|
wsComponents.secure = isSecure(wsComponents);
|
|
8583
8780
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -8585,7 +8782,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8585
8782
|
wsComponents.query = undefined;
|
|
8586
8783
|
return wsComponents;
|
|
8587
8784
|
},
|
|
8588
|
-
serialize: function
|
|
8785
|
+
serialize: function serialize2(wsComponents, options) {
|
|
8589
8786
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
8590
8787
|
wsComponents.port = undefined;
|
|
8591
8788
|
}
|
|
@@ -8753,7 +8950,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8753
8950
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
8754
8951
|
var handler$6 = {
|
|
8755
8952
|
scheme: "urn:uuid",
|
|
8756
|
-
parse: function
|
|
8953
|
+
parse: function parse2(urnComponents, options) {
|
|
8757
8954
|
var uuidComponents = urnComponents;
|
|
8758
8955
|
uuidComponents.uuid = uuidComponents.nss;
|
|
8759
8956
|
uuidComponents.nss = undefined;
|
|
@@ -8762,7 +8959,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
8762
8959
|
}
|
|
8763
8960
|
return uuidComponents;
|
|
8764
8961
|
},
|
|
8765
|
-
serialize: function
|
|
8962
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
8766
8963
|
var urnComponents = uuidComponents;
|
|
8767
8964
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
8768
8965
|
return urnComponents;
|
|
@@ -10208,7 +10405,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
10208
10405
|
|
|
10209
10406
|
// node_modules/ajv/lib/cache.js
|
|
10210
10407
|
var require_cache = __commonJS((exports, module) => {
|
|
10211
|
-
var Cache = module.exports = function
|
|
10408
|
+
var Cache = module.exports = function Cache2() {
|
|
10212
10409
|
this._cache = {};
|
|
10213
10410
|
};
|
|
10214
10411
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
@@ -15503,6 +15700,7 @@ var init_zodToJsonSchema = __esm(() => {
|
|
|
15503
15700
|
|
|
15504
15701
|
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
15505
15702
|
var init_esm = __esm(() => {
|
|
15703
|
+
init_zodToJsonSchema();
|
|
15506
15704
|
init_Options();
|
|
15507
15705
|
init_Refs();
|
|
15508
15706
|
init_parseDef();
|
|
@@ -15534,7 +15732,6 @@ var init_esm = __esm(() => {
|
|
|
15534
15732
|
init_unknown();
|
|
15535
15733
|
init_selectParser();
|
|
15536
15734
|
init_zodToJsonSchema();
|
|
15537
|
-
init_zodToJsonSchema();
|
|
15538
15735
|
});
|
|
15539
15736
|
|
|
15540
15737
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
@@ -16156,23 +16353,31 @@ var init_mcp = __esm(() => {
|
|
|
16156
16353
|
};
|
|
16157
16354
|
});
|
|
16158
16355
|
|
|
16159
|
-
// src/logger/
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
|
|
16164
|
-
|
|
16165
|
-
|
|
16166
|
-
|
|
16167
|
-
|
|
16168
|
-
|
|
16169
|
-
|
|
16170
|
-
|
|
16171
|
-
this.
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16356
|
+
// src/logger/tidewave-logger.ts
|
|
16357
|
+
import { appendFile, readFile } from "fs/promises";
|
|
16358
|
+
import * as path5 from "path";
|
|
16359
|
+
import * as os2 from "os";
|
|
16360
|
+
import * as crypto from "crypto";
|
|
16361
|
+
|
|
16362
|
+
class TidewaveLogger {
|
|
16363
|
+
logFilePath;
|
|
16364
|
+
constructor() {
|
|
16365
|
+
const cwd = process.cwd();
|
|
16366
|
+
const digest = crypto.createHash("md5").update(cwd).digest("hex").slice(0, 16);
|
|
16367
|
+
const tempDir = os2.tmpdir();
|
|
16368
|
+
this.logFilePath = path5.join(tempDir, `${digest}.tidewave.ndjson`);
|
|
16369
|
+
}
|
|
16370
|
+
async addLog(log) {
|
|
16371
|
+
const line = JSON.stringify(log) + `
|
|
16372
|
+
`;
|
|
16373
|
+
try {
|
|
16374
|
+
await appendFile(this.logFilePath, line, "utf8");
|
|
16375
|
+
} catch (error) {
|
|
16376
|
+
console.log("[Tidewave] failed to write to log file, error:", error);
|
|
16377
|
+
}
|
|
16378
|
+
}
|
|
16379
|
+
async getLogs(options) {
|
|
16380
|
+
let logs = await this.getAllLogs();
|
|
16176
16381
|
if (options?.level) {
|
|
16177
16382
|
const level = options.level.toUpperCase();
|
|
16178
16383
|
logs = logs.filter((log) => log.severityText === level);
|
|
@@ -16190,31 +16395,26 @@ class CircularBuffer {
|
|
|
16190
16395
|
}
|
|
16191
16396
|
return logs;
|
|
16192
16397
|
}
|
|
16193
|
-
getAllLogs() {
|
|
16194
|
-
|
|
16195
|
-
|
|
16398
|
+
async getAllLogs() {
|
|
16399
|
+
try {
|
|
16400
|
+
const content = await readFile(this.logFilePath, "utf8");
|
|
16401
|
+
return content.split(`
|
|
16402
|
+
`).map((line) => {
|
|
16403
|
+
try {
|
|
16404
|
+
return JSON.parse(line);
|
|
16405
|
+
} catch {
|
|
16406
|
+
return null;
|
|
16407
|
+
}
|
|
16408
|
+
}).filter((log) => log !== null);
|
|
16409
|
+
} catch (error) {
|
|
16410
|
+
console.log("[Tidewave] failed to read from log file, error:", error);
|
|
16411
|
+
return [];
|
|
16196
16412
|
}
|
|
16197
|
-
return [...this.buffer.slice(this.writeIndex), ...this.buffer.slice(0, this.writeIndex)].filter(Boolean);
|
|
16198
|
-
}
|
|
16199
|
-
getStats() {
|
|
16200
|
-
return {
|
|
16201
|
-
totalLogs: this.count,
|
|
16202
|
-
bufferSize: this.maxSize,
|
|
16203
|
-
bufferUsage: Math.min(this.count / this.maxSize * 100, 100).toFixed(1) + "%"
|
|
16204
|
-
};
|
|
16205
|
-
}
|
|
16206
|
-
clear() {
|
|
16207
|
-
this.buffer = new Array(this.maxSize);
|
|
16208
|
-
this.writeIndex = 0;
|
|
16209
|
-
this.count = 0;
|
|
16210
16413
|
}
|
|
16211
16414
|
}
|
|
16212
|
-
var
|
|
16213
|
-
var
|
|
16214
|
-
|
|
16215
|
-
globalThis.__tidewaveCircularBuffer = new CircularBuffer(1024);
|
|
16216
|
-
}
|
|
16217
|
-
circularBuffer = globalThis.__tidewaveCircularBuffer;
|
|
16415
|
+
var tidewaveLogger;
|
|
16416
|
+
var init_tidewave_logger = __esm(() => {
|
|
16417
|
+
tidewaveLogger = new TidewaveLogger;
|
|
16218
16418
|
});
|
|
16219
16419
|
|
|
16220
16420
|
// src/mcp.ts
|
|
@@ -16277,7 +16477,7 @@ async function handleGetDocs({ reference }) {
|
|
|
16277
16477
|
isError: true
|
|
16278
16478
|
};
|
|
16279
16479
|
}
|
|
16280
|
-
if (!docs.documentation) {
|
|
16480
|
+
if ("documentation" in docs && !docs.documentation) {
|
|
16281
16481
|
return {
|
|
16282
16482
|
content: [
|
|
16283
16483
|
{
|
|
@@ -16306,15 +16506,15 @@ async function handleGetSourcePath({ reference }) {
|
|
|
16306
16506
|
isError: true
|
|
16307
16507
|
};
|
|
16308
16508
|
}
|
|
16309
|
-
const { path:
|
|
16509
|
+
const { path: path6, format } = sourceResult;
|
|
16310
16510
|
return {
|
|
16311
|
-
content: [{ type: "text", text: `${
|
|
16511
|
+
content: [{ type: "text", text: `${path6}(${format})` }],
|
|
16312
16512
|
isError: false
|
|
16313
16513
|
};
|
|
16314
16514
|
}
|
|
16315
16515
|
async function handleGetLogs(args) {
|
|
16316
16516
|
try {
|
|
16317
|
-
const logs =
|
|
16517
|
+
const logs = await tidewaveLogger.getLogs({
|
|
16318
16518
|
tail: args.tail,
|
|
16319
16519
|
grep: args.grep,
|
|
16320
16520
|
level: args.level,
|
|
@@ -16370,7 +16570,7 @@ var init_mcp2 = __esm(() => {
|
|
|
16370
16570
|
init_package();
|
|
16371
16571
|
init_core();
|
|
16372
16572
|
init_src();
|
|
16373
|
-
|
|
16573
|
+
init_tidewave_logger();
|
|
16374
16574
|
({
|
|
16375
16575
|
docs: { mcp: docsMcp },
|
|
16376
16576
|
source: { mcp: sourceMcp },
|
|
@@ -16991,7 +17191,7 @@ init_mcp2();
|
|
|
16991
17191
|
|
|
16992
17192
|
// src/cli/install.ts
|
|
16993
17193
|
import * as fs2 from "fs";
|
|
16994
|
-
import * as
|
|
17194
|
+
import * as path6 from "path";
|
|
16995
17195
|
import * as child_process from "child_process";
|
|
16996
17196
|
import * as readline from "readline";
|
|
16997
17197
|
async function handleInstall(options) {
|
|
@@ -17039,7 +17239,7 @@ The installer only works for Next.js projects
|
|
|
17039
17239
|
}
|
|
17040
17240
|
async function detectNextJsVersion(dir) {
|
|
17041
17241
|
try {
|
|
17042
|
-
const nextPackageJsonPath =
|
|
17242
|
+
const nextPackageJsonPath = path6.join(dir, "node_modules", "next", "package.json");
|
|
17043
17243
|
if (!fs2.existsSync(nextPackageJsonPath)) {
|
|
17044
17244
|
return null;
|
|
17045
17245
|
}
|
|
@@ -17059,13 +17259,13 @@ async function detectNextJsVersion(dir) {
|
|
|
17059
17259
|
}
|
|
17060
17260
|
}
|
|
17061
17261
|
function detectPackageManager(dir) {
|
|
17062
|
-
if (fs2.existsSync(
|
|
17262
|
+
if (fs2.existsSync(path6.join(dir, "bun.lockb")))
|
|
17063
17263
|
return "bun";
|
|
17064
|
-
if (fs2.existsSync(
|
|
17264
|
+
if (fs2.existsSync(path6.join(dir, "pnpm-lock.yaml")))
|
|
17065
17265
|
return "pnpm";
|
|
17066
|
-
if (fs2.existsSync(
|
|
17266
|
+
if (fs2.existsSync(path6.join(dir, "yarn.lock")))
|
|
17067
17267
|
return "yarn";
|
|
17068
|
-
if (fs2.existsSync(
|
|
17268
|
+
if (fs2.existsSync(path6.join(dir, "package-lock.json")))
|
|
17069
17269
|
return "npm";
|
|
17070
17270
|
return "npm";
|
|
17071
17271
|
}
|
|
@@ -17134,8 +17334,8 @@ Please install manually:
|
|
|
17134
17334
|
}
|
|
17135
17335
|
}
|
|
17136
17336
|
async function createApiHandler(dir, dryRun) {
|
|
17137
|
-
const apiDir =
|
|
17138
|
-
const handlerPath =
|
|
17337
|
+
const apiDir = path6.join(dir, "pages", "api");
|
|
17338
|
+
const handlerPath = path6.join(apiDir, "tidewave.ts");
|
|
17139
17339
|
const handlerContent = `import type { NextApiRequest, NextApiResponse } from 'next';
|
|
17140
17340
|
|
|
17141
17341
|
export default async function handler(
|
|
@@ -17160,28 +17360,28 @@ export const config = {
|
|
|
17160
17360
|
`;
|
|
17161
17361
|
if (fs2.existsSync(handlerPath)) {
|
|
17162
17362
|
if (dryRun) {
|
|
17163
|
-
console.log(source_default.gray(`[DRY RUN] Would ask to overwrite: ${
|
|
17363
|
+
console.log(source_default.gray(`[DRY RUN] Would ask to overwrite: ${path6.relative(dir, handlerPath)}`));
|
|
17164
17364
|
return;
|
|
17165
17365
|
}
|
|
17166
17366
|
const shouldOverwrite = await promptUser(source_default.yellow(`
|
|
17167
|
-
⚠️ ${
|
|
17367
|
+
⚠️ ${path6.relative(dir, handlerPath)} already exists. Overwrite? (Y/n): `));
|
|
17168
17368
|
if (!shouldOverwrite) {
|
|
17169
|
-
console.log(source_default.gray(`⏭️ Skipping: ${
|
|
17369
|
+
console.log(source_default.gray(`⏭️ Skipping: ${path6.relative(dir, handlerPath)}`));
|
|
17170
17370
|
return;
|
|
17171
17371
|
}
|
|
17172
17372
|
}
|
|
17173
17373
|
if (dryRun) {
|
|
17174
|
-
console.log(source_default.gray(`[DRY RUN] Would create: ${
|
|
17374
|
+
console.log(source_default.gray(`[DRY RUN] Would create: ${path6.relative(dir, handlerPath)}`));
|
|
17175
17375
|
return;
|
|
17176
17376
|
}
|
|
17177
17377
|
fs2.mkdirSync(apiDir, { recursive: true });
|
|
17178
17378
|
fs2.writeFileSync(handlerPath, handlerContent, "utf-8");
|
|
17179
|
-
console.log(source_default.green(`✅ Created: ${
|
|
17379
|
+
console.log(source_default.green(`✅ Created: ${path6.relative(dir, handlerPath)}`));
|
|
17180
17380
|
}
|
|
17181
17381
|
async function createMiddleware(dir, nextVersion, dryRun) {
|
|
17182
17382
|
const isNext16Plus = nextVersion.major >= 16;
|
|
17183
17383
|
const fileName = isNext16Plus ? "proxy.ts" : "middleware.ts";
|
|
17184
|
-
const filePath =
|
|
17384
|
+
const filePath = path6.join(dir, fileName);
|
|
17185
17385
|
if (fs2.existsSync(filePath)) {
|
|
17186
17386
|
console.log(source_default.yellow(`⏭️ ${fileName} already exists`));
|
|
17187
17387
|
const content = fs2.readFileSync(filePath, "utf-8");
|
|
@@ -17245,9 +17445,9 @@ function printMiddlewareInstructions(isNext16Plus) {
|
|
|
17245
17445
|
console.log();
|
|
17246
17446
|
}
|
|
17247
17447
|
async function createInstrumentation(dir, dryRun) {
|
|
17248
|
-
const rootPath =
|
|
17249
|
-
const srcPath =
|
|
17250
|
-
const hasSrcDir = fs2.existsSync(
|
|
17448
|
+
const rootPath = path6.join(dir, "instrumentation.ts");
|
|
17449
|
+
const srcPath = path6.join(dir, "src", "instrumentation.ts");
|
|
17450
|
+
const hasSrcDir = fs2.existsSync(path6.join(dir, "src"));
|
|
17251
17451
|
const instrumentationPath = hasSrcDir ? srcPath : rootPath;
|
|
17252
17452
|
if (fs2.existsSync(rootPath) || fs2.existsSync(srcPath)) {
|
|
17253
17453
|
const existingPath = fs2.existsSync(rootPath) ? rootPath : srcPath;
|
|
@@ -17296,14 +17496,14 @@ export async function register() {
|
|
|
17296
17496
|
}
|
|
17297
17497
|
`;
|
|
17298
17498
|
if (dryRun) {
|
|
17299
|
-
console.log(source_default.gray(`[DRY RUN] Would create: ${
|
|
17499
|
+
console.log(source_default.gray(`[DRY RUN] Would create: ${path6.relative(dir, instrumentationPath)}`));
|
|
17300
17500
|
return;
|
|
17301
17501
|
}
|
|
17302
17502
|
if (hasSrcDir) {
|
|
17303
|
-
fs2.mkdirSync(
|
|
17503
|
+
fs2.mkdirSync(path6.dirname(instrumentationPath), { recursive: true });
|
|
17304
17504
|
}
|
|
17305
17505
|
fs2.writeFileSync(instrumentationPath, instrumentationContent, "utf-8");
|
|
17306
|
-
console.log(source_default.green(`✅ Created: ${
|
|
17506
|
+
console.log(source_default.green(`✅ Created: ${path6.relative(dir, instrumentationPath)}`));
|
|
17307
17507
|
}
|
|
17308
17508
|
function printInstrumentationInstructions() {
|
|
17309
17509
|
console.log(source_default.cyan(` // Inside your register() function:
|
|
@@ -17322,9 +17522,9 @@ function printInstrumentationInstructions() {
|
|
|
17322
17522
|
}
|
|
17323
17523
|
|
|
17324
17524
|
// src/cli/index.ts
|
|
17325
|
-
function chdir(
|
|
17525
|
+
function chdir(path7) {
|
|
17326
17526
|
try {
|
|
17327
|
-
process.chdir(
|
|
17527
|
+
process.chdir(path7);
|
|
17328
17528
|
} catch (e) {
|
|
17329
17529
|
console.error(source_default.red(`Failed to apply given prefix: ${e}`));
|
|
17330
17530
|
}
|