-
Notifications
You must be signed in to change notification settings - Fork 28
feat(create): show generated app name in hint line instead of input default #340
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
Open
srtaalej
wants to merge
5
commits into
main
Choose a base branch
from
ale-feat-app-naming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c99f80
fix: show generated app name in hint line instead of input default
srtaalej af97eca
Update cmd/project/create.go
srtaalej 5ed7e88
fix: update imports in cmd/
srtaalej 7b610e5
Merge branch 'main' into ale-feat-app-naming
srtaalej a120396
fix: edge case
srtaalej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,13 +18,11 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "io" | ||
| "math/rand" | ||
| "net/http" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
| "time" | ||
|
|
||
| "github.com/go-git/go-git/v5" | ||
| "github.com/go-git/go-git/v5/plumbing" | ||
|
|
@@ -150,23 +148,15 @@ func Create(ctx context.Context, clients *shared.ClientFactory, log *logger.Logg | |
| return appDirPath, nil | ||
| } | ||
|
|
||
| // generateRandomAppName will create a random app name based on two words and a number | ||
| func generateRandomAppName() string { | ||
| rand.New(rand.NewSource(time.Now().UnixNano())) | ||
| var firstRandomNum = rand.Intn(len(adjectives)) | ||
| var secondRandomNum = rand.Intn(len(animals)) | ||
| var randomName = fmt.Sprintf("%s-%s-%d", adjectives[firstRandomNum], animals[secondRandomNum], rand.Intn(1000)) | ||
| return randomName | ||
| } | ||
|
|
||
| // getAppDirName will validate and return the app's directory name | ||
| func getAppDirName(appName string) (string, error) { | ||
| if len(appName) <= 0 { | ||
| return generateRandomAppName(), nil | ||
| return "", fmt.Errorf("app name is required") | ||
| } | ||
|
|
||
| // trim whitespace | ||
| appName = strings.ReplaceAll(appName, " ", "") | ||
| appName = strings.TrimSpace(appName) | ||
| appName = strings.ReplaceAll(appName, " ", "-") | ||
|
Comment on lines
168
to
+159
Member
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. 📣 note: Let's call this out in the changelog as a fix as well! I'll make a few changes to this since we'll also want to keep it focused on just developer-facing features- |
||
|
|
||
| // name cannot be a reserved word | ||
| if goutils.Contains(reserved, appName, false) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧪 suggestion: We might want to include a test case alongside af97eca changes - do we have a unit test that's checking for
--templatearguments whileIsTTYis also set to false?