squared 0.3.6 → 0.4.1

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.
@@ -6,7 +6,7 @@ module Squared
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
8
  common: %w[dry-run include-workspace-root workspaces=b? w|workspace=b].freeze,
9
- install: %w[prefer-dedupe package-lock-only cpu=q libc=e os=q].freeze,
9
+ install: %w[prefer-dedupe package-lock-only cpu=b libc=b os=b].freeze,
10
10
  install_base: %w[ignore-scripts install-links strict-peer-deps include=b omit=b install-strategy=b].freeze,
11
11
  install_no: %w[audit bin-links fund package-lock].freeze,
12
12
  install_as: %w[foreground-scripts g|global no-save save save-bundle save-dev E|save-exact save-optional
@@ -37,15 +37,14 @@ module Squared
37
37
  no-node-version-check no-progress non-interactive offline pnp prefer-offline prod
38
38
  pure-lockfile skip-integrity-check strict-semver update-checksums cache-folder=p emoji=b?
39
39
  global-folder=p https-proxy=q link-folder=p modules-folder=p mutex=q network-concurrency=i
40
- network-timeout=i preferred-cache-folder=p production=e? proxy=q otp=e registry=q
41
- scripts-prepend-node-path=e?].freeze,
42
- update: %w[A|audit C|caret E|exact L|latest T|tilde P|pattern=q S|scope=e].freeze
40
+ network-timeout=i preferred-cache-folder=p production=b? proxy=q otp=b registry=q].freeze,
41
+ update: %w[A|audit C|caret E|exact L|latest T|tilde P|pattern=q S|scope=b].freeze
43
42
  }.freeze
44
43
  OPT_BERRY = {
45
44
  install: %w[check-cache check-resolutions immutable immutable-cache inline-builds json refresh-lockfile
46
- mode=e].freeze,
47
- update: %w[C|caret E|exact F|fixed interactive T|tilde R|recursive mode=e].freeze,
48
- dedupe: %w[check json mode=e strategy=b].freeze,
45
+ mode=b].freeze,
46
+ update: %w[C|caret E|exact F|fixed interactive T|tilde R|recursive mode=b].freeze,
47
+ dedupe: %w[check json mode=b strategy=b].freeze,
49
48
  pack: %w[n|dry-run install-if-needed json o|out=p].freeze
50
49
  }.freeze
51
50
  private_constant :OPT_NPM, :OPT_PNPM, :OPT_YARN, :OPT_BERRY
@@ -93,12 +92,13 @@ module Squared
93
92
  def initialize(*, **kwargs)
94
93
  super
95
94
  if @pass.include?(Node.ref)
96
- initialize_ref(Node.ref)
95
+ initialize_ref Node.ref
97
96
  initialize_logger(**kwargs)
98
97
  else
99
98
  initialize_build(Node.ref, prod: prod?, **kwargs)
100
99
  initialize_env(**kwargs)
101
100
  end
101
+ @buildtype = :run if script?
102
102
  @pm = {}
103
103
  @dependfile = basepath('package.json')
104
104
  end
@@ -218,26 +218,25 @@ module Squared
218
218
  end
219
219
  end
220
220
 
221
- def copy(from: 'build', into: 'node_modules', workspace: false, scope: nil, also: nil, create: nil,
221
+ def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, workspace: false,
222
222
  link: false, force: false, override: false, **kwargs)
223
- return if @copy == false
224
-
223
+ glob = kwargs[:include]
224
+ pass = kwargs[:exclude]
225
225
  if @copy && !override
226
- return super if runnable?(@copy)
226
+ return super unless @copy.is_a?(Hash)
227
227
 
228
228
  from = @copy[:from] if @copy.key?(:from)
229
229
  into = @copy[:into] if @copy.key?(:into)
230
230
  workspace = @copy[:workspace] if @copy.key?(:workspace)
231
231
  link = @copy[:link] if @copy.key?(:link)
232
- force = @copy[:force] if @copy.key?(:link)
233
- glob = @copy[:include]
234
- exclude = @copy[:exclude]
235
- scope = @copy[:scope]
236
- also = @copy[:also]
237
- create = @copy[:create]
238
- else
239
- glob = kwargs[:include]
240
- exclude = kwargs[:exclude]
232
+ force = @copy[:force] if @copy.key?(:force)
233
+ scope = @copy[:scope] if @copy.key?(:scope)
234
+ also = @copy[:also] if @copy.key?(:also)
235
+ create = @copy[:create] if @copy.key?(:create)
236
+ glob = @copy[:include] if @copy.key?(:include)
237
+ pass = @copy[:exclude] if @copy.key?(:exclude)
238
+ elsif @copy == false
239
+ return
241
240
  end
242
241
  items = []
243
242
  items << @workspace.home if build? && path != @workspace.home && @workspace.home?
@@ -256,8 +255,6 @@ module Squared
256
255
  dest = @workspace.find(name: dir)&.path
257
256
  log.warn message("copy project :#{dir}", hint: 'not found') unless dest
258
257
  when Hash
259
- glob = dir[:include]
260
- exclude = dir[:exclude]
261
258
  from = dir[:from] if dir.key?(:from)
262
259
  into = dir[:into] if dir.key?(:into)
263
260
  scope = dir[:scope] if dir.key?(:scope)
@@ -266,11 +263,13 @@ module Squared
266
263
  dest = dir[:target]
267
264
  create = dir[:create]
268
265
  workspace = dir[:workspace]
266
+ glob = dir[:include]
267
+ pass = dir[:exclude]
269
268
  dest = items.first unless dest && dest != true
270
269
  when Project::Base
271
270
  dest = dir.path
272
271
  else
273
- raise_error("given: #{dir}", hint: 'unknown')
272
+ raise_error "copy given: #{dir}"
274
273
  end
275
274
  next unless from && dest&.directory?
276
275
 
@@ -305,7 +304,7 @@ module Squared
305
304
  target.each do |src, to|
306
305
  glob.each { |val| log.info "cp #{from.join(val)} #{to}" }
307
306
  begin
308
- copy_dir(src, to, glob, create: create, link: link, force: force, pass: exclude, verbose: verbose)
307
+ copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
309
308
  rescue StandardError => e
310
309
  log.error e
311
310
  ret = on(:error, :copy, e)
@@ -320,6 +319,7 @@ module Squared
320
319
  if @depend && !flag
321
320
  super
322
321
  elsif outdated?
322
+ workspace.rev_clear name
323
323
  return update if !flag && env('NODE_UPDATE')
324
324
 
325
325
  if (yarn = dependtype(:yarn)) > 0
@@ -387,7 +387,7 @@ module Squared
387
387
  ret = on(:error, :outdated, e)
388
388
  raise if exception && ret != true
389
389
  end
390
- warn log_message(Logger::WARN, e) if warning?
390
+ warn log_message(Logger::WARN, e, pass: true) if warning?
391
391
  return
392
392
  else
393
393
  dep1 = json['dependencies'] || {}
@@ -405,7 +405,7 @@ module Squared
405
405
 
406
406
  latest = val['latest']
407
407
  ch = file[0]
408
- if ch =~ /[~^]/
408
+ if ch.match?(/[~^]/)
409
409
  file = file[1..-1]
410
410
  elsif inter && rev == :major
411
411
  major = true
@@ -414,7 +414,7 @@ module Squared
414
414
  next
415
415
  end
416
416
  current = val['current'] || file
417
- want = rev == :major && (ver = latest.match(SEM_VER)) && !ver[6] ? latest : val['wanted']
417
+ want = rev == :major && !latest[SEM_VER, 6] ? latest : val['wanted']
418
418
  next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
419
419
 
420
420
  f = semscan(file)
@@ -540,7 +540,9 @@ module Squared
540
540
 
541
541
  def publish(flag = nil, *, sync: invoked_sync?('publish', flag), otp: nil, tag: nil, dryrun: nil, **)
542
542
  if read_packagemanager(:private)
543
- warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private') if warning?
543
+ if warning?
544
+ warn log_message(Logger::WARN, 'invalid task "publish"', subject: name, hint: 'private', pass: true)
545
+ end
544
546
  return
545
547
  end
546
548
  return unless version
@@ -564,7 +566,7 @@ module Squared
564
566
  banner = format_banner(cmd.to_s)
565
567
  Open3.popen2e(cmd.done) do |_, out|
566
568
  write_lines(out, banner: banner, sub: npmnotice + [
567
- { pat: /^(.+)(Tarball .+)$/, styles: :blue, index: 2 }
569
+ { pat: /^(.+)(Tarball .+)$/, styles: color(:blue), index: 2 }
568
570
  ])
569
571
  end
570
572
  end
@@ -676,7 +678,7 @@ module Squared
676
678
  end
677
679
  on :last, :bump unless dryrun?
678
680
  else
679
- raise_error('not found', hint: 'version')
681
+ raise_error('version not found', hint: dependfile)
680
682
  end
681
683
  rescue StandardError => e
682
684
  log.debug e
@@ -699,26 +701,26 @@ module Squared
699
701
  run(from: :pack)
700
702
  end
701
703
 
702
- def compose(opts, flags = nil, script: false, args: nil, from: :build, **)
703
- return unless opts
704
+ def compose(target, opts = nil, script: false, args: nil, from: :run, **)
705
+ return unless target
704
706
 
705
707
  if script
706
708
  ret = session dependbin, 'run'
707
- raise_error("#{dependbin} run script: #{from}", hint: "given #{opts}") unless append_any(opts)
708
- append_any flags if flags
709
+ raise_error("#{dependbin} run: given #{target}", hint: from) unless append_any(target, build: true)
710
+ append_any opts if opts
709
711
  append_loglevel
710
712
  append_any(args, delim: true) if args
711
713
  ret
712
714
  else
713
- case opts
715
+ case target
714
716
  when String
715
- opts
717
+ target
716
718
  when Hash
717
- append_hash(opts).join(' ')
719
+ append_hash(target).join(' ')
718
720
  when Enumerable
719
- opts.to_a.join(' ')
721
+ target.to_a.join(' ')
720
722
  else
721
- raise_error("#{project}: #{from}", hint: "given #{opts}")
723
+ raise_error("compose given: #{target}", hint: from)
722
724
  end
723
725
  end
724
726
  end
@@ -727,10 +729,6 @@ module Squared
727
729
  @depend != false && (!@depend.nil? || outdated?)
728
730
  end
729
731
 
730
- def copy?
731
- super || @copy.is_a?(Hash)
732
- end
733
-
734
732
  def outdated?
735
733
  dependfile.exist?
736
734
  end
@@ -740,8 +738,8 @@ module Squared
740
738
  end
741
739
 
742
740
  def yarn?
743
- (@pm[:yarn] ||= if basepath('yarn.lock', ascend: dependext).exist?
744
- if (rc = basepath('.yarnrc.yml', ascend: dependext)).exist?
741
+ (@pm[:yarn] ||= if rootpath('yarn.lock', ascend: dependext).exist?
742
+ if (rc = rootpath('.yarnrc.yml', ascend: dependext)).exist?
745
743
  begin
746
744
  require 'yaml'
747
745
  doc = YAML.load_file(rc)
@@ -761,7 +759,7 @@ module Squared
761
759
  end
762
760
 
763
761
  def pnpm?
764
- (@pm[:pnpm] ||= if basepath('pnpm-lock.yaml', ascend: dependext).exist?
762
+ (@pm[:pnpm] ||= if rootpath('pnpm-lock.yaml', ascend: dependext).exist?
765
763
  begin
766
764
  require 'yaml'
767
765
  doc = YAML.load_file(basepath('node_modules/.modules.yaml', ascend: dependext))
@@ -913,9 +911,9 @@ module Squared
913
911
 
914
912
  def npmnotice
915
913
  [
916
- { pat: /^(npm error )(code|\d+)(.+)$/, styles: :cyan, index: 2 },
917
- { pat: /^(npm )(error)(.*)$/, styles: :red, index: 2 },
918
- { pat: /^(npm )(notice)(.*)$/, styles: :cyan, index: 2 },
914
+ { pat: /^(npm error )(code|\d+)(.+)$/, styles: color(:cyan), index: 2 },
915
+ { pat: /^(npm )(error)(.*)$/, styles: color(:red), index: 2 },
916
+ { pat: /^(npm )(notice)(.*)$/, styles: color(:cyan), index: 2 },
919
917
  { pat: /^(npm )(.+)$/, styles: :bold }
920
918
  ]
921
919
  end
@@ -4,26 +4,42 @@ module Squared
4
4
  module Workspace
5
5
  module Project
6
6
  class Python < Git
7
- REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
7
+ REQUIREMENTS = %w[requirements.txt pyproject.toml setup.cfg].freeze
8
8
  SETUPTOOLS = %w[setup.py pyproject.toml].freeze
9
9
  DIR_PYTHON = (REQUIREMENTS + SETUPTOOLS).freeze
10
+ OPT_PYTHON = {
11
+ common: %w[b B d E h i I O OO P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
12
+ build: %w[n|no-isolation s|sdist v|verbose w|wheel x|skip-dependency-check C|config-setting=q installer=b
13
+ o|outdir=p].freeze
14
+ }.freeze
10
15
  OPT_PIP = {
11
16
  common: %w[debug disable-pip-version-check isolated no-cache-dir no-color no-input no-python-version-warning
12
17
  q|quiet require-virtualenv v|verbose cache-dir=p cert=p client-cert=p exists-action=b log=p
13
- proxy=q python=e retries=i timeout=i trusted-host=e use-deprecated=e use-feature=e].freeze,
18
+ proxy=q python=q retries=i timeout=i trusted-host=b use-deprecated=b use-feature=b].freeze,
14
19
  install: %w[break-system-packages check-build-dependencies compile dry-run force-reinstall I|ignore-installed
15
20
  ignore-requires-python no-build-isolation no-clean no-compile no-deps no-index no-warn-conflicts
16
- no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=e
21
+ no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=b
17
22
  config-settings=q c|constraint=p e|editable=b? extra-index-url=q f|find-links=q global-option=q
18
23
  implementation=b i|index-url=q no-binary=q only-binary=q platform=q prefix=p progress-bar=b
19
- python-version=q report=p r|requirement=p root=p root-user-action=e src=p t|target=p
24
+ python-version=q report=p r|requirement=p root=p root-user-action=b src=p t|target=p
20
25
  upgrade-strategy=b].freeze
21
26
  }.freeze
22
- private_constant :REQUIREMENTS, :SETUPTOOLS, :DIR_PYTHON, :OPT_PIP
27
+ OPT_HATCH = {
28
+ common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=e
29
+ q|quiet v|verbose].freeze,
30
+ build: %w[clean-hooks-after ext hooks-only no-hooks c|clean t|target=b].freeze,
31
+ publish: %w[initialize-auth n|no-prompt y|yes a|auth=q ca-cert=p client-cert=p client-key=p o|option=q
32
+ p|publisher=b r|repo=b u|user=q].freeze
33
+ }.freeze
34
+ OPT_TWINE = {
35
+ publish: %w[attestations disable-progress-bar non-interactive skip-existing verbose s|sign c|comment=q
36
+ config-file=p cert=p client-cert=p i|identity=b p|password=q r|repository=b repository-url=q
37
+ sign-with=b u|username=q].freeze
38
+ }.freeze
39
+ private_constant :REQUIREMENTS, :SETUPTOOLS, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_HATCH, :OPT_TWINE
23
40
 
24
41
  class << self
25
42
  def populate(*); end
26
- def batchargs(*); end
27
43
 
28
44
  def tasks
29
45
  [:outdated].freeze
@@ -47,7 +63,7 @@ module Squared
47
63
  def initialize(*, **kwargs)
48
64
  super
49
65
  if @pass.include?(Python.ref)
50
- initialize_ref(Python.ref)
66
+ initialize_ref Python.ref
51
67
  initialize_logger(**kwargs)
52
68
  else
53
69
  initialize_build(Python.ref, **kwargs)
@@ -58,7 +74,9 @@ module Squared
58
74
  end
59
75
 
60
76
  @@tasks[ref] = {
61
- 'install' => %i[user force upgrade target editable].freeze
77
+ 'install' => %i[user force upgrade target editable].freeze,
78
+ 'build' => %i[python hatch].freeze,
79
+ 'publish' => %i[twine hatch].freeze
62
80
  }.freeze
63
81
 
64
82
  def ref
@@ -111,6 +129,16 @@ module Squared
111
129
  depend flag, args.to_a
112
130
  end
113
131
  end
132
+ when 'build'
133
+ format_desc(action, flag, 'opts*', after: flag == :hatch ? 'location?' : 'srcdir?')
134
+ task flag do |_, args|
135
+ buildx flag, args.to_a
136
+ end
137
+ when 'publish'
138
+ format_desc(action, flag, 'opts*', after: flag == :hatch ? 'artifacts?' : 'dist?')
139
+ task flag do |_, args|
140
+ publish flag, args.to_a
141
+ end
114
142
  end
115
143
  end
116
144
  end
@@ -122,6 +150,7 @@ module Squared
122
150
  if @depend && !flag
123
151
  super
124
152
  elsif outdated?
153
+ workspace.rev_clear name
125
154
  cmd = pip_session 'install'
126
155
  case flag
127
156
  when :user
@@ -143,21 +172,6 @@ module Squared
143
172
  end
144
173
  end
145
174
 
146
- def install(flag, opts, strategy: nil)
147
- cmd = pip_session 'install'
148
- out = append_pip(flag, opts, from: :install)
149
- case flag
150
- when :editable
151
- cmd << '--editable' << (out.pop || '.')
152
- option_clear out
153
- when :upgrade
154
- cmd << '--upgrade'
155
- cmd << basic_option('upgrade-strategy', strategy) if strategy
156
- append_value out
157
- end
158
- run(from: :install)
159
- end
160
-
161
175
  def outdated(*, sync: invoked_sync?('outdated'))
162
176
  cmd = pip_session 'list', '--outdated'
163
177
  append_global
@@ -173,7 +187,7 @@ module Squared
173
187
  buffer = []
174
188
  out = ->(val) { sync ? puts(val) : buffer << val }
175
189
  IO.popen(cmd).each do |line|
176
- next if line =~ /^[\s-]+$/
190
+ next if line.match?(/^[\s-]+$/)
177
191
 
178
192
  if start > 0
179
193
  unless stdin?
@@ -210,7 +224,7 @@ module Squared
210
224
  end
211
225
  out.("#{start.to_s.rjust(2)}. #{line}")
212
226
  start += 1
213
- elsif line =~ /^Package /
227
+ elsif line.start_with?('Package')
214
228
  unless stdin?
215
229
  sub = { pat: /^(.*)(?<!\dm)(Package|Latest)(.+)$/, styles: theme[:header], index: 2 }
216
230
  out.(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
@@ -231,6 +245,82 @@ module Squared
231
245
  on :last, :outdated
232
246
  end
233
247
 
248
+ def install(flag, opts = [], strategy: nil)
249
+ cmd = pip_session 'install'
250
+ out = append_pip(flag, opts, from: :install)
251
+ case flag
252
+ when :editable
253
+ cmd << '--editable' << (out.pop || '.')
254
+ option_clear out
255
+ when :upgrade
256
+ cmd << '--upgrade'
257
+ cmd << basic_option('upgrade-strategy', strategy) if strategy
258
+ append_value out
259
+ end
260
+ run(from: :install)
261
+ end
262
+
263
+ def buildx(flag, opts = [])
264
+ cmd = session flag
265
+ out = []
266
+ srcdir = nil
267
+ case flag
268
+ when :python
269
+ cmd << shell_option('m', 'build')
270
+ list = OPT_PYTHON[:build] + OPT_PYTHON[:common]
271
+ when :hatch
272
+ cmd << 'build'
273
+ list = OPT_HATCH[:build] + OPT_HATCH[:common]
274
+ end
275
+ option_sanitize(opts, list).first.each do |opt|
276
+ if opt =~ /^(v+|q+)$/ || (flag == :python && opt =~ /^(b+)$/)
277
+ cmd << "-#{$1}"
278
+ elsif !srcdir && basepath(opt).exist? && projectpath?(opt)
279
+ srcdir = opt
280
+ else
281
+ out << opt
282
+ end
283
+ end
284
+ if flag == :hatch
285
+ if ENV['HATCH_BUILD_LOCATION']
286
+ srcdir = nil
287
+ else
288
+ srcdir ||= path
289
+ end
290
+ cmd << basic_option('p', project) unless ENV['HATCH_PROJECT'] || session_arg?('p', 'project')
291
+ end
292
+ cmd << shell_quote(basepath(srcdir)) if srcdir
293
+ option_clear out
294
+ run(from: :"#{flag}:build")
295
+ end
296
+
297
+ def publish(flag, opts = [])
298
+ cmd = session flag
299
+ out = []
300
+ case flag
301
+ when :twine
302
+ cmd << 'upload'
303
+ list = OPT_TWINE[:publish]
304
+ when :hatch
305
+ cmd << 'publish'
306
+ list = OPT_HATCH[:publish] + OPT_HATCH[:common]
307
+ end
308
+ option_sanitize(opts, list).first.each do |opt|
309
+ if flag == :hatch && opt =~ /^(v+|q+)$/
310
+ cmd << "-#{$1}"
311
+ else
312
+ out << opt
313
+ end
314
+ end
315
+ if out.empty?
316
+ dist = basepath.join('dist')
317
+ raise_error('no source files given', hint: dist) unless dist.directory? && !dist.empty?
318
+ out << "#{dist}/*"
319
+ end
320
+ append_value out
321
+ run(from: :"#{flag}:publish")
322
+ end
323
+
234
324
  def variable_set(key, *val, **)
235
325
  case key
236
326
  when :dependfile
@@ -11,27 +11,27 @@ module Squared
11
11
  install: %w[frozen no-cache no-prune system path=p binstubs=p? standalone=q? target-rbconfig=p trust-policy=b
12
12
  with=q without=q].freeze,
13
13
  install_base: %w[full-index quiet retry gemfile=p j|jobs=i].freeze,
14
- update: %w[conservative local pre redownload ruby strict bundler=e? g|group=q source=e].freeze,
14
+ update: %w[conservative local pre redownload ruby strict bundler=b? g|group=q source=b].freeze,
15
15
  outdated: %w[filter-major filter-minor filter-patch groups local parseable pre only-explicit strict
16
- update-strict g|group=q source=e].freeze,
16
+ update-strict g|group=q source=b].freeze,
17
17
  exec: %w[gemfile=p].freeze,
18
18
  check: %w[dry-run gemfile=p].freeze
19
19
  }.freeze
20
20
  OPT_GEM = {
21
21
  common: %w[backtrace debug q|quiet no-verbose norc silent V|verbose config-file=p].freeze,
22
- install: %w[version=e].freeze,
23
- update: %w[system=e?].freeze,
22
+ install: %w[version=b].freeze,
23
+ update: %w[system=b?].freeze,
24
24
  outdated: %w[b|both clear-sources l|local no-http-proxy r|remote B|bulk-threshold=i p|http-proxy=q?
25
25
  platform=q source=q].freeze,
26
- push: %w[no-http-proxy attestation=p host=q key=e otp=e p|http-proxy=q?].freeze,
26
+ push: %w[no-http-proxy attestation=p host=q key=b otp=b p|http-proxy=q?].freeze,
27
27
  build: %w[force strict o|output=p platform=q].freeze,
28
- exec: %w[conservative prerelease no-prerelease g|gem=b version=e].freeze,
28
+ exec: %w[conservative prerelease no-prerelease g|gem=b version=b].freeze,
29
29
  pristine: %w[all env-shebang extensions no-env-shebang no-extensions only-executables only-missing-extensions
30
- only-plugins n|bindir=p i|install-dir=p skip=e v|version=e].freeze,
30
+ only-plugins n|bindir=p i|install-dir=p skip=b v|version=b].freeze,
31
31
  shared: %w[f b|both clear-sources conservative default development development-all E|explain
32
32
  ignore-dependencies l|local N|no-document r|remote w|vendor n|bindir=p build-root=p
33
33
  bulk-threshold=i document=b? g|file=p? p|http-proxy=q i|install-dir=p platform=q s|source=q
34
- target-rbconfig=p? P|trust-policy=b without=e].freeze,
34
+ target-rbconfig=p? P|trust-policy=b without=b].freeze,
35
35
  shared_no: %w[env-shebang force format-executable http-proxy lock minimal-deps post-install-message
36
36
  prerelease suggestions user-install wrappers].freeze
37
37
  }.freeze
@@ -39,7 +39,6 @@ module Squared
39
39
 
40
40
  class << self
41
41
  def populate(*); end
42
- def batchargs(*); end
43
42
 
44
43
  def tasks
45
44
  [:outdated].freeze
@@ -70,7 +69,7 @@ module Squared
70
69
  def initialize(*, autodetect: false, **kwargs)
71
70
  super
72
71
  if @pass.include?(Ruby.ref)
73
- initialize_ref(Ruby.ref)
72
+ initialize_ref Ruby.ref
74
73
  initialize_logger(**kwargs)
75
74
  else
76
75
  initialize_build(Ruby.ref, **kwargs)
@@ -83,7 +82,7 @@ module Squared
83
82
 
84
83
  begin
85
84
  File.foreach(file) do |line|
86
- next unless line =~ %r{\brequire\s+(["'])bundler/gem_tasks\1}
85
+ next unless line.match?(%r{\brequire\s+(["'])bundler/gem_tasks\1})
87
86
 
88
87
  cmd = bundle_output('exec', 'rake').to_s
89
88
  @output[0] = "#{cmd} build"
@@ -178,6 +177,7 @@ module Squared
178
177
  if @depend
179
178
  super
180
179
  elsif outdated?
180
+ workspace.rev_clear name
181
181
  cmd = bundle_session 'install'
182
182
  if (n = option('jobs')).to_i > 0
183
183
  cmd << "-j#{n}"
@@ -188,7 +188,7 @@ module Squared
188
188
 
189
189
  def copy(from: 'lib', include: nil, exclude: nil, into: @gemdir, override: false)
190
190
  if @copy && !override
191
- return super if runnable?(@copy)
191
+ return super unless @copy.is_a?(Hash)
192
192
 
193
193
  from = @copy[:from] if @copy.key?(:from)
194
194
  glob = @copy[:include] if @copy.key?(:include)
@@ -301,7 +301,7 @@ module Squared
301
301
  end
302
302
  end
303
303
  out.("#{start.to_s.rjust(2)}. #{line}")
304
- elsif line =~ /^Gem /
304
+ elsif line.start_with?('Gem')
305
305
  unless stdin?
306
306
  sub = { pat: /^(.+)(?<!\dm)(Gem|Latest)(.+)$/, styles: theme[:header], index: 2 }
307
307
  out.(print_footer(" # #{line.chomp}", reverse: true, sub: [sub, sub]))
@@ -388,14 +388,14 @@ module Squared
388
388
  pwd_set(pass: !pwd.nil?, from: from) do
389
389
  items = [[%w[Gem Current Latest], nil]]
390
390
  IO.popen(cmd.done).each do |line|
391
- if (data = line.match(/^(\S+) \((\S+) < ([^)]+)\)$/))
392
- cur = semscan(data[2])
393
- lat = semscan(data[3])
394
- items << [data.to_a.drop(1), if semmajor?(cur, lat)
395
- %i[green bold]
396
- else
397
- cur[2] == lat[2] ? [:yellow] : [:green]
398
- end]
391
+ if line =~ /^(\S+) \((\S+) < ([^)]+)\)$/
392
+ cur = semscan($2)
393
+ lat = semscan($3)
394
+ items << [$~.to_a.drop(1), if semmajor?(cur, lat)
395
+ %i[green bold]
396
+ else
397
+ cur[2] == lat[2] ? [:yellow] : [:green]
398
+ end]
399
399
  else
400
400
  puts line
401
401
  end
@@ -427,7 +427,7 @@ module Squared
427
427
  line = sub_style(line, pat: /^(.+)(?<!\dm)(#{a}|#{c})(.*)$/, styles: theme[:header], index: 2)
428
428
  end
429
429
  puts line
430
- puts '-' * n
430
+ puts sub_style(ARG[:BORDER][1] * n, styles: borderstyle)
431
431
  else
432
432
  styles = item.last
433
433
  a = a.ljust(d)
@@ -461,25 +461,23 @@ module Squared
461
461
  when :build, :push
462
462
  if !out.empty?
463
463
  if flag == :build && out.size == 1
464
- cmd << basepath(out.first)
464
+ cmd << shell_quote(basepath(out.first))
465
465
  else
466
- raise_error('gem', flag, out.join(', '), hint: 'unrecognized option')
466
+ raise_error("unknown args: #{out.join(', ')}", hint: flag)
467
467
  end
468
468
  elsif flag == :build
469
469
  cmd << "#{project}.gemspec"
470
470
  end
471
471
  when :exec
472
- raise_error('gem', flag, hint: 'no command given') if out.empty?
472
+ raise_error('no command given', hint: flag) if out.empty?
473
473
  cmd << project << out.join(' ')
474
474
  else
475
- if out.empty? && cmd.none? { |val| val =~ /^--system(?:=|$)/ }
476
- raise_error('gem', flag, hint: 'no gemname given')
477
- end
475
+ raise_error('no gemname given', hint: flag) if out.empty? && !session_arg?('system')
478
476
  if flag == :pristine
479
477
  if session_arg?('all')
480
478
  append_repeat 'skip', out
481
479
  out.clear
482
- elsif (n = out.first =~ /@/)
480
+ elsif (n = out.first.index('@'))
483
481
  name = out.first
484
482
  if n == 0
485
483
  cmd << project
@@ -504,7 +502,7 @@ module Squared
504
502
  when 'exec', 'check'
505
503
  args = option_sanitize(args, OPT_BUNDLE[flag.to_sym] + OPT_BUNDLE[:common]).first
506
504
  end
507
- raise_error('bundle', flag, hint: 'no command given') unless !args.empty? || flag == 'check'
505
+ raise_error('no command given', hint: flag) unless !args.empty? || flag == 'check'
508
506
  cmd.merge(args)
509
507
  run(from: :"bundle:#{flag}")
510
508
  end
@@ -568,7 +566,7 @@ module Squared
568
566
  end
569
567
  pwd_set { parse.(`#{bundle_output('show', project)}`) } unless @gemdir
570
568
  end
571
- raise_error('failed to parse', hint: @version || 'path') unless @gemdir
569
+ raise_error('parse failed', hint: @version || 'path') unless @gemdir
572
570
  rescue StandardError => e
573
571
  log.error e
574
572
  @version = nil
@@ -601,7 +599,7 @@ module Squared
601
599
 
602
600
  def bundle_session(*cmd, **kwargs)
603
601
  ret = session('bundle', *cmd, **kwargs)
604
- append_nocolor(target: ret)
602
+ append_nocolor
605
603
  ret
606
604
  end
607
605
 
@@ -647,7 +645,7 @@ module Squared
647
645
  def rakefile
648
646
  return unless (file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? })
649
647
 
650
- basepath(file)
648
+ basepath file
651
649
  end
652
650
 
653
651
  def rakeapp
@@ -657,13 +655,13 @@ module Squared
657
655
  def rakepwd
658
656
  return unless Rake::VERSION >= '13.0.4'
659
657
 
660
- quote_option('C', path)
658
+ quote_option 'C', path
661
659
  end
662
660
 
663
661
  def gempwd
664
662
  return unless Gem::VERSION >= '3.4.2'
665
663
 
666
- quote_option('C', path)
664
+ quote_option 'C', path
667
665
  end
668
666
 
669
667
  def gempath(val = @version)