mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-10 03:19:44 +00:00
Consolidate frontend (#468)
* Consolidate frontend * Remove no longer needed cd * Get Roboto from bower_components * Remove external dependency from update_mdi.py * Copy leaflet assets on build time * Tweak Dockerfile * Create Python package * Set zip_safe to False * Update build scripts * Version bump to 20171021.0 * Fix service worker * Version bump to 20171021.2 * Update docker ignore * Tweak Dockerfile thanks to Adam
This commit is contained in:
36
script/fingerprint_frontend.py
Executable file
36
script/fingerprint_frontend.py
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a file with all md5 hashes of the assets."""
|
||||
|
||||
from collections import OrderedDict
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
fingerprint_file = './hass_frontend/__init__.py'
|
||||
base_dir = 'hass_frontend/'
|
||||
|
||||
|
||||
def fingerprint():
|
||||
"""Fingerprint the frontend files."""
|
||||
files = (glob.glob(base_dir + '**/*.html') +
|
||||
glob.glob(base_dir + '*.html') +
|
||||
glob.glob(base_dir + 'core.js') +
|
||||
glob.glob(base_dir + 'compatibility.js'))
|
||||
|
||||
md5s = OrderedDict()
|
||||
|
||||
for fil in sorted(files):
|
||||
name = fil[len(base_dir):]
|
||||
with open(fil) as fp:
|
||||
md5 = hashlib.md5(fp.read().encode('utf-8')).hexdigest()
|
||||
md5s[name] = md5
|
||||
|
||||
template = "FINGERPRINTS = {}\n"
|
||||
result = template.format(json.dumps(md5s, indent=4))
|
||||
|
||||
with open(fingerprint_file, 'at') as fp:
|
||||
fp.write(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fingerprint()
|
||||
Reference in New Issue
Block a user