rexer 0.16.0 → 0.18.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: 61d1b3b0172a3db2da03ac1f428f447a5296df8430fabaf21f4ce1cb1f96ce41
4
- data.tar.gz: 8dc2852d1ef7f6052d2c8d09cba035276fd7b039bc109be732d0599142a27059
3
+ metadata.gz: 3fe6850152b1a1e856bafec9f7adf383dbb89695f197cda8e4a88ae76e5c4b8c
4
+ data.tar.gz: 8ce54a978f7a005ce9145fc5cb8a494514015a5a519d84867594a53107d4f635
5
5
  SHA512:
6
- metadata.gz: 72c9335b6be10bb6a7220d3b632ce2d0c20719165b5e93d17244e5f8c4412ea8fad0b36e805ae1cba51ef652d77afce8dd98676bfe1dcfb0b14e24249cf4fa8d
7
- data.tar.gz: b708a563d706ba42aad33a1daa40a5d7a7c4365c481be516d423a2a05176f8b4c0f6ef68afae27ca571ba55a99f03b3dbf51e10de497f91f672f781ff87a762a
6
+ metadata.gz: aaf7b96f1636a12698524517308ce3e2c4ae97f2feffea679cdaa25392cef21c4fe99da85d71bebb56a56dce306f016cdd140f37610c50dd0335a539f951ce5d
7
+ data.tar.gz: fa5f144cc10405f2bae71e98e582b99e66178b6c65bc65bd57bc92dba1f90c18eca4ac61a4b3ad8d1ddca387d6dfbe8cb00a573b82bf5bcd29dab89f021cfbb0
data/README.md CHANGED
@@ -79,6 +79,7 @@ This command uninstalls the extensions and deletes the `.extensions.lock`.
79
79
  ```
80
80
  $ rex
81
81
  Commands:
82
+ rex edit # Edit .extensions.rb
82
83
  rex envs # Show the list of environments and their extensions defined in .extensions.rb
83
84
  rex help [COMMAND] # Describe available commands or one specific command
84
85
  rex init # Create a new .extensions.rb file
@@ -106,6 +107,9 @@ If the specified ENV is currently installed, it compares the current `.extension
106
107
  * Uninstalls deleted extensions (the `uninstalled` hook is executed).
107
108
  * Reload extensions whose source settings has changed (for example, the `branch` or `tag` has changed) and runs the database migration if necessary.
108
109
 
110
+ > [!TIP]
111
+ > Execute the install command when running the rex command without a subcommand.
112
+
109
113
  ### rex update [extensions...]
110
114
 
111
115
  Loads `.extensions.lock` and updates the currently installed extensions to the latest version. `.extensions.rb` is NOT referenced in this command.
data/lib/rexer/cli.rb CHANGED
@@ -5,6 +5,8 @@ require "active_support/core_ext/object/blank"
5
5
 
6
6
  module Rexer
7
7
  class Cli < Thor
8
+ default_command :install
9
+
8
10
  def self.exit_on_failure? = true
9
11
 
10
12
  class_option :verbose, type: :boolean, aliases: "-v", desc: "Detailed output"
@@ -50,6 +52,11 @@ module Rexer
50
52
  Commands::Envs.new.call
51
53
  end
52
54
 
55
+ desc "edit", "Edit .extensions.rb"
56
+ def edit
57
+ Commands::Edit.new.call
58
+ end
59
+
53
60
  desc "version", "Show Rexer version"
54
61
  def version
55
62
  puts Rexer::VERSION
@@ -0,0 +1,28 @@
1
+ require "shellwords"
2
+
3
+ module Rexer
4
+ module Commands
5
+ class Edit
6
+ def call
7
+ definition_file = Definition.file
8
+
9
+ if editor.to_s.empty?
10
+ puts Paint["Please set your $VISUAL or $EDITOR environment variable.", :red]
11
+ exit 1
12
+ end
13
+
14
+ edit_system_editor(definition_file.to_s)
15
+ end
16
+
17
+ private
18
+
19
+ def editor
20
+ ENV["VISUAL"].to_s.empty? ? ENV["EDITOR"] : ENV["VISUAL"]
21
+ end
22
+
23
+ def edit_system_editor(file_path)
24
+ system(*Shellwords.split(editor), file_path)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,7 +2,12 @@ module Rexer
2
2
  module Commands
3
3
  class Init
4
4
  def call
5
- definition_file = Definition.file
5
+ unless redmine_root_dir?
6
+ puts Paint["Please run in the Redmine root directory.", :red]
7
+ exit 1
8
+ end
9
+
10
+ definition_file = Pathname.new(Rexer.definition_file)
6
11
 
7
12
  if definition_file.exist?
8
13
  puts Paint["#{definition_file.basename} already exists", :red]
@@ -34,6 +39,10 @@ module Rexer
34
39
 
35
40
  TEMPLATE
36
41
  end
42
+
43
+ def redmine_root_dir?
44
+ Pathname.new("README.rdoc").then { _1.exist? && _1.read.include?("Redmine") }
45
+ end
37
46
  end
38
47
  end
39
48
  end
@@ -2,7 +2,7 @@ module Rexer
2
2
  module Definition
3
3
  module Lock
4
4
  def self.file
5
- @file ||= Pathname.new(Rexer.definition_lock_file)
5
+ @file ||= Definition.dir.join(Rexer.definition_lock_file)
6
6
  end
7
7
 
8
8
  def self.load_data
@@ -10,6 +10,8 @@ module Rexer
10
10
 
11
11
  dsl = Dsl.new.tap { _1.instance_eval(file.read) }
12
12
  dsl.to_data
13
+ rescue DefinitionFileNotFound
14
+ nil
13
15
  end
14
16
 
15
17
  def self.create_file(env)
@@ -10,6 +10,12 @@ module Rexer
10
10
  end
11
11
  end
12
12
 
13
+ class DefinitionFileNotFound < StandardError
14
+ def initialize
15
+ super("No definition file (#{Rexer.definition_file}) found")
16
+ end
17
+ end
18
+
13
19
  Source = ::Data.define(:type, :options)
14
20
 
15
21
  Plugin = ::Data.define(:name, :source, :hooks, :env) do
@@ -20,13 +26,32 @@ module Rexer
20
26
  include ExtensionComparable
21
27
  end
22
28
 
29
+ def self.dir
30
+ @dir ||= find_difinition_dir
31
+ end
32
+
23
33
  def self.file
24
- @file ||= Pathname.new(Rexer.definition_file)
34
+ @file ||= dir.join(Rexer.definition_file)
25
35
  end
26
36
 
27
37
  def self.load_data
28
38
  dsl = Dsl.new.tap { _1.instance_eval(file.read) }
29
39
  dsl.to_data
40
+ rescue DefinitionFileNotFound
41
+ nil
42
+ end
43
+
44
+ def self.find_difinition_dir
45
+ definition_file = Rexer.definition_file
46
+ dir = Pathname.pwd
47
+
48
+ until dir.join(definition_file).exist?
49
+ raise DefinitionFileNotFound if dir.root?
50
+ dir = dir.parent
51
+ end
52
+
53
+ dir
30
54
  end
55
+ private_class_method :find_difinition_dir
31
56
  end
32
57
  end
@@ -1,11 +1,7 @@
1
- require "active_support/core_ext/class/attribute"
2
-
3
1
  module Rexer
4
2
  module Extension
5
3
  module Entity
6
4
  class Base
7
- class_attribute :root_dir
8
-
9
5
  def initialize(definition)
10
6
  @definition = definition
11
7
  @hooks = definition.hooks || {}
@@ -14,6 +10,8 @@ module Rexer
14
10
 
15
11
  attr_reader :hooks, :name
16
12
 
13
+ def root_dir = raise "Not implemented"
14
+
17
15
  def exist?
18
16
  path.exist? && !path.empty?
19
17
  end
@@ -36,7 +34,9 @@ module Rexer
36
34
  end
37
35
 
38
36
  class Plugin < Base
39
- self.root_dir = Pathname.new("plugins")
37
+ def root_dir
38
+ @root_dir ||= Rexer.redmine_root_dir.join("plugins")
39
+ end
40
40
 
41
41
  def contains_db_migrations?
42
42
  path.join("db", "migrate").then { _1.exist? && !_1.empty? }
@@ -48,7 +48,9 @@ module Rexer
48
48
  end
49
49
 
50
50
  class Theme < Base
51
- self.root_dir = Pathname.new("themes")
51
+ def root_dir
52
+ @root_dir ||= Rexer.redmine_root_dir.join("themes")
53
+ end
52
54
  end
53
55
  end
54
56
  end
@@ -16,12 +16,8 @@ module Rexer
16
16
 
17
17
  attr_reader :plugin
18
18
 
19
- def needs_db_migration?
20
- plugin.contains_db_migrations?
21
- end
22
-
23
19
  def run_db_migrate(extra_envs = {})
24
- return unless needs_db_migration?
20
+ return unless plugin.contains_db_migrations?
25
21
 
26
22
  envs = {"NAME" => plugin.name.to_s}.merge(extra_envs)
27
23
  cmds = build_cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate", envs:)
@@ -35,7 +35,7 @@ module Rexer
35
35
  end
36
36
 
37
37
  def call_installed_hook
38
- plugin.hooks[:installed]&.call
38
+ Rexer.redmine_root_dir { plugin.hooks[:installed]&.call }
39
39
  end
40
40
  end
41
41
  end
@@ -28,7 +28,7 @@ module Rexer
28
28
  end
29
29
 
30
30
  def call_uninstalled_hook
31
- plugin.hooks[:uninstalled]&.call
31
+ Rexer.redmine_root_dir { plugin.hooks[:uninstalled]&.call }
32
32
  end
33
33
  end
34
34
  end
@@ -23,7 +23,7 @@ module Rexer
23
23
  end
24
24
 
25
25
  def call_installed_hook
26
- theme.hooks[:installed]&.call
26
+ Rexer.redmine_root_dir { theme.hooks[:installed]&.call }
27
27
  end
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ module Rexer
23
23
  end
24
24
 
25
25
  def call_uninstalled_hook
26
- theme.hooks[:uninstalled]&.call
26
+ Rexer.redmine_root_dir { theme.hooks[:uninstalled]&.call }
27
27
  end
28
28
  end
29
29
  end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.16.0"
2
+ VERSION = "0.18.0"
3
3
  end
data/lib/rexer.rb CHANGED
@@ -21,6 +21,14 @@ module Rexer
21
21
  ".extensions.lock"
22
22
  end
23
23
 
24
+ def redmine_root_dir
25
+ if block_given?
26
+ Dir.chdir(Definition.dir) { yield }
27
+ else
28
+ Definition.dir
29
+ end
30
+ end
31
+
24
32
  def config
25
33
  @config ||= Config.new(command_prefix: ENV["REXER_COMMAND_PREFIX"])
26
34
  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.16.0
4
+ version: 0.18.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: 2025-01-01 00:00:00.000000000 Z
11
+ date: 2025-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -126,6 +126,7 @@ files:
126
126
  - lib/rexer.rb
127
127
  - lib/rexer/cli.rb
128
128
  - lib/rexer/commands.rb
129
+ - lib/rexer/commands/edit.rb
129
130
  - lib/rexer/commands/envs.rb
130
131
  - lib/rexer/commands/init.rb
131
132
  - lib/rexer/commands/install.rb
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
176
  - !ruby/object:Gem::Version
176
177
  version: '0'
177
178
  requirements: []
178
- rubygems_version: 3.5.11
179
+ rubygems_version: 3.5.22
179
180
  signing_key:
180
181
  specification_version: 4
181
182
  summary: A command-line tool for managing Redmine Plugins and Themes