diff --git a/.appflow/scripts/prebuild.sh b/.appflow/scripts/prebuild.sh new file mode 100755 index 0000000..c8313be --- /dev/null +++ b/.appflow/scripts/prebuild.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# npm hook run before the build script +# see: https://ionic.io/docs/appflow/automation/environments + +# echo ">>> prebuild script" + +# create .env file if running in Ionic Appflow +if [ "$CI_AUTOMATED_BUILD" = "1" ] +then + echo "Appflow build; creating .env file" + echo "VITE_BUILD_DATE=$(date +'%Y-%m-%d')" > .env + echo "VITE_BUILD_TIME=$(date +'%H:%M:%S%z')" >> .env + echo "VITE_BUILD_TS=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> .env + echo "VITE_BUILD_COMMIT_SHA=$CI_GIT_COMMIT_SHA" >> .env + echo "VITE_BUILD_WORKFLOW_NAME=$CI_AUTOMATION_NAME" >> .env + echo "VITE_BUILD_WORKFLOW_RUN_NUMBER=$CI_BUILD_NUMBER" >> .env + echo "VITE_BUILD_WORKFLOW_RUN_ATTEMPT=1" >> .env +else + echo "NOT an Appflow build; skipping .env file creation" +fi diff --git a/.gitignore b/.gitignore index bad4d28..c4c5b40 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,7 @@ # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local +.env* /.nx /.nx/cache /.vscode/* diff --git a/package.json b/package.json index 50af995..0b36802 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "type": "module", "scripts": { "dev": "vite", + "prebuild": "./.appflow/scripts/prebuild.sh", "build": "tsc && vite build", "preview": "vite preview", "test": "vitest",