Skip to content

Commit 7ff954f

Browse files
authored
chore: validate manifest key/id pairings (#321)
1 parent c564d36 commit 7ff954f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎scripts/validate-manifests.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export async function validateManifests() {
3131
}
3232

3333
for (const [id, replacement] of Object.entries(manifest.replacements)) {
34+
if (replacement.id !== id) {
35+
throw new Error(
36+
`${manifestPath}: replacement key "${id}" does not match its id property "${replacement.id}"`
37+
);
38+
}
39+
3440
if (!replacement.webFeatureId) continue;
3541

3642
const {featureId, compatKey} = replacement.webFeatureId;
@@ -48,6 +54,22 @@ export async function validateManifests() {
4854
);
4955
}
5056
}
57+
58+
for (const [key, mapping] of Object.entries(manifest.mappings)) {
59+
if (mapping.type === 'module' && mapping.moduleName !== key) {
60+
throw new Error(
61+
`${manifestPath}: mapping key "${key}" does not match its moduleName "${mapping.moduleName}"`
62+
);
63+
}
64+
65+
for (const replacementId of mapping.replacements) {
66+
if (!manifest.replacements[replacementId]) {
67+
throw new Error(
68+
`${manifestPath}: mapping "${key}" references unknown replacement "${replacementId}"`
69+
);
70+
}
71+
}
72+
}
5173
}
5274
console.log('OK');
5375
}

0 commit comments

Comments
 (0)