squared 0.5.4 → 0.5.5
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 +123 -63
- data/README.md +662 -1273
- 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 +7 -2
- data/lib/squared/common/system.rb +1 -1
- data/lib/squared/config.rb +8 -8
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +26 -8
- data/lib/squared/workspace/project/base.rb +94 -19
- data/lib/squared/workspace/project/docker.rb +2 -2
- data/lib/squared/workspace/project/git.rb +140 -118
- data/lib/squared/workspace/project/node.rb +18 -19
- data/lib/squared/workspace/project/python.rb +36 -19
- data/lib/squared/workspace/project/ruby.rb +97 -53
- data/lib/squared/workspace/project/support/class.rb +46 -3
- data/lib/squared/workspace/repo.rb +36 -13
- data/squared.gemspec +2 -2
- metadata +5 -6
- data/README.ruby.md +0 -728
@@ -30,7 +30,7 @@ module Squared
|
|
30
30
|
OPT_POETRY = {
|
31
31
|
common: %w[ansi no-ansi no-cache n|no-interaction no-plugins q|quiet v|verbose P|project=p].freeze,
|
32
32
|
build: %w[clean config-settings=qq f|format=b o|output=p].freeze,
|
33
|
-
publish: %w[build dry-run skip-existing cert=p client-cert=p dist-dir=p p|password=b r|repository=
|
33
|
+
publish: %w[build dry-run skip-existing cert=p client-cert=p dist-dir=p p|password=b r|repository=q
|
34
34
|
u|username=b].freeze
|
35
35
|
}.freeze
|
36
36
|
OPT_PDM = {
|
@@ -45,7 +45,7 @@ module Squared
|
|
45
45
|
q|quiet v|verbose].freeze,
|
46
46
|
build: %w[clean-hooks-after ext hooks-only no-hooks c|clean t|target=b].freeze,
|
47
47
|
publish: %w[initialize-auth n|no-prompt y|yes a|auth=q ca-cert=p client-cert=p client-key=p o|option=q
|
48
|
-
p|publisher=b r|repo=
|
48
|
+
p|publisher=b r|repo=q u|user=q].freeze
|
49
49
|
}.freeze
|
50
50
|
OPT_TWINE = {
|
51
51
|
publish: %w[attestations disable-progress-bar non-interactive s|sign skip-existing verbose cert=p
|
@@ -78,7 +78,7 @@ module Squared
|
|
78
78
|
|
79
79
|
attr_reader :venv, :editable
|
80
80
|
|
81
|
-
def initialize(*, editable: '.', verbose: nil, **kwargs)
|
81
|
+
def initialize(*, editable: '.', verbose: nil, asdf: 'python', **kwargs)
|
82
82
|
super
|
83
83
|
if @pass.include?(Python.ref)
|
84
84
|
initialize_ref Python.ref
|
@@ -132,7 +132,7 @@ module Squared
|
|
132
132
|
format_desc action, nil, "script+|#{indexchar}index+|#,pattern*"
|
133
133
|
task action, [:command] do |_, args|
|
134
134
|
found = 0
|
135
|
-
[
|
135
|
+
%w[tool.poetry.scripts tool.pdm.scripts project.scripts].each_with_index do |table, index|
|
136
136
|
next if (list = read_pyproject(table)).empty?
|
137
137
|
|
138
138
|
if args.command == '#'
|
@@ -276,13 +276,16 @@ module Squared
|
|
276
276
|
end
|
277
277
|
when :upgrade
|
278
278
|
task flag, [:strategy] do |_, args|
|
279
|
-
case (strategy = args.strategy)
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
279
|
+
args = case (strategy = args.strategy)
|
280
|
+
when 'eager', 'only-if-needed'
|
281
|
+
args.extras
|
282
|
+
when 'needed'
|
283
|
+
strategy = 'only-if-needed'
|
284
|
+
args.extras
|
285
|
+
else
|
286
|
+
strategy = nil
|
287
|
+
args.to_a
|
288
|
+
end
|
286
289
|
install(flag, args, strategy: strategy)
|
287
290
|
end
|
288
291
|
when :target
|
@@ -320,12 +323,18 @@ module Squared
|
|
320
323
|
end
|
321
324
|
break unless flag == :python
|
322
325
|
when 'publish'
|
323
|
-
format_desc(action, flag, 'opts*', after: case flag
|
324
|
-
|
325
|
-
|
326
|
-
|
326
|
+
format_desc(action, flag, 'test?,opts*', after: case flag
|
327
|
+
when :hatch then 'artifacts?'
|
328
|
+
when :twine then 'dist?'
|
329
|
+
end)
|
327
330
|
task flag do |_, args|
|
328
|
-
|
331
|
+
args = args.to_a
|
332
|
+
publish(flag, args, test: if args.first == 'test'
|
333
|
+
args.shift
|
334
|
+
true
|
335
|
+
else
|
336
|
+
false
|
337
|
+
end)
|
329
338
|
end
|
330
339
|
end
|
331
340
|
end
|
@@ -532,7 +541,7 @@ module Squared
|
|
532
541
|
run(from: :"#{flag}:build")
|
533
542
|
end
|
534
543
|
|
535
|
-
def publish(flag, opts = [])
|
544
|
+
def publish(flag, opts = [], test: false)
|
536
545
|
case flag
|
537
546
|
when :poetry
|
538
547
|
poetry_session 'publish'
|
@@ -549,10 +558,17 @@ module Squared
|
|
549
558
|
end
|
550
559
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
551
560
|
dist = lambda do
|
552
|
-
(
|
561
|
+
path.join('dist').tap do |dir|
|
553
562
|
raise_error('no source files found', hint: dir) unless dir.directory? && !dir.empty?
|
554
563
|
end
|
555
564
|
end
|
565
|
+
if test
|
566
|
+
if op.arg?('r', flag == :hatch ? 'repo' : 'repository')
|
567
|
+
op.push('test')
|
568
|
+
else
|
569
|
+
op << quote_option('r', 'testpypi')
|
570
|
+
end
|
571
|
+
end
|
556
572
|
case flag
|
557
573
|
when :hatch, :twine
|
558
574
|
if op.empty?
|
@@ -676,6 +692,7 @@ module Squared
|
|
676
692
|
op.found << opt
|
677
693
|
end
|
678
694
|
end
|
695
|
+
op << '--no-build-isolation' if option('build-isolation', equals: '0')
|
679
696
|
op.swap
|
680
697
|
if edit
|
681
698
|
edit = path + edit unless %r{\A[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
@@ -790,7 +807,7 @@ module Squared
|
|
790
807
|
end
|
791
808
|
@pyproject[table] = ret
|
792
809
|
end
|
793
|
-
return ret.find { |val| val
|
810
|
+
return ret.find { |val| val.first == key }&.last if key
|
794
811
|
|
795
812
|
ret
|
796
813
|
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,
|
@@ -91,7 +91,7 @@ module Squared
|
|
91
91
|
'irb' => nil
|
92
92
|
})
|
93
93
|
|
94
|
-
def initialize(*, autodetect: false, gemspec: nil, **kwargs)
|
94
|
+
def initialize(*, autodetect: false, gemspec: nil, asdf: 'ruby', **kwargs)
|
95
95
|
super
|
96
96
|
if @pass.include?(Ruby.ref)
|
97
97
|
initialize_ref Ruby.ref
|
@@ -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
|
@@ -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?
|
@@ -209,7 +215,7 @@ module Squared
|
|
209
215
|
when :build, :push, :exec, :update
|
210
216
|
format_desc(action, flag, 'opts*', after: case flag
|
211
217
|
when :exec then 'command,args*'
|
212
|
-
when :push then 'file
|
218
|
+
when :push then 'file?|:'
|
213
219
|
when :update then 'name*'
|
214
220
|
end)
|
215
221
|
task flag do |_, args|
|
@@ -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
|
|
@@ -451,16 +466,44 @@ module Squared
|
|
451
466
|
when :version
|
452
467
|
pwd_set do
|
453
468
|
out = []
|
454
|
-
|
469
|
+
order = { 'rvm' => -1, 'rbenv' => -1, 'chruby' => -1, 'asdf' => -1 }
|
470
|
+
ENV.fetch('PATH', '').split(':').each_with_index do |val, index|
|
471
|
+
order.each_key do |key|
|
472
|
+
if val.match?(%r{[/.]#{key}/})
|
473
|
+
order[key] = index
|
474
|
+
break
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
paths = [
|
455
479
|
'$HOME/.rvm/bin/rvm',
|
456
480
|
'/usr/local/rvm/bin/rvm',
|
457
481
|
'/usr/share/rvm/bin/rvm',
|
458
482
|
"#{ENV.fetch('RBENV_ROOT', '$HOME/.rbenv')}/bin/rbenv",
|
459
483
|
'/usr/bin/rbenv',
|
460
|
-
'/usr/local/share/chruby/chruby.sh'
|
461
|
-
|
462
|
-
|
463
|
-
|
484
|
+
'/usr/local/share/chruby/chruby.sh'
|
485
|
+
]
|
486
|
+
paths << "#{ENV.fetch('ASDF_DATA_DIR', '$HOME/.asdf')}/installs/#{@asdf.first}" if @asdf
|
487
|
+
paths.sort do |a, b|
|
488
|
+
c = -1
|
489
|
+
d = -1
|
490
|
+
order.each do |key, val|
|
491
|
+
pat = %r{/\.?#{key}}
|
492
|
+
c = val if a.match?(pat)
|
493
|
+
d = val if b.match?(pat)
|
494
|
+
end
|
495
|
+
if c == d
|
496
|
+
0
|
497
|
+
elsif c == -1
|
498
|
+
1
|
499
|
+
elsif d == -1
|
500
|
+
-1
|
501
|
+
else
|
502
|
+
c < d ? -1 : 1
|
503
|
+
end
|
504
|
+
end
|
505
|
+
.push('')
|
506
|
+
.each do |val|
|
464
507
|
next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
|
465
508
|
|
466
509
|
trim = ->(s) { s[/\A\D+\d+\.\d+(?:\.\S+)?/, 0].sub(/\A([a-z]+)-/i, '\1 ') }
|
@@ -475,12 +518,15 @@ module Squared
|
|
475
518
|
when 'chruby.sh'
|
476
519
|
chruby = session_output 'source', val
|
477
520
|
`#{chruby.with('ruby --version')}`
|
478
|
-
when 'install'
|
479
|
-
ver = '.tool-versions'
|
480
|
-
`asdf current ruby`[/ruby\s+\S+/, 0].sub(/\s+/, ' ')
|
481
521
|
else
|
482
|
-
|
483
|
-
|
522
|
+
if @asdf
|
523
|
+
cmd = 'asdf'
|
524
|
+
ver = '.tool-versions'
|
525
|
+
`asdf current #{@asdf.first}`[/\A\S+\s+\S+/, 0].sub(/\s+/, ' ')
|
526
|
+
else
|
527
|
+
ver = nil
|
528
|
+
`ruby --version`
|
529
|
+
end
|
484
530
|
end)
|
485
531
|
break if workspace.windows?
|
486
532
|
|
@@ -488,7 +534,7 @@ module Squared
|
|
488
534
|
out << trim.call(case cmd
|
489
535
|
when 'chruby.sh'
|
490
536
|
`#{chruby.with('chruby --version')}`.sub(':', '')
|
491
|
-
when '
|
537
|
+
when 'asdf'
|
492
538
|
"asdf #{`asdf version`.delete_prefix('v')}"
|
493
539
|
else
|
494
540
|
`#{cmd} --version`
|
@@ -500,8 +546,8 @@ module Squared
|
|
500
546
|
`rbenv which ruby`
|
501
547
|
when 'chruby.sh'
|
502
548
|
`#{chruby.with('which ruby')}`
|
503
|
-
when '
|
504
|
-
`asdf which
|
549
|
+
when 'asdf'
|
550
|
+
`asdf which #{@asdf.first}`
|
505
551
|
else
|
506
552
|
`which ruby`
|
507
553
|
end)
|
@@ -692,14 +738,14 @@ module Squared
|
|
692
738
|
.clear(pass: false)
|
693
739
|
end
|
694
740
|
when :push
|
695
|
-
if op.empty?
|
696
|
-
file = path + (if (spec = gemspec)
|
741
|
+
if op.empty? || (n = op.index(':'))
|
742
|
+
file = path + (if !n && (spec = gemspec)
|
697
743
|
"#{spec.name}-#{spec.version}.gem"
|
698
744
|
else
|
699
745
|
choice_index('Select a file', Dir.glob('*.gem', base: path), force: true)
|
700
746
|
end)
|
701
747
|
else
|
702
|
-
file = path + op.shift
|
748
|
+
file = path + op.shift.yield_self { |val| val.include?('.') ? val : "#{val}.gem" }
|
703
749
|
raise_error('gem not found', hint: file) unless file.exist?
|
704
750
|
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
705
751
|
end
|
@@ -815,14 +861,11 @@ module Squared
|
|
815
861
|
def gemspec
|
816
862
|
return @gemspec unless @gemspec.nil?
|
817
863
|
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
log.debug e
|
824
|
-
end
|
825
|
-
@gemspec ||= false
|
864
|
+
@gemspec = if (file = gemfile)
|
865
|
+
Gem::Specification.load(file.to_s) rescue false
|
866
|
+
else
|
867
|
+
false
|
868
|
+
end
|
826
869
|
end
|
827
870
|
|
828
871
|
def gemname
|
@@ -938,6 +981,7 @@ module Squared
|
|
938
981
|
else
|
939
982
|
op.clear
|
940
983
|
end
|
984
|
+
op
|
941
985
|
end
|
942
986
|
|
943
987
|
def ruby_session(*cmd, **kwargs)
|
@@ -979,27 +1023,10 @@ module Squared
|
|
979
1023
|
session_output('rake', *cmd, **kwargs)
|
980
1024
|
end
|
981
1025
|
|
982
|
-
def read_rakefile
|
983
|
-
@read_rakefile ||= [].tap do |ret|
|
984
|
-
opt = rakepwd
|
985
|
-
pwd_set(pass: !opt.nil?) do
|
986
|
-
IO.popen(rake_output(opt, '-AT').to_s).each do |line|
|
987
|
-
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
988
|
-
|
989
|
-
ret << [$1, $2]
|
990
|
-
end
|
991
|
-
end
|
992
|
-
end
|
993
|
-
end
|
994
|
-
|
995
1026
|
def preopts
|
996
1027
|
verbosetype > 1 && !session_arg?('quiet') ? ['--verbose'] : []
|
997
1028
|
end
|
998
1029
|
|
999
|
-
def gemdir?
|
1000
|
-
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1001
|
-
end
|
1002
|
-
|
1003
1030
|
def variables
|
1004
1031
|
(super + %i[version autodetect]).freeze
|
1005
1032
|
end
|
@@ -1018,6 +1045,19 @@ module Squared
|
|
1018
1045
|
quote_option 'C', path
|
1019
1046
|
end
|
1020
1047
|
|
1048
|
+
def raketasks
|
1049
|
+
@raketasks ||= [].tap do |ret|
|
1050
|
+
opt = rakepwd
|
1051
|
+
pwd_set(pass: !opt.nil?) do
|
1052
|
+
IO.popen(rake_output(opt, '-AT').to_s).each do |line|
|
1053
|
+
next unless line =~ /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/
|
1054
|
+
|
1055
|
+
ret << [$1, $2]
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
end
|
1060
|
+
|
1021
1061
|
def gempwd
|
1022
1062
|
return unless !pwd? && semgte?(Gem::VERSION, '3.4.2')
|
1023
1063
|
|
@@ -1045,6 +1085,10 @@ module Squared
|
|
1045
1085
|
def gempath(val = version)
|
1046
1086
|
File.join('gems', "#{gemname}-#{val}")
|
1047
1087
|
end
|
1088
|
+
|
1089
|
+
def gemdir?
|
1090
|
+
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1091
|
+
end
|
1048
1092
|
end
|
1049
1093
|
|
1050
1094
|
Application.implement Ruby
|
@@ -10,6 +10,9 @@ module Squared
|
|
10
10
|
include Common::Shell
|
11
11
|
extend Forwardable
|
12
12
|
|
13
|
+
OPT_VALUE = /\A([^=]+)=(.+)\z/
|
14
|
+
private_constant :OPT_VALUE
|
15
|
+
|
13
16
|
class << self
|
14
17
|
include Common::Format
|
15
18
|
include Shell
|
@@ -74,7 +77,7 @@ module Squared
|
|
74
77
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
75
78
|
:merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
76
79
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
77
|
-
:pop, :push, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
80
|
+
:pop, :push, :concat, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
78
81
|
|
79
82
|
def_delegator :@extras, :delete, :remove
|
80
83
|
def_delegator :@extras, :delete_if, :remove_if
|
@@ -164,7 +167,7 @@ module Squared
|
|
164
167
|
elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
|
165
168
|
add "--no-#{name}"
|
166
169
|
else
|
167
|
-
if opt =~
|
170
|
+
if opt =~ OPT_VALUE
|
168
171
|
key = $1
|
169
172
|
val = $2
|
170
173
|
merge = m.include?(key)
|
@@ -209,6 +212,22 @@ module Squared
|
|
209
212
|
self
|
210
213
|
end
|
211
214
|
|
215
|
+
def uniq(list)
|
216
|
+
items = map { |val| nameonly(val) }
|
217
|
+
list.reject do |val|
|
218
|
+
next true if items.include?(s = nameonly(val))
|
219
|
+
|
220
|
+
pat = /\A#{s = fill_option(s)}(?:#{s.start_with?('--') ? '[= ]' : '.*'}|\z)/
|
221
|
+
any? { |opt| opt.match?(pat) }
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def uniq!(list)
|
226
|
+
n = size
|
227
|
+
concat uniq(list)
|
228
|
+
extras if size > n
|
229
|
+
end
|
230
|
+
|
212
231
|
def clear(opts = nil, errors: false, **kwargs)
|
213
232
|
styles = project.theme[:inline] if project
|
214
233
|
if !opts
|
@@ -275,7 +294,7 @@ module Squared
|
|
275
294
|
unless found.empty?
|
276
295
|
add '--' if delim
|
277
296
|
extras.clear
|
278
|
-
|
297
|
+
concat other
|
279
298
|
if path
|
280
299
|
found.each { |val| add_path(val) }
|
281
300
|
else
|
@@ -285,6 +304,24 @@ module Squared
|
|
285
304
|
self
|
286
305
|
end
|
287
306
|
|
307
|
+
def append?(key, val = nil, type: nil, **kwargs)
|
308
|
+
return false if arg?(key)
|
309
|
+
|
310
|
+
val = yield self if block_given?
|
311
|
+
return false unless val
|
312
|
+
|
313
|
+
type ||= :quote if kwargs.empty?
|
314
|
+
op << case type
|
315
|
+
when :quote
|
316
|
+
quote_option(key, val)
|
317
|
+
when :basic
|
318
|
+
basic_option(key, val)
|
319
|
+
else
|
320
|
+
shell_option(key, val, **kwargs)
|
321
|
+
end
|
322
|
+
true
|
323
|
+
end
|
324
|
+
|
288
325
|
def reset(errors: false)
|
289
326
|
extras.clear
|
290
327
|
clear(errors: true) if errors
|
@@ -294,6 +331,12 @@ module Squared
|
|
294
331
|
def arg?(*args, **kwargs)
|
295
332
|
OptionPartition.arg?(target, *args, **kwargs)
|
296
333
|
end
|
334
|
+
|
335
|
+
private
|
336
|
+
|
337
|
+
def nameonly(val)
|
338
|
+
val[OPT_VALUE, 1] || val
|
339
|
+
end
|
297
340
|
end
|
298
341
|
|
299
342
|
class JoinSet < Set
|
@@ -113,16 +113,17 @@ module Squared
|
|
113
113
|
def __repo__(**kwargs)
|
114
114
|
kwargs.delete(:parallel) if env('REPO_SYNC', ignore: '0')
|
115
115
|
|
116
|
-
namespace
|
116
|
+
namespace task_name('repo') do |ns|
|
117
117
|
path = ns.scope.path
|
118
118
|
branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
|
119
119
|
target = branch || manifest
|
120
120
|
cmd = nil
|
121
121
|
stage = nil
|
122
|
+
opts = %w[force rebase detach submodules fail no-update gc]
|
122
123
|
newline = ARGV.any?(/^repo:/)
|
123
124
|
desc = lambda do |val, alt = nil|
|
124
125
|
if (ver = branch || alt)
|
125
|
-
val = val.sub('{0}', '
|
126
|
+
val = val.sub('{0}', "opts*=#{opts.join(',')}")
|
126
127
|
task_desc(path, val, ver)
|
127
128
|
else
|
128
129
|
task_desc 'inactive'
|
@@ -130,7 +131,7 @@ module Squared
|
|
130
131
|
end
|
131
132
|
|
132
133
|
desc.call('all[{0}]')
|
133
|
-
task 'all'
|
134
|
+
task 'all' do |_, args|
|
134
135
|
cmd ||= repo_opts args
|
135
136
|
stage ||= 'all'
|
136
137
|
ns['sync'].invoke
|
@@ -156,26 +157,44 @@ module Squared
|
|
156
157
|
end
|
157
158
|
end
|
158
159
|
|
159
|
-
desc.call("init[manifest?=#{target},{0}]", target)
|
160
|
-
task 'init'
|
160
|
+
desc.call("init[manifest?=#{target},groups?,{0}]", target)
|
161
|
+
task 'init' do |_, args|
|
162
|
+
args = args.to_a
|
163
|
+
u = env('REPO_URL') || manifest_url
|
164
|
+
m = args.first && !opts.include?(args.first) ? args.shift : target
|
165
|
+
g = case (g = env('REPO_GROUPS'))
|
166
|
+
when '0', 'false'
|
167
|
+
nil
|
168
|
+
else
|
169
|
+
g || (args.first && !opts.include?(args.first) ? args.shift : nil)
|
170
|
+
end
|
161
171
|
cmd = repo_opts args
|
172
|
+
s = case (s = env('REPO_SUBMODULES'))
|
173
|
+
when '0', 'false'
|
174
|
+
false
|
175
|
+
else
|
176
|
+
s ? true : cmd.include?('--fetch-submodules')
|
177
|
+
end
|
162
178
|
stage = 'init'
|
163
179
|
puts if newline
|
164
|
-
|
165
|
-
|
180
|
+
args = ["-u #{u}", "-m #{m}.xml"]
|
181
|
+
args << "-g #{g}" if g
|
182
|
+
args << '--submodules' if s
|
183
|
+
Common::System.shell("#{repo_bin} init #{args.join(' ')}", chdir: root)
|
166
184
|
next if env('REPO_STAGE', equals: '0')
|
167
185
|
|
168
186
|
ns['all'].invoke
|
169
187
|
end
|
170
188
|
|
171
189
|
desc.call('sync[{0}]')
|
172
|
-
task 'sync'
|
190
|
+
task 'sync' do |t, args|
|
173
191
|
raise_error 'repo not initialized' unless branch || stage == 'init'
|
174
192
|
cmd ||= repo_opts args
|
175
193
|
cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
|
176
194
|
puts unless !newline || stage == 'init'
|
177
195
|
begin
|
178
|
-
Common::System.shell("
|
196
|
+
Common::System.shell("#{repo_bin} sync #{cmd.join(' ')}", chdir: root,
|
197
|
+
exception: cmd.include?('--fail-fast'))
|
179
198
|
rescue Errno::ENOENT => e
|
180
199
|
emphasize(e, title: root)
|
181
200
|
raise
|
@@ -210,10 +229,10 @@ module Squared
|
|
210
229
|
case val
|
211
230
|
when 'force'
|
212
231
|
ret << '--force-checkout'
|
213
|
-
when 'rebase'
|
214
|
-
ret <<
|
215
|
-
when '
|
216
|
-
ret << '--
|
232
|
+
when 'rebase', 'detach'
|
233
|
+
ret << "--#{val}"
|
234
|
+
when 'submodules'
|
235
|
+
ret << '--fetch-submodules'
|
217
236
|
when 'fail'
|
218
237
|
ret << '--fail-fast'
|
219
238
|
when 'no-update'
|
@@ -225,6 +244,10 @@ module Squared
|
|
225
244
|
ret
|
226
245
|
end
|
227
246
|
|
247
|
+
def repo_bin
|
248
|
+
Common::System.shell_bin('repo')
|
249
|
+
end
|
250
|
+
|
228
251
|
def repo?
|
229
252
|
!manifest_url.nil? && (repo_install? || @repo_override == true)
|
230
253
|
end
|
data/squared.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = %q{Rake task generator for managing multi-language workspaces.}
|
12
12
|
spec.description = %q{Rake task generator for managing multi-language workspaces.}
|
13
|
-
spec.homepage = "https://github.com/anpham6/squared"
|
13
|
+
spec.homepage = "https://github.com/anpham6/squared-ruby"
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
15
15
|
spec.licenses = ["BSD-3-Clause"]
|
16
16
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.metadata["documentation_uri"] = "https://squared.readthedocs.io"
|
20
20
|
|
21
21
|
spec.files = Dir["lib/**/*"] +
|
22
|
-
%w[CHANGELOG.md LICENSE README.md
|
22
|
+
%w[CHANGELOG.md LICENSE README.md squared.gemspec]
|
23
23
|
spec.bindir = "exe"
|
24
24
|
spec.executables = []
|
25
25
|
spec.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
@@ -75,7 +75,6 @@ files:
|
|
75
75
|
- CHANGELOG.md
|
76
76
|
- LICENSE
|
77
77
|
- README.md
|
78
|
-
- README.ruby.md
|
79
78
|
- lib/squared.rb
|
80
79
|
- lib/squared/app.rb
|
81
80
|
- lib/squared/common.rb
|
@@ -104,12 +103,12 @@ files:
|
|
104
103
|
- lib/squared/workspace/support/base.rb
|
105
104
|
- lib/squared/workspace/support/data.rb
|
106
105
|
- squared.gemspec
|
107
|
-
homepage: https://github.com/anpham6/squared
|
106
|
+
homepage: https://github.com/anpham6/squared-ruby
|
108
107
|
licenses:
|
109
108
|
- BSD-3-Clause
|
110
109
|
metadata:
|
111
|
-
homepage_uri: https://github.com/anpham6/squared
|
112
|
-
source_code_uri: https://github.com/anpham6/squared
|
110
|
+
homepage_uri: https://github.com/anpham6/squared-ruby
|
111
|
+
source_code_uri: https://github.com/anpham6/squared-ruby
|
113
112
|
documentation_uri: https://squared.readthedocs.io
|
114
113
|
rdoc_options: []
|
115
114
|
require_paths:
|
@@ -125,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
124
|
- !ruby/object:Gem::Version
|
126
125
|
version: '0'
|
127
126
|
requirements: []
|
128
|
-
rubygems_version: 3.6.
|
127
|
+
rubygems_version: 3.6.9
|
129
128
|
specification_version: 4
|
130
129
|
summary: Rake task generator for managing multi-language workspaces.
|
131
130
|
test_files: []
|