Skip to content

fix(create-rslib): improve template argument parsing and defaults#1467

Merged
Timeless0911 merged 2 commits intomainfrom
fix/create-rslib-template-arg-parsing
Jan 30, 2026
Merged

fix(create-rslib): improve template argument parsing and defaults#1467
Timeless0911 merged 2 commits intomainfrom
fix/create-rslib-template-arg-parsing

Conversation

@Timeless0911
Copy link
Copy Markdown
Contributor

Summary

This PR improves the parsing of the --template argument in create-rslib.

  • Extracted parseTemplateName logic to handle template names more robustly.
  • When a language suffix (-ts or -js) is omitted, it now correctly defaults to -ts (appending it to the template name) instead of treating the last part of the template name as the language.
  • Added unit tests for parseTemplateName.
  • Removed order: 'pre' from rspress template config.

Related Links

N/A

Checklist

  • Tests updated.
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 30, 2026 12:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the parsing of the --template argument in create-rslib by extracting the template name parsing logic into a dedicated function and correcting the default language behavior. Previously, when a language suffix was omitted, the code would incorrectly treat the last segment of the template name as the language. Now it correctly defaults to TypeScript by appending -ts to the template name.

Changes:

  • Extracted template parsing logic into a new exported parseTemplateName function
  • Fixed default language behavior to append -ts when no language suffix is provided
  • Added comprehensive unit tests for the new parsing function
  • Removed unused order: 'pre' property from rspress template configuration

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/create-rslib/src/index.ts Extracted parseTemplateName function with improved logic for handling template names with and without language suffixes; removed order: 'pre' from rspress config
packages/create-rslib/test/index.test.ts Added unit tests for parseTemplateName covering single-segment and multi-segment templates with and without language suffixes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Timeless0911 Timeless0911 merged commit d7f51d6 into main Jan 30, 2026
11 checks passed
@Timeless0911 Timeless0911 deleted the fix/create-rslib-template-arg-parsing branch January 30, 2026 13:02
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