Skip to content

feat(cli): polish fern config migrate with docs.yml $ref pointer, drop group/defaultGroup, and workflow migration#14515

Merged
iamnamananand996 merged 17 commits intomainfrom
devin/FER-8911-1775156471
Apr 16, 2026
Merged

feat(cli): polish fern config migrate with docs.yml $ref pointer, drop group/defaultGroup, and workflow migration#14515
iamnamananand996 merged 17 commits intomainfrom
devin/FER-8911-1775156471

Conversation

@iamnamananand996
Copy link
Copy Markdown
Contributor

@iamnamananand996 iamnamananand996 commented Apr 2, 2026

Description

Closes FER-8911

Polishes the fern config migrate command with several improvements to handle real-world migration edge cases.

Changes Made

1. Drop defaultGroup and group from migration output

  • Removed defaultGroup propagation in Migrator.ts (multi-API path) and both convertSdkTargets / convertSdkTargetsFromRaw in convertSdkTargets.ts
  • Removed target.group = [groupName] assignment from convertGeneratorToTarget and convertRawGeneratorToTarget
  • Schemas (SdksSchema, SdkTargetSchema) are left unchanged for backward-compat reading

2. docs.yml $ref pointer

  • New migrateDocsYml function checks if docs.yml exists in the fern/ directory and, if so, returns a { $ref: "./docs.yml" } pointer
  • The migrated fern.yml simply points its docs key at the existing docs.yml file via $ref syntax — no inlining or recursive resolution
  • docs.yml is not added to migratedFiles (it must remain on disk since fern.yml now references it)

3. GitHub Actions workflow migration

  • New migrateGithubWorkflows function scans .github/workflows/*.yml and .yaml files
  • Transforms fern generatefern sdk generate
  • Transforms --group--target (only on lines containing fern generate)

4. Generator metadata and smart-casing migration

  • Migrates generator-level metadata fields: package-descriptiondescription, author/emailauthors, licenseoutput.git.license
  • Emits unsupported warning for metadata.reference-url (no fern.yml equivalent)
  • Emits unsupported warning for smart-casing (not supported in fern.yml)

5. Settings key alias

  • Added title-as-schema-name as an alias for titleAsSchemaName in the settings migration key map

6. Changelog entry (unreleased versioning system)

  • Added packages/cli/cli/changes/unreleased/polish-fern-config-migrate.yml using the new unreleased changelog system (no direct versions.yml entry)

7. Comprehensive test suite

  • migrateDocsYml.test.ts — 5 tests: missing file, $ref pointer creation, empty file, complex content, no inlining
  • migrateGithubWorkflows.test.ts — 9 tests: missing dir, empty dir, command rewriting, --group--target, fern-api variant, no-op, multiple files, non-yaml ignored, multi-command
  • convertSdkTargets.test.ts — 13 tests: empty groups, basic conversion, group/defaultGroup exclusion, multi-group, deduplication, unknown generators, config preservation, npm publish, apiName, raw format, image field, missing name, git output
  • FernConfigJsonMigrator.test.ts — 9 tests: detect/migrate for fern.config.json
  • GeneratorsYmlMigrator.test.ts — real-world xai REST/gRPC configs, metadata migration, smart-casing warnings, multi-group, openapi settings, auth
  • Migrator.test.ts — end-to-end integration tests for single-API and multi-API workspaces
  • convertApiSpecs.test.ts — API spec conversion edge cases
  • convertGitOutput.test.ts — git output configuration conversion
  • convertSettings.test.ts — settings key mapping including title-as-schema-name alias

Human review checklist

  • docs field type castdocsRef is cast via as unknown as schemas.FernYmlSchema["docs"] since { $ref: string } doesn't match the DocsSchema zod type. This works at runtime (YAML serializer sees a plain object) but bypasses compile-time type checking.
  • Metadata migration type castsgenerator.metadata and smart-casing are accessed via as casts (e.g. (generator as { "smart-casing"?: boolean })). These bypass compile-time checks; verify the underlying types actually carry these fields at runtime.
  • Duplicated metadata migration logic — The metadata → target.metadata / license → output.git.license block is duplicated between convertGeneratorToTarget and convertRawGeneratorToTarget. Consider extracting a shared helper if this grows.
  • Workflow regex scope--group → --target replacement is scoped to lines matching fern generate, but could still transform echo/comment lines that happen to contain that pattern.

Testing

  • Unit tests added (50+ tests across 9 test files)
  • Lint (pnpm run check) passes
  • Format (pnpm format) passes
  • Manual testing completed

Link to Devin session: https://app.devin.ai/sessions/9a72485c90c3405a98a3885f0fb90ebb
Requested by: @iamnamananand996

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Comment thread packages/cli/cli-v2/src/migrator/docs-yml/DocsYmlMigrator.ts Outdated
@devin-ai-integration devin-ai-integration bot force-pushed the devin/FER-8911-1775156471 branch from 549a1f0 to 026a8cf Compare April 3, 2026 19:09
@devin-ai-integration devin-ai-integration bot changed the title feat(cli): polish fern config migrate with docs.yml $ref resolution, drop group/defaultGroup, and workflow migration feat(cli): polish fern config migrate with docs.yml $ref pointer, drop group/defaultGroup, and workflow migration Apr 6, 2026
@devin-ai-integration devin-ai-integration bot force-pushed the devin/FER-8911-1775156471 branch from 8b41090 to e4e5f2a Compare April 6, 2026 19:06
@iamnamananand996 iamnamananand996 marked this pull request as ready for review April 7, 2026 11:01
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@devin-ai-integration devin-ai-integration bot force-pushed the devin/FER-8911-1775156471 branch 2 times, most recently from 5ed5b6a to 57f70a8 Compare April 7, 2026 20:52
@devin-ai-integration devin-ai-integration bot force-pushed the devin/FER-8911-1775156471 branch from 57f70a8 to d6f16d7 Compare April 7, 2026 22:22
fern-support and others added 12 commits April 7, 2026 22:29
…sing migration

- Add 6 new test files covering GeneratorsYmlMigrator, FernConfigJsonMigrator,
  Migrator (end-to-end), convertApiSpecs, convertGitOutput, and convertSettings
- Fix convertSdkTargets to migrate generator-level metadata fields (license →
  output.git.license, author/email → metadata.authors, package-description →
  metadata.description) and warn on unsupported reference-url and smart-casing
- Add 5 new tests to convertSdkTargets.test.ts covering metadata and smart-casing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Minor formatting changes across migrator tests and convertSdkTargets: condense multiline writeFile calls, inline arrays/objects and imports, and compact license/author assignment expressions into single-line forms for consistency and readability. No functional behavior changed; only whitespace/line-wrapping adjustments in:
- packages/cli/cli-v2/src/migrator/__test__/FernConfigJsonMigrator.test.ts
- packages/cli/cli-v2/src/migrator/__test__/GeneratorsYmlMigrator.test.ts
- packages/cli/cli-v2/src/migrator/__test__/convertApiSpecs.test.ts
- packages/cli/cli-v2/src/migrator/converters/convertSdkTargets.ts
- Add makeLogger() helper to Migrator.test.ts with all required Logger
  fields (disable, enable, trace, log) instead of partial inline objects
- Use toMatchObject for repository access in convertGitOutput.test.ts
  to avoid accessing a property on a discriminated union without narrowing
- Use toHaveProperty for messageNaming in convertSettings.test.ts since
  the field is on AsyncApiSettingsSchema, not OpenApiSettingsSchema

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@@ -1,5 +1,17 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json

- version: 4.65.0
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the new unreleased versioning system

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — removed the 4.65.0 entry from versions.yml and created packages/cli/cli/changes/unreleased/polish-fern-config-migrate.yml instead, using the new unreleased versioning system. This should also eliminate the recurring merge conflicts on this file.

@iamnamananand996 iamnamananand996 merged commit 62b53d5 into main Apr 16, 2026
60 checks passed
@iamnamananand996 iamnamananand996 deleted the devin/FER-8911-1775156471 branch April 16, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants