squared 0.4.17 → 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 +99 -58
- data/README.md +648 -1286
- 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 +1 -1
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +17 -7
- data/lib/squared/workspace/project/base.rb +24 -19
- data/lib/squared/workspace/project/docker.rb +2 -2
- data/lib/squared/workspace/project/git.rb +123 -109
- data/lib/squared/workspace/project/node.rb +22 -19
- data/lib/squared/workspace/project/python.rb +2 -2
- data/lib/squared/workspace/project/ruby.rb +50 -35
- data/lib/squared/workspace/project/support/class.rb +46 -3
- data/lib/squared/workspace/repo.rb +36 -13
- data/squared.gemspec +2 -2
- metadata +4 -5
- data/README.ruby.md +0 -725
@@ -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
|
@@ -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?
|
@@ -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
|
|
@@ -815,14 +830,11 @@ module Squared
|
|
815
830
|
def gemspec
|
816
831
|
return @gemspec unless @gemspec.nil?
|
817
832
|
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
log.debug e
|
824
|
-
end
|
825
|
-
@gemspec ||= false
|
833
|
+
@gemspec = if (file = gemfile)
|
834
|
+
Gem::Specification.load(file.to_s) rescue false
|
835
|
+
else
|
836
|
+
false
|
837
|
+
end
|
826
838
|
end
|
827
839
|
|
828
840
|
def gemname
|
@@ -938,6 +950,7 @@ module Squared
|
|
938
950
|
else
|
939
951
|
op.clear
|
940
952
|
end
|
953
|
+
op
|
941
954
|
end
|
942
955
|
|
943
956
|
def ruby_session(*cmd, **kwargs)
|
@@ -979,27 +992,10 @@ module Squared
|
|
979
992
|
session_output('rake', *cmd, **kwargs)
|
980
993
|
end
|
981
994
|
|
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
995
|
def preopts
|
996
996
|
verbosetype > 1 && !session_arg?('quiet') ? ['--verbose'] : []
|
997
997
|
end
|
998
998
|
|
999
|
-
def gemdir?
|
1000
|
-
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1001
|
-
end
|
1002
|
-
|
1003
999
|
def variables
|
1004
1000
|
(super + %i[version autodetect]).freeze
|
1005
1001
|
end
|
@@ -1017,6 +1013,19 @@ module Squared
|
|
1017
1013
|
quote_option 'C', path
|
1018
1014
|
end
|
1019
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
|
+
|
1020
1029
|
def gempwd
|
1021
1030
|
return unless !pwd? && semgte?(Gem::VERSION, '3.4.2')
|
1022
1031
|
|
@@ -1044,6 +1053,12 @@ module Squared
|
|
1044
1053
|
def gempath(val = version)
|
1045
1054
|
File.join('gems', "#{gemname}-#{val}")
|
1046
1055
|
end
|
1056
|
+
|
1057
|
+
def gemdir?
|
1058
|
+
!@gemdir.nil? && @gemdir.exist? && !@gemdir.empty?
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
alias read_rakefile raketasks
|
1047
1062
|
end
|
1048
1063
|
|
1049
1064
|
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
|
@@ -73,7 +76,7 @@ module Squared
|
|
73
76
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
74
77
|
:merge, :delete, :delete?, :delete_if, :grep, :grep_v, :inspect, :to_a, :to_s
|
75
78
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
76
|
-
:pop, :push, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
79
|
+
:pop, :push, :concat, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
77
80
|
|
78
81
|
def_delegator :@extras, :delete, :remove
|
79
82
|
def_delegator :@extras, :delete_if, :remove_if
|
@@ -163,7 +166,7 @@ module Squared
|
|
163
166
|
elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
|
164
167
|
add "--no-#{name}"
|
165
168
|
else
|
166
|
-
if opt =~
|
169
|
+
if opt =~ OPT_VALUE
|
167
170
|
key = $1
|
168
171
|
val = $2
|
169
172
|
merge = m.include?(key)
|
@@ -208,6 +211,22 @@ module Squared
|
|
208
211
|
self
|
209
212
|
end
|
210
213
|
|
214
|
+
def uniq(list)
|
215
|
+
items = map { |val| nameonly(val) }
|
216
|
+
list.reject do |val|
|
217
|
+
next true if items.include?(s = nameonly(val))
|
218
|
+
|
219
|
+
pat = /\A#{s = fill_option(s)}(?:#{s.start_with?('--') ? '[= ]' : '.*'}|\z)/
|
220
|
+
any? { |opt| opt.match?(pat) }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def uniq!(list)
|
225
|
+
n = size
|
226
|
+
concat uniq(list)
|
227
|
+
extras if size > n
|
228
|
+
end
|
229
|
+
|
211
230
|
def clear(opts = nil, errors: false, **kwargs)
|
212
231
|
styles = project.theme[:inline] if project
|
213
232
|
if !opts
|
@@ -274,7 +293,7 @@ module Squared
|
|
274
293
|
unless found.empty?
|
275
294
|
add '--' if delim
|
276
295
|
extras.clear
|
277
|
-
|
296
|
+
concat other
|
278
297
|
if path
|
279
298
|
found.each { |val| add_path(val) }
|
280
299
|
else
|
@@ -284,6 +303,24 @@ module Squared
|
|
284
303
|
self
|
285
304
|
end
|
286
305
|
|
306
|
+
def append?(key, val = nil, type: nil, **kwargs)
|
307
|
+
return false if arg?(key)
|
308
|
+
|
309
|
+
val = yield self if block_given?
|
310
|
+
return false unless val
|
311
|
+
|
312
|
+
type ||= :quote if kwargs.empty?
|
313
|
+
op << case type
|
314
|
+
when :quote
|
315
|
+
quote_option(key, val)
|
316
|
+
when :basic
|
317
|
+
basic_option(key, val)
|
318
|
+
else
|
319
|
+
shell_option(key, val, **kwargs)
|
320
|
+
end
|
321
|
+
true
|
322
|
+
end
|
323
|
+
|
287
324
|
def reset(errors: false)
|
288
325
|
extras.clear
|
289
326
|
clear(errors: true) if errors
|
@@ -293,6 +330,12 @@ module Squared
|
|
293
330
|
def arg?(*args, **kwargs)
|
294
331
|
OptionPartition.arg?(target, *args, **kwargs)
|
295
332
|
end
|
333
|
+
|
334
|
+
private
|
335
|
+
|
336
|
+
def nameonly(val)
|
337
|
+
val[OPT_VALUE, 1] || val
|
338
|
+
end
|
296
339
|
end
|
297
340
|
end
|
298
341
|
end
|
@@ -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.index { |val| val.start_with?('repo:') }.to_i > 0
|
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::Shell.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.4.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.4.
|
4
|
+
version: 0.4.18
|
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
|
@@ -105,12 +104,12 @@ files:
|
|
105
104
|
- lib/squared/workspace/support/base.rb
|
106
105
|
- lib/squared/workspace/support/data.rb
|
107
106
|
- squared.gemspec
|
108
|
-
homepage: https://github.com/anpham6/squared
|
107
|
+
homepage: https://github.com/anpham6/squared-ruby
|
109
108
|
licenses:
|
110
109
|
- BSD-3-Clause
|
111
110
|
metadata:
|
112
|
-
homepage_uri: https://github.com/anpham6/squared
|
113
|
-
source_code_uri: https://github.com/anpham6/squared
|
111
|
+
homepage_uri: https://github.com/anpham6/squared-ruby
|
112
|
+
source_code_uri: https://github.com/anpham6/squared-ruby
|
114
113
|
documentation_uri: https://squared.readthedocs.io
|
115
114
|
rdoc_options: []
|
116
115
|
require_paths:
|