squared 0.5.16 → 0.5.18

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: 0a3f9923041ce7530aea68d4f1988908a52262254841860cb48800978faf777a
4
- data.tar.gz: 331352c83df0aa4e8b6f410a094f8b9c3e78a0f1a6624c820936333055786240
3
+ metadata.gz: 7c64d1ba5b8781c76d0dbbccf6cbedf66e217043fbfd2bc33220a8c2d60baa82
4
+ data.tar.gz: 0566e40b09f80693e1abbbf7e97de7bb92e952d5d2890be37340da34e0f24be3
5
5
  SHA512:
6
- metadata.gz: 7b3c510c77ca4761e6e5cc0c27498b32df7fa9f8be94d2560934ad3f436774c0860a6de7fac24de70d4b4ee04b163b587c544261326c34deacc291e7478bdfd4
7
- data.tar.gz: 734bc751eb03ae220ec4a494e266353f3d8b30382ebc59afcc8271a613d3102b403e912884e938f861bc6b0edab366140a0040b4e44d9d1b48c403a18ea6e85f
6
+ metadata.gz: 4ff0e0a44837f6fec6016680564f784968e0627367e727dfd30d1533f951f437b57ca746cc5876aa97ae05c11bc89ca79b149783e9082e15adc7d437e95c87e1
7
+ data.tar.gz: ac233a17a56d35be1008b1e598d875fe173e85d412eafd13477536a469da1de9e06f16c245c02c5e568b8250a4a8bbf2693b9859fc3e3231ac43ff0a661371e6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.18] - 2025-11-25
4
+
5
+ ### Fixed
6
+
7
+ - See `0.5.18`.
8
+
9
+ ## [0.4.32] - 2025-11-25
10
+
11
+ ### Fixed
12
+
13
+ - Git method commit did not include --dry-run with add command.
14
+ - JoinSet method include? did not always search to start of delimiter.
15
+ - Config viewer did not check for a readable package registry document.
16
+ - Powershell executable did not check for alternate path location.
17
+
18
+ ## [0.5.17] - 2025-11-22
19
+
20
+ ### Fixed
21
+
22
+ - See `0.4.31`.
23
+
24
+ ## [0.4.31] - 2025-11-22
25
+
26
+ ### Changed
27
+
28
+ - Project base attribute project was converted into an accessor.
29
+ - Ruby command flag is given precedence to a program file.
30
+
31
+ ### Fixed
32
+
33
+ - Repo application tasks are not created on Windows.
34
+ - Repo module used conflicting REPO_URL with Repo application.
35
+ - Project task outdated did not check pass and only exclusions.
36
+ - Workspace static method resolve did nothing when given a String.
37
+ - Project base run command types did not include Struct.
38
+ - Project change directory context did not always restore when raised.
39
+ - Ruby file method attributes did not always return nil.
40
+ - JoinSet with a delimiter did not report correct size.
41
+
3
42
  ## [0.5.16] - 2025-11-14
4
43
 
5
44
  ### Fixed
@@ -1247,6 +1286,7 @@
1247
1286
 
1248
1287
  - Changelog was created.
1249
1288
 
1289
+ [0.5.17]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.17
1250
1290
  [0.5.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.16
1251
1291
  [0.5.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.15
1252
1292
  [0.5.14]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.14
@@ -1264,6 +1304,7 @@
1264
1304
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1265
1305
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1266
1306
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1307
+ [0.4.31]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.31
1267
1308
  [0.4.30]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.30
1268
1309
  [0.4.29]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.29
1269
1310
  [0.4.28]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.28
data/README.md CHANGED
@@ -23,23 +23,9 @@ The range chart indicates the latest Ruby tested against at the time of release.
23
23
  gem install squared
24
24
  ```
25
25
 
26
- ### Optional
27
-
28
- * [Repo](https://source.android.com/docs/setup/reference/repo)
29
- * https://github.com/anpham6/squared-repo
30
- * Python 3.6
31
- * Not compatible with Windows
32
-
33
- ```sh
34
- mkdir -p ~/.bin
35
- PATH="${HOME}/.bin:${PATH}"
36
- curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
37
- chmod a+rx ~/.bin/repo
38
- ```
39
-
40
26
  ## Example - Rakefile
41
27
 
42
- Projects from any accessible folder can be added relative to the parent directory (e.g. *REPO_ROOT*) or absolutely. The same Rakefile can also manage other similarly cloned `Repo` repositories remotely by setting the `REPO_ROOT` environment variable to the location. Missing projects will simply be excluded from the task runner.
28
+ Projects from any accessible folder can be added relative to the parent directory or absolutely. Missing projects will simply be excluded from the task runner.
43
29
 
44
30
  ```ruby
45
31
  require "squared"
@@ -55,14 +41,6 @@ require "squared/app" # All workspace related mod
55
41
 
56
42
  # NODE_ENV = production
57
43
 
58
- # REPO_ROOT = /workspaces |
59
- # REPO_HOME = /workspaces/squared | Dir.pwd
60
- # rake = /workspaces/squared/Rakefile | main?
61
- # OR
62
- # REPO_ROOT = /workspaces | Dir.pwd
63
- # rake = /workspaces/Rakefile |
64
- # REPO_HOME = /workspaces/squared | main: "squared"
65
-
66
44
  # pathname = /workspaces/pathname
67
45
  # optparse = /workspaces/optparse
68
46
  # log = /workspaces/logger
@@ -77,7 +55,6 @@ require "squared/app" # All workspace related mod
77
55
  Workspace::Application
78
56
  .new(Dir.pwd, main: "squared") # Dir.pwd? (main? is implicitly basename)
79
57
  .banner("group", "project", styles: ["yellow", "black"], border: "bold") # name | project | path | ref | group? | parent? | version?
80
- .repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "build:prod"], ref: :node) # Repo (optional)
81
58
  .run("rake install", ref: :ruby)
82
59
  .depend(false, group: "default")
83
60
  .clean("rake clean", group: "default")
@@ -730,7 +707,37 @@ Workspace::Application
730
707
 
731
708
  ### Repo
732
709
 
733
- These global options also can target the application main suffix `${NAME}`. (e.g. REPO_ROOT_SQUARED)
710
+ * [Repo](https://source.android.com/docs/setup/reference/repo)
711
+ * https://github.com/anpham6/squared-repo
712
+ * Python 3.6
713
+ * Not compatible with Windows
714
+
715
+ ```sh
716
+ mkdir -p ~/.bin
717
+ PATH="${HOME}/.bin:${PATH}"
718
+ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
719
+ chmod a+rx ~/.bin/repo
720
+ ```
721
+
722
+ ```ruby
723
+ # REPO_ROOT = /workspaces |
724
+ # REPO_HOME = /workspaces/squared | Dir.pwd
725
+ # rake = /workspaces/squared/Rakefile | main?
726
+ #
727
+ # OR
728
+ #
729
+ # REPO_ROOT = /workspaces | Dir.pwd
730
+ # rake = /workspaces/Rakefile |
731
+ # REPO_HOME = /workspaces/squared | main: "squared"
732
+
733
+ Workspace::Application
734
+ .new(main: "squared")
735
+ .repo("https://github.com/anpham6/squared-repo", "nightly", script: ["build:dev", "prod"], ref: :node)
736
+ .add("squared", script: ["build:stage1", "build:stage2"])
737
+ .build
738
+ ```
739
+
740
+ These global options also can target the application main suffix `${NAME}`. (e.g. *REPO_ROOT_SQUARED*)
734
741
 
735
742
  ```sh
736
743
  REPO_ROOT # parent dir
@@ -742,7 +749,7 @@ REPO_DEV # pattern,0,1
742
749
  REPO_PROD # pattern,0,1
743
750
  REPO_WARN # 0,1
744
751
  REPO_SYNC # 0,1
745
- REPO_URL # manifest repository
752
+ REPO_GIT # manifest repository
746
753
  REPO_MANIFEST # e.g. latest,nightly,prod
747
754
  REPO_GROUPS # e.g. base,prod,docs
748
755
  REPO_STAGE # 0,1,2,3,4
@@ -750,6 +757,8 @@ REPO_SUBMODULLES # 0,1
750
757
  REPO_TIMEOUT # confirm dialog (seconds)
751
758
  ```
752
759
 
760
+ Other similarly cloned `Repo` repositories can be managed remotely by setting the `REPO_ROOT` environment variable to the location.
761
+
753
762
  ## LICENSE
754
763
 
755
764
  BSD 3-Clause
@@ -67,6 +67,7 @@ module Squared
67
67
  end
68
68
  wrap = ->(s, n) { "\x1B[#{n.join(';')}m#{s}\x1B[0m" }
69
69
  code = []
70
+ args.clear if args.size == 1 && args.first.nil?
70
71
  args.concat(Array(styles)).flatten.each_with_index do |type, i|
71
72
  next unless type
72
73
 
@@ -180,19 +181,20 @@ module Squared
180
181
  args = args.map(&:to_s)
181
182
  if level.is_a?(::Numeric)
182
183
  if append && respond_to?(:log)
183
- (log rescue nil).tap do |ref|
184
- ref.add(level, message(subject, *args, hint: hint, space: ', ')) if ref.is_a?(::Logger)
185
- end
184
+ ref = log rescue nil
185
+ ref.add(level, message(subject, *args, hint: hint, space: ', ')) if ref.is_a?(::Logger)
186
186
  end
187
- return false if !pass && level < ARG[:LEVEL]
187
+ return false unless pass || level >= ARG[:LEVEL]
188
188
  end
189
- if (args.size > 1 && !hint) || hint == false
189
+ if hint.nil? ? args.size > 1 : !hint
190
190
  title = log_title(level, color: false)
191
191
  sub = [pat: /\A(#{Regexp.escape(title)})(.*)\z/m, styles: __get__(:theme)[:logger][log_sym(level)]] if color
192
192
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
193
193
  else
194
194
  msg = [log_title(level, color: color)]
195
- msg << (color ? sub_style(subject.to_s, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
195
+ if subject
196
+ msg << (color ? sub_style(subject.to_s, (@theme.is_a?(::Hash) && @theme[:subject]) || :bold) : subject)
197
+ end
196
198
  msg << args.shift if msg.size == 1
197
199
  message(msg.join(' '), *args, hint: hint)
198
200
  end
@@ -80,7 +80,11 @@ module Squared
80
80
  end
81
81
  sep = unless flag.empty?
82
82
  if flag[0] == '-'
83
- flag[1] == '-' ? '=' : ' '
83
+ if flag[1] == '-'
84
+ '='
85
+ else
86
+ merge ? '' : ' '
87
+ end
84
88
  elsif flag.size == 1
85
89
  pre = '-'
86
90
  merge ? '' : ' '
@@ -108,7 +112,8 @@ module Squared
108
112
  end
109
113
 
110
114
  def shell_bin(name, env: true)
111
- key = name.upcase
115
+ key = name.to_s.upcase
116
+ key = File.basename(key, '.*') if Rake::Win32.windows?
112
117
  shell_quote((env && ENV["PATH_#{key}"]) || PATH[key] || PATH[key.to_sym] || name,
113
118
  option: false, force: false, double: true)
114
119
  end
@@ -22,8 +22,8 @@ module Squared
22
22
  nil
23
23
  end
24
24
 
25
- def link(project, main = project.dependfile.basename, name = nil, **kwargs, &blk)
26
- return unless project.enabled?
25
+ def link(project, main = project.dependfile&.basename, name = nil, **kwargs, &blk)
26
+ return unless project.enabled? && main
27
27
 
28
28
  ret = new(main, name, project: project, **kwargs)
29
29
  ret.instance_eval(&blk) if block_given?
@@ -159,7 +159,7 @@ module Squared
159
159
  end
160
160
 
161
161
  def also(path, type = nil, name: nil, **kwargs)
162
- return self if @mime.frozen? || !(file = basepath(path)).exist?
162
+ return self unless (file = basepath(path)).exist? && !@mime.frozen?
163
163
 
164
164
  ext = mimetype file
165
165
  type ||= ext
@@ -211,7 +211,7 @@ module Squared
211
211
  file = nil
212
212
  ext[0] = mime
213
213
  elsif file
214
- keys.prepend(file)
214
+ keys.unshift(file)
215
215
  alt = basepath "#{main}.{#{ext.join(',')}}"
216
216
  file = Dir[alt].first
217
217
  else
@@ -293,7 +293,7 @@ module Squared
293
293
  if stdin?
294
294
  puts out.map!(&:last).join("\n")
295
295
  else
296
- out.map! { |item| '%-*s : %s' % [pad, item[0], item[1]] }
296
+ out.map! { |a, b| '%-*s : %s' % [pad, a, b] }
297
297
  end
298
298
  end
299
299
 
@@ -309,7 +309,7 @@ module Squared
309
309
  return unless Rake::TaskManager.record_task_metadata
310
310
 
311
311
  val = "#{ext.first}[#{target ? '' : "file?=#{File.basename(main)}.#{ext.last},"}keys+]"
312
- args = *name.split(':').append(command, val)
312
+ args = *name.split(':').push(command, val)
313
313
  if project
314
314
  project.workspace.task_desc(*args)
315
315
  else
@@ -322,7 +322,9 @@ module Squared
322
322
  end
323
323
 
324
324
  def warning?
325
- project ? project.workspace.warning : true
325
+ return true unless project
326
+
327
+ project.workspace.warning
326
328
  end
327
329
 
328
330
  def stdin?
@@ -347,7 +349,9 @@ module Squared
347
349
  end
348
350
 
349
351
  def basepath(*args)
350
- project ? project.basepath(*args) : Pathname.pwd.join(*args)
352
+ return Pathname.pwd.join(*args) unless project
353
+
354
+ project.basepath(*args)
351
355
  end
352
356
  end
353
357
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.16'
4
+ VERSION = '0.5.18'
5
5
  end
@@ -29,7 +29,7 @@ module Squared
29
29
  self.impl_project = obj
30
30
  impl_series.base_set(obj)
31
31
  else
32
- kind_project.prepend(obj)
32
+ kind_project.unshift(obj)
33
33
  obj.tasks&.each { |task| impl_series.add(task, obj) }
34
34
  end
35
35
  if (args = obj.batchargs)
@@ -497,7 +497,7 @@ module Squared
497
497
  if (base = task_base?(key))
498
498
  tasks << key if obj.has?(key, baseref)
499
499
  elsif (batch = series.batch_get(key))
500
- obj.allref.each do |ref|
500
+ obj.allref do |ref|
501
501
  next unless obj.has?(key, ref) && (data = batch[ref])
502
502
 
503
503
  data.each do |val|
@@ -516,7 +516,7 @@ module Squared
516
516
  if tasks.empty?
517
517
  return [] if (base && !obj.ref?(baseref)) || !(data = series.alias_get(key))
518
518
 
519
- obj.allref.each do |ref|
519
+ obj.allref do |ref|
520
520
  next unless obj.has?(key, ref) && (alt = data[ref])
521
521
 
522
522
  ret = task_resolve obj, alt
@@ -785,7 +785,7 @@ module Squared
785
785
  end
786
786
  end
787
787
  if step == -1
788
- level.prepend(data.action)
788
+ level.unshift(data.action)
789
789
  step = 0
790
790
  elsif step > 0
791
791
  (level[step -= 1] ||= []).concat(data.action)
@@ -80,9 +80,9 @@ module Squared
80
80
  'asdf' => %i[set exec current]
81
81
  })
82
82
 
83
- attr_reader :name, :project, :workspace, :path, :theme, :group, :parent, :dependfile,
83
+ attr_reader :name, :workspace, :path, :theme, :group, :parent, :dependfile,
84
84
  :exception, :pipe, :verbose
85
- attr_accessor :global
85
+ attr_accessor :global, :project
86
86
 
87
87
  def initialize(workspace, path, name, *, group: nil, first: {}, last: {}, error: {}, common: ARG[:COMMON],
88
88
  **kwargs)
@@ -365,7 +365,7 @@ module Squared
365
365
  when 'unpack'
366
366
  format_desc(action, flag, 'tag/url,dir,digest?,f|force?', before: flag == :ext ? 'ext' : nil)
367
367
  params = %i[tag dir digest force]
368
- params.prepend(:ext) if flag == :ext
368
+ params.unshift(:ext) if flag == :ext
369
369
  task flag, params do |_, args|
370
370
  ext = flag == :ext ? param_guard(action, flag, args: args, key: :ext) : flag.to_s
371
371
  tag = param_guard(action, flag, args: args, key: :tag)
@@ -402,7 +402,7 @@ module Squared
402
402
  @asdf[1].children
403
403
  .map(&:basename)
404
404
  .sort { |a, b| b <=> a }
405
- .append('latest', 'system'),
405
+ .push('latest', 'system'),
406
406
  force: true, accept: [['Confirm?', false, true]],
407
407
  values: ['Options'])
408
408
  OptionPartition.strip(opts)
@@ -533,7 +533,7 @@ module Squared
533
533
  flags = append_hash(flags, target: []).join(' ') if flags.is_a?(Hash)
534
534
  case opts
535
535
  when Hash
536
- cmd = Array(cmd).append(flags)
536
+ cmd = Array(cmd).push(flags)
537
537
  .concat(append_hash(opts, target: [], build: true))
538
538
  .compact
539
539
  .join(' ')
@@ -1075,8 +1075,8 @@ module Squared
1075
1075
  @log = Logger.new(enabled? ? @log.first : nil, **@log.last)
1076
1076
  end
1077
1077
 
1078
- def allref
1079
- @ref.reverse_each
1078
+ def allref(&blk)
1079
+ @ref.reverse_each(&blk)
1080
1080
  end
1081
1081
 
1082
1082
  def basepath(*args)
@@ -1090,7 +1090,7 @@ module Squared
1090
1090
  path.parent.ascend.each do |dir|
1091
1091
  target = dir.join(*args)
1092
1092
  return target if target.exist?
1093
- break if (ascend && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
1093
+ break if (ascend.is_a?(String) && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
1094
1094
  end
1095
1095
  ret
1096
1096
  end
@@ -1356,7 +1356,9 @@ module Squared
1356
1356
  end
1357
1357
 
1358
1358
  def print_error(*args, loglevel: Logger::WARN, **kwargs)
1359
- warn log_message(loglevel, *args, **kwargs) if warning?
1359
+ return unless warning?
1360
+
1361
+ warn log_message(loglevel, *args, **kwargs)
1360
1362
  end
1361
1363
 
1362
1364
  def print_item(*val, series: true)
@@ -1509,8 +1511,8 @@ module Squared
1509
1511
  "#{msg}#{!always && (!obj || obj == 0 || obj.to_s.empty?) ? '' : message(hint: message(title, obj.to_s))}"
1510
1512
  end
1511
1513
 
1512
- def append_repeat(flag, opts, target: @session)
1513
- opts.each { |val| target << shell_option(flag, val) }
1514
+ def append_repeat(flag, opts, target: @session, **kwargs)
1515
+ opts.each { |val| target << shell_option(flag, val, **kwargs) }
1514
1516
  end
1515
1517
 
1516
1518
  def append_hash(data, target: @session || [], build: false)
@@ -1536,6 +1538,8 @@ module Squared
1536
1538
  target << basic_option(key, val)
1537
1539
  when FalseClass
1538
1540
  target << shell_option(key).sub(/^--(?!no-)/, '--no-')
1541
+ when Pathname
1542
+ target << shell_option(key, val, escape: false)
1539
1543
  else
1540
1544
  target << shell_option(key, val.is_a?(String) ? val : nil)
1541
1545
  end
@@ -1594,18 +1598,18 @@ module Squared
1594
1598
  return if list.empty?
1595
1599
 
1596
1600
  kwargs[:ignore] = false if no && !kwargs.key?(:ignore)
1597
- [].tap do |ret|
1598
- list.flatten.each do |flag|
1599
- next unless (val = option(flag, target: target, **kwargs))
1601
+ ret = []
1602
+ list.flatten.each do |flag|
1603
+ next unless (val = option(flag, target: target, **kwargs))
1600
1604
 
1601
- if no && val == '0'
1602
- flag = "no-#{flag}"
1603
- val = nil
1604
- end
1605
- ret << shell_option(flag, equals ? val : nil, escape: escape, quote: quote, force: force)
1605
+ if no && val == '0'
1606
+ flag = "no-#{flag}"
1607
+ val = nil
1606
1608
  end
1607
- ret.each { |val| target << val } unless ret.empty?
1609
+ ret << shell_option(flag, equals ? val : nil, escape: escape, quote: quote, force: force)
1608
1610
  end
1611
+ ret.each { |val| target << val } unless ret.empty?
1612
+ ret
1609
1613
  end
1610
1614
 
1611
1615
  def append_nocolor(target: @session)
@@ -1653,9 +1657,9 @@ module Squared
1653
1657
  end
1654
1658
 
1655
1659
  def collect_hash(data, pass: [])
1656
- [].tap do |ret|
1657
- data.each { |key, val| ret.concat(val) unless pass.include?(key) }
1658
- end
1660
+ ret = []
1661
+ data.each { |key, val| ret.concat(val) unless pass.include?(key) }
1662
+ ret
1659
1663
  end
1660
1664
 
1661
1665
  def parse_json(val, kind: Hash, hint: nil)
@@ -1766,7 +1770,7 @@ module Squared
1766
1770
  def command(*args)
1767
1771
  return args.join(' && ') unless workspace.powershell?
1768
1772
 
1769
- "powershell.exe -Command #{shell_quote("& {#{args.join(' ; ')}}", option: false, double: true)}"
1773
+ "#{shell_bin('powershell.exe')} -Command \"& {#{args.join(' ; ')}}\""
1770
1774
  end
1771
1775
 
1772
1776
  def relativepath(*list, all: false)
@@ -1908,16 +1912,15 @@ module Squared
1908
1912
  end
1909
1913
 
1910
1914
  def pwd_set(pass: false, dryrun: false, from: nil)
1911
- pwd = Dir.pwd
1912
- return yield if (path.to_s == pwd || pass == true) && (workspace.mri? || !workspace.windows?)
1915
+ return yield if (path.to_s == Dir.pwd || pass == true) && (workspace.mri? || !workspace.windows?)
1913
1916
 
1914
- Dir.chdir path
1915
- ret = yield
1916
- Dir.chdir pwd
1917
+ pwd = Dir.pwd
1918
+ Dir.chdir(path)
1919
+ yield
1917
1920
  rescue StandardError => e
1918
1921
  on_error(e, from, dryrun: dryrun)
1919
- else
1920
- ret
1922
+ ensure
1923
+ Dir.chdir(pwd) if pwd
1921
1924
  end
1922
1925
 
1923
1926
  def run_set(cmd, val = nil, opts: nil, **)
@@ -2097,7 +2100,7 @@ module Squared
2097
2100
 
2098
2101
  def runnable?(val)
2099
2102
  case val
2100
- when String, Enumerable, Proc, Method
2103
+ when String, Enumerable, Proc, Method, Struct
2101
2104
  true
2102
2105
  else
2103
2106
  false
@@ -2159,14 +2162,9 @@ module Squared
2159
2162
  end
2160
2163
 
2161
2164
  def has_value?(data, other)
2162
- case data
2163
- when Hash
2164
- other.is_a?(Enumerable) ? other.any? { |obj| data.value?(obj) } : data.value?(other)
2165
- when Enumerable
2166
- other.is_a?(Enumerable) ? other.any? { |obj| data.include?(obj) } : data.include?(other)
2167
- else
2168
- false
2169
- end
2165
+ return false unless data.is_a?(Enumerable)
2166
+
2167
+ other.is_a?(Enumerable) ? other.any? { |obj,| data.include?(obj) } : data.include?(other)
2170
2168
  end
2171
2169
 
2172
2170
  def variables
@@ -134,7 +134,7 @@ module Squared
134
134
  File.write(@revfile, JSON.pretty_generate(@revdoc))
135
135
  rescue StandardError => e
136
136
  log&.debug e
137
- warn log_message(Logger::WARN, e, pass: true) if warning?
137
+ warn log_message(Logger::WARN, e, pass: true) if warning
138
138
  ensure
139
139
  @revlock = false
140
140
  end
@@ -1457,13 +1457,14 @@ module Squared
1457
1457
  append_pathspec op.extras
1458
1458
  end
1459
1459
  co = git_session('commit', options: false)
1460
- pu = git_output 'push', upstream && '--set-upstream'
1460
+ pu = git_output 'push'
1461
+ co << '--amend' if amend
1462
+ pu << '--set-upstream' if upstream
1461
1463
  if dryrun?
1462
- op.delete('--dry-run')
1464
+ op.adjoin('--dry-run')
1463
1465
  co << '--dry-run'
1464
1466
  pu << '--dry-run'
1465
1467
  end
1466
- co << '--amend' if amend
1467
1468
  if message
1468
1469
  append_message message
1469
1470
  elsif flag == :'amend-orig' || option('edit', equals: '0')
@@ -1471,7 +1472,6 @@ module Squared
1471
1472
  end
1472
1473
  pu << '--force-with-lease' if amend
1473
1474
  pu.merge(repotrack(origin, branch))
1474
- puts if pass
1475
1475
  adding = git_spawn 'diff --name-only --no-color'
1476
1476
  source op
1477
1477
  cached = git_spawn 'diff --cached --name-only --no-color'
@@ -1494,7 +1494,8 @@ module Squared
1494
1494
  case flag
1495
1495
  when :commit, :'no-commit'
1496
1496
  op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
1497
- op << "--#{flag}" << '--'
1497
+ op << "--#{flag}"
1498
+ op.delim
1498
1499
  if branch
1499
1500
  op << branch
1500
1501
  op.clear(pass: false)
@@ -1699,7 +1700,7 @@ module Squared
1699
1700
  cmd, opts = git_session('rev-parse', opts: opts)
1700
1701
  case flag
1701
1702
  when :commit
1702
- cmd << ((n = size.to_i) > 0 ? basic_option('short', [n, 5].max) : '--verify')
1703
+ cmd << (size.to_i.zero? ? '--verify' : basic_option('short', [size.to_i, 5].max))
1703
1704
  append_commit(ref, head: true)
1704
1705
  when :branch
1705
1706
  cmd << '--abbrev-ref'
@@ -1748,7 +1749,7 @@ module Squared
1748
1749
  case flag
1749
1750
  when :blame
1750
1751
  raise_error 'no file found' unless (n = op.index { |s| basepath(s).file? })
1751
- op << '--' << shell_quote(basepath(op.delete_at(n)))
1752
+ op.delim << shell_quote(basepath(op.delete_at(n)))
1752
1753
  op.clear
1753
1754
  when :revert
1754
1755
  if VAL_GIT[:rebase][:send].any? { |val| op.arg?(val) }
@@ -1763,12 +1764,11 @@ module Squared
1763
1764
  grep, list = op.partition { |val| OptionPartition.pattern?(val) }
1764
1765
  unless grep.empty? && !list.empty?
1765
1766
  grep.map! { |val| Regexp.new(val[1..-2]) }
1766
- files = [].tap do |out|
1767
- status_data.each do |a, b|
1768
- next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
1767
+ files = []
1768
+ status_data.each do |a, b|
1769
+ next if b.strip.empty? || (!grep.empty? && grep.none? { |pat| pat.match?(a) })
1769
1770
 
1770
- out << "#{sub_style(b, styles: color(:red))} #{a}"
1771
- end
1771
+ files << "#{sub_style(b, styles: color(:red))} #{a}"
1772
1772
  end
1773
1773
  unless files.empty?
1774
1774
  files = choice_index('Select files', files, multiple: true, force: true, trim: /^\S+\s/,
@@ -1924,7 +1924,7 @@ module Squared
1924
1924
  end
1925
1925
  args = []
1926
1926
  args << quote_option('sort', sort) if sort
1927
- args << shell_option('count', env('GIT_COUNT', ARG[:CHOICE])) if count
1927
+ args << basic_option('count', env('GIT_COUNT', ARG[:CHOICE])) if count
1928
1928
  choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
1929
1929
  end
1930
1930
 
@@ -1957,13 +1957,13 @@ module Squared
1957
1957
  end
1958
1958
 
1959
1959
  def status_data(*args)
1960
- [].tap do |ret|
1961
- git_spawn('status -z -uall', *args).split("\x0").each do |line|
1962
- next unless line =~ /^(.)(.) (.+)$/
1960
+ ret = []
1961
+ git_spawn('status -z -uall', *args).split("\x0").each do |line|
1962
+ next unless line =~ /^(.)(.) (.+)$/
1963
1963
 
1964
- ret << [$3, $2, $1]
1965
- end
1964
+ ret << [$3, $2, $1]
1966
1965
  end
1966
+ ret
1967
1967
  end
1968
1968
 
1969
1969
  def append_pull(opts, list, target: @session, flag: nil, no: nil, remote: nil, from: nil)
@@ -2038,7 +2038,9 @@ module Squared
2038
2038
 
2039
2039
  def append_message(val = nil, target: @session)
2040
2040
  val = messageopt if val.to_s.empty?
2041
- target << quote_option('message', val) if val
2041
+ return unless val
2042
+
2043
+ target << quote_option('message', val)
2042
2044
  end
2043
2045
 
2044
2046
  def append_head(val = nil, target: @session)
@@ -160,7 +160,8 @@ module Squared
160
160
  elsif exception
161
161
  indexerror n, list
162
162
  else
163
- next log.warn "run script #{n} of #{list.size} (out of range)"
163
+ log.warn "run script #{n} of #{list.size} (out of range)"
164
+ next
164
165
  end
165
166
  else
166
167
  opts << val
@@ -198,11 +199,11 @@ module Squared
198
199
  if op.empty?
199
200
  op << package
200
201
  if (args = readline('Enter arguments', force: false))
201
- op << '--' unless pnpm?
202
+ op.delim unless pnpm?
202
203
  op << args
203
204
  end
204
205
  else
205
- op << '--' unless pnpm?
206
+ op.delim unless pnpm?
206
207
  op << package << op.join(' ')
207
208
  end
208
209
  else
@@ -218,7 +219,7 @@ module Squared
218
219
  version = param_guard(action, 'version', args: args, key: :version)
219
220
  args = args.extras
220
221
  args << readline('Enter command', force: true) if args.empty?
221
- args.prepend(File.join(ENV['NVM_DIR'], 'nvm-exec'))
222
+ args.unshift(File.join(ENV['NVM_DIR'], 'nvm-exec'))
222
223
  run(args.join(' '), { 'NODE_VERSION' => version }, banner: false, from: :nvm)
223
224
  end
224
225
  when 'pack'
@@ -281,6 +282,8 @@ module Squared
281
282
 
282
283
  def copy(from: 'build', into: 'node_modules', scope: nil, also: nil, create: nil, files: nil, workspace: false,
283
284
  link: false, force: false, override: false, sync: invoked_sync?('copy'), **kwargs)
285
+ return if @copy == false
286
+
284
287
  glob = kwargs[:include]
285
288
  pass = kwargs[:exclude]
286
289
  if @copy && !override
@@ -297,8 +300,6 @@ module Squared
297
300
  create = @copy[:create] if @copy.key?(:create)
298
301
  glob = @copy[:include] if @copy.key?(:include)
299
302
  pass = @copy[:exclude] if @copy.key?(:exclude)
300
- elsif @copy == false
301
- return
302
303
  end
303
304
  items = []
304
305
  if build? && path != @workspace.home && @workspace.home?
@@ -631,6 +632,7 @@ module Squared
631
632
  else
632
633
  footer.call(0, found.size)
633
634
  end
635
+ printsucc
634
636
  commit(:add, ['package.json'], pass: true)
635
637
  end
636
638
  elsif !avail.empty?
@@ -864,7 +866,7 @@ module Squared
864
866
  end
865
867
 
866
868
  def outdated?
867
- dependfile.exist?
869
+ dependfile.exist? && !task_pass?('outdated')
868
870
  end
869
871
 
870
872
  def update?
@@ -8,7 +8,7 @@ module Squared
8
8
  DIR_PYTHON = (DEP_PYTHON + %w[README.rst]).freeze
9
9
  OPT_PYTHON = {
10
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
- build: %w[n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel C|config-setting=q installer=b
11
+ build: %w[C=bm n|no-isolation s|sdist x|skip-dependency-check v|verbose w|wheel 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
@@ -624,7 +624,7 @@ module Squared
624
624
  end
625
625
 
626
626
  def outdated?
627
- dependtype > 0
627
+ dependtype > 0 && !task_pass?('outdated')
628
628
  end
629
629
 
630
630
  private
@@ -636,7 +636,7 @@ module Squared
636
636
  def python_session(*cmd, opts: nil)
637
637
  return session('python', *preopts(quiet: false), *cmd, path: venv.nil?) unless opts
638
638
 
639
- op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: /\A(?:v+|OO)\z/)
639
+ op = OptionPartition.new(opts, OPT_PYTHON[:common], project: self, single: singleopt(:python))
640
640
  ret = session('python', *op.to_a, *cmd, path: venv.nil?)
641
641
  [ret, op.extras]
642
642
  end
@@ -733,7 +733,7 @@ module Squared
733
733
  quote_option('cache-dir', basepath(val))
734
734
  end
735
735
  end
736
- option('proxy', target: target) { |val| target << shell_option('proxy', val) }
736
+ option('proxy', target: target) { |val| target << quote_option('proxy', val) }
737
737
  option('python', target: target) { |val| target << quote_option('python', basepath(val)) }
738
738
  append_nocolor(target: target)
739
739
  end
@@ -814,7 +814,7 @@ module Squared
814
814
  def singleopt(flag = nil)
815
815
  case flag
816
816
  when :python
817
- /\A(?:v+|q+|b+)\z/
817
+ /\A(?:v+|q+|b+|V+|O+)\z/
818
818
  when :twine
819
819
  nil
820
820
  else
@@ -294,6 +294,8 @@ module Squared
294
294
  end
295
295
 
296
296
  def copy(from: gemlib, into: @gemdir, override: false, **kwargs)
297
+ return if @copy == false
298
+
297
299
  glob = kwargs[:include]
298
300
  pass = kwargs[:exclude]
299
301
  if @copy && !override
@@ -303,8 +305,6 @@ module Squared
303
305
  glob = @copy[:include] if @copy.key?(:include)
304
306
  pass = @copy[:exclude] if @copy.key?(:exclude)
305
307
  into = @copy[:into] if @copy.key?(:into)
306
- elsif @copy == false
307
- return
308
308
  end
309
309
  return unless into
310
310
 
@@ -468,13 +468,15 @@ module Squared
468
468
  case flag
469
469
  when :file, :script
470
470
  op = OptionPartition.new(opts, OPT_RUBY[:ruby], ruby_session, project: self, args: true)
471
- if file
472
- op.unshift(shell_quote(basepath(file)))
473
- elsif command
471
+ if command
474
472
  op << quote_option('e', command, option: false)
473
+ elsif file
474
+ op.unshift(basepath(file))
475
+ end
476
+ unless op.arg?('e')
477
+ op.push(args) if args
478
+ op.append(delim: true, escape: false, quote: false) unless op.empty?
475
479
  end
476
- op.push(args) if args
477
- op.append(delim: true, escape: false, quote: false) unless op.empty?
478
480
  when :version
479
481
  pwd_set do
480
482
  out = []
@@ -514,7 +516,7 @@ module Squared
514
516
  c < d ? -1 : 1
515
517
  end
516
518
  end
517
- .append('')
519
+ .push('')
518
520
  .each do |val|
519
521
  next unless val.empty? || File.exist?(val.sub('$HOME', Dir.home))
520
522
 
@@ -801,7 +803,7 @@ module Squared
801
803
  else
802
804
  [name[0, n], name[(n + 1)..-1]]
803
805
  end
804
- op.adjoin(pre, shell_option('version', ver))
806
+ op.adjoin(pre, basic_option('version', ver))
805
807
  .clear
806
808
  elsif flag == :install
807
809
  op.append_any
@@ -809,7 +811,7 @@ module Squared
809
811
  op.append
810
812
  end
811
813
  op.clear(errors: true)
812
- op << '--' << readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
814
+ op.delim << readline('Enter command [args]', force: true) if flag == :install && op.remove(':')
813
815
  else
814
816
  op.append
815
817
  end
@@ -857,7 +859,7 @@ module Squared
857
859
  r.each { |val| op << shell_option('r', val, merge: true) }
858
860
  Array(path).each { |val| op << quote_option('I', val, merge: true) }
859
861
  if args
860
- op << '--' << args
862
+ op.delim << args
861
863
  op.clear
862
864
  else
863
865
  op.append(delim: true)
@@ -866,13 +868,8 @@ module Squared
866
868
  end
867
869
 
868
870
  def gemspec
869
- return @gemspec unless @gemspec.nil?
870
-
871
- @gemspec = if gemfile
872
- Gem::Specification.load(gemfile.to_s) rescue false
873
- else
874
- false
875
- end
871
+ @gemspec = !gemfile.nil? && Gem::Specification.load(gemfile.to_s) rescue false if @gemspec.nil?
872
+ @gemspec || nil
876
873
  end
877
874
 
878
875
  def gemname
@@ -924,7 +921,7 @@ module Squared
924
921
  out = `#{gem_output(opt, 'list --local -d', gemname)}`
925
922
  if out =~ /#{Regexp.escape(gemname)} \(([^)]+)\)/
926
923
  split_escape($1)
927
- .prepend(version)
924
+ .unshift(version)
928
925
  .uniq
929
926
  .each do |val|
930
927
  next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
@@ -962,7 +959,7 @@ module Squared
962
959
  end
963
960
 
964
961
  def outdated?
965
- dependtype > 0
962
+ dependtype > 0 && !task_pass?('outdated')
966
963
  end
967
964
 
968
965
  private
@@ -1054,11 +1051,11 @@ module Squared
1054
1051
  end
1055
1052
 
1056
1053
  def rakefile
1057
- return @rakefile unless @rakefile.nil?
1058
-
1059
- @rakefile = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }.yield_self do |file|
1060
- file ? basepath(file) : false
1054
+ if @rakefile.nil?
1055
+ file = Rake::Application::DEFAULT_RAKEFILES.find { |val| basepath(val).exist? }
1056
+ @rakefile = !file.nil? && basepath(file)
1061
1057
  end
1058
+ @rakefile || nil
1062
1059
  end
1063
1060
 
1064
1061
  def rakepwd
@@ -1087,11 +1084,12 @@ module Squared
1087
1084
  end
1088
1085
 
1089
1086
  def gemfile
1090
- return @gemfile unless @gemfile.nil?
1091
-
1092
- @gemfile = [project, name].map! { |val| basepath("#{val}.gemspec") }
1093
- .concat(path.glob('*.gemspec'))
1094
- .find(&:exist?) || false
1087
+ if @gemfile.nil?
1088
+ @gemfile = [project, name].map! { |val| basepath("#{val}.gemspec") }
1089
+ .concat(path.glob('*.gemspec'))
1090
+ .find(&:exist?) || false
1091
+ end
1092
+ @gemfile || nil
1095
1093
  end
1096
1094
 
1097
1095
  def gemlib
@@ -29,15 +29,15 @@ module Squared
29
29
  pat, s = Array(strip)
30
30
  ret.map! { |val| val.is_a?(String) ? val.gsub(pat, s || '') : val }
31
31
  end
32
- if escape || quote
33
- ret.map! do |val|
34
- if opt?(val)
35
- val
36
- elsif escape
37
- shell_escape(val, quote: quote, double: double)
38
- else
39
- shell_quote(val, force: force, double: double)
40
- end
32
+ ret.map! do |val|
33
+ next val if opt?(val)
34
+
35
+ if quote || val.is_a?(Pathname)
36
+ shell_quote(val, force: force, double: double)
37
+ elsif escape
38
+ shell_escape(val, quote: quote, double: double)
39
+ else
40
+ val
41
41
  end
42
42
  end
43
43
  if target.is_a?(Set)
@@ -431,6 +431,11 @@ module Squared
431
431
  self
432
432
  end
433
433
 
434
+ def delim
435
+ add '--'
436
+ self
437
+ end
438
+
434
439
  def splice(*exclude, quote: true, delim: true, path: false, pattern: false, &blk)
435
440
  found, other = if block_given?
436
441
  partition(&blk)
@@ -553,7 +558,7 @@ module Squared
553
558
  end
554
559
 
555
560
  def last(val, pat)
556
- (@last ||= []).append([val, pat, $1]) if val =~ pat
561
+ (@last ||= []).push([val, pat, $1]) if val =~ pat
557
562
  self << val
558
563
  end
559
564
 
@@ -632,8 +637,15 @@ module Squared
632
637
  extras!(obj) || super
633
638
  end
634
639
 
635
- def add?(obj)
636
- extras!(obj) || super
640
+ def size
641
+ super + extras.size
642
+ end
643
+
644
+ def include?(obj)
645
+ return true if super
646
+ return extras.include?(obj) unless (n = extras.index(@partition))
647
+
648
+ extras[0..n].include?(obj)
637
649
  end
638
650
 
639
651
  def to_a
@@ -641,21 +653,25 @@ module Squared
641
653
  end
642
654
 
643
655
  def to_s
644
- pass.join(@delim)
656
+ to_a.join(@delim)
645
657
  end
646
658
 
647
659
  def to_enum(*args)
648
- pass.to_enum(*args)
660
+ to_a.to_enum(*args)
649
661
  end
650
662
 
651
663
  def to_json(*args)
652
- pass.to_json(*args)
664
+ to_a.to_json(*args)
653
665
  end
654
666
 
655
667
  def to_yaml(*args)
656
- pass.to_yaml(*args)
668
+ to_a.to_yaml(*args)
657
669
  end
658
670
 
671
+ alias add :<<
672
+ alias add? :<<
673
+ alias member? include?
674
+
659
675
  private
660
676
 
661
677
  def extras!(obj)
@@ -158,7 +158,7 @@ module Squared
158
158
  desc.call("init[manifest?=#{target},groups?,{0}]", target)
159
159
  task 'init' do |_, args|
160
160
  args = args.to_a
161
- u = env('REPO_URL') || manifest_url
161
+ u = env('REPO_GIT') || manifest_url
162
162
  m = args.first && !opts.include?(args.first) ? args.shift : target
163
163
  g = args.first && !opts.include?(args.first) ? args.shift : nil
164
164
  g = case (val = env('REPO_GROUPS'))
@@ -216,7 +216,7 @@ module Squared
216
216
  end
217
217
  end
218
218
 
219
- series.sync.append(
219
+ series.sync.push(
220
220
  task_join(path, 'all'),
221
221
  task_join(path, 'init'),
222
222
  task_join(path, 'sync')
@@ -251,7 +251,7 @@ module Squared
251
251
  end
252
252
 
253
253
  def repo?
254
- return false unless manifest_url
254
+ return false unless manifest_url && !windows?
255
255
 
256
256
  repo_install? || @repo_override == true
257
257
  end
@@ -5,12 +5,14 @@ module Squared
5
5
  class << self
6
6
  include Common
7
7
 
8
- def resolve(*args)
8
+ def resolve(*args, base: '..')
9
+ values = __get__(:project).values
9
10
  ret = args.map do |id|
10
11
  if id.is_a?(Symbol)
11
12
  project id
12
13
  else
13
- __get__(:project).find { |_, val| File.expand_path(val.path) == File.expand_path(id, __dir__) }
14
+ values.find { |proj| proj.name == id } || values.find { |proj| proj.project == id } ||
15
+ values.find { |proj| proj.path.to_s == File.expand_path(id, base) }
14
16
  end
15
17
  end
16
18
  ret.size == 1 ? ret.first : ret
@@ -18,7 +20,7 @@ module Squared
18
20
 
19
21
  def expect(name)
20
22
  ret = project name
21
- return ret if ret&.path&.directory?
23
+ return ret if ret&.path&.directory? && !ret.path.empty?
22
24
 
23
25
  raise NoMethodError, "project is not initialized (#{name})"
24
26
  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.5.16
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.7.2
127
+ rubygems_version: 3.6.9
128
128
  specification_version: 4
129
129
  summary: Rake task generator for managing multi-language workspaces.
130
130
  test_files: []