Skip to content

Commit

Permalink
Say 'not present' for versions that don't use pack formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Jan 23, 2024
1 parent 5c490bb commit 76974f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Next
- Changed the CLI result to say 'not present' instead of 'not known' for versions that do not use a pack format.

## 1.3.12
*2024-01-23*
- Changed the CLI result to say 'not known' instead of 'undefined' for versions without associated pack formats.
Expand Down
8 changes: 6 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getPackFormat, getPackFormats, getVersions, LATEST } from './index'
import { FormatResult } from './types'
const VERSION = require('../package.json').version

const indent = (n: number): string => ' '.repeat(n * 4)
Expand Down Expand Up @@ -82,10 +83,13 @@ else if (args.latest) {
}
// Print the pack format of a given version
else if (ver) {
const formatResult = (result: FormatResult): string => (result + '').replace('null', 'not present').replace('undefined', 'not known')
if (!args.resource) {
console.log(`Data pack format of ${ver} is ${getPackFormat(ver, 'data') ?? 'not known'}`)
const result = formatResult(getPackFormat(ver, 'data'));
console.log(`Data pack format of ${ver} is ${result}`)
}
if (!args.data) {
console.log(`Resource pack format of ${ver} is ${getPackFormat(ver, 'resource') ?? 'not known'}`)
const result = formatResult(getPackFormat(ver, 'resource'));
console.log(`Resource pack format of ${ver} is ${result}`)
}
}
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { VersionName, SnapshotName, PackType, FormatResult, VersionsResult } fro
// Data sets //

const START_RELEASES: Record<VersionName, Record<PackType, FormatResult>> = {
'1.6.x': { resource: 1, data: undefined },
'1.9.x': { resource: 2, data: undefined },
'1.11.x': { resource: 3, data: undefined },
'1.0.x': { resource: null, data: null },
'1.6.x': { resource: 1, data: null },
'1.9.x': { resource: 2, data: null },
'1.11.x': { resource: 3, data: null },
'1.13.x': { resource: 4, data: 4 },
'1.15.x': { resource: 5, data: 5 },
'1.16.2': { resource: 6, data: 6 },
Expand All @@ -25,9 +26,9 @@ const START_RELEASES: Record<VersionName, Record<PackType, FormatResult>> = {
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>> = {
'13w24a': { resource: 1, data: undefined },
'15w31a': { resource: 2, data: undefined },
'16w32a': { resource: 3, data: undefined },
'13w24a': { resource: 1, data: null },
'15w31a': { resource: 2, data: null },
'16w32a': { resource: 3, data: null },
'17w48a': { resource: 4, data: 4 },
'20w06a': { resource: 5, data: 5 },
'20w45a': { resource: 7, data: 6 },
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type SnapshotName = `${number}w${string}${Lowercase<string>}`
export type PackType = 'resource' | 'data'
export type PackMap = Record<PackType, FormatResult>

export type FormatResult = number | undefined
export type FormatResult = number | null | undefined

export interface VersionsResult {
releases: { min: VersionName | '', max: VersionName | '' },
Expand Down

0 comments on commit 76974f6

Please sign in to comment.