squared 0.7.6 → 0.8.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/CHANGELOG.md +106 -10
- data/README.md +40 -36
- data/lib/squared/common/base.rb +0 -1
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +25 -24
- data/lib/squared/common/shell.rb +24 -17
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +17 -13
- data/lib/squared/config.rb +3 -11
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -29
- data/lib/squared/workspace/project/base.rb +95 -82
- data/lib/squared/workspace/project/docker.rb +46 -29
- data/lib/squared/workspace/project/git.rb +158 -64
- data/lib/squared/workspace/project/node.rb +255 -165
- data/lib/squared/workspace/project/python.rb +27 -28
- data/lib/squared/workspace/project/ruby.rb +100 -72
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +9 -12
- data/lib/squared/workspace/project/support/utils.rb +10 -1
- data/lib/squared/workspace/repo.rb +9 -7
- data/lib/squared/workspace/series.rb +10 -2
- metadata +2 -2
|
@@ -105,7 +105,7 @@ module Squared
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
def bannerargs
|
|
108
|
-
%i[version dependfile venv].freeze
|
|
108
|
+
%i[version dependfile venv editable].freeze
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def venv?
|
|
@@ -201,7 +201,7 @@ module Squared
|
|
|
201
201
|
end
|
|
202
202
|
found |= 1
|
|
203
203
|
run(script, from: :run)
|
|
204
|
-
elsif exception
|
|
204
|
+
elsif exception?
|
|
205
205
|
indexerror n, list
|
|
206
206
|
else
|
|
207
207
|
found |= 2
|
|
@@ -216,7 +216,7 @@ module Squared
|
|
|
216
216
|
found |= 1
|
|
217
217
|
run(pdm_session('run', val), from: :run)
|
|
218
218
|
else
|
|
219
|
-
raise
|
|
219
|
+
raise message('script', val) if exception?
|
|
220
220
|
|
|
221
221
|
found |= 2
|
|
222
222
|
log.warn "run script \"#{val}\"".subhint('not indexed')
|
|
@@ -265,10 +265,10 @@ module Squared
|
|
|
265
265
|
|
|
266
266
|
format_desc action, flag, 'c/reate?,d/epend?,opts*'
|
|
267
267
|
task flag do |_, args|
|
|
268
|
-
|
|
269
|
-
rm_rf(venv, verbose:
|
|
270
|
-
venv_init if has_value!(
|
|
271
|
-
depend :force,
|
|
268
|
+
opts = args.to_a
|
|
269
|
+
rm_rf(venv, verbose: !silent?)
|
|
270
|
+
venv_init if has_value!(opts, 'c', 'create')
|
|
271
|
+
depend :force, opts if has_value!(opts, 'd', 'depend')
|
|
272
272
|
end
|
|
273
273
|
when :exec
|
|
274
274
|
format_desc action, flag, 'command,args*'
|
|
@@ -391,7 +391,7 @@ module Squared
|
|
|
391
391
|
else 'outdir?,srcdir?'
|
|
392
392
|
end)
|
|
393
393
|
task flag do |_, args|
|
|
394
|
-
|
|
394
|
+
build_ flag, args.to_a
|
|
395
395
|
end
|
|
396
396
|
break if be
|
|
397
397
|
when 'publish'
|
|
@@ -438,9 +438,9 @@ module Squared
|
|
|
438
438
|
if flag
|
|
439
439
|
cmd << case flag
|
|
440
440
|
when :requirement, :target
|
|
441
|
-
quote_option
|
|
441
|
+
quote_option flag, basepath(target)
|
|
442
442
|
else
|
|
443
|
-
shell_option
|
|
443
|
+
shell_option flag
|
|
444
444
|
end
|
|
445
445
|
op = append_pip flag, opts, pipopts(:install)
|
|
446
446
|
op.clear
|
|
@@ -614,7 +614,8 @@ module Squared
|
|
|
614
614
|
op.clear
|
|
615
615
|
when :user, :upgrade
|
|
616
616
|
op.concat(packages)
|
|
617
|
-
|
|
617
|
+
raise ArgumentError, message('no packages listed', hint: flag) if op.empty?
|
|
618
|
+
|
|
618
619
|
op << "--#{flag}"
|
|
619
620
|
op.append
|
|
620
621
|
python_session('-m pip', *op.to_a.drop(1)) if workspace.windows?
|
|
@@ -622,7 +623,7 @@ module Squared
|
|
|
622
623
|
run(banner: banner, from: :install)
|
|
623
624
|
end
|
|
624
625
|
|
|
625
|
-
def
|
|
626
|
+
def build_(flag, opts = [], outdir: nil, srcdir: nil)
|
|
626
627
|
list = case flag
|
|
627
628
|
when :poetry
|
|
628
629
|
cmd = poetry_session 'build'
|
|
@@ -705,12 +706,9 @@ module Squared
|
|
|
705
706
|
dist = lambda do
|
|
706
707
|
dir = basepath 'dist'
|
|
707
708
|
return dir if dir.directory? && !dir.empty?
|
|
709
|
+
raise message('no source to publish', hint: dir) if dir.exist?
|
|
708
710
|
|
|
709
|
-
|
|
710
|
-
raise_error 'no source to publish', hint: dir
|
|
711
|
-
else
|
|
712
|
-
raise_error Errno::ENOENT, dir, hint: 'publish'
|
|
713
|
-
end
|
|
711
|
+
raise Errno::ENOENT, message(dir, hint: 'publish')
|
|
714
712
|
end
|
|
715
713
|
if test
|
|
716
714
|
if op.arg?('r', flag == :hatch ? 'repo' : 'repository')
|
|
@@ -771,7 +769,7 @@ module Squared
|
|
|
771
769
|
when :install, :uninstall
|
|
772
770
|
op << '.' if installable? && !op.arg?('r', 'requirement')
|
|
773
771
|
else
|
|
774
|
-
|
|
772
|
+
raise ArgumentError, message('no packages listed', hint: flag)
|
|
775
773
|
end
|
|
776
774
|
elsif flag == :install
|
|
777
775
|
op.append_any
|
|
@@ -794,7 +792,8 @@ module Squared
|
|
|
794
792
|
.clear
|
|
795
793
|
when :cache
|
|
796
794
|
op.concat(args)
|
|
797
|
-
|
|
795
|
+
raise message('no subcommand', hint: flag) if op.empty?
|
|
796
|
+
|
|
798
797
|
op << (action = op.shift)
|
|
799
798
|
case action
|
|
800
799
|
when 'dir', 'info', 'purge'
|
|
@@ -802,13 +801,15 @@ module Squared
|
|
|
802
801
|
when 'list', 'remove'
|
|
803
802
|
op.add_first(quote: true)
|
|
804
803
|
else
|
|
805
|
-
|
|
804
|
+
raise ArgumentError, message('unrecognized args', action, hint: flag)
|
|
806
805
|
end
|
|
807
806
|
op.clear
|
|
808
807
|
when :config
|
|
809
808
|
op.concat(args)
|
|
810
|
-
|
|
811
|
-
|
|
809
|
+
raise message('no subcommand', hint: flag) if op.empty?
|
|
810
|
+
|
|
811
|
+
action = op.shift
|
|
812
|
+
op << action
|
|
812
813
|
case action
|
|
813
814
|
when 'list', 'edit', 'debug'
|
|
814
815
|
nil
|
|
@@ -816,7 +817,7 @@ module Squared
|
|
|
816
817
|
op.add_first
|
|
817
818
|
op.add_first(quote: true, expect: true) if action == 'set'
|
|
818
819
|
else
|
|
819
|
-
|
|
820
|
+
raise ArgumentError, message('unrecognized args', action, hint: flag)
|
|
820
821
|
end
|
|
821
822
|
op.clear
|
|
822
823
|
when :hash
|
|
@@ -853,7 +854,7 @@ module Squared
|
|
|
853
854
|
def variable_set(key, *args, **, &blk)
|
|
854
855
|
if block_given?
|
|
855
856
|
case key
|
|
856
|
-
when :dependfile, :
|
|
857
|
+
when :dependfile, :venv
|
|
857
858
|
args = block_args args, &blk
|
|
858
859
|
end
|
|
859
860
|
end
|
|
@@ -870,8 +871,6 @@ module Squared
|
|
|
870
871
|
log.warn "variable_set: @dependfile=#{val}".subhint('not supported')
|
|
871
872
|
end
|
|
872
873
|
end
|
|
873
|
-
when :editable
|
|
874
|
-
editable_set args.first
|
|
875
874
|
when :venv
|
|
876
875
|
@venv = (basepath(*args) unless args.empty? || args.first.nil?)
|
|
877
876
|
else
|
|
@@ -1025,7 +1024,7 @@ module Squared
|
|
|
1025
1024
|
|
|
1026
1025
|
if found
|
|
1027
1026
|
line.chomp!($1) if line =~ /(?<=[\d"'{}\[\]]|true|false)(\s*#.*)$/
|
|
1028
|
-
break if line.match?(/^\s*\[(
|
|
1027
|
+
break if line.match?(/^\s*\[([\w.\-"' ]+|".+"|'.+')\]\s*$/)
|
|
1029
1028
|
|
|
1030
1029
|
if ch
|
|
1031
1030
|
val = line.rstrip
|
|
@@ -1129,7 +1128,7 @@ module Squared
|
|
|
1129
1128
|
end
|
|
1130
1129
|
|
|
1131
1130
|
def variables
|
|
1132
|
-
(super + %i[venv
|
|
1131
|
+
(super + %i[venv]).freeze
|
|
1133
1132
|
end
|
|
1134
1133
|
|
|
1135
1134
|
def runenv
|
|
@@ -8,7 +8,7 @@ module Squared
|
|
|
8
8
|
GEMNAME = /\A[A-Za-z\d][A-Za-z\d_.-]*\z/.freeze
|
|
9
9
|
DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
|
|
10
10
|
OPT_RUBY = {
|
|
11
|
-
ruby: %w[0=im?
|
|
11
|
+
ruby: %w[a c l n p s S w 0=im? C=pm e=q E=bm F=qm i=bm? I=pm r=bm W=bm? x=pm? d|debug jit rjit verbose
|
|
12
12
|
y|yydebug backtrace-limit=i crash-report=q disable=q dump=q enable=q encoding=b external-encoding=b
|
|
13
13
|
internal-encoding=b parser=b].freeze,
|
|
14
14
|
rake: %w[A|all B|build-all comments n|dry-run m|multitask P|prereqs q|quiet X|no-deprecation-warnings
|
|
@@ -16,14 +16,14 @@ module Squared
|
|
|
16
16
|
D|describe=q? e|execute=q E|execute-continue=q p|execute-print=q f|rakefile=p job-stats=b? j|jobs=i?
|
|
17
17
|
I|libdir=p R|rakelib=p rakelibdir=p r|require=b suppress-backtrace=q T|tasks=q? t|trace=b?
|
|
18
18
|
W|where=q?].freeze,
|
|
19
|
-
irb: %w[d f U w E=b I=
|
|
19
|
+
irb: %w[d f U w E=b I=pm r=bm W=im? autocomplete colorize echo echo-on-assignment extra-doc-dir inf-ruby-mode
|
|
20
20
|
inspect multiline no-pager noautocomplete nocolorize noecho noecho-on-assignment noinspect
|
|
21
21
|
nomultiline noprompt noscript nosingleline noverbose regexp-completor sample-book-mode script
|
|
22
22
|
simple-prompt single-irb singleline tracer truncate-echo-on-assignment type-completor verbose
|
|
23
23
|
back-trace-limit=i context-mode=i prompt=b prompt-mode=b].freeze,
|
|
24
24
|
rdbg: %w[no-color no-rc no-sigint-hook c|command n|nonstop stop-at-load cookie=q e=q host=q x|init-script=p
|
|
25
25
|
O|open=q? port=i port-range=b session-name=q sock-path=q util=q].freeze,
|
|
26
|
-
rbs: %w[I=pm r=bm no-
|
|
26
|
+
rbs: %w[I=pm r=bm no-collection no-stdlib collection=p log-level=b log-output=p repo=p].freeze,
|
|
27
27
|
rubocop: %w[D P r=bm auto-gen-config a|autocorrect A|autocorrect-all d|debug disable-pending-cops
|
|
28
28
|
display-only-correctable display-only-fail-level-offenses display-only-failed
|
|
29
29
|
display-only-safe-correctable S|display-style-guide display-time editor-mode enable-pending-cops
|
|
@@ -34,8 +34,8 @@ module Squared
|
|
|
34
34
|
start-server stderr stop-server C|cache=b cache-root=p config=p exclude-limit=i fail-level=b
|
|
35
35
|
f|format=b except=q only=q o|out=p plugin=p require=p show-cops=q show-docs-url=q
|
|
36
36
|
s|stdin=p].freeze,
|
|
37
|
-
pry: %w[f I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
|
|
38
|
-
d|disable-plugin=q
|
|
37
|
+
pry: %w[f e=q I=pm no-color no-history no-multiline no-pager no-plugins simple-prompt c|context=q
|
|
38
|
+
d|disable-plugin=q gem=b r|require=bm s|select-plugin=q].freeze,
|
|
39
39
|
no: {
|
|
40
40
|
rubocop: %w[auto-gen-enforced-style auto-gen-only-exclude auto-gen-timestamp color display-cop-names
|
|
41
41
|
offense-counts parallel server].freeze
|
|
@@ -69,7 +69,7 @@ module Squared
|
|
|
69
69
|
plugin: %w[source=q version=q].freeze,
|
|
70
70
|
plugin_uninstall: %w[all].freeze,
|
|
71
71
|
show: %w[paths].freeze,
|
|
72
|
-
update: %w[all
|
|
72
|
+
update: %w[all conservative pre ruby strict bundler=b? g|group=q source=q].freeze,
|
|
73
73
|
v3: {
|
|
74
74
|
binstubs: %w[all].freeze,
|
|
75
75
|
cache: %w[all frozen no-prune].freeze,
|
|
@@ -212,7 +212,8 @@ module Squared
|
|
|
212
212
|
attr_reader :gemdir
|
|
213
213
|
attr_accessor :autodetect
|
|
214
214
|
|
|
215
|
-
def initialize(*, autodetect: false, steep: 'Steepfile', rubocop: '.rubocop.yml', asdf: 'ruby',
|
|
215
|
+
def initialize(*, autodetect: false, exec: false, steep: 'Steepfile', rubocop: '.rubocop.yml', asdf: 'ruby',
|
|
216
|
+
**kwargs)
|
|
216
217
|
super
|
|
217
218
|
if @pass.include?(Ruby.ref)
|
|
218
219
|
initialize_ref Ruby.ref
|
|
@@ -225,6 +226,7 @@ module Squared
|
|
|
225
226
|
serve_set kwargs[:serve]
|
|
226
227
|
gemfile_set kwargs[:gemspec]
|
|
227
228
|
self.autodetect = autodetect
|
|
229
|
+
@bundle = { exec: exec.is_a?(String) ? basepath!(exec) : false }
|
|
228
230
|
@steepfile = basepath! steep if steep
|
|
229
231
|
@rubocopfile = Pathname.new(rubocop).realpath rescue basepath!(Dir.home, '.rubocop.yml') if rubocop
|
|
230
232
|
@rubygems = kwargs.fetch(:rubygems, 0)
|
|
@@ -297,7 +299,7 @@ module Squared
|
|
|
297
299
|
queue.call
|
|
298
300
|
if (item = tasks[n.pred])
|
|
299
301
|
cmd = [pre, item.first].compact.join(' ')
|
|
300
|
-
elsif exception
|
|
302
|
+
elsif exception?
|
|
301
303
|
indexerror n, tasks
|
|
302
304
|
else
|
|
303
305
|
log.warn "rake task #{n} of #{tasks.size}".subhint('out of range')
|
|
@@ -380,7 +382,7 @@ module Squared
|
|
|
380
382
|
if val.include?('*')
|
|
381
383
|
out.concat(Dir.glob(val, base: path))
|
|
382
384
|
elsif !(file = basepath!(val))
|
|
383
|
-
print_error(
|
|
385
|
+
print_error('file not found', hint: val)
|
|
384
386
|
elsif file.directory?
|
|
385
387
|
out.concat(file.glob('**/*.rb'))
|
|
386
388
|
else
|
|
@@ -436,17 +438,18 @@ module Squared
|
|
|
436
438
|
when 'gem'
|
|
437
439
|
case flag
|
|
438
440
|
when :outdated
|
|
439
|
-
format_desc action, flag, "semver?=major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
|
|
441
|
+
format_desc action, flag, "semver?=(=)major|minor|patch,#{shortname('i', 's', 'u', 'd')},opts*"
|
|
440
442
|
task flag, [:semver] do |_, args|
|
|
441
|
-
opts =
|
|
442
|
-
|
|
443
|
+
opts = if args.semver =~ /^(=)?(major|minor|patch)$/i
|
|
444
|
+
equals = !$1.nil?
|
|
445
|
+
semver = $2.downcase
|
|
443
446
|
args.extras
|
|
444
447
|
else
|
|
445
|
-
semver = nil
|
|
446
448
|
args.to_a
|
|
447
449
|
end
|
|
448
450
|
gem(flag, opts: opts, banner: true, filter: {
|
|
449
451
|
semver: semver,
|
|
452
|
+
equals: equals,
|
|
450
453
|
update: has_value!(opts, 'u', 'update'),
|
|
451
454
|
interactive: has_value!(opts, 'i', 'interactive'),
|
|
452
455
|
select: has_value!(opts, 's', 'select'),
|
|
@@ -560,7 +563,7 @@ module Squared
|
|
|
560
563
|
else
|
|
561
564
|
%w[## ;]
|
|
562
565
|
end
|
|
563
|
-
msg = if
|
|
566
|
+
msg = if Prompt.reline.respond_to?(:readmultiline)
|
|
564
567
|
'ruby>'
|
|
565
568
|
else
|
|
566
569
|
multiline = Array(multiline)
|
|
@@ -603,7 +606,7 @@ module Squared
|
|
|
603
606
|
pwd_set do
|
|
604
607
|
out = []
|
|
605
608
|
tool = args.name || (s && !SEM_VER.match?(s) ? s : 'ruby')
|
|
606
|
-
trim = ->(val) { val
|
|
609
|
+
trim = ->(val) { val =~ /^\D+\d+\.\d+(?:\.\S+)?/ ? $&.sub(/^([a-z]+)-/i, '\1 ') : val }
|
|
607
610
|
vm, bin = vmname(bin: true)
|
|
608
611
|
out << trim.call(case vm
|
|
609
612
|
when 'rvm'
|
|
@@ -689,9 +692,9 @@ module Squared
|
|
|
689
692
|
.lines
|
|
690
693
|
.map { |line| line.sub(/#.*$/, '').strip }
|
|
691
694
|
.reject(&:empty?)
|
|
692
|
-
.yield_self do |
|
|
693
|
-
target =
|
|
694
|
-
target ? [target] :
|
|
695
|
+
.yield_self do |lines|
|
|
696
|
+
target = lines.find { |line| line.include?(tool) }
|
|
697
|
+
target ? [target] : lines
|
|
695
698
|
end
|
|
696
699
|
.join(', ')
|
|
697
700
|
end
|
|
@@ -725,7 +728,7 @@ module Squared
|
|
|
725
728
|
out.map!(&:split)
|
|
726
729
|
pad = as_a(out, :first, :size).max
|
|
727
730
|
print_item
|
|
728
|
-
puts(out.map { |line| '%*s %s' % [pad, line.first, line
|
|
731
|
+
puts(out.map { |line| '%*s %s' % [pad, line.first, line.drop(1).join(' ')] })
|
|
729
732
|
end
|
|
730
733
|
end
|
|
731
734
|
when :reshim
|
|
@@ -1065,6 +1068,7 @@ module Squared
|
|
|
1065
1068
|
buffer = []
|
|
1066
1069
|
filter = kwargs.fetch(:filter, {})
|
|
1067
1070
|
semver = filter[:semver]
|
|
1071
|
+
equals = filter[:equals]
|
|
1068
1072
|
update = if sync && filter[:select]
|
|
1069
1073
|
semver ||= 'major'
|
|
1070
1074
|
items = []
|
|
@@ -1141,6 +1145,8 @@ module Squared
|
|
|
1141
1145
|
when 2
|
|
1142
1146
|
case semver
|
|
1143
1147
|
when 'major', 'minor'
|
|
1148
|
+
next if equals && semver == 'major'
|
|
1149
|
+
|
|
1144
1150
|
update&.push(a)
|
|
1145
1151
|
when 'patch'
|
|
1146
1152
|
next
|
|
@@ -1154,6 +1160,8 @@ module Squared
|
|
|
1154
1160
|
else
|
|
1155
1161
|
case semver
|
|
1156
1162
|
when 'major', 'minor', 'patch'
|
|
1163
|
+
next if equals && semver != 'patch'
|
|
1164
|
+
|
|
1157
1165
|
update&.push(a)
|
|
1158
1166
|
end
|
|
1159
1167
|
unless stdin?
|
|
@@ -1252,26 +1260,36 @@ module Squared
|
|
|
1252
1260
|
case flag
|
|
1253
1261
|
when :build
|
|
1254
1262
|
if op.empty?
|
|
1255
|
-
|
|
1263
|
+
raise Errno::ENOENT, message('gemspec', hint: project) unless gemfile
|
|
1264
|
+
|
|
1256
1265
|
op.add_path(gemfile)
|
|
1257
1266
|
else
|
|
1258
|
-
op.add_first(path: true)
|
|
1267
|
+
op.add_first(path: !op.first.include?('*'), quote: true)
|
|
1259
1268
|
.clear(pass: false)
|
|
1260
1269
|
end
|
|
1261
1270
|
when :push
|
|
1271
|
+
target = gemname
|
|
1262
1272
|
if op.empty? || (n = op.index(':'))
|
|
1263
1273
|
file = basepath(if !n && (spec = gemspec)
|
|
1264
1274
|
"#{spec.name}-#{spec.version}.gem"
|
|
1265
1275
|
else
|
|
1266
1276
|
choice_index 'Select a file', Dir.glob('*.gem', base: path)
|
|
1267
1277
|
end)
|
|
1278
|
+
op.add_path(file)
|
|
1279
|
+
elsif (file = op.shift).include?('*')
|
|
1280
|
+
file = '*.gem' if file == '*'
|
|
1281
|
+
target = Dir.glob(file, base: path).join(', ')
|
|
1282
|
+
raise Errno::ENOENT, message(file, hint: flag) if target.empty?
|
|
1283
|
+
|
|
1284
|
+
op.add_quote(file)
|
|
1268
1285
|
else
|
|
1269
|
-
file = basepath(
|
|
1270
|
-
|
|
1271
|
-
|
|
1286
|
+
file = basepath(file.include?('.') ? file : "#{file}.gem")
|
|
1287
|
+
raise Errno::ENOENT, message(file, hint: flag) unless file.exist?
|
|
1288
|
+
raise ArgumentError, message('unrecognized args', op.join(', '), hint: flag) unless op.empty?
|
|
1289
|
+
|
|
1290
|
+
op.add_path(file)
|
|
1272
1291
|
end
|
|
1273
|
-
|
|
1274
|
-
return run(from: from, interactive: ['Push', 'N', gemname]) unless with || !banner
|
|
1292
|
+
return run(from: from, interactive: ['Push', 'N', target]) unless with || !banner
|
|
1275
1293
|
when :exec
|
|
1276
1294
|
min = if op.arg?('g', 'gem')
|
|
1277
1295
|
1
|
|
@@ -1327,7 +1345,8 @@ module Squared
|
|
|
1327
1345
|
op.unshift(name)
|
|
1328
1346
|
end
|
|
1329
1347
|
end
|
|
1330
|
-
|
|
1348
|
+
raise ArgumentError, message('missing gem name', hint: flag) if op.empty?
|
|
1349
|
+
|
|
1331
1350
|
if op.arg?('all')
|
|
1332
1351
|
if flag == :pristine
|
|
1333
1352
|
append_repeat 'skip', op.extras
|
|
@@ -1367,7 +1386,7 @@ module Squared
|
|
|
1367
1386
|
op << action
|
|
1368
1387
|
op.clear
|
|
1369
1388
|
else
|
|
1370
|
-
|
|
1389
|
+
raise ArgumentError, message('unrecognized command', action, hint: flag)
|
|
1371
1390
|
end
|
|
1372
1391
|
end
|
|
1373
1392
|
when :open, :owner, :unpack, :yank
|
|
@@ -1404,7 +1423,7 @@ module Squared
|
|
|
1404
1423
|
end
|
|
1405
1424
|
end
|
|
1406
1425
|
opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
|
|
1407
|
-
invalid = ->(a) {
|
|
1426
|
+
invalid = ->(a) { raise ArgumentError, message('unrecognized args', a.join(', '), hint: flag) }
|
|
1408
1427
|
cmd = bundle_session flag
|
|
1409
1428
|
case flag
|
|
1410
1429
|
when :cache, :check, :clean, :init, :install, :lock, :pack, :package, :platform
|
|
@@ -1623,8 +1642,8 @@ module Squared
|
|
|
1623
1642
|
|
|
1624
1643
|
def rubocop(*args, sync: true, banner: verbose?, with: nil, pass: PASS_RUBY[:rubocop], **kwargs)
|
|
1625
1644
|
opts = session_opts(with, args: args, kwargs: kwargs, pass: pass)
|
|
1626
|
-
op = OptionPartition.new(opts, OPT_RUBY[:rubocop], session('rubocop'),
|
|
1627
|
-
|
|
1645
|
+
op = OptionPartition.new(opts, OPT_RUBY[:rubocop], session(*bundle_args('rubocop')),
|
|
1646
|
+
project: self, strict: strict?, no: OPT_RUBY[:no][:rubocop])
|
|
1628
1647
|
if @rubocopfile && !op.arg?('c', 'config') && !rootpath('.rubocop.yml', ascend: true).exist?
|
|
1629
1648
|
op.add_path(@rubocopfile, option: 'c')
|
|
1630
1649
|
end
|
|
@@ -1659,7 +1678,7 @@ module Squared
|
|
|
1659
1678
|
end
|
|
1660
1679
|
|
|
1661
1680
|
def vmname(bin: false)
|
|
1662
|
-
order = { 'rbenv' => -1, 'rvm' => -1, 'chruby' => -1, 'mise' => -1 }
|
|
1681
|
+
order = { 'rbenv' => -1, 'rvm' => -1, 'chruby' => -1, 'asdf' => -1, 'mise' => -1 }
|
|
1663
1682
|
ENV.fetch('PATH', '').split(':').each_with_index do |val, index|
|
|
1664
1683
|
order.each_key do |key|
|
|
1665
1684
|
next unless val.match?(%r{[/.]#{key}/})
|
|
@@ -1668,36 +1687,40 @@ module Squared
|
|
|
1668
1687
|
break
|
|
1669
1688
|
end
|
|
1670
1689
|
end
|
|
1690
|
+
items = [
|
|
1691
|
+
"#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
|
|
1692
|
+
'$HOME/.rvm/bin/rvm',
|
|
1693
|
+
'$HOME/.local/bin/mise',
|
|
1694
|
+
'/usr/bin/rbenv',
|
|
1695
|
+
'/usr/bin/mise',
|
|
1696
|
+
'/usr/local/rvm/bin/rvm',
|
|
1697
|
+
'/usr/share/rvm/bin/rvm',
|
|
1698
|
+
'/usr/local/share/chruby/chruby.sh'
|
|
1699
|
+
]
|
|
1671
1700
|
if @asdf
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
1
|
|
1696
|
-
elsif d == -1
|
|
1697
|
-
-1
|
|
1698
|
-
else
|
|
1699
|
-
c < d ? -1 : 1
|
|
1700
|
-
end
|
|
1701
|
+
dir = File.join(ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf'), "installs/#{@asdf.first}")
|
|
1702
|
+
if @@asdf.version == 16
|
|
1703
|
+
items = [dir]
|
|
1704
|
+
else
|
|
1705
|
+
items << dir
|
|
1706
|
+
end
|
|
1707
|
+
end
|
|
1708
|
+
items.sort do |a, b|
|
|
1709
|
+
c = -1
|
|
1710
|
+
d = -1
|
|
1711
|
+
order.each do |key, val|
|
|
1712
|
+
pat = %r{/\.?#{key}}
|
|
1713
|
+
c = val if a.match?(pat)
|
|
1714
|
+
d = val if b.match?(pat)
|
|
1715
|
+
end
|
|
1716
|
+
if c == d
|
|
1717
|
+
0
|
|
1718
|
+
elsif c == -1
|
|
1719
|
+
1
|
|
1720
|
+
elsif d == -1
|
|
1721
|
+
-1
|
|
1722
|
+
else
|
|
1723
|
+
c < d ? -1 : 1
|
|
1701
1724
|
end
|
|
1702
1725
|
end
|
|
1703
1726
|
.each do |val|
|
|
@@ -1725,7 +1748,7 @@ module Squared
|
|
|
1725
1748
|
def project
|
|
1726
1749
|
return @project unless @project.frozen?
|
|
1727
1750
|
|
|
1728
|
-
@project = (
|
|
1751
|
+
@project = (gemspec&.name || @project).dup
|
|
1729
1752
|
end
|
|
1730
1753
|
|
|
1731
1754
|
def depend?
|
|
@@ -1820,8 +1843,8 @@ module Squared
|
|
|
1820
1843
|
private
|
|
1821
1844
|
|
|
1822
1845
|
def run_repl(*args, opts:, banner:, from:, delim: true, **kwargs)
|
|
1823
|
-
op = OptionPartition.new(opts, OPT_RUBY[from], session(from), project: self, strict: strict?,
|
|
1824
|
-
|
|
1846
|
+
op = OptionPartition.new(opts, OPT_RUBY[from], session(*bundle_args(from)), project: self, strict: strict?,
|
|
1847
|
+
first: [/\.rb$/])
|
|
1825
1848
|
r = []
|
|
1826
1849
|
r << 'bundler/setup' if !op.arg?('r') && bundle_load
|
|
1827
1850
|
r.concat(Array(kwargs[:name])) if kwargs[:name]
|
|
@@ -1848,14 +1871,15 @@ module Squared
|
|
|
1848
1871
|
end
|
|
1849
1872
|
|
|
1850
1873
|
def rake_session(*cmd, **kwargs)
|
|
1851
|
-
session('rake', *preopts, *cmd, **kwargs)
|
|
1874
|
+
session(*bundle_args('rake'), *preopts, *cmd, **kwargs)
|
|
1852
1875
|
end
|
|
1853
1876
|
|
|
1854
1877
|
def rbs_session(*cmd, opts: nil)
|
|
1855
|
-
|
|
1878
|
+
args = bundle_args 'rbs'
|
|
1879
|
+
return session(*args, *cmd) unless opts
|
|
1856
1880
|
|
|
1857
1881
|
op = OptionPartition.new(opts, OPT_RUBY[:rbs], project: self, strict: strict?)
|
|
1858
|
-
[session(
|
|
1882
|
+
[session(*args, *op.to_a, *cmd), op.extras]
|
|
1859
1883
|
end
|
|
1860
1884
|
|
|
1861
1885
|
def gem_output(*cmd, **kwargs)
|
|
@@ -1871,7 +1895,15 @@ module Squared
|
|
|
1871
1895
|
end
|
|
1872
1896
|
|
|
1873
1897
|
def rake_output(*cmd, **kwargs)
|
|
1874
|
-
session_output('rake', *cmd, **kwargs)
|
|
1898
|
+
session_output(*bundle_args('rake'), *cmd, **kwargs)
|
|
1899
|
+
end
|
|
1900
|
+
|
|
1901
|
+
def bundle_args(*args)
|
|
1902
|
+
if (val = @bundle[:exec])
|
|
1903
|
+
args.unshift(quote_option('gemfile', val)) unless val == true
|
|
1904
|
+
args.unshift('bundle', 'exec')
|
|
1905
|
+
end
|
|
1906
|
+
args
|
|
1875
1907
|
end
|
|
1876
1908
|
|
|
1877
1909
|
def bundle_load
|
|
@@ -1933,10 +1965,6 @@ module Squared
|
|
|
1933
1965
|
verbose? ? ['--verbose'] : []
|
|
1934
1966
|
end
|
|
1935
1967
|
|
|
1936
|
-
def variables
|
|
1937
|
-
(super + %i[autodetect]).freeze
|
|
1938
|
-
end
|
|
1939
|
-
|
|
1940
1968
|
def rakefile
|
|
1941
1969
|
if @rakefile.nil?
|
|
1942
1970
|
file = Rake::Application::DEFAULT_RAKEFILES.find { |val| exist?(val) }
|
|
@@ -20,8 +20,8 @@ module Squared
|
|
|
20
20
|
include Shell
|
|
21
21
|
include Prompt
|
|
22
22
|
|
|
23
|
-
def append(target, *args, delim: false, escape: false, quote: true, strip: nil,
|
|
24
|
-
|
|
23
|
+
def append(target, *args, delim: false, escape: false, quote: true, strip: nil, double: false, filter: nil,
|
|
24
|
+
pass: nil, **kwargs)
|
|
25
25
|
return if (ret = args.flatten(1)).empty?
|
|
26
26
|
|
|
27
27
|
target << '--' if delim && !target.include?('--')
|
|
@@ -52,7 +52,7 @@ module Squared
|
|
|
52
52
|
if !(pa = val.is_a?(Pathname)) && escape
|
|
53
53
|
shell_escape(val, quote: quote, double: double)
|
|
54
54
|
elsif quote || pa
|
|
55
|
-
shell_quote(val,
|
|
55
|
+
shell_quote(val, double: double, **kwargs)
|
|
56
56
|
else
|
|
57
57
|
val
|
|
58
58
|
end
|
|
@@ -135,7 +135,7 @@ module Squared
|
|
|
135
135
|
[name, $3, $2 || (name.size == 1 && $1.empty? ? true : '')]
|
|
136
136
|
end
|
|
137
137
|
|
|
138
|
-
def arg?(target, *args, value: false
|
|
138
|
+
def arg?(target, *args, value: false)
|
|
139
139
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
|
140
140
|
r << matchopts(s, value) unless s.empty?
|
|
141
141
|
a = target.to_a
|
|
@@ -315,7 +315,7 @@ module Squared
|
|
|
315
315
|
end
|
|
316
316
|
numtype = [
|
|
317
317
|
[i, /\A\d+\z/],
|
|
318
|
-
[f, /\A\d*(
|
|
318
|
+
[f, /\A\d*(\.\d+)?\z/],
|
|
319
319
|
[si, /\A-?\d+\z/]
|
|
320
320
|
].freeze
|
|
321
321
|
numcheck = ->(k, v) { numtype.any? { |flag, pat| flag.include?(k) && v.match?(pat) } }
|
|
@@ -395,10 +395,10 @@ module Squared
|
|
|
395
395
|
self
|
|
396
396
|
end
|
|
397
397
|
|
|
398
|
-
def append(*args, clear: false, **kwargs, &blk)
|
|
398
|
+
def append(*args, clear: false, preserve: '"', **kwargs, &blk)
|
|
399
399
|
args = clear ? extras.dup.tap { extras.clear } : extras if args.empty?
|
|
400
400
|
pass = kwargs[:pass] ||= []
|
|
401
|
-
OptionPartition.append(target, *args, **kwargs, &blk)
|
|
401
|
+
OptionPartition.append(target, *args, preserve: preserve, **kwargs, &blk)
|
|
402
402
|
errors.concat(pass)
|
|
403
403
|
self
|
|
404
404
|
end
|
|
@@ -609,7 +609,7 @@ module Squared
|
|
|
609
609
|
val = OptionPartition.send(:matchopts, val) unless val.is_a?(Regexp)
|
|
610
610
|
blk = proc { |s| s&.match?(val) }
|
|
611
611
|
else
|
|
612
|
-
raise TypeError,
|
|
612
|
+
raise TypeError, Common::Format.message('unknown', val, hint: target.first)
|
|
613
613
|
end
|
|
614
614
|
end
|
|
615
615
|
ret = find_all(&blk)
|
|
@@ -658,10 +658,7 @@ module Squared
|
|
|
658
658
|
|
|
659
659
|
def readline(msg, fallback = nil, option: nil, quote: false, force: true, double: false)
|
|
660
660
|
begin
|
|
661
|
-
|
|
662
|
-
ret = Readline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
|
|
663
|
-
rescue LoadError
|
|
664
|
-
raise unless (ret = fallback) || !force
|
|
661
|
+
ret = Common::Prompt.reline.readline("#{msg}#{force ? ':' : '?'} ", false).strip
|
|
665
662
|
rescue Interrupt
|
|
666
663
|
exit(force ? 1 : 0)
|
|
667
664
|
else
|