rails / rails-new

Create Rails projects with Ruby installed
MIT License
206 stars 23 forks source link

Homebrew formula #17

Open yahonda opened 5 months ago

yahonda commented 5 months ago

I want the rails-new can be installed via Homebrew for macOS users.

Expected behavior

macOS users can create a new Rails application as follows.

% brew install rails-new
% rails-new myapp
bweis commented 4 months ago

Took a crack at adding a formula and ran into a myriad of problems. :/

ruby

class RailsNew < Formula
  desc "Create Rails projects with Ruby installed"
  homepage "https://github.com/rails/rails-new"
  url "https://github.com/rails/rails-new/archive/refs/tags/v0.3.0.tar.gz"
  sha256 "a03c3f1530a28817d0989390be87ebc6a644f3eaa1a98dbb7420f7de3995c3f8"
  license "MIT"

  depends_on "rust" => :build
  depends_on :macos
  depends_on "docker" => :test
  depends_on "docker-credential-helper" => :test

  # Because of limitations with docker, use an alternative container runtime
  depends_on "colima" => :test

  def install
    system "cargo", "install", *std_cargo_args
  end

  test do
    assert_match version.to_s, shell_output(bin/"rails-new -V")
  end
end

If anyone want's to continue where I left off and hack away at it.

hachi8833 commented 2 months ago

I created the Fomulae for rails-new on my local /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/r/rails-new.rb via brew create --set-name "rails-new" "https://github.com/rails/rails-new/archive/refs/tags/v0.4.1.tar.gz", and then tweaked it as follows:

class RailsNew < Formula
  desc "Create Rails projects with Ruby installed"
  homepage "https://github.com/rails/rails-new"
  url "https://github.com/rails/rails-new/archive/refs/tags/v0.4.1.tar.gz"
  sha256 "d9c11267eb7c7a40a740768d09e5da60e07009d490d6561b734c35ac88095d51"
  license "MIT"

  depends_on "rust" => :build
  depends_on "docker" => :test
  depends_on "docker-credential-helper" => :test

  def install
    system "cargo", "install", *std_cargo_args
  end

  test do
    assert_match version.to_s, shell_output(bin/"rails-new -V")
  end
end

Running brew audit --new rails-new showed the following, which means the remaining step before sending the PR to Homebrew repo is just to bump the version from v0.4.0 to v1.0.0 or later when ready:

$ brew audit --new rails-new
rails-new
  * v0.4.1 is a GitHub pre-release.
Error: 1 problem in 1 formula detected.

Ref: https://zenn.dev/kou_pg_0131/articles/homebrew-add-formula

I look forward to the day to add the formula ❤️

thomasgallagher commented 2 months ago

+1 for this please.

Homebrew installation would vastly simplify the installation process, and also hopefully remove the trust based steps on MacOS (maybe I'm reaching here?).