squared 0.4.11 → 0.4.13
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 +76 -0
- data/README.md +3 -3
- data/README.ruby.md +68 -11
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/format.rb +8 -5
- data/lib/squared/common/shell.rb +14 -14
- data/lib/squared/common/system.rb +2 -2
- data/lib/squared/common/utils.rb +4 -8
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +154 -5
- data/lib/squared/workspace/project/base.rb +327 -161
- data/lib/squared/workspace/project/docker.rb +87 -47
- data/lib/squared/workspace/project/git.rb +62 -52
- data/lib/squared/workspace/project/node.rb +111 -59
- data/lib/squared/workspace/project/python.rb +143 -104
- data/lib/squared/workspace/project/ruby.rb +33 -22
- data/lib/squared/workspace/project/support/class.rb +6 -6
- data/lib/squared/workspace/project.rb +2 -7
- data/lib/squared/workspace/series.rb +34 -0
- data/lib/squared/workspace/support/data.rb +10 -0
- data/lib/squared/workspace/support.rb +3 -0
- data/lib/squared/workspace.rb +1 -0
- metadata +3 -1
@@ -100,9 +100,8 @@ module Squared
|
|
100
100
|
initialize_build(Ruby.ref, **kwargs)
|
101
101
|
initialize_env(**kwargs)
|
102
102
|
end
|
103
|
+
dependfile_set GEMFILE
|
103
104
|
@autodetect = autodetect
|
104
|
-
@dependindex = GEMFILE.index { |file| basepath(file).exist? }
|
105
|
-
@dependfile = @path + GEMFILE[@dependindex || 0]
|
106
105
|
return if !@output[0].nil? || !@copy.nil? || @version || @autodetect || (file = rakefile).nil?
|
107
106
|
|
108
107
|
begin
|
@@ -203,7 +202,7 @@ module Squared
|
|
203
202
|
gem!(flag, args, filter: filter)
|
204
203
|
end
|
205
204
|
when :build, :push, :exec
|
206
|
-
format_desc(action, flag, 'opts*', before: flag == :exec ? 'command
|
205
|
+
format_desc(action, flag, 'opts*', before: flag == :exec ? 'command,args*' : nil)
|
207
206
|
task flag do |_, args|
|
208
207
|
gem! flag, args.to_a
|
209
208
|
end
|
@@ -219,15 +218,20 @@ module Squared
|
|
219
218
|
when :file
|
220
219
|
format_desc action, flag, 'path,opts*,args*'
|
221
220
|
task flag, [:rb] do |_, args|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
221
|
+
file = args.rb
|
222
|
+
args = args.to_a.drop(1)
|
223
|
+
unless file && !file.include?('*')
|
224
|
+
values = ['Arguments']
|
225
|
+
values.unshift('Options') unless file
|
226
|
+
file, opts, extra = choice_index('Select a file', Dir.glob(file || '*.rb', base: path),
|
227
|
+
values: values, force: true, series: !args.include?('v'))
|
228
|
+
if file
|
229
|
+
extra = opts
|
230
|
+
else
|
231
|
+
args.concat(OptionPartition.strip(opts))
|
232
|
+
end
|
229
233
|
end
|
230
|
-
ruby(flag, args, file: file)
|
234
|
+
ruby(flag, args, file: file, args: extra)
|
231
235
|
end
|
232
236
|
when :script
|
233
237
|
format_desc action, flag, 'opts*,args*'
|
@@ -374,8 +378,7 @@ module Squared
|
|
374
378
|
found += 1
|
375
379
|
end
|
376
380
|
if theme[:current]
|
377
|
-
line = sub_style(line, styles: theme[:current], pat: /^(.+)(#{Regexp.escape(c)})(.+)$/,
|
378
|
-
index: 2)
|
381
|
+
line = sub_style(line, styles: theme[:current], pat: /^(.+)(#{Regexp.escape(c)})(.+)$/, index: 2)
|
379
382
|
end
|
380
383
|
line = sub_style(line, *colormap(styles), pat: /^((?:\S+\s+){2})(#{Regexp.escape(l)})(.*)$/,
|
381
384
|
index: 2)
|
@@ -428,7 +431,7 @@ module Squared
|
|
428
431
|
run_rb(from: :update)
|
429
432
|
end
|
430
433
|
|
431
|
-
def ruby(flag, opts = [], file: nil, command: nil)
|
434
|
+
def ruby(flag, opts = [], file: nil, command: nil, args: nil)
|
432
435
|
case flag
|
433
436
|
when :file, :script
|
434
437
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
@@ -437,9 +440,7 @@ module Squared
|
|
437
440
|
elsif command
|
438
441
|
op << quote_option('e', command, option: false)
|
439
442
|
end
|
440
|
-
if (args = ENV
|
441
|
-
op.extras << args
|
442
|
-
end
|
443
|
+
op.extras << args if (args = ENV.fetch('RUBY_ARGS', args))
|
443
444
|
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
444
445
|
when :version
|
445
446
|
pwd_set do
|
@@ -604,7 +605,7 @@ module Squared
|
|
604
605
|
g = a.ljust(d)
|
605
606
|
pat = [/^([^.]+\.)([^.]+\..+)$/, /^([^.]+\.[^.]+\.)(.+)$/]
|
606
607
|
pre = b.start_with?('0.')
|
607
|
-
latest = [theme[:
|
608
|
+
latest = [theme[:latest]]
|
608
609
|
case item.last
|
609
610
|
when 1
|
610
611
|
case filter
|
@@ -698,7 +699,11 @@ module Squared
|
|
698
699
|
end
|
699
700
|
when :exec
|
700
701
|
raise_error('missing command', hint: flag) if op.empty?
|
701
|
-
op << project
|
702
|
+
op << basic_option('gem', project) unless op.arg?('g', 'gem')
|
703
|
+
if (args = command_args(op.extras))
|
704
|
+
op.push(args)
|
705
|
+
end
|
706
|
+
op.append(delim: true, quote: false)
|
702
707
|
else
|
703
708
|
raise_error('missing gemname', hint: flag) if op.empty? && !op.arg?('system')
|
704
709
|
if flag == :pristine
|
@@ -734,8 +739,12 @@ module Squared
|
|
734
739
|
end
|
735
740
|
case flag
|
736
741
|
when 'exec', 'config'
|
737
|
-
|
738
|
-
|
742
|
+
if args.empty?
|
743
|
+
cmd << readline('Enter arguments', force: true)
|
744
|
+
else
|
745
|
+
args << command_args(args)
|
746
|
+
cmd.merge(args)
|
747
|
+
end
|
739
748
|
else
|
740
749
|
option_clear args
|
741
750
|
end
|
@@ -757,7 +766,9 @@ module Squared
|
|
757
766
|
|
758
767
|
def irb(name, opts = [], path: @path + 'lib', load: nil)
|
759
768
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
760
|
-
|
769
|
+
r = as_a name
|
770
|
+
r.unshift('bundler/setup') unless load
|
771
|
+
r.each { |val| op << shell_option('r', val, merge: true) }
|
761
772
|
as_a(path).each { |val| op << quote_option('I', val, merge: true) }
|
762
773
|
if load
|
763
774
|
op << '--' << load
|
@@ -15,7 +15,7 @@ module Squared
|
|
15
15
|
include Shell
|
16
16
|
include Prompt
|
17
17
|
|
18
|
-
def append(target, *args, delim: false, escape: false, quote: true)
|
18
|
+
def append(target, *args, delim: false, escape: false, quote: true, **)
|
19
19
|
return if (ret = args.flatten).empty?
|
20
20
|
|
21
21
|
target << '--' if delim && !target.include?('--')
|
@@ -44,10 +44,10 @@ module Squared
|
|
44
44
|
return [] unless val
|
45
45
|
|
46
46
|
val = shell_split(val) if val.is_a?(String)
|
47
|
-
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/
|
47
|
+
val.map { |s| s.sub(/\A-([a-z\d])(.+)\z/i, '\1=\2').sub(/\A--?/, '') }.reject(&:empty?)
|
48
48
|
end
|
49
49
|
|
50
|
-
def arg?(target, *args, value: false)
|
50
|
+
def arg?(target, *args, value: false, **)
|
51
51
|
r, s = args.partition { |val| val.is_a?(Regexp) }
|
52
52
|
unless s.empty?
|
53
53
|
s.map! { |val| Regexp.escape(shell_option(val)) }
|
@@ -60,9 +60,9 @@ module Squared
|
|
60
60
|
attr_reader :target, :extras, :found, :errors, :values, :project, :path
|
61
61
|
|
62
62
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
63
|
-
:merge, :delete, :delete?, :grep, :inspect, :to_a, :to_s
|
64
|
-
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :first, :last, :shift, :
|
65
|
-
:join, :map, :map!, :
|
63
|
+
:merge, :delete, :delete?, :delete_if, :grep, :inspect, :to_a, :to_s
|
64
|
+
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
65
|
+
:pop, :push, :join, :map, :map!, :select, :reject, :size
|
66
66
|
|
67
67
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
68
68
|
@target = target.is_a?(Set) ? target : Set.new(target)
|
@@ -7,13 +7,8 @@ module Squared
|
|
7
7
|
attr_accessor :line_width
|
8
8
|
|
9
9
|
def max_width(lines)
|
10
|
-
|
11
|
-
|
12
|
-
require 'io/console'
|
13
|
-
win = $stdout.winsize[1] rescue nil
|
14
|
-
end
|
15
|
-
n = [lines.max_by(&:size).size, line_width].max
|
16
|
-
[n, win > 0 ? win : ::Float::INFINITY].min
|
10
|
+
n = [lines.max_by(&:size).size, 80].max
|
11
|
+
[n, Rake.application.terminal_width].min
|
17
12
|
end
|
18
13
|
end
|
19
14
|
|
@@ -76,6 +76,7 @@ module Squared
|
|
76
76
|
@sync = []
|
77
77
|
@multiple = []
|
78
78
|
@parallel = []
|
79
|
+
@chain = {}
|
79
80
|
@exclude = exclude.freeze
|
80
81
|
@session = {
|
81
82
|
group: {},
|
@@ -139,6 +140,26 @@ module Squared
|
|
139
140
|
@multiple.concat(sync)
|
140
141
|
end
|
141
142
|
|
143
|
+
def chain(key, level, sync: [])
|
144
|
+
return if level.empty?
|
145
|
+
|
146
|
+
index = 0
|
147
|
+
prereqs = level.map do |tasks|
|
148
|
+
task_join(key, index += 1).tap do |subkey|
|
149
|
+
if sync.include?(tasks) || (tasks.size == 1 && (sync << tasks))
|
150
|
+
task subkey => tasks
|
151
|
+
else
|
152
|
+
multitask subkey => tasks
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
@chain[key] = level.freeze
|
157
|
+
parallel << key
|
158
|
+
|
159
|
+
format_desc key, level.map(&:size).join('-')
|
160
|
+
task key => prereqs
|
161
|
+
end
|
162
|
+
|
142
163
|
def name_get(key)
|
143
164
|
(TASK_NAME[key] || key).to_s
|
144
165
|
end
|
@@ -187,6 +208,19 @@ module Squared
|
|
187
208
|
data.keys.any? { |ref| obj.ref?(ref) }
|
188
209
|
end
|
189
210
|
|
211
|
+
def chain?(val)
|
212
|
+
@chain.each_value do |tasks|
|
213
|
+
tasks.flatten(1).each do |task|
|
214
|
+
next unless Rake::Task[task].already_invoked
|
215
|
+
|
216
|
+
if val == task || Rake::Task[task].prerequisites.any? { |pr| pr == val && Rake::Task[val].already_invoked }
|
217
|
+
return true
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
false
|
222
|
+
end
|
223
|
+
|
190
224
|
def multiple?(val = nil)
|
191
225
|
already_invoked?(multiple, val)
|
192
226
|
end
|
data/lib/squared/workspace.rb
CHANGED
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
@@ -101,6 +101,8 @@ files:
|
|
101
101
|
- lib/squared/workspace/project/support/class.rb
|
102
102
|
- lib/squared/workspace/repo.rb
|
103
103
|
- lib/squared/workspace/series.rb
|
104
|
+
- lib/squared/workspace/support.rb
|
105
|
+
- lib/squared/workspace/support/data.rb
|
104
106
|
- squared.gemspec
|
105
107
|
homepage: https://github.com/anpham6/squared
|
106
108
|
licenses:
|