mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 09:56:36 +00:00
Add version to JS (#839)
* Add version to JS * Throw if version wasn't found
This commit is contained in:
parent
c11a525a2d
commit
13f8fa7e11
@ -15,6 +15,7 @@
|
|||||||
"__DEV__": false,
|
"__DEV__": false,
|
||||||
"__DEMO__": false,
|
"__DEMO__": false,
|
||||||
"__BUILD__": false,
|
"__BUILD__": false,
|
||||||
|
"__VERSION__": false,
|
||||||
"Polymer": true,
|
"Polymer": true,
|
||||||
"webkitSpeechRecognition": false,
|
"webkitSpeechRecognition": false,
|
||||||
"ResizeObserver": false
|
"ResizeObserver": false
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const fs = require('fs');
|
||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const rollupEach = require('gulp-rollup-each');
|
const rollupEach = require('gulp-rollup-each');
|
||||||
const commonjs = require('rollup-plugin-commonjs');
|
const commonjs = require('rollup-plugin-commonjs');
|
||||||
@ -8,6 +9,11 @@ const uglify = require('../common/gulp-uglify.js');
|
|||||||
|
|
||||||
const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
|
const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
|
||||||
const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
|
const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
|
||||||
|
const version = fs.readFileSync('setup.py', 'utf8').match(/\d{8}[^']*/);
|
||||||
|
if (!version) {
|
||||||
|
throw Error('Version not found');
|
||||||
|
}
|
||||||
|
const VERSION = version[0];
|
||||||
|
|
||||||
function getRollupInputOptions(es6) {
|
function getRollupInputOptions(es6) {
|
||||||
const babelOpts = {
|
const babelOpts = {
|
||||||
@ -51,6 +57,7 @@ function getRollupInputOptions(es6) {
|
|||||||
__DEV__: JSON.stringify(DEV),
|
__DEV__: JSON.stringify(DEV),
|
||||||
__DEMO__: JSON.stringify(DEMO),
|
__DEMO__: JSON.stringify(DEMO),
|
||||||
__BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
|
__BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
|
||||||
|
__VERSION__: JSON.stringify(VERSION),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
@ -4,6 +4,7 @@ window.HAWS = HAWS;
|
|||||||
window.HASS_DEMO = __DEMO__;
|
window.HASS_DEMO = __DEMO__;
|
||||||
window.HASS_DEV = __DEV__;
|
window.HASS_DEV = __DEV__;
|
||||||
window.HASS_BUILD = __BUILD__;
|
window.HASS_BUILD = __BUILD__;
|
||||||
|
window.HASS_VERSION = __VERSION__;
|
||||||
|
|
||||||
const init = window.createHassConnection = function (password) {
|
const init = window.createHassConnection = function (password) {
|
||||||
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
const proto = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user