squared 0.4.12 → 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 +30 -0
- data/README.ruby.md +5 -1
- data/lib/squared/common/shell.rb +14 -14
- data/lib/squared/common/system.rb +2 -2
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +1 -0
- data/lib/squared/workspace/project/base.rb +273 -101
- data/lib/squared/workspace/project/docker.rb +83 -43
- data/lib/squared/workspace/project/git.rb +15 -10
- data/lib/squared/workspace/project/node.rb +35 -4
- data/lib/squared/workspace/project/python.rb +127 -96
- data/lib/squared/workspace/project/ruby.rb +29 -19
- data/lib/squared/workspace/project/support/class.rb +2 -2
- metadata +1 -1
@@ -32,22 +32,24 @@ module Squared
|
|
32
32
|
no-attach=b pull=b scale=i t|timeout=i wait-timeout=i].freeze
|
33
33
|
}.freeze,
|
34
34
|
container: {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
35
|
+
create: %w[init i|interactive no-healthcheck oom-kill-disable privileged P|publish-all q|quiet read-only
|
36
|
+
rm runtime t|tty use-api-socket io-maxbandwidth=b io-maxiops=b add-host=q annotation=q
|
37
|
+
a|attach=b blkio-weight=i blkio-weight-device=i cap-add=b cap-drop=b cgroup-parent=b cgroupns=b
|
38
|
+
cidfile=p device=q device-cgroup-rule=q device-read-bps=q device-read-iops=q device-write-bps=q
|
39
|
+
device-write-iops=q disable-content-trust=b? dns=e dns-option=e dns-search=e domainname=b
|
40
|
+
entrypoint=q e|env=qq env-file=p expose=e gpus=q group-add=b health-cmd=q health-interval=b
|
41
|
+
health-retries=i health-start-interval=b health-start-period=b health-timeout=b h|hostname=e ip=b
|
42
|
+
ip6=e ipc=b isolation=b kernel-memory=b l|label=q label-file=p link=b link-local-ip=b
|
43
|
+
log-driver=b log-opt=q mac-address=e m|memory=b memory-reservation=b memory-swap=n
|
44
|
+
memory-swappiness=n mount=qq name=b network=b network-alias=b oom-score-adj=b pid=b pids-limit=n
|
45
|
+
platform=b p|publish=e pull=b restart=b runtime=b security-opt=q shm-size=b stop-signal=b
|
46
|
+
stop-timeout=i storage-opt=q sysctl=q tmpfs=q ulimit=q u|user=b userns=b uts=b v|volume=q
|
47
|
+
volume-driver=b volumes-from=b w|workdir=q].freeze,
|
48
|
+
run: %w[d|detach detach-keys=q sig-proxy=b?].freeze,
|
47
49
|
exec: %w[d|detach i|interactive privileged t|tty detach-keys=q e|env=qq env-file=p user=e
|
48
50
|
w|workdir=q].freeze,
|
49
51
|
update: %w[blkio-weight=i cpu-period=i cpu-quota=i cpu-rt-period=i cpu-rt-runtime=i c|cpu-shares=i cpus=f
|
50
|
-
cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=b pids-limit=
|
52
|
+
cpuset-cpus=b cpuset-mems=b m|memory=b memory-reservation=b memory-swap=b pids-limit=n
|
51
53
|
restart=q].freeze,
|
52
54
|
commit: %w[a|author=q c|change=q m|message=q pause=b?].freeze,
|
53
55
|
inspect: %w[s|size f|format=q].freeze,
|
@@ -60,7 +62,8 @@ module Squared
|
|
60
62
|
image: {
|
61
63
|
list: %w[a|all digests no-trunc f|filter=q format=q].freeze,
|
62
64
|
push: %w[a|all-tags disable-content-trust=b? platform=b q|quiet].freeze,
|
63
|
-
rm: %w[f|force no-prune].freeze
|
65
|
+
rm: %w[f|force no-prune].freeze,
|
66
|
+
save: %w[o|output=p platform=b].freeze
|
64
67
|
}.freeze,
|
65
68
|
network: {
|
66
69
|
connect: %w[alias=b driver-opt=q gw-priority=n ip=b ip6=b link=b link-local-ip=b].freeze,
|
@@ -90,8 +93,8 @@ module Squared
|
|
90
93
|
subtasks({
|
91
94
|
'build' => %i[tag context bake].freeze,
|
92
95
|
'compose' => %i[build run exec up].freeze,
|
93
|
-
'image' => %i[list rm push].freeze,
|
94
|
-
'container' => %i[run exec update commit inspect diff start stop restart pause unpause top stats kill
|
96
|
+
'image' => %i[list rm push tag save].freeze,
|
97
|
+
'container' => %i[run create exec update commit inspect diff start stop restart pause unpause top stats kill
|
95
98
|
rm].freeze,
|
96
99
|
'network' => %i[connect disconnect].freeze
|
97
100
|
})
|
@@ -107,7 +110,7 @@ module Squared
|
|
107
110
|
@tag = tag || tagname("#{@project}:#{@version || 'latest'}")
|
108
111
|
@mounts = mounts
|
109
112
|
@secrets = secrets
|
110
|
-
@registry =
|
113
|
+
@registry = tagjoin registry, kwargs[:username]
|
111
114
|
initialize_ref Docker.ref
|
112
115
|
initialize_logger(**kwargs)
|
113
116
|
initialize_env(**kwargs)
|
@@ -174,7 +177,7 @@ module Squared
|
|
174
177
|
container(flag, args.extras, id: id)
|
175
178
|
end
|
176
179
|
end
|
177
|
-
when :run
|
180
|
+
when :run, :create
|
178
181
|
format_desc action, flag, 'image,opts*,args*'
|
179
182
|
task flag, [:image] do |_, args|
|
180
183
|
if args.image
|
@@ -197,12 +200,15 @@ module Squared
|
|
197
200
|
tag = param_guard(action, flag, args: args, key: :tag)
|
198
201
|
image(flag, args.extras, id: tag)
|
199
202
|
end
|
200
|
-
|
201
|
-
format_desc(action, flag, flag
|
203
|
+
else
|
204
|
+
format_desc(action, flag, case flag
|
205
|
+
when :rm, :save then 'id*,opts*'
|
206
|
+
when :tag then 'version?'
|
207
|
+
else 'opts*,args*' end)
|
202
208
|
task flag do |_, args|
|
203
209
|
args = args.to_a
|
204
|
-
if flag
|
205
|
-
choice_command
|
210
|
+
if args.empty? && flag != :list
|
211
|
+
choice_command flag
|
206
212
|
else
|
207
213
|
image flag, args
|
208
214
|
end
|
@@ -340,13 +346,15 @@ module Squared
|
|
340
346
|
|
341
347
|
def container(flag, opts = [], id: nil)
|
342
348
|
cmd, opts = docker_session('container', flag, opts: opts)
|
349
|
+
rc = flag == :run || flag == :create
|
343
350
|
list = OPT_DOCKER[:container].fetch(flag, [])
|
344
|
-
list += OPT_DOCKER[:container][:
|
345
|
-
|
351
|
+
list += OPT_DOCKER[:container][:create] if flag == :run
|
352
|
+
list += OPT_DOCKER[:container][:update] if rc
|
353
|
+
op = OptionPartition.new(opts, list, cmd, project: self, args: rc || flag == :exec)
|
346
354
|
from = :"container:#{flag}"
|
347
355
|
case flag
|
348
|
-
when :run, :exec
|
349
|
-
if
|
356
|
+
when :run, :create, :exec
|
357
|
+
if rc && !op.arg?('mount')
|
350
358
|
run = VAL_DOCKER[:run]
|
351
359
|
both = run[:bind] + run[:tmpfs]
|
352
360
|
diff = run[:bind].reject { |val| run[:tmpfs].include?(val) }
|
@@ -378,7 +386,7 @@ module Squared
|
|
378
386
|
cmd << "--mount type=#{tmpfs ? 'tmpfs' : 'bind'},#{args.join(',')}"
|
379
387
|
end
|
380
388
|
end
|
381
|
-
append_command(flag, id
|
389
|
+
append_command(flag, id || tagmain, op.extras, from: from)
|
382
390
|
when :update
|
383
391
|
raise_error('missing container', hint: from) if op.empty?
|
384
392
|
op.append(escape: true)
|
@@ -442,7 +450,7 @@ module Squared
|
|
442
450
|
|
443
451
|
def image(flag, opts = [], sync: true, id: nil, registry: nil)
|
444
452
|
cmd, opts = docker_session('image', flag, opts: opts)
|
445
|
-
op = OptionPartition.new(opts, OPT_DOCKER[:image][
|
453
|
+
op = OptionPartition.new(opts, OPT_DOCKER[:image].fetch(flag, []), cmd, project: self)
|
446
454
|
exception = @exception
|
447
455
|
banner = true
|
448
456
|
from = :"image:#{flag}"
|
@@ -473,7 +481,7 @@ module Squared
|
|
473
481
|
end
|
474
482
|
else
|
475
483
|
if op.empty?
|
476
|
-
list_image(
|
484
|
+
list_image(:rm, docker_output('image ls -a'), from: from) do |val|
|
477
485
|
image(:rm, opts, sync: sync, id: val)
|
478
486
|
end
|
479
487
|
else
|
@@ -481,6 +489,14 @@ module Squared
|
|
481
489
|
end
|
482
490
|
return
|
483
491
|
end
|
492
|
+
when :tag, :save
|
493
|
+
list_image(flag, docker_output('image ls -a'), from: from) do |val|
|
494
|
+
op << val
|
495
|
+
if flag == :tag
|
496
|
+
op << tagname("#{@project}:#{op.extras.first}")
|
497
|
+
break
|
498
|
+
end
|
499
|
+
end
|
484
500
|
when :push
|
485
501
|
id ||= option('tag', ignore: false) || tagmain
|
486
502
|
registry ||= op.shift || option('registry') || @registry
|
@@ -497,7 +513,8 @@ module Squared
|
|
497
513
|
exception = true
|
498
514
|
banner = false
|
499
515
|
end
|
500
|
-
run(cmd, sync: sync, exception: exception, banner: banner, from: from)
|
516
|
+
ret = run(cmd, sync: sync, exception: exception, banner: banner, from: from)
|
517
|
+
print_success if success?(ret) && (flag == :tag || flag == :save)
|
501
518
|
end
|
502
519
|
|
503
520
|
def network(flag, opts = [], target: nil)
|
@@ -685,14 +702,14 @@ module Squared
|
|
685
702
|
|
686
703
|
def choice_command(flag)
|
687
704
|
msg, cmd, index = case flag
|
688
|
-
when :run, :rm
|
689
|
-
['Choose an image', 'images -a', 2]
|
690
705
|
when :exec
|
691
706
|
['Choose a container', 'ps -a', 0]
|
692
707
|
when :bake
|
693
708
|
['Choose a target', 'buildx bake --list=type=targets', 0]
|
694
|
-
|
709
|
+
when :connect, :disconnect
|
695
710
|
['Choose a network', 'network ls', 0]
|
711
|
+
else
|
712
|
+
['Choose an image', 'images -a', 2]
|
696
713
|
end
|
697
714
|
lines = `#{docker_output(cmd)}`.lines
|
698
715
|
header = lines.shift
|
@@ -702,25 +719,43 @@ module Squared
|
|
702
719
|
puts " # #{header}"
|
703
720
|
multiple = false
|
704
721
|
parse = ->(val) { val.split(/\s+/)[index] }
|
722
|
+
ctx = flag.to_s
|
705
723
|
case flag
|
706
724
|
when :run, :exec
|
707
725
|
values = [['Options', flag == :run], ['Arguments', flag == :exec]]
|
708
|
-
cmd = flag.to_s
|
709
726
|
when :rm, :bake
|
710
727
|
values = ['Options']
|
711
728
|
multiple = true
|
712
|
-
|
713
|
-
|
729
|
+
ctx = flag == :rm ? 'image rm' : "buildx bake -f #{shell_quote(dockerfile)}"
|
730
|
+
when :save
|
731
|
+
values = [['Output', true], 'Platform']
|
732
|
+
multiple = true
|
733
|
+
when :connect, :disconnect
|
714
734
|
values = ['Options', ['Container', true]]
|
715
|
-
|
735
|
+
ctx = "network #{flag}"
|
716
736
|
end
|
717
737
|
out, opts, args = choice_index(msg, lines, multiple: multiple, values: values)
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
738
|
+
cmd = docker_output ctx
|
739
|
+
case flag
|
740
|
+
when :tag
|
741
|
+
args = tagjoin @registry, @tag
|
742
|
+
when :save
|
743
|
+
opts = "#{opts}.tar" unless opts.end_with?('.tar')
|
744
|
+
cmd << quote_option('output', File.expand_path(opts))
|
745
|
+
if args
|
746
|
+
cmd << basic_option('platform', args)
|
747
|
+
args = nil
|
748
|
+
end
|
749
|
+
else
|
750
|
+
cmd << opts << '--'
|
751
|
+
end
|
752
|
+
cmd.merge(if out.is_a?(Array)
|
753
|
+
out.map! { |val| parse.call(val) }
|
754
|
+
else
|
755
|
+
[parse.call(out)]
|
756
|
+
end)
|
757
|
+
cmd << args
|
758
|
+
print_success if success?(run(cmd)) && ctx.match?(/\A(?:network|tag|save)/)
|
724
759
|
end
|
725
760
|
end
|
726
761
|
|
@@ -743,6 +778,11 @@ module Squared
|
|
743
778
|
val && projectpath?(val) ? shell_quote(path + val) : '.'
|
744
779
|
end
|
745
780
|
|
781
|
+
def tagjoin(*args, char: '/')
|
782
|
+
args.compact!
|
783
|
+
args.join(char) unless args.empty?
|
784
|
+
end
|
785
|
+
|
746
786
|
def tagname(val)
|
747
787
|
val = val.split(':').map! { |s| charname(s.sub(/^\W+/, '')) }
|
748
788
|
ret = val.join(':')
|
@@ -984,7 +984,14 @@ module Squared
|
|
984
984
|
end
|
985
985
|
end
|
986
986
|
opts[:origin] = val if (val = option('origin', ignore: false))
|
987
|
-
|
987
|
+
if (val = option('branch', strict: true))
|
988
|
+
opts[:branch] = val
|
989
|
+
opts.delete(:revision)
|
990
|
+
elsif (val = option('revision', strict: true))
|
991
|
+
opts[:revision] = val
|
992
|
+
opts.delete(:branch)
|
993
|
+
opts.delete(:mirror)
|
994
|
+
end
|
988
995
|
opts[:local] = val != '0' if (val = option('local', strict: true))
|
989
996
|
opts.delete(:'recurse-submodules') || opts.delete(:'no-recurse-submodules') if append_submodules(from: :clone)
|
990
997
|
append_hash opts
|
@@ -1760,15 +1767,13 @@ module Squared
|
|
1760
1767
|
end
|
1761
1768
|
|
1762
1769
|
def list_result(size, type, grep: [], action: 'found', from: nil)
|
1763
|
-
if
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
|
1771
|
-
end
|
1770
|
+
if size == 0
|
1771
|
+
puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
|
1772
|
+
elsif verbose
|
1773
|
+
styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
|
1774
|
+
styles << :bold if styles.size <= 1
|
1775
|
+
puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
|
1776
|
+
sub: [pat: /^(\d+)(.+)$/, styles: styles])
|
1772
1777
|
end
|
1773
1778
|
on :last, from
|
1774
1779
|
end
|
@@ -12,6 +12,7 @@ module Squared
|
|
12
12
|
install_as: %w[foreground-scripts g|global no-save save save-bundle save-dev E|save-exact save-optional
|
13
13
|
save-peer S|save-prod].freeze,
|
14
14
|
run: %w[foreground-scripts if-present ignore-scripts script-shell=p].freeze,
|
15
|
+
exec: %w[c|call=q package=b].freeze,
|
15
16
|
pack: %w[json ignore-scripts pack-destination=p].freeze
|
16
17
|
}.freeze
|
17
18
|
OPT_PNPM = {
|
@@ -30,6 +31,7 @@ module Squared
|
|
30
31
|
dedupe: %w[check].freeze,
|
31
32
|
run: %w[if-present no-bail parallel r|recursive report-summary reporter-hide-prefix resume-from sequential
|
32
33
|
stream use-stderr].freeze,
|
34
|
+
exec: %w[no-reporter-hide-prefix parallel r|recursive report-summary resume-from c|shell-mode].freeze,
|
33
35
|
pack: %w[json pack-destination=p pack-gzip-level=i].freeze
|
34
36
|
}.freeze
|
35
37
|
OPT_YARN = {
|
@@ -91,6 +93,7 @@ module Squared
|
|
91
93
|
'publish' => %i[latest tag].freeze,
|
92
94
|
'add' => nil,
|
93
95
|
'run' => nil,
|
96
|
+
'exec' => nil,
|
94
97
|
'pack' => nil
|
95
98
|
})
|
96
99
|
|
@@ -103,8 +106,8 @@ module Squared
|
|
103
106
|
initialize_build(Node.ref, prod: prod?, **kwargs)
|
104
107
|
initialize_env(**kwargs)
|
105
108
|
end
|
106
|
-
@pm = {}
|
107
109
|
@dependfile = @path + 'package.json'
|
110
|
+
@pm = {}
|
108
111
|
end
|
109
112
|
|
110
113
|
def ref
|
@@ -178,6 +181,35 @@ module Squared
|
|
178
181
|
run(from: :run)
|
179
182
|
end
|
180
183
|
end
|
184
|
+
when 'exec'
|
185
|
+
format_desc action, nil, 'pkg/cmd,opts*,args*'
|
186
|
+
task action, [:package] do |_, args|
|
187
|
+
if (package = args.package)
|
188
|
+
args = args.to_a.drop(1)
|
189
|
+
if pnpm?
|
190
|
+
pre = ->(ch) { "-#{ch}" if (ch = args.delete(ch)) }
|
191
|
+
cmd = session 'pnpm', pre.call('r'), pre.call('c'), 'exec'
|
192
|
+
list = OPT_PNPM[:exec] + OPT_PNPM[:filter] + OPT_PNPM[:common]
|
193
|
+
else
|
194
|
+
cmd = session 'npm', 'exec'
|
195
|
+
list = OPT_NPM[:exec] + OPT_NPM[:common]
|
196
|
+
end
|
197
|
+
op = OptionPartition.new(args, list, cmd, project: self)
|
198
|
+
if op.empty?
|
199
|
+
op << package
|
200
|
+
if (args = readline('Enter arguments', force: false))
|
201
|
+
op << '--' unless pnpm?
|
202
|
+
op << args
|
203
|
+
end
|
204
|
+
else
|
205
|
+
op << '--' unless pnpm?
|
206
|
+
op << package << op.join(' ')
|
207
|
+
end
|
208
|
+
else
|
209
|
+
session 'npm', 'exec', quote_option('c', readline('Enter command', force: true), double: true)
|
210
|
+
end
|
211
|
+
run(from: :exec)
|
212
|
+
end
|
181
213
|
when 'pack'
|
182
214
|
format_desc action, nil, 'opts*'
|
183
215
|
task action do |_, args|
|
@@ -365,8 +397,7 @@ module Squared
|
|
365
397
|
elsif pnpm?
|
366
398
|
cmd = session 'pnpm'
|
367
399
|
if flag == :add
|
368
|
-
cmd << 'add'
|
369
|
-
cmd << "--save-#{save}"
|
400
|
+
cmd << 'add' << "--save-#{save}"
|
370
401
|
cmd << '--save-exact' if exact
|
371
402
|
else
|
372
403
|
cmd << 'install'
|
@@ -527,7 +558,7 @@ module Squared
|
|
527
558
|
a = sub_style(a, styles: theme[:major])
|
528
559
|
sub_style(c, :bold, styles: color(:green))
|
529
560
|
else
|
530
|
-
sub_style(c, pat: SEM_VER, styles: color(:green), index: d)
|
561
|
+
sub_style(c, pat: SEM_VER, styles: color(d == 3 ? :green : :yellow), index: d)
|
531
562
|
end
|
532
563
|
puts "#{pad_ord.call(i, found)}. #{a + b + c}"
|
533
564
|
end
|
@@ -80,24 +80,19 @@ module Squared
|
|
80
80
|
initialize_build(Python.ref, **kwargs)
|
81
81
|
initialize_env(**kwargs)
|
82
82
|
end
|
83
|
-
|
84
|
-
@dependfile = @path + DEP_PYTHON[@dependindex || 0]
|
83
|
+
dependfile_set DEP_PYTHON
|
85
84
|
@verbose = verbose.size if verbose.is_a?(String) && verbose.match?(/\Av+\z/)
|
86
|
-
|
87
|
-
when '.', Pathname
|
88
|
-
editable
|
89
|
-
when String
|
90
|
-
Pathname.new(editable)
|
91
|
-
end
|
85
|
+
editable_set editable
|
92
86
|
venv_set venv if venv
|
93
87
|
end
|
94
88
|
|
95
89
|
subtasks({
|
96
|
-
'venv' => %i[
|
90
|
+
'venv' => %i[exec create remove show].freeze,
|
97
91
|
'pip' => %i[uninstall freeze].freeze,
|
98
92
|
'install' => %i[user force upgrade target editable].freeze,
|
99
93
|
'build' => %i[python poetry hatch].freeze,
|
100
|
-
'publish' => %i[poetry twine hatch].freeze
|
94
|
+
'publish' => %i[poetry twine hatch].freeze,
|
95
|
+
'exec' => nil
|
101
96
|
})
|
102
97
|
|
103
98
|
def ref
|
@@ -112,105 +107,130 @@ module Squared
|
|
112
107
|
Python.subtasks do |action, flags|
|
113
108
|
next if @pass.include?(action)
|
114
109
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
110
|
+
if flags.nil?
|
111
|
+
case action
|
112
|
+
when 'exec'
|
113
|
+
format_desc action, nil, 'command|:,args*'
|
114
|
+
task action do |_, args|
|
115
|
+
i = (args = args.to_a).delete(':')
|
116
|
+
cmd = if i && !workspace.windows?
|
117
|
+
readline('Enter script', force: true, multiline: ['##', ';'])
|
118
|
+
elsif i || args.empty?
|
119
|
+
readline('Enter command', force: true)
|
120
|
+
else
|
121
|
+
if (val = command_args(args, prefix: 'python'))
|
122
|
+
args << val
|
123
|
+
end
|
124
|
+
args.join(' ')
|
125
|
+
end
|
126
|
+
Kernel.exec(cmd, chdir: path)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
else
|
130
|
+
namespace action do
|
131
|
+
flags.each do |flag|
|
132
|
+
case action
|
133
|
+
when 'venv'
|
134
|
+
if flag == :create
|
135
|
+
format_desc action, flag, 'dir,opts*'
|
136
|
+
task flag, [:dir] do |_, args|
|
137
|
+
dir = path + param_guard(action, flag, args: args, key: :dir)
|
138
|
+
venv_create dir, args.extras
|
139
|
+
end
|
140
|
+
elsif venv
|
141
|
+
case flag
|
142
|
+
when :remove
|
143
|
+
next unless projectpath?(venv)
|
144
|
+
|
145
|
+
format_desc action, flag, 'c|create?,d|depend?'
|
146
|
+
task flag do |_, args|
|
147
|
+
rm_rf(venv, verbose: true)
|
148
|
+
venv_init if has_value?(%w[c create], args.to_a)
|
149
|
+
depend if has_value?(%w[d depend], args.to_a)
|
150
|
+
end
|
151
|
+
when :exec
|
152
|
+
format_desc action, flag, 'command,args*'
|
153
|
+
task flag do |_, args|
|
154
|
+
args = args.to_a
|
155
|
+
if args.empty?
|
156
|
+
args = readline('Enter command', force: true).split(' ', 2)
|
157
|
+
elsif args.size == 1 && !option('interactive', prefix: 'venv', equals: '0')
|
158
|
+
args << readline('Enter arguments', force: false)
|
159
|
+
end
|
160
|
+
venv_init
|
161
|
+
run args.join(' ')
|
162
|
+
end
|
163
|
+
when :show
|
164
|
+
format_desc action, flag
|
165
|
+
task flag do
|
166
|
+
puts venv
|
167
|
+
end
|
168
|
+
end
|
124
169
|
end
|
125
|
-
|
170
|
+
when 'pip'
|
126
171
|
case flag
|
127
|
-
when :
|
128
|
-
|
129
|
-
|
130
|
-
format_desc action, flag, 'c|create?,d|depend?'
|
172
|
+
when :freeze
|
173
|
+
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
131
174
|
task flag do |_, args|
|
132
|
-
|
133
|
-
|
134
|
-
|
175
|
+
if (file = pip(flag, args.to_a)) && verbose
|
176
|
+
puts File.read(file)
|
177
|
+
end
|
135
178
|
end
|
136
|
-
when :
|
137
|
-
format_desc action, flag, '
|
179
|
+
when :uninstall
|
180
|
+
format_desc action, flag, 'package+,opts*'
|
138
181
|
task flag do |_, args|
|
139
|
-
|
140
|
-
args = readline('Enter command', force: true).split(' ', 2) if args.empty?
|
141
|
-
venv_init
|
142
|
-
run session(*args, path: false)
|
143
|
-
end
|
144
|
-
when :show
|
145
|
-
format_desc action, flag
|
146
|
-
task flag do
|
147
|
-
puts venv
|
182
|
+
pip flag, args.to_a
|
148
183
|
end
|
149
184
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
185
|
+
when 'install'
|
186
|
+
format_desc(action, flag, 'opts*', before: case flag
|
187
|
+
when :target then 'dir'
|
188
|
+
when :editable then 'path/url?'
|
189
|
+
when :upgrade then 'strategy?,package+'
|
190
|
+
end)
|
191
|
+
case flag
|
192
|
+
when :editable
|
193
|
+
task flag do |_, args|
|
194
|
+
install flag, args.to_a
|
158
195
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
task flag, [:strategy] do |_, args|
|
179
|
-
case (strategy = args.strategy)
|
180
|
-
when 'eager', 'only-if-needed'
|
181
|
-
args = args.extras
|
182
|
-
else
|
183
|
-
args = args.to_a
|
184
|
-
strategy = nil
|
196
|
+
when :upgrade
|
197
|
+
task flag, [:strategy] do |_, args|
|
198
|
+
case (strategy = args.strategy)
|
199
|
+
when 'eager', 'only-if-needed'
|
200
|
+
args = args.extras
|
201
|
+
else
|
202
|
+
args = args.to_a
|
203
|
+
strategy = nil
|
204
|
+
end
|
205
|
+
install(flag, args, strategy: strategy)
|
206
|
+
end
|
207
|
+
when :target
|
208
|
+
task flag, [:dir] do |_, args|
|
209
|
+
dir = param_guard(action, flag, args: args, key: :dir)
|
210
|
+
depend(flag, args.extras, target: dir)
|
211
|
+
end
|
212
|
+
else
|
213
|
+
task flag do |_, args|
|
214
|
+
depend flag, args.to_a
|
185
215
|
end
|
186
|
-
install(flag, args, strategy: strategy)
|
187
216
|
end
|
188
|
-
when
|
189
|
-
|
190
|
-
|
191
|
-
|
217
|
+
when 'build'
|
218
|
+
format_desc(action, flag, 'opts*', after: case flag
|
219
|
+
when :python then 'srcdir?'
|
220
|
+
when :hatch then 'location?'
|
221
|
+
end)
|
222
|
+
task flag do |_, args|
|
223
|
+
build! flag, args.to_a
|
192
224
|
end
|
193
|
-
|
225
|
+
when 'publish'
|
226
|
+
format_desc(action, flag, 'opts*', after: case flag
|
227
|
+
when :hatch then 'artifacts?'
|
228
|
+
when :twine then 'dist?'
|
229
|
+
end)
|
194
230
|
task flag do |_, args|
|
195
|
-
|
231
|
+
publish flag, args.to_a
|
196
232
|
end
|
197
233
|
end
|
198
|
-
when 'build'
|
199
|
-
format_desc(action, flag, 'opts*', after: case flag
|
200
|
-
when :python then 'srcdir?'
|
201
|
-
when :hatch then 'location?'
|
202
|
-
end)
|
203
|
-
task flag do |_, args|
|
204
|
-
build! flag, args.to_a
|
205
|
-
end
|
206
|
-
when 'publish'
|
207
|
-
format_desc(action, flag, 'opts*', after: case flag
|
208
|
-
when :hatch then 'artifacts?'
|
209
|
-
when :twine then 'dist?'
|
210
|
-
end)
|
211
|
-
task flag do |_, args|
|
212
|
-
publish flag, args.to_a
|
213
|
-
end
|
214
234
|
end
|
215
235
|
end
|
216
236
|
end
|
@@ -432,7 +452,9 @@ module Squared
|
|
432
452
|
else
|
433
453
|
log.warn "variable_set: @#{key}=#{req} (not supported)"
|
434
454
|
end
|
435
|
-
when :
|
455
|
+
when :editable
|
456
|
+
editable_set val.first
|
457
|
+
when :venv
|
436
458
|
instance_variable_set(:"@#{key}", val.empty? ? nil : basepath(*val))
|
437
459
|
else
|
438
460
|
super
|
@@ -551,6 +573,15 @@ module Squared
|
|
551
573
|
append_nocolor(target: target)
|
552
574
|
end
|
553
575
|
|
576
|
+
def editable_set(val)
|
577
|
+
@editable = case val
|
578
|
+
when '.', Pathname
|
579
|
+
val
|
580
|
+
when String
|
581
|
+
Pathname.new(editable)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
554
585
|
def singleopt(flag = nil)
|
555
586
|
case flag
|
556
587
|
when :python
|