fix: typing

This commit is contained in:
Nerivec
2025-03-03 13:36:54 +01:00
parent a82300d5ce
commit ad75bd6e1a
9 changed files with 11 additions and 11 deletions

View File

@@ -25,8 +25,8 @@ jobs:
cache: pnpm
- run: |
pnpm self-update
pnpm up --latest
pnpm self-update
pnpm up --latest
- uses: peter-evans/create-pull-request@v7
id: cpr
@@ -40,4 +40,4 @@ jobs:
if: ${{ steps.cpr.outputs.pull-request-number }}
with:
issue-number: ${{ steps.cpr.outputs.pull-request-number }}
body: "CC: @Koenkk"
body: 'CC: @Koenkk'

View File

@@ -66,7 +66,7 @@ export async function download(manufacturer: string, releasesUrl: string, assetF
const release = getLatestImage(releases, sortByPublishedAt);
if (release) {
const cachedData = readCacheJson<ReleasesJson | undefined>(manufacturer);
const cachedData = readCacheJson<ReleasesJson>(manufacturer);
const cached = cachedData?.length ? getLatestImage(cachedData, sortByPublishedAt) : undefined;
for (const assetFinder of assetFinders) {

View File

@@ -59,7 +59,7 @@ export async function download(): Promise<void> {
const images = await getJson<ImagesJson>(NAME, PRODUCTION_FIRMWARE_URL);
if (images?.length) {
const cachedData = readCacheJson<ImagesJson | undefined>(NAME);
const cachedData = readCacheJson<ImagesJson>(NAME);
for (const image of images) {
if (image.fw_type !== 2) {

View File

@@ -50,7 +50,7 @@ export async function download(): Promise<void> {
const images = await getJson<ImagesJson>(NAME, FIRMWARE_URL);
if (images?.length) {
const cachedData = readCacheJson<ImagesJson | undefined>(CACHE_FILENAME);
const cachedData = readCacheJson<ImagesJson>(CACHE_FILENAME);
for (const image of images) {
if (image.fw_type !== 2) {

View File

@@ -41,7 +41,7 @@ export async function download(): Promise<void> {
const models = await getJson<ModelsJson>(NAME, FIRMWARE_URL);
if (models) {
const cachedData = readCacheJson<ModelsJson | undefined>(NAME);
const cachedData = readCacheJson<ModelsJson>(NAME);
for (const model in models) {
if (model == '') {

View File

@@ -77,7 +77,7 @@ export async function download(): Promise<void> {
const images = await getJson<ImagesJson>(NAME, FIRMWARE_URL);
if (images?.firmwares?.length) {
const cachedData = readCacheJson<ImagesJson | undefined>(NAME);
const cachedData = readCacheJson<ImagesJson>(NAME);
const cachedDataByProduct = cachedData?.firmwares?.length ? groupByProduct(cachedData.firmwares) : undefined;
const firmwareByProduct = groupByProduct(images.firmwares);

View File

@@ -34,7 +34,7 @@ export async function download(): Promise<void> {
const images = await getJson<ImagesJson>(NAME, FIRMWARE_URL);
if (images?.versions?.length) {
const cachedData = readCacheJson<ImagesJson | undefined>(NAME);
const cachedData = readCacheJson<ImagesJson>(NAME);
for (const image of images.versions) {
const archiveUrl = image.url; //.replace(/^http:\/\//, 'https://');

View File

@@ -71,7 +71,7 @@ export async function download(): Promise<void> {
if (pageText?.length) {
const images = parseText(pageText);
const imagesByType = groupByImageType(images);
const cachedData = readCacheJson<Image[] | undefined>(NAME);
const cachedData = readCacheJson<Image[]>(NAME);
const cachedDataByType = cachedData ? groupByImageType(cachedData) : undefined;
for (const imageType in imagesByType) {

View File

@@ -93,7 +93,7 @@ export function writeCacheJson<T>(fileName: string, contents: T, basePath: strin
writeFileSync(path.join(basePath, `${fileName}.json`), JSON.stringify(contents), 'utf8');
}
export function readCacheJson<T>(fileName: string, basePath: string = CACHE_DIR): T {
export function readCacheJson<T>(fileName: string, basePath: string = CACHE_DIR): T | undefined {
const filePath = path.join(basePath, `${fileName}.json`);
return existsSync(filePath) ? JSON.parse(readFileSync(filePath, 'utf8')) : undefined;