build: check config.json validity during build (#38354)
This commit is contained in:
parent
7fac63ce85
commit
e0ad52f1d9
|
@ -3,6 +3,8 @@
|
|||
import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
@ -10,6 +12,7 @@ parser.add_argument('--overlay', dest='overlay', type=str)
|
|||
args = parser.parse_args()
|
||||
|
||||
# get themes
|
||||
errors = False
|
||||
themes = []
|
||||
for dirname in sorted(os.listdir('static')):
|
||||
config = os.path.join('static', dirname, 'config.json')
|
||||
|
@ -28,8 +31,41 @@ for dirname in sorted(os.listdir('static')):
|
|||
if args.overlay:
|
||||
theme['module'] = 'publik-base'
|
||||
theme['overlay'] = args.overlay
|
||||
|
||||
# validation checks
|
||||
theme_color = theme['variables'].get('theme_color')
|
||||
if theme_color and not re.match(r'#[0-9a-fA-F]{6}$', theme_color):
|
||||
print('E: invalid theme color for %s (%s)' % (dirname, theme_color), file=sys.stderr)
|
||||
errors = True
|
||||
if theme.get('settings'):
|
||||
for settings_app in theme['settings']:
|
||||
if settings_app not in ('authentic2', 'combo', 'fargo', 'wcs'):
|
||||
print('E: unknown application key for %s (%s)' % (dirname, settings_app), file=sys.stderr)
|
||||
errors = True
|
||||
continue
|
||||
if settings_app == 'combo':
|
||||
for settings_key in theme['settings'][settings_app].keys():
|
||||
if settings_key not in (
|
||||
'COMBO_ASSET_SLOTS.update',
|
||||
'COMBO_MAP_ATTRIBUTION',
|
||||
'COMBO_MAP_DEFAULT_POSITION',
|
||||
'COMBO_MAP_MAX_BOUNDS',
|
||||
'COMBO_MAP_TILE_URLTEMPLATE',
|
||||
'COMBO_PUBLIC_TEMPLATES.update',
|
||||
'JSON_CELL_TYPES.update',
|
||||
'PWA_NOTIFICATION_BADGE_URL',
|
||||
'PWA_NOTIFICATION_ICON_URL',
|
||||
'WCS_CATEGORY_ASSET_SLOTS',
|
||||
'WCS_FORM_ASSET_SLOTS',
|
||||
):
|
||||
print('E: unknown settings key for %s (%s)' % (dirname, settings_key), file=sys.stderr)
|
||||
errors = True
|
||||
|
||||
themes.append(theme)
|
||||
|
||||
if errors:
|
||||
sys.exit(1)
|
||||
|
||||
# get parameters
|
||||
parameters = {'primary-color': {'type': 'color'}}
|
||||
if os.path.exists('help/fr/misc-scss.page'):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"label": "Alpes-Maritimes 2018",
|
||||
"settings": {
|
||||
"combo": {
|
||||
"COMBO_ASSET_SLOTS": {
|
||||
"COMBO_ASSET_SLOTS.update": {
|
||||
"social:dossiers:autonomie": {
|
||||
"label": "Pictogramme dossier autonomie"
|
||||
},
|
||||
|
@ -10,7 +10,7 @@
|
|||
"label": "Pictogramme dossier handicap"
|
||||
}
|
||||
},
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"desappairage": {
|
||||
"form": [
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
"settings": {
|
||||
"combo": {
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"cd13_liste_des_dossiers": {
|
||||
"cache_duration": 10,
|
||||
"name": "Liste des dossiers",
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
},
|
||||
"settings": {
|
||||
"combo": {
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"references": {
|
||||
"name": "References",
|
||||
"url": "https://gestion.entrouvert.org/api/references/",
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"corner1": {"lat": "45.2307", "lng": "5.6640"},
|
||||
"corner2": {"lat": "45.1179", "lng": "5.7980"}
|
||||
},
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"user": {
|
||||
"cache_duration": 60,
|
||||
"name": "Cellule usager",
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
},
|
||||
"COMBO_MAP_TILE_URLTEMPLATE": "https://tiles.entrouvert.org/hdm/{z}/{x}/{y}.png",
|
||||
"COMBO_MAP_ATTRIBUTION": "© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>",
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"parkings": {
|
||||
"url": "https://places-parkings.quimper-communaute.bzh/WebServiceInfosGeolocFront.asmx/GetGeoJsonListDysplayItemByType?type=parkings",
|
||||
"name": "Parkings",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
"settings": {
|
||||
"combo": {
|
||||
"JSON_CELL_TYPES": {
|
||||
"JSON_CELL_TYPES.update": {
|
||||
"communes-toulouse": {
|
||||
"url": "https://data.toulouse-metropole.fr/api/records/1.0/search/?dataset=communes-de-toulouse-metropole&sort=ville&rows=100",
|
||||
"name": "Communes de Toulouse",
|
||||
|
|
Loading…
Reference in New Issue