Skip to content

Commit

Permalink
rename npm scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Mar 3, 2025
1 parent 13b31c6 commit 491be06
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install elan
- name: Install elan, build and test server
uses: leanprover/lean-action@v1
with:
lake-package-directory: "server"
use-mathlib-cache: false
use-github-cache: false
auto-config: false
build: false
test: false
build: true
test: true
lint: false
- name: Install dependencies
run: npm install
- name: Build Lean
run: npm run build_server
# - name: Build for Production
# run: npm run build_client
- name: Build client for production
run: npm run build:client
- name: Cypress tests
if: always()
run: npm test
4 changes: 2 additions & 2 deletions doc/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The server is made out of two parts, named "relay" and "server".
The former, "relay", is the server which
sets up a socket connection to the client, starts the lean servers to work on files and
relays messages between the lean server and the client. `index.mjs` is the file that needs to
be run, which is done for example using `pm2` or by calling `npm run start_server` or
be run, which is done for example using `pm2` or by calling `npm run start:server` or
`npm run production`, see more later.

The latter, "server", is the lean server which has two jobs. For one, it produces the "gameserver"
Expand Down Expand Up @@ -46,7 +46,7 @@ This way any changes to files in `client/` or `relay/` will cause the server to
Alternative, you can run `npm run build` followed by the commands

```
npm run start_client
npm run start:client
npm run production
```

Expand Down
4 changes: 2 additions & 2 deletions doc/npm_scripts.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## NPM Scripts

* `npm start`: Start the project in development mode. The browser will automatically reload when client files get changed. The Lean server will get recompiled and restarted when lean files get changed. The Lean server will be started without a container. The client and server can be started separately using the scripts `npm run start_client` and `npm run start_server`. The project can be accessed via `http://localhost:3000`.
* `npm start`: Start the project in development mode. The browser will automatically reload when client files get changed. The Lean server will get recompiled and restarted when lean files get changed. The Lean server will be started without a container. The client and server can be started separately using the scripts `npm run start:client` and `npm run start:server`. The project can be accessed via `http://localhost:3000`.
Internally, websocket requests to `ws://localhost:3000/websockets` will be forwarded to a Lean server running on port `8080`.

* `npm run build`: Build the project in production mode. All assets of the client will be compiled into `client/dist`.
On the server side, the command will set up a docker image containing the Lean server. The two parts can be built separately using `npm run build_client` and `npm run build_server`.
On the server side, the command will set up a docker image containing the Lean server. The two parts can be built separately using `npm run build:client` and `npm run build:server`.

* `npm run production`: Start the project in production mode. This requires that the build script has been run. It will start a server on the port specified in the `PORT` environment variable or by default on `8080`. You can run on a specific port by running `PORT=80 npm run production`. The server will serve the files in `client/dist` via http and give access to the bubblewrapped Lean server via the web socket protocol.

Expand Down
4 changes: 2 additions & 2 deletions doc/running_locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ npm start

You should see a message like this:
```bash
[server] > [email protected] start_server
[server] > [email protected] start:server
[server] > (cd server && lake build) && (cd relay && cross-env NODE_ENV=development nodemon -e mjs --exec "node ./index.mjs")
[server]
[client]
[client] > [email protected] start_client
[client] > [email protected] start:client
[client] > cross-env NODE_ENV=development vite --host
[client]
[server] [nodemon] 3.0.#
Expand Down
2 changes: 1 addition & 1 deletion doc/troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here are known issues/pitfalls with the local setup using `npm`.
* If `CDPATH` is set on your mac/linux system, it might provide issues with `npm start` resulting in a server crash or blank screen. In particular `npm start` will display
```
[server] sh: line 0: cd: server: No such file or directory
[server] npm run start_server exited with code 1
[server] npm run start:server exited with code 1
```
As a fix you might need to delete your manually set `CDPATH` environment variable.

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,17 @@
"wait-on": "^8.0.2"
},
"scripts": {
"start": "concurrently -n server,client -c blue,green \"npm run start_server\" \"npm run start_client\"",
"start_server": "(cd server && lake build && lake build TestGame) && (cd relay && cross-env NODE_ENV=development nodemon -e mjs --exec \"node ./index.mjs\")",
"start_client": "cross-env NODE_ENV=development vite --host",
"build": "npm run build_server && npm run build_client",
"start": "concurrently -n server,client -c blue,green \"npm run start:server\" \"npm run start:client\"",
"start:server": "(cd server && lake build && lake build TestGame) && (cd relay && cross-env NODE_ENV=development nodemon -e mjs --exec \"node ./index.mjs\")",
"start:client": "cross-env NODE_ENV=development vite --host",
"build": "npm run build:server && npm run build:client",
"preview": "vite preview",
"build_server": "cd server && lake build",
"build_client": "cross-env NODE_ENV=production vite build",
"build:server": "cd server && lake build",
"build:client": "cross-env NODE_ENV=production vite build",
"production": "cross-env NODE_ENV=production node relay/index.mjs",
"translate": "npx i18next-scanner --config client/i18next-scanner.config.cjs",
"test:bare": "wait-on --resources \"http://localhost:8080\" \"http://localhost:3000\" && cypress run",
"test": "concurrently -k -n server,client,cypress -c blue,green,cyan \"npm run start_server\" \"npm run start_client\" \"npm run test:bare\""
"test": "concurrently -k -n server,client,cypress -c blue,green,cyan \"npm run start:server\" \"npm run start:client\" \"npm run test:bare\""
},
"eslintConfig": {
"extends": [
Expand Down

0 comments on commit 491be06

Please sign in to comment.