@suss/adapter-typescript 0.24.2 → 0.24.4
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/index.cjs +177 -91
- package/dist/index.js +173 -85
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/adapter.ts
|
|
2
|
-
import
|
|
2
|
+
import path11 from "path";
|
|
3
3
|
import {
|
|
4
4
|
Node as Node64,
|
|
5
5
|
Project,
|
|
@@ -1871,8 +1871,8 @@ function loadImportGraphsDepthFirstFromPaths(project, rootPaths) {
|
|
|
1871
1871
|
stack.pop();
|
|
1872
1872
|
loadOrder.push(top.path);
|
|
1873
1873
|
let deepest = 0;
|
|
1874
|
-
for (const
|
|
1875
|
-
deepest = Math.max(deepest, chainDepth.get(
|
|
1874
|
+
for (const path15 of top.deps) {
|
|
1875
|
+
deepest = Math.max(deepest, chainDepth.get(path15) ?? 0);
|
|
1876
1876
|
}
|
|
1877
1877
|
chainDepth.set(top.path, deepest + 1);
|
|
1878
1878
|
}
|
|
@@ -2224,11 +2224,11 @@ function walkAndWarm(root, reach) {
|
|
|
2224
2224
|
if (warmedFiles.get(target) !== void 0) {
|
|
2225
2225
|
continue;
|
|
2226
2226
|
}
|
|
2227
|
-
const
|
|
2228
|
-
if (visited.has(
|
|
2227
|
+
const path15 = target.getFilePath();
|
|
2228
|
+
if (visited.has(path15)) {
|
|
2229
2229
|
continue;
|
|
2230
2230
|
}
|
|
2231
|
-
visited.add(
|
|
2231
|
+
visited.add(path15);
|
|
2232
2232
|
stack.push(frameOf(target, reach));
|
|
2233
2233
|
continue;
|
|
2234
2234
|
}
|
|
@@ -2245,7 +2245,7 @@ function sitsOnWarmChains(file) {
|
|
|
2245
2245
|
return false;
|
|
2246
2246
|
}
|
|
2247
2247
|
const imported = importedFilePathsOf(project, file.getFilePath());
|
|
2248
|
-
return imported.length > 0 && imported.every((
|
|
2248
|
+
return imported.length > 0 && imported.every((path15) => warmed.has(path15));
|
|
2249
2249
|
}
|
|
2250
2250
|
function markWarmed(file) {
|
|
2251
2251
|
warmedFiles.set(file, true);
|
|
@@ -5024,7 +5024,7 @@ function isPathStatement(node) {
|
|
|
5024
5024
|
return Node16.isStatement(node) && !Node16.isFunctionDeclaration(node);
|
|
5025
5025
|
}
|
|
5026
5026
|
function siteOf(node) {
|
|
5027
|
-
const
|
|
5027
|
+
const path15 = [];
|
|
5028
5028
|
let current2 = node;
|
|
5029
5029
|
for (; ; ) {
|
|
5030
5030
|
const parent = current2.getParent();
|
|
@@ -5032,10 +5032,10 @@ function siteOf(node) {
|
|
|
5032
5032
|
return null;
|
|
5033
5033
|
}
|
|
5034
5034
|
if (isPathStatement(current2)) {
|
|
5035
|
-
|
|
5035
|
+
path15.unshift(current2);
|
|
5036
5036
|
}
|
|
5037
5037
|
if (isRoot(parent)) {
|
|
5038
|
-
return { root: parent, path:
|
|
5038
|
+
return { root: parent, path: path15 };
|
|
5039
5039
|
}
|
|
5040
5040
|
current2 = parent;
|
|
5041
5041
|
}
|
|
@@ -7048,14 +7048,14 @@ function unitForJsxRoute(node, match, routeNames, kind, resolution) {
|
|
|
7048
7048
|
}
|
|
7049
7049
|
return routeUnit(node, kind, match.method, resolved.path, target, resolution);
|
|
7050
7050
|
}
|
|
7051
|
-
function routeUnit(at, kind, method,
|
|
7052
|
-
const routeInfo = { method, path:
|
|
7051
|
+
function routeUnit(at, kind, method, path15, target, resolution) {
|
|
7052
|
+
const routeInfo = { method, path: path15 };
|
|
7053
7053
|
if (target.kind === "unreadable") {
|
|
7054
7054
|
return {
|
|
7055
7055
|
func: null,
|
|
7056
7056
|
announcedAt: at,
|
|
7057
7057
|
kind,
|
|
7058
|
-
name:
|
|
7058
|
+
name: path15,
|
|
7059
7059
|
nameKind: "label",
|
|
7060
7060
|
routeInfo
|
|
7061
7061
|
};
|
|
@@ -8321,11 +8321,11 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8321
8321
|
return null;
|
|
8322
8322
|
}
|
|
8323
8323
|
const method2 = stringPropertyOf(arg, binding.method.property, resolution);
|
|
8324
|
-
const
|
|
8325
|
-
if (method2 === null ||
|
|
8324
|
+
const path16 = stringPropertyOf(arg, binding.path.property, resolution);
|
|
8325
|
+
if (method2 === null || path16 === null) {
|
|
8326
8326
|
return null;
|
|
8327
8327
|
}
|
|
8328
|
-
return { method: method2.toUpperCase(), path:
|
|
8328
|
+
return { method: method2.toUpperCase(), path: path16 };
|
|
8329
8329
|
}
|
|
8330
8330
|
if (binding.method.type !== "fromRegistration" || binding.path.type !== "fromArgument") {
|
|
8331
8331
|
return null;
|
|
@@ -8342,8 +8342,8 @@ function extractRouteInfoFromBinding(call, methodName, binding, resolution) {
|
|
|
8342
8342
|
method = arg.getLiteralValue().toUpperCase();
|
|
8343
8343
|
}
|
|
8344
8344
|
const pathArg = call.getArguments()[binding.path.position];
|
|
8345
|
-
const
|
|
8346
|
-
return
|
|
8345
|
+
const path15 = pathArg === void 0 ? void 0 : pathFromArgument(pathArg, resolution);
|
|
8346
|
+
return path15 === void 0 ? null : { method, path: path15 };
|
|
8347
8347
|
}
|
|
8348
8348
|
|
|
8349
8349
|
// src/discovery/registrationLoop.ts
|
|
@@ -8475,7 +8475,7 @@ function bodyCallsOnRoutable(loop, guard, resolution) {
|
|
|
8475
8475
|
}
|
|
8476
8476
|
function readRouteSpec(element, shape, resolution) {
|
|
8477
8477
|
let method = null;
|
|
8478
|
-
let
|
|
8478
|
+
let path15 = null;
|
|
8479
8479
|
let handler = null;
|
|
8480
8480
|
for (const prop of element.getProperties()) {
|
|
8481
8481
|
if (Node33.isMethodDeclaration(prop) && prop.getName() === shape.handlerKey) {
|
|
@@ -8493,16 +8493,16 @@ function readRouteSpec(element, shape, resolution) {
|
|
|
8493
8493
|
if (name === shape.methodKey) {
|
|
8494
8494
|
method = readStringLiteralValue(init);
|
|
8495
8495
|
} else if (name === shape.pathKey) {
|
|
8496
|
-
|
|
8496
|
+
path15 = readStringLiteralValue(init);
|
|
8497
8497
|
} else if (name === shape.handlerKey) {
|
|
8498
8498
|
const func = functionValueOf(init, resolution);
|
|
8499
8499
|
handler = func === null ? null : { func, name: handlerName(init) };
|
|
8500
8500
|
}
|
|
8501
8501
|
}
|
|
8502
|
-
if (method === null ||
|
|
8502
|
+
if (method === null || path15 === null || handler === null) {
|
|
8503
8503
|
return null;
|
|
8504
8504
|
}
|
|
8505
|
-
return { method, path:
|
|
8505
|
+
return { method, path: path15, handler: handler.func, handlerName: handler.name };
|
|
8506
8506
|
}
|
|
8507
8507
|
function readStringLiteralValue(node) {
|
|
8508
8508
|
if (Node33.isStringLiteral(node) || Node33.isNoSubstitutionTemplateLiteral(node)) {
|
|
@@ -8623,8 +8623,8 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8623
8623
|
const subject = subjectOfCall(sourceFile, args, match, resolution);
|
|
8624
8624
|
const prefix = subject === void 0 ? "" : mountPrefixes?.effectivePrefixFor(subject) ?? "";
|
|
8625
8625
|
for (const reg of match.registrations) {
|
|
8626
|
-
const
|
|
8627
|
-
if (
|
|
8626
|
+
const path15 = substitutePath(reg.pathTemplate, args);
|
|
8627
|
+
if (path15 === null) {
|
|
8628
8628
|
continue;
|
|
8629
8629
|
}
|
|
8630
8630
|
const handler = resolveHandler(reg.handlerArg, args, resolution);
|
|
@@ -8638,7 +8638,7 @@ function discoverRegistrationTemplates(sourceFile, match, kind, resolution, moun
|
|
|
8638
8638
|
...subject === void 0 ? {} : { registrationSubjectId: nodeId(subject) },
|
|
8639
8639
|
routeInfo: {
|
|
8640
8640
|
method: reg.method.toUpperCase(),
|
|
8641
|
-
path: prefix === "" ?
|
|
8641
|
+
path: prefix === "" ? path15 : joinMountedPath2(prefix, path15)
|
|
8642
8642
|
}
|
|
8643
8643
|
});
|
|
8644
8644
|
}
|
|
@@ -9101,24 +9101,24 @@ function declName(decl) {
|
|
|
9101
9101
|
|
|
9102
9102
|
// src/parameterReads.ts
|
|
9103
9103
|
function pathAbove(reference) {
|
|
9104
|
-
const
|
|
9104
|
+
const path15 = [];
|
|
9105
9105
|
let current2 = reference;
|
|
9106
9106
|
for (; ; ) {
|
|
9107
9107
|
const parent = current2.getParent();
|
|
9108
9108
|
if (parent !== void 0 && Node38.isPropertyAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9109
|
-
|
|
9109
|
+
path15.push(parent.getName());
|
|
9110
9110
|
current2 = parent;
|
|
9111
9111
|
continue;
|
|
9112
9112
|
}
|
|
9113
9113
|
if (parent !== void 0 && Node38.isElementAccessExpression(parent) && parent.getExpression() === current2) {
|
|
9114
9114
|
const argument = parent.getArgumentExpression();
|
|
9115
9115
|
if (argument !== void 0 && Node38.isStringLiteral(argument)) {
|
|
9116
|
-
|
|
9116
|
+
path15.push(argument.getLiteralValue());
|
|
9117
9117
|
current2 = parent;
|
|
9118
9118
|
continue;
|
|
9119
9119
|
}
|
|
9120
9120
|
}
|
|
9121
|
-
return
|
|
9121
|
+
return path15;
|
|
9122
9122
|
}
|
|
9123
9123
|
}
|
|
9124
9124
|
function declaresParameterOf(node, func) {
|
|
@@ -12471,9 +12471,9 @@ function createSourceFileLookup(project) {
|
|
|
12471
12471
|
if (sf === null) {
|
|
12472
12472
|
return null;
|
|
12473
12473
|
}
|
|
12474
|
-
const
|
|
12475
|
-
const index = functionsByFile.get(
|
|
12476
|
-
functionsByFile.set(
|
|
12474
|
+
const path15 = sf.getFilePath();
|
|
12475
|
+
const index = functionsByFile.get(path15) ?? indexFunctions(sf);
|
|
12476
|
+
functionsByFile.set(path15, index);
|
|
12477
12477
|
if (location.span !== void 0) {
|
|
12478
12478
|
const bySpan = index.get(spanKey(location.span));
|
|
12479
12479
|
if (bySpan !== void 0) {
|
|
@@ -12660,7 +12660,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12660
12660
|
}
|
|
12661
12661
|
const responses = [];
|
|
12662
12662
|
let method;
|
|
12663
|
-
let
|
|
12663
|
+
let path15;
|
|
12664
12664
|
for (const prop of endpointNode.getProperties()) {
|
|
12665
12665
|
if (!Node54.isPropertyAssignment(prop)) {
|
|
12666
12666
|
continue;
|
|
@@ -12675,7 +12675,7 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12675
12675
|
if (propName === pattern.pathProperty) {
|
|
12676
12676
|
const val = prop.getInitializer();
|
|
12677
12677
|
if (val !== void 0 && Node54.isStringLiteral(val)) {
|
|
12678
|
-
|
|
12678
|
+
path15 = val.getLiteralValue();
|
|
12679
12679
|
}
|
|
12680
12680
|
}
|
|
12681
12681
|
if (propName === pattern.responseExtraction.property) {
|
|
@@ -12700,10 +12700,10 @@ function extractEndpointContract(endpointNode, pattern, framework, resolution) {
|
|
|
12700
12700
|
if (responses.length === 0) {
|
|
12701
12701
|
return null;
|
|
12702
12702
|
}
|
|
12703
|
-
const boundaryBinding = method !== void 0 ||
|
|
12703
|
+
const boundaryBinding = method !== void 0 || path15 !== void 0 ? restBinding({
|
|
12704
12704
|
transport: "http",
|
|
12705
12705
|
method: method ?? null,
|
|
12706
|
-
path:
|
|
12706
|
+
path: path15 ?? null,
|
|
12707
12707
|
recognition: framework
|
|
12708
12708
|
}) : null;
|
|
12709
12709
|
return {
|
|
@@ -12914,6 +12914,11 @@ function parameterName(segment, convention) {
|
|
|
12914
12914
|
}
|
|
12915
12915
|
|
|
12916
12916
|
// src/discovery/graphqlClientConstruction.ts
|
|
12917
|
+
import fs4 from "fs";
|
|
12918
|
+
import path8 from "path";
|
|
12919
|
+
import {
|
|
12920
|
+
parse as graphqlParse2
|
|
12921
|
+
} from "graphql";
|
|
12917
12922
|
import picomatch2 from "picomatch";
|
|
12918
12923
|
import {
|
|
12919
12924
|
Node as Node55
|
|
@@ -12931,15 +12936,20 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
|
12931
12936
|
const workspace = sole !== null ? boundWorkspaceFor(sole, packs) : null;
|
|
12932
12937
|
const soleClient = sole !== null ? workspace !== null ? { ...sole, workspace } : sole : null;
|
|
12933
12938
|
let registry = null;
|
|
12939
|
+
let defined = null;
|
|
12934
12940
|
for (const summary of summaries) {
|
|
12935
12941
|
if (!isGraphqlOperationBinding(summary.identity.boundaryBinding)) {
|
|
12936
12942
|
continue;
|
|
12937
12943
|
}
|
|
12938
|
-
const
|
|
12944
|
+
const found = readGraphqlMetadata(summary) ?? {};
|
|
12945
|
+
const existing = withoutFragmentsDefinedElsewhere(found, () => {
|
|
12946
|
+
defined ??= fragmentsRegisteredIn(sourceFiles);
|
|
12947
|
+
return defined;
|
|
12948
|
+
});
|
|
12939
12949
|
const scoped = scopedWorkspaceFor(summary.location.file, scopes);
|
|
12940
12950
|
const client = scoped !== null ? { uri: null, uriRef: null, workspace: scoped } : soleClient;
|
|
12941
12951
|
const dangling = (existing.unresolvedFragments?.length ?? 0) > 0;
|
|
12942
|
-
if (client === null && !dangling) {
|
|
12952
|
+
if (client === null && !dangling && existing === found) {
|
|
12943
12953
|
continue;
|
|
12944
12954
|
}
|
|
12945
12955
|
if (dangling && registry === null) {
|
|
@@ -12952,6 +12962,84 @@ function stampGraphqlClientRefs(summaries, sourceFiles, packs, resolution) {
|
|
|
12952
12962
|
});
|
|
12953
12963
|
}
|
|
12954
12964
|
}
|
|
12965
|
+
function fragmentsRegisteredIn(sourceFiles) {
|
|
12966
|
+
const registered = /* @__PURE__ */ new Set();
|
|
12967
|
+
for (const sourceFile of sourceFiles) {
|
|
12968
|
+
sourceFile.forEachDescendant((node) => {
|
|
12969
|
+
if (!Node55.isCallExpression(node)) {
|
|
12970
|
+
return;
|
|
12971
|
+
}
|
|
12972
|
+
const argument = node.getArguments()[0];
|
|
12973
|
+
if (argument === void 0 || !Node55.isNoSubstitutionTemplateLiteral(argument)) {
|
|
12974
|
+
return;
|
|
12975
|
+
}
|
|
12976
|
+
for (const name of fragmentOnlyDocumentNames(argument.getLiteralText())) {
|
|
12977
|
+
registered.add(name);
|
|
12978
|
+
}
|
|
12979
|
+
});
|
|
12980
|
+
}
|
|
12981
|
+
for (const text of graphqlFileTextsNear(sourceFiles)) {
|
|
12982
|
+
for (const name of fragmentOnlyDocumentNames(text)) {
|
|
12983
|
+
registered.add(name);
|
|
12984
|
+
}
|
|
12985
|
+
}
|
|
12986
|
+
return registered;
|
|
12987
|
+
}
|
|
12988
|
+
function graphqlFileTextsNear(sourceFiles) {
|
|
12989
|
+
const roots = new Set(
|
|
12990
|
+
sourceFiles.map((sourceFile) => path8.dirname(sourceFile.getFilePath()))
|
|
12991
|
+
);
|
|
12992
|
+
const texts = [];
|
|
12993
|
+
for (const root of roots) {
|
|
12994
|
+
let entries;
|
|
12995
|
+
try {
|
|
12996
|
+
entries = fs4.readdirSync(root, { withFileTypes: true });
|
|
12997
|
+
} catch {
|
|
12998
|
+
continue;
|
|
12999
|
+
}
|
|
13000
|
+
for (const entry of entries) {
|
|
13001
|
+
if (entry.isFile() && /\.(graphql|gql)$/.test(entry.name)) {
|
|
13002
|
+
try {
|
|
13003
|
+
texts.push(fs4.readFileSync(path8.join(root, entry.name), "utf8"));
|
|
13004
|
+
} catch {
|
|
13005
|
+
}
|
|
13006
|
+
}
|
|
13007
|
+
}
|
|
13008
|
+
}
|
|
13009
|
+
return texts;
|
|
13010
|
+
}
|
|
13011
|
+
function fragmentOnlyDocumentNames(text) {
|
|
13012
|
+
if (!text.includes("fragment")) {
|
|
13013
|
+
return [];
|
|
13014
|
+
}
|
|
13015
|
+
let parsed;
|
|
13016
|
+
try {
|
|
13017
|
+
parsed = graphqlParse2(text);
|
|
13018
|
+
} catch {
|
|
13019
|
+
return [];
|
|
13020
|
+
}
|
|
13021
|
+
const names = [];
|
|
13022
|
+
for (const definition of parsed.definitions) {
|
|
13023
|
+
if (definition.kind !== "FragmentDefinition") {
|
|
13024
|
+
return [];
|
|
13025
|
+
}
|
|
13026
|
+
names.push(definition.name.value);
|
|
13027
|
+
}
|
|
13028
|
+
return names;
|
|
13029
|
+
}
|
|
13030
|
+
function withoutFragmentsDefinedElsewhere(metadata, definedInProject) {
|
|
13031
|
+
const unresolved = metadata.unresolvedFragments ?? [];
|
|
13032
|
+
if (unresolved.length === 0) {
|
|
13033
|
+
return metadata;
|
|
13034
|
+
}
|
|
13035
|
+
const defined = definedInProject();
|
|
13036
|
+
const left = unresolved.filter((name) => !defined.has(name));
|
|
13037
|
+
if (left.length === unresolved.length) {
|
|
13038
|
+
return metadata;
|
|
13039
|
+
}
|
|
13040
|
+
const { unresolvedFragments: _dropped, ...rest } = metadata;
|
|
13041
|
+
return left.length === 0 ? rest : { ...rest, unresolvedFragments: left };
|
|
13042
|
+
}
|
|
12955
13043
|
function compileOperationScopes(packs) {
|
|
12956
13044
|
return packs.flatMap((pack) => pack.graphqlOperationScopes ?? []).map((scope) => {
|
|
12957
13045
|
const matchers2 = scope.files.map(
|
|
@@ -13357,8 +13445,8 @@ function noteExpanded(expanded, readings, discovery) {
|
|
|
13357
13445
|
const paths = new Set(match.registrations.map((one) => one.pathTemplate));
|
|
13358
13446
|
const methods = expanded.get(reading.declarationId) ?? /* @__PURE__ */ new Set();
|
|
13359
13447
|
for (const sink of reading.helper.sinks) {
|
|
13360
|
-
const
|
|
13361
|
-
if (sink.method !== null &&
|
|
13448
|
+
const path15 = sink.arguments[0];
|
|
13449
|
+
if (sink.method !== null && path15?.as === "text" && paths.has(path15.text)) {
|
|
13362
13450
|
methods.add(sink.method);
|
|
13363
13451
|
}
|
|
13364
13452
|
}
|
|
@@ -15493,14 +15581,14 @@ function readArrayLiteralText(node) {
|
|
|
15493
15581
|
}
|
|
15494
15582
|
|
|
15495
15583
|
// src/summaryIdentity.ts
|
|
15496
|
-
import
|
|
15584
|
+
import path9 from "path";
|
|
15497
15585
|
import {
|
|
15498
15586
|
disambiguateSummaryIds,
|
|
15499
15587
|
linkCallsToSummaries,
|
|
15500
15588
|
summaryIdFromParts
|
|
15501
15589
|
} from "@suss/behavioral-ir";
|
|
15502
15590
|
function workspaceRootFor(anchor) {
|
|
15503
|
-
return namedPackageDirAbove(anchor) ??
|
|
15591
|
+
return namedPackageDirAbove(anchor) ?? path9.resolve(anchor);
|
|
15504
15592
|
}
|
|
15505
15593
|
function workspaceNameFor(root) {
|
|
15506
15594
|
if (root === void 0) {
|
|
@@ -15510,7 +15598,7 @@ function workspaceNameFor(root) {
|
|
|
15510
15598
|
if (dir !== null) {
|
|
15511
15599
|
return packageNameAt(dir);
|
|
15512
15600
|
}
|
|
15513
|
-
const folder =
|
|
15601
|
+
const folder = path9.basename(path9.resolve(root));
|
|
15514
15602
|
return folder.length > 0 ? folder : null;
|
|
15515
15603
|
}
|
|
15516
15604
|
function nameSummaries(summaries, args) {
|
|
@@ -15525,10 +15613,10 @@ function nameSummaries(summaries, args) {
|
|
|
15525
15613
|
linkCallsToSummaries(summaries);
|
|
15526
15614
|
}
|
|
15527
15615
|
function relativeFile(file, projectRoot) {
|
|
15528
|
-
if (projectRoot === void 0 || !
|
|
15616
|
+
if (projectRoot === void 0 || !path9.isAbsolute(file)) {
|
|
15529
15617
|
return file;
|
|
15530
15618
|
}
|
|
15531
|
-
const relative =
|
|
15619
|
+
const relative = path9.relative(projectRoot, file);
|
|
15532
15620
|
return relative.startsWith("..") ? file : relative;
|
|
15533
15621
|
}
|
|
15534
15622
|
function idFor(workspace, file, summary) {
|
|
@@ -15563,11 +15651,11 @@ function declineWhenRunFromSource(cacheDir) {
|
|
|
15563
15651
|
}
|
|
15564
15652
|
|
|
15565
15653
|
// src/workspacePatterns.ts
|
|
15566
|
-
import
|
|
15567
|
-
import
|
|
15654
|
+
import fs5 from "fs";
|
|
15655
|
+
import path10 from "path";
|
|
15568
15656
|
function readJson(filePath) {
|
|
15569
15657
|
try {
|
|
15570
|
-
return JSON.parse(
|
|
15658
|
+
return JSON.parse(fs5.readFileSync(filePath, "utf8"));
|
|
15571
15659
|
} catch {
|
|
15572
15660
|
return void 0;
|
|
15573
15661
|
}
|
|
@@ -15594,7 +15682,7 @@ function pnpmWorkspaceGlobs(yamlText) {
|
|
|
15594
15682
|
return globs;
|
|
15595
15683
|
}
|
|
15596
15684
|
function workspaceGlobsAt(dir) {
|
|
15597
|
-
const pkg = readJson(
|
|
15685
|
+
const pkg = readJson(path10.join(dir, "package.json"));
|
|
15598
15686
|
if (typeof pkg === "object" && pkg !== null && "workspaces" in pkg) {
|
|
15599
15687
|
const ws = pkg.workspaces;
|
|
15600
15688
|
if (Array.isArray(ws)) {
|
|
@@ -15606,10 +15694,10 @@ function workspaceGlobsAt(dir) {
|
|
|
15606
15694
|
);
|
|
15607
15695
|
}
|
|
15608
15696
|
}
|
|
15609
|
-
const pnpmPath =
|
|
15610
|
-
if (
|
|
15697
|
+
const pnpmPath = path10.join(dir, "pnpm-workspace.yaml");
|
|
15698
|
+
if (fs5.existsSync(pnpmPath)) {
|
|
15611
15699
|
try {
|
|
15612
|
-
return pnpmWorkspaceGlobs(
|
|
15700
|
+
return pnpmWorkspaceGlobs(fs5.readFileSync(pnpmPath, "utf8"));
|
|
15613
15701
|
} catch {
|
|
15614
15702
|
return null;
|
|
15615
15703
|
}
|
|
@@ -15618,14 +15706,14 @@ function workspaceGlobsAt(dir) {
|
|
|
15618
15706
|
}
|
|
15619
15707
|
function isDirectory(candidate) {
|
|
15620
15708
|
try {
|
|
15621
|
-
return
|
|
15709
|
+
return fs5.statSync(candidate).isDirectory();
|
|
15622
15710
|
} catch {
|
|
15623
15711
|
return false;
|
|
15624
15712
|
}
|
|
15625
15713
|
}
|
|
15626
15714
|
function subdirectoriesOf(dir) {
|
|
15627
15715
|
try {
|
|
15628
|
-
return
|
|
15716
|
+
return fs5.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(".") && name !== "node_modules");
|
|
15629
15717
|
} catch {
|
|
15630
15718
|
return [];
|
|
15631
15719
|
}
|
|
@@ -15643,13 +15731,13 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15643
15731
|
for (const dir of current2) {
|
|
15644
15732
|
for (const entry of subdirectoriesOf(dir)) {
|
|
15645
15733
|
if (pattern.test(entry)) {
|
|
15646
|
-
next.push(
|
|
15734
|
+
next.push(path10.join(dir, entry));
|
|
15647
15735
|
}
|
|
15648
15736
|
}
|
|
15649
15737
|
}
|
|
15650
15738
|
} else {
|
|
15651
15739
|
for (const dir of current2) {
|
|
15652
|
-
next.push(
|
|
15740
|
+
next.push(path10.join(dir, segment));
|
|
15653
15741
|
}
|
|
15654
15742
|
}
|
|
15655
15743
|
current2 = next.filter(isDirectory);
|
|
@@ -15657,7 +15745,7 @@ function directoriesMatchingGlob(root, glob) {
|
|
|
15657
15745
|
return current2;
|
|
15658
15746
|
}
|
|
15659
15747
|
function packageAt(dir) {
|
|
15660
|
-
const packageJsonPath =
|
|
15748
|
+
const packageJsonPath = path10.join(dir, "package.json");
|
|
15661
15749
|
const pkg = readJson(packageJsonPath);
|
|
15662
15750
|
if (typeof pkg === "object" && pkg !== null && typeof pkg.name === "string") {
|
|
15663
15751
|
return { name: pkg.name, packageJsonPath };
|
|
@@ -15665,7 +15753,7 @@ function packageAt(dir) {
|
|
|
15665
15753
|
return null;
|
|
15666
15754
|
}
|
|
15667
15755
|
function workspacePackagesFrom(anchor) {
|
|
15668
|
-
let dir =
|
|
15756
|
+
let dir = path10.resolve(anchor);
|
|
15669
15757
|
for (; ; ) {
|
|
15670
15758
|
const globs = workspaceGlobsAt(dir);
|
|
15671
15759
|
if (globs !== null) {
|
|
@@ -15685,7 +15773,7 @@ function workspacePackagesFrom(anchor) {
|
|
|
15685
15773
|
(a, b) => a.packageJsonPath.localeCompare(b.packageJsonPath)
|
|
15686
15774
|
);
|
|
15687
15775
|
}
|
|
15688
|
-
const parent =
|
|
15776
|
+
const parent = path10.dirname(dir);
|
|
15689
15777
|
if (parent === dir) {
|
|
15690
15778
|
return [];
|
|
15691
15779
|
}
|
|
@@ -16227,11 +16315,11 @@ function extractConsumerBinding(unit, pattern, pack, resolution) {
|
|
|
16227
16315
|
return null;
|
|
16228
16316
|
}
|
|
16229
16317
|
const method = extractBindingMethod(binding, callSite, pack, resolution);
|
|
16230
|
-
const
|
|
16318
|
+
const path15 = extractBindingPath(binding, callSite, pack, resolution);
|
|
16231
16319
|
return restBinding2({
|
|
16232
16320
|
transport: pack.protocol,
|
|
16233
16321
|
method: method ?? null,
|
|
16234
|
-
path:
|
|
16322
|
+
path: path15 ?? null,
|
|
16235
16323
|
recognition: pack.name
|
|
16236
16324
|
});
|
|
16237
16325
|
}
|
|
@@ -16878,8 +16966,8 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16878
16966
|
if (pathArg === void 0) {
|
|
16879
16967
|
continue;
|
|
16880
16968
|
}
|
|
16881
|
-
const
|
|
16882
|
-
if (
|
|
16969
|
+
const path15 = pathFromArgument(pathArg, resolution);
|
|
16970
|
+
if (path15 === void 0) {
|
|
16883
16971
|
continue;
|
|
16884
16972
|
}
|
|
16885
16973
|
const callerFunc = enclosingFunction(callExpr);
|
|
@@ -16891,7 +16979,7 @@ function synthesizeCallerSummaries(wrapper, _project, options, resolution) {
|
|
|
16891
16979
|
continue;
|
|
16892
16980
|
}
|
|
16893
16981
|
seen.add(dedupKey);
|
|
16894
|
-
out.push(buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
16982
|
+
out.push(buildCallerSummary(wrapper, callerFunc, callExpr, path15, options));
|
|
16895
16983
|
}
|
|
16896
16984
|
return out;
|
|
16897
16985
|
}
|
|
@@ -16948,7 +17036,7 @@ function callerName(func) {
|
|
|
16948
17036
|
}
|
|
16949
17037
|
return "anonymous";
|
|
16950
17038
|
}
|
|
16951
|
-
function buildCallerSummary(wrapper, callerFunc, callExpr,
|
|
17039
|
+
function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
16952
17040
|
const wrapperBinding = wrapper.summary.identity.boundaryBinding;
|
|
16953
17041
|
const wrapperRest = wrapperBinding?.semantics.name === "rest" ? wrapperBinding.semantics : null;
|
|
16954
17042
|
const syntheticPack = {
|
|
@@ -16980,7 +17068,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path14, options) {
|
|
|
16980
17068
|
raw.boundaryBinding = restBinding2({
|
|
16981
17069
|
transport: wrapperBinding?.transport ?? "http",
|
|
16982
17070
|
method: wrapperRest?.method ?? null,
|
|
16983
|
-
path:
|
|
17071
|
+
path: path15,
|
|
16984
17072
|
recognition: wrapperBinding?.recognition ?? "unknown"
|
|
16985
17073
|
});
|
|
16986
17074
|
const summary = assembleSummary3(raw, options);
|
|
@@ -17038,7 +17126,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17038
17126
|
...suppliedConfig,
|
|
17039
17127
|
frameworks: expandWorkspacePatterns(
|
|
17040
17128
|
suppliedConfig.frameworks,
|
|
17041
|
-
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ?
|
|
17129
|
+
suppliedConfig.projectRoot ?? (suppliedConfig.tsConfigFilePath !== void 0 ? path11.dirname(suppliedConfig.tsConfigFilePath) : void 0)
|
|
17042
17130
|
)
|
|
17043
17131
|
};
|
|
17044
17132
|
const project = config.project ?? new Project(
|
|
@@ -17047,11 +17135,11 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17047
17135
|
skipAddingFilesFromTsConfig: true
|
|
17048
17136
|
} : { skipAddingFilesFromTsConfig: true }
|
|
17049
17137
|
);
|
|
17050
|
-
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(
|
|
17138
|
+
const runRoot = config.projectRoot ?? (config.tsConfigFilePath !== void 0 ? workspaceRootFor(path11.dirname(config.tsConfigFilePath)) : void 0);
|
|
17051
17139
|
let lazyBootstrapped = false;
|
|
17052
17140
|
let projectFileSet;
|
|
17053
17141
|
const cacheDir = declineWhenRunFromSource(
|
|
17054
|
-
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ?
|
|
17142
|
+
config.cacheDir === null ? null : config.cacheDir ?? (config.tsConfigFilePath !== void 0 ? path11.join(path11.dirname(config.tsConfigFilePath), ".suss", "cache") : null)
|
|
17055
17143
|
);
|
|
17056
17144
|
const cache = createCacheLayer(cacheDir);
|
|
17057
17145
|
const packsDigest = `${computeAdapterPacksDigest(
|
|
@@ -17755,8 +17843,8 @@ function buildSubUnitSummary(subUnit, parent, invocationRecognizers, accessRecog
|
|
|
17755
17843
|
}
|
|
17756
17844
|
|
|
17757
17845
|
// src/bootstrap/noTsconfigProject.ts
|
|
17758
|
-
import
|
|
17759
|
-
import
|
|
17846
|
+
import fs6 from "fs";
|
|
17847
|
+
import path12 from "path";
|
|
17760
17848
|
import {
|
|
17761
17849
|
ModuleKind,
|
|
17762
17850
|
ModuleResolutionKind,
|
|
@@ -17792,7 +17880,7 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17792
17880
|
const found = [];
|
|
17793
17881
|
let entries;
|
|
17794
17882
|
try {
|
|
17795
|
-
entries =
|
|
17883
|
+
entries = fs6.readdirSync(rootDir, { withFileTypes: true });
|
|
17796
17884
|
} catch {
|
|
17797
17885
|
return [];
|
|
17798
17886
|
}
|
|
@@ -17800,10 +17888,10 @@ function findSourceFiles(rootDir, depth = 0) {
|
|
|
17800
17888
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name)) {
|
|
17801
17889
|
continue;
|
|
17802
17890
|
}
|
|
17803
|
-
const full =
|
|
17891
|
+
const full = path12.join(rootDir, entry.name);
|
|
17804
17892
|
if (entry.isDirectory()) {
|
|
17805
17893
|
found.push(...findSourceFiles(full, depth + 1));
|
|
17806
|
-
} else if (SOURCE_EXTENSIONS.has(
|
|
17894
|
+
} else if (SOURCE_EXTENSIONS.has(path12.extname(entry.name)) && !entry.name.endsWith(".d.ts")) {
|
|
17807
17895
|
found.push(full);
|
|
17808
17896
|
}
|
|
17809
17897
|
}
|
|
@@ -17838,15 +17926,15 @@ function createProjectWithoutTsconfig(rootDir) {
|
|
|
17838
17926
|
return { project, files };
|
|
17839
17927
|
}
|
|
17840
17928
|
function findNearestTsconfig(startDir) {
|
|
17841
|
-
let dir =
|
|
17929
|
+
let dir = path12.resolve(startDir);
|
|
17842
17930
|
while (true) {
|
|
17843
17931
|
for (const name of ["tsconfig.json", "jsconfig.json"]) {
|
|
17844
|
-
const candidate =
|
|
17845
|
-
if (
|
|
17932
|
+
const candidate = path12.join(dir, name);
|
|
17933
|
+
if (fs6.existsSync(candidate)) {
|
|
17846
17934
|
return candidate;
|
|
17847
17935
|
}
|
|
17848
17936
|
}
|
|
17849
|
-
const parent =
|
|
17937
|
+
const parent = path12.dirname(dir);
|
|
17850
17938
|
if (parent === dir) {
|
|
17851
17939
|
return null;
|
|
17852
17940
|
}
|
|
@@ -17855,7 +17943,7 @@ function findNearestTsconfig(startDir) {
|
|
|
17855
17943
|
}
|
|
17856
17944
|
|
|
17857
17945
|
// src/facts/why.ts
|
|
17858
|
-
import
|
|
17946
|
+
import path13 from "path";
|
|
17859
17947
|
import { Node as Node65, Project as Project3, SyntaxKind as SyntaxKind13 } from "ts-morph";
|
|
17860
17948
|
import { explainResolutionProof, renderExplanation } from "@suss/resolution";
|
|
17861
17949
|
var JS_PHRASES = {
|
|
@@ -17868,7 +17956,7 @@ var TypeScriptWhySession = class {
|
|
|
17868
17956
|
store;
|
|
17869
17957
|
root;
|
|
17870
17958
|
constructor(options) {
|
|
17871
|
-
this.root =
|
|
17959
|
+
this.root = path13.resolve(options.dir);
|
|
17872
17960
|
const tsconfig = findNearestTsconfig(this.root);
|
|
17873
17961
|
this.project = tsconfig === null ? createProjectWithoutTsconfig(this.root).project : new Project3({ tsConfigFilePath: tsconfig });
|
|
17874
17962
|
this.store = new ResolutionStore();
|
|
@@ -17957,7 +18045,7 @@ var TypeScriptWhySession = class {
|
|
|
17957
18045
|
};
|
|
17958
18046
|
}
|
|
17959
18047
|
sourceFileAt(file) {
|
|
17960
|
-
const absolute =
|
|
18048
|
+
const absolute = path13.resolve(this.root, file);
|
|
17961
18049
|
const loaded = this.project.getSourceFile(absolute);
|
|
17962
18050
|
if (loaded !== void 0) {
|
|
17963
18051
|
return loaded;
|
|
@@ -17971,7 +18059,7 @@ var TypeScriptWhySession = class {
|
|
|
17971
18059
|
/** A module key: a file path said relative to the root, or a package name. */
|
|
17972
18060
|
displayPath(key) {
|
|
17973
18061
|
if (key.startsWith(this.root)) {
|
|
17974
|
-
return
|
|
18062
|
+
return path13.relative(this.root, key);
|
|
17975
18063
|
}
|
|
17976
18064
|
return key;
|
|
17977
18065
|
}
|
|
@@ -18000,7 +18088,7 @@ function displayNameOf(node) {
|
|
|
18000
18088
|
}
|
|
18001
18089
|
|
|
18002
18090
|
// src/stubEvidence.ts
|
|
18003
|
-
import
|
|
18091
|
+
import path14 from "path";
|
|
18004
18092
|
import { Project as Project4 } from "ts-morph";
|
|
18005
18093
|
function stubEvidenceIn(project, packageName, root) {
|
|
18006
18094
|
const resolution = new ResolutionStore();
|
|
@@ -18016,7 +18104,7 @@ function stubEvidenceIn(project, packageName, root) {
|
|
|
18016
18104
|
calls: []
|
|
18017
18105
|
};
|
|
18018
18106
|
entry.calls.push({
|
|
18019
|
-
file:
|
|
18107
|
+
file: path14.relative(root, sourceFile.getFilePath()).split(path14.sep).join("/"),
|
|
18020
18108
|
line: one.call.getStartLineNumber(),
|
|
18021
18109
|
args: one.call.getArguments().map((arg) => effectArgOf(arg))
|
|
18022
18110
|
});
|
|
@@ -18031,7 +18119,7 @@ function stubEvidence(options) {
|
|
|
18031
18119
|
const project = new Project4(
|
|
18032
18120
|
options.tsConfigFilePath !== void 0 ? { tsConfigFilePath: options.tsConfigFilePath } : { compilerOptions: { allowJs: true } }
|
|
18033
18121
|
);
|
|
18034
|
-
const root = options.tsConfigFilePath !== void 0 ?
|
|
18122
|
+
const root = options.tsConfigFilePath !== void 0 ? path14.dirname(options.tsConfigFilePath) : path14.resolve(options.directory ?? process.cwd());
|
|
18035
18123
|
if (options.tsConfigFilePath === void 0) {
|
|
18036
18124
|
project.addSourceFilesAtPaths([
|
|
18037
18125
|
`${root}/**/*.{ts,tsx,js,jsx}`,
|