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

Remove the crystal lib generator code. #800

Merged
merged 2 commits into from
Jun 10, 2023
Merged

Remove the crystal lib generator code. #800

merged 2 commits into from
Jun 10, 2023

Conversation

jwoertink
Copy link
Member

Fixes #741
Ref luckyframework/lucky#1812

This PR removes the initial step of running crystal init app .... We had been using this command to bootstrap the structure, but then remove almost every file after it was generated.

This now generates an empty directory, and only inserts what is needed which, in theory, should reduce file operations, as well as help in the effort to running on Windows.

/cc @mdwagner

@@ -89,171 +82,80 @@ class LuckyCli::Generators::Web
if default_directory?
project_dir
else
[full_project_directory.chomp('/'), project_dir].join('/')
File.join(full_project_directory.chomp('/'), project_dir)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how this looks on Windows, by we may need to see if there's some sort of Crystal::System::FileSeparator or whatever. I'm assuming on Windows we'd need to chomp('\')...

Copy link
Contributor

Choose a reason for hiding this comment

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

While you can use File methods for dealing with Paths, because they are just wrappers around Path, I'd recommend to just use Path directly instead. It makes it more clear what you're doing (e.g. path manipulation), and use File for actual filesystem operations (e.g. read/write a file).

You don't actually need #chomp here:

Suggested change
File.join(full_project_directory.chomp('/'), project_dir)
File.join(full_project_directory, project_dir)

But this is my suggestion (which is the same as File#join, just prefer using Path):

Suggested change
File.join(full_project_directory.chomp('/'), project_dir)
Path.new(full_project_directory).join(project_dir).to_s

However, my above suggestion would be better suited in a separate PR to change all other places using File instead of Path (I might add this to my lucky_template work).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I never thought about using Path until I started seeing your code. I think that makes more sense. Maybe I'll just merge this PR in as-is, then in another one we can go through it all and really start cleaning stuff up.

@jwoertink
Copy link
Member Author

Looks like the ameba failure is actually caused from crystal-ameba/ameba#372 so it'll be fixed on the next release.

Not sure why the sectester stuff is failing... Seems it can't connect? @bararchy do you have any ideas on https://github.com/luckyframework/lucky_cli/actions/runs/4973638473/jobs/8899605681 ?

@bararchy
Copy link
Contributor

@jwoertink seems strange... do we maybe need to install openssl or ca-certificate ubuntu package? 🤷
Does it pass locally for you? because for me it works fine...

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

Successfully merging this pull request may close these issues.

Consider dropping crystal init during setup
4 participants