Skip to content

Commit

Permalink
Make --latest check snapshots instead of releases list
Browse files Browse the repository at this point in the history
Makes the result properly accurate.
  • Loading branch information
Nixinova committed Jan 23, 2024
1 parent f509674 commit 84c5fd5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Next
- Fixed the result of `--latest` not always returning the very latest version.
- Updated resource pack format to `24`.
- Updated data pack format to `26`.

Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const START_RELEASES: Record<VersionName, Record<PackType, FormatResult>> = {
'1.21.x': { resource: undefined, data: undefined },
}

const maxFormat = (type: 'resource' | 'data') => Math.max(...Object.values(START_RELEASES).map(release => release[type] ?? 0));
const LATEST = { resource: maxFormat('resource'), data: maxFormat('data') };

const d = new Date(), year = d.getFullYear() - 2000, maxWeek = (d.getMonth() + 1) * 5
const fauxCurrentSnapshot: SnapshotName = `${year}w${maxWeek.toString().padStart(2, '0')}a`
const START_SNAPSHOTS: Record<string, Record<PackType, FormatResult>> = {
Expand Down Expand Up @@ -75,6 +72,9 @@ const SPECIAL: Record<PackType, Record<number, string[]>> = {
},
}

const maxFormat = (type: 'resource' | 'data') => Math.max(...Object.values(START_SNAPSHOTS).map(release => release[type] ?? 0));
const LATEST = { resource: maxFormat('resource'), data: maxFormat('data') };

/**
* @param version the version to look up
* @param type the pack format type to return; either 'resource' or 'data'
Expand Down

0 comments on commit 84c5fd5

Please sign in to comment.