-
Notifications
You must be signed in to change notification settings - Fork 2
Fix create-app package names for path targets #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-api-routes", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-basic", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-complex-routing", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-custom-ws-transport", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-mpa", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-plugin-authoring", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-with-sqlite", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-with-tailwind", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "name": "example-with-trpc", | ||
| "type": "module", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| import path from "node:path"; | ||||||
|
|
||||||
| const scopedPackagePattern = /^@[^/\\]+[/\\][^/\\]+$/; | ||||||
|
|
||||||
| export function derivePackageName(inputName: string, targetDir: string): string { | ||||||
| const trimmedName = inputName.trim(); | ||||||
|
|
||||||
| if (scopedPackagePattern.test(trimmedName)) { | ||||||
| return trimmedName.replace("\\", "/"); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NPM package names must be lowercase. Lowercasing the scoped name here ensures that the generated
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| return path.basename(path.resolve(targetDir)); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to scoped names, the basename of the target directory should be lowercased to ensure a valid NPM package name. This prevents issues where a directory named with uppercase letters would otherwise produce an invalid
Suggested change
|
||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trimming the
projectNameensures that leading or trailing whitespace from user input doesn't result in unexpected directory names or invalid package metadata. This improves the robustness of the scaffolding process.