squared 0.6.17 → 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 -176
- data/README.md +242 -205
- data/lib/squared/common/base.rb +0 -7
- data/lib/squared/common/format.rb +7 -10
- data/lib/squared/common/prompt.rb +24 -25
- data/lib/squared/common/shell.rb +27 -35
- data/lib/squared/common/system.rb +29 -21
- data/lib/squared/common/utils.rb +44 -63
- data/lib/squared/config.rb +17 -16
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +292 -186
- data/lib/squared/workspace/project/base.rb +566 -494
- data/lib/squared/workspace/project/docker.rb +177 -169
- data/lib/squared/workspace/project/git.rb +233 -203
- data/lib/squared/workspace/project/node.rb +119 -155
- data/lib/squared/workspace/project/python.rb +249 -162
- data/lib/squared/workspace/project/ruby.rb +408 -298
- data/lib/squared/workspace/project/support/class.rb +13 -7
- data/lib/squared/workspace/project/support/optionpartition.rb +72 -57
- 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 +93 -89
- data/lib/squared/workspace/support/base.rb +15 -1
- metadata +3 -2
|
@@ -5,10 +5,10 @@ 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
|
-
install_a: %w[audit=! bin-links=!
|
|
11
|
-
|
|
10
|
+
install_a: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
|
|
11
|
+
package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
12
12
|
install_b: %w[no-save B|save-bundle D|save-dev O|save-optional save-peer P|save-prod g|global=!?
|
|
13
13
|
S|save=!?].freeze,
|
|
14
14
|
run: %w[foreground-scripts=!? if-present=!? ignore-scripts=!? script-shell=p].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
|
|
@@ -181,7 +181,7 @@ module Squared
|
|
|
181
181
|
when 'add'
|
|
182
182
|
format_desc action, nil, 'save?=[=-]prod|dev|optional|peer|bundle,(-)name+'
|
|
183
183
|
task action, [:save] do |_, args|
|
|
184
|
-
packages = if args.save =~
|
|
184
|
+
packages = if args.save =~ /\A([=-]*)?(prod|dev|optional|peer|bundle)\z/
|
|
185
185
|
save = [$2, $1.include?('='), $1.include?('-')]
|
|
186
186
|
args.extras
|
|
187
187
|
else
|
|
@@ -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
|
|
@@ -526,39 +533,35 @@ module Squared
|
|
|
526
533
|
rm = lambda do |target|
|
|
527
534
|
return if remove.empty?
|
|
528
535
|
|
|
529
|
-
run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '),
|
|
536
|
+
run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), sync: sync, from: :remove)
|
|
530
537
|
end
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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')
|
|
534
546
|
else
|
|
535
|
-
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')
|
|
536
553
|
if yarn == 1
|
|
537
|
-
cmd << '--
|
|
538
|
-
|
|
539
|
-
cmd << '--
|
|
540
|
-
cmd << '--force' if option('force')
|
|
541
|
-
else
|
|
542
|
-
cmd << '--mode=skip-build' if option('ignore-scripts')
|
|
543
|
-
cmd << '--check-cache' if !flag && option('force')
|
|
544
|
-
end
|
|
545
|
-
if nolockfile?('yarn')
|
|
546
|
-
cmd << '--no-lockfile'
|
|
547
|
-
elsif option('ci')
|
|
548
|
-
if yarn == 1
|
|
549
|
-
cmd << '--frozen-lockfile'
|
|
550
|
-
elsif !flag
|
|
551
|
-
cmd << '--immutable' << '--refresh-lockfile'
|
|
552
|
-
end
|
|
553
|
-
end
|
|
554
|
-
if add
|
|
555
|
-
cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
|
|
556
|
-
rm.call(cmd)
|
|
557
|
-
om.call(cmd)
|
|
558
|
-
cmd << '--exact' if exact
|
|
554
|
+
cmd << '--frozen-lockfile'
|
|
555
|
+
elsif !flag
|
|
556
|
+
cmd << '--immutable' << '--refresh-lockfile'
|
|
559
557
|
end
|
|
560
558
|
end
|
|
561
|
-
|
|
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
|
|
562
565
|
elsif pnpm?
|
|
563
566
|
cmd = session('pnpm', flag || 'install')
|
|
564
567
|
append_nocolor
|
|
@@ -569,7 +572,6 @@ module Squared
|
|
|
569
572
|
cmd << '--save-exact' if exact
|
|
570
573
|
option('allow-build') { |val| cmd << quote_option('allow-build', val) }
|
|
571
574
|
else
|
|
572
|
-
cmd << '--prod' if prod?
|
|
573
575
|
append_platform
|
|
574
576
|
end
|
|
575
577
|
option('public-hoist-pattern') do |val|
|
|
@@ -586,37 +588,14 @@ module Squared
|
|
|
586
588
|
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
587
589
|
cmd << '--dangerously-allow-all-builds' if option('approve-builds')
|
|
588
590
|
else
|
|
589
|
-
cmd = session
|
|
590
|
-
option('
|
|
591
|
-
cmd = npm_output 'approve-scripts'
|
|
592
|
-
cmd << case val
|
|
593
|
-
when '1'
|
|
594
|
-
'--all --no-allow-scripts-pin'
|
|
595
|
-
when 'true', 'all'
|
|
596
|
-
'--all'
|
|
597
|
-
else
|
|
598
|
-
val.split(/\s+/).quote!.join(' ')
|
|
599
|
-
end
|
|
600
|
-
print_run cmd, silent?
|
|
601
|
-
run(cmd, banner: false)
|
|
602
|
-
end
|
|
603
|
-
option('engine-strict', ignore: false) do |val|
|
|
604
|
-
cmd << case val
|
|
605
|
-
when '0', 'false'
|
|
606
|
-
'--engine-strict=false'
|
|
607
|
-
else
|
|
608
|
-
'--engine-strict'
|
|
609
|
-
end
|
|
610
|
-
end
|
|
591
|
+
cmd = session 'npm'
|
|
592
|
+
cmd << (ci = option('ci') ? 'ci' : 'install')
|
|
611
593
|
cmd << '--workspaces=false' if ws
|
|
612
|
-
cmd << '--force' if option('force')
|
|
613
594
|
append_nocolor
|
|
614
595
|
append_loglevel
|
|
615
596
|
if omit
|
|
616
597
|
cmd << "--omit=#{save || omit}"
|
|
617
598
|
save = nil
|
|
618
|
-
elsif !add && prod?
|
|
619
|
-
cmd << '--include=prod'
|
|
620
599
|
end
|
|
621
600
|
unless ci
|
|
622
601
|
if add
|
|
@@ -635,7 +614,7 @@ module Squared
|
|
|
635
614
|
|
|
636
615
|
cmd.merge(packages.quote!)
|
|
637
616
|
end
|
|
638
|
-
run(from: flag || :depend
|
|
617
|
+
run(sync: sync, from: flag || :depend)
|
|
639
618
|
end
|
|
640
619
|
end
|
|
641
620
|
|
|
@@ -649,14 +628,14 @@ module Squared
|
|
|
649
628
|
banner = format_banner(cmd.temp(('--dry-run' if dryrun)))
|
|
650
629
|
print_item banner if sync
|
|
651
630
|
begin
|
|
652
|
-
data = pwd_set(dryrun: dryrun) { `#{cmd.temp('--json --loglevel=error')}` }
|
|
631
|
+
data = pwd_set(cmd, dryrun: dryrun) { `#{cmd.temp('--json --loglevel=error')}` }
|
|
653
632
|
doc = dependfile.read
|
|
654
633
|
json = JSON.parse(doc)
|
|
655
634
|
dep1 = json['dependencies'] || {}
|
|
656
635
|
dep2 = json['devDependencies'] || {}
|
|
657
636
|
target = json['name']
|
|
658
|
-
rescue
|
|
659
|
-
on_error(e,
|
|
637
|
+
rescue => e
|
|
638
|
+
on_error(e, dryrun: dryrun)
|
|
660
639
|
return
|
|
661
640
|
end
|
|
662
641
|
found = []
|
|
@@ -721,7 +700,7 @@ module Squared
|
|
|
721
700
|
when :patch
|
|
722
701
|
a == c && b == d && f[4] != w[4]
|
|
723
702
|
end
|
|
724
|
-
if upgrade && !w[
|
|
703
|
+
if upgrade && !w[5]
|
|
725
704
|
next if file == want
|
|
726
705
|
|
|
727
706
|
found << [key, file, want, if a != c
|
|
@@ -877,22 +856,17 @@ module Squared
|
|
|
877
856
|
package(:update, from: :update)
|
|
878
857
|
end
|
|
879
858
|
|
|
880
|
-
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil
|
|
881
|
-
workspace: false)
|
|
859
|
+
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil)
|
|
882
860
|
if read_package('private')
|
|
883
|
-
return if workspace
|
|
884
|
-
|
|
885
861
|
ws = children.select { |proj| proj.ref?(Node.ref) }
|
|
886
862
|
if ws.empty?
|
|
887
863
|
print_error('nothing to publish', subject: name, hint: 'private')
|
|
888
864
|
elsif confirm_basic('Publish workspace?', ws.map(&:name).join(', '), 'N')
|
|
889
|
-
ws.each
|
|
890
|
-
proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, workspace: true)
|
|
891
|
-
end
|
|
865
|
+
ws.each { |proj| proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun) }
|
|
892
866
|
end
|
|
893
867
|
return
|
|
894
868
|
end
|
|
895
|
-
return print_error(
|
|
869
|
+
return print_error("version: #{dependname}", subject: name, hint: 'not found') unless version
|
|
896
870
|
|
|
897
871
|
cmd = session 'npm', 'publish'
|
|
898
872
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
|
@@ -915,8 +889,9 @@ module Squared
|
|
|
915
889
|
else
|
|
916
890
|
require 'open3'
|
|
917
891
|
on :first, from
|
|
918
|
-
pwd_set(
|
|
919
|
-
|
|
892
|
+
pwd_set(cmd, dryrun: dryrun) do
|
|
893
|
+
cmd = session_done cmd
|
|
894
|
+
Open3.popen2e(cmd) do |_, out|
|
|
920
895
|
write_lines(out, banner: format_banner(cmd),
|
|
921
896
|
sub: npmnotice(opt_style(color(:bright_blue), /^(.+)(Tarball .+)$/, 2)))
|
|
922
897
|
end
|
|
@@ -961,7 +936,7 @@ module Squared
|
|
|
961
936
|
end, cmd, project: self)
|
|
962
937
|
if yarn == 1 && flag != :reinstall
|
|
963
938
|
op << '--no-lockfile' if nolockfile?('yarn')
|
|
964
|
-
op << '--ignore-engines'
|
|
939
|
+
op << '--ignore-engines' if option('ignore-engines')
|
|
965
940
|
end
|
|
966
941
|
else
|
|
967
942
|
args = if pnpm?
|
|
@@ -976,22 +951,18 @@ module Squared
|
|
|
976
951
|
flag = :install
|
|
977
952
|
end
|
|
978
953
|
flags = [flag]
|
|
979
|
-
unless flag == :rebuild
|
|
980
|
-
|
|
981
|
-
|
|
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
|
|
982
961
|
end
|
|
962
|
+
no = OPT_PNPM[:no][flag]
|
|
983
963
|
[
|
|
984
964
|
opts,
|
|
985
|
-
flags
|
|
986
|
-
unless flag == :dedupe
|
|
987
|
-
out << :common_filter
|
|
988
|
-
unless flag == :add
|
|
989
|
-
out << :install_b
|
|
990
|
-
out << :common_cpu unless flag == :update
|
|
991
|
-
end
|
|
992
|
-
end
|
|
993
|
-
pnpmopts(*out)
|
|
994
|
-
end,
|
|
965
|
+
pnpmopts(*flags),
|
|
995
966
|
session('pnpm', flag)
|
|
996
967
|
]
|
|
997
968
|
else
|
|
@@ -1013,12 +984,12 @@ module Squared
|
|
|
1013
984
|
unless flag == :dedupe
|
|
1014
985
|
%w[save ignore-scripts strict-peer-deps].each do |key|
|
|
1015
986
|
option(key, prefix: 'npm', ignore: false) do |val|
|
|
1016
|
-
opts << case val
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
987
|
+
opts << basic_option(key, case val
|
|
988
|
+
when '0', 'false'
|
|
989
|
+
false
|
|
990
|
+
else
|
|
991
|
+
true
|
|
992
|
+
end)
|
|
1022
993
|
end
|
|
1023
994
|
end
|
|
1024
995
|
flags << :install_b
|
|
@@ -1050,15 +1021,14 @@ module Squared
|
|
|
1050
1021
|
op.found << (spec == 2 && (n = opt.index('@')) ? opt[0, n] : opt)
|
|
1051
1022
|
end
|
|
1052
1023
|
end
|
|
1053
|
-
op.swap
|
|
1054
|
-
.concat(packages)
|
|
1024
|
+
op.swap.concat(packages)
|
|
1055
1025
|
raise_error ArgumentError, 'no packages to add' if op.empty? && spec == 1
|
|
1056
1026
|
op.append(quote: true)
|
|
1057
1027
|
.clear(errors: true)
|
|
1058
1028
|
else
|
|
1059
1029
|
op.clear
|
|
1060
1030
|
end
|
|
1061
|
-
run(from: from ||
|
|
1031
|
+
run(from: from || symjoin('package', flag))
|
|
1062
1032
|
end
|
|
1063
1033
|
|
|
1064
1034
|
def bump(flag, val = nil)
|
|
@@ -1088,8 +1058,8 @@ module Squared
|
|
|
1088
1058
|
else
|
|
1089
1059
|
raise_error 'version not found', hint: dependfile
|
|
1090
1060
|
end
|
|
1091
|
-
rescue
|
|
1092
|
-
on_error(e,
|
|
1061
|
+
rescue => e
|
|
1062
|
+
on_error(e, dryrun: dryrun?)
|
|
1093
1063
|
end
|
|
1094
1064
|
|
|
1095
1065
|
def pack(opts = [])
|
|
@@ -1149,11 +1119,9 @@ module Squared
|
|
|
1149
1119
|
print_run(cmd, banner, **kwargs)
|
|
1150
1120
|
session 'npx', cmd
|
|
1151
1121
|
start = time_epoch if kwargs.fetch(:verbose, verbose? && !stdin?)
|
|
1152
|
-
run(sync: sync, banner: banner, exception: kwargs.fetch(:exception, exception), from: from)
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
print_status(name, subject: 'tsc', start: start, from: :completed)
|
|
1156
|
-
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
|
|
1157
1125
|
end
|
|
1158
1126
|
|
|
1159
1127
|
def compose(target, opts = nil, script: false, args: nil, from: nil, **)
|
|
@@ -1272,12 +1240,8 @@ module Squared
|
|
|
1272
1240
|
|
|
1273
1241
|
private
|
|
1274
1242
|
|
|
1275
|
-
def npm_output(*cmd, **kwargs)
|
|
1276
|
-
session_output('npm', *cmd, **kwargs)
|
|
1277
|
-
end
|
|
1278
|
-
|
|
1279
1243
|
def read_package(key = 'packageManager', update: false)
|
|
1280
|
-
|
|
1244
|
+
unless !update && @pm.key?(key)
|
|
1281
1245
|
doc = JSON.parse(dependfile.read)
|
|
1282
1246
|
@pm[key] = case key
|
|
1283
1247
|
when 'packageManager'
|
|
@@ -1294,7 +1258,7 @@ module Squared
|
|
|
1294
1258
|
@pm[:_] = true
|
|
1295
1259
|
end
|
|
1296
1260
|
end
|
|
1297
|
-
rescue
|
|
1261
|
+
rescue => e
|
|
1298
1262
|
log.debug e
|
|
1299
1263
|
@pm[key] = nil
|
|
1300
1264
|
else
|
|
@@ -1337,7 +1301,7 @@ module Squared
|
|
|
1337
1301
|
else
|
|
1338
1302
|
1
|
|
1339
1303
|
end
|
|
1340
|
-
rescue
|
|
1304
|
+
rescue => e
|
|
1341
1305
|
return 0 if exist
|
|
1342
1306
|
|
|
1343
1307
|
log.debug e
|
|
@@ -1356,7 +1320,7 @@ module Squared
|
|
|
1356
1320
|
else
|
|
1357
1321
|
4
|
|
1358
1322
|
end
|
|
1359
|
-
rescue
|
|
1323
|
+
rescue => e
|
|
1360
1324
|
if exist
|
|
1361
1325
|
%w[pnpm-lock.yaml pnpm-workspace.yaml].any? { |val| exist?(val) } ? 4 : 0
|
|
1362
1326
|
else
|
|
@@ -1366,15 +1330,15 @@ module Squared
|
|
|
1366
1330
|
end
|
|
1367
1331
|
|
|
1368
1332
|
def remove_modules(prefix = dependbin)
|
|
1369
|
-
modules = basepath
|
|
1370
|
-
return false unless modules &&
|
|
1333
|
+
modules = basepath 'node_modules'
|
|
1334
|
+
return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
|
|
1371
1335
|
|
|
1372
1336
|
modules.rmtree
|
|
1373
1337
|
rescue Timeout::Error => e
|
|
1374
1338
|
puts
|
|
1375
1339
|
print_error(e, hint: modules, pass: true)
|
|
1376
1340
|
exit 1
|
|
1377
|
-
rescue
|
|
1341
|
+
rescue => e
|
|
1378
1342
|
print_error(e, pass: true)
|
|
1379
1343
|
false
|
|
1380
1344
|
else
|
|
@@ -1455,23 +1419,23 @@ module Squared
|
|
|
1455
1419
|
end
|
|
1456
1420
|
|
|
1457
1421
|
def lockfile(delete = false)
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
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?
|
|
1464
1428
|
if delete
|
|
1465
|
-
|
|
1429
|
+
ret.delete
|
|
1466
1430
|
return
|
|
1467
1431
|
end
|
|
1468
|
-
|
|
1469
|
-
elsif (
|
|
1470
|
-
|
|
1432
|
+
ret
|
|
1433
|
+
elsif (ret = rootpath(ret.basename, ascend: dependroot)).exist?
|
|
1434
|
+
ret
|
|
1471
1435
|
end
|
|
1472
|
-
rescue
|
|
1436
|
+
rescue => e
|
|
1473
1437
|
log.debug e
|
|
1474
|
-
|
|
1438
|
+
ret
|
|
1475
1439
|
end
|
|
1476
1440
|
|
|
1477
1441
|
def nolockfile?(prefix = dependbin)
|