Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback #18

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "0.2",
"ignorePaths": [],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": ["hass", "bunx"],
"ignoreWords": [],
"import": []
}
File renamed without changes.
32 changes: 0 additions & 32 deletions .eslintrc.js

This file was deleted.

89 changes: 89 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"env": {
"es6": true,
"node": true
},
"plugins": [
"import",
"jsonc",
"no-unsanitized",
"sonarjs",
"simple-import-sort",
"sort-keys-fix",
"unicorn",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": ["tsconfig.json"]
},
"overrides": [
{
"files": ["src/**/*.ts"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:jsonc/recommended-with-jsonc",
"plugin:sonarjs/recommended",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
"plugin:@cspell/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"prettier/prettier": "error",
"unicorn/switch-case-braces": "off",
"unicorn/prefer-module": "off",
"@typescript-eslint/no-magic-numbers": "off",
"unicorn/no-object-as-default-parameter": "off",
"unicorn/no-null": "off",
"unicorn/no-empty-file": "off",
"sonarjs/prefer-single-boolean-return": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/no-await-expression-member": "off",
"unicorn/no-useless-undefined": "off",
"@typescript-eslint/unbound-method": "error",
"import/no-extraneous-dependencies": [
"error",
{
"packageDir": "./"
}
],
"sonarjs/prefer-immediate-return": "off",
"no-case-declarations": "off",
"no-async-promise-executor": "off",
"sonarjs/no-duplicate-string": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/no-array-for-each": "off",
"unicorn/import-style": "off",
"sort-keys-fix/sort-keys-fix": "warn",
"unicorn/prefer-event-target": "off",
"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",
"no-console": ["error"],
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "error"
}
},
{
"files": ["*.spec.ts", "*.test.ts"],
"env": {
"jest": true
},
"rules": {
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-magic-numbers": "off",
"sonarjs/no-unused-collection": "warn",
"unicorn/consistent-function-scoping": "off"
}
},
{
"files": ["metrics.helper.ts", "*.module.ts"],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/no-magic-numbers": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# These are supported funding model platforms

# Note: This is an override for this repository specifically
github: [webbertakken, zoe-codez]
github: webbertakken
patreon: # Replace with a single Patreon username
open_collective: # replace with a single OpenCollective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: "yarn"
cache: 'yarn'

- name: Install deps
run: yarn install --frozen-lockfile --immutable
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: "yarn"
cache: 'yarn'

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

- name: Tests
run: yarn test:coverage
run: yarn coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
/node_modules
/deploy
/previous_deploy.tar.gz
/synapse_storage.db
/.yarn
/.idea
/.vscode
/.env*
!/.env*.dist
!/.env*.template
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi

# Heavy checks should only be done on staged files
yarn lint-staged
# Heavy checks should only be done on staged files123
bun run lint-staged
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

8 changes: 4 additions & 4 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"singleQuote": false,
"trailingComma": "all",
"jsxSingleQuote": false,
"semi": false,
"singleQuote": true,
"printWidth": 100,
"arrowParens": "avoid"
"trailingComma": "all",
"proseWrap": "always"
}
1 change: 0 additions & 1 deletion .stignore

This file was deleted.

10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
## ##
###########################################################

# see all versions at https://hub.docker.com/r/oven/bun/tags
ARG BUN_VERSION="1"

# see all versions at https://hub.docker.com/r/bitnami/node/tags
ARG NODE_VERSION="20"

Expand Down Expand Up @@ -35,7 +38,7 @@ ENV VOLTA_HOME "/root/.volta"
ENV PATH "$VOLTA_HOME/bin:$PATH"

# Copy only relevant files
COPY package.json yarn.lock .yarnrc.yml tsconfig.json vitest.config.ts .prettier* .eslint* /app/
COPY package.json yarn.lock .yarnrc.yml tsconfig.json vitest.config.ts .prettier* .eslint* .cspell.json /app/
COPY src/ /app/src/

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

# match port in app
ENV PORT 3000

# Run the app
EXPOSE $PORT
EXPOSE 3000
CMD ["./server"]
89 changes: 61 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,117 @@
## Automation Standalone πŸ‘πŸ’»πŸ³
# Automation Standalone πŸ‘πŸ’»πŸ³

Welcome to the Digital Alchemy standalone automation repository!

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

- πŸ“š [Documentation](https://docs.digital-alchemy.app)
This repository is designed to work both locally and deployed as a docker container. The container
will interact with the HomeAssistant websocket to fulfill its automation goals.

## Community

- πŸ“š [Documentation](https://docs.digital-alchemy.app/)
- πŸ—£οΈ [Discord](https://discord.gg/JkZ35Gv97Y)

## πŸ—οΈ Setup
## Setup

### Prerequisites

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

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

### Clone

Clone the repository to your local machine and change directory to thew new repo:
Clone the repository to your local machine:

```bash
git clone git@github.com/Digital-Alchemy-TS/automation-standalone.git
```

### Change directory

Change directory to the repository root:

```bash
cd automation-standalone
```

### Install Dependencies
### Install

Install dependencies using Yarn:

```bash
# (optional) enable yarn for setups without Volta
corepack enable

# install node_modules
yarn install
yarn
```

### Configure

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

```bash
cp .env.template .env
cp .env.dist .env
```

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

## πŸͺ„ Workspace Usage
## Usage

### Management
### Sync

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

```bash
yarn upgrade
yarn sync
```

Update the library type definitions based on current Home Assistant state. <sup>[docs](https://docs.digital-alchemy.app/docs/home-automation/type-writer/)</sup>
### Run

Run your automations locally

```bash
yarn type-writer
yarn dev
```

### Run
## Testing

Run your automations locally
#### Unit tests and integration tests

Run all your tests

```bash
# normal start
yarn start
yarn test
```

#### End-to-end tests

See [./playground](./playground/README.md) folder readme.

## Publication

# automatic reload when code changes
yarn start:watch
### Build

Build the application

```bash
yarn build
```

## 🐳 Deployments
### Publish

Build and publish your application to a docker registry

```bash
yarn publish
```

### Deploy

For now, this will be considered a manual step. Basically all you have to do is pull the image that
you've just pushed.

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

## πŸ“„ License

Expand Down
Loading