Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2932708c6 | ||
|
|
e835adeb16 |
No files matched your search
@@ -126,7 +126,7 @@ jobs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
run: bun scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build desktop artifact
|
||||
shell: bash
|
||||
@@ -248,7 +248,7 @@ jobs:
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
run: bun scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build CLI package
|
||||
run: bun run build --filter=@t3tools/web --filter=t3
|
||||
@@ -348,7 +348,7 @@ jobs:
|
||||
name: Update version strings
|
||||
env:
|
||||
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
|
||||
run: node scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
|
||||
run: bun scripts/update-release-package-versions.ts "$RELEASE_VERSION" --github-output
|
||||
|
||||
- name: Format package.json files
|
||||
if: steps.update_versions.outputs.changed == 'true'
|
||||
@@ -364,7 +364,7 @@ jobs:
|
||||
env:
|
||||
RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
|
||||
run: |
|
||||
if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock; then
|
||||
if git diff --quiet -- apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json apps/marketing/public/schemas bun.lock; then
|
||||
echo "No version changes to commit."
|
||||
exit 0
|
||||
fi
|
||||
@@ -372,6 +372,6 @@ jobs:
|
||||
git config user.name "${{ steps.app_bot.outputs.name }}"
|
||||
git config user.email "${{ steps.app_bot.outputs.email }}"
|
||||
|
||||
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
|
||||
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json apps/marketing/public/schemas bun.lock
|
||||
git commit -m "chore(release): prepare $RELEASE_TAG"
|
||||
git push origin HEAD:main
|
||||
@@ -4,8 +4,9 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"build:schemas": "bun ../../scripts/build-server-settings-schema.ts",
|
||||
"dev": "bun run build:schemas && astro dev",
|
||||
"build": "bun run build:schemas && astro build",
|
||||
"preview": "astro preview",
|
||||
"typecheck": "astro check"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Server Settings",
|
||||
"description": "JSON Schema for the server-authoritative settings.json file consumed by T3 Code.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enableAssistantStreaming": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"defaultThreadEnvMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["local", "worktree"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"textGenerationModelSelection": {
|
||||
"anyOf": [
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["codex"]
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"reasoningEffort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["xhigh", "high", "medium", "low"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["claudeAgent"]
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"thinking": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"effort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["low", "medium", "high", "max", "ultrathink"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"contextWindow": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"providers": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"codex": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"homePath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"claudeAgent": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -0,0 +1,258 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"title": "T3 Code Server Settings",
|
||||
"description": "JSON Schema for the server-authoritative settings.json file consumed by T3 Code.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enableAssistantStreaming": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"defaultThreadEnvMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["local", "worktree"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"textGenerationModelSelection": {
|
||||
"anyOf": [
|
||||
{
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["codex"]
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"reasoningEffort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["xhigh", "high", "medium", "low"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"enum": ["claudeAgent"]
|
||||
},
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"thinking": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"effort": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": ["low", "medium", "high", "max", "ultrathink"]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"fastMode": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"contextWindow": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["provider", "model"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"providers": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"codex": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"homePath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"claudeAgent": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"binaryPath": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"customModels": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
import { ClaudeModelSelection } from "@t3tools/contracts";
|
||||
import { resolveApiModelId } from "@t3tools/shared/model";
|
||||
import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
|
||||
import { toJsonSchemaObject } from "@t3tools/shared/schemaJson";
|
||||
|
||||
import { TextGenerationError } from "../Errors.ts";
|
||||
import { type TextGenerationShape, TextGeneration } from "../Services/TextGeneration.ts";
|
||||
@@ -27,7 +28,6 @@ import {
|
||||
sanitizeCommitSubject,
|
||||
sanitizePrTitle,
|
||||
sanitizeThreadTitle,
|
||||
toJsonSchemaObject,
|
||||
} from "../Utils.ts";
|
||||
import { normalizeClaudeModelOptionsWithCapabilities } from "@t3tools/shared/model";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import { CodexModelSelection } from "@t3tools/contracts";
|
||||
import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
|
||||
import { toJsonSchemaObject } from "@t3tools/shared/schemaJson";
|
||||
|
||||
import { resolveAttachmentPath } from "../../attachmentStore.ts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
@@ -26,7 +27,6 @@ import {
|
||||
sanitizeCommitSubject,
|
||||
sanitizePrTitle,
|
||||
sanitizeThreadTitle,
|
||||
toJsonSchemaObject,
|
||||
} from "../Utils.ts";
|
||||
import { getCodexModelCapabilities } from "../../provider/Layers/CodexProvider.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
|
||||
@@ -14,15 +14,6 @@ export function isGitRepository(cwd: string): boolean {
|
||||
return existsSync(join(cwd, ".git"));
|
||||
}
|
||||
|
||||
/** Convert an Effect Schema to a flat JSON Schema object, inlining `$defs` when present. */
|
||||
export function toJsonSchemaObject(schema: Schema.Top): unknown {
|
||||
const document = Schema.toJsonSchemaDocument(schema);
|
||||
if (document.definitions && Object.keys(document.definitions).length > 0) {
|
||||
return { ...document.schema, $defs: document.definitions };
|
||||
}
|
||||
return document.schema;
|
||||
}
|
||||
|
||||
/** Truncate a text section to `maxChars`, appending a `[truncated]` marker when needed. */
|
||||
export function limitSection(value: string, maxChars: number): string {
|
||||
if (value.length <= maxChars) return value;
|
||||
|
||||
@@ -17,6 +17,8 @@ This document covers how to run desktop releases from one tag, first without sig
|
||||
- Includes Electron auto-update metadata (for example `latest*.yml` and `*.blockmap`) in release assets.
|
||||
- Publishes the CLI package (`apps/server`, npm package `t3`) with OIDC trusted publishing.
|
||||
- Signing is optional and auto-detected per platform from secrets.
|
||||
- Refreshes the marketing-site JSON Schema for `settings.json` at `/schemas/server-settings.schema.json`.
|
||||
- Commits an immutable versioned JSON Schema copy at `/schemas/server-settings/<version>.schema.json`.
|
||||
|
||||
## Desktop auto-update notes
|
||||
|
||||
|
||||
@@ -43,6 +43,15 @@ export const formatSchemaError = (cause: Cause.Cause<Schema.SchemaError>) => {
|
||||
: Cause.pretty(cause);
|
||||
};
|
||||
|
||||
/** Convert an Effect Schema to a flat JSON Schema object, inlining `$defs` when present. */
|
||||
export const toJsonSchemaObject = (schema: Schema.Top): unknown => {
|
||||
const document = Schema.toJsonSchemaDocument(schema);
|
||||
if (document.definitions && Object.keys(document.definitions).length > 0) {
|
||||
return { ...document.schema, $defs: document.definitions };
|
||||
}
|
||||
return document.schema;
|
||||
};
|
||||
|
||||
/**
|
||||
* A `Getter` that parses a lenient JSON string (tolerating trailing commas
|
||||
* and JS-style comments) into an unknown value.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
SERVER_SETTINGS_SCHEMA_RELATIVE_PATH,
|
||||
writeServerSettingsJsonSchemas,
|
||||
} from "./lib/server-settings-schema.ts";
|
||||
|
||||
const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
writeServerSettingsJsonSchemas({ rootDir });
|
||||
|
||||
console.log(`Wrote ${SERVER_SETTINGS_SCHEMA_RELATIVE_PATH}`);
|
||||
@@ -0,0 +1,53 @@
|
||||
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildServerSettingsJsonSchema,
|
||||
getVersionedServerSettingsSchemaRelativePath,
|
||||
SERVER_SETTINGS_SCHEMA_RELATIVE_PATH,
|
||||
writeServerSettingsJsonSchemas,
|
||||
} from "./server-settings-schema";
|
||||
|
||||
describe("buildServerSettingsJsonSchema", () => {
|
||||
it("builds a JSON schema document for settings.json", () => {
|
||||
const schema = buildServerSettingsJsonSchema();
|
||||
|
||||
expect(schema.$schema).toBe("https://json-schema.org/draft/2020-12/schema");
|
||||
expect(schema.title).toBe("T3 Code Server Settings");
|
||||
expect(schema.type).toBe("object");
|
||||
expect(schema.additionalProperties).toBe(false);
|
||||
expect(schema.properties).toMatchObject({
|
||||
enableAssistantStreaming: expect.any(Object),
|
||||
defaultThreadEnvMode: expect.any(Object),
|
||||
textGenerationModelSelection: expect.any(Object),
|
||||
providers: expect.any(Object),
|
||||
});
|
||||
});
|
||||
|
||||
it("writes latest and versioned schema files", () => {
|
||||
const rootDir = mkdtempSync(join(tmpdir(), "t3-server-settings-schema-"));
|
||||
|
||||
try {
|
||||
const result = writeServerSettingsJsonSchemas({ rootDir, version: "1.2.3" });
|
||||
expect(result.changed).toBe(true);
|
||||
|
||||
const latestSchema = JSON.parse(
|
||||
readFileSync(resolve(rootDir, SERVER_SETTINGS_SCHEMA_RELATIVE_PATH), "utf8"),
|
||||
) as Record<string, unknown>;
|
||||
const versionedSchema = JSON.parse(
|
||||
readFileSync(
|
||||
resolve(rootDir, getVersionedServerSettingsSchemaRelativePath("1.2.3")),
|
||||
"utf8",
|
||||
),
|
||||
) as Record<string, unknown>;
|
||||
|
||||
expect(latestSchema).toEqual(versionedSchema);
|
||||
expect(latestSchema.title).toBe("T3 Code Server Settings");
|
||||
} finally {
|
||||
rmSync(rootDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { resolve, dirname } from "node:path";
|
||||
|
||||
import { ServerSettings } from "@t3tools/contracts/settings";
|
||||
import { toJsonSchemaObject } from "@t3tools/shared/schemaJson";
|
||||
|
||||
const JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
||||
|
||||
export const SERVER_SETTINGS_SCHEMA_RELATIVE_PATH =
|
||||
"apps/marketing/public/schemas/server-settings.schema.json";
|
||||
export const SERVER_SETTINGS_VERSIONED_SCHEMA_DIRECTORY_RELATIVE_PATH =
|
||||
"apps/marketing/public/schemas/server-settings";
|
||||
|
||||
export const getVersionedServerSettingsSchemaRelativePath = (version: string) =>
|
||||
`${SERVER_SETTINGS_VERSIONED_SCHEMA_DIRECTORY_RELATIVE_PATH}/${version}.schema.json`;
|
||||
|
||||
export function buildServerSettingsJsonSchema(): Record<string, unknown> {
|
||||
const schema = toJsonSchemaObject(ServerSettings);
|
||||
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
||||
throw new Error("ServerSettings JSON schema must be an object schema.");
|
||||
}
|
||||
|
||||
return {
|
||||
...schema,
|
||||
$schema: JSON_SCHEMA_DRAFT_2020_12,
|
||||
title: "T3 Code Server Settings",
|
||||
description: "JSON Schema for the server-authoritative settings.json file consumed by T3 Code.",
|
||||
};
|
||||
}
|
||||
|
||||
function writeJsonFileIfChanged(filePath: string, document: Record<string, unknown>): boolean {
|
||||
const nextContent = `${JSON.stringify(document, null, 2)}\n`;
|
||||
const previousContent = (() => {
|
||||
try {
|
||||
return readFileSync(filePath, "utf8");
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
|
||||
if (previousContent === nextContent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mkdirSync(dirname(filePath), { recursive: true });
|
||||
writeFileSync(filePath, nextContent);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function writeServerSettingsJsonSchemas(options?: {
|
||||
readonly rootDir?: string;
|
||||
readonly version?: string;
|
||||
}): {
|
||||
readonly changed: boolean;
|
||||
} {
|
||||
const rootDir = resolve(options?.rootDir ?? process.cwd());
|
||||
const latestSchema = buildServerSettingsJsonSchema();
|
||||
let changed = writeJsonFileIfChanged(
|
||||
resolve(rootDir, SERVER_SETTINGS_SCHEMA_RELATIVE_PATH),
|
||||
latestSchema,
|
||||
);
|
||||
|
||||
if (options?.version) {
|
||||
changed =
|
||||
writeJsonFileIfChanged(
|
||||
resolve(rootDir, getVersionedServerSettingsSchemaRelativePath(options.version)),
|
||||
latestSchema,
|
||||
) || changed;
|
||||
}
|
||||
|
||||
return { changed };
|
||||
}
|
||||
@@ -1,5 +1,13 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import {
|
||||
cpSync,
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
rmSync,
|
||||
writeFileSync,
|
||||
} from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
@@ -81,7 +89,7 @@ try {
|
||||
copyWorkspaceManifestFixture(tempRoot);
|
||||
|
||||
execFileSync(
|
||||
process.execPath,
|
||||
"bun",
|
||||
[
|
||||
resolve(repoRoot, "scripts/update-release-package-versions.ts"),
|
||||
"9.9.9-smoke.0",
|
||||
@@ -106,9 +114,34 @@ try {
|
||||
"Expected bun.lock to contain the smoke version.",
|
||||
);
|
||||
|
||||
const latestSchemaPath = resolve(
|
||||
tempRoot,
|
||||
"apps/marketing/public/schemas/server-settings.schema.json",
|
||||
);
|
||||
const versionedSchemaPath = resolve(
|
||||
tempRoot,
|
||||
"apps/marketing/public/schemas/server-settings/9.9.9-smoke.0.schema.json",
|
||||
);
|
||||
if (!existsSync(latestSchemaPath)) {
|
||||
throw new Error(
|
||||
"Expected release version alignment to generate the latest server settings schema.",
|
||||
);
|
||||
}
|
||||
if (!existsSync(versionedSchemaPath)) {
|
||||
throw new Error(
|
||||
"Expected release version alignment to generate the versioned server settings schema.",
|
||||
);
|
||||
}
|
||||
const versionedSchema = readFileSync(versionedSchemaPath, "utf8");
|
||||
assertContains(
|
||||
versionedSchema,
|
||||
'"title": "T3 Code Server Settings"',
|
||||
"Expected versioned server settings schema to contain schema metadata.",
|
||||
);
|
||||
|
||||
const { arm64Path, x64Path } = writeMacManifestFixtures(tempRoot);
|
||||
execFileSync(
|
||||
process.execPath,
|
||||
"bun",
|
||||
[resolve(repoRoot, "scripts/merge-mac-update-manifests.ts"), arm64Path, x64Path],
|
||||
{
|
||||
cwd: repoRoot,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
releasePackageFiles,
|
||||
updateReleasePackageVersions,
|
||||
} from "./update-release-package-versions";
|
||||
|
||||
describe("updateReleasePackageVersions", () => {
|
||||
it("updates package versions and writes latest plus versioned server settings schemas", () => {
|
||||
const rootDir = mkdtempSync(join(tmpdir(), "t3-release-version-bump-"));
|
||||
|
||||
try {
|
||||
for (const relativePath of releasePackageFiles) {
|
||||
const filePath = resolve(rootDir, relativePath);
|
||||
mkdirSync(dirname(filePath), { recursive: true });
|
||||
writeFileSync(
|
||||
filePath,
|
||||
`${JSON.stringify({ name: relativePath, version: "0.0.0" }, null, 2)}\n`,
|
||||
);
|
||||
}
|
||||
|
||||
const result = updateReleasePackageVersions("1.2.3", { rootDir });
|
||||
expect(result.changed).toBe(true);
|
||||
|
||||
for (const relativePath of releasePackageFiles) {
|
||||
const packageJson = JSON.parse(readFileSync(resolve(rootDir, relativePath), "utf8")) as {
|
||||
version?: string;
|
||||
};
|
||||
expect(packageJson.version).toBe("1.2.3");
|
||||
}
|
||||
|
||||
expect(
|
||||
JSON.parse(
|
||||
readFileSync(
|
||||
resolve(rootDir, "apps/marketing/public/schemas/server-settings.schema.json"),
|
||||
"utf8",
|
||||
),
|
||||
),
|
||||
).toMatchObject({ title: "T3 Code Server Settings" });
|
||||
|
||||
expect(
|
||||
JSON.parse(
|
||||
readFileSync(
|
||||
resolve(rootDir, "apps/marketing/public/schemas/server-settings/1.2.3.schema.json"),
|
||||
"utf8",
|
||||
),
|
||||
),
|
||||
).toMatchObject({ title: "T3 Code Server Settings" });
|
||||
} finally {
|
||||
rmSync(rootDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,8 @@ import { appendFileSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { writeServerSettingsJsonSchemas } from "./lib/server-settings-schema.ts";
|
||||
|
||||
export const releasePackageFiles = [
|
||||
"apps/server/package.json",
|
||||
"apps/desktop/package.json",
|
||||
@@ -37,6 +39,8 @@ export function updateReleasePackageVersions(
|
||||
changed = true;
|
||||
}
|
||||
|
||||
changed = writeServerSettingsJsonSchemas({ rootDir, version }).changed || changed;
|
||||
|
||||
return { changed };
|
||||
}
|
||||
|
||||
@@ -99,7 +103,7 @@ if (isMain) {
|
||||
);
|
||||
|
||||
if (!changed) {
|
||||
console.log("All package.json versions already match release version.");
|
||||
console.log("All release version artifacts already match the requested version.");
|
||||
}
|
||||
|
||||
if (writeGithubOutput) {
|
||||
|
||||
Reference in new issue
Block a user