v2: codemod iterations, canonical zod schema exports from sdk-shared (#2354)
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
This commit is contained in:
parent
7ea6fde1b6
commit
0fb8406d83
2 changed files with 2954 additions and 1665 deletions
|
|
@ -12,7 +12,7 @@ const PROJECT_ROOT = join(__dirname, '..');
|
|||
* - `2025-11-25`: the frozen, released schema.
|
||||
* - `2026-07-28`: the upcoming protocol revision.
|
||||
*
|
||||
* Each is written to `packages/core/src/types/spec.types.<version>.ts`.
|
||||
* Each is written to `packages/core-internal/src/types/spec.types.<version>.ts`.
|
||||
*/
|
||||
const SUPPORTED_VERSIONS = ['2025-11-25', '2026-07-28'] as const;
|
||||
type SpecVersion = (typeof SUPPORTED_VERSIONS)[number];
|
||||
|
|
@ -90,13 +90,13 @@ async function updateSpecTypes(version: SpecVersion, providedSHA?: string): Prom
|
|||
const fullContent = header + specContent;
|
||||
|
||||
// Format with prettier using the project's config so the output passes lint
|
||||
const outputPath = join(PROJECT_ROOT, 'packages', 'core', 'src', 'types', `spec.types.${version}.ts`);
|
||||
const outputPath = join(PROJECT_ROOT, 'packages', 'core-internal', 'src', 'types', `spec.types.${version}.ts`);
|
||||
const prettierConfig = await prettier.resolveConfig(outputPath);
|
||||
const formatted = await prettier.format(fullContent, { ...prettierConfig, filepath: outputPath });
|
||||
|
||||
writeFileSync(outputPath, formatted, 'utf-8');
|
||||
|
||||
console.log(`[${version}] Successfully updated packages/core/src/types/spec.types.${version}.ts`);
|
||||
console.log(`[${version}] Successfully updated packages/core-internal/src/types/spec.types.${version}.ts`);
|
||||
}
|
||||
|
||||
function isSupportedVersion(value: string): value is SpecVersion {
|
||||
|
|
|
|||
|
|
@ -516,7 +516,7 @@ function findPackageSrcDirs(packagesDir: string): string[] {
|
|||
const fullPath = join(entry.parentPath, entry.name);
|
||||
|
||||
// Only include src dirs that are direct children of a package
|
||||
// (e.g., packages/core/src, packages/middleware/express/src)
|
||||
// (e.g., packages/core-internal/src, packages/middleware/express/src)
|
||||
// Skip nested src dirs like node_modules/*/src
|
||||
if (fullPath.includes('node_modules')) continue;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue