rexer 0.9.0 → 0.10.0

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: 8718806ffc0a827890d574a6396e88904059b58b5087b6ac09740da7bd39be42
4
- data.tar.gz: b651388f82e418b597bbdf59016bf5a392b86593a462db1248eee5e6c101239f
3
+ metadata.gz: 35c79e74d0ffb8e149f5d608a67bd6c9fa709bb5da7d4442e6851453e5a66a43
4
+ data.tar.gz: f216971952e8e873e7959f8861fc55c674e0e22765cc2e12cd485793b6d65c8e
5
5
  SHA512:
6
- metadata.gz: ba24fbdc765bc378b6fd024c9e9215db5476c40cb77890da0468343374d79049d2bbb18d2a216377c71d4cc42d77a221c75493f3783f553521b29b27c8a1641d
7
- data.tar.gz: fde4958f98ae92922e07a16b8b0564897a7449ab8f16b5102c9ca77389614290a7e5c59128af436843e028783094ba017af9ef59b4fd99250ca494f00845dff5
6
+ metadata.gz: 52467965bc3cdfe91c72af5ea5504681e2fc12d2be7179309d464e131e7b766fc0efc6aeea7affcda9c287af129550828cf64ec5cd3b94c38deb1b880cf5d7e1
7
+ data.tar.gz: bcbffc9a28d139cf185cd068bed5ca594a163d97d054c33b62463794aec39f453d162e9e9f1abf071d7f2d81efcd910aa6a25c765cb185a653234ff7c666f0e0
data/README.md CHANGED
@@ -80,13 +80,13 @@ This command uninstalls the extensions and deletes the `.extensions.lock`.
80
80
  ```
81
81
  $ rex
82
82
  Commands:
83
- rex envs # Show the list of defined environments in .extensions.rb
83
+ rex envs # Show the list of environments and their extensions defined in .extensions.rb
84
84
  rex help [COMMAND] # Describe available commands or one specific command
85
85
  rex init # Create a new .extensions.rb file
86
86
  rex install [ENV] # Install the definitions in .extensions.rb for the specified environment
87
87
  rex state # Show the current state of the installed extensions
88
- rex switch [ENV] # Uninstall extensions for the currently installed environment and install ext...
89
- rex uninstall # Uninstall extensions for the currently installed environment based on the st...
88
+ rex switch [ENV] # Uninstall extensions for the currently installed environment and install extensions for the specified environment
89
+ rex uninstall # Uninstall extensions for the currently installed environment based on the state in .extensions.lock and remove the lock file
90
90
  rex update # Update extensions for the currently installed environment to the latest version
91
91
  rex version # Show Rexer version
92
92
 
@@ -166,7 +166,12 @@ In addition, you can define as many environments as you like, and list the defin
166
166
  ```
167
167
  $ rex envs
168
168
  default
169
+ bleuclair (support-propshaft)
170
+ redmine_issues_panel (master)
171
+
169
172
  stable
173
+ bleuclair (support-propshaft)
174
+ redmine_issues_panel (v1.0.2)
170
175
  ```
171
176
 
172
177
  ### Defining hooks
data/lib/rexer/cli.rb CHANGED
@@ -39,7 +39,7 @@ module Rexer
39
39
  Commands::State.new.call
40
40
  end
41
41
 
42
- desc "envs", "Show the list of defined environments in .extensions.rb"
42
+ desc "envs", "Show the list of environments and their extensions defined in .extensions.rb"
43
43
  def envs
44
44
  Commands::Envs.new.call
45
45
  end
@@ -6,16 +6,27 @@ module Rexer
6
6
  end
7
7
 
8
8
  def call
9
- puts(*defined_envs)
9
+ defined_envs = definition.envs
10
+ defined_envs.each.with_index do |env, i|
11
+ puts env
12
+
13
+ definition_with(env).then { _1.themes + _1.plugins }.each do
14
+ puts " #{_1.name} (#{Source.from_definition(_1.source).info})"
15
+ end
16
+
17
+ puts if i < defined_envs.size - 1
18
+ end
10
19
  end
11
20
 
12
21
  private
13
22
 
14
23
  attr_reader :definition
15
24
 
16
- def defined_envs
17
- all_envs = definition.plugins.map(&:env) + definition.themes.map(&:env)
18
- all_envs.uniq.sort
25
+ def definition_with(env)
26
+ definition.with(
27
+ plugins: definition.plugins.select { _1.env == env },
28
+ themes: definition.themes.select { _1.env == env }
29
+ )
19
30
  end
20
31
  end
21
32
  end
@@ -37,9 +37,12 @@ module Rexer
37
37
  end
38
38
 
39
39
  def load_definition(env)
40
- Definition.load_data.tap { |data|
41
- data.env = env
42
- }
40
+ data = Definition.load_data
41
+ data.with(
42
+ plugins: data.plugins.select { _1.env == env },
43
+ themes: data.themes.select { _1.env == env },
44
+ env:
45
+ )
43
46
  end
44
47
 
45
48
  def load_lock_definition
@@ -1,22 +1,12 @@
1
1
  module Rexer
2
2
  module Definition
3
- class Data
4
- attr_accessor :env
5
- attr_reader :version
6
-
7
- def initialize(plugins, themes, env: nil, version: nil)
8
- @plugins = plugins
9
- @themes = themes
10
- @env = env
11
- @version = version
12
- end
13
-
14
- def plugins
15
- env ? @plugins.select { _1.env == env } : @plugins
3
+ Data = ::Data.define(:plugins, :themes, :env, :version) do
4
+ def initialize(plugins:, themes:, env: nil, version: nil)
5
+ super
16
6
  end
17
7
 
18
- def themes
19
- env ? @themes.select { _1.env == env } : @themes
8
+ def envs
9
+ (plugins.map(&:env) + themes.map(&:env)).uniq.sort
20
10
  end
21
11
 
22
12
  def diff(other)
@@ -1,10 +1,17 @@
1
1
  module Rexer
2
2
  module Definition
3
3
  class Dsl
4
- def initialize(env = :default)
4
+ def initialize
5
5
  @plugins = []
6
6
  @themes = []
7
- @env = env
7
+ @env = :default
8
+ end
9
+
10
+ class EnvDsl < self
11
+ def initialize(env)
12
+ super()
13
+ @env = env
14
+ end
8
15
  end
9
16
 
10
17
  def plugin(name, **opts, &hooks)
@@ -27,7 +34,7 @@ module Rexer
27
34
 
28
35
  def env(*env_names, &dsl)
29
36
  env_names.each do |env_name|
30
- data = self.class.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
37
+ data = EnvDsl.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
31
38
 
32
39
  @plugins += data.plugins
33
40
  @themes += data.themes
@@ -23,17 +23,20 @@ module Rexer
23
23
 
24
24
  class Dsl < Definition::Dsl
25
25
  def lock(env:, version:)
26
- lock_state.update(env:, version:)
26
+ @lock_env = env
27
+ @lock_version = version
27
28
  end
28
29
 
29
30
  def to_data
30
- Definition::Data.new(@plugins, @themes, **lock_state)
31
+ plugins = lock_by_env(@plugins)
32
+ themes = lock_by_env(@themes)
33
+ Definition::Data.new(plugins, themes, @lock_env, @lock_version)
31
34
  end
32
35
 
33
36
  private
34
37
 
35
- def lock_state
36
- @lock_state ||= {}
38
+ def lock_by_env(plugins_or_themes)
39
+ plugins_or_themes.select { _1.env == @lock_env }
37
40
  end
38
41
  end
39
42
  end
@@ -39,14 +39,14 @@ module Rexer
39
39
  return unless needs_db_migration?
40
40
 
41
41
  envs = {"NAME" => name.to_s}.merge(extra_envs)
42
- cmds = cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate")
42
+ cmds = build_cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate", envs:)
43
43
 
44
- broadcast(:processing, "Execute #{cmds} with #{envs}")
44
+ broadcast(:processing, "Execute #{cmds}")
45
45
 
46
46
  if Rexer.verbosity.debug?
47
- system(envs, cmds, exception: true)
47
+ system(cmds, exception: true)
48
48
  else
49
- _, error, status = Open3.capture3(envs, cmds)
49
+ _, error, status = Open3.capture3(cmds)
50
50
  raise error unless status.success?
51
51
  end
52
52
  end
@@ -55,8 +55,9 @@ module Rexer
55
55
  @source ||= Source.from_definition(definition.source)
56
56
  end
57
57
 
58
- def cmd(*command)
59
- [Rexer.config.command_prefix, *command].compact.join(" ")
58
+ def build_cmd(*command, envs: {})
59
+ envs_str = envs.map { [_1, _2].join("=") }
60
+ [Rexer.config.command_prefix, *command, *envs_str].compact.join(" ")
60
61
  end
61
62
  end
62
63
 
@@ -86,7 +87,7 @@ module Rexer
86
87
  def run_bundle_install
87
88
  return unless plugin_dir.join("Gemfile").exist?
88
89
 
89
- cmds = cmd("bundle", "install", Rexer.verbosity.debug? ? nil : "--quiet")
90
+ cmds = build_cmd("bundle", "install", Rexer.verbosity.debug? ? nil : "--quiet")
90
91
 
91
92
  broadcast(:processing, "Execute #{cmds}")
92
93
 
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya Hidaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-01 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor