mirror of
https://github.com/home-assistant/frontend.git
synced 2026-10-05 15:29:00 +01:00
Polymer 3 modulize (#1154)
* Version bump to 20180510.1 * Fix hass util * Fix translations * Bye paper-time-input * Add webpack config * Add webpack to package.json * Fix translation import * Disable web animations polyfill bad import * Disable importHref import * Update webpack config to build authorize.js * Build translations json * Build frontend correctly * Run eslint --fix * Load markdown JS on demand (#1155) * Add HTML imports (#1160) * Fix localize (#1161) * Fix Roboto in build (#1162) * Load web animations polyfill (#1163) * P3: Fix chart js (#1164) * P3: Fix Chart JS * Update timeline package * P3: panel resolver (#1165) * WIP * Initial importing of panels * Fix panel resolver * Fix automation and script editor (#1166) * Expose Polymer and Polymer.Element on window (#1167) * Remove unused import * eslint --fix * Es5 build (#1168) * Build for ES5 * Fix build_frontend * Remove stale comment * Migrate to use paper-material-styles (#1170) * Send parsed date to history/logbook (#1171) * Fork app storage behavior (#1172) * Add paper input with type time (#1173) * Fix authorize * Lint * Sort imports * Lint * Remove eslint-html * Do not lint authorize.html * Fix polymer lint * Try chrome 62 for wct * P3: Add patched iconset (#1175) * Add patched iconset * Lint * Test with latest Chrome again * Use less window.hassUtil * Teporarily use my fecha fork * Import correct intl.messageFormat * Update wct-browser-legacy to 1.0.0 * Include polyfill in right place * Fix IntlMessageFormat * Fix test not having a global scope * Rollup <_< * Fork app-localize-behavior * Disable wct tests * Lint
This commit is contained in:
1 parent
205d6a8347
commit
a4afc2e37a
274 files changed
+12972
-10037
No files matched your search
+12
-26
@@ -16,45 +16,33 @@ cp -r public/__init__.py $OUTPUT_DIR_ES5/
|
||||
|
||||
# Build frontend
|
||||
BUILD_DEV=0 ./node_modules/.bin/gulp
|
||||
NODE_ENV=production webpack -p
|
||||
BUILD_DEV=0 ./node_modules/.bin/gulp authorize authorize-es5
|
||||
|
||||
# Entry points
|
||||
cp build/*.js build/*.html $OUTPUT_DIR
|
||||
cp build-es5/*.js build-es5/*.html $OUTPUT_DIR_ES5
|
||||
|
||||
# Panels
|
||||
mkdir $OUTPUT_DIR/panels
|
||||
cp build/panels/*.html $OUTPUT_DIR/panels
|
||||
mkdir $OUTPUT_DIR_ES5/panels
|
||||
cp build-es5/panels/*.html $OUTPUT_DIR_ES5/panels
|
||||
|
||||
# Chart code
|
||||
cp build/src/resources/ha-chart-scripts.html $OUTPUT_DIR
|
||||
cp build-es5/src/resources/ha-chart-scripts.html $OUTPUT_DIR_ES5
|
||||
# Copy frontend to output
|
||||
cp build/core.js $OUTPUT_DIR
|
||||
cp build/webpack/* $OUTPUT_DIR
|
||||
cp build-es5/core.js $OUTPUT_DIR_ES5
|
||||
cp build-es5/webpack/* $OUTPUT_DIR_ES5
|
||||
cp build-es5/compatibility.js $OUTPUT_DIR_ES5
|
||||
|
||||
# Translations
|
||||
cp -r build-translations/output $OUTPUT_DIR/translations
|
||||
|
||||
# Local Roboto
|
||||
cp -r bower_components/font-roboto-local/fonts $OUTPUT_DIR
|
||||
cp -r node_modules/@polymer/font-roboto-local/fonts $OUTPUT_DIR
|
||||
|
||||
# Polyfill web components
|
||||
cp bower_components/webcomponentsjs/webcomponents-lite.js $OUTPUT_DIR
|
||||
cp bower_components/webcomponentsjs/custom-elements-es5-adapter.js $OUTPUT_DIR_ES5
|
||||
cp node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js $OUTPUT_DIR
|
||||
cp node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js $OUTPUT_DIR_ES5
|
||||
|
||||
# Icons
|
||||
script/update_mdi.py
|
||||
|
||||
# Leaflet
|
||||
mkdir $OUTPUT_DIR/images/leaflet
|
||||
cp bower_components/leaflet/dist/leaflet.css $OUTPUT_DIR/images/leaflet
|
||||
cp -r bower_components/leaflet/dist/images $OUTPUT_DIR/images/leaflet/
|
||||
|
||||
# Generate service worker
|
||||
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker-es5
|
||||
cp build-es5/service_worker.js $OUTPUT_DIR_ES5
|
||||
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker
|
||||
cp build/service_worker.js $OUTPUT_DIR
|
||||
cp node_modules/leaflet/dist/leaflet.css $OUTPUT_DIR/images/leaflet
|
||||
cp -r node_modules/leaflet/dist/images $OUTPUT_DIR/images/leaflet/
|
||||
|
||||
./node_modules/.bin/gulp compress
|
||||
|
||||
@@ -65,7 +53,5 @@ echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR_ES5/__init__.py
|
||||
echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR_ES5/__init__.py
|
||||
|
||||
# Generate the MD5 hash of the new frontend
|
||||
script/fingerprint_frontend.py --base_dir $OUTPUT_DIR
|
||||
script/fingerprint_frontend.py --base_dir $OUTPUT_DIR_ES5
|
||||
./node_modules/.bin/gulp gen-index-html
|
||||
./node_modules/.bin/gulp gen-index-html-es5
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Set XSS_VERSION or MARKED_VERSION to set package versions. If unset, the latest version will be used.
|
||||
|
||||
# Stop on errors
|
||||
set -e
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
output="public/markdown-js.html"
|
||||
|
||||
echo "<script>" > $output
|
||||
|
||||
pkgs="xss:dist/xss.min.js marked:marked.min.js"
|
||||
|
||||
for pkg in $pkgs; do
|
||||
name="$(cut -d':' -f1 <<< "$pkg")"
|
||||
js_path="$(cut -d':' -f2 <<< "$pkg")"
|
||||
|
||||
# Check env variable for version
|
||||
version=$(eval "echo \$$(echo $name | tr "a-z" "A-Z")_VERSION")
|
||||
if [ -z "$version" ]; then
|
||||
version=$(yarn -s info $name dist-tags.latest)
|
||||
fi
|
||||
|
||||
homepage=$(yarn -s info "$name@$version" homepage)
|
||||
license=$(yarn -s info "$name@$version" license)
|
||||
tarball=$(yarn -s info "$name@$version" dist.tarball)
|
||||
|
||||
cat >>$output <<EOF
|
||||
/*
|
||||
* $name@$version ($license)
|
||||
* $homepage
|
||||
*/
|
||||
EOF
|
||||
echo "Downloading $name@$version"
|
||||
curl -s "$tarball" | tar -xzO "package/$js_path" | ./node_modules/.bin/uglifyjs -c -m >> $output
|
||||
done
|
||||
|
||||
echo "</script>" >> $output
|
||||
|
||||
size=$(wc -c < $output)
|
||||
gzip_size=$(cat $output | gzip | wc -c)
|
||||
|
||||
echo "$size bytes ($gzip_size bytes gzipped) written to $output"
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate a file with all md5 hashes of the assets."""
|
||||
|
||||
from collections import OrderedDict
|
||||
import glob
|
||||
import hashlib
|
||||
import json
|
||||
import argparse
|
||||
from os import path
|
||||
import re
|
||||
|
||||
parser = argparse.ArgumentParser(description='Generate fingerprints of frontend files.')
|
||||
parser.add_argument('--base_dir', type=str, help='Base dir to look for files.', default='hass_frontend')
|
||||
args = parser.parse_args()
|
||||
base_dir = args.base_dir + '/'
|
||||
fingerprint_file = path.join(base_dir, '__init__.py')
|
||||
panel_match = re.compile(r'ha-panel-((\w|-)+)\.html')
|
||||
|
||||
|
||||
def fingerprint():
|
||||
"""Fingerprint the panels."""
|
||||
files = glob.glob(base_dir + 'panels/*.html')
|
||||
md5s = OrderedDict()
|
||||
|
||||
for fil in sorted(files):
|
||||
panel = panel_match.search(fil).groups(0)[0]
|
||||
with open(fil) as fp:
|
||||
md5 = hashlib.md5(fp.read().encode('utf-8')).hexdigest()
|
||||
md5s[panel] = 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()
|
||||
@@ -34,7 +34,7 @@ def get_remote_version():
|
||||
|
||||
def clean_component(source):
|
||||
"""Clean component."""
|
||||
return source[source.index(START_ICONSET):]
|
||||
return source[source.index(START_ICONSET):].replace('iron-iconset-svg', 'ha-iconset-svg')
|
||||
|
||||
|
||||
def write_component(source):
|
||||
|
||||
Reference in new issue
Block a user