fix: address release v2 reviews

This commit is contained in:
ajnart committed 2026-08-14 02:18:46 +02:00
1 parent 4905ea6738
commit 32732680e5
55 files changed
+925 -294

No files matched your search

@@ -3,7 +3,7 @@ import { test } from "node:test";
import { resolve } from "node:path";
import { checkFeatureContracts } from "./contracts.mts";
import { formatFeatureChanges, planFeatureGeneration } from "./generate-feature.mts";
import { formatFeatureChanges, getIntegrationGeneratorChoices, planFeatureGeneration } from "./generate-feature.mts";
// oxlint-disable-next-line import/no-unassigned-import -- Registers shared contract tests in this suite.
import "./check-feature.contract.mts";
@@ -13,6 +13,55 @@ test("the checked-in feature contracts are consistent", () => {
assert.deepEqual(checkFeatureContracts(root), []);
});
test("reads generator choices from the canonical integration definitions", () => {
const choices = getIntegrationGeneratorChoices(root);
assert.ok(choices.categories.includes("miscellaneous"));
assert.ok(choices.secretKinds.includes("apiKey"));
});
test("adds translations to empty JSON registries without a leading comma", async () => {
const fs = await import("node:fs");
const os = await import("node:os");
const path = await import("node:path");
const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "homarr-feature-generator-"));
try {
for (const sourcePath of [
"packages/definitions/src/integration.ts",
"packages/definitions/src/widget.ts",
"packages/definitions/src/widget-integration-map.ts",
"packages/definitions/src/docs/widget-doc-slugs.ts",
"packages/widgets/src/manifest.ts",
"packages/widgets/src/catalog.ts",
"packages/widgets/src/index.tsx",
]) {
const target = path.join(temporaryRoot, sourcePath);
fs.mkdirSync(path.dirname(target), { recursive: true });
fs.copyFileSync(path.join(root, sourcePath), target);
}
const translationPath = path.join(temporaryRoot, "packages/translation/src/lang/en.json");
fs.mkdirSync(path.dirname(translationPath), { recursive: true });
fs.writeFileSync(translationPath, '{\n "integration": {},\n "widget": {}\n}\n');
const changes = planFeatureGeneration(temporaryRoot, {
widget: {
kind: "exampleEmptyRegistry",
name: "Example empty registry",
slug: "example-empty-registry",
description: "Verifies empty translation registry insertion.",
icon: "IconBox",
supportedIntegrations: [],
},
});
const translation = changes.find((change) => change.path === "packages/translation/src/lang/en.json");
assert.ok(translation);
assert.doesNotThrow(() => JSON.parse(translation.content));
} finally {
fs.rmSync(temporaryRoot, { recursive: true, force: true });
}
});
test("paired generation plans every formatter-clean contract without writing", async () => {
const description =
"A deliberately long feature description that verifies generated source stays formatter-clean when contributor input exceeds the configured print width.";