@ariestools/toolchain 8.7.9 → 8.7.11
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/api-exposure/analyzer/analyzePackage.d.ts.map +1 -1
- package/dist/actions/api-exposure/apiExposure.d.ts.map +1 -1
- package/dist/actions/api-exposure/config.d.ts +7 -2
- package/dist/actions/api-exposure/config.d.ts.map +1 -1
- package/dist/actions/api-exposure/index.d.ts +1 -0
- package/dist/actions/api-exposure/index.d.ts.map +1 -1
- package/dist/actions/api-exposure/installStrategy.d.ts +74 -0
- package/dist/actions/api-exposure/installStrategy.d.ts.map +1 -0
- package/dist/actions/api-exposure/reporters.d.ts +2 -1
- package/dist/actions/api-exposure/reporters.d.ts.map +1 -1
- package/dist/actions/api-exposure/scoring.d.ts +4 -4
- package/dist/actions/api-exposure/scoring.d.ts.map +1 -1
- package/dist/actions/api-exposure/types.d.ts +32 -6
- package/dist/actions/api-exposure/types.d.ts.map +1 -1
- package/dist/actions/deplint/deplint.d.ts +1 -1
- package/dist/actions/deplint/deplint.d.ts.map +1 -1
- package/dist/actions/deplint/engine.d.ts.map +1 -1
- package/dist/actions/deplint/rules.d.ts.map +1 -1
- package/dist/actions/deplint/rulesMisplaced.d.ts.map +1 -1
- package/dist/actions/deplint/snapshot.d.ts +4 -3
- package/dist/actions/deplint/snapshot.d.ts.map +1 -1
- package/dist/actions/deplint/types.d.ts +14 -3
- package/dist/actions/deplint/types.d.ts.map +1 -1
- package/dist/actions/package/compile/ApiExposureConfig.d.ts +11 -2
- package/dist/actions/package/compile/ApiExposureConfig.d.ts.map +1 -1
- package/dist/actions/package/compile/XyConfig.d.ts +9 -2
- package/dist/actions/package/compile/XyConfig.d.ts.map +1 -1
- package/dist/bin/skills.mjs +24 -16
- package/dist/bin/skills.mjs.map +1 -1
- package/dist/bin/xy.mjs +365 -85
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/lib/shouldRunInstall.d.ts.map +1 -1
- package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/bin/xy.mjs
CHANGED
|
@@ -20982,7 +20982,11 @@ function shouldRunInstall(cwd) {
|
|
|
20982
20982
|
},
|
|
20983
20983
|
cwd,
|
|
20984
20984
|
encoding: "utf8",
|
|
20985
|
-
stdio:
|
|
20985
|
+
stdio: isJsonMode() ? [
|
|
20986
|
+
"inherit",
|
|
20987
|
+
2,
|
|
20988
|
+
2
|
|
20989
|
+
] : "inherit"
|
|
20986
20990
|
}).status !== 0) {
|
|
20987
20991
|
console.warn(chalk.yellow(`${pm} install failed`));
|
|
20988
20992
|
return false;
|
|
@@ -23618,6 +23622,12 @@ function getAeiRule(id) {
|
|
|
23618
23622
|
}
|
|
23619
23623
|
//#endregion
|
|
23620
23624
|
//#region src/actions/api-exposure/config.ts
|
|
23625
|
+
const CLASSIFICATIONS = /* @__PURE__ */ new Set([
|
|
23626
|
+
"dep",
|
|
23627
|
+
"dev",
|
|
23628
|
+
"peer",
|
|
23629
|
+
"peer-with-default"
|
|
23630
|
+
]);
|
|
23621
23631
|
const DEFAULT_AEI_THRESHOLDS = {
|
|
23622
23632
|
dependencyMax: 39,
|
|
23623
23633
|
probablyDependencyMax: 79,
|
|
@@ -23726,23 +23736,17 @@ function resolvePeerForwarding(peerForwarding = "when-exposed") {
|
|
|
23726
23736
|
if (peerForwarding !== "always" && peerForwarding !== "when-used" && peerForwarding !== "when-exposed") throw new TypeError("commands.apiExposure.peerForwarding must be \"always\", \"when-used\", or \"when-exposed\"");
|
|
23727
23737
|
return peerForwarding;
|
|
23728
23738
|
}
|
|
23729
|
-
function
|
|
23730
|
-
const globalRuleSettings = config?.rules ?? {};
|
|
23731
|
-
validateRuleIds("commands.apiExposure.rules", globalRuleSettings);
|
|
23732
|
-
const packages = config?.packages ?? {};
|
|
23739
|
+
function validatePackageOverrides(packages) {
|
|
23733
23740
|
for (const [pattern, override] of Object.entries(packages)) {
|
|
23734
23741
|
if (typeof override !== "object" || override === null || Array.isArray(override)) throw new TypeError(`commands.apiExposure.packages["${pattern}"] must be an object`);
|
|
23735
|
-
if (override.classification !== void 0 && ![
|
|
23736
|
-
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
].includes(override.classification)) throw new TypeError(`commands.apiExposure.packages["${pattern}"].classification must be "dep", "dev", or "peer"`);
|
|
23740
|
-
if (override.rules !== void 0) {
|
|
23741
|
-
validateRuleIds(`commands.apiExposure.packages["${pattern}"].rules`, override.rules);
|
|
23742
|
-
for (const [ruleId, setting] of Object.entries(override.rules)) parseRuleSetting(`commands.apiExposure.packages["${pattern}"].rules["${ruleId}"]`, setting);
|
|
23743
|
-
}
|
|
23742
|
+
if (override.classification !== void 0 && !CLASSIFICATIONS.has(override.classification)) throw new TypeError(`commands.apiExposure.packages["${pattern}"].classification must be "dep", "dev", "peer", or "peer-with-default"`);
|
|
23743
|
+
if (override.rules === void 0) continue;
|
|
23744
|
+
validateRuleIds(`commands.apiExposure.packages["${pattern}"].rules`, override.rules);
|
|
23745
|
+
for (const [ruleId, setting] of Object.entries(override.rules)) parseRuleSetting(`commands.apiExposure.packages["${pattern}"].rules["${ruleId}"]`, setting);
|
|
23744
23746
|
}
|
|
23745
|
-
|
|
23747
|
+
}
|
|
23748
|
+
function resolveGlobalRules(globalRuleSettings) {
|
|
23749
|
+
return AEI_RULES.map((definition) => {
|
|
23746
23750
|
const base = {
|
|
23747
23751
|
...definition,
|
|
23748
23752
|
enabled: definition.defaultEnabled ?? true,
|
|
@@ -23753,8 +23757,9 @@ function normalizeApiExposureConfig(config) {
|
|
|
23753
23757
|
if (setting === void 0) return base;
|
|
23754
23758
|
return applySetting(base, parseRuleSetting(`commands.apiExposure.rules["${definition.id}"]`, setting));
|
|
23755
23759
|
});
|
|
23756
|
-
|
|
23757
|
-
|
|
23760
|
+
}
|
|
23761
|
+
function buildRuleFor(packages, globalRulesById) {
|
|
23762
|
+
return (ruleId, dependency) => {
|
|
23758
23763
|
const globalRule = globalRulesById.get(ruleId);
|
|
23759
23764
|
if (globalRule === void 0 || dependency === void 0) return globalRule;
|
|
23760
23765
|
let resolved = globalRule;
|
|
@@ -23764,15 +23769,31 @@ function normalizeApiExposureConfig(config) {
|
|
|
23764
23769
|
}
|
|
23765
23770
|
return resolved;
|
|
23766
23771
|
};
|
|
23767
|
-
|
|
23772
|
+
}
|
|
23773
|
+
function buildClassificationFor(packages) {
|
|
23774
|
+
return (dependency) => {
|
|
23768
23775
|
let classification;
|
|
23769
23776
|
for (const { override } of matchingOverrides(packages, dependency)) classification = override.classification ?? classification;
|
|
23770
23777
|
return classification;
|
|
23771
23778
|
};
|
|
23779
|
+
}
|
|
23780
|
+
function resolvePeerWithDefault(value) {
|
|
23781
|
+
if (value === void 0) return false;
|
|
23782
|
+
if (typeof value !== "boolean") throw new TypeError("commands.apiExposure.peerWithDefault must be a boolean");
|
|
23783
|
+
return value;
|
|
23784
|
+
}
|
|
23785
|
+
function normalizeApiExposureConfig(config) {
|
|
23786
|
+
const globalRuleSettings = config?.rules ?? {};
|
|
23787
|
+
validateRuleIds("commands.apiExposure.rules", globalRuleSettings);
|
|
23788
|
+
const packages = config?.packages ?? {};
|
|
23789
|
+
validatePackageOverrides(packages);
|
|
23790
|
+
const globalRules = resolveGlobalRules(globalRuleSettings);
|
|
23791
|
+
const globalRulesById = new Map(globalRules.map((rule) => [rule.id, rule]));
|
|
23772
23792
|
return {
|
|
23773
|
-
classificationFor,
|
|
23793
|
+
classificationFor: buildClassificationFor(packages),
|
|
23774
23794
|
peerForwarding: resolvePeerForwarding(config?.peerForwarding),
|
|
23775
|
-
|
|
23795
|
+
peerWithDefault: resolvePeerWithDefault(config?.peerWithDefault),
|
|
23796
|
+
ruleFor: buildRuleFor(packages, globalRulesById),
|
|
23776
23797
|
rules: globalRules,
|
|
23777
23798
|
thresholds: resolveThresholds(config?.thresholds),
|
|
23778
23799
|
treeShaking: config?.treeShaking ?? true
|
|
@@ -23799,15 +23820,155 @@ function resolveFindings(raw, config) {
|
|
|
23799
23820
|
return findings;
|
|
23800
23821
|
}
|
|
23801
23822
|
//#endregion
|
|
23823
|
+
//#region src/actions/api-exposure/installStrategy.ts
|
|
23824
|
+
/**
|
|
23825
|
+
* Infinite exposure rules that put the dependency on the package's public
|
|
23826
|
+
* identity surface (re-export, subclass, owned export). v1 peer-with-default
|
|
23827
|
+
* requires at least one of these (API-EXPOSURE-INDEX.md §12).
|
|
23828
|
+
*/
|
|
23829
|
+
const IDENTITY_SURFACE_RULE_IDS = /* @__PURE__ */ new Set([
|
|
23830
|
+
"aei.exposure.class-extends",
|
|
23831
|
+
"aei.exposure.exported-owned-value",
|
|
23832
|
+
"aei.exposure.named-reexport",
|
|
23833
|
+
"aei.exposure.star-reexport"
|
|
23834
|
+
]);
|
|
23835
|
+
/**
|
|
23836
|
+
* Coupling / host-context findings that veto shipping a default install —
|
|
23837
|
+
* nested copies break shared registries, globals, or React contexts.
|
|
23838
|
+
*/
|
|
23839
|
+
const HOST_CONTEXT_RULE_IDS = /* @__PURE__ */ new Set([
|
|
23840
|
+
"aei.coupling.global-state",
|
|
23841
|
+
"aei.coupling.shared-registry",
|
|
23842
|
+
"aei.signal.creates-context"
|
|
23843
|
+
]);
|
|
23844
|
+
/**
|
|
23845
|
+
* Framework / plugin-host packages that must never receive a default
|
|
23846
|
+
* install via `peer-with-default` (even when always imported).
|
|
23847
|
+
*/
|
|
23848
|
+
const DEFAULT_HOST_FRAMEWORK_PACKAGES = /* @__PURE__ */ new Set([
|
|
23849
|
+
"@angular/core",
|
|
23850
|
+
"@angular/common",
|
|
23851
|
+
"@storybook/react",
|
|
23852
|
+
"@vue/runtime-core",
|
|
23853
|
+
"astro",
|
|
23854
|
+
"eslint",
|
|
23855
|
+
"jasmine",
|
|
23856
|
+
"jest",
|
|
23857
|
+
"mocha",
|
|
23858
|
+
"next",
|
|
23859
|
+
"nuxt",
|
|
23860
|
+
"preact",
|
|
23861
|
+
"prettier",
|
|
23862
|
+
"react",
|
|
23863
|
+
"react-dom",
|
|
23864
|
+
"react-native",
|
|
23865
|
+
"rollup",
|
|
23866
|
+
"solid-js",
|
|
23867
|
+
"svelte",
|
|
23868
|
+
"typescript",
|
|
23869
|
+
"vite",
|
|
23870
|
+
"vitest",
|
|
23871
|
+
"vue",
|
|
23872
|
+
"webpack",
|
|
23873
|
+
"zone.js"
|
|
23874
|
+
]);
|
|
23875
|
+
/**
|
|
23876
|
+
* Whether the package has a static value import of the dependency
|
|
23877
|
+
* (runtime-required signal). When import scanning is unavailable, returns
|
|
23878
|
+
* false so promotion stays conservative.
|
|
23879
|
+
*/
|
|
23880
|
+
function hasRuntimeValueImport(dependency, importedPackages) {
|
|
23881
|
+
return importedPackages?.value.has(dependency) ?? false;
|
|
23882
|
+
}
|
|
23883
|
+
function hasIdentitySurface(findings) {
|
|
23884
|
+
return findings.some((finding) => finding.infinite && IDENTITY_SURFACE_RULE_IDS.has(finding.ruleId));
|
|
23885
|
+
}
|
|
23886
|
+
function hasHostContextVeto(findings) {
|
|
23887
|
+
return findings.some((finding) => HOST_CONTEXT_RULE_IDS.has(finding.ruleId));
|
|
23888
|
+
}
|
|
23889
|
+
/**
|
|
23890
|
+
* True when the only conclusive peer reason is a forwarded chain contract
|
|
23891
|
+
* with no local identity surface — not a candidate for shipping a default.
|
|
23892
|
+
*/
|
|
23893
|
+
function isChainForwardOnly(findings) {
|
|
23894
|
+
const infinite = findings.filter((finding) => finding.infinite);
|
|
23895
|
+
if (infinite.length === 0) return false;
|
|
23896
|
+
if (hasIdentitySurface(findings)) return false;
|
|
23897
|
+
return infinite.every((finding) => finding.ruleId === "aei.signal.required-peer");
|
|
23898
|
+
}
|
|
23899
|
+
/**
|
|
23900
|
+
* Resolves how a peer-leaning dependency should be installed (spec §12).
|
|
23901
|
+
* Only meaningful when the base score recommendation is `peer`.
|
|
23902
|
+
*
|
|
23903
|
+
* - `none` — optional / feature-gated peer (no default, often optional meta)
|
|
23904
|
+
* - `dev` — peer + local dev companion (current library default)
|
|
23905
|
+
* - `default` — peer + dependencies (`peer-with-default`)
|
|
23906
|
+
*/
|
|
23907
|
+
function resolveInstallStrategy({ dependency, findings, hostPackages = DEFAULT_HOST_FRAMEWORK_PACKAGES, importedPackages, optionalPeer }) {
|
|
23908
|
+
if (optionalPeer) return "none";
|
|
23909
|
+
if (hostPackages.has(dependency) || dependency.startsWith("@angular/") || dependency.startsWith("@vue/")) return "dev";
|
|
23910
|
+
if (hasHostContextVeto(findings)) return "dev";
|
|
23911
|
+
if (isChainForwardOnly(findings)) return "dev";
|
|
23912
|
+
if (!hasRuntimeValueImport(dependency, importedPackages)) return "dev";
|
|
23913
|
+
if (!hasIdentitySurface(findings)) return "dev";
|
|
23914
|
+
return "default";
|
|
23915
|
+
}
|
|
23916
|
+
/**
|
|
23917
|
+
* Promotes a definitive `peer` recommendation to `peer-with-default` when
|
|
23918
|
+
* install strategy is `default`. No-op when peer-with-default is disabled
|
|
23919
|
+
* or the base band is not definitive `peer`.
|
|
23920
|
+
*/
|
|
23921
|
+
function applyPeerWithDefaultPromotion(baseRecommendation, installStrategy, enabled) {
|
|
23922
|
+
if (!enabled) return baseRecommendation;
|
|
23923
|
+
if (baseRecommendation !== "peer") return baseRecommendation;
|
|
23924
|
+
if (installStrategy !== "default") return baseRecommendation;
|
|
23925
|
+
return "peer-with-default";
|
|
23926
|
+
}
|
|
23927
|
+
const PEER_LEANING_FOR_STRATEGY = /* @__PURE__ */ new Set([
|
|
23928
|
+
"peer",
|
|
23929
|
+
"probably-peer",
|
|
23930
|
+
"peer-with-default"
|
|
23931
|
+
]);
|
|
23932
|
+
/**
|
|
23933
|
+
* When peer-with-default mode is on and the recommendation is peer-leaning,
|
|
23934
|
+
* compute install strategy and optionally promote score-sourced `peer` to
|
|
23935
|
+
* `peer-with-default`.
|
|
23936
|
+
*/
|
|
23937
|
+
function applyInstallStrategy({ dependency, findings, importedPackages, optionalPeer, peerWithDefaultEnabled, recommendation, recommendationSource }) {
|
|
23938
|
+
if (!peerWithDefaultEnabled || !PEER_LEANING_FOR_STRATEGY.has(recommendation)) return {
|
|
23939
|
+
installStrategy: void 0,
|
|
23940
|
+
recommendation
|
|
23941
|
+
};
|
|
23942
|
+
const installStrategy = resolveInstallStrategy({
|
|
23943
|
+
dependency,
|
|
23944
|
+
findings,
|
|
23945
|
+
importedPackages,
|
|
23946
|
+
optionalPeer
|
|
23947
|
+
});
|
|
23948
|
+
if (recommendationSource !== "score") return {
|
|
23949
|
+
installStrategy,
|
|
23950
|
+
recommendation
|
|
23951
|
+
};
|
|
23952
|
+
return {
|
|
23953
|
+
installStrategy,
|
|
23954
|
+
recommendation: applyPeerWithDefaultPromotion(recommendation, installStrategy, true)
|
|
23955
|
+
};
|
|
23956
|
+
}
|
|
23957
|
+
//#endregion
|
|
23802
23958
|
//#region src/actions/api-exposure/types.ts
|
|
23803
|
-
/** Ordered band scale used by the scoring combination matrix. */
|
|
23804
|
-
const
|
|
23959
|
+
/** Ordered band scale used by the scoring combination matrix (section 10). */
|
|
23960
|
+
const AEI_SCORE_BAND_ORDER = [
|
|
23805
23961
|
"dependency",
|
|
23806
23962
|
"probably-dependency",
|
|
23807
23963
|
"review",
|
|
23808
23964
|
"probably-peer",
|
|
23809
23965
|
"peer"
|
|
23810
23966
|
];
|
|
23967
|
+
/**
|
|
23968
|
+
* Full recommendation order for reporters / fail-on (includes install strategy).
|
|
23969
|
+
* `peer-with-default` ranks above `peer` (same contract, plus default install).
|
|
23970
|
+
*/
|
|
23971
|
+
const AEI_BAND_ORDER = [...AEI_SCORE_BAND_ORDER, "peer-with-default"];
|
|
23811
23972
|
function aeiBandForScore(aei, thresholds) {
|
|
23812
23973
|
if (aei <= thresholds.dependencyMax) return "dependency";
|
|
23813
23974
|
if (aei <= thresholds.probablyDependencyMax) return "probably-dependency";
|
|
@@ -23827,8 +23988,8 @@ function crsBandForScore(crs) {
|
|
|
23827
23988
|
*/
|
|
23828
23989
|
function combineBands(base, crs) {
|
|
23829
23990
|
const shift = crs === "low" ? -1 : crs === "high" ? 1 : 0;
|
|
23830
|
-
const index =
|
|
23831
|
-
return
|
|
23991
|
+
const index = AEI_SCORE_BAND_ORDER.indexOf(base) + shift;
|
|
23992
|
+
return AEI_SCORE_BAND_ORDER[Math.min(Math.max(index, 0), AEI_SCORE_BAND_ORDER.length - 1)];
|
|
23832
23993
|
}
|
|
23833
23994
|
/**
|
|
23834
23995
|
* Computes both scores and the combined recommendation from a dependency's
|
|
@@ -24853,10 +25014,12 @@ function createExposureProgram(workspaceDir, entryPoints, cache) {
|
|
|
24853
25014
|
function readManifestSections(workspaceDir) {
|
|
24854
25015
|
try {
|
|
24855
25016
|
const pkg = JSON.parse(fs.readFileSync(PATH.join(workspaceDir, "package.json"), "utf8"));
|
|
25017
|
+
const optionalPeers = new Set(Object.entries(pkg.peerDependenciesMeta ?? {}).filter(([, meta]) => meta?.optional === true).map(([name]) => name));
|
|
24856
25018
|
return {
|
|
24857
25019
|
dependencies: new Set(Object.keys(pkg.dependencies ?? {})),
|
|
24858
25020
|
devDependencies: new Set(Object.keys(pkg.devDependencies ?? {})),
|
|
24859
25021
|
isPrivate: pkg.private === true,
|
|
25022
|
+
optionalPeers,
|
|
24860
25023
|
peerDependencies: new Set(Object.keys(pkg.peerDependencies ?? {})),
|
|
24861
25024
|
sideEffectsFree: pkg.sideEffects === false
|
|
24862
25025
|
};
|
|
@@ -24865,14 +25028,18 @@ function readManifestSections(workspaceDir) {
|
|
|
24865
25028
|
dependencies: /* @__PURE__ */ new Set(),
|
|
24866
25029
|
devDependencies: /* @__PURE__ */ new Set(),
|
|
24867
25030
|
isPrivate: false,
|
|
25031
|
+
optionalPeers: /* @__PURE__ */ new Set(),
|
|
24868
25032
|
peerDependencies: /* @__PURE__ */ new Set(),
|
|
24869
25033
|
sideEffectsFree: false
|
|
24870
25034
|
};
|
|
24871
25035
|
}
|
|
24872
25036
|
}
|
|
24873
25037
|
function currentSectionOf(dependency, sections) {
|
|
24874
|
-
|
|
24875
|
-
|
|
25038
|
+
const inDeps = sections.dependencies.has(dependency);
|
|
25039
|
+
const inPeers = sections.peerDependencies.has(dependency);
|
|
25040
|
+
if (inDeps && inPeers) return "dependencies+peerDependencies";
|
|
25041
|
+
if (inDeps) return "dependencies";
|
|
25042
|
+
if (inPeers) return "peerDependencies";
|
|
24876
25043
|
if (sections.devDependencies.has(dependency)) return "devDependencies";
|
|
24877
25044
|
return "unlisted";
|
|
24878
25045
|
}
|
|
@@ -25072,7 +25239,16 @@ function assessDependency({ config, dependency, importedPackages, isSelfOrIntern
|
|
|
25072
25239
|
workspaceDir
|
|
25073
25240
|
});
|
|
25074
25241
|
if (resolved === void 0) return void 0;
|
|
25075
|
-
const [
|
|
25242
|
+
const [baseRecommendation, recommendationSource] = resolved;
|
|
25243
|
+
const { installStrategy, recommendation } = applyInstallStrategy({
|
|
25244
|
+
dependency,
|
|
25245
|
+
findings,
|
|
25246
|
+
importedPackages,
|
|
25247
|
+
optionalPeer: sections.optionalPeers.has(dependency),
|
|
25248
|
+
peerWithDefaultEnabled: config.peerWithDefault,
|
|
25249
|
+
recommendation: baseRecommendation,
|
|
25250
|
+
recommendationSource
|
|
25251
|
+
});
|
|
25076
25252
|
return {
|
|
25077
25253
|
aei: score.aei,
|
|
25078
25254
|
aeiInfinite: score.aeiInfinite,
|
|
@@ -25081,6 +25257,7 @@ function assessDependency({ config, dependency, importedPackages, isSelfOrIntern
|
|
|
25081
25257
|
currentSection: currentSectionOf(dependency, sections),
|
|
25082
25258
|
dependency,
|
|
25083
25259
|
findings,
|
|
25260
|
+
installStrategy,
|
|
25084
25261
|
recommendation,
|
|
25085
25262
|
recommendationSource,
|
|
25086
25263
|
treeShakingModifier: score.treeShakingModifier
|
|
@@ -25108,9 +25285,14 @@ function isProvidedBySections(dependency, findings, sections, workspaceDir) {
|
|
|
25108
25285
|
* entirely (the `aei.exposure.provided-transitive` reporting gate, off by
|
|
25109
25286
|
* default).
|
|
25110
25287
|
*/
|
|
25288
|
+
function mapClassificationOverride(classification) {
|
|
25289
|
+
if (classification === "peer-with-default") return "peer-with-default";
|
|
25290
|
+
if (classification === "peer") return "peer";
|
|
25291
|
+
return "dependency";
|
|
25292
|
+
}
|
|
25111
25293
|
function resolveRecommendation(scored, findings, { config, dependency, isSelfOrInternal, isTerminal, refTypes, sections, workspaceDir }) {
|
|
25112
25294
|
const classification = config.classificationFor(dependency) ?? refTypes?.get(dependency);
|
|
25113
|
-
if (classification !== void 0 && !(isTerminal === true && classification === "peer"
|
|
25295
|
+
if (classification !== void 0 && !(isTerminal === true && (classification === "peer" || classification === "peer-with-default"))) return [mapClassificationOverride(classification), "override"];
|
|
25114
25296
|
if (isTerminal === true) {
|
|
25115
25297
|
if (sections.isPrivate && currentSectionOf(dependency, sections) === "devDependencies") return void 0;
|
|
25116
25298
|
return ["dependency", "terminal"];
|
|
@@ -25132,7 +25314,8 @@ function analyzeWorkspaceApiExposure({ cache, config, isTerminal, refTypes, work
|
|
|
25132
25314
|
const requiredPeerSources = getRuntimeRootedNonOptionalTransitivePeerSources(workspaceDir, getDependenciesFromPackageJson(PATH.join(workspaceDir, "package.json")), { excludeSatisfiedInChain: true });
|
|
25133
25315
|
const entryPoints = resolveEntryPoints(workspaceDir);
|
|
25134
25316
|
const program = createExposureProgram(workspaceDir, entryPoints, cache);
|
|
25135
|
-
const
|
|
25317
|
+
const needsImportedPackages = config.peerForwarding !== "always" || config.peerWithDefault;
|
|
25318
|
+
const importedPackages = program === void 0 || !needsImportedPackages ? void 0 : getImportedPackages(program, workspaceDir);
|
|
25136
25319
|
const raw = [];
|
|
25137
25320
|
if (program !== void 0) raw.push(...getExposureFindings({
|
|
25138
25321
|
entryFiles: entryPoints,
|
|
@@ -25172,16 +25355,19 @@ function bandIndex(band) {
|
|
|
25172
25355
|
* True when a dependency's current placement contradicts its recommendation:
|
|
25173
25356
|
* peer-leaning recommendations for deps in `dependencies`, or dep-leaning
|
|
25174
25357
|
* recommendations for deps in `peerDependencies`. `review` is never a
|
|
25175
|
-
* mismatch — it asks for a human decision.
|
|
25358
|
+
* mismatch — it asks for a human decision. `peer-with-default` matches only
|
|
25359
|
+
* when both `dependencies` and `peerDependencies` list the package.
|
|
25176
25360
|
*/
|
|
25177
25361
|
function isMismatch(assessment) {
|
|
25178
25362
|
const { currentSection, recommendation } = assessment;
|
|
25179
25363
|
if (recommendation === "review") return false;
|
|
25180
|
-
if (
|
|
25181
|
-
return currentSection
|
|
25364
|
+
if (recommendation === "peer-with-default") return currentSection !== "dependencies+peerDependencies";
|
|
25365
|
+
if (bandIndex(recommendation) > bandIndex("review")) return currentSection !== "peerDependencies";
|
|
25366
|
+
return currentSection === "peerDependencies" || currentSection === "dependencies+peerDependencies";
|
|
25182
25367
|
}
|
|
25183
25368
|
function bandColor(band) {
|
|
25184
25369
|
switch (band) {
|
|
25370
|
+
case "peer-with-default": return chalk.cyan;
|
|
25185
25371
|
case "peer":
|
|
25186
25372
|
case "probably-peer": return chalk.magenta;
|
|
25187
25373
|
case "review": return chalk.yellow;
|
|
@@ -25195,7 +25381,8 @@ function renderAssessment(assessment, verbose) {
|
|
|
25195
25381
|
const color = bandColor(assessment.recommendation);
|
|
25196
25382
|
const mismatch = isMismatch(assessment) ? ` ${chalk.red("MISMATCH")}` : "";
|
|
25197
25383
|
const source = assessment.recommendationSource === "score" ? "" : ` [${assessment.recommendationSource}]`;
|
|
25198
|
-
|
|
25384
|
+
const strategy = assessment.installStrategy === void 0 ? "" : chalk.dim(` strategy=${assessment.installStrategy}`);
|
|
25385
|
+
console.log(` ${chalk.bold(assessment.dependency)} ${formatScore(assessment)} → ${color(assessment.recommendation)} (currently: ${assessment.currentSection})${source}${strategy}${mismatch}`);
|
|
25199
25386
|
if (!(verbose || isMismatch(assessment) || assessment.recommendation === "review")) return;
|
|
25200
25387
|
for (const finding of assessment.findings) {
|
|
25201
25388
|
const weight = finding.infinite ? " ∞" : `+${finding.weight}`.padStart(4);
|
|
@@ -25233,27 +25420,30 @@ function resolveTargetWorkspaces$1(targetPackage, inputWorkspaces) {
|
|
|
25233
25420
|
workspaceNames
|
|
25234
25421
|
};
|
|
25235
25422
|
}
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25239
|
-
|
|
25240
|
-
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
|
|
25245
|
-
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
}
|
|
25250
|
-
|
|
25423
|
+
function refTypesFromDeplintConfig(deplintConfig) {
|
|
25424
|
+
return new Map(Object.entries(deplintConfig.packages ?? {}).flatMap(([name, pkgConfig]) => pkgConfig.refType === void 0 ? [] : [[name, pkgConfig.refType]]));
|
|
25425
|
+
}
|
|
25426
|
+
async function loadNormalizedConfig(workspaceLocation) {
|
|
25427
|
+
const apiExposureConfig = await loadWorkspaceCommandConfig(workspaceLocation, "apiExposure");
|
|
25428
|
+
const deplintConfig = await loadWorkspaceCommandConfig(workspaceLocation, "deplint");
|
|
25429
|
+
const peerWithDefault = apiExposureConfig.peerWithDefault === true || deplintConfig.classifier === "aei-next";
|
|
25430
|
+
return {
|
|
25431
|
+
config: normalizeApiExposureConfig({
|
|
25432
|
+
...apiExposureConfig,
|
|
25433
|
+
peerWithDefault
|
|
25434
|
+
}),
|
|
25435
|
+
refTypes: refTypesFromDeplintConfig(deplintConfig)
|
|
25436
|
+
};
|
|
25437
|
+
}
|
|
25438
|
+
function filterAssessmentsByDep(result, dep) {
|
|
25439
|
+
if (dep === void 0 || dep.length === 0) return;
|
|
25440
|
+
result.assessments = result.assessments.filter((assessment) => dep.some((pattern) => assessment.dependency === pattern || isMatch(assessment.dependency, pattern)));
|
|
25441
|
+
}
|
|
25442
|
+
async function analyzeWorkspaces(targetWorkspaces, workspaceNames, cache, dep, verbose) {
|
|
25251
25443
|
const results = [];
|
|
25252
25444
|
for (const workspace of targetWorkspaces) {
|
|
25253
25445
|
if (verbose === true) console.log(chalk.dim(`api-exposure: analyzing ${workspace.name}`));
|
|
25254
|
-
const config =
|
|
25255
|
-
const deplintConfig = await loadWorkspaceCommandConfig(workspace.location, "deplint");
|
|
25256
|
-
const refTypes = new Map(Object.entries(deplintConfig.packages ?? {}).flatMap(([name, pkgConfig]) => pkgConfig.refType === void 0 ? [] : [[name, pkgConfig.refType]]));
|
|
25446
|
+
const { config, refTypes } = await loadNormalizedConfig(workspace.location);
|
|
25257
25447
|
const result = analyzeWorkspaceApiExposure({
|
|
25258
25448
|
cache,
|
|
25259
25449
|
config,
|
|
@@ -25262,17 +25452,45 @@ const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspa
|
|
|
25262
25452
|
workspace,
|
|
25263
25453
|
workspaceNames
|
|
25264
25454
|
});
|
|
25265
|
-
|
|
25455
|
+
filterAssessmentsByDep(result, dep);
|
|
25266
25456
|
results.push(result);
|
|
25267
25457
|
}
|
|
25458
|
+
return results;
|
|
25459
|
+
}
|
|
25460
|
+
/** Band confidence for --fail-on: distance from the neutral `review` band. */
|
|
25461
|
+
function confidence(band) {
|
|
25462
|
+
return Math.abs(bandIndex(band) - bandIndex("review"));
|
|
25463
|
+
}
|
|
25464
|
+
function collectDiagnostics(results, failOn) {
|
|
25268
25465
|
const allAssessments = results.flatMap((result) => result.assessments);
|
|
25269
25466
|
const warningAssessments = new Set(allAssessments.filter((assessment) => assessment.recommendation === "review"));
|
|
25270
25467
|
const mismatches = allAssessments.filter((assessment) => isMismatch(assessment));
|
|
25271
|
-
const confidence = (band) => Math.abs(bandIndex(band) - bandIndex("review"));
|
|
25272
25468
|
const failingMismatches = failOn === void 0 ? [] : mismatches.filter((assessment) => confidence(assessment.recommendation) >= confidence(failOn));
|
|
25273
25469
|
for (const assessment of mismatches) warningAssessments.add(assessment);
|
|
25274
25470
|
const errorAssessments = /* @__PURE__ */ new Set([...failingMismatches, ...allAssessments.filter((assessment) => (assessment.recommendation === "review" || isMismatch(assessment)) && assessment.findings.some((finding) => finding.level === "error"))]);
|
|
25275
25471
|
for (const assessment of errorAssessments) warningAssessments.delete(assessment);
|
|
25472
|
+
return {
|
|
25473
|
+
errorAssessments,
|
|
25474
|
+
mismatches,
|
|
25475
|
+
warningAssessments
|
|
25476
|
+
};
|
|
25477
|
+
}
|
|
25478
|
+
const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspaces: inputWorkspaces }) => {
|
|
25479
|
+
const effectiveFormat = format ?? (isJsonMode() ? "json" : "human");
|
|
25480
|
+
const targetPackage = typeof pkg === "string" && pkg.length > 0 && pkg !== "undefined" ? pkg : void 0;
|
|
25481
|
+
const { targetWorkspaces, workspaceNames } = resolveTargetWorkspaces$1(targetPackage, inputWorkspaces);
|
|
25482
|
+
if (targetWorkspaces.length === 0) {
|
|
25483
|
+
console.error(chalk.red(`Workspace not found: ${targetPackage}`));
|
|
25484
|
+
return {
|
|
25485
|
+
envelope: {
|
|
25486
|
+
errorCount: 1,
|
|
25487
|
+
errors: [{ message: `Workspace not found: ${targetPackage}` }]
|
|
25488
|
+
},
|
|
25489
|
+
exitCode: 1
|
|
25490
|
+
};
|
|
25491
|
+
}
|
|
25492
|
+
const results = await analyzeWorkspaces(targetWorkspaces, workspaceNames, createSharedProgramCache(), dep, verbose);
|
|
25493
|
+
const { errorAssessments, mismatches, warningAssessments } = collectDiagnostics(results, failOn);
|
|
25276
25494
|
if (!isJsonMode() && effectiveFormat === "human") {
|
|
25277
25495
|
renderHumanApiExposure(results, {
|
|
25278
25496
|
minBand,
|
|
@@ -29547,12 +29765,17 @@ function resolvedAddFix(context, dependency, section, detail, isOptional) {
|
|
|
29547
29765
|
};
|
|
29548
29766
|
}
|
|
29549
29767
|
//#endregion
|
|
29768
|
+
//#region src/actions/deplint/types.ts
|
|
29769
|
+
function isAeiClassifierMode(mode) {
|
|
29770
|
+
return mode === "aei" || mode === "aei-next";
|
|
29771
|
+
}
|
|
29772
|
+
//#endregion
|
|
29550
29773
|
//#region src/actions/deplint/rulesMisplaced.ts
|
|
29551
29774
|
function resolvePeerDeclaredVersion(context, dep) {
|
|
29552
29775
|
return context.packageParams.peerDependencyVersions[dep] ?? (context.workspaceNames?.has(dep) ?? false ? "workspace:~" : "*");
|
|
29553
29776
|
}
|
|
29554
29777
|
function shouldSkipAeiPeerDemotion(context, dep, version) {
|
|
29555
|
-
return context.isTerminalPackage || context.classifierMode
|
|
29778
|
+
return context.isTerminalPackage || !isAeiClassifierMode(context.classifierMode) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep) || dep.startsWith("@types/") || version.startsWith("workspace:");
|
|
29556
29779
|
}
|
|
29557
29780
|
/**
|
|
29558
29781
|
* A peer this package never imports is not a placement candidate — demoting
|
|
@@ -29578,13 +29801,23 @@ function evaluateMisplacedPeer(context, dep, version) {
|
|
|
29578
29801
|
mode: "to-dev",
|
|
29579
29802
|
version
|
|
29580
29803
|
};
|
|
29581
|
-
if ((context.workspaceNames?.has(dep) ?? false) && !context.forcePeers.has(dep)) return {
|
|
29804
|
+
if ((context.workspaceNames?.has(dep) ?? false) && !context.forcePeers.has(dep) && !context.forcePeerWithDefault.has(dep)) return {
|
|
29582
29805
|
alreadyInTarget: context.packageParams.dependencies.includes(dep),
|
|
29583
29806
|
dep,
|
|
29584
29807
|
message: `peerDependency ${dep} should be a dependency — sibling workspace packages ship in lockstep; set refType "peer" in xy.config.ts to override`,
|
|
29585
29808
|
mode: "to-dep",
|
|
29586
29809
|
version
|
|
29587
29810
|
};
|
|
29811
|
+
if (context.forcePeerWithDefault.has(dep) || context.classifyDependency(dep) === "peer-with-default") {
|
|
29812
|
+
if (context.packageParams.dependencies.includes(dep)) return void 0;
|
|
29813
|
+
return {
|
|
29814
|
+
alreadyInTarget: false,
|
|
29815
|
+
dep,
|
|
29816
|
+
message: `peerDependency ${dep} should also be a dependency — peer-with-default (default install + peer contract)`,
|
|
29817
|
+
mode: "add-dep-companion",
|
|
29818
|
+
version: context.packageParams.devDependencyVersions[dep] ?? version
|
|
29819
|
+
};
|
|
29820
|
+
}
|
|
29588
29821
|
if (shouldSkipAeiPeerDemotion(context, dep, version)) return void 0;
|
|
29589
29822
|
if (!isImportedAnywhere(context, dep)) return void 0;
|
|
29590
29823
|
if (context.classifyDependency(dep) !== "dependency") return void 0;
|
|
@@ -29620,6 +29853,18 @@ const misplacedDependenciesRule = {
|
|
|
29620
29853
|
if (context.isTerminalPackage) continue;
|
|
29621
29854
|
if (context.forceDeps.has(dep)) continue;
|
|
29622
29855
|
if (context.packageParams.dependencyVersions[dep]?.startsWith("workspace:")) continue;
|
|
29856
|
+
if (context.forcePeerWithDefault.has(dep) || context.classifyDependency(dep) === "peer-with-default") {
|
|
29857
|
+
if (context.packageParams.peerDependencies.includes(dep)) continue;
|
|
29858
|
+
context.report({
|
|
29859
|
+
data: {
|
|
29860
|
+
dep,
|
|
29861
|
+
mode: "add-peer-companion"
|
|
29862
|
+
},
|
|
29863
|
+
dependency: dep,
|
|
29864
|
+
message: `dependency ${dep} should also be a peerDependency — peer-with-default (default install + peer contract)`
|
|
29865
|
+
});
|
|
29866
|
+
continue;
|
|
29867
|
+
}
|
|
29623
29868
|
if (context.forcePeers.has(dep) || context.classifyDependency(dep) === "peer") {
|
|
29624
29869
|
const reason = context.forcePeers.has(dep) ? "configured as refType \"peer\"" : "external runtime dep — consumers should control the version";
|
|
29625
29870
|
context.report({
|
|
@@ -29644,6 +29889,10 @@ const misplacedDependenciesRule = {
|
|
|
29644
29889
|
fromSection: "dependencies",
|
|
29645
29890
|
toSection: "devDependencies"
|
|
29646
29891
|
}];
|
|
29892
|
+
if (data.mode === "add-peer-companion") {
|
|
29893
|
+
const optional = context.forcePeerOptional.get(data.dep);
|
|
29894
|
+
return [resolvedAddFix(context, data.dep, "peerDependencies", "added peer companion for peer-with-default", optional)];
|
|
29895
|
+
}
|
|
29647
29896
|
const optional = context.forcePeerOptional.get(data.dep);
|
|
29648
29897
|
const fixes = [{
|
|
29649
29898
|
action: "move",
|
|
@@ -29681,9 +29930,10 @@ const misplacedPeerDependenciesRule = {
|
|
|
29681
29930
|
});
|
|
29682
29931
|
}
|
|
29683
29932
|
},
|
|
29684
|
-
resolveFixes(diagnostic) {
|
|
29933
|
+
resolveFixes(diagnostic, context) {
|
|
29685
29934
|
const data = diagnostic.data;
|
|
29686
29935
|
if (!data) return [];
|
|
29936
|
+
if (data.mode === "add-dep-companion") return [resolvedAddFix(context, data.dep, "dependencies", "added dependency companion for peer-with-default")];
|
|
29687
29937
|
if (data.alreadyInTarget ?? false) return [{
|
|
29688
29938
|
action: "remove",
|
|
29689
29939
|
dependency: data.dep,
|
|
@@ -29843,11 +30093,13 @@ const unlistedDependenciesRule = {
|
|
|
29843
30093
|
});
|
|
29844
30094
|
continue;
|
|
29845
30095
|
}
|
|
29846
|
-
const
|
|
30096
|
+
const classification = context.classifyDependency(imp);
|
|
30097
|
+
const isPeerWithDefault = !context.isTerminalPackage && section === "dependencies" && !context.forceDeps.has(imp) && (context.forcePeerWithDefault.has(imp) || classification === "peer-with-default");
|
|
30098
|
+
const isPeer = !context.isTerminalPackage && section === "dependencies" && !context.forceDeps.has(imp) && !isPeerWithDefault && classification === "peer";
|
|
29847
30099
|
context.report({
|
|
29848
30100
|
data: {
|
|
29849
30101
|
imp,
|
|
29850
|
-
mode: isPeer ? "peer-companion" : "direct",
|
|
30102
|
+
mode: isPeerWithDefault ? "peer-with-default" : isPeer ? "peer-companion" : "direct",
|
|
29851
30103
|
section
|
|
29852
30104
|
},
|
|
29853
30105
|
dependency: imp,
|
|
@@ -29860,6 +30112,10 @@ const unlistedDependenciesRule = {
|
|
|
29860
30112
|
const data = diagnostic.data;
|
|
29861
30113
|
if (!data) return [];
|
|
29862
30114
|
if (data.mode === "forced-dev") return [resolvedAddFix(context, data.imp, "devDependencies", "added to devDependencies")];
|
|
30115
|
+
if (data.mode === "peer-with-default") {
|
|
30116
|
+
const optional = resolvePromotedPeerOptional(context, data.imp);
|
|
30117
|
+
return ["dependencies", "peerDependencies"].map((section) => resolvedAddFix(context, data.imp, section, `added to ${section} (peer-with-default)`, section === "peerDependencies" ? optional : void 0));
|
|
30118
|
+
}
|
|
29863
30119
|
if (data.mode === "peer-companion") {
|
|
29864
30120
|
const optional = resolvePromotedPeerOptional(context, data.imp);
|
|
29865
30121
|
return ["peerDependencies", "devDependencies"].map((section) => resolvedAddFix(context, data.imp, section, `added to ${section}`, section === "peerDependencies" ? optional : void 0));
|
|
@@ -30171,11 +30427,14 @@ const redundantPeerDependenciesRule = {
|
|
|
30171
30427
|
},
|
|
30172
30428
|
evaluate(context) {
|
|
30173
30429
|
const findings = findRedundantPeerDeps(context.packageParams, context.exclude);
|
|
30174
|
-
for (const dep of findings)
|
|
30175
|
-
|
|
30176
|
-
|
|
30177
|
-
|
|
30178
|
-
|
|
30430
|
+
for (const dep of findings) {
|
|
30431
|
+
if (context.forcePeerWithDefault.has(dep) || context.classifyDependency(dep) === "peer-with-default") continue;
|
|
30432
|
+
context.report({
|
|
30433
|
+
data: { dep },
|
|
30434
|
+
dependency: dep,
|
|
30435
|
+
message: `Redundant peerDependency ${dep} — already listed in dependencies`
|
|
30436
|
+
});
|
|
30437
|
+
}
|
|
30179
30438
|
},
|
|
30180
30439
|
resolveFixes(diagnostic) {
|
|
30181
30440
|
const data = diagnostic.data;
|
|
@@ -30314,10 +30573,10 @@ const builtInDeplintPlugin = {
|
|
|
30314
30573
|
severity: "warning"
|
|
30315
30574
|
},
|
|
30316
30575
|
evaluate(context) {
|
|
30317
|
-
if (context.classifierMode
|
|
30576
|
+
if (!isAeiClassifierMode(context.classifierMode) || context.isTerminalPackage) return;
|
|
30318
30577
|
const candidates = /* @__PURE__ */ new Set([...context.packageParams.dependencies, ...context.packageParams.peerDependencies]);
|
|
30319
30578
|
for (const dep of candidates) {
|
|
30320
|
-
if (context.forceDeps.has(dep) || context.forceDevs.has(dep) || context.forcePeers.has(dep)) continue;
|
|
30579
|
+
if (context.forceDeps.has(dep) || context.forceDevs.has(dep) || context.forcePeers.has(dep) || context.forcePeerWithDefault.has(dep)) continue;
|
|
30321
30580
|
if (context.packageParams.dependencyVersions[dep]?.startsWith("workspace:")) continue;
|
|
30322
30581
|
if (context.workspaceNames?.has(dep) ?? false) continue;
|
|
30323
30582
|
if (dep.startsWith("@types/")) continue;
|
|
@@ -30373,6 +30632,7 @@ function buildUnusedDependencyExclude(options, requiredTransitivePeers) {
|
|
|
30373
30632
|
...options.forceDeps ?? [],
|
|
30374
30633
|
...options.forceDevs ?? [],
|
|
30375
30634
|
...options.forcePeers ?? [],
|
|
30635
|
+
...options.forcePeerWithDefault ?? [],
|
|
30376
30636
|
...options.forcePeerOptional?.keys() ?? []
|
|
30377
30637
|
]);
|
|
30378
30638
|
}
|
|
@@ -30382,32 +30642,40 @@ function buildUnusedPeerDependencyExclude(options, runtimeRootedRequired) {
|
|
|
30382
30642
|
...runtimeRootedRequired,
|
|
30383
30643
|
...options.forceDeps ?? [],
|
|
30384
30644
|
...options.forcePeers ?? [],
|
|
30645
|
+
...options.forcePeerWithDefault ?? [],
|
|
30385
30646
|
...options.forcePeerOptional?.keys() ?? []
|
|
30386
30647
|
]);
|
|
30387
30648
|
}
|
|
30388
30649
|
const sharedAeiProgramCache = createSharedProgramCache();
|
|
30389
30650
|
/**
|
|
30390
30651
|
* Builds the dep-vs-peer classifier attached to the workspace context.
|
|
30391
|
-
* `legacy` preserves the historical external-default rule; `aei`
|
|
30392
|
-
* `xy api-exposure` analyzer lazily (once per snapshot,
|
|
30393
|
-
*
|
|
30394
|
-
*
|
|
30395
|
-
*
|
|
30652
|
+
* `legacy` preserves the historical external-default rule; `aei` /
|
|
30653
|
+
* `aei-next` run the `xy api-exposure` analyzer lazily (once per snapshot,
|
|
30654
|
+
* on first use) and map its bands: peer/probably-peer → peer,
|
|
30655
|
+
* peer-with-default → peer-with-default (`aei-next` only), review → review,
|
|
30656
|
+
* everything else → dependency. Deps the analyzer produced no assessment
|
|
30657
|
+
* for scored zero exposure, so they classify as plain dependencies.
|
|
30396
30658
|
*/
|
|
30397
30659
|
function buildDependencyClassifier(workspace, options, isTerminal, peerDependencies, externalDistImports) {
|
|
30398
|
-
|
|
30660
|
+
const classifier = options.classifier ?? "legacy";
|
|
30661
|
+
if (!isAeiClassifierMode(classifier)) return (dependency) => shouldBePeerDependency(dependency, workspace.location, peerDependencies, externalDistImports, options.workspaceNames) ? "peer" : "dependency";
|
|
30399
30662
|
let recommendations;
|
|
30400
30663
|
return (dependency) => {
|
|
30664
|
+
if (options.forcePeerWithDefault?.has(dependency) ?? false) return "peer-with-default";
|
|
30401
30665
|
if (recommendations === void 0) {
|
|
30402
30666
|
const result = analyzeWorkspaceApiExposure({
|
|
30403
30667
|
cache: sharedAeiProgramCache,
|
|
30404
|
-
config: normalizeApiExposureConfig(
|
|
30668
|
+
config: normalizeApiExposureConfig({
|
|
30669
|
+
...options.apiExposureConfig,
|
|
30670
|
+
peerWithDefault: classifier === "aei-next" || options.apiExposureConfig?.peerWithDefault === true
|
|
30671
|
+
}),
|
|
30405
30672
|
isTerminal,
|
|
30406
30673
|
workspace,
|
|
30407
30674
|
workspaceNames: options.workspaceNames
|
|
30408
30675
|
});
|
|
30409
30676
|
recommendations = new Map(result.assessments.map((assessment) => {
|
|
30410
30677
|
switch (assessment.recommendation) {
|
|
30678
|
+
case "peer-with-default": return [assessment.dependency, "peer-with-default"];
|
|
30411
30679
|
case "peer":
|
|
30412
30680
|
case "probably-peer": return [assessment.dependency, "peer"];
|
|
30413
30681
|
case "review": return [assessment.dependency, "review"];
|
|
@@ -30418,6 +30686,18 @@ function buildDependencyClassifier(workspace, options, isTerminal, peerDependenc
|
|
|
30418
30686
|
return recommendations.get(dependency) ?? "dependency";
|
|
30419
30687
|
};
|
|
30420
30688
|
}
|
|
30689
|
+
function resolvePeerForwardingPolicy(classifier, apiExposureConfig, sourceParams) {
|
|
30690
|
+
const forwardingMode = isAeiClassifierMode(classifier ?? "legacy") ? apiExposureConfig?.peerForwarding ?? "when-exposed" : "always";
|
|
30691
|
+
if (forwardingMode === "always") return void 0;
|
|
30692
|
+
return {
|
|
30693
|
+
importedModules: forwardingMode === "when-exposed" ? /* @__PURE__ */ new Set([...sourceParams.externalDistImports, ...sourceParams.externalDistTypeImports]) : /* @__PURE__ */ new Set([
|
|
30694
|
+
...sourceParams.externalAllImports,
|
|
30695
|
+
...sourceParams.externalDistImports,
|
|
30696
|
+
...sourceParams.externalDistTypeImports
|
|
30697
|
+
]),
|
|
30698
|
+
mode: forwardingMode
|
|
30699
|
+
};
|
|
30700
|
+
}
|
|
30421
30701
|
function buildWorkspaceContext(workspace, options = {}) {
|
|
30422
30702
|
const { sourceExclude, terminalOverride, phases } = options;
|
|
30423
30703
|
const findFilesStarted = performance.now();
|
|
@@ -30441,15 +30721,7 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
30441
30721
|
const packageMetaStarted = performance.now();
|
|
30442
30722
|
const packageJsonPath = `${workspace.location}/package.json`;
|
|
30443
30723
|
const packageParams = getDependenciesFromPackageJson(packageJsonPath);
|
|
30444
|
-
const
|
|
30445
|
-
const peerForwarding = forwardingMode === "always" ? void 0 : {
|
|
30446
|
-
importedModules: forwardingMode === "when-exposed" ? /* @__PURE__ */ new Set([...sourceParams.externalDistImports, ...sourceParams.externalDistTypeImports]) : /* @__PURE__ */ new Set([
|
|
30447
|
-
...sourceParams.externalAllImports,
|
|
30448
|
-
...sourceParams.externalDistImports,
|
|
30449
|
-
...sourceParams.externalDistTypeImports
|
|
30450
|
-
]),
|
|
30451
|
-
mode: forwardingMode
|
|
30452
|
-
};
|
|
30724
|
+
const peerForwarding = resolvePeerForwardingPolicy(options.classifier, options.apiExposureConfig, sourceParams);
|
|
30453
30725
|
const requiredTransitivePeers = getRequiredNonOptionalTransitivePeers(workspace.location, packageParams);
|
|
30454
30726
|
const runtimeRootedRequired = new Set([...getRuntimeRootedNonOptionalTransitivePeers(workspace.location, packageParams)].filter((peer) => isPeerForwarded(peerForwarding, peer)));
|
|
30455
30727
|
const packageClassification = classifyDeplintPackage(workspace.location, terminalOverride);
|
|
@@ -30466,6 +30738,7 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
30466
30738
|
forceDeps: options.forceDeps ?? /* @__PURE__ */ new Set(),
|
|
30467
30739
|
forceDevs: options.forceDevs ?? /* @__PURE__ */ new Set(),
|
|
30468
30740
|
forcePeerOptional: options.forcePeerOptional ?? /* @__PURE__ */ new Map(),
|
|
30741
|
+
forcePeerWithDefault: options.forcePeerWithDefault ?? /* @__PURE__ */ new Set(),
|
|
30469
30742
|
forcePeers: options.forcePeers ?? /* @__PURE__ */ new Set(),
|
|
30470
30743
|
isTerminalPackage: packageClassification.isTerminalPackage,
|
|
30471
30744
|
packageKind: packageClassification.kind,
|
|
@@ -30545,7 +30818,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30545
30818
|
const wsConfig = await loadWorkspaceCommandConfig(workspace.location, "deplint");
|
|
30546
30819
|
const rules = await loadDeplintRules(wsConfig);
|
|
30547
30820
|
const classifier = options.classifier ?? wsConfig.classifier ?? "legacy";
|
|
30548
|
-
const apiExposureConfig = classifier === "aei" ? await loadWorkspaceCommandConfig(workspace.location, "apiExposure") : void 0;
|
|
30821
|
+
const apiExposureConfig = classifier === "aei" || classifier === "aei-next" ? await loadWorkspaceCommandConfig(workspace.location, "apiExposure") : void 0;
|
|
30549
30822
|
const configuredExclude = normalizeConfigList(wsConfig.exclude);
|
|
30550
30823
|
const cliExclude = normalizeConfigList(options.cliExclude);
|
|
30551
30824
|
const sourceExclude = [...configuredExclude, ...cliExclude];
|
|
@@ -30553,6 +30826,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30553
30826
|
const forceDeps = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "dep").map(([name]) => name));
|
|
30554
30827
|
const forceDevs = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "dev").map(([name]) => name));
|
|
30555
30828
|
const forcePeers = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "peer").map(([name]) => name));
|
|
30829
|
+
const forcePeerWithDefault = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "peer-with-default").map(([name]) => name));
|
|
30556
30830
|
const forcePeerOptional = /* @__PURE__ */ new Map();
|
|
30557
30831
|
for (const [name, cfg] of packageEntries) if (typeof cfg.peerOptional === "boolean") forcePeerOptional.set(name, cfg.peerOptional);
|
|
30558
30832
|
const rangeStyleOptions = rules.find((rule) => rule.id === "dep.peerDependencies.range-style")?.options ?? {};
|
|
@@ -30572,6 +30846,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30572
30846
|
forceDeps,
|
|
30573
30847
|
forceDevs,
|
|
30574
30848
|
forcePeerOptional,
|
|
30849
|
+
forcePeerWithDefault,
|
|
30575
30850
|
forcePeers,
|
|
30576
30851
|
peerRangeBound,
|
|
30577
30852
|
peerRangeForm,
|
|
@@ -51021,7 +51296,8 @@ const BAND_CHOICES = [
|
|
|
51021
51296
|
"probably-dependency",
|
|
51022
51297
|
"review",
|
|
51023
51298
|
"probably-peer",
|
|
51024
|
-
"peer"
|
|
51299
|
+
"peer",
|
|
51300
|
+
"peer-with-default"
|
|
51025
51301
|
];
|
|
51026
51302
|
const apiExposureCommand = {
|
|
51027
51303
|
command: "api-exposure [package]",
|
|
@@ -51133,8 +51409,12 @@ const deplintCommand = {
|
|
|
51133
51409
|
description: "Source paths to exclude from import scanning (comma-separated or repeated)",
|
|
51134
51410
|
type: "array"
|
|
51135
51411
|
}).option("classifier", {
|
|
51136
|
-
choices: [
|
|
51137
|
-
|
|
51412
|
+
choices: [
|
|
51413
|
+
"aei",
|
|
51414
|
+
"aei-next",
|
|
51415
|
+
"legacy"
|
|
51416
|
+
],
|
|
51417
|
+
description: "Dep-vs-peer classifier: legacy (external ⇒ peer), aei (API Exposure Index), or aei-next (AEI + peer-with-default)",
|
|
51138
51418
|
type: "string"
|
|
51139
51419
|
}).option("fix", {
|
|
51140
51420
|
alias: "f",
|