mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests (Local Emulator) / E2E Tests (Local Emulator, Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E Fallback Tests / E2E Fallback Tests (Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Lint & build / lint_and_build (24) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import fs from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { defineConfig, mergeConfig } from 'vitest/config'
|
|
import sharedConfig from '../../vitest.shared'
|
|
|
|
const tanstackStartServerContextStub = fileURLToPath(new URL('./src/tanstack-start-server-context.default.ts', import.meta.url)) // THIS_LINE_PLATFORM template
|
|
|
|
const SOURCE_FILE_PATTERN = /\.(jsx?|tsx?)$/;
|
|
const CLIENT_VERSION_SENTINEL = "STACK_COMPILE_TIME_CLIENT_PACKAGE_VERSION_SENTINEL";
|
|
const ENFORCE_PRE: "pre" = "pre";
|
|
|
|
function getPackageVersionLabel() {
|
|
const packageJson: unknown = JSON.parse(fs.readFileSync(fileURLToPath(new URL("./package.json", import.meta.url)), "utf-8"));
|
|
if (
|
|
typeof packageJson !== "object"
|
|
|| packageJson === null
|
|
|| !("name" in packageJson)
|
|
|| typeof packageJson.name !== "string"
|
|
|| !("version" in packageJson)
|
|
|| typeof packageJson.version !== "string"
|
|
) {
|
|
throw new Error("Expected package.json to include string name and version fields.");
|
|
}
|
|
|
|
return `js ${packageJson.name}@${packageJson.version}`;
|
|
}
|
|
|
|
const replaceCompileTimeClientVersion = () => {
|
|
const packageVersionLabel = getPackageVersionLabel();
|
|
return {
|
|
name: 'stackframe vitest client version replacement',
|
|
enforce: ENFORCE_PRE,
|
|
transform(code: string, id: string) {
|
|
const filePath = id.split(/[?#]/, 1)[0];
|
|
if (!SOURCE_FILE_PATTERN.test(filePath) || !code.includes(CLIENT_VERSION_SENTINEL)) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
code: code.replaceAll(CLIENT_VERSION_SENTINEL, packageVersionLabel),
|
|
map: null,
|
|
};
|
|
},
|
|
};
|
|
};
|
|
|
|
export default mergeConfig(
|
|
sharedConfig,
|
|
defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
"@hexclave/tanstack-start/tanstack-start-server-context": tanstackStartServerContextStub, // THIS_LINE_PLATFORM template
|
|
},
|
|
},
|
|
plugins: [replaceCompileTimeClientVersion()],
|
|
}),
|
|
)
|