squared 0.4.1 → 0.4.3
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 +4 -4
- data/CHANGELOG.md +27 -0
- data/README.ruby.md +1 -0
- data/lib/squared/common/base.rb +2 -1
- data/lib/squared/common/format.rb +1 -1
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/project/base.rb +1 -1
- data/lib/squared/workspace/project/docker.rb +19 -15
- data/lib/squared/workspace/project/git.rb +24 -11
- data/lib/squared/workspace/project/python.rb +62 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e853dbba49cb1383e99d6d2c1cc7a4dbe9a62a3c3af22eefdb1980cb4d541a59
|
4
|
+
data.tar.gz: 7beece13d36c4f8269c4172f94e83f0237c122bd582a78c47b4085ca3e337bbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc95be4880369baca382127c313baf9e561ce5b44ec9bcaa2069226e2774350ae037b22b1f0b1a4fe3b11efd3ac4e109154e0d78ee50b07ebfc2949ffdebfc9
|
7
|
+
data.tar.gz: 56380157773696be7f6430259d4f6d63e3ef3b198abdea4d7433419252c742d10b50c6b3374c824acfce130ef06f30e13b4f045f89d2c7528d47738a1ca9e670
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.4.3] - 2025-04-01
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Git global command branch shows ahead and behind values.
|
8
|
+
- Workspace theme style label warn was created.
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Git and Docker did not order common options first.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
|
16
|
+
- Git commit amend uses flag --force-with-lease.
|
17
|
+
|
18
|
+
## [0.4.2] - 2025-03-28
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Python command build and publish with Poetry was implemented.
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Docker image command list did not display ID when empty.
|
27
|
+
|
3
28
|
## [0.4.1] - 2025-03-20
|
4
29
|
|
5
30
|
### Added
|
@@ -380,6 +405,8 @@
|
|
380
405
|
|
381
406
|
- Changelog was created.
|
382
407
|
|
408
|
+
[0.4.3]: https://github.com/anpham6/squared/releases/tag/v0.4.3-ruby
|
409
|
+
[0.4.2]: https://github.com/anpham6/squared/releases/tag/v0.4.2-ruby
|
383
410
|
[0.4.1]: https://github.com/anpham6/squared/releases/tag/v0.4.1-ruby
|
384
411
|
[0.4.0]: https://github.com/anpham6/squared/releases/tag/v0.4.0-ruby
|
385
412
|
[0.3.6]: https://github.com/anpham6/squared/releases/tag/v0.3.6-ruby
|
data/README.ruby.md
CHANGED
data/lib/squared/common/base.rb
CHANGED
@@ -231,7 +231,7 @@ module Squared
|
|
231
231
|
if val.is_a?(::Array)
|
232
232
|
lines = val.map(&:to_s)
|
233
233
|
else
|
234
|
-
lines = val.to_s.lines
|
234
|
+
lines = val.to_s.lines(chomp: true)
|
235
235
|
lines[0] = "#{val.class}: #{lines.first}" if (err = val.is_a?(StandardError))
|
236
236
|
end
|
237
237
|
n = cols || max.(lines)
|
data/lib/squared/version.rb
CHANGED
@@ -639,7 +639,7 @@ module Squared
|
|
639
639
|
|
640
640
|
dest = target.join(File.basename(file.path))
|
641
641
|
FileUtils.mv(entry, dest)
|
642
|
-
dest.children.each { |
|
642
|
+
dest.children.each { |child| FileUtils.mv(child, target) }
|
643
643
|
dest.rmdir
|
644
644
|
target = entry
|
645
645
|
depth -= 1
|
@@ -400,8 +400,8 @@ module Squared
|
|
400
400
|
status = %w[created exited dead]
|
401
401
|
end
|
402
402
|
ps.merge(status.map { |s| "--filter=\"status=#{s}\"" })
|
403
|
-
list_image(flag, ps, no: no, hint: "status: #{status.join(', ')}", from: from) do |
|
404
|
-
run(cmd.temp(
|
403
|
+
list_image(flag, ps, no: no, hint: "status: #{status.join(', ')}", from: from) do |img|
|
404
|
+
run(cmd.temp(img), from: from)
|
405
405
|
end
|
406
406
|
return
|
407
407
|
else
|
@@ -426,9 +426,8 @@ module Squared
|
|
426
426
|
break
|
427
427
|
end
|
428
428
|
end
|
429
|
-
flag = :run if flag == :list
|
430
429
|
list_image(flag, cmd << '-a', from: from) do |val|
|
431
|
-
container(
|
430
|
+
container(:run, if name
|
432
431
|
opts.dup << "name=#{index == 0 ? name : "#{name}-#{index}"}"
|
433
432
|
else
|
434
433
|
opts
|
@@ -493,11 +492,14 @@ module Squared
|
|
493
492
|
private
|
494
493
|
|
495
494
|
def docker_session(*cmd, opts: nil)
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
495
|
+
if opts
|
496
|
+
out = []
|
497
|
+
opts = option_sanitize(opts, OPT_DOCKER[:common], target: out).first
|
498
|
+
ret = session('docker', *out, *cmd)
|
499
|
+
[ret, opts]
|
500
|
+
else
|
501
|
+
session('docker', *cmd)
|
502
|
+
end
|
501
503
|
end
|
502
504
|
|
503
505
|
def docker_output(*cmd, **kwargs)
|
@@ -528,20 +530,22 @@ module Squared
|
|
528
530
|
found = false
|
529
531
|
IO.popen(session_done(cmd << '--format=json')).each_with_index do |line, index|
|
530
532
|
data = JSON.parse(line)
|
533
|
+
id = data['ID']
|
531
534
|
rt = [data['Repository'], data['Tag']].reject { |val| val == '<none>' }.join(':')
|
532
|
-
rt = nil if
|
535
|
+
rt = nil if rt.empty?
|
533
536
|
aa = if data['Names']
|
534
537
|
as_a(data['Names']).join(', ')
|
535
|
-
elsif
|
538
|
+
elsif rt
|
536
539
|
dd = true
|
537
540
|
data['Repository']
|
538
541
|
else
|
539
|
-
|
542
|
+
id
|
540
543
|
end
|
541
544
|
bb = index.succ.to_s
|
542
545
|
cc = bb.size + 1
|
543
|
-
|
544
|
-
|
546
|
+
ee = data['Image'] || rt || aa
|
547
|
+
a = sub_style(ee, styles: theme[:inline])
|
548
|
+
b = "Execute #{sub_style(flag, styles: theme[:active])} on #{a}#{ee == id ? '' : " (#{id})"}"
|
545
549
|
c, d = no ? ['y/N', 'N'] : ['Y/n', 'Y']
|
546
550
|
e = time_format(time_offset(data['CreatedAt']), pass: ['ms'])
|
547
551
|
f = sub_style(ARG[:BORDER][0], styles: theme[:inline])
|
@@ -560,7 +564,7 @@ module Squared
|
|
560
564
|
next unless confirm("#{h + b}? [#{c}] ", d, timeout: 60)
|
561
565
|
|
562
566
|
puts if @@print_order == 0
|
563
|
-
blk.call
|
567
|
+
blk.call id
|
564
568
|
end
|
565
569
|
puts log_message(Logger::INFO, 'none detected', subject: "#{name}:#{from}", hint: hint) unless found
|
566
570
|
end
|
@@ -698,7 +698,9 @@ module Squared
|
|
698
698
|
|
699
699
|
def pull(flag = nil, opts = [], sync: invoked_sync?('pull', flag), remote: nil)
|
700
700
|
cmd, opts = git_session('pull', flag && "--#{flag}", opts: opts)
|
701
|
-
if
|
701
|
+
if flag == :rebase
|
702
|
+
cmd << '--autostash' if option('autostash')
|
703
|
+
elsif (val = option('rebase', ignore: false))
|
702
704
|
cmd << case val
|
703
705
|
when '0'
|
704
706
|
'--no-rebase'
|
@@ -1080,10 +1082,10 @@ module Squared
|
|
1080
1082
|
unless (origin = option('repository', prefix: 'git', ignore: false))
|
1081
1083
|
out = source(git_output('log -n1 --format=%h%d'), io: true, banner: false, stdout: true).first
|
1082
1084
|
if out =~ /^#{r[2]} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/
|
1083
|
-
split_escape($1).each do |
|
1084
|
-
next unless
|
1085
|
+
split_escape($1).each do |s|
|
1086
|
+
next unless s.end_with?("/#{branch}")
|
1085
1087
|
|
1086
|
-
origin =
|
1088
|
+
origin = s[0, s.size - branch.size - 1]
|
1087
1089
|
break
|
1088
1090
|
end
|
1089
1091
|
end
|
@@ -1111,7 +1113,7 @@ module Squared
|
|
1111
1113
|
b << '--dry-run'
|
1112
1114
|
end
|
1113
1115
|
a << pathspec
|
1114
|
-
b << '--force' if amend
|
1116
|
+
b << '--force-with-lease' if amend
|
1115
1117
|
b << origin << branch
|
1116
1118
|
puts if pass
|
1117
1119
|
source a
|
@@ -1215,7 +1217,16 @@ module Squared
|
|
1215
1217
|
a = sub_style(data[0], styles: theme[:inline])
|
1216
1218
|
b = sub_style(data[1], styles: theme[:extra])
|
1217
1219
|
r = /\A(?:\[(.+?)(?=\]\s)\]\s)?(.+)\z/m.match(data[2..-1].join(' '))
|
1218
|
-
|
1220
|
+
if (r1 = r[1]) && r1 =~ /^(.+):(?: ([a-z]+) (\d+),)? ([a-z]+) (\d+)$/
|
1221
|
+
write = ->(s1, s2) { "#{s1.capitalize.rjust(7)}: #{sub_style(s2, styles: theme[:warn])}" }
|
1222
|
+
r1 = $1
|
1223
|
+
r2 = $2 && write.($2, $3)
|
1224
|
+
r3 = write.($4, $5)
|
1225
|
+
end
|
1226
|
+
r1 = nil if r1 == "origin/#{data[0]}"
|
1227
|
+
[" Branch: #{a + (r1 ? " (#{r1})" : '')}", r2, r3, " Commit: #{b}", "Message: #{r[2]}"]
|
1228
|
+
.compact
|
1229
|
+
.join("\n")
|
1219
1230
|
end
|
1220
1231
|
on :last, from
|
1221
1232
|
end
|
@@ -1577,11 +1588,13 @@ module Squared
|
|
1577
1588
|
|
1578
1589
|
def git_session(*cmd, opts: nil, worktree: true, **kwargs)
|
1579
1590
|
dir = worktree ? ["--work-tree=#{shell_quote(path)}", "--git-dir=#{shell_quote(gitpath)}"] : []
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1591
|
+
if opts
|
1592
|
+
opts = option_sanitize(opts, OPT_GIT[:common], target: dir).first
|
1593
|
+
ret = session('git', *dir, *cmd, **kwargs)
|
1594
|
+
[ret, opts]
|
1595
|
+
else
|
1596
|
+
session('git', *dir, *cmd, **kwargs)
|
1597
|
+
end
|
1585
1598
|
end
|
1586
1599
|
|
1587
1600
|
def git_output(*cmd, **kwargs)
|
@@ -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.cfg].freeze
|
7
|
+
REQUIREMENTS = %w[requirements.txt pyproject.toml setup.cfg poetry.lock].freeze
|
8
8
|
SETUPTOOLS = %w[setup.py pyproject.toml].freeze
|
9
9
|
DIR_PYTHON = (REQUIREMENTS + SETUPTOOLS).freeze
|
10
10
|
OPT_PYTHON = {
|
@@ -24,6 +24,12 @@ module Squared
|
|
24
24
|
python-version=q report=p r|requirement=p root=p root-user-action=b src=p t|target=p
|
25
25
|
upgrade-strategy=b].freeze
|
26
26
|
}.freeze
|
27
|
+
OPT_POETRY = {
|
28
|
+
common: %w[ansi no-ansi no-cache n|no-interaction no-plugins P|project=p q|quiet v|verbose].freeze,
|
29
|
+
build: %w[clean config-settings=qq f|format=b o|output=p].freeze,
|
30
|
+
publish: %w[build dry-run client-cert=p cert=p dist-dir=p p|password=b r|repository=b skip-existing
|
31
|
+
u|username=b].freeze
|
32
|
+
}.freeze
|
27
33
|
OPT_HATCH = {
|
28
34
|
common: %w[color interactive no-color no-interactive cache-dir=p config=p data-dir=p e|env=b p|project=e
|
29
35
|
q|quiet v|verbose].freeze,
|
@@ -36,7 +42,8 @@ module Squared
|
|
36
42
|
config-file=p cert=p client-cert=p i|identity=b p|password=q r|repository=b repository-url=q
|
37
43
|
sign-with=b u|username=q].freeze
|
38
44
|
}.freeze
|
39
|
-
private_constant :REQUIREMENTS, :SETUPTOOLS, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :
|
45
|
+
private_constant :REQUIREMENTS, :SETUPTOOLS, :DIR_PYTHON, :OPT_PYTHON, :OPT_PIP, :OPT_POETRY, :OPT_HATCH,
|
46
|
+
:OPT_TWINE
|
40
47
|
|
41
48
|
class << self
|
42
49
|
def populate(*); end
|
@@ -75,8 +82,8 @@ module Squared
|
|
75
82
|
|
76
83
|
@@tasks[ref] = {
|
77
84
|
'install' => %i[user force upgrade target editable].freeze,
|
78
|
-
'build' => %i[python hatch].freeze,
|
79
|
-
'publish' => %i[twine hatch].freeze
|
85
|
+
'build' => %i[python poetry hatch].freeze,
|
86
|
+
'publish' => %i[poetry twine hatch].freeze
|
80
87
|
}.freeze
|
81
88
|
|
82
89
|
def ref
|
@@ -130,12 +137,22 @@ module Squared
|
|
130
137
|
end
|
131
138
|
end
|
132
139
|
when 'build'
|
133
|
-
format_desc(action, flag, 'opts*', after: flag
|
140
|
+
format_desc(action, flag, 'opts*', after: case flag
|
141
|
+
when :python
|
142
|
+
'srcdir?'
|
143
|
+
when :hatch
|
144
|
+
'location?'
|
145
|
+
end)
|
134
146
|
task flag do |_, args|
|
135
147
|
buildx flag, args.to_a
|
136
148
|
end
|
137
149
|
when 'publish'
|
138
|
-
format_desc(action, flag, 'opts*', after: flag
|
150
|
+
format_desc(action, flag, 'opts*', after: case flag
|
151
|
+
when :hatch
|
152
|
+
'artifacts?'
|
153
|
+
when :twine
|
154
|
+
'dist?'
|
155
|
+
end)
|
139
156
|
task flag do |_, args|
|
140
157
|
publish flag, args.to_a
|
141
158
|
end
|
@@ -151,22 +168,27 @@ module Squared
|
|
151
168
|
super
|
152
169
|
elsif outdated?
|
153
170
|
workspace.rev_clear name
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
cmd << "--#{flag}"
|
158
|
-
when :target
|
159
|
-
cmd << quote_option('target', basepath(target))
|
160
|
-
when :force
|
161
|
-
cmd << '--force-reinstall'
|
171
|
+
if !flag && dependtype == 4
|
172
|
+
cmd = session 'poetry', 'install'
|
173
|
+
cmd << '--no-root' if option('no-root')
|
162
174
|
else
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
175
|
+
cmd = pip_session 'install'
|
176
|
+
case flag
|
177
|
+
when :user
|
178
|
+
cmd << "--#{flag}"
|
179
|
+
when :target
|
180
|
+
cmd << quote_option('target', basepath(target))
|
181
|
+
when :force
|
182
|
+
cmd << '--force-reinstall'
|
183
|
+
else
|
184
|
+
append_global
|
185
|
+
end
|
186
|
+
append_pip(flag, opts, from: :install) if flag
|
187
|
+
if dependtype == 1 && !session_arg?('e', 'editable')
|
188
|
+
cmd << '-r requirements.txt' unless session_arg?('r', 'requirement')
|
189
|
+
elsif !session_arg?('e', 'editable', value: true)
|
190
|
+
cmd << '.'
|
191
|
+
end
|
170
192
|
end
|
171
193
|
run(from: :depend, sync: sync)
|
172
194
|
end
|
@@ -268,6 +290,9 @@ module Squared
|
|
268
290
|
when :python
|
269
291
|
cmd << shell_option('m', 'build')
|
270
292
|
list = OPT_PYTHON[:build] + OPT_PYTHON[:common]
|
293
|
+
when :poetry
|
294
|
+
cmd << 'build'
|
295
|
+
list = OPT_POETRY[:build] + OPT_POETRY[:common]
|
271
296
|
when :hatch
|
272
297
|
cmd << 'build'
|
273
298
|
list = OPT_HATCH[:build] + OPT_HATCH[:common]
|
@@ -281,7 +306,17 @@ module Squared
|
|
281
306
|
out << opt
|
282
307
|
end
|
283
308
|
end
|
284
|
-
|
309
|
+
case flag
|
310
|
+
when :poetry
|
311
|
+
if srcdir
|
312
|
+
if session_arg?('o', 'output')
|
313
|
+
out << srcdir
|
314
|
+
else
|
315
|
+
cmd << quote_option('output', basepath(srcdir))
|
316
|
+
end
|
317
|
+
srcdir = nil
|
318
|
+
end
|
319
|
+
when :hatch
|
285
320
|
if ENV['HATCH_BUILD_LOCATION']
|
286
321
|
srcdir = nil
|
287
322
|
else
|
@@ -298,6 +333,9 @@ module Squared
|
|
298
333
|
cmd = session flag
|
299
334
|
out = []
|
300
335
|
case flag
|
336
|
+
when :poetry
|
337
|
+
cmd << 'publish'
|
338
|
+
list = OPT_POETRY[:publish] + OPT_POETRY[:common]
|
301
339
|
when :twine
|
302
340
|
cmd << 'upload'
|
303
341
|
list = OPT_TWINE[:publish]
|
@@ -306,7 +344,7 @@ module Squared
|
|
306
344
|
list = OPT_HATCH[:publish] + OPT_HATCH[:common]
|
307
345
|
end
|
308
346
|
option_sanitize(opts, list).first.each do |opt|
|
309
|
-
if flag
|
347
|
+
if flag != :twine && opt =~ /^(v+|q+)$/
|
310
348
|
cmd << "-#{$1}"
|
311
349
|
else
|
312
350
|
out << opt
|
@@ -315,7 +353,7 @@ module Squared
|
|
315
353
|
if out.empty?
|
316
354
|
dist = basepath.join('dist')
|
317
355
|
raise_error('no source files given', hint: dist) unless dist.directory? && !dist.empty?
|
318
|
-
out << "#{dist}/*"
|
356
|
+
out << "#{dist}/*" unless flag == :poetry
|
319
357
|
end
|
320
358
|
append_value out
|
321
359
|
run(from: :"#{flag}:publish")
|
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.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- An Pham
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rake
|