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

refactor: Make all requiresCategory and scriptSrc fields an array #176

Merged
merged 3 commits into from
Jul 9, 2024
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
12 changes: 2 additions & 10 deletions .github/workflows/scripts/technology_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,12 @@ class StringOrArrayOrDictValidator(AbstractValidator):
def get_type(self) -> list[Type]:
return [str, list, dict]


class IntOrArrayValidator(AbstractValidator):
def get_type(self) -> list[Type]:
return [int, list]


class DictValidator(RegexValidator):
def get_type(self) -> list[Type]:
return [dict]


class CategoryValidator(IntOrArrayValidator):
class CategoryValidator(ArrayValidator):
def __init__(self, categories: list[int], required: bool = False):
super().__init__(required)
self._categories: Final[list[int]] = categories
Expand All @@ -179,8 +173,6 @@ def _validate(self, tech_name: str, data: Any) -> bool:
type_validator: bool = super()._validate(tech_name, data)
if not type_validator:
return False
if isinstance(data, int):
data = [data]
for category_id in data:
if category_id not in self._categories:
self._set_custom_error(CategoryNotFoundException(f"The category '{category_id}' for tech '{tech_name}' does not exist!"))
Expand Down Expand Up @@ -260,7 +252,7 @@ def __init__(self, file_name: str):
"url": StringOrArrayValidator(contains_regex=True),
"xhr": StringOrArrayValidator(contains_regex=True),
"meta": DictValidator(contains_regex=True),
"scriptSrc": StringOrArrayValidator(contains_regex=True),
"scriptSrc": ArrayValidator(contains_regex=True),
"scripts": StringOrArrayValidator(contains_regex=True),
"html": ArrayValidator(contains_regex=True),
"certIssuer": StringValidator()
Expand Down
30 changes: 8 additions & 22 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,10 @@
}
},
"requiresCategory": {
"oneOf": [
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "number"
}
]
"type": "array",
"items": {
"type": "number"
}
},
"meta": {
"type": "object",
Expand All @@ -185,17 +178,10 @@
}
},
"scriptSrc": {
"oneOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/non-empty-non-blank-string"
}
},
{
"$ref": "#/definitions/non-empty-non-blank-string"
}
]
"type": "array",
"items": {
"$ref": "#/definitions/non-empty-non-blank-string"
}
},
"scripts": {
"oneOf": [
Expand Down
28 changes: 21 additions & 7 deletions src/technologies/_.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"recurring"
],
"saas": true,
"scriptSrc": "bitrix(?:\\.info/|/js/main/core)",
"scriptSrc": [
"bitrix(?:\\.info/|/js/main/core)"
],
"website": "https://www.1c-bitrix.ru"
},
"2B Advice": {
Expand All @@ -37,7 +39,9 @@
"BBCookieControler": ""
},
"saas": true,
"scriptSrc": "2badvice-cdn\\.azureedge\\.net",
"scriptSrc": [
"2badvice-cdn\\.azureedge\\.net"
],
"website": "https://www.2b-advice.com/en/data-privacy-software/cookie-consent-plugin/"
},
"30namaPlayer": {
Expand Down Expand Up @@ -100,7 +104,9 @@
"poa"
],
"saas": true,
"scriptSrc": "4tellcdn\\.azureedge\\.net",
"scriptSrc": [
"4tellcdn\\.azureedge\\.net"
],
"website": "https://4-tell.com"
},
"42stores": {
Expand Down Expand Up @@ -150,7 +156,9 @@
"recurring",
"low"
],
"scriptSrc": "\\.5centscdn\\.com/",
"scriptSrc": [
"\\.5centscdn\\.com/"
],
"website": "https://www.5centscdn.net"
},
"6sense": {
Expand All @@ -169,7 +177,9 @@
"recurring"
],
"saas": true,
"scriptSrc": "\\.6sc\\.co/",
"scriptSrc": [
"\\.6sc\\.co/"
],
"website": "https://6sense.com"
},
"8base": {
Expand All @@ -196,7 +206,9 @@
"dom": "model-viewer",
"icon": "model-viewer.svg",
"oss": true,
"scriptSrc": "/model-viewer/dist/model-viewer\\.min\\.js",
"scriptSrc": [
"/model-viewer/dist/model-viewer\\.min\\.js"
],
"website": "https://modelviewer.dev"
},
"@sulu/web": {
Expand All @@ -219,7 +231,9 @@
"_hyperscript": ""
},
"oss": true,
"scriptSrc": "//unpkg\\.com/hyperscript\\.org@([\\d\\.]+)\\;version:\\1",
"scriptSrc": [
"//unpkg\\.com/hyperscript\\.org@([\\d\\.]+)\\;version:\\1"
],
"website": "https://hyperscript.org"
}
}
Loading