mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
fix: strip leading "v" from version strings before building
This commit is contained in:
@@ -9,6 +9,7 @@ import { rimraf } from 'rimraf';
|
||||
import { nativeNodeModulesPlugin } from '../esbuild/native-node-module.ts';
|
||||
import { nodeProtocolPlugin } from '../esbuild/node-protocol.ts';
|
||||
|
||||
import { trimStart } from 'lodash-es';
|
||||
import { createRequire } from 'node:module';
|
||||
const __require = createRequire(import.meta.url);
|
||||
const esbuildPluginPino = __require('esbuild-plugin-pino');
|
||||
@@ -88,7 +89,7 @@ const result = await esbuild.build({
|
||||
metafile: true,
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
'process.env.TUNARR_VERSION': `"${process.env.TUNARR_VERSION}"`,
|
||||
'process.env.TUNARR_VERSION': `"${trimStart(process.env.TUNARR_VERSION, 'v')}"`,
|
||||
'process.env.TUNARR_BUILD': `"${process.env.TUNARR_BUILD}"`,
|
||||
'process.env.TUNARR_EDGE_BUILD': `"${isEdgeBuild}"`,
|
||||
'import.meta.url': '__import_meta_url',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { trimStart } from 'lodash-es';
|
||||
import tunarrPackage from '../../package.json' with { type: 'json' };
|
||||
import { getBooleanEnvVar, getEnvVar, TUNARR_ENV_VARS } from './env.ts';
|
||||
import { isNonEmptyString, isProduction } from './index.js';
|
||||
@@ -6,8 +7,10 @@ let tunarrVersion: string;
|
||||
export const getTunarrVersion = () => {
|
||||
if (!tunarrVersion) {
|
||||
// Attempt to set for dev. This is relative to the shared package
|
||||
tunarrVersion =
|
||||
getEnvVar(TUNARR_ENV_VARS.BUILD_ENV_VAR) ?? tunarrPackage.version ?? '';
|
||||
tunarrVersion = trimStart(
|
||||
getEnvVar(TUNARR_ENV_VARS.BUILD_ENV_VAR) ?? tunarrPackage.version ?? '',
|
||||
'v',
|
||||
);
|
||||
|
||||
const isEdgeBuild = getBooleanEnvVar(
|
||||
TUNARR_ENV_VARS.IS_EDGE_BUILD_ENV_VAR,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Close, Refresh } from '@mui/icons-material';
|
||||
import { Button, Stack } from '@mui/material';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { trimStart } from 'lodash-es';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import type { StrictOmit } from 'ts-essentials';
|
||||
import { getApiVersionOptions } from '../generated/@tanstack/react-query.gen.ts';
|
||||
@@ -21,7 +22,8 @@ export const useVersion = (
|
||||
});
|
||||
|
||||
const versionMismatch =
|
||||
!query.isLoading && query.data?.tunarr !== __TUNARR_VERSION__;
|
||||
!query.isLoading &&
|
||||
trimStart(query.data?.tunarr, 'v') !== trimStart(__TUNARR_VERSION__, 'v');
|
||||
|
||||
if (versionMismatch) {
|
||||
snackbar.enqueueSnackbar({
|
||||
@@ -35,8 +37,8 @@ export const useVersion = (
|
||||
the browser to get the latest. If this message persists, clear your
|
||||
browser cache and reload.
|
||||
<br />
|
||||
Web version = {__TUNARR_VERSION__}, Server version ={' '}
|
||||
{query.data?.tunarr}
|
||||
Web version = {trimStart(__TUNARR_VERSION__, 'v')}, Server version ={' '}
|
||||
{trimStart(query.data?.tunarr, 'v')}
|
||||
</span>
|
||||
),
|
||||
variant: 'warning',
|
||||
|
||||
@@ -14,6 +14,9 @@ const packageVersion = packageDef.version;
|
||||
|
||||
const version = (() => {
|
||||
let tunarrVersion = process.env.TUNARR_VERSION ?? packageVersion;
|
||||
if (tunarrVersion.startsWith('v')) {
|
||||
tunarrVersion = tunarrVersion.slice(1);
|
||||
}
|
||||
const build = process.env[BUILD_ENV_VAR] ?? '';
|
||||
const isEdgeBuildValue = process.env[IS_EDGE_BUILD_ENV_VAR];
|
||||
const isEdgeBuild = isEdgeBuildValue === 'true' || isEdgeBuildValue === '1';
|
||||
|
||||
Reference in New Issue
Block a user