From 76974f67dd5e318ab8b3ebab4c1c135f27b971dc Mon Sep 17 00:00:00 2001 From: Nixinova Date: Tue, 23 Jan 2024 20:45:35 +1300 Subject: [PATCH] Say 'not present' for versions that don't use pack formats --- changelog.md | 3 +++ src/cli.ts | 8 ++++++-- src/index.ts | 13 +++++++------ src/types.ts | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 518387f..a55f5d4 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/cli.ts b/src/cli.ts index a08abc1..f78d899 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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) @@ -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}`) } } diff --git a/src/index.ts b/src/index.ts index 5282671..cede4b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,9 +3,10 @@ import { VersionName, SnapshotName, PackType, FormatResult, VersionsResult } fro // Data sets // const START_RELEASES: Record> = { - '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 }, @@ -25,9 +26,9 @@ const START_RELEASES: Record> = { 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> = { - '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 }, diff --git a/src/types.ts b/src/types.ts index 7f8e369..411f166 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,7 +4,7 @@ export type SnapshotName = `${number}w${string}${Lowercase}` export type PackType = 'resource' | 'data' export type PackMap = Record -export type FormatResult = number | undefined +export type FormatResult = number | null | undefined export interface VersionsResult { releases: { min: VersionName | '', max: VersionName | '' },