Skip to content

chore: change file structure for split and join commands#2721

Open
DmitryAnansky wants to merge 3 commits intomainfrom
chore/refactor-split-command-structure
Open

chore: change file structure for split and join commands#2721
DmitryAnansky wants to merge 3 commits intomainfrom
chore/refactor-split-command-structure

Conversation

@DmitryAnansky
Copy link
Copy Markdown
Contributor

@DmitryAnansky DmitryAnansky commented Apr 6, 2026

What/Why/How?

  • Updates to the file structure of the split and join commands.
  • No changes to the underlying logic.

Reference

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Mostly a structural refactor, but it touches core split, join, and stats command code paths and rewires many imports, so regressions are possible if any module boundaries or constants moved incorrectly.

Overview
Refactors the CLI command internals without intended behavior changes. The split command is broken into spec-specific modules (oas/ and asyncapi/) plus shared utils/, with shared constants moved to split/constants.ts and OpenAPI method/component constants moved to split/oas/constants.ts.

join is updated to consume the new split constants/utilities (e.g., COMPONENTS, crawl, startsWithComponents) and its helper imports are renamed/relocated under join/utils. The stats command’s output formatting is extracted into a new stats/print-stats/ module.

Documentation for split is updated to reflect support for OpenAPI 3.x and AsyncAPI 2.x/3.x and to describe what gets split for each spec.

Reviewed by Cursor Bugbot for commit 58005c7. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 6, 2026

⚠️ No Changeset found

Latest commit: 58005c7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@DmitryAnansky DmitryAnansky force-pushed the chore/refactor-split-command-structure branch from 602d6af to 074e9fb Compare April 6, 2026 14:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.92% (🎯 79%) 6686 / 8365
🔵 Statements 79.35% (🎯 79%) 6917 / 8717
🔵 Functions 83.12% (🎯 82%) 1355 / 1630
🔵 Branches 71.6% (🎯 71%) 4547 / 6350
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/cli/src/types.ts 100% 100% 100% 100%
packages/cli/src/commands/join/index.ts 90.27% 83.67% 85.71% 90.14% 109, 117-126, 148, 190, 204, 222
packages/cli/src/commands/split/constants.ts 100% 100% 100% 100%
packages/cli/src/commands/split/index.ts 77.77% 66.66% 100% 82.35% 28, 51-56
packages/cli/src/commands/split/asyncapi/constants.ts 100% 100% 100% 100%
packages/cli/src/commands/split/asyncapi/find-asyncapi-component-types.ts 100% 100% 100% 100%
packages/cli/src/commands/split/asyncapi/gather-asyncapi-component-files.ts 86.66% 80% 50% 92.85% 23, 36
packages/cli/src/commands/split/asyncapi/iterate-asyncapi-channels.ts 86.66% 50% 100% 100% 29, 36
packages/cli/src/commands/split/asyncapi/iterate-asyncapi-components.ts 94.73% 50% 100% 94.73% 57-61
packages/cli/src/commands/split/asyncapi/iterate-asyncapi-operations.ts 84.61% 50% 100% 100% 31, 41
packages/cli/src/commands/split/asyncapi/remove-asyncapi-empty-components.ts 85.71% 66.66% 100% 100% 14
packages/cli/src/commands/split/asyncapi/split-asyncapi-definition.ts 100% 83.33% 100% 100%
packages/cli/src/commands/split/oas/constants.ts 100% 100% 100% 100%
packages/cli/src/commands/split/oas/split-oas-definition.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/crawl.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/create-component-dir.ts 100% 50% 100% 100%
packages/cli/src/commands/split/utils/does-file-differ.ts 100% 50% 100% 100%
packages/cli/src/commands/split/utils/extract-filename-from-path.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/find-component-type.ts 75% 75% 100% 100% 7
packages/cli/src/commands/split/utils/gather-components-files.ts 83.33% 83.33% 50% 83.33% 24
packages/cli/src/commands/split/utils/get-file-name-path.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/implicitly-reference-discriminator.ts 10.52% 5% 100% 5.88% 15-39
packages/cli/src/commands/split/utils/is-not-security-component-type.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/is-supported-extension.ts 0% 0% 0% 0% 2
packages/cli/src/commands/split/utils/iterate-components.ts 96.15% 50% 100% 96.15% 64-68
packages/cli/src/commands/split/utils/iterate-path-items.ts 86.95% 80% 100% 100% 29, 36, 45
packages/cli/src/commands/split/utils/remove-empty-components.ts 100% 66.66% 100% 100%
packages/cli/src/commands/split/utils/replace-$-refs.ts 63.15% 52.63% 100% 66.66% 17-21, 32, 35
packages/cli/src/commands/split/utils/replace-channel-refs.ts 83.33% 73.68% 100% 82.35% 14-17
packages/cli/src/commands/split/utils/starts-with-components.ts 100% 100% 100% 100%
packages/cli/src/commands/split/utils/traverse-directory-deep.ts 23.07% 37.5% 50% 27.27% 9, 12-29
packages/cli/src/commands/stats/index.ts 0% 0% 0% 0% 27-69
packages/cli/src/commands/stats/print-stats/index.ts 0% 0% 0% 0% 19-33
packages/cli/src/commands/stats/print-stats/json.ts 0% 100% 0% 0% 8-17
packages/cli/src/commands/stats/print-stats/markdown.ts 0% 100% 0% 0% 10-16
packages/cli/src/commands/stats/print-stats/stylish.ts 0% 100% 0% 0% 11-15
Generated in workflow #9318 for commit 58005c7 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.284s ± 0.026s ▓ 1.01x
cli-next 3.254s ± 0.026s ▓ 1.00x (Fastest)

@DmitryAnansky DmitryAnansky force-pushed the chore/refactor-split-command-structure branch from e2d4cea to 6af3817 Compare April 6, 2026 17:08
@DmitryAnansky DmitryAnansky marked this pull request as ready for review April 6, 2026 17:25
@DmitryAnansky DmitryAnansky requested review from a team as code owners April 6, 2026 17:25
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Unused re-export of iteratePathItems from index
    • Removed the unused iteratePathItems import and re-export from split/index.ts since all consumers import it directly from the utils module.

Create PR

Or push these changes by commenting:

@cursor push 3af4bd3de9
Preview (3af4bd3de9)
diff --git a/packages/cli/src/commands/split/index.ts b/packages/cli/src/commands/split/index.ts
--- a/packages/cli/src/commands/split/index.ts
+++ b/packages/cli/src/commands/split/index.ts
@@ -18,7 +18,6 @@
   type AnyDefinition,
   type SplitArgv,
 } from './types.js';
-import { iteratePathItems } from './utils/iterate-path-items.js';
 
 export async function handleSplit({ argv, collectSpecData }: CommandArgs<SplitArgv>) {
   const startedAt = performance.now();
@@ -63,4 +62,3 @@
   printExecutionTime('split', startedAt, api);
 }
 
-export { iteratePathItems };

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 58005c7. Configure here.

api: string;
outDir: string;
separator: string;
} & VerifyConfigOptions;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unused re-export of iteratePathItems from index

Low Severity

iteratePathItems is imported and re-exported from index.ts, but no consumer imports it from this path anymore. The only usage in the test file now imports directly from ../utils/iterate-path-items.js, and the only other consumer (split-oas-definition.ts) also imports directly from the utils path. This is dead re-export code left over from the restructuring.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 58005c7. Configure here.

@DmitryAnansky DmitryAnansky self-assigned this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants