carrick 0.3.149 → 0.3.151
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/global-install.d.ts +2 -2
- package/dist/global-install.js +1 -1
- package/dist/global-install.js.map +1 -1
- package/dist/hook/post-edit.js +4 -0
- package/dist/hook/post-edit.js.map +1 -1
- package/dist/hook/rechecks.d.ts +6 -0
- package/dist/hook/rechecks.js +19 -0
- package/dist/hook/rechecks.js.map +1 -1
- package/dist/hook/reuse.d.ts +1 -0
- package/dist/hook/reuse.js +10 -1
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-start.js +15 -13
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stop-wait.js +17 -3
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/upgrade.d.ts +11 -0
- package/dist/hook/upgrade.js +81 -0
- package/dist/hook/upgrade.js.map +1 -0
- package/dist/hook/worktree.d.ts +10 -0
- package/dist/hook/worktree.js +45 -0
- package/dist/hook/worktree.js.map +1 -0
- package/dist/init/repo-copies.d.ts +2 -0
- package/dist/init/repo-copies.js +1 -1
- package/dist/init/repo-copies.js.map +1 -1
- package/dist/init/self-update.d.ts +2 -2
- package/dist/init/self-update.js +56 -12
- package/dist/init/self-update.js.map +1 -1
- package/dist/self-upgrade.d.ts +1 -0
- package/dist/self-upgrade.js +10 -0
- package/dist/self-upgrade.js.map +1 -0
- package/dist/upgrade.d.ts +26 -0
- package/dist/upgrade.js +86 -0
- package/dist/upgrade.js.map +1 -0
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/anchors.d.ts +7 -0
- package/sidecar/dist/src/capture/anchors.js +13 -4
- package/sidecar/dist/src/capture/check-classify.js +4 -2
- package/sidecar/dist/src/capture/check.js +8 -4
- package/sidecar/dist/src/capture/deep-walk.d.ts +14 -8
- package/sidecar/dist/src/capture/deep-walk.js +26 -9
- package/sidecar/dist/src/capture/index.js +4 -2
- package/sidecar/dist/src/capture/self-check.d.ts +7 -0
- package/sidecar/dist/src/capture/self-check.js +19 -1
- package/sidecar/dist/src/capture/service-config.d.ts +5 -4
- package/sidecar/dist/src/capture/service-config.js +15 -12
- package/sidecar/dist/src/library-claims.js +244 -30
- package/sidecar/dist/src/position-rows.js +25 -3
- package/sidecar/dist/src/types.d.ts +27 -4
- package/sidecar/dist/src/validators.d.ts +284 -34
- package/sidecar/dist/src/validators.js +19 -3
|
@@ -27,8 +27,17 @@ import { unresolvedAtAnchor, unresolvedSpecifiersReachableFrom, } from './unreso
|
|
|
27
27
|
* module setting maps back to the source and, in the stub, to its
|
|
28
28
|
* declaration.
|
|
29
29
|
*/
|
|
30
|
+
/**
|
|
31
|
+
* The absolute path of an anchor's `source_file`. The scanner sends a file
|
|
32
|
+
* outside the service root as an absolute path; `path.join` would nest it
|
|
33
|
+
* under the root, so a source file resolves with `path.resolve`: absolute
|
|
34
|
+
* stays absolute, relative is taken from the root.
|
|
35
|
+
*/
|
|
36
|
+
export function resolveSourceFile(repoRoot, sourceFile) {
|
|
37
|
+
return path.resolve(repoRoot, sourceFile);
|
|
38
|
+
}
|
|
30
39
|
export function entryRelativeSpecifier(entryDir, repoRoot, sourceFile, resolveFromEntry) {
|
|
31
|
-
const target =
|
|
40
|
+
const target = resolveSourceFile(repoRoot, sourceFile);
|
|
32
41
|
const from = (file) => {
|
|
33
42
|
const rel = path.relative(entryDir, file).split(path.sep).join('/');
|
|
34
43
|
return rel.startsWith('.') ? rel : `./${rel}`;
|
|
@@ -114,7 +123,7 @@ export function resolveAnchor(program, request, args) {
|
|
|
114
123
|
...(unresolved ? { unresolved } : {}),
|
|
115
124
|
};
|
|
116
125
|
}
|
|
117
|
-
const sourceAbs =
|
|
126
|
+
const sourceAbs = resolveSourceFile(args.repoRoot, request.source_file);
|
|
118
127
|
const sourceFile = program.getSourceFile(sourceAbs);
|
|
119
128
|
if (!sourceFile) {
|
|
120
129
|
return demote(`source file not in program: ${request.source_file}`);
|
|
@@ -439,7 +448,7 @@ function mergeUnresolved(atAnchor, substitutedPaths, specifiers) {
|
|
|
439
448
|
function unresolvedSpecifiersForLiteral(program, sourceFileRel, repoRoot) {
|
|
440
449
|
if (!sourceFileRel)
|
|
441
450
|
return [];
|
|
442
|
-
const sourceFile = program.getSourceFile(
|
|
451
|
+
const sourceFile = program.getSourceFile(resolveSourceFile(repoRoot, sourceFileRel));
|
|
443
452
|
return sourceFile ? unresolvedSpecifiersReachableFrom(program, sourceFile) : [];
|
|
444
453
|
}
|
|
445
454
|
/** `undeclaredNamesIn` over type text rather than a built node. */
|
|
@@ -492,7 +501,7 @@ function substituteUndeclaredNamesInText(text, program, destination) {
|
|
|
492
501
|
function qualifyNamesFromSource(text, program, sourceFileRel, printed, args) {
|
|
493
502
|
if (!sourceFileRel)
|
|
494
503
|
return undefined;
|
|
495
|
-
const source = program.getSourceFile(
|
|
504
|
+
const source = program.getSourceFile(resolveSourceFile(args.repoRoot, sourceFileRel));
|
|
496
505
|
const parsed = parseLiteralAnchor(text);
|
|
497
506
|
if (!source || !parsed)
|
|
498
507
|
return undefined;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import { decisiveAssignmentLine, unwidenedAliasOf, } from './check-probe.js';
|
|
35
35
|
import { scrubDiagnostic, scrubPaths } from './check-scrub.js';
|
|
36
|
-
import {
|
|
36
|
+
import { onlyDeclaredOpenMembers } from './deep-walk.js';
|
|
37
37
|
import { describeFieldReport, fieldReportNotes, } from './check-fields.js';
|
|
38
38
|
const PRIMARY_RE = /^(?<file>(?:[a-zA-Z]:)?[^(]*?)\((?<line>\d+),(?<col>\d+)\): error TS(?<code>\d+): (?<msg>.*)$/;
|
|
39
39
|
/** Parse `tsc --pretty false` output into structured diagnostics. */
|
|
@@ -462,7 +462,9 @@ function factness(input, strict = false) {
|
|
|
462
462
|
for (const side of ['sent', 'expected']) {
|
|
463
463
|
// Open members only (carrick#2591): the closed members were judged and an
|
|
464
464
|
// open one is never a mismatch, so the verdict is a fact about the type.
|
|
465
|
-
|
|
465
|
+
// A declared `unknown` is open on the receiving side alone.
|
|
466
|
+
if (!strict &&
|
|
467
|
+
onlyDeclaredOpenMembers(findings[side], side === 'expected', findings[side === 'sent' ? 'expected' : 'sent']))
|
|
466
468
|
continue;
|
|
467
469
|
const first = findings[side][0];
|
|
468
470
|
if (!first)
|
|
@@ -25,7 +25,7 @@ import { scrubPaths } from './check-scrub.js';
|
|
|
25
25
|
import { assembleWorkspace, writeProbes, } from './check-workspace.js';
|
|
26
26
|
import { buildPoisonIndexes } from './check-poison.js';
|
|
27
27
|
import { openProbeProgram, probeDeepFindings } from './check-deep.js';
|
|
28
|
-
import {
|
|
28
|
+
import { onlyDeclaredOpenMembers } from './deep-walk.js';
|
|
29
29
|
import { pairFieldReports } from './check-fields.js';
|
|
30
30
|
import { pairDispatchUnions } from './check-union.js';
|
|
31
31
|
function runProcess(command, args, cwd, env, limits) {
|
|
@@ -669,9 +669,13 @@ function deepDecayOf(plan, aliasRecords) {
|
|
|
669
669
|
// pre-gate reads, exactly as when the walk stopped at the first hit.
|
|
670
670
|
const findings = record?.any_provenance ?? [];
|
|
671
671
|
// An `any` the source declares under a named member is an open member
|
|
672
|
-
// (carrick#2591)
|
|
673
|
-
//
|
|
674
|
-
|
|
672
|
+
// (carrick#2591), and so is an `unknown` on the side that receives the
|
|
673
|
+
// payload, or one the receiving side also declares at the same path: the pair is probed, and the compiler judges the closed members.
|
|
674
|
+
// Anything else on the record keeps the pair out of the probe.
|
|
675
|
+
const other = side === 'producer' ? 'consumer' : 'producer';
|
|
676
|
+
const otherEndpoint = plan.spec[other];
|
|
677
|
+
const counterpart = aliasRecords.get(otherEndpoint.service_name)?.get(otherEndpoint.alias)?.any_provenance ?? [];
|
|
678
|
+
if (onlyDeclaredOpenMembers(findings, side === plan.direction.expected, counterpart))
|
|
675
679
|
continue;
|
|
676
680
|
const finding = findings[0];
|
|
677
681
|
if (finding) {
|
|
@@ -93,20 +93,26 @@ export declare function isErrorPlaceholder(t: ts.Type): boolean;
|
|
|
93
93
|
*/
|
|
94
94
|
export declare function pathNamesAMember(path: string): boolean;
|
|
95
95
|
/**
|
|
96
|
-
* True when every finding is
|
|
97
|
-
* member
|
|
96
|
+
* True when every finding is a top type the SOURCE declares under a named
|
|
97
|
+
* member: an OPEN member (carrick#2591). The policy: an open member is never
|
|
98
98
|
* a mismatch, and the closed members are judged as for a fully typed pair.
|
|
99
99
|
* `any` accepts and supplies every shape in the assignment the probe makes, so
|
|
100
100
|
* the compiler already judges only the closed members.
|
|
101
101
|
*
|
|
102
|
+
* `unknown` is open only on the side that RECEIVES the payload
|
|
103
|
+
* (`receiving`): any type is assignable to `unknown`, so no mismatch can hide
|
|
104
|
+
* there. On the sending side `unknown` rejects a narrower receiver, so it
|
|
105
|
+
* would read as a mismatch the policy forbids and stays a gate, except where
|
|
106
|
+
* the `counterpart` (the receiving side's findings) declares a top type at the
|
|
107
|
+
* same path: anything is assignable there.
|
|
108
|
+
*
|
|
102
109
|
* Nothing else qualifies. A callable's return (`getData()`) is no data
|
|
103
|
-
* member.
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* walk's cap may have stopped listing, so it cannot vouch for every position.
|
|
110
|
+
* member. A `budget_exhausted` sentinel, a root top type and a top type an
|
|
111
|
+
* unresolved import left say nothing about the author's intent. A list as long
|
|
112
|
+
* as the walk's cap may have stopped listing, so it cannot vouch for every
|
|
113
|
+
* position.
|
|
108
114
|
*/
|
|
109
|
-
export declare function
|
|
115
|
+
export declare function onlyDeclaredOpenMembers(findings: readonly TypeProvenance[], receiving: boolean, counterpart?: readonly TypeProvenance[]): boolean;
|
|
110
116
|
/** What an anchor's SOURCE program could not resolve (carrick#1164). */
|
|
111
117
|
export interface UnresolvedAtAnchor {
|
|
112
118
|
/** Member paths holding the unresolved-reference placeholder. */
|
|
@@ -290,23 +290,40 @@ export function pathNamesAMember(path) {
|
|
|
290
290
|
return false;
|
|
291
291
|
}
|
|
292
292
|
/**
|
|
293
|
-
* True when
|
|
294
|
-
*
|
|
293
|
+
* True when the other side declares `unknown` or `any` at exactly `path`
|
|
294
|
+
* (the same member, `[index]` element or nested member named on both sides).
|
|
295
|
+
* Anything is assignable there, so a sent `unknown` cannot mismatch. A list
|
|
296
|
+
* at the walk's cap may have stopped listing, so it vouches for nothing.
|
|
297
|
+
*/
|
|
298
|
+
function counterpartDeclaresTopAt(counterpart, path) {
|
|
299
|
+
return (counterpart.length < MAX_DEEP_FINDINGS &&
|
|
300
|
+
counterpart.some((c) => (c.kind === 'any' || c.kind === 'unknown') && c.reason === 'declared' && c.path === path));
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* True when every finding is a top type the SOURCE declares under a named
|
|
304
|
+
* member: an OPEN member (carrick#2591). The policy: an open member is never
|
|
295
305
|
* a mismatch, and the closed members are judged as for a fully typed pair.
|
|
296
306
|
* `any` accepts and supplies every shape in the assignment the probe makes, so
|
|
297
307
|
* the compiler already judges only the closed members.
|
|
298
308
|
*
|
|
309
|
+
* `unknown` is open only on the side that RECEIVES the payload
|
|
310
|
+
* (`receiving`): any type is assignable to `unknown`, so no mismatch can hide
|
|
311
|
+
* there. On the sending side `unknown` rejects a narrower receiver, so it
|
|
312
|
+
* would read as a mismatch the policy forbids and stays a gate, except where
|
|
313
|
+
* the `counterpart` (the receiving side's findings) declares a top type at the
|
|
314
|
+
* same path: anything is assignable there.
|
|
315
|
+
*
|
|
299
316
|
* Nothing else qualifies. A callable's return (`getData()`) is no data
|
|
300
|
-
* member.
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* walk's cap may have stopped listing, so it cannot vouch for every position.
|
|
317
|
+
* member. A `budget_exhausted` sentinel, a root top type and a top type an
|
|
318
|
+
* unresolved import left say nothing about the author's intent. A list as long
|
|
319
|
+
* as the walk's cap may have stopped listing, so it cannot vouch for every
|
|
320
|
+
* position.
|
|
305
321
|
*/
|
|
306
|
-
export function
|
|
322
|
+
export function onlyDeclaredOpenMembers(findings, receiving, counterpart = []) {
|
|
307
323
|
return (findings.length > 0 &&
|
|
308
324
|
findings.length < MAX_DEEP_FINDINGS &&
|
|
309
|
-
findings.every((f) => f.kind === 'any'
|
|
325
|
+
findings.every((f) => (f.kind === 'any' ||
|
|
326
|
+
(f.kind === 'unknown' && (receiving || counterpartDeclaresTopAt(counterpart, f.path)))) &&
|
|
310
327
|
f.reason === 'declared' &&
|
|
311
328
|
pathNamesAMember(f.path) &&
|
|
312
329
|
!f.path.includes('()')));
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import ts from 'typescript';
|
|
31
31
|
import * as fs from 'node:fs';
|
|
32
32
|
import * as path from 'node:path';
|
|
33
|
-
import { entryRelativeSpecifier, resolveAnchor } from './anchors.js';
|
|
33
|
+
import { entryRelativeSpecifier, resolveAnchor, resolveSourceFile } from './anchors.js';
|
|
34
34
|
import { findAugmentationFiles } from './augmentations.js';
|
|
35
35
|
import { installedVersions, lockfileVersions } from './lockfile.js';
|
|
36
36
|
import { installedResolutionEdges, RESOLUTION_FILE } from './resolution-edges.js';
|
|
@@ -513,6 +513,7 @@ export function captureStub(opts) {
|
|
|
513
513
|
bareCheckout,
|
|
514
514
|
repoRoot: dependencyRoot,
|
|
515
515
|
compilerHost,
|
|
516
|
+
outsideSources: written.outsideSources,
|
|
516
517
|
});
|
|
517
518
|
let aliases;
|
|
518
519
|
let secondAliases;
|
|
@@ -791,6 +792,7 @@ function writeStub(surface, stubDir, ctx) {
|
|
|
791
792
|
pinned,
|
|
792
793
|
unpinned,
|
|
793
794
|
installs: rewritten.installs,
|
|
795
|
+
outsideSources: Object.fromEntries([...placed.outside].map(([source, rel]) => [path.join(typesDir, rel), `${source}.ts`])),
|
|
794
796
|
};
|
|
795
797
|
}
|
|
796
798
|
/**
|
|
@@ -1215,7 +1217,7 @@ function resolveAnchors(opts, parsed, ctx, deno, owner) {
|
|
|
1215
1217
|
ctx.progress('program', 'building the program the anchors are read in');
|
|
1216
1218
|
const anchorSources = [
|
|
1217
1219
|
...new Set(opts.anchors
|
|
1218
|
-
.flatMap((a) => (a.source_file ? [
|
|
1220
|
+
.flatMap((a) => (a.source_file ? [resolveSourceFile(ctx.repoRoot, a.source_file)] : []))),
|
|
1219
1221
|
].filter((f) => fs.existsSync(f));
|
|
1220
1222
|
const options = sidecarCompilerOptions({
|
|
1221
1223
|
...parsed.options,
|
|
@@ -56,6 +56,13 @@ export interface SelfCheckArgs {
|
|
|
56
56
|
/** Producer repo root; its node_modules (if any) backs resolution. */
|
|
57
57
|
repoRoot: string;
|
|
58
58
|
compilerHost?: (options: ts.CompilerOptions) => ts.CompilerHost;
|
|
59
|
+
/**
|
|
60
|
+
* Absolute stub path of each declaration emitted for a source outside the
|
|
61
|
+
* service's rootDir -> that source's own path. A bare specifier such a
|
|
62
|
+
* declaration names that the stub's links do not reach is resolved from the
|
|
63
|
+
* source's place in the checkout, as the compiler resolved it at emit.
|
|
64
|
+
*/
|
|
65
|
+
outsideSources?: Readonly<Record<string, string>>;
|
|
59
66
|
}
|
|
60
67
|
/** The records of each surface, in `args.surfaces` order. */
|
|
61
68
|
export declare function selfCheckStub(args: SelfCheckArgs): CaptureAliasRecord[][];
|
|
@@ -110,8 +110,26 @@ export const SELF_CHECK_OPTIONS = sidecarCompilerOptions({
|
|
|
110
110
|
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
111
111
|
types: [],
|
|
112
112
|
});
|
|
113
|
+
/** The host of a self-check program, with outside declarations resolving from their source. */
|
|
114
|
+
function selfCheckHost(args) {
|
|
115
|
+
const outside = args.outsideSources;
|
|
116
|
+
if (!outside || Object.keys(outside).length === 0)
|
|
117
|
+
return args.compilerHost?.(SELF_CHECK_OPTIONS);
|
|
118
|
+
const host = args.compilerHost?.(SELF_CHECK_OPTIONS) ?? ts.createCompilerHost(SELF_CHECK_OPTIONS);
|
|
119
|
+
const fallback = host.resolveModuleNames?.bind(host);
|
|
120
|
+
host.resolveModuleNames = (names, containingFile, reused, redirected, options, containingSourceFile) => names.map((name, index) => {
|
|
121
|
+
const resolved = fallback
|
|
122
|
+
? fallback([name], containingFile, reused?.slice(index, index + 1), redirected, options, containingSourceFile)[0]
|
|
123
|
+
: ts.resolveModuleName(name, containingFile, options, host).resolvedModule;
|
|
124
|
+
const source = outside[path.resolve(containingFile)];
|
|
125
|
+
if (resolved || !source || name.startsWith('.') || path.isAbsolute(name))
|
|
126
|
+
return resolved;
|
|
127
|
+
return ts.resolveModuleName(name, source, options, host).resolvedModule;
|
|
128
|
+
});
|
|
129
|
+
return host;
|
|
130
|
+
}
|
|
113
131
|
function runSelfCheck(args, treeFiles, repaired) {
|
|
114
|
-
const program = ts.createProgram(treeFiles, SELF_CHECK_OPTIONS, args
|
|
132
|
+
const program = ts.createProgram(treeFiles, SELF_CHECK_OPTIONS, selfCheckHost(args));
|
|
115
133
|
const checker = program.getTypeChecker();
|
|
116
134
|
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
117
135
|
// A surface holds EVERY alias, and every alias's closure starts there, so
|
|
@@ -33,8 +33,9 @@ export declare function realPath(p: string): string;
|
|
|
33
33
|
* The config each file of one service is typed under (carrick#1604,
|
|
34
34
|
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
35
35
|
* From the file's directory up to the service root, inclusive, each directory's
|
|
36
|
-
* `tsconfig.json`,
|
|
37
|
-
* project it references, lists the file; the first that does
|
|
36
|
+
* `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
|
|
37
|
+
* program, or a project it references, lists the file; the first that does
|
|
38
|
+
* types it (a
|
|
38
39
|
* solution config hands the file to the reference that lists it). A config
|
|
39
40
|
* that lists the file nowhere is passed over. The climb stops after a
|
|
40
41
|
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
@@ -50,7 +51,7 @@ export declare class GoverningConfigs {
|
|
|
50
51
|
private readonly serviceConfig;
|
|
51
52
|
private readonly report;
|
|
52
53
|
private readonly root;
|
|
53
|
-
/** Directory -> the
|
|
54
|
+
/** Directory -> the configs in it, in order, for every directory a climb visited. */
|
|
54
55
|
private readonly dirConfigs;
|
|
55
56
|
/** Config -> its projects; undefined for one that cannot be read. */
|
|
56
57
|
private readonly graphs;
|
|
@@ -62,7 +63,7 @@ export declare class GoverningConfigs {
|
|
|
62
63
|
constructor(serviceRoot: string, serviceConfig: string | undefined, report?: (diagnostic: string) => void);
|
|
63
64
|
/** Absolute path of the config that types `file`, or undefined for none. */
|
|
64
65
|
configFor(file: string): string | undefined;
|
|
65
|
-
private
|
|
66
|
+
private configsIn;
|
|
66
67
|
/** The project reached from `config` that lists `file`, absolute. */
|
|
67
68
|
private listingOwner;
|
|
68
69
|
}
|
|
@@ -76,8 +76,9 @@ const FILE_CONFIG_NAMES = ['tsconfig.json', 'jsconfig.json'];
|
|
|
76
76
|
* The config each file of one service is typed under (carrick#1604,
|
|
77
77
|
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
78
78
|
* From the file's directory up to the service root, inclusive, each directory's
|
|
79
|
-
* `tsconfig.json`,
|
|
80
|
-
* project it references, lists the file; the first that does
|
|
79
|
+
* `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
|
|
80
|
+
* program, or a project it references, lists the file; the first that does
|
|
81
|
+
* types it (a
|
|
81
82
|
* solution config hands the file to the reference that lists it). A config
|
|
82
83
|
* that lists the file nowhere is passed over. The climb stops after a
|
|
83
84
|
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
@@ -93,7 +94,7 @@ export class GoverningConfigs {
|
|
|
93
94
|
serviceConfig;
|
|
94
95
|
report;
|
|
95
96
|
root;
|
|
96
|
-
/** Directory -> the
|
|
97
|
+
/** Directory -> the configs in it, in order, for every directory a climb visited. */
|
|
97
98
|
dirConfigs = new Map();
|
|
98
99
|
/** Config -> its projects; undefined for one that cannot be read. */
|
|
99
100
|
graphs = new Map();
|
|
@@ -115,10 +116,11 @@ export class GoverningConfigs {
|
|
|
115
116
|
const from = path.relative(this.root, dir);
|
|
116
117
|
if (from.startsWith('..') || path.isAbsolute(from))
|
|
117
118
|
break;
|
|
118
|
-
const config
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
for (const config of this.configsIn(dir)) {
|
|
120
|
+
const owner = this.listingOwner(config, absolute);
|
|
121
|
+
if (owner !== undefined)
|
|
122
|
+
return owner;
|
|
123
|
+
}
|
|
122
124
|
// tsserver looks in a `node_modules` directory itself, then stops.
|
|
123
125
|
if (dir === this.root || path.basename(dir) === 'node_modules')
|
|
124
126
|
break;
|
|
@@ -128,12 +130,13 @@ export class GoverningConfigs {
|
|
|
128
130
|
return undefined;
|
|
129
131
|
return this.listingOwner(this.serviceConfig, absolute) ?? this.serviceConfig;
|
|
130
132
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
configsIn(dir) {
|
|
134
|
+
let configs = this.dirConfigs.get(dir);
|
|
135
|
+
if (configs === undefined) {
|
|
136
|
+
configs = FILE_CONFIG_NAMES.map((n) => path.join(dir, n)).filter((c) => fs.existsSync(c));
|
|
137
|
+
this.dirConfigs.set(dir, configs);
|
|
135
138
|
}
|
|
136
|
-
return
|
|
139
|
+
return configs;
|
|
137
140
|
}
|
|
138
141
|
/** The project reached from `config` that lists `file`, absolute. */
|
|
139
142
|
listingOwner(config, file) {
|