@ariestools/toolchain 8.7.25 → 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/bin/xy.mjs CHANGED
@@ -20839,7 +20839,7 @@ const LOCAL_PROTOCOLS = [
20839
20839
  "link:",
20840
20840
  "portal:"
20841
20841
  ];
20842
- function readPackageJson$9(filePath) {
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$9(PATH.resolve(cwd, "package.json"))?.name;
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$9(PATH.resolve(cwd, target.location, "package.json"));
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
- return pkg.main !== void 0 || pkg.module !== void 0 || !isCliOnlyExports(pkg.exports);
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 ?? {})];
23437
+ }
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;
23363
23503
  }
23364
- function withTerminalOverride(classification, isTerminalOverride) {
23365
- if (isTerminalOverride === void 0) return classification;
23366
- if (isTerminalOverride) return {
23367
- isTerminalPackage: true,
23368
- kind: classification.kind === "terminal[private]" ? "terminal[private]" : "terminal[cli]"
23504
+ function mergeOptions(embedded, options) {
23505
+ return {
23506
+ ...embedded,
23507
+ ...definedEntries(options)
23369
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
23537
+ };
23538
+ }
23539
+ function buildClassification(role, facets, runtimeRoots) {
23370
23540
  return {
23371
- isTerminalPackage: false,
23372
- kind: classification.kind === "library/cli" || classification.kind === "terminal[cli]" ? "library/cli" : "library"
23541
+ facets,
23542
+ isTerminalPackage: !facets.hasImportConsumers,
23543
+ kind: role,
23544
+ role,
23545
+ runtimeRoots
23373
23546
  };
23374
23547
  }
23375
23548
  /**
23376
- * Classifies a package by the dependency behavior deplint should apply and the
23377
- * label shown in progress output.
23549
+ * Classifies a package by role and policy facets for deplint.
23378
23550
  *
23379
- * Terminal packages have unsatisfied runtime peers added to `dependencies`;
23380
- * libraries get them in `peerDependencies` so consumers inherit the
23381
- * requirement.
23382
- *
23383
- * Labels:
23384
- * - `terminal[private]`: `private: true`, usually unpublished apps/services.
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, isTerminalOverride) {
23390
- try {
23391
- const pkg = JSON.parse(fs.readFileSync(`${location}/package.json`, "utf8"));
23392
- if (pkg.private === true) return withTerminalOverride({
23393
- isTerminalPackage: true,
23394
- kind: "terminal[private]"
23395
- }, isTerminalOverride);
23396
- if (pkg.xy?.commands?.deplint?.terminal === true) return withTerminalOverride({
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
- * For terminal packages (apps): runtime peers → dependencies, dev-only → devDependencies.
23707
- * For library packages: runtime peers → peerDependencies + devDependencies (peer passes
23708
- * the requirement to consumers, devDep satisfies it for the library's own development).
23709
- * Dev-only peers → devDependencies only.
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, isTerminal) {
23868
+ function resolvePeerTargetSections(hasRuntimeSource, peerTargetOrIsTerminal) {
23712
23869
  if (!hasRuntimeSource) return ["devDependencies"];
23713
- if (isTerminal) return ["dependencies"];
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 findFiles(location, sourceExclude) {
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 manifestRuntimeEntries = getManifestRuntimeEntries(pkg);
26375
- const runtimeEntries = [...new Set([...manifestRuntimeEntries, ...getBinEntries(pkg)].filter(canResolveToCode))];
26376
- const binFiles = getBinFiles(location, pkg);
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
- distFiles: getReachableRuntimeFiles(uniqueFiles(manifestRuntimeEntries.flatMap((entry) => resolveRuntimeEntry(location, entry)), binFiles), shouldIncludeFile),
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
- function excludeToolingConfigImports(paths) {
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) => !isToolingConfigFile(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,17 +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, srcImportPaths, srcTypeImportPaths }) {
29525
+ function getEffectiveRuntimeImportPaths({ distImportPaths, distTypeImportPaths, hasDist, srcImportPaths, srcTypeImportPaths, useSourceFallback }) {
29336
29526
  if (hasDist) return {
29337
29527
  importPaths: distImportPaths,
29338
29528
  typeImportPaths: distTypeImportPaths
29339
29529
  };
29530
+ if (!useSourceFallback) return {
29531
+ importPaths: {},
29532
+ typeImportPaths: {}
29533
+ };
29340
29534
  return {
29341
- importPaths: excludeToolingConfigImports(srcImportPaths),
29342
- typeImportPaths: excludeToolingConfigImports(srcTypeImportPaths)
29535
+ importPaths: excludeNonRuntimeSourceImports(srcImportPaths),
29536
+ typeImportPaths: excludeNonRuntimeSourceImports(srcTypeImportPaths)
29343
29537
  };
29344
29538
  }
29345
- function getExternalImportsFromFiles({ allFiles, distFiles, location, name, tsconfigExtends = [], tsconfigPaths = [], tsconfigTypes = [] }) {
29539
+ function getExternalImportsFromFiles({ allFiles, distFiles, location, name, tsconfigExtends = [], tsconfigPaths = [], tsconfigTypes = [], useSourceFallback = true }) {
29346
29540
  const srcImportPaths = {};
29347
29541
  const srcTypeImportPaths = {};
29348
29542
  for (const path of allFiles) {
@@ -29366,7 +29560,8 @@ function getExternalImportsFromFiles({ allFiles, distFiles, location, name, tsco
29366
29560
  distTypeImportPaths,
29367
29561
  hasDist,
29368
29562
  srcImportPaths,
29369
- srcTypeImportPaths
29563
+ srcTypeImportPaths,
29564
+ useSourceFallback
29370
29565
  });
29371
29566
  const allImports = Object.keys(allImportPaths);
29372
29567
  const distImports = Object.keys(effectiveDistImportPaths);
@@ -30946,7 +31141,7 @@ function resolvePeerDeclaredVersion(context, dep) {
30946
31141
  return context.packageParams.peerDependencyVersions[dep] ?? (context.workspaceNames?.has(dep) ?? false ? "workspace:~" : "*");
30947
31142
  }
30948
31143
  function shouldSkipAeiPeerDemotion(context, dep, version) {
30949
- return context.isTerminalPackage || !isAeiClassifierMode(context.classifierMode) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep) || dep.startsWith("@types/") || version.startsWith("workspace:");
31144
+ return !context.facets.hasImportConsumers || !isAeiClassifierMode(context.classifierMode) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep) || dep.startsWith("@types/") || version.startsWith("workspace:");
30950
31145
  }
30951
31146
  /**
30952
31147
  * A peer this package never imports is not a placement candidate — demoting
@@ -31021,7 +31216,7 @@ const misplacedDependenciesRule = {
31021
31216
  });
31022
31217
  continue;
31023
31218
  }
31024
- if (context.isTerminalPackage) continue;
31219
+ if (!context.facets.hasImportConsumers) continue;
31025
31220
  if (context.forceDeps.has(dep)) continue;
31026
31221
  if (context.packageParams.dependencyVersions[dep]?.startsWith("workspace:")) continue;
31027
31222
  if (context.forcePeerWithDefault.has(dep) || context.classifyDependency(dep) === "peer-with-default") {
@@ -31151,7 +31346,7 @@ function naturalPlacementForDependency(context, dependency) {
31151
31346
  if (!isDeclaredDependency(context, dependency)) return void 0;
31152
31347
  if (context.workspaceNames?.has(dependency) ?? false) return "dep";
31153
31348
  if (context.packageParams.dependencyVersions[dependency]?.startsWith("workspace:")) return "dep";
31154
- if (context.isTerminalPackage) return isDevOnlyDeclaration(context, dependency) ? void 0 : "dep";
31349
+ if (!context.facets.hasImportConsumers) return isDevOnlyDeclaration(context, dependency) ? void 0 : "dep";
31155
31350
  if (dependency.startsWith("@types/")) return isDevOnlyDeclaration(context, dependency) ? "dev" : void 0;
31156
31351
  if (isDevOnlyDeclaration(context, dependency)) return void 0;
31157
31352
  return classificationToPlacement(context.classifyDependency(dependency));
@@ -31407,8 +31602,9 @@ const unlistedDependenciesRule = {
31407
31602
  continue;
31408
31603
  }
31409
31604
  const classification = context.classifyDependency(imp);
31410
- const isPeerWithDefault = !context.isTerminalPackage && section === "dependencies" && !context.forceDeps.has(imp) && (context.forcePeerWithDefault.has(imp) || classification === "peer-with-default");
31411
- const isPeer = !context.isTerminalPackage && section === "dependencies" && !context.forceDeps.has(imp) && !isPeerWithDefault && classification === "peer";
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";
31412
31608
  context.report({
31413
31609
  data: {
31414
31610
  imp,
@@ -31447,7 +31643,7 @@ const unusedDependenciesRule = {
31447
31643
  evaluate(context) {
31448
31644
  const findings = findUnusedDependencies(context.workspace.location, context.packageParams.dependencies, context.packageParams.devDependencies, context.sourceParams.externalDistImports, context.sourceParams.externalDistTypeImports, context.sourceParams.externalAllImports, context.unusedDependencyExclude);
31449
31645
  for (const finding of findings) {
31450
- if (context.isTerminalPackage && finding.kind === "move-to-dev") continue;
31646
+ if (finding.kind === "move-to-dev" && !shouldAllowMoveToDev(context.facets, context.hasTrustedRuntimeGraph)) continue;
31451
31647
  context.report({
31452
31648
  data: finding,
31453
31649
  dependency: finding.dep,
@@ -31531,7 +31727,7 @@ const redundantDevDependenciesRule = {
31531
31727
  evaluate(context) {
31532
31728
  for (const dep of context.packageParams.devDependencies) {
31533
31729
  if (!context.packageParams.dependencies.includes(dep)) continue;
31534
- if (!context.isTerminalPackage && !context.forceDeps.has(dep) && context.classifyDependency(dep) === "peer") continue;
31730
+ if (context.facets.hasImportConsumers && !context.forceDeps.has(dep) && context.classifyDependency(dep) === "peer") continue;
31535
31731
  context.report({
31536
31732
  data: { dep },
31537
31733
  dependency: dep,
@@ -31628,7 +31824,7 @@ const unsatisfiedPeersRule = {
31628
31824
  severity: "error"
31629
31825
  },
31630
31826
  evaluate(context) {
31631
- const findings = findUnsatisfiedPeers(context.workspace, context.packageParams, context.exclude, context.isTerminalPackage, context.forcePeerOptional, context.forceDevs, context.peerForwarding);
31827
+ const findings = findUnsatisfiedPeers(context.workspace, context.packageParams, context.exclude, !context.facets.hasImportConsumers, context.forcePeerOptional, context.forceDevs, context.peerForwarding);
31632
31828
  for (const finding of findings) {
31633
31829
  const requiredBy = finding.sources.map((source) => source.requiredBy).join(", ");
31634
31830
  const chain = finding.sources.find((source) => (source.chain && source.chain.length > 0) ?? false)?.chain?.join(" -> ");
@@ -31647,7 +31843,7 @@ const unsatisfiedPeersRule = {
31647
31843
  if (!finding) return [];
31648
31844
  if (finding.reason === "missing") {
31649
31845
  const optional = resolvePromotedPeerOptional(context, finding.peer, finding.sources);
31650
- return resolvePeerTargetSections(finding.hasRuntimeSource, context.isTerminalPackage).map((section) => ({
31846
+ return resolvePeerTargetSections(finding.hasRuntimeSource, context.facets.peerTarget).map((section) => ({
31651
31847
  action: "add",
31652
31848
  dependency: finding.peer,
31653
31849
  detail: `added to ${section}`,
@@ -31709,7 +31905,7 @@ const unrequestedPeerDependenciesRule = {
31709
31905
  severity: "error"
31710
31906
  },
31711
31907
  evaluate(context) {
31712
- if (!context.isTerminalPackage) return;
31908
+ if (context.facets.hasImportConsumers) return;
31713
31909
  const exclude = /* @__PURE__ */ new Set([...context.exclude ?? [], ...context.forcePeers]);
31714
31910
  const findings = findUnrequestedPeerDeps(context.workspace.location, context.packageParams, context.sourceParams, true, exclude);
31715
31911
  for (const dep of findings) context.report({
@@ -31892,7 +32088,7 @@ const builtInDeplintPlugin = {
31892
32088
  severity: "warning"
31893
32089
  },
31894
32090
  evaluate(context) {
31895
- if (!isAeiClassifierMode(context.classifierMode) || context.isTerminalPackage) return;
32091
+ if (!isAeiClassifierMode(context.classifierMode) || !context.facets.hasImportConsumers) return;
31896
32092
  const candidates = /* @__PURE__ */ new Set([...context.packageParams.dependencies, ...context.packageParams.peerDependencies]);
31897
32093
  for (const dep of candidates) {
31898
32094
  if (context.forceDeps.has(dep) || context.forceDevs.has(dep) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep)) continue;
@@ -32009,38 +32205,52 @@ function resolvePeerForwardingPolicy(classifier, apiExposureConfig, sourceParams
32009
32205
  mode: forwardingMode
32010
32206
  };
32011
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
+ }
32012
32218
  function buildWorkspaceContext(workspace, options = {}) {
32013
- 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);
32014
32223
  const findFilesStarted = performance.now();
32015
- const { allFiles, distFiles, runtimeRoots } = findFiles(workspace.location, sourceExclude);
32016
- if (phases !== void 0) phases.findFilesMs = performance.now() - findFilesStarted;
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;
32017
32231
  const importsStarted = performance.now();
32018
- const tsconfigExtends = getExtendsFromTsconfigs(workspace.location);
32019
- const tsconfigPaths = getPathsFromTsconfigs(workspace.location);
32020
- const tsconfigTypes = getTypesFromTsconfigs(workspace.location);
32021
32232
  const sourceParams = getExternalImportsFromFiles({
32022
32233
  allFiles,
32023
32234
  distFiles,
32024
32235
  hasRuntimeRoots: runtimeRoots.length > 0,
32025
32236
  location: workspace.location,
32026
32237
  name: workspace.name,
32027
- tsconfigExtends,
32028
- tsconfigPaths,
32029
- tsconfigTypes
32238
+ tsconfigExtends: getExtendsFromTsconfigs(workspace.location),
32239
+ tsconfigPaths: getPathsFromTsconfigs(workspace.location),
32240
+ tsconfigTypes: getTypesFromTsconfigs(workspace.location),
32241
+ useSourceFallback: packageClassification.facets.runtimeEntry !== "none"
32030
32242
  });
32031
- if (phases !== void 0) phases.importsMs = performance.now() - importsStarted;
32032
- const packageMetaStarted = performance.now();
32243
+ recordPhase(phases, "importsMs", importsStarted);
32033
32244
  const packageJsonPath = `${workspace.location}/package.json`;
32034
32245
  const packageParams = getDependenciesFromPackageJson(packageJsonPath);
32035
32246
  const peerForwarding = resolvePeerForwardingPolicy(options.classifier, options.apiExposureConfig, sourceParams);
32036
32247
  const requiredTransitivePeers = getRequiredNonOptionalTransitivePeers(workspace.location, packageParams);
32037
32248
  const runtimeRootedRequired = new Set([...getRuntimeRootedNonOptionalTransitivePeers(workspace.location, packageParams)].filter((peer) => isPeerForwarded(peerForwarding, peer)));
32038
- const packageClassification = classifyDeplintPackage(workspace.location, terminalOverride);
32039
- if (phases !== void 0) phases.packageMetaMs = performance.now() - packageMetaStarted;
32040
32249
  return {
32041
32250
  classifierMode: options.classifier ?? "legacy",
32042
32251
  classifyDependency: buildDependencyClassifier(workspace, options, packageClassification.isTerminalPackage, packageParams.peerDependencies, sourceParams.externalDistImports),
32043
32252
  exclude: options.exclude,
32253
+ facets: packageClassification.facets,
32044
32254
  fileContext: {
32045
32255
  allFiles,
32046
32256
  distFiles,
@@ -32051,6 +32261,7 @@ function buildWorkspaceContext(workspace, options = {}) {
32051
32261
  forcePeerOptional: options.forcePeerOptional ?? /* @__PURE__ */ new Map(),
32052
32262
  forcePeerWithDefault: options.forcePeerWithDefault ?? /* @__PURE__ */ new Set(),
32053
32263
  forcePeers: options.forcePeers ?? /* @__PURE__ */ new Set(),
32264
+ hasTrustedRuntimeGraph,
32054
32265
  isTerminalPackage: packageClassification.isTerminalPackage,
32055
32266
  localConfigPath: options.localConfigPath,
32056
32267
  localPackageConfigs: options.localPackageConfigs ?? /* @__PURE__ */ new Map(),
@@ -32062,6 +32273,7 @@ function buildWorkspaceContext(workspace, options = {}) {
32062
32273
  peerRangeBound: options.peerRangeBound,
32063
32274
  peerRangeForm: options.peerRangeForm ?? "shorthand",
32064
32275
  requiredPackages: options.requiredPackages ?? /* @__PURE__ */ new Map(),
32276
+ role: packageClassification.role,
32065
32277
  sourceParams,
32066
32278
  sourceExclude: sourceExclude ?? [],
32067
32279
  unusedDependencyExclude: buildUnusedDependencyExclude(options, requiredTransitivePeers),
@@ -32121,7 +32333,8 @@ function buildWorkspaceProgressContext(context) {
32121
32333
  forcePeers: context.forcePeers.size,
32122
32334
  isTerminalPackage: context.isTerminalPackage,
32123
32335
  packageKind: context.packageKind,
32124
- peerDependencies: context.packageParams.peerDependencies.length
32336
+ peerDependencies: context.packageParams.peerDependencies.length,
32337
+ role: context.role
32125
32338
  };
32126
32339
  }
32127
32340
  function normalizeConfigList(values) {
@@ -32176,6 +32389,16 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
32176
32389
  peerRangeForm,
32177
32390
  phases: options.profile === true ? contextPhases : void 0,
32178
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
+ },
32179
32402
  sourceExclude,
32180
32403
  terminalOverride: wsConfig.terminal,
32181
32404
  workspaceNames