Module: Shakapacker
- Extended by:
- Shakapacker
- Included in:
- Shakapacker
- Defined in:
- lib/shakapacker.rb,
lib/shakapacker/runner.rb,
lib/shakapacker/version.rb,
lib/shakapacker/utils/misc.rb,
lib/shakapacker/base_strategy.rb,
lib/shakapacker/mtime_strategy.rb,
lib/shakapacker/webpack_runner.rb,
lib/shakapacker/digest_strategy.rb,
lib/shakapacker/version_checker.rb,
lib/shakapacker/compiler_strategy.rb,
lib/shakapacker/dev_server_runner.rb,
lib/shakapacker/deprecation_helper.rb,
lib/shakapacker/utils/version_syntax_converter.rb
Defined Under Namespace
Modules: Helper, Utils
Classes: BaseStrategy, Commands, Compiler, CompilerStrategy, Configuration, DevServer, DevServerProxy, DevServerRunner, DigestStrategy, Engine, Env, Instance, Manifest, MtimeStrategy, Runner, VersionChecker, WebpackRunner
Constant Summary
collapse
- DEFAULT_ENV =
"production".freeze
- VERSION =
Change the version in package.json too, please!
"7.3.0.beta.1".freeze
- DEPRECATION_GUIDE_URL =
"https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md"
- DEPRECATION_MESSAGE =
<<~MSG
DEPRECATION NOTICE:
Using webpacker spelling is deprecated in Shakapacker.
Update your project with the new spelling.
For more information about this process, check:
#{DEPRECATION_GUIDE_URL}
MSG
- SHELL =
Thor::Shell::Color.new
Instance Method Summary
collapse
Instance Method Details
#ensure_log_goes_to_stdout ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/shakapacker.rb', line 27
def ensure_log_goes_to_stdout
old_logger = Shakapacker.logger
Shakapacker.logger = Logger.new(STDOUT)
yield
ensure
Shakapacker.logger = old_logger
end
|
#get_config_file_path_with_backward_compatibility(config_path) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/shakapacker/deprecation_helper.rb', line 16
def get_config_file_path_with_backward_compatibility(config_path)
if config_path.to_s.end_with?("shakapacker.yml") && !File.exist?(config_path)
webpacker_config_path = if config_path.class == Pathname
Pathname.new(config_path.to_s.gsub("shakapacker.yml", "webpacker.yml"))
else
config_path.gsub("shakapacker.yml", "webpacker.yml")
end
if File.exist?(webpacker_config_path)
puts_deprecation_message(
short_deprecation_message(
"config/webpacker.yml",
"config/shakapacker.yml"
)
)
return webpacker_config_path
end
end
config_path
end
|
#instance=(instance) ⇒ Object
11
12
13
|
# File 'lib/shakapacker.rb', line 11
def instance=(instance)
@instance = instance
end
|
#puts_deprecation_message(message) ⇒ Object
75
76
77
|
# File 'lib/shakapacker/deprecation_helper.rb', line 75
def puts_deprecation_message(message)
SHELL.say "\n#{message}\n", :yellow
end
|
#puts_rake_deprecation_message(webpacker_task_name) ⇒ Object
#set_shakapacker_env_variables_for_backward_compatibility ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/shakapacker/deprecation_helper.rb', line 38
def set_shakapacker_env_variables_for_backward_compatibility
webpacker_env_variables = ENV.select { |key| key.start_with?("WEBPACKER_") }
deprecation_message_body = ""
webpacker_env_variables.each do |webpacker_key, _|
shakapacker_key = webpacker_key.gsub("WEBPACKER_", "SHAKAPACKER_")
next if ENV.key?(shakapacker_key)
deprecation_message_body += <<~MSG
Use `#{shakapacker_key}` instead of the deprecated `#{webpacker_key}`.
MSG
ENV[shakapacker_key] = ENV[webpacker_key]
end
if deprecation_message_body.present?
Shakapacker.puts_deprecation_message(
<<~MSG
DEPRECATION NOTICE:
#{deprecation_message_body}
Read more: #{Shakapacker::DEPRECATION_GUIDE_URL}
MSG
)
end
end
|
#short_deprecation_message(old_usage, new_usage) ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/shakapacker/deprecation_helper.rb', line 66
def short_deprecation_message(old_usage, new_usage)
<<~MSG
DEPRECATION NOTICE:
Consider using `#{new_usage}` instead of the deprecated `#{old_usage}`.
Read more: #{DEPRECATION_GUIDE_URL}
MSG
end
|
#with_node_env(env) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/shakapacker.rb', line 19
def with_node_env(env)
original = ENV["NODE_ENV"]
ENV["NODE_ENV"] = env
yield
ensure
ENV["NODE_ENV"] = original
end
|