From fc7ed6bd202af9848dd16004d4fbc85aa757963b Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Tue, 7 Oct 2025 12:10:24 +0200 Subject: [PATCH] clean turbo config and cache github actions (#1805) * refactor: turbo scripts refactor dev and build scripts remove cleanup * fix e2e script * cache playwright * cache pnpm * fix docker env in vite * fixup! refactor: turbo scripts * chore: add comment --- .eslintignore | 3 +- .github/workflows/build_cli.yml | 14 +++- .../{build.yml => build_electron.yml} | 14 +++- .github/workflows/build_resolver.yml | 17 +++- .github/workflows/test.yml | 80 ++++++++++--------- .prettierignore | 2 + DEVELOPMENT.md | 18 ++--- Dockerfile | 73 +++++++++-------- apps/client/package.json | 9 +-- apps/client/src/externals.ts | 6 +- .../panel/network-panel/NetworkLogPanel.tsx | 4 +- apps/client/vite.config.js | 7 +- apps/electron/package.json | 6 +- apps/resolver/.eslintignore | 2 + apps/resolver/package.json | 1 + apps/server/.eslintignore | 2 + apps/server/esbuild.dev.js | 10 --- apps/server/esbuild.docker.js | 8 -- apps/server/esbuild.electron.js | 8 -- apps/server/esbuild.js | 16 ++++ apps/server/esbuildCommon.js | 10 --- apps/server/package.json | 19 +++-- package.json | 20 ++--- packages/types/.eslintignore | 2 + packages/types/package.json | 2 +- packages/utils/.eslintignore | 2 + packages/utils/package.json | 3 +- playwright.config.ts | 23 ++++-- pnpm-lock.yaml | 58 +++++++------- turbo.json | 54 ++++++------- 30 files changed, 266 insertions(+), 227 deletions(-) rename .github/workflows/{build.yml => build_electron.yml} (84%) create mode 100644 apps/resolver/.eslintignore create mode 100644 apps/server/.eslintignore delete mode 100644 apps/server/esbuild.dev.js delete mode 100644 apps/server/esbuild.docker.js delete mode 100644 apps/server/esbuild.electron.js create mode 100644 apps/server/esbuild.js delete mode 100644 apps/server/esbuildCommon.js create mode 100644 packages/types/.eslintignore create mode 100644 packages/utils/.eslintignore diff --git a/.eslintignore b/.eslintignore index cfdd63c69..877ad032b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ - "ONTIME_VERSION.js" + "ONTIME_VERSION.js" +dist/ diff --git a/.github/workflows/build_cli.yml b/.github/workflows/build_cli.yml index 86c270017..effc09658 100644 --- a/.github/workflows/build_cli.yml +++ b/.github/workflows/build_cli.yml @@ -13,8 +13,20 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 + + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/build.yml b/.github/workflows/build_electron.yml similarity index 84% rename from .github/workflows/build.yml rename to .github/workflows/build_electron.yml index fe8e8268d..29b253124 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_electron.yml @@ -11,8 +11,20 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 + + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile diff --git a/.github/workflows/build_resolver.yml b/.github/workflows/build_resolver.yml index 71d543c2d..8f763fd4d 100644 --- a/.github/workflows/build_resolver.yml +++ b/.github/workflows/build_resolver.yml @@ -13,15 +13,26 @@ jobs: steps: - uses: actions/checkout@v4 - + - name: Setup pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 + + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build project packages - run: pnpm turbo @getontime/resolver#build + run: pnpm build:resolver - name: Publish to NPM run: pnpm publish --access public --no-git-checks diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ed99f191..66cdd12e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,47 +16,33 @@ jobs: - uses: actions/checkout@v4 - name: Setup pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 + + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile - # Run code quality per package - - name: React - Run linter + TypeScript checks - if: always() - run: pnpm lint && tsc --noEmit - working-directory: ./apps/client - - - name: Server - Run linter + TypeScript checks - if: always() - run: pnpm lint && tsc --noEmit - working-directory: ./apps/server - - - name: Utils - Run linter + TypeScript checks - if: always() - run: pnpm lint && tsc --noEmit - working-directory: ./packages/utils - - - name: Types - Run linter - if: always() + # Run code quality + - name: Run linter run: pnpm lint - working-directory: ./packages/types + + - name: Run TypeScript checks + run: pnpm typecheck # We choose to run tests separately - - name: React - Run unit tests + - name: Run unit tests if: always() - run: pnpm test:pipeline - working-directory: ./apps/client - - - name: Server - Run unit tests - if: always() - run: pnpm test:pipeline - working-directory: ./apps/server - - - name: Utils - Run unit tests - if: always() - run: pnpm test:pipeline - working-directory: ./packages/utils + run: pnpm test e2e-test: runs-on: ubuntu-latest @@ -64,14 +50,36 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup pnpm - uses: pnpm/action-setup@v3 + uses: pnpm/action-setup@v4 + + - name: Get pnpm store directory + run: echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ env.PNPM_STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Build client - run: pnpm build:local + - name: Get installed Playwright version + run: echo "PLAYWRIGHT_VERSION=$(pnpm ls @playwright/test --parseable | cut -s -d '@' -f3 | cut -d '/' -f1)" >> $GITHUB_ENV + - name: Cache playwright binaries + uses: actions/cache@v4 + with: + path: | + ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} + restore-keys: | + ${{ runner.os }}-playwright- + - run: npx playwright install --with-deps + if: steps.playwright-cache.outputs.cache-hit != 'true' - name: Install Playwright Browsers run: npx playwright install --with-deps diff --git a/.prettierignore b/.prettierignore index 9f0973be1..46cb21864 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,3 +9,5 @@ playwright-report **/*.yml **/*.json !tsconfig.common.json +!turbo.json +!package.json diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 130d301c7..48f93b23a 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -21,7 +21,7 @@ Locally, we would need to run both the React client and the node.js server in de From the project root, run the following commands - __Install the project dependencies__ by running `pnpm i` -- __Run dev mode__ by running `pnpm turbo dev` +- __Run dev mode__ by running `pnpm dev` or `pnpm dev:electron` to get the electron window ### Debugging backend @@ -30,10 +30,10 @@ The previous command will start the development servers for both the client, ser Typically in dev mode we prefer to start these in separate terminals to help with error tracking and debugging. We do that by creating two terminals an running -- __Run the React UI__ by running `pnpm turbo dev --filter=ontime-ui` -- __Run the nodejs server__ by running `pnpm turbo dev --filter=ontime-server` +- __Run the React UI__ by running `pnpm dev --filter=ontime-ui` +- __Run the nodejs server__ by running `pnpm dev --filter=ontime-server` -- If you need to set breakpoints and inspect the code execution, enable Node.js inspect mode by running `pnpm turbo dev:inspect --filter=ontime-server`. +- If you need to set breakpoints and inspect the code execution, enable Node.js inspect mode by running `pnpm dev:inspect --filter=ontime-server`. ## TESTING @@ -46,7 +46,7 @@ Generally we have 2 types of tests. Unit tests are contained in mostly all the apps and packages (client, server and utils) -You can run unit tests by running `pnpm turbo test:pipeline` from the project root. +You can run unit tests by running `pnpm test:pipeline` from the project root. This will run all tests and close test runner. Alternatively you can navigate to an app or project and run `pnpm test` to run those tests in watch mode @@ -66,7 +66,7 @@ start the webserver with `pnpm dev:server` Some other useful commands -- `pnpm e2e --ui` open playwright UI +- `pnpm e2e:ui` open playwright UI - `pnpm e2e --headed` run tests with a visible browser window ## CREATE AN INSTALLABLE FILE (Windows | MacOS | Linux) @@ -77,13 +77,13 @@ You can generate a distribution for your OS by running the following steps. From the project root, run the following commands - __Install the project dependencies__ by running `pnpm i` -- __Build the UI and server__ by running `pnpm turbo run build:electron` -- __Create the package__ by running `pnpm turbo run dist-win`, `pnpm turbo run dist-mac` or `pnpm turbo run dist-linux` +- __Build the UI and server__ by running `pnpm build` +- __Create the package__ by running `pnpm dist-win`, `pnpm dist-mac` or `pnpm dist-linux` The build distribution assets will be at `.apps/electron/dist` Note: The MacOS build will only work in CI, locally it will fail due to notarisation issues. -Use the `pnpm turbo run dist-mac:local` command to build a MacOS distribution locally and skip the notary process. +Use the `pnpm dist-mac:local` command to build a MacOS distribution locally and skip the notary process. ## DOCKER diff --git a/Dockerfile b/Dockerfile index 726130551..58480312b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,36 @@ -FROM node:22-bullseye AS builder -ENV PNPM_HOME="/pnpm" -ENV PATH="$PNPM_HOME:$PATH" -RUN npm install -g pnpm@10.11.0 -COPY . /app -WORKDIR /app -RUN pnpm --filter=ontime-ui --filter=ontime-server --filter=ontime-utils install --config.dedupe-peer-dependents=false --frozen-lockfile -RUN pnpm --filter=ontime-ui --filter=ontime-server run build:docker - -FROM node:22-alpine - -# Set environment variables -# Environment Variable to signal that we are running production -ENV NODE_ENV=docker -# Ontime Data path -ENV ONTIME_DATA=/data/ - -WORKDIR /app/ - -# Prepare UI -COPY --from=builder /app/apps/client/build ./client/ - -# Prepare Backend -COPY --from=builder /app/apps/server/dist/ ./server/ -COPY --from=builder /app/apps/server/src/external/ ./external/ -COPY --from=builder /app/apps/server/src/user/ ./user/ -COPY --from=builder /app/apps/server/src/html/ ./html/ - -# Export default ports -EXPOSE 4001/tcp 8888/udp 9999/udp - -CMD ["node", "server/docker.cjs"] - -# Build and run commands -# !!! Note that this command needs pre-build versions of the UI and server apps -# docker buildx build . -t getontime/ontime -# docker run -p 4001:4001 -p 8888:8888/udp -p 9999:9999/udp -v ./ontime-db:/data/ getontime/ontime +FROM node:22-bullseye AS builder +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN npm install -g pnpm@10.11.0 +COPY . /app +WORKDIR /app +RUN pnpm --filter=ontime-ui --filter=ontime-server --filter=ontime-utils --filter=ontime-types install --config.dedupe-peer-dependents=false --frozen-lockfile +RUN pnpm run build:docker + +FROM node:22-alpine + +# Set environment variables +# Environment Variable to signal that we are running production +ENV NODE_ENV=docker +# Ontime Data path +ENV ONTIME_DATA=/data/ + +WORKDIR /app/ + +# Prepare UI +COPY --from=builder /app/apps/client/build ./client/ + +# Prepare Backend +COPY --from=builder /app/apps/server/dist/ ./server/ +COPY --from=builder /app/apps/server/src/external/ ./external/ +COPY --from=builder /app/apps/server/src/user/ ./user/ +COPY --from=builder /app/apps/server/src/html/ ./html/ + +# Export default ports +EXPOSE 4001/tcp 8888/udp 9999/udp + +CMD ["node", "server/docker.cjs"] + +# Build and run commands +# docker buildx build . -t getontime/ontime +# docker run -p 4001:4001 -p 8888:8888/udp -p 9999:9999/udp -v ./ontime-db:/data/ getontime/ontime diff --git a/apps/client/package.json b/apps/client/package.json index a6b69bf9c..40258b8a4 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -37,15 +37,12 @@ "addversion": "node -p \"'export const ONTIME_VERSION = ' + JSON.stringify(require('../../package.json').version) + ';'\" > src/ONTIME_VERSION.js", "postinstall": "pnpm addversion", "dev": "cross-env BROWSER=none vite", - "build": "vite build", - "build:local": "cross-env NODE_ENV=local vite build", - "build:electron": "cross-env NODE_ENV=local vite build", - "build:docker": "cross-env VITE_IS_DOCKER=true vite build", - "build:localdocker": "cross-env NODE_ENV=local vite build", + "dev:electron": "pnpm dev", "lint": "eslint . --quiet", + "typecheck": "tsc --noEmit", + "build": "vite build", "test": "vitest", "test:pipeline": "vitest run", - "cleanup": "rm -rf .turbo && rm -rf node_modules && rm -rf build", "analyse": "npx vite-bundle-visualizer" }, "browserslist": { diff --git a/apps/client/src/externals.ts b/apps/client/src/externals.ts index 8b805de08..d7f572489 100644 --- a/apps/client/src/externals.ts +++ b/apps/client/src/externals.ts @@ -17,11 +17,11 @@ export const buyMeACoffeeUrl = 'https://buymeacoffee.com/cpvalente'; // resolve environment export const appVersion = version; -export const isProduction = import.meta.env.MODE === 'production'; -export const isDev = !isProduction; +export const isDocker = import.meta.env.IS_DOCKER; // this env is made available by the vite.config.js define function +export const isProduction = import.meta.env.PROD; +export const isDev = import.meta.env.DEV; export const currentHostName = window.location.hostname; export const isLocalhost = currentHostName === 'localhost' || currentHostName === '127.0.0.1'; -export const isDockerImage = Boolean(import.meta.env.VITE_IS_DOCKER); export const isOntimeCloud = currentHostName.includes('cloud.getontime.no'); // resolve entrypoint URLs diff --git a/apps/client/src/features/app-settings/panel/network-panel/NetworkLogPanel.tsx b/apps/client/src/features/app-settings/panel/network-panel/NetworkLogPanel.tsx index dd39a260b..075cb9a0e 100644 --- a/apps/client/src/features/app-settings/panel/network-panel/NetworkLogPanel.tsx +++ b/apps/client/src/features/app-settings/panel/network-panel/NetworkLogPanel.tsx @@ -4,7 +4,7 @@ import { MessageTag } from 'ontime-types'; import useScrollIntoView from '../../../../common/hooks/useScrollIntoView'; import { usePing } from '../../../../common/hooks/useSocket'; import { sendSocket } from '../../../../common/utils/socket'; -import { isDockerImage } from '../../../../externals'; +import { isDocker } from '../../../../externals'; import type { PanelBaseProps } from '../../panel-list/PanelList'; import * as Panel from '../../panel-utils/PanelUtils'; @@ -18,7 +18,7 @@ export default function NetworkLogPanel({ location }: PanelBaseProps) { return ( <> Network - {isDockerImage && ( + {isDocker && ( diff --git a/apps/client/vite.config.js b/apps/client/vite.config.js index 73ae3980c..e95deef66 100644 --- a/apps/client/vite.config.js +++ b/apps/client/vite.config.js @@ -8,14 +8,17 @@ import svgrPlugin from 'vite-plugin-svgr'; import { ONTIME_VERSION } from './src/ONTIME_VERSION'; const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN; -const isDev = process.env.NODE_ENV === 'local' || process.env.NODE_ENV === 'development'; export default defineConfig({ base: './', // Ontime cloud: we use relative paths to allow them to reference a dynamic base set at runtime + define: { + // we pass along the NODE_ENV here in case it is a docker build + 'import.meta.env.IS_DOCKER': process.env.NODE_ENV === 'docker', + }, plugins: [ react(), svgrPlugin(), - !isDev && + sentryAuthToken && sentryVitePlugin({ org: 'get-ontime', project: 'ontime', diff --git a/apps/electron/package.json b/apps/electron/package.json index 6b30a38c5..813c9e398 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -21,14 +21,12 @@ "wait-on": "^7.2.0" }, "scripts": { - "postinstall": "", + "dev:electron": "wait-on http://localhost:3000 && cross-env NODE_ENV=development electron .", "lint": "eslint . --quiet", - "dev": "wait-on http://localhost:3000 && cross-env NODE_ENV=development electron .", "dist-win": "electron-builder --publish=never --x64 --win", "dist-mac": "electron-builder --publish=never --mac", "dist-mac:local": "electron-builder --publish=never --mac -c.mac.identity=null", - "dist-linux": "electron-builder --publish=never --x64 --linux", - "cleanup": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" + "dist-linux": "electron-builder --publish=never --x64 --linux" }, "build": { "productName": "ontime-prerelease", diff --git a/apps/resolver/.eslintignore b/apps/resolver/.eslintignore new file mode 100644 index 000000000..a0270fb28 --- /dev/null +++ b/apps/resolver/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/apps/resolver/package.json b/apps/resolver/package.json index 0884b1876..5173ec5a7 100644 --- a/apps/resolver/package.json +++ b/apps/resolver/package.json @@ -8,6 +8,7 @@ "description": "shared typings for ontime", "scripts": { "lint": "eslint . --quiet", + "typecheck": "tsc --noEmit", "prebuild": "pnpm rimraf ./dist", "build": "tsup && pnpm rimraf ./dist/index.js", "postbuild": "pnpm rimraf ./dist/index.d.ts" diff --git a/apps/server/.eslintignore b/apps/server/.eslintignore new file mode 100644 index 000000000..a0270fb28 --- /dev/null +++ b/apps/server/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/apps/server/esbuild.dev.js b/apps/server/esbuild.dev.js deleted file mode 100644 index 7a9b2f645..000000000 --- a/apps/server/esbuild.dev.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as esbuild from 'esbuild'; -import { esbuildCommon } from './esbuildCommon.js'; - -await esbuild.build({ - ...esbuildCommon, - entryPoints: ['src/app.ts'], - minify: false, - dropLabels: [], - outfile: 'dist/index.cjs', -}); diff --git a/apps/server/esbuild.docker.js b/apps/server/esbuild.docker.js deleted file mode 100644 index f4463ff4e..000000000 --- a/apps/server/esbuild.docker.js +++ /dev/null @@ -1,8 +0,0 @@ -import * as esbuild from 'esbuild'; -import { esbuildCommon } from './esbuildCommon.js'; - -await esbuild.build({ - ...esbuildCommon, - entryPoints: ['src/index.ts'], - outfile: 'dist/docker.cjs', -}); diff --git a/apps/server/esbuild.electron.js b/apps/server/esbuild.electron.js deleted file mode 100644 index 4afaf5589..000000000 --- a/apps/server/esbuild.electron.js +++ /dev/null @@ -1,8 +0,0 @@ -import * as esbuild from 'esbuild'; -import { esbuildCommon } from './esbuildCommon.js'; - -await esbuild.build({ - ...esbuildCommon, - entryPoints: ['src/app.ts'], - outfile: 'dist/index.cjs', -}); diff --git a/apps/server/esbuild.js b/apps/server/esbuild.js new file mode 100644 index 000000000..584263362 --- /dev/null +++ b/apps/server/esbuild.js @@ -0,0 +1,16 @@ +import * as esbuild from 'esbuild'; + +const isDocker = process.env.NODE_ENV === 'docker'; + +await esbuild.build({ + logLevel: 'error', + platform: 'node', + target: ['node20'], + format: 'cjs', + bundle: true, + minify: true, + legalComments: 'external', + dropLabels: ['DEV'], + entryPoints: isDocker ? ['src/index.ts'] : ['src/app.ts'], + outfile: isDocker ? 'dist/docker.cjs' : 'dist/index.cjs', +}); diff --git a/apps/server/esbuildCommon.js b/apps/server/esbuildCommon.js deleted file mode 100644 index a7fe8891c..000000000 --- a/apps/server/esbuildCommon.js +++ /dev/null @@ -1,10 +0,0 @@ -export const esbuildCommon = { - logLevel: 'error', - platform: 'node', - target: ['node20'], - format: 'cjs', - bundle: true, - minify: true, - legalComments: 'external', - dropLabels: ['DEV'], -}; diff --git a/apps/server/package.json b/apps/server/package.json index ea59bb425..70c0eb4be 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -48,19 +48,18 @@ "scripts": { "addversion": "node -p \"'export const ONTIME_VERSION = ' + JSON.stringify(require('../../package.json').version) + ';'\" > src/ONTIME_VERSION.js", "postinstall": "pnpm addversion", + "dev": "cross-env NODE_ENV=development tsx watch ./src/index.ts", + "dev:electron": "pnpm dev", "dev:inspect": "cross-env NODE_ENV=development tsx watch --inspect ./src/index.ts", - "dev:test": "cross-env IS_TEST=true tsx ./src/index.ts", - "prebuild": "tsx ./scripts/bundleCss.ts && tsx ./scripts/bundleTranslation.ts", - "build": "node esbuild.electron.js", - "build:electron": "node esbuild.electron.js", - "build:local": "node esbuild.dev.js", - "build:docker": "node esbuild.docker.js", - "build:localdocker": "cross-env NODE_ENV=local node esbuild.docker.js", + "lint": "eslint . --quiet", - "test": "cross-env IS_TEST=true vitest", - "test:pipeline": "cross-env IS_TEST=true vitest run", "typecheck": "tsc --noEmit", - "cleanup": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" + + "prebuild": "tsx ./scripts/bundleCss.ts && tsx ./scripts/bundleTranslation.ts", + "build": "node esbuild.js", + + "test": "cross-env IS_TEST=true vitest", + "test:pipeline": "cross-env IS_TEST=true vitest run" } } diff --git a/package.json b/package.json index b45aa2ba8..77fc9a66f 100644 --- a/package.json +++ b/package.json @@ -22,19 +22,19 @@ "type": "module", "scripts": { "dev": "turbo run dev", + "dev:electron": "turbo run dev:electron", "lint": "turbo run lint", + "typecheck": "turbo run typecheck", "build": "turbo run build", - "build:local": "turbo run build:local", - "build:electron": "turbo run build:electron", - "build:localdocker": "turbo run build:localdocker", + "build:docker": "cross-env NODE_ENV=docker turbo run build --filter=ontime-server --filter=ontime-ui", "dist-win": "turbo run dist-win", "dist-mac": "turbo run dist-mac", "dist-linux": "turbo run dist-linux", - "e2e": "pnpm clear-temp && cross-env DEBUG=pw:webserver npx playwright test -c playwright.config.ts", - "e2e:ui": "cross-env DEBUG=pw:webserver npx playwright test --ui -c playwright.config.ts", + "e2e": "turbo run build --filter=ontime-ui && pnpm clear-temp && cross-env DEBUG=pw:webserver npx playwright test -c playwright.config.ts", + "e2e:ui": "cross-env NODE_ENV=development cross-env DEBUG=pw:webserver npx playwright test --ui -c playwright.config.ts", "e2e:i": "npx playwright codegen", - "cleanup": "pnpm rimraf node_modules && rimraf **/node_modules && rimraf **/**/node_modules", - "clear-temp": "rm -rf e2e/tests/fixtures/tmp" + "clear-temp": "rimraf e2e/tests/fixtures/tmp", + "test": "turbo run test:pipeline" }, "devDependencies": { "@playwright/test": "^1.51.1", @@ -46,9 +46,9 @@ "eslint-config-prettier": "catalog:", "eslint-plugin-playwright": "^1.5.2", "prettier": "catalog:", - "turbo": "^2.3.3", + "turbo": "2.5.8", "typescript": "catalog:", - "rimraf": "catalog:" + "rimraf": "catalog:" }, - "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977" + "packageManager": "pnpm@10.18.0+sha512.e804f889f1cecc40d572db084eec3e4881739f8dec69c0ff10d2d1beff9a4e309383ba27b5b750059d7f4c149535b6cd0d2cb1ed3aeb739239a4284a68f40cfa" } diff --git a/packages/types/.eslintignore b/packages/types/.eslintignore new file mode 100644 index 000000000..a0270fb28 --- /dev/null +++ b/packages/types/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/packages/types/package.json b/packages/types/package.json index e8e7ccd4c..7f6ba92c6 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -7,8 +7,8 @@ "private": true, "description": "shared typings for ontime", "scripts": { - "cleanup": "rm -rf .turbo && rm -rf node_modules", "lint": "eslint . --quiet", + "typecheck": "tsc --noEmit", "build": "tsc" }, "keywords": [], diff --git a/packages/utils/.eslintignore b/packages/utils/.eslintignore new file mode 100644 index 000000000..a0270fb28 --- /dev/null +++ b/packages/utils/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/packages/utils/package.json b/packages/utils/package.json index 6145004c0..6e5e71247 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -7,8 +7,7 @@ "scripts": { "lint": "eslint . --quiet", "test": "vitest", - "test:pipeline": "vitest run", - "cleanup": "rm -rf .turbo && rm -rf node_modules" + "test:pipeline": "vitest run" }, "dependencies": { "deepmerge-ts": "^7.0.3", diff --git a/playwright.config.ts b/playwright.config.ts index d6fac572e..7b5bbe012 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,6 +1,8 @@ import type { PlaywrightTestConfig } from '@playwright/test'; import { devices } from '@playwright/test'; +const isDevMode = process.env.NODE_ENV === 'development'; + /** * See https://playwright.dev/docs/test-configuration. */ @@ -15,18 +17,25 @@ const config: PlaywrightTestConfig = { retries: process.env.CI ? 2 : 0, workers: 1, reporter: 'html', - webServer: { - command: 'turbo run dev --filter=ontime-server', - port: 4001, - reuseExistingServer: true, - timeout: 60 * 1000, - }, + webServer: isDevMode + ? { + command: 'turbo run dev', + port: 3000, + reuseExistingServer: true, + timeout: 60 * 1000, + } + : { + command: 'turbo run dev --filter=ontime-server', + port: 4001, + reuseExistingServer: true, + timeout: 60 * 1000, + }, use: { screenshot: 'only-on-failure', video: 'retain-on-failure', viewport: { width: 1920, height: 1080 }, actionTimeout: 5000, - baseURL: 'http://localhost:4001', + baseURL: isDevMode ? 'http://localhost:3000' : 'http://localhost:4001', ignoreHTTPSErrors: true, trace: 'on-first-retry', launchOptions: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 969c6352d..e6170996b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,8 +75,8 @@ importers: specifier: 'catalog:' version: 6.0.1 turbo: - specifier: ^2.3.3 - version: 2.5.6 + specifier: 2.5.8 + version: 2.5.8 typescript: specifier: 'catalog:' version: 5.5.3 @@ -4890,38 +4890,38 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - turbo-darwin-64@2.5.6: - resolution: {integrity: sha512-3C1xEdo4aFwMJAPvtlPqz1Sw/+cddWIOmsalHFMrsqqydcptwBfu26WW2cDm3u93bUzMbBJ8k3zNKFqxJ9ei2A==} + turbo-darwin-64@2.5.8: + resolution: {integrity: sha512-Dh5bCACiHO8rUXZLpKw+m3FiHtAp2CkanSyJre+SInEvEr5kIxjGvCK/8MFX8SFRjQuhjtvpIvYYZJB4AGCxNQ==} cpu: [x64] os: [darwin] - turbo-darwin-arm64@2.5.6: - resolution: {integrity: sha512-LyiG+rD7JhMfYwLqB6k3LZQtYn8CQQUePbpA8mF/hMLPAekXdJo1g0bUPw8RZLwQXUIU/3BU7tXENvhSGz5DPA==} + turbo-darwin-arm64@2.5.8: + resolution: {integrity: sha512-f1H/tQC9px7+hmXn6Kx/w8Jd/FneIUnvLlcI/7RGHunxfOkKJKvsoiNzySkoHQ8uq1pJnhJ0xNGTlYM48ZaJOQ==} cpu: [arm64] os: [darwin] - turbo-linux-64@2.5.6: - resolution: {integrity: sha512-GOcUTT0xiT/pSnHL4YD6Yr3HreUhU8pUcGqcI2ksIF9b2/r/kRHwGFcsHgpG3+vtZF/kwsP0MV8FTlTObxsYIA==} + turbo-linux-64@2.5.8: + resolution: {integrity: sha512-hMyvc7w7yadBlZBGl/bnR6O+dJTx3XkTeyTTH4zEjERO6ChEs0SrN8jTFj1lueNXKIHh1SnALmy6VctKMGnWfw==} cpu: [x64] os: [linux] - turbo-linux-arm64@2.5.6: - resolution: {integrity: sha512-10Tm15bruJEA3m0V7iZcnQBpObGBcOgUcO+sY7/2vk1bweW34LMhkWi8svjV9iDF68+KJDThnYDlYE/bc7/zzQ==} + turbo-linux-arm64@2.5.8: + resolution: {integrity: sha512-LQELGa7bAqV2f+3rTMRPnj5G/OHAe2U+0N9BwsZvfMvHSUbsQ3bBMWdSQaYNicok7wOZcHjz2TkESn1hYK6xIQ==} cpu: [arm64] os: [linux] - turbo-windows-64@2.5.6: - resolution: {integrity: sha512-FyRsVpgaj76It0ludwZsNN40ytHN+17E4PFJyeliBEbxrGTc5BexlXVpufB7XlAaoaZVxbS6KT8RofLfDRyEPg==} + turbo-windows-64@2.5.8: + resolution: {integrity: sha512-3YdcaW34TrN1AWwqgYL9gUqmZsMT4T7g8Y5Azz+uwwEJW+4sgcJkIi9pYFyU4ZBSjBvkfuPZkGgfStir5BBDJQ==} cpu: [x64] os: [win32] - turbo-windows-arm64@2.5.6: - resolution: {integrity: sha512-j/tWu8cMeQ7HPpKri6jvKtyXg9K1gRyhdK4tKrrchH8GNHscPX/F71zax58yYtLRWTiK04zNzPcUJuoS0+v/+Q==} + turbo-windows-arm64@2.5.8: + resolution: {integrity: sha512-eFC5XzLmgXJfnAK3UMTmVECCwuBcORrWdewoiXBnUm934DY6QN8YowC/srhNnROMpaKaqNeRpoB5FxCww3eteQ==} cpu: [arm64] os: [win32] - turbo@2.5.6: - resolution: {integrity: sha512-gxToHmi9oTBNB05UjUsrWf0OyN5ZXtD0apOarC1KIx232Vp3WimRNy3810QzeNSgyD5rsaIDXlxlbnOzlouo+w==} + turbo@2.5.8: + resolution: {integrity: sha512-5c9Fdsr9qfpT3hA0EyYSFRZj1dVVsb6KIWubA9JBYZ/9ZEAijgUEae0BBR/Xl/wekt4w65/lYLTFaP3JmwSO8w==} hasBin: true type-check@0.4.0: @@ -10369,32 +10369,32 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - turbo-darwin-64@2.5.6: + turbo-darwin-64@2.5.8: optional: true - turbo-darwin-arm64@2.5.6: + turbo-darwin-arm64@2.5.8: optional: true - turbo-linux-64@2.5.6: + turbo-linux-64@2.5.8: optional: true - turbo-linux-arm64@2.5.6: + turbo-linux-arm64@2.5.8: optional: true - turbo-windows-64@2.5.6: + turbo-windows-64@2.5.8: optional: true - turbo-windows-arm64@2.5.6: + turbo-windows-arm64@2.5.8: optional: true - turbo@2.5.6: + turbo@2.5.8: optionalDependencies: - turbo-darwin-64: 2.5.6 - turbo-darwin-arm64: 2.5.6 - turbo-linux-64: 2.5.6 - turbo-linux-arm64: 2.5.6 - turbo-windows-64: 2.5.6 - turbo-windows-arm64: 2.5.6 + turbo-darwin-64: 2.5.8 + turbo-darwin-arm64: 2.5.8 + turbo-linux-64: 2.5.8 + turbo-linux-arm64: 2.5.8 + turbo-windows-64: 2.5.8 + turbo-windows-arm64: 2.5.8 type-check@0.4.0: dependencies: diff --git a/turbo.json b/turbo.json index ff9e97e6e..bbc081411 100644 --- a/turbo.json +++ b/turbo.json @@ -1,12 +1,21 @@ { "$schema": "https://turbo.build/schema.json", - "globalEnv": ["NODE_ENV", "GITHUB_TOKEN", "APPLEID", "APPLEIDPASS", "TEAMID", "CSC_KEY_PASSWORD", "CSC_LINK"], + "globalEnv": [ + "NODE_ENV", + "GITHUB_TOKEN", + "APPLEID", + "APPLEIDPASS", + "TEAMID", + "CSC_KEY_PASSWORD", + "CSC_LINK", + "SENTRY_AUTH_TOKEN" + ], "tasks": { "dev": { "cache": false, "persistent": true }, - "dev:server": { + "dev:electron": { "cache": false, "persistent": true }, @@ -14,45 +23,36 @@ "cache": false, "persistent": true }, - "dev:test": { - "cache": false - }, + "test": {}, "test:pipeline": {}, + "lint": { - "cache": false + "dependsOn": ["^lint"] }, "typecheck": { - "cache": false + "dependsOn": ["^typecheck"] }, "build": { - "dependsOn": [ - "^build" - ], - "env": ["SENTRY_AUTH_TOKEN"] - }, - "build:local": {}, - "build:electron": { - "env": ["SENTRY_AUTH_TOKEN"] - }, - "build:localdocker": {}, - "e2e": { - "dependsOn": [ - "^build" - ] + "dependsOn": ["^build"], + "outputs": ["dist/**", "build/**"] }, + "dist-win": { - "dependsOn": ["build"] + "dependsOn": ["build"], + "outputs": ["dist/**"] }, "dist-mac": { - "dependsOn": ["build"] + "dependsOn": ["build"], + "outputs": ["dist/**"] }, "dist-mac:local": { - "dependsOn": ["build"] + "dependsOn": ["build"], + "outputs": ["dist/**"] }, "dist-linux": { - "dependsOn": ["build"] - }, - "cleanup": {} + "dependsOn": ["build"], + "outputs": ["dist/**"] + } } }