From 07f032eb132e43ed30481b38708c882da63d8f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 26 Jun 2019 22:52:46 +0200 Subject: [PATCH] Initial commit --- .gitattributes | 1 + .gitignore | 4 ++ Makefile | 52 ++++++++++++++++++++ custom_components/browser_mod/__init__.py | 8 +++ custom_components/browser_mod/browser_mod.js | 1 + js/main.js | 2 + 6 files changed, 68 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 custom_components/browser_mod/__init__.py create mode 100644 custom_components/browser_mod/browser_mod.js create mode 100644 js/main.js diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3589743 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +custom_components/browser_mod/browser_mod.js binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d26a54b --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +package-lock.json +package.json +webpack.config.js diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..447b430 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +AUTHOR := Thomas Lovén +CARD_TOOLS := $(PWD)/../card-tools + +PACKAGE := browser_mod +DOCKER_CMD:=docker run --rm -v $(CARD_TOOLS):/card-tools:ro -v $(PWD):/usr/src/$(PACKAGE) -w="/usr/src/$(PACKAGE)" node:11 + +setup := package.json package-lock.json webpack.config.js + +JS := $(wildcard js/*.js) +PY := $(wildcard custom_components/browser_mod/*.py) +OUTPUT := ../../config/custom_components/browser_mod/__init__.py + +build: $(setup) custom_components/browser_mod/browser_mod.js $(OUTPUT) + +$(OUTPUT): $(PY) + cp custom_components/browser_mod/* ../../config/custom_components/browser_mod/. + +custom_components/browser_mod/browser_mod.js: $(JS) + $(DOCKER_CMD) npm run build + +dev: setup + $(DOCKER_CMD) npm run watch + +setup: $(setup) + +clean: + rm package.json package-lock.json webpack.config.js + rm -r node_modules + rm $(PACKAGE).js + +define WEBPACK_CONFIG +const path = require('path'); + +module.exports = { + entry: './js/main.js', + mode: 'production', + output: { + filename: 'custom_components/browser_mod/browser_mod.js', + path: path.resolve(__dirname) + } +}; +endef +export WEBPACK_CONFIG +webpack.config.js: + echo "$$WEBPACK_CONFIG" >> $@ + +package-lock.json: + $(DOCKER_CMD) npm install webpack webpack-cli --save-dev + +package.json: + $(DOCKER_CMD) /bin/bash -c "npm set init.license 'MIT' && npm set init.author.name '$(AUTHOR)' && npm init -y" + $(DOCKER_CMD) sed -E -i -e '/^ +"main"/d' -e '/^ +"scripts"/a\ "build": "webpack",' -e '/^ +"scripts"/a\ "watch": "webpack --watch --mode=development",' -e '2a\ "private": true,' $@ diff --git a/custom_components/browser_mod/__init__.py b/custom_components/browser_mod/__init__.py new file mode 100644 index 0000000..b4082c4 --- /dev/null +++ b/custom_components/browser_mod/__init__.py @@ -0,0 +1,8 @@ +import logging + +_LOGGER = logging.getLogger(__name__) + +async def async_setup(hass, config): + _LOGGER.error(f"Setting up browser_mod") + + return True diff --git a/custom_components/browser_mod/browser_mod.js b/custom_components/browser_mod/browser_mod.js new file mode 100644 index 0000000..4b67296 --- /dev/null +++ b/custom_components/browser_mod/browser_mod.js @@ -0,0 +1 @@ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){alert("Hello!")}]); \ No newline at end of file diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..1985686 --- /dev/null +++ b/js/main.js @@ -0,0 +1,2 @@ +alert("Hello!") +