squared 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa6a0925852c1485cd33d015135c405cd857444be25e52a07a3f3b99e4fdb9c1
4
- data.tar.gz: 1f1007675d785192b7f28800e1bb3be1e6fa42a62afb0cd4a6dd0527cbcdcc80
3
+ metadata.gz: c3ecf3c0d10f36460a83779df904d378fbca6fa8d5b08e9813f1b5e8d1d91952
4
+ data.tar.gz: a12c3454145efdb8319d72240f53ccda0eeabbe4779055c0e7c7180a8621e8af
5
5
  SHA512:
6
- metadata.gz: c8cb9d7a36b8a0b5e7769c0b847670f20abb02a74cb7000caeb36a99d114c6b84aa8b3025bcbe6cd1d1e7922e0fcdd5804796f9a2f606f81fc8d9997b90ced44
7
- data.tar.gz: bc241dfbb6b61cbd210a47b6bdf56d566b163aaf525b101fa507ef3ad721a022b1c5d1e2d4a78aded5613be994c784366ed1e49fef3b2430f8192917af62f3ab
6
+ metadata.gz: 408330c1da4bec81cb8170ba606001b3491c0d4061a9e32492714f15941d6043a9fa5e0b62e831dc46977e0abf91b9617bd704f4142f66cbb47fb2e69a9f639e
7
+ data.tar.gz: 3bf4983b1e3cb87a57611f66f6d8a4f6d79f8d056855358d1bf75f43ed6459fa8aef21daf7a8afc3025f89f40a95c5247d8a1a90c9c21991e14cc281bb83ed8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.9] - 2025-04-17
4
+
5
+ ### Fixed
6
+
7
+ - Project option parser did not separate custom values.
8
+
9
+ ## [0.2.9] - 2025-04-17
10
+
11
+ ### Changed
12
+
13
+ - Project log file naming supports more date formats.
14
+
15
+ ### Fixed
16
+
17
+ - Environment options did not always pass session object.
18
+ - Git command pull actions used unknown flags.
19
+ - Workspace describe did not merge multiple invocations.
20
+
21
+ ## [0.1.6] - 2025-04-17
22
+
23
+ ### Fixed
24
+
25
+ - User-defined program paths were not reduced to bare name.
26
+ - Project path validation did not include separator.
27
+
3
28
  ## [0.3.8] - 2025-04-12
4
29
 
5
30
  ### Fixed
@@ -345,6 +370,7 @@
345
370
 
346
371
  - Changelog was created.
347
372
 
373
+ [0.3.9]: https://github.com/anpham6/squared/releases/tag/v0.3.9-ruby
348
374
  [0.3.8]: https://github.com/anpham6/squared/releases/tag/v0.3.8-ruby
349
375
  [0.3.7]: https://github.com/anpham6/squared/releases/tag/v0.3.7-ruby
350
376
  [0.3.6]: https://github.com/anpham6/squared/releases/tag/v0.3.6-ruby
@@ -354,6 +380,7 @@
354
380
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
355
381
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
356
382
  [0.3.0]: https://github.com/anpham6/squared/releases/tag/v0.3.0-ruby
383
+ [0.2.9]: https://github.com/anpham6/squared/releases/tag/v0.2.9-ruby
357
384
  [0.2.8]: https://github.com/anpham6/squared/releases/tag/v0.2.8-ruby
358
385
  [0.2.7]: https://github.com/anpham6/squared/releases/tag/v0.2.7-ruby
359
386
  [0.2.6]: https://github.com/anpham6/squared/releases/tag/v0.2.6-ruby
@@ -363,6 +390,7 @@
363
390
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
364
391
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
365
392
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
393
+ [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
366
394
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
367
395
  [0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
368
396
  [0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
@@ -274,6 +274,10 @@ module Squared
274
274
  val.gsub(/\x1B\[(\d+;?)+m/, '')
275
275
  end
276
276
 
277
+ def stripext(val)
278
+ File.basename(val, File.extname(val))
279
+ end
280
+
277
281
  def raise_error(*args, hint: nil, kind: ArgumentError)
278
282
  raise kind, message(*args, hint: hint, empty: true), caller_locations(1).map(&:to_s)
279
283
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.3.8'
4
+ VERSION = '0.3.9'
5
5
  end
@@ -350,7 +350,7 @@ module Squared
350
350
  end
351
351
 
352
352
  def describe(data)
353
- @describe = {
353
+ @describe ||= {
354
354
  alias: {},
355
355
  replace: [],
356
356
  pattern: {}
@@ -173,19 +173,24 @@ module Squared
173
173
  return if @log
174
174
 
175
175
  log = log.is_a?(Hash) ? log.dup : { file: log }
176
- unless (file = env('LOG_FILE'))
177
- file = case env('LOG_AUTO')
178
- when 'y', 'year'
179
- "#{@name}-#{Date.today.year}.log"
180
- when 'm', 'month'
181
- "#{@name}-#{Date.today.strftime('%Y-%m')}.log"
182
- when 'd', 'day', '1'
183
- "#{@name}-#{Date.today}.log"
184
- end
185
- end
186
- if file ||= log[:file]
187
- file = Date.today.strftime(file)
188
- file = (dir = env('LOG_DIR')) ? @workspace.home.join(dir, file) : @workspace.home.join(file)
176
+ if (file = env('LOG_FILE'))
177
+ file = DateTime.now.strftime(file)
178
+ elsif (val = env('LOG_AUTO'))
179
+ file = "#{@name}-%s.log" % [case val
180
+ when 'y', 'year'
181
+ Date.today.year
182
+ when 'm', 'month'
183
+ Date.today.strftime('%Y-%m')
184
+ when 'd', 'day', '1'
185
+ Date.today
186
+ else
187
+ val.include?('%') ? DateTime.now.strftime(val) : DateTime.now.strftime
188
+ end]
189
+ elsif (val = log[:file])
190
+ file = val.is_a?(String) ? DateTime.now.strftime(val) : "#{@name}-#{Date.today}.log"
191
+ end
192
+ if file
193
+ file = (val = env('LOG_DIR')) ? @workspace.home.join(val, file) : @workspace.home.join(file)
189
194
  begin
190
195
  file = file.realdirpath
191
196
  rescue StandardError => e
@@ -853,7 +858,7 @@ module Squared
853
858
  end
854
859
 
855
860
  def session(*cmd, prefix: cmd.first, main: true, options: true)
856
- prefix = prefix.to_s.upcase
861
+ prefix = stripext(prefix.to_s).upcase
857
862
  if (val = PATH[prefix] || PATH[prefix.to_sym])
858
863
  cmd[0] = shell_quote(val, force: false)
859
864
  end
@@ -888,11 +893,10 @@ module Squared
888
893
  cmd.done
889
894
  end
890
895
 
891
- def option(*args, prefix: @session&.first, **kwargs)
896
+ def option(*args, target: @session, prefix: target&.first, **kwargs)
892
897
  if prefix
893
- prefix = File.basename(prefix, File.extname(prefix))
894
898
  args.each do |val|
895
- ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
899
+ ret = env("#{stripext(prefix)}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
896
900
  return ret if ret
897
901
  end
898
902
  end
@@ -933,8 +937,10 @@ module Squared
933
937
  p << flag
934
938
  when 'i'
935
939
  i << flag
936
- else
940
+ when 'v'
937
941
  reg << Regexp.escape(flag)
942
+ else
943
+ next
938
944
  end
939
945
  bare << flag if val.end_with?('?')
940
946
  else
@@ -952,7 +958,7 @@ module Squared
952
958
  elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
953
959
  target << "--no-#{name}"
954
960
  else
955
- if opt =~ /^([^=]+)=(.+)$/
961
+ if opt =~ /\A([^=]+)=(.+)\z/
956
962
  a = $1
957
963
  if e.include?(a)
958
964
  target << shell_option(a, $2)
@@ -973,7 +979,7 @@ module Squared
973
979
  found = true if first && pass.none? { |val| opt.include?(val) }
974
980
  end
975
981
  end
976
- [ret, reg.empty? ? /\A\s+\z/ : /^(#{reg.join('|')})=(.+)$/]
982
+ [ret, reg.empty? ? /\A\s+\z/ : /\A(#{reg.join('|')})=(.+)\z/]
977
983
  end
978
984
 
979
985
  def option_clear(opts, target: @session, **kwargs)
@@ -1191,7 +1197,7 @@ module Squared
1191
1197
  return if (list = list.flatten).empty?
1192
1198
 
1193
1199
  list.flatten.each do |opt|
1194
- next unless (val = option(opt, **kwargs))
1200
+ next unless (val = option(opt, target: target, **kwargs))
1195
1201
 
1196
1202
  return target << (if flag
1197
1203
  shell_option(opt, equals ? val : nil, quote: quote, escape: escape, force: force)
@@ -1220,7 +1226,7 @@ module Squared
1220
1226
  end
1221
1227
 
1222
1228
  def append_nocolor(target: @session)
1223
- target << '--no-color' if !ARG[:COLOR] || stdin? || option('no-color', ignore: false)
1229
+ target << '--no-color' if !ARG[:COLOR] || stdin? || option('no-color', target: target, ignore: false)
1224
1230
  end
1225
1231
 
1226
1232
  def collect_hash(data, pass: [])
@@ -1397,7 +1403,8 @@ module Squared
1397
1403
  end
1398
1404
 
1399
1405
  def projectpath?(val)
1400
- Pathname.new(val).absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?('..')
1406
+ val = Pathname.new(val).cleanpath
1407
+ val.absolute? ? val.to_s.start_with?(File.join(path, '')) : !val.to_s.start_with?(File.join('..', ''))
1401
1408
  end
1402
1409
 
1403
1410
  def semmajor?(cur, want)
@@ -86,11 +86,12 @@ module Squared
86
86
  show: %w[s exit-code histogram].freeze
87
87
  }.freeze,
88
88
  fetch: {
89
- base: %w[multiple progress P|prune-tags refetch stdin u|update-head-ok recurse-submodules=b
89
+ base: %w[multiple progress P|prune-tags refetch stdin u|update-head-ok
90
90
  recurse-submodules-default=b].freeze,
91
91
  pull: %w[4 6 n t a|append atomic dry-run f|force k|keep n|negotiate-only prefetch p|prune q|quiet
92
92
  set-upstream unshallow update-shallow v|verbose deepen=i depth=i j|jobs=i negotiation-tip=q
93
- refmap=q o|server-option=e shallow-exclude=e shallow-since=b upload-pack=e].freeze
93
+ recurse-submodules=v refmap=q o|server-option=e shallow-exclude=e shallow-since=v
94
+ upload-pack=e].freeze
94
95
  }.freeze,
95
96
  log: {
96
97
  base: %w[all all-match alternate-refs author-date-order basic-regexp bisect boundary cherry cherry-mark
@@ -121,7 +122,7 @@ module Squared
121
122
  no-empty-directory recurse-submodules sparse s|stage u|unmerged abbrev=i x|exclude=q
122
123
  X|exclude-from=p exclude-per-directory=p format=q with-tree=q].freeze,
123
124
  ls_remote: %w[exit-code get-url q|quiet o|server-option=e symref sort=q upload-pack=e].freeze,
124
- pull: %w[e n allow-unrelated-histories ff-only S|gpg-sign=e log=i r|rebase=b? s|strategy=b
125
+ pull: %w[e n allow-unrelated-histories ff-only S|gpg-sign=e log=i r|rebase=v? s|strategy=b
125
126
  X|strategy-option=e].freeze,
126
127
  rebase: %w[n C=i allow-empty-message apply committer-date-is-author-date edit-todo f|force-rebase ignore-date
127
128
  ignore-whitespace i|interactive keep-base m merge no-ff q|quiet quit r|rebase-merges=b?
@@ -567,8 +568,11 @@ module Squared
567
568
  end
568
569
 
569
570
  def pull(flag = nil, opts = [], sync: invoked_sync?('pull', flag), remote: nil)
570
- cmd = git_session 'pull', flag && "--#{flag}"
571
- if (val = option('rebase', ignore: false))
571
+ cmd = git_session 'pull'
572
+ if flag == :rebase
573
+ cmd << '--rebase'
574
+ cmd << '--autostash' if option('autostash')
575
+ elsif (val = option('rebase', ignore: false))
572
576
  cmd << case val
573
577
  when '0'
574
578
  '--no-rebase'
@@ -1227,11 +1231,11 @@ module Squared
1227
1231
  end
1228
1232
 
1229
1233
  def append_pull(opts, list, target: @session, no: nil, flag: nil, remote: nil)
1230
- cmd << '--force' if option('force')
1234
+ target << '--force' if option('force', target: target)
1231
1235
  rsm = append_submodules(target: target)
1232
1236
  out = []
1233
1237
  refspec = []
1234
- opts, pat = option_sanitize(opts, remote ? list + ['refspec=b'] : list, target: target, no: no)
1238
+ opts, pat = option_sanitize(opts, remote ? list + ['refspec=v'] : list, target: target, no: no)
1235
1239
  opts.each do |opt|
1236
1240
  if opt =~ pat
1237
1241
  case $1
@@ -1252,7 +1256,7 @@ module Squared
1252
1256
  end
1253
1257
  if remote
1254
1258
  append_value(remote, target: target, delim: true)
1255
- if (val = option('refspec', strict: true))
1259
+ if (val = option('refspec', target: target, strict: true))
1256
1260
  append_value(split_escape(val), target: target)
1257
1261
  else
1258
1262
  target.merge(refspec)
@@ -1271,10 +1275,10 @@ module Squared
1271
1275
  end
1272
1276
 
1273
1277
  def append_pathspec(files = [], target: @session, expect: false, parent: false)
1274
- if session_arg?('pathspec-from-file')
1278
+ if session_arg?('pathspec-from-file', target: target)
1275
1279
  option_clear files
1276
1280
  else
1277
- if files.empty? && (val = option('pathspec'))
1281
+ if files.empty? && (val = option('pathspec', target: target))
1278
1282
  files = split_escape(val)
1279
1283
  end
1280
1284
  files = projectmap(files, parent: parent)
@@ -1297,7 +1301,7 @@ module Squared
1297
1301
  end
1298
1302
 
1299
1303
  def append_submodules(from = nil, target: @session)
1300
- return unless (val = option('recurse-submodules', ignore: false))
1304
+ return unless (val = option('recurse-submodules', target: target, ignore: false))
1301
1305
 
1302
1306
  if from == :clone
1303
1307
  projectmap(split_escape(val)).each do |path|
@@ -1326,7 +1330,9 @@ module Squared
1326
1330
  end
1327
1331
 
1328
1332
  def dryrun?(*, target: @session, **)
1329
- !!target&.include?('--dry-run')
1333
+ return false unless target
1334
+
1335
+ target.include?('--dry-run')
1330
1336
  end
1331
1337
 
1332
1338
  def quiet?(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 include-workspace-root workspaces=b? w|workspace=b].freeze,
8
+ common: %w[dry-run include-workspace-root workspaces=b? w|workspace=v].freeze,
9
9
  install: %w[prefer-dedupe package-lock-only cpu=q libc=e os=q].freeze,
10
10
  install_base: %w[ignore-scripts install-links strict-peer-deps include=b omit=b install-strategy=b].freeze,
11
11
  install_no: %w[audit bin-links fund package-lock].freeze,
@@ -14,7 +14,7 @@ module Squared
14
14
  install: %w[break-system-packages check-build-dependencies compile dry-run force-reinstall I|ignore-installed
15
15
  ignore-requires-python no-build-isolation no-clean no-compile no-deps no-index no-warn-conflicts
16
16
  no-warn-script-location pre prefer-binary require-hashes U|upgrade use-pep517 user abi=e
17
- config-settings=q c|constraint=p e|editable=b? extra-index-url=q f|find-links=q global-option=q
17
+ config-settings=q c|constraint=p e|editable=v? extra-index-url=q f|find-links=q global-option=q
18
18
  implementation=b i|index-url=q no-binary=q only-binary=q platform=q prefix=p progress-bar=b
19
19
  python-version=q report=p r|requirement=p root=p root-user-action=e src=p t|target=p
20
20
  upgrade-strategy=b].freeze
@@ -305,7 +305,7 @@ module Squared
305
305
  end
306
306
 
307
307
  def append_global(target: @session)
308
- if (val = option('cache-dir'))
308
+ if (val = option('cache-dir', target: target))
309
309
  target << case val
310
310
  when '0', 'false'
311
311
  '--no-cache-dir'
@@ -313,8 +313,8 @@ module Squared
313
313
  quote_option('cache-dir', basepath(val))
314
314
  end
315
315
  end
316
- target << shell_option('proxy', val) if (val = option('proxy'))
317
- target << quote_option('python', basepath(val)) if (val = option('python'))
316
+ target << shell_option('proxy', val) if (val = option('proxy', target: target))
317
+ target << quote_option('python', basepath(val)) if (val = option('python', target: target))
318
318
  append_nocolor(target: target)
319
319
  end
320
320
  end
@@ -25,7 +25,7 @@ module Squared
25
25
  platform=q source=q].freeze,
26
26
  push: %w[no-http-proxy attestation=p host=q key=e otp=e p|http-proxy=q?].freeze,
27
27
  build: %w[force strict o|output=p platform=q].freeze,
28
- exec: %w[conservative prerelease no-prerelease g|gem=b version=e].freeze,
28
+ exec: %w[conservative prerelease no-prerelease g|gem=v version=e].freeze,
29
29
  pristine: %w[all env-shebang extensions no-env-shebang no-extensions only-executables only-missing-extensions
30
30
  only-plugins n|bindir=p i|install-dir=p skip=e v|version=e].freeze,
31
31
  shared: %w[f b|both clear-sources conservative default development development-all E|explain
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.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.6.7
123
+ rubygems_version: 3.6.8
124
124
  specification_version: 4
125
125
  summary: Rake task generator for managing multi-language workspaces.
126
126
  test_files: []