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

Sync quickstart projects #16

Merged
merged 5 commits into from
Aug 9, 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: 0 additions & 9 deletions .cspell.json

This file was deleted.

File renamed without changes.
32 changes: 32 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
plugins: ["@typescript-eslint", "import", "prettier", "unicorn"],
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:unicorn/recommended",
"plugin:prettier/recommended",
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: [".eslintrc.js"],
rules: {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-namespace": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/import-style": "off",
"unicorn/prefer-module": "off",
"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": "off",
},
};
89 changes: 0 additions & 89 deletions .eslintrc.json

This file was deleted.

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
github: [webbertakken, zoe-codez]
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 coverage
run: yarn test:coverage

- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
/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 files123
bun run lint-staged
# Heavy checks should only be done on staged files
yarn lint-staged
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
8 changes: 4 additions & 4 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 100,
"singleQuote": false,
"trailingComma": "all",
"proseWrap": "always"
"jsxSingleQuote": false,
"printWidth": 100,
"arrowParens": "avoid"
}
1 change: 1 addition & 0 deletions .stignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
## ##
###########################################################

# 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 @@ -38,7 +35,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* .cspell.json /app/
COPY package.json yarn.lock .yarnrc.yml tsconfig.json vitest.config.ts .prettier* .eslint* /app/
COPY src/ /app/src/

# Build and pre-flight checks
Expand Down Expand Up @@ -90,6 +87,9 @@ 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 3000
EXPOSE $PORT
CMD ["./server"]
84 changes: 24 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,118 +1,82 @@
# Automation Standalone 🏡💻🐳
## Automation Standalone 🏡💻🐳

Welcome to the Digital Alchemy standalone automation repository!

## Purpose

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

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

- [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:
Clone the repository to your local machine and change directory to thew new repo:

```bash
git clone [email protected]/Digital-Alchemy-TS/automation-standalone.git
```

### Change directory

Change directory to the repository root:

```bash
cd automation-standalone
```

### Install
### Install Dependencies

Install dependencies using Yarn:

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

# install node_modules
yarn install
```

### Configure

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

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

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

## Usage
## 🪄 Workspace Usage

### Sync
### Management

Synchronize the latest DA packages and write types based on your HA instance

```bash
yarn sync
```

### Run

Run your automations locally
Upgrade the version of `@digital-alchemy` libraries to latest.

```bash
yarn dev
yarn upgrade
```

## Testing

#### Unit tests and integration tests

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

```bash
yarn test
yarn type-writer
```

#### End-to-end tests

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

## Publication

### Build
### Run

Build the application
Run your automations locally

```bash
yarn build
```

### Publish
# normal start
yarn start

Build and publish your application to a docker registry

```bash
yarn publish
# automatic reload when code changes
yarn start:watch
```

### 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.

> _**Note:** make sure that the same variables from `.env.dist` are passed into the container at
> runtime._

## 📄 License

This project is licensed under the MIT License, as detailed in the [LICENSE](./LICENSE) file.
Loading
Loading