From 41451280ab34bd6fee473f63ff238b5df2602662 Mon Sep 17 00:00:00 2001 From: omuretsu <84951833+Snarling@users.noreply.github.com> Date: Tue, 10 Jan 2023 20:51:14 -0500 Subject: [PATCH] Update build process `npm run build` now generates a .app folder with the minimal run files `npm run electron` now uses the .app contents as a base deploy-dev.yml should upload just the .app folder after building (not tested yet) --- .github/workflows/deploy-dev.yml | 2 +- .gitignore | 3 ++- package.json | 2 +- tools/build.sh | 13 +++++++++++++ tools/package-electron.sh | 13 +++++-------- 5 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 tools/build.sh diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 69690d927..6e9237fb2 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -29,7 +29,7 @@ jobs: - run: npm run build - uses: actions/upload-pages-artifact@v1 with: - path: "." + path: ".app" - name: Deploy to gh pages id: deployment uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index b6311a1a2..92eee2617 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,8 @@ Netburner.txt /input/bitburner.api.json .cypress -# tmp folder for electron +# tmp folder for build and electron +.app .package .build diff --git a/package.json b/package.json index d28a02497..a4b1eb0d6 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "format:report-diff": "bash -c 'if [[ $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | wc -c) -ne 0 ]]; then prettier -c $(git diff --name-only --diff-filter=ACMRTUXB origin/dev | grep -E \"(.js$|.jsx$|.ts$|.tsx$)\" | xargs); fi'", "start": "http-server -p 8000", "start:dev": "webpack serve --progress --env devServer --mode development", - "build": "webpack --mode production", + "build": "bash ./tools/build.sh", "build:dev": "webpack --mode development", "lint": "eslint --fix --ext js,jsx,ts,tsx --max-warnings 0 src", "lint:report": "eslint --ext js,jsx,ts,tsx --max-warnings 0 src", diff --git a/tools/build.sh b/tools/build.sh new file mode 100644 index 000000000..e26c98f09 --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# builds the game in the root folder +webpack --mode production + +# Clear out any files remaining from old builds and recreate folder +rm -rf .app +mkdir .app + +# Should be all the files needed. +cp index.html .app +cp favicon.ico .app +cp -r dist .app diff --git a/tools/package-electron.sh b/tools/package-electron.sh index 26612b4f7..d3ecd99d4 100755 --- a/tools/package-electron.sh +++ b/tools/package-electron.sh @@ -1,18 +1,15 @@ #!/bin/bash -set -euxo pipefail - -# Clear out any files remaining from old builds +# Clear out any files remaining from old builds and recreate folder rm -rf .package +mkdir .package -mkdir -p .package/dist/ || true - -cp index.html .package -cp favicon.ico .package +# .app should have the fully built game already after npm run build +cp -r .app/* .package cp -r electron/* .package + # steam_appid.txt would end up in the resource dir rm .package/steam_appid.txt -cp -r dist .package # Install electron sub-dependencies cd electron