mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add volume mapping docs and build/version metadata
Add a volume-mapping guide and surface build/version metadata throughout the project. Changes included: - documentation: Add documentation/deployment/volume-mapping.md and update TABLEOFCONTENTS.md and README to reference it (helps users align download client and RMAB paths). - CI: Capture package.json version in .github/workflows/build-unified-image.yml, pass APP_VERSION as a build-arg, and update the Discord notification to show the semantic version and pull `:latest`. - Docker: Declare ARG APP_VERSION and expose NEXT_PUBLIC_APP_VERSION / APP_VERSION / GIT_COMMIT env vars in dockerfile.unified so runtime and client can read the semantic version and commit. - App API/UI: Update src/app/api/version/route.ts and src/components/ui/VersionBadge.tsx to prefer semantic app version (APP_VERSION / NEXT_PUBLIC_APP_VERSION), include fullVersion and commit info, show commit in tooltip, and adjust fallback/dev labels. - Tests: Update tests (system.routes.test.ts and VersionBadge.test.tsx) to reflect the new version/commit fields and behavior. - Audible integration: Add ipRedirectOverride query param to multiple Audible requests to avoid IP-based region redirects. - Misc: Bump package.json version to 1.0.0. These changes make version information consistent between build, runtime, and UI, improve CI notifications, add user guidance for common volume-mapping issues, and harden Audible scraping against region redirects.
This commit is contained in:
@@ -6,18 +6,14 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET() {
|
||||
const gitCommit = process.env.APP_VERSION || 'unknown';
|
||||
const appVersion = process.env.APP_VERSION || 'unknown';
|
||||
const gitCommit = process.env.GIT_COMMIT || 'unknown';
|
||||
const buildDate = process.env.BUILD_DATE || 'unknown';
|
||||
|
||||
// Get short commit hash (first 7 characters)
|
||||
const shortCommit = gitCommit !== 'unknown' && gitCommit.length >= 7
|
||||
? gitCommit.substring(0, 7)
|
||||
: gitCommit;
|
||||
|
||||
return NextResponse.json({
|
||||
version: `v.${shortCommit}`,
|
||||
version: appVersion !== 'unknown' ? `v${appVersion}` : 'vDEV',
|
||||
fullVersion: appVersion,
|
||||
commit: gitCommit,
|
||||
shortCommit,
|
||||
buildDate,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,27 +9,35 @@ import React, { useEffect, useState } from 'react';
|
||||
|
||||
export function VersionBadge() {
|
||||
const [version, setVersion] = useState<string | null>(null);
|
||||
const [commit, setCommit] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Try to get version from build-time env var first (instant, no API call)
|
||||
const buildTimeVersion = process.env.NEXT_PUBLIC_GIT_COMMIT;
|
||||
const buildTimeVersion = process.env.NEXT_PUBLIC_APP_VERSION;
|
||||
|
||||
if (buildTimeVersion && buildTimeVersion !== 'unknown') {
|
||||
// Get short commit hash (first 7 characters)
|
||||
const shortCommit = buildTimeVersion.length >= 7
|
||||
? buildTimeVersion.substring(0, 7)
|
||||
: buildTimeVersion;
|
||||
setVersion(`v.${shortCommit}`);
|
||||
setVersion(`v${buildTimeVersion}`);
|
||||
// Also get commit for tooltip if available
|
||||
const buildTimeCommit = process.env.NEXT_PUBLIC_GIT_COMMIT;
|
||||
if (buildTimeCommit && buildTimeCommit !== 'unknown') {
|
||||
const shortCommit = buildTimeCommit.length >= 7
|
||||
? buildTimeCommit.substring(0, 7)
|
||||
: buildTimeCommit;
|
||||
setCommit(shortCommit);
|
||||
}
|
||||
} else {
|
||||
// Fallback to API call if build-time env var is not available
|
||||
fetch('/api/version')
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
setVersion(data.version);
|
||||
if (data.commit && data.commit !== 'unknown') {
|
||||
setCommit(data.commit.substring(0, 7));
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to fetch version:', error);
|
||||
setVersion('v.dev');
|
||||
setVersion('vDEV');
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
@@ -38,10 +46,12 @@ export function VersionBadge() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tooltipText = commit ? `${version} (${commit})` : version;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="inline-flex items-center px-2.5 py-1 rounded-md bg-gradient-to-r from-gray-100 to-gray-200 dark:from-gray-700 dark:to-gray-800 border border-gray-300 dark:border-gray-600 shadow-sm"
|
||||
title={`Version ${version}`}
|
||||
title={tooltipText}
|
||||
>
|
||||
<span className="text-xs font-mono font-medium text-gray-700 dark:text-gray-300">
|
||||
{version}
|
||||
|
||||
@@ -215,7 +215,10 @@ export class AudibleService {
|
||||
logger.info(` Fetching page ${page}/${maxPages}...`);
|
||||
|
||||
const response = await this.fetchWithRetry('/adblbestsellers', {
|
||||
params: page > 1 ? { page } : {},
|
||||
params: {
|
||||
ipRedirectOverride: 'true', // Explicitly include to prevent IP-based region redirects
|
||||
...(page > 1 ? { page } : {}),
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
@@ -307,7 +310,10 @@ export class AudibleService {
|
||||
logger.info(` Fetching page ${page}/${maxPages}...`);
|
||||
|
||||
const response = await this.fetchWithRetry('/newreleases', {
|
||||
params: page > 1 ? { page } : {},
|
||||
params: {
|
||||
ipRedirectOverride: 'true', // Explicitly include to prevent IP-based region redirects
|
||||
...(page > 1 ? { page } : {}),
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
@@ -392,6 +398,7 @@ export class AudibleService {
|
||||
|
||||
const response = await this.fetchWithRetry('/search', {
|
||||
params: {
|
||||
ipRedirectOverride: 'true', // Explicitly include to prevent IP-based region redirects
|
||||
keywords: query,
|
||||
page,
|
||||
},
|
||||
@@ -572,7 +579,11 @@ export class AudibleService {
|
||||
*/
|
||||
private async scrapeAudibleDetails(asin: string): Promise<AudibleAudiobook | null> {
|
||||
try {
|
||||
const response = await this.fetchWithRetry(`/pd/${asin}`);
|
||||
const response = await this.fetchWithRetry(`/pd/${asin}`, {
|
||||
params: {
|
||||
ipRedirectOverride: 'true', // Explicitly include to prevent IP-based region redirects
|
||||
},
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
// Initialize result object
|
||||
|
||||
Reference in New Issue
Block a user