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
This commit is contained in:
Alex Christoffer Rasmussen
2025-10-07 12:10:24 +02:00
parent 750927dc8d
commit fc7ed6bd20
30 changed files with 266 additions and 227 deletions
+3 -6
View File
@@ -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": {
+3 -3
View File
@@ -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
@@ -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 (
<>
<Panel.Header>Network</Panel.Header>
{isDockerImage && (
{isDocker && (
<Panel.Section>
<OntimeCloudStats />
</Panel.Section>
+5 -2
View File
@@ -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',
+2 -4
View File
@@ -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",
+2
View File
@@ -0,0 +1,2 @@
node_modules
dist
+1
View File
@@ -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"
+2
View File
@@ -0,0 +1,2 @@
node_modules
dist
-10
View File
@@ -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',
});
-8
View File
@@ -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',
});
-8
View File
@@ -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',
});
+16
View File
@@ -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',
});
-10
View File
@@ -1,10 +0,0 @@
export const esbuildCommon = {
logLevel: 'error',
platform: 'node',
target: ['node20'],
format: 'cjs',
bundle: true,
minify: true,
legalComments: 'external',
dropLabels: ['DEV'],
};
+9 -10
View File
@@ -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"
}
}