Skip to content

refactor: replace extract code with sanity schema library#584

Draft
binoy14 wants to merge 2 commits intomainfrom
manifest-cleanup
Draft

refactor: replace extract code with sanity schema library#584
binoy14 wants to merge 2 commits intomainfrom
manifest-cleanup

Conversation

@binoy14
Copy link
Contributor

@binoy14 binoy14 commented Mar 10, 2026

Description

Replaces duplicate code with @sanity/schema/_internal

What to review

Anything I miss

Testing

Existing tests should suffice

@claude
Copy link

claude bot commented Mar 10, 2026

Claude finished @binoy14's task in 2m 22s —— View job


Review

  • Read CLAUDE.md and gather context
  • Analyze PR diff and changed files
  • Post review findings

Bug: schema list without --id flag will error

In packages/@sanity/cli/src/commands/schema/list.ts:68, when the --id flag is not provided, flags.id is undefined, and the code does:

const id = parseWorkspaceSchemaId(flags.id ?? '', errors)?.schemaId

This passes an empty string '' to parseWorkspaceSchemaId. The old local implementation had a guard if (id === undefined) { return } that skipped validation entirely. If the library's parseWorkspaceSchemaId treats an empty string as an error (pushing "id argument is empty" to the errors array), this will cause schema list (without --id) to fail.

Fix:

const id = flags.id !== undefined ? parseWorkspaceSchemaId(flags.id, errors)?.schemaId : undefined

Fix this →


Verify: extractCreateWorkspaceManifest handles icon resolution without workDir

The old extractWorkspaceManifest(workspaces, workDir) in extractWorkspaceManifest.ts passed workDir into icon resolution (resolveIcon({..., workDir})). The new code in extractManifest.worker.ts:23 calls extractCreateWorkspaceManifest(workspace) with no workDir. If the library's implementation still requires a working directory to resolve local icon references (e.g. React components defined in local files), icon extraction could silently fail or return null for workspaces that previously had icons. Worth confirming the library handles this case.


extractManifestSchemaTypes removed from public _internal export

packages/@sanity/cli/src/exports/_internal.ts previously exported extractManifestSchemaTypes. This is a breaking change for any consumer that imports from @sanity/cli/_internal. If this export was intentionally public-facing, a deprecation path or a re-export from @sanity/schema/_internal may be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant