Aktualisiere die Version auf 1.4.2 und füge Funktionen zur Fehlerprotokollierung und Validierung von Saison-Slugs hinzu
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m51s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 2m43s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 8s
Some checks failed
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m51s
Code Analysis and Production Deploy / analyze (pull_request) Failing after 2m43s
Code Analysis and Production Deploy / deploy-production (pull_request) Has been skipped
Code Analysis and Production Deploy / deploy-test (pull_request) Has been skipped
Require Package Version Change / check (pull_request) Failing after 8s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harheimertc-website",
|
"name": "harheimertc-website",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
"description": "Moderne Webseite für den Harheimer Tischtennis Club",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -75,6 +75,26 @@ function seasonSlugToLabel(slug) {
|
|||||||
return `20${match[1]}/${match[2]}`
|
return `20${match[1]}/${match[2]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logReadError(message, filePath, error) {
|
||||||
|
console.error(message, { filePath, error })
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireSeasonSlug(seasonSlug) {
|
||||||
|
const value = String(seasonSlug || '')
|
||||||
|
if (!SEASON_SLUG_PATTERN.test(value)) {
|
||||||
|
throw new Error(`Ungueltiger Spielplan-Saison-Slug: ${value}`)
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeSpielplanCsvPath(csvPath) {
|
||||||
|
const value = String(csvPath || '')
|
||||||
|
if (value.includes('\0') || path.basename(value) !== 'spielplan.csv') {
|
||||||
|
throw new Error('Ungueltiger Spielplan-CSV-Pfad')
|
||||||
|
}
|
||||||
|
return path.normalize(value)
|
||||||
|
}
|
||||||
|
|
||||||
export function getCurrentSeasonSlug(date = new Date()) {
|
export function getCurrentSeasonSlug(date = new Date()) {
|
||||||
const year = date.getFullYear()
|
const year = date.getFullYear()
|
||||||
const month = date.getMonth()
|
const month = date.getMonth()
|
||||||
@@ -353,7 +373,7 @@ async function readFirstExistingJson(paths) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code !== 'ENOENT') {
|
||||||
console.error(`Fehler beim Lesen der Spielplan-JSON ${filePath}:`, error)
|
logReadError('Fehler beim Lesen der Spielplan-JSON', filePath, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +394,7 @@ async function readFirstExistingCsv(paths) {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code !== 'ENOENT') {
|
||||||
console.error(`Fehler beim Lesen der Spielplan-CSV ${filePath}:`, error)
|
logReadError('Fehler beim Lesen der Spielplan-CSV', filePath, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,7 +439,7 @@ export async function listSpielplanSeasons() {
|
|||||||
entries = await fs.readdir(directory)
|
entries = await fs.readdir(directory)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== 'ENOENT') {
|
if (error.code !== 'ENOENT') {
|
||||||
console.error(`Fehler beim Lesen des Spielplan-Saisonverzeichnisses ${directory}:`, error)
|
logReadError('Fehler beim Lesen des Spielplan-Saisonverzeichnisses', directory, error)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -468,5 +488,7 @@ export async function readSpielplanData(options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getSpielplanSeasonJsonPathForCsvPath(csvPath, seasonSlug) {
|
export function getSpielplanSeasonJsonPathForCsvPath(csvPath, seasonSlug) {
|
||||||
return path.join(path.dirname(csvPath), 'spielplaene', `spielplan-${seasonSlug}.json`)
|
const safeCsvPath = normalizeSpielplanCsvPath(csvPath)
|
||||||
|
const safeSeasonSlug = requireSeasonSlug(seasonSlug)
|
||||||
|
return `${path.dirname(safeCsvPath)}/spielplaene/spielplan-${safeSeasonSlug}.json`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user