Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/cli/src/create/__tests__/discovery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ describe('expandCreateShorthand', () => {
expect(expandCreateShorthand('/absolute/path')).toBe('/absolute/path');
});

it('should handle scope-only input gracefully', () => {
expect(expandCreateShorthand('@scope')).toBe('@scope');
it('should expand scope-only input to @scope/create', () => {
expect(expandCreateShorthand('@scope')).toBe('@scope/create');
expect(expandCreateShorthand('@scope@latest')).toBe('@scope/create@latest');
expect(expandCreateShorthand('@scope@1.2.3')).toBe('@scope/create@1.2.3');
});

it('should handle special cases where default convention does not apply', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/create/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ export function expandCreateShorthand(templateName: string): string {
if (templateName.startsWith('@')) {
const slashIndex = templateName.indexOf('/');
if (slashIndex === -1) {
return templateName;
// @scope or @scope@version → @scope/create[@version]
const atIndex = templateName.indexOf('@', 1);
const scope = atIndex === -1 ? templateName : templateName.slice(0, atIndex);
const version = atIndex === -1 ? '' : templateName.slice(atIndex);
return `${scope}/create${version}`;
}
const scope = templateName.slice(0, slashIndex);
const rest = templateName.slice(slashIndex + 1);
Expand Down
Loading