diff --git a/.env b/.env.development similarity index 88% rename from .env rename to .env.development index b7744dbf4..c8c8de089 100644 --- a/.env +++ b/.env.development @@ -7,4 +7,5 @@ VITE_WMTS_BASE_URL=https://sys-wmts.dev.bgdi.ch/ VITE_WMS_BASE_URL=https://sys-wms.dev.bgdi.ch/ VITE_API_SERVICES_BASE_URL=https://sys-map.dev.bgdi.ch/api/ VITE_API_SERVICE_KML_BASE_URL=https://sys-public.dev.bgdi.ch/ +VITE_API_SERVICE_KML_STORAGE_BASE_URL=https://sys-public.dev.bgdi.ch/ VITE_APP_API_SERVICE_SHORTLINK_BASE_URL=https://sys-s.dev.bgdi.ch/ diff --git a/.env.integration b/.env.integration index d2ab352ad..2ae17afd0 100644 --- a/.env.integration +++ b/.env.integration @@ -6,4 +6,5 @@ VITE_WMTS_BASE_URL=https://sys-wmts.int.bgdi.ch/ VITE_WMS_BASE_URL=https://sys-wms.int.bgdi.ch/ VITE_API_SERVICES_BASE_URL=https://sys-map.int.bgdi.ch/api/ VITE_API_SERVICE_KML_BASE_URL=https://sys-public.int.bgdi.ch/ +VITE_API_SERVICE_KML_STORAGE_BASE_URL=https://sys-public.int.bgdi.ch/ VITE_APP_API_SERVICE_SHORTLINK_BASE_URL=https://sys-s.int.bgdi.ch/ diff --git a/.env.production b/.env.production index 397748d5c..af9fb5e34 100644 --- a/.env.production +++ b/.env.production @@ -1,10 +1,10 @@ -VITE_APP_API_BASE_URL=https://api3.geo.admin.ch/ +VITE_API_BASE_URL=https://api3.geo.admin.ch/ VITE_API_SERVICE_ALTI_BASE_URL=https://api3.geo.admin.ch/ VITE_API_SERVICE_SEARCH_BASE_URL=https://api3.geo.admin.ch/ -VITE_APP_API_PUBLIC_URL=https://public.geo.admin.ch/ -VITE_APP_DATA_BASE_URL=https://data.geo.admin.ch/ -VITE_APP_WMTS_BASE_URL=https://wmts.geo.admin.ch/ -VITE_APP_WMS_BASE_URL=https://wms.geo.admin.ch/ -VITE_APP_API_SERVICES_BASE_URL=https://map.geo.admin.ch/ -VITE_APP_API_SERVICE_KML_BASE_URL=https://public.geo.admin.ch/ +VITE_DATA_BASE_URL=https://data.geo.admin.ch/ +VITE_WMTS_BASE_URL=https://wmts.geo.admin.ch/ +VITE_WMS_BASE_URL=https://wms.geo.admin.ch/ +VITE_API_SERVICES_BASE_URL=https://map.geo.admin.ch/api/ +VITE_API_SERVICE_KML_BASE_URL=https://public.geo.admin.ch/ +VITE_API_SERVICE_KML_STORAGE_BASE_URL=https://public.geo.admin.ch/ VITE_APP_API_SERVICE_SHORTLINK_BASE_URL=https://s.geo.admin.ch/ diff --git a/.gitignore b/.gitignore index 9c09eac3e..8cbfe0f8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .DS_Store node_modules -/dist +dist/ # local env files .env.local diff --git a/buildspec.yml b/buildspec.yml index f012195d6..10110e4a4 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -44,11 +44,20 @@ phases: export GIT_BRANCH=${GIT_BRANCH##*/} fi # if this build has been triggered by a push on master (PR merge on master), we deploy on INT (otherwise everything goes to dev) - - export BUILD_TYPE=dev - export DEPLOY_TARGET="dev" - - if [ "${GIT_BRANCH}" = "master" ] ; then + - export BUILD_TYPE_1=dev + - export BUILD_OUTPUT_1=development + - export BUILD_TYPE_2=dev + - export BUILD_OUTPUT_2=development + - if [[ "${GIT_BRANCH}" == "master" ]]; then export DEPLOY_TARGET="int"; - export BUILD_TYPE=prod; + export BUILD_TYPE_1=int; + export BUILD_OUTPUT_1=integration; + export BUILD_TYPE_2=prod; + export BUILD_OUTPUT_2=production; + elif [[ "${GIT_BRANCH}" == "develop" ]]; then + export BUILD_TYPE_2=int; + export BUILD_OUTPUT_2=integration; fi # if we are on DEV, we have to switch to the account "swisstopo-bgdi-dev", otherwise the account is "swisstopo-bgdi" - export AWS_ACCOUNT_TO_USE="${AWS_SWISSTOPO_BGDI_DEV_ACCOUNT_ID}:role/BgdiDevCodebuildAccess" @@ -75,7 +84,10 @@ phases: - echo GIT_HASH=${GIT_HASH} - echo GIT_TAG=${GIT_TAG} - echo GIT_DIRTY=${GIT_DIRTY} - - echo BUILD_TYPE=${BUILD_TYPE} + - echo BUILD_TYPE_1=${BUILD_TYPE_1} + - echo BUILD_TYPE_2=${BUILD_TYPE_2} + - echo BUILD_OUTPUT_2=${BUILD_OUTPUT_2} + - echo BUILD_OUTPUT_1=${BUILD_OUTPUT_1} - echo DEPLOY_TARGET=${DEPLOY_TARGET} - echo AWS_ACCOUNT_TO_USE=${AWS_ACCOUNT_TO_USE} - echo APP_VERSION=${GIT_TAG} @@ -85,8 +97,13 @@ phases: build: commands: - echo =================================================================== - - echo Building application for ${BUILD_TYPE} - - npm run build-${BUILD_TYPE} + - echo Building application for ${BUILD_TYPE_1} + - npm run build:${BUILD_TYPE_1} + - if [[ "${BUILD_TYPE_1}" != "${BUILD_TYPE_2}" ]]; then + echo -------------------------------------------------------------------; + echo Building application for ${BUILD_TYPE_2}; + npm run build:${BUILD_TYPE_2}; + fi post_build: @@ -105,13 +122,19 @@ phases: - echo =================================================================== - echo E2E Testings... # will build the application in dev mode before testing - - CYPRESS_CACHE_FOLDER=/tmp/.cache npm run test:e2e:ci + - CYPRESS_CACHE_FOLDER=/tmp/.cache npm run test:e2e:ci:${BUILD_TYPE_1} - echo DONE artifacts: # The name below is only used for manual build (not by build started by the webhook) - name: ${BUILD_TYPE}/web-mapviewer/${APP_VERSION} + name: ${BUILD_TYPE_1}/web-mapviewer/${APP_VERSION} files: - '**/*' - base-directory: dist \ No newline at end of file + base-directory: dist/${BUILD_OUTPUT_1} + secondary-artifacts: + production: + name: ${BUILD_TYPE_2}/web-mapviewer/${APP_VERSION} + files: + - '**/*' + base-directory: dist/${BUILD_OUTPUT_2} \ No newline at end of file diff --git a/cypress.config.ts b/cypress.config.ts index d66e1e54c..9d0b7f4b5 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -69,6 +69,6 @@ module.exports = defineConfig({ }, baseUrl: 'http://localhost:8080', specPattern: 'tests/e2e-cypress/integration/**/*.*', - supportFile: 'tests/e2e-cypress/support/index.js', + supportFile: 'tests/e2e-cypress/support/index.js' }, }) diff --git a/package.json b/package.json index fe93f5e4b..13e7a35c7 100644 --- a/package.json +++ b/package.json @@ -4,19 +4,23 @@ "scripts": { "start": "npm run dev", "dev": "vite --port 8080", - "preview": "vite build && vite preview --port 8080", + "preview": "npm run build:prod && vite preview --port 8080 --outDir dist/production", + "preview:dev": "npm run build:dev && vite preview --port 8080 --outDir dist/development", "test:unit": "vitest --run --environment jsdom", "test:unit:watch": "vitest --environment jsdom", "test:e2e": "start-server-and-test dev 8080 'cypress open'", "test:e2e:tablet": "start-server-and-test preview 8080 'cypress open --config viewportWidth=768,viewportHeight=1024'", "test:e2e:desktop": "start-server-and-test preview 8080 'cypress open --config viewportWidth=1440,viewportHeight=900'", "test:e2e:ci": "start-server-and-test preview 8080 'cypress run'", + "test:e2e:ci:dev": "start-server-and-test preview:dev 8080 'cypress run'", + "test:e2e:ci:prod": "npm run test:e2e:ci", "test:ci": "npm run test:unit && npm run test:e2e:ci", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", "build": "npm run type-check && vite build", - "build-dev": "npm run build -- --mode development", - "build-prod": "npm run build -- --mode production", + "build:dev": "npm run build -- --mode development", + "build:int": "npm run build -- --mode integration", + "build:prod": "npm run build -- --mode production", "deploy:dev": "node scripts/deploy.js dev", "deploy:int": "node scripts/deploy.js int", "update:translations": "node scripts/generate-i18n-files.js", diff --git a/scripts/deploy.js b/scripts/deploy.js index f5c68b810..454589c8e 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -65,7 +65,7 @@ const s3Utils = require('./s3-utils') const fileUtils = require('./file-utils') // Checking if index.html file is present in dist folder (if build has been done beforehand) -if (!fileUtils.fileExists('./dist/index.html')) { +if (!fileUtils.fileExists('./dist/development/index.html')) { console.error('Please build the project before trying to deploy') process.exit(1) } @@ -114,7 +114,7 @@ s3Utils bucketFolder = branch } - const distFolderRelativePath = './dist/' + const distFolderRelativePath = './dist/development' const distFolderFullPath = resolve(distFolderRelativePath) let countFileBeingUploaded = 0 diff --git a/src/config.js b/src/config.js index 20baf1d88..83bbe2dfe 100644 --- a/src/config.js +++ b/src/config.js @@ -96,7 +96,7 @@ export const API_SERVICES_BASE_URL = enforceEndingSlashInUrl( * @type String */ export const API_SERVICE_KML_BASE_URL = enforceEndingSlashInUrl( - import.meta.env.VITE_API_SERVICE_KML_BASE_URL || API_PUBLIC_URL + import.meta.env.VITE_API_SERVICE_KML_BASE_URL ) /** @@ -108,7 +108,7 @@ export const API_SERVICE_KML_BASE_URL = enforceEndingSlashInUrl( * @type String */ export const API_SERVICE_KML_STORAGE_BASE_URL = enforceEndingSlashInUrl( - import.meta.env.VITE_API_SERVICE_KML_STORAGE_BASE_URL || API_SERVICE_KML_BASE_URL + import.meta.env.VITE_API_SERVICE_KML_STORAGE_BASE_URL ) /** diff --git a/tests/e2e-cypress/fixtures/service-kml/lonelyMarker.kml b/tests/e2e-cypress/fixtures/service-kml/lonelyMarker.kml index 74a235d20..85fdb5ccd 100644 --- a/tests/e2e-cypress/fixtures/service-kml/lonelyMarker.kml +++ b/tests/e2e-cypress/fixtures/service-kml/lonelyMarker.kml @@ -6,7 +6,7 @@