squared 0.4.25 → 0.5.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 +62 -364
- data/README.md +1279 -650
- data/README.ruby.md +722 -0
- data/lib/squared/common/base.rb +8 -9
- data/lib/squared/common/format.rb +17 -24
- data/lib/squared/common/prompt.rb +38 -42
- data/lib/squared/common/shell.rb +29 -29
- data/lib/squared/common/system.rb +34 -37
- data/lib/squared/common/utils.rb +3 -28
- data/lib/squared/common.rb +2 -1
- data/lib/squared/config.rb +21 -21
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +67 -91
- data/lib/squared/workspace/project/base.rb +355 -476
- data/lib/squared/workspace/project/docker.rb +175 -203
- data/lib/squared/workspace/project/git.rb +357 -498
- data/lib/squared/workspace/project/node.rb +138 -213
- data/lib/squared/workspace/project/python.rb +88 -306
- data/lib/squared/workspace/project/ruby.rb +220 -300
- data/lib/squared/workspace/project/support/class.rb +94 -288
- data/lib/squared/workspace/project.rb +0 -10
- data/lib/squared/workspace/repo.rb +53 -92
- data/lib/squared/workspace/series.rb +34 -32
- data/lib/squared/workspace/support/data.rb +3 -2
- data/lib/squared/workspace/support.rb +0 -1
- data/lib/squared/workspace.rb +1 -1
- data/squared.gemspec +5 -5
- metadata +8 -12
- data/lib/squared/common/class.rb +0 -110
- data/lib/squared/workspace/support/base.rb +0 -37
|
@@ -5,34 +5,32 @@ module Squared
|
|
|
5
5
|
module Project
|
|
6
6
|
class Node < Git
|
|
7
7
|
OPT_NPM = {
|
|
8
|
-
common: %w[dry-run
|
|
9
|
-
install: %w[package-lock-only
|
|
10
|
-
install_base: %w[
|
|
11
|
-
strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
|
|
8
|
+
common: %w[dry-run include-workspace-root workspaces=b? w|workspace=v].freeze,
|
|
9
|
+
install: %w[prefer-dedupe package-lock-only cpu=b libc=b os=b].freeze,
|
|
10
|
+
install_base: %w[ignore-scripts install-links strict-peer-deps include=b omit=b install-strategy=b].freeze,
|
|
12
11
|
install_no: %w[audit bin-links fund package-lock].freeze,
|
|
13
|
-
install_as: %w[no-save save-bundle save-dev save-
|
|
14
|
-
|
|
15
|
-
run: %w[foreground-scripts
|
|
12
|
+
install_as: %w[foreground-scripts g|global no-save save save-bundle save-dev E|save-exact save-optional
|
|
13
|
+
save-peer S|save-prod].freeze,
|
|
14
|
+
run: %w[foreground-scripts if-present ignore-scripts script-shell=p].freeze,
|
|
16
15
|
exec: %w[c|call=q package=b].freeze,
|
|
17
|
-
pack: %w[ignore-scripts
|
|
16
|
+
pack: %w[json ignore-scripts pack-destination=p].freeze
|
|
18
17
|
}.freeze
|
|
19
18
|
OPT_PNPM = {
|
|
20
19
|
common: %w[aggregate-output color no-color stream use-stderr C|dir=p loglevel=b w|workspace-root].freeze,
|
|
21
|
-
cpu: %w[cpu=b libc=b os=b].freeze,
|
|
22
20
|
filter: %w[fail-if-no-match changed-files-ignore-pattern=q filter=q filter-prod=q test-pattern=q].freeze,
|
|
23
21
|
install: %w[fix-lockfile force ignore-pnpmfile ignore-workspace lockfile-only merge-git-branch-lockfiles
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
no-hoist no-lockfile no-optional prefer-frozen-lockfile resolution-only shamefully-hoist
|
|
23
|
+
side-effects-cache side-effects-cache-readonly s|silent strict-peer-dependencies
|
|
26
24
|
use-running-store-server use-store-server child-concurrency=i hoist-pattern=q lockfile-dir=p
|
|
27
25
|
modules-dir=p network-concurrency=i package-import-method=b public-hoist-pattern=q
|
|
28
26
|
reporter=b].freeze,
|
|
29
27
|
install_base: %w[global-dir ignore-scripts offline prefer-offline store-dir=p virtual-store-dir=p].freeze,
|
|
30
28
|
install_no: %w[frozen-lockfile verify-store-integrity].freeze,
|
|
31
29
|
install_as: %w[D|dev global-dir no-optional P|prod r|recursive].freeze,
|
|
32
|
-
update: %w[
|
|
30
|
+
update: %w[global interactive latest depth=i].freeze,
|
|
33
31
|
dedupe: %w[check].freeze,
|
|
34
|
-
run: %w[if-present no-bail parallel r|recursive report-summary reporter-hide-prefix resume-from
|
|
35
|
-
|
|
32
|
+
run: %w[if-present no-bail parallel r|recursive report-summary reporter-hide-prefix resume-from sequential
|
|
33
|
+
stream use-stderr].freeze,
|
|
36
34
|
exec: %w[no-reporter-hide-prefix parallel r|recursive report-summary resume-from c|shell-mode].freeze,
|
|
37
35
|
pack: %w[json pack-destination=p pack-gzip-level=i].freeze
|
|
38
36
|
}.freeze
|
|
@@ -96,10 +94,11 @@ module Squared
|
|
|
96
94
|
'add' => nil,
|
|
97
95
|
'run' => nil,
|
|
98
96
|
'exec' => nil,
|
|
97
|
+
'nvm' => nil,
|
|
99
98
|
'pack' => nil
|
|
100
99
|
})
|
|
101
100
|
|
|
102
|
-
def initialize(*,
|
|
101
|
+
def initialize(*, **kwargs)
|
|
103
102
|
super
|
|
104
103
|
if @pass.include?(Node.ref)
|
|
105
104
|
initialize_ref Node.ref
|
|
@@ -108,8 +107,8 @@ module Squared
|
|
|
108
107
|
initialize_build(Node.ref, prod: prod?, **kwargs)
|
|
109
108
|
initialize_env(**kwargs)
|
|
110
109
|
end
|
|
111
|
-
@dependfile =
|
|
112
|
-
@pm = {
|
|
110
|
+
@dependfile = @path + 'package.json'
|
|
111
|
+
@pm = {}
|
|
113
112
|
end
|
|
114
113
|
|
|
115
114
|
def ref
|
|
@@ -118,11 +117,11 @@ module Squared
|
|
|
118
117
|
|
|
119
118
|
def populate(*, **)
|
|
120
119
|
super
|
|
121
|
-
return unless
|
|
120
|
+
return unless outdated? && ref?(Node.ref)
|
|
122
121
|
|
|
123
122
|
namespace name do
|
|
124
123
|
Node.subtasks do |action, flags|
|
|
125
|
-
next if
|
|
124
|
+
next if @pass.include?(action)
|
|
126
125
|
|
|
127
126
|
if flags.nil?
|
|
128
127
|
case action
|
|
@@ -134,23 +133,23 @@ module Squared
|
|
|
134
133
|
exact = true
|
|
135
134
|
save = save[1..-1]
|
|
136
135
|
end
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
case save
|
|
137
|
+
when 'prod', 'dev', 'optional', 'peer'
|
|
138
|
+
packages = args.to_a.drop(1)
|
|
139
|
+
else
|
|
140
|
+
save = 'prod'
|
|
141
|
+
packages = args.to_a
|
|
142
|
+
end
|
|
144
143
|
param_guard(action, 'name', args: packages)
|
|
145
144
|
depend(:add, packages: packages, save: save, exact: exact)
|
|
146
145
|
end
|
|
147
146
|
when 'run'
|
|
148
147
|
next if (list = read_scripts).empty?
|
|
149
148
|
|
|
150
|
-
format_desc action, nil,
|
|
149
|
+
format_desc action, nil, 'script,opts*|^index+|#,pattern*'
|
|
151
150
|
task action, [:script] do |_, args|
|
|
152
151
|
if args.script == '#'
|
|
153
|
-
format_list(list,
|
|
152
|
+
format_list(list, 'run[^N]', 'scripts', grep: args.extras, from: dependfile.to_s)
|
|
154
153
|
else
|
|
155
154
|
args = param_guard(action, 'script', args: args.to_a)
|
|
156
155
|
opts = []
|
|
@@ -187,7 +186,7 @@ module Squared
|
|
|
187
186
|
format_desc action, nil, 'pkg/cmd,opts*,args*'
|
|
188
187
|
task action, [:package] do |_, args|
|
|
189
188
|
if (package = args.package)
|
|
190
|
-
args = args.
|
|
189
|
+
args = args.to_a.drop(1)
|
|
191
190
|
if pnpm?
|
|
192
191
|
pre = ->(ch) { "-#{ch}" if (ch = args.delete(ch)) }
|
|
193
192
|
cmd = session 'pnpm', pre.call('r'), pre.call('c'), 'exec'
|
|
@@ -212,6 +211,17 @@ module Squared
|
|
|
212
211
|
end
|
|
213
212
|
run(from: :exec)
|
|
214
213
|
end
|
|
214
|
+
when 'nvm'
|
|
215
|
+
next unless ENV['NVM_DIR']
|
|
216
|
+
|
|
217
|
+
format_desc action, nil, 'version,args*'
|
|
218
|
+
task action, [:version] do |_, args|
|
|
219
|
+
version = param_guard(action, 'version', args: args, key: :version)
|
|
220
|
+
args = args.to_a.drop(1)
|
|
221
|
+
args << readline('Enter command', force: true) if args.empty?
|
|
222
|
+
args.prepend(File.join(ENV['NVM_DIR'], 'nvm-exec'))
|
|
223
|
+
run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
|
|
224
|
+
end
|
|
215
225
|
when 'pack'
|
|
216
226
|
format_desc action, nil, 'opts*'
|
|
217
227
|
task action do |_, args|
|
|
@@ -223,12 +233,12 @@ module Squared
|
|
|
223
233
|
flags.each do |flag|
|
|
224
234
|
case action
|
|
225
235
|
when 'outdated'
|
|
226
|
-
format_desc(action, flag, %w[
|
|
236
|
+
format_desc(action, flag, %w[prune interactive dry-run].freeze, arg: 'opts?')
|
|
227
237
|
task flag do |_, args|
|
|
228
238
|
outdated flag, args.to_a
|
|
229
239
|
end
|
|
230
240
|
when 'package'
|
|
231
|
-
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : '
|
|
241
|
+
format_desc(action, flag, 'opts*', after: flag == :dedupe ? nil : 'names*')
|
|
232
242
|
task flag do |_, args|
|
|
233
243
|
package flag, args.to_a
|
|
234
244
|
end
|
|
@@ -249,7 +259,7 @@ module Squared
|
|
|
249
259
|
format_desc(action, flag, 'otp?,dry-run?,public|restricted?', before: flag == :tag ? 'tag' : nil)
|
|
250
260
|
task flag do |_, args|
|
|
251
261
|
args = args.to_a
|
|
252
|
-
dryrun = true if args.delete('dry-run') || args.delete('
|
|
262
|
+
dryrun = true if args.delete('dry-run') || args.delete('d')
|
|
253
263
|
if args.delete('public') || args.delete('p')
|
|
254
264
|
access = 'public'
|
|
255
265
|
elsif args.delete('restricted') || args.delete('r')
|
|
@@ -270,7 +280,7 @@ module Squared
|
|
|
270
280
|
end
|
|
271
281
|
end
|
|
272
282
|
|
|
273
|
-
def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil,
|
|
283
|
+
def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, workspace: false,
|
|
274
284
|
link: false, force: false, override: false, sync: invoked_sync?('copy'), **kwargs)
|
|
275
285
|
glob = kwargs[:include]
|
|
276
286
|
pass = kwargs[:exclude]
|
|
@@ -279,7 +289,6 @@ module Squared
|
|
|
279
289
|
|
|
280
290
|
from = @copy[:from] if @copy.key?(:from)
|
|
281
291
|
into = @copy[:into] if @copy.key?(:into)
|
|
282
|
-
files = @copy[:files] if @copy.key?(:files)
|
|
283
292
|
workspace = @copy[:workspace] if @copy.key?(:workspace)
|
|
284
293
|
link = @copy[:link] if @copy.key?(:link)
|
|
285
294
|
force = @copy[:force] if @copy.key?(:force)
|
|
@@ -301,7 +310,6 @@ module Squared
|
|
|
301
310
|
|
|
302
311
|
on :first, :copy
|
|
303
312
|
print_item unless @output[0] || !verbose || task_invoked?(/^copy(?::#{Node.ref}|$)/)
|
|
304
|
-
packed = false
|
|
305
313
|
items.each do |dir|
|
|
306
314
|
case dir
|
|
307
315
|
when Pathname
|
|
@@ -339,56 +347,16 @@ module Squared
|
|
|
339
347
|
end
|
|
340
348
|
next unless from && dest&.directory?
|
|
341
349
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
unless packed
|
|
345
|
-
require 'open3'
|
|
346
|
-
files = pwd_set do
|
|
347
|
-
Open3.capture2e(session_output('npm', 'pack --dry-run --no-color', npmname).to_s)
|
|
348
|
-
.first
|
|
349
|
-
.scan(/^npm notice \d+(?:\.\d+)?[a-z]+ (.+)$/i)
|
|
350
|
-
.map { |item| Pathname.new(item.first) }
|
|
351
|
-
.select(&:exist?)
|
|
352
|
-
end
|
|
353
|
-
.concat(Array(files))
|
|
354
|
-
packed = true
|
|
355
|
-
end
|
|
356
|
-
to = dest.join(into, npmname)
|
|
357
|
-
to.mkpath
|
|
358
|
-
log.info "cp npm:#{npmname} #{to}"
|
|
359
|
-
subdir = []
|
|
360
|
-
errors = 0
|
|
361
|
-
files.each do |file|
|
|
362
|
-
s, d = file.is_a?(Array) ? file : [file, file]
|
|
363
|
-
dest = to + d
|
|
364
|
-
unless subdir.include?((target = dest.dirname).to_s)
|
|
365
|
-
target.mkpath
|
|
366
|
-
subdir << target.to_s
|
|
367
|
-
end
|
|
368
|
-
begin
|
|
369
|
-
FileUtils.cp(basepath(s), dest, verbose: verbosetype > 0)
|
|
370
|
-
rescue StandardError => e
|
|
371
|
-
print_error e
|
|
372
|
-
errors += 1
|
|
373
|
-
end
|
|
374
|
-
end
|
|
375
|
-
rescue StandardError => e
|
|
376
|
-
on_error e, :copy
|
|
377
|
-
else
|
|
378
|
-
puts message(to, subdir.size, files.size - errors) if verbose
|
|
379
|
-
end
|
|
380
|
-
next
|
|
381
|
-
end
|
|
382
|
-
glob = Array(glob || '**/*')
|
|
350
|
+
from = path + from
|
|
351
|
+
glob = as_a(glob || '**/*')
|
|
383
352
|
target = []
|
|
384
|
-
from = basepath from
|
|
385
353
|
if workspace
|
|
386
|
-
|
|
387
|
-
next unless
|
|
354
|
+
from.glob('*').each do |entry|
|
|
355
|
+
next unless entry.directory?
|
|
388
356
|
|
|
389
|
-
sub = if (proj = @workspace.find(
|
|
357
|
+
sub = if (proj = @workspace.find(entry))
|
|
390
358
|
proj.packagename
|
|
391
|
-
elsif (file =
|
|
359
|
+
elsif (file = entry + 'package.json').exist?
|
|
392
360
|
begin
|
|
393
361
|
doc = JSON.parse(file.read)
|
|
394
362
|
rescue StandardError => e
|
|
@@ -399,20 +367,22 @@ module Squared
|
|
|
399
367
|
end
|
|
400
368
|
end
|
|
401
369
|
if sub
|
|
402
|
-
target << [
|
|
370
|
+
target << [entry, dest.join(into, sub)]
|
|
403
371
|
else
|
|
404
|
-
log.debug message("package.json in \"#{
|
|
372
|
+
log.debug message("package.json in \"#{entry}\"", hint: 'not found')
|
|
405
373
|
end
|
|
406
374
|
end
|
|
407
375
|
else
|
|
408
|
-
target << [from, dest.join(into, scope ||
|
|
376
|
+
target << [from, dest.join(into, scope || project)]
|
|
409
377
|
end
|
|
410
378
|
target.each do |src, to|
|
|
411
379
|
glob.each { |val| log.info "cp #{from + val} #{to}" }
|
|
412
380
|
begin
|
|
413
|
-
copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose:
|
|
381
|
+
copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
|
|
414
382
|
rescue StandardError => e
|
|
415
|
-
|
|
383
|
+
log.error e
|
|
384
|
+
ret = on(:error, :copy, e)
|
|
385
|
+
raise if exception && ret != true
|
|
416
386
|
end
|
|
417
387
|
end
|
|
418
388
|
end
|
|
@@ -426,19 +396,7 @@ module Squared
|
|
|
426
396
|
workspace.rev_clear(name, sync: sync)
|
|
427
397
|
return update if !flag && env('NODE_UPDATE')
|
|
428
398
|
|
|
429
|
-
|
|
430
|
-
yarn = pnpm ? 0 : dependtype(:yarn)
|
|
431
|
-
if @pm[:__] && !pnpm && yarn == 0
|
|
432
|
-
case @pm[:__]
|
|
433
|
-
when 'pnpm'
|
|
434
|
-
pnpm = true
|
|
435
|
-
when 'yarn'
|
|
436
|
-
yarn = 1
|
|
437
|
-
when 'berry'
|
|
438
|
-
yarn = 2
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
if yarn > 0
|
|
399
|
+
if (yarn = dependtype(:yarn)) > 0
|
|
442
400
|
cmd = session 'yarn'
|
|
443
401
|
if flag == :add
|
|
444
402
|
cmd << 'add'
|
|
@@ -448,16 +406,15 @@ module Squared
|
|
|
448
406
|
cmd << 'install'
|
|
449
407
|
cmd << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
|
|
450
408
|
end
|
|
451
|
-
elsif pnpm
|
|
409
|
+
elsif pnpm?
|
|
452
410
|
cmd = session 'pnpm'
|
|
453
411
|
if flag == :add
|
|
454
412
|
cmd << 'add' << "--save-#{save}"
|
|
455
413
|
cmd << '--save-exact' if exact
|
|
456
414
|
else
|
|
457
415
|
cmd << 'install'
|
|
458
|
-
append_platform
|
|
459
416
|
end
|
|
460
|
-
|
|
417
|
+
option('public-hoist-pattern', ignore: false) do |val|
|
|
461
418
|
split_escape(val).each { |opt| cmd << shell_option('public-hoist-pattern', opt) }
|
|
462
419
|
end
|
|
463
420
|
cmd << '--ignore-workspace' if env('NODE_WORKSPACES', equals: '0')
|
|
@@ -467,9 +424,7 @@ module Squared
|
|
|
467
424
|
if flag == :add
|
|
468
425
|
cmd << "--save-#{save}"
|
|
469
426
|
cmd << '--save-exact' if exact
|
|
470
|
-
cmd.merge(packages.map { |pkg|
|
|
471
|
-
else
|
|
472
|
-
append_platform
|
|
427
|
+
cmd.merge(packages.map { |pkg| shell_escape(pkg) })
|
|
473
428
|
end
|
|
474
429
|
cmd << '--workspaces=false' if env('NODE_WORKSPACES', equals: '0')
|
|
475
430
|
cmd << '--package-lock=false' if option('package-lock', equals: '0')
|
|
@@ -482,7 +437,7 @@ module Squared
|
|
|
482
437
|
|
|
483
438
|
def outdated(flag = nil, opts = [], sync: invoked_sync?('outdated', flag))
|
|
484
439
|
dryrun = opts.include?('dry-run') || opts.include?('d')
|
|
485
|
-
if pnpm?
|
|
440
|
+
if pnpm? && read_packagemanager(version: '7.15', update: true)
|
|
486
441
|
cmd = session 'pnpm', 'outdated'
|
|
487
442
|
dryrun ||= dryrun?('pnpm')
|
|
488
443
|
else
|
|
@@ -493,14 +448,19 @@ module Squared
|
|
|
493
448
|
log.info cmd.to_s
|
|
494
449
|
on :first, :outdated
|
|
495
450
|
end
|
|
496
|
-
banner = format_banner(cmd.temp(dryrun ? '--dry-run' : nil))
|
|
451
|
+
banner = format_banner(cmd.temp(dryrun ? ' --dry-run' : nil))
|
|
497
452
|
print_item banner if sync
|
|
498
453
|
begin
|
|
499
454
|
data = pwd_set { `#{cmd.temp('--json', '--loglevel=error')}` }
|
|
500
455
|
doc = dependfile.read
|
|
501
456
|
json = JSON.parse(doc)
|
|
502
457
|
rescue StandardError => e
|
|
503
|
-
|
|
458
|
+
log.error e
|
|
459
|
+
unless dryrun
|
|
460
|
+
ret = on(:error, :outdated, e)
|
|
461
|
+
raise if exception && ret != true
|
|
462
|
+
end
|
|
463
|
+
warn log_message(Logger::WARN, e, pass: true) if warning?
|
|
504
464
|
return
|
|
505
465
|
else
|
|
506
466
|
dep1 = json['dependencies'] || {}
|
|
@@ -527,19 +487,7 @@ module Squared
|
|
|
527
487
|
next
|
|
528
488
|
end
|
|
529
489
|
current = val['current'] || file
|
|
530
|
-
want = val['wanted']
|
|
531
|
-
unless latest[SEM_VER, 6]
|
|
532
|
-
case rev
|
|
533
|
-
when :major
|
|
534
|
-
want = latest
|
|
535
|
-
when :minor
|
|
536
|
-
want = latest if latest[SEM_VER, 1] == want[SEM_VER, 1]
|
|
537
|
-
when :patch
|
|
538
|
-
if (g = latest.match(SEM_VER)) && (h = want.match(SEM_VER)) && g[1] == h[1] && g[3] == h[3]
|
|
539
|
-
want = latest
|
|
540
|
-
end
|
|
541
|
-
end
|
|
542
|
-
end
|
|
490
|
+
want = rev == :major && !latest[SEM_VER, 6] ? latest : val['wanted']
|
|
543
491
|
next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
|
|
544
492
|
|
|
545
493
|
f = semscan file
|
|
@@ -596,7 +544,7 @@ module Squared
|
|
|
596
544
|
found.each_with_index do |item, i|
|
|
597
545
|
a, b, c, d, e = item
|
|
598
546
|
f = inter && (rev != :major || e || semmajor?(item[5], item[6]))
|
|
599
|
-
if f && !confirm_outdated(a, c, (d / 2.0).ceil, lock: e)
|
|
547
|
+
if f && !confirm_outdated(a, c, (d / 2.0).ceil, b, lock: e, col1: col1)
|
|
600
548
|
cur = -1
|
|
601
549
|
else
|
|
602
550
|
cur = modified
|
|
@@ -631,13 +579,10 @@ module Squared
|
|
|
631
579
|
footer.call(modified, found.size)
|
|
632
580
|
elsif modified > 0
|
|
633
581
|
modified = -1
|
|
582
|
+
footer.call(0, found.size)
|
|
634
583
|
File.write(dependfile, doc)
|
|
635
|
-
if opts.include?('update') || opts.include?('u') || option('update')
|
|
636
|
-
update
|
|
637
|
-
else
|
|
638
|
-
footer.call(0, found.size)
|
|
639
|
-
end
|
|
640
584
|
commit(:add, refs: ['package.json'], pass: true)
|
|
585
|
+
install if opts.include?('prune') || opts.include?('p')
|
|
641
586
|
end
|
|
642
587
|
elsif !avail.empty?
|
|
643
588
|
col1 = size_col.call(avail, 0) + 4
|
|
@@ -663,60 +608,61 @@ module Squared
|
|
|
663
608
|
end
|
|
664
609
|
|
|
665
610
|
def update(*)
|
|
666
|
-
package
|
|
611
|
+
package 'update'
|
|
667
612
|
end
|
|
668
613
|
|
|
669
|
-
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil,
|
|
670
|
-
|
|
671
|
-
|
|
614
|
+
def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, access: nil)
|
|
615
|
+
if read_packagemanager(:private)
|
|
616
|
+
if warning?
|
|
617
|
+
warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private', pass: true)
|
|
618
|
+
end
|
|
672
619
|
return
|
|
673
620
|
end
|
|
621
|
+
return unless version
|
|
622
|
+
|
|
674
623
|
cmd = session 'npm', 'publish'
|
|
624
|
+
dryrun = dryrun?('npm') if dryrun.nil?
|
|
675
625
|
cmd << basic_option('otp', otp) if otp ||= option('otp')
|
|
676
|
-
cmd << basic_option('tag', tag
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
require 'open3'
|
|
694
|
-
on :first, from
|
|
695
|
-
pwd_set(from: from, dryrun: dryrun) do
|
|
696
|
-
cmd = session_done cmd
|
|
697
|
-
Open3.popen2e(cmd) do |_, out|
|
|
698
|
-
write_lines(out, banner: format_banner(cmd),
|
|
699
|
-
sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:bright_blue), index: 2])
|
|
626
|
+
cmd << basic_option('tag', tag) if tag ||= option('tag')
|
|
627
|
+
cmd << basic_option('access', access) if access ||= option('access')
|
|
628
|
+
if verbose
|
|
629
|
+
if dryrun
|
|
630
|
+
cmd << '--dry-run'
|
|
631
|
+
else
|
|
632
|
+
log.info cmd.to_s
|
|
633
|
+
end
|
|
634
|
+
unless sync
|
|
635
|
+
on :first, :publish unless dryrun
|
|
636
|
+
pwd_set(from: :publish) do
|
|
637
|
+
require 'open3'
|
|
638
|
+
banner = format_banner cmd.to_s
|
|
639
|
+
Open3.popen2e(cmd.done) do |_, out|
|
|
640
|
+
write_lines(out, sub: npmnotice + [pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2],
|
|
641
|
+
banner: banner)
|
|
642
|
+
end
|
|
700
643
|
end
|
|
644
|
+
on :last, :publish unless dryrun
|
|
645
|
+
return
|
|
701
646
|
end
|
|
702
|
-
|
|
647
|
+
elsif dryrun
|
|
648
|
+
return
|
|
703
649
|
end
|
|
650
|
+
run(from: :publish, sync: sync)
|
|
704
651
|
end
|
|
705
652
|
|
|
706
|
-
def package(flag, opts = []
|
|
653
|
+
def package(flag, opts = [])
|
|
707
654
|
workspace.rev_clear(name)
|
|
708
655
|
if (yarn = dependtype(:yarn)) > 0
|
|
709
656
|
cmd = session 'yarn', if flag == :update
|
|
710
|
-
yarn == 1 ? 'upgrade' : 'up'
|
|
657
|
+
flag = yarn == 1 ? 'upgrade' : 'up'
|
|
711
658
|
else
|
|
712
|
-
|
|
659
|
+
flag
|
|
713
660
|
end
|
|
714
661
|
op = OptionPartition.new(opts, if yarn == 1
|
|
715
|
-
OPT_YARN.fetch(flag
|
|
662
|
+
OPT_YARN.fetch(flag, []) + OPT_YARN[:common]
|
|
716
663
|
else
|
|
717
664
|
OPT_BERRY[flag]
|
|
718
665
|
end, cmd, project: self)
|
|
719
|
-
op << '--ignore-engines' if yarn == 1 && !option('ignore-engines', equals: '0')
|
|
720
666
|
op.clear
|
|
721
667
|
append_loglevel
|
|
722
668
|
else
|
|
@@ -724,7 +670,6 @@ module Squared
|
|
|
724
670
|
cmd = session 'pnpm', flag
|
|
725
671
|
list = OPT_PNPM[:install_base] + OPT_PNPM.fetch(flag, []) + OPT_PNPM[:common]
|
|
726
672
|
list.concat(OPT_PNPM[:install_as] + OPT_PNPM[:filter]) unless flag == :dedupe
|
|
727
|
-
list.concat(OPT_PNPM[:cpu]) unless flag == :update
|
|
728
673
|
no = OPT_PNPM[:"#{flag}_no"]
|
|
729
674
|
else
|
|
730
675
|
cmd = session 'npm', flag
|
|
@@ -737,7 +682,7 @@ module Squared
|
|
|
737
682
|
if opt =~ op.values
|
|
738
683
|
case $1
|
|
739
684
|
when 'w', 'workspace'
|
|
740
|
-
op << ($2.match?(%r{[\\/]}) ? quote_option($1,
|
|
685
|
+
op << ($2.match?(%r{[\\/]}) ? quote_option($1, path + $2) : shell_option($1, $2))
|
|
741
686
|
end
|
|
742
687
|
elsif opt.include?('=')
|
|
743
688
|
op.errors << opt
|
|
@@ -746,17 +691,16 @@ module Squared
|
|
|
746
691
|
end
|
|
747
692
|
end
|
|
748
693
|
op.swap
|
|
749
|
-
append_platform if flag == :install
|
|
750
694
|
append_nocolor
|
|
751
695
|
append_loglevel
|
|
752
696
|
if flag == :dedupe
|
|
753
697
|
op.clear
|
|
754
698
|
else
|
|
755
|
-
op.append(
|
|
699
|
+
op.append(escape: true)
|
|
756
700
|
end
|
|
757
701
|
op.clear(errors: true)
|
|
758
702
|
end
|
|
759
|
-
run(from:
|
|
703
|
+
run(from: :"package:#{flag}")
|
|
760
704
|
end
|
|
761
705
|
|
|
762
706
|
def bump(flag, val = nil)
|
|
@@ -770,17 +714,14 @@ module Squared
|
|
|
770
714
|
when :major
|
|
771
715
|
if seg[0] != '0' || seg[2].nil?
|
|
772
716
|
seg[0] = seg[0].succ
|
|
773
|
-
seg[2] = '0'
|
|
774
717
|
else
|
|
775
718
|
seg[2] = seg[2].succ
|
|
776
719
|
end
|
|
777
|
-
seg[4] = '0'
|
|
778
720
|
when :minor
|
|
779
721
|
if seg[0] == '0'
|
|
780
722
|
seg[4] &&= seg[4].succ
|
|
781
723
|
else
|
|
782
724
|
seg[2] = seg[2].succ
|
|
783
|
-
seg[4] &&= '0'
|
|
784
725
|
end
|
|
785
726
|
when :patch
|
|
786
727
|
seg[4] &&= seg[4].succ
|
|
@@ -796,22 +737,24 @@ module Squared
|
|
|
796
737
|
log.info "bump version #{cur} to #{val} (#{flag})"
|
|
797
738
|
on :first, :bump
|
|
798
739
|
end
|
|
799
|
-
if
|
|
800
|
-
puts val
|
|
801
|
-
elsif verbose
|
|
740
|
+
if verbose
|
|
802
741
|
major = flag == :major
|
|
803
742
|
emphasize("version: #{val}", title: name, border: borderstyle, sub: [
|
|
804
743
|
headerstyle,
|
|
805
744
|
{ pat: /\A(version:)( )(\S+)(.*)\z/, styles: color(major ? :green : :yellow), index: 3 },
|
|
806
745
|
{ pat: /\A(version:)(.*)\z/, styles: theme[major ? :major : :active] }
|
|
807
746
|
])
|
|
747
|
+
elsif stdin?
|
|
748
|
+
puts val
|
|
808
749
|
end
|
|
809
750
|
on :last, :bump unless dryrun?
|
|
810
751
|
else
|
|
811
752
|
raise_error('version not found', hint: dependfile)
|
|
812
753
|
end
|
|
813
754
|
rescue StandardError => e
|
|
814
|
-
|
|
755
|
+
log.debug e
|
|
756
|
+
ret = on(:error, :bump, e)
|
|
757
|
+
raise if exception && ret != true
|
|
815
758
|
end
|
|
816
759
|
end
|
|
817
760
|
|
|
@@ -821,7 +764,7 @@ module Squared
|
|
|
821
764
|
cmd = session dependbin, 'pack'
|
|
822
765
|
if dependtype(:yarn) > 1
|
|
823
766
|
op = OptionPartition.new(opts, OPT_BERRY[:pack], cmd, project: self)
|
|
824
|
-
op
|
|
767
|
+
op << quote_option('out', Pathname.pwd + "#{project}-#{version}.tgz") unless op.arg?('out')
|
|
825
768
|
else
|
|
826
769
|
op = OptionPartition.new(opts, pnpm? ? OPT_PNPM[:pack] : OPT_NPM[:pack] + OPT_NPM[:common], cmd,
|
|
827
770
|
project: self)
|
|
@@ -831,12 +774,12 @@ module Squared
|
|
|
831
774
|
|
|
832
775
|
case $1
|
|
833
776
|
when 'w', 'workspace'
|
|
834
|
-
op << ($2.match?(%r{[\\/]}) ? quote_option($1,
|
|
777
|
+
op << ($2.match?(%r{[\\/]}) ? quote_option($1, path + $2) : shell_option($1, $2))
|
|
835
778
|
op.found << opt
|
|
836
779
|
end
|
|
837
780
|
end
|
|
838
781
|
end
|
|
839
|
-
op
|
|
782
|
+
op << quote_option('pack-destination', Dir.pwd) unless op.arg?('pack-destination')
|
|
840
783
|
end
|
|
841
784
|
op.clear
|
|
842
785
|
run(from: :pack)
|
|
@@ -848,16 +791,16 @@ module Squared
|
|
|
848
791
|
if script
|
|
849
792
|
ret = session dependbin, 'run'
|
|
850
793
|
raise_error("#{dependbin} run: given #{target}", hint: from) unless append_any(target, build: true)
|
|
851
|
-
append_any opts
|
|
794
|
+
append_any opts
|
|
852
795
|
append_loglevel
|
|
853
|
-
append_any(args, delim: true)
|
|
796
|
+
append_any(args, delim: true)
|
|
854
797
|
ret
|
|
855
798
|
else
|
|
856
799
|
case target
|
|
857
800
|
when String
|
|
858
801
|
target
|
|
859
802
|
when Hash
|
|
860
|
-
append_hash(target
|
|
803
|
+
append_hash(target).join(' ')
|
|
861
804
|
when Enumerable
|
|
862
805
|
target.to_a.join(' ')
|
|
863
806
|
else
|
|
@@ -949,26 +892,14 @@ module Squared
|
|
|
949
892
|
respond_to?(meth) && __send__(meth) ? @pm[prog] : 0
|
|
950
893
|
end
|
|
951
894
|
|
|
952
|
-
def dependbin
|
|
953
|
-
if yarn?
|
|
954
|
-
'yarn'
|
|
955
|
-
else
|
|
956
|
-
pnpm? ? 'pnpm' : 'npm'
|
|
957
|
-
end
|
|
958
|
-
end
|
|
959
|
-
|
|
960
895
|
def version
|
|
961
|
-
@version
|
|
896
|
+
super || (@version = read_packagemanager(:version))
|
|
962
897
|
end
|
|
963
898
|
|
|
964
899
|
def packagename
|
|
965
900
|
read_packagemanager :name
|
|
966
901
|
end
|
|
967
902
|
|
|
968
|
-
def scripts
|
|
969
|
-
@scripts ||= read_scripts.to_h
|
|
970
|
-
end
|
|
971
|
-
|
|
972
903
|
private
|
|
973
904
|
|
|
974
905
|
def read_packagemanager(key = nil, version: nil, update: false)
|
|
@@ -986,11 +917,9 @@ module Squared
|
|
|
986
917
|
@pm[:_] = false
|
|
987
918
|
nil
|
|
988
919
|
else
|
|
989
|
-
if key
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
ret
|
|
993
|
-
end
|
|
920
|
+
return @pm[key] if key
|
|
921
|
+
|
|
922
|
+
!(ret = @pm[:_]) || (version && ret[ret.index('@') + 1..-1] < version) ? nil : ret
|
|
994
923
|
end
|
|
995
924
|
|
|
996
925
|
def read_install
|
|
@@ -1006,7 +935,7 @@ module Squared
|
|
|
1006
935
|
end
|
|
1007
936
|
|
|
1008
937
|
def append_loglevel(target: @session)
|
|
1009
|
-
level = env
|
|
938
|
+
level = env 'NODE_LOGLEVEL'
|
|
1010
939
|
silent = !verbose || level == 'silent'
|
|
1011
940
|
return unless silent || level
|
|
1012
941
|
|
|
@@ -1037,11 +966,15 @@ module Squared
|
|
|
1037
966
|
end
|
|
1038
967
|
end
|
|
1039
968
|
|
|
1040
|
-
def
|
|
1041
|
-
|
|
1042
|
-
|
|
969
|
+
def dryrun?(prefix = dependbin, **)
|
|
970
|
+
super || !option('dry-run', prefix: prefix).nil?
|
|
971
|
+
end
|
|
1043
972
|
|
|
1044
|
-
|
|
973
|
+
def dependbin
|
|
974
|
+
if yarn?
|
|
975
|
+
'yarn'
|
|
976
|
+
else
|
|
977
|
+
pnpm? ? 'pnpm' : 'npm'
|
|
1045
978
|
end
|
|
1046
979
|
end
|
|
1047
980
|
|
|
@@ -1049,22 +982,14 @@ module Squared
|
|
|
1049
982
|
'package.json' if parent&.has?('outdated', Node.ref)
|
|
1050
983
|
end
|
|
1051
984
|
|
|
1052
|
-
def npmname
|
|
1053
|
-
packagename || project
|
|
1054
|
-
end
|
|
1055
|
-
|
|
1056
985
|
def npmnotice
|
|
1057
986
|
[
|
|
1058
|
-
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:
|
|
1059
|
-
{ pat: /^(npm )(error)(.*)$/, styles: color(:
|
|
1060
|
-
{ pat: /^(npm )(notice)(.*)$/, styles: color(:
|
|
987
|
+
{ pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:cyan), index: 2 },
|
|
988
|
+
{ pat: /^(npm )(error)(.*)$/, styles: color(:red), index: 2 },
|
|
989
|
+
{ pat: /^(npm )(notice)(.*)$/, styles: color(:cyan), index: 2 },
|
|
1061
990
|
{ pat: /^(npm )(.+)$/, styles: :bold }
|
|
1062
991
|
]
|
|
1063
992
|
end
|
|
1064
|
-
|
|
1065
|
-
def dryrun?(prefix = dependbin, **)
|
|
1066
|
-
super || !option('dry-run', prefix: prefix).nil?
|
|
1067
|
-
end
|
|
1068
993
|
end
|
|
1069
994
|
|
|
1070
995
|
Application.implement Node
|