From a39636398c6b5e643172ad347cb33dd505acb025 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 5 Jun 2023 19:25:03 +0200 Subject: [PATCH] Add commands to easily setup and start dummy app Use bin/setup to setup local dev env and bin/start to start the dummy app for local testing. --- README.md | 6 ++---- bin/setup | 36 ++++++++++++++++++++++++++++++++++++ bin/start | 17 +++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100755 bin/setup create mode 100755 bin/start diff --git a/README.md b/README.md index d9190fda40..03b88a10e9 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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/dev +$ bin/start ``` diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..32982c05a0 --- /dev/null +++ b/bin/setup @@ -0,0 +1,36 @@ +#!/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 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" +end + +puts "\n== Alchemy is ready 🎉 ==" +puts "Start server by typing:\n\n bin/start" diff --git a/bin/start b/bin/start new file mode 100755 index 0000000000..651eb15e08 --- /dev/null +++ b/bin/start @@ -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