squared 0.4.14 → 0.4.15

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: fafee0b2a60973f9363c71173b9de4ed4779090e2ef3c2331d3ecd9f3a2a9398
4
- data.tar.gz: 8eb5bfef9ec19b7985866ffd1f0b55a849ff7d27a895b76d29a1cd85553e717a
3
+ metadata.gz: 0cf3c1ed045970581434b5e6571a75ccb21a8ea564d83b1f85c6deca107424d5
4
+ data.tar.gz: 2300104c9cf7fcd5babbe2989c9a68af8f8b024546baf3969198df1973ab98fe
5
5
  SHA512:
6
- metadata.gz: 464952bd65f6c404a89ef8624549e04a7a4ec0cc2c0b211e73d0464cf1bcd8094f760449ab7e0e944fd390cf01029f14ef2b6a082ae67d1ad071d243821ee527
7
- data.tar.gz: d36b6c580ccabb5bde29585cdb4642c7a81dadfff59b5766fa76efece506983ed0335551fdd31a41eced8c6631967573a6ad4a19f22b912e61a93f6f10e334ec
6
+ metadata.gz: 5983d6fa81ba44335c2af020292f6260a02ffd4c6a8c9c9213b68d50606a14aa33fd4df032a5abfcc0677d44f5e30e69d726b3c5dcc2ac0dfbb378bdd9fa0618
7
+ data.tar.gz: dcd11eb155202c2dbbcb1d7a533516c4c0d16381caccb49a0b67612e915297242b7caa74d684afcb9db08530d68a1f0a693512189f8e6b7d9fe6579f2c5e444a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.15] - 2025-07-16
4
+
5
+ ### Added
6
+
7
+ - Python command outdated option user was implemented.
8
+ - Git command commit action amend and amend-orig are interactive.
9
+
10
+ ### Changed
11
+
12
+ - Ruby task copy does not guess Gem directory when version is used.
13
+ - Workspace hash-based data uses global method for key creation.
14
+
15
+ ## [0.3.13] - 2025-07-16
16
+
17
+ ### Fixed
18
+
19
+ - See `0.2.13`.
20
+
21
+ ## [0.2.13] - 2025-07-16
22
+
23
+ ### Fixed
24
+
25
+ - Project graph did not ignore circular references.
26
+
27
+ ## [0.1.10] - 2025-07-16
28
+
29
+ ### Fixed
30
+
31
+ - Module namespaces were not combined in the right order.
32
+ - Workspace group tasks were not registered.
33
+
3
34
  ## [0.4.14] - 2025-07-05
4
35
 
5
36
  ### Added
@@ -802,6 +833,7 @@
802
833
 
803
834
  - Changelog was created.
804
835
 
836
+ [0.4.15]: https://github.com/anpham6/squared/releases/tag/v0.4.15-ruby
805
837
  [0.4.14]: https://github.com/anpham6/squared/releases/tag/v0.4.14-ruby
806
838
  [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
807
839
  [0.4.12]: https://github.com/anpham6/squared/releases/tag/v0.4.12-ruby
@@ -817,6 +849,7 @@
817
849
  [0.4.2]: https://github.com/anpham6/squared/releases/tag/v0.4.2-ruby
818
850
  [0.4.1]: https://github.com/anpham6/squared/releases/tag/v0.4.1-ruby
819
851
  [0.4.0]: https://github.com/anpham6/squared/releases/tag/v0.4.0-ruby
852
+ [0.3.13]: https://github.com/anpham6/squared/releases/tag/v0.3.13-ruby
820
853
  [0.3.12]: https://github.com/anpham6/squared/releases/tag/v0.3.12-ruby
821
854
  [0.3.11]: https://github.com/anpham6/squared/releases/tag/v0.3.11-ruby
822
855
  [0.3.10]: https://github.com/anpham6/squared/releases/tag/v0.3.10-ruby
@@ -830,6 +863,7 @@
830
863
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
831
864
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
832
865
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
866
+ [0.2.13]: https://github.com/anpham6/squared/releases/tag/v0.2.13-ruby
833
867
  [0.2.12]: https://github.com/anpham6/squared/releases/tag/v0.2.12-ruby
834
868
  [0.2.11]: https://github.com/anpham6/squared/releases/tag/v0.2.11-ruby
835
869
  [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
@@ -843,6 +877,7 @@
843
877
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
844
878
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
845
879
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
880
+ [0.1.10]: https://github.com/anpham6/squared/releases/tag/v0.1.10-ruby
846
881
  [0.1.9]: https://github.com/anpham6/squared/releases/tag/v0.1.9-ruby
847
882
  [0.1.8]: https://github.com/anpham6/squared/releases/tag/v0.1.8-ruby
848
883
  [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.14'
4
+ VERSION = '0.4.15'
5
5
  end
@@ -92,7 +92,7 @@ module Squared
92
92
  @prefix = prefix
93
93
  @series = Application.series_wrap(self)
94
94
  @project = {}
95
- @kind = {}
95
+ @kind = Workspace.hashlist
96
96
  @extensions = []
97
97
  @envname = env_key(@main).freeze
98
98
  @pipe = env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
@@ -106,20 +106,20 @@ module Squared
106
106
  else
107
107
  @theme = {}
108
108
  end
109
- @chain = {}
109
+ @chain = Workspace.hashlist
110
110
  @script = {
111
- group: {},
112
- ref: {},
111
+ group: Workspace.hashobj,
112
+ ref: Workspace.hashobj,
113
113
  group!: {},
114
114
  ref!: {}
115
115
  }.freeze
116
116
  @events = {
117
- group: {},
118
- ref: {}
117
+ group: Workspace.hashobj,
118
+ ref: Workspace.hashobj
119
119
  }.freeze
120
120
  @pass = {
121
- group: {},
122
- ref: {},
121
+ group: Workspace.hashobj,
122
+ ref: Workspace.hashobj,
123
123
  global: {},
124
124
  pattern: []
125
125
  }.freeze
@@ -225,7 +225,7 @@ module Squared
225
225
  end
226
226
  end
227
227
  data = Struct::ChainData.new(action, step, ns.call(with), ns.call(before), ns.call(after), sync)
228
- (@chain[task_name(task.to_s)] ||= []) << data
228
+ @chain[task_name(task.to_s)] << data
229
229
  self
230
230
  end
231
231
 
@@ -267,9 +267,9 @@ module Squared
267
267
 
268
268
  def pass(name, group: @group, ref: @ref, &blk)
269
269
  data = if group
270
- @pass[:group][group] ||= {}
270
+ @pass[:group][group]
271
271
  elsif ref
272
- @pass[:ref][ref] ||= {}
272
+ @pass[:ref][ref]
273
273
  else
274
274
  @pass[:global]
275
275
  end
@@ -826,8 +826,8 @@ module Squared
826
826
  items = as_a(ref, :to_sym)
827
827
  end
828
828
  items.each do |name|
829
- (@script[label][name] ||= {})[task] = val
830
- (@events[label][name] ||= {})[task] = on if on.is_a?(Hash)
829
+ @script[label][name][task] = val
830
+ @events[label][name][task] = on if on.is_a?(Hash)
831
831
  end
832
832
  self
833
833
  end
@@ -844,15 +844,17 @@ module Squared
844
844
  end
845
845
 
846
846
  def data_get(*args, group: nil, ref: nil, target: nil)
847
- target[:group][group.to_sym] if group
848
- if ref.is_a?(Enumerable)
847
+ if group && target[:group].key?(key = group.to_sym)
848
+ target[:group][key]
849
+ elsif ref.is_a?(Enumerable)
849
850
  ref.each do |key|
850
- next unless (ret = target[:ref][key])
851
+ next unless target[:ref].key?(key)
851
852
 
853
+ ret = target[:ref][key]
852
854
  return ret if args.empty? || args.any? { |val| ret.key?(val) }
853
855
  end
854
856
  nil
855
- elsif ref
857
+ elsif ref && target[:ref].key?(ref)
856
858
  target[:ref][ref]
857
859
  end
858
860
  end
@@ -9,7 +9,6 @@ module Squared
9
9
  module Workspace
10
10
  module Project
11
11
  class Base
12
- include Comparable
13
12
  include Common::Format
14
13
  include System
15
14
  include Shell
@@ -17,6 +16,7 @@ module Squared
17
16
  include Utils
18
17
  include Support
19
18
  include Rake::DSL
19
+ include ::Comparable
20
20
 
21
21
  VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
22
22
  pass exclude].freeze
@@ -238,8 +238,13 @@ module Squared
238
238
  end
239
239
  end
240
240
 
241
+ def ==(other)
242
+ equal?(other)
243
+ end
244
+
241
245
  def <=>(other)
242
- return 0 unless workspace == other.workspace
246
+ return unless workspace == other.workspace
247
+ return 0 if equal?(other)
243
248
 
244
249
  a, b = graph_deps
245
250
  return 1 if a.include?(other)
@@ -266,14 +271,12 @@ module Squared
266
271
  -1
267
272
  elsif f.any? { |val| e.include?(val) }
268
273
  1
269
- elsif @index != -1 && (i = other.instance_variable_get(:@index)) != -1
270
- @index < i ? -1 : 1
271
- else
272
- 0
274
+ elsif @index >= 0 && (i = other.instance_variable_get(:@index)) >= 0
275
+ @index <=> i
273
276
  end
274
277
  rescue StandardError => e
275
278
  log&.debug e
276
- 0
279
+ nil
277
280
  end
278
281
 
279
282
  def ref
@@ -1145,7 +1148,7 @@ module Squared
1145
1148
  done
1146
1149
  end
1147
1150
 
1148
- def graph_collect(target, start = [], data: {}, pass: [])
1151
+ def graph_collect(target, start = [], data: {}, pass: [], root: [])
1149
1152
  deps = []
1150
1153
  (start.empty? ? target.instance_variable_get(:@graph) : start)&.each do |val|
1151
1154
  next if pass.include?(val)
@@ -1158,10 +1161,12 @@ module Squared
1158
1161
  items = workspace.find(group: val, ref: val.to_sym)
1159
1162
  end
1160
1163
  items.each do |proj|
1161
- next if pass.include?(proj.name)
1164
+ next if pass.include?(name = proj.name)
1162
1165
 
1163
- graph_collect(proj, data: data, pass: pass) if proj.graph? && !data.key?(proj.name)
1164
- next if (objs = data.fetch(proj.name, [])).include?(target)
1166
+ if proj.graph? && !data.key?(name) && !root.include?(name)
1167
+ graph_collect(proj, data: data, pass: pass, root: root + [name, target.name])
1168
+ end
1169
+ next if (objs = data.fetch(name, [])).include?(target)
1165
1170
 
1166
1171
  deps << proj
1167
1172
  deps.concat(objs)
@@ -265,7 +265,6 @@ module Squared
265
265
  when Enumerable
266
266
  ret.merge(opts.to_a)
267
267
  end
268
-
269
268
  [args, flags].each_with_index do |target, index|
270
269
  if target.is_a?(String)
271
270
  ret << target
@@ -3,7 +3,7 @@
3
3
  module Squared
4
4
  module Workspace
5
5
  module Git
6
- GIT_REPO = {}
6
+ GIT_REPO = Workspace.hashobj
7
7
  GIT_PROTO = %r{^(?:https?|ssh|git|file)://}i.freeze
8
8
  private_constant :GIT_REPO, :GIT_PROTO
9
9
 
@@ -58,8 +58,8 @@ module Squared
58
58
  end
59
59
  end
60
60
  key = task_name key
61
- (GIT_REPO[main] ||= {})[key] = [uri.to_s, opts]
62
- (@kind[key] ||= []) << Project::Git
61
+ GIT_REPO[main][key] = [uri.to_s, opts]
62
+ @kind[key] << Project::Git
63
63
  end
64
64
  if cache == true
65
65
  revbuild
@@ -396,12 +396,12 @@ module Squared
396
396
  if flag == :fixup
397
397
  ref, squash, pick = choice_commit(accept: [['Auto squash?', true]], reflog: false,
398
398
  values: ['Pick [amend|reword]'])
399
- pick = case pick&.downcase
400
- when 'a', 'amend'
401
- 'amend'
402
- when 'r', 'reword'
403
- 'reword'
404
- end
399
+ pick &&= case pick.downcase
400
+ when 'a', 'amend'
401
+ 'amend'
402
+ when 'r', 'reword'
403
+ 'reword'
404
+ end
405
405
  if squash
406
406
  found = false
407
407
  git_spawn(git_output('log --format=%h'), stdout: false).each do |val|
@@ -413,12 +413,14 @@ module Squared
413
413
  end
414
414
  end
415
415
  end
416
- refs = pick == 'reword' ? [] : param_guard(action, flag, args: args.to_a)
417
- if flag == :add
418
- opts = refs
419
- refs = []
420
- else
421
- opts = []
416
+ opts = []
417
+ refs = []
418
+ unless pick == 'reword'
419
+ if flag == :add
420
+ opts = param_guard(action, flag, args: args.to_a)
421
+ elsif (refs = args.to_a).empty?
422
+ refs = readline('Enter file patterns', force: true).shellsplit
423
+ end
422
424
  end
423
425
  commit(flag, opts, refs: refs, ref: ref, squash: squash, pick: pick)
424
426
  end
@@ -280,7 +280,7 @@ module Squared
280
280
  end
281
281
  end
282
282
  when 'outdated'
283
- format_desc action, flag, 'eager?'
283
+ format_desc action, flag, 'eager?,user?'
284
284
  task flag do |_, args|
285
285
  outdated flag, args.to_a
286
286
  end
@@ -431,7 +431,9 @@ module Squared
431
431
  when :patch
432
432
  patch
433
433
  end
434
- install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil) unless !pkg || pkg.empty?
434
+ unless !pkg || pkg.empty?
435
+ install(:upgrade, pkg, strategy: opts.include?('eager') ? 'eager' : nil, user: opts.include?('user'))
436
+ end
435
437
  elsif start == 0
436
438
  puts 'No updates were found'
437
439
  end
@@ -439,7 +441,7 @@ module Squared
439
441
  on :last, :outdated
440
442
  end
441
443
 
442
- def install(flag, opts = [], strategy: nil)
444
+ def install(flag, opts = [], strategy: nil, user: nil)
443
445
  cmd = pip_session 'install'
444
446
  out = append_pip(flag, opts, from: :install)
445
447
  case flag
@@ -449,6 +451,7 @@ module Squared
449
451
  when :upgrade
450
452
  raise_error('no packages listed', hint: flag) if out.empty?
451
453
  cmd << '--upgrade'
454
+ cmd << '--user' if user
452
455
  cmd << basic_option('upgrade-strategy', strategy) if strategy
453
456
  append_value out
454
457
  end
@@ -4,7 +4,7 @@ module Squared
4
4
  module Workspace
5
5
  module Project
6
6
  class Ruby < Git
7
- GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb Isolate].freeze
7
+ GEMFILE = %w[Gemfile Gemfile.lock gem.deps.rb gems.rb Isolate].freeze
8
8
  DIR_RUBY = (GEMFILE + Rake::Application::DEFAULT_RAKEFILES + ['README.rdoc']).freeze
9
9
  OPT_RUBY = {
10
10
  ruby: %w[0=im? a c e=q E=bm F=qm i=bm? I=pm l n p r=bm s S w W=bm? x=pm? d|debug jit rjit v|verbose y|yydebug
@@ -849,18 +849,20 @@ module Squared
849
849
  pwd_set(pass: !pwd.nil?) do
850
850
  out = `#{gem_output(pwd, 'list --local -d', project)}`
851
851
  if out =~ /#{Regexp.escape(project)} \(([^)]+)\)/
852
- ver = $1.split(/\s*,\s*/)
853
- ver.unshift(@version).uniq!
854
- ver.each do |val|
855
- next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
856
-
857
- set.call(val, $1)
858
- break
859
- end
852
+ $1.split(/\s*,\s*/)
853
+ .unshift(@version)
854
+ .uniq
855
+ .each do |val|
856
+ next unless out =~ /\(#{Regexp.escape(val)}(?:,[^)]+|\b)\):([^\n]+)/
857
+
858
+ set.call(val, $1)
859
+ return gemdir? if @gemdir
860
+ end
860
861
  end
861
862
  end
862
- end
863
- unless @gemdir
863
+ require 'rubygems'
864
+ @gemdir = Pathname.new(Gem.dir) + gempath
865
+ else
864
866
  parse = lambda do |path|
865
867
  next unless path
866
868
 
@@ -873,9 +875,10 @@ module Squared
873
875
  target = RUBY_VERSION.start_with?('2.6') ? RubyVM : $LOAD_PATH
874
876
  parse.call(target.resolve_feature_path(project)&.last)
875
877
  end
876
- pwd_set { parse.call(`#{bundle_output('show', project)}`) } unless @gemdir
878
+ if !@gemdir && !pwd_set { parse.call(`#{bundle_output('show', project)}`) }
879
+ raise_error 'gems directory not found'
880
+ end
877
881
  end
878
- raise_error('parse failed', hint: @version || 'path') unless @gemdir
879
882
  rescue StandardError => e
880
883
  log.error e
881
884
  @version = nil
@@ -10,16 +10,16 @@ module Squared
10
10
 
11
11
  TASK_BASE = []
12
12
  TASK_BATCH = {}
13
- TASK_EXTEND = {}
13
+ TASK_EXTEND = Workspace.hashlist
14
14
  TASK_KEYS = []
15
- TASK_ALIAS = {}
15
+ TASK_ALIAS = Workspace.hashobj
16
16
  TASK_NAME = {}
17
17
  private_constant :TASK_BASE, :TASK_BATCH, :TASK_EXTEND, :TASK_KEYS, :TASK_ALIAS, :TASK_NAME
18
18
 
19
19
  class << self
20
20
  def add(task, obj)
21
21
  key_set task
22
- (TASK_EXTEND[task] ||= []) << obj
22
+ TASK_EXTEND[task] << obj
23
23
  end
24
24
 
25
25
  def batch(*args, obj)
@@ -37,7 +37,7 @@ module Squared
37
37
 
38
38
  def alias(ref, obj)
39
39
  if obj.is_a?(Hash)
40
- obj.each { |key, val| (TASK_ALIAS[key] ||= {})[ref] = val }
40
+ obj.each { |key, val| TASK_ALIAS[key][ref] = val }
41
41
  else
42
42
  TASK_ALIAS[obj]&.delete(ref)
43
43
  end
@@ -79,8 +79,8 @@ module Squared
79
79
  @chain = {}
80
80
  @exclude = exclude.freeze
81
81
  @session = {
82
- group: {},
83
- parent: {},
82
+ group: Workspace.hashlist,
83
+ parent: Workspace.hashlist,
84
84
  id: []
85
85
  }
86
86
  @data = {}
@@ -95,7 +95,7 @@ module Squared
95
95
 
96
96
  if (g = proj.group)
97
97
  id << g
98
- (group[:"#{key}:#{g}"] ||= []).concat(tasks)
98
+ group[:"#{key}:#{g}"].concat(tasks)
99
99
  else
100
100
  items.concat(tasks)
101
101
  end
@@ -106,7 +106,7 @@ module Squared
106
106
  next unless (b = ws.find_base(proj)) && (n = b.ref.to_s) != g
107
107
 
108
108
  id << n
109
- (parent[:"#{key}:#{n}"] ||= []).concat(tasks)
109
+ parent[:"#{key}:#{n}"].concat(tasks)
110
110
  end
111
111
  end
112
112
 
@@ -27,6 +27,14 @@ module Squared
27
27
  !!project(name)&.enabled?
28
28
  end
29
29
 
30
+ def hashobj
31
+ Hash.new { |data, key| data[key] = {} }
32
+ end
33
+
34
+ def hashlist
35
+ Hash.new { |data, key| data[key] = [] }
36
+ end
37
+
30
38
  private
31
39
 
32
40
  def project(name)
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.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham