@ariestools/toolchain 8.7.24 → 8.7.26
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/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.d.ts +10 -5
- package/dist/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.d.ts.map +1 -1
- package/dist/actions/deplint/engine.d.ts.map +1 -1
- package/dist/actions/deplint/findFiles.d.ts +25 -1
- package/dist/actions/deplint/findFiles.d.ts.map +1 -1
- package/dist/actions/deplint/fixer.d.ts.map +1 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.d.ts +10 -1
- package/dist/actions/deplint/getExternalImportsFromFiles.d.ts.map +1 -1
- package/dist/actions/deplint/index.d.ts +1 -0
- package/dist/actions/deplint/index.d.ts.map +1 -1
- package/dist/actions/deplint/isTerminalPackage.d.ts +72 -14
- package/dist/actions/deplint/isTerminalPackage.d.ts.map +1 -1
- package/dist/actions/deplint/rules.d.ts.map +1 -1
- package/dist/actions/deplint/rulesDeprecatedRefType.d.ts +16 -0
- package/dist/actions/deplint/rulesDeprecatedRefType.d.ts.map +1 -0
- package/dist/actions/deplint/snapshot.d.ts +12 -1
- package/dist/actions/deplint/snapshot.d.ts.map +1 -1
- package/dist/actions/deplint/types.d.ts +36 -2
- package/dist/actions/deplint/types.d.ts.map +1 -1
- package/dist/actions/package/compile/XyConfig.d.ts +23 -11
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/bin/xy.mjs +403 -119
- package/dist/bin/xy.mjs.map +1 -1
- package/package.json +4 -4
package/dist/bin/xy.mjs
CHANGED
|
@@ -20839,7 +20839,7 @@ const LOCAL_PROTOCOLS = [
|
|
|
20839
20839
|
"link:",
|
|
20840
20840
|
"portal:"
|
|
20841
20841
|
];
|
|
20842
|
-
function readPackageJson$
|
|
20842
|
+
function readPackageJson$10(filePath) {
|
|
20843
20843
|
if (!existsSync(filePath)) return void 0;
|
|
20844
20844
|
try {
|
|
20845
20845
|
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
@@ -20850,7 +20850,7 @@ function readPackageJson$9(filePath) {
|
|
|
20850
20850
|
function collectSecurePackageTargets(cwd, workspaces) {
|
|
20851
20851
|
const targets = [];
|
|
20852
20852
|
const seenLocations = /* @__PURE__ */ new Set();
|
|
20853
|
-
const rootName = readPackageJson$
|
|
20853
|
+
const rootName = readPackageJson$10(PATH.resolve(cwd, "package.json"))?.name;
|
|
20854
20854
|
if (rootName !== void 0 && rootName.length > 0) {
|
|
20855
20855
|
targets.push({
|
|
20856
20856
|
location: ".",
|
|
@@ -20889,7 +20889,7 @@ function collectExternalDeclaredDeps(deps, depType, target, localPackageNames, d
|
|
|
20889
20889
|
function collectSecureDeclaredDependencies(cwd, targets, localPackageNames) {
|
|
20890
20890
|
const declared = [];
|
|
20891
20891
|
for (const target of targets) {
|
|
20892
|
-
const pkg = readPackageJson$
|
|
20892
|
+
const pkg = readPackageJson$10(PATH.resolve(cwd, target.location, "package.json"));
|
|
20893
20893
|
if (!pkg) continue;
|
|
20894
20894
|
for (const depType of DEP_FIELDS$1) collectExternalDeclaredDeps(pkg[depType], depType, target, localPackageNames, declared);
|
|
20895
20895
|
}
|
|
@@ -23347,6 +23347,74 @@ const EXPORT_META_KEYS = /* @__PURE__ */ new Set([
|
|
|
23347
23347
|
"./package.json",
|
|
23348
23348
|
"./README.md"
|
|
23349
23349
|
]);
|
|
23350
|
+
const APP_PACKAGE_NAMES = /* @__PURE__ */ new Set([
|
|
23351
|
+
"@remix-run/dev",
|
|
23352
|
+
"@sveltejs/kit",
|
|
23353
|
+
"next",
|
|
23354
|
+
"nuxt",
|
|
23355
|
+
"react-scripts",
|
|
23356
|
+
"vite",
|
|
23357
|
+
"vite-node"
|
|
23358
|
+
]);
|
|
23359
|
+
const START_SCRIPT_KEYS = [
|
|
23360
|
+
"start",
|
|
23361
|
+
"start:prod",
|
|
23362
|
+
"start:production",
|
|
23363
|
+
"start:node",
|
|
23364
|
+
"serve"
|
|
23365
|
+
];
|
|
23366
|
+
/** Default policy profile for each role (rules.md). */
|
|
23367
|
+
const ROLE_FACET_DEFAULTS = {
|
|
23368
|
+
"app": {
|
|
23369
|
+
allowMoveToDev: true,
|
|
23370
|
+
hasImportConsumers: false,
|
|
23371
|
+
peerTarget: "dep",
|
|
23372
|
+
prodInstallMatters: true,
|
|
23373
|
+
runtimeEntry: "framework"
|
|
23374
|
+
},
|
|
23375
|
+
"cli": {
|
|
23376
|
+
allowMoveToDev: true,
|
|
23377
|
+
hasImportConsumers: false,
|
|
23378
|
+
peerTarget: "dep",
|
|
23379
|
+
prodInstallMatters: true,
|
|
23380
|
+
runtimeEntry: "manifest"
|
|
23381
|
+
},
|
|
23382
|
+
"library": {
|
|
23383
|
+
allowMoveToDev: true,
|
|
23384
|
+
hasImportConsumers: true,
|
|
23385
|
+
peerTarget: "peer",
|
|
23386
|
+
prodInstallMatters: false,
|
|
23387
|
+
runtimeEntry: "manifest"
|
|
23388
|
+
},
|
|
23389
|
+
"library/cli": {
|
|
23390
|
+
allowMoveToDev: true,
|
|
23391
|
+
hasImportConsumers: true,
|
|
23392
|
+
peerTarget: "peer",
|
|
23393
|
+
prodInstallMatters: true,
|
|
23394
|
+
runtimeEntry: "manifest"
|
|
23395
|
+
},
|
|
23396
|
+
"service": {
|
|
23397
|
+
allowMoveToDev: true,
|
|
23398
|
+
hasImportConsumers: false,
|
|
23399
|
+
peerTarget: "dep",
|
|
23400
|
+
prodInstallMatters: true,
|
|
23401
|
+
runtimeEntry: "scripts"
|
|
23402
|
+
},
|
|
23403
|
+
"tooling": {
|
|
23404
|
+
allowMoveToDev: true,
|
|
23405
|
+
hasImportConsumers: false,
|
|
23406
|
+
peerTarget: "none",
|
|
23407
|
+
prodInstallMatters: false,
|
|
23408
|
+
runtimeEntry: "none"
|
|
23409
|
+
},
|
|
23410
|
+
"workspace-root": {
|
|
23411
|
+
allowMoveToDev: true,
|
|
23412
|
+
hasImportConsumers: false,
|
|
23413
|
+
peerTarget: "none",
|
|
23414
|
+
prodInstallMatters: false,
|
|
23415
|
+
runtimeEntry: "none"
|
|
23416
|
+
}
|
|
23417
|
+
};
|
|
23350
23418
|
function hasBinSetup(bin) {
|
|
23351
23419
|
if (typeof bin === "string") return bin.length > 0;
|
|
23352
23420
|
if (typeof bin !== "object" || bin === null || Array.isArray(bin)) return false;
|
|
@@ -23359,70 +23427,154 @@ function isCliOnlyExports(exports) {
|
|
|
23359
23427
|
return Object.keys(exports).every((k) => EXPORT_META_KEYS.has(k));
|
|
23360
23428
|
}
|
|
23361
23429
|
function hasLibrarySurface(pkg) {
|
|
23362
|
-
|
|
23430
|
+
if (pkg.main !== void 0 || pkg.module !== void 0) return true;
|
|
23431
|
+
if (pkg.exports === void 0) return false;
|
|
23432
|
+
if (hasBinSetup(pkg.bin)) return !isCliOnlyExports(pkg.exports);
|
|
23433
|
+
return true;
|
|
23434
|
+
}
|
|
23435
|
+
function dependencyNames(pkg) {
|
|
23436
|
+
return [...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})];
|
|
23363
23437
|
}
|
|
23364
|
-
function
|
|
23365
|
-
|
|
23366
|
-
|
|
23367
|
-
|
|
23368
|
-
|
|
23438
|
+
function hasAppFramework(pkg) {
|
|
23439
|
+
return dependencyNames(pkg).some((name) => APP_PACKAGE_NAMES.has(name));
|
|
23440
|
+
}
|
|
23441
|
+
/**
|
|
23442
|
+
* True when a script value appears to launch a local JS/TS entry with node/tsx.
|
|
23443
|
+
*/
|
|
23444
|
+
function scriptInvokesLocalEntry(script) {
|
|
23445
|
+
return /\b(?:node|tsx|ts-node)(?:\.\w+)?\b(?:\s+-[^\s"]+)*\s+["']?(?:\.\/)?[^\s"']+\.[cm]?[jt]sx?/.test(script);
|
|
23446
|
+
}
|
|
23447
|
+
function hasStartScriptEntry(pkg) {
|
|
23448
|
+
const scripts = pkg.scripts;
|
|
23449
|
+
if (scripts === void 0) return false;
|
|
23450
|
+
for (const key of START_SCRIPT_KEYS) {
|
|
23451
|
+
const value = scripts[key];
|
|
23452
|
+
if (typeof value === "string" && scriptInvokesLocalEntry(value)) return true;
|
|
23453
|
+
}
|
|
23454
|
+
return false;
|
|
23455
|
+
}
|
|
23456
|
+
const SCRIPT_LOCAL_ENTRY_RE = /\b(?:node|tsx|ts-node)(?:\.\w+)?\b(?:\s+-[^\s"]+)*\s+["']?((?:\.\/)?[^\s"']+\.[cm]?[jt]sx?)["']?/gi;
|
|
23457
|
+
function collectLocalEntriesFromScript(script, seen, entries) {
|
|
23458
|
+
for (const match of script.matchAll(SCRIPT_LOCAL_ENTRY_RE)) {
|
|
23459
|
+
const entry = match[1]?.replace(/^\.\//, "");
|
|
23460
|
+
if (entry === void 0 || entry.length === 0 || seen.has(entry)) continue;
|
|
23461
|
+
seen.add(entry);
|
|
23462
|
+
entries.push(entry.startsWith(".") ? entry : `./${entry}`);
|
|
23463
|
+
}
|
|
23464
|
+
}
|
|
23465
|
+
/**
|
|
23466
|
+
* Extract package-relative code entry paths from start-like scripts.
|
|
23467
|
+
*/
|
|
23468
|
+
function getScriptRuntimeEntries(pkg) {
|
|
23469
|
+
const scripts = pkg.scripts;
|
|
23470
|
+
if (scripts === void 0) return [];
|
|
23471
|
+
const entries = [];
|
|
23472
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23473
|
+
for (const key of START_SCRIPT_KEYS) {
|
|
23474
|
+
const value = scripts[key];
|
|
23475
|
+
if (typeof value === "string") collectLocalEntriesFromScript(value, seen, entries);
|
|
23476
|
+
}
|
|
23477
|
+
return entries;
|
|
23478
|
+
}
|
|
23479
|
+
function isWorkspaceRootPackage(location, pkg) {
|
|
23480
|
+
if (pkg.workspaces !== void 0 && pkg.workspaces !== null) return true;
|
|
23481
|
+
const abs = PATH.resolve(location);
|
|
23482
|
+
return fs.existsSync(PATH.join(abs, "pnpm-workspace.yaml")) || fs.existsSync(PATH.join(abs, "pnpm-workspace.yml"));
|
|
23483
|
+
}
|
|
23484
|
+
function readPackageJson$9(location) {
|
|
23485
|
+
try {
|
|
23486
|
+
return JSON.parse(fs.readFileSync(`${location}/package.json`, "utf8"));
|
|
23487
|
+
} catch {
|
|
23488
|
+
return;
|
|
23489
|
+
}
|
|
23490
|
+
}
|
|
23491
|
+
function definedEntries(options) {
|
|
23492
|
+
if (options === void 0) return {};
|
|
23493
|
+
const result = {};
|
|
23494
|
+
if (options.allowMoveToDev !== void 0) result.allowMoveToDev = options.allowMoveToDev;
|
|
23495
|
+
if (options.hasImportConsumers !== void 0) result.hasImportConsumers = options.hasImportConsumers;
|
|
23496
|
+
if (options.peerTarget !== void 0) result.peerTarget = options.peerTarget;
|
|
23497
|
+
if (options.prodInstallMatters !== void 0) result.prodInstallMatters = options.prodInstallMatters;
|
|
23498
|
+
if (options.role !== void 0) result.role = options.role;
|
|
23499
|
+
if (options.runtimeEntry !== void 0) result.runtimeEntry = options.runtimeEntry;
|
|
23500
|
+
if (options.runtimeRoots !== void 0) result.runtimeRoots = options.runtimeRoots;
|
|
23501
|
+
if (options.terminal !== void 0) result.terminal = options.terminal;
|
|
23502
|
+
return result;
|
|
23503
|
+
}
|
|
23504
|
+
function mergeOptions(embedded, options) {
|
|
23505
|
+
return {
|
|
23506
|
+
...embedded,
|
|
23507
|
+
...definedEntries(options)
|
|
23508
|
+
};
|
|
23509
|
+
}
|
|
23510
|
+
function detectRole(location, pkg) {
|
|
23511
|
+
if (isWorkspaceRootPackage(location, pkg) && !hasLibrarySurface(pkg) && !hasBinSetup(pkg.bin)) return "workspace-root";
|
|
23512
|
+
if (hasLibrarySurface(pkg)) return hasBinSetup(pkg.bin) ? "library/cli" : "library";
|
|
23513
|
+
if (hasBinSetup(pkg.bin)) return "cli";
|
|
23514
|
+
if (pkg.private === true) {
|
|
23515
|
+
if (hasStartScriptEntry(pkg)) return "service";
|
|
23516
|
+
if (hasAppFramework(pkg)) return "app";
|
|
23517
|
+
return "service";
|
|
23518
|
+
}
|
|
23519
|
+
return "library";
|
|
23520
|
+
}
|
|
23521
|
+
function applyTerminalLegacy(role, pkg, terminal) {
|
|
23522
|
+
if (terminal === void 0) return role;
|
|
23523
|
+
if (terminal) {
|
|
23524
|
+
if (!ROLE_FACET_DEFAULTS[role].hasImportConsumers) return role;
|
|
23525
|
+
return hasBinSetup(pkg.bin) ? "cli" : "service";
|
|
23526
|
+
}
|
|
23527
|
+
if (ROLE_FACET_DEFAULTS[role].hasImportConsumers) return role;
|
|
23528
|
+
return hasBinSetup(pkg.bin) ? "library/cli" : "library";
|
|
23529
|
+
}
|
|
23530
|
+
function applyFacetOverrides(base, options) {
|
|
23531
|
+
return {
|
|
23532
|
+
allowMoveToDev: options.allowMoveToDev ?? base.allowMoveToDev,
|
|
23533
|
+
hasImportConsumers: options.hasImportConsumers ?? base.hasImportConsumers,
|
|
23534
|
+
peerTarget: options.peerTarget ?? base.peerTarget,
|
|
23535
|
+
prodInstallMatters: options.prodInstallMatters ?? base.prodInstallMatters,
|
|
23536
|
+
runtimeEntry: options.runtimeEntry ?? base.runtimeEntry
|
|
23369
23537
|
};
|
|
23538
|
+
}
|
|
23539
|
+
function buildClassification(role, facets, runtimeRoots) {
|
|
23370
23540
|
return {
|
|
23371
|
-
|
|
23372
|
-
|
|
23541
|
+
facets,
|
|
23542
|
+
isTerminalPackage: !facets.hasImportConsumers,
|
|
23543
|
+
kind: role,
|
|
23544
|
+
role,
|
|
23545
|
+
runtimeRoots
|
|
23373
23546
|
};
|
|
23374
23547
|
}
|
|
23375
23548
|
/**
|
|
23376
|
-
* Classifies a package by
|
|
23377
|
-
* label shown in progress output.
|
|
23378
|
-
*
|
|
23379
|
-
* Terminal packages have unsatisfied runtime peers added to `dependencies`;
|
|
23380
|
-
* libraries get them in `peerDependencies` so consumers inherit the
|
|
23381
|
-
* requirement.
|
|
23549
|
+
* Classifies a package by role and policy facets for deplint.
|
|
23382
23550
|
*
|
|
23383
|
-
*
|
|
23384
|
-
*
|
|
23385
|
-
* - `terminal[cli]`: published CLI shape; a non-private CLI should declare `bin`.
|
|
23386
|
-
* - `library/cli`: package has `bin` plus an importable library surface.
|
|
23387
|
-
* - `library`: importable package without a CLI entry.
|
|
23551
|
+
* See `rules.md` → Package role model. Prefer reading `facets` in rules;
|
|
23552
|
+
* `isTerminalPackage` is `!facets.hasImportConsumers` for compatibility.
|
|
23388
23553
|
*/
|
|
23389
|
-
function classifyDeplintPackage(location,
|
|
23390
|
-
|
|
23391
|
-
|
|
23392
|
-
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
isTerminalPackage: true,
|
|
23398
|
-
kind: "terminal[cli]"
|
|
23399
|
-
}, isTerminalOverride);
|
|
23400
|
-
const hasBin = hasBinSetup(pkg.bin);
|
|
23401
|
-
if (hasBin && hasLibrarySurface(pkg)) return withTerminalOverride({
|
|
23402
|
-
isTerminalPackage: false,
|
|
23403
|
-
kind: "library/cli"
|
|
23404
|
-
}, isTerminalOverride);
|
|
23405
|
-
if (hasBin) return withTerminalOverride({
|
|
23406
|
-
isTerminalPackage: true,
|
|
23407
|
-
kind: "terminal[cli]"
|
|
23408
|
-
}, isTerminalOverride);
|
|
23409
|
-
return withTerminalOverride({
|
|
23410
|
-
isTerminalPackage: false,
|
|
23411
|
-
kind: "library"
|
|
23412
|
-
}, isTerminalOverride);
|
|
23413
|
-
} catch {
|
|
23414
|
-
return withTerminalOverride({
|
|
23415
|
-
isTerminalPackage: false,
|
|
23416
|
-
kind: "library"
|
|
23417
|
-
}, isTerminalOverride);
|
|
23418
|
-
}
|
|
23554
|
+
function classifyDeplintPackage(location, optionsOrTerminal) {
|
|
23555
|
+
const options = typeof optionsOrTerminal === "boolean" ? { terminal: optionsOrTerminal } : optionsOrTerminal;
|
|
23556
|
+
const pkg = readPackageJson$9(location);
|
|
23557
|
+
if (pkg === void 0) return buildClassification("library", applyFacetOverrides(ROLE_FACET_DEFAULTS.library, options ?? {}), options?.runtimeRoots ?? []);
|
|
23558
|
+
const merged = mergeOptions(pkg.xy?.commands?.deplint, options);
|
|
23559
|
+
const autoRole = detectRole(location, pkg);
|
|
23560
|
+
const role = merged.role ?? applyTerminalLegacy(autoRole, pkg, merged.terminal);
|
|
23561
|
+
return buildClassification(role, applyFacetOverrides(ROLE_FACET_DEFAULTS[role], merged), merged.runtimeRoots ?? []);
|
|
23419
23562
|
}
|
|
23420
23563
|
/**
|
|
23421
|
-
* Determines if a package is "terminal" for rule behavior
|
|
23564
|
+
* Determines if a package is "terminal" for rule behavior
|
|
23565
|
+
* (`!hasImportConsumers`).
|
|
23422
23566
|
*/
|
|
23423
23567
|
function isTerminalPackage$1(location) {
|
|
23424
23568
|
return classifyDeplintPackage(location).isTerminalPackage;
|
|
23425
23569
|
}
|
|
23570
|
+
/**
|
|
23571
|
+
* Whether demotion (`move-to-dev`) is allowed given facets and graph trust.
|
|
23572
|
+
*/
|
|
23573
|
+
function shouldAllowMoveToDev(facets, hasTrustedRuntimeGraph) {
|
|
23574
|
+
if (!facets.allowMoveToDev) return false;
|
|
23575
|
+
if (!hasTrustedRuntimeGraph && facets.prodInstallMatters) return false;
|
|
23576
|
+
return true;
|
|
23577
|
+
}
|
|
23426
23578
|
//#endregion
|
|
23427
23579
|
//#region src/actions/deplint/checkPackage/getUnsatisfiedPeerDependencies.ts
|
|
23428
23580
|
/** True when the policy (if any) obliges this package to forward `peer`. */
|
|
@@ -23703,14 +23855,21 @@ function findMismatchedSources(location, sources, peer, installedVersion) {
|
|
|
23703
23855
|
});
|
|
23704
23856
|
}
|
|
23705
23857
|
/**
|
|
23706
|
-
*
|
|
23707
|
-
*
|
|
23708
|
-
*
|
|
23709
|
-
*
|
|
23858
|
+
* Where to write an unsatisfied peer, based on package role facets.
|
|
23859
|
+
*
|
|
23860
|
+
* - no runtime source → `devDependencies` only (local resolution)
|
|
23861
|
+
* - `peerTarget: 'dep'` (terminal products) → `dependencies`
|
|
23862
|
+
* - `peerTarget: 'peer'` (libraries) → `peerDependencies` + `devDependencies`
|
|
23863
|
+
* - `peerTarget: 'none'` → no auto-add for runtime peers
|
|
23864
|
+
*
|
|
23865
|
+
* The second argument accepts a boolean for backward compatibility
|
|
23866
|
+
* (`true` ⇒ dep, `false` ⇒ peer).
|
|
23710
23867
|
*/
|
|
23711
|
-
function resolvePeerTargetSections(hasRuntimeSource,
|
|
23868
|
+
function resolvePeerTargetSections(hasRuntimeSource, peerTargetOrIsTerminal) {
|
|
23712
23869
|
if (!hasRuntimeSource) return ["devDependencies"];
|
|
23713
|
-
|
|
23870
|
+
const peerTarget = typeof peerTargetOrIsTerminal === "boolean" ? peerTargetOrIsTerminal ? "dep" : "peer" : peerTargetOrIsTerminal;
|
|
23871
|
+
if (peerTarget === "none") return [];
|
|
23872
|
+
if (peerTarget === "dep") return ["dependencies"];
|
|
23714
23873
|
return ["peerDependencies", "devDependencies"];
|
|
23715
23874
|
}
|
|
23716
23875
|
//#endregion
|
|
@@ -26358,7 +26517,22 @@ function uniqueFiles(...lists) {
|
|
|
26358
26517
|
for (const list of lists) appendUniqueFiles(list, seen, result);
|
|
26359
26518
|
return result;
|
|
26360
26519
|
}
|
|
26361
|
-
function
|
|
26520
|
+
function normalizeFindFilesOptions(sourceExcludeOrOptions) {
|
|
26521
|
+
if (sourceExcludeOrOptions === void 0) return {};
|
|
26522
|
+
if (Array.isArray(sourceExcludeOrOptions)) return { sourceExclude: sourceExcludeOrOptions };
|
|
26523
|
+
return sourceExcludeOrOptions;
|
|
26524
|
+
}
|
|
26525
|
+
/**
|
|
26526
|
+
* Collects declared runtime entry paths and the reachable file graph.
|
|
26527
|
+
*
|
|
26528
|
+
* `runtimeEntry` controls which sources contribute roots:
|
|
26529
|
+
* - `manifest`: exports/main/module/types/bin (default)
|
|
26530
|
+
* - `scripts`: start-like npm scripts → node/tsx targets, plus manifest
|
|
26531
|
+
* - `framework`: same as scripts + manifest for now
|
|
26532
|
+
* - `none`: only explicit `extraRuntimeRoots` (if any)
|
|
26533
|
+
*/
|
|
26534
|
+
function findFiles(location, sourceExcludeOrOptions) {
|
|
26535
|
+
const { sourceExclude, runtimeEntry = "manifest", extraRuntimeRoots = [] } = normalizeFindFilesOptions(sourceExcludeOrOptions);
|
|
26362
26536
|
const pkg = readPackageJson$7(location);
|
|
26363
26537
|
const workspaceIgnores = getNestedWorkspaceIgnores(location);
|
|
26364
26538
|
const sourceIgnorePatterns = toSourceIgnorePatterns(location, sourceExclude);
|
|
@@ -26371,12 +26545,25 @@ function findFiles(location, sourceExclude) {
|
|
|
26371
26545
|
...sourceIgnorePatterns
|
|
26372
26546
|
];
|
|
26373
26547
|
const allFiles = findFilesByGlob(location, `./**/${codeExtensions$1}`, ignore);
|
|
26374
|
-
const
|
|
26375
|
-
const
|
|
26376
|
-
const
|
|
26548
|
+
const useManifest = runtimeEntry !== "none";
|
|
26549
|
+
const useScripts = runtimeEntry === "framework" || runtimeEntry === "scripts";
|
|
26550
|
+
const manifestRuntimeEntries = useManifest ? getManifestRuntimeEntries(pkg) : [];
|
|
26551
|
+
const binEntries = useManifest ? getBinEntries(pkg) : [];
|
|
26552
|
+
const scriptEntries = useScripts ? getScriptRuntimeEntries(pkg ?? {}) : [];
|
|
26553
|
+
const configEntries = extraRuntimeRoots.map((entry) => entry.startsWith(".") || entry.startsWith("/") ? entry : `./${entry}`);
|
|
26554
|
+
const runtimeEntries = [...new Set([
|
|
26555
|
+
...manifestRuntimeEntries,
|
|
26556
|
+
...binEntries,
|
|
26557
|
+
...scriptEntries,
|
|
26558
|
+
...configEntries
|
|
26559
|
+
].filter((entry) => typeof entry === "string" && (entry.includes("*") || canResolveToCode(entry))))];
|
|
26560
|
+
const binFiles = useManifest ? getBinFiles(location, pkg) : [];
|
|
26377
26561
|
return {
|
|
26378
26562
|
allFiles,
|
|
26379
|
-
|
|
26563
|
+
/** Absolute paths of resolved root files (empty when nothing on disk yet). */
|
|
26564
|
+
declaredRuntimeRoots: runtimeEntries,
|
|
26565
|
+
distFiles: getReachableRuntimeFiles(uniqueFiles(manifestRuntimeEntries.flatMap((entry) => resolveRuntimeEntry(location, entry)), binFiles, scriptEntries.flatMap((entry) => resolveRuntimeEntry(location, entry)), configEntries.flatMap((entry) => resolveRuntimeEntry(location, entry))), shouldIncludeFile),
|
|
26566
|
+
/** Declared entry strings used for progress / trust (may not exist on disk). */
|
|
26380
26567
|
runtimeRoots: runtimeEntries
|
|
26381
26568
|
};
|
|
26382
26569
|
}
|
|
@@ -29278,11 +29465,14 @@ const removeTsconfigPathAliases = (imports, pathPatterns) => {
|
|
|
29278
29465
|
};
|
|
29279
29466
|
const isDeclarationFile$1 = (file) => file.endsWith(".d.ts") || file.endsWith(".d.cts") || file.endsWith(".d.mts");
|
|
29280
29467
|
const toolingConfigFilePattern = /(?:^|[\\/])xy\.config\.[cm]?[jt]sx?$/;
|
|
29468
|
+
/** Test / tooling paths that must not count as production runtime imports. */
|
|
29469
|
+
const nonRuntimeSourceFilePattern = /(?:^|[\\/])(?:spec|__tests?__)(?:[\\/]|$)|(?:^|[\\/])[^\\/]+\.(?:spec|test)\.[cm]?[jt]sx?$/i;
|
|
29281
29470
|
const isToolingConfigFile = (file) => toolingConfigFilePattern.test(file);
|
|
29282
|
-
|
|
29471
|
+
const isNonRuntimeSourceFile = (file) => isToolingConfigFile(file) || nonRuntimeSourceFilePattern.test(file);
|
|
29472
|
+
function excludeNonRuntimeSourceImports(paths) {
|
|
29283
29473
|
const filtered = {};
|
|
29284
29474
|
for (const [imp, files] of Object.entries(paths)) {
|
|
29285
|
-
const kept = files.filter((file) => !
|
|
29475
|
+
const kept = files.filter((file) => !isNonRuntimeSourceFile(file));
|
|
29286
29476
|
if (kept.length > 0) filtered[imp] = kept;
|
|
29287
29477
|
}
|
|
29288
29478
|
return filtered;
|
|
@@ -29332,21 +29522,21 @@ function warnMissingExportTargets(name, location) {
|
|
|
29332
29522
|
function hasShippedTsconfig(location) {
|
|
29333
29523
|
return (readPackageJson$5(location)?.files)?.some((f) => f === "tsconfig.json" || f.includes("tsconfig")) ?? false;
|
|
29334
29524
|
}
|
|
29335
|
-
function getEffectiveRuntimeImportPaths({ distImportPaths, distTypeImportPaths, hasDist,
|
|
29525
|
+
function getEffectiveRuntimeImportPaths({ distImportPaths, distTypeImportPaths, hasDist, srcImportPaths, srcTypeImportPaths, useSourceFallback }) {
|
|
29336
29526
|
if (hasDist) return {
|
|
29337
29527
|
importPaths: distImportPaths,
|
|
29338
29528
|
typeImportPaths: distTypeImportPaths
|
|
29339
29529
|
};
|
|
29340
|
-
if (!
|
|
29530
|
+
if (!useSourceFallback) return {
|
|
29341
29531
|
importPaths: {},
|
|
29342
29532
|
typeImportPaths: {}
|
|
29343
29533
|
};
|
|
29344
29534
|
return {
|
|
29345
|
-
importPaths:
|
|
29346
|
-
typeImportPaths:
|
|
29535
|
+
importPaths: excludeNonRuntimeSourceImports(srcImportPaths),
|
|
29536
|
+
typeImportPaths: excludeNonRuntimeSourceImports(srcTypeImportPaths)
|
|
29347
29537
|
};
|
|
29348
29538
|
}
|
|
29349
|
-
function getExternalImportsFromFiles({ allFiles, distFiles,
|
|
29539
|
+
function getExternalImportsFromFiles({ allFiles, distFiles, location, name, tsconfigExtends = [], tsconfigPaths = [], tsconfigTypes = [], useSourceFallback = true }) {
|
|
29350
29540
|
const srcImportPaths = {};
|
|
29351
29541
|
const srcTypeImportPaths = {};
|
|
29352
29542
|
for (const path of allFiles) {
|
|
@@ -29369,9 +29559,9 @@ function getExternalImportsFromFiles({ allFiles, distFiles, hasRuntimeRoots = tr
|
|
|
29369
29559
|
distImportPaths,
|
|
29370
29560
|
distTypeImportPaths,
|
|
29371
29561
|
hasDist,
|
|
29372
|
-
hasRuntimeRoots,
|
|
29373
29562
|
srcImportPaths,
|
|
29374
|
-
srcTypeImportPaths
|
|
29563
|
+
srcTypeImportPaths,
|
|
29564
|
+
useSourceFallback
|
|
29375
29565
|
});
|
|
29376
29566
|
const allImports = Object.keys(allImportPaths);
|
|
29377
29567
|
const distImports = Object.keys(effectiveDistImportPaths);
|
|
@@ -30862,6 +31052,68 @@ function resolvePeerRangeFormOption(options) {
|
|
|
30862
31052
|
return options.bound === void 0 ? "shorthand" : "broad";
|
|
30863
31053
|
}
|
|
30864
31054
|
//#endregion
|
|
31055
|
+
//#region src/actions/deplint/rulesDeprecatedRefType.ts
|
|
31056
|
+
/**
|
|
31057
|
+
* Convert a raw package entry that still uses deprecated `refType` into the
|
|
31058
|
+
* modern `placement` (+ historical `presence: "allowed"` vouching) shape.
|
|
31059
|
+
*
|
|
31060
|
+
* - `refType` alone → `placement: refType`, `presence: "allowed"` (unless
|
|
31061
|
+
* presence was already explicit)
|
|
31062
|
+
* - `placement` + `refType` → keep placement, drop refType, preserve
|
|
31063
|
+
* vouching by defaulting presence to `"allowed"` when unset (refType used
|
|
31064
|
+
* to imply allowed)
|
|
31065
|
+
* - Always drop `refType`
|
|
31066
|
+
*/
|
|
31067
|
+
function migrateRefTypePackageConfig(config) {
|
|
31068
|
+
if (config.refType === void 0) return void 0;
|
|
31069
|
+
return {
|
|
31070
|
+
placement: config.placement ?? config.refType,
|
|
31071
|
+
presence: config.presence ?? "allowed",
|
|
31072
|
+
...config.peerOptional !== void 0 && { peerOptional: config.peerOptional }
|
|
31073
|
+
};
|
|
31074
|
+
}
|
|
31075
|
+
const deprecatedRefTypeRule = {
|
|
31076
|
+
category: "workspace",
|
|
31077
|
+
id: "dep.package.deprecated-reftype",
|
|
31078
|
+
meta: {
|
|
31079
|
+
description: "Deprecated refType package config should be migrated to placement (+ presence)",
|
|
31080
|
+
fixable: ["config"],
|
|
31081
|
+
severity: "warning"
|
|
31082
|
+
},
|
|
31083
|
+
evaluate(context) {
|
|
31084
|
+
if (context.localConfigPath === void 0 || context.localPackageConfigs.size === 0) return;
|
|
31085
|
+
for (const [dependency, config] of context.localPackageConfigs) {
|
|
31086
|
+
if (config.refType === void 0) continue;
|
|
31087
|
+
const migrated = migrateRefTypePackageConfig(config);
|
|
31088
|
+
if (migrated === void 0) continue;
|
|
31089
|
+
const from = `refType: "${config.refType}"`;
|
|
31090
|
+
const toParts = [`placement: "${migrated.placement}"`, ...migrated.presence === void 0 ? [] : [`presence: "${migrated.presence}"`]];
|
|
31091
|
+
context.report({
|
|
31092
|
+
data: {
|
|
31093
|
+
configPath: context.localConfigPath,
|
|
31094
|
+
dependency,
|
|
31095
|
+
migrated,
|
|
31096
|
+
refType: config.refType
|
|
31097
|
+
},
|
|
31098
|
+
dependency,
|
|
31099
|
+
file: context.localConfigPath,
|
|
31100
|
+
message: `deprecated ${from} for ${dependency} — use ${toParts.join(", ")} instead (run \`xy deplint --fix\` to migrate)`
|
|
31101
|
+
});
|
|
31102
|
+
}
|
|
31103
|
+
},
|
|
31104
|
+
resolveFixes(diagnostic) {
|
|
31105
|
+
const data = diagnostic.data;
|
|
31106
|
+
if (!data) return [];
|
|
31107
|
+
return [{
|
|
31108
|
+
action: "set-package-config",
|
|
31109
|
+
config: data.migrated,
|
|
31110
|
+
configPath: data.configPath,
|
|
31111
|
+
dependency: data.dependency,
|
|
31112
|
+
detail: `migrated refType "${data.refType}" to placement for ${data.dependency}`
|
|
31113
|
+
}];
|
|
31114
|
+
}
|
|
31115
|
+
};
|
|
31116
|
+
//#endregion
|
|
30865
31117
|
//#region src/actions/deplint/rulesDiagnostic.ts
|
|
30866
31118
|
function isRuleFixable(rule) {
|
|
30867
31119
|
return (rule.meta.fixable?.length ?? 0) > 0;
|
|
@@ -30889,7 +31141,7 @@ function resolvePeerDeclaredVersion(context, dep) {
|
|
|
30889
31141
|
return context.packageParams.peerDependencyVersions[dep] ?? (context.workspaceNames?.has(dep) ?? false ? "workspace:~" : "*");
|
|
30890
31142
|
}
|
|
30891
31143
|
function shouldSkipAeiPeerDemotion(context, dep, version) {
|
|
30892
|
-
return context.
|
|
31144
|
+
return !context.facets.hasImportConsumers || !isAeiClassifierMode(context.classifierMode) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep) || dep.startsWith("@types/") || version.startsWith("workspace:");
|
|
30893
31145
|
}
|
|
30894
31146
|
/**
|
|
30895
31147
|
* A peer this package never imports is not a placement candidate — demoting
|
|
@@ -30964,7 +31216,7 @@ const misplacedDependenciesRule = {
|
|
|
30964
31216
|
});
|
|
30965
31217
|
continue;
|
|
30966
31218
|
}
|
|
30967
|
-
if (context.
|
|
31219
|
+
if (!context.facets.hasImportConsumers) continue;
|
|
30968
31220
|
if (context.forceDeps.has(dep)) continue;
|
|
30969
31221
|
if (context.packageParams.dependencyVersions[dep]?.startsWith("workspace:")) continue;
|
|
30970
31222
|
if (context.forcePeerWithDefault.has(dep) || context.classifyDependency(dep) === "peer-with-default") {
|
|
@@ -31094,7 +31346,7 @@ function naturalPlacementForDependency(context, dependency) {
|
|
|
31094
31346
|
if (!isDeclaredDependency(context, dependency)) return void 0;
|
|
31095
31347
|
if (context.workspaceNames?.has(dependency) ?? false) return "dep";
|
|
31096
31348
|
if (context.packageParams.dependencyVersions[dependency]?.startsWith("workspace:")) return "dep";
|
|
31097
|
-
if (context.
|
|
31349
|
+
if (!context.facets.hasImportConsumers) return isDevOnlyDeclaration(context, dependency) ? void 0 : "dep";
|
|
31098
31350
|
if (dependency.startsWith("@types/")) return isDevOnlyDeclaration(context, dependency) ? "dev" : void 0;
|
|
31099
31351
|
if (isDevOnlyDeclaration(context, dependency)) return void 0;
|
|
31100
31352
|
return classificationToPlacement(context.classifyDependency(dependency));
|
|
@@ -31350,8 +31602,9 @@ const unlistedDependenciesRule = {
|
|
|
31350
31602
|
continue;
|
|
31351
31603
|
}
|
|
31352
31604
|
const classification = context.classifyDependency(imp);
|
|
31353
|
-
const
|
|
31354
|
-
const
|
|
31605
|
+
const promotesPeers = context.facets.hasImportConsumers;
|
|
31606
|
+
const isPeerWithDefault = promotesPeers && section === "dependencies" && !context.forceDeps.has(imp) && (context.forcePeerWithDefault.has(imp) || classification === "peer-with-default");
|
|
31607
|
+
const isPeer = promotesPeers && section === "dependencies" && !context.forceDeps.has(imp) && !isPeerWithDefault && classification === "peer";
|
|
31355
31608
|
context.report({
|
|
31356
31609
|
data: {
|
|
31357
31610
|
imp,
|
|
@@ -31389,11 +31642,14 @@ const unusedDependenciesRule = {
|
|
|
31389
31642
|
},
|
|
31390
31643
|
evaluate(context) {
|
|
31391
31644
|
const findings = findUnusedDependencies(context.workspace.location, context.packageParams.dependencies, context.packageParams.devDependencies, context.sourceParams.externalDistImports, context.sourceParams.externalDistTypeImports, context.sourceParams.externalAllImports, context.unusedDependencyExclude);
|
|
31392
|
-
for (const finding of findings)
|
|
31393
|
-
|
|
31394
|
-
|
|
31395
|
-
|
|
31396
|
-
|
|
31645
|
+
for (const finding of findings) {
|
|
31646
|
+
if (finding.kind === "move-to-dev" && !shouldAllowMoveToDev(context.facets, context.hasTrustedRuntimeGraph)) continue;
|
|
31647
|
+
context.report({
|
|
31648
|
+
data: finding,
|
|
31649
|
+
dependency: finding.dep,
|
|
31650
|
+
message: finding.kind === "move-to-dev" ? `dependency should be devDependency in package.json: ${finding.dep}${finding.reason != null && finding.reason.length > 0 ? ` (${finding.reason})` : ""}` : `Unused dependency in package.json: ${finding.dep}`
|
|
31651
|
+
});
|
|
31652
|
+
}
|
|
31397
31653
|
},
|
|
31398
31654
|
resolveFixes(diagnostic) {
|
|
31399
31655
|
const data = diagnostic.data;
|
|
@@ -31471,7 +31727,7 @@ const redundantDevDependenciesRule = {
|
|
|
31471
31727
|
evaluate(context) {
|
|
31472
31728
|
for (const dep of context.packageParams.devDependencies) {
|
|
31473
31729
|
if (!context.packageParams.dependencies.includes(dep)) continue;
|
|
31474
|
-
if (
|
|
31730
|
+
if (context.facets.hasImportConsumers && !context.forceDeps.has(dep) && context.classifyDependency(dep) === "peer") continue;
|
|
31475
31731
|
context.report({
|
|
31476
31732
|
data: { dep },
|
|
31477
31733
|
dependency: dep,
|
|
@@ -31568,7 +31824,7 @@ const unsatisfiedPeersRule = {
|
|
|
31568
31824
|
severity: "error"
|
|
31569
31825
|
},
|
|
31570
31826
|
evaluate(context) {
|
|
31571
|
-
const findings = findUnsatisfiedPeers(context.workspace, context.packageParams, context.exclude, context.
|
|
31827
|
+
const findings = findUnsatisfiedPeers(context.workspace, context.packageParams, context.exclude, !context.facets.hasImportConsumers, context.forcePeerOptional, context.forceDevs, context.peerForwarding);
|
|
31572
31828
|
for (const finding of findings) {
|
|
31573
31829
|
const requiredBy = finding.sources.map((source) => source.requiredBy).join(", ");
|
|
31574
31830
|
const chain = finding.sources.find((source) => (source.chain && source.chain.length > 0) ?? false)?.chain?.join(" -> ");
|
|
@@ -31587,7 +31843,7 @@ const unsatisfiedPeersRule = {
|
|
|
31587
31843
|
if (!finding) return [];
|
|
31588
31844
|
if (finding.reason === "missing") {
|
|
31589
31845
|
const optional = resolvePromotedPeerOptional(context, finding.peer, finding.sources);
|
|
31590
|
-
return resolvePeerTargetSections(finding.hasRuntimeSource, context.
|
|
31846
|
+
return resolvePeerTargetSections(finding.hasRuntimeSource, context.facets.peerTarget).map((section) => ({
|
|
31591
31847
|
action: "add",
|
|
31592
31848
|
dependency: finding.peer,
|
|
31593
31849
|
detail: `added to ${section}`,
|
|
@@ -31649,7 +31905,7 @@ const unrequestedPeerDependenciesRule = {
|
|
|
31649
31905
|
severity: "error"
|
|
31650
31906
|
},
|
|
31651
31907
|
evaluate(context) {
|
|
31652
|
-
if (
|
|
31908
|
+
if (context.facets.hasImportConsumers) return;
|
|
31653
31909
|
const exclude = /* @__PURE__ */ new Set([...context.exclude ?? [], ...context.forcePeers]);
|
|
31654
31910
|
const findings = findUnrequestedPeerDeps(context.workspace.location, context.packageParams, context.sourceParams, true, exclude);
|
|
31655
31911
|
for (const dep of findings) context.report({
|
|
@@ -31819,6 +32075,7 @@ const builtInDeplintPlugin = {
|
|
|
31819
32075
|
rules: [
|
|
31820
32076
|
requiredPackagesRule,
|
|
31821
32077
|
redundantPackagePlacementRule,
|
|
32078
|
+
deprecatedRefTypeRule,
|
|
31822
32079
|
unlistedDependenciesRule,
|
|
31823
32080
|
unusedDependenciesRule,
|
|
31824
32081
|
misplacedDependenciesRule,
|
|
@@ -31831,7 +32088,7 @@ const builtInDeplintPlugin = {
|
|
|
31831
32088
|
severity: "warning"
|
|
31832
32089
|
},
|
|
31833
32090
|
evaluate(context) {
|
|
31834
|
-
if (!isAeiClassifierMode(context.classifierMode) || context.
|
|
32091
|
+
if (!isAeiClassifierMode(context.classifierMode) || !context.facets.hasImportConsumers) return;
|
|
31835
32092
|
const candidates = /* @__PURE__ */ new Set([...context.packageParams.dependencies, ...context.packageParams.peerDependencies]);
|
|
31836
32093
|
for (const dep of candidates) {
|
|
31837
32094
|
if (context.forceDeps.has(dep) || context.forceDevs.has(dep) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep)) continue;
|
|
@@ -31948,38 +32205,52 @@ function resolvePeerForwardingPolicy(classifier, apiExposureConfig, sourceParams
|
|
|
31948
32205
|
mode: forwardingMode
|
|
31949
32206
|
};
|
|
31950
32207
|
}
|
|
32208
|
+
function resolveClassifyOptions(roleOptions, terminalOverride) {
|
|
32209
|
+
if (terminalOverride === void 0 || roleOptions?.terminal !== void 0) return roleOptions ?? {};
|
|
32210
|
+
return {
|
|
32211
|
+
...roleOptions,
|
|
32212
|
+
terminal: terminalOverride
|
|
32213
|
+
};
|
|
32214
|
+
}
|
|
32215
|
+
function recordPhase(phases, key, started) {
|
|
32216
|
+
if (phases !== void 0) phases[key] = performance.now() - started;
|
|
32217
|
+
}
|
|
31951
32218
|
function buildWorkspaceContext(workspace, options = {}) {
|
|
31952
|
-
const { sourceExclude, terminalOverride, phases } = options;
|
|
32219
|
+
const { sourceExclude, terminalOverride, phases, roleOptions } = options;
|
|
32220
|
+
const packageMetaStarted = performance.now();
|
|
32221
|
+
const packageClassification = classifyDeplintPackage(workspace.location, resolveClassifyOptions(roleOptions, terminalOverride));
|
|
32222
|
+
recordPhase(phases, "packageMetaMs", packageMetaStarted);
|
|
31953
32223
|
const findFilesStarted = performance.now();
|
|
31954
|
-
const { allFiles, distFiles, runtimeRoots } = findFiles(workspace.location,
|
|
31955
|
-
|
|
32224
|
+
const { allFiles, distFiles, runtimeRoots } = findFiles(workspace.location, {
|
|
32225
|
+
extraRuntimeRoots: packageClassification.runtimeRoots,
|
|
32226
|
+
runtimeEntry: packageClassification.facets.runtimeEntry,
|
|
32227
|
+
sourceExclude
|
|
32228
|
+
});
|
|
32229
|
+
recordPhase(phases, "findFilesMs", findFilesStarted);
|
|
32230
|
+
const hasTrustedRuntimeGraph = packageClassification.facets.runtimeEntry === "none" || runtimeRoots.length > 0;
|
|
31956
32231
|
const importsStarted = performance.now();
|
|
31957
|
-
const tsconfigExtends = getExtendsFromTsconfigs(workspace.location);
|
|
31958
|
-
const tsconfigPaths = getPathsFromTsconfigs(workspace.location);
|
|
31959
|
-
const tsconfigTypes = getTypesFromTsconfigs(workspace.location);
|
|
31960
32232
|
const sourceParams = getExternalImportsFromFiles({
|
|
31961
32233
|
allFiles,
|
|
31962
32234
|
distFiles,
|
|
31963
32235
|
hasRuntimeRoots: runtimeRoots.length > 0,
|
|
31964
32236
|
location: workspace.location,
|
|
31965
32237
|
name: workspace.name,
|
|
31966
|
-
tsconfigExtends,
|
|
31967
|
-
tsconfigPaths,
|
|
31968
|
-
tsconfigTypes
|
|
32238
|
+
tsconfigExtends: getExtendsFromTsconfigs(workspace.location),
|
|
32239
|
+
tsconfigPaths: getPathsFromTsconfigs(workspace.location),
|
|
32240
|
+
tsconfigTypes: getTypesFromTsconfigs(workspace.location),
|
|
32241
|
+
useSourceFallback: packageClassification.facets.runtimeEntry !== "none"
|
|
31969
32242
|
});
|
|
31970
|
-
|
|
31971
|
-
const packageMetaStarted = performance.now();
|
|
32243
|
+
recordPhase(phases, "importsMs", importsStarted);
|
|
31972
32244
|
const packageJsonPath = `${workspace.location}/package.json`;
|
|
31973
32245
|
const packageParams = getDependenciesFromPackageJson(packageJsonPath);
|
|
31974
32246
|
const peerForwarding = resolvePeerForwardingPolicy(options.classifier, options.apiExposureConfig, sourceParams);
|
|
31975
32247
|
const requiredTransitivePeers = getRequiredNonOptionalTransitivePeers(workspace.location, packageParams);
|
|
31976
32248
|
const runtimeRootedRequired = new Set([...getRuntimeRootedNonOptionalTransitivePeers(workspace.location, packageParams)].filter((peer) => isPeerForwarded(peerForwarding, peer)));
|
|
31977
|
-
const packageClassification = classifyDeplintPackage(workspace.location, terminalOverride);
|
|
31978
|
-
if (phases !== void 0) phases.packageMetaMs = performance.now() - packageMetaStarted;
|
|
31979
32249
|
return {
|
|
31980
32250
|
classifierMode: options.classifier ?? "legacy",
|
|
31981
32251
|
classifyDependency: buildDependencyClassifier(workspace, options, packageClassification.isTerminalPackage, packageParams.peerDependencies, sourceParams.externalDistImports),
|
|
31982
32252
|
exclude: options.exclude,
|
|
32253
|
+
facets: packageClassification.facets,
|
|
31983
32254
|
fileContext: {
|
|
31984
32255
|
allFiles,
|
|
31985
32256
|
distFiles,
|
|
@@ -31990,8 +32261,10 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
31990
32261
|
forcePeerOptional: options.forcePeerOptional ?? /* @__PURE__ */ new Map(),
|
|
31991
32262
|
forcePeerWithDefault: options.forcePeerWithDefault ?? /* @__PURE__ */ new Set(),
|
|
31992
32263
|
forcePeers: options.forcePeers ?? /* @__PURE__ */ new Set(),
|
|
32264
|
+
hasTrustedRuntimeGraph,
|
|
31993
32265
|
isTerminalPackage: packageClassification.isTerminalPackage,
|
|
31994
32266
|
localConfigPath: options.localConfigPath,
|
|
32267
|
+
localPackageConfigs: options.localPackageConfigs ?? /* @__PURE__ */ new Map(),
|
|
31995
32268
|
localPackagePolicies: options.localPackagePolicies ?? /* @__PURE__ */ new Map(),
|
|
31996
32269
|
packageKind: packageClassification.kind,
|
|
31997
32270
|
packageJsonPath,
|
|
@@ -32000,6 +32273,7 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
32000
32273
|
peerRangeBound: options.peerRangeBound,
|
|
32001
32274
|
peerRangeForm: options.peerRangeForm ?? "shorthand",
|
|
32002
32275
|
requiredPackages: options.requiredPackages ?? /* @__PURE__ */ new Map(),
|
|
32276
|
+
role: packageClassification.role,
|
|
32003
32277
|
sourceParams,
|
|
32004
32278
|
sourceExclude: sourceExclude ?? [],
|
|
32005
32279
|
unusedDependencyExclude: buildUnusedDependencyExclude(options, requiredTransitivePeers),
|
|
@@ -32059,7 +32333,8 @@ function buildWorkspaceProgressContext(context) {
|
|
|
32059
32333
|
forcePeers: context.forcePeers.size,
|
|
32060
32334
|
isTerminalPackage: context.isTerminalPackage,
|
|
32061
32335
|
packageKind: context.packageKind,
|
|
32062
|
-
peerDependencies: context.packageParams.peerDependencies.length
|
|
32336
|
+
peerDependencies: context.packageParams.peerDependencies.length,
|
|
32337
|
+
role: context.role
|
|
32063
32338
|
};
|
|
32064
32339
|
}
|
|
32065
32340
|
function normalizeConfigList(values) {
|
|
@@ -32085,7 +32360,8 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
32085
32360
|
const forcePeerOptional = /* @__PURE__ */ new Map();
|
|
32086
32361
|
for (const [name, policy] of packageEntries) if (typeof policy.peerOptional === "boolean") forcePeerOptional.set(name, policy.peerOptional);
|
|
32087
32362
|
const localConfigPath = findXyConfigFile(PATH.isAbsolute(workspace.location) ? workspace.location : PATH.resolve(INIT_CWD(), workspace.location));
|
|
32088
|
-
const
|
|
32363
|
+
const localPackageConfigs = localConfigPath === void 0 ? /* @__PURE__ */ new Map() : readPackagesFromConfigFile(localConfigPath);
|
|
32364
|
+
const localPackagePolicies = localConfigPath === void 0 ? /* @__PURE__ */ new Map() : normalizeDeplintPackagePolicies(Object.fromEntries(localPackageConfigs));
|
|
32089
32365
|
const rangeStyleOptions = rules.find((rule) => rule.id === "dep.peerDependencies.range-style")?.options ?? {};
|
|
32090
32366
|
const peerRangeForm = resolvePeerRangeFormOption(rangeStyleOptions);
|
|
32091
32367
|
const peerRangeBound = resolvePeerRangeBoundOption(rangeStyleOptions);
|
|
@@ -32107,11 +32383,22 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
32107
32383
|
forcePeerWithDefault,
|
|
32108
32384
|
forcePeers,
|
|
32109
32385
|
localConfigPath,
|
|
32386
|
+
localPackageConfigs,
|
|
32110
32387
|
localPackagePolicies,
|
|
32111
32388
|
peerRangeBound,
|
|
32112
32389
|
peerRangeForm,
|
|
32113
32390
|
phases: options.profile === true ? contextPhases : void 0,
|
|
32114
32391
|
requiredPackages,
|
|
32392
|
+
roleOptions: {
|
|
32393
|
+
allowMoveToDev: wsConfig.allowMoveToDev,
|
|
32394
|
+
hasImportConsumers: wsConfig.hasImportConsumers,
|
|
32395
|
+
peerTarget: wsConfig.peerTarget,
|
|
32396
|
+
prodInstallMatters: wsConfig.prodInstallMatters,
|
|
32397
|
+
role: wsConfig.role,
|
|
32398
|
+
runtimeEntry: wsConfig.runtimeEntry,
|
|
32399
|
+
runtimeRoots: wsConfig.runtimeRoots,
|
|
32400
|
+
terminal: wsConfig.terminal
|
|
32401
|
+
},
|
|
32115
32402
|
sourceExclude,
|
|
32116
32403
|
terminalOverride: wsConfig.terminal,
|
|
32117
32404
|
workspaceNames
|
|
@@ -32330,13 +32617,14 @@ var DeplintPackageEditor = class {
|
|
|
32330
32617
|
//#endregion
|
|
32331
32618
|
//#region src/actions/deplint/fixer.ts
|
|
32332
32619
|
function isConfigFix(fix) {
|
|
32333
|
-
return fix.action === "remove-package-config";
|
|
32620
|
+
return fix.action === "remove-package-config" || fix.action === "set-package-config";
|
|
32334
32621
|
}
|
|
32335
32622
|
function listConfigFixEntries(diagnostics) {
|
|
32336
32623
|
return diagnostics.flatMap((diagnostic) => {
|
|
32337
32624
|
return (diagnostic.fixes ?? []).flatMap((fix) => {
|
|
32338
32625
|
if (!isConfigFix(fix)) return [];
|
|
32339
32626
|
return [{
|
|
32627
|
+
config: fix.action === "set-package-config" ? fix.config : void 0,
|
|
32340
32628
|
configPath: fix.configPath,
|
|
32341
32629
|
dependency: fix.dependency,
|
|
32342
32630
|
detail: fix.detail,
|
|
@@ -32356,23 +32644,19 @@ function groupByConfigDir(entries) {
|
|
|
32356
32644
|
return byDir;
|
|
32357
32645
|
}
|
|
32358
32646
|
function applyConfigFixesForDir(dir, entries, cwd) {
|
|
32359
|
-
const
|
|
32360
|
-
|
|
32361
|
-
|
|
32647
|
+
const byDep = /* @__PURE__ */ new Map();
|
|
32648
|
+
for (const entry of entries) byDep.set(entry.dependency, entry);
|
|
32649
|
+
const uniqueEntries = byDep.values().toArray();
|
|
32650
|
+
const written = applyPackageEditsToConfigDir(dir, uniqueEntries.map((entry) => ({
|
|
32651
|
+
config: entry.config,
|
|
32652
|
+
dependency: entry.dependency
|
|
32362
32653
|
})));
|
|
32363
32654
|
if (written === void 0) return [];
|
|
32364
|
-
|
|
32365
|
-
|
|
32366
|
-
|
|
32367
|
-
|
|
32368
|
-
|
|
32369
|
-
applied.push({
|
|
32370
|
-
dependency: entry.dependency,
|
|
32371
|
-
detail: `${entry.detail} (${PATH.relative(cwd, written) || PATH.basename(written)})`,
|
|
32372
|
-
workspace: entry.workspace
|
|
32373
|
-
});
|
|
32374
|
-
}
|
|
32375
|
-
return applied;
|
|
32655
|
+
return uniqueEntries.map((entry) => ({
|
|
32656
|
+
dependency: entry.dependency,
|
|
32657
|
+
detail: `${entry.detail} (${PATH.relative(cwd, written) || PATH.basename(written)})`,
|
|
32658
|
+
workspace: entry.workspace
|
|
32659
|
+
}));
|
|
32376
32660
|
}
|
|
32377
32661
|
function applyConfigFixes(diagnostics) {
|
|
32378
32662
|
const cwd = INIT_CWD();
|