Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.11/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@octokit/rest": "^22.0.1",
"@types/node": "^25.6.0",
"@vitest/coverage-v8": "^3.2.4",
"typescript": "^5.9.3",
"typescript": "^6.0.2",
"vitest": "^3.2.4"
},
"pnpm": {
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/autodl/gammatroniques.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function download(): Promise<void> {

const appUrl: ImagesJsonBuildPart | undefined = page.builds[0].parts.find((part) => part.type === "app");

if (!appUrl || !appUrl.ota) {
if (!appUrl?.ota) {
console.error(`${logPrefix} No image found.`);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/check_images.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {existsSync} from "node:fs";
import {join} from "node:path";
import {BASE_INDEX_MANIFEST_FILENAME, BASE_REPO_URL, PREV_INDEX_MANIFEST_FILENAME, REPO_BRANCH, readManifest} from "./common";
import {BASE_INDEX_MANIFEST_FILENAME, BASE_REPO_URL, PREV_INDEX_MANIFEST_FILENAME, REPO_BRANCH, readManifest} from "./common.js";

const baseManifest = readManifest(BASE_INDEX_MANIFEST_FILENAME);

Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {exec} from "node:child_process";
import {createHash} from "node:crypto";
import {existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync} from "node:fs";
import path from "node:path";
import type {ExtraMetas, ExtraMetasWithFileName, ImageHeader, RepoImageMeta} from "./types";
import type {ExtraMetas, ExtraMetasWithFileName, ImageHeader, RepoImageMeta} from "./types.js";

export const UPGRADE_FILE_IDENTIFIER = Buffer.from([0x1e, 0xf1, 0xee, 0x0b]);
export const BASE_REPO_URL = "https://raw.githubusercontent.com/Koenkk/zigbee-OTA/";
Expand Down
4 changes: 2 additions & 2 deletions src/find_matches.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BASE_INDEX_MANIFEST_FILENAME, PREV_INDEX_MANIFEST_FILENAME, readManifest} from "./common";
import type {RepoImageMeta} from "./types";
import {BASE_INDEX_MANIFEST_FILENAME, PREV_INDEX_MANIFEST_FILENAME, readManifest} from "./common.js";
import type {RepoImageMeta} from "./types.js";

const USAGE = `Usage: tsx src/find_matches.ts <BASE|PREV> <imageType> <manufacturerCode> [modelId] [manufacturerName]
Examples:
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_check_ota_pr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from "node:assert";
import {existsSync, mkdirSync, writeFileSync} from "node:fs";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {
Expand All @@ -17,6 +16,7 @@ import {
} from "./common.js";
import {getChangedOtaFiles} from "./ghw_get_changed_ota_files.js";
import {processOtaFiles} from "./ghw_process_ota_files.js";
import type {Context} from "./types.js";

function throwError(comment: string): void {
writeFileSync(PR_ARTIFACT_ERROR_FILEPATH, comment);
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_concat_cacerts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {readdirSync, readFileSync, writeFileSync} from "node:fs";
import path from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import type {Context} from "./types.js";

export const CACERTS_DIR = "cacerts";
export const CACERTS_CONCAT_FILEPATH = "cacerts.pem";
Expand Down
3 changes: 1 addition & 2 deletions src/ghw_create_autodl_release.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import {BASE_IMAGES_DIR, BASE_INDEX_MANIFEST_FILENAME, execute, PREV_IMAGES_DIR, PREV_INDEX_MANIFEST_FILENAME, readManifest} from "./common.js";
import type {RepoImageMeta} from "./types.js";
import type {Context, RepoImageMeta} from "./types.js";

// about 3 lines
const MAX_RELEASE_NOTES_LENGTH = 380;
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_create_pr_to_default.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "node:assert";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import type {Context} from "./types.js";

const IGNORE_OTA_WORKFLOW_LABEL = "ignore-ota-workflow";

Expand Down
2 changes: 1 addition & 1 deletion src/ghw_get_changed_ota_files.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from "node:assert";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {BASE_IMAGES_DIR} from "./common.js";
import type {Context} from "./types.js";

export async function getChangedOtaFiles(
github: Octokit,
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_identify_stacks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {readFileSync, writeFileSync} from "node:fs";
import {join} from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {BASE_INDEX_MANIFEST_FILENAME, BASE_REPO_URL, parseImageHeader, REPO_BRANCH, readManifest, UPGRADE_FILE_IDENTIFIER} from "./common.js";
import type {Context} from "./types.js";

enum ZigbeeStackVersion {
Zigbee2006 = 0x0000,
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_overwrite_cache.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {existsSync, mkdirSync} from "node:fs";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {ALL_AUTODL_MANUFACTURERS, CACHE_DIR} from "./common.js";
import type {Context} from "./types.js";

export async function overwriteCache(_github: Octokit, core: typeof CoreApi, _context: Context, manufacturersCSV?: string): Promise<void> {
if (!existsSync(CACHE_DIR)) {
Expand Down
3 changes: 1 addition & 2 deletions src/ghw_process_ota_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from "node:assert";
import {readFileSync, renameSync} from "node:fs";
import path from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import {
addImageToBase,
Expand All @@ -17,7 +16,7 @@ import {
parseImageHeader,
UPGRADE_FILE_IDENTIFIER,
} from "./common.js";
import type {ExtraMetas, GHExtraMetas, RepoImageMeta} from "./types.js";
import type {Context, ExtraMetas, GHExtraMetas, RepoImageMeta} from "./types.js";

const GLEDOPTO_MANUFACTURER_CODE = 4687;
const TUYA_MANUFACTURER_CODE_1 = 4098;
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_report_ota_pr.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from "node:assert";
import {existsSync, readFileSync, writeFileSync} from "node:fs";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {execute, PR_ARTIFACT_DIR, PR_DIFF_FILENAME, PR_ERROR_FILENAME, PR_NUMBER_FILENAME} from "./common.js";
import type {Context} from "./types.js";

export async function reportOtaPR(github: Octokit, core: typeof CoreApi, context: Context): Promise<void> {
assert(context.payload.workflow_run, "Not a workflow run");
Expand Down
3 changes: 1 addition & 2 deletions src/ghw_reprocess_all_images.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync} from "node:fs";
import path from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import {
addImageToBase,
Expand All @@ -24,7 +23,7 @@ import {
UPGRADE_FILE_IDENTIFIER,
writeManifest,
} from "./common.js";
import type {RepoImageMeta} from "./types";
import type {Context, RepoImageMeta} from "./types.js";

/** These are now handled by autodl */
const IGNORE_3RD_PARTIES = ["https://github.com/fairecasoimeme/", "https://github.com/xyzroe/"];
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_run_autodl.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {existsSync, mkdirSync, rmSync} from "node:fs";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {ALL_AUTODL_MANUFACTURERS, BASE_INDEX_MANIFEST_FILENAME, CACHE_DIR, PREV_INDEX_MANIFEST_FILENAME, TMP_DIR, writeManifest} from "./common.js";
import type {Context} from "./types.js";

export async function runAutodl(_github: Octokit, core: typeof CoreApi, _context: Context, manufacturersCSV?: string): Promise<void> {
const manufacturers = manufacturersCSV ? manufacturersCSV.trim().split(",") : ALL_AUTODL_MANUFACTURERS;
Expand Down
2 changes: 1 addition & 1 deletion src/ghw_update_manifests.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import assert from "node:assert";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";

import {BASE_INDEX_MANIFEST_FILENAME, PREV_INDEX_MANIFEST_FILENAME, readManifest, writeManifest} from "./common.js";
import {getChangedOtaFiles} from "./ghw_get_changed_ota_files.js";
import {processOtaFiles} from "./ghw_process_ota_files.js";
import type {Context} from "./types.js";

export async function updateManifests(github: Octokit, core: typeof CoreApi, context: Context): Promise<void> {
assert(context.eventName === "push", "Not a push");
Expand Down
2 changes: 1 addition & 1 deletion src/process_firmware_image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
UPGRADE_FILE_IDENTIFIER,
writeManifest,
} from "./common.js";
import type {ExtraMetas} from "./types";
import type {ExtraMetas} from "./types.js";

export enum ProcessFirmwareImageStatus {
Error = -1,
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// XXX: workaround, `Context` no longer exported in v9+
import type {context as githubContext} from "@actions/github";
export type Context = typeof githubContext;

//-- Copied from ZHC
export interface Version {
imageType: number;
Expand Down
4 changes: 2 additions & 2 deletions tests/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import {copyFileSync, existsSync, mkdirSync} from "node:fs";
import path from "node:path";
import {it} from "vitest";
import * as common from "../src/common";
import type {ExtraMetas, RepoImageMeta} from "../src/types";
import * as common from "../src/common.js";
import type {ExtraMetas, RepoImageMeta} from "../src/types.js";

export const IMAGE_LUMI = "20240726111155_OTA_lumi.switch.n1aeu1_0.0.0_0025_20240725_8F4299.ota";
export const IMAGE_GLEDOPTO = "GL-B-008P_V17A1_OTAV7.ota";
Expand Down
9 changes: 4 additions & 5 deletions tests/ghw_check_ota_pr.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {existsSync, readFileSync, rmSync, writeFileSync} from "node:fs";
import path from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi} from "vitest";
import * as common from "../src/common";
import {checkOtaPR} from "../src/ghw_check_ota_pr";
import type {RepoImageMeta} from "../src/types";
import * as common from "../src/common.js";
import {checkOtaPR} from "../src/ghw_check_ota_pr.js";
import type {Context, RepoImageMeta} from "../src/types.js";
import {
BASE_IMAGES_TEST_DIR_PATH,
getAdjustedContent,
Expand All @@ -29,7 +28,7 @@ import {
PREV_IMAGES_TEST_DIR_PATH,
useImage,
withExtraMetas,
} from "./data.test";
} from "./data.test.js";

const github = {
rest: {
Expand Down
9 changes: 4 additions & 5 deletions tests/ghw_reprocess_all_images.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync} from "node:fs";
import path from "node:path";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi} from "vitest";
import * as common from "../src/common";
import * as common from "../src/common.js";
import {
NOT_IN_BASE_MANIFEST_IMAGES_DIR,
NOT_IN_MANIFEST_FILENAME,
NOT_IN_PREV_MANIFEST_IMAGES_DIR,
reProcessAllImages,
} from "../src/ghw_reprocess_all_images";
import type {RepoImageMeta} from "../src/types";
} from "../src/ghw_reprocess_all_images.js";
import type {Context, RepoImageMeta} from "../src/types.js";
import {
BASE_IMAGES_TEST_DIR_PATH,
getAdjustedContent,
Expand All @@ -26,7 +25,7 @@ import {
PREV_IMAGES_TEST_DIR_PATH,
useImage,
withExtraMetas,
} from "./data.test";
} from "./data.test.js";

/** not used */
const github = {};
Expand Down
9 changes: 4 additions & 5 deletions tests/ghw_update_manifests.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {rmSync} from "node:fs";
import type * as CoreApi from "@actions/core";
import type {Context} from "@actions/github/lib/context";
import type {Octokit} from "@octokit/rest";
import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi} from "vitest";
import * as common from "../src/common";
import {updateManifests} from "../src/ghw_update_manifests";
import type {RepoImageMeta} from "../src/types";
import * as common from "../src/common.js";
import {updateManifests} from "../src/ghw_update_manifests.js";
import type {Context, RepoImageMeta} from "../src/types.js";
import {
BASE_IMAGES_TEST_DIR_PATH,
getAdjustedContent,
Expand All @@ -15,7 +14,7 @@ import {
PREV_IMAGES_TEST_DIR_PATH,
useImage,
withExtraMetas,
} from "./data.test";
} from "./data.test.js";

const github = {
rest: {
Expand Down
8 changes: 4 additions & 4 deletions tests/process_firmware_image.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {existsSync, mkdirSync, readFileSync, rmSync} from "node:fs";
import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, type MockInstance, vi} from "vitest";
import * as common from "../src/common";
import {ProcessFirmwareImageStatus, processFirmwareImage} from "../src/process_firmware_image";
import type {RepoImageMeta} from "../src/types";
import * as common from "../src/common.js";
import {ProcessFirmwareImageStatus, processFirmwareImage} from "../src/process_firmware_image.js";
import type {RepoImageMeta} from "../src/types.js";
import {
BASE_IMAGES_TEST_DIR_PATH,
getAdjustedContent,
Expand All @@ -20,7 +20,7 @@ import {
PREV_IMAGES_TEST_DIR_PATH,
useImage,
withExtraMetas,
} from "./data.test";
} from "./data.test.js";

describe("Process Firmware Image", () => {
let baseManifest: RepoImageMeta[];
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"module": "ESNext",
"moduleResolution": "node10",
"module": "nodenext",
"moduleResolution": "nodenext",
"target": "ESNext",
"lib": ["ESNext"],
"types": ["node"],
"esModuleInterop": true,
"declaration": true,
"declarationMap": true,
Expand Down
Loading