- version 1.0.0 во всех package.json monorepo - версия в GET /health и в меню пользователя (vite define) - Docker: тег vX.Y.Z собирает образ :X.Y.Z и :X.Y, latest остаётся за main - README: как закрепить версию образа Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
85ac5b15cb
commit
68c5774df9
13 files changed
+49
-10
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@cfdm/api",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "pnpm --filter @cfdm/shared build && pnpm --filter @cfdm/db build && tsx watch src/index.ts",
|
||||
|
||||
@@ -3,7 +3,7 @@ import cors from '@fastify/cors'
|
||||
import sensible from '@fastify/sensible'
|
||||
import staticPlugin from '@fastify/static'
|
||||
import rateLimit from '@fastify/rate-limit'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
@@ -38,6 +38,11 @@ import { portalUsersRoutes } from './routes/portal-users.js'
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
/** Версия из apps/api/package.json (src/ и dist/ лежат на одном уровне с ним). */
|
||||
export const APP_VERSION: string = (
|
||||
JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string }
|
||||
).version
|
||||
|
||||
export interface BuildAppOptions {
|
||||
dbPath?: string
|
||||
staticDir?: string
|
||||
@@ -67,7 +72,7 @@ export async function buildApp(opts: BuildAppOptions = {}) {
|
||||
await app.register(authPlugin)
|
||||
await app.register(spacePlugin)
|
||||
|
||||
app.get('/health', async () => ({ ok: true }))
|
||||
app.get('/health', async () => ({ ok: true, version: APP_VERSION }))
|
||||
await app.register(launcherRoutes)
|
||||
|
||||
await app.register(spacesRoutes)
|
||||
|
||||
@@ -187,3 +187,17 @@ describe('dashboard stats', () => {
|
||||
await app.close()
|
||||
})
|
||||
})
|
||||
|
||||
describe('/health', () => {
|
||||
beforeEach(() => resetTestDb())
|
||||
afterEach(() => closeDb())
|
||||
|
||||
it('returns the release version from package.json', async () => {
|
||||
const { version } = (await import('../../package.json', { with: { type: 'json' } })).default
|
||||
const app = await buildApp()
|
||||
const res = await app.inject({ url: '/health' })
|
||||
expect(res.json()).toEqual({ ok: true, version })
|
||||
expect(version).toMatch(/^\d+\.\d+\.\d+$/)
|
||||
await app.close()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user