squared 0.4.16 → 0.4.18
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 +129 -57
- data/README.md +648 -1281
- data/lib/squared/common/base.rb +1 -1
- data/lib/squared/common/format.rb +5 -3
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/shell.rb +8 -2
- data/lib/squared/common/system.rb +18 -17
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +27 -12
- data/lib/squared/workspace/project/base.rb +63 -39
- data/lib/squared/workspace/project/docker.rb +69 -53
- data/lib/squared/workspace/project/git.rb +297 -186
- data/lib/squared/workspace/project/node.rb +43 -25
- data/lib/squared/workspace/project/python.rb +38 -13
- data/lib/squared/workspace/project/ruby.rb +74 -51
- data/lib/squared/workspace/project/support/class.rb +109 -15
- data/lib/squared/workspace/repo.rb +74 -47
- data/squared.gemspec +2 -2
- metadata +4 -5
- data/README.ruby.md +0 -721
@@ -97,7 +97,7 @@ module Squared
|
|
97
97
|
'pack' => nil
|
98
98
|
})
|
99
99
|
|
100
|
-
def initialize(*, **kwargs)
|
100
|
+
def initialize(*, init: nil, **kwargs)
|
101
101
|
super
|
102
102
|
if @pass.include?(Node.ref)
|
103
103
|
initialize_ref Node.ref
|
@@ -107,7 +107,7 @@ module Squared
|
|
107
107
|
initialize_env(**kwargs)
|
108
108
|
end
|
109
109
|
@dependfile = @path + 'package.json'
|
110
|
-
@pm = {}
|
110
|
+
@pm = { __: init }
|
111
111
|
end
|
112
112
|
|
113
113
|
def ref
|
@@ -116,7 +116,7 @@ module Squared
|
|
116
116
|
|
117
117
|
def populate(*, **)
|
118
118
|
super
|
119
|
-
return unless outdated? && ref?(Node.ref)
|
119
|
+
return unless (outdated? && ref?(Node.ref)) || @only
|
120
120
|
|
121
121
|
namespace name do
|
122
122
|
Node.subtasks do |action, flags|
|
@@ -429,7 +429,19 @@ module Squared
|
|
429
429
|
workspace.rev_clear(name, sync: sync)
|
430
430
|
return update if !flag && env('NODE_UPDATE')
|
431
431
|
|
432
|
-
|
432
|
+
pnpm = pnpm?
|
433
|
+
yarn = pnpm ? 0 : dependtype(:yarn)
|
434
|
+
if @pm[:__] && !pnpm && yarn == 0
|
435
|
+
case @pm[:__]
|
436
|
+
when 'pnpm'
|
437
|
+
pnpm = true
|
438
|
+
when 'yarn'
|
439
|
+
yarn = 1
|
440
|
+
when 'berry'
|
441
|
+
yarn = 2
|
442
|
+
end
|
443
|
+
end
|
444
|
+
if yarn > 0
|
433
445
|
cmd = session 'yarn'
|
434
446
|
if flag == :add
|
435
447
|
cmd << 'add'
|
@@ -439,7 +451,7 @@ module Squared
|
|
439
451
|
cmd << 'install'
|
440
452
|
cmd << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
|
441
453
|
end
|
442
|
-
elsif pnpm
|
454
|
+
elsif pnpm
|
443
455
|
cmd = session 'pnpm'
|
444
456
|
if flag == :add
|
445
457
|
cmd << 'add' << "--save-#{save}"
|
@@ -645,10 +657,10 @@ module Squared
|
|
645
657
|
return
|
646
658
|
end
|
647
659
|
cmd = session 'npm', 'publish'
|
648
|
-
cmd << basic_option('otp', otp) if otp
|
649
|
-
cmd << basic_option('tag', tag) if tag
|
650
|
-
cmd << basic_option('access', access) if access
|
651
|
-
dryrun
|
660
|
+
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
661
|
+
cmd << basic_option('tag', tag) if tag ||= option('tag')
|
662
|
+
cmd << basic_option('access', access) if access ||= option('access')
|
663
|
+
dryrun ||= dryrun?('npm')
|
652
664
|
if dryrun
|
653
665
|
cmd << '--dry-run'
|
654
666
|
else
|
@@ -659,13 +671,12 @@ module Squared
|
|
659
671
|
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
|
660
672
|
else
|
661
673
|
on :first, from
|
662
|
-
pwd_set(from:
|
674
|
+
pwd_set(from: from, dryrun: dryrun) do
|
663
675
|
require 'open3'
|
664
|
-
banner = format_banner
|
676
|
+
banner = format_banner cmd.to_s
|
665
677
|
Open3.popen2e(cmd.done) do |_, out|
|
666
|
-
write_lines(out,
|
667
|
-
|
668
|
-
])
|
678
|
+
write_lines(out, sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2],
|
679
|
+
banner: banner)
|
669
680
|
end
|
670
681
|
end
|
671
682
|
on :last, from
|
@@ -737,15 +748,18 @@ module Squared
|
|
737
748
|
when :major
|
738
749
|
if seg[0] != '0' || seg[2].nil?
|
739
750
|
seg[0] = seg[0].succ
|
751
|
+
seg[2] = '0'
|
740
752
|
else
|
741
753
|
seg[2] = seg[2].succ
|
742
754
|
end
|
755
|
+
seg[4] = '0'
|
743
756
|
when :minor
|
744
757
|
if seg[0] == '0'
|
745
758
|
seg[4] &&= seg[4].succ
|
746
759
|
else
|
747
760
|
seg[2] = seg[2].succ
|
748
761
|
end
|
762
|
+
seg[4] = '0'
|
749
763
|
when :patch
|
750
764
|
seg[4] &&= seg[4].succ
|
751
765
|
end
|
@@ -760,15 +774,15 @@ module Squared
|
|
760
774
|
log.info "bump version #{cur} to #{val} (#{flag})"
|
761
775
|
on :first, :bump
|
762
776
|
end
|
763
|
-
if
|
777
|
+
if stdin?
|
778
|
+
puts val
|
779
|
+
elsif verbose
|
764
780
|
major = flag == :major
|
765
781
|
emphasize("version: #{val}", title: name, border: borderstyle, sub: [
|
766
782
|
headerstyle,
|
767
783
|
{ pat: /\A(version:)( )(\S+)(.*)\z/, styles: color(major ? :green : :yellow), index: 3 },
|
768
784
|
{ pat: /\A(version:)(.*)\z/, styles: theme[major ? :major : :active] }
|
769
785
|
])
|
770
|
-
elsif stdin?
|
771
|
-
puts val
|
772
786
|
end
|
773
787
|
on :last, :bump unless dryrun?
|
774
788
|
else
|
@@ -785,7 +799,7 @@ module Squared
|
|
785
799
|
cmd = session dependbin, 'pack'
|
786
800
|
if dependtype(:yarn) > 1
|
787
801
|
op = OptionPartition.new(opts, OPT_BERRY[:pack], cmd, project: self)
|
788
|
-
op
|
802
|
+
op.append?('out', Pathname.pwd + "#{project}-#{version}.tgz")
|
789
803
|
else
|
790
804
|
op = OptionPartition.new(opts, pnpm? ? OPT_PNPM[:pack] : OPT_NPM[:pack] + OPT_NPM[:common], cmd,
|
791
805
|
project: self)
|
@@ -800,7 +814,7 @@ module Squared
|
|
800
814
|
end
|
801
815
|
end
|
802
816
|
end
|
803
|
-
op
|
817
|
+
op.append?('pack-destination', Dir.pwd)
|
804
818
|
end
|
805
819
|
op.clear
|
806
820
|
run(from: :pack)
|
@@ -914,13 +928,17 @@ module Squared
|
|
914
928
|
end
|
915
929
|
|
916
930
|
def version
|
917
|
-
|
931
|
+
self.version ||= read_packagemanager(:version)
|
918
932
|
end
|
919
933
|
|
920
934
|
def packagename
|
921
935
|
read_packagemanager :name
|
922
936
|
end
|
923
937
|
|
938
|
+
def scripts
|
939
|
+
@scripts ||= read_scripts.to_h
|
940
|
+
end
|
941
|
+
|
924
942
|
private
|
925
943
|
|
926
944
|
def read_packagemanager(key = nil, version: nil, update: false)
|
@@ -940,7 +958,7 @@ module Squared
|
|
940
958
|
else
|
941
959
|
if key
|
942
960
|
@pm[key]
|
943
|
-
elsif (ret = @pm[:_]) && !
|
961
|
+
elsif (ret = @pm[:_]) && (!version || semgte?(ret[(ret.index('@') + 1)..-1], version))
|
944
962
|
ret
|
945
963
|
end
|
946
964
|
end
|
@@ -989,10 +1007,6 @@ module Squared
|
|
989
1007
|
end
|
990
1008
|
end
|
991
1009
|
|
992
|
-
def dryrun?(prefix = dependbin, **)
|
993
|
-
super || !option('dry-run', prefix: prefix).nil?
|
994
|
-
end
|
995
|
-
|
996
1010
|
def dependbin
|
997
1011
|
if yarn?
|
998
1012
|
'yarn'
|
@@ -1017,6 +1031,10 @@ module Squared
|
|
1017
1031
|
{ pat: /^(npm )(.+)$/, styles: :bold }
|
1018
1032
|
]
|
1019
1033
|
end
|
1034
|
+
|
1035
|
+
def dryrun?(prefix = dependbin, **)
|
1036
|
+
super || !option('dry-run', prefix: prefix).nil?
|
1037
|
+
end
|
1020
1038
|
end
|
1021
1039
|
|
1022
1040
|
Application.implement Node
|
@@ -87,7 +87,6 @@ module Squared
|
|
87
87
|
initialize_build(Python.ref, **kwargs)
|
88
88
|
initialize_env(**kwargs)
|
89
89
|
end
|
90
|
-
@verbose = verbose.size if verbose.is_a?(String) && verbose.match?(/\Av+\z/)
|
91
90
|
dependfile_set DEP_PYTHON
|
92
91
|
editable_set editable
|
93
92
|
venv_set kwargs[:venv]
|
@@ -95,7 +94,7 @@ module Squared
|
|
95
94
|
|
96
95
|
subtasks({
|
97
96
|
'venv' => %i[exec create remove show].freeze,
|
98
|
-
'pip' => %i[uninstall freeze].freeze,
|
97
|
+
'pip' => %i[upgrade uninstall freeze].freeze,
|
99
98
|
'install' => %i[user force upgrade target editable].freeze,
|
100
99
|
'outdated' => %i[major minor patch].freeze,
|
101
100
|
'build' => %i[python poetry pdm hatch].freeze,
|
@@ -104,13 +103,22 @@ module Squared
|
|
104
103
|
'exec' => nil
|
105
104
|
})
|
106
105
|
|
106
|
+
def verbose=(val)
|
107
|
+
case val
|
108
|
+
when /\Av+\z/
|
109
|
+
@verbose = val.size
|
110
|
+
else
|
111
|
+
super
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
107
115
|
def ref
|
108
116
|
Python.ref
|
109
117
|
end
|
110
118
|
|
111
119
|
def populate(*, **)
|
112
120
|
super
|
113
|
-
return unless outdated? && ref?(Python.ref)
|
121
|
+
return unless (outdated? && ref?(Python.ref)) || @only
|
114
122
|
|
115
123
|
namespace name do
|
116
124
|
Python.subtasks do |action, flags|
|
@@ -124,7 +132,7 @@ module Squared
|
|
124
132
|
format_desc action, nil, "script+|#{indexchar}index+|#,pattern*"
|
125
133
|
task action, [:command] do |_, args|
|
126
134
|
found = 0
|
127
|
-
[
|
135
|
+
%w[tool.poetry.scripts tool.pdm.scripts project.scripts].each_with_index do |table, index|
|
128
136
|
next if (list = read_pyproject(table)).empty?
|
129
137
|
|
130
138
|
if args.command == '#'
|
@@ -159,7 +167,7 @@ module Squared
|
|
159
167
|
found |= 1
|
160
168
|
run(pdm_session('run', val), from: :run)
|
161
169
|
else
|
162
|
-
raise_error
|
170
|
+
raise_error "script: #{val}" if exception
|
163
171
|
found |= 2
|
164
172
|
log.warn "run script \"#{val}\" (not indexed)"
|
165
173
|
end
|
@@ -234,6 +242,14 @@ module Squared
|
|
234
242
|
end
|
235
243
|
when 'pip'
|
236
244
|
case flag
|
245
|
+
when :upgrade
|
246
|
+
format_desc action, flag, 'opts*'
|
247
|
+
task flag do |_, args|
|
248
|
+
args = args.to_a
|
249
|
+
args.unshift('upgrade')
|
250
|
+
args << 'pip'
|
251
|
+
install flag, args
|
252
|
+
end
|
237
253
|
when :freeze
|
238
254
|
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
239
255
|
task flag do |_, args|
|
@@ -287,7 +303,7 @@ module Squared
|
|
287
303
|
when 'build'
|
288
304
|
case flag
|
289
305
|
when :poetry
|
290
|
-
next unless
|
306
|
+
next unless poetry?
|
291
307
|
when :pdm
|
292
308
|
next unless build_backend == 'pdm.backend'
|
293
309
|
when :hatch
|
@@ -325,8 +341,8 @@ module Squared
|
|
325
341
|
elsif outdated?
|
326
342
|
venv_init
|
327
343
|
workspace.rev_clear(name, sync: sync)
|
328
|
-
if !flag &&
|
329
|
-
cmd = poetry_session 'install
|
344
|
+
if !flag && poetry?
|
345
|
+
cmd = poetry_session 'install -n'
|
330
346
|
cmd << '--no-root' if option('no-root')
|
331
347
|
else
|
332
348
|
cmd = pip_session 'install'
|
@@ -351,7 +367,7 @@ module Squared
|
|
351
367
|
end
|
352
368
|
|
353
369
|
def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated'))
|
354
|
-
cmd = pip_session 'list
|
370
|
+
cmd = pip_session 'list --outdated'
|
355
371
|
append_global
|
356
372
|
cmd = session_done cmd
|
357
373
|
log.info cmd
|
@@ -458,6 +474,11 @@ module Squared
|
|
458
474
|
cmd << '--user' if user
|
459
475
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
460
476
|
append_value out
|
477
|
+
if workspace.windows?
|
478
|
+
pip = cmd.to_a.drop(1)
|
479
|
+
cmd = python_session '-m pip'
|
480
|
+
cmd.merge(pip)
|
481
|
+
end
|
461
482
|
end
|
462
483
|
run(from: :install)
|
463
484
|
end
|
@@ -506,7 +527,7 @@ module Squared
|
|
506
527
|
end
|
507
528
|
op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
|
508
529
|
end
|
509
|
-
op
|
530
|
+
op.add_path(srcdir) if srcdir
|
510
531
|
op.clear
|
511
532
|
run(from: :"#{flag}:build")
|
512
533
|
end
|
@@ -552,7 +573,7 @@ module Squared
|
|
552
573
|
out = append_pip(nil, opts, from: flag)
|
553
574
|
case flag
|
554
575
|
when :uninstall
|
555
|
-
raise_error('no packages listed', hint:
|
576
|
+
raise_error('no packages listed', hint: flag) if out.empty?
|
556
577
|
cmd.merge(out)
|
557
578
|
when :freeze
|
558
579
|
venv_init
|
@@ -653,7 +674,7 @@ module Squared
|
|
653
674
|
end
|
654
675
|
op.swap
|
655
676
|
if edit
|
656
|
-
edit = path + edit unless %r{
|
677
|
+
edit = path + edit unless %r{\A[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
657
678
|
if flag == :editable
|
658
679
|
op.push(edit)
|
659
680
|
else
|
@@ -765,7 +786,7 @@ module Squared
|
|
765
786
|
end
|
766
787
|
@pyproject[table] = ret
|
767
788
|
end
|
768
|
-
return ret.find { |val| val
|
789
|
+
return ret.find { |val| val.first == key }&.last if key
|
769
790
|
|
770
791
|
ret
|
771
792
|
end
|
@@ -866,6 +887,10 @@ module Squared
|
|
866
887
|
puts(dir.directory? ? "Success: #{dir}" : 'Failed') if banner && !status
|
867
888
|
end
|
868
889
|
|
890
|
+
def poetry?
|
891
|
+
build_backend ? build_backend == 'poetry.core.masonry.api' : dependtype == 1
|
892
|
+
end
|
893
|
+
|
869
894
|
def requirements?
|
870
895
|
dependtype == 5
|
871
896
|
end
|
@@ -25,8 +25,8 @@ module Squared
|
|
25
25
|
common: %w[no-color V|verbose retry=i].freeze,
|
26
26
|
install: %w[frozen no-cache no-prune system binstubs=p? path=p standalone=q? target-rbconfig=p trust-policy=b
|
27
27
|
with=q without=q].freeze,
|
28
|
-
install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
|
29
|
-
update: %w[conservative local pre
|
28
|
+
install_base: %w[force full-index quiet redownload retry gemfile=p j|jobs=i].freeze,
|
29
|
+
update: %w[conservative local pre ruby strict bundler=b? g|group=q source=b].freeze,
|
30
30
|
outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
|
31
31
|
update-strict g|group=q source=b].freeze,
|
32
32
|
exec: %w[gemfile=p].freeze,
|
@@ -102,7 +102,13 @@ module Squared
|
|
102
102
|
end
|
103
103
|
dependfile_set GEMFILE
|
104
104
|
@autodetect = autodetect
|
105
|
-
@gemfile =
|
105
|
+
@gemfile = if gemspec == false
|
106
|
+
false
|
107
|
+
elsif gemspec
|
108
|
+
path + (gemspec.include?('.') ? gemspec : "#{gemspec}.gemspec")
|
109
|
+
elsif (gemspec = path + "#{name}.gemspec").exist? || (gemspec = path + "#{project}.gemspec").exist?
|
110
|
+
gemspec
|
111
|
+
end
|
106
112
|
return if !@output[0].nil? || !@copy.nil? || version || @autodetect || !rakefile
|
107
113
|
|
108
114
|
begin
|
@@ -126,7 +132,7 @@ module Squared
|
|
126
132
|
|
127
133
|
def populate(*, **)
|
128
134
|
super
|
129
|
-
return unless outdated? && ref?(Ruby.ref)
|
135
|
+
return unless (outdated? && ref?(Ruby.ref)) || @only
|
130
136
|
|
131
137
|
namespace name do
|
132
138
|
Ruby.subtasks do |action, flags|
|
@@ -140,21 +146,21 @@ module Squared
|
|
140
146
|
format_desc action, nil, "task+,opts*|#{indexchar}index+|#,pattern*"
|
141
147
|
task action, [:command] do |_, args|
|
142
148
|
if args.command == '#'
|
143
|
-
format_list(
|
144
|
-
|
149
|
+
format_list(raketasks, "rake[#{indexchar}N]", 'tasks', grep: args.extras, from: rakefile,
|
150
|
+
each: ->(val) { val[0] + val[1].to_s })
|
145
151
|
else
|
146
152
|
args, opts = args.to_a.partition { |val| indexitem(val) }
|
147
153
|
if args.empty?
|
148
154
|
rake(opts: opts)
|
149
155
|
else
|
150
|
-
|
156
|
+
tasks = raketasks
|
151
157
|
while (n, pre = indexitem(args.shift))
|
152
|
-
if (item =
|
158
|
+
if (item = tasks[n - 1])
|
153
159
|
cmd = pre ? "#{pre} #{item.first}" : item.first
|
154
160
|
elsif exception
|
155
|
-
indexerror n,
|
161
|
+
indexerror n, tasks
|
156
162
|
else
|
157
|
-
log.warn "rake task #{n} of #{
|
163
|
+
log.warn "rake task #{n} of #{tasks.size} (out of range)"
|
158
164
|
next
|
159
165
|
end
|
160
166
|
if opts.empty?
|
@@ -171,7 +177,7 @@ module Squared
|
|
171
177
|
format_desc action, nil, 'opts*,args*|:'
|
172
178
|
task action do |_, args|
|
173
179
|
args = args.to_a
|
174
|
-
name = basepath(
|
180
|
+
name = gemlib.any? { |file| basepath(file).join("#{gemname}.rb").exist? } ? gemname : nil
|
175
181
|
irb(name, args, args: (readline('Enter file [arguments]', force: false) if args.delete(':')))
|
176
182
|
end
|
177
183
|
else
|
@@ -275,7 +281,7 @@ module Squared
|
|
275
281
|
end
|
276
282
|
end
|
277
283
|
|
278
|
-
def copy(from:
|
284
|
+
def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
|
279
285
|
glob = kwargs[:include]
|
280
286
|
pass = kwargs[:exclude]
|
281
287
|
if @copy && !override
|
@@ -426,7 +432,16 @@ module Squared
|
|
426
432
|
|
427
433
|
def install(flag, opts = [])
|
428
434
|
bundle_session 'install', "--#{flag}"
|
429
|
-
append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:install] + OPT_BUNDLE[:common]
|
435
|
+
op = append_bundle opts, OPT_BUNDLE[:install_base] + OPT_BUNDLE[:install] + OPT_BUNDLE[:common]
|
436
|
+
if op.arg?('force')
|
437
|
+
op.delete('--force')
|
438
|
+
if flag != :redownload
|
439
|
+
op << '--redownload'
|
440
|
+
elsif (lock = basepath('Gemfile.lock')).exist?
|
441
|
+
config = basepath('.bundle', 'config')
|
442
|
+
lock.delete unless config.exist? && config.read.match?(/\bBUNDLE_FROZEN:\s+"true"/)
|
443
|
+
end
|
444
|
+
end
|
430
445
|
run_rb(from: :install)
|
431
446
|
end
|
432
447
|
|
@@ -565,7 +580,7 @@ module Squared
|
|
565
580
|
minor = 0
|
566
581
|
patch = 0
|
567
582
|
update = []
|
568
|
-
pwd_set(pass: !
|
583
|
+
pwd_set(pass: !gempwd.nil?, from: from) do
|
569
584
|
items = [[%w[Gem Current Latest], nil]]
|
570
585
|
IO.popen(cmd.done).each do |line|
|
571
586
|
if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
|
@@ -685,11 +700,11 @@ module Squared
|
|
685
700
|
on :last, from
|
686
701
|
return
|
687
702
|
when :build
|
688
|
-
if
|
689
|
-
op
|
690
|
-
|
691
|
-
|
692
|
-
|
703
|
+
if op.empty?
|
704
|
+
op.add_path(gemfile)
|
705
|
+
else
|
706
|
+
op.add_path(op.shift)
|
707
|
+
.clear(pass: false)
|
693
708
|
end
|
694
709
|
when :push
|
695
710
|
if op.empty?
|
@@ -703,7 +718,7 @@ module Squared
|
|
703
718
|
raise_error('gem not found', hint: file) unless file.exist?
|
704
719
|
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
705
720
|
end
|
706
|
-
op
|
721
|
+
op.add_path(file)
|
707
722
|
run_rb(from: from, interactive: "Push #{sub_style(gemname, styles: theme[:active])}")
|
708
723
|
return
|
709
724
|
when :exec
|
@@ -730,7 +745,7 @@ module Squared
|
|
730
745
|
raise_error('missing gemname', hint: flag) if op.empty?
|
731
746
|
case flag
|
732
747
|
when :install, :uninstall, :pristine
|
733
|
-
post = readline('Enter command [args]', force: true) if flag == :install && op.
|
748
|
+
post = readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
|
734
749
|
if op.arg?('all')
|
735
750
|
if flag == :pristine
|
736
751
|
append_repeat 'skip', op.extras
|
@@ -797,7 +812,7 @@ module Squared
|
|
797
812
|
run_s(args, banner: false, from: :rake)
|
798
813
|
end
|
799
814
|
|
800
|
-
def irb(name = nil, opts = [], path:
|
815
|
+
def irb(name = nil, opts = [], path: gemlib, args: nil)
|
801
816
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
802
817
|
r = args ? [] : ['bundler/setup']
|
803
818
|
r << name if name
|
@@ -815,15 +830,11 @@ module Squared
|
|
815
830
|
def gemspec
|
816
831
|
return @gemspec unless @gemspec.nil?
|
817
832
|
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
rescue StandardError => e
|
824
|
-
log.debug e
|
825
|
-
end
|
826
|
-
@gemspec ||= false
|
833
|
+
@gemspec = if (file = gemfile)
|
834
|
+
Gem::Specification.load(file.to_s) rescue false
|
835
|
+
else
|
836
|
+
false
|
837
|
+
end
|
827
838
|
end
|
828
839
|
|
829
840
|
def gemname
|
@@ -885,7 +896,6 @@ module Squared
|
|
885
896
|
end
|
886
897
|
end
|
887
898
|
end
|
888
|
-
require 'rubygems'
|
889
899
|
@gemdir = Pathname.new(Gem.dir) + gempath
|
890
900
|
else
|
891
901
|
parse = lambda do |path|
|
@@ -940,6 +950,7 @@ module Squared
|
|
940
950
|
else
|
941
951
|
op.clear
|
942
952
|
end
|
953
|
+
op
|
943
954
|
end
|
944
955
|
|
945
956
|
def ruby_session(*cmd, **kwargs)
|
@@ -981,27 +992,10 @@ module Squared
|
|
981
992
|
session_output('rake', *cmd, **kwargs)
|
982
993
|
end
|
983
994
|
|
984
|
-
def read_rakefile
|
985
|
-
@read_rakefile ||= [].tap do |ret|
|
986
|
-
pwd = rakepwd
|
987
|
-
pwd_set(pass: !pwd.nil?) do
|
988
|
-
IO.popen(rake_output(pwd, '-AT').to_s).each do |line|
|
989
|
-
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
990
|
-
|
991
|
-
ret << [$1, $2]
|
992
|
-
end
|
993
|
-
end
|
994
|
-
end
|
995
|
-
end
|
996
|
-
|
997
995
|
def preopts
|
998
996
|
verbosetype > 1 && !session_arg?('quiet') ? ['--verbose'] : []
|
999
997
|
end
|
1000
998
|
|
1001
|
-
def gemdir?
|
1002
|
-
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1003
|
-
end
|
1004
|
-
|
1005
999
|
def variables
|
1006
1000
|
(super + %i[version autodetect]).freeze
|
1007
1001
|
end
|
@@ -1014,13 +1008,26 @@ module Squared
|
|
1014
1008
|
end
|
1015
1009
|
|
1016
1010
|
def rakepwd
|
1017
|
-
return
|
1011
|
+
return unless !pwd? && semgte?(Rake::VERSION, '13.0.4')
|
1018
1012
|
|
1019
1013
|
quote_option 'C', path
|
1020
1014
|
end
|
1021
1015
|
|
1016
|
+
def raketasks
|
1017
|
+
@raketasks ||= [].tap do |ret|
|
1018
|
+
opt = rakepwd
|
1019
|
+
pwd_set(pass: !opt.nil?) do
|
1020
|
+
IO.popen(rake_output(opt, '-AT').to_s).each do |line|
|
1021
|
+
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
1022
|
+
|
1023
|
+
ret << [$1, $2]
|
1024
|
+
end
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
end
|
1028
|
+
|
1022
1029
|
def gempwd
|
1023
|
-
return
|
1030
|
+
return unless !pwd? && semgte?(Gem::VERSION, '3.4.2')
|
1024
1031
|
|
1025
1032
|
quote_option 'C', path
|
1026
1033
|
end
|
@@ -1033,9 +1040,25 @@ module Squared
|
|
1033
1040
|
.find { |file| File.exist?(file) } || false
|
1034
1041
|
end
|
1035
1042
|
|
1043
|
+
def gemlib
|
1044
|
+
@gemlib ||= begin
|
1045
|
+
lib = Set.new(['lib'])
|
1046
|
+
if (spec = gemspec)
|
1047
|
+
lib.merge(spec.require_paths || [])
|
1048
|
+
end
|
1049
|
+
lib.select { |file| basepath(file).exist? }
|
1050
|
+
end
|
1051
|
+
end
|
1052
|
+
|
1036
1053
|
def gempath(val = version)
|
1037
1054
|
File.join('gems', "#{gemname}-#{val}")
|
1038
1055
|
end
|
1056
|
+
|
1057
|
+
def gemdir?
|
1058
|
+
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
alias read_rakefile raketasks
|
1039
1062
|
end
|
1040
1063
|
|
1041
1064
|
Application.implement Ruby
|