toys-core 0.10.3 → 0.10.4
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/CHANGELOG.md +5 -0
- data/lib/toys/core.rb +1 -1
- data/lib/toys/standard_mixins/bundler.rb +40 -16
- data/lib/toys/utils/gems.rb +49 -13
- data/lib/toys/utils/gems/gemfile.rb +6 -0
- data/lib/toys/utils/terminal.rb +1 -1
- metadata +5 -130
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73bf616783bbde0d72f5f62c57437220208bb4e06d46feb6eeea4507aae386a6
|
4
|
+
data.tar.gz: 3e526d1a50a7d03b8d42ef762b7bae02b5964efbc18a0b029dd39362876ff689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90100efa91c07240449b8da3ce72c358c4e09766afa80bdae044e0769586a6c890815e4c71786526fa00851d2fbc32db82fec586b01bf0bf9877ab17fb7b2867
|
7
|
+
data.tar.gz: f45936daa1ec21ee4d5531f5bda027a27cc45f4d99d678636d2c529fe1e0f1592130e5cddee5ffd25f8750487a92b8697f77f7a86d96f85cae63aa2840908f68
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 0.10.4 / 2020-07-11
|
4
|
+
|
5
|
+
* IMPROVED: Bundler integration can now handle Toys itself being in the bundle, as long as the version requirements cover the running Toys version.
|
6
|
+
* IMPROVED: Passing `static: true` to the `:bundler` mixin installs the bundle at definition rather than execution time.
|
7
|
+
|
3
8
|
### 0.10.3 / 2020-07-04
|
4
9
|
|
5
10
|
* FIXED: The `exec_separate_tool` method in the `:exec` mixin no longer throws ENOEXEC on Windows.
|
data/lib/toys/core.rb
CHANGED
@@ -7,6 +7,10 @@ module Toys
|
|
7
7
|
#
|
8
8
|
# The following parameters can be passed when including this mixin:
|
9
9
|
#
|
10
|
+
# * `:static` (Boolean) If `true`, installs the bundle immediately, when
|
11
|
+
# defining the tool. If `false` (the default), installs the bundle just
|
12
|
+
# before the tool runs.
|
13
|
+
#
|
10
14
|
# * `:groups` (Array<String>) The groups to include in setup
|
11
15
|
#
|
12
16
|
# * `:search_dirs` (Array<String,Symbol>) Directories to search for a
|
@@ -41,32 +45,39 @@ module Toys
|
|
41
45
|
module Bundler
|
42
46
|
include Mixin
|
43
47
|
|
44
|
-
on_initialize do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
on_initialize do |static: false, search_dirs: nil, **kwargs|
|
49
|
+
unless static
|
50
|
+
require "toys/utils/gems"
|
51
|
+
search_dirs = ::Toys::StandardMixins::Bundler.resolve_search_dirs(
|
52
|
+
search_dirs,
|
53
|
+
self[::Toys::Context::Key::CONTEXT_DIRECTORY],
|
54
|
+
self[::Toys::Context::Key::TOOL_SOURCE]
|
55
|
+
)
|
56
|
+
::Toys::StandardMixins::Bundler.setup_bundle(search_dirs, **kwargs)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
on_include do |static: false, search_dirs: nil, **kwargs|
|
61
|
+
if static
|
62
|
+
require "toys/utils/gems"
|
63
|
+
search_dirs = ::Toys::StandardMixins::Bundler.resolve_search_dirs(
|
64
|
+
search_dirs, context_directory, source_info
|
65
|
+
)
|
66
|
+
::Toys::StandardMixins::Bundler.setup_bundle(search_dirs, **kwargs)
|
67
|
+
end
|
57
68
|
end
|
58
69
|
|
59
70
|
## @private
|
60
|
-
def self.resolve_search_dirs(search_dirs,
|
71
|
+
def self.resolve_search_dirs(search_dirs, context_dir, source_info)
|
61
72
|
search_dirs ||= [:toys, :context, :current]
|
62
73
|
Array(search_dirs).flat_map do |dir|
|
63
74
|
case dir
|
64
75
|
when :context
|
65
|
-
|
76
|
+
context_dir
|
66
77
|
when :current
|
67
78
|
::Dir.getwd
|
68
79
|
when :toys
|
69
|
-
toys_dir_stack(
|
80
|
+
toys_dir_stack(source_info)
|
70
81
|
when ::String
|
71
82
|
dir
|
72
83
|
else
|
@@ -84,6 +95,19 @@ module Toys
|
|
84
95
|
end
|
85
96
|
dirs
|
86
97
|
end
|
98
|
+
|
99
|
+
## @private
|
100
|
+
def self.setup_bundle(search_dirs,
|
101
|
+
groups: nil,
|
102
|
+
on_missing: nil,
|
103
|
+
on_conflict: nil,
|
104
|
+
terminal: nil,
|
105
|
+
input: nil,
|
106
|
+
output: nil)
|
107
|
+
gems = ::Toys::Utils::Gems.new(on_missing: on_missing, on_conflict: on_conflict,
|
108
|
+
terminal: terminal, input: input, output: output)
|
109
|
+
gems.bundle(groups: groups, search_dirs: search_dirs)
|
110
|
+
end
|
87
111
|
end
|
88
112
|
end
|
89
113
|
end
|
data/lib/toys/utils/gems.rb
CHANGED
@@ -81,16 +81,22 @@ module Toys
|
|
81
81
|
#
|
82
82
|
# @param on_missing [:confirm,:error,:install] What to do if a needed gem
|
83
83
|
# is not installed. Possible values:
|
84
|
+
#
|
84
85
|
# * `:confirm` - prompt the user on whether to install
|
85
86
|
# * `:error` - raise an exception
|
86
87
|
# * `:install` - just install the gem
|
88
|
+
#
|
87
89
|
# The default is `:confirm`.
|
90
|
+
#
|
88
91
|
# @param on_conflict [:error,:warn,:ignore] What to do if bundler has
|
89
92
|
# already been run with a different Gemfile. Possible values:
|
93
|
+
#
|
90
94
|
# * `:error` - raise an exception
|
91
95
|
# * `:ignore` - just silently proceed without bundling again
|
92
96
|
# * `:warn` - print a warning and proceed without bundling again
|
97
|
+
#
|
93
98
|
# The default is `:error`.
|
99
|
+
#
|
94
100
|
# @param terminal [Toys::Utils::Terminal] Terminal to use (optional)
|
95
101
|
# @param input [IO] Input IO (optional, defaults to STDIN)
|
96
102
|
# @param output [IO] Output IO (optional, defaults to STDOUT)
|
@@ -146,8 +152,9 @@ module Toys
|
|
146
152
|
search_dirs: nil)
|
147
153
|
Gems.synchronize do
|
148
154
|
gemfile_path = find_gemfile(Array(search_dirs))
|
149
|
-
activate("bundler", "~> 2.1")
|
150
155
|
if configure_gemfile(gemfile_path)
|
156
|
+
activate("bundler", "~> 2.1")
|
157
|
+
require "bundler"
|
151
158
|
setup_bundle(gemfile_path, groups || [])
|
152
159
|
end
|
153
160
|
end
|
@@ -184,14 +191,14 @@ module Toys
|
|
184
191
|
error.message.include?("Could not find")
|
185
192
|
end
|
186
193
|
if !is_missing_spec || @on_missing == :error
|
187
|
-
|
194
|
+
report_activation_error(name, requirements, error)
|
188
195
|
return
|
189
196
|
end
|
190
197
|
confirm_and_install_gem(name, requirements)
|
191
198
|
begin
|
192
199
|
gem(name, *requirements)
|
193
200
|
rescue ::Gem::LoadError => e
|
194
|
-
|
201
|
+
report_activation_error(name, requirements, e)
|
195
202
|
end
|
196
203
|
end
|
197
204
|
|
@@ -215,7 +222,7 @@ module Toys
|
|
215
222
|
::Gem::Specification.reset
|
216
223
|
end
|
217
224
|
|
218
|
-
def
|
225
|
+
def report_activation_error(name, requirements, err)
|
219
226
|
if ::ENV["BUNDLE_GEMFILE"]
|
220
227
|
raise GemfileUpdateNeededError.new(gem_requirements_text(name, requirements),
|
221
228
|
::ENV["BUNDLE_GEMFILE"])
|
@@ -233,12 +240,14 @@ module Toys
|
|
233
240
|
|
234
241
|
def configure_gemfile(gemfile_path)
|
235
242
|
old_path = ::ENV["BUNDLE_GEMFILE"]
|
236
|
-
if old_path
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
243
|
+
if old_path
|
244
|
+
if gemfile_path != old_path
|
245
|
+
case @on_conflict
|
246
|
+
when :warn
|
247
|
+
terminal.puts("Warning: could not set up bundler because it is already set up.", :red)
|
248
|
+
when :error
|
249
|
+
raise AlreadyBundledError, "Could not set up bundler because it is already set up"
|
250
|
+
end
|
242
251
|
end
|
243
252
|
return false
|
244
253
|
end
|
@@ -247,21 +256,47 @@ module Toys
|
|
247
256
|
end
|
248
257
|
|
249
258
|
def setup_bundle(gemfile_path, groups)
|
250
|
-
require "bundler"
|
251
259
|
begin
|
260
|
+
modify_bundle_definition(gemfile_path)
|
252
261
|
::Bundler.setup(*groups)
|
253
262
|
rescue ::Bundler::GemNotFound
|
254
263
|
restore_toys_libs
|
255
264
|
install_bundle(gemfile_path)
|
256
265
|
::Bundler.reset!
|
266
|
+
modify_bundle_definition(gemfile_path)
|
257
267
|
::Bundler.setup(*groups)
|
258
268
|
end
|
259
269
|
restore_toys_libs
|
260
270
|
end
|
261
271
|
|
272
|
+
def modify_bundle_definition(gemfile_path)
|
273
|
+
builder = ::Bundler::Dsl.new
|
274
|
+
builder.eval_gemfile(gemfile_path)
|
275
|
+
begin
|
276
|
+
builder.eval_gemfile(::File.join(__dir__, "gems", "gemfile.rb"))
|
277
|
+
rescue ::Bundler::Dsl::DSLError
|
278
|
+
terminal.puts(
|
279
|
+
"WARNING: Unable to integrate your Gemfile into the Toys runtime.\n" \
|
280
|
+
"When using the Toys Bundler integration features, do NOT list\n" \
|
281
|
+
"the toys or toys-core gems directly in your Gemfile. They can be\n" \
|
282
|
+
"dependencies of another gem, but cannot be listed directly.",
|
283
|
+
:red
|
284
|
+
)
|
285
|
+
return
|
286
|
+
end
|
287
|
+
toys_gems = ["toys-core"]
|
288
|
+
toys_gems << "toys" if ::Toys.const_defined?(:VERSION)
|
289
|
+
definition = builder.to_definition(gemfile_path + ".lock", { gems: toys_gems })
|
290
|
+
::Bundler.instance_variable_set(:@definition, definition)
|
291
|
+
end
|
292
|
+
|
262
293
|
def restore_toys_libs
|
294
|
+
$LOAD_PATH.delete(::Toys::CORE_LIB_PATH)
|
263
295
|
$LOAD_PATH.unshift(::Toys::CORE_LIB_PATH)
|
264
|
-
|
296
|
+
if ::Toys.const_defined?(:LIB_PATH)
|
297
|
+
$LOAD_PATH.delete(::Toys::LIB_PATH)
|
298
|
+
$LOAD_PATH.unshift(::Toys::LIB_PATH)
|
299
|
+
end
|
265
300
|
end
|
266
301
|
|
267
302
|
def permission_to_bundle?
|
@@ -271,7 +306,8 @@ module Toys
|
|
271
306
|
when :error
|
272
307
|
false
|
273
308
|
else
|
274
|
-
terminal.confirm("Your bundle
|
309
|
+
terminal.confirm("Your bundle requires additional gems. Install? ",
|
310
|
+
default: @default_confirm)
|
275
311
|
end
|
276
312
|
end
|
277
313
|
|
data/lib/toys/utils/terminal.rb
CHANGED
metadata
CHANGED
@@ -1,141 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toys-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: did_you_mean
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: highline
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.14'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.14'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest-focus
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-rg
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '5.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rdoc
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 6.1.2
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 6.1.2
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: redcarpet
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.5'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '3.5'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.79.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.79.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: yard
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.9.24
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.9.24
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
139
13
|
description: Toys-Core is the command line tool framework underlying Toys. It can
|
140
14
|
be used to create command line executables using the Toys DSL and classes.
|
141
15
|
email:
|
@@ -188,6 +62,7 @@ files:
|
|
188
62
|
- lib/toys/utils/completion_engine.rb
|
189
63
|
- lib/toys/utils/exec.rb
|
190
64
|
- lib/toys/utils/gems.rb
|
65
|
+
- lib/toys/utils/gems/gemfile.rb
|
191
66
|
- lib/toys/utils/help_text.rb
|
192
67
|
- lib/toys/utils/terminal.rb
|
193
68
|
- lib/toys/wrappable_string.rb
|
@@ -198,7 +73,7 @@ metadata:
|
|
198
73
|
changelog_uri: https://github.com/dazuma/toys/blob/master/toys-core/CHANGELOG.md
|
199
74
|
source_code_uri: https://github.com/dazuma/toys
|
200
75
|
bug_tracker_uri: https://github.com/dazuma/toys/issues
|
201
|
-
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.10.
|
76
|
+
documentation_uri: https://dazuma.github.io/toys/gems/toys-core/v0.10.4
|
202
77
|
post_install_message:
|
203
78
|
rdoc_options: []
|
204
79
|
require_paths:
|