fix(frontend): move mock api files instead of removing

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-09-02 14:52:13 +02:00
parent dc48d52d75
commit 1f0439b618
4 changed files with 24 additions and 8 deletions

View file

@ -7,15 +7,29 @@
set -e
cleanup () {
if [ -d ../tmp/src/pages/api ]; then
echo "🦔 > Moving Mock API files back"
mv ../tmp/src/pages/api src/pages
fi
}
trap cleanup EXIT
echo "🦔 Frontend Production Build"
echo "🦔 > Clearing existing builds"
rm -rf dist/
echo "🦔 > Preparing files"
if [ "${1}" = "--keep-mock-api" ]; then
echo "🦔 > Keeping Mock API"
if [ ! -z "${NEXT_PUBLIC_USE_MOCK_API}" ]; then
echo "🦔 > Keeping Mock API because NEXT_PUBLIC_USE_MOCK_API is set"
if [ ! -d src/pages/api ]; then
echo "🦔 > ⚠️ src/pages/api doesn't exist"
fi
else
rm -rf src/pages/api
echo "🦔 > Moving Mock API because NEXT_PUBLIC_USE_MOCK_API is unset"
mkdir -p ../tmp/src/pages
mv src/pages/api ../tmp/src/pages/api
fi
echo "🦔 > Building"

View file

@ -4,9 +4,9 @@
"private": true,
"license": "AGPL-3.0",
"scripts": {
"build": "cross-env NODE_ENV=production ./build.sh",
"build:mock": "cross-env BUILD_TIME=true NEXT_PUBLIC_USE_MOCK_API=true ./build.sh --keep-mock-api",
"build:test": "cross-env BUILD_TIME=true NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true ./build.sh --keep-mock-api",
"build" : "cross-env NODE_ENV=production dotenv -- ./build.sh",
"build:mock" : "cross-env NEXT_PUBLIC_USE_MOCK_API=true dotenv -- ./build.sh",
"build:test" : "cross-env NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true dotenv -c test -- ./build.sh",
"analyze": "cross-env ANALYZE=true yarn build --profile",
"format": "prettier -c \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"",
"format:fix": "prettier -w \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"",
@ -151,6 +151,7 @@
"cypress": "13.1.0",
"cypress-commands": "3.0.0",
"cypress-fill-command": "1.0.2",
"dotenv-cli" : "7.3.0",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"eslint-config-prettier": "9.0.0",

View file

@ -18,8 +18,8 @@
"format": "dotenv -- turbo run format",
"start:dev": "dotenv -- turbo run start:dev",
"start": "dotenv -- turbo run start",
"test:ci": "dotenv -- turbo run test:ci",
"test": "dotenv -- turbo run test"
"test:ci": "dotenv -c test -- turbo run test:ci",
"test": "dotenv -c test -- turbo run test"
},
"packageManager": "yarn@3.6.3",
"resolutions": {

View file

@ -2461,6 +2461,7 @@ __metadata:
dom-serializer: 2.0.0
domhandler: 5.0.3
dompurify: 3.0.5
dotenv-cli: 7.3.0
emoji-picker-element: 1.18.3
emoji-picker-element-data: 1.4.0
eslint: 8.48.0