squared 0.6.9 → 0.6.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd07ce40c31b81be676defc0120ee1090e6bf020153b0234bcc9656e791279d3
4
- data.tar.gz: e4179c5daf66d93a6795a3a15be28f93936d90da081fdfde2f779d05cddbc20e
3
+ metadata.gz: e9559cf340c4a95816cc2853417bfb3c43053cf59cdd4e4b38fac0c074f41264
4
+ data.tar.gz: 60d6c5b20aa58e9606402745283948393253363ed38d5f15322be5d7cbfde7d5
5
5
  SHA512:
6
- metadata.gz: 437e260ef864d9734038ef84cf17bef22582d68f0081f4a8a7c4c16157bc32b3322673d2cb069ee84313b61243df30d65e3a3be432d613a2b977981e95b32aae
7
- data.tar.gz: 02efccc2029b33cdfa91cf0da6454f7c9116e12320c7a378d8ccdf19d16a70414f36999fbf97bfd975ca24007c932e3d62d13753c4227ca565e6c569e3a36824
6
+ metadata.gz: 0b34a0a55c607060040c027b19bc16b5ad93ba1403d753c45a75edadb3086f179b1e533b4d5058787b544012e0eda60d5e1b70ed9ff26c5fda65d55fd74b5513
7
+ data.tar.gz: 65478734cb5d093f3abb96022479ba3aec90b7b08741f0f924c348b06466dedb0a8db9d19e7d78e2d0f7cd26c874f7ff56d387323b943baa969097f2c97f37c5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.11] - 2026-03-11
4
+
5
+ ### Changed
6
+
7
+ - Git internal data calls do not write to logs.
8
+
9
+ ## [0.5.22] - 2026-03-11
10
+
11
+ - Project base run command was not covered due to lack of type checking.
12
+
13
+ ## [0.4.36] - 2026-03-11
14
+
15
+ ### Added
16
+
17
+ - Python venv initialization installs setuptools when detected.
18
+ - Node task depend adds prod option flags when NODE_ENV=production.
19
+
20
+ ### Fixed
21
+
22
+ - OptionPartition methods with escape parameter were reordered.
23
+ - OptionPartition methods with quote parameter were revised.
24
+
25
+ ## [0.6.10] - 2025-02-23
26
+
27
+ ### Added
28
+
29
+ - Docker command image action [ls|rm|tag|save] can be filtered.
30
+ - Pip command options were updated to 26.1.
31
+
32
+ ### Changed
33
+
34
+ - Ruby property autodetect was converted into an accessor.
35
+ - Python property editable was converted into an accessor.
36
+
37
+ ### Fixed
38
+
39
+ - Git task show was completely non-functional due to excessive formatting.
40
+ - Gem command install did not respond to interactive prompt.
41
+ - Docker task clean does not run in parallel without ENV override.
42
+
3
43
  ## [0.6.9] - 2025-01-07
4
44
 
5
45
  ### Added
@@ -1568,7 +1608,7 @@
1568
1608
  - Rake did not set original rakefile when calling itself.
1569
1609
  - Extended tasks were not associated to their supporting class method.
1570
1610
 
1571
- ## [0.1.0] - 2024-12-7
1611
+ ## [0.1.0] - 2024-12-07
1572
1612
 
1573
1613
  ### Added
1574
1614
 
@@ -1589,12 +1629,14 @@
1589
1629
  - Git pull did not display colors for diff bar chart.
1590
1630
  - Git commit did not fetch latest refs before submitting.
1591
1631
 
1592
- ## [0.0.12] - 2024-12-1
1632
+ ## [0.0.12] - 2024-12-01
1593
1633
 
1594
1634
  ### Added
1595
1635
 
1596
1636
  - Changelog was created.
1597
1637
 
1638
+ [0.6.11]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.11
1639
+ [0.6.10]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.10
1598
1640
  [0.6.9]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.9
1599
1641
  [0.6.8]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.8
1600
1642
  [0.6.7]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.7
@@ -1605,6 +1647,7 @@
1605
1647
  [0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
1606
1648
  [0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
1607
1649
  [0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
1650
+ [0.5.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.22
1608
1651
  [0.5.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.21
1609
1652
  [0.5.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.20
1610
1653
  [0.5.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.19
@@ -1627,6 +1670,7 @@
1627
1670
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1628
1671
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1629
1672
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1673
+ [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
1630
1674
  [0.4.35]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.35
1631
1675
  [0.4.34]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.34
1632
1676
  [0.4.33]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.33
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  | 2025-01-07 | 0.2.0 | | 3.4.0 |
12
12
  | 2025-02-07 | 0.3.0 | | 3.4.1 |
13
13
  | 2025-03-06 | 0.4.0 | | 3.4.2 |
14
- | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.3 |
14
+ | 2025-06-16 | 0.5.0 | 2.5.0 | 3.4.4 |
15
15
  | ---------- | ----- | ----- | ----- |
16
16
  | 2025-08-23 | 0.5.5 | | 3.4.5 |
17
17
  | 2025-10-31 | 0.6.0 | | 3.4.7 |
@@ -733,12 +733,13 @@ docker build --no-cache --label=v1 --build-arg="NODE_TAG=24" --build-arg="RUBY_V
733
733
  | compose | build | TARGET=s |
734
734
  | compose | run | VERSION=s |
735
735
  | container | commit | REGISTRY=s PLATFORM=s DISABLE_CONTENT_TRUST=0,1 |
736
- | container | -run -create -exec | ALL=1 |
736
+ | container | -run -create -exec | ALL=1 FILTER=s |
737
737
  | | -update -commit | |
738
738
  | image | rm | Y=1 |
739
739
  | image | push | TAG=s REGISTRY=s |
740
740
  | image | -push | ALL=1 |
741
- | network | * | ALL=1 |
741
+ | image | -push -pull | FILTER=s |
742
+ | network | * | ALL=1 FILTER=s |
742
743
 
743
744
  ### asdf
744
745
 
@@ -806,7 +807,7 @@ REPO_MANIFEST # e.g. latest,nightly,prod
806
807
  REPO_GROUPS # e.g. base,prod,docs
807
808
  REPO_STAGE # 0,1,2,3,4
808
809
  REPO_SUBMODULLES # 0,1
809
- REPO_Y # 0,1
810
+ REPO_Y # 0,1 (bypass interactive prompt)
810
811
  REPO_TIMEOUT # confirm dialog (seconds)
811
812
  ```
812
813
 
@@ -835,7 +836,7 @@ Features can be enabled through ENV when calling global tasks such as through *C
835
836
  | :------------- | :------------- | :------------------------------------------------------- |
836
837
  | depend | - | FORCE CI IGNORE_SCRIPTS |
837
838
  | outdated | - | U|UPDATE=major|minor|patch DIFF DRY_RUN |
838
- | publish | - | OTP=s TAG=s ACCESS=0,1,s DRY_RUN |
839
+ | publish | - | OTP=s TAG=s ACCESS=0,1,s DRY_RUN Y |
839
840
  | depend package | * | PACAKGE_LOCK|LOCKFILE=0 NO_LOCKFILE=1 Y |
840
841
  | npm pnpm | depend package | CPU=s OS=s LIBC=s |
841
842
  | npm | package | SAVE IGNORE_SCRIPTS STRICT_PEER_DEPS |
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.6.9'
4
+ VERSION = '0.6.11'
5
5
  end
@@ -251,7 +251,7 @@ module Squared
251
251
  print_error e
252
252
  end
253
253
  log[:progname] ||= @name
254
- env('LOG_LEVEL', ignore: false) { |val| log[:level] = val.start_with?(/\d/) ? log_sym(val.to_i) : val }
254
+ env('LOG_LEVEL', ignore: false) { |s| log[:level] = s.start_with?(/\d/) ? log_sym(s.to_i) : s }
255
255
  log.delete(:file)
256
256
  @log = [file, log]
257
257
  end
@@ -521,7 +521,7 @@ module Squared
521
521
  args[0] = instance_eval(&blk) || f
522
522
  return unless args.first
523
523
  end
524
- if args.all? { |val| val.is_a?(Array) }
524
+ if args.all?(Array)
525
525
  cmd = []
526
526
  var = {}
527
527
  args.each do |val|
@@ -841,7 +841,7 @@ module Squared
841
841
  ensure
842
842
  if dir
843
843
  remove_entry dir
844
- elsif delete && file&.exist?
844
+ elsif delete && file.exist?
845
845
  file.unlink
846
846
  end
847
847
  end
@@ -1323,17 +1323,17 @@ module Squared
1323
1323
  s += "#{indent || (last && data[final].last == context) ? ' ' : a} "
1324
1324
  k += 1
1325
1325
  end
1326
- s += "#{j ? d : c}#{b * 3} #{tag.call(proj)}"
1326
+ s + "#{j ? d : c}#{b * 3} #{tag.call(proj)}"
1327
1327
  end
1328
1328
  end
1329
1329
  if order
1330
1330
  n = order.size
1331
1331
  order[name] ||= if proj.parent
1332
- if order[s = proj.parent.name]
1333
- order[s] += 1
1332
+ if order[key = proj.parent.name]
1333
+ order[key] += 1
1334
1334
  n.pred
1335
1335
  else
1336
- order[s] = n.succ
1336
+ order[key] = n.succ
1337
1337
  n
1338
1338
  end
1339
1339
  else
@@ -1918,8 +1918,10 @@ module Squared
1918
1918
  args
1919
1919
  end
1920
1920
 
1921
- def confirm_basic(msg, target, default = 'Y', style: :inline, **kwargs)
1922
- confirm("#{msg} [#{sub_style(target.to_s, style.is_a?(Symbol) ? theme[style] : style)}]", default, **kwargs)
1921
+ def confirm_basic(msg, hint, default = 'Y', style: :inline, target: @session, prefix: nil, **kwargs)
1922
+ return true if prefix ? option('y', prefix: prefix) : target && option('y', target: target)
1923
+
1924
+ confirm("#{msg} [#{sub_style(hint.to_s, style.is_a?(Symbol) ? theme[style] : style)}]", default, **kwargs)
1923
1925
  end
1924
1926
 
1925
1927
  def confirm_outdated(pkg, ver, type, cur = nil, lock: false, col0: 0, col1: 0, col2: nil, col3: 0, col4: 0,
@@ -2258,7 +2260,7 @@ module Squared
2258
2260
  ret = []
2259
2261
  if data[:command]
2260
2262
  ret[0] = data[:command]
2261
- ret[1] = data[:opts] unless diso
2263
+ ret[1] = data[:opts] unless noopt
2262
2264
  ret[3] = data[:args]
2263
2265
  elsif data[:script]
2264
2266
  ret[1] = data[:script]
@@ -2267,7 +2269,7 @@ module Squared
2267
2269
  else
2268
2270
  ret[0] = false
2269
2271
  end
2270
- ret[2] = data[:env] unless dise
2272
+ ret[2] = data[:env] unless noenv
2271
2273
  ret
2272
2274
  end
2273
2275
  self.global = global
@@ -2275,7 +2277,7 @@ module Squared
2275
2277
  when Hash
2276
2278
  @output = parse.call(data)
2277
2279
  when Enumerable
2278
- @output = if cmd.all? { |data| data.is_a?(Hash) }
2280
+ @output = if cmd.all?(Hash)
2279
2281
  noopt = false
2280
2282
  noenv = false
2281
2283
  cmd.map { |data| parse.call(data) }
@@ -282,14 +282,18 @@ module Squared
282
282
  end
283
283
  else
284
284
  format_desc(action, flag, case flag
285
- when :rm, :save then 'id*,opts*'
286
- when :tag then 'version?'
285
+ when :rm, :save then 'id,opts*'
286
+ when :tag then 'version'
287
287
  else 'opts*,args*'
288
- end)
288
+ end, before: 'pattern?')
289
289
  task flag do |_, args|
290
290
  args = args.to_a
291
+ n = args.size
292
+ if (n > 1 || (flag == :ls && n > 0)) && OptionPartition.pattern?(args.first)
293
+ filter = args.shift
294
+ end
291
295
  if !args.empty? || flag == :ls
292
- image flag, args
296
+ image(flag, args, filter: filter)
293
297
  else
294
298
  choice_command flag
295
299
  end
@@ -315,8 +319,8 @@ module Squared
315
319
  def clean(*, sync: invoked_sync?('clean'), **)
316
320
  if runnable?(@clean)
317
321
  super
318
- else
319
- image(:rm, sync: sync)
322
+ elsif sync || option('y', prefix: 'docker')
323
+ image :rm
320
324
  end
321
325
  end
322
326
 
@@ -533,7 +537,7 @@ module Squared
533
537
  run(from: from)
534
538
  end
535
539
 
536
- def image(flag, opts = [], sync: true, id: nil, registry: nil)
540
+ def image(flag, opts = [], sync: true, id: nil, registry: nil, filter: nil)
537
541
  cmd, opts = docker_session('image', flag, opts: opts)
538
542
  op = OptionPartition.new(opts, OPT_DOCKER[:image].fetch(flag, []), cmd, project: self)
539
543
  exception = self.exception
@@ -551,7 +555,7 @@ module Squared
551
555
  opts.delete(val)
552
556
  break
553
557
  end
554
- list_image(:run, from: from) do |val|
558
+ list_image(:run, filter: filter, from: from) do |val|
555
559
  container(:run, if name
556
560
  opts.dup << "name=#{index == 0 ? name : "#{name}-#{index}"}"
557
561
  else
@@ -565,9 +569,7 @@ module Squared
565
569
  when :rm
566
570
  unless id
567
571
  if op.empty?
568
- list_image(:rm, from: from) do |val|
569
- image(:rm, opts, sync: sync, id: val)
570
- end
572
+ list_image(:rm, filter: filter, from: from) { |val| image(:rm, opts, sync: sync, id: val) }
571
573
  else
572
574
  op.each { |val| run(cmd.temp(val), sync: sync, from: from) }
573
575
  end
@@ -579,13 +581,16 @@ module Squared
579
581
  banner = false
580
582
  end
581
583
  when :tag, :save
582
- list_image(flag, from: from) do |val|
584
+ found = false
585
+ list_image(flag, filter: filter, from: from) do |val|
583
586
  op << val
587
+ found = true
584
588
  if flag == :tag
585
589
  op << tagname("#{project}:#{op.first}")
586
590
  break
587
591
  end
588
592
  end
593
+ raise_error ArgumentError, 'target not specified', hint: flag unless found
589
594
  when :push
590
595
  id ||= option('tag', ignore: false) || tagmain
591
596
  registry ||= op.shift || option('registry') || @registry
@@ -774,12 +779,20 @@ module Squared
774
779
  [cmd, status, no]
775
780
  end
776
781
 
777
- def list_image(flag, cmd = docker_output('image ls -a'), hint: nil, no: true, from: nil)
782
+ def list_image(flag, cmd = docker_output('image ls -a'), filter: nil, hint: nil, no: true, from: nil)
778
783
  pwd_set(from: from) do
779
784
  index = 1
780
785
  all = option('all', prefix: 'docker')
781
786
  y = from == :'image:rm' && option('y', prefix: 'docker')
782
- pat = /\b(?:#{dnsname(name)}|#{tagname(project)}|#{tagmain.split(':', 2).first})\b/
787
+ filter = env('DOCKER_FILTER', filter).to_s
788
+ pat = if OptionPartition.pattern?(filter)
789
+ Regexp.new(filter)
790
+ elsif filter.match?(/[:_-]$/)
791
+ /\b#{Regexp.escape(filter)}/
792
+ else
793
+ filter = filter.empty? ? '(?:[:_-]|$)' : "[:_-]#{filter}"
794
+ /\b(?:#{dnsname(name)}|#{tagname(project)}|#{tagmain.split(':', 2).first})#{filter}/
795
+ end
783
796
  IO.popen(cmd.temp('--format=json')).each do |line|
784
797
  data = JSON.parse(line)
785
798
  id = data['ID']
@@ -426,7 +426,7 @@ module Squared
426
426
  end
427
427
  if squash
428
428
  found = false
429
- git_spawn(git_output('log --format=%h'), stdout: false).each do |val|
429
+ git_spawn('log --format=%h', stdout: false).each do |val|
430
430
  if found
431
431
  squash = val.chomp
432
432
  break
@@ -1747,8 +1747,9 @@ module Squared
1747
1747
  opts << format if format
1748
1748
  end
1749
1749
  list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff] + OPT_GIT[:log][:diff_context]
1750
- op = OptionPartition.new(opts, list, cmd, project: self, pass: [:base],
1751
- no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log]))
1750
+ op = OptionPartition.new(opts, list, cmd,
1751
+ project: self,
1752
+ no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log], pass: [:base]))
1752
1753
  op.append(delim: true)
1753
1754
  source(exception: false, banner: flag != :oneline)
1754
1755
  end
@@ -1887,22 +1888,22 @@ module Squared
1887
1888
  if io && banner == false
1888
1889
  from = nil
1889
1890
  banner = nil
1891
+ args = false
1890
1892
  else
1891
- if banner
1892
- banner = nil unless banner? && !multiple
1893
- args = true
1894
- end
1895
1893
  if from == false
1896
1894
  from = nil
1897
1895
  elsif !from && cmd.respond_to?(:drop)
1898
1896
  from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) }
1899
1897
  from &&= :"git:#{from}"
1900
1898
  end
1901
- banner &&= cmd.temp { |val| val.start_with?(/--(?:work-tree|git-dir)/) } if cmd.respond_to?(:temp)
1899
+ if banner
1900
+ banner = cmd.temp { |val| val.start_with?(/--(work-tree|git-dir)/) } if cmd.respond_to?(:temp)
1901
+ args = true
1902
+ end
1902
1903
  end
1903
1904
  cmd = session_done cmd
1904
- log&.info cmd
1905
- banner = if banner
1905
+ log&.info cmd unless args == false
1906
+ banner = if banner && banner? && !multiple
1906
1907
  format_banner(banner.is_a?(String) ? banner : cmd, hint: hint, strip: true)
1907
1908
  end
1908
1909
  on :first, from
@@ -2121,9 +2122,7 @@ module Squared
2121
2122
 
2122
2123
  def append_message(val = nil, target: @session)
2123
2124
  val = messageopt if val.to_s.empty?
2124
- return unless val
2125
-
2126
- target << quote_option('message', val)
2125
+ target << quote_option('message', val) if val
2127
2126
  end
2128
2127
 
2129
2128
  def append_head(val = nil, target: @session)
@@ -5,7 +5,7 @@ module Squared
5
5
  module Project
6
6
  class Node < Git
7
7
  OPT_NPM = {
8
- common: %w[dry-run=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
8
+ common: %w[dry-run=!? force=!? loglevel=b include-workspace-root=!? workspaces=!? w|workspace=v].freeze,
9
9
  install: %w[package-lock-only=!? prefer-dedupe=!? E|save-exact=!? before=q cpu=b libc=b os=b].freeze,
10
10
  install_a: %w[audit=! bin-links=! foreground-scripts=!? fund=! ignore-scripts=!? install-links=!?
11
11
  package-lock=! strict-peer-deps=!? include=b install-strategy=b omit=b].freeze,
@@ -529,31 +529,36 @@ module Squared
529
529
  run(target.temp(*remove).sub!(/ (?:add|install) /, ' remove '), from: :remove, sync: sync)
530
530
  end
531
531
  if (yarn = dependtype(:yarn)) > 0
532
- cmd = session('yarn', flag || 'install')
533
- append_loglevel
534
- if yarn == 1
535
- cmd << '--ignore-engines' unless option('ignore-engines', equals: '0')
536
- cmd << '--ignore-scripts' if option('ignore-scripts')
537
- cmd << '--force' if option('force')
532
+ if !flag && yarn > 1 && prod?
533
+ cmd = session 'yarn', 'workspaces focus --all --production'
538
534
  else
539
- cmd << '--mode=skip-build' if option('ignore-scripts')
540
- cmd << '--check-cache' if !flag && option('force')
541
- end
542
- if nolockfile?('yarn')
543
- cmd << '--no-lockfile'
544
- elsif option('ci')
535
+ cmd = session('yarn', flag || 'install')
545
536
  if yarn == 1
546
- cmd << '--frozen-lockfile'
547
- elsif !flag
548
- cmd << '--immutable' << '--refresh-lockfile'
537
+ cmd << '--production' if prod?
538
+ cmd << '--ignore-engines' unless option('ignore-engines', equals: '0')
539
+ cmd << '--ignore-scripts' if option('ignore-scripts')
540
+ cmd << '--force' if option('force')
541
+ else
542
+ cmd << '--mode=skip-build' if option('ignore-scripts')
543
+ cmd << '--check-cache' if !flag && option('force')
544
+ end
545
+ if nolockfile?('yarn')
546
+ cmd << '--no-lockfile'
547
+ elsif option('ci')
548
+ if yarn == 1
549
+ cmd << '--frozen-lockfile'
550
+ elsif !flag
551
+ cmd << '--immutable' << '--refresh-lockfile'
552
+ end
553
+ end
554
+ if add
555
+ cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
556
+ rm.call(cmd)
557
+ om.call(cmd)
558
+ cmd << '--exact' if exact
549
559
  end
550
560
  end
551
- if add
552
- cmd << '-W' if yarn == 1 && !option('w', 'ignore-workspace-root-check', equals: '0')
553
- rm.call(cmd)
554
- om.call(cmd)
555
- cmd << '--exact' if exact
556
- end
561
+ append_loglevel
557
562
  elsif pnpm?
558
563
  cmd = session('pnpm', flag || 'install')
559
564
  append_nocolor
@@ -564,6 +569,7 @@ module Squared
564
569
  cmd << '--save-exact' if exact
565
570
  option('allow-build') { |val| cmd << quote_option('allow-build', val) }
566
571
  else
572
+ cmd << '--prod' if prod?
567
573
  append_platform
568
574
  end
569
575
  option('public-hoist-pattern') do |val|
@@ -588,6 +594,8 @@ module Squared
588
594
  if omit
589
595
  cmd << "--omit=#{save || omit}"
590
596
  save = nil
597
+ elsif !add && prod?
598
+ cmd << '--include=prod'
591
599
  end
592
600
  unless ci
593
601
  if add
@@ -1329,7 +1337,7 @@ module Squared
1329
1337
 
1330
1338
  def remove_modules(prefix = dependbin)
1331
1339
  modules = basepath 'node_modules'
1332
- return false unless modules.directory? && (option('y', prefix: prefix) || confirm_basic('Remove?', modules))
1340
+ return false unless modules.directory? && confirm_basic('Remove?', modules, prefix: prefix)
1333
1341
 
1334
1342
  modules.rmtree
1335
1343
  rescue Timeout::Error => e
@@ -29,14 +29,16 @@ module Squared
29
29
  install: %w[break-system-packages compile dry-run force-reinstall I|ignore-installed no-compile
30
30
  no-warn-conflicts no-warn-script-location U|upgrade user prefix=p report=p root=p
31
31
  root-user-action=b t|target=p upgrade-strategy=b].freeze,
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
- only-binary=q].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,
32
+ install_a: %w[ignore-requires-python no-index pre prefer-binary all-releases=b extra-index-url=q
33
+ f|find-links=q i|index-url=q no-binary=q only-binary=q only-final=b uploaded-prior-to=q].freeze,
34
+ install_b: %w[build-constraint check-build-dependencies no-build-isolation no-clean no-deps
35
+ require-hashes use-pep517 c|constraint=p group=q progress-bar=b r|requirement=p
36
+ requirements-from-script=p src=p].freeze,
36
37
  install_c: %w[C|config-settings=q e|editable=v].freeze,
37
38
  hash: %w[a|algorithm].freeze,
38
- list: %w[e|editable exclude-editable include-editable l|local no-index not-required o|outdated pre u|uptodate
39
- user exclude=b extra-index-url=q format=b f|find-links=q i|index-url=q path=p].freeze,
39
+ list: %w[e|editable exclude-editable include-editable l|local no-index not-required o|outdated pre
40
+ prefer-binary u|uptodate user all-releases=b exclude=b extra-index-url=q format=b f|find-links=q
41
+ i|index-url=q no-binary=q only-binary=q only-final=b path=p].freeze,
40
42
  lock: %w[o|output=p].freeze,
41
43
  show: %w[f|files].freeze,
42
44
  uninstall: %w[break-system-packages y|yes r|requirement=p root-user-action=b].freeze,
@@ -73,7 +75,7 @@ module Squared
73
75
  debug: %w[platform].freeze,
74
76
  install: %w[C config-settings c constraint extra-index-url no-binary only-binary platform
75
77
  r requirement].freeze,
76
- list: %w[exclude extra-index-url].freeze
78
+ list: %w[exclude extra-index-url no-binary only-binary].freeze
77
79
  }.freeze
78
80
  }.freeze
79
81
  private_constant :DEP_PYTHON, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_POETRY, :OPT_PDM, :OPT_HATCH, :OPT_TWINE,
@@ -99,7 +101,8 @@ module Squared
99
101
  end
100
102
  end
101
103
 
102
- attr_reader :venv, :editable
104
+ attr_reader :venv
105
+ attr_accessor :editable
103
106
 
104
107
  def initialize(*, editable: '.', asdf: 'python', **kwargs)
105
108
  super
@@ -249,7 +252,7 @@ module Squared
249
252
  if args.empty?
250
253
  args = readline('Enter command', force: true).split(' ', 2)
251
254
  elsif args.size == 1 && !option('interactive', equals: '0', prefix: ref)
252
- args << readline('Enter arguments', force: false)
255
+ args << readline('Enter arguments', force: false) unless args.first.include?(' ')
253
256
  end
254
257
  venv_init
255
258
  run args.join(' ')
@@ -1071,7 +1074,11 @@ module Squared
1071
1074
  .clear(pass: false)
1072
1075
  .arg?(/\A-v+\z/)
1073
1076
  ret = run(op, env, exception: true, banner: banner)
1074
- pip(:install, 'poetry', banner: false) if poetry?
1077
+ if poetry?
1078
+ pip(:install, 'poetry', banner: false)
1079
+ elsif setuptools?
1080
+ pip(:install, 'setuptools', 'wheel', banner: false)
1081
+ end
1075
1082
  success?(ret, banner, !status) { |out| puts(out && dir.directory? ? "Success: #{dir}" : 'Failed') }
1076
1083
  end
1077
1084
 
@@ -187,6 +187,7 @@ module Squared
187
187
  })
188
188
 
189
189
  attr_reader :gemdir
190
+ attr_accessor :autodetect
190
191
 
191
192
  def initialize(*, autodetect: false, gemspec: nil, steep: 'Steepfile', rubocop: '.rubocop.yml', asdf: 'ruby',
192
193
  **kwargs)
@@ -199,7 +200,7 @@ module Squared
199
200
  initialize_env(**kwargs)
200
201
  end
201
202
  dependfile_set GEMFILE
202
- @autodetect = autodetect
203
+ self.autodetect = autodetect
203
204
  @gemfile = if gemspec == false
204
205
  false
205
206
  elsif gemspec
@@ -207,7 +208,7 @@ module Squared
207
208
  end
208
209
  @steepfile = basepath! steep if steep
209
210
  @rubocopfile = Pathname.new(rubocop).realpath rescue basepath!(Dir.home, '.rubocop.yml') if rubocop
210
- return unless rakefile && @output[0].nil? && @copy.nil? && !version && !@autodetect
211
+ return unless rakefile && @output[0].nil? && @copy.nil? && !version && !self.autodetect
211
212
 
212
213
  begin
213
214
  File.foreach(rakefile) do |line|
@@ -811,7 +812,7 @@ module Squared
811
812
  `rvm current`[/^\S+/, 0]
812
813
  when 'rbenv'
813
814
  name = `rbenv version-name`
814
- name.match?(SEM_VER) ? "ruby #{name}" : name
815
+ (name =~ SEM_VER) == 0 ? "ruby #{name}" : name
815
816
  when 'chruby.sh'
816
817
  chruby = session_output 'source', val
817
818
  `#{chruby.with('ruby --version')}`
@@ -1106,6 +1107,7 @@ module Squared
1106
1107
  when :dependency, :environment, :list, :search, :specification, :which
1107
1108
  op.concat(args)
1108
1109
  end
1110
+ ia = op.remove(':')
1109
1111
  op.each do |opt|
1110
1112
  if gems && !opt.start_with?('-') && !opt.match?(GEMNAME)
1111
1113
  op.errors << opt
@@ -1169,7 +1171,7 @@ module Squared
1169
1171
  end
1170
1172
  when :install, :uninstall, :pristine
1171
1173
  if flag == :install
1172
- post = if op.remove(':')
1174
+ post = if ia
1173
1175
  op.concat(args)
1174
1176
  readline('Enter command [args]', force: true)
1175
1177
  elsif op.empty?
@@ -1187,14 +1189,14 @@ module Squared
1187
1189
  else
1188
1190
  op.clear
1189
1191
  end
1190
- elsif (n = op.index { |val| val.match?(/(\A|[a-z])@\d/) })
1192
+ elsif (n = op.index { |val| val.match?(/(\A|[\w.-])@\d/) })
1191
1193
  name = op.remove_at(n)
1192
1194
  pre, ver = if (n = name.index('@')) == 0
1193
1195
  [gemname, name[1..-1]]
1194
1196
  else
1195
1197
  [name[0, n], name[n.succ..-1]]
1196
1198
  end
1197
- op.adjoin(pre, basic_option('version', ver))
1199
+ op.adjoin(pre, quote_option('version', ver))
1198
1200
  .clear
1199
1201
  end
1200
1202
  if flag == :install
@@ -1502,7 +1504,7 @@ module Squared
1502
1504
  def copy?
1503
1505
  return true if @copy.is_a?(Hash) ? copy[:into] : super
1504
1506
  return gemdir? if gemdir
1505
- return false unless @autodetect
1507
+ return false unless autodetect
1506
1508
 
1507
1509
  set = lambda do |val, path|
1508
1510
  base = Pathname.new(path.strip)
@@ -1515,7 +1517,7 @@ module Squared
1515
1517
  end
1516
1518
  if version
1517
1519
  begin
1518
- case @autodetect
1520
+ case autodetect
1519
1521
  when 'rvm'
1520
1522
  pwd_set { `rvm info homes` }[/^\s+gem:\s+"(.+)"$/, 1]
1521
1523
  when 'rbenv'
@@ -1573,7 +1575,7 @@ module Squared
1573
1575
  log.error e
1574
1576
  self.version = nil
1575
1577
  @gemdir = nil
1576
- @autodetect = false
1578
+ self.autodetect = false
1577
1579
  else
1578
1580
  gemdir?
1579
1581
  end
@@ -1652,7 +1654,7 @@ module Squared
1652
1654
  def unpack_get(tag, ext)
1653
1655
  return super unless ext == 'gem'
1654
1656
 
1655
- "https://rubygems.org/downloads/#{File.basename(tag, '.gem')}.gem"
1657
+ "https://rubygems.org/downloads/#{tag.sub_ext('.gem')}"
1656
1658
  end
1657
1659
 
1658
1660
  def preopts
@@ -27,7 +27,7 @@ module Squared
27
27
  def multiple=(val)
28
28
  case val
29
29
  when Enumerable
30
- @multiple.concat(val.to_a.map { |val| val.is_a?(Regexp) ? val : val.to_s })
30
+ @multiple.concat(val.to_a.map { |pat| pat.is_a?(Regexp) ? pat : pat.to_s })
31
31
  when String, Symbol, Pathname
32
32
  @multiple << val.to_s
33
33
  when Regexp
@@ -48,10 +48,10 @@ module Squared
48
48
  ret.map! do |val|
49
49
  next val if opt?(val)
50
50
 
51
- if quote || val.is_a?(Pathname)
52
- shell_quote(val, force: force, double: double)
53
- elsif escape
51
+ if !(pa = val.is_a?(Pathname)) && escape
54
52
  shell_escape(val, quote: quote, double: double)
53
+ elsif quote || pa
54
+ shell_quote(val, force: force, double: double)
55
55
  else
56
56
  val
57
57
  end
@@ -336,7 +336,7 @@ module Squared
336
336
  push opt
337
337
  skip = true if args
338
338
  end
339
- skip = true if first&.any? { |s| s.is_a?(Regexp) ? opt.match?(s) : !opt.include?(s) }
339
+ skip = true if first&.any? { |pat| pat.is_a?(Regexp) ? opt.match?(pat) : !opt.include?(pat) }
340
340
  end
341
341
  end
342
342
  @values = @values.empty? ? /\A\s+\z/ : /\A(#{@values.join('|')})#{sep}(.+)\z/m
@@ -361,7 +361,8 @@ module Squared
361
361
  self
362
362
  end
363
363
 
364
- def append_any(*args, escape: false, quote: true, **kwargs)
364
+ def append_any(*args, escape: false, **kwargs)
365
+ quote = kwargs.fetch(:quote, true)
365
366
  (args.empty? ? extras : args.flatten).each do |val|
366
367
  if block_given?
367
368
  temp = val
@@ -369,7 +370,7 @@ module Squared
369
370
  if val.is_a?(Array)
370
371
  found << temp
371
372
  k, v, q = val
372
- add_option(k, v, escape: escape, quote: quote, double: q == '"', merge: q == true, **kwargs)
373
+ add_option(k, v, escape: escape, double: q == '"', merge: q == true, **kwargs)
373
374
  next
374
375
  end
375
376
  end
@@ -377,10 +378,10 @@ module Squared
377
378
 
378
379
  if exist?(val)
379
380
  add_path(val, **kwargs)
380
- elsif quote
381
- add_quote(val, **kwargs)
382
381
  elsif escape
383
382
  add shell_escape(val, **kwargs)
383
+ elsif quote
384
+ add_quote(val, **kwargs)
384
385
  else
385
386
  add val
386
387
  end
@@ -494,7 +495,7 @@ module Squared
494
495
 
495
496
  def add_path(*args, option: nil, force: true, double: false, **kwargs)
496
497
  if args.empty?
497
- args = select { |val| val.is_a?(String) }
498
+ args = grep(String)
498
499
  found.concat(args)
499
500
  args.map! { |val| path + val } if path
500
501
  append(args, force: force, **kwargs)
@@ -510,6 +511,7 @@ module Squared
510
511
  end
511
512
 
512
513
  def add_quote(*args, **kwargs)
514
+ kwargs.delete(:quote)
513
515
  merge(args.compact
514
516
  .map! { |val| val == '--' || OptionPartition.opt?(val) ? val : shell_quote(val, **kwargs) })
515
517
  self
@@ -520,8 +522,8 @@ module Squared
520
522
  self
521
523
  end
522
524
 
523
- def add_first(fallback = nil, prefix: nil, path: false, escape: false, quote: false, reverse: false,
524
- expect: false, **kwargs)
525
+ def add_first(fallback = nil, prefix: nil, path: false, escape: false, reverse: false, expect: false,
526
+ **kwargs)
525
527
  val = (reverse ? pop : shift) || fallback
526
528
  if val
527
529
  temp = val
@@ -529,10 +531,10 @@ module Squared
529
531
  unless block_given? && !(val = yield val).is_a?(String)
530
532
  if path
531
533
  add_path(val, **kwargs)
532
- elsif quote
533
- add_quote(val, **kwargs)
534
534
  elsif escape
535
535
  add shell_escape(val, **kwargs)
536
+ elsif kwargs[:quote]
537
+ add_quote(val, **kwargs)
536
538
  else
537
539
  add val
538
540
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham