Skip to content

Commit

Permalink
fix: detect caxa binary and use cwd for finding the data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Jun 20, 2021
1 parent d731bb1 commit f00efaf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ jobs:
- name: Compile x64 binary
id: compile
run: |
npx caxa -i . -o ${{ matrix.output }} -e server-build -e build -e package.json -e package-lock.json -e node_modules -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/server-build/index.js"
npx caxa -i . -o ${{ matrix.output }} -e server-build -e build -e package.json -e package-lock.json -e node_modules -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/server-build/index.js" "--caxa"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifact-${{ matrix.output }}
name: artifact-${{ matrix.output }}
path: "${{ matrix.output }}"

build_arm:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Build ${{ matrix.arch }}
run: |
CMD='cp -r /caxa /caxa2 && cd /caxa2 && echo "unsafe-perm = true" > .npmrc && npm ci && npm run build && npx caxa -i . -o /caxa/${{ matrix.output }} -e server-build -e build -e package.json -e package-lock.json -e node_modules -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/server-build/index.js"'
CMD='cp -r /caxa /caxa2 && cd /caxa2 && echo "unsafe-perm = true" > .npmrc && npm ci && npm run build && npx caxa -i . -o /caxa/${{ matrix.output }} -e server-build -e build -e package.json -e package-lock.json -e node_modules -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/server-build/index.js" "--caxa"'
docker run --rm --platform ${{ matrix.docker_platform }} -v $PWD:/caxa ${{ matrix.docker_image }} sh -c "$CMD"
- name: Upload artifacts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build:frontend": "node scripts/copy-monaco-editor-files.js && npm run relay-compiler && vite build --base=./",
"build:backend": "tsc --project server/tsconfig.json",
"build": "npm run build:frontend && npm run build:backend",
"compile": "npx caxa -i ./ -e server-build -e build -e package.json -e package-lock.json -e node_modules -o bin/dungeon-revealer-bin -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/server-build/index.js\"",
"compile": "npx caxa -i ./ -e server-build -e build -e package.json -e package-lock.json -e node_modules -o bin/dungeon-revealer-bin -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/server-build/index.js\" \"--caxa\"",
"eslint": "eslint --ignore-path .gitignore --max-warnings 0 \"**/*.js\" \"bin/dungeon-revealer\"",
"postinstall": "patch-package",
"start": "node ./bin/dungeon-revealer",
Expand Down
5 changes: 0 additions & 5 deletions server/@types/pkg/index.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "./../server-build",
"typeRoots": ["../node_modules/@types", "./@types"]
"typeRoots": ["../node_modules/@types"]
},
"include": ["./"]
}
5 changes: 3 additions & 2 deletions server/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import * as express from "express";
* In the bundled pkg "binary" we use the execPath.
*/
export const getDefaultDataDirectory = () => {
if (process.pkg) {
return path.resolve(path.dirname(process.execPath), "data");
const isCaxa = process.argv.includes("--caxa");
if (isCaxa) {
return path.resolve(process.cwd(), "data");
} else {
// eslint-disable-next-line id-blacklist
return path.resolve(__dirname, "..", "data");
Expand Down

1 comment on commit f00efaf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image has been published to DockerHub. 🐋

You can easily try this build out locally with Docker.

docker run -p 3000:3000 dungeonrevealer/dungeon-revealer:f00efaf587ed3ab71c00fd10398c631138591b12

Please sign in to comment.