squared 0.1.3 → 0.1.5

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: 11c047668befa13733be4f81fbac270909c72be73754f70b464e804c11f8204e
4
- data.tar.gz: fac920aa92d55210e48c2f780ea366b58f0c9ed870d524b5bf19eeeeb2628ab1
3
+ metadata.gz: a3ad5f0881e8642ae1d57fccbba6a1fdc3ff555b6efcd7eb2989a5675ff5bcd3
4
+ data.tar.gz: 426a514ca02ddf64fa2009ad165d0bf9e0053905c58643c7398e7c1d17630fcc
5
5
  SHA512:
6
- metadata.gz: 78b3346cbf690fa4ce9a36431eaad0ffb24d464a46700810c19f6938b5e020c94c1ede8709f61e448f75443f3b8c9df8a00877e380e81beb7ce37732dc244289
7
- data.tar.gz: ee6b18f73590b38fa91a2f73852cbc6ccc467255bed2c5c540731d565dc43e15b1b6c103866003979518ef416fcb450beb5c58f5f1ad1c20119437d5f795aa84
6
+ metadata.gz: af9e72989be1dbbf614f8c7dd5989a0081775e4433ad280a4bae600660e56bd1ba20aa6a3f33ad367b349a209227be5b823c4e496367533260c1a86ae3a6dd6c
7
+ data.tar.gz: d0dd6f39e8b8f8834768c93ab26718618d0d0023f99a242321f6925bee9fcc782ebbfd86a698bdcebe17fb1deb763c79d46d77001d55a13b24ddc391beb0a3c8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.5] - 2024-02-25
4
+
5
+ ### Fixed
6
+
7
+ - Node copy method ignored include argument when called directly.
8
+ - Logger is not initialized when using only Git base class.
9
+ - Hide warnings about readline during execution.
10
+ - Logger is not initialized when using only base class.
11
+ - Merging ENV build options were double escaped.
12
+
13
+ ## [0.1.4] - 2024-02-05
14
+
15
+ ### Fixed
16
+
17
+ - Build options with array args were not recognized.
18
+ - Base clean command did not enumerate non-string values.
19
+ - Git command refs did not include ref option.
20
+ - Pip upgrade did not append package names.
21
+
3
22
  ## [0.1.3] - 2024-01-02
4
23
 
5
24
  ### Fixed
@@ -79,6 +98,8 @@
79
98
 
80
99
  - Changelog was created.
81
100
 
101
+ [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
102
+ [0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
82
103
  [0.1.3]: https://github.com/anpham6/squared/releases/tag/v0.1.3-ruby
83
104
  [0.1.2]: https://github.com/anpham6/squared/releases/tag/v0.1.2-ruby
84
105
  [0.1.1]: https://github.com/anpham6/squared/releases/tag/v0.1.1-ruby
data/README.ruby.md CHANGED
@@ -255,16 +255,16 @@ Non-task:
255
255
  # :env :run :opts
256
256
  # LD_LIBRARY_PATH="path/to/lib" CFLAGS="-Wall" gcc a.c -o a.o -c
257
257
  BUILD_${NAME} # gcc a.c -o a.o
258
- BUILD_OPTS_${NAME} # -c
259
- BUILD_ENV_${NAME} # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
258
+ BUILD_${NAME}_OPTS # -c
259
+ BUILD_${NAME}_ENV # {"LD_LIBRARY_PATH":"path/to/lib","CFLAGS":"-Wall"} (hash/json)
260
260
 
261
261
  # :env :opts :script
262
262
  # NODE_ENV="production" NO_COLOR="1" npm run --loglevel=error --workspaces=false build:dev
263
263
  BUILD_${NAME} # build:dev
264
- BUILD_OPTS_${NAME} # --loglevel=error --workspaces=false
265
- BUILD_ENV_${NAME} # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
266
- BUILD_DEV_${NAME} # pattern,0,1 (:dev)
267
- BUILD_PROD_${NAME} # pattern,0,1 (:prod)
264
+ BUILD_${NAME}_OPTS # --loglevel=error --workspaces=false
265
+ BUILD_${NAME}_ENV # {"NODE_ENV":"production","NO_COLOR":"1"} (hash/json)
266
+ BUILD_${NAME}_DEV # pattern,0,1 (:dev)
267
+ BUILD_${NAME}_PROD # pattern,0,1 (:prod)
268
268
 
269
269
  BUILD_${NAME}=0 # skip project
270
270
  ```
@@ -10,7 +10,7 @@ module Squared
10
10
 
11
11
  def shell_escape(val, quote: false, force: false)
12
12
  if (data = /\A(--?[^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val unless data[2]
13
+ return val if !data[2] || (!data[4] && data[5] =~ /\s/)
14
14
 
15
15
  join = ->(opt) { data[1] + data[3] + shell_quote(opt) }
16
16
  if data[4] == data[6]
@@ -32,8 +32,9 @@ module Squared
32
32
  Rake::Win32.windows? ? "\"#{double_quote(val)}\"" : "'#{single_quote(val)}'"
33
33
  end
34
34
 
35
- def shell_split(val, quote: false, join: nil)
36
- val = Shellwords.split(val).map { |opt| shell_escape(opt, quote: quote) }
35
+ def shell_split(val, escape: true, quote: false, join: nil)
36
+ val = Shellwords.split(val)
37
+ val = val.map { |opt| shell_escape(opt, quote: quote) } if escape
37
38
  return val unless join
38
39
 
39
40
  val.join(join.is_a?(::String) ? join : ' ')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.5'
5
5
  end
@@ -187,7 +187,7 @@ module Squared
187
187
  @prod = env_match("#{pre}_PROD", prod)
188
188
  cmd = @output[0]
189
189
  unless cmd == false || cmd.is_a?(Array) || (val = env('BUILD', suffix: 'OPTS')).nil?
190
- @output[cmd ? 1 : 3] = shell_split(val, join: true)
190
+ @output[cmd ? 1 : 3] = shell_split(val, escape: false, join: true)
191
191
  end
192
192
  unless @output[2] == false || (val = env('BUILD', suffix: 'ENV')).nil?
193
193
  begin
@@ -195,7 +195,7 @@ module Squared
195
195
  raise_error('invalid JSON object', val, hint: "#{prefix}_ENV") unless data.is_a?(Hash)
196
196
  @output[2] = data
197
197
  rescue StandardError => e
198
- log.warn e
198
+ log&.warn e
199
199
  end
200
200
  end
201
201
  return unless (val = env('BUILD', strict: true))
@@ -291,7 +291,7 @@ module Squared
291
291
  if val.directory? && !val.empty?
292
292
  true
293
293
  else
294
- log.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
294
+ log&.warn "workspace \"#{val}\" (#{val.empty? ? 'empty' : 'not found'})"
295
295
  false
296
296
  end
297
297
  end
@@ -343,7 +343,7 @@ module Squared
343
343
  when String
344
344
  cmd = "#{cmd} #{opts}"
345
345
  when Array
346
- cmd = cmd.join(' && ')
346
+ cmd = as_a(cmd).concat(opts).join(' && ')
347
347
  else
348
348
  cmd = [cmd, compose(opts, script: false)].compact.join(' ') unless opts == false || !respond_to?(:compose)
349
349
  end
@@ -364,11 +364,11 @@ module Squared
364
364
  end
365
365
 
366
366
  def doc(*, sync: invoked_sync?('doc'), **)
367
- build(@doc, sync: sync) if @doc
367
+ build(*as_a(@doc), sync: sync) if @doc
368
368
  end
369
369
 
370
370
  def test(*, sync: invoked_sync?('test'), **)
371
- build(@test, sync: sync) if @test
371
+ build(*as_a(@test), sync: sync) if @test
372
372
  end
373
373
 
374
374
  def clean(*)
@@ -376,21 +376,21 @@ module Squared
376
376
  when String
377
377
  run_s(@clean, sync: invoked_sync?('clean'))
378
378
  when Enumerable
379
- as_a(@clean).each do |val|
380
- if (val = val.to_s) =~ %r{[\\/]$}
381
- dir = Pathname.new(val)
382
- dir = basepath(dir) unless dir.absolute?
383
- next unless dir.directory?
384
-
385
- log.warn "rm -rf #{dir}"
386
- dir.rmtree
379
+ (@clean.is_a?(Hash) ? @clean.values : as_a(@clean)).each do |val|
380
+ val = val.to_s
381
+ path = basepath(val)
382
+ if path.directory? && val =~ %r{[\\/]$}
383
+ log&.warn "rm -rf #{path}"
384
+ path.rmtree
387
385
  else
388
- files = val.include?('*') ? Dir[basepath(val)] : [basepath(val)]
386
+ files = val.include?('*') ? Dir[path] : [path]
389
387
  files.each do |file|
388
+ next unless File.file?(file)
389
+
390
390
  begin
391
- File.delete(file) if File.file?(file)
391
+ File.delete(file)
392
392
  rescue StandardError => e
393
- log.error e
393
+ log&.error e
394
394
  end
395
395
  end
396
396
  end
@@ -440,7 +440,7 @@ module Squared
440
440
  instance_variable_set :"@#{key}", val.first
441
441
  end
442
442
  else
443
- log.warn "variable_set: @#{key} (private)"
443
+ log&.warn "variable_set: @#{key} (private)"
444
444
  end
445
445
  end
446
446
 
@@ -548,10 +548,10 @@ module Squared
548
548
 
549
549
  def run(cmd = @session, var = nil, exception: @exception, sync: true, banner: true, chdir: path, **)
550
550
  cmd = session_done(cmd)
551
- log.info cmd
551
+ log&.info cmd
552
552
  begin
553
553
  if cmd =~ /\A[^:]+:[^:]/ && workspace.task_defined?(cmd)
554
- log.warn "ENV was discarded: #{var}" if var
554
+ log&.warn "ENV was discarded: #{var}" if var
555
555
  task_invoke(cmd, exception: exception, warning: warning?)
556
556
  else
557
557
  print_item format_banner(cmd, banner: banner) if sync
@@ -559,7 +559,7 @@ module Squared
559
559
  shell(*args, chdir: chdir, exception: exception)
560
560
  end
561
561
  rescue StandardError => e
562
- log.error e
562
+ log&.error e
563
563
  raise
564
564
  end
565
565
  end
@@ -402,7 +402,7 @@ module Squared
402
402
  end
403
403
 
404
404
  def refs(flag, grep: nil)
405
- git_session 'ls-remote', " --#{flag}"
405
+ git_session 'ls-remote', "--#{flag}", '--refs'
406
406
  out, banner = source(io: true)
407
407
  print_item banner
408
408
  ret = write_lines(out, grep: grep)
@@ -410,7 +410,7 @@ module Squared
410
410
  end
411
411
 
412
412
  def files(flag, grep: nil)
413
- git_session 'ls-files', " --#{flag}"
413
+ git_session 'ls-files', "--#{flag}"
414
414
  out, banner = source(io: true)
415
415
  print_item banner
416
416
  ret = write_lines(out, grep: grep)
@@ -552,7 +552,7 @@ module Squared
552
552
  def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
553
553
  sub: nil)
554
554
  cmd = session_done(cmd)
555
- log.info cmd
555
+ log&.info cmd
556
556
  banner = format_banner(cmd.gsub(File.join(path, ''), ''), banner: banner)
557
557
  cmd = cmd.sub(/\Agit\b/, "git --work-tree=#{shell_quote(path)} --git-dir=#{shell_quote(gitpath)}")
558
558
  begin
@@ -586,7 +586,7 @@ module Squared
586
586
  end
587
587
  end
588
588
  rescue StandardError => e
589
- log.error e
589
+ log&.error e
590
590
  raise if exception
591
591
 
592
592
  warn log_message(Logger::WARN, e) if warning?
@@ -602,7 +602,7 @@ module Squared
602
602
  next if grep && !line.match?(grep)
603
603
 
604
604
  if loglevel
605
- log.add loglevel, line
605
+ log&.add loglevel, line
606
606
  else
607
607
  sub&.each { |h| line = sub_style(line, **h) }
608
608
  if banner
@@ -123,8 +123,8 @@ module Squared
123
123
  end
124
124
  end
125
125
 
126
- def copy(from: 'build', into: 'node_modules', workspace: false, include: nil, exclude: nil, scope: nil,
127
- also: nil, create: nil, override: false)
126
+ def copy(from: 'build', into: 'node_modules', workspace: false, scope: nil,
127
+ also: nil, create: nil, override: false, **kwargs)
128
128
  return if @copy == false
129
129
 
130
130
  if @copy && !override
@@ -138,6 +138,9 @@ module Squared
138
138
  scope = @copy[:scope]
139
139
  also = @copy[:also]
140
140
  create = @copy[:create]
141
+ else
142
+ glob = kwargs[:include]
143
+ exclude = kwargs[:exclude]
141
144
  end
142
145
  items = []
143
146
  items << @workspace.home if build? && path != @workspace.home && @workspace.home?
@@ -4,7 +4,7 @@ module Squared
4
4
  module Workspace
5
5
  module Project
6
6
  class Python < Git
7
- REQUIREMENTS = %w[requirements.txt pyproject.toml setup.py].freeze
7
+ REQUIREMENTS = %w[requirements.txt pyproject.toml].freeze
8
8
  OPT_USER = %w[pre dry-run].freeze
9
9
  OPT_FORCE = (OPT_USER + ['user']).freeze
10
10
  OPT_GENERAL = %w{venv isolated no-cache-dir [v]erbose}.freeze
@@ -29,7 +29,7 @@ module Squared
29
29
  def config?(val)
30
30
  return false unless (val = as_path(val))
31
31
 
32
- REQUIREMENTS.any? { |file| val.join(file).exist? }
32
+ (REQUIREMENTS + ['setup.py']).any? { |file| val.join(file).exist? }
33
33
  end
34
34
  end
35
35
 
@@ -98,32 +98,30 @@ module Squared
98
98
  if @depend && !flag
99
99
  super
100
100
  elsif outdated?
101
- case (type = dependtype)
102
- when 1, 2
103
- cmd = pip_session 'install'
104
- case flag
105
- when :user
106
- cmd << '--user'
107
- append_pip opts, OPT_USER
108
- when :target
109
- cmd << shell_option('target', basepath(dir), quote: true)
110
- append_pip opts, OPT_USER + ['upgrade']
111
- append_eager opts
112
- when :upgrade
113
- cmd << '--upgrade'
114
- append_pip opts, OPT_FORCE
115
- append_eager opts
116
- when :force
117
- cmd << '--force-reinstall'
118
- append_pip opts, OPT_FORCE
119
- else
120
- append_pip
121
- end
122
- cmd << (type == 1 ? '-r requirements.txt' : '.')
123
- run(sync: sync)
124
- when 3
125
- run_s('python setup.py install', sync: sync)
101
+ cmd = pip_session 'install'
102
+ case flag
103
+ when :user
104
+ cmd << '--user'
105
+ append_pip opts, OPT_USER
106
+ when :target
107
+ cmd << shell_option('target', basepath(dir), quote: true)
108
+ append_pip opts, OPT_USER + ['upgrade']
109
+ append_eager opts
110
+ when :upgrade
111
+ cmd << '--upgrade'
112
+ extra = []
113
+ append_pip(opts, OPT_FORCE, extra: extra)
114
+ append_eager opts
115
+ extra.delete('eager')
116
+ append_value(extra, delim: true)
117
+ when :force
118
+ cmd << '--force-reinstall'
119
+ append_pip opts, OPT_FORCE
120
+ else
121
+ append_pip
126
122
  end
123
+ cmd << (dependtype == 1 ? '-r requirements.txt' : '.') unless flag == :upgrade
124
+ run(sync: sync)
127
125
  end
128
126
  end
129
127
 
@@ -162,17 +160,19 @@ module Squared
162
160
  session('pip', *cmd)
163
161
  end
164
162
 
165
- def append_pip(opts = [], list = [])
163
+ def append_pip(opts = [], list = [], extra: nil)
166
164
  opts.each do |opt|
167
165
  data = nil
168
- next unless list.include?(opt) || OPT_GENERAL.include?(opt) || (data = opt.match(/^verbose|(v+)$/))
169
-
170
- @session << case opt
171
- when 'venv'
172
- '--require-virtualenv'
173
- else
174
- (data && data[1] ? "-#{data[1]}" : "--#{opt}")
175
- end
166
+ if list.include?(opt) || OPT_GENERAL.include?(opt) || (data = opt.match(/^verbose|(v+)$/))
167
+ @session << case opt
168
+ when 'venv'
169
+ '--require-virtualenv'
170
+ else
171
+ (data && data[1] ? "-#{data[1]}" : "--#{opt}")
172
+ end
173
+ elsif extra
174
+ extra << opt
175
+ end
176
176
  end
177
177
  val = nil
178
178
  @session << shell_option('proxy', val, quote: true) if (val = option('proxy'))
data/squared.gemspec CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "rake"
28
28
  spec.add_dependency "logger"
29
29
  spec.add_dependency "rexml"
30
+ spec.add_dependency "readline"
30
31
  end
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.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-02 00:00:00.000000000 Z
10
+ date: 2025-02-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: readline
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
54
68
  description: Rake task generator for managing multi-language workspaces.
55
69
  email:
56
70
  - anpham6@gmail.com