squared 0.7.10 → 0.8.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 +44 -79
- data/README.md +38 -35
- data/lib/squared/common/base.rb +0 -8
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +26 -25
- data/lib/squared/common/shell.rb +11 -11
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +18 -22
- data/lib/squared/config.rb +5 -12
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -31
- data/lib/squared/workspace/project/base.rb +81 -88
- data/lib/squared/workspace/project/docker.rb +42 -41
- data/lib/squared/workspace/project/git.rb +169 -72
- data/lib/squared/workspace/project/node.rb +171 -135
- data/lib/squared/workspace/project/python.rb +51 -50
- data/lib/squared/workspace/project/ruby.rb +54 -46
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +7 -10
- data/lib/squared/workspace/project/support/utils.rb +15 -22
- data/lib/squared/workspace/repo.rb +9 -6
- data/lib/squared/workspace/series.rb +12 -5
- metadata +2 -2
|
@@ -8,8 +8,8 @@ module Squared
|
|
|
8
8
|
common: %w[dry-run=!? force=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
|
|
9
9
|
common_scripts: %w[dangerously-allow-all-scripts=!? strict-allow-scripts=!? allow-scripts=q].freeze,
|
|
10
10
|
install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
|
|
11
|
-
install_a: %w[audit=! bin-links=!
|
|
12
|
-
|
|
11
|
+
install_a: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
|
|
12
|
+
package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
13
13
|
install_b: %w[no-save B|save-bundle D|save-dev O|save-optional save-peer P|save-prod g|global=!?
|
|
14
14
|
S|save=!?].freeze,
|
|
15
15
|
install_c: %w[allow-directory=b? allow-file=b? allow-git=b? allow-remote=b?].freeze,
|
|
@@ -159,13 +159,13 @@ module Squared
|
|
|
159
159
|
subtasks({
|
|
160
160
|
'package' => %i[install add update dedupe approve deny rebuild reinstall].freeze,
|
|
161
161
|
'outdated' => %i[major minor patch].freeze,
|
|
162
|
-
'
|
|
163
|
-
'publish' => %i[latest tag verify].freeze,
|
|
162
|
+
'publish' => %i[latest tag stage verify].freeze,
|
|
164
163
|
'tsc' => %i[project build].freeze,
|
|
165
164
|
'add' => nil,
|
|
166
165
|
'run' => nil,
|
|
167
166
|
'exec' => nil,
|
|
168
167
|
'nvm' => nil,
|
|
168
|
+
'bump' => nil,
|
|
169
169
|
'pack' => nil
|
|
170
170
|
})
|
|
171
171
|
|
|
@@ -297,6 +297,18 @@ module Squared
|
|
|
297
297
|
args.unshift(path.call('nvm-exec'))
|
|
298
298
|
run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
|
|
299
299
|
end
|
|
300
|
+
when 'bump'
|
|
301
|
+
format_desc action, nil, 'version|pre?{major,minor,patch}|prerelease'
|
|
302
|
+
task action, [:version] do |_, args|
|
|
303
|
+
version = param_guard(action, 'to', args: args, key: :version)
|
|
304
|
+
if version.match?(/^((pre)?(major|minor|patch))|prerelease$/)
|
|
305
|
+
flag = version.to_sym
|
|
306
|
+
version = nil
|
|
307
|
+
else
|
|
308
|
+
flag = :version
|
|
309
|
+
end
|
|
310
|
+
bump flag, version
|
|
311
|
+
end
|
|
300
312
|
when 'pack'
|
|
301
313
|
format_desc action, nil, 'opts*'
|
|
302
314
|
task action do |_, args|
|
|
@@ -315,27 +327,12 @@ module Squared
|
|
|
315
327
|
when 'package'
|
|
316
328
|
format_desc(action, flag, 'opts*', before: case flag
|
|
317
329
|
when :dedupe, :rebuild then nil
|
|
318
|
-
when :reinstall then '
|
|
330
|
+
when :reinstall then 'force?'
|
|
319
331
|
else 'name*'
|
|
320
332
|
end)
|
|
321
333
|
task flag do |_, args|
|
|
322
334
|
package flag, args.to_a
|
|
323
335
|
end
|
|
324
|
-
when 'bump'
|
|
325
|
-
break unless version
|
|
326
|
-
|
|
327
|
-
if flag == :version
|
|
328
|
-
format_desc action, flag, 'version'
|
|
329
|
-
task flag, [:version] do |_, args|
|
|
330
|
-
version = param_guard(action, flag, args: args, key: :version)
|
|
331
|
-
bump flag, version
|
|
332
|
-
end
|
|
333
|
-
else
|
|
334
|
-
format_desc action, flag
|
|
335
|
-
task flag do
|
|
336
|
-
bump flag
|
|
337
|
-
end
|
|
338
|
-
end
|
|
339
336
|
when 'publish'
|
|
340
337
|
if flag == :verify
|
|
341
338
|
format_desc action, flag, 'version?,ext*'
|
|
@@ -348,22 +345,70 @@ module Squared
|
|
|
348
345
|
publish(flag, version: version, ext: ext)
|
|
349
346
|
end
|
|
350
347
|
else
|
|
351
|
-
format_desc(action, flag,
|
|
352
|
-
|
|
348
|
+
format_desc(action, flag,
|
|
349
|
+
"otp?,#{'registry?,' if flag == :stage}p/ublic|r/estricted?,d/ry-run?",
|
|
350
|
+
before: case flag
|
|
351
|
+
when :tag then 'tag'
|
|
352
|
+
when :stage then '{select=view,approve,reject,download}|publish=tag?'
|
|
353
|
+
end)
|
|
353
354
|
task flag do |_, args|
|
|
354
355
|
args = args.to_a
|
|
355
|
-
access =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
356
|
+
access = nil
|
|
357
|
+
dryrun = nil
|
|
358
|
+
stage = []
|
|
359
|
+
parse = lambda do
|
|
360
|
+
access = if has_value!(args, 'r', 'restricted')
|
|
361
|
+
'restricted'
|
|
362
|
+
elsif has_value!(args, 'p', 'public')
|
|
363
|
+
'public'
|
|
364
|
+
end
|
|
365
|
+
dryrun = has_value!(args, 'd', 'dry-run')
|
|
366
|
+
end
|
|
367
|
+
case flag
|
|
368
|
+
when :stage
|
|
369
|
+
case args.first
|
|
370
|
+
when 'view', 'approve', 'reject', 'download'
|
|
371
|
+
out = pwd_set { `#{npm_output("stage list #{npmname} --json --loglevel=error")}` }
|
|
372
|
+
pad0 = 0
|
|
373
|
+
pad1 = 0
|
|
374
|
+
data = Array(parse_json(out, kind: Array)).map do |item|
|
|
375
|
+
ver = item['version']
|
|
376
|
+
tag = item['tag']
|
|
377
|
+
pad0 = [pad0, ver.size].max
|
|
378
|
+
pad1 = [pad1, tag.size].max
|
|
379
|
+
[ver, tag, item['id'], item['actor']]
|
|
380
|
+
end
|
|
381
|
+
if data.empty?
|
|
382
|
+
print_error('no staged releases', loglevel: Logger::INFO, subject: npmname)
|
|
383
|
+
exit 1
|
|
384
|
+
end
|
|
385
|
+
data.each do |item|
|
|
386
|
+
item[0] = item[0].rjust(pad0)
|
|
387
|
+
item[1] = item[1].rjust(pad1)
|
|
388
|
+
end
|
|
389
|
+
stage << args.shift
|
|
390
|
+
stage << choice_index('Select a release', data.map { |item| item.join(' ') },
|
|
391
|
+
column: /^(?:\S+\s+){2}(\S+)/)
|
|
392
|
+
if %w[approve reject].include?(stage.first)
|
|
393
|
+
otp = args.shift if args.first&.match?(/^\d+$/)
|
|
394
|
+
registry = args.first
|
|
395
|
+
option('otp', prefix: 'npm') { |val| otp = val }
|
|
396
|
+
option('registry', prefix: 'npm') { |val| registry = val }
|
|
397
|
+
end
|
|
398
|
+
else
|
|
399
|
+
stage << 'publish'
|
|
400
|
+
parse.call
|
|
401
|
+
tag, otp = args
|
|
402
|
+
end
|
|
403
|
+
when :latest
|
|
404
|
+
parse.call
|
|
362
405
|
otp = args.first
|
|
363
406
|
else
|
|
407
|
+
parse.call
|
|
364
408
|
tag, otp = param_guard(action, flag, args: args)
|
|
365
409
|
end
|
|
366
|
-
publish(flag, otp: otp, tag: tag, access: access,
|
|
410
|
+
publish(flag, otp: otp, tag: tag, access: access, stage: stage, registry: registry,
|
|
411
|
+
dryrun: dryrun)
|
|
367
412
|
end
|
|
368
413
|
end
|
|
369
414
|
when 'tsc'
|
|
@@ -420,7 +465,7 @@ module Squared
|
|
|
420
465
|
return if items.empty?
|
|
421
466
|
|
|
422
467
|
on :first, :copy
|
|
423
|
-
print_item unless @output[0] || silent? || task_invoked?(/^copy(
|
|
468
|
+
print_item unless @output[0] || silent? || task_invoked?(/^copy(:#{Node.ref}|$)/)
|
|
424
469
|
packed = false
|
|
425
470
|
items.each do |dir|
|
|
426
471
|
case dir
|
|
@@ -435,7 +480,7 @@ module Squared
|
|
|
435
480
|
@workspace.rev_clear(proj.name, sync: sync)
|
|
436
481
|
proj.path
|
|
437
482
|
else
|
|
438
|
-
log.warn message(
|
|
483
|
+
log.warn message('target not found', dir, hint: 'copy')
|
|
439
484
|
nil
|
|
440
485
|
end
|
|
441
486
|
when Hash
|
|
@@ -455,7 +500,7 @@ module Squared
|
|
|
455
500
|
dest = dir.path
|
|
456
501
|
@workspace.rev_clear(dir.name, sync: sync)
|
|
457
502
|
else
|
|
458
|
-
|
|
503
|
+
raise TypeError, message('unknown', dir, hint: 'copy')
|
|
459
504
|
end
|
|
460
505
|
next unless from && dest&.directory?
|
|
461
506
|
|
|
@@ -517,7 +562,7 @@ module Squared
|
|
|
517
562
|
if sub
|
|
518
563
|
target << [entry, dest.join(into, sub)]
|
|
519
564
|
else
|
|
520
|
-
log.debug message("#{dependname} in \"#{entry}\"", hint: '
|
|
565
|
+
log.debug message("missing #{dependname} in \"#{entry}\"", hint: 'copy')
|
|
521
566
|
end
|
|
522
567
|
end
|
|
523
568
|
else
|
|
@@ -566,7 +611,7 @@ module Squared
|
|
|
566
611
|
rm = lambda do |target|
|
|
567
612
|
return if remove.empty?
|
|
568
613
|
|
|
569
|
-
run(target.temp(*remove).sub!(/ (
|
|
614
|
+
run(target.temp(*remove).sub!(/ (add|install) /, ' remove '), sync: sync, from: :remove)
|
|
570
615
|
end
|
|
571
616
|
yarn = dependtype(:yarn)
|
|
572
617
|
if yarn > 0
|
|
@@ -583,7 +628,7 @@ module Squared
|
|
|
583
628
|
cmd << '--mode=skip-build' if option('ignore-scripts')
|
|
584
629
|
cmd << '--check-cache' if !flag && option('force')
|
|
585
630
|
end
|
|
586
|
-
if nolockfile?('yarn')
|
|
631
|
+
if nolockfile?(prefix: 'yarn')
|
|
587
632
|
cmd << '--no-lockfile'
|
|
588
633
|
elsif option('ci')
|
|
589
634
|
if yarn == 1
|
|
@@ -619,7 +664,7 @@ module Squared
|
|
|
619
664
|
cmd << '--ignore-workspace' if ws
|
|
620
665
|
cmd << if option('force')
|
|
621
666
|
'--force'
|
|
622
|
-
elsif nolockfile?('pnpm')
|
|
667
|
+
elsif nolockfile?(prefix: 'pnpm')
|
|
623
668
|
'--no-lockfile'
|
|
624
669
|
elsif option('ci')
|
|
625
670
|
'--frozen-lockfile'
|
|
@@ -627,7 +672,8 @@ module Squared
|
|
|
627
672
|
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
628
673
|
cmd << '--dangerously-allow-all-builds' if option('approve-builds')
|
|
629
674
|
else
|
|
630
|
-
cmd = session
|
|
675
|
+
cmd = session 'npm'
|
|
676
|
+
cmd << (ci = option('ci') ? 'ci' : 'install')
|
|
631
677
|
option('approve-scripts') do |val|
|
|
632
678
|
cmd = npm_output 'approve-scripts'
|
|
633
679
|
cmd << case val
|
|
@@ -641,26 +687,6 @@ module Squared
|
|
|
641
687
|
print_run cmd, silent?
|
|
642
688
|
run(cmd, banner: false)
|
|
643
689
|
end
|
|
644
|
-
option('allow-scripts', ignore: false) do |val|
|
|
645
|
-
cmd << case val
|
|
646
|
-
when '0'
|
|
647
|
-
'--ignore-scripts'
|
|
648
|
-
when 'false'
|
|
649
|
-
'--strict-allow-scripts'
|
|
650
|
-
when '1', 'true'
|
|
651
|
-
'--dangerously-allow-all-scripts'
|
|
652
|
-
else
|
|
653
|
-
quote_option 'allow-scripts', val
|
|
654
|
-
end
|
|
655
|
-
end
|
|
656
|
-
option('engine-strict', ignore: false) do |val|
|
|
657
|
-
cmd << case val
|
|
658
|
-
when '0', 'false'
|
|
659
|
-
'--engine-strict=false'
|
|
660
|
-
else
|
|
661
|
-
'--engine-strict'
|
|
662
|
-
end
|
|
663
|
-
end
|
|
664
690
|
cmd << '--workspaces=false' if ws
|
|
665
691
|
cmd << '--force' if option('force')
|
|
666
692
|
append_nocolor
|
|
@@ -680,7 +706,7 @@ module Squared
|
|
|
680
706
|
append_platform
|
|
681
707
|
end
|
|
682
708
|
end
|
|
683
|
-
cmd << '--package-lock=false' << 'save=false' if nolockfile?('npm')
|
|
709
|
+
cmd << '--package-lock=false' << 'save=false' if nolockfile?(prefix: 'npm')
|
|
684
710
|
cmd << '--ignore-scripts' if option('ignore-scripts')
|
|
685
711
|
end
|
|
686
712
|
if add
|
|
@@ -760,7 +786,7 @@ module Squared
|
|
|
760
786
|
end
|
|
761
787
|
next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
|
|
762
788
|
|
|
763
|
-
f = semscan
|
|
789
|
+
f = semscan(file, fill: !option('save-exact').nil?)
|
|
764
790
|
w = semscan want
|
|
765
791
|
a = f[0]
|
|
766
792
|
b = f[2]
|
|
@@ -770,8 +796,12 @@ module Squared
|
|
|
770
796
|
when :major
|
|
771
797
|
a == '0' ? c == '0' || c == '1' : true
|
|
772
798
|
when :minor
|
|
799
|
+
next unless f[4]
|
|
800
|
+
|
|
773
801
|
ch == '^' && (a == '0' ? c == '0' && b == d : a == c)
|
|
774
802
|
when :patch
|
|
803
|
+
next unless b && f[4]
|
|
804
|
+
|
|
775
805
|
a == c && b == d && f[4] != w[4]
|
|
776
806
|
end
|
|
777
807
|
if upgrade && !w[6]
|
|
@@ -783,7 +813,7 @@ module Squared
|
|
|
783
813
|
a == '0' ? 1 : 3
|
|
784
814
|
else
|
|
785
815
|
5
|
|
786
|
-
end, major,
|
|
816
|
+
end, major, semscan(file), w]
|
|
787
817
|
elsif !major
|
|
788
818
|
avail << [key, file, latest, latest != current]
|
|
789
819
|
end
|
|
@@ -931,18 +961,14 @@ module Squared
|
|
|
931
961
|
end
|
|
932
962
|
|
|
933
963
|
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, access: nil, dryrun: nil,
|
|
934
|
-
version: nil, ext: [], workspace: false)
|
|
964
|
+
version: nil, stage: [], registry: nil, ext: [], workspace: false)
|
|
935
965
|
if read_package('private')
|
|
936
|
-
return if workspace
|
|
966
|
+
return if workspace || !stage.empty?
|
|
937
967
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
ws.each do |proj|
|
|
943
|
-
proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, version: version,
|
|
944
|
-
ext: ext, workspace: true)
|
|
945
|
-
end
|
|
968
|
+
from, accept = flag == :verify ? %w[verify Y] : %w[publish N]
|
|
969
|
+
each(accept: accept, ref: Node.ref, from: from) do |proj|
|
|
970
|
+
proj.publish(flag, sync: sync, otp: otp, tag: tag, access: access, dryrun: dryrun, version: version,
|
|
971
|
+
ext: ext, workspace: true)
|
|
946
972
|
end
|
|
947
973
|
elsif version ||= self.version
|
|
948
974
|
if flag == :verify
|
|
@@ -1013,24 +1039,35 @@ module Squared
|
|
|
1013
1039
|
end
|
|
1014
1040
|
end
|
|
1015
1041
|
else
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
when 'r', 'restricted'
|
|
1023
|
-
cmd << '--access=restricted'
|
|
1042
|
+
args = ['npm']
|
|
1043
|
+
if stage.empty?
|
|
1044
|
+
args << 'publish'
|
|
1045
|
+
else
|
|
1046
|
+
args << 'stage' << stage.shift
|
|
1047
|
+
args.concat(stage)
|
|
1024
1048
|
end
|
|
1025
|
-
|
|
1049
|
+
cmd = session(*args)
|
|
1050
|
+
if stage.empty?
|
|
1051
|
+
otp ||= option('otp')
|
|
1052
|
+
cmd << basic_option('tag', tag.tr(' ', '-')) if tag ||= option('tag')
|
|
1053
|
+
case access || option('access')
|
|
1054
|
+
when 'p', 'public'
|
|
1055
|
+
cmd << '--access=public'
|
|
1056
|
+
when 'r', 'restricted'
|
|
1057
|
+
cmd << '--access=restricted'
|
|
1058
|
+
end
|
|
1059
|
+
dryrun ||= dryrun?(prefix: 'npm')
|
|
1060
|
+
end
|
|
1061
|
+
cmd << basic_option('otp', otp) if otp
|
|
1062
|
+
cmd << quote_option('registry', registry) if registry
|
|
1026
1063
|
if dryrun
|
|
1027
1064
|
cmd << '--dry-run'
|
|
1028
1065
|
else
|
|
1029
|
-
from = :'npm:publish'
|
|
1030
1066
|
log.info cmd.to_s
|
|
1067
|
+
from = symjoin args.take(3)
|
|
1031
1068
|
end
|
|
1032
1069
|
if sync
|
|
1033
|
-
run(sync: sync, from: from, interactive: !dryrun && ['Publish', 'N', npmname])
|
|
1070
|
+
run(sync: sync, from: from, interactive: !dryrun && stage.empty? && ['Publish', 'N', npmname])
|
|
1034
1071
|
else
|
|
1035
1072
|
require 'open3'
|
|
1036
1073
|
on :first, from
|
|
@@ -1045,13 +1082,12 @@ module Squared
|
|
|
1045
1082
|
end
|
|
1046
1083
|
end
|
|
1047
1084
|
elsif !workspace
|
|
1048
|
-
print_error(
|
|
1085
|
+
print_error('version not found', subject: name, hint: dependname)
|
|
1049
1086
|
end
|
|
1050
1087
|
end
|
|
1051
1088
|
|
|
1052
1089
|
def package(flag, opts = [], packages: [], from: nil)
|
|
1053
1090
|
workspace.rev_clear(name)
|
|
1054
|
-
force = true if flag == :reinstall && has_value!(opts, 'f')
|
|
1055
1091
|
yarn = dependtype(:yarn)
|
|
1056
1092
|
if yarn > 0 && !(yarn == 1 && ((flag == :update && !packages.empty?) || %i[approve deny
|
|
1057
1093
|
rebuild].include?(flag)))
|
|
@@ -1065,8 +1101,8 @@ module Squared
|
|
|
1065
1101
|
end
|
|
1066
1102
|
when :reinstall
|
|
1067
1103
|
if yarn == 1
|
|
1068
|
-
remove_modules 'yarn' if opts.include?('force')
|
|
1069
|
-
elsif opts.delete('force')
|
|
1104
|
+
remove_modules(prefix: 'yarn') if opts.include?('force')
|
|
1105
|
+
elsif opts.delete('force')
|
|
1070
1106
|
opts << 'check-cache'
|
|
1071
1107
|
end
|
|
1072
1108
|
opts << 'no-lockfile' if lockfile(true)
|
|
@@ -1086,7 +1122,7 @@ module Squared
|
|
|
1086
1122
|
end
|
|
1087
1123
|
end, cmd, project: self, strict: strict?)
|
|
1088
1124
|
if yarn == 1 && flag != :reinstall
|
|
1089
|
-
op << '--no-lockfile' if nolockfile?('yarn')
|
|
1125
|
+
op << '--no-lockfile' if nolockfile?(prefix: 'yarn')
|
|
1090
1126
|
op << '--ignore-engines' if option('ignore-engines')
|
|
1091
1127
|
end
|
|
1092
1128
|
else
|
|
@@ -1099,7 +1135,7 @@ module Squared
|
|
|
1099
1135
|
else
|
|
1100
1136
|
case flag
|
|
1101
1137
|
when :install, :update
|
|
1102
|
-
opts << 'no-lockfile' if nolockfile?('pnpm')
|
|
1138
|
+
opts << 'no-lockfile' if nolockfile?(prefix: 'pnpm')
|
|
1103
1139
|
spec = 0 if flag == :update
|
|
1104
1140
|
when :add
|
|
1105
1141
|
spec = 1
|
|
@@ -1129,13 +1165,13 @@ module Squared
|
|
|
1129
1165
|
else
|
|
1130
1166
|
case flag
|
|
1131
1167
|
when :install, :update
|
|
1132
|
-
opts.unshift('package-lock=false', 'save=false') if nolockfile?('npm')
|
|
1168
|
+
opts.unshift('package-lock=false', 'save=false') if nolockfile?(prefix: 'npm')
|
|
1133
1169
|
spec = flag == :install ? 0 : 2
|
|
1134
1170
|
when :add
|
|
1135
1171
|
spec = 1
|
|
1136
1172
|
flag = :install
|
|
1137
1173
|
when :reinstall
|
|
1138
|
-
remove_modules 'npm' if opts.delete('force')
|
|
1174
|
+
remove_modules(prefix: 'npm') if opts.delete('force')
|
|
1139
1175
|
opts.unshift('package-lock=false') if lockfile(true)
|
|
1140
1176
|
flag = :install
|
|
1141
1177
|
end
|
|
@@ -1196,35 +1232,41 @@ module Squared
|
|
|
1196
1232
|
run(from: from || symjoin('package', flag))
|
|
1197
1233
|
end
|
|
1198
1234
|
|
|
1199
|
-
def bump(flag, val = nil)
|
|
1200
|
-
|
|
1235
|
+
def bump(flag = :patch, val = nil, workspace: false)
|
|
1236
|
+
if read_package('private')
|
|
1237
|
+
return if workspace
|
|
1201
1238
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1239
|
+
each(accept: 'N', ref: Node.ref, from: 'bump') { |proj| proj.bump(flag, val, workspace: true) }
|
|
1240
|
+
elsif val ||= version && sembump(version, flag)
|
|
1241
|
+
begin
|
|
1242
|
+
doc = dependfile.read
|
|
1243
|
+
unless doc.sub!(/"version"\s*:\s*"#{version}"/, "\"version\": \"#{val}\"")
|
|
1244
|
+
raise message('version not found', hint: dependfile)
|
|
1245
|
+
end
|
|
1246
|
+
|
|
1247
|
+
unless dryrun?
|
|
1248
|
+
log.info "bump version #{version} to #{val.subhint(flag)}"
|
|
1249
|
+
on :first, :bump
|
|
1250
|
+
dependfile.write(doc)
|
|
1251
|
+
end
|
|
1252
|
+
if stdin?
|
|
1253
|
+
puts val
|
|
1254
|
+
elsif !silent?
|
|
1255
|
+
major = flag == :major
|
|
1256
|
+
emphasize("version: #{val}", title: name, border: borderstyle, sub: [
|
|
1257
|
+
headerstyle,
|
|
1258
|
+
opt_style(color(major ? :green : :yellow), /\A(version:)( )(\S+)(.*)\z/, 3),
|
|
1259
|
+
opt_style(theme[major ? :major : :active], /\A(version:)(.*)\z/)
|
|
1260
|
+
])
|
|
1261
|
+
end
|
|
1262
|
+
unless dryrun?
|
|
1263
|
+
commit(:add, [dependname], pass: true)
|
|
1264
|
+
on :last, :bump
|
|
1265
|
+
end
|
|
1266
|
+
rescue => e
|
|
1267
|
+
on_error(e, dryrun: dryrun?)
|
|
1222
1268
|
end
|
|
1223
|
-
else
|
|
1224
|
-
raise_error 'version not found', hint: dependfile
|
|
1225
1269
|
end
|
|
1226
|
-
rescue => e
|
|
1227
|
-
on_error(e, dryrun: dryrun?)
|
|
1228
1270
|
end
|
|
1229
1271
|
|
|
1230
1272
|
def pack(opts = [])
|
|
@@ -1296,7 +1338,8 @@ module Squared
|
|
|
1296
1338
|
|
|
1297
1339
|
if script
|
|
1298
1340
|
ret = session dependbin, 'run'
|
|
1299
|
-
|
|
1341
|
+
raise message(dependbin, 'run', target, hint: from) unless append_any(target, build: true)
|
|
1342
|
+
|
|
1300
1343
|
append_any opts if opts
|
|
1301
1344
|
append_loglevel
|
|
1302
1345
|
append_any(args, delim: true) if args
|
|
@@ -1310,7 +1353,7 @@ module Squared
|
|
|
1310
1353
|
when Enumerable
|
|
1311
1354
|
target.to_a.join(' ')
|
|
1312
1355
|
else
|
|
1313
|
-
|
|
1356
|
+
raise TypeError, message('unknown', target, hint: 'compose')
|
|
1314
1357
|
end
|
|
1315
1358
|
end
|
|
1316
1359
|
end
|
|
@@ -1410,11 +1453,7 @@ module Squared
|
|
|
1410
1453
|
end
|
|
1411
1454
|
|
|
1412
1455
|
def dependbin
|
|
1413
|
-
|
|
1414
|
-
'yarn'
|
|
1415
|
-
else
|
|
1416
|
-
pnpm? ? 'pnpm' : 'npm'
|
|
1417
|
-
end
|
|
1456
|
+
yarn? ? 'yarn' : pnpm? ? 'pnpm' : 'npm'
|
|
1418
1457
|
end
|
|
1419
1458
|
|
|
1420
1459
|
def version
|
|
@@ -1470,7 +1509,8 @@ module Squared
|
|
|
1470
1509
|
next if yarntype(exist: true) == 0
|
|
1471
1510
|
when /^pnpm/
|
|
1472
1511
|
next if pnpmtype(exist: true) == 0
|
|
1473
|
-
when /^npm/
|
|
1512
|
+
when /^npm/
|
|
1513
|
+
nil
|
|
1474
1514
|
else
|
|
1475
1515
|
next
|
|
1476
1516
|
end
|
|
@@ -1523,9 +1563,9 @@ module Squared
|
|
|
1523
1563
|
end
|
|
1524
1564
|
end
|
|
1525
1565
|
|
|
1526
|
-
def remove_modules(prefix
|
|
1527
|
-
modules = basepath
|
|
1528
|
-
return false unless modules && confirm_basic('Remove?', modules, prefix: prefix)
|
|
1566
|
+
def remove_modules(prefix: dependbin)
|
|
1567
|
+
modules = basepath 'node_modules'
|
|
1568
|
+
return false unless modules.directory? && confirm_basic('Remove?', modules, prefix: prefix)
|
|
1529
1569
|
|
|
1530
1570
|
modules.rmtree
|
|
1531
1571
|
rescue Timeout::Error => e
|
|
@@ -1588,7 +1628,7 @@ module Squared
|
|
|
1588
1628
|
end
|
|
1589
1629
|
|
|
1590
1630
|
def dependroot
|
|
1591
|
-
dependname if parent&.has?('outdated', Node.ref)
|
|
1631
|
+
dependname if parent&.has?('outdated', ref: Node.ref)
|
|
1592
1632
|
end
|
|
1593
1633
|
|
|
1594
1634
|
def npmname
|
|
@@ -1613,11 +1653,7 @@ module Squared
|
|
|
1613
1653
|
end
|
|
1614
1654
|
|
|
1615
1655
|
def lockfile(delete = false)
|
|
1616
|
-
ret = basepath(
|
|
1617
|
-
'yarn.lock'
|
|
1618
|
-
else
|
|
1619
|
-
pnpm? ? 'pnpm-lock.yaml' : 'package-lock.json'
|
|
1620
|
-
end)
|
|
1656
|
+
ret = basepath(yarn? ? 'yarn.lock' : pnpm? ? 'pnpm-lock.yaml' : 'package-lock.json')
|
|
1621
1657
|
if ret.exist?
|
|
1622
1658
|
if delete
|
|
1623
1659
|
ret.delete
|
|
@@ -1636,11 +1672,11 @@ module Squared
|
|
|
1636
1672
|
@serve != false
|
|
1637
1673
|
end
|
|
1638
1674
|
|
|
1639
|
-
def nolockfile?(prefix
|
|
1675
|
+
def nolockfile?(prefix: dependbin)
|
|
1640
1676
|
option('package-lock', 'lockfile', prefix: prefix, equals: '0') || !option('no-lockfile', prefix: prefix).nil?
|
|
1641
1677
|
end
|
|
1642
1678
|
|
|
1643
|
-
def dryrun?(prefix
|
|
1679
|
+
def dryrun?(prefix: dependbin)
|
|
1644
1680
|
super(target: @session, prefix: prefix)
|
|
1645
1681
|
end
|
|
1646
1682
|
end
|