12
12
require "time"
13
13
require "uri"
14
14
15
- # This file is a script that will configure a custom bundle for the Ruby LSP. The custom bundle allows developers to use
15
+ # This file is a script that will configure a composed bundle for the Ruby LSP. The composed bundle allows developers to use
16
16
# the Ruby LSP without including the gem in their application's Gemfile while at the same time giving us access to the
17
17
# exact locked versions of dependencies.
18
18
@@ -62,7 +62,7 @@ def initialize(project_path, **options)
62
62
@retry = T . let ( false , T ::Boolean )
63
63
end
64
64
65
- # Sets up the custom bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
65
+ # Sets up the composed bundle and returns the `BUNDLE_GEMFILE`, `BUNDLE_PATH` and `BUNDLE_APP_CONFIG` that should be
66
66
# used for running the server
67
67
sig { returns ( T ::Hash [ String , String ] ) }
68
68
def setup!
@@ -73,12 +73,12 @@ def setup!
73
73
ignore_file = @custom_dir + ".gitignore"
74
74
ignore_file . write ( "*" ) unless ignore_file . exist?
75
75
76
- # Do not set up a custom bundle if LSP dependencies are already in the Gemfile
76
+ # Do not set up a composed bundle if LSP dependencies are already in the Gemfile
77
77
if @dependencies [ "ruby-lsp" ] &&
78
78
@dependencies [ "debug" ] &&
79
79
( @rails_app ? @dependencies [ "ruby-lsp-rails" ] : true )
80
80
$stderr. puts (
81
- "Ruby LSP> Skipping custom bundle setup since LSP dependencies are already in #{ @gemfile } " ,
81
+ "Ruby LSP> Skipping composed bundle setup since LSP dependencies are already in #{ @gemfile } " ,
82
82
)
83
83
84
84
return run_bundle_install
@@ -96,7 +96,7 @@ def setup!
96
96
97
97
if @custom_lockfile . exist? && @lockfile_hash_path . exist? && @lockfile_hash_path . read == current_lockfile_hash
98
98
$stderr. puts (
99
- "Ruby LSP> Skipping custom bundle setup since #{ @custom_lockfile } already exists and is up to date" ,
99
+ "Ruby LSP> Skipping composed bundle setup since #{ @custom_lockfile } already exists and is up to date" ,
100
100
)
101
101
return run_bundle_install ( @custom_gemfile )
102
102
end
@@ -110,8 +110,8 @@ def setup!
110
110
private
111
111
112
112
sig { returns ( T ::Hash [ String , T . untyped ] ) }
113
- def custom_bundle_dependencies
114
- @custom_bundle_dependencies ||= T . let (
113
+ def composed_bundle_dependencies
114
+ @composed_bundle_dependencies ||= T . let (
115
115
begin
116
116
original_bundle_gemfile = ENV [ "BUNDLE_GEMFILE" ]
117
117
@@ -136,8 +136,8 @@ def write_custom_gemfile
136
136
"" ,
137
137
]
138
138
139
- # If there's a top level Gemfile, we want to evaluate from the custom bundle. We get the source from the top level
140
- # Gemfile, so if there isn't one we need to add a default source
139
+ # If there's a top level Gemfile, we want to evaluate from the composed bundle. We get the source from the top
140
+ # level Gemfile, so if there isn't one we need to add a default source
141
141
if @gemfile &.exist? && @lockfile &.exist?
142
142
parts << "eval_gemfile(File.expand_path(\" ../#{ @gemfile_name } \" , __dir__))"
143
143
else
@@ -187,7 +187,7 @@ def run_bundle_install(bundle_gemfile = @gemfile)
187
187
env = bundler_settings_as_env
188
188
env [ "BUNDLE_GEMFILE" ] = bundle_gemfile . to_s
189
189
190
- # If the user has a custom bundle path configured, we need to ensure that we will use the absolute and not
190
+ # If the user has a composed bundle path configured, we need to ensure that we will use the absolute and not
191
191
# relative version of it when running `bundle install`. This is necessary to avoid installing the gems under the
192
192
# `.ruby-lsp` folder, which is not the user's intention. For example, if the path is configured as `vendor`, we
193
193
# want to install it in the top level `vendor` and not `.ruby-lsp/vendor`
@@ -244,7 +244,7 @@ def run_bundle_install_through_command(env)
244
244
base_bundle = base_bundle_command ( env )
245
245
246
246
# If `ruby-lsp` and `debug` (and potentially `ruby-lsp-rails`) are already in the Gemfile, then we shouldn't try
247
- # to upgrade them or else we'll produce undesired source control changes. If the custom bundle was just created
247
+ # to upgrade them or else we'll produce undesired source control changes. If the composed bundle was just created
248
248
# and any of `ruby-lsp`, `ruby-lsp-rails` or `debug` weren't a part of the Gemfile, then we need to run `bundle
249
249
# install` for the first time to generate the Gemfile.lock with them included or else Bundler will complain that
250
250
# they're missing. We can only update if the custom `.ruby-lsp/Gemfile.lock` already exists and includes all gems
@@ -274,16 +274,16 @@ def run_bundle_install_through_command(env)
274
274
command << "1>&2"
275
275
276
276
# Add bundle update
277
- $stderr. puts ( "Ruby LSP> Running bundle install for the custom bundle. This may take a while..." )
277
+ $stderr. puts ( "Ruby LSP> Running bundle install for the composed bundle. This may take a while..." )
278
278
$stderr. puts ( "Ruby LSP> Command: #{ command } " )
279
279
280
- # Try to run the bundle install or update command. If that fails, it normally means that the custom lockfile is in
281
- # a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
280
+ # Try to run the bundle install or update command. If that fails, it normally means that the composed lockfile is
281
+ # in a bad state that no longer reflects the top level one. In that case, we can remove the whole directory, try
282
282
# another time and give up if it fails again
283
283
if !system ( env , command ) && !@retry && @custom_gemfile . exist?
284
284
@retry = true
285
285
@custom_dir . rmtree
286
- $stderr. puts ( "Ruby LSP> Running bundle install failed. Trying to re-generate the custom bundle from scratch" )
286
+ $stderr. puts ( "Ruby LSP> Running bundle install failed. Trying to re-generate the composed bundle from scratch" )
287
287
return setup!
288
288
end
289
289
@@ -330,14 +330,14 @@ def should_bundle_update?
330
330
if @rails_app
331
331
return false if @dependencies . values_at ( "ruby-lsp" , "ruby-lsp-rails" , "debug" ) . all?
332
332
333
- # If the custom lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle install
334
- # before updating
335
- return false if custom_bundle_dependencies . values_at ( "ruby-lsp" , "debug" , "ruby-lsp-rails" ) . any? ( &:nil? )
333
+ # If the composed lockfile doesn't include `ruby-lsp`, `ruby-lsp-rails` or `debug`, we need to run bundle
334
+ # install before updating
335
+ return false if composed_bundle_dependencies . values_at ( "ruby-lsp" , "debug" , "ruby-lsp-rails" ) . any? ( &:nil? )
336
336
else
337
337
return false if @dependencies . values_at ( "ruby-lsp" , "debug" ) . all?
338
338
339
- # If the custom lockfile doesn't include `ruby-lsp` or `debug`, we need to run bundle install before updating
340
- return false if custom_bundle_dependencies . values_at ( "ruby-lsp" , "debug" ) . any? ( &:nil? )
339
+ # If the composed lockfile doesn't include `ruby-lsp` or `debug`, we need to run bundle install before updating
340
+ return false if composed_bundle_dependencies . values_at ( "ruby-lsp" , "debug" ) . any? ( &:nil? )
341
341
end
342
342
343
343
# If the last updated file doesn't exist or was updated more than 4 hours ago, we should update
0 commit comments