squared 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ruby.md +55 -2
- data/lib/squared/common/base.rb +5 -3
- data/lib/squared/common/class.rb +10 -2
- data/lib/squared/common/format.rb +29 -18
- data/lib/squared/common/prompt.rb +2 -4
- data/lib/squared/common/shell.rb +4 -3
- data/lib/squared/common/system.rb +12 -14
- data/lib/squared/common/utils.rb +29 -3
- data/lib/squared/common.rb +0 -4
- data/lib/squared/config.rb +35 -32
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +51 -45
- data/lib/squared/workspace/project/base.rb +248 -83
- data/lib/squared/workspace/project/git.rb +38 -44
- data/lib/squared/workspace/project/node.rb +57 -96
- data/lib/squared/workspace/project/python.rb +16 -19
- data/lib/squared/workspace/project/ruby.rb +69 -48
- data/lib/squared/workspace/repo.rb +12 -11
- data/lib/squared/workspace/series.rb +15 -14
- data/lib/squared/workspace.rb +1 -1
- metadata +2 -3
- data/lib/squared/common/task.rb +0 -25
@@ -14,8 +14,9 @@ module Squared
|
|
14
14
|
def populate(ws, **)
|
15
15
|
return if ws.series[:pull].empty?
|
16
16
|
|
17
|
+
name = ws.task_name('all')
|
17
18
|
desc ws.task_name('all[git?=rebase|stash]', desc: true)
|
18
|
-
task
|
19
|
+
task name, [:git] do |_, args|
|
19
20
|
sync = lambda do |key|
|
20
21
|
key = ws.task_name(key)
|
21
22
|
ws.task_defined?(ret = ws.task_join(key, 'sync')) ? ret : key
|
@@ -30,8 +31,10 @@ module Squared
|
|
30
31
|
sync.('pull')
|
31
32
|
end]
|
32
33
|
cmd << ws.task_name('build')
|
33
|
-
Common::
|
34
|
+
Common::Utils.task_invoke(*cmd, **ws.invokeargs)
|
34
35
|
end
|
36
|
+
ws.series.sync << name
|
37
|
+
ws.series.multiple << name
|
35
38
|
end
|
36
39
|
|
37
40
|
def tasks
|
@@ -65,7 +68,7 @@ module Squared
|
|
65
68
|
|
66
69
|
def initialize(*, **)
|
67
70
|
super
|
68
|
-
initialize_ref(Git.ref) if
|
71
|
+
initialize_ref(Git.ref) if gitpath.exist?
|
69
72
|
end
|
70
73
|
|
71
74
|
def ref
|
@@ -95,8 +98,7 @@ module Squared
|
|
95
98
|
else
|
96
99
|
desc format_desc(action, flag, 'pathspec+')
|
97
100
|
task flag, [:pathspec] do |_, args|
|
98
|
-
files = args.to_a
|
99
|
-
guard_params(action, flag, args: files)
|
101
|
+
files = guard_params(action, flag, args: args.to_a)
|
100
102
|
__send__(action, flag, files)
|
101
103
|
end
|
102
104
|
end
|
@@ -138,15 +140,15 @@ module Squared
|
|
138
140
|
when :branch
|
139
141
|
desc format_desc(action, flag, 'name,pathspec*')
|
140
142
|
task flag, [:name, :pathspec] do |_, args|
|
141
|
-
guard_params(action, flag, args: args, key: :name)
|
142
|
-
diff(flag, args.to_a[1..-1], branch:
|
143
|
+
branch = guard_params(action, flag, args: args, key: :name)
|
144
|
+
diff(flag, args.to_a[1..-1] || [], branch: branch)
|
143
145
|
end
|
144
146
|
when :files
|
145
147
|
desc format_desc(action, flag, 'path1,path2')
|
146
148
|
task flag, [:path1, :path2] do |_, args|
|
147
|
-
guard_params(action, flag, args: args, key: :path1)
|
148
|
-
guard_params(action, flag, args: args, key: :path2)
|
149
|
-
diff(flag, [
|
149
|
+
path1 = guard_params(action, flag, args: args, key: :path1)
|
150
|
+
path2 = guard_params(action, flag, args: args, key: :path2)
|
151
|
+
diff(flag, [path1, path2])
|
150
152
|
end
|
151
153
|
end
|
152
154
|
when :checkout
|
@@ -154,7 +156,7 @@ module Squared
|
|
154
156
|
when :branch
|
155
157
|
desc format_desc(action, flag, 'name,create?=b|B,commit?,detach?=d')
|
156
158
|
task flag, [:name, :create, :commit, :detach] do |_, args|
|
157
|
-
guard_params(action, flag, args: args, key: :name)
|
159
|
+
branch = guard_params(action, flag, args: args, key: :name)
|
158
160
|
create = args.create
|
159
161
|
if args.commit == 'd'
|
160
162
|
detach = 'd'
|
@@ -172,7 +174,7 @@ module Squared
|
|
172
174
|
commit = args.commit
|
173
175
|
end
|
174
176
|
guard_params(action, flag, args: { create: create }, key: :create, pat: /^b$/i) if create
|
175
|
-
checkout(flag, branch:
|
177
|
+
checkout(flag, branch: branch, create: create, commit: commit, detach: detach)
|
176
178
|
end
|
177
179
|
when :detach
|
178
180
|
desc format_desc(action, flag, 'branch/commit?')
|
@@ -187,10 +189,9 @@ module Squared
|
|
187
189
|
end
|
188
190
|
when :reset
|
189
191
|
if flag == :head
|
190
|
-
desc format_desc(action, flag, 'ref
|
192
|
+
desc format_desc(action, flag, 'ref,pathspec+')
|
191
193
|
task flag, [:ref, :pathspec] do |_, args|
|
192
|
-
files = args.to_a[1..-1]
|
193
|
-
guard_params(action, flag, args: files)
|
194
|
+
files = guard_params(action, flag, args: args.to_a[1..-1] || [])
|
194
195
|
reset(flag, files, ref: args.ref)
|
195
196
|
end
|
196
197
|
else
|
@@ -234,7 +235,7 @@ module Squared
|
|
234
235
|
end
|
235
236
|
|
236
237
|
def stash(flag = nil, files = [], commit: nil)
|
237
|
-
cmd = git_session 'stash',
|
238
|
+
cmd = git_session 'stash', flag || 'push'
|
238
239
|
case flag
|
239
240
|
when :apply, :pop
|
240
241
|
cmd << '--index' if option('index')
|
@@ -267,15 +268,15 @@ module Squared
|
|
267
268
|
print_item banner
|
268
269
|
banner = nil
|
269
270
|
end
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
271
|
+
ret = write_lines(out, banner: banner, sub: if verbose
|
272
|
+
[
|
273
|
+
{ pat: /^(.)([A-Z])(.+)$/, styles: :red, index: 2 },
|
274
|
+
{ pat: /^([A-Z])(.+)$/, styles: :green },
|
275
|
+
{ pat: /^(\?\?)(.+)$/, styles: :red },
|
276
|
+
{ pat: /^(## )(.+)(\.{3})(.+)$/,
|
277
|
+
styles: [nil, :green, nil, :red], index: -1 }
|
278
|
+
]
|
279
|
+
end)
|
279
280
|
list_result(ret, 'files', action: 'modified')
|
280
281
|
end
|
281
282
|
|
@@ -380,7 +381,7 @@ module Squared
|
|
380
381
|
end
|
381
382
|
end
|
382
383
|
cmd << sha
|
383
|
-
append_pathspec(files,
|
384
|
+
append_pathspec(files, parent: flag == :files)
|
384
385
|
source(exception: cmd.include?('--exit-code'))
|
385
386
|
end
|
386
387
|
|
@@ -395,8 +396,7 @@ module Squared
|
|
395
396
|
pathspec = if flag == :all || (amend && files.size == 1 && files.first == '*')
|
396
397
|
'--all'
|
397
398
|
else
|
398
|
-
files =
|
399
|
-
raise_error('commit', 'pathspec', hint: 'missing') if files.empty?
|
399
|
+
raise_error('commit', 'pathspec', hint: 'missing') if (files = projectmap(files)).empty?
|
400
400
|
"-- #{files.join(' ')}"
|
401
401
|
end
|
402
402
|
unless push?
|
@@ -446,12 +446,11 @@ module Squared
|
|
446
446
|
|
447
447
|
private
|
448
448
|
|
449
|
-
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false,
|
450
|
-
banner: ARG[:BANNER])
|
449
|
+
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true)
|
451
450
|
cmd = session_done(cmd)
|
452
451
|
log.info cmd
|
453
|
-
banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner
|
454
|
-
cmd = cmd.sub(/^git\b/, "git --work-tree #{shell_quote(path)} --git-dir #{shell_quote(
|
452
|
+
banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner)
|
453
|
+
cmd = cmd.sub(/^git\b/, "git --work-tree #{shell_quote(path)} --git-dir #{shell_quote(gitpath)}")
|
455
454
|
begin
|
456
455
|
if io
|
457
456
|
[IO.popen(cmd), banner]
|
@@ -526,11 +525,6 @@ module Squared
|
|
526
525
|
end
|
527
526
|
end
|
528
527
|
|
529
|
-
def source_path(files, pass: false)
|
530
|
-
files = files.select { |val| source_path?(val) } unless pass
|
531
|
-
files.map { |val| val == '.' ? '.' : shell_quote(base_path(val.strip)) }
|
532
|
-
end
|
533
|
-
|
534
528
|
def append_pull(opts, list, flag = nil)
|
535
529
|
append_submodules flag
|
536
530
|
opts.each do |opt|
|
@@ -544,18 +538,18 @@ module Squared
|
|
544
538
|
|
545
539
|
def append_commit(val)
|
546
540
|
val = val.to_s.strip
|
547
|
-
val.empty? ? 'HEAD' : val
|
541
|
+
@session << (val.empty? ? 'HEAD' : val)
|
548
542
|
end
|
549
543
|
|
550
|
-
def append_pathspec(files = [], expect: false,
|
544
|
+
def append_pathspec(files = [], expect: false, parent: false)
|
551
545
|
if files.empty? && (val = option('pathspec'))
|
552
546
|
files = split_escape(val)
|
553
547
|
end
|
554
|
-
files =
|
548
|
+
files = projectmap(files, parent: parent)
|
555
549
|
if !files.empty?
|
556
550
|
@session << "-- #{files.join(' ')}"
|
557
551
|
elsif expect
|
558
|
-
raise_error(
|
552
|
+
raise_error(parent ? 'pathspec not present' : 'pathspec not within worktree', hint: 'invalid')
|
559
553
|
end
|
560
554
|
end
|
561
555
|
|
@@ -591,8 +585,8 @@ module Squared
|
|
591
585
|
session('git', *cmd)
|
592
586
|
end
|
593
587
|
|
594
|
-
def
|
595
|
-
|
588
|
+
def gitpath
|
589
|
+
basepath('.git')
|
596
590
|
end
|
597
591
|
|
598
592
|
def push?
|
@@ -604,7 +598,7 @@ module Squared
|
|
604
598
|
end
|
605
599
|
|
606
600
|
def threadargs
|
607
|
-
{ stderr: true, exception: !workspace.series.multiple? }
|
601
|
+
{ stderr: true, exception: exception || !workspace.series.multiple? }
|
608
602
|
end
|
609
603
|
end
|
610
604
|
|
@@ -4,8 +4,6 @@ module Squared
|
|
4
4
|
module Workspace
|
5
5
|
module Project
|
6
6
|
class Node < Git
|
7
|
-
include Common::Prompt
|
8
|
-
|
9
7
|
class << self
|
10
8
|
def populate(*); end
|
11
9
|
|
@@ -21,6 +19,10 @@ module Squared
|
|
21
19
|
[ref, { refresh: :build }]
|
22
20
|
end
|
23
21
|
|
22
|
+
def bannerargs
|
23
|
+
%i[version dependfile].freeze
|
24
|
+
end
|
25
|
+
|
24
26
|
def prod?
|
25
27
|
ENV['NODE_ENV'] == 'production'
|
26
28
|
end
|
@@ -39,8 +41,6 @@ module Squared
|
|
39
41
|
run: nil
|
40
42
|
}.freeze
|
41
43
|
|
42
|
-
attr_reader :package
|
43
|
-
|
44
44
|
def initialize(*, **kwargs)
|
45
45
|
super
|
46
46
|
if @pass.include?(Node.ref)
|
@@ -51,7 +51,7 @@ module Squared
|
|
51
51
|
initialize_env(**kwargs)
|
52
52
|
end
|
53
53
|
@pm = {}
|
54
|
-
@
|
54
|
+
@dependfile = basepath('package.json')
|
55
55
|
end
|
56
56
|
|
57
57
|
def ref
|
@@ -70,45 +70,17 @@ module Squared
|
|
70
70
|
desc format_desc(action, nil, 'command+|^index|#,pattern*')
|
71
71
|
task action, [:command] do |_, args|
|
72
72
|
if args.command == '#'
|
73
|
-
|
74
|
-
grep = args.extras.map { |val| Regexp.new(val) }
|
75
|
-
lines = []
|
76
|
-
if (pad = list.size) > 0
|
77
|
-
pad = pad.to_s.size
|
78
|
-
list.each_with_index do |val, i|
|
79
|
-
next unless grep.empty? || grep.any? { |pat| pat.match?(val[0]) }
|
80
|
-
|
81
|
-
lines << "#{(i + 1).to_s.rjust(pad)}. #{val[0]}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
if lines.empty?
|
85
|
-
lines = ['No scripts were found:', '']
|
86
|
-
unless args.extras.empty?
|
87
|
-
i = 0
|
88
|
-
lines += args.extras.to_a.map { |s| "#{i += 1}. #{s}" }
|
89
|
-
lines << ''
|
90
|
-
end
|
91
|
-
lines << package.to_s
|
92
|
-
pat = /^(#{Regexp.escape(lines.last)})(.*)$/
|
93
|
-
else
|
94
|
-
pat = /^(\s*\d+\.)(.+)$/
|
95
|
-
end
|
96
|
-
emphasize(lines, title: task_join(name, 'run[^N]'), border: borderstyle, sub: [
|
97
|
-
headerstyle,
|
98
|
-
{ pat: pat, styles: theme[:active] }
|
99
|
-
])
|
73
|
+
format_list(read_scripts, 'run[^N]', 'scripts', grep: args.extras, from: dependfile.to_s)
|
100
74
|
else
|
101
|
-
cmd = args.to_a
|
102
|
-
guard_params(action, 'command', args: cmd)
|
103
|
-
list = nil
|
75
|
+
cmd = guard_params(action, 'command', args: args.to_a)
|
104
76
|
cmd.each do |val|
|
105
|
-
if (data =
|
106
|
-
|
107
|
-
|
77
|
+
if (data = indexdata(val))
|
78
|
+
n, opts = data
|
79
|
+
list = read_scripts
|
108
80
|
if (item = list[n - 1])
|
109
|
-
val = item.first
|
81
|
+
val = opts ? "#{item.first} #{opts}" : item.first
|
110
82
|
elsif exception
|
111
|
-
|
83
|
+
indexerror n, list
|
112
84
|
else
|
113
85
|
next log.warn "run script #{n} of #{list.size} (out of range)"
|
114
86
|
end
|
@@ -145,7 +117,9 @@ module Squared
|
|
145
117
|
end
|
146
118
|
end
|
147
119
|
|
148
|
-
def copy(from: 'build', glob:
|
120
|
+
def copy(from: 'build', glob: nil, into: 'node_modules', scope: nil, also: nil, override: false)
|
121
|
+
return if @copy == false
|
122
|
+
|
149
123
|
if @copy && !override
|
150
124
|
return super if runnable?(@copy)
|
151
125
|
|
@@ -165,36 +139,29 @@ module Squared
|
|
165
139
|
else
|
166
140
|
case dir
|
167
141
|
when ::String
|
168
|
-
dest = workspace.
|
142
|
+
dest = workspace.rootpath(dir)
|
169
143
|
when ::Symbol
|
170
|
-
dest =
|
144
|
+
dest = workspace.find(name: dir)&.path
|
145
|
+
log.warn message("copy project :#{dir}", hint: 'not found') unless dest
|
171
146
|
when ::Hash
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
dest = val
|
179
|
-
when :from
|
180
|
-
from = val
|
181
|
-
when :glob
|
182
|
-
glob = val
|
183
|
-
when :scope
|
184
|
-
scope = val
|
185
|
-
when :into
|
186
|
-
into = val
|
187
|
-
end
|
188
|
-
end
|
147
|
+
missing = ->(val) { log.warn message("copy attr :#{val}", hint: 'missing') }
|
148
|
+
glob = dir[:glob]
|
149
|
+
into = dir[:into] if dir.key?(:into)
|
150
|
+
scope = dir[:scope]
|
151
|
+
missing.('target') unless (dest = dir[:target])
|
152
|
+
missing.('from') unless (from = dir[:from])
|
189
153
|
when Project::Base
|
190
154
|
dest = dir.path
|
155
|
+
else
|
156
|
+
raise_error("given: #{dir}", hint: 'unknown')
|
191
157
|
end
|
192
158
|
end
|
193
|
-
next unless dest&.directory?
|
159
|
+
next unless from && dest&.directory?
|
194
160
|
|
195
|
-
from =
|
161
|
+
from = basepath(from)
|
196
162
|
dest = dest.join(into, scope || project)
|
197
|
-
|
163
|
+
glob = as_a(glob || '**/*')
|
164
|
+
glob.each { |val| log.info "cp #{from.join(val)} #{dest}" }
|
198
165
|
copy_d(from, dest, glob: glob, verbose: verbose)
|
199
166
|
end
|
200
167
|
end
|
@@ -203,7 +170,7 @@ module Squared
|
|
203
170
|
if @depend && !flag
|
204
171
|
super
|
205
172
|
elsif outdated?
|
206
|
-
if (yarn =
|
173
|
+
if (yarn = dependtype(:yarn)) > 0
|
207
174
|
cmd = session 'yarn'
|
208
175
|
if yarn > 1
|
209
176
|
if flag == :dedupe
|
@@ -272,14 +239,14 @@ module Squared
|
|
272
239
|
dryrun ||= !option('dry-run', prefix: 'npm').nil?
|
273
240
|
end
|
274
241
|
log.info cmd
|
275
|
-
banner = format_banner("#{cmd}#{dryrun ? ' --dry-run' : ''}"
|
242
|
+
banner = format_banner("#{cmd}#{dryrun ? ' --dry-run' : ''}")
|
276
243
|
if invoked_sync?('outdated', rev)
|
277
244
|
print_item banner
|
278
245
|
banner = nil
|
279
246
|
end
|
280
247
|
data = nil
|
281
248
|
pwd_set { data = `#{cmd} --json --loglevel=error` }
|
282
|
-
json = JSON.parse(doc =
|
249
|
+
json = JSON.parse(doc = dependfile.read)
|
283
250
|
dep1 = json['dependencies'] || {}
|
284
251
|
dep2 = json['devDependencies'] || {}
|
285
252
|
found = []
|
@@ -312,7 +279,7 @@ module Squared
|
|
312
279
|
d = w[2]
|
313
280
|
case rev
|
314
281
|
when :major
|
315
|
-
upgrade = a == '0' ? c == '0' : true
|
282
|
+
upgrade = a == '0' ? c == '0' || c == '1' : true
|
316
283
|
when :minor
|
317
284
|
upgrade = ch == '^' && (a == '0' ? c == '0' && b == d : a == c)
|
318
285
|
when :patch
|
@@ -357,7 +324,7 @@ module Squared
|
|
357
324
|
col2 = size_col.(found, 1) + 4
|
358
325
|
found.each_with_index do |item, i|
|
359
326
|
a, b, c, d, e = item
|
360
|
-
if inter && (rev != :major || e || semmajor(item[5], item[6])) && !confirm_outdated(a, c, d, e)
|
327
|
+
if inter && (rev != :major || e || semmajor?(item[5], item[6])) && !confirm_outdated(a, c, d, e)
|
361
328
|
cur = -1
|
362
329
|
else
|
363
330
|
cur = modified
|
@@ -389,10 +356,10 @@ module Squared
|
|
389
356
|
if dryrun || (modified == 0 && pending > 0)
|
390
357
|
footer.(modified)
|
391
358
|
elsif modified > 0
|
392
|
-
File.write(
|
359
|
+
File.write(dependfile, doc)
|
393
360
|
modified = -1
|
394
361
|
footer.()
|
395
|
-
commit(:add, 'package.json', pass: true)
|
362
|
+
commit(:add, ['package.json'], pass: true)
|
396
363
|
install if opts.include?('prune')
|
397
364
|
end
|
398
365
|
elsif !avail.empty?
|
@@ -459,9 +426,9 @@ module Squared
|
|
459
426
|
end
|
460
427
|
unless (out = seg.join) == ver
|
461
428
|
begin
|
462
|
-
doc =
|
429
|
+
doc = dependfile.read
|
463
430
|
if doc.sub!(/"version"\s*:\s*"#{ver}"/, "\"version\": \"#{out}\"")
|
464
|
-
|
431
|
+
dependfile.write(doc)
|
465
432
|
log.info "bump version #{ver} to #{out} (#{flag})"
|
466
433
|
if verbose
|
467
434
|
major = flag == :major
|
@@ -488,11 +455,11 @@ module Squared
|
|
488
455
|
@pm[:version]
|
489
456
|
end
|
490
457
|
|
491
|
-
def
|
492
|
-
prog
|
493
|
-
|
494
|
-
|
495
|
-
@pm[prog]
|
458
|
+
def dependtype(prog)
|
459
|
+
return @pm[prog] if @pm.key?(prog)
|
460
|
+
|
461
|
+
meth = :"#{prog}?"
|
462
|
+
respond_to?(meth) && __send__(meth) ? @pm[prog] : 0
|
496
463
|
end
|
497
464
|
|
498
465
|
def depend?
|
@@ -504,12 +471,12 @@ module Squared
|
|
504
471
|
end
|
505
472
|
|
506
473
|
def outdated?
|
507
|
-
|
474
|
+
dependfile.exist?
|
508
475
|
end
|
509
476
|
|
510
477
|
def yarn?
|
511
|
-
(@pm[:yarn] ||= if
|
512
|
-
if (rc =
|
478
|
+
(@pm[:yarn] ||= if basepath('yarn.lock', ascend: find_package).exist?
|
479
|
+
if (rc = basepath('.yarnrc.yml', ascend: find_package)).exist?
|
513
480
|
begin
|
514
481
|
require 'yaml'
|
515
482
|
doc = YAML.load_file(rc)
|
@@ -528,10 +495,10 @@ module Squared
|
|
528
495
|
end
|
529
496
|
|
530
497
|
def pnpm?
|
531
|
-
(@pm[:pnpm] ||= if
|
498
|
+
(@pm[:pnpm] ||= if basepath('pnpm-lock.yaml', ascend: find_package).exist?
|
532
499
|
begin
|
533
500
|
require 'yaml'
|
534
|
-
doc = YAML.load_file(
|
501
|
+
doc = YAML.load_file(basepath('node_modules/.modules.yaml', ascend: find_package))
|
535
502
|
@pm[:_] = doc['packageManager']
|
536
503
|
case doc['nodeLinker']
|
537
504
|
when 'hoisted'
|
@@ -551,7 +518,7 @@ module Squared
|
|
551
518
|
|
552
519
|
def workspaces?
|
553
520
|
if pnpm?
|
554
|
-
|
521
|
+
basepath('pnpm-workspace.yaml').exist?
|
555
522
|
else
|
556
523
|
read_packagemanager
|
557
524
|
@pm[:workspaces].is_a?(::Array)
|
@@ -570,20 +537,18 @@ module Squared
|
|
570
537
|
|
571
538
|
def read_packagemanager(version: nil)
|
572
539
|
if @pm[:_].nil?
|
573
|
-
doc = JSON.parse(
|
540
|
+
doc = JSON.parse(dependfile.read)
|
574
541
|
@pm[:_] = (val = doc['packageManager']) ? val[0..(val.index('+') || 0) - 1] : false
|
575
542
|
@pm[:scripts] = doc['scripts']
|
576
543
|
@pm[:version] = doc['version']
|
577
544
|
@pm[:workspaces] = doc['workspaces']
|
578
545
|
end
|
579
546
|
rescue StandardError => e
|
580
|
-
log.debug e if
|
547
|
+
log.debug e if dependfile.exist?
|
581
548
|
@pm[:_] = false
|
582
549
|
nil
|
583
550
|
else
|
584
|
-
|
585
|
-
|
586
|
-
@pm[:_]
|
551
|
+
!(ret = @pm[:_]) || (version && ret[ret.index('@') + 1..-1] < version) ? nil : ret
|
587
552
|
end
|
588
553
|
|
589
554
|
def read_install
|
@@ -595,7 +560,7 @@ module Squared
|
|
595
560
|
|
596
561
|
def read_scripts
|
597
562
|
read_packagemanager
|
598
|
-
@pm[:scripts].is_a?(Hash) ? @pm[:scripts].to_a : []
|
563
|
+
@pm[:scripts].is_a?(::Hash) ? @pm[:scripts].to_a : []
|
599
564
|
end
|
600
565
|
|
601
566
|
def append_loglevel
|
@@ -604,7 +569,7 @@ module Squared
|
|
604
569
|
return unless silent || level
|
605
570
|
|
606
571
|
if yarn?
|
607
|
-
if
|
572
|
+
if dependtype(:yarn) == 1
|
608
573
|
if silent
|
609
574
|
@session << '--silent'
|
610
575
|
elsif level == 'verbose'
|
@@ -640,18 +605,14 @@ module Squared
|
|
640
605
|
'PATCH'
|
641
606
|
end, styles: theme[:header])
|
642
607
|
b = sub_style("#{pkg} #{ver}", styles: theme[:inline])
|
643
|
-
c, d = rev == 1 || lock ? [
|
608
|
+
c, d = rev == 1 || lock ? %w[y/N N] : %w[Y/n Y]
|
644
609
|
e = lock ? " #{sub_style('(locked)', styles: color(:red))}" : ''
|
645
|
-
confirm("Upgrade to #{a}? #{b}#{e} [#{c}] ", d, timeout: 60)
|
610
|
+
Common::Prompt.confirm("Upgrade to #{a}? #{b}#{e} [#{c}] ", d, timeout: 60)
|
646
611
|
end
|
647
612
|
|
648
613
|
def find_package
|
649
614
|
'package.json' if parent&.has?('outdated', Node.ref)
|
650
615
|
end
|
651
|
-
|
652
|
-
def headerstyle
|
653
|
-
{ pat: /^(\S+)(\s+)$/, styles: theme[:header] }
|
654
|
-
end
|
655
616
|
end
|
656
617
|
|
657
618
|
Application.implement Node
|
@@ -13,12 +13,15 @@ module Squared
|
|
13
13
|
class << self
|
14
14
|
def populate(*); end
|
15
15
|
def batchargs(*); end
|
16
|
-
def aliasargs(*); end
|
17
16
|
|
18
17
|
def tasks
|
19
18
|
%i[outdated].freeze
|
20
19
|
end
|
21
20
|
|
21
|
+
def bannerargs
|
22
|
+
%i[dependfile].freeze
|
23
|
+
end
|
24
|
+
|
22
25
|
def venv?
|
23
26
|
Dir.exist?(ENV.fetch('VIRTUAL_ENV', ''))
|
24
27
|
end
|
@@ -30,8 +33,6 @@ module Squared
|
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
|
-
attr_reader :requirements
|
34
|
-
|
35
36
|
def initialize(*, **kwargs)
|
36
37
|
super
|
37
38
|
if @pass.include?(Python.ref)
|
@@ -41,8 +42,8 @@ module Squared
|
|
41
42
|
initialize_build(Python.ref, **kwargs)
|
42
43
|
initialize_env(**kwargs)
|
43
44
|
end
|
44
|
-
@
|
45
|
-
@
|
45
|
+
@dependindex = REQUIREMENTS.index { |file| basepath(file).exist? }
|
46
|
+
@dependfile = basepath(REQUIREMENTS[@dependindex || 0])
|
46
47
|
end
|
47
48
|
|
48
49
|
@@tasks[ref] = {
|
@@ -78,8 +79,8 @@ module Squared
|
|
78
79
|
desc format_desc(action, flag, list, req: req)
|
79
80
|
if flag == :target
|
80
81
|
task flag, [:dir, :opts] do |_, args|
|
81
|
-
guard_params(action, flag, args: args, key: :dir)
|
82
|
-
depend(flag, dir:
|
82
|
+
dir = guard_params(action, flag, args: args, key: :dir)
|
83
|
+
depend(flag, dir: dir, opts: args.to_a[1..-1] || [])
|
83
84
|
end
|
84
85
|
else
|
85
86
|
task flag do |_, args|
|
@@ -97,7 +98,7 @@ module Squared
|
|
97
98
|
if @depend && !flag
|
98
99
|
super
|
99
100
|
elsif outdated?
|
100
|
-
case (type =
|
101
|
+
case (type = dependtype)
|
101
102
|
when 1, 2
|
102
103
|
cmd = pip_session 'install'
|
103
104
|
case flag
|
@@ -105,7 +106,7 @@ module Squared
|
|
105
106
|
cmd << '--user'
|
106
107
|
append_pip opts, OPT_USER
|
107
108
|
when :target
|
108
|
-
cmd << "--target=#{shell_escape(
|
109
|
+
cmd << "--target=#{shell_escape(basepath(dir), quote: true)}"
|
109
110
|
append_pip opts, OPT_USER + ['upgrade']
|
110
111
|
append_eager opts
|
111
112
|
when :upgrade
|
@@ -129,17 +130,13 @@ module Squared
|
|
129
130
|
run
|
130
131
|
end
|
131
132
|
|
132
|
-
def install_type(*)
|
133
|
-
requirements.exist? ? @reqindex + 1 : 0
|
134
|
-
end
|
135
|
-
|
136
133
|
def variable_set(key, *val, **)
|
137
134
|
case key
|
138
|
-
when :
|
139
|
-
req =
|
135
|
+
when :dependfile
|
136
|
+
req = basepath(*val)
|
140
137
|
if (index = REQUIREMENTS.index(req.basename.to_s))
|
141
|
-
@
|
142
|
-
@
|
138
|
+
@dependindex = index
|
139
|
+
@dependfile = req
|
143
140
|
else
|
144
141
|
log.warn "variable_set: @#{key}=#{req} (not supported)"
|
145
142
|
end
|
@@ -153,7 +150,7 @@ module Squared
|
|
153
150
|
end
|
154
151
|
|
155
152
|
def outdated?
|
156
|
-
|
153
|
+
dependtype > 0
|
157
154
|
end
|
158
155
|
|
159
156
|
private
|
@@ -179,7 +176,7 @@ module Squared
|
|
179
176
|
@session << "--proxy=#{shell_escape(val, quote: true)}"
|
180
177
|
end
|
181
178
|
if (val = option('log', ignore: false))
|
182
|
-
@session << "--log=#{shell_escape(
|
179
|
+
@session << "--log=#{shell_escape(basepath(val), quote: true)}"
|
183
180
|
end
|
184
181
|
append_nocolor option('no-color')
|
185
182
|
end
|