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

v2.28.5 #323

Merged
merged 55 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3110f61
Updated due to Noita update
TwoAbove May 23, 2023
182ed2c
Bump socket.io-parser from 4.2.1 to 4.2.3
dependabot[bot] May 24, 2023
f1cb8b7
Merge pull request #303 from TwoAbove/dependabot/npm_and_yarn/socket.…
TwoAbove May 24, 2023
d40fcf0
Added manual offset setter
TwoAbove May 24, 2023
15e6bc2
Merge branch 'develop' of github.com:TwoAbove/noita-tools into develop
TwoAbove May 24, 2023
da51fef
Updated spells
TwoAbove May 27, 2023
3a50b7d
Fixed LC/AP bug
TwoAbove Jun 1, 2023
c8792ff
Updated spell list
TwoAbove Jun 1, 2023
47b5cb3
Updated console build
TwoAbove Jun 15, 2023
c548ad4
Added docker build
TwoAbove Jun 15, 2023
28ce324
Updated docker build
TwoAbove Jun 15, 2023
734559c
Updated docker build
TwoAbove Jun 15, 2023
e728155
Updated docker build
TwoAbove Jun 15, 2023
23af646
Updated console search
TwoAbove Jun 16, 2023
7535d20
Updated lockfile
TwoAbove Jun 16, 2023
b6a3c62
Fixed yarn
TwoAbove Jun 16, 2023
53cb5e4
Fixed build
TwoAbove Jun 16, 2023
201cad0
Fixed build
TwoAbove Jun 16, 2023
bcde5a4
Updated yarn deps
TwoAbove Jun 16, 2023
a8ef659
Updated for Noita update
TwoAbove Jun 17, 2023
48da7e5
Added search cluster init
TwoAbove Jun 17, 2023
10dca1e
Removed test docker gh action target
TwoAbove Jun 17, 2023
9431bed
Updated docker build to create 2 versions
TwoAbove Jun 17, 2023
79a3c4b
Added lambda always-online count
TwoAbove Jun 17, 2023
f172c11
Added docker build caching
TwoAbove Jun 17, 2023
dd51390
Added logging
TwoAbove Jun 17, 2023
3396d6b
Updated cluster search setup
TwoAbove Jun 17, 2023
3ac4ad6
Updated lambda ping to better handle short searches
TwoAbove Jun 18, 2023
c2cb05e
Reduced lambda ping frequency
TwoAbove Jun 18, 2023
593ecc8
Fixed cluster status UI
TwoAbove Jun 18, 2023
0fae492
Optimized wasm
TwoAbove Jun 18, 2023
fa4d7ea
Optimized wasm
TwoAbove Jun 18, 2023
b7ce617
Micro-wasm info provider POC
TwoAbove Jun 19, 2023
65db44e
Merge branch 'develop' of github.com:TwoAbove/noita-tools into wasmsc…
TwoAbove Jun 19, 2023
d76b286
Updated gungen
TwoAbove Jun 19, 2023
6aaf6aa
Merge pull request #304 from TwoAbove/wasmscript
TwoAbove Jun 19, 2023
f8d2460
Updated README.md
TwoAbove Jun 20, 2023
fb4e041
Added auto refresh
TwoAbove Jun 22, 2023
ba7955e
UI polish
TwoAbove Jun 30, 2023
2986f12
Removed performance test
TwoAbove Jun 30, 2023
8724a62
Fixed Weather display
TwoAbove Jul 13, 2023
5f4c137
Updated re Noita update
TwoAbove Jul 22, 2023
58182b3
Updated re Noita update
TwoAbove Jul 27, 2023
94c8f24
#314 Fixed gamble
TwoAbove Sep 21, 2023
c996a80
Fixed tests and made some WASM performance optimizations
TwoAbove Sep 22, 2023
36de782
Merge pull request #317 from TwoAbove/cherry-pick
TwoAbove Sep 22, 2023
ce2be4b
Rased rate limits
TwoAbove Oct 6, 2023
5740b9f
Fixed patreon API update
TwoAbove Oct 6, 2023
9e059a5
Updated Patreon webhooks once again - 2 formats?
TwoAbove Oct 6, 2023
0408a22
Reverted to main Noita branch
TwoAbove Oct 20, 2023
324461a
Removed unneeded comments
TwoAbove Oct 20, 2023
cd5b8af
Fixed Entity rendering
TwoAbove Oct 20, 2023
e425f77
Removed yarn
TwoAbove Oct 20, 2023
2c7691b
Removed yarn
TwoAbove Oct 20, 2023
3f35a2a
Fixed workflow
TwoAbove Oct 20, 2023
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: 7 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ cypress
node_modules
build
dataScripts
lambda-build
public
server
*.Dockerfile

.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
47 changes: 47 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Docker Build and Push

on:
push:
branches:
- master
- develop

jobs:
build_and_push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set image tag based on branch
run: echo "IMAGE_TAG=$(if [ "${{ github.ref }}" = "refs/heads/master" ]; then echo 'latest'; else echo 'latest-dev'; fi)" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./console.Dockerfile
push: true
tags: ghcr.io/twoabove/noitool-console-search:${{ env.IMAGE_TAG }}
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
cache: "yarn"
cache: "npm"
node-version: ${{ matrix.node }}

- name: Cache build
Expand All @@ -50,8 +50,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Yarn install
run: yarn install --immutable
- name: npm install
run: npm install --immutable

build:
needs: setup
Expand All @@ -78,7 +78,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
cache: "yarn"
cache: "npm"
node-version: ${{ matrix.node }}

- name: Cache build
Expand All @@ -105,7 +105,7 @@ jobs:
false # This is needed because node throws console.warn messages that
# get treated as errors in CI
run: |
DISABLE_ESLINT_PLUGIN=true yarn build
DISABLE_ESLINT_PLUGIN=true npm run build
if [ -d "./build" ]; then
echo "Build dir exists"
exit 0
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
cache: "yarn"
cache: "npm"
node-version: ${{ matrix.node }}

- name: Cache build
Expand All @@ -160,7 +160,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Test
run: yarn test
run: npm test
env:
CI: true

Expand Down Expand Up @@ -189,7 +189,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
cache: "yarn"
cache: "npm"
node-version: ${{ matrix.node }}

- name: Cache build
Expand All @@ -211,7 +211,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: e2e
run: yarn e2e
run: npm e2e
env:
CI:
false # This is needed because node throws console.warn messages that
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ typings/

# Optional npm cache directory
.npm
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Optional eslint cache
.eslintcache
Expand Down Expand Up @@ -105,10 +111,11 @@ dist
.tern-port

build
lambda-build
console-build

ssl

dataScripts/src/mapsToObj/gen
dataScripts/src/out

cypress/screenshots/
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build
lambda-build
console-build
ssl
dataScripts/src/mapsToObj/gen
public
Expand Down
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,42 @@ Current features include:

### Prerequisites

- The machine should have node installed (ideally v18.6+) and yarn.
- The machine should have node installed (ideally v18.6+) and npm.
- Follow to <https://www.noitool.com/?profile=true> and link your patreon account. Under your patreon username, there will now be an id like `6456aff2478c4f8f91701018`

### Installing and connecting

#### Docker

You can use docker to simply spin up a compute node:

```bash
docker pull ghcr.io/twoabove/noitool-console-search:latest && docker run -it ghcr.io/twoabove/noitool-console-search:latest --userId xxx
# Or for dev
docker pull ghcr.io/twoabove/noitool-console-search:latest-dev && docker run -it ghcr.io/twoabove/noitool-console-search:latest-dev --userId xxx --url https://dev.noitool.com/
```

#### CLI

To connect to noitool as a compute node, follow these steps:

```bash
git clone https://github.com/TwoAbove/noita-tools.git
cd noita-tools
git checkout master # for https://www.noitool.com
# git checkout develop # for https://dev.noitool.com
yarn install --frozen-lockfile
yarn lambda-build
yarn console-search --userId 6456aff2478c4f8f91701018
npm install --frozen-lockfile
npm run console-build
npm run console-search --userId 6456aff2478c4f8f91701018
```

console-search args:
console-search args (or env vars):

- `--url`: default <https://www.noitool.com/>. Change to <https://dev.noitool.com/> for the dev build
- `--cores`: default `os.cpus()`. The amount of threads to use.
- `--userId`: The user to connect as.
- `--exit` default `false`. Add if you want the worker to exit if there are no more jobs.
- `--url` `NOITOOL_URL`: default <https://www.noitool.com/>. Change to <https://dev.noitool.com/> for the dev build
- `--cores` `NOITOOL_CORES`: default `os.cpus()`. The amount of threads to use.
- `--userId` `NOITOOL_USER_ID`: The user to connect as.
- `--exit` `NOITOOL_EXIT` default `false`. Add if you want the worker to exit if there are no more jobs.
- `--minRunTime` `NOITOOL_MIN_RUN_TIME` default `0`. This minimum amount of time (in seconds) that the worker will run for. If there are no more jobs, it will exit after this time. A value of 0 means that this is disabled.

## Technical details and implementation details that I found interesting

Expand All @@ -67,7 +80,6 @@ Prerequisites:
- [emscripten](https://emscripten.org/docs/getting_started/downloads.html) is installed
- `npm i -g google-closure-compiler`
- Node
- Yarn

After extracting noita wak, run

Expand All @@ -78,6 +90,7 @@ find . -type f -not -path '*/\.*' -exec sed -i 's/<!------------ MATERIALS -----
find . -type f -not -path '*/\.*' -exec sed -i 's/<!-- attack_ranged_min_distance="60" -->//g' {} +;
find . -type f -not -path '*/\.*' -exec sed -i 's/<!---------------- shield ---------------- -->//g' {} +;
find . -type f -not -path '*/\.*' -exec sed -i 's/<!-- fuse_tnt durability is 11 so this is capable of destroying it -->//g' {} +;
tac $NOLLA_PATH/entities/misc/eradicate.xml | sed '0,/<Entity>$/s//<\/Entity>/' | tac >$NOLLA_PATH/entities/misc/eradicate.xml;
```

to fix comments for the xml parser
Expand Down Expand Up @@ -116,6 +129,6 @@ To get the prefix, run:
npm config get prefix
```

Installation (after emscripten): `yarn`
Installation (after emscripten): `npm i`

Running: `yarn dev`
Running: `npm run dev`
23 changes: 15 additions & 8 deletions console.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-slim as build-image
FROM node:20-slim as build-image

RUN apt-get update && \
apt-get install -y \
Expand All @@ -15,17 +15,24 @@ RUN mkdir -p /app

WORKDIR /app

RUN npm i esbuild

COPY . .

RUN yarn install --frozen-lockfile
# RUN npm install

RUN npm run console-build

FROM node:20-slim

RUN yarn lambda-build
RUN apt-get update && \
apt-get install -y \
python3 make g++

RUN rm -rf node_modules && yarn install --frozen-lockfile --production=true
WORKDIR /app

FROM node:18-alpine
COPY --from=build-image /app/console-build /app/

COPY --from=build-image /app/lambda-build ./
COPY --from=build-image /app/node_modules ./
RUN npm install --production=true

ENTRYPOINT ["node", "consoleSearch.js"]
ENTRYPOINT ["npm", "run", "start"]
30 changes: 13 additions & 17 deletions lambdaBuild.js → consoleBuild.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const fs = require("fs");
const path = require("path");

// const requireResolvePlugin = require('@chialab/esbuild-plugin-require-resolve');
// const { resolve } = require('path');
// const tsc = require('tsc-prog');

// rimraf lambda-build/* && tsc --project ./tsconfig.lambda.json && copyfiles -u 1 src/**/*.wasm lambda-build
// rimraf console-build/* && tsc --project ./tsconfig.lambda.json && copyfiles -u 1 src/**/*.wasm console-build

// tsc.build({
// basePath: __dirname,
Expand All @@ -14,7 +15,7 @@ const path = require("path");
// });

// writeFileSync(
// resolve(__dirname, 'lambda-build/package.json'),
// resolve(__dirname, 'console-build/package.json'),
// JSON.stringify(
// {
// // type: 'commonjs',
Expand All @@ -30,8 +31,8 @@ const path = require("path");
// 2
// )
// );
if (!fs.existsSync("lambda-build")) {
fs.mkdirSync("lambda-build");
if (!fs.existsSync("console-build")) {
fs.mkdirSync("console-build");
}

const pkg = require(path.resolve("./package.json"));
Expand All @@ -51,37 +52,32 @@ require("esbuild")
metafile: true,
sourcemap: true,
// minify: true,
target: ["node18"],
outdir: "lambda-build",
target: ["node20"],
format: "esm",
banner: {
js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`,
},
// outfile: 'lambda-build/consoleSearch.js'
outdir: "console-build",
packages: "external",
external,
})
.then(() => {
const pkg = {
name: "noitool-console",
type: "module",
module: "consoleSearch.js",
version: "0.0.0",
};

fs.writeFileSync(path.resolve(__dirname, "lambda-build", "package.json"), JSON.stringify(pkg, null, 4));
fs.copyFileSync(
path.resolve(__dirname, "search.package.json"),
path.resolve(__dirname, "console-build", "package.json")
);

{
// Need to figure out how to correctly fix URL requires with esbuild
const fixFile = path.resolve(__dirname, "lambda-build", "consoleSearch.js");
const fixFile = path.resolve(__dirname, "console-build", "consoleSearch.js");
let f = fs.readFileSync(fixFile, "utf8");
let result = f.replace("../workers/seedSearcher.worker.node.ts", "./workers/seedSearcher.worker.node.js");
fs.writeFileSync(fixFile, result);
}

{
// Need to figure out how to correctly fix URL requires with esbuild
const fixFile = path.resolve(__dirname, "lambda-build", "workers/seedSearcher.worker.node.js");
const fixFile = path.resolve(__dirname, "console-build", "workers/seedSearcher.worker.node.js");
let f = fs.readFileSync(fixFile, "utf8");
let result = "" + f;
result = result.replaceAll(`.json";`, `.json"assert{type:"json"};`);
Expand Down
13 changes: 13 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ module.exports = {
},
});

// https://github.com/facebook/create-react-app/pull/11752#issuecomment-1345231546
config.ignoreWarnings = [
function ignoreSourcemapsloaderWarnings(warning) {
return (
warning.module &&
warning.module.resource.includes("node_modules") &&
warning.details &&
warning.details.includes("source-map-loader")
);
},
];

config.experiments = {
css: false,
futureDefaults: true,
asyncWebAssembly: true,
};
Expand Down
Loading