Mark references into missing module folders
This commit is contained in:
@@ -44,6 +44,7 @@ export function buildFindings({ files, references, i18n, packageActivity }={}) {
|
||||
const wildcardReferences = [];
|
||||
const findings = [];
|
||||
const inactiveModuleReferenceIds = new Set();
|
||||
const missingModuleReferenceIds = new Set();
|
||||
|
||||
for (const reference of resolvedReferences) {
|
||||
const normalized = reference.normalized;
|
||||
@@ -85,6 +86,10 @@ export function buildFindings({ files, references, i18n, packageActivity }={}) {
|
||||
|
||||
const ownerRelation = compareOwner(reference.sourceScope, file.ownerHint);
|
||||
if (ownerRelation === "non-package-to-package") {
|
||||
if (isMissingModuleTarget(file, packageActivity)) {
|
||||
missingModuleReferenceIds.add(file.ownerHint.ownerId);
|
||||
continue;
|
||||
}
|
||||
if (isInactiveModuleTarget(file, packageActivity)) {
|
||||
inactiveModuleReferenceIds.add(file.ownerHint.ownerId);
|
||||
continue;
|
||||
@@ -144,7 +149,7 @@ export function buildFindings({ files, references, i18n, packageActivity }={}) {
|
||||
|
||||
return {
|
||||
findings,
|
||||
notices: createNotices({ inactiveModuleReferenceIds, packageActivity, i18n })
|
||||
notices: createNotices({ inactiveModuleReferenceIds, missingModuleReferenceIds, packageActivity, i18n })
|
||||
};
|
||||
}
|
||||
|
||||
@@ -239,19 +244,42 @@ function isInactiveModuleTarget(file, packageActivity) {
|
||||
return active === false;
|
||||
}
|
||||
|
||||
function createNotices({ inactiveModuleReferenceIds, packageActivity, i18n }) {
|
||||
const moduleIds = [...inactiveModuleReferenceIds].sort((a, b) => a.localeCompare(b));
|
||||
if (!moduleIds.length) return [];
|
||||
const moduleLabels = moduleIds.map(id => packageActivity?.moduleLabels?.get?.(id) ?? id);
|
||||
return [{
|
||||
kind: "inactive-module-references",
|
||||
severity: "info",
|
||||
moduleIds,
|
||||
moduleLabels,
|
||||
message: format(i18n, "KSA.Notice.InactiveModuleReferences", {
|
||||
modules: moduleLabels.join(", ")
|
||||
})
|
||||
}];
|
||||
function isMissingModuleTarget(file, packageActivity) {
|
||||
if (file.ownerHint?.ownerType !== "module") return false;
|
||||
return packageActivity?.modules?.has?.(file.ownerHint.ownerId) === false;
|
||||
}
|
||||
|
||||
function createNotices({ inactiveModuleReferenceIds, missingModuleReferenceIds, packageActivity, i18n }) {
|
||||
const notices = [];
|
||||
|
||||
const inactiveModuleIds = [...inactiveModuleReferenceIds].sort((a, b) => a.localeCompare(b));
|
||||
if (inactiveModuleIds.length) {
|
||||
const moduleLabels = inactiveModuleIds.map(id => packageActivity?.moduleLabels?.get?.(id) ?? id);
|
||||
notices.push({
|
||||
kind: "inactive-module-references",
|
||||
severity: "info",
|
||||
moduleIds: inactiveModuleIds,
|
||||
moduleLabels,
|
||||
message: format(i18n, "KSA.Notice.InactiveModuleReferences", {
|
||||
modules: moduleLabels.join(", ")
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
const missingModuleIds = [...missingModuleReferenceIds].sort((a, b) => a.localeCompare(b));
|
||||
if (missingModuleIds.length) {
|
||||
notices.push({
|
||||
kind: "missing-module-references",
|
||||
severity: "info",
|
||||
moduleIds: missingModuleIds,
|
||||
moduleLabels: missingModuleIds,
|
||||
message: format(i18n, "KSA.Notice.MissingModuleReferences", {
|
||||
modules: missingModuleIds.join(", ")
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return notices;
|
||||
}
|
||||
|
||||
function isDerivedSceneThumbnail(file) {
|
||||
|
||||
Reference in New Issue
Block a user