-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rule to detect echidna deliverer change (#1710)
* add rule deliverer-change to echidna files * add test for change of delivers * fix test * use w3c-api for previous id * fix test * fix test * fix test * remove unused var * use moch for good document * fix test * Update lib/rules/echidna/deliverer-change.js Co-authored-by: Denis Ah-Kang <[email protected]> * Update lib/l10n-en_GB.js Co-authored-by: Denis Ah-Kang <[email protected]> * refine get previous IDs * better regexp to getPreviousDelivererIDs * address #1710 (comment) --------- Co-authored-by: Denis Ah-Kang <[email protected]>
- Loading branch information
1 parent
a7262b1
commit 25c225d
Showing
19 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import w3cApi from 'node-w3capi'; | ||
|
||
w3cApi.apiKey = process.env.W3C_API_KEY; | ||
|
||
const self = { | ||
name: 'echidna.deliverer-change', | ||
section: 'metadata', | ||
rule: 'delivererID', | ||
}; | ||
|
||
export const { name } = self; | ||
|
||
function getPreviousDelivererIDs(shortname, previousUrl) { | ||
const date = previousUrl.match(/-(\d{8})\/$/); | ||
if (date) | ||
return new Promise(resolve => { | ||
// e.g. https://api.w3.org/specifications/WGSL/versions/20230221/deliverers | ||
w3cApi | ||
.specification(shortname) | ||
.version(date[1]) | ||
.deliverers() | ||
.fetch({ embed: true }, (err, data) => { | ||
resolve(data && data.map(obj => obj.id)); | ||
}); | ||
}); | ||
return new Promise(resolve => { | ||
resolve([]); | ||
}); | ||
} | ||
|
||
/** | ||
* @param sr | ||
* @param done | ||
*/ | ||
export async function check(sr, done) { | ||
const previousVersion = await sr.getPreviousVersion(sr); | ||
const shortname = await sr.getShortname(sr); | ||
|
||
if (!previousVersion) { | ||
return done(); | ||
} | ||
|
||
const previousDelivererIDs = await getPreviousDelivererIDs( | ||
shortname, | ||
previousVersion | ||
); | ||
const delivererIDs = await sr.getDelivererIDs(); | ||
|
||
const delivererChanged = | ||
delivererIDs.sort().toString() !== | ||
previousDelivererIDs.sort().toString(); | ||
|
||
if (delivererChanged) { | ||
sr.error(self, 'deliverer-changed', { | ||
this: delivererIDs.sort().toString(), | ||
previous: previousDelivererIDs.sort().toString(), | ||
}); | ||
} | ||
|
||
done(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters