@ariestools/toolchain 8.7.10 → 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 +360 -84
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/xy/lint/apiExposureCommand.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/bin/xy.mjs
CHANGED
|
@@ -23622,6 +23622,12 @@ function getAeiRule(id) {
|
|
|
23622
23622
|
}
|
|
23623
23623
|
//#endregion
|
|
23624
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
|
+
]);
|
|
23625
23631
|
const DEFAULT_AEI_THRESHOLDS = {
|
|
23626
23632
|
dependencyMax: 39,
|
|
23627
23633
|
probablyDependencyMax: 79,
|
|
@@ -23730,23 +23736,17 @@ function resolvePeerForwarding(peerForwarding = "when-exposed") {
|
|
|
23730
23736
|
if (peerForwarding !== "always" && peerForwarding !== "when-used" && peerForwarding !== "when-exposed") throw new TypeError("commands.apiExposure.peerForwarding must be \"always\", \"when-used\", or \"when-exposed\"");
|
|
23731
23737
|
return peerForwarding;
|
|
23732
23738
|
}
|
|
23733
|
-
function
|
|
23734
|
-
const globalRuleSettings = config?.rules ?? {};
|
|
23735
|
-
validateRuleIds("commands.apiExposure.rules", globalRuleSettings);
|
|
23736
|
-
const packages = config?.packages ?? {};
|
|
23739
|
+
function validatePackageOverrides(packages) {
|
|
23737
23740
|
for (const [pattern, override] of Object.entries(packages)) {
|
|
23738
23741
|
if (typeof override !== "object" || override === null || Array.isArray(override)) throw new TypeError(`commands.apiExposure.packages["${pattern}"] must be an object`);
|
|
23739
|
-
if (override.classification !== void 0 && ![
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
].includes(override.classification)) throw new TypeError(`commands.apiExposure.packages["${pattern}"].classification must be "dep", "dev", or "peer"`);
|
|
23744
|
-
if (override.rules !== void 0) {
|
|
23745
|
-
validateRuleIds(`commands.apiExposure.packages["${pattern}"].rules`, override.rules);
|
|
23746
|
-
for (const [ruleId, setting] of Object.entries(override.rules)) parseRuleSetting(`commands.apiExposure.packages["${pattern}"].rules["${ruleId}"]`, setting);
|
|
23747
|
-
}
|
|
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);
|
|
23748
23746
|
}
|
|
23749
|
-
|
|
23747
|
+
}
|
|
23748
|
+
function resolveGlobalRules(globalRuleSettings) {
|
|
23749
|
+
return AEI_RULES.map((definition) => {
|
|
23750
23750
|
const base = {
|
|
23751
23751
|
...definition,
|
|
23752
23752
|
enabled: definition.defaultEnabled ?? true,
|
|
@@ -23757,8 +23757,9 @@ function normalizeApiExposureConfig(config) {
|
|
|
23757
23757
|
if (setting === void 0) return base;
|
|
23758
23758
|
return applySetting(base, parseRuleSetting(`commands.apiExposure.rules["${definition.id}"]`, setting));
|
|
23759
23759
|
});
|
|
23760
|
-
|
|
23761
|
-
|
|
23760
|
+
}
|
|
23761
|
+
function buildRuleFor(packages, globalRulesById) {
|
|
23762
|
+
return (ruleId, dependency) => {
|
|
23762
23763
|
const globalRule = globalRulesById.get(ruleId);
|
|
23763
23764
|
if (globalRule === void 0 || dependency === void 0) return globalRule;
|
|
23764
23765
|
let resolved = globalRule;
|
|
@@ -23768,15 +23769,31 @@ function normalizeApiExposureConfig(config) {
|
|
|
23768
23769
|
}
|
|
23769
23770
|
return resolved;
|
|
23770
23771
|
};
|
|
23771
|
-
|
|
23772
|
+
}
|
|
23773
|
+
function buildClassificationFor(packages) {
|
|
23774
|
+
return (dependency) => {
|
|
23772
23775
|
let classification;
|
|
23773
23776
|
for (const { override } of matchingOverrides(packages, dependency)) classification = override.classification ?? classification;
|
|
23774
23777
|
return classification;
|
|
23775
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]));
|
|
23776
23792
|
return {
|
|
23777
|
-
classificationFor,
|
|
23793
|
+
classificationFor: buildClassificationFor(packages),
|
|
23778
23794
|
peerForwarding: resolvePeerForwarding(config?.peerForwarding),
|
|
23779
|
-
|
|
23795
|
+
peerWithDefault: resolvePeerWithDefault(config?.peerWithDefault),
|
|
23796
|
+
ruleFor: buildRuleFor(packages, globalRulesById),
|
|
23780
23797
|
rules: globalRules,
|
|
23781
23798
|
thresholds: resolveThresholds(config?.thresholds),
|
|
23782
23799
|
treeShaking: config?.treeShaking ?? true
|
|
@@ -23803,15 +23820,155 @@ function resolveFindings(raw, config) {
|
|
|
23803
23820
|
return findings;
|
|
23804
23821
|
}
|
|
23805
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
|
|
23806
23958
|
//#region src/actions/api-exposure/types.ts
|
|
23807
|
-
/** Ordered band scale used by the scoring combination matrix. */
|
|
23808
|
-
const
|
|
23959
|
+
/** Ordered band scale used by the scoring combination matrix (section 10). */
|
|
23960
|
+
const AEI_SCORE_BAND_ORDER = [
|
|
23809
23961
|
"dependency",
|
|
23810
23962
|
"probably-dependency",
|
|
23811
23963
|
"review",
|
|
23812
23964
|
"probably-peer",
|
|
23813
23965
|
"peer"
|
|
23814
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"];
|
|
23815
23972
|
function aeiBandForScore(aei, thresholds) {
|
|
23816
23973
|
if (aei <= thresholds.dependencyMax) return "dependency";
|
|
23817
23974
|
if (aei <= thresholds.probablyDependencyMax) return "probably-dependency";
|
|
@@ -23831,8 +23988,8 @@ function crsBandForScore(crs) {
|
|
|
23831
23988
|
*/
|
|
23832
23989
|
function combineBands(base, crs) {
|
|
23833
23990
|
const shift = crs === "low" ? -1 : crs === "high" ? 1 : 0;
|
|
23834
|
-
const index =
|
|
23835
|
-
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)];
|
|
23836
23993
|
}
|
|
23837
23994
|
/**
|
|
23838
23995
|
* Computes both scores and the combined recommendation from a dependency's
|
|
@@ -24857,10 +25014,12 @@ function createExposureProgram(workspaceDir, entryPoints, cache) {
|
|
|
24857
25014
|
function readManifestSections(workspaceDir) {
|
|
24858
25015
|
try {
|
|
24859
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));
|
|
24860
25018
|
return {
|
|
24861
25019
|
dependencies: new Set(Object.keys(pkg.dependencies ?? {})),
|
|
24862
25020
|
devDependencies: new Set(Object.keys(pkg.devDependencies ?? {})),
|
|
24863
25021
|
isPrivate: pkg.private === true,
|
|
25022
|
+
optionalPeers,
|
|
24864
25023
|
peerDependencies: new Set(Object.keys(pkg.peerDependencies ?? {})),
|
|
24865
25024
|
sideEffectsFree: pkg.sideEffects === false
|
|
24866
25025
|
};
|
|
@@ -24869,14 +25028,18 @@ function readManifestSections(workspaceDir) {
|
|
|
24869
25028
|
dependencies: /* @__PURE__ */ new Set(),
|
|
24870
25029
|
devDependencies: /* @__PURE__ */ new Set(),
|
|
24871
25030
|
isPrivate: false,
|
|
25031
|
+
optionalPeers: /* @__PURE__ */ new Set(),
|
|
24872
25032
|
peerDependencies: /* @__PURE__ */ new Set(),
|
|
24873
25033
|
sideEffectsFree: false
|
|
24874
25034
|
};
|
|
24875
25035
|
}
|
|
24876
25036
|
}
|
|
24877
25037
|
function currentSectionOf(dependency, sections) {
|
|
24878
|
-
|
|
24879
|
-
|
|
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";
|
|
24880
25043
|
if (sections.devDependencies.has(dependency)) return "devDependencies";
|
|
24881
25044
|
return "unlisted";
|
|
24882
25045
|
}
|
|
@@ -25076,7 +25239,16 @@ function assessDependency({ config, dependency, importedPackages, isSelfOrIntern
|
|
|
25076
25239
|
workspaceDir
|
|
25077
25240
|
});
|
|
25078
25241
|
if (resolved === void 0) return void 0;
|
|
25079
|
-
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
|
+
});
|
|
25080
25252
|
return {
|
|
25081
25253
|
aei: score.aei,
|
|
25082
25254
|
aeiInfinite: score.aeiInfinite,
|
|
@@ -25085,6 +25257,7 @@ function assessDependency({ config, dependency, importedPackages, isSelfOrIntern
|
|
|
25085
25257
|
currentSection: currentSectionOf(dependency, sections),
|
|
25086
25258
|
dependency,
|
|
25087
25259
|
findings,
|
|
25260
|
+
installStrategy,
|
|
25088
25261
|
recommendation,
|
|
25089
25262
|
recommendationSource,
|
|
25090
25263
|
treeShakingModifier: score.treeShakingModifier
|
|
@@ -25112,9 +25285,14 @@ function isProvidedBySections(dependency, findings, sections, workspaceDir) {
|
|
|
25112
25285
|
* entirely (the `aei.exposure.provided-transitive` reporting gate, off by
|
|
25113
25286
|
* default).
|
|
25114
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
|
+
}
|
|
25115
25293
|
function resolveRecommendation(scored, findings, { config, dependency, isSelfOrInternal, isTerminal, refTypes, sections, workspaceDir }) {
|
|
25116
25294
|
const classification = config.classificationFor(dependency) ?? refTypes?.get(dependency);
|
|
25117
|
-
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"];
|
|
25118
25296
|
if (isTerminal === true) {
|
|
25119
25297
|
if (sections.isPrivate && currentSectionOf(dependency, sections) === "devDependencies") return void 0;
|
|
25120
25298
|
return ["dependency", "terminal"];
|
|
@@ -25136,7 +25314,8 @@ function analyzeWorkspaceApiExposure({ cache, config, isTerminal, refTypes, work
|
|
|
25136
25314
|
const requiredPeerSources = getRuntimeRootedNonOptionalTransitivePeerSources(workspaceDir, getDependenciesFromPackageJson(PATH.join(workspaceDir, "package.json")), { excludeSatisfiedInChain: true });
|
|
25137
25315
|
const entryPoints = resolveEntryPoints(workspaceDir);
|
|
25138
25316
|
const program = createExposureProgram(workspaceDir, entryPoints, cache);
|
|
25139
|
-
const
|
|
25317
|
+
const needsImportedPackages = config.peerForwarding !== "always" || config.peerWithDefault;
|
|
25318
|
+
const importedPackages = program === void 0 || !needsImportedPackages ? void 0 : getImportedPackages(program, workspaceDir);
|
|
25140
25319
|
const raw = [];
|
|
25141
25320
|
if (program !== void 0) raw.push(...getExposureFindings({
|
|
25142
25321
|
entryFiles: entryPoints,
|
|
@@ -25176,16 +25355,19 @@ function bandIndex(band) {
|
|
|
25176
25355
|
* True when a dependency's current placement contradicts its recommendation:
|
|
25177
25356
|
* peer-leaning recommendations for deps in `dependencies`, or dep-leaning
|
|
25178
25357
|
* recommendations for deps in `peerDependencies`. `review` is never a
|
|
25179
|
-
* 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.
|
|
25180
25360
|
*/
|
|
25181
25361
|
function isMismatch(assessment) {
|
|
25182
25362
|
const { currentSection, recommendation } = assessment;
|
|
25183
25363
|
if (recommendation === "review") return false;
|
|
25184
|
-
if (
|
|
25185
|
-
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";
|
|
25186
25367
|
}
|
|
25187
25368
|
function bandColor(band) {
|
|
25188
25369
|
switch (band) {
|
|
25370
|
+
case "peer-with-default": return chalk.cyan;
|
|
25189
25371
|
case "peer":
|
|
25190
25372
|
case "probably-peer": return chalk.magenta;
|
|
25191
25373
|
case "review": return chalk.yellow;
|
|
@@ -25199,7 +25381,8 @@ function renderAssessment(assessment, verbose) {
|
|
|
25199
25381
|
const color = bandColor(assessment.recommendation);
|
|
25200
25382
|
const mismatch = isMismatch(assessment) ? ` ${chalk.red("MISMATCH")}` : "";
|
|
25201
25383
|
const source = assessment.recommendationSource === "score" ? "" : ` [${assessment.recommendationSource}]`;
|
|
25202
|
-
|
|
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}`);
|
|
25203
25386
|
if (!(verbose || isMismatch(assessment) || assessment.recommendation === "review")) return;
|
|
25204
25387
|
for (const finding of assessment.findings) {
|
|
25205
25388
|
const weight = finding.infinite ? " ∞" : `+${finding.weight}`.padStart(4);
|
|
@@ -25237,27 +25420,30 @@ function resolveTargetWorkspaces$1(targetPackage, inputWorkspaces) {
|
|
|
25237
25420
|
workspaceNames
|
|
25238
25421
|
};
|
|
25239
25422
|
}
|
|
25240
|
-
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
|
|
25245
|
-
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25251
|
-
|
|
25252
|
-
|
|
25253
|
-
}
|
|
25254
|
-
|
|
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) {
|
|
25255
25443
|
const results = [];
|
|
25256
25444
|
for (const workspace of targetWorkspaces) {
|
|
25257
25445
|
if (verbose === true) console.log(chalk.dim(`api-exposure: analyzing ${workspace.name}`));
|
|
25258
|
-
const config =
|
|
25259
|
-
const deplintConfig = await loadWorkspaceCommandConfig(workspace.location, "deplint");
|
|
25260
|
-
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);
|
|
25261
25447
|
const result = analyzeWorkspaceApiExposure({
|
|
25262
25448
|
cache,
|
|
25263
25449
|
config,
|
|
@@ -25266,17 +25452,45 @@ const apiExposure = async ({ dep, failOn, format, minBand, pkg, verbose, workspa
|
|
|
25266
25452
|
workspace,
|
|
25267
25453
|
workspaceNames
|
|
25268
25454
|
});
|
|
25269
|
-
|
|
25455
|
+
filterAssessmentsByDep(result, dep);
|
|
25270
25456
|
results.push(result);
|
|
25271
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) {
|
|
25272
25465
|
const allAssessments = results.flatMap((result) => result.assessments);
|
|
25273
25466
|
const warningAssessments = new Set(allAssessments.filter((assessment) => assessment.recommendation === "review"));
|
|
25274
25467
|
const mismatches = allAssessments.filter((assessment) => isMismatch(assessment));
|
|
25275
|
-
const confidence = (band) => Math.abs(bandIndex(band) - bandIndex("review"));
|
|
25276
25468
|
const failingMismatches = failOn === void 0 ? [] : mismatches.filter((assessment) => confidence(assessment.recommendation) >= confidence(failOn));
|
|
25277
25469
|
for (const assessment of mismatches) warningAssessments.add(assessment);
|
|
25278
25470
|
const errorAssessments = /* @__PURE__ */ new Set([...failingMismatches, ...allAssessments.filter((assessment) => (assessment.recommendation === "review" || isMismatch(assessment)) && assessment.findings.some((finding) => finding.level === "error"))]);
|
|
25279
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);
|
|
25280
25494
|
if (!isJsonMode() && effectiveFormat === "human") {
|
|
25281
25495
|
renderHumanApiExposure(results, {
|
|
25282
25496
|
minBand,
|
|
@@ -29551,12 +29765,17 @@ function resolvedAddFix(context, dependency, section, detail, isOptional) {
|
|
|
29551
29765
|
};
|
|
29552
29766
|
}
|
|
29553
29767
|
//#endregion
|
|
29768
|
+
//#region src/actions/deplint/types.ts
|
|
29769
|
+
function isAeiClassifierMode(mode) {
|
|
29770
|
+
return mode === "aei" || mode === "aei-next";
|
|
29771
|
+
}
|
|
29772
|
+
//#endregion
|
|
29554
29773
|
//#region src/actions/deplint/rulesMisplaced.ts
|
|
29555
29774
|
function resolvePeerDeclaredVersion(context, dep) {
|
|
29556
29775
|
return context.packageParams.peerDependencyVersions[dep] ?? (context.workspaceNames?.has(dep) ?? false ? "workspace:~" : "*");
|
|
29557
29776
|
}
|
|
29558
29777
|
function shouldSkipAeiPeerDemotion(context, dep, version) {
|
|
29559
|
-
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:");
|
|
29560
29779
|
}
|
|
29561
29780
|
/**
|
|
29562
29781
|
* A peer this package never imports is not a placement candidate — demoting
|
|
@@ -29582,13 +29801,23 @@ function evaluateMisplacedPeer(context, dep, version) {
|
|
|
29582
29801
|
mode: "to-dev",
|
|
29583
29802
|
version
|
|
29584
29803
|
};
|
|
29585
|
-
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 {
|
|
29586
29805
|
alreadyInTarget: context.packageParams.dependencies.includes(dep),
|
|
29587
29806
|
dep,
|
|
29588
29807
|
message: `peerDependency ${dep} should be a dependency — sibling workspace packages ship in lockstep; set refType "peer" in xy.config.ts to override`,
|
|
29589
29808
|
mode: "to-dep",
|
|
29590
29809
|
version
|
|
29591
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
|
+
}
|
|
29592
29821
|
if (shouldSkipAeiPeerDemotion(context, dep, version)) return void 0;
|
|
29593
29822
|
if (!isImportedAnywhere(context, dep)) return void 0;
|
|
29594
29823
|
if (context.classifyDependency(dep) !== "dependency") return void 0;
|
|
@@ -29624,6 +29853,18 @@ const misplacedDependenciesRule = {
|
|
|
29624
29853
|
if (context.isTerminalPackage) continue;
|
|
29625
29854
|
if (context.forceDeps.has(dep)) continue;
|
|
29626
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
|
+
}
|
|
29627
29868
|
if (context.forcePeers.has(dep) || context.classifyDependency(dep) === "peer") {
|
|
29628
29869
|
const reason = context.forcePeers.has(dep) ? "configured as refType \"peer\"" : "external runtime dep — consumers should control the version";
|
|
29629
29870
|
context.report({
|
|
@@ -29648,6 +29889,10 @@ const misplacedDependenciesRule = {
|
|
|
29648
29889
|
fromSection: "dependencies",
|
|
29649
29890
|
toSection: "devDependencies"
|
|
29650
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
|
+
}
|
|
29651
29896
|
const optional = context.forcePeerOptional.get(data.dep);
|
|
29652
29897
|
const fixes = [{
|
|
29653
29898
|
action: "move",
|
|
@@ -29685,9 +29930,10 @@ const misplacedPeerDependenciesRule = {
|
|
|
29685
29930
|
});
|
|
29686
29931
|
}
|
|
29687
29932
|
},
|
|
29688
|
-
resolveFixes(diagnostic) {
|
|
29933
|
+
resolveFixes(diagnostic, context) {
|
|
29689
29934
|
const data = diagnostic.data;
|
|
29690
29935
|
if (!data) return [];
|
|
29936
|
+
if (data.mode === "add-dep-companion") return [resolvedAddFix(context, data.dep, "dependencies", "added dependency companion for peer-with-default")];
|
|
29691
29937
|
if (data.alreadyInTarget ?? false) return [{
|
|
29692
29938
|
action: "remove",
|
|
29693
29939
|
dependency: data.dep,
|
|
@@ -29847,11 +30093,13 @@ const unlistedDependenciesRule = {
|
|
|
29847
30093
|
});
|
|
29848
30094
|
continue;
|
|
29849
30095
|
}
|
|
29850
|
-
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";
|
|
29851
30099
|
context.report({
|
|
29852
30100
|
data: {
|
|
29853
30101
|
imp,
|
|
29854
|
-
mode: isPeer ? "peer-companion" : "direct",
|
|
30102
|
+
mode: isPeerWithDefault ? "peer-with-default" : isPeer ? "peer-companion" : "direct",
|
|
29855
30103
|
section
|
|
29856
30104
|
},
|
|
29857
30105
|
dependency: imp,
|
|
@@ -29864,6 +30112,10 @@ const unlistedDependenciesRule = {
|
|
|
29864
30112
|
const data = diagnostic.data;
|
|
29865
30113
|
if (!data) return [];
|
|
29866
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
|
+
}
|
|
29867
30119
|
if (data.mode === "peer-companion") {
|
|
29868
30120
|
const optional = resolvePromotedPeerOptional(context, data.imp);
|
|
29869
30121
|
return ["peerDependencies", "devDependencies"].map((section) => resolvedAddFix(context, data.imp, section, `added to ${section}`, section === "peerDependencies" ? optional : void 0));
|
|
@@ -30175,11 +30427,14 @@ const redundantPeerDependenciesRule = {
|
|
|
30175
30427
|
},
|
|
30176
30428
|
evaluate(context) {
|
|
30177
30429
|
const findings = findRedundantPeerDeps(context.packageParams, context.exclude);
|
|
30178
|
-
for (const dep of findings)
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
|
|
30182
|
-
|
|
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
|
+
}
|
|
30183
30438
|
},
|
|
30184
30439
|
resolveFixes(diagnostic) {
|
|
30185
30440
|
const data = diagnostic.data;
|
|
@@ -30318,10 +30573,10 @@ const builtInDeplintPlugin = {
|
|
|
30318
30573
|
severity: "warning"
|
|
30319
30574
|
},
|
|
30320
30575
|
evaluate(context) {
|
|
30321
|
-
if (context.classifierMode
|
|
30576
|
+
if (!isAeiClassifierMode(context.classifierMode) || context.isTerminalPackage) return;
|
|
30322
30577
|
const candidates = /* @__PURE__ */ new Set([...context.packageParams.dependencies, ...context.packageParams.peerDependencies]);
|
|
30323
30578
|
for (const dep of candidates) {
|
|
30324
|
-
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;
|
|
30325
30580
|
if (context.packageParams.dependencyVersions[dep]?.startsWith("workspace:")) continue;
|
|
30326
30581
|
if (context.workspaceNames?.has(dep) ?? false) continue;
|
|
30327
30582
|
if (dep.startsWith("@types/")) continue;
|
|
@@ -30377,6 +30632,7 @@ function buildUnusedDependencyExclude(options, requiredTransitivePeers) {
|
|
|
30377
30632
|
...options.forceDeps ?? [],
|
|
30378
30633
|
...options.forceDevs ?? [],
|
|
30379
30634
|
...options.forcePeers ?? [],
|
|
30635
|
+
...options.forcePeerWithDefault ?? [],
|
|
30380
30636
|
...options.forcePeerOptional?.keys() ?? []
|
|
30381
30637
|
]);
|
|
30382
30638
|
}
|
|
@@ -30386,32 +30642,40 @@ function buildUnusedPeerDependencyExclude(options, runtimeRootedRequired) {
|
|
|
30386
30642
|
...runtimeRootedRequired,
|
|
30387
30643
|
...options.forceDeps ?? [],
|
|
30388
30644
|
...options.forcePeers ?? [],
|
|
30645
|
+
...options.forcePeerWithDefault ?? [],
|
|
30389
30646
|
...options.forcePeerOptional?.keys() ?? []
|
|
30390
30647
|
]);
|
|
30391
30648
|
}
|
|
30392
30649
|
const sharedAeiProgramCache = createSharedProgramCache();
|
|
30393
30650
|
/**
|
|
30394
30651
|
* Builds the dep-vs-peer classifier attached to the workspace context.
|
|
30395
|
-
* `legacy` preserves the historical external-default rule; `aei`
|
|
30396
|
-
* `xy api-exposure` analyzer lazily (once per snapshot,
|
|
30397
|
-
*
|
|
30398
|
-
*
|
|
30399
|
-
*
|
|
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.
|
|
30400
30658
|
*/
|
|
30401
30659
|
function buildDependencyClassifier(workspace, options, isTerminal, peerDependencies, externalDistImports) {
|
|
30402
|
-
|
|
30660
|
+
const classifier = options.classifier ?? "legacy";
|
|
30661
|
+
if (!isAeiClassifierMode(classifier)) return (dependency) => shouldBePeerDependency(dependency, workspace.location, peerDependencies, externalDistImports, options.workspaceNames) ? "peer" : "dependency";
|
|
30403
30662
|
let recommendations;
|
|
30404
30663
|
return (dependency) => {
|
|
30664
|
+
if (options.forcePeerWithDefault?.has(dependency) ?? false) return "peer-with-default";
|
|
30405
30665
|
if (recommendations === void 0) {
|
|
30406
30666
|
const result = analyzeWorkspaceApiExposure({
|
|
30407
30667
|
cache: sharedAeiProgramCache,
|
|
30408
|
-
config: normalizeApiExposureConfig(
|
|
30668
|
+
config: normalizeApiExposureConfig({
|
|
30669
|
+
...options.apiExposureConfig,
|
|
30670
|
+
peerWithDefault: classifier === "aei-next" || options.apiExposureConfig?.peerWithDefault === true
|
|
30671
|
+
}),
|
|
30409
30672
|
isTerminal,
|
|
30410
30673
|
workspace,
|
|
30411
30674
|
workspaceNames: options.workspaceNames
|
|
30412
30675
|
});
|
|
30413
30676
|
recommendations = new Map(result.assessments.map((assessment) => {
|
|
30414
30677
|
switch (assessment.recommendation) {
|
|
30678
|
+
case "peer-with-default": return [assessment.dependency, "peer-with-default"];
|
|
30415
30679
|
case "peer":
|
|
30416
30680
|
case "probably-peer": return [assessment.dependency, "peer"];
|
|
30417
30681
|
case "review": return [assessment.dependency, "review"];
|
|
@@ -30422,6 +30686,18 @@ function buildDependencyClassifier(workspace, options, isTerminal, peerDependenc
|
|
|
30422
30686
|
return recommendations.get(dependency) ?? "dependency";
|
|
30423
30687
|
};
|
|
30424
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
|
+
}
|
|
30425
30701
|
function buildWorkspaceContext(workspace, options = {}) {
|
|
30426
30702
|
const { sourceExclude, terminalOverride, phases } = options;
|
|
30427
30703
|
const findFilesStarted = performance.now();
|
|
@@ -30445,15 +30721,7 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
30445
30721
|
const packageMetaStarted = performance.now();
|
|
30446
30722
|
const packageJsonPath = `${workspace.location}/package.json`;
|
|
30447
30723
|
const packageParams = getDependenciesFromPackageJson(packageJsonPath);
|
|
30448
|
-
const
|
|
30449
|
-
const peerForwarding = forwardingMode === "always" ? void 0 : {
|
|
30450
|
-
importedModules: forwardingMode === "when-exposed" ? /* @__PURE__ */ new Set([...sourceParams.externalDistImports, ...sourceParams.externalDistTypeImports]) : /* @__PURE__ */ new Set([
|
|
30451
|
-
...sourceParams.externalAllImports,
|
|
30452
|
-
...sourceParams.externalDistImports,
|
|
30453
|
-
...sourceParams.externalDistTypeImports
|
|
30454
|
-
]),
|
|
30455
|
-
mode: forwardingMode
|
|
30456
|
-
};
|
|
30724
|
+
const peerForwarding = resolvePeerForwardingPolicy(options.classifier, options.apiExposureConfig, sourceParams);
|
|
30457
30725
|
const requiredTransitivePeers = getRequiredNonOptionalTransitivePeers(workspace.location, packageParams);
|
|
30458
30726
|
const runtimeRootedRequired = new Set([...getRuntimeRootedNonOptionalTransitivePeers(workspace.location, packageParams)].filter((peer) => isPeerForwarded(peerForwarding, peer)));
|
|
30459
30727
|
const packageClassification = classifyDeplintPackage(workspace.location, terminalOverride);
|
|
@@ -30470,6 +30738,7 @@ function buildWorkspaceContext(workspace, options = {}) {
|
|
|
30470
30738
|
forceDeps: options.forceDeps ?? /* @__PURE__ */ new Set(),
|
|
30471
30739
|
forceDevs: options.forceDevs ?? /* @__PURE__ */ new Set(),
|
|
30472
30740
|
forcePeerOptional: options.forcePeerOptional ?? /* @__PURE__ */ new Map(),
|
|
30741
|
+
forcePeerWithDefault: options.forcePeerWithDefault ?? /* @__PURE__ */ new Set(),
|
|
30473
30742
|
forcePeers: options.forcePeers ?? /* @__PURE__ */ new Set(),
|
|
30474
30743
|
isTerminalPackage: packageClassification.isTerminalPackage,
|
|
30475
30744
|
packageKind: packageClassification.kind,
|
|
@@ -30549,7 +30818,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30549
30818
|
const wsConfig = await loadWorkspaceCommandConfig(workspace.location, "deplint");
|
|
30550
30819
|
const rules = await loadDeplintRules(wsConfig);
|
|
30551
30820
|
const classifier = options.classifier ?? wsConfig.classifier ?? "legacy";
|
|
30552
|
-
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;
|
|
30553
30822
|
const configuredExclude = normalizeConfigList(wsConfig.exclude);
|
|
30554
30823
|
const cliExclude = normalizeConfigList(options.cliExclude);
|
|
30555
30824
|
const sourceExclude = [...configuredExclude, ...cliExclude];
|
|
@@ -30557,6 +30826,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30557
30826
|
const forceDeps = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "dep").map(([name]) => name));
|
|
30558
30827
|
const forceDevs = new Set(packageEntries.filter(([, cfg]) => cfg.refType === "dev").map(([name]) => name));
|
|
30559
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));
|
|
30560
30830
|
const forcePeerOptional = /* @__PURE__ */ new Map();
|
|
30561
30831
|
for (const [name, cfg] of packageEntries) if (typeof cfg.peerOptional === "boolean") forcePeerOptional.set(name, cfg.peerOptional);
|
|
30562
30832
|
const rangeStyleOptions = rules.find((rule) => rule.id === "dep.peerDependencies.range-style")?.options ?? {};
|
|
@@ -30576,6 +30846,7 @@ async function loadWorkspaceEvaluationContext(workspace, options, workspaceNames
|
|
|
30576
30846
|
forceDeps,
|
|
30577
30847
|
forceDevs,
|
|
30578
30848
|
forcePeerOptional,
|
|
30849
|
+
forcePeerWithDefault,
|
|
30579
30850
|
forcePeers,
|
|
30580
30851
|
peerRangeBound,
|
|
30581
30852
|
peerRangeForm,
|
|
@@ -51025,7 +51296,8 @@ const BAND_CHOICES = [
|
|
|
51025
51296
|
"probably-dependency",
|
|
51026
51297
|
"review",
|
|
51027
51298
|
"probably-peer",
|
|
51028
|
-
"peer"
|
|
51299
|
+
"peer",
|
|
51300
|
+
"peer-with-default"
|
|
51029
51301
|
];
|
|
51030
51302
|
const apiExposureCommand = {
|
|
51031
51303
|
command: "api-exposure [package]",
|
|
@@ -51137,8 +51409,12 @@ const deplintCommand = {
|
|
|
51137
51409
|
description: "Source paths to exclude from import scanning (comma-separated or repeated)",
|
|
51138
51410
|
type: "array"
|
|
51139
51411
|
}).option("classifier", {
|
|
51140
|
-
choices: [
|
|
51141
|
-
|
|
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)",
|
|
51142
51418
|
type: "string"
|
|
51143
51419
|
}).option("fix", {
|
|
51144
51420
|
alias: "f",
|