squared 0.4.8 → 0.4.9

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.
@@ -98,9 +98,8 @@ module Squared
98
98
  initialize_build(Node.ref, prod: prod?, **kwargs)
99
99
  initialize_env(**kwargs)
100
100
  end
101
- @buildtype = :run if script?
102
101
  @pm = {}
103
- @dependfile = basepath('package.json')
102
+ @dependfile = @path + 'package.json'
104
103
  end
105
104
 
106
105
  def ref
@@ -204,8 +203,8 @@ module Squared
204
203
  if check.call(otp)
205
204
  dryrun = true
206
205
  otp = nil
207
- elsif dryrun
208
- dryrun = check.call(dryrun)
206
+ else
207
+ dryrun &&= check.call(dryrun)
209
208
  end
210
209
  publish(flag, otp: otp, tag: tag, dryrun: dryrun)
211
210
  end
@@ -253,7 +252,7 @@ module Squared
253
252
  dest = dir
254
253
  @workspace.rev_clear(dest)
255
254
  when String
256
- dest = @workspace.rootpath(dir)
255
+ dest = @workspace.root + dir
257
256
  @workspace.rev_clear(dest)
258
257
  when Symbol
259
258
  if (proj = @workspace.find(name: dir))
@@ -284,16 +283,16 @@ module Squared
284
283
  end
285
284
  next unless from && dest&.directory?
286
285
 
287
- from = basepath(from)
286
+ from = path + from
288
287
  glob = as_a(glob || '**/*')
289
288
  target = []
290
289
  if workspace
291
- Dir.glob(from.join('*')).each do |path|
290
+ Dir.glob(from + '*').each do |path|
292
291
  next unless (path = Pathname.new(path)).directory?
293
292
 
294
293
  sub = if (proj = @workspace.find(path))
295
294
  proj.packagename
296
- elsif (file = path.join('package.json')).exist?
295
+ elsif (file = path + 'package.json').exist?
297
296
  begin
298
297
  doc = JSON.parse(file.read)
299
298
  rescue StandardError => e
@@ -313,7 +312,7 @@ module Squared
313
312
  target << [from, dest.join(into, scope || project)]
314
313
  end
315
314
  target.each do |src, to|
316
- glob.each { |val| log.info "cp #{from.join(val)} #{to}" }
315
+ glob.each { |val| log.info "cp #{from + val} #{to}" }
317
316
  begin
318
317
  copy_dir(src, to, glob, create: create, link: link, force: force, pass: pass, verbose: verbose)
319
318
  rescue StandardError => e
@@ -428,8 +427,8 @@ module Squared
428
427
  want = rev == :major && !latest[SEM_VER, 6] ? latest : val['wanted']
429
428
  next unless (current != want || file != want) && (want.match?(SEM_VER) || !file.match?(SEM_VER))
430
429
 
431
- f = semscan(file)
432
- w = semscan(want)
430
+ f = semscan file
431
+ w = semscan want
433
432
  a = f[0]
434
433
  b = f[2]
435
434
  c = w[0]
@@ -623,7 +622,7 @@ module Squared
623
622
  if opt =~ op.values
624
623
  case $1
625
624
  when 'w', 'workspace'
626
- op << ($2.match?(%r{[\\/]}) ? quote_option($1, basepath($2)) : shell_option($1, $2))
625
+ op << ($2.match?(%r{[\\/]}) ? quote_option($1, path + $2) : shell_option($1, $2))
627
626
  end
628
627
  elsif opt.include?('=')
629
628
  op.errors << opt
@@ -704,7 +703,7 @@ module Squared
704
703
  cmd = session dependbin, 'pack'
705
704
  if dependtype(:yarn) > 1
706
705
  op = OptionPartition.new(opts, OPT_BERRY[:pack], cmd, project: self)
707
- op << quote_option('out', Pathname.pwd.join("#{project}-#{version}.tgz")) unless op.arg?('out')
706
+ op << quote_option('out', Pathname.pwd + "#{project}-#{version}.tgz") unless op.arg?('out')
708
707
  else
709
708
  op = OptionPartition.new(opts, pnpm? ? OPT_PNPM[:pack] : OPT_NPM[:pack] + OPT_NPM[:common], cmd,
710
709
  project: self)
@@ -714,7 +713,7 @@ module Squared
714
713
 
715
714
  case $1
716
715
  when 'w', 'workspace'
717
- op << ($2.match?(%r{[\\/]}) ? quote_option($1, basepath($2)) : shell_option($1, $2))
716
+ op << ($2.match?(%r{[\\/]}) ? quote_option($1, path + $2) : shell_option($1, $2))
718
717
  op.found << opt
719
718
  end
720
719
  end
@@ -725,7 +724,7 @@ module Squared
725
724
  run(from: :pack)
726
725
  end
727
726
 
728
- def compose(target, opts = nil, script: false, args: nil, from: :run, **)
727
+ def compose(target, opts = nil, script: false, args: nil, from: nil, **)
729
728
  return unless target
730
729
 
731
730
  if script
@@ -10,13 +10,13 @@ module Squared
10
10
  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,
11
11
  build: %w[n|no-isolation s|sdist v|verbose w|wheel x|skip-dependency-check C|config-setting=q installer=b
12
12
  o|outdir=p].freeze,
13
- venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files
14
- without-pip prompt=q].freeze
13
+ venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
14
+ prompt=q].freeze
15
15
  }.freeze
16
16
  OPT_PIP = {
17
17
  common: %w[debug disable-pip-version-check isolated no-cache-dir no-color no-input no-python-version-warning
18
- q|quiet require-virtualenv v|verbose cache-dir=p cert=p client-cert=p exists-action=b log=p
19
- proxy=q python=q retries=i timeout=i trusted-host=b use-deprecated=b use-feature=b].freeze,
18
+ q|quiet require-virtualenv v|verbose cache-dir=p cert=p client-cert=p exists-action=b log=p proxy=q
19
+ python=q retries=i timeout=i trusted-host=b use-deprecated=b use-feature=b].freeze,
20
20
  install: %w[break-system-packages check-build-dependencies compile dry-run force-reinstall I|ignore-installed
21
21
  ignore-requires-python no-build-isolation no-clean no-compile no-deps no-index no-warn-conflicts
22
22
  no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=b
@@ -34,7 +34,7 @@ module Squared
34
34
  u|username=b].freeze
35
35
  }.freeze
36
36
  OPT_HATCH = {
37
- common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=e
37
+ common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
38
38
  q|quiet v|verbose].freeze,
39
39
  build: %w[clean-hooks-after ext hooks-only no-hooks c|clean t|target=b].freeze,
40
40
  publish: %w[initialize-auth n|no-prompt y|yes a|auth=q ca-cert=p client-cert=p client-key=p o|option=q
@@ -81,8 +81,8 @@ module Squared
81
81
  initialize_env(**kwargs)
82
82
  end
83
83
  @dependindex = DEP_PYTHON.index { |file| basepath(file).exist? }
84
- @dependfile = basepath(DEP_PYTHON[@dependindex || 0])
85
- @verbose = $1.size if verbose.is_a?(String) && verbose =~ /^(v+)$/
84
+ @dependfile = @path + DEP_PYTHON[@dependindex || 0]
85
+ @verbose = verbose.size if verbose.is_a?(String) && verbose.match?(/\Av+\z/)
86
86
  @editable = case editable
87
87
  when '.', Pathname
88
88
  editable
@@ -119,12 +119,12 @@ module Squared
119
119
  if flag == :create
120
120
  format_desc action, flag, 'dir,opts*'
121
121
  task flag, [:dir] do |_, args|
122
- dir = basepath(param_guard(action, flag, args: args, key: :dir))
122
+ dir = path + param_guard(action, flag, args: args, key: :dir)
123
123
  cmd, opts = python_session('-m venv', opts: args.extras)
124
124
  op = OptionPartition.new(opts, OPT_PYTHON[:venv], cmd, project: self)
125
125
  op.append(dir, delim: true)
126
126
  .clear(pass: false)
127
- v = op.arg?(/^-v+$/, 'verbose')
127
+ v = op.arg?(/\A-v+\z/, 'verbose')
128
128
  run(exception: true)
129
129
  puts(dir.directory? ? "Success: #{dir}" : 'Failed') unless v
130
130
  end
@@ -142,7 +142,8 @@ module Squared
142
142
  when :run
143
143
  format_desc action, flag, 'args+'
144
144
  task flag do |_, args|
145
- args = param_guard(action, flag, args: args.to_a)
145
+ args = args.to_a
146
+ args = readline('Enter command', force: true).split(' ', 2) if args.empty?
146
147
  venv_init
147
148
  run session(*args, path: false)
148
149
  end
@@ -170,12 +171,9 @@ module Squared
170
171
  end
171
172
  when 'install'
172
173
  format_desc(action, flag, 'opts*', before: case flag
173
- when :target
174
- 'dir'
175
- when :editable
176
- 'path/url?'
177
- when :upgrade
178
- 'strategy?,package+'
174
+ when :target then 'dir'
175
+ when :editable then 'path/url?'
176
+ when :upgrade then 'strategy?,package+'
179
177
  end)
180
178
  case flag
181
179
  when :editable
@@ -205,20 +203,16 @@ module Squared
205
203
  end
206
204
  when 'build'
207
205
  format_desc(action, flag, 'opts*', after: case flag
208
- when :python
209
- 'srcdir?'
210
- when :hatch
211
- 'location?'
206
+ when :python then 'srcdir?'
207
+ when :hatch then 'location?'
212
208
  end)
213
209
  task flag do |_, args|
214
210
  build! flag, args.to_a
215
211
  end
216
212
  when 'publish'
217
213
  format_desc(action, flag, 'opts*', after: case flag
218
- when :hatch
219
- 'artifacts?'
220
- when :twine
221
- 'dist?'
214
+ when :hatch then 'artifacts?'
215
+ when :twine then 'dist?'
222
216
  end)
223
217
  task flag do |_, args|
224
218
  publish flag, args.to_a
@@ -246,7 +240,7 @@ module Squared
246
240
  when :user
247
241
  cmd << '--user'
248
242
  when :target
249
- cmd << quote_option('target', basepath(target))
243
+ cmd << quote_option('target', path + target)
250
244
  when :force
251
245
  cmd << '--force-reinstall'
252
246
  end
@@ -264,10 +258,10 @@ module Squared
264
258
  def outdated(*, sync: invoked_sync?('outdated'))
265
259
  cmd = pip_session 'list', '--outdated'
266
260
  append_global
267
- cmd = session_done(cmd)
261
+ cmd = session_done cmd
268
262
  log.info cmd
269
263
  on :first, :outdated
270
- banner = format_banner(cmd)
264
+ banner = format_banner cmd
271
265
  print_item banner if sync
272
266
  start = 0
273
267
  found = 0
@@ -285,8 +279,8 @@ module Squared
285
279
 
286
280
  latest = lat.join
287
281
  current = cur.join
288
- semver(cur)
289
- semver(lat)
282
+ semver cur
283
+ semver lat
290
284
  if semmajor?(cur, lat)
291
285
  type = 2
292
286
  major += 1
@@ -378,7 +372,7 @@ module Squared
378
372
  if op.arg?('o', 'output')
379
373
  op.extras << srcdir
380
374
  else
381
- op << quote_option('output', basepath(srcdir))
375
+ op << quote_option('output', path + srcdir)
382
376
  end
383
377
  srcdir = nil
384
378
  end
@@ -390,7 +384,7 @@ module Squared
390
384
  end
391
385
  op << basic_option('p', project) unless ENV['HATCH_PROJECT'] || op.arg?('p', 'project')
392
386
  end
393
- op << shell_quote(basepath(srcdir)) if srcdir
387
+ op << shell_quote(path + srcdir) if srcdir
394
388
  op.clear
395
389
  run(from: :"#{flag}:build")
396
390
  end
@@ -409,7 +403,7 @@ module Squared
409
403
  end
410
404
  op = OptionPartition.new(opts, list, @session, project: self, single: singleopt(flag))
411
405
  if op.empty?
412
- dist = basepath.join('dist')
406
+ dist = path + 'dist'
413
407
  raise_error('no source files found', hint: dist) unless dist.directory? && !dist.empty?
414
408
  op.extras << "#{dist}/*" unless flag == :poetry
415
409
  end
@@ -468,7 +462,7 @@ module Squared
468
462
  def python_session(*cmd, opts: nil)
469
463
  return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
470
464
 
471
- op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /^v+$/)
465
+ op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\Av+\z/)
472
466
  ret = session('python', *op.to_a, *cmd, path: venv.nil?)
473
467
  [ret, op.extras]
474
468
  end
@@ -476,7 +470,7 @@ module Squared
476
470
  def poetry_session(*cmd)
477
471
  ret = session('poetry', *cmd, *preopts)
478
472
  if (val = option('project', ignore: false))
479
- ret << quote_option('project', basepath(val))
473
+ ret << quote_option('project', path + val)
480
474
  end
481
475
  ret
482
476
  end
@@ -513,7 +507,7 @@ module Squared
513
507
  end
514
508
  op.swap
515
509
  if edit
516
- edit = basepath(edit) unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
510
+ edit = path + edit unless %r{^[a-z]+(?:\+[a-z]+)?://}i.match?(edit)
517
511
  if flag == :editable
518
512
  op.extras << edit
519
513
  else
@@ -541,7 +535,7 @@ module Squared
541
535
  when '0', 'false'
542
536
  return
543
537
  else
544
- val = basepath(val)
538
+ val = path + val
545
539
  end
546
540
  elsif session_arg?('e', 'editable', target: target) || !(val = editable)
547
541
  return
@@ -555,22 +549,22 @@ module Squared
555
549
  when '0', 'false'
556
550
  '--no-cache-dir'
557
551
  else
558
- quote_option('cache-dir', basepath(val))
552
+ quote_option('cache-dir', path + val)
559
553
  end
560
554
  end
561
555
  target << shell_option('proxy', val) if (val = option('proxy', target: target))
562
- target << quote_option('python', basepath(val)) if (val = option('python', target: target))
556
+ target << quote_option('python', path + val) if (val = option('python', target: target))
563
557
  append_nocolor(target: target)
564
558
  end
565
559
 
566
560
  def singleopt(flag = nil)
567
561
  case flag
568
562
  when :python
569
- /^(?:v+|q+|b+)$/
563
+ /\A(?:v+|q+|b+)\z/
570
564
  when :twine
571
565
  nil
572
566
  else
573
- /^(?:v+|q+)$/
567
+ /\A(?:v+|q+)\z/
574
568
  end
575
569
  end
576
570
 
@@ -605,7 +599,7 @@ module Squared
605
599
 
606
600
  def venv_set(val)
607
601
  @venv = Pathname.new(val)
608
- @venv = basepath(@venv) unless @venv.absolute?
602
+ @venv = @path + @venv unless @venv.absolute?
609
603
  if projectpath?(@venv)
610
604
  if @venv.exist?
611
605
  log.debug "venv found: #{@venv}"