squared 0.5.2 → 0.5.4

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: 9600e055e98f7c95c616af1a848044cb945f64597d986cad88392523a7ffb737
4
- data.tar.gz: 255dc97b2d9738085a37fc336f43a6a835270d1ddcf28e9889712d077bc7f827
3
+ metadata.gz: 5f2dec97bece08fd8a158d8db320fbcb507e0e35c0d05802763616ed8c66a943
4
+ data.tar.gz: 5049853f41262335db8d2ff6c86f7c8b583e87ef868f18970f12e239aa40c58e
5
5
  SHA512:
6
- metadata.gz: 498761f07fcfe36010066c6e0e9c6487aaef3652214420c9d6012a61155980bc13475531416a4584641bd0a2ef909016e0f04d1224c991363050692c224f6798
7
- data.tar.gz: 3addf62ff638f20117db50cd40a13149490401f9b97a04f19ef2a6d6e02133eea763595ee1df8239933cc68db7e6725caa29de1cb1356b4fec93a38565ccbf7e
6
+ metadata.gz: 0aa7c2688ecaec61eb92d696dc4a10cd95de39799fad9a295561b33f933093335a7ddc5109ef56dab7b734a48505ef882c72d17a47e847f78fd312448a3210e0
7
+ data.tar.gz: 7f174f6e1ac139e4deaf97445660b4c021822d97ec74bc9997ce7932b02f88c6abc2b822f3b0b4f2213144c0aec66e9c6d52d40f0cff2d8ccaf7d36b091cf1e0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.4] - 2025-08-09
4
+
5
+ ### Changed
6
+
7
+ - Shellwords gem is no longer globally required.
8
+
9
+ ## [0.4.17] - 2025-08-09
10
+
11
+ ### Added
12
+
13
+ - Node repos can be initialized with specific package manager.
14
+ - Docker Engine options were updated to 28.0.
15
+ - Git commands pull and fetch action all was implemented.
16
+ - Git command reset action undo was implemented.
17
+ - Python command pip action upgrade was implemented.
18
+ - Git commands refs and files can use both pathspec and pattern.
19
+ - Git command submodule was implemented.
20
+ - Git command status was implemented.
21
+ - Git command switch action branch was implemented.
22
+
23
+ ### Changed
24
+
25
+ - Project task events can be assigned to a single proc.
26
+ - Ruby task copy uses require paths from gem specification.
27
+ - Docker task build:bake was renamed bake:build.
28
+ - Project global tasks can be hidden and still expose subtasks.
29
+ - Repo command line options can be overriden with class method.
30
+ - Repo task all variable REPO_DRYRUN was replaced with REPO_STAGE.
31
+ - Repo command sync option no-fail was renamed fail.
32
+
33
+ ### Fixed
34
+
35
+ - Gem command outdated did not work outside main project folder.
36
+ - Node command bump did not reset major and minor trailing digits.
37
+ - Docker image status message was displayed backwards.
38
+
39
+ ## [0.5.3] - 2025-07-27
40
+
41
+ ### Fixed
42
+
43
+ - See `0.4.16`.
44
+
45
+ ## [0.4.16] - 2025-07-27
46
+
47
+ ### Added
48
+
49
+ - Git command blame was implemented.
50
+ - Project property only for task filtering was implemented.
51
+ - Node command copy uses NPM pack to refresh development packages.
52
+ - Docker command bake action check was implemented.
53
+ - Ruby uses gem specification for name and version.
54
+ - Ruby constructor parameter gemspec was implemented.
55
+
56
+ ### Changed
57
+
58
+ - Project boolean property readers were converted into accessors.
59
+ - Workspace hash singleton methods were relocated under Support.
60
+ - Project property version uses setter method for validation.
61
+ - Node command publish will prompt when tag is not semantic.
62
+ - Gem command push without args uses gemspec to locate archive.
63
+ - Prompts will exit process without raising a generic error.
64
+
65
+ ### Fixed
66
+
67
+ - Gem command exec did not separate command and arguments.
68
+ - Project warning messages were not displayed for errors.
69
+ - Python command outdated did not load virtual env in Windows.
70
+ - Python virtual env original options are not modified.
71
+ - Node could not compare semantic versions above double digits.
72
+
3
73
  ## [0.5.2] - 2025-07-16
4
74
 
5
75
  ### Changed
@@ -874,9 +944,13 @@
874
944
 
875
945
  - Changelog was created.
876
946
 
947
+ [0.5.4]: https://github.com/anpham6/squared/releases/tag/v0.5.4-ruby
948
+ [0.5.3]: https://github.com/anpham6/squared/releases/tag/v0.5.3-ruby
877
949
  [0.5.2]: https://github.com/anpham6/squared/releases/tag/v0.5.2-ruby
878
950
  [0.5.1]: https://github.com/anpham6/squared/releases/tag/v0.5.1-ruby
879
951
  [0.5.0]: https://github.com/anpham6/squared/releases/tag/v0.5.0-ruby
952
+ [0.4.17]: https://github.com/anpham6/squared/releases/tag/v0.4.17-ruby
953
+ [0.4.16]: https://github.com/anpham6/squared/releases/tag/v0.4.16-ruby
880
954
  [0.4.15]: https://github.com/anpham6/squared/releases/tag/v0.4.15-ruby
881
955
  [0.4.14]: https://github.com/anpham6/squared/releases/tag/v0.4.14-ruby
882
956
  [0.4.13]: https://github.com/anpham6/squared/releases/tag/v0.4.13-ruby
data/README.ruby.md CHANGED
@@ -66,6 +66,7 @@ require "squared/app" # All workspace related mod
66
66
  # log = /workspaces/logger
67
67
  # emc = /workspaces/e-mc
68
68
  # pir = /workspaces/pi-r
69
+ # pir2 = /workspaces/pi-r2
69
70
  # squared = /workspaces/squared
70
71
  # cli = /workspaces/squared/publish/sqd-cli
71
72
  # sqd-serve = /workspaces/squared/publish/sqd-serve
@@ -83,11 +84,12 @@ Workspace::Application
83
84
  .add("pathname", run: "rake compile", copy: "rake install", test: "rake test", group: "default", env: { # Ruby (with C extensions)
84
85
  "CFLAGS" => "-fPIC -O1"
85
86
  })
86
- .add("optparse", doc: "rake rdoc", group: "default") # Uses bundler/gem_tasks (without C extensions)
87
+ .add("optparse", doc: "rake rdoc", gemspec: "optparse.gemspec", group: "default") # Uses bundler/gem_tasks (without C extensions)
87
88
  .add("logger", copy: { from: "lib", glob: "**/*.rb", into: "~/.rvm/gems/ruby-3.4.0/gems/logger-1.6.1" }, clean: ["tmp/"]) # autodetect: true | "rvm" | "rbenv" | "asdf" | "bundler"
88
89
  .add("e-mc", "emc", copy: { from: "publish", scope: "@e-mc", also: [:pir, "squared-express/"] }, ref: :node) # Node
89
90
  .add("pi-r", "pir", copy: { from: "publish", scope: "@pi-r" }, clean: ["publish/**/*.js", "tmp/"]) # Trailing slash required for directories
90
- .add("squared", script: ["build:stage1", "build:stage2"], group: "app") do # Copy target (main)
91
+ .add("pi-r2", "pir2", copy: { from: :npm, also: %i[squared express], files: ["LICENSE", ["README.md.ruby", "README.md"]] }) # Uses dist files from NPM package spec
92
+ .add("squared", init: 'pnpm', script: ["build:stage1", "build:stage2"], group: "app") do # Use pnpm/yarn/berry for depend + Copy target (main)
91
93
  # Repo (global)
92
94
  as(:run, "build:dev", "dev") # npm run build:dev -> npm run dev
93
95
  as(:run, { "build:dev": "dev", "build:prod": "prod" })
@@ -108,7 +110,7 @@ Workspace::Application
108
110
  variable_set :depend, false
109
111
  variable_set :clean, ["build/sqd/"]
110
112
  end
111
- .with(:docker, pass: ["unpack"]) do
113
+ .with(:docker, only: ["build", "compose"]) do
112
114
  .add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", registry: "localhost:5000", username: "squared",
113
115
  args: "--ssh=default",
114
116
  secrets: ["id=github,env=GITHUB_TOKEN"],
@@ -498,11 +500,11 @@ Most project classes will inherit from `Git` which enables these tasks:
498
500
  | checkout | checkout | commit branch track detach path |
499
501
  | commit | commit | add all amend amend-orig fixup |
500
502
  | diff | diff | head cached branch files between contain |
501
- | fetch | fetch | origin remote |
503
+ | fetch | fetch | origin remote all |
502
504
  | files | ls-files | cached modified deleted others |
503
- | git | | add clean mv rm revert |
505
+ | git | | add blame clean mv rm revert |
504
506
  | merge | merge | commit no-commit send |
505
- | pull | pull | origin remote |
507
+ | pull | pull | origin remote all |
506
508
  | rebase | rebase | branch onto send |
507
509
  | refs | ls-remote --refs | heads tags remote |
508
510
  | reset | reset | commit index patch mode |
@@ -510,7 +512,7 @@ Most project classes will inherit from `Git` which enables these tasks:
510
512
  | rev | rev | commit output |
511
513
  | show | show | format oneline |
512
514
  | stash | stash | push pop apply branch drop clear list |
513
- | switch | switch | create detach merge |
515
+ | switch | switch | branch create detach |
514
516
  | tag | tag | add sign delete list |
515
517
 
516
518
  You can disable all of them at once using the `exclude` property.
@@ -623,6 +625,8 @@ LOG_LEVEL # See gem "logger"
623
625
 
624
626
  ### Git
625
627
 
628
+ * Version: 2.50
629
+
626
630
  ```sh
627
631
  GIT_OPTIONS=q,strategy=ort # all
628
632
  GIT_OPTIONS_${NAME}=v,ff # project only
@@ -632,15 +636,15 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
632
636
 
633
637
  | Command | Flag | ENV |
634
638
  | :--------- | :---------------- | :-------------------------------------------------------------------- |
635
- | branch | create | TRACK=0,1,s FORCE |
636
- | branch | move copy | FORCE |
639
+ | branch | create | TRACK=0,1,s F|FORCE |
640
+ | branch | move copy | F|FORCE |
637
641
  | branch | set delete | COUNT=n |
638
642
  | branch | global | SYNC |
639
643
  | checkout | branch | DETACH TRACK=s COUNT=n |
640
644
  | checkout | detach | REFLOG=1 |
641
645
  | checkout | track | COUNT=n |
642
646
  | checkout | global path | HEAD=s PATHSPEC=s |
643
- | checkout | * | FORCE MERGE |
647
+ | checkout | * | F|FORCE MERGE |
644
648
  | clone | * | DEPTH=n ORIGIN=s BRANCH=s REVISION=s LOCAL=0,1 |
645
649
  | commit | * | UPSTREAM=s DRY_RUN EDIT=0 M|MESSAGE=s |
646
650
  | diff | -between -contain | MERGE_BASE |
@@ -648,13 +652,13 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
648
652
  | diff | * | PATHSPEC=s |
649
653
  | fetch | -remote | ALL |
650
654
  | fetch | remote | REFSPEC=s |
651
- | fetch | * | FORCE RECURSE_SUBMODULES=0,1,s |
655
+ | fetch | * | F|FORCE RECURSE_SUBMODULES=0,1,s |
652
656
  | git | rm | PATHSPEC=s |
653
657
  | log | * | PATHSPEC=s |
654
658
  | pull | rebase | AUTOSTASH |
655
659
  | pull | remote | REFSPEC=s |
656
660
  | pull | -remote | ALL |
657
- | pull | * | REBASE=0,1 FORCE RECURSE_SUBMODULES=0,1,s |
661
+ | pull | * | REBASE=0,1 F|FORCE RECURSE_SUBMODULES=0,1,s |
658
662
  | rebase | branch | HEAD=s |
659
663
  | rebase | onto | INTERACTIVE I HEAD=s |
660
664
  | reset | mode (mixed) | N REFRESH=0 |
@@ -668,14 +672,16 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
668
672
  | status | global | BRANCH LONG IGNORE_SUBMODULES=s,0-3 PATHSPEC=s |
669
673
  | switch | detach | REFLOG=1 |
670
674
  | switch | -detach | HEAD=s |
671
- | switch | * | FORCE |
675
+ | switch | * | F|FORCE |
672
676
  | tag | add | SIGN FORCE HEAD=s M|MESSAGE=s |
673
- | tag | sign | FORCE HEAD=s M|MESSAGE=s |
677
+ | tag | sign | F|FORCE HEAD=s M|MESSAGE=s |
674
678
  | tag | delete | COUNT=n |
675
679
  | rev | commit branch | HEAD=s |
676
680
 
677
681
  ### Docker
678
682
 
683
+ * Version: 28.3
684
+
679
685
  ```sh
680
686
  DOCKER_OPTIONS=q,no-cache # all
681
687
  DOCKER_OPTIONS_${NAME}=v,no-cache=false # project only (override)
@@ -713,7 +719,7 @@ REPO_WARN # 0,1
713
719
  REPO_SYNC # 0,1
714
720
  REPO_URL # manifest repository
715
721
  REPO_MANIFEST # e.g. latest,nightly,prod
716
- REPO_DRYRUN # 0,1,2
722
+ REPO_STAGE # 0,1,2,3
717
723
  REPO_TIMEOUT # confirm dialog (seconds)
718
724
  ```
719
725
 
@@ -124,7 +124,7 @@ module Squared
124
124
  def check_style(args, empty: true)
125
125
  ret = []
126
126
  colors = __get__(:colors)
127
- as_a(args, flat: true, compact: true).each do |val|
127
+ Array(args).flatten.compact.each do |val|
128
128
  if !val.is_a?(::Numeric)
129
129
  val = val.to_sym
130
130
  ret << val if colors.key?(val) || TEXT_STYLE.include?(val)
@@ -135,7 +135,9 @@ module Squared
135
135
  ret << "-0.#{b}".to_f unless b.to_i > 255
136
136
  end
137
137
  end
138
- ret if empty || !ret.empty?
138
+ return if ret.empty? && !empty
139
+
140
+ ret
139
141
  end
140
142
 
141
143
  def apply_style(data, key, args, empty: true)
@@ -222,7 +224,7 @@ module Squared
222
224
  n = 0
223
225
  max = ->(v) { n = [n, v.max_by(&:size).size].max }
224
226
  set = lambda do |v|
225
- ret = as_a(v, :to_s)
227
+ ret = Array(v).map(&:to_s)
226
228
  max.call(ret)
227
229
  ret
228
230
  end
@@ -246,7 +248,7 @@ module Squared
246
248
  ret = sub_style(ret, styles: border) if border
247
249
  ret
248
250
  end
249
- sub = as_a sub
251
+ sub = sub.is_a?(::Hash) ? [sub] : Array(sub)
250
252
  pr = lambda do |line|
251
253
  s = line.ljust(n)
252
254
  sub.each { |h| s = sub_style(s, **h) }
@@ -90,9 +90,9 @@ module Squared
90
90
  end
91
91
  attempts -= 1
92
92
  next if attempts > 0
93
- break unless force
94
93
 
95
- exit 1
94
+ exit 1 if force
95
+ break
96
96
  end
97
97
  rescue Interrupt
98
98
  puts
@@ -125,7 +125,7 @@ module Squared
125
125
  end
126
126
  ret = (prompt.call || '').strip
127
127
  multiline.each { |val| break if ret.delete_suffix!(val) } if multiline.is_a?(::Enumerable)
128
- raise_error 'user cancelled' if force && ret.empty?
128
+ exit 1 if force && ret.empty?
129
129
  ret
130
130
  else
131
131
  prompt.call
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'shellwords'
4
3
  require 'rake'
5
4
 
6
5
  module Squared
@@ -31,13 +30,19 @@ module Squared
31
30
 
32
31
  "#{$1}=%s" % if $2.include?(' ')
33
32
  shell_quote($2, option: false)
33
+ elsif Rake::Win32.windows?
34
+ $2
34
35
  else
35
- Rake::Win32.windows? ? $2 : Shellwords.escape($2)
36
+ require 'shellwords'
37
+ Shellwords.escape($2)
36
38
  end
37
39
  elsif Rake::Win32.windows?
38
40
  quote ? shell_quote(val, double: double, force: force) : val
41
+ elsif val.empty?
42
+ ''
39
43
  else
40
- val.empty? ? '' : Shellwords.escape(val)
44
+ require 'shellwords'
45
+ Shellwords.escape(val)
41
46
  end
42
47
  end
43
48
 
@@ -86,8 +91,7 @@ module Squared
86
91
  end
87
92
 
88
93
  def shell_split(val, join: nil, **kwargs)
89
- ret = val.shellsplit
90
- ret.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
94
+ ret = val.shellsplit.map! { |opt| shell_escape(opt, double: true, option: true, **kwargs) }
91
95
  return ret unless join
92
96
 
93
97
  ret.join(join.is_a?(::String) ? join : ' ')
@@ -12,9 +12,9 @@ module Squared
12
12
  if RUBY_ENGINE == 'jruby' && Rake::Win32.windows?
13
13
  e = kwargs[:exception]
14
14
  if (dir = kwargs[:chdir]) && ((pwd = Dir.pwd) != dir)
15
- Dir.chdir(dir)
15
+ Dir.chdir dir
16
16
  ret = Kernel.send(name, *args)
17
- Dir.chdir(pwd)
17
+ Dir.chdir pwd
18
18
  else
19
19
  ret = Kernel.send(name, *args)
20
20
  end
@@ -59,7 +59,7 @@ module Squared
59
59
  soft = 0
60
60
  subdir.each do |dir, files|
61
61
  if link
62
- files.dup.yield_self do |items|
62
+ files.dup.tap do |items|
63
63
  files.clear
64
64
  items.each do |file|
65
65
  if file.exist?
@@ -93,6 +93,15 @@ module Squared
93
93
  Time.now.utc.strftime(s).to_i - Time.parse(val).utc.strftime(s).to_i
94
94
  end
95
95
 
96
+ def rand_s(size)
97
+ if RUBY_VERSION >= '3.1'
98
+ require 'random/formatter'
99
+ Random.new.alphanumeric(size)
100
+ else
101
+ (0...size).map { rand(97..122).chr }.join
102
+ end
103
+ end
104
+
96
105
  def env(key, default = nil, suffix: nil, strict: false, equals: nil, ignore: nil)
97
106
  ret = env_value(key, suffix: suffix, strict: strict)
98
107
  return ret == equals.to_s unless equals.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.4'
5
5
  end
@@ -26,7 +26,7 @@ module Squared
26
26
  next unless base || obj < impl_project
27
27
 
28
28
  if base
29
- @impl_project = obj
29
+ self.impl_project = obj
30
30
  impl_series.base_set(obj)
31
31
  else
32
32
  kind_project.prepend(obj)
@@ -39,7 +39,7 @@ module Squared
39
39
  impl_series.alias(*args)
40
40
  end
41
41
  if (args = obj.bannerargs)
42
- @attr_banner.merge(args)
42
+ attr_banner.merge(args)
43
43
  end
44
44
  end
45
45
  end
@@ -83,7 +83,7 @@ module Squared
83
83
  basename = @home.basename.to_s
84
84
  if main
85
85
  @main = main.to_s.freeze
86
- @home += @main unless @main == basename || (windows? && @main.downcase == basename.downcase)
86
+ @home += @main unless @main == basename || (windows? && @main.casecmp?(basename))
87
87
  else
88
88
  @main = basename.freeze
89
89
  end
@@ -92,7 +92,7 @@ module Squared
92
92
  @prefix = prefix
93
93
  @series = Application.series_wrap(self)
94
94
  @project = {}
95
- @kind = Workspace.hashlist
95
+ @kind = Support.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 = Workspace.hashlist
109
+ @chain = Support.hashlist
110
110
  @script = {
111
- group: Workspace.hashobj,
112
- ref: Workspace.hashobj,
111
+ group: Support.hashobj,
112
+ ref: Support.hashobj,
113
113
  group!: {},
114
114
  ref!: {}
115
115
  }.freeze
116
116
  @events = {
117
- group: Workspace.hashobj,
118
- ref: Workspace.hashobj
117
+ group: Support.hashobj,
118
+ ref: Support.hashobj
119
119
  }.freeze
120
120
  @pass = {
121
- group: Workspace.hashobj,
122
- ref: Workspace.hashobj,
121
+ group: Support.hashobj,
122
+ ref: Support.hashobj,
123
123
  global: {},
124
124
  pattern: []
125
125
  }.freeze
@@ -625,12 +625,16 @@ module Squared
625
625
  Rake::Win32.windows?
626
626
  end
627
627
 
628
+ def mri?
629
+ RUBY_ENGINE == 'ruby'
630
+ end
631
+
628
632
  def jruby?
629
633
  RUBY_ENGINE == 'jruby'
630
634
  end
631
635
 
632
- def jruby_win?
633
- jruby? && windows?
636
+ def truffleruby?
637
+ RUBY_ENGINE == 'truffleruby'
634
638
  end
635
639
 
636
640
  def docker?
@@ -682,9 +686,14 @@ module Squared
682
686
  private
683
687
 
684
688
  def __build__(default: nil, **)
685
- return unless default && task_defined?(out = task_name(default))
686
-
687
- task Rake.application.default_task_name => out
689
+ unless task_defined?('squared:version')
690
+ task 'squared:version' do
691
+ puts Squared::VERSION
692
+ end
693
+ end
694
+ if default && task_defined?(out = task_name(default))
695
+ task Rake.application.default_task_name => out
696
+ end
688
697
  end
689
698
 
690
699
  def __chain__(*)