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 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 "🦔 Frontend Production Build"
echo "🦔 > Clearing existing builds" echo "🦔 > Clearing existing builds"
rm -rf dist/ rm -rf dist/
echo "🦔 > Preparing files" echo "🦔 > Preparing files"
if [ "${1}" = "--keep-mock-api" ]; then if [ ! -z "${NEXT_PUBLIC_USE_MOCK_API}" ]; then
echo "🦔 > Keeping Mock API" 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 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 fi
echo "🦔 > Building" echo "🦔 > Building"

View file

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

View file

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

View file

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