solidusio / solidus_paypal_commerce_platform

💳 Integrate Solidus with Paypal Commerce Platform
https://developer.paypal.com/docs/platforms/
BSD 3-Clause "New" or "Revised" License
17 stars 24 forks source link

Fix dummy and sandbox generation #189

Closed kennyadsl closed 1 year ago

kennyadsl commented 1 year ago

Summary

This change fixes two issues:

  1. Now that we need importmap/stimulus/turbo running in the storefront application, we also need to generate the dummy and sandbox apps with that stack installed. The --skip-bundle option prevents those options from being installed, so we need to run them manually. ~I tried to remove the --skip-bundle instead, but there are a lot of errors, apparently related to having the app containing some files that won't work before solidus is installed.~ See PR's comments below. 👇
  2. --skip-spring has been replaced by --skip-bootsnap in Rails

Additional notes

We could try to remove --skip-bundle instead, but I'm still not sure it's possible. @elia do you remember why it was needed?

For reference, this is the stacktrace removing it ``` Creating the dummy-app app... create create README.md create Rakefile create .ruby-version create config.ru create Gemfile create app create app/assets/config/manifest.js create app/assets/stylesheets/application.css create app/channels/application_cable/channel.rb create app/channels/application_cable/connection.rb create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/jobs/application_job.rb create app/mailers/application_mailer.rb create app/models/application_record.rb create app/views/layouts/application.html.erb create app/views/layouts/mailer.html.erb create app/views/layouts/mailer.text.erb create app/assets/images create bin create bin/rails create bin/rake create bin/setup create config create config/routes.rb create config/application.rb create config/environment.rb create config/cable.yml create config/puma.rb create config/storage.yml create config/environments create config/environments/development.rb create config/environments/production.rb create config/environments/test.rb create config/initializers create config/initializers/assets.rb create config/initializers/content_security_policy.rb create config/initializers/cors.rb create config/initializers/filter_parameter_logging.rb create config/initializers/inflections.rb create config/initializers/new_framework_defaults_7_0.rb create config/initializers/permissions_policy.rb create config/locales create config/locales/en.yml create config/master.key create config/boot.rb create config/database.yml create db create db/seeds.rb create lib create lib/tasks create lib/assets create log create public create public/404.html create public/422.html create public/500.html create public/apple-touch-icon-precomposed.png create public/apple-touch-icon.png create public/favicon.ico create public/robots.txt create tmp create tmp/pids create tmp/cache create tmp/cache/assets create vendor create storage create tmp/storage remove config/initializers/cors.rb remove config/initializers/new_framework_defaults_7_0.rb run bundle install Fetching gem metadata from https://rubygems.org/........... Resolving dependencies... Using rake 13.0.6 Using rack 2.2.6.2 Using nio4r 2.5.8 Using minitest 5.17.0 Using timeout 0.3.1 Using bundler 2.3.23 Using racc 1.6.2 Using crass 1.0.6 Using websocket-extensions 0.1.5 Using marcel 1.0.2 Using mini_mime 1.1.2 Using concurrent-ruby 1.2.0 Using date 3.3.3 Using builder 3.2.4 Using net-protocol 0.2.1 Using erubi 1.12.0 Using io-console 0.6.0 Using i18n 1.12.0 Using method_source 1.0.0 Using sprockets 4.2.0 Using zeitwerk 2.6.6 Using rack-test 2.0.2 Using puma 5.6.5 Using reline 0.3.2 Using nokogiri 1.14.1 (arm64-darwin) Using websocket-driver 0.7.5 Using tzinfo 2.0.6 Using thor 1.2.1 Using bindex 0.8.1 Using net-imap 0.3.4 Using net-pop 0.1.2 Using net-smtp 0.3.3 Using sqlite3 1.6.0 (arm64-darwin) Using loofah 2.19.1 Using mail 2.8.1 Using irb 1.6.2 Using activesupport 7.0.4.2 Using rails-html-sanitizer 1.5.0 Using rails-dom-testing 2.0.3 Using globalid 1.1.0 Using activemodel 7.0.4.2 Using debug 1.7.1 Using activerecord 7.0.4.2 Using actionview 7.0.4.2 Using activejob 7.0.4.2 Using actionpack 7.0.4.2 Using jbuilder 2.11.5 Using actioncable 7.0.4.2 Using activestorage 7.0.4.2 Using actionmailer 7.0.4.2 Using railties 7.0.4.2 Using actionmailbox 7.0.4.2 Using actiontext 7.0.4.2 Using importmap-rails 1.1.5 Using stimulus-rails 1.2.1 Using turbo-rails 1.3.3 Using rails 7.0.4.2 Using web-console 4.2.0 Using sprockets-rails 3.4.2 Bundle complete! 11 Gemfile dependencies, 59 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. run bundle binstubs bundler rails importmap:install rails aborted! LoadError: cannot load such file -- active_storage/engine /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/config/application.rb:8:in `require' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/config/application.rb:8:in `' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/Rakefile:4:in `require_relative' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/Rakefile:4:in `' bin/rails:4:in `require' bin/rails:4:in `
' (See full trace by running task with --trace) rails turbo:install stimulus:install rails aborted! LoadError: cannot load such file -- active_storage/engine /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/config/application.rb:8:in `require' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/config/application.rb:8:in `' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/Rakefile:4:in `require_relative' /Users/kennyadsl/Code/solidusio-contrib/solidus_paypal_commerce_platform/dummy-app/Rakefile:4:in `' bin/rails:4:in `require' bin/rails:4:in `
' (See full trace by running task with --trace) Fetching https://github.com/solidusio/solidus.git Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... # ... the rest is identical to a succeeding installation ```

Please note that despite these errors, the installation reaches the finish line but it's corrupted because the hotwire stack is not installed.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

elia commented 1 year ago

We could try to remove --skip-bundle instead, but I'm still not sure it's possible. @elia do you remember why it was needed?

I think skip bundle was added to optimize the number of times we run bundle install, but in order for the js stuff to work we need to put it back I think.

kennyadsl commented 1 year ago

@elia I updated the description with the stacktrace when I add it back.

elia commented 1 year ago

This is the script we're using on solidus_stripe, notice how it skips the unbundled for rails new:

#!/usr/bin/env bash

set -e

extension_name="solidus_stripe"

# Stay away from the bundler env of the containing extension.
function unbundled {
  ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- "$@"
}

# "sqlite" is set by the ORB extension instead of "sqlite3",
# all other options are already in the format expected by `rails new`.
test "$DB" = "sqlite" && export DB="sqlite3"

rm -rf ./dummy-app
rails_version=`bundle exec ruby -e'require "rails"; puts Rails.version'`
rails _${rails_version}_ new dummy-app \
  --database=${DB:-sqlite3} \
  --skip-git \
  --skip-rc

if [ ! -d "dummy-app" ]; then
  echo 'dummy-app rails application failed'
  exit 1
fi

cd ./dummy-app
unbundled bundle add solidus --github solidusio/solidus --branch "${BRANCH:-master}" --version '> 0.a'
unbundled bundle exec rake db:drop db:create
unbundled bundle exec rails generate solidus:install --auto-accept --payment-method=none --no-seed --no-sample "$@"
unbundled bundle add $extension_name --path ..
unbundled bundle exec rails generate $extension_name:install --migrate --specs=all