Skip to content
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

CLI issues: Generated app default Project name invalid if CWD name has hyphens + why not generate in CWD #2092

Closed
cloudwheels opened this issue Nov 28, 2018 · 3 comments · Fixed by #3252
Assignees

Comments

@cloudwheels
Copy link

cloudwheels commented Nov 28, 2018

Current Behavior

lb4 app suggests a project name based on CWD. If this has hyphens they are replaced with spaces so the default suggested name is invalid.

More importantly, why bother suggesting this if it's going to create a sub-directory anyway.
Why not either:

  • create the project in CWD (that's why I created a folder for it!)
  • if it must be created in a subdir, just suggest "package" or "code", since I don't really want a structure my-project/my-project by default (From my home the default suggestion creates ~/username as the project directory.)

I can see the logic of not just spawning into my home directory, for example, without warning and I know other generators follow this pattern, but my preference would be just make directory, copy into that with WARN this is the current directory & make clear the Project name is really for the package.json.

See "Other examples" below.

ALSO
I am asked to enter the

Project root directory

but if I enter a path, the generator appears to complete, but doesn't actually create the directory:

? Project root directory: ~/my-lb4-app/code
create .npmrc
create .prettierignore
create .prettierrc
...
added 528 packages in 18.892s
Application nigel was created in ~/my-lb4-app/code
nigel@cloudshell:~$ cd ~/my-lb4-app/code
-bash: cd: /home/nigel/my-lb4-app/code: No such file or directory

Edit: actually it is there:

nigel@cloudshell:~ (cw-wadh)$ ls *~*
my-lb4-app

Ewww.

Other examples:

nigel@cloudshell:~$ mkdir loopback-next && cd $_ && lb4 app
? Project name: (loopback next) 
>> Invalid npm package name: loopback next
? Project name: loopback-next
Application loopback-next was created in loopback-next.
nigel@cloudshell:~/loopback-next$ ls
loopback-next
@cloudwheels cloudwheels changed the title CLI issues: Generated app default Project name invalid if CWD name has hyphens + why not generate in CWD + copy error not thrown CLI issues: Generated app default Project name invalid if CWD name has hyphens + why not generate in CWD Nov 28, 2018
@cloudwheels
Copy link
Author

cloudwheels commented Nov 28, 2018

removed

copy error not thrown

See above. It worked, just horribly.

@dhmlau
Copy link
Member

dhmlau commented Dec 2, 2018

@cloudwheels,

If this has hyphens they are replaced with spaces so the default suggested name is invalid.

I just scaffolded an application with project name test-1-2-3, and it seems to be working as expected. It is being created in the test-1-2-3 directory. Is it what you're seeing too?

$ lb4 app
? Project name: test-1-2-3
? Project description: loopback4 example
? Project root directory: test-1-2-3

? Project root directory: ~/my-lb4-app/code

For this one, it looks like a bug.

@dhmlau dhmlau self-assigned this Dec 2, 2018
@bajtos
Copy link
Member

bajtos commented Jan 11, 2019

More importantly, why bother suggesting this if it's going to create a sub-directory anyway.

I believe it's possible to create a new LB4 inside an existing directory too. It's an important option making it easy to scaffold a new LB4 project in a directory already initialized e.g. when creating a new GitHub repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants