squared 0.6.13 → 0.7.0
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 +69 -85
- data/README.md +242 -204
- data/lib/squared/common/format.rb +7 -10
- data/lib/squared/common/prompt.rb +23 -24
- data/lib/squared/common/shell.rb +21 -22
- data/lib/squared/common/system.rb +29 -21
- data/lib/squared/common/utils.rb +43 -54
- data/lib/squared/config.rb +17 -16
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +292 -180
- data/lib/squared/workspace/project/base.rb +559 -467
- data/lib/squared/workspace/project/docker.rb +166 -159
- data/lib/squared/workspace/project/git.rb +202 -168
- data/lib/squared/workspace/project/node.rb +115 -127
- data/lib/squared/workspace/project/python.rb +248 -160
- data/lib/squared/workspace/project/ruby.rb +403 -292
- data/lib/squared/workspace/project/support/class.rb +13 -7
- data/lib/squared/workspace/project/support/optionpartition.rb +70 -55
- data/lib/squared/workspace/project/support/utils.rb +68 -0
- data/lib/squared/workspace/project.rb +0 -7
- data/lib/squared/workspace/repo.rb +234 -169
- data/lib/squared/workspace/series.rb +91 -86
- data/lib/squared/workspace/support/base.rb +15 -1
- metadata +3 -2
|
@@ -5,7 +5,7 @@ module Squared
|
|
|
5
5
|
module Project
|
|
6
6
|
class Node < Git
|
|
7
7
|
OPT_NPM = {
|
|
8
|
-
common: %w[dry-run=!?
|
|
8
|
+
common: %w[dry-run=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
|
|
9
9
|
install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
|
|
10
10
|
install_a: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
|
|
11
11
|
package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
@@ -149,11 +149,11 @@ module Squared
|
|
|
149
149
|
'pack' => nil
|
|
150
150
|
})
|
|
151
151
|
|
|
152
|
-
def initialize(*,
|
|
152
|
+
def initialize(*, ts: 'tsconfig.json', asdf: 'nodejs', **kwargs)
|
|
153
153
|
super
|
|
154
154
|
if @pass.include?(Node.ref)
|
|
155
155
|
initialize_ref Node.ref
|
|
156
|
-
initialize_logger
|
|
156
|
+
initialize_logger kwargs[:log]
|
|
157
157
|
else
|
|
158
158
|
initialize_build(Node.ref, prod: prod?, **kwargs)
|
|
159
159
|
initialize_env(**kwargs)
|
|
@@ -161,7 +161,7 @@ module Squared
|
|
|
161
161
|
@dependname = 'package.json'
|
|
162
162
|
dependfile_set [@dependname]
|
|
163
163
|
@tsfile = basepath! ts
|
|
164
|
-
@pm = { __: init }
|
|
164
|
+
@pm = { __: kwargs[:init] }
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
def ref
|
|
@@ -201,23 +201,24 @@ module Squared
|
|
|
201
201
|
format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
|
|
202
202
|
else
|
|
203
203
|
args = param_guard(action, 'script', args: args.to_a)
|
|
204
|
-
opts = []
|
|
205
|
-
args.each do |val|
|
|
204
|
+
opts = args.each_with_object([]) do |val, out|
|
|
206
205
|
if (n, extra = indexitem(val))
|
|
207
206
|
if (item = list[n.pred])
|
|
208
207
|
run compose([item.first, extra].compact.join(' '), script: true)
|
|
209
208
|
elsif exception
|
|
210
209
|
indexerror n, list
|
|
211
210
|
else
|
|
212
|
-
|
|
211
|
+
log.warn "run script #{n} of #{list.size}".subhint('out of range')
|
|
212
|
+
next
|
|
213
213
|
end
|
|
214
214
|
else
|
|
215
|
-
|
|
215
|
+
out << val
|
|
216
216
|
end
|
|
217
217
|
end
|
|
218
218
|
next if opts.empty?
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
yarn = dependtype(:yarn)
|
|
221
|
+
list = if yarn > 0
|
|
221
222
|
yarn == 1 ? OPT_YARN[:run] + OPT_YARN[:common] : OPT_BERRY[:run]
|
|
222
223
|
elsif pnpm?
|
|
223
224
|
pnpmopts :run, :common_filter
|
|
@@ -260,14 +261,20 @@ module Squared
|
|
|
260
261
|
run(from: :exec)
|
|
261
262
|
end
|
|
262
263
|
when 'nvm'
|
|
263
|
-
next unless ENV['NVM_DIR']
|
|
264
|
+
next unless ENV['NVM_DIR'] && !workspace.windows?
|
|
264
265
|
|
|
265
|
-
format_desc action, nil, 'version
|
|
266
|
+
format_desc action, nil, 'version?,args*'
|
|
266
267
|
task action, [:version] do |_, args|
|
|
267
|
-
|
|
268
|
+
path = ->(s) { File.join(ENV['NVM_DIR'], s) }
|
|
269
|
+
unless (version = args.version)
|
|
270
|
+
cmd = ". #{path.call('nvm.sh')} && nvm list --no-colors --no-alias"
|
|
271
|
+
version = pwd_set(from: :nvm) do
|
|
272
|
+
choice_index('Select a version', IO.popen(cmd).map { |line| line[/\s(v\S+)/, 1] }, series: true)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
268
275
|
args = args.extras
|
|
269
276
|
args << readline('Enter command', force: true) if args.empty?
|
|
270
|
-
args.unshift(
|
|
277
|
+
args.unshift(path.call('nvm-exec'))
|
|
271
278
|
run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
|
|
272
279
|
end
|
|
273
280
|
when 'pack'
|
|
@@ -423,11 +430,12 @@ module Squared
|
|
|
423
430
|
begin
|
|
424
431
|
unless packed
|
|
425
432
|
require 'open3'
|
|
426
|
-
|
|
427
|
-
|
|
433
|
+
cmd = session_output 'npm', 'pack --dry-run --no-color', npmname
|
|
434
|
+
files = pwd_set(cmd, from: :'npm:pack') do
|
|
435
|
+
Open3.capture2e(cmd.to_s)
|
|
428
436
|
.first
|
|
429
437
|
.scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
|
|
430
|
-
.map
|
|
438
|
+
.map { |item| Pathname.new(item.first) }
|
|
431
439
|
.select(&:exist?)
|
|
432
440
|
end.concat(Array(files))
|
|
433
441
|
packed = true
|
|
@@ -435,21 +443,21 @@ module Squared
|
|
|
435
443
|
base = dest.join(into, npmname)
|
|
436
444
|
base.mkpath
|
|
437
445
|
log.info "cp npm:#{npmname} #{base}"
|
|
438
|
-
subdir = []
|
|
439
446
|
errors = 0
|
|
440
|
-
files.
|
|
441
|
-
s, d = file.is_a?(Array) ? file : [file
|
|
447
|
+
subdir = files.each_with_object([]) do |file, out|
|
|
448
|
+
s, d = file.is_a?(Array) ? file : [file] * 2
|
|
442
449
|
dest = base + d
|
|
443
|
-
|
|
450
|
+
target = dest.dirname
|
|
451
|
+
unless out.include?(dirname = target.to_s)
|
|
444
452
|
target.mkpath
|
|
445
|
-
|
|
453
|
+
out << dirname
|
|
446
454
|
end
|
|
447
455
|
FileUtils.cp(basepath(s), dest, verbose: !silent?)
|
|
448
|
-
rescue
|
|
449
|
-
print_error e
|
|
456
|
+
rescue => e
|
|
457
|
+
print_error(Logger::ERROR, e, subject: name)
|
|
450
458
|
errors += 1
|
|
451
459
|
end
|
|
452
|
-
rescue
|
|
460
|
+
rescue => e
|
|
453
461
|
on_error e, :copy
|
|
454
462
|
else
|
|
455
463
|
puts message(base, subdir.size, files.size - errors) unless silent?
|
|
@@ -469,9 +477,8 @@ module Squared
|
|
|
469
477
|
begin
|
|
470
478
|
doc = JSON.parse(file.read)
|
|
471
479
|
doc['name']
|
|
472
|
-
rescue
|
|
473
|
-
|
|
474
|
-
raise if exception
|
|
480
|
+
rescue => e
|
|
481
|
+
print_error(Logger::ERROR, e, subject: proj.name)
|
|
475
482
|
end
|
|
476
483
|
end
|
|
477
484
|
if sub
|
|
@@ -486,8 +493,8 @@ module Squared
|
|
|
486
493
|
target.each do |src, to|
|
|
487
494
|
glob.each { |val| log.info "cp #{from + val} #{to}" }
|
|
488
495
|
copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: !silent?)
|
|
489
|
-
rescue
|
|
490
|
-
on_error e
|
|
496
|
+
rescue => e
|
|
497
|
+
on_error e
|
|
491
498
|
end
|
|
492
499
|
end
|
|
493
500
|
on :last, :copy
|
|
@@ -499,7 +506,7 @@ module Squared
|
|
|
499
506
|
super
|
|
500
507
|
elsif outdated?
|
|
501
508
|
workspace.rev_clear(name, sync: sync)
|
|
502
|
-
return update if !flag && env('NODE_UPDATE')
|
|
509
|
+
return update if !flag && (env('UPDATE') || env('NODE_UPDATE'))
|
|
503
510
|
|
|
504
511
|
add = flag == :add
|
|
505
512
|
if add
|
|
@@ -508,7 +515,6 @@ module Squared
|
|
|
508
515
|
end
|
|
509
516
|
save, exact, omit = save if save.is_a?(Array)
|
|
510
517
|
ws = env('NODE_WORKSPACES', equals: '0')
|
|
511
|
-
ci = option('ci')
|
|
512
518
|
om = lambda do |cmd|
|
|
513
519
|
if omit
|
|
514
520
|
save = case save
|
|
@@ -527,39 +533,35 @@ module Squared
|
|
|
527
533
|
rm = lambda do |target|
|
|
528
534
|
return if remove.empty?
|
|
529
535
|
|
|
530
|
-
run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '),
|
|
536
|
+
run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), sync: sync, from: :remove)
|
|
531
537
|
end
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
538
|
+
yarn = dependtype(:yarn)
|
|
539
|
+
if yarn > 0
|
|
540
|
+
cmd = session('yarn', flag || 'install')
|
|
541
|
+
append_loglevel
|
|
542
|
+
if yarn == 1
|
|
543
|
+
cmd << '--ignore-engines' if option('ignore-engines')
|
|
544
|
+
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
545
|
+
cmd << '--force' if option('force')
|
|
535
546
|
else
|
|
536
|
-
cmd
|
|
547
|
+
cmd << '--mode=skip-build' if option('ignore-scripts')
|
|
548
|
+
cmd << '--check-cache' if !flag && option('force')
|
|
549
|
+
end
|
|
550
|
+
if nolockfile?('yarn')
|
|
551
|
+
cmd << '--no-lockfile'
|
|
552
|
+
elsif option('ci')
|
|
537
553
|
if yarn == 1
|
|
538
|
-
cmd << '--
|
|
539
|
-
|
|
540
|
-
cmd << '--
|
|
541
|
-
cmd << '--force' if option('force')
|
|
542
|
-
else
|
|
543
|
-
cmd << '--mode=skip-build' if option('ignore-scripts')
|
|
544
|
-
cmd << '--check-cache' if !flag && option('force')
|
|
545
|
-
end
|
|
546
|
-
if nolockfile?('yarn')
|
|
547
|
-
cmd << '--no-lockfile'
|
|
548
|
-
elsif ci
|
|
549
|
-
if yarn == 1
|
|
550
|
-
cmd << '--frozen-lockfile'
|
|
551
|
-
elsif !flag
|
|
552
|
-
cmd << '--immutable' << '--refresh-lockfile'
|
|
553
|
-
end
|
|
554
|
-
end
|
|
555
|
-
if add
|
|
556
|
-
cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
|
|
557
|
-
rm.call(cmd)
|
|
558
|
-
om.call(cmd)
|
|
559
|
-
cmd << '--exact' if exact
|
|
554
|
+
cmd << '--frozen-lockfile'
|
|
555
|
+
elsif !flag
|
|
556
|
+
cmd << '--immutable' << '--refresh-lockfile'
|
|
560
557
|
end
|
|
561
558
|
end
|
|
562
|
-
|
|
559
|
+
if add
|
|
560
|
+
cmd << '-W' if yarn == 1 && option('w', 'ignore-workspace-root-check', notequals: '0')
|
|
561
|
+
rm.call(cmd)
|
|
562
|
+
om.call(cmd)
|
|
563
|
+
cmd << '--exact' if exact
|
|
564
|
+
end
|
|
563
565
|
elsif pnpm?
|
|
564
566
|
cmd = session('pnpm', flag || 'install')
|
|
565
567
|
append_nocolor
|
|
@@ -570,7 +572,6 @@ module Squared
|
|
|
570
572
|
cmd << '--save-exact' if exact
|
|
571
573
|
option('allow-build') { |val| cmd << quote_option('allow-build', val) }
|
|
572
574
|
else
|
|
573
|
-
cmd << '--prod' if prod?
|
|
574
575
|
append_platform
|
|
575
576
|
end
|
|
576
577
|
option('public-hoist-pattern') do |val|
|
|
@@ -581,22 +582,20 @@ module Squared
|
|
|
581
582
|
'--force'
|
|
582
583
|
elsif nolockfile?('pnpm')
|
|
583
584
|
'--no-lockfile'
|
|
584
|
-
elsif ci
|
|
585
|
+
elsif option('ci')
|
|
585
586
|
'--frozen-lockfile'
|
|
586
587
|
end
|
|
587
588
|
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
588
589
|
cmd << '--dangerously-allow-all-builds' if option('approve-builds')
|
|
589
590
|
else
|
|
590
|
-
cmd = session
|
|
591
|
+
cmd = session 'npm'
|
|
592
|
+
cmd << (ci = option('ci') ? 'ci' : 'install')
|
|
591
593
|
cmd << '--workspaces=false' if ws
|
|
592
|
-
cmd << '--force' if option('force')
|
|
593
594
|
append_nocolor
|
|
594
595
|
append_loglevel
|
|
595
596
|
if omit
|
|
596
597
|
cmd << "--omit=#{save || omit}"
|
|
597
598
|
save = nil
|
|
598
|
-
elsif !add && prod?
|
|
599
|
-
cmd << '--include=prod'
|
|
600
599
|
end
|
|
601
600
|
unless ci
|
|
602
601
|
if add
|
|
@@ -615,7 +614,7 @@ module Squared
|
|
|
615
614
|
|
|
616
615
|
cmd.merge(packages.quote!)
|
|
617
616
|
end
|
|
618
|
-
run(from: flag || :depend
|
|
617
|
+
run(sync: sync, from: flag || :depend)
|
|
619
618
|
end
|
|
620
619
|
end
|
|
621
620
|
|
|
@@ -629,14 +628,14 @@ module Squared
|
|
|
629
628
|
banner = format_banner(cmd.temp(('--dry-run' if dryrun)))
|
|
630
629
|
print_item banner if sync
|
|
631
630
|
begin
|
|
632
|
-
data = pwd_set(dryrun: dryrun) { `#{cmd.temp('--json --loglevel=error')}` }
|
|
631
|
+
data = pwd_set(cmd, dryrun: dryrun) { `#{cmd.temp('--json --loglevel=error')}` }
|
|
633
632
|
doc = dependfile.read
|
|
634
633
|
json = JSON.parse(doc)
|
|
635
634
|
dep1 = json['dependencies'] || {}
|
|
636
635
|
dep2 = json['devDependencies'] || {}
|
|
637
636
|
target = json['name']
|
|
638
|
-
rescue
|
|
639
|
-
on_error(e,
|
|
637
|
+
rescue => e
|
|
638
|
+
on_error(e, dryrun: dryrun)
|
|
640
639
|
return
|
|
641
640
|
end
|
|
642
641
|
found = []
|
|
@@ -857,22 +856,17 @@ module Squared
|
|
|
857
856
|
package(:update, from: :update)
|
|
858
857
|
end
|
|
859
858
|
|
|
860
|
-
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil
|
|
861
|
-
workspace: false)
|
|
859
|
+
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
|
|
862
860
|
if read_package('private')
|
|
863
|
-
return if workspace
|
|
864
|
-
|
|
865
861
|
ws = children.select { |proj| proj.ref?(Node.ref) }
|
|
866
862
|
if ws.empty?
|
|
867
863
|
print_error('nothing to publish', subject: name, hint: 'private')
|
|
868
864
|
elsif confirm_basic('Publish workspace?', ws.map(&:name).join(', '), 'N')
|
|
869
|
-
ws.each
|
|
870
|
-
proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, workspace: true)
|
|
871
|
-
end
|
|
865
|
+
ws.each { |proj| proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun) }
|
|
872
866
|
end
|
|
873
867
|
return
|
|
874
868
|
end
|
|
875
|
-
return print_error(
|
|
869
|
+
return print_error("version: #{dependname}", subject: name, hint: 'not found') unless version
|
|
876
870
|
|
|
877
871
|
cmd = session 'npm', 'publish'
|
|
878
872
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
|
@@ -895,8 +889,9 @@ module Squared
|
|
|
895
889
|
else
|
|
896
890
|
require 'open3'
|
|
897
891
|
on :first, from
|
|
898
|
-
pwd_set(
|
|
899
|
-
|
|
892
|
+
pwd_set(cmd, dryrun: dryrun) do
|
|
893
|
+
cmd = session_done cmd
|
|
894
|
+
Open3.popen2e(cmd) do |_, out|
|
|
900
895
|
write_lines(out, banner: format_banner(cmd),
|
|
901
896
|
sub: npmnotice(opt_style(color(:bright_blue), /^(.+)(Tarball .+)$/, 2)))
|
|
902
897
|
end
|
|
@@ -941,7 +936,7 @@ module Squared
|
|
|
941
936
|
end, cmd, project: self)
|
|
942
937
|
if yarn == 1 && flag != :reinstall
|
|
943
938
|
op << '--no-lockfile' if nolockfile?('yarn')
|
|
944
|
-
op << '--ignore-engines'
|
|
939
|
+
op << '--ignore-engines' if option('ignore-engines')
|
|
945
940
|
end
|
|
946
941
|
else
|
|
947
942
|
args = if pnpm?
|
|
@@ -956,22 +951,18 @@ module Squared
|
|
|
956
951
|
flag = :install
|
|
957
952
|
end
|
|
958
953
|
flags = [flag]
|
|
959
|
-
unless flag == :rebuild
|
|
960
|
-
|
|
961
|
-
|
|
954
|
+
flags << :install_a unless flag == :rebuild
|
|
955
|
+
unless flag == :dedupe
|
|
956
|
+
flags << :common_filter
|
|
957
|
+
unless flag == :add
|
|
958
|
+
flags << :install_b
|
|
959
|
+
flags << :common_cpu unless flag == :update
|
|
960
|
+
end
|
|
962
961
|
end
|
|
962
|
+
no = OPT_PNPM[:no][flag]
|
|
963
963
|
[
|
|
964
964
|
opts,
|
|
965
|
-
flags
|
|
966
|
-
unless flag == :dedupe
|
|
967
|
-
out << :common_filter
|
|
968
|
-
unless flag == :add
|
|
969
|
-
out << :install_b
|
|
970
|
-
out << :common_cpu unless flag == :update
|
|
971
|
-
end
|
|
972
|
-
end
|
|
973
|
-
pnpmopts(*out)
|
|
974
|
-
end,
|
|
965
|
+
pnpmopts(*flags),
|
|
975
966
|
session('pnpm', flag)
|
|
976
967
|
]
|
|
977
968
|
else
|
|
@@ -993,12 +984,12 @@ module Squared
|
|
|
993
984
|
unless flag == :dedupe
|
|
994
985
|
%w[save ignore-scripts strict-peer-deps].each do |key|
|
|
995
986
|
option(key, prefix: 'npm', ignore: false) do |val|
|
|
996
|
-
opts << case val
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
987
|
+
opts << basic_option(key, case val
|
|
988
|
+
when '0', 'false'
|
|
989
|
+
false
|
|
990
|
+
else
|
|
991
|
+
true
|
|
992
|
+
end)
|
|
1002
993
|
end
|
|
1003
994
|
end
|
|
1004
995
|
flags << :install_b
|
|
@@ -1030,15 +1021,14 @@ module Squared
|
|
|
1030
1021
|
op.found << (spec == 2 && (n = opt.index('@')) ? opt[0, n] : opt)
|
|
1031
1022
|
end
|
|
1032
1023
|
end
|
|
1033
|
-
op.swap
|
|
1034
|
-
.concat(packages)
|
|
1024
|
+
op.swap.concat(packages)
|
|
1035
1025
|
raise_error ArgumentError, 'no packages to add' if op.empty? && spec == 1
|
|
1036
1026
|
op.append(quote: true)
|
|
1037
1027
|
.clear(errors: true)
|
|
1038
1028
|
else
|
|
1039
1029
|
op.clear
|
|
1040
1030
|
end
|
|
1041
|
-
run(from: from ||
|
|
1031
|
+
run(from: from || symjoin('package', flag))
|
|
1042
1032
|
end
|
|
1043
1033
|
|
|
1044
1034
|
def bump(flag, val = nil)
|
|
@@ -1068,8 +1058,8 @@ module Squared
|
|
|
1068
1058
|
else
|
|
1069
1059
|
raise_error 'version not found', hint: dependfile
|
|
1070
1060
|
end
|
|
1071
|
-
rescue
|
|
1072
|
-
on_error(e,
|
|
1061
|
+
rescue => e
|
|
1062
|
+
on_error(e, dryrun: dryrun?)
|
|
1073
1063
|
end
|
|
1074
1064
|
|
|
1075
1065
|
def pack(opts = [])
|
|
@@ -1129,11 +1119,9 @@ module Squared
|
|
|
1129
1119
|
print_run(cmd, banner, **kwargs)
|
|
1130
1120
|
session 'npx', cmd
|
|
1131
1121
|
start = time_epoch if kwargs.fetch(:verbose, verbose? && !stdin?)
|
|
1132
|
-
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: from)
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
print_status(name, subject: 'tsc', start: start, from: :completed)
|
|
1136
|
-
end
|
|
1122
|
+
ret = run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception?), from: from)
|
|
1123
|
+
print_status(name, subject: 'tsc', start: start) if success?(ret, banner, start.nil?) && start
|
|
1124
|
+
ret
|
|
1137
1125
|
end
|
|
1138
1126
|
|
|
1139
1127
|
def compose(target, opts = nil, script: false, args: nil, from: nil, **)
|
|
@@ -1253,7 +1241,7 @@ module Squared
|
|
|
1253
1241
|
private
|
|
1254
1242
|
|
|
1255
1243
|
def read_package(key = 'packageManager', update: false)
|
|
1256
|
-
|
|
1244
|
+
unless !update && @pm.key?(key)
|
|
1257
1245
|
doc = JSON.parse(dependfile.read)
|
|
1258
1246
|
@pm[key] = case key
|
|
1259
1247
|
when 'packageManager'
|
|
@@ -1270,7 +1258,7 @@ module Squared
|
|
|
1270
1258
|
@pm[:_] = true
|
|
1271
1259
|
end
|
|
1272
1260
|
end
|
|
1273
|
-
rescue
|
|
1261
|
+
rescue => e
|
|
1274
1262
|
log.debug e
|
|
1275
1263
|
@pm[key] = nil
|
|
1276
1264
|
else
|
|
@@ -1313,7 +1301,7 @@ module Squared
|
|
|
1313
1301
|
else
|
|
1314
1302
|
1
|
|
1315
1303
|
end
|
|
1316
|
-
rescue
|
|
1304
|
+
rescue => e
|
|
1317
1305
|
return 0 if exist
|
|
1318
1306
|
|
|
1319
1307
|
log.debug e
|
|
@@ -1332,7 +1320,7 @@ module Squared
|
|
|
1332
1320
|
else
|
|
1333
1321
|
4
|
|
1334
1322
|
end
|
|
1335
|
-
rescue
|
|
1323
|
+
rescue => e
|
|
1336
1324
|
if exist
|
|
1337
1325
|
%w[pnpm-lock.yaml pnpm-workspace.yaml].any? { |val| exist?(val) } ? 4 : 0
|
|
1338
1326
|
else
|
|
@@ -1343,14 +1331,14 @@ module Squared
|
|
|
1343
1331
|
|
|
1344
1332
|
def remove_modules(prefix = dependbin)
|
|
1345
1333
|
modules = basepath 'node_modules'
|
|
1346
|
-
return false unless modules.directory? &&
|
|
1334
|
+
return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
|
|
1347
1335
|
|
|
1348
1336
|
modules.rmtree
|
|
1349
1337
|
rescue Timeout::Error => e
|
|
1350
1338
|
puts
|
|
1351
1339
|
print_error(e, hint: modules, pass: true)
|
|
1352
1340
|
exit 1
|
|
1353
|
-
rescue
|
|
1341
|
+
rescue => e
|
|
1354
1342
|
print_error(e, pass: true)
|
|
1355
1343
|
false
|
|
1356
1344
|
else
|
|
@@ -1431,23 +1419,23 @@ module Squared
|
|
|
1431
1419
|
end
|
|
1432
1420
|
|
|
1433
1421
|
def lockfile(delete = false)
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
if
|
|
1422
|
+
ret = basepath(if yarn?
|
|
1423
|
+
'yarn.lock'
|
|
1424
|
+
else
|
|
1425
|
+
pnpm? ? 'pnpm-lock.yaml' : 'package-lock.json'
|
|
1426
|
+
end)
|
|
1427
|
+
if ret.exist?
|
|
1440
1428
|
if delete
|
|
1441
|
-
|
|
1429
|
+
ret.delete
|
|
1442
1430
|
return
|
|
1443
1431
|
end
|
|
1444
|
-
|
|
1445
|
-
elsif (
|
|
1446
|
-
|
|
1432
|
+
ret
|
|
1433
|
+
elsif (ret = rootpath(ret.basename, ascend: dependroot)).exist?
|
|
1434
|
+
ret
|
|
1447
1435
|
end
|
|
1448
|
-
rescue
|
|
1436
|
+
rescue => e
|
|
1449
1437
|
log.debug e
|
|
1450
|
-
|
|
1438
|
+
ret
|
|
1451
1439
|
end
|
|
1452
1440
|
|
|
1453
1441
|
def nolockfile?(prefix = dependbin)
|