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

Consider dropping crystal init during setup #741

Closed
jwoertink opened this issue Mar 19, 2022 · 1 comment · Fixed by #800
Closed

Consider dropping crystal init during setup #741

jwoertink opened this issue Mar 19, 2022 · 1 comment · Fixed by #800

Comments

@jwoertink
Copy link
Member

Right now when you run lucky init, we run crystal init app NAME under the hood. It's nice because it gives us a default structure, and a ton of things like setting up the src, and spec folders and such.

The issue is right after we do that, we basically remove almost all of it.

private def remove_generated_src_files
remove_default_generated_if_exists("src")
end
private def remove_generated_spec_files
remove_default_generated_if_exists("spec")
end
private def remove_default_readme
remove_default_generated_if_exists("README.md")
end
private def remove_default_license
remove_license_from_shard
remove_default_generated_if_exists("LICENSE")
end
private def remove_default_generated_if_exists(file_or_directory : String)
to_delete = "#{project_dir}/#{file_or_directory}"
if File.exists?(to_delete)
FileUtils.rm_rf(to_delete)
end
end
private def remove_license_from_shard
shard_path = "#{project_dir}/shard.yml"
lines = [] of String
File.each_line shard_path do |line|
lines << line unless line.includes?("license")
end
File.write shard_path, lines.join("\n")
end

We used to even have this 45f3529 because Crystal would default generate a travis CI, but then we started using Github, and then later versions of Crystal stopped generating that.

We're also at the mercy of whatever naming conventions, or bugs may appear in the crystal init.( ref )

Related: #735

In regards to that issue, if we just generated our own structure out of the box, we'd keep control and flexibility to what goes in to an app.

The main downside would be that this also opens us to bugs with all the different permutations of app type (i.e. browser, api, auth, etc...), it's possible we miss something, or similar to the Crystal naming bug, we end up creating our own bugs with naming....

@grepsedawk
Copy link
Contributor

One of the patterns I've come across that I like here is that I treat crystal init as an overlay to the existing repo codebase

https://github.com/grepsedawk/sharded.cr/blob/main/.github/workflows/init#L18-L19

I take all the "my files" and copy crystal init's files over those, with the no clobber flag. This allows me to (more) plainly build a directory with files to override default shard files.

@jwoertink jwoertink added the hacktoberfest Valid Issue for Hacktoberfest label Sep 30, 2022
@jwoertink jwoertink removed the hacktoberfest Valid Issue for Hacktoberfest label Nov 6, 2022
jwoertink added a commit that referenced this issue May 14, 2023
jwoertink added a commit that referenced this issue Jun 10, 2023
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 a pull request may close this issue.

2 participants