squared 0.3.7 → 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: 404b6e4de1ff62a628030bfa5487287dac6a962a6e052297537533a29ff6be2c
4
- data.tar.gz: a136f94da4653d88325e3ed571523d1d3a57d8974695ce306bfadd6c2264e6c1
3
+ metadata.gz: c3ecf3c0d10f36460a83779df904d378fbca6fa8d5b08e9813f1b5e8d1d91952
4
+ data.tar.gz: a12c3454145efdb8319d72240f53ccda0eeabbe4779055c0e7c7180a8621e8af
5
5
  SHA512:
6
- metadata.gz: 26e2e83cdefdb8b3c9641f1aa5880432426cfbd807ddb659252f10735eafb0353d61d80ef87876251c6b8720fa434d5cb0df7a541476ff4573f71e6c8a49b27d
7
- data.tar.gz: c457360ca63c5941594781613662c51b3d5ae18d9bac436f70357ebbc4ef2418504f8f376981cc03bb5590bc20d9540909fd2318414b631c091b64ee8e58df04
6
+ metadata.gz: 408330c1da4bec81cb8170ba606001b3491c0d4061a9e32492714f15941d6043a9fa5e0b62e831dc46977e0abf91b9617bd704f4142f66cbb47fb2e69a9f639e
7
+ data.tar.gz: 3bf4983b1e3cb87a57611f66f6d8a4f6d79f8d056855358d1bf75f43ed6459fa8aef21daf7a8afc3025f89f40a95c5247d8a1a90c9c21991e14cc281bb83ed8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
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
+
28
+ ## [0.3.8] - 2025-04-12
29
+
30
+ ### Fixed
31
+
32
+ - Project class did not parse verbose string values.
33
+
34
+ ## [0.2.8] - 2025-04-12
35
+
36
+ ### Fixed
37
+
38
+ - User-defined program paths were not sanitized for ENV.
39
+ - Project clean task used incompatible rmtree flag.
40
+ - Git branch unset-upstream used undefined variable.
41
+
3
42
  ## [0.3.7] - 2025-04-08
4
43
 
5
44
  - See `0.2.7`.
@@ -331,6 +370,8 @@
331
370
 
332
371
  - Changelog was created.
333
372
 
373
+ [0.3.9]: https://github.com/anpham6/squared/releases/tag/v0.3.9-ruby
374
+ [0.3.8]: https://github.com/anpham6/squared/releases/tag/v0.3.8-ruby
334
375
  [0.3.7]: https://github.com/anpham6/squared/releases/tag/v0.3.7-ruby
335
376
  [0.3.6]: https://github.com/anpham6/squared/releases/tag/v0.3.6-ruby
336
377
  [0.3.5]: https://github.com/anpham6/squared/releases/tag/v0.3.5-ruby
@@ -339,6 +380,8 @@
339
380
  [0.3.2]: https://github.com/anpham6/squared/releases/tag/v0.3.2-ruby
340
381
  [0.3.1]: https://github.com/anpham6/squared/releases/tag/v0.3.1-ruby
341
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
384
+ [0.2.8]: https://github.com/anpham6/squared/releases/tag/v0.2.8-ruby
342
385
  [0.2.7]: https://github.com/anpham6/squared/releases/tag/v0.2.7-ruby
343
386
  [0.2.6]: https://github.com/anpham6/squared/releases/tag/v0.2.6-ruby
344
387
  [0.2.5]: https://github.com/anpham6/squared/releases/tag/v0.2.5-ruby
@@ -347,6 +390,7 @@
347
390
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
348
391
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
349
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
350
394
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
351
395
  [0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
352
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.7'
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: {}
@@ -80,7 +80,7 @@ module Squared
80
80
  when nil
81
81
  workspace.verbose
82
82
  when String
83
- env_pipe(verbose, workspace.verbose, strict: true, index: true)
83
+ env_bool(verbose, workspace.verbose, strict: true, index: true)
84
84
  else
85
85
  verbose
86
86
  end
@@ -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
@@ -447,7 +452,7 @@ module Squared
447
452
  path = basepath(val)
448
453
  if path.directory? && val =~ %r{[\\/]\z}
449
454
  log&.warn "rm -rf #{path}"
450
- path.rmtree(verbose: verbose)
455
+ FileUtils.rm_rf(path, verbose: verbose)
451
456
  else
452
457
  log&.warn "rm #{path}"
453
458
  (val.include?('*') ? Dir[path] : [path]).each do |file|
@@ -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,10 +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
898
  args.each do |val|
894
- ret = env("#{prefix}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
899
+ ret = env("#{stripext(prefix)}_#{val.gsub(/\W/, '_')}".upcase, **kwargs)
895
900
  return ret if ret
896
901
  end
897
902
  end
@@ -932,8 +937,10 @@ module Squared
932
937
  p << flag
933
938
  when 'i'
934
939
  i << flag
935
- else
940
+ when 'v'
936
941
  reg << Regexp.escape(flag)
942
+ else
943
+ next
937
944
  end
938
945
  bare << flag if val.end_with?('?')
939
946
  else
@@ -951,7 +958,7 @@ module Squared
951
958
  elsif opt.start_with?('no-') && no.include?(name = opt[3..-1])
952
959
  target << "--no-#{name}"
953
960
  else
954
- if opt =~ /^([^=]+)=(.+)$/
961
+ if opt =~ /\A([^=]+)=(.+)\z/
955
962
  a = $1
956
963
  if e.include?(a)
957
964
  target << shell_option(a, $2)
@@ -972,7 +979,7 @@ module Squared
972
979
  found = true if first && pass.none? { |val| opt.include?(val) }
973
980
  end
974
981
  end
975
- [ret, reg.empty? ? /\A\s+\z/ : /^(#{reg.join('|')})=(.+)$/]
982
+ [ret, reg.empty? ? /\A\s+\z/ : /\A(#{reg.join('|')})=(.+)\z/]
976
983
  end
977
984
 
978
985
  def option_clear(opts, target: @session, **kwargs)
@@ -1190,7 +1197,7 @@ module Squared
1190
1197
  return if (list = list.flatten).empty?
1191
1198
 
1192
1199
  list.flatten.each do |opt|
1193
- next unless (val = option(opt, **kwargs))
1200
+ next unless (val = option(opt, target: target, **kwargs))
1194
1201
 
1195
1202
  return target << (if flag
1196
1203
  shell_option(opt, equals ? val : nil, quote: quote, escape: escape, force: force)
@@ -1219,7 +1226,7 @@ module Squared
1219
1226
  end
1220
1227
 
1221
1228
  def append_nocolor(target: @session)
1222
- 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)
1223
1230
  end
1224
1231
 
1225
1232
  def collect_hash(data, pass: [])
@@ -1396,7 +1403,8 @@ module Squared
1396
1403
  end
1397
1404
 
1398
1405
  def projectpath?(val)
1399
- 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('..', ''))
1400
1408
  end
1401
1409
 
1402
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'
@@ -975,7 +979,7 @@ module Squared
975
979
  return unless ref
976
980
 
977
981
  if ref.start_with?('^')
978
- cmd << '--unset-upstream' << shell_escape(arg[1..-1])
982
+ cmd << '--unset-upstream' << shell_escape(ref[1..-1])
979
983
  target = nil
980
984
  stdout = true
981
985
  else
@@ -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,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -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.2
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: []