diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 290fbf4ae0..cb1bb4647c 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -12,13 +12,37 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: './web/.node-version' + - name: Cache Cypress binary + id: cache-cypress + uses: actions/cache@v3 + with: + path: ~/.cache/Cypress + key: ${{ runner.os }}-cypress-${{ hashFiles('./web/pnpm-lock.yaml') }} + - name: Restore node_modules for web + id: cache-web + uses: actions/cache@v3 + with: + path: web/node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('./web/pnpm-lock.yaml') }} + - name: Install web dependencies + if: steps.cache-web.outputs.cache-hit != 'true' + run: pnpm install --frozen-lockfile + working-directory: ./web + - name: Install Cypress binary + if: steps.cache-cypress.outputs.cache-hit != 'true' + run: pnpm exec cypress install + working-directory: ./web - name: Cypress run component tests uses: cypress-io/github-action@v6 env: TZ: Europe/Copenhagen with: working-directory: ./web - install: true + install: false # to run component tests we need to use "component: true" component: true - name: Upload screenshots @@ -38,12 +62,37 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: './web/.node-version' + - name: Cache Cypress binary + id: cache-cypress + uses: actions/cache@v3 + with: + path: ~/.cache/Cypress + key: ${{ runner.os }}-cypress-${{ hashFiles('./web/pnpm-lock.yaml') }} + - name: Restore node_modules for web + id: cache-web + uses: actions/cache@v3 + with: + path: web/node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('./web/pnpm-lock.yaml') }} + - name: Install web dependencies + if: steps.cache-web.outputs.cache-hit != 'true' + run: pnpm install --frozen-lockfile + working-directory: ./web + - name: Install Cypress binary + if: steps.cache-cypress.outputs.cache-hit != 'true' + run: pnpm exec cypress install + working-directory: ./web - name: Cypress run e2e tests uses: cypress-io/github-action@v6 env: TZ: Europe/Copenhagen with: working-directory: ./web + install: false build: pnpm run build --mode testing start: pnpm run preview config: baseUrl=http://127.0.0.1:4173/ diff --git a/.github/workflows/deploy-preview-branch.yml b/.github/workflows/deploy-preview-branch.yml index f8730e1a8b..ae190dd216 100644 --- a/.github/workflows/deploy-preview-branch.yml +++ b/.github/workflows/deploy-preview-branch.yml @@ -21,10 +21,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 3a39c8ba5a..02b36bf154 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -17,10 +17,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index ef7e752113..25bd00daf1 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -21,10 +21,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/jsonlint.yml b/.github/workflows/jsonlint.yml index b3ee41e351..b1e3b93e69 100644 --- a/.github/workflows/jsonlint.yml +++ b/.github/workflows/jsonlint.yml @@ -11,10 +11,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Node LTS + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Install jsonlint-mod run: | npm install -g jsonlint-mod diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 186350697e..c6552ec5a2 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -15,10 +15,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index e77aa71cea..58df5566f6 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -16,10 +16,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index fdbf74b41b..8a5cd99c73 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -16,10 +16,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/validate_generate_files.yml b/.github/workflows/validate_generate_files.yml index 2800b208c2..0fc5f3c6aa 100644 --- a/.github/workflows/validate_generate_files.yml +++ b/.github/workflows/validate_generate_files.yml @@ -16,10 +16,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules for web id: cache-web uses: actions/cache@v3 diff --git a/.github/workflows/validate_generated_files.yml b/.github/workflows/validate_generated_files.yml index 164bfa29ff..2a2493e005 100644 --- a/.github/workflows/validate_generated_files.yml +++ b/.github/workflows/validate_generated_files.yml @@ -16,10 +16,10 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 - - name: Setup Node v18.x + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 + node-version-file: './web/.node-version' - name: Restore node_modules id: cache uses: actions/cache@v3 diff --git a/mockserver/.node-version b/mockserver/.node-version new file mode 100644 index 0000000000..209e3ef4b6 --- /dev/null +++ b/mockserver/.node-version @@ -0,0 +1 @@ +20 diff --git a/web/.node-version b/web/.node-version new file mode 100644 index 0000000000..209e3ef4b6 --- /dev/null +++ b/web/.node-version @@ -0,0 +1 @@ +20 diff --git a/web/package.json b/web/package.json index cb3c8522bf..51233c6230 100644 --- a/web/package.json +++ b/web/package.json @@ -14,8 +14,8 @@ "build": "pnpm update-version && vite build", "update-version": "echo '{\"version\": \"'$npm_package_version'\"}' > public/client-version.json", "create-generated-files": "pnpm run generate-world && pnpm run generate-zones-config", - "generate-world": "ts-node --esm ./geo/generateWorld.ts", - "generate-zones-config": "ts-node --esm ./scripts/generateZonesConfig.ts", + "generate-world": "node --import=./scripts/register-tsNodeESM.js ./geo/generateWorld.ts", + "generate-zones-config": "node --import=./scripts/register-tsNodeESM.js ./scripts/generateZonesConfig.ts", "predev": "pnpm run create-generated-files", "dev": "vite --open", "cy:component": "cypress open --component -b electron", @@ -195,7 +195,7 @@ "workbox-window": "7.0.0" }, "engines": { - "node": ">=18", + "node": "^20", "pnpm": "^8" } } diff --git a/web/scripts/register-tsNodeESM.js b/web/scripts/register-tsNodeESM.js new file mode 100644 index 0000000000..b4124d0e8e --- /dev/null +++ b/web/scripts/register-tsNodeESM.js @@ -0,0 +1,8 @@ +/** + * This script is meant to be used with 'node --import=register-tsNodeESM.js', and allows + * node v20 to use ts-node to execute Typescript files that contain ESM modules, without + * outputting JS files. + */ +import { register } from 'node:module'; +import { pathToFileURL } from 'node:url'; +register('ts-node/esm', pathToFileURL('./'));