squared 0.6.5 → 0.6.6
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.md +80 -26
- data/lib/squared/common/format.rb +5 -1
- data/lib/squared/common/shell.rb +7 -2
- data/lib/squared/config.rb +12 -8
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +14 -20
- data/lib/squared/workspace/project/base.rb +39 -26
- data/lib/squared/workspace/project/docker.rb +37 -41
- data/lib/squared/workspace/project/git.rb +58 -44
- data/lib/squared/workspace/project/node.rb +42 -37
- data/lib/squared/workspace/project/python.rb +100 -77
- data/lib/squared/workspace/project/ruby.rb +149 -104
- data/lib/squared/workspace/project/support/class.rb +26 -8
- data/lib/squared/workspace/project/support/optionpartition.rb +93 -42
- data/lib/squared/workspace/series.rb +3 -1
- data/lib/squared/workspace.rb +4 -3
- metadata +1 -1
|
@@ -7,9 +7,9 @@ module Squared
|
|
|
7
7
|
DEP_PYTHON = %w[poetry.lock setup.cfg pyproject.toml setup.py requirements.txt].freeze
|
|
8
8
|
DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
|
|
9
9
|
OPT_PYTHON = {
|
|
10
|
-
common: %w[b=+ B d E h i I O P q=+ s S u v=+ x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
|
|
11
|
-
build: %w[n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel
|
|
12
|
-
o|outdir=p].freeze,
|
|
10
|
+
common: %w[b=+ B d E h i I O P q=+ s S u v=+ V=+ x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
|
|
11
|
+
build: %w[C=bm n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel config-json=q config-setting=q
|
|
12
|
+
installer=b o|outdir=p].freeze,
|
|
13
13
|
venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
|
|
14
14
|
prompt=q].freeze
|
|
15
15
|
}.freeze
|
|
@@ -68,6 +68,7 @@ module Squared
|
|
|
68
68
|
sign-with=b u|username=q].freeze
|
|
69
69
|
}.freeze
|
|
70
70
|
PASS_PYTHON = {
|
|
71
|
+
python: %w[c v V].freeze,
|
|
71
72
|
pip: {
|
|
72
73
|
debug: %w[platform].freeze,
|
|
73
74
|
install: %w[C config-settings c constraint extra-index-url no-binary only-binary platform
|
|
@@ -178,7 +179,7 @@ module Squared
|
|
|
178
179
|
indexerror n, list
|
|
179
180
|
else
|
|
180
181
|
found |= 2
|
|
181
|
-
log.warn "run script #{n} of #{list.size}
|
|
182
|
+
log.warn "run script #{n} of #{list.size}".subhint('out of range')
|
|
182
183
|
end
|
|
183
184
|
else
|
|
184
185
|
case i
|
|
@@ -191,18 +192,18 @@ module Squared
|
|
|
191
192
|
else
|
|
192
193
|
raise_error "script: #{val}" if exception
|
|
193
194
|
found |= 2
|
|
194
|
-
log.warn "run script \"#{val}\"
|
|
195
|
+
log.warn "run script \"#{val}\"".subhint('not indexed')
|
|
195
196
|
end
|
|
196
197
|
end
|
|
197
198
|
end
|
|
198
199
|
end
|
|
199
200
|
break
|
|
200
201
|
end
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
next if found.anybits?(1)
|
|
203
|
+
|
|
204
|
+
puts log_message(found == 0 ? Logger::INFO : Logger.WARN,
|
|
205
|
+
"no scripts #{found == 0 ? 'found' : 'executed'}",
|
|
206
|
+
subject: name, hint: pyprojectfile)
|
|
206
207
|
end
|
|
207
208
|
when 'exec'
|
|
208
209
|
format_desc action, nil, ':|command,args*'
|
|
@@ -234,11 +235,12 @@ module Squared
|
|
|
234
235
|
when :remove
|
|
235
236
|
next unless projectpath?(venv)
|
|
236
237
|
|
|
237
|
-
format_desc action, flag, 'c/reate?,d/epend
|
|
238
|
+
format_desc action, flag, 'c/reate?,d/epend?,opts*'
|
|
238
239
|
task flag do |_, args|
|
|
240
|
+
args = args.to_a
|
|
239
241
|
rm_rf(venv, verbose: true)
|
|
240
|
-
venv_init if has_value
|
|
241
|
-
depend if has_value
|
|
242
|
+
venv_init if has_value!(args, 'c', 'create')
|
|
243
|
+
depend :force, args if has_value!(args, 'd', 'depend')
|
|
242
244
|
end
|
|
243
245
|
when :exec
|
|
244
246
|
format_desc action, flag, 'command,args*'
|
|
@@ -286,11 +288,11 @@ module Squared
|
|
|
286
288
|
pip(flag, opts: args.to_a, banner: true)
|
|
287
289
|
end
|
|
288
290
|
when :reinstall
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
next unless venv && projectpath?(venv)
|
|
292
|
+
|
|
293
|
+
format_desc action, flag
|
|
294
|
+
task flag do
|
|
295
|
+
ns['venv:remove'].invoke('depend')
|
|
294
296
|
end
|
|
295
297
|
end
|
|
296
298
|
when 'install'
|
|
@@ -309,7 +311,7 @@ module Squared
|
|
|
309
311
|
install flag, (case args.strategy
|
|
310
312
|
when 'eager'
|
|
311
313
|
'eager'
|
|
312
|
-
when
|
|
314
|
+
when /^only-if|needed$/
|
|
313
315
|
'only-if-needed'
|
|
314
316
|
end.yield_self do |val|
|
|
315
317
|
if val
|
|
@@ -451,11 +453,10 @@ module Squared
|
|
|
451
453
|
buffer = []
|
|
452
454
|
out = ->(val) { sync ? puts(val) : buffer << val }
|
|
453
455
|
if workspace.windows?
|
|
454
|
-
(venv ? command(runenv, cmd) : `#{cmd}`).lines
|
|
456
|
+
(venv ? command(runenv, cmd) : `#{cmd}`).lines(chomp: true)
|
|
455
457
|
else
|
|
456
|
-
IO.popen(runenv || {}, cmd)
|
|
458
|
+
IO.popen(runenv || {}, cmd).readlines(chomp: true)
|
|
457
459
|
end.each do |line|
|
|
458
|
-
line.chomp!
|
|
459
460
|
next if line.match?(/^[ -]+$/)
|
|
460
461
|
|
|
461
462
|
if start > 0
|
|
@@ -516,34 +517,33 @@ module Squared
|
|
|
516
517
|
puts buffer
|
|
517
518
|
end
|
|
518
519
|
if found > 0
|
|
519
|
-
if se
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
520
|
+
items = if se
|
|
521
|
+
choice('Select a package', items.map(&:first),
|
|
522
|
+
multiple: true, force: false, index: true, border: true).map! { |n| items[n.pred].last }
|
|
523
|
+
elsif ia
|
|
524
|
+
items.map(&:last)
|
|
525
|
+
else
|
|
526
|
+
case flag
|
|
527
|
+
when :major
|
|
528
|
+
major + minor + patch
|
|
529
|
+
when :minor
|
|
530
|
+
minor + patch
|
|
531
|
+
else
|
|
532
|
+
patch
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
if up && !items.empty?
|
|
536
|
+
base = %w[eager no-deps]
|
|
537
|
+
base << 'user' unless venv
|
|
538
|
+
opts = (base & opts).map! { |val| val == 'eager' ? "upgrade-strategy=#{val}" : val }
|
|
539
|
+
if dryrun
|
|
540
|
+
opts.map! { |val| fill_option(val) }
|
|
541
|
+
print_run pip_output('install --upgrade', *opts, *items.quote!), false
|
|
530
542
|
else
|
|
531
|
-
|
|
543
|
+
install(:upgrade, opts, packages: items, banner: false)
|
|
532
544
|
end
|
|
533
|
-
end.tap do |packages|
|
|
534
|
-
if up && !packages.empty?
|
|
535
|
-
base = %w[eager no-deps]
|
|
536
|
-
base << 'user' unless venv
|
|
537
|
-
opts = (base & opts).map! { |val| val == 'eager' ? "upgrade-strategy=#{val}" : val }
|
|
538
|
-
if dryrun
|
|
539
|
-
opts.map! { |val| fill_option(val) }
|
|
540
|
-
print_run pip_output('install --upgrade', *opts, *packages.quote!), false
|
|
541
|
-
else
|
|
542
|
-
install(:upgrade, opts, packages: packages, banner: false)
|
|
543
|
-
end
|
|
544
|
-
end
|
|
545
|
-
print_status(major.size, minor.size, patch.size, from: :outdated)
|
|
546
545
|
end
|
|
546
|
+
print_status(major.size, minor.size, patch.size, from: :outdated)
|
|
547
547
|
elsif start == 0 || hide
|
|
548
548
|
puts 'No updates were found'
|
|
549
549
|
end
|
|
@@ -634,7 +634,7 @@ module Squared
|
|
|
634
634
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
|
635
635
|
dist = lambda do
|
|
636
636
|
dir = basepath 'dist'
|
|
637
|
-
|
|
637
|
+
return dir if dir.directory? && !dir.empty?
|
|
638
638
|
|
|
639
639
|
if dir.exist?
|
|
640
640
|
raise_error 'no source to publish', hint: dir
|
|
@@ -663,6 +663,27 @@ module Squared
|
|
|
663
663
|
run(from: :"#{flag}:publish", interactive: ['Publish', 'N', project])
|
|
664
664
|
end
|
|
665
665
|
|
|
666
|
+
def python(*args, sync: true, banner: verbose?, with: nil, pass: PASS_PYTHON[:python], **kwargs)
|
|
667
|
+
op = OptionPartition.new(session_opts(with, args: args, kwargs: kwargs, pass: pass), OPT_PYTHON[:common],
|
|
668
|
+
session('python', path: venv.nil?),
|
|
669
|
+
project: self, multiple: [/^-c/], single: singleopt(:python), args: true,
|
|
670
|
+
stdin: true)
|
|
671
|
+
op.concat(args)
|
|
672
|
+
if op.include?('-')
|
|
673
|
+
op.exist?(add: true)
|
|
674
|
+
else
|
|
675
|
+
op.append_any { |val| OptionPartition.parse_arg!('c', val) }
|
|
676
|
+
if op.arg?('c')
|
|
677
|
+
op.clear
|
|
678
|
+
else
|
|
679
|
+
op.exist?(add: true, first: true) unless op.arg?('m')
|
|
680
|
+
op.append(escape: kwargs.fetch(:escape, false), quote: kwargs.fetch(:quote, false))
|
|
681
|
+
end
|
|
682
|
+
end
|
|
683
|
+
print_run(op, banner, **kwargs)
|
|
684
|
+
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: :python)
|
|
685
|
+
end
|
|
686
|
+
|
|
666
687
|
def pip(flag, *args, sync: true, banner: verbose?, with: nil, pass: nil, **kwargs)
|
|
667
688
|
flag = flag.to_sym
|
|
668
689
|
pass = PASS_PYTHON[:pip].fetch(pip_install?(flag) ? :install : flag, []) + %w[v verbose] if pass.nil?
|
|
@@ -736,7 +757,8 @@ module Squared
|
|
|
736
757
|
op.clear
|
|
737
758
|
end
|
|
738
759
|
print_run(op, banner, **kwargs)
|
|
739
|
-
run(sync: sync, banner: banner, from: :"pip:#{flag}")
|
|
760
|
+
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: :"pip:#{flag}")
|
|
761
|
+
.yield_self { |val| ret || val }
|
|
740
762
|
end
|
|
741
763
|
|
|
742
764
|
def variable_set(key, *args, **, &blk)
|
|
@@ -785,14 +807,14 @@ module Squared
|
|
|
785
807
|
def python_session(*cmd, opts: nil)
|
|
786
808
|
return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
|
|
787
809
|
|
|
788
|
-
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single:
|
|
810
|
+
op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: singleopt(:python))
|
|
789
811
|
[session('python', *op.to_a, *cmd, path: venv.nil?), op.extras]
|
|
790
812
|
end
|
|
791
813
|
|
|
792
814
|
def poetry_session(*cmd)
|
|
793
|
-
session('poetry', *cmd, *preopts)
|
|
794
|
-
|
|
795
|
-
|
|
815
|
+
ret = session('poetry', *cmd, *preopts)
|
|
816
|
+
option('project', ignore: false) { |val| ret << quote_option('project', basepath(val)) }
|
|
817
|
+
ret
|
|
796
818
|
end
|
|
797
819
|
|
|
798
820
|
def pdm_session(*cmd, opts: nil)
|
|
@@ -859,7 +881,7 @@ module Squared
|
|
|
859
881
|
def append_editable(target: @session)
|
|
860
882
|
return if requirements? && editable == '.'
|
|
861
883
|
|
|
862
|
-
if (val = option('
|
|
884
|
+
if (val = option('e', 'editable', target: target, ignore: false))
|
|
863
885
|
OptionPartition.delete_key(target, 'e', 'editable')
|
|
864
886
|
case val
|
|
865
887
|
when '0', 'false'
|
|
@@ -883,7 +905,7 @@ module Squared
|
|
|
883
905
|
quote_option 'cache-dir', basepath(val)
|
|
884
906
|
end
|
|
885
907
|
end,
|
|
886
|
-
option('proxy', target: target) { |val|
|
|
908
|
+
option('proxy', target: target) { |val| quote_option('proxy', val) },
|
|
887
909
|
option('python', target: target) { |val| quote_option('python', basepath(val)) }
|
|
888
910
|
])
|
|
889
911
|
append_nocolor(target: target)
|
|
@@ -957,15 +979,14 @@ module Squared
|
|
|
957
979
|
end
|
|
958
980
|
|
|
959
981
|
def pyprojectfile
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
@pyprojectfile = (file = basepath(DEP_PYTHON[2])).exist? ? file : false
|
|
982
|
+
@pyprojectfile = basepath!(DEP_PYTHON[2]) || false if @pyprojectfile.nil?
|
|
983
|
+
@pyprojectfile || nil
|
|
963
984
|
end
|
|
964
985
|
|
|
965
986
|
def singleopt(flag = nil)
|
|
966
987
|
case flag
|
|
967
988
|
when :python
|
|
968
|
-
/\A(?:v+|q+|b+)\z/
|
|
989
|
+
/\A(?:v+|q+|b+|V+|O+)\z/
|
|
969
990
|
when :pdm
|
|
970
991
|
/\Av+\z/
|
|
971
992
|
when :twine
|
|
@@ -976,14 +997,14 @@ module Squared
|
|
|
976
997
|
end
|
|
977
998
|
|
|
978
999
|
def preopts(quiet: true)
|
|
979
|
-
[]
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
end
|
|
1000
|
+
ret = []
|
|
1001
|
+
case verbose
|
|
1002
|
+
when FalseClass
|
|
1003
|
+
ret << '--quiet' if quiet
|
|
1004
|
+
when Numeric
|
|
1005
|
+
ret << "-#{'v' * verbose}" if verbose > 0
|
|
986
1006
|
end
|
|
1007
|
+
ret
|
|
987
1008
|
end
|
|
988
1009
|
|
|
989
1010
|
def variables
|
|
@@ -1016,20 +1037,21 @@ module Squared
|
|
|
1016
1037
|
def venv_set(val)
|
|
1017
1038
|
return unless val
|
|
1018
1039
|
|
|
1040
|
+
write = ->(level, hint) { log.add(level, "venv: #{@venv}".subhint(hint)) }
|
|
1019
1041
|
if val.is_a?(Array)
|
|
1020
1042
|
val, *opts = val
|
|
1021
1043
|
@venvopts = opts
|
|
1022
1044
|
end
|
|
1023
|
-
@venv = basepath
|
|
1045
|
+
@venv = basepath val
|
|
1024
1046
|
if projectpath?(@venv)
|
|
1025
1047
|
if @venv.exist?
|
|
1026
|
-
|
|
1027
|
-
elsif
|
|
1048
|
+
write.call(Logger::DEBUG, 'found')
|
|
1049
|
+
elsif path.directory? && !path.empty?
|
|
1028
1050
|
@venv.mkpath
|
|
1029
|
-
|
|
1051
|
+
write.call(Logger::INFO, 'mkdir')
|
|
1030
1052
|
end
|
|
1031
1053
|
elsif !@venv.directory?
|
|
1032
|
-
|
|
1054
|
+
write.call(Logger::WARN, 'invalid')
|
|
1033
1055
|
@venv = nil
|
|
1034
1056
|
end
|
|
1035
1057
|
end
|
|
@@ -1037,20 +1059,21 @@ module Squared
|
|
|
1037
1059
|
def venv_init
|
|
1038
1060
|
return if !venv || (venvbin.directory? && !venvbin.empty?)
|
|
1039
1061
|
|
|
1040
|
-
puts log_message(venv, subject: 'venv', hint: 'init')
|
|
1062
|
+
puts log_message(venv, subject: 'venv', hint: 'init') unless silent?
|
|
1041
1063
|
opts = @venvopts&.map { |val| OptionPartition.strip(val) }&.flatten
|
|
1042
1064
|
venv_create(venv, opts || ["prompt=#{name}", 'upgrade-deps'], env: false, banner: false)
|
|
1043
|
-
puts log_message(venv, subject: 'venv', hint: 'created')
|
|
1065
|
+
puts log_message(venv, subject: 'venv', hint: 'created') unless silent?
|
|
1044
1066
|
end
|
|
1045
1067
|
|
|
1046
|
-
def venv_create(dir, opts = [], env: nil, banner:
|
|
1068
|
+
def venv_create(dir, opts = [], env: nil, banner: banner?)
|
|
1047
1069
|
cmd, opts = python_session('-m venv', opts: opts)
|
|
1048
1070
|
op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
|
|
1049
1071
|
status = op.append(dir, delim: true)
|
|
1050
1072
|
.clear(pass: false)
|
|
1051
1073
|
.arg?(/\A-v+\z/)
|
|
1052
|
-
run(op, env, exception: true, banner: banner)
|
|
1053
|
-
|
|
1074
|
+
success?(run(op, env, exception: true, banner: banner), banner, !status) do |ret|
|
|
1075
|
+
puts(ret && dir.directory? ? "Success: #{dir}" : 'Failed')
|
|
1076
|
+
end
|
|
1054
1077
|
end
|
|
1055
1078
|
|
|
1056
1079
|
def pip_install?(flag)
|
|
@@ -1071,7 +1094,7 @@ module Squared
|
|
|
1071
1094
|
end
|
|
1072
1095
|
|
|
1073
1096
|
def installable?
|
|
1074
|
-
setuptools? ||
|
|
1097
|
+
setuptools? || !!pyprojectfile
|
|
1075
1098
|
end
|
|
1076
1099
|
|
|
1077
1100
|
def setuptools?
|