squared 0.4.19 → 0.4.21
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 +48 -0
- data/README.md +17 -13
- data/lib/squared/common/format.rb +3 -7
- data/lib/squared/common/shell.rb +3 -3
- data/lib/squared/common/system.rb +2 -3
- data/lib/squared/config.rb +3 -3
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +3 -1
- data/lib/squared/workspace/project/base.rb +83 -89
- data/lib/squared/workspace/project/docker.rb +14 -15
- data/lib/squared/workspace/project/git.rb +28 -31
- data/lib/squared/workspace/project/node.rb +32 -30
- data/lib/squared/workspace/project/python.rb +24 -32
- data/lib/squared/workspace/project/ruby.rb +108 -108
- data/lib/squared/workspace/project/support/class.rb +166 -42
- data/lib/squared/workspace/repo.rb +0 -3
- data/lib/squared/workspace/series.rb +16 -18
- metadata +1 -1
@@ -6,7 +6,7 @@ module Squared
|
|
6
6
|
class Docker < Base
|
7
7
|
COMPOSEFILE = %w[compose.yaml compose.yml docker-compose.yaml docker-compose.yml].freeze
|
8
8
|
BAKEFILE = %w[docker-bake.json docker-bake.hcl docker-bake.override.json docker-bake.override.hcl].freeze
|
9
|
-
DIR_DOCKER = (COMPOSEFILE + BAKEFILE).freeze
|
9
|
+
DIR_DOCKER = (COMPOSEFILE + BAKEFILE + ['Dockerfile']).freeze
|
10
10
|
OPT_DOCKER = {
|
11
11
|
common: %w[tls tlsverify config=p c|context=b D|debug H|host=q l|log-level=b tlscacert=p tlscert=p
|
12
12
|
tlskey=p].freeze,
|
@@ -91,7 +91,7 @@ module Squared
|
|
91
91
|
def config?(val)
|
92
92
|
return false unless (val = as_path(val))
|
93
93
|
|
94
|
-
|
94
|
+
DIR_DOCKER.any? { |file| val.join(file).exist? }
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -312,7 +312,7 @@ module Squared
|
|
312
312
|
append_context
|
313
313
|
when :bake, :compose
|
314
314
|
if (val = option(from == :bake ? 'target' : 'service', ignore: false))
|
315
|
-
ret.merge(split_escape(val).map! { |s|
|
315
|
+
ret.merge(split_escape(val).map! { |s| shell_quote(s) })
|
316
316
|
end
|
317
317
|
end
|
318
318
|
ret
|
@@ -401,7 +401,7 @@ module Squared
|
|
401
401
|
args << k
|
402
402
|
next
|
403
403
|
when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-path'
|
404
|
-
v =
|
404
|
+
v = basepath v
|
405
405
|
v = shell_quote(v, option: false, force: false) if q == ''
|
406
406
|
end
|
407
407
|
args << "#{k}=#{q + v + q}"
|
@@ -520,7 +520,7 @@ module Squared
|
|
520
520
|
list_image(flag, docker_output('image ls -a'), from: from) do |val|
|
521
521
|
op << val
|
522
522
|
if flag == :tag
|
523
|
-
op << tagname("#{@project}:#{op.
|
523
|
+
op << tagname("#{@project}:#{op.first}")
|
524
524
|
break
|
525
525
|
end
|
526
526
|
end
|
@@ -575,16 +575,15 @@ module Squared
|
|
575
575
|
end
|
576
576
|
|
577
577
|
def dockerfile(val = nil)
|
578
|
-
if val
|
579
|
-
@file = false
|
580
|
-
elsif val
|
578
|
+
if val
|
581
579
|
@file = if val.is_a?(Array)
|
582
580
|
val = val.select { |file| basepath(file).exist? }
|
583
581
|
val.size > 1 ? val : val.first
|
584
|
-
|
585
|
-
|
582
|
+
elsif val == true
|
583
|
+
DIR_DOCKER.find { |file| basepath(file).exist? }
|
584
|
+
elsif val != 'Dockerfile'
|
585
|
+
val
|
586
586
|
end
|
587
|
-
@file ||= false
|
588
587
|
end
|
589
588
|
basepath((@file.is_a?(Array) ? @file.first : @file) || 'Dockerfile')
|
590
589
|
end
|
@@ -622,17 +621,17 @@ module Squared
|
|
622
621
|
end
|
623
622
|
|
624
623
|
def append_file(type, target: @session)
|
625
|
-
return if ENV['COMPOSE_FILE'] && compose?(type)
|
624
|
+
return if !@file || (ENV['COMPOSE_FILE'] && compose?(type))
|
626
625
|
|
627
626
|
unless @file.is_a?(Array)
|
628
627
|
case type
|
629
628
|
when 2, 4
|
630
629
|
return
|
631
630
|
when 3
|
632
|
-
return unless COMPOSEFILE.map { |val|
|
631
|
+
return unless COMPOSEFILE.map { |val| basepath(val) }.select(&:exist?).size > 1
|
633
632
|
end
|
634
633
|
end
|
635
|
-
files = Array(@file).map { |val| quote_option('file',
|
634
|
+
files = Array(@file).map { |val| quote_option('file', basepath(val)) }
|
636
635
|
if target.is_a?(Set)
|
637
636
|
opts = target.to_a.insert(2, *files)
|
638
637
|
target.clear.merge(opts)
|
@@ -812,7 +811,7 @@ module Squared
|
|
812
811
|
end
|
813
812
|
|
814
813
|
def contextdir(val = nil)
|
815
|
-
val && projectpath?(val) ? shell_quote(
|
814
|
+
val && projectpath?(val) ? shell_quote(basepath(val)) : '.'
|
816
815
|
end
|
817
816
|
|
818
817
|
def tagjoin(*args, char: '/')
|
@@ -542,7 +542,7 @@ module Squared
|
|
542
542
|
commit1 = commithead args.commit1
|
543
543
|
if commit1
|
544
544
|
commit2 = commithead param_guard(action, flag, args: args, key: :commit2)
|
545
|
-
args = args.extras
|
545
|
+
args = args.extras
|
546
546
|
range = [commit1, commit2]
|
547
547
|
else
|
548
548
|
range, opts, refs = choice_commit(multiple: view ? true : 2, values: %w[Options Pathspec])
|
@@ -752,12 +752,12 @@ module Squared
|
|
752
752
|
args = args.extras
|
753
753
|
else
|
754
754
|
commit, mode = choice_commit(values: ['Mode [mixed|soft|hard|N]'])
|
755
|
-
args = args.extras.
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
755
|
+
args = args.extras.concat(case mode&.downcase
|
756
|
+
when 'h', 'hard' then ['hard']
|
757
|
+
when 's', 'soft' then ['soft']
|
758
|
+
when 'n', 'N' then ['mixed', 'N']
|
759
|
+
else ['mixed']
|
760
|
+
end)
|
761
761
|
end
|
762
762
|
print_success if success?(reset(flag, args, commit: commit))
|
763
763
|
end
|
@@ -992,7 +992,7 @@ module Squared
|
|
992
992
|
cur = nil
|
993
993
|
foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
|
994
994
|
line.chomp!
|
995
|
-
cur ||= line.
|
995
|
+
cur ||= line.sub!(/\A\* /, '')
|
996
996
|
heads << line if matchany?(line, reg)
|
997
997
|
end
|
998
998
|
raise_error('head not found', hint: 'for-each-ref') unless cur
|
@@ -1028,7 +1028,7 @@ module Squared
|
|
1028
1028
|
return unless upstream
|
1029
1029
|
|
1030
1030
|
op = OptionPartition.new(opts, OPT_GIT[:rebase], cmd, project: self, no: OPT_GIT[:no][:rebase])
|
1031
|
-
|
1031
|
+
op << upstream
|
1032
1032
|
append_head op.shift
|
1033
1033
|
op.clear(pass: false)
|
1034
1034
|
when :onto
|
@@ -1110,7 +1110,7 @@ module Squared
|
|
1110
1110
|
if op.empty?
|
1111
1111
|
values = [['Branch name', true]]
|
1112
1112
|
else
|
1113
|
-
op << op.
|
1113
|
+
op << op.shift
|
1114
1114
|
end
|
1115
1115
|
end
|
1116
1116
|
out = choice_index('Choose a stash', git_spawn('stash list', stdout: false),
|
@@ -1121,7 +1121,7 @@ module Squared
|
|
1121
1121
|
op << out
|
1122
1122
|
end
|
1123
1123
|
elsif !op.empty?
|
1124
|
-
op << op.
|
1124
|
+
op << op.shift
|
1125
1125
|
elsif flag == :branch
|
1126
1126
|
raise_error 'no branch name'
|
1127
1127
|
end
|
@@ -1234,7 +1234,7 @@ module Squared
|
|
1234
1234
|
start = epochtime
|
1235
1235
|
build(@output, sync: sync, from: :'git:revbuild')
|
1236
1236
|
rescue StandardError => e
|
1237
|
-
|
1237
|
+
print_error(e, pass: true)
|
1238
1238
|
else
|
1239
1239
|
print_status(name, subject: 'revbuild', start: start, from: :completed)
|
1240
1240
|
workspace.rev_write(name, { 'revision' => sha, 'files' => status_digest(*args, **kwargs) },
|
@@ -1265,7 +1265,6 @@ module Squared
|
|
1265
1265
|
end
|
1266
1266
|
when :patch
|
1267
1267
|
cmd << '--patch'
|
1268
|
-
append_pathspec(refs, pass: false)
|
1269
1268
|
when :undo
|
1270
1269
|
cmd << '--hard HEAD@{1}'
|
1271
1270
|
ref = false
|
@@ -1486,12 +1485,12 @@ module Squared
|
|
1486
1485
|
case flag
|
1487
1486
|
when :commit, :'no-commit'
|
1488
1487
|
op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
|
1489
|
-
raise_error 'no branch/commit' if op.empty?
|
1490
1488
|
op << "--#{flag}" << '--'
|
1491
1489
|
if branch
|
1492
1490
|
op << branch
|
1493
1491
|
op.clear(pass: false)
|
1494
1492
|
else
|
1493
|
+
raise_error 'no branch/commit' if op.empty?
|
1495
1494
|
append_commit(*op.extras)
|
1496
1495
|
end
|
1497
1496
|
else
|
@@ -1598,9 +1597,7 @@ module Squared
|
|
1598
1597
|
end
|
1599
1598
|
on :last, from
|
1600
1599
|
end
|
1601
|
-
if ret == 0
|
1602
|
-
warn log_message(Logger::WARN, name, 'no ref found', subject: 'branch', hint: 'head', pass: true)
|
1603
|
-
end
|
1600
|
+
print_error(name, 'no ref found', subject: 'branch', hint: 'head', pass: true) if ret == 0
|
1604
1601
|
return
|
1605
1602
|
end
|
1606
1603
|
return unless success?(source(stdout: stdout))
|
@@ -1748,8 +1745,8 @@ module Squared
|
|
1748
1745
|
end)
|
1749
1746
|
case flag
|
1750
1747
|
when :blame
|
1751
|
-
raise_error 'no file found' unless (n = op.index { |s| (
|
1752
|
-
op << '--' << shell_quote(
|
1748
|
+
raise_error 'no file found' unless (n = op.index { |s| basepath(s).file? })
|
1749
|
+
op << '--' << shell_quote(basepath(op.delete_at(n)))
|
1753
1750
|
op.clear
|
1754
1751
|
when :revert
|
1755
1752
|
if VAL_GIT[:rebase][:send].any? { |val| op.arg?(val) }
|
@@ -1813,7 +1810,10 @@ module Squared
|
|
1813
1810
|
from = nil
|
1814
1811
|
banner = nil
|
1815
1812
|
else
|
1816
|
-
|
1813
|
+
if banner
|
1814
|
+
banner = nil unless banner? && !multiple
|
1815
|
+
args = true
|
1816
|
+
end
|
1817
1817
|
if cmd.respond_to?(:done)
|
1818
1818
|
if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
|
1819
1819
|
from = :"git:#{from}"
|
@@ -1826,17 +1826,14 @@ module Squared
|
|
1826
1826
|
log&.info cmd
|
1827
1827
|
banner = if banner
|
1828
1828
|
banner = (banner.is_a?(String) ? banner : cmd).gsub(File.join(path, ''), '')
|
1829
|
-
format_banner(hint ? "#{banner} (#{hint})" : banner
|
1829
|
+
format_banner(hint ? "#{banner} (#{hint})" : banner)
|
1830
1830
|
end
|
1831
1831
|
on :first, from
|
1832
1832
|
begin
|
1833
1833
|
if io
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
banner ? [IO.popen(cmd), banner, from] : IO.popen(cmd)
|
1838
|
-
end
|
1839
|
-
return ret
|
1834
|
+
return `#{cmd}` if stdout
|
1835
|
+
|
1836
|
+
return args ? [IO.popen(cmd), banner || '', from] : IO.popen(cmd)
|
1840
1837
|
elsif stdin? ? sync : stdout
|
1841
1838
|
print_item banner unless multiple
|
1842
1839
|
ret = `#{cmd}`
|
@@ -1952,7 +1949,7 @@ module Squared
|
|
1952
1949
|
next if !glob.empty? && glob.none? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
|
1953
1950
|
next if !pass.empty? && pass.any? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
|
1954
1951
|
|
1955
|
-
ret[file] = algorithm.hexdigest(File.read(
|
1952
|
+
ret[file] = algorithm.hexdigest(File.read(basepath(file)))
|
1956
1953
|
end
|
1957
1954
|
ret
|
1958
1955
|
end
|
@@ -1984,7 +1981,7 @@ module Squared
|
|
1984
1981
|
when 'recurse-submodules'
|
1985
1982
|
op.append?($1, $2, type: :basic)
|
1986
1983
|
when 'refspec'
|
1987
|
-
refspec <<
|
1984
|
+
refspec << shell_quote($2)
|
1988
1985
|
end
|
1989
1986
|
elsif op.arg?('multiple')
|
1990
1987
|
op.found << opt
|
@@ -2002,12 +1999,12 @@ module Squared
|
|
2002
1999
|
end
|
2003
2000
|
op.delete('--all')
|
2004
2001
|
elsif op.arg?('multiple')
|
2005
|
-
op.
|
2002
|
+
op.add_quote(*op.found)
|
2006
2003
|
return
|
2007
2004
|
elsif option('all')
|
2008
2005
|
op << '--all'
|
2009
2006
|
end
|
2010
|
-
op.clear(errors: true, subject: flag
|
2007
|
+
op.clear(errors: true, subject: flag) if flag
|
2011
2008
|
end
|
2012
2009
|
|
2013
2010
|
def append_commit(*val, target: @session, head: false)
|
@@ -5,15 +5,17 @@ module Squared
|
|
5
5
|
module Project
|
6
6
|
class Node < Git
|
7
7
|
OPT_NPM = {
|
8
|
-
common: %w[dry-run include-workspace-root
|
9
|
-
install: %w[
|
10
|
-
|
8
|
+
common: %w[dry-run=!? include-workspace-root=!? loglevel=b workspaces=!? w|workspace=v].freeze,
|
9
|
+
install: %w[package-lock-only=!? prefer-dedupe=!? audit=! bin-links=! cpu=b fund=! libc=b os=b
|
10
|
+
package-lock=!].freeze,
|
11
|
+
install_base: %w[ignore-scripts=!? install-links=!? strict-peer-deps=!? include=b install-strategy=b
|
12
|
+
omit=b].freeze,
|
11
13
|
install_no: %w[audit bin-links fund package-lock].freeze,
|
12
|
-
install_as: %w[
|
13
|
-
|
14
|
-
run: %w[foreground-scripts if-present ignore-scripts script-shell=p].freeze,
|
14
|
+
install_as: %w[no-save save-bundle save-dev save-optional save-peer save-prod foreground-scripts=!?
|
15
|
+
g|global=!? S|save=!? E|save-exact=!?].freeze,
|
16
|
+
run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].freeze,
|
15
17
|
exec: %w[c|call=q package=b].freeze,
|
16
|
-
pack: %w[json
|
18
|
+
pack: %w[json=!? pack-destination=p].freeze
|
17
19
|
}.freeze
|
18
20
|
OPT_PNPM = {
|
19
21
|
common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b w|workspace-root].freeze,
|
@@ -106,7 +108,7 @@ module Squared
|
|
106
108
|
initialize_build(Node.ref, prod: prod?, **kwargs)
|
107
109
|
initialize_env(**kwargs)
|
108
110
|
end
|
109
|
-
@dependfile =
|
111
|
+
@dependfile = basepath 'package.json'
|
110
112
|
@pm = { __: init }
|
111
113
|
end
|
112
114
|
|
@@ -257,11 +259,6 @@ module Squared
|
|
257
259
|
otp = args.first
|
258
260
|
else
|
259
261
|
tag, otp = param_guard(action, flag, args: args)
|
260
|
-
unless SEM_VER.match?(tag)
|
261
|
-
a = sub_style(project, styles: theme[:active])
|
262
|
-
b = sub_style(tag, styles: theme[:inline])
|
263
|
-
exit 1 unless confirm("Publish #{a}@#{b}? [y/N] ", 'N')
|
264
|
-
end
|
265
262
|
end
|
266
263
|
publish(flag, otp: otp, tag: tag, dryrun: dryrun, access: access)
|
267
264
|
end
|
@@ -369,7 +366,7 @@ module Squared
|
|
369
366
|
subdir << target.to_s
|
370
367
|
end
|
371
368
|
begin
|
372
|
-
FileUtils.cp(
|
369
|
+
FileUtils.cp(basepath(s), dest, verbose: verbose.is_a?(Numeric) && verbose > 0)
|
373
370
|
rescue StandardError => e
|
374
371
|
print_error e
|
375
372
|
errors += 1
|
@@ -384,7 +381,7 @@ module Squared
|
|
384
381
|
end
|
385
382
|
glob = Array(glob || '**/*')
|
386
383
|
target = []
|
387
|
-
from =
|
384
|
+
from = basepath from
|
388
385
|
if workspace
|
389
386
|
Dir.glob(from + '*').each do |path|
|
390
387
|
next unless (path = Pathname.new(path)).directory?
|
@@ -469,7 +466,7 @@ module Squared
|
|
469
466
|
if flag == :add
|
470
467
|
cmd << "--save-#{save}"
|
471
468
|
cmd << '--save-exact' if exact
|
472
|
-
cmd.merge(packages.map { |pkg|
|
469
|
+
cmd.merge(packages.map { |pkg| shell_quote(pkg) })
|
473
470
|
end
|
474
471
|
cmd << '--workspaces=false' if env('NODE_WORKSPACES', equals: '0')
|
475
472
|
cmd << '--package-lock=false' if option('package-lock', equals: '0')
|
@@ -652,14 +649,19 @@ module Squared
|
|
652
649
|
end
|
653
650
|
|
654
651
|
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
|
655
|
-
|
656
|
-
|
652
|
+
unless version && !read_packagemanager(:private)
|
653
|
+
print_error('invalid task "publish"', subject: name, hint: version ? 'private' : nil)
|
657
654
|
return
|
658
655
|
end
|
659
656
|
cmd = session 'npm', 'publish'
|
660
657
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
661
|
-
cmd << basic_option('tag', tag) if tag ||= option('tag')
|
662
|
-
|
658
|
+
cmd << basic_option('tag', tag.tr(' ', '-')) if tag ||= option('tag')
|
659
|
+
case access || option('access')
|
660
|
+
when 'p', 'public'
|
661
|
+
cmd << '--access=public'
|
662
|
+
when 'r', 'restricted'
|
663
|
+
cmd << '--access=restricted'
|
664
|
+
end
|
663
665
|
dryrun ||= dryrun?('npm')
|
664
666
|
if dryrun
|
665
667
|
cmd << '--dry-run'
|
@@ -670,13 +672,13 @@ module Squared
|
|
670
672
|
if sync
|
671
673
|
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(npmname, styles: theme[:active])}")
|
672
674
|
else
|
675
|
+
require 'open3'
|
673
676
|
on :first, from
|
674
677
|
pwd_set(from: from, dryrun: dryrun) do
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
banner: banner)
|
678
|
+
cmd = session_done cmd
|
679
|
+
Open3.popen2e(cmd) do |_, out|
|
680
|
+
write_lines(out, banner: format_banner(cmd),
|
681
|
+
sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2])
|
680
682
|
end
|
681
683
|
end
|
682
684
|
on :last, from
|
@@ -716,7 +718,7 @@ module Squared
|
|
716
718
|
if opt =~ op.values
|
717
719
|
case $1
|
718
720
|
when 'w', 'workspace'
|
719
|
-
op << ($2.match?(%r{[\\/]}) ? quote_option($1,
|
721
|
+
op << ($2.match?(%r{[\\/]}) ? quote_option($1, basepath($2)) : shell_option($1, $2))
|
720
722
|
end
|
721
723
|
elsif opt.include?('=')
|
722
724
|
op.errors << opt
|
@@ -809,7 +811,7 @@ module Squared
|
|
809
811
|
|
810
812
|
case $1
|
811
813
|
when 'w', 'workspace'
|
812
|
-
op << ($2.match?(%r{[\\/]}) ? quote_option($1,
|
814
|
+
op << ($2.match?(%r{[\\/]}) ? quote_option($1, basepath($2)) : shell_option($1, $2))
|
813
815
|
op.found << opt
|
814
816
|
end
|
815
817
|
end
|
@@ -1025,9 +1027,9 @@ module Squared
|
|
1025
1027
|
|
1026
1028
|
def npmnotice
|
1027
1029
|
[
|
1028
|
-
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:
|
1029
|
-
{ pat: /^(npm )(error)(.*)$/, styles: color(:
|
1030
|
-
{ pat: /^(npm )(notice)(.*)$/, styles: color(:
|
1030
|
+
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:bright_cyan), index: 2 },
|
1031
|
+
{ pat: /^(npm )(error)(.*)$/, styles: color(:bright_red), index: 2 },
|
1032
|
+
{ pat: /^(npm )(notice)(.*)$/, styles: color(:bright_cyan), index: 2 },
|
1031
1033
|
{ pat: /^(npm )(.+)$/, styles: :bold }
|
1032
1034
|
]
|
1033
1035
|
end
|
@@ -37,8 +37,8 @@ module Squared
|
|
37
37
|
common: %w[I|ignore-python no-cache n|non-interactive].freeze,
|
38
38
|
build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
|
39
39
|
k|skip=b].freeze,
|
40
|
-
publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
|
41
|
-
|
40
|
+
publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
|
41
|
+
i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
|
42
42
|
}.freeze
|
43
43
|
OPT_HATCH = {
|
44
44
|
common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
|
@@ -207,7 +207,7 @@ module Squared
|
|
207
207
|
if flag == :create
|
208
208
|
format_desc action, flag, 'dir,opts*'
|
209
209
|
task flag, [:dir] do |_, args|
|
210
|
-
dir =
|
210
|
+
dir = basepath param_guard(action, flag, args: args, key: :dir)
|
211
211
|
venv_create dir, args.extras
|
212
212
|
end
|
213
213
|
elsif venv
|
@@ -245,10 +245,7 @@ module Squared
|
|
245
245
|
when :upgrade
|
246
246
|
format_desc action, flag, 'opts*'
|
247
247
|
task flag do |_, args|
|
248
|
-
|
249
|
-
args.unshift('upgrade')
|
250
|
-
args << 'pip'
|
251
|
-
install flag, args
|
248
|
+
install flag, ['upgrade', *args.to_a, 'pip']
|
252
249
|
end
|
253
250
|
when :freeze
|
254
251
|
format_desc action, flag, "file?=#{DEP_PYTHON[4]},opts*"
|
@@ -303,7 +300,7 @@ module Squared
|
|
303
300
|
when 'build'
|
304
301
|
case flag
|
305
302
|
when :poetry
|
306
|
-
next unless poetry
|
303
|
+
next unless build_backend == 'poetry.core.masonry.api'
|
307
304
|
when :pdm
|
308
305
|
next unless build_backend == 'pdm.backend'
|
309
306
|
when :hatch
|
@@ -351,7 +348,7 @@ module Squared
|
|
351
348
|
when :user
|
352
349
|
cmd << '--user'
|
353
350
|
when :target
|
354
|
-
cmd << quote_option('target',
|
351
|
+
cmd << quote_option('target', basepath(target))
|
355
352
|
when :force
|
356
353
|
cmd << '--force-reinstall'
|
357
354
|
end
|
@@ -474,11 +471,7 @@ module Squared
|
|
474
471
|
cmd << '--user' if user
|
475
472
|
cmd << basic_option('upgrade-strategy', strategy) if strategy
|
476
473
|
append_value out
|
477
|
-
if workspace.windows?
|
478
|
-
pip = cmd.to_a.drop(1)
|
479
|
-
cmd = python_session '-m pip'
|
480
|
-
cmd.merge(pip)
|
481
|
-
end
|
474
|
+
python_session('-m pip', *cmd.to_a.drop(1)) if workspace.windows?
|
482
475
|
end
|
483
476
|
run(from: :install)
|
484
477
|
end
|
@@ -515,7 +508,7 @@ module Squared
|
|
515
508
|
if op.arg?(*args)
|
516
509
|
op.push(srcdir)
|
517
510
|
else
|
518
|
-
op << quote_option(args.last,
|
511
|
+
op << quote_option(args.last, basepath(srcdir))
|
519
512
|
end
|
520
513
|
srcdir = nil
|
521
514
|
end
|
@@ -549,7 +542,7 @@ module Squared
|
|
549
542
|
end
|
550
543
|
op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
|
551
544
|
dist = lambda do
|
552
|
-
(
|
545
|
+
basepath('dist').tap do |dir|
|
553
546
|
raise_error('no source files found', hint: dir) unless dir.directory? && !dir.empty?
|
554
547
|
end
|
555
548
|
end
|
@@ -558,7 +551,7 @@ module Squared
|
|
558
551
|
if op.empty?
|
559
552
|
op.push("#{dist.call}/*")
|
560
553
|
else
|
561
|
-
op.map! { |val|
|
554
|
+
op.map! { |val| basepath(val) }
|
562
555
|
end
|
563
556
|
op.append
|
564
557
|
else
|
@@ -629,7 +622,7 @@ module Squared
|
|
629
622
|
def poetry_session(*cmd)
|
630
623
|
ret = session('poetry', *cmd, *preopts)
|
631
624
|
if (val = option('project', ignore: false))
|
632
|
-
ret << quote_option('project',
|
625
|
+
ret << quote_option('project', basepath(val))
|
633
626
|
end
|
634
627
|
ret
|
635
628
|
end
|
@@ -651,7 +644,7 @@ module Squared
|
|
651
644
|
end
|
652
645
|
|
653
646
|
def append_pip(flag, opts, target: @session, from: nil)
|
654
|
-
|
647
|
+
unless from && !opts.empty?
|
655
648
|
append_global(target: target)
|
656
649
|
return []
|
657
650
|
end
|
@@ -674,11 +667,11 @@ module Squared
|
|
674
667
|
end
|
675
668
|
op.swap
|
676
669
|
if edit
|
677
|
-
edit =
|
670
|
+
edit = basepath(edit) unless %r{\A[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
|
678
671
|
if flag == :editable
|
679
672
|
op.push(edit)
|
680
673
|
else
|
681
|
-
|
674
|
+
op << quote_option('e', edit)
|
682
675
|
end
|
683
676
|
end
|
684
677
|
case flag
|
@@ -689,25 +682,25 @@ module Squared
|
|
689
682
|
[]
|
690
683
|
end
|
691
684
|
else
|
692
|
-
|
685
|
+
op.extras
|
693
686
|
end
|
694
687
|
end
|
695
688
|
|
696
689
|
def append_editable(target: @session)
|
697
|
-
return if requirements?
|
690
|
+
return if requirements? && editable == '.'
|
698
691
|
|
699
692
|
if (val = option('editable', 'e', target: target, ignore: false))
|
700
|
-
|
693
|
+
OptionPartition.delete_key(target, 'e', 'editable')
|
701
694
|
case val
|
702
695
|
when '0', 'false'
|
703
696
|
return
|
704
697
|
else
|
705
|
-
val =
|
698
|
+
val = basepath val
|
706
699
|
end
|
707
700
|
elsif session_arg?('e', 'editable', target: target) || !(val = editable)
|
708
701
|
return
|
709
702
|
end
|
710
|
-
target << quote_option('e', val)
|
703
|
+
target << quote_option('e', basepath(val))
|
711
704
|
end
|
712
705
|
|
713
706
|
def append_global(target: @session)
|
@@ -716,11 +709,11 @@ module Squared
|
|
716
709
|
when '0', 'false'
|
717
710
|
'--no-cache-dir'
|
718
711
|
else
|
719
|
-
quote_option('cache-dir',
|
712
|
+
quote_option('cache-dir', basepath(val))
|
720
713
|
end
|
721
714
|
end
|
722
715
|
target << shell_option('proxy', val) if (val = option('proxy', target: target))
|
723
|
-
target << quote_option('python',
|
716
|
+
target << quote_option('python', basepath(val)) if (val = option('python', target: target))
|
724
717
|
append_nocolor(target: target)
|
725
718
|
end
|
726
719
|
|
@@ -842,7 +835,7 @@ module Squared
|
|
842
835
|
when '.', Pathname
|
843
836
|
val
|
844
837
|
when String
|
845
|
-
Pathname.new(
|
838
|
+
Pathname.new(val) unless val.empty?
|
846
839
|
end
|
847
840
|
end
|
848
841
|
|
@@ -853,8 +846,7 @@ module Squared
|
|
853
846
|
val, *opts = val
|
854
847
|
@venvopts = opts
|
855
848
|
end
|
856
|
-
@venv =
|
857
|
-
@venv = @path + @venv unless @venv.absolute?
|
849
|
+
@venv = basepath(val)
|
858
850
|
if projectpath?(@venv)
|
859
851
|
if @venv.exist?
|
860
852
|
log.debug "venv found: #{@venv}"
|
@@ -888,7 +880,7 @@ module Squared
|
|
888
880
|
end
|
889
881
|
|
890
882
|
def poetry?
|
891
|
-
|
883
|
+
dependtype == 1
|
892
884
|
end
|
893
885
|
|
894
886
|
def requirements?
|