3223a5ced7
Stale package.json создавал ложное впечатление rollback'а: staging
показывал "v1.2.0" хотя последний tag — v1.2.2 (package.json не bump'ился
со времён v1.2.0 release).
Vote A — branch builds НЕ используют package.json как version label.
Vite определяет channel:
serverTag != none → что прод/staging RUNS
clientTag → что build'ил CI tag pipeline (CI_COMMIT_TAG set)
CI без tag → 'dev' literal (staging / branch CI build)
локально → 'local' literal (pnpm dev)
Detection через новый __APP_CI__ define из process.env.CI (GitLab сетает
CI=true). Local pnpm dev: CI undefined → channel='local'.
package.json.version всё ещё инжектится как __APP_VERSION__ и видна в
tooltip badge'а как 'floor vX.Y.Z' — не как primary label.
Files:
- vite.config.ts: + APP_CI from process.env.CI
- src/vite-env.d.ts: + __APP_CI__ declare
- src/components/version/useAppVersion.ts: + clientCI
- src/components/version/VersionBadge.tsx: channel logic вместо fallback
Verify all three modes:
local → 'local · {commit}'
CI branch → 'dev · {commit}'
CI tag v1.3.1 → 'v1.3.1 · {commit}'
Tests: 116 pass.
30 lines
992 B
TypeScript
30 lines
992 B
TypeScript
/// <reference types="vite/client" />
|
|
|
|
interface ImportMetaEnv {
|
|
readonly VITE_API_BASE?: string
|
|
readonly VITE_API_PROXY?: string
|
|
}
|
|
|
|
interface ImportMeta {
|
|
readonly env: ImportMetaEnv
|
|
}
|
|
|
|
/**
|
|
* Build identity injected via Vite {@code define} (см. vite.config.ts).
|
|
* Используются {@code useAppVersion} hook + {@code UpdateBanner} component
|
|
* для server-vs-client comparison.
|
|
*
|
|
* <ul>
|
|
* <li>__APP_VERSION__ — package.json.version (fallback floor).</li>
|
|
* <li>__APP_TAG__ — CI_COMMIT_TAG без 'v' префикса. Пустая строка для
|
|
* branch / local builds. Authoritative для release builds.</li>
|
|
* <li>__APP_COMMIT__ — 8-char short SHA.</li>
|
|
* <li>__APP_BUILT_AT__ — ISO timestamp когда vite собирал bundle.</li>
|
|
* </ul>
|
|
*/
|
|
declare const __APP_VERSION__: string
|
|
declare const __APP_TAG__: string
|
|
declare const __APP_CI__: boolean
|
|
declare const __APP_COMMIT__: string
|
|
declare const __APP_BUILT_AT__: string
|