@suss/adapter-typescript 0.24.4 → 0.26.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/index.cjs +773 -796
- package/dist/index.js +176 -198
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { Database as Database5 } from "@suss/datalog";
|
|
22
22
|
import {
|
|
23
23
|
assembleSummary as assembleSummary3,
|
|
24
|
+
commonDirectoryOf as commonDirectoryOf2,
|
|
24
25
|
composeWrappers,
|
|
25
26
|
createCacheLayer,
|
|
26
27
|
runDigest,
|
|
@@ -4382,181 +4383,8 @@ function declarationOf(value) {
|
|
|
4382
4383
|
import { Node as Node18 } from "ts-morph";
|
|
4383
4384
|
|
|
4384
4385
|
// src/discovery/importScan.ts
|
|
4385
|
-
import path3 from "path";
|
|
4386
|
-
|
|
4387
|
-
// src/diagnostics.ts
|
|
4388
4386
|
import path2 from "path";
|
|
4389
|
-
import {
|
|
4390
|
-
import {
|
|
4391
|
-
createPackTallies,
|
|
4392
|
-
emptyTally,
|
|
4393
|
-
recordPackFailure,
|
|
4394
|
-
summaryCountsByPack
|
|
4395
|
-
} from "@suss/extractor";
|
|
4396
|
-
function commonDirectoryOf(files) {
|
|
4397
|
-
const absolute = files.filter((f) => path2.isAbsolute(f));
|
|
4398
|
-
const first = absolute[0];
|
|
4399
|
-
if (first === void 0) {
|
|
4400
|
-
return void 0;
|
|
4401
|
-
}
|
|
4402
|
-
let shared = path2.dirname(first).split(path2.sep);
|
|
4403
|
-
for (const file of absolute.slice(1)) {
|
|
4404
|
-
const parts = path2.dirname(file).split(path2.sep);
|
|
4405
|
-
let i = 0;
|
|
4406
|
-
while (i < shared.length && i < parts.length && shared[i] === parts[i]) {
|
|
4407
|
-
i += 1;
|
|
4408
|
-
}
|
|
4409
|
-
shared = shared.slice(0, i);
|
|
4410
|
-
}
|
|
4411
|
-
const joined2 = shared.join(path2.sep);
|
|
4412
|
-
return joined2.length > 1 ? joined2 : void 0;
|
|
4413
|
-
}
|
|
4414
|
-
var DEFAULT_RESOLUTION = {
|
|
4415
|
-
moduleResolution: ts3.ModuleResolutionKind.Bundler,
|
|
4416
|
-
target: ts3.ScriptTarget.ESNext,
|
|
4417
|
-
module: ts3.ModuleKind.ESNext
|
|
4418
|
-
};
|
|
4419
|
-
function resolutionContext(args) {
|
|
4420
|
-
if (args.tsConfigFilePath !== void 0) {
|
|
4421
|
-
const configFile = ts3.readConfigFile(
|
|
4422
|
-
args.tsConfigFilePath,
|
|
4423
|
-
ts3.sys.readFile
|
|
4424
|
-
);
|
|
4425
|
-
if (configFile.error !== void 0) {
|
|
4426
|
-
return null;
|
|
4427
|
-
}
|
|
4428
|
-
const dir = path2.dirname(args.tsConfigFilePath);
|
|
4429
|
-
const parsed = ts3.parseJsonConfigFileContent(
|
|
4430
|
-
configFile.config,
|
|
4431
|
-
ts3.sys,
|
|
4432
|
-
dir,
|
|
4433
|
-
/*existingOptions*/
|
|
4434
|
-
void 0,
|
|
4435
|
-
args.tsConfigFilePath
|
|
4436
|
-
);
|
|
4437
|
-
return {
|
|
4438
|
-
containingFile: path2.join(dir, "index.ts"),
|
|
4439
|
-
options: parsed.options
|
|
4440
|
-
};
|
|
4441
|
-
}
|
|
4442
|
-
if (args.projectRoot === void 0 || !path2.isAbsolute(args.projectRoot)) {
|
|
4443
|
-
return null;
|
|
4444
|
-
}
|
|
4445
|
-
return {
|
|
4446
|
-
containingFile: path2.join(args.projectRoot, "index.ts"),
|
|
4447
|
-
options: DEFAULT_RESOLUTION
|
|
4448
|
-
};
|
|
4449
|
-
}
|
|
4450
|
-
function unresolvedGatesFor(gates, args) {
|
|
4451
|
-
if (gates.length === 0) {
|
|
4452
|
-
return [];
|
|
4453
|
-
}
|
|
4454
|
-
const context = resolutionContext(args);
|
|
4455
|
-
if (context === null) {
|
|
4456
|
-
return [];
|
|
4457
|
-
}
|
|
4458
|
-
const unresolved = [];
|
|
4459
|
-
for (const gate of gates) {
|
|
4460
|
-
const resolved = ts3.resolveModuleName(
|
|
4461
|
-
gate,
|
|
4462
|
-
context.containingFile,
|
|
4463
|
-
context.options,
|
|
4464
|
-
ts3.sys
|
|
4465
|
-
);
|
|
4466
|
-
if (resolved.resolvedModule === void 0) {
|
|
4467
|
-
unresolved.push(gate);
|
|
4468
|
-
}
|
|
4469
|
-
}
|
|
4470
|
-
return unresolved;
|
|
4471
|
-
}
|
|
4472
|
-
function helpersWithNoCall(patterns, matched, projectRoot) {
|
|
4473
|
-
const missing = [];
|
|
4474
|
-
for (const pattern of patterns) {
|
|
4475
|
-
if (pattern.match.type !== "registrationTemplate" || matched.has(pattern.match.helperName)) {
|
|
4476
|
-
continue;
|
|
4477
|
-
}
|
|
4478
|
-
const from = pattern.match.importModule;
|
|
4479
|
-
missing.push(
|
|
4480
|
-
from === void 0 ? pattern.match.helperName : `${pattern.match.helperName} from ${shortModule(from, projectRoot)}`
|
|
4481
|
-
);
|
|
4482
|
-
}
|
|
4483
|
-
return missing;
|
|
4484
|
-
}
|
|
4485
|
-
function shortModule(module, projectRoot) {
|
|
4486
|
-
if (projectRoot === void 0 || !path2.isAbsolute(module)) {
|
|
4487
|
-
return module;
|
|
4488
|
-
}
|
|
4489
|
-
return path2.relative(projectRoot, module);
|
|
4490
|
-
}
|
|
4491
|
-
function buildExtractionReport(args) {
|
|
4492
|
-
const bySummary = summaryCountsByPack(args.summaries);
|
|
4493
|
-
const packFunnels = args.packs.map((pack) => {
|
|
4494
|
-
const gates = packIsUngated(pack) ? [] : collectPackGates(pack);
|
|
4495
|
-
const tally = args.tallies.get(pack.name) ?? emptyTally();
|
|
4496
|
-
const counted = bySummary.get(pack.name) ?? {
|
|
4497
|
-
bound: 0,
|
|
4498
|
-
providers: 0,
|
|
4499
|
-
withBehavior: 0
|
|
4500
|
-
};
|
|
4501
|
-
return {
|
|
4502
|
-
pack: pack.name,
|
|
4503
|
-
version: pack.version ?? null,
|
|
4504
|
-
discovers: pack.discovery.length > 0 || pack.discoverUnits !== void 0,
|
|
4505
|
-
recognizes: (pack.invocationRecognizers?.length ?? 0) > 0 || (pack.accessRecognizers?.length ?? 0) > 0,
|
|
4506
|
-
gates,
|
|
4507
|
-
unresolvedGates: unresolvedGatesFor(gates, {
|
|
4508
|
-
tsConfigFilePath: args.tsConfigFilePath,
|
|
4509
|
-
projectRoot: args.projectRoot
|
|
4510
|
-
}),
|
|
4511
|
-
candidateFiles: tally.candidateFiles,
|
|
4512
|
-
unitsDiscovered: tally.unitsDiscovered,
|
|
4513
|
-
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
4514
|
-
effectsRecognized: tally.effectsRecognized,
|
|
4515
|
-
unitsClaimed: tally.unitsClaimed,
|
|
4516
|
-
selfCollisions: tally.selfCollisions,
|
|
4517
|
-
summariesProduced: tally.summariesProduced,
|
|
4518
|
-
failures: tally.failures,
|
|
4519
|
-
helpersUnmatched: helpersWithNoCall(
|
|
4520
|
-
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
4521
|
-
tally.helpersMatched,
|
|
4522
|
-
args.projectRoot
|
|
4523
|
-
),
|
|
4524
|
-
summariesBound: counted.bound,
|
|
4525
|
-
providerSummaries: counted.providers,
|
|
4526
|
-
summariesWithBehavior: counted.withBehavior,
|
|
4527
|
-
declarations: pack.declarations ?? null
|
|
4528
|
-
};
|
|
4529
|
-
});
|
|
4530
|
-
return {
|
|
4531
|
-
filesInProject: args.filesInProject,
|
|
4532
|
-
filesWalked: args.filesWalked,
|
|
4533
|
-
packs: packFunnels,
|
|
4534
|
-
summaries: args.summaries.length,
|
|
4535
|
-
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
4536
|
-
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
4537
|
-
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
4538
|
-
};
|
|
4539
|
-
}
|
|
4540
|
-
function firstEmptyStage(packs, args) {
|
|
4541
|
-
if (args.filesInProject === 0) {
|
|
4542
|
-
return "tsconfig";
|
|
4543
|
-
}
|
|
4544
|
-
const gateFailed = packs.some(
|
|
4545
|
-
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
4546
|
-
);
|
|
4547
|
-
if (gateFailed) {
|
|
4548
|
-
return "gateResolution";
|
|
4549
|
-
}
|
|
4550
|
-
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
4551
|
-
return "candidateFiles";
|
|
4552
|
-
}
|
|
4553
|
-
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
4554
|
-
return "discovery";
|
|
4555
|
-
}
|
|
4556
|
-
return "assembly";
|
|
4557
|
-
}
|
|
4558
|
-
|
|
4559
|
-
// src/discovery/importScan.ts
|
|
4387
|
+
import { commonDirectoryOf } from "@suss/extractor";
|
|
4560
4388
|
function specifierMatches(specifier, moduleName, subpaths) {
|
|
4561
4389
|
if (specifier === moduleName) {
|
|
4562
4390
|
return true;
|
|
@@ -4648,7 +4476,7 @@ function resolvedModuleFile(project, importModule, resolution) {
|
|
|
4648
4476
|
function projectFileNamedBy(project, specifier) {
|
|
4649
4477
|
const files = project.getSourceFiles().filter((sf) => !sf.isDeclarationFile());
|
|
4650
4478
|
const root = commonDirectoryOf(files.map((sf) => sf.getFilePath())) ?? "/";
|
|
4651
|
-
const target = withoutSourceExtension(
|
|
4479
|
+
const target = withoutSourceExtension(path2.resolve(root, specifier));
|
|
4652
4480
|
for (const candidate of files) {
|
|
4653
4481
|
if (withoutSourceExtension(candidate.getFilePath()) === target) {
|
|
4654
4482
|
return candidate;
|
|
@@ -6107,7 +5935,7 @@ import { Node as Node26 } from "ts-morph";
|
|
|
6107
5935
|
|
|
6108
5936
|
// src/discovery/graphqlShared.ts
|
|
6109
5937
|
import fs2 from "fs";
|
|
6110
|
-
import
|
|
5938
|
+
import path3 from "path";
|
|
6111
5939
|
import {
|
|
6112
5940
|
Kind as GraphqlKind,
|
|
6113
5941
|
parse as graphqlParse,
|
|
@@ -6650,8 +6478,8 @@ function resolveGraphqlFileImport(decl) {
|
|
|
6650
6478
|
return null;
|
|
6651
6479
|
}
|
|
6652
6480
|
const sourceFile = importDecl.getSourceFile();
|
|
6653
|
-
const baseDir =
|
|
6654
|
-
const absolute =
|
|
6481
|
+
const baseDir = path3.dirname(sourceFile.getFilePath());
|
|
6482
|
+
const absolute = path3.resolve(baseDir, specifier);
|
|
6655
6483
|
try {
|
|
6656
6484
|
return fs2.readFileSync(absolute, "utf8");
|
|
6657
6485
|
} catch {
|
|
@@ -7258,13 +7086,13 @@ import { Node as Node30 } from "ts-morph";
|
|
|
7258
7086
|
|
|
7259
7087
|
// src/packageExports.ts
|
|
7260
7088
|
import fs3 from "fs";
|
|
7261
|
-
import
|
|
7089
|
+
import path4 from "path";
|
|
7262
7090
|
function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
7263
|
-
const absPkgJson =
|
|
7264
|
-
const pkgDir =
|
|
7091
|
+
const absPkgJson = path4.resolve(packageJsonPath);
|
|
7092
|
+
const pkgDir = path4.dirname(absPkgJson);
|
|
7265
7093
|
const raw = fs3.readFileSync(absPkgJson, "utf8");
|
|
7266
7094
|
const pkg = JSON.parse(raw);
|
|
7267
|
-
const packageName = pkg.name ??
|
|
7095
|
+
const packageName = pkg.name ?? path4.basename(pkgDir);
|
|
7268
7096
|
const warnings = [];
|
|
7269
7097
|
const entries = [];
|
|
7270
7098
|
const pushEntry = (subPath, distPath) => {
|
|
@@ -7283,7 +7111,7 @@ function resolvePackageExports(packageJsonPath, opts = {}) {
|
|
|
7283
7111
|
subPath,
|
|
7284
7112
|
exportPathPrefix: subPathToPrefix(subPath),
|
|
7285
7113
|
sourceFile: src,
|
|
7286
|
-
publishedFile:
|
|
7114
|
+
publishedFile: path4.resolve(pkgDir, distPath)
|
|
7287
7115
|
});
|
|
7288
7116
|
};
|
|
7289
7117
|
const exportsField = pkg.exports;
|
|
@@ -7325,12 +7153,12 @@ function resolvePackageExportsCached(packageJsonPath) {
|
|
|
7325
7153
|
return fresh;
|
|
7326
7154
|
}
|
|
7327
7155
|
function namedPackageDirAbove(start) {
|
|
7328
|
-
let at =
|
|
7156
|
+
let at = path4.resolve(start);
|
|
7329
7157
|
for (let up = 0; up < 12; up += 1) {
|
|
7330
7158
|
if (packageNameAt(at) !== null) {
|
|
7331
7159
|
return at;
|
|
7332
7160
|
}
|
|
7333
|
-
const parent =
|
|
7161
|
+
const parent = path4.dirname(at);
|
|
7334
7162
|
if (parent === at) {
|
|
7335
7163
|
break;
|
|
7336
7164
|
}
|
|
@@ -7341,7 +7169,7 @@ function namedPackageDirAbove(start) {
|
|
|
7341
7169
|
function packageNameAt(dir) {
|
|
7342
7170
|
try {
|
|
7343
7171
|
const manifest = JSON.parse(
|
|
7344
|
-
fs3.readFileSync(
|
|
7172
|
+
fs3.readFileSync(path4.join(dir, "package.json"), "utf8")
|
|
7345
7173
|
);
|
|
7346
7174
|
if (typeof manifest.name === "string" && manifest.name.length > 0) {
|
|
7347
7175
|
return manifest.name;
|
|
@@ -7391,7 +7219,7 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7391
7219
|
const stem = withoutDist.replace(/\.d\.ts$/, "").replace(/\.js$/, "").replace(/\.cjs$/, "").replace(/\.mjs$/, "").replace(/\.ts$/, "");
|
|
7392
7220
|
const candidates = [`${stem}.ts`, `${stem}.tsx`];
|
|
7393
7221
|
for (const candidate of candidates) {
|
|
7394
|
-
const abs =
|
|
7222
|
+
const abs = path4.resolve(pkgDir, candidate);
|
|
7395
7223
|
if (fs3.existsSync(abs)) {
|
|
7396
7224
|
return abs;
|
|
7397
7225
|
}
|
|
@@ -7400,20 +7228,20 @@ function resolveSourceFor(pkgDir, distPath, srcRoot) {
|
|
|
7400
7228
|
}
|
|
7401
7229
|
|
|
7402
7230
|
// src/resolve/sourceDeclaration.ts
|
|
7403
|
-
import
|
|
7231
|
+
import path5 from "path";
|
|
7404
7232
|
function sourceDeclarationsBehind(decl, resolution, visited = /* @__PURE__ */ new Set()) {
|
|
7405
7233
|
const file = decl.getSourceFile();
|
|
7406
7234
|
if (!file.isDeclarationFile() || file.isInNodeModules()) {
|
|
7407
7235
|
return [decl];
|
|
7408
7236
|
}
|
|
7409
|
-
const packageDir = namedPackageDirAbove(
|
|
7237
|
+
const packageDir = namedPackageDirAbove(path5.dirname(file.getFilePath()));
|
|
7410
7238
|
if (packageDir === null || visited.has(packageDir)) {
|
|
7411
7239
|
return [decl];
|
|
7412
7240
|
}
|
|
7413
7241
|
visited.add(packageDir);
|
|
7414
7242
|
const project = file.getProject();
|
|
7415
7243
|
const { entries } = resolvePackageExportsCached(
|
|
7416
|
-
|
|
7244
|
+
path5.join(packageDir, "package.json")
|
|
7417
7245
|
);
|
|
7418
7246
|
const found = [];
|
|
7419
7247
|
for (const entry of entries) {
|
|
@@ -8515,7 +8343,7 @@ function handlerName(value) {
|
|
|
8515
8343
|
}
|
|
8516
8344
|
|
|
8517
8345
|
// src/discovery/registrationTemplate.ts
|
|
8518
|
-
import
|
|
8346
|
+
import path6 from "path";
|
|
8519
8347
|
import { Node as Node35 } from "ts-morph";
|
|
8520
8348
|
import { joinMountedPath as joinMountedPath2 } from "@suss/resolution";
|
|
8521
8349
|
|
|
@@ -8671,7 +8499,7 @@ function subjectOfCall(sourceFile, args, match, resolution) {
|
|
|
8671
8499
|
}
|
|
8672
8500
|
function helperCallsOf(sourceFile, match, resolution) {
|
|
8673
8501
|
const module = match.importModule;
|
|
8674
|
-
if (module !== void 0 && !
|
|
8502
|
+
if (module !== void 0 && !path6.isAbsolute(module)) {
|
|
8675
8503
|
const store = resolution ?? new ResolutionStore();
|
|
8676
8504
|
return callsResolvingTo(sourceFile, store, {
|
|
8677
8505
|
module,
|
|
@@ -12839,6 +12667,159 @@ function readContractForClientCall(callExpression, methodName, pattern, framewor
|
|
|
12839
12667
|
return null;
|
|
12840
12668
|
}
|
|
12841
12669
|
|
|
12670
|
+
// src/diagnostics.ts
|
|
12671
|
+
import path7 from "path";
|
|
12672
|
+
import { ts as ts3 } from "ts-morph";
|
|
12673
|
+
import {
|
|
12674
|
+
createPackTallies,
|
|
12675
|
+
emptyTally,
|
|
12676
|
+
recordPackFailure,
|
|
12677
|
+
summaryCountsByPack
|
|
12678
|
+
} from "@suss/extractor";
|
|
12679
|
+
var DEFAULT_RESOLUTION = {
|
|
12680
|
+
moduleResolution: ts3.ModuleResolutionKind.Bundler,
|
|
12681
|
+
target: ts3.ScriptTarget.ESNext,
|
|
12682
|
+
module: ts3.ModuleKind.ESNext
|
|
12683
|
+
};
|
|
12684
|
+
function resolutionContext(args) {
|
|
12685
|
+
if (args.tsConfigFilePath !== void 0) {
|
|
12686
|
+
const configFile = ts3.readConfigFile(
|
|
12687
|
+
args.tsConfigFilePath,
|
|
12688
|
+
ts3.sys.readFile
|
|
12689
|
+
);
|
|
12690
|
+
if (configFile.error !== void 0) {
|
|
12691
|
+
return null;
|
|
12692
|
+
}
|
|
12693
|
+
const dir = path7.dirname(args.tsConfigFilePath);
|
|
12694
|
+
const parsed = ts3.parseJsonConfigFileContent(
|
|
12695
|
+
configFile.config,
|
|
12696
|
+
ts3.sys,
|
|
12697
|
+
dir,
|
|
12698
|
+
/*existingOptions*/
|
|
12699
|
+
void 0,
|
|
12700
|
+
args.tsConfigFilePath
|
|
12701
|
+
);
|
|
12702
|
+
return {
|
|
12703
|
+
containingFile: path7.join(dir, "index.ts"),
|
|
12704
|
+
options: parsed.options
|
|
12705
|
+
};
|
|
12706
|
+
}
|
|
12707
|
+
if (args.projectRoot === void 0 || !path7.isAbsolute(args.projectRoot)) {
|
|
12708
|
+
return null;
|
|
12709
|
+
}
|
|
12710
|
+
return {
|
|
12711
|
+
containingFile: path7.join(args.projectRoot, "index.ts"),
|
|
12712
|
+
options: DEFAULT_RESOLUTION
|
|
12713
|
+
};
|
|
12714
|
+
}
|
|
12715
|
+
function unresolvedGatesFor(gates, args) {
|
|
12716
|
+
if (gates.length === 0) {
|
|
12717
|
+
return [];
|
|
12718
|
+
}
|
|
12719
|
+
const context = resolutionContext(args);
|
|
12720
|
+
if (context === null) {
|
|
12721
|
+
return [];
|
|
12722
|
+
}
|
|
12723
|
+
const unresolved = [];
|
|
12724
|
+
for (const gate of gates) {
|
|
12725
|
+
const resolved = ts3.resolveModuleName(
|
|
12726
|
+
gate,
|
|
12727
|
+
context.containingFile,
|
|
12728
|
+
context.options,
|
|
12729
|
+
ts3.sys
|
|
12730
|
+
);
|
|
12731
|
+
if (resolved.resolvedModule === void 0) {
|
|
12732
|
+
unresolved.push(gate);
|
|
12733
|
+
}
|
|
12734
|
+
}
|
|
12735
|
+
return unresolved;
|
|
12736
|
+
}
|
|
12737
|
+
function helpersWithNoCall(patterns, matched, projectRoot) {
|
|
12738
|
+
const missing = [];
|
|
12739
|
+
for (const pattern of patterns) {
|
|
12740
|
+
if (pattern.match.type !== "registrationTemplate" || matched.has(pattern.match.helperName)) {
|
|
12741
|
+
continue;
|
|
12742
|
+
}
|
|
12743
|
+
const from = pattern.match.importModule;
|
|
12744
|
+
missing.push(
|
|
12745
|
+
from === void 0 ? pattern.match.helperName : `${pattern.match.helperName} from ${shortModule(from, projectRoot)}`
|
|
12746
|
+
);
|
|
12747
|
+
}
|
|
12748
|
+
return missing;
|
|
12749
|
+
}
|
|
12750
|
+
function shortModule(module, projectRoot) {
|
|
12751
|
+
if (projectRoot === void 0 || !path7.isAbsolute(module)) {
|
|
12752
|
+
return module;
|
|
12753
|
+
}
|
|
12754
|
+
return path7.relative(projectRoot, module);
|
|
12755
|
+
}
|
|
12756
|
+
function buildExtractionReport(args) {
|
|
12757
|
+
const bySummary = summaryCountsByPack(args.summaries);
|
|
12758
|
+
const packFunnels = args.packs.map((pack) => {
|
|
12759
|
+
const gates = packIsUngated(pack) ? [] : collectPackGates(pack);
|
|
12760
|
+
const tally = args.tallies.get(pack.name) ?? emptyTally();
|
|
12761
|
+
const counted = bySummary.get(pack.name) ?? {
|
|
12762
|
+
bound: 0,
|
|
12763
|
+
providers: 0,
|
|
12764
|
+
withBehavior: 0
|
|
12765
|
+
};
|
|
12766
|
+
return {
|
|
12767
|
+
pack: pack.name,
|
|
12768
|
+
version: pack.version ?? null,
|
|
12769
|
+
discovers: pack.discovery.length > 0 || pack.discoverUnits !== void 0,
|
|
12770
|
+
recognizes: (pack.invocationRecognizers?.length ?? 0) > 0 || (pack.accessRecognizers?.length ?? 0) > 0,
|
|
12771
|
+
gates,
|
|
12772
|
+
unresolvedGates: unresolvedGatesFor(gates, {
|
|
12773
|
+
tsConfigFilePath: args.tsConfigFilePath,
|
|
12774
|
+
projectRoot: args.projectRoot
|
|
12775
|
+
}),
|
|
12776
|
+
candidateFiles: tally.candidateFiles,
|
|
12777
|
+
unitsDiscovered: tally.unitsDiscovered,
|
|
12778
|
+
unitsInGatedFiles: tally.unitsInGatedFiles,
|
|
12779
|
+
effectsRecognized: tally.effectsRecognized,
|
|
12780
|
+
unitsClaimed: tally.unitsClaimed,
|
|
12781
|
+
summariesProduced: tally.summariesProduced,
|
|
12782
|
+
failures: tally.failures,
|
|
12783
|
+
helpersUnmatched: helpersWithNoCall(
|
|
12784
|
+
[...pack.discovery, ...args.contributedPatterns?.(pack.name) ?? []],
|
|
12785
|
+
tally.helpersMatched,
|
|
12786
|
+
args.projectRoot
|
|
12787
|
+
),
|
|
12788
|
+
summariesBound: counted.bound,
|
|
12789
|
+
providerSummaries: counted.providers,
|
|
12790
|
+
summariesWithBehavior: counted.withBehavior,
|
|
12791
|
+
declarations: pack.declarations ?? null
|
|
12792
|
+
};
|
|
12793
|
+
});
|
|
12794
|
+
return {
|
|
12795
|
+
filesInProject: args.filesInProject,
|
|
12796
|
+
filesWalked: args.filesWalked,
|
|
12797
|
+
packs: packFunnels,
|
|
12798
|
+
summaries: args.summaries.length,
|
|
12799
|
+
filesWithUnreadableExports: [...args.filesWithUnreadableExports ?? []],
|
|
12800
|
+
reassignedNamesUnstated: args.reassignedNamesUnstated ?? 0,
|
|
12801
|
+
emptyStage: args.summaries.length === 0 ? firstEmptyStage(packFunnels, args) : null
|
|
12802
|
+
};
|
|
12803
|
+
}
|
|
12804
|
+
function firstEmptyStage(packs, args) {
|
|
12805
|
+
if (args.filesInProject === 0) {
|
|
12806
|
+
return "tsconfig";
|
|
12807
|
+
}
|
|
12808
|
+
const gateFailed = packs.some(
|
|
12809
|
+
(p) => p.unresolvedGates.length > 0 && p.candidateFiles > 0
|
|
12810
|
+
);
|
|
12811
|
+
if (gateFailed) {
|
|
12812
|
+
return "gateResolution";
|
|
12813
|
+
}
|
|
12814
|
+
if (args.filesWalked === 0 || packs.every((p) => p.candidateFiles === 0)) {
|
|
12815
|
+
return "candidateFiles";
|
|
12816
|
+
}
|
|
12817
|
+
if (packs.every((p) => p.unitsDiscovered === 0)) {
|
|
12818
|
+
return "discovery";
|
|
12819
|
+
}
|
|
12820
|
+
return "assembly";
|
|
12821
|
+
}
|
|
12822
|
+
|
|
12842
12823
|
// src/discovery/filenameRoute.ts
|
|
12843
12824
|
function routePathFromFile(filePath, convention) {
|
|
12844
12825
|
const belowRoot = segmentsBelowRoot(filePath, convention.root);
|
|
@@ -16528,9 +16509,6 @@ function extractFromSourceFile(sourceFile, frameworks, claimedUnits, options, ta
|
|
|
16528
16509
|
const claimKey = unitDedupKey(unit);
|
|
16529
16510
|
const claimant = claimed.get(claimKey);
|
|
16530
16511
|
if (claimant !== void 0) {
|
|
16531
|
-
if (claimant.pack === pack.name && claimant.file === sourceFile.getFilePath() && tally !== void 0) {
|
|
16532
|
-
tally.selfCollisions += 1;
|
|
16533
|
-
}
|
|
16534
16512
|
if (claimant.file !== sourceFile.getFilePath()) {
|
|
16535
16513
|
recordFileDependency(claimant.file);
|
|
16536
16514
|
}
|
|
@@ -17083,7 +17061,7 @@ function buildCallerSummary(wrapper, callerFunc, callExpr, path15, options) {
|
|
|
17083
17061
|
return summary;
|
|
17084
17062
|
}
|
|
17085
17063
|
function named(summaries, workspace, runRoot) {
|
|
17086
|
-
const projectRoot = runRoot ??
|
|
17064
|
+
const projectRoot = runRoot ?? commonDirectoryOf2(summaries.map((s) => s.location.file));
|
|
17087
17065
|
nameSummaries(summaries, {
|
|
17088
17066
|
workspace: workspace ?? workspaceNameFor(projectRoot),
|
|
17089
17067
|
projectRoot
|
|
@@ -17520,7 +17498,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17520
17498
|
filesWalked: walkList.length,
|
|
17521
17499
|
summaries: composed,
|
|
17522
17500
|
tsConfigFilePath: config.tsConfigFilePath,
|
|
17523
|
-
projectRoot:
|
|
17501
|
+
projectRoot: commonDirectoryOf2(
|
|
17524
17502
|
sourceFiles.map((f) => f.getFilePath())
|
|
17525
17503
|
),
|
|
17526
17504
|
filesWithUnreadableExports: unreadableExportFiles(),
|
|
@@ -17532,7 +17510,7 @@ function createTypeScriptAdapter(suppliedConfig) {
|
|
|
17532
17510
|
return named(
|
|
17533
17511
|
composed,
|
|
17534
17512
|
config.workspace,
|
|
17535
|
-
runRoot ??
|
|
17513
|
+
runRoot ?? commonDirectoryOf2(sourceFiles.map((f) => f.getFilePath()))
|
|
17536
17514
|
);
|
|
17537
17515
|
}
|
|
17538
17516
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/adapter-typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Read a TypeScript or JavaScript codebase with suss and check what each handler returns against every caller, spec and template it can see.",
|
|
6
6
|
"keywords": [
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@suss/behavioral-ir": "0.
|
|
52
|
-
"@suss/datalog": "0.
|
|
53
|
-
"@suss/extractor": "0.
|
|
54
|
-
"@suss/resolution": "0.
|
|
55
|
-
"@suss/values": "0.
|
|
51
|
+
"@suss/behavioral-ir": "0.26.0",
|
|
52
|
+
"@suss/datalog": "0.26.0",
|
|
53
|
+
"@suss/extractor": "0.26.0",
|
|
54
|
+
"@suss/resolution": "0.26.0",
|
|
55
|
+
"@suss/values": "0.26.0",
|
|
56
56
|
"graphql": "^16.8.0",
|
|
57
57
|
"picomatch": "^4.0.4",
|
|
58
58
|
"ts-morph": "^23.0.0",
|