squared 0.6.0 → 0.6.2

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.
@@ -31,7 +31,7 @@ module Squared
31
31
  return self
32
32
  end
33
33
  if base
34
- base = base.match?(GIT_PROTO) ? "#{base.chomp('/')}/" : @root + base
34
+ base = base.match?(GIT_PROTO) ? "#{base.chomp('/')}/" : rootpath(base)
35
35
  repo.each do |target|
36
36
  if target.is_a?(Project::Git)
37
37
  data[target.localname] = target.project
@@ -50,7 +50,7 @@ module Squared
50
50
  end
51
51
  unless uri.match?(GIT_PROTO) || Pathname.new(uri).absolute?
52
52
  if uri.start_with?('.')
53
- uri = @root + uri
53
+ uri = rootpath uri
54
54
  elsif base
55
55
  uri = base + uri
56
56
  else
@@ -154,9 +154,9 @@ module Squared
154
154
  namespace=p].freeze,
155
155
  add: %w[A e|edit f|force ignore-errors ignore-missing i|interactive n|dry-run p|patch pathspec-file-nul
156
156
  refresh renormalize sparse u|update v|verbose chmod=b pathspec-from-file=p].freeze,
157
- branch: %w[a|all create-reflog i|ignore-case omit-empty q|quiet r|remotes v|verbose abbrev=i color=b column=b
158
- contains=b format=q merged=b no-contains=b no-merged=b points-at=b u|set-upstream-to=b sort=q
159
- t|track=b].freeze,
157
+ branch: %w[a|all create-reflog i|ignore-case omit-empty q|quiet r|remotes v|verbose=+ abbrev=i color=b
158
+ column=b contains=b format=q merged=b no-contains=b no-merged=b points-at=b u|set-upstream-to=b
159
+ sort=q t|track=b].freeze,
160
160
  checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
161
161
  pathspec-file-nul q|quiet ours theirs conflict=b orphan=b pathspec-from-file=p t|track=b].freeze,
162
162
  diff: {
@@ -183,9 +183,9 @@ module Squared
183
183
  A|after-context=i B|before-context=i color=b C|context=i m|max-count=n max-depth=i
184
184
  open-files-in-pager=b threads=n].freeze,
185
185
  mv: %w[k f|force n|dry-run v|verbose].freeze,
186
- revert: %w[e S=bm? abort continue n|no-commit quit reference skip cleanup=b gpg-sign=b? m|mainline=i
187
- s|signoff strategy=b X|strategy-option=b].freeze,
188
- rm: %w[r cached f|force n|dry-run ignore-unmatch pathspec-file-nul q|quiet sparse v|verbose
186
+ revert: %w[e S=bm? n|no-commit reference cleanup=b gpg-sign=b? m|mainline=i s|signoff strategy=b
187
+ X|strategy-option=b].freeze,
188
+ rm: %w[r cached f|force n|dry-run ignore-unmatch pathspec-file-nul q|quiet sparse
189
189
  pathspec-from-file=p].freeze
190
190
  }.freeze,
191
191
  log: {
@@ -245,7 +245,7 @@ module Squared
245
245
  pop: %w[index].freeze,
246
246
  apply: %w[index].freeze
247
247
  }.freeze,
248
- status: %w[z u=bm? b|branch long s|short show-stash v|verbose column=b find-renames=i? ignore-submodules=b?
248
+ status: %w[z u=bm? b|branch long s|short show-stash v|verbose=+ column=b find-renames=i? ignore-submodules=b?
249
249
  ignored=b? porcelain=b? untracked-files=b?].freeze,
250
250
  submodule: {
251
251
  status: %w[cached recursive].freeze,
@@ -296,7 +296,8 @@ module Squared
296
296
  send: %w[continue skip abort quit].freeze,
297
297
  value: %w[true false merges interactive].freeze
298
298
  }.freeze,
299
- reset: %w[soft mixed hard merge keep recurse-submodules no-recurse-submodules].freeze
299
+ reset: %w[soft mixed hard merge keep recurse-submodules no-recurse-submodules].freeze,
300
+ revbuild: %w[untracked-files ignore-submodules ignored].freeze
300
301
  }.freeze
301
302
  private_constant :OPT_GIT, :VAL_GIT
302
303
 
@@ -462,15 +463,18 @@ module Squared
462
463
  when :add, :sign
463
464
  format_desc action, flag, 'name,message?,commit?,remote?'
464
465
  task flag, [:name, :message, :commit, :remote] do |_, args|
465
- if (name = args.name)
466
- message = args.message
467
- commit = commithead args.commit
468
- remote = args.remote
469
- else
470
- commit, name, message = choice_commit(reflog: false, series: true,
471
- values: [['Enter tag name', true], 'Enter message'])
472
- remote = choice_remote
473
- end
466
+ remote = if (name = args.name)
467
+ message = args.message
468
+ commit = commithead args.commit
469
+ args.remote
470
+ else
471
+ commit, name, message = choice_commit(reflog: false, series: true,
472
+ values: [
473
+ ['Enter tag name', true],
474
+ 'Enter message'
475
+ ])
476
+ choice_remote
477
+ end
474
478
  tag(flag, refs: [name], message: message, commit: commit, remote: remote).tap do |ret|
475
479
  success?(ret, !remote)
476
480
  end
@@ -996,7 +1000,7 @@ module Squared
996
1000
  end
997
1001
  end
998
1002
  append_pull(opts, OPT_GIT[:pull] + OPT_GIT[:fetch][:pull],
999
- no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull], remote: remote, flag: flag, from: :pull)
1003
+ flag: flag, from: :pull, remote: remote, no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull])
1000
1004
  source(sync: sync, sub: if stdout?
1001
1005
  [
1002
1006
  opt_style(color(:red), /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, 4),
@@ -1044,8 +1048,8 @@ module Squared
1044
1048
  def fetch(flag = nil, opts = [], sync: invoked_sync?('fetch', flag), remote: nil)
1045
1049
  opts = git_session('fetch', opts: opts).last
1046
1050
  opts << 'all' if flag == :all || option('all')
1047
- append_pull(opts, collect_hash(OPT_GIT[:fetch]), no: collect_hash(OPT_GIT[:no][:fetch]),
1048
- remote: remote, flag: flag, from: :fetch)
1051
+ append_pull(opts, collect_hash(OPT_GIT[:fetch]), flag: flag, from: :fetch, remote: remote,
1052
+ no: collect_hash(OPT_GIT[:no][:fetch]))
1049
1053
  source(sync: sync, **threadargs)
1050
1054
  end
1051
1055
 
@@ -1148,7 +1152,7 @@ module Squared
1148
1152
  append_option(OptionPartition.select(OPT_GIT[:stash][:push], no: false), no: true, ignore: false)
1149
1153
  append_message
1150
1154
  end
1151
- source(banner: !quiet?, sync: sync, **threadargs)
1155
+ source(sync: sync, banner: !quiet?, **threadargs)
1152
1156
  end
1153
1157
 
1154
1158
  def status(flag = nil, opts = [])
@@ -1214,22 +1218,22 @@ module Squared
1214
1218
  kwargs = kwargs.key?(:include) || kwargs.key?(:exclude) ? statusargs.call : @revbuild || {}
1215
1219
  case flag
1216
1220
  when :build
1217
- op = OptionPartition.new(opts, %w[ignore-submodules=b? ignored=b? untracked-files=b?], project: self)
1221
+ op = OptionPartition.new(opts, VAL_GIT[:revbuild].map { |key| "#{key}=b?" }, project: self)
1218
1222
  op.clear(append: true)
1219
1223
  args = op.to_a
1220
1224
  else
1221
- args = [
1222
- option('untracked-files', prefix: 'git') { |val| basic_option('untracked-files', val) },
1223
- option('ignore-submodules', prefix: 'git') { |val| basic_option('ignore-submodules', val) },
1224
- option('ignored', prefix: 'git') { |val| basic_option('ignored', val) }
1225
- ].compact
1225
+ args = parse_env('GIT_OPTIONS')
1226
+ .grep(/\A--#{Regexp.union(*VAL_GIT[:revbuild])}/)
1227
+ .concat(VAL_GIT[:revbuild].map { |key| option(key, prefix: 'git') { |val| basic_option(key, val) } })
1228
+ .compact
1229
+ OptionPartition.uniq!(args)
1226
1230
  end
1227
1231
  if (cur = workspace.rev_entry(name)) && cur['revision'] == sha && !env('REVBUILD_FORCE')
1228
1232
  files = status_digest(*args, **kwargs)
1229
1233
  if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
1230
1234
  workspace.rev_timeutc(name, 'build') unless (since = workspace.rev_timesince(name, 'build'))
1231
1235
  if stdout?
1232
- puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: since && "#{since} ago")
1236
+ puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: ("#{since} ago" if since))
1233
1237
  end
1234
1238
  return
1235
1239
  end
@@ -1427,7 +1431,7 @@ module Squared
1427
1431
  return ret
1428
1432
  end
1429
1433
  message ||= messageopt
1430
- if !message && !amend
1434
+ unless message || amend
1431
1435
  return if pass
1432
1436
 
1433
1437
  message = readline('Enter message', force: true)
@@ -1638,10 +1642,10 @@ module Squared
1638
1642
  case flag
1639
1643
  when :create
1640
1644
  cmd << quote_option(branch.delete_prefix!('^') ? 'C' : 'c', branch)
1641
- cmd << case (track ||= option('track', ignore: false))
1642
- when 'n', 'N', '0', 'false'
1645
+ cmd << case (track ||= option('track', ignore: false))&.downcase
1646
+ when 'n', '0', 'false'
1643
1647
  '--no-track'
1644
- when 'y', 'Y', '1', 'true'
1648
+ when 'y', '1', 'true'
1645
1649
  '--track'
1646
1650
  when 'direct', 'inherit'
1647
1651
  basic_option 'track', track
@@ -1751,7 +1755,12 @@ module Squared
1751
1755
  def git(flag, opts = [])
1752
1756
  cmd, opts = git_session(flag, opts: opts)
1753
1757
  list = OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, [])
1754
- list.concat(OPT_GIT[:log][:diff_context]) if flag == :add
1758
+ case flag
1759
+ when :add
1760
+ list.concat(OPT_GIT[:log][:diff_context])
1761
+ when :revert
1762
+ list.concat(VAL_GIT[:rebase][:send])
1763
+ end
1755
1764
  op = OptionPartition.new(opts, list, cmd, project: self, no: OPT_GIT[:no][flag], single: /\A\d+\z/,
1756
1765
  first: case flag
1757
1766
  when :blame, :revert then nil
@@ -1763,7 +1772,7 @@ module Squared
1763
1772
  op.append(basepath(op.remove_at(n)), delim: true)
1764
1773
  .clear
1765
1774
  when :revert
1766
- if VAL_GIT[:rebase][:send].any? { |val| op.arg?(val) }
1775
+ if op.arg?(*VAL_GIT[:rebase][:send])
1767
1776
  op.clear
1768
1777
  elsif op.empty?
1769
1778
  raise_error 'no commit target'
@@ -1844,9 +1853,10 @@ module Squared
1844
1853
  end
1845
1854
  if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
1846
1855
  from = :"git:#{from}"
1856
+ elsif from == false
1857
+ from = nil
1847
1858
  end
1848
1859
  banner &&= cmd.temp { |val| val.start_with?(/--(?:work-tree|git-dir)/) } if cmd.respond_to?(:temp)
1849
- from = nil if from == false
1850
1860
  end
1851
1861
  cmd = session_done cmd
1852
1862
  log&.info cmd
@@ -1969,7 +1979,7 @@ module Squared
1969
1979
  ret = {}
1970
1980
  status_data(*args).each do |file,|
1971
1981
  next if !glob.empty? && glob.none? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
1972
- next if !pass.empty? && pass.any? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
1982
+ next if pass.any? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
1973
1983
 
1974
1984
  ret[file] = algorithm.hexdigest(File.read(basepath(file)))
1975
1985
  end
@@ -1986,7 +1996,7 @@ module Squared
1986
1996
  end
1987
1997
  end
1988
1998
 
1989
- def append_pull(opts, list, target: @session, flag: nil, no: nil, remote: nil, from: nil)
1999
+ def append_pull(opts, list, flag:, from:, target: @session, no: nil, remote: nil)
1990
2000
  target << '--force' if option('f', 'force', target: target)
1991
2001
  append_submodules(target: target, from: from)
1992
2002
  return if !remote && opts.empty?
@@ -302,22 +302,21 @@ module Squared
302
302
  end
303
303
  end
304
304
  when 'publish'
305
- format_desc(action, flag, 'otp?,d/ry-run?,p/ublic|r/estricted?',
306
- before: ('tag' if flag == :tag))
305
+ format_desc(action, flag, 'otp?,p/ublic|r/estricted?,d/ry-run?', before: ('tag' if flag == :tag))
307
306
  task flag do |_, args|
308
307
  args = args.to_a
309
- dryrun = true if args.delete('dry-run') || args.delete('d')
310
- access = if args.delete('public') || args.delete('p')
311
- 'public'
312
- elsif args.delete('restricted') || args.delete('r')
308
+ access = if has_value!(args, 'r', 'restricted')
313
309
  'restricted'
310
+ elsif has_value!(args, 'p', 'public')
311
+ 'public'
314
312
  end
313
+ dryrun = has_value!(args, 'd', 'dry-run')
315
314
  if flag == :latest
316
315
  otp = args.first
317
316
  else
318
317
  tag, otp = param_guard(action, flag, args: args)
319
318
  end
320
- publish(flag, otp: otp, tag: tag, dryrun: dryrun, access: access)
319
+ publish(flag, otp: otp, tag: tag, access: access, dryrun: dryrun)
321
320
  end
322
321
  when 'tsc'
323
322
  break unless @tsfile
@@ -325,15 +324,11 @@ module Squared
325
324
  format_desc(action, flag, 'opts*', "#{flag == :project ? 'before' : 'after'}": 'config?')
326
325
  task flag do |_, args|
327
326
  args = args.to_a
328
- if flag == :project
329
- project = if !args.empty? && exist?(args.first)
330
- args.shift
331
- else
332
- @tsfile
333
- end
334
- end
335
- watch = !(args.delete('watch') || args.delete('w')).nil?
336
- tsc(*args, banner: true, project: project, build: flag == :build, watch: watch)
327
+ tsc(*args, banner: true, "#{flag}": if flag == :build
328
+ true
329
+ else
330
+ exist?(args.first) ? args.shift : @tsfile
331
+ end, watch: has_value!(args, 'w', 'watch'))
337
332
  end
338
333
  end
339
334
  end
@@ -345,6 +340,8 @@ module Squared
345
340
 
346
341
  def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, files: nil, workspace: false,
347
342
  link: false, force: false, override: false, sync: invoked_sync?('copy'), **kwargs)
343
+ return if @copy == false
344
+
348
345
  glob = kwargs[:include]
349
346
  pass = kwargs[:exclude]
350
347
  if @copy && !override
@@ -361,8 +358,6 @@ module Squared
361
358
  create = @copy[:create] if @copy.key?(:create)
362
359
  glob = @copy[:include] if @copy.key?(:include)
363
360
  pass = @copy[:exclude] if @copy.key?(:exclude)
364
- elsif @copy == false
365
- return
366
361
  end
367
362
  items = []
368
363
  if build? && path != @workspace.home && @workspace.home?
@@ -381,7 +376,7 @@ module Squared
381
376
  dest = dir
382
377
  @workspace.rev_clear(dest, sync: sync)
383
378
  when String
384
- dest = @workspace.root + dir
379
+ dest = @workspace.rootpath(dir)
385
380
  @workspace.rev_clear(dest, sync: sync)
386
381
  when Symbol
387
382
  dest = if (proj = @workspace.find(name: dir))
@@ -918,12 +913,9 @@ module Squared
918
913
  end
919
914
 
920
915
  def bump(flag, val = nil)
921
- if flag != :version
922
- val = sembump version, flag
923
- return if val == version
924
- elsif !val
925
- return
926
- end
916
+ val = sembump version, flag unless flag == :version
917
+ return unless val
918
+
927
919
  doc = dependfile.read
928
920
  if doc.sub!(/"version"\s*:\s*"#{version}"/, "\"version\": \"#{val}\"")
929
921
  unless dryrun?
@@ -7,16 +7,16 @@ module Squared
7
7
  DEP_PYTHON = %w[poetry.lock setup.cfg pyproject.toml setup.py requirements.txt].freeze
8
8
  DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
9
9
  OPT_PYTHON = {
10
- common: %w[b B d E h i I O P q s S u v x c=q m=b W=b X=q check-hash-based-pycs=b].freeze,
10
+ common: %w[b=+ B d E h i I O 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 x|skip-dependency-check v|verbose w|wheel C|config-setting=q installer=b
12
12
  o|outdir=p].freeze,
13
13
  venv: %w[clear copies symlinks system-site-packages upgrade upgrade-deps without-scm-ignore-files without-pip
14
14
  prompt=q].freeze
15
15
  }.freeze
16
16
  OPT_PIP = {
17
- common: %w[debug disable-pip-version-check isolated no-cache-dir no-color no-input q|quiet require-virtualenv
18
- v|verbose cache-dir=p cert=p client-cert=p exists-action=b keyring-provider=b log=p proxy=q
19
- python=q resume-retries=i retries=i timeout=i trusted-host=b use-deprecated=b
17
+ common: %w[debug disable-pip-version-check isolated no-cache-dir no-color no-input require-virtualenv
18
+ q|quiet=+ v|verbose=+ cache-dir=p cert=p client-cert=p exists-action=b keyring-provider=b log=p
19
+ proxy=q python=q resume-retries=i retries=i timeout=i trusted-host=b use-deprecated=b
20
20
  use-feature=b].freeze,
21
21
  cache: %w[format=b].freeze,
22
22
  completion: %w[b|bash f|fish p|powershell z|zsh].freeze,
@@ -31,8 +31,8 @@ module Squared
31
31
  root-user-action=b t|target=p upgrade-strategy=b].freeze,
32
32
  install_a: %w[ignore-requires-python no-index pre extra-index-url=q f|find-links=q i|index-url=q no-binary=q
33
33
  only-binary=q].freeze,
34
- install_b: %w[check-build-dependencies no-build-isolation no-clean no-deps prefer-binary require-hashes
35
- use-pep517 c|constraint=p group=q progress-bar=b r|requirement=p src=p].freeze,
34
+ install_b: %w[build-constraint check-build-dependencies no-build-isolation no-clean no-deps prefer-binary
35
+ require-hashes use-pep517 c|constraint=p group=q progress-bar=b r|requirement=p src=p].freeze,
36
36
  install_c: %w[C|config-settings=q e|editable=v].freeze,
37
37
  hash: %w[a|algorithm].freeze,
38
38
  list: %w[e|editable exclude-editable include-editable l|local no-index not-required o|outdated pre u|uptodate
@@ -43,21 +43,21 @@ module Squared
43
43
  wheel: %w[no-verify w|wheel-dir=p].freeze
44
44
  }.freeze
45
45
  OPT_POETRY = {
46
- common: %w[ansi no-ansi no-cache n|no-interaction no-plugins q|quiet v|verbose P|project=p].freeze,
46
+ common: %w[ansi no-ansi no-cache n|no-interaction no-plugins q|quiet=+ v|verbose=+ P|project=p].freeze,
47
47
  build: %w[clean config-settings=qq f|format=b o|output=p].freeze,
48
48
  publish: %w[build dry-run skip-existing cert=p client-cert=p dist-dir=p p|password=b r|repository=q
49
49
  u|username=b].freeze
50
50
  }.freeze
51
51
  OPT_PDM = {
52
52
  common: %w[I|ignore-python no-cache n|non-interactive].freeze,
53
- build: %w[C=bm no-clean no-isolation no-sdist no-wheel quiet verbose config-setting=q d|dest=p p|project=p
54
- k|skip=b].freeze,
55
- publish: %w[no-build no-very-ssl quiet S|sign skip-existing verbose ca-certs=p c|comment=q d|dest=p
53
+ build: %w[C=bm no-clean no-isolation no-sdist no-wheel q|quiet v|verbose=+ config-setting=q d|dest=p
54
+ p|project=p k|skip=b].freeze,
55
+ publish: %w[no-build no-very-ssl q|quiet S|sign skip-existing v|verbose=+ ca-certs=p c|comment=q d|dest=p
56
56
  i|identity=b P|password=q p|project=p r|repository=q k|skip=b u|username=b].freeze
57
57
  }.freeze
58
58
  OPT_HATCH = {
59
59
  common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=b
60
- q|quiet v|verbose].freeze,
60
+ q|quiet=+ v|verbose=+].freeze,
61
61
  build: %w[clean-hooks-after ext hooks-only no-hooks c|clean t|target=b].freeze,
62
62
  publish: %w[initialize-auth n|no-prompt y|yes a|auth=q ca-cert=p client-cert=p client-key=p o|option=q
63
63
  p|publisher=b r|repo=q u|user=q].freeze
@@ -923,6 +923,8 @@ module Squared
923
923
  case flag
924
924
  when :python
925
925
  /\A(?:v+|q+|b+)\z/
926
+ when :pdm
927
+ /\Av+\z/
926
928
  when :twine
927
929
  nil
928
930
  else