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

Make it easier to run the dummy app locally #2483

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ If you want to contribute to Alchemy ([and we encourage you to do so](CONTRIBUTI
First of all you need to clone your fork to your local development machine. Then you need to install the dependencies with bundler.

```bash
$ bundle install
$ bin/setup
```

To prepare the tests of your Alchemy fork please make sure to run the preparation task:
Expand All @@ -316,7 +316,7 @@ to set up the database for testing.
### Run your tests with:

```bash
$ bundle exec rspec
$ bin/rspec
```

**Alternatively** you can just run*:
Expand All @@ -332,9 +332,7 @@ $ bundle exec rake
You can even start the dummy app and use it to manually test your changes with:

```bash
$ cd spec/dummy
$ bin/setup
$ bin/rails s
$ bin/start
```


Expand Down
37 changes: 37 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby
require "fileutils"

# path to dummy application root.
APP_ROOT = File.expand_path("../spec/dummy", __dir__)

# path to alchemy gem
GEM_ROOT = File.expand_path("../", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir GEM_ROOT do
puts "\n== Linking Admin JS package =="
system! "yarn link"
puts "== Installing dependencies =="
system! "yarn install"
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
end

FileUtils.chdir APP_ROOT do
puts "\n== Installing Alchemy into dummy app =="
system!("bin/rails javascript:install:esbuild")
system!("bin/rails g alchemy:install --skip --skip-demo-files --auto-accept")

puts "\n== Link Alchemy admin package =="
system! "yarn link @alchemy_cms/admin"
system! "yarn install"

puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
end

puts "\n== Alchemy is ready 🎉 =="
puts "Start server by typing:\n\n bin/start"
17 changes: 17 additions & 0 deletions bin/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby
require "fileutils"

# path to dummy application root.
APP_ROOT = File.expand_path("../spec/dummy", __dir__)

# path to alchemy gem
GEM_ROOT = File.expand_path("../", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
puts "\n== Starting dummy app =="
system! "bin/dev"
end
18 changes: 11 additions & 7 deletions spec/dummy/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@ require "fileutils"
# path to your application root.
APP_ROOT = File.expand_path("..", __dir__)

# path to alchemy gem
GEM_ROOT = File.expand_path("../../..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir GEM_ROOT do
puts "\n== Linking Admin JS package =="
system! "yarn link"
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
Expand All @@ -17,17 +25,13 @@ FileUtils.chdir APP_ROOT do
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end
puts "\n== Installing Node dependencies =="
system! "yarn link @alchemy_cms/admin"
system! "yarn install"

puts "\n== Preparing database =="
system! "bin/rails db:prepare"

puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! "bin/rails restart"
end