squared 0.4.12 → 0.4.14
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 +100 -0
- data/README.ruby.md +6 -2
- data/lib/squared/common/base.rb +5 -2
- data/lib/squared/common/format.rb +8 -2
- data/lib/squared/common/prompt.rb +1 -1
- data/lib/squared/common/shell.rb +14 -14
- data/lib/squared/common/system.rb +21 -14
- data/lib/squared/common/utils.rb +7 -3
- data/lib/squared/config.rb +6 -5
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +21 -12
- data/lib/squared/workspace/project/base.rb +348 -137
- data/lib/squared/workspace/project/docker.rb +95 -52
- data/lib/squared/workspace/project/git.rb +86 -52
- data/lib/squared/workspace/project/node.rb +71 -44
- data/lib/squared/workspace/project/python.rb +360 -131
- data/lib/squared/workspace/project/ruby.rb +140 -103
- data/lib/squared/workspace/project/support/class.rb +39 -3
- data/lib/squared/workspace/repo.rb +2 -1
- data/lib/squared/workspace/support/data.rb +2 -2
- metadata +1 -1
@@ -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
|
@@ -131,7 +134,7 @@ module Squared
|
|
131
134
|
end
|
132
135
|
case save
|
133
136
|
when 'prod', 'dev', 'optional', 'peer'
|
134
|
-
packages = args.
|
137
|
+
packages = args.extras
|
135
138
|
else
|
136
139
|
save = 'prod'
|
137
140
|
packages = args.to_a
|
@@ -142,10 +145,10 @@ module Squared
|
|
142
145
|
when 'run'
|
143
146
|
next if (list = read_scripts).empty?
|
144
147
|
|
145
|
-
format_desc action, nil,
|
148
|
+
format_desc action, nil, "script,opts*|#{indexchar}index+|#,pattern*"
|
146
149
|
task action, [:script] do |_, args|
|
147
150
|
if args.script == '#'
|
148
|
-
format_list(list,
|
151
|
+
format_list(list, "run[#{indexchar}N]", 'scripts', grep: args.extras, from: dependfile)
|
149
152
|
else
|
150
153
|
args = param_guard(action, 'script', args: args.to_a)
|
151
154
|
opts = []
|
@@ -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.extras
|
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|
|
@@ -194,7 +226,7 @@ module Squared
|
|
194
226
|
outdated flag, args.to_a
|
195
227
|
end
|
196
228
|
when 'package'
|
197
|
-
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : '
|
229
|
+
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : 'name*')
|
198
230
|
task flag do |_, args|
|
199
231
|
package flag, args.to_a
|
200
232
|
end
|
@@ -304,7 +336,7 @@ module Squared
|
|
304
336
|
next unless from && dest&.directory?
|
305
337
|
|
306
338
|
from = path + from
|
307
|
-
glob =
|
339
|
+
glob = Array(glob || '**/*')
|
308
340
|
target = []
|
309
341
|
if workspace
|
310
342
|
Dir.glob(from + '*').each do |path|
|
@@ -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'
|
@@ -417,7 +448,7 @@ module Squared
|
|
417
448
|
ret = on(:error, :outdated, e)
|
418
449
|
raise if exception && ret != true
|
419
450
|
end
|
420
|
-
warn log_message(Logger::WARN, e
|
451
|
+
warn log_message(Logger::WARN, e) if warning?
|
421
452
|
return
|
422
453
|
else
|
423
454
|
dep1 = json['dependencies'] || {}
|
@@ -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
|
@@ -565,50 +596,43 @@ module Squared
|
|
565
596
|
end
|
566
597
|
|
567
598
|
def update(*)
|
568
|
-
package
|
599
|
+
package('update', from: :update)
|
569
600
|
end
|
570
601
|
|
571
602
|
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, access: nil)
|
572
|
-
if read_packagemanager(:private)
|
573
|
-
|
574
|
-
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private', pass: true)
|
575
|
-
end
|
603
|
+
if !version || read_packagemanager(:private)
|
604
|
+
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: version ? 'private' : nil)
|
576
605
|
return
|
577
606
|
end
|
578
|
-
return unless version
|
579
|
-
|
580
607
|
cmd = session 'npm', 'publish'
|
581
|
-
dryrun = dryrun?('npm') if dryrun.nil?
|
582
608
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
583
609
|
cmd << basic_option('tag', tag) if tag ||= option('tag')
|
584
610
|
cmd << basic_option('access', access) if access ||= option('access')
|
585
|
-
if
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
611
|
+
dryrun = dryrun?('npm') if dryrun.nil?
|
612
|
+
if dryrun
|
613
|
+
cmd << '--dry-run'
|
614
|
+
else
|
615
|
+
from = :publish
|
616
|
+
log.info cmd.to_s
|
617
|
+
end
|
618
|
+
if sync
|
619
|
+
run(from: from, sync: sync, interactive: !dryrun && "Publish #{sub_style(project, styles: theme[:active])}")
|
620
|
+
else
|
621
|
+
on :first, from
|
622
|
+
pwd_set(from: :publish, dryrun: dryrun) do
|
623
|
+
require 'open3'
|
624
|
+
banner = format_banner(cmd.to_s)
|
625
|
+
Open3.popen2e(cmd.done) do |_, out|
|
626
|
+
write_lines(out, banner: banner, sub: npmnotice + [
|
627
|
+
{ pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2 }
|
628
|
+
])
|
601
629
|
end
|
602
|
-
on :last, :publish unless dryrun
|
603
|
-
return
|
604
630
|
end
|
605
|
-
|
606
|
-
return
|
631
|
+
on :last, from
|
607
632
|
end
|
608
|
-
run(from: :publish, sync: sync)
|
609
633
|
end
|
610
634
|
|
611
|
-
def package(flag, opts = [])
|
635
|
+
def package(flag, opts = [], from: nil)
|
612
636
|
workspace.rev_clear(name)
|
613
637
|
if (yarn = dependtype(:yarn)) > 0
|
614
638
|
cmd = session 'yarn', if flag == :update
|
@@ -634,6 +658,7 @@ module Squared
|
|
634
658
|
list = OPT_NPM[:install_base] + OPT_NPM.fetch(flag, []) + OPT_NPM[:common]
|
635
659
|
list.concat(OPT_NPM[:install_as]) unless flag == :dedupe
|
636
660
|
no = OPT_NPM[:install_no]
|
661
|
+
cmd << '--save=true' if option('save')
|
637
662
|
end
|
638
663
|
op = OptionPartition.new(opts, list, cmd, no: no, project: self)
|
639
664
|
op.each do |opt|
|
@@ -658,7 +683,7 @@ module Squared
|
|
658
683
|
end
|
659
684
|
op.clear(errors: true)
|
660
685
|
end
|
661
|
-
run(from: :"package:#{flag}")
|
686
|
+
run(from: from || :"package:#{flag}")
|
662
687
|
end
|
663
688
|
|
664
689
|
def bump(flag, val = nil)
|
@@ -875,9 +900,11 @@ module Squared
|
|
875
900
|
@pm[:_] = false
|
876
901
|
nil
|
877
902
|
else
|
878
|
-
|
879
|
-
|
880
|
-
|
903
|
+
if key
|
904
|
+
@pm[key]
|
905
|
+
elsif (ret = @pm[:_]) && !(version && ret[(ret.index('@') + 1)..-1] < version)
|
906
|
+
ret
|
907
|
+
end
|
881
908
|
end
|
882
909
|
|
883
910
|
def read_install
|