forked from fedi/mastodon
Fix mastodon:setup choking on env variables containing '%' (#13940)
Fix a regression introduced in #13928, caused by TTY::Command building shell commands by chaining string substitutions. Ditch TTY::Command and use system instead (both do shell out).
This commit is contained in:
parent
bf94934623
commit
175fd5b8ba
1
Gemfile
1
Gemfile
|
@ -94,7 +94,6 @@ gem 'simple_form', '~> 5.0'
|
||||||
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
gem 'sprockets-rails', '~> 3.2', require: 'sprockets/railtie'
|
||||||
gem 'stoplight', '~> 2.2.0'
|
gem 'stoplight', '~> 2.2.0'
|
||||||
gem 'strong_migrations', '~> 0.6'
|
gem 'strong_migrations', '~> 0.6'
|
||||||
gem 'tty-command', '~> 0.9', require: false
|
|
||||||
gem 'tty-prompt', '~> 0.21', require: false
|
gem 'tty-prompt', '~> 0.21', require: false
|
||||||
gem 'twitter-text', '~> 1.14'
|
gem 'twitter-text', '~> 1.14'
|
||||||
gem 'tzinfo-data', '~> 1.2020'
|
gem 'tzinfo-data', '~> 1.2020'
|
||||||
|
|
|
@ -623,8 +623,6 @@ GEM
|
||||||
thwait (0.1.0)
|
thwait (0.1.0)
|
||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
tty-color (0.5.1)
|
tty-color (0.5.1)
|
||||||
tty-command (0.9.0)
|
|
||||||
pastel (~> 0.7.0)
|
|
||||||
tty-cursor (0.7.1)
|
tty-cursor (0.7.1)
|
||||||
tty-prompt (0.21.0)
|
tty-prompt (0.21.0)
|
||||||
necromancer (~> 0.5.0)
|
necromancer (~> 0.5.0)
|
||||||
|
@ -792,7 +790,6 @@ DEPENDENCIES
|
||||||
strong_migrations (~> 0.6)
|
strong_migrations (~> 0.6)
|
||||||
thor (~> 0.20)
|
thor (~> 0.20)
|
||||||
thwait (~> 0.1.0)
|
thwait (~> 0.1.0)
|
||||||
tty-command (~> 0.9)
|
|
||||||
tty-prompt (~> 0.21)
|
tty-prompt (~> 0.21)
|
||||||
twitter-text (~> 1.14)
|
twitter-text (~> 1.14)
|
||||||
tzinfo-data (~> 1.2020)
|
tzinfo-data (~> 1.2020)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'tty-command'
|
|
||||||
require 'tty-prompt'
|
require 'tty-prompt'
|
||||||
|
|
||||||
namespace :mastodon do
|
namespace :mastodon do
|
||||||
|
@ -334,8 +333,6 @@ namespace :mastodon do
|
||||||
prompt.say 'This configuration will be written to .env.production'
|
prompt.say 'This configuration will be written to .env.production'
|
||||||
|
|
||||||
if prompt.yes?('Save configuration?')
|
if prompt.yes?('Save configuration?')
|
||||||
cmd = TTY::Command.new(printer: :quiet)
|
|
||||||
|
|
||||||
env_contents = env.each_pair.map do |key, value|
|
env_contents = env.each_pair.map do |key, value|
|
||||||
if value.is_a?(String) && value =~ /[\s\#\\"]/
|
if value.is_a?(String) && value =~ /[\s\#\\"]/
|
||||||
if value =~ /[']/
|
if value =~ /[']/
|
||||||
|
@ -367,7 +364,7 @@ namespace :mastodon do
|
||||||
prompt.say 'Running `RAILS_ENV=production rails db:setup` ...'
|
prompt.say 'Running `RAILS_ENV=production rails db:setup` ...'
|
||||||
prompt.say "\n\n"
|
prompt.say "\n\n"
|
||||||
|
|
||||||
if cmd.run!(env.merge({ RAILS_ENV: 'production', SAFETY_ASSURED: 1 }), :rails, 'db:setup').failure?
|
if !system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production', 'SAFETY_ASSURED' => '1' }), 'rails db:setup')
|
||||||
prompt.error 'That failed! Perhaps your configuration is not right'
|
prompt.error 'That failed! Perhaps your configuration is not right'
|
||||||
else
|
else
|
||||||
prompt.ok 'Done!'
|
prompt.ok 'Done!'
|
||||||
|
@ -382,7 +379,7 @@ namespace :mastodon do
|
||||||
prompt.say 'Running `RAILS_ENV=production rails assets:precompile` ...'
|
prompt.say 'Running `RAILS_ENV=production rails assets:precompile` ...'
|
||||||
prompt.say "\n\n"
|
prompt.say "\n\n"
|
||||||
|
|
||||||
if cmd.run!(env.merge({ RAILS_ENV: 'production' }), :rails, 'assets:precompile').failure?
|
if !system(env.transform_values(&:to_s).merge({ 'RAILS_ENV' => 'production' }), 'rails assets:precompile')
|
||||||
prompt.error 'That failed! Maybe you need swap space?'
|
prompt.error 'That failed! Maybe you need swap space?'
|
||||||
else
|
else
|
||||||
prompt.say 'Done!'
|
prompt.say 'Done!'
|
||||||
|
|
Loading…
Reference in a new issue