Skip to content

Commit 1924a10

Browse files
authored
sync (#18)
1 parent 7320f64 commit 1924a10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2249
-2368
lines changed

.cspell.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"version": "0.2",
3+
"ignorePaths": [],
4+
"dictionaryDefinitions": [],
5+
"dictionaries": [],
6+
"words": ["hass", "bunx"],
7+
"ignoreWords": [],
8+
"import": []
9+
}

.env.template .env.dist

File renamed without changes.

.eslintrc.js

-32
This file was deleted.

.eslintrc.json

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"node": true
5+
},
6+
"plugins": [
7+
"import",
8+
"jsonc",
9+
"no-unsanitized",
10+
"sonarjs",
11+
"simple-import-sort",
12+
"sort-keys-fix",
13+
"unicorn",
14+
"prettier"
15+
],
16+
"parser": "@typescript-eslint/parser",
17+
"parserOptions": {
18+
"sourceType": "module",
19+
"project": ["tsconfig.json"]
20+
},
21+
"overrides": [
22+
{
23+
"files": ["src/**/*.ts"],
24+
"extends": [
25+
"plugin:@typescript-eslint/recommended",
26+
"plugin:jsonc/recommended-with-jsonc",
27+
"plugin:sonarjs/recommended",
28+
"plugin:unicorn/recommended",
29+
"plugin:prettier/recommended",
30+
"plugin:@cspell/recommended"
31+
],
32+
"parser": "@typescript-eslint/parser",
33+
"rules": {
34+
"prettier/prettier": "error",
35+
"unicorn/switch-case-braces": "off",
36+
"unicorn/prefer-module": "off",
37+
"@typescript-eslint/no-magic-numbers": "off",
38+
"unicorn/no-object-as-default-parameter": "off",
39+
"unicorn/no-null": "off",
40+
"unicorn/no-empty-file": "off",
41+
"sonarjs/prefer-single-boolean-return": "off",
42+
"unicorn/no-array-callback-reference": "off",
43+
"unicorn/no-await-expression-member": "off",
44+
"unicorn/no-useless-undefined": "off",
45+
"@typescript-eslint/unbound-method": "error",
46+
"import/no-extraneous-dependencies": [
47+
"error",
48+
{
49+
"packageDir": "./"
50+
}
51+
],
52+
"sonarjs/prefer-immediate-return": "off",
53+
"no-case-declarations": "off",
54+
"no-async-promise-executor": "off",
55+
"sonarjs/no-duplicate-string": "off",
56+
"unicorn/prefer-node-protocol": "off",
57+
"unicorn/no-array-for-each": "off",
58+
"unicorn/import-style": "off",
59+
"sort-keys-fix/sort-keys-fix": "warn",
60+
"unicorn/prefer-event-target": "off",
61+
"simple-import-sort/imports": "warn",
62+
"simple-import-sort/exports": "warn",
63+
"no-console": ["error"],
64+
"@typescript-eslint/no-unnecessary-type-constraint": "off",
65+
"@typescript-eslint/no-unused-vars": "warn",
66+
"@typescript-eslint/no-explicit-any": "error"
67+
}
68+
},
69+
{
70+
"files": ["*.spec.ts", "*.test.ts"],
71+
"env": {
72+
"jest": true
73+
},
74+
"rules": {
75+
"@typescript-eslint/unbound-method": "off",
76+
"@typescript-eslint/no-magic-numbers": "off",
77+
"sonarjs/no-unused-collection": "warn",
78+
"unicorn/consistent-function-scoping": "off"
79+
}
80+
},
81+
{
82+
"files": ["metrics.helper.ts", "*.module.ts"],
83+
"parser": "@typescript-eslint/parser",
84+
"rules": {
85+
"@typescript-eslint/no-magic-numbers": "off"
86+
}
87+
}
88+
]
89+
}

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# These are supported funding model platforms
22

33
# Note: This is an override for this repository specifically
4-
github: [webbertakken, zoe-codez]
4+
github: webbertakken
55
patreon: # Replace with a single Patreon username
66
open_collective: # replace with a single OpenCollective username
77
ko_fi: # Replace with a single Ko-fi username

.github/workflows/main.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version-file: package.json
23-
cache: "yarn"
23+
cache: 'yarn'
2424

2525
- name: Install deps
2626
run: yarn install --frozen-lockfile --immutable

.github/workflows/pull-request.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
uses: actions/setup-node@v4
2121
with:
2222
node-version-file: package.json
23-
cache: "yarn"
23+
cache: 'yarn'
2424

2525
- name: Install deps
2626
run: yarn install --frozen-lockfile --immutable
2727

2828
- name: Tests
29-
run: yarn test:coverage
29+
run: yarn coverage
3030

3131
- name: Upload coverage reports to Codecov
3232
uses: codecov/[email protected]

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
/node_modules
55
/deploy
66
/previous_deploy.tar.gz
7-
/synapse_storage.db
87
/.yarn
98
/.idea
109
/.vscode
1110
/.env*
1211
!/.env*.dist
13-
!/.env*.template

.husky/pre-commit

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
55
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi
66

7-
# Heavy checks should only be done on staged files
8-
yarn lint-staged
7+
# Heavy checks should only be done on staged files123
8+
bun run lint-staged

.nvmrc

-1
This file was deleted.

.prettierrc.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"singleQuote": false,
3-
"trailingComma": "all",
4-
"jsxSingleQuote": false,
2+
"semi": false,
3+
"singleQuote": true,
54
"printWidth": 100,
6-
"arrowParens": "avoid"
5+
"trailingComma": "all",
6+
"proseWrap": "always"
77
}

.stignore

-1
This file was deleted.

Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
## ##
55
###########################################################
66

7+
# see all versions at https://hub.docker.com/r/oven/bun/tags
8+
ARG BUN_VERSION="1"
9+
710
# see all versions at https://hub.docker.com/r/bitnami/node/tags
811
ARG NODE_VERSION="20"
912

@@ -35,7 +38,7 @@ ENV VOLTA_HOME "/root/.volta"
3538
ENV PATH "$VOLTA_HOME/bin:$PATH"
3639

3740
# Copy only relevant files
38-
COPY package.json yarn.lock .yarnrc.yml tsconfig.json vitest.config.ts .prettier* .eslint* /app/
41+
COPY package.json yarn.lock .yarnrc.yml tsconfig.json vitest.config.ts .prettier* .eslint* .cspell.json /app/
3942
COPY src/ /app/src/
4043

4144
# Build and pre-flight checks
@@ -87,9 +90,6 @@ WORKDIR /app
8790
# Copy the distributable files and production specific dependencies
8891
COPY --from=builder /app/dist /app/package.json ./
8992

90-
# match port in app
91-
ENV PORT 3000
92-
9393
# Run the app
94-
EXPOSE $PORT
94+
EXPOSE 3000
9595
CMD ["./server"]

README.md

+61-28
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,117 @@
1-
## Automation Standalone 🏡💻🐳
1+
# Automation Standalone 🏡💻🐳
22

33
Welcome to the Digital Alchemy standalone automation repository!
44

5-
This repository is designed to work as a locally running development server, as well as providing options for long term deployments.
5+
## Purpose
66

7-
- 📚 [Documentation](https://docs.digital-alchemy.app)
7+
This repository is designed to work both locally and deployed as a docker container. The container
8+
will interact with the HomeAssistant websocket to fulfill its automation goals.
9+
10+
## Community
11+
12+
- 📚 [Documentation](https://docs.digital-alchemy.app/)
813
- 🗣️ [Discord](https://discord.gg/JkZ35Gv97Y)
914

10-
## 🏗️ Setup
15+
## Setup
1116

1217
### Prerequisites
1318

14-
Digital Alchemy targets `node20`, which is the only required system dependency. Recommended workspace tools:
19+
These tools need to be installed on your machine:
1520

1621
- [Volta](https://volta.sh/) - Autonomously manages Node and Yarn versions
1722
- [Docker desktop](https://www.docker.com/products/docker-desktop/) - For packaging the application
1823

1924
### Clone
2025

21-
Clone the repository to your local machine and change directory to thew new repo:
26+
Clone the repository to your local machine:
2227

2328
```bash
2429
git clone [email protected]/Digital-Alchemy-TS/automation-standalone.git
30+
```
31+
32+
### Change directory
2533

34+
Change directory to the repository root:
35+
36+
```bash
2637
cd automation-standalone
2738
```
2839

29-
### Install Dependencies
40+
### Install
3041

3142
Install dependencies using Yarn:
3243

3344
```bash
34-
# (optional) enable yarn for setups without Volta
35-
corepack enable
36-
37-
# install node_modules
38-
yarn install
45+
yarn
3946
```
4047

4148
### Configure
4249

43-
Create a `.env` file from the `.env.template` example file. <sup>[docs](https://docs.digital-alchemy.app/docs/core/configuration)</sup>
50+
Create a `.env` file from the `.env.dist` example file.
4451

4552
```bash
46-
cp .env.template .env
53+
cp .env.dist .env
4754
```
4855

4956
Then, configure each variable in `.env` so that the application can connect to your HA instance.
5057

51-
## 🪄 Workspace Usage
58+
## Usage
5259

53-
### Management
60+
### Sync
5461

55-
Upgrade the version of `@digital-alchemy` libraries to latest.
62+
Synchronize the latest DA packages and write types based on your HA instance
5663

5764
```bash
58-
yarn upgrade
65+
yarn sync
5966
```
6067

61-
Update the library type definitions based on current Home Assistant state. <sup>[docs](https://docs.digital-alchemy.app/docs/home-automation/type-writer/)</sup>
68+
### Run
69+
70+
Run your automations locally
6271

6372
```bash
64-
yarn type-writer
73+
yarn dev
6574
```
6675

67-
### Run
76+
## Testing
6877

69-
Run your automations locally
78+
#### Unit tests and integration tests
79+
80+
Run all your tests
7081

7182
```bash
72-
# normal start
73-
yarn start
83+
yarn test
84+
```
85+
86+
#### End-to-end tests
87+
88+
See [./playground](./playground/README.md) folder readme.
89+
90+
## Publication
7491

75-
# automatic reload when code changes
76-
yarn start:watch
92+
### Build
93+
94+
Build the application
95+
96+
```bash
97+
yarn build
7798
```
7899

79-
## 🐳 Deployments
100+
### Publish
101+
102+
Build and publish your application to a docker registry
103+
104+
```bash
105+
yarn publish
106+
```
107+
108+
### Deploy
109+
110+
For now, this will be considered a manual step. Basically all you have to do is pull the image that
111+
you've just pushed.
80112

81-
> See the [extended documentation](https://docs.digital-alchemy.app/docs/home-automation/quickstart/automation-standalone/) for details
113+
> _**Note:** make sure that the same variables from `.env.dist` are passed into the container at
114+
> runtime._
82115
83116
## 📄 License
84117

0 commit comments

Comments
 (0)