diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index e0ebcff..b594903 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -46,5 +46,5 @@ jobs: git config user.name "Allen" git config user.email "accounts@stupid-genius.com" - name: Publish to pages branch - run: ./publish.sh + run: ./tools/publish.sh diff --git a/esbuild.mjs b/esbuild.mjs index b8a656a..3b62384 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -8,7 +8,7 @@ const onBuild = { setup(build){ build.onEnd(result => { // console.log(result); - exec('./build.sh spa', (err, stdout, stderr) => { + exec('./tools/build.sh spa', (err, stdout, stderr) => { if(err || stderr){ console.dir(err); console.error(stderr); diff --git a/package.json b/package.json index 8c1d1ad..99c12fd 100644 --- a/package.json +++ b/package.json @@ -34,15 +34,15 @@ "mocha": "^9.2.2" }, "scripts": { - "build": "npm run clean; ./build.sh", + "app": "npm run build; docker compose up --build; docker compose down", + "build": "npm run clean; ./tools/build.sh", "clean": "rm -rf dist", - "cluster": "npm run build; docker compose up --build; docker compose down", "container": "docker run --name webapp -p80:3000 --rm webapptemplate", "esbuild": "esbuild", "image": "docker build -t webapptemplate .", "nodemon": "npx nodemon dist/server/index.js", "package": "mkdir -p package; cd dist; npm pack --pack-destination='../package/'", - "start": "NODE_ENV=development ./serve.sh", + "start": "NODE_ENV=development ./tools/serve.sh", "test": "mocha test/server && karma start" } } diff --git a/build.sh b/tools/build.sh similarity index 82% rename from build.sh rename to tools/build.sh index dcbbe6c..361f4d8 100755 --- a/build.sh +++ b/tools/build.sh @@ -8,6 +8,7 @@ node esbuild.mjs if [[ -z "$1" || "$1" -ne spa ]]; then echo Full build cp -R app/server/ dist/server/ + cp .env dist/ else echo SPA build fi @@ -16,5 +17,7 @@ if [ -d "app/client/images" ] && [ -n "app/client/images/*" ]; then cp -R app/client/images dist/client/ fi jq '{name: .name, description: .description, version: .version, dependencies: .dependencies}' package.json > dist/package.json -cp package-lock.json .env dist/ +if [ "$NODE_ENV" = "production" ]; then + npm --prefix dist update --package-lock-only +fi echo Build complete diff --git a/nginx/create-cert.sh b/tools/create-cert.sh similarity index 100% rename from nginx/create-cert.sh rename to tools/create-cert.sh diff --git a/publish.sh b/tools/publish.sh similarity index 100% rename from publish.sh rename to tools/publish.sh diff --git a/serve.sh b/tools/serve.sh similarity index 78% rename from serve.sh rename to tools/serve.sh index a7e00e8..6e87669 100755 --- a/serve.sh +++ b/tools/serve.sh @@ -10,7 +10,6 @@ set +a APPPORT=3000 if [ "$NODE_ENV" = "production" ]; then - echo "NODE_ENV is set to production" if [ -n "$SPAMODE" ]; then npx http-server -c-1 client/ -p $APPPORT else @@ -21,13 +20,12 @@ else BSPID=$! echo BrowserSync PID $BSPID trap "kill -0 $BSPID &> /dev/null && kill $BSPID && echo sending SIGTERM to $BSPID" INT HUP TERM QUIT ABRT EXIT - # if [[ -z "$1" || "$1" -ne spa ]]; then if [ -n "$SPAMODE" ]; then echo Server in SPA mode - (fswatch -ol 1 app/client | xargs -n1 -I{} ./build.sh spa) & + (fswatch -ol 1 app/client | xargs -n1 -I{} ./tools/build.sh spa) & npx http-server -c-1 dist/client/ -p $APPPORT else - (fswatch -ol 1 app | xargs -n1 -I{} ./build.sh) & + (fswatch -ol 1 app | xargs -n1 -I{} ./tools/build.sh) & npm run nodemon fi fi