rexer 0.14.0 → 0.15.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: 9226515e3b9599a9915d140c03d8153f1e562409b5c2d8d3f28501d547511ffc
4
- data.tar.gz: 8aa2e357ea18131f0fdef8a00276a891f8dec119ad0c9171524384ac4a6119f7
3
+ metadata.gz: a65472e424f27d1a96fa1be7093fcb9eac2f59606dd9b93c907dfec412b8309d
4
+ data.tar.gz: b56d1515e26fd98f800c772f64511bd241c83e1e0b706f4bbdd6b2cbf734a375
5
5
  SHA512:
6
- metadata.gz: 002633010dcb32959079688a3510edda19e93784145b47b5ca60cf48749348d36f63691c94df30568b8a1fbc3acf63940a832ffa9afc80b0325a430398e9b122
7
- data.tar.gz: 236685fa7ad6d2760831d2a416b81a1e2e23efb588399e83134e81dbcf06fa3a6b83351f383eae4f59adf3e8aae7c772ed70b6fbe3066004fa92664fca88ecc3
6
+ metadata.gz: bdeb0d3f7855f8fef1710f0d7918ce2b24c39004ac2cc0fa3ddd3c1e201eb5bf3afef7c08531caa539842189eb95fa99fd11166bdbcfc8fbef4ea5345541d2c8
7
+ data.tar.gz: 160d63e6239cd0d417443d2935c35a826340040cc917c28f29d3827e5e9db53bcacdc28a45c9a665f12e4087a88b436407258fe995dfd1ab08a30a25cd057783
data/README.md CHANGED
@@ -41,9 +41,10 @@ rex init
41
41
  This command generates a `.extensions.rb`, so define the extensions you want to install in the file like below.
42
42
 
43
43
  ```ruby
44
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "support-propshaft" }
44
+ theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "master" }
45
45
 
46
46
  plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.2" }
47
+ plugin :redmica_ui_extension, github: { repo: "redmica/redmica_ui_extension", ref: "4fdc298bc310be2ab295008c0ee522b0ec0e319a" }
47
48
  ```
48
49
 
49
50
  Then, run the following command in the root directory of the Redmine application.
@@ -86,7 +87,7 @@ Commands:
86
87
  rex state # Show the current state of the installed extensions
87
88
  rex switch [ENV] # Uninstall extensions for the currently installed environment and install extensions for the specified environment
88
89
  rex uninstall # Uninstall extensions for the currently installed environment based on the state in .extensions.lock and remove the lock file
89
- rex update # Update extensions for the currently installed environment to the latest version
90
+ rex update # Update extensions for the currently installed environment to the latest version if extensions are updateable
90
91
  rex version # Show Rexer version
91
92
 
92
93
  Options:
@@ -123,85 +124,6 @@ rex v # means version
123
124
  and more...
124
125
  ```
125
126
 
126
- ## Syntax of .extensions.rb file
127
-
128
- ### Plugin
129
-
130
- ```ruby
131
- plugin :plugin_name, <source>: { ... }
132
- ```
133
-
134
- ### Theme
135
-
136
- ```ruby
137
- theme :theme_name, <source>: { ... }
138
- ```
139
-
140
- ### Source
141
-
142
- #### Git
143
-
144
- ```ruby
145
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel" }
146
- ```
147
- ```ruby
148
- # Specify the branch
149
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", branch: "main" }
150
- # Specify the tag
151
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.0" }
152
- # Specify the commit
153
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", ref: "5cfb8ccbabb2fad2c8f2273a4dda3f16ef2de124" }
154
- ```
155
-
156
- #### GitHub
157
-
158
- ```ruby
159
- plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", tag: "v1.0.0" }
160
- ```
161
-
162
- ### Env
163
-
164
- ```ruby
165
- plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" }
166
-
167
- # This is the same as the above.
168
- env :default do
169
- plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" }
170
- end
171
-
172
- env :stable do
173
- plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", tag: "v1.0.2" }
174
- end
175
-
176
- env :default, :stable do
177
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" }
178
- end
179
- ```
180
-
181
- ### Hooks
182
-
183
- ```ruby
184
- plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" } do
185
- installed do
186
- puts "The plugin has been installed."
187
- end
188
-
189
- uninstalled do
190
- puts "The plugin has been uninstalled."
191
- end
192
- end
193
-
194
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" } do
195
- installed do
196
- puts "The theme has been installed."
197
- end
198
-
199
- uninstalled do
200
- puts "The theme has been uninstalled."
201
- end
202
- end
203
- ```
204
-
205
127
  ## Advanced Usage
206
128
 
207
129
  ### Defining for each environment and extension
@@ -209,25 +131,25 @@ end
209
131
  You can define an environment and extensions for each environment using the `env ... do - end` block.
210
132
 
211
133
  ```ruby
212
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel" }
134
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", branch: "master" }
213
135
 
214
136
  env :stable do
215
- plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.2" }
137
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", tag: "v1.0.2" }
216
138
  end
217
139
 
218
140
  env :default, :stable do
219
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "support-propshaft" }
141
+ theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" }
220
142
  end
221
143
  ```
222
144
 
223
145
  Definitions other than `env ... do - end` are implicitly defined as `env :default do - end`. Therefore, the above is resolved as follows:
224
146
 
225
147
  * default env
226
- * bleuclair (support-propshaft)
227
- * redmine_issues_panel (master)
148
+ * bleuclair (farend/redmine_theme_farend_bleuclair@main)
149
+ * redmine_issues_panel (redmica/redmine_issues_panel@master)
228
150
  * stable env
229
- * bleuclair (support-propshaft)
230
- * redmine_issues_panel (v1.0.2)
151
+ * bleuclair (farend/redmine_theme_farend_bleuclair@main)
152
+ * redmine_issues_panel (redmica/redmine_issues_panel@v1.0.2)
231
153
 
232
154
  If you want to install extensions for the `default` environment, run the following command.
233
155
 
@@ -258,12 +180,12 @@ In addition, you can define as many environments as you like, and list the defin
258
180
  ```
259
181
  $ rex envs
260
182
  default
261
- bleuclair (support-propshaft)
262
- redmine_issues_panel (master)
183
+ bleuclair (farend/redmine_theme_farend_bleuclair@main)
184
+ redmine_issues_panel (redmica/redmine_issues_panel@master)
263
185
 
264
186
  stable
265
- bleuclair (support-propshaft)
266
- redmine_issues_panel (v1.0.2)
187
+ bleuclair (farend/redmine_theme_farend_bleuclair@main)
188
+ redmine_issues_panel (redmica/redmine_issues_panel@v1.0.2)
267
189
  ```
268
190
 
269
191
  ### Defining hooks
@@ -294,6 +216,85 @@ export REXER_COMMAND_PREFIX="docker compose exec -T app"
294
216
 
295
217
  In the above case, the `bin/rails redmine:plugins:migrate` command is executed as `docker compose exec -T app bin/rails redmine:plugins:migrate`.
296
218
 
219
+ ## Extensions.rb Syntax
220
+
221
+ ### Plugin
222
+
223
+ ```ruby
224
+ plugin :plugin_name, <source>: { ... }
225
+ ```
226
+
227
+ ### Theme
228
+
229
+ ```ruby
230
+ theme :theme_name, <source>: { ... }
231
+ ```
232
+
233
+ ### Source
234
+
235
+ #### Git
236
+
237
+ ```ruby
238
+ plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel" }
239
+ ```
240
+ ```ruby
241
+ # Specify the branch
242
+ plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", branch: "main" }
243
+ # Specify the tag
244
+ plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.0" }
245
+ # Specify the commit
246
+ plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", ref: "5cfb8ccbabb2fad2c8f2273a4dda3f16ef2de124" }
247
+ ```
248
+
249
+ #### GitHub
250
+
251
+ ```ruby
252
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", tag: "v1.0.0" }
253
+ ```
254
+
255
+ ### Env
256
+
257
+ ```ruby
258
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" }
259
+
260
+ # This is the same as the above.
261
+ env :default do
262
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" }
263
+ end
264
+
265
+ env :stable do
266
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel", tag: "v1.0.2" }
267
+ end
268
+
269
+ env :default, :stable do
270
+ theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" }
271
+ end
272
+ ```
273
+
274
+ ### Hooks
275
+
276
+ ```ruby
277
+ plugin :redmine_issues_panel, github: { repo: "redmica/redmine_issues_panel" } do
278
+ installed do
279
+ puts "The plugin has been installed."
280
+ end
281
+
282
+ uninstalled do
283
+ puts "The plugin has been uninstalled."
284
+ end
285
+ end
286
+
287
+ theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" } do
288
+ installed do
289
+ puts "The theme has been installed."
290
+ end
291
+
292
+ uninstalled do
293
+ puts "The theme has been uninstalled."
294
+ end
295
+ end
296
+ ```
297
+
297
298
  ## Developing
298
299
 
299
300
  ### Running the command
@@ -10,8 +10,12 @@ module Rexer
10
10
  defined_envs.each.with_index do |env, i|
11
11
  puts env
12
12
 
13
- definition_with(env).then { _1.themes + _1.plugins }.each do
14
- puts " #{_1.name} (#{Source.from_definition(_1.source).info})"
13
+ themes_in(env) do
14
+ print_extension_definition(_1)
15
+ end
16
+
17
+ plugins_in(env) do
18
+ print_extension_definition(_1)
15
19
  end
16
20
 
17
21
  puts if i < defined_envs.size - 1
@@ -22,11 +26,20 @@ module Rexer
22
26
 
23
27
  attr_reader :definition
24
28
 
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
- )
29
+ def print_extension_definition(extension_def)
30
+ puts " #{extension_def.name} (#{Source.from_definition(extension_def.source).info})"
31
+ end
32
+
33
+ def themes_in(env)
34
+ definition.themes.each do
35
+ yield _1 if _1.env == env
36
+ end
37
+ end
38
+
39
+ def plugins_in(env)
40
+ definition.plugins.each do
41
+ yield _1 if _1.env == env
42
+ end
30
43
  end
31
44
  end
32
45
  end
@@ -20,29 +20,27 @@ module Rexer
20
20
  attr_reader :lock_definition
21
21
 
22
22
  def print_plugins
23
- plugins = lock_definition.plugins
24
- return if plugins.empty?
23
+ plugin_defs = lock_definition.plugins
24
+ return if plugin_defs.empty?
25
25
 
26
26
  puts "\nPlugins:"
27
- plugins.each do
28
- puts " * #{_1.name} (#{source_info(_1.source)})"
27
+ plugin_defs.each do
28
+ plugin = Extension::Entity::Plugin.new(_1)
29
+ puts " * #{plugin.name} (#{plugin.source_info})"
29
30
  end
30
31
  end
31
32
 
32
33
  def print_themes
33
- themes = lock_definition.themes
34
- return if themes.empty?
34
+ theme_defs = lock_definition.themes
35
+ return if theme_defs.empty?
35
36
 
36
37
  puts "\nThemes:"
37
- themes.each do
38
- puts " * #{_1.name} (#{source_info(_1.source)})"
38
+ theme_defs.each do
39
+ theme = Extension::Entity::Theme.new(_1)
40
+ puts " * #{theme.name} (#{theme.source_info})"
39
41
  end
40
42
  end
41
43
 
42
- def source_info(definition_source)
43
- Source.from_definition(definition_source).info
44
- end
45
-
46
44
  def no_lock_file_found
47
45
  lock_definition.nil?.tap { |result|
48
46
  puts "No lock file found" if result
@@ -7,7 +7,7 @@ module Rexer
7
7
 
8
8
  def call(env)
9
9
  return if no_lock_file_found
10
- return if already_on(env)
10
+ return if already_in(env)
11
11
 
12
12
  Uninstall.new.call
13
13
  Install.new.call(env)
@@ -23,9 +23,9 @@ module Rexer
23
23
  }
24
24
  end
25
25
 
26
- def already_on(env)
26
+ def already_in(env)
27
27
  (lock_definition.env == env).tap do |result|
28
- puts "Already on #{env} environment" if result
28
+ puts "Already in #{env} environment" if result
29
29
  end
30
30
  end
31
31
  end
@@ -0,0 +1,55 @@
1
+ require "active_support/core_ext/class/attribute"
2
+
3
+ module Rexer
4
+ module Extension
5
+ module Entity
6
+ class Base
7
+ class_attribute :root_dir
8
+
9
+ def initialize(definition)
10
+ @definition = definition
11
+ @hooks = definition.hooks || {}
12
+ @name = definition.name
13
+ end
14
+
15
+ attr_reader :hooks, :name
16
+
17
+ def exist?
18
+ path.exist? && !path.empty?
19
+ end
20
+
21
+ def path
22
+ @path ||= root_dir.join(name.to_s)
23
+ end
24
+
25
+ def source_info
26
+ @source_info ||= source.info(path)
27
+ end
28
+
29
+ def source
30
+ @source ||= Source.from_definition(definition.source)
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :definition
36
+ end
37
+
38
+ class Plugin < Base
39
+ self.root_dir = Pathname.new("plugins")
40
+
41
+ def contains_db_migrations?
42
+ path.join("db", "migrate").then { _1.exist? && !_1.empty? }
43
+ end
44
+
45
+ def contains_gemfile?
46
+ path.join("Gemfile").exist?
47
+ end
48
+ end
49
+
50
+ class Theme < Base
51
+ self.root_dir = Pathname.new("themes")
52
+ end
53
+ end
54
+ end
55
+ end
@@ -9,36 +9,21 @@ module Rexer
9
9
 
10
10
  def initialize(definition)
11
11
  @definition = definition
12
- @name = definition.name
13
- @hooks = definition.hooks || {}
12
+ @plugin = Entity::Plugin.new(definition)
14
13
  end
15
14
 
16
15
  private
17
16
 
18
- attr_reader :name, :hooks, :definition
19
-
20
- def plugin_root_dir
21
- Pathname.new("plugins")
22
- end
23
-
24
- def plugin_dir
25
- @plugin_dir ||= plugin_root_dir.join(name.to_s)
26
- end
27
-
28
- def plugin_exists?
29
- plugin_dir.exist? && !plugin_dir.empty?
30
- end
17
+ attr_reader :plugin
31
18
 
32
19
  def needs_db_migration?
33
- plugin_dir.join("db", "migrate").then {
34
- _1.exist? && !_1.empty?
35
- }
20
+ plugin.contains_db_migrations?
36
21
  end
37
22
 
38
23
  def run_db_migrate(extra_envs = {})
39
24
  return unless needs_db_migration?
40
25
 
41
- envs = {"NAME" => name.to_s}.merge(extra_envs)
26
+ envs = {"NAME" => plugin.name.to_s}.merge(extra_envs)
42
27
  cmds = build_cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate", envs:)
43
28
 
44
29
  broadcast(:processing, "Execute #{cmds}")
@@ -51,10 +36,6 @@ module Rexer
51
36
  end
52
37
  end
53
38
 
54
- def source
55
- @source ||= Source.from_definition(definition.source)
56
- end
57
-
58
39
  def build_cmd(*command, envs: {})
59
40
  envs_str = envs.map { [_1, _2].join("=") }
60
41
  [Rexer.config.command_prefix, *command, *envs_str].compact.join(" ")
@@ -3,9 +3,9 @@ module Rexer
3
3
  module Plugin
4
4
  class Install < Action
5
5
  def call
6
- broadcast(:started, "Install #{name}")
6
+ broadcast(:started, "Install #{plugin.name}")
7
7
 
8
- if plugin_exists?
8
+ if plugin.exist?
9
9
  broadcast(:skipped, "Already exists")
10
10
  return
11
11
  end
@@ -13,7 +13,7 @@ module Rexer
13
13
  load_from_source
14
14
  run_bundle_install
15
15
  run_db_migrate
16
- hooks[:installed]&.call
16
+ call_installed_hook
17
17
 
18
18
  broadcast(:completed)
19
19
  end
@@ -21,11 +21,11 @@ module Rexer
21
21
  private
22
22
 
23
23
  def load_from_source
24
- source.load(plugin_dir.to_s)
24
+ plugin.source.load(plugin.path.to_s)
25
25
  end
26
26
 
27
27
  def run_bundle_install
28
- return unless plugin_dir.join("Gemfile").exist?
28
+ return unless plugin.contains_gemfile?
29
29
 
30
30
  cmds = build_cmd("bundle", "install", Rexer.verbosity.debug? ? nil : "--quiet")
31
31
 
@@ -33,6 +33,10 @@ module Rexer
33
33
 
34
34
  system(cmds, exception: true)
35
35
  end
36
+
37
+ def call_installed_hook
38
+ plugin.hooks[:installed]&.call
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -3,9 +3,9 @@ module Rexer
3
3
  module Plugin
4
4
  class ReloadSource < Action
5
5
  def call
6
- return unless plugin_exists?
6
+ return unless plugin.exist?
7
7
 
8
- broadcast(:started, "Reload #{name} source")
8
+ broadcast(:started, "Reload #{plugin.name} source")
9
9
 
10
10
  reload_source
11
11
  run_db_migrate
@@ -16,10 +16,8 @@ module Rexer
16
16
  private
17
17
 
18
18
  def reload_source
19
- plugin_dir.to_s.then { |dir|
20
- FileUtils.rm_rf(dir)
21
- source.load(dir)
22
- }
19
+ plugin.path.rmtree
20
+ plugin.source.load(plugin.path.to_s)
23
21
  end
24
22
  end
25
23
  end
@@ -3,16 +3,16 @@ module Rexer
3
3
  module Plugin
4
4
  class Uninstall < Action
5
5
  def call
6
- broadcast(:started, "Uninstall #{name}")
6
+ broadcast(:started, "Uninstall #{plugin.name}")
7
7
 
8
- unless plugin_exists?
8
+ unless plugin.exist?
9
9
  broadcast(:skipped, "Not exists")
10
10
  return
11
11
  end
12
12
 
13
13
  reset_db_migration
14
14
  remove_plugin
15
- hooks[:uninstalled]&.call
15
+ call_uninstalled_hook
16
16
 
17
17
  broadcast(:completed)
18
18
  end
@@ -24,7 +24,11 @@ module Rexer
24
24
  end
25
25
 
26
26
  def remove_plugin
27
- plugin_dir.rmtree
27
+ plugin.path.rmtree
28
+ end
29
+
30
+ def call_uninstalled_hook
31
+ plugin.hooks[:uninstalled]&.call
28
32
  end
29
33
  end
30
34
  end
@@ -3,11 +3,11 @@ module Rexer
3
3
  module Plugin
4
4
  class Update < Action
5
5
  def call
6
- return unless plugin_exists?
6
+ return unless plugin.exist?
7
7
 
8
- broadcast(:started, "Update #{name}")
8
+ broadcast(:started, "Update #{plugin.name}")
9
9
 
10
- unless source.updatable?
10
+ unless plugin.source.updatable?
11
11
  broadcast(:skipped, "Not updatable")
12
12
  return
13
13
  end
@@ -21,7 +21,7 @@ module Rexer
21
21
  private
22
22
 
23
23
  def update_source
24
- source.update(plugin_dir.to_s)
24
+ plugin.source.update(plugin.path)
25
25
  end
26
26
  end
27
27
  end
@@ -8,36 +8,12 @@ module Rexer
8
8
 
9
9
  def initialize(definition)
10
10
  @definition = definition
11
- @name = definition.name
12
- @hooks = definition.hooks || {}
11
+ @theme = Entity::Theme.new(definition)
13
12
  end
14
13
 
15
14
  private
16
15
 
17
- attr_reader :name, :hooks, :definition
18
-
19
- def theme_root_dir
20
- public_themes = Pathname.pwd.join("public", "themes")
21
-
22
- if public_themes.exist?
23
- # When Redmine version is v5.1 or older, public/themes is used.
24
- public_themes
25
- else
26
- Pathname.new("themes")
27
- end
28
- end
29
-
30
- def theme_dir
31
- @theme_dir ||= theme_root_dir.join(name.to_s)
32
- end
33
-
34
- def theme_exists?
35
- theme_dir.exist? && !theme_dir.empty?
36
- end
37
-
38
- def source
39
- @source ||= Source.from_definition(definition.source)
40
- end
16
+ attr_reader :theme
41
17
  end
42
18
  end
43
19
  end
@@ -3,15 +3,15 @@ module Rexer
3
3
  module Theme
4
4
  class Install < Action
5
5
  def call
6
- broadcast(:started, "Install #{name}")
6
+ broadcast(:started, "Install #{theme.name}")
7
7
 
8
- if theme_exists?
8
+ if theme.exist?
9
9
  broadcast(:skipped, "Already exists")
10
10
  return
11
11
  end
12
12
 
13
13
  load_from_source
14
- hooks[:installed]&.call
14
+ call_installed_hook
15
15
 
16
16
  broadcast(:completed)
17
17
  end
@@ -19,7 +19,11 @@ module Rexer
19
19
  private
20
20
 
21
21
  def load_from_source
22
- source.load(theme_dir.to_s)
22
+ theme.source.load(theme.path.to_s)
23
+ end
24
+
25
+ def call_installed_hook
26
+ theme.hooks[:installed]&.call
23
27
  end
24
28
  end
25
29
  end
@@ -3,9 +3,9 @@ module Rexer
3
3
  module Theme
4
4
  class ReloadSource < Action
5
5
  def call
6
- return unless theme_exists?
6
+ return unless theme.exist?
7
7
 
8
- broadcast(:started, "Reload #{name} source")
8
+ broadcast(:started, "Reload #{theme.name} source")
9
9
 
10
10
  reload_source
11
11
 
@@ -15,10 +15,8 @@ module Rexer
15
15
  private
16
16
 
17
17
  def reload_source
18
- theme_dir.to_s.then { |dir|
19
- FileUtils.rm_rf(dir)
20
- source.load(dir)
21
- }
18
+ theme.path.rmtree
19
+ theme.source.load(theme.path.to_s)
22
20
  end
23
21
  end
24
22
  end
@@ -3,15 +3,15 @@ module Rexer
3
3
  module Theme
4
4
  class Uninstall < Action
5
5
  def call
6
- broadcast(:started, "Uninstall #{name}")
6
+ broadcast(:started, "Uninstall #{theme.name}")
7
7
 
8
- unless theme_exists?
8
+ unless theme.exist?
9
9
  broadcast(:skipped, "Not exists")
10
10
  return
11
11
  end
12
12
 
13
13
  remove_theme
14
- hooks[:uninstalled]&.call
14
+ call_uninstalled_hook
15
15
 
16
16
  broadcast(:completed)
17
17
  end
@@ -19,7 +19,11 @@ module Rexer
19
19
  private
20
20
 
21
21
  def remove_theme
22
- theme_dir.rmtree
22
+ theme.path.rmtree
23
+ end
24
+
25
+ def call_uninstalled_hook
26
+ theme.hooks[:uninstalled]&.call
23
27
  end
24
28
  end
25
29
  end
@@ -3,9 +3,9 @@ module Rexer
3
3
  module Theme
4
4
  class Update < Action
5
5
  def call
6
- return unless theme_exists?
6
+ return unless theme.exist?
7
7
 
8
- broadcast(:started, "Update #{name}")
8
+ broadcast(:started, "Update #{theme.name}")
9
9
 
10
10
  update_source
11
11
 
@@ -15,7 +15,7 @@ module Rexer
15
15
  private
16
16
 
17
17
  def update_source
18
- source.update(theme_dir.to_s)
18
+ theme.source.update(theme.path.to_s)
19
19
  end
20
20
  end
21
21
  end
@@ -17,7 +17,7 @@ module Rexer
17
17
  end
18
18
 
19
19
  # Return the status of the source.
20
- def info = ""
20
+ def info(_work_dir = nil) = ""
21
21
  end
22
22
  end
23
23
  end
@@ -9,7 +9,6 @@ module Rexer
9
9
  @branch = branch
10
10
  @tag = tag
11
11
  @ref = ref
12
- @reference = branch || tag || ref
13
12
  end
14
13
 
15
14
  def load(path)
@@ -25,27 +24,35 @@ module Rexer
25
24
  branch || reference.nil?
26
25
  end
27
26
 
28
- def info
29
- URI.parse(url).then do |uri|
30
- "#{uri.host}#{uri.path}@#{reference_name}"
31
- end
27
+ def info(work_dir = nil)
28
+ uri = URI.parse(url).then { "#{_1.host}#{_1.path}" }
29
+ ref = reference(short_ref: true) || current_branch(work_dir)
30
+
31
+ [uri, ref].compact.join("@")
32
32
  end
33
33
 
34
34
  private
35
35
 
36
- attr_reader :url, :reference, :branch, :tag, :ref
36
+ attr_reader :url, :branch, :tag
37
37
 
38
38
  def checkout(git)
39
39
  reference&.then { git.checkout(_1) }
40
40
  end
41
41
 
42
- def reference_name
43
- branch || tag || ref || "main"
42
+ def reference(short_ref: false)
43
+ branch || tag || ref(short: short_ref)
44
+ end
45
+
46
+ def ref(short: false)
47
+ return nil unless @ref
48
+ return @ref unless short
49
+
50
+ @ref.match?(/^[a-z0-9]+$/) ? @ref.slice(0, 7) : @ref
44
51
  end
45
52
 
46
- def short_ref
47
- return unless ref
48
- ref.match?(/^[a-z0-9]+$/) ? ref.slice(0, 7) : ref
53
+ def current_branch(work_dir)
54
+ return nil unless work_dir
55
+ ::Git.open(work_dir).current_branch
49
56
  end
50
57
  end
51
58
  end
@@ -6,8 +6,8 @@ module Rexer
6
6
  super(url: "https://github.com/#{repo}", branch: branch, tag: tag, ref: ref)
7
7
  end
8
8
 
9
- def info
10
- "#{@repo}@#{reference_name}"
9
+ def info(work_dir = nil)
10
+ [@repo, reference(short_ref: true) || current_branch(work_dir)].compact.join("@")
11
11
  end
12
12
  end
13
13
  end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
data/lib/rexer.rb CHANGED
@@ -1,12 +1,4 @@
1
1
  module Rexer
2
- def self.definition_file
3
- ".extensions.rb"
4
- end
5
-
6
- def self.definition_lock_file
7
- ".extensions.lock"
8
- end
9
-
10
2
  Config = Data.define(
11
3
  # The prefix of the command such as bundle install and bin/rails redmine:plugins:migrate.
12
4
  #
@@ -21,6 +13,14 @@ module Rexer
21
13
  class << self
22
14
  attr_accessor :verbosity
23
15
 
16
+ def definition_file
17
+ ".extensions.rb"
18
+ end
19
+
20
+ def definition_lock_file
21
+ ".extensions.lock"
22
+ end
23
+
24
24
  def config
25
25
  @config ||= Config.new(command_prefix: ENV["REXER_COMMAND_PREFIX"])
26
26
  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.14.0
4
+ version: 0.15.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-11-24 00:00:00.000000000 Z
11
+ date: 2024-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -139,6 +139,7 @@ files:
139
139
  - lib/rexer/definition/diff.rb
140
140
  - lib/rexer/definition/dsl.rb
141
141
  - lib/rexer/definition/lock.rb
142
+ - lib/rexer/extension/entity.rb
142
143
  - lib/rexer/extension/plugin/action.rb
143
144
  - lib/rexer/extension/plugin/install.rb
144
145
  - lib/rexer/extension/plugin/reload_source.rb