mirror of
https://github.com/Koenkk/zigbee-OTA.git
synced 2026-06-24 10:58:33 +00:00
fix: typing
This commit is contained in:
6
.github/workflows/update_dependencies.yml
vendored
6
.github/workflows/update_dependencies.yml
vendored
@@ -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'
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 == '') {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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://');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user