spring 3.1.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -3
- data/lib/spring/application.rb +14 -10
- data/lib/spring/client/binstub.rb +22 -29
- data/lib/spring/client/rails.rb +2 -4
- data/lib/spring/commands.rb +10 -3
- data/lib/spring/configuration.rb +6 -1
- data/lib/spring/env.rb +1 -1
- data/lib/spring/version.rb +1 -1
- data/lib/spring/watcher/abstract.rb +4 -5
- data/lib/spring/watcher/polling.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25f487be691e4b74fec8082de6dae9c31b2b5452adea9546e615fe972bb92302
|
4
|
+
data.tar.gz: 7b7997de4635a441fdba39157260f18f6be1f7c4c41b3fe1b43b21a0fada61d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a1a3b647476c8582da82cfbaa35524e427303149a1bc2e375f115ba25ef32166fd5800e968f3873afef84e6a38b686447b68c1145e9bfffe6aecff03379cb8
|
7
|
+
data.tar.gz: 985b243181c0a7c6a4c37052fe504f1f3e51303f7c014924ff2dc8c10693e17b45bba8cf0b39f49a2c378da761b715b501d4f535102f3b82bf5006618461235f
|
data/README.md
CHANGED
@@ -16,9 +16,9 @@ boot it every time you run a test, rake task or migration.
|
|
16
16
|
|
17
17
|
## Compatibility
|
18
18
|
|
19
|
-
* Ruby versions: MRI 2.
|
20
|
-
* Rails versions:
|
21
|
-
|
19
|
+
* Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1
|
20
|
+
* Rails versions: 6.0, 6.1, 7.0
|
21
|
+
* Bundler v2.1+
|
22
22
|
|
23
23
|
Spring makes extensive use of `Process.fork`, so won't be able to
|
24
24
|
provide a speed up on platforms which don't support forking (Windows, JRuby).
|
@@ -389,6 +389,12 @@ a command runs:
|
|
389
389
|
Spring.quiet = true
|
390
390
|
```
|
391
391
|
|
392
|
+
You can also set the initial state of the `quiet` configuration option to true
|
393
|
+
by setting the `SPRING_QUIET` environment variable before executing Spring.
|
394
|
+
This is useful if you want to set quiet mode when invoking the Spring executable
|
395
|
+
in a subprocess, and cannot or prefer not to set it programmatically
|
396
|
+
via the `Spring.quiet` option in `~/.spring.rb` or the app's `config/spring.rb`.
|
397
|
+
|
392
398
|
### Environment variables
|
393
399
|
|
394
400
|
The following environment variables are used by Spring:
|
@@ -413,6 +419,8 @@ The following environment variables are used by Spring:
|
|
413
419
|
the long-running Spring server process. By default, this is related to
|
414
420
|
the socket path; if the socket path is `/foo/bar/spring.sock` the
|
415
421
|
pidfile will be `/foo/bar/spring.pid`.
|
422
|
+
* `SPRING_QUIET` - If set, the initial state of the `Spring.quiet`
|
423
|
+
configuration option will default to `true`.
|
416
424
|
* `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
|
417
425
|
server when it is not already running. Defaults to `spring _[version]_
|
418
426
|
server --background`.
|
data/lib/spring/application.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "spring/boot"
|
2
|
-
require "set"
|
3
2
|
require "pty"
|
4
3
|
|
5
4
|
module Spring
|
@@ -11,8 +10,8 @@ module Spring
|
|
11
10
|
@original_env = original_env
|
12
11
|
@spring_env = spring_env
|
13
12
|
@mutex = Mutex.new
|
14
|
-
@waiting =
|
15
|
-
@clients =
|
13
|
+
@waiting = {}
|
14
|
+
@clients = {}
|
16
15
|
@preloaded = false
|
17
16
|
@state = :initialized
|
18
17
|
@interrupt = IO.pipe
|
@@ -92,8 +91,8 @@ module Spring
|
|
92
91
|
|
93
92
|
require Spring.application_root_path.join("config", "application")
|
94
93
|
|
95
|
-
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('
|
96
|
-
raise "Spring only supports Rails >=
|
94
|
+
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('6.0.0')
|
95
|
+
raise "Spring only supports Rails >= 6.0.0"
|
97
96
|
end
|
98
97
|
|
99
98
|
Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
|
@@ -128,7 +127,12 @@ module Spring
|
|
128
127
|
end
|
129
128
|
|
130
129
|
def eager_preload
|
131
|
-
with_pty
|
130
|
+
with_pty do
|
131
|
+
# we can't see stderr and there could be issues when it's overflown
|
132
|
+
# see https://github.com/rails/spring/issues/396
|
133
|
+
STDERR.reopen("/dev/null")
|
134
|
+
preload
|
135
|
+
end
|
132
136
|
end
|
133
137
|
|
134
138
|
def run
|
@@ -150,7 +154,7 @@ module Spring
|
|
150
154
|
log "got client"
|
151
155
|
manager.puts
|
152
156
|
|
153
|
-
@clients
|
157
|
+
@clients[client] = true
|
154
158
|
|
155
159
|
_stdout, stderr, _stdin = streams = 3.times.map { client.recv_io }
|
156
160
|
[STDOUT, STDERR, STDIN].zip(streams).each { |a, b| a.reopen(b) }
|
@@ -181,7 +185,7 @@ module Spring
|
|
181
185
|
pid = fork {
|
182
186
|
# Make sure to close other clients otherwise their graceful termination
|
183
187
|
# will be impossible due to reference from this fork.
|
184
|
-
@clients.
|
188
|
+
@clients.each_key { |c| c.close if c != client }
|
185
189
|
|
186
190
|
Process.setsid
|
187
191
|
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
|
@@ -245,7 +249,7 @@ module Spring
|
|
245
249
|
if exiting?
|
246
250
|
# Ensure that we do not ignore subsequent termination attempts
|
247
251
|
log "forced exit"
|
248
|
-
@waiting.
|
252
|
+
@waiting.each_key { |pid| Process.kill("TERM", pid) }
|
249
253
|
Kernel.exit
|
250
254
|
else
|
251
255
|
state! :terminating
|
@@ -337,7 +341,7 @@ module Spring
|
|
337
341
|
end
|
338
342
|
|
339
343
|
def wait(pid, streams, client)
|
340
|
-
@mutex.synchronize { @waiting
|
344
|
+
@mutex.synchronize { @waiting[pid] = true }
|
341
345
|
|
342
346
|
# Wait in a separate thread so we can run multiple commands at once
|
343
347
|
Spring.failsafe_thread {
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
1
|
module Spring
|
4
2
|
module Client
|
5
3
|
class Binstub < Command
|
@@ -11,41 +9,36 @@ module Spring
|
|
11
9
|
# client is not invoked for whatever reason, then the Kernel.exit won't
|
12
10
|
# happen, and so we'll fall back to the lines after this block, which
|
13
11
|
# should cause the "unsprung" version of the command to run.
|
14
|
-
LOADER =
|
15
|
-
|
16
|
-
|
17
|
-
rescue LoadError => e
|
18
|
-
raise unless e.message.include?('spring')
|
19
|
-
end
|
20
|
-
CODE
|
12
|
+
LOADER = <<~CODE
|
13
|
+
load File.expand_path("spring", __dir__)
|
14
|
+
CODE
|
21
15
|
|
22
16
|
# The defined? check ensures these lines don't execute when we load the
|
23
17
|
# binstub from the application process. Which means that in the application
|
24
18
|
# process we'll execute the lines which come after the LOADER block, which
|
25
19
|
# is what we want.
|
26
|
-
SPRING =
|
27
|
-
#!/usr/bin/env ruby
|
28
|
-
|
29
|
-
# This file loads Spring without using
|
30
|
-
# It gets overwritten when you run the `spring binstub` command.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
CODE
|
20
|
+
SPRING = <<~CODE
|
21
|
+
#!/usr/bin/env ruby
|
22
|
+
|
23
|
+
# This file loads Spring without using loading other gems in the Gemfile, in order to be fast.
|
24
|
+
# It gets overwritten when you run the `spring binstub` command.
|
25
|
+
|
26
|
+
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
|
27
|
+
require "bundler"
|
28
|
+
|
29
|
+
Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
|
30
|
+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
31
|
+
gem "spring", spring.version
|
32
|
+
require "spring/binstub"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
CODE
|
45
36
|
|
46
37
|
OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
|
47
38
|
|
48
39
|
BINSTUB_VARIATIONS = Regexp.union [
|
40
|
+
%{load File.expand_path("spring", __dir__)\n},
|
41
|
+
%{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError => e\n raise unless e.message.include?('spring')\nend\n},
|
49
42
|
%{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
|
50
43
|
%{begin\n spring_bin_path = File.expand_path('../spring', __FILE__)\n load spring_bin_path\nrescue LoadError => e\n raise unless e.message.end_with? spring_bin_path, 'spring/binstub'\nend\n},
|
51
44
|
LOADER
|
@@ -146,7 +139,7 @@ CODE
|
|
146
139
|
@mode = :add
|
147
140
|
@items = args.drop(1)
|
148
141
|
.map { |name| find_commands name }
|
149
|
-
.
|
142
|
+
.flatten.uniq
|
150
143
|
.map { |command| Item.new(command) }
|
151
144
|
end
|
152
145
|
|
data/lib/spring/client/rails.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require "set"
|
2
|
-
|
3
1
|
module Spring
|
4
2
|
module Client
|
5
3
|
class Rails < Command
|
6
|
-
COMMANDS =
|
4
|
+
COMMANDS = %w(console runner generate destroy test)
|
7
5
|
|
8
6
|
ALIASES = {
|
9
7
|
"c" => "console",
|
@@ -22,7 +20,7 @@ module Spring
|
|
22
20
|
|
23
21
|
if COMMANDS.include?(command_name)
|
24
22
|
Run.call(["rails_#{command_name}", *args.drop(2)])
|
25
|
-
elsif command_name.start_with?("db:")
|
23
|
+
elsif command_name&.start_with?("db:") && !command_name.start_with?("db:system")
|
26
24
|
Run.call(["rake", *args.drop(1)])
|
27
25
|
else
|
28
26
|
require "spring/configuration"
|
data/lib/spring/commands.rb
CHANGED
@@ -28,9 +28,16 @@ module Spring
|
|
28
28
|
config = File.expand_path("~/.spring.rb")
|
29
29
|
require config if File.exist?(config)
|
30
30
|
|
31
|
-
#
|
32
|
-
|
33
|
-
|
31
|
+
# We force the TTY so bundler doesn't show a backtrace in case gems are missing.
|
32
|
+
old_env = ENV["BUNDLER_FORCE_TTY"]
|
33
|
+
ENV["BUNDLER_FORCE_TTY"] = "true"
|
34
|
+
begin
|
35
|
+
# If the config/spring.rb contains requires for commands from other gems,
|
36
|
+
# then we need to be under bundler.
|
37
|
+
require "bundler/setup"
|
38
|
+
ensure
|
39
|
+
ENV["BUNDLER_FORCE_TTY"] = old_env
|
40
|
+
end
|
34
41
|
|
35
42
|
# Auto-require any Spring extensions which are in the Gemfile
|
36
43
|
Gem::Specification.map(&:name).grep(/^spring-/).each do |command|
|
data/lib/spring/configuration.rb
CHANGED
@@ -2,7 +2,8 @@ require "spring/errors"
|
|
2
2
|
|
3
3
|
module Spring
|
4
4
|
class << self
|
5
|
-
attr_accessor :application_root
|
5
|
+
attr_accessor :application_root
|
6
|
+
attr_writer :quiet
|
6
7
|
|
7
8
|
def gemfile
|
8
9
|
require "bundler"
|
@@ -52,6 +53,10 @@ module Spring
|
|
52
53
|
@project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
|
53
54
|
end
|
54
55
|
|
56
|
+
def quiet
|
57
|
+
@quiet || ENV.key?('SPRING_QUIET')
|
58
|
+
end
|
59
|
+
|
55
60
|
private
|
56
61
|
|
57
62
|
def find_project_root(current_dir)
|
data/lib/spring/env.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "pathname"
|
2
|
-
require "digest/md5"
|
3
2
|
|
4
3
|
require "spring/version"
|
5
4
|
require "spring/configuration"
|
@@ -41,6 +40,7 @@ module Spring
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def application_id
|
43
|
+
require "digest/md5"
|
44
44
|
ENV["SPRING_APPLICATION_ID"] || Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s)
|
45
45
|
end
|
46
46
|
|
data/lib/spring/version.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "set"
|
2
1
|
require "pathname"
|
3
2
|
require "mutex_m"
|
4
3
|
|
@@ -19,8 +18,8 @@ module Spring
|
|
19
18
|
|
20
19
|
@root = File.realpath(root)
|
21
20
|
@latency = latency
|
22
|
-
@files =
|
23
|
-
@directories =
|
21
|
+
@files = {}
|
22
|
+
@directories = {}
|
24
23
|
@stale = false
|
25
24
|
@listeners = []
|
26
25
|
|
@@ -63,10 +62,10 @@ module Spring
|
|
63
62
|
synchronize {
|
64
63
|
items.each do |item|
|
65
64
|
if item.directory?
|
66
|
-
directories
|
65
|
+
directories[item.realpath.to_s] = true
|
67
66
|
else
|
68
67
|
begin
|
69
|
-
files
|
68
|
+
files[item.realpath.to_s] = true
|
70
69
|
rescue Errno::ENOENT
|
71
70
|
# Race condition. Ignore symlinks whose target was removed
|
72
71
|
# since the check above, or are deeply chained.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -97,7 +97,8 @@ files:
|
|
97
97
|
homepage: https://github.com/rails/spring
|
98
98
|
licenses:
|
99
99
|
- MIT
|
100
|
-
metadata:
|
100
|
+
metadata:
|
101
|
+
rubygems_mfa_required: 'true'
|
101
102
|
post_install_message:
|
102
103
|
rdoc_options: []
|
103
104
|
require_paths:
|
@@ -106,14 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
107
|
requirements:
|
107
108
|
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.
|
110
|
+
version: 2.7.0
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
requirements:
|
112
113
|
- - ">="
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.3.7
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: Rails application preloader
|