diff --git a/README.md b/README.md index 103f3c4..007c951 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,19 @@ Under development, however mainly for personal use! ## How to setup ## 1. Download or clone source code -2. Run `npm i` to install the packages -3. Change `accounts.example.json` to `accounts.json` and add your account details -4. Change `config.json` to your liking -5. Run `npm run build` to build the script -6. Run `npm run start` to start the built script +2. Change `accounts.example.json` to `accounts.json` and add your account details +3. Change `config.json` to your liking +4. Either go the nix or non-nix route + +### How to setup (not with nix) ### +5. Run `npm i` to install the packages +6. Run `npm run build` to build the script +7. Run `npm run start` to start the built script + +### How to setup (with nix) ## +5. Get [Nix](https://nixos.org/) +6. Run `./run.sh` +7. That's it! ## Notes ## - If you end the script without closing the browser window first (only with headless as false), you'll be left with hanging chrome instances using resources. Use taskmanager to kill these or use the included `npm run kill-chrome-win` script. (Windows) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..27bbe28 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1749727998, + "narHash": "sha256-mHv/yeUbmL91/TvV95p+mBVahm9mdQMJoqaTVTALaFw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fd487183437963a59ba763c0cc4f27e3447dd6dd", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e327534 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + flake-utils = { + url = "github:numtide/flake-utils"; + }; + }; + + outputs = + { nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + }; + in + { + devShell = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + nodejs + playwright-driver.browsers + typescript + playwright-test + + # fixes "waiting until load" issue compared to + # setting headless in config.json + xvfb-run + ]; + + shellHook = '' + export PLAYWRIGHT_BROWSERS_PATH=${pkgs.playwright-driver.browsers} + export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true + npm i + npm run build + ''; + }; + } + ); +} diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..cffeb43 --- /dev/null +++ b/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +nix develop --command bash -c "xvfb-run npm run start"