squared 0.4.14 → 0.4.16
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 +64 -0
- data/README.ruby.md +4 -2
- data/lib/squared/common/prompt.rb +3 -3
- data/lib/squared/common/shell.rb +1 -2
- data/lib/squared/common/utils.rb +9 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +25 -19
- data/lib/squared/workspace/project/base.rb +173 -124
- data/lib/squared/workspace/project/docker.rb +21 -24
- data/lib/squared/workspace/project/git.rb +41 -41
- data/lib/squared/workspace/project/node.rb +67 -25
- data/lib/squared/workspace/project/python.rb +18 -11
- data/lib/squared/workspace/project/ruby.rb +95 -59
- data/lib/squared/workspace/project/support/class.rb +2 -4
- data/lib/squared/workspace/series.rb +8 -8
- data/lib/squared/workspace/support/base.rb +17 -0
- data/lib/squared/workspace/support.rb +1 -0
- data/squared.gemspec +2 -2
- metadata +3 -2
@@ -4,7 +4,7 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Ruby < Git
|
7
|
-
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
|
7
|
+
GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb gems.rb Isolate].freeze
|
8
8
|
DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
|
9
9
|
OPT_RUBY = {
|
10
10
|
ruby: %w[0=im? a c e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit v|verbose y|yydebug
|
@@ -91,7 +91,7 @@ module Squared
|
|
91
91
|
'irb' => nil
|
92
92
|
})
|
93
93
|
|
94
|
-
def initialize(*, autodetect: false, **kwargs)
|
94
|
+
def initialize(*, autodetect: false, gemspec: nil, **kwargs)
|
95
95
|
super
|
96
96
|
if @pass.include?(Ruby.ref)
|
97
97
|
initialize_ref Ruby.ref
|
@@ -102,7 +102,8 @@ module Squared
|
|
102
102
|
end
|
103
103
|
dependfile_set GEMFILE
|
104
104
|
@autodetect = autodetect
|
105
|
-
|
105
|
+
@gemfile = path + gemspec if gemspec
|
106
|
+
return if !@output[0].nil? || !@copy.nil? || version || @autodetect || !rakefile
|
106
107
|
|
107
108
|
begin
|
108
109
|
File.foreach(rakefile) do |line|
|
@@ -129,12 +130,12 @@ module Squared
|
|
129
130
|
|
130
131
|
namespace name do
|
131
132
|
Ruby.subtasks do |action, flags|
|
132
|
-
next if
|
133
|
+
next if task_pass?(action)
|
133
134
|
|
134
135
|
if flags.nil?
|
135
136
|
case action
|
136
137
|
when 'rake'
|
137
|
-
next
|
138
|
+
next unless rakefile
|
138
139
|
|
139
140
|
format_desc action, nil, "task+,opts*|#{indexchar}index+|#,pattern*"
|
140
141
|
task action, [:command] do |_, args|
|
@@ -167,13 +168,11 @@ module Squared
|
|
167
168
|
end
|
168
169
|
end
|
169
170
|
when 'irb'
|
170
|
-
next unless (spec = basepath("#{project}.gemspec") || basepath("#{name}.gemspec"))
|
171
|
-
next unless basepath('lib').join("#{gemname = stripext(spec)}.rb").exist?
|
172
|
-
|
173
171
|
format_desc action, nil, 'opts*,args*|:'
|
174
172
|
task action do |_, args|
|
175
173
|
args = args.to_a
|
176
|
-
|
174
|
+
name = basepath('lib').join("#{gemname}.rb").exist? ? gemname : nil
|
175
|
+
irb(name, args, args: (readline('Enter file [arguments]', force: false) if args.delete(':')))
|
177
176
|
end
|
178
177
|
else
|
179
178
|
format_desc(action, nil, 'opts*', before: case action
|
@@ -303,9 +302,7 @@ module Squared
|
|
303
302
|
begin
|
304
303
|
copy_dir(a, b, c, pass: pass, verbose: verbose)
|
305
304
|
rescue StandardError => e
|
306
|
-
|
307
|
-
ret = on(:error, :copy, e)
|
308
|
-
raise if exception && ret != true
|
305
|
+
on_error e, :copy
|
309
306
|
end
|
310
307
|
end
|
311
308
|
on :last, :copy
|
@@ -445,11 +442,11 @@ module Squared
|
|
445
442
|
when :file, :script
|
446
443
|
op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
|
447
444
|
if file
|
448
|
-
op.
|
445
|
+
op.unshift(shell_quote(path + file))
|
449
446
|
elsif command
|
450
447
|
op << quote_option('e', command, option: false)
|
451
448
|
end
|
452
|
-
op.
|
449
|
+
op.push(args) if (args = ENV.fetch('RUBY_ARGS', args))
|
453
450
|
op.append(delim: true, escape: false, quote: false) unless op.empty?
|
454
451
|
when :version
|
455
452
|
pwd_set do
|
@@ -688,37 +685,44 @@ module Squared
|
|
688
685
|
on :last, from
|
689
686
|
return
|
690
687
|
when :build
|
691
|
-
if op.empty?
|
692
|
-
spec = [path + "#{project}.gemspec", path + "#{name}.gemspec", *Dir.glob(path + '*.gemspec')]
|
693
|
-
op << File.basename(spec) if (spec = spec.find { |file| File.exist?(file) })
|
694
|
-
else
|
688
|
+
if !op.empty?
|
695
689
|
op << shell_quote(path + op.shift)
|
696
690
|
op.clear(pass: false)
|
691
|
+
elsif (file = gemfile)
|
692
|
+
op << shell_quote(file)
|
697
693
|
end
|
698
694
|
when :push
|
699
695
|
if op.empty?
|
700
|
-
|
696
|
+
file = path + (if (spec = gemspec)
|
697
|
+
"#{spec.name}-#{spec.version}.gem"
|
698
|
+
else
|
699
|
+
choice_index('Select a file', Dir.glob('*.gem', base: path), force: true)
|
700
|
+
end)
|
701
701
|
else
|
702
702
|
file = path + op.shift
|
703
|
+
raise_error('gem not found', hint: file) unless file.exist?
|
703
704
|
raise_error("unknown args: #{op.join(', ')}", hint: flag) unless op.empty?
|
704
|
-
if file.exist?
|
705
|
-
op << shell_quote(file)
|
706
|
-
else
|
707
|
-
raise_error('gem not found', hint: file)
|
708
|
-
end
|
709
705
|
end
|
710
|
-
|
706
|
+
op << shell_quote(file)
|
707
|
+
run_rb(from: from, interactive: "Push #{sub_style(gemname, styles: theme[:active])}")
|
711
708
|
return
|
712
709
|
when :exec
|
713
|
-
|
714
|
-
|
715
|
-
|
710
|
+
min = if op.arg?('g', 'gem')
|
711
|
+
1
|
712
|
+
elsif op.empty?
|
713
|
+
op << basic_option('gem', gemname)
|
714
|
+
1
|
715
|
+
else
|
716
|
+
op << op.shift
|
717
|
+
0
|
718
|
+
end
|
719
|
+
if (args = command_args(op.extras, min: min, force: min == 1 && op.empty?))
|
716
720
|
op.push(args)
|
717
721
|
end
|
718
|
-
op.append(
|
722
|
+
op.append(quote: false)
|
719
723
|
when :update
|
720
724
|
unless op.arg?('system')
|
721
|
-
op.push(
|
725
|
+
op.push(gemname) if op.empty?
|
722
726
|
op.adjoin
|
723
727
|
end
|
724
728
|
op.clear(errors: true)
|
@@ -738,7 +742,7 @@ module Squared
|
|
738
742
|
items = op.extras.to_a
|
739
743
|
name = items.delete_at(n)
|
740
744
|
if (n = name.index('@')) == 0
|
741
|
-
pre =
|
745
|
+
pre = gemname
|
742
746
|
ver = name[1..-1]
|
743
747
|
else
|
744
748
|
pre = name[0, n]
|
@@ -793,10 +797,11 @@ module Squared
|
|
793
797
|
run_s(args, banner: false, from: :rake)
|
794
798
|
end
|
795
799
|
|
796
|
-
def irb(name, opts = [], path:
|
800
|
+
def irb(name = nil, opts = [], path: basepath('lib'), args: nil)
|
797
801
|
op = OptionPartition.new(opts, OPT_RUBY[:irb], session('irb'), project: self, first: [/\.rb$/])
|
798
802
|
r = args ? [] : ['bundler/setup']
|
799
|
-
|
803
|
+
r << name if name
|
804
|
+
r.each { |val| op << shell_option('r', val, merge: true) }
|
800
805
|
Array(path).each { |val| op << quote_option('I', val, merge: true) }
|
801
806
|
if args
|
802
807
|
op << '--' << args
|
@@ -807,6 +812,24 @@ module Squared
|
|
807
812
|
run(banner: false)
|
808
813
|
end
|
809
814
|
|
815
|
+
def gemspec
|
816
|
+
return @gemspec unless @gemspec.nil?
|
817
|
+
|
818
|
+
begin
|
819
|
+
if (file = gemfile)
|
820
|
+
require 'rubygems'
|
821
|
+
@gemspec = Gem::Specification.load(file.to_s)
|
822
|
+
end
|
823
|
+
rescue StandardError => e
|
824
|
+
log.debug e
|
825
|
+
end
|
826
|
+
@gemspec ||= false
|
827
|
+
end
|
828
|
+
|
829
|
+
def gemname
|
830
|
+
@gemname ||= ((spec = gemspec) ? spec.name : project)
|
831
|
+
end
|
832
|
+
|
810
833
|
def depend?
|
811
834
|
@depend != false && (!@depend.nil? || outdated?)
|
812
835
|
end
|
@@ -815,7 +838,7 @@ module Squared
|
|
815
838
|
return true if super || (@copy.is_a?(Hash) && copy.fetch(:into, nil))
|
816
839
|
return gemdir? if @gemdir
|
817
840
|
|
818
|
-
if
|
841
|
+
if version
|
819
842
|
begin
|
820
843
|
case @autodetect
|
821
844
|
when 'rvm'
|
@@ -840,42 +863,47 @@ module Squared
|
|
840
863
|
return false unless @autodetect
|
841
864
|
|
842
865
|
set = lambda do |val, path|
|
843
|
-
|
844
|
-
|
866
|
+
if (ver = version) && ver != val
|
867
|
+
log.warn "using version #{val} (given #{ver})"
|
868
|
+
end
|
869
|
+
self.version = val
|
845
870
|
@gemdir = Pathname.new(path.strip) + gempath
|
846
871
|
end
|
847
|
-
if
|
848
|
-
|
849
|
-
pwd_set(pass: !
|
850
|
-
out = `#{gem_output(
|
851
|
-
if out =~ /#{Regexp.escape(
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
872
|
+
if version
|
873
|
+
opt = gempwd
|
874
|
+
pwd_set(pass: !opt.nil?) do
|
875
|
+
out = `#{gem_output(opt, 'list --local -d', gemname)}`
|
876
|
+
if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
|
877
|
+
$1.split(/\s*,\s*/)
|
878
|
+
.unshift(@version)
|
879
|
+
.uniq
|
880
|
+
.each do |val|
|
881
|
+
next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
|
882
|
+
|
883
|
+
set.call(val, $1)
|
884
|
+
return gemdir? if @gemdir
|
885
|
+
end
|
860
886
|
end
|
861
887
|
end
|
862
|
-
|
863
|
-
|
888
|
+
require 'rubygems'
|
889
|
+
@gemdir = Pathname.new(Gem.dir) + gempath
|
890
|
+
else
|
864
891
|
parse = lambda do |path|
|
865
892
|
next unless path
|
866
893
|
|
867
|
-
lib = Regexp.new(['', 'gems', "#{
|
894
|
+
lib = Regexp.new(['', 'gems', "#{gemname}-([^#{File::SEPARATOR}]+)", ''].join(File::SEPARATOR))
|
868
895
|
if (ver = path[lib, 1]) && (val = path[/\A(.+)#{gempath(ver[1])}/, 1])
|
869
896
|
set.call(ver, val)
|
870
897
|
end
|
871
898
|
end
|
872
899
|
if RUBY_VERSION >= '2.6'
|
873
900
|
target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
|
874
|
-
parse.call(target.resolve_feature_path(
|
901
|
+
parse.call(target.resolve_feature_path(gemname)&.last)
|
902
|
+
end
|
903
|
+
if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', gemname)}`) }
|
904
|
+
raise_error 'gems directory not found'
|
875
905
|
end
|
876
|
-
pwd_set { parse.call(`#{bundle_output('show', project)}`) } unless @gemdir
|
877
906
|
end
|
878
|
-
raise_error('parse failed', hint: @version || 'path') unless @gemdir
|
879
907
|
rescue StandardError => e
|
880
908
|
log.error e
|
881
909
|
@version = nil
|
@@ -979,10 +1007,10 @@ module Squared
|
|
979
1007
|
end
|
980
1008
|
|
981
1009
|
def rakefile
|
982
|
-
return @rakefile
|
1010
|
+
return @rakefile unless @rakefile.nil?
|
983
1011
|
|
984
1012
|
file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
|
985
|
-
@rakefile = file ? path + file :
|
1013
|
+
@rakefile = file ? path + file : false
|
986
1014
|
end
|
987
1015
|
|
988
1016
|
def rakepwd
|
@@ -997,8 +1025,16 @@ module Squared
|
|
997
1025
|
quote_option 'C', path
|
998
1026
|
end
|
999
1027
|
|
1000
|
-
def
|
1001
|
-
|
1028
|
+
def gemfile
|
1029
|
+
return @gemfile unless @gemfile.nil?
|
1030
|
+
|
1031
|
+
@gemfile = [project, name].map! { |val| path + "#{val}.gemspec" }
|
1032
|
+
.concat(path.glob('*.gemspec'))
|
1033
|
+
.find { |file| File.exist?(file) } || false
|
1034
|
+
end
|
1035
|
+
|
1036
|
+
def gempath(val = version)
|
1037
|
+
File.join('gems', "#{gemname}-#{val}")
|
1002
1038
|
end
|
1003
1039
|
end
|
1004
1040
|
|
@@ -35,9 +35,7 @@ module Squared
|
|
35
35
|
kwargs[:hint] ||= 'unrecognized'
|
36
36
|
append(target, opts, delim: true) if kwargs.delete(:append)
|
37
37
|
warn log_message(Logger::WARN, opts.join(', '), pass: true, **kwargs)
|
38
|
-
|
39
|
-
|
40
|
-
raise_error 'user cancelled'
|
38
|
+
exit 1 unless pass || confirm("Run? [#{sub_style(target, styles: styles)}] [y/N] ", 'N')
|
41
39
|
end
|
42
40
|
|
43
41
|
def strip(val)
|
@@ -62,7 +60,7 @@ module Squared
|
|
62
60
|
def_delegators :@target, :+, :-, :<<, :any?, :none?, :include?, :add, :add?, :find, :find_all, :find_index,
|
63
61
|
:merge, :delete, :delete?, :delete_if, :grep, :inspect, :to_a, :to_s
|
64
62
|
def_delegators :@extras, :empty?, :each, :each_with_index, :partition, :dup, :first, :last, :shift, :unshift,
|
65
|
-
:pop, :push, :join, :map, :map!, :select, :reject, :size
|
63
|
+
:pop, :push, :index, :delete_at, :join, :map, :map!, :select, :reject, :size
|
66
64
|
|
67
65
|
def initialize(opts, list, target = Set.new, project: nil, path: nil, **kwargs, &blk)
|
68
66
|
@target = target.is_a?(Set) ? target : Set.new(target)
|
@@ -10,16 +10,16 @@ module Squared
|
|
10
10
|
|
11
11
|
TASK_BASE = []
|
12
12
|
TASK_BATCH = {}
|
13
|
-
TASK_EXTEND =
|
13
|
+
TASK_EXTEND = Support.hashlist
|
14
14
|
TASK_KEYS = []
|
15
|
-
TASK_ALIAS =
|
15
|
+
TASK_ALIAS = Support.hashobj
|
16
16
|
TASK_NAME = {}
|
17
17
|
private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def add(task, obj)
|
21
21
|
key_set task
|
22
|
-
|
22
|
+
TASK_EXTEND[task] << obj
|
23
23
|
end
|
24
24
|
|
25
25
|
def batch(*args, obj)
|
@@ -37,7 +37,7 @@ module Squared
|
|
37
37
|
|
38
38
|
def alias(ref, obj)
|
39
39
|
if obj.is_a?(Hash)
|
40
|
-
obj.each { |key, val|
|
40
|
+
obj.each { |key, val| TASK_ALIAS[key][ref] = val }
|
41
41
|
else
|
42
42
|
TASK_ALIAS[obj]&.delete(ref)
|
43
43
|
end
|
@@ -79,8 +79,8 @@ module Squared
|
|
79
79
|
@chain = {}
|
80
80
|
@exclude = exclude.freeze
|
81
81
|
@session = {
|
82
|
-
group:
|
83
|
-
parent:
|
82
|
+
group: Support.hashlist,
|
83
|
+
parent: Support.hashlist,
|
84
84
|
id: []
|
85
85
|
}
|
86
86
|
@data = {}
|
@@ -95,7 +95,7 @@ module Squared
|
|
95
95
|
|
96
96
|
if (g = proj.group)
|
97
97
|
id << g
|
98
|
-
|
98
|
+
group[:"#{key}:#{g}"].concat(tasks)
|
99
99
|
else
|
100
100
|
items.concat(tasks)
|
101
101
|
end
|
@@ -106,7 +106,7 @@ module Squared
|
|
106
106
|
next unless (b = ws.find_base(proj)) && (n = b.ref.to_s) != g
|
107
107
|
|
108
108
|
id << n
|
109
|
-
|
109
|
+
parent[:"#{key}:#{n}"].concat(tasks)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Squared
|
4
|
+
module Workspace
|
5
|
+
module Support
|
6
|
+
class << self
|
7
|
+
def hashobj
|
8
|
+
Hash.new { |data, key| data[key] = {} }
|
9
|
+
end
|
10
|
+
|
11
|
+
def hashlist
|
12
|
+
Hash.new { |data, key| data[key] = [] }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/squared.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
version = File.read(File.join(__dir__, "lib/squared/version.rb"))[/\bVERSION = '(.+)'$/, 1]
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "squared"
|
7
|
-
spec.version =
|
7
|
+
spec.version = version
|
8
8
|
spec.authors = ["An Pham"]
|
9
9
|
spec.email = ["anpham6@gmail.com"]
|
10
10
|
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/squared/workspace/repo.rb
|
103
103
|
- lib/squared/workspace/series.rb
|
104
104
|
- lib/squared/workspace/support.rb
|
105
|
+
- lib/squared/workspace/support/base.rb
|
105
106
|
- lib/squared/workspace/support/data.rb
|
106
107
|
- squared.gemspec
|
107
108
|
homepage: https://github.com/anpham6/squared
|
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
|
-
rubygems_version: 3.6.
|
129
|
+
rubygems_version: 3.6.9
|
129
130
|
specification_version: 4
|
130
131
|
summary: Rake task generator for managing multi-language workspaces.
|
131
132
|
test_files: []
|