Skip to content

Commit

Permalink
add devcontainer and cleanup build
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Nov 7, 2019
1 parent 68dee53 commit e734e51
Show file tree
Hide file tree
Showing 19 changed files with 662 additions and 239 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
default_config:
lovelace:
mode: yaml
demo:
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "Config Template Card Development",
"image": "ludeeus/devcontainer:monster-stable",
"context": "..",
"appPort": ["5000:5000", "9123:8123"],
"postCreateCommand": "npm install",
"runArgs": [
"-v",
"${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh" // This is added so you can push from inside the container
],
"extensions": [
"github.vscode-pull-request-github",
"tabnine.tabnine-vscode",
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode",
"bierner.lit-html",
"runem.lit-plugin",
"ms-python.python"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
25 changes: 25 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resources:
- url: http://127.0.0.1:5000/config-template-card.js
type: module
views:
- cards:
- type: 'custom:config-template-card'
variables:
- states['light.bed_light'].state
- states['cover.garage_door'].state
entities:
- light.bed_light
- cover.garage_door
- alarm_control_panel.ha_alarm
- climate.ecobee
card:
type: "${vars[0] === 'on' ? 'custom:hui-glance-card' : 'custom:hui-entities-card'}"
entities:
- entity: alarm_control_panel.ha_alarm
name: "${vars[1] === 'open' && states['alarm_control_panel.ha_alarm'].state === 'armed_home' ? 'Close the garage!' : ''}"
- entity: binary_sensor.basement_floor_wet
- entity: climate.ecobee
name: "${states['climate.ecobee'].attributes.current_temperature > 22 ? 'Cozy' : 'Too Hot/Cold'}"
- entity: cover.garage_door
- entity: "${vars[0] === 'on' ? 'light.bed_light' : 'climate.ecobee'}"
icon: "${vars[1] === 'open' ? 'mdi:hotel' : '' }"
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
experimentalDecorators: true,
},
rules: {
"@typescript-eslint/camelcase": 0
}
};
18 changes: 0 additions & 18 deletions .eslintrc.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Build"

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: Test build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build
run: |
npm install
npm run build
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
release:
types: [published]

jobs:
release:
name: Prepare release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

# Build
- name: Build the file
run: |
cd /home/runner/work/config-template-card/config-template-card
npm install
npm run build
# Upload build file to the releas as an asset.
- name: Upload zip to release
uses: svenstaro/upload-release-action@v1-release

with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: /home/runner/work/config-template-card/config-template-card/dist/config-template-card.js
asset_name: config-template-card.js
tag: ${{ github.ref }}
overwrite: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/node_modules/
.rpt2_cache/
/.rpt2_cache/
package-lock.json
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
104 changes: 36 additions & 68 deletions dist/config-template-card.js

Large diffs are not rendered by default.

87 changes: 48 additions & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
{
"name": "config-template-card",
"version": "1.0.6",
"description": "Lovelace config-template-card",
"keywords": [
"home-assistant",
"homeassistant",
"hass",
"automation",
"lovelace",
"custom-cards"
],
"module": "config-template-card.js",
"repository": "[email protected]:custom_cards/config-template-card.git",
"author": "Ian Richardson <[email protected]>",
"license": "MIT",
"dependencies": {
"deep-clone-simple": "^1.1.1",
"custom-card-helpers": "^1.3.5",
"home-assistant-js-websocket": "^4.4.0",
"lit-element": "^2.2.1"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.6.0",
"@typescript-eslint/parser": "^2.6.0",
"eslint": "^6.6.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"prettier": "^1.18.2",
"rollup": "^1.26.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-typescript2": "^0.24.3",
"typescript": "^3.6.4"
},
"scripts": {
"start": "rollup -c --watch",
"build": "npm run lint && npm run rollup",
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
}
"name": "config-template-card",
"version": "1.0.8",
"description": "Lovelace config-template-card",
"keywords": [
"home-assistant",
"homeassistant",
"hass",
"automation",
"lovelace",
"custom-cards"
],
"module": "config-template-card.js",
"repository": "[email protected]:iantrich/config-template-card.git",
"author": "Ian Richardson <[email protected]>",
"license": "MIT",
"dependencies": {
"custom-card-helpers": "^1.3.9",
"deep-clone-simple": "^1.1.1",
"home-assistant-js-websocket": "^4.4.0",
"lit-element": "^2.2.1",
"lit-html": "^1.1.2"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-decorators": "^7.4.0",
"@typescript-eslint/eslint-plugin": "^2.6.0",
"@typescript-eslint/parser": "^2.6.0",
"eslint": "^6.6.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.1",
"prettier": "^1.18.2",
"rollup": "^1.26.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-typescript2": "^0.24.3",
"rollup-plugin-uglify": "^6.0.3",
"typescript": "^3.6.4"
},
"scripts": {
"start": "rollup -c rollup.config.dev.js --watch",
"build": "npm run lint && npm run rollup",
"lint": "eslint src/*.ts",
"rollup": "rollup -c"
}
}
24 changes: 24 additions & 0 deletions rollup.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import serve from 'rollup-plugin-serve';

export default {
input: ['src/config-template-card.ts'],
output: {
dir: './dist',
format: 'es',
},
plugins: [
resolve(),
typescript(),
serve({
contentBase: './dist',
host: '0.0.0.0',
port: 5000,
allowCrossOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
}),
], treeshake: false,
};
16 changes: 9 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import resolve from "rollup-plugin-node-resolve";
import typescript from "rollup-plugin-typescript2";

export default {
input: ['src/config-template-card.ts'],
input: ["src/config-template-card.ts"],
output: {
dir: './dist',
format: 'es',
dir: "./dist",
format: "es"
},
plugins: [resolve(), typescript()],
treeshake: false,
plugins: [
resolve(),
typescript(),
], treeshake: false,
};
Loading

0 comments on commit e734e51

Please sign in to comment.