Skip to content

Commit 0b37d0c

Browse files
ochafikclaude
andcommitted
refactor: move generated files to src/generated/ with simpler names
Moved: - src/schema.generated.ts → src/generated/schema.ts - src/schema.generated.test.ts → src/generated/schema.test.ts - src/schema.generated.json → src/generated/schema.json Benefits: - Cleaner organization (generated files isolated) - Simpler names without .generated suffix - Easier to gitignore if desired later 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 559c99c commit 0b37d0c

File tree

7 files changed

+17
-24
lines changed

7 files changed

+17
-24
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Verify generated schemas are up-to-date
3131
run: |
3232
npm run generate:schemas
33-
git diff --exit-code src/schema.generated.ts src/schema.generated.test.ts src/schema.generated.json || (echo "Generated schemas are out of date. Run 'npm run generate:schemas' and commit." && exit 1)
33+
git diff --exit-code src/generated/ || (echo "Generated schemas are out of date. Run 'npm run generate:schemas' and commit." && exit 1)
3434
3535
- run: npm test
3636

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"types": "./dist/src/app-bridge.d.ts",
2424
"default": "./dist/src/app-bridge.js"
2525
},
26-
"./schema.json": "./dist/src/schema.generated.json"
26+
"./schema.json": "./dist/src/generated/schema.json"
2727
},
2828
"files": [
2929
"dist"

scripts/generate-schemas.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,10 @@ const __dirname = dirname(__filename);
5959
const PROJECT_ROOT = join(__dirname, "..");
6060

6161
const SPEC_TYPES_FILE = join(PROJECT_ROOT, "src", "spec.types.ts");
62-
const SCHEMA_OUTPUT_FILE = join(PROJECT_ROOT, "src", "schema.generated.ts");
63-
const SCHEMA_TEST_OUTPUT_FILE = join(
64-
PROJECT_ROOT,
65-
"src",
66-
"schema.generated.test.ts",
67-
);
68-
const JSON_SCHEMA_OUTPUT_FILE = join(
69-
PROJECT_ROOT,
70-
"src",
71-
"schema.generated.json",
72-
);
62+
const GENERATED_DIR = join(PROJECT_ROOT, "src", "generated");
63+
const SCHEMA_OUTPUT_FILE = join(GENERATED_DIR, "schema.ts");
64+
const SCHEMA_TEST_OUTPUT_FILE = join(GENERATED_DIR, "schema.test.ts");
65+
const JSON_SCHEMA_OUTPUT_FILE = join(GENERATED_DIR, "schema.json");
7366

7467
/**
7568
* External types from MCP SDK that ts-to-zod can't resolve.
@@ -108,15 +101,15 @@ async function main() {
108101
console.warn("⚠️ Warning: Circular dependencies detected in types");
109102
}
110103

111-
let schemasContent = result.getZodSchemasFile("./spec.types.js");
104+
let schemasContent = result.getZodSchemasFile("../spec.types.js");
112105
schemasContent = postProcess(schemasContent);
113106

114107
writeFileSync(SCHEMA_OUTPUT_FILE, schemasContent, "utf-8");
115108
console.log(`✅ Written: ${SCHEMA_OUTPUT_FILE}`);
116109

117110
const testsContent = result.getIntegrationTestFile(
118-
"./spec.types.js",
119-
"./schema.generated.js",
111+
"../spec.types.js",
112+
"./schema.js",
120113
);
121114
if (testsContent) {
122115
const processedTests = postProcessTests(testsContent);
@@ -137,7 +130,7 @@ async function main() {
137130
async function generateJsonSchema() {
138131
// Dynamic import of the generated schemas
139132
// tsx handles TypeScript imports at runtime
140-
const schemas = await import("../src/schema.generated.js");
133+
const schemas = await import("../src/generated/schema.js");
141134

142135
const jsonSchema: {
143136
$schema: string;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// Run: npm run generate:schemas
44
import { z } from "zod/v4";
55

6-
import * as spec from "./spec.types.js";
7-
import * as generated from "./schema.generated.js";
6+
import * as spec from "../spec.types.js";
7+
import * as generated from "./schema.js";
88

99
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1010
function expectType<T>(_: T) {

src/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* MCP Apps Protocol Types and Schemas
33
*
4-
* This file re-exports types from spec.types.ts and schemas from schema.generated.ts.
5-
* Compile-time verification is handled by schema.generated.test.ts.
4+
* This file re-exports types from spec.types.ts and schemas from generated/schema.ts.
5+
* Compile-time verification is handled by generated/schema.test.ts.
66
*
77
* @see spec.types.ts for the source of truth TypeScript interfaces
8-
* @see schema.generated.ts for auto-generated Zod schemas
9-
* @see schema.generated.test.ts for compile-time verification
8+
* @see generated/schema.ts for auto-generated Zod schemas
9+
* @see generated/schema.test.ts for compile-time verification
1010
*/
1111

1212
// Re-export all types from spec.types.ts
@@ -54,4 +54,4 @@ export {
5454
McpUiInitializeRequestSchema,
5555
McpUiInitializeResultSchema,
5656
McpUiInitializedNotificationSchema,
57-
} from "./schema.generated.js";
57+
} from "./generated/schema.js";

0 commit comments

Comments
 (0)