Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple specification URLs #147

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import YAML from 'yaml';

/** Web platform feature */
export interface FeatureData {
/** Specification URL
* @format uri
*/
spec: string;
/** Specification */
spec: specification_url | [specification_url, specification_url, ...specification_url[]];
/** caniuse.com identifier */
caniuse?: string;
/** Whether a feature is considered a "baseline" web platform feature and when it achieved that status */
Expand All @@ -31,6 +29,11 @@ interface SupportStatus {
support?: {[K in browserIdentifier]?: string};
}

/** Specification URL
* @format uri
*/
type specification_url = string;

/** Usage stats URL
* @format uri
*/
Expand Down
20 changes: 17 additions & 3 deletions schemas/defs.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,23 @@
"type": "array"
},
"spec": {
"description": "Specification URL",
"format": "uri",
"type": "string"
"anyOf": [
{
"description": "Specification URL",
"format": "uri",
"type": "string"
},
{
"items": {
"description": "Specification URL",
"format": "uri",
"type": "string"
},
"minItems": 2,
"type": "array"
}
],
"description": "Specifications"
},
"status": {
"additionalProperties": false,
Expand Down
13 changes: 8 additions & 5 deletions scripts/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ let checked = 0;
let errors = 0;

for (const [id, data] of Object.entries(features)) {
const url = new URL(data.spec);
if (!isOK(url)) {
console.error(`URL for ${id} not in web-specs: ${url.toString()}`);
errors++;
const specs = Array.isArray(data.spec) ? data.spec : [data.spec];
for (const spec of specs) {
const url = new URL(spec);
if (!isOK(url)) {
console.error(`URL for ${id} not in web-specs: ${url.toString()}`);
errors++;
}
checked++;
}
checked++;
}

if (errors) {
Expand Down