squared 0.0.11 → 0.0.12
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/README.ruby.md +55 -2
- data/lib/squared/common/base.rb +5 -3
- data/lib/squared/common/class.rb +10 -2
- data/lib/squared/common/format.rb +29 -18
- data/lib/squared/common/prompt.rb +2 -4
- data/lib/squared/common/shell.rb +4 -3
- data/lib/squared/common/system.rb +12 -14
- data/lib/squared/common/utils.rb +29 -3
- data/lib/squared/common.rb +0 -4
- data/lib/squared/config.rb +35 -32
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +51 -45
- data/lib/squared/workspace/project/base.rb +248 -83
- data/lib/squared/workspace/project/git.rb +38 -44
- data/lib/squared/workspace/project/node.rb +57 -96
- data/lib/squared/workspace/project/python.rb +16 -19
- data/lib/squared/workspace/project/ruby.rb +69 -48
- data/lib/squared/workspace/repo.rb +12 -11
- data/lib/squared/workspace/series.rb +15 -14
- data/lib/squared/workspace.rb +1 -1
- metadata +2 -3
- data/lib/squared/common/task.rb +0 -25
@@ -15,12 +15,15 @@ module Squared
|
|
15
15
|
class << self
|
16
16
|
def populate(*); end
|
17
17
|
def batchargs(*); end
|
18
|
-
def aliasargs(*); end
|
19
18
|
|
20
19
|
def tasks
|
21
20
|
%i[outdated].freeze
|
22
21
|
end
|
23
22
|
|
23
|
+
def bannerargs
|
24
|
+
%i[dependfile].freeze
|
25
|
+
end
|
26
|
+
|
24
27
|
def config?(val)
|
25
28
|
return false unless (val = as_path(val))
|
26
29
|
|
@@ -38,8 +41,6 @@ module Squared
|
|
38
41
|
rake: nil
|
39
42
|
}.freeze
|
40
43
|
|
41
|
-
attr_reader :gemfile
|
42
|
-
|
43
44
|
def initialize(*, version: nil, autodetect: false, **kwargs)
|
44
45
|
super
|
45
46
|
if @pass.include?(Ruby.ref)
|
@@ -51,8 +52,8 @@ module Squared
|
|
51
52
|
end
|
52
53
|
@version = env('BUILD', version, suffix: 'VERSION')
|
53
54
|
@autodetect = autodetect
|
54
|
-
|
55
|
-
@
|
55
|
+
@dependindex = GEMFILE.index { |file| basepath(file).exist? }
|
56
|
+
@dependfile = basepath(GEMFILE[@dependindex || 0])
|
56
57
|
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
57
58
|
|
58
59
|
begin
|
@@ -89,9 +90,25 @@ module Squared
|
|
89
90
|
when :rake
|
90
91
|
next unless rakefile
|
91
92
|
|
92
|
-
desc format_desc(action, nil, 'command*')
|
93
|
+
desc format_desc(action, nil, 'command*|^index,args*|#,pattern*')
|
93
94
|
task action, [:command] do |_, args|
|
94
|
-
|
95
|
+
if args.command == '#'
|
96
|
+
format_list(read_rakefile, 'rake[^N]', 'tasks', grep: args.extras, from: rakefile.to_s,
|
97
|
+
each: ->(val) { val[0] + val[1].to_s })
|
98
|
+
elsif (data = indexdata(args.command))
|
99
|
+
n, opts = data
|
100
|
+
list = read_rakefile
|
101
|
+
if (item = list[n - 1])
|
102
|
+
cmd = opts ? "#{opts} #{item.first}" : item.first
|
103
|
+
elsif exception
|
104
|
+
indexerror n, list
|
105
|
+
else
|
106
|
+
next log.warn "rake task #{n} of #{list.size} (out of range)"
|
107
|
+
end
|
108
|
+
rake(args.extras.empty? ? cmd : "#{cmd}[#{args.extras.join(',')}]")
|
109
|
+
else
|
110
|
+
rake(*args.to_a)
|
111
|
+
end
|
95
112
|
end
|
96
113
|
end
|
97
114
|
else
|
@@ -103,16 +120,14 @@ module Squared
|
|
103
120
|
when :gem
|
104
121
|
desc format_desc(action, flag, 'name+')
|
105
122
|
task flag, [:name] do |_, args|
|
106
|
-
|
107
|
-
|
108
|
-
depend(flag, opts: name)
|
123
|
+
opts = guard_params(action, flag, args: args.to_a)
|
124
|
+
depend(flag, opts: opts)
|
109
125
|
end
|
110
126
|
when :with, :without
|
111
127
|
desc format_desc(action, flag, 'group+')
|
112
128
|
task flag, [:group] do |_, args|
|
113
|
-
|
114
|
-
|
115
|
-
depend(flag, opts: group)
|
129
|
+
opts = guard_params(action, flag, args: args.to_a)
|
130
|
+
depend(flag, opts: opts)
|
116
131
|
end
|
117
132
|
else
|
118
133
|
desc format_desc(action, flag, OPT_INSTALL)
|
@@ -130,9 +145,8 @@ module Squared
|
|
130
145
|
when :gem
|
131
146
|
desc format_desc(action, flag, 'name+')
|
132
147
|
task flag, [:name] do |_, args|
|
133
|
-
|
134
|
-
|
135
|
-
pristine(flag, opts: name)
|
148
|
+
opts = guard_params(action, flag, args: args.to_a)
|
149
|
+
pristine(flag, opts: opts)
|
136
150
|
end
|
137
151
|
when :all
|
138
152
|
desc format_desc(action, flag, 'skip*')
|
@@ -142,8 +156,8 @@ module Squared
|
|
142
156
|
when :version
|
143
157
|
desc format_desc(action, flag, 'version?')
|
144
158
|
task flag, [:version] do |_, args|
|
145
|
-
guard_params(action, flag, args: args, key: :version)
|
146
|
-
pristine(flag, version:
|
159
|
+
version = guard_params(action, flag, args: args, key: :version)
|
160
|
+
pristine(flag, version: version)
|
147
161
|
end
|
148
162
|
end
|
149
163
|
end
|
@@ -192,7 +206,7 @@ module Squared
|
|
192
206
|
end
|
193
207
|
end
|
194
208
|
|
195
|
-
def copy(from: 'lib', glob:
|
209
|
+
def copy(from: 'lib', glob: nil, into: @gemdir, override: false)
|
196
210
|
if @copy && !override
|
197
211
|
return super if runnable?(@copy)
|
198
212
|
|
@@ -204,11 +218,11 @@ module Squared
|
|
204
218
|
|
205
219
|
dest = Pathname.new(into).realpath
|
206
220
|
print_item unless @output[0]
|
207
|
-
glob = as_a(glob)
|
221
|
+
glob = as_a(glob || '**/*')
|
208
222
|
as_a(from).each_with_index do |val, i|
|
209
|
-
a =
|
223
|
+
a = basepath(val)
|
210
224
|
b = dest.join(val)
|
211
|
-
c = glob[i] ||
|
225
|
+
c = glob[i] || glob[0]
|
212
226
|
log.info "cp #{a.join(c)} #{b}"
|
213
227
|
copy_d(a, b, glob: c, verbose: verbose)
|
214
228
|
end
|
@@ -245,7 +259,7 @@ module Squared
|
|
245
259
|
end
|
246
260
|
minor_set = -> { styles[0] = cur[2] == lat[2] ? :yellow : :green }
|
247
261
|
if data.empty?
|
248
|
-
semmajor(cur, lat) ? major_set.() : minor_set.()
|
262
|
+
semmajor?(cur, lat) ? major_set.() : minor_set.()
|
249
263
|
else
|
250
264
|
data.each do |val|
|
251
265
|
break unless (req = /(>=?|=|~>|!=|<=?) (#{Regexp.escape(val.join)})/.match(line))
|
@@ -253,10 +267,10 @@ module Squared
|
|
253
267
|
v = semver(val).join
|
254
268
|
case req[1]
|
255
269
|
when '>', '>='
|
256
|
-
semmajor(cur, lat) ? major_set.() : minor_set.()
|
270
|
+
semmajor?(cur, lat) ? major_set.() : minor_set.()
|
257
271
|
when '<', '<='
|
258
272
|
if c <= v
|
259
|
-
if semmajor(cur, lat)
|
273
|
+
if semmajor?(cur, lat)
|
260
274
|
major_set.()
|
261
275
|
else
|
262
276
|
styles[0] = :yellow
|
@@ -269,9 +283,9 @@ module Squared
|
|
269
283
|
styles[1] = :bold
|
270
284
|
end
|
271
285
|
when '~>'
|
272
|
-
if c < v && cur[0] == val[0] && !semmajor(cur, val)
|
286
|
+
if c < v && cur[0] == val[0] && !semmajor?(cur, val)
|
273
287
|
styles[0] = :yellow
|
274
|
-
elsif semmajor(val, lat)
|
288
|
+
elsif semmajor?(val, lat)
|
275
289
|
styles[1] = :underline
|
276
290
|
else
|
277
291
|
styles[1] = :bold
|
@@ -307,7 +321,7 @@ module Squared
|
|
307
321
|
end
|
308
322
|
if found > 0
|
309
323
|
begin
|
310
|
-
if major == 0 && (data = /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/.match(
|
324
|
+
if major == 0 && (data = /\b(?:source\s+(["'])(.+?)\1|remote:\s+(\S+))/.match(dependfile.read))
|
311
325
|
status = (data[2] || data[3]).chomp('/')
|
312
326
|
right = true
|
313
327
|
end
|
@@ -349,28 +363,13 @@ module Squared
|
|
349
363
|
end
|
350
364
|
|
351
365
|
def rake(*cmd)
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
def rakefile
|
356
|
-
file = ::Rake::Application::DEFAULT_RAKEFILES.find { |val| base_path(val).exist? }
|
357
|
-
base_path(file) if file
|
358
|
-
end
|
359
|
-
|
360
|
-
def variable_set(key, *val, **)
|
361
|
-
case key
|
362
|
-
when :gemfile
|
363
|
-
@gemfile = base_path(val.first)
|
366
|
+
if cmd.empty?
|
367
|
+
run_s 'rake'
|
364
368
|
else
|
365
|
-
|
369
|
+
run_s(*cmd.map { |val| "rake #{val}" }, banner: false)
|
366
370
|
end
|
367
371
|
end
|
368
372
|
|
369
|
-
def variables
|
370
|
-
ret = super + VAR_SET
|
371
|
-
ret.freeze
|
372
|
-
end
|
373
|
-
|
374
373
|
def depend?
|
375
374
|
@depend != false && (!@depend.nil? || outdated?)
|
376
375
|
end
|
@@ -410,11 +409,16 @@ module Squared
|
|
410
409
|
end
|
411
410
|
|
412
411
|
def outdated?
|
413
|
-
|
412
|
+
dependtype > 0
|
414
413
|
end
|
415
414
|
|
416
415
|
private
|
417
416
|
|
417
|
+
def variables
|
418
|
+
ret = super + VAR_SET
|
419
|
+
ret.freeze
|
420
|
+
end
|
421
|
+
|
418
422
|
def run_rb(sync: true)
|
419
423
|
run(sync: sync, banner: !@session.include?('--quiet'))
|
420
424
|
end
|
@@ -437,7 +441,7 @@ module Squared
|
|
437
441
|
def gem_session(*cmd)
|
438
442
|
ret = session('gem', *cmd)
|
439
443
|
if (val = option('config-file', ignore: false))
|
440
|
-
ret << "--config-file=#{shell_escape(
|
444
|
+
ret << "--config-file=#{shell_escape(basepath(val), quote: true)}"
|
441
445
|
end
|
442
446
|
ret << '--norc' if option('norc')
|
443
447
|
ret
|
@@ -449,6 +453,23 @@ module Squared
|
|
449
453
|
@session
|
450
454
|
end
|
451
455
|
|
456
|
+
def read_rakefile
|
457
|
+
return @rakelist if @rakelist
|
458
|
+
|
459
|
+
ret = []
|
460
|
+
IO.popen("rake -C #{shell_quote(path)} -AT").each do |line|
|
461
|
+
next unless (data = /^rake ((?:[^\[: ]+:?)+)(\[[^\]]+\])?/.match(line))
|
462
|
+
|
463
|
+
ret << [data[1], data[2]]
|
464
|
+
end
|
465
|
+
@rakelist = ret
|
466
|
+
end
|
467
|
+
|
468
|
+
def rakefile
|
469
|
+
file = ::Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
|
470
|
+
basepath(file) if file
|
471
|
+
end
|
472
|
+
|
452
473
|
def gempath
|
453
474
|
File.join('gems', "#{project}-#{@version}")
|
454
475
|
end
|
@@ -5,11 +5,7 @@ require 'rexml/document'
|
|
5
5
|
module Squared
|
6
6
|
module Workspace
|
7
7
|
module Repo
|
8
|
-
include Common
|
9
|
-
include Format
|
10
|
-
include Prompt
|
11
|
-
include System
|
12
|
-
include Utils
|
8
|
+
include Common::Format
|
13
9
|
|
14
10
|
class << self
|
15
11
|
def read_manifest(path)
|
@@ -147,7 +143,7 @@ module Squared
|
|
147
143
|
message(@prefix, 'repo', val.sub('{0}', 'opts*=force,rebase,detach,gc,no-update,no-fail'), ver, empty: true)
|
148
144
|
end
|
149
145
|
|
150
|
-
namespace task_name('repo') do |repo|
|
146
|
+
namespace(name = task_name('repo')) do |repo|
|
151
147
|
desc status.('all[{0}]')
|
152
148
|
task 'all', [:opts] do |_, args|
|
153
149
|
parse_opts.(args)
|
@@ -161,10 +157,10 @@ module Squared
|
|
161
157
|
end
|
162
158
|
.each_value do |proj|
|
163
159
|
proj.build(sync: true)
|
164
|
-
next unless proj.
|
160
|
+
next unless proj.dev? && proj.copy?
|
165
161
|
|
166
|
-
if (ws = proj.workspace).task_defined?(target = ws.task_name(proj.name, 'copy'))
|
167
|
-
|
162
|
+
if (ws = proj.workspace).task_defined?(target = ws.task_name(task_join(proj.name, 'copy')))
|
163
|
+
task_invoke(target, **ws.invokeargs)
|
168
164
|
else
|
169
165
|
proj.copy(sync: true)
|
170
166
|
end
|
@@ -190,20 +186,25 @@ module Squared
|
|
190
186
|
cmd << '--fail-fast' if failfast
|
191
187
|
puts if newline && stage != 'init'
|
192
188
|
begin
|
193
|
-
shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
|
189
|
+
Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
|
194
190
|
rescue StandardError => e
|
195
191
|
emphasize(e, title: "rake stash #{task_name(task_join('repo', stage || 'sync'))}")
|
196
192
|
raise
|
197
193
|
end
|
198
194
|
end
|
199
195
|
end
|
196
|
+
series.sync.push(
|
197
|
+
task_join(name, 'all'),
|
198
|
+
task_join(name, 'init'),
|
199
|
+
task_join(name, 'sync')
|
200
|
+
)
|
200
201
|
end
|
201
202
|
|
202
203
|
def repo_confirm
|
203
204
|
return false unless root.directory?
|
204
205
|
|
205
206
|
path = sub_style(root, styles: theme[:inline])
|
206
|
-
@repo_override = confirm(
|
207
|
+
@repo_override = Common::Prompt.confirm(
|
207
208
|
"#{log_title(:warn)} \"#{path}\" is not empty. Continue with installation? [y/N] ",
|
208
209
|
'N',
|
209
210
|
timeout: env('REPO_TIMEOUT', 15, ignore: '0')
|
@@ -8,10 +8,10 @@ module Squared
|
|
8
8
|
include ::Rake::DSL
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
-
TASK_BASE = %i[build depend doc test copy clean]
|
11
|
+
TASK_BASE = %i[build depend graph doc test copy clean]
|
12
12
|
TASK_BATCH = {}
|
13
13
|
TASK_EXTEND = {}
|
14
|
-
TASK_KEYS = TASK_BASE.dup
|
14
|
+
TASK_KEYS = TASK_BASE.dup + TASK_BATCH.keys
|
15
15
|
TASK_ALIAS = {}
|
16
16
|
TASK_NAME = {}
|
17
17
|
private_constant :TASK_BASE, :TASK_BATCH, :TASK_KEYS, :TASK_NAME, :TASK_EXTEND
|
@@ -22,23 +22,24 @@ module Squared
|
|
22
22
|
(TASK_EXTEND[task] ||= []).push(obj)
|
23
23
|
end
|
24
24
|
|
25
|
-
def batch(
|
25
|
+
def batch(*args, obj)
|
26
26
|
if obj.is_a?(::Hash)
|
27
27
|
obj.each do |key, val|
|
28
28
|
key_set key
|
29
29
|
data = TASK_BATCH[key] ||= {}
|
30
|
-
(data[ref] ||= []).concat(val)
|
30
|
+
args.each { |ref| (data[ref] ||= []).concat(val) }
|
31
31
|
end
|
32
|
-
elsif (data = TASK_BATCH[obj])
|
33
|
-
|
32
|
+
elsif (data = TASK_BATCH[obj])
|
33
|
+
args.each { |ref| data.delete(ref) }
|
34
|
+
TASK_KEYS.delete(obj) if data.empty?
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
def alias(ref, obj)
|
38
39
|
if obj.is_a?(::Hash)
|
39
40
|
obj.each { |key, val| (TASK_ALIAS[key] ||= {})[ref] = val }
|
40
|
-
|
41
|
-
|
41
|
+
else
|
42
|
+
TASK_ALIAS[obj]&.delete(ref)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -76,13 +77,13 @@ module Squared
|
|
76
77
|
|
77
78
|
def populate(proj)
|
78
79
|
group, parent, id = @session.values
|
80
|
+
ws = proj.workspace
|
79
81
|
@data.each do |key, items|
|
80
|
-
ws = proj.workspace
|
81
82
|
next if (tasks = ws.task_resolve(proj, key)).empty?
|
82
83
|
|
83
84
|
if (g = proj.group)
|
84
85
|
id << g
|
85
|
-
(group[:"#{key}:#{g}"] ||= []).
|
86
|
+
(group[:"#{key}:#{g}"] ||= []).concat(tasks)
|
86
87
|
else
|
87
88
|
items.concat(tasks)
|
88
89
|
end
|
@@ -90,10 +91,10 @@ module Squared
|
|
90
91
|
desc ws.task_name(t = ws.task_join(proj.name, key), desc: true)
|
91
92
|
task ws.task_name(t) => tasks
|
92
93
|
end
|
93
|
-
next unless (b = ws.find_base(proj)) && (
|
94
|
+
next unless (b = ws.find_base(proj)) && (n = b.ref.to_s) != g
|
94
95
|
|
95
|
-
id <<
|
96
|
-
(parent[:"#{key}:#{
|
96
|
+
id << n
|
97
|
+
(parent[:"#{key}:#{n}"] ||= []).concat(tasks)
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
@@ -170,7 +171,7 @@ module Squared
|
|
170
171
|
private
|
171
172
|
|
172
173
|
def already_invoked?(list, val)
|
173
|
-
return false
|
174
|
+
return false if val && !list.include?(val)
|
174
175
|
|
175
176
|
::Rake::Task.tasks.any? { |obj| obj.already_invoked && (val ? val == obj.name : list.include?(obj.name)) }
|
176
177
|
end
|
data/lib/squared/workspace.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -71,7 +71,6 @@ files:
|
|
71
71
|
- lib/squared/common/prompt.rb
|
72
72
|
- lib/squared/common/shell.rb
|
73
73
|
- lib/squared/common/system.rb
|
74
|
-
- lib/squared/common/task.rb
|
75
74
|
- lib/squared/common/utils.rb
|
76
75
|
- lib/squared/config.rb
|
77
76
|
- lib/squared/version.rb
|
data/lib/squared/common/task.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rake'
|
4
|
-
|
5
|
-
module Squared
|
6
|
-
module Common
|
7
|
-
module Task
|
8
|
-
module_function
|
9
|
-
|
10
|
-
def invoke(series, *args, exception: true, warning: true)
|
11
|
-
series = [series] unless series.is_a?(::Array)
|
12
|
-
series.each { |name| ::Rake::Task[name].invoke(*args) }
|
13
|
-
rescue StandardError => e
|
14
|
-
raise if exception
|
15
|
-
|
16
|
-
warn e if warning
|
17
|
-
end
|
18
|
-
|
19
|
-
def invoked?(*name)
|
20
|
-
val = name.size > 1 ? name.join(':') : name.first.to_s
|
21
|
-
::Rake::Task.tasks.any? { |obj| obj.already_invoked && obj.name == val }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|