rexer 0.1.0 → 0.3.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 +4 -4
- data/README.md +15 -12
- data/lib/rexer/cli.rb +5 -0
- data/lib/rexer/commands/envs.rb +24 -0
- data/lib/rexer/commands/install.rb +4 -4
- data/lib/rexer/commands/state.rb +2 -4
- data/lib/rexer/definition/diff.rb +6 -6
- data/lib/rexer/definition/dsl.rb +3 -3
- data/lib/rexer/extension/plugin.rb +19 -4
- data/lib/rexer/extension/theme.rb +26 -5
- data/lib/rexer/source/base.rb +3 -3
- data/lib/rexer/source.rb +9 -0
- data/lib/rexer/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b58d350ffc9bafc33b202240ed26a3ecf6228a29677ba2cca1938c81bd32576
|
4
|
+
data.tar.gz: 68d15da77b4838c6bbd97e35bd2b301c2cdf0d738176cc24fe62a07c1e486013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ef4db2f19d7fc91b28d265b8afe6a51080553ec4d2bd8f9a02824c05ed166593a1fbe44ed7e28a3a2ec3eb40d98a255963eb953b4e900340902ec4499a619cd
|
7
|
+
data.tar.gz: 330a05a5692158e30db7a3a4f55d2b830b18265dfb1fb277e5b73f27af113002014234431a8abe2f8a2932c2ca16f65b3c76121e483f9add212bcd0e45e74de4
|
data/README.md
CHANGED
@@ -9,13 +9,13 @@ It is mainly aimed at helping with the development of Redmine and its plugins, a
|
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
```
|
13
|
+
gem install rexer
|
14
|
+
```
|
15
15
|
|
16
|
-
|
16
|
+
## Supported Redmine
|
17
17
|
|
18
|
-
|
18
|
+
Rexer is tested with Redmine v5.1 and trunk.
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
@@ -55,6 +55,7 @@ This command uninstalls the extensions and deletes the `.extensions.lock` file.
|
|
55
55
|
$ rex
|
56
56
|
Commands:
|
57
57
|
rex help [COMMAND] # Describe available commands or one specific command
|
58
|
+
rex envs # Show the list of defined environments in .extensions.rb
|
58
59
|
rex install [ENV] # Install extensions for the specified environment
|
59
60
|
rex state # Show the current state of the installed extensions
|
60
61
|
rex switch [ENV] # Uninstall extensions for the currently installed environment and install extensions for the specified environment
|
@@ -116,29 +117,31 @@ plugin :redmica_s3, github: { repo: "redmica/redmica_s3" } do
|
|
116
117
|
uninstalled do
|
117
118
|
Pathname.new("config", "s3.yml").delete
|
118
119
|
end
|
119
|
-
|
120
|
-
updated do
|
121
|
-
puts "updated"
|
122
|
-
end
|
123
120
|
end
|
124
121
|
```
|
125
122
|
|
126
123
|
## Developing
|
127
124
|
|
128
|
-
### Running
|
125
|
+
### Running tests
|
129
126
|
|
130
127
|
First, you need to build the docker image for the integration tests.
|
131
128
|
|
132
129
|
```
|
133
|
-
rake
|
130
|
+
rake test:prepare_integration
|
134
131
|
```
|
135
132
|
|
136
|
-
Then, you can run
|
133
|
+
Then, you can run all tests.
|
137
134
|
|
138
135
|
```
|
139
136
|
rake test
|
140
137
|
```
|
141
138
|
|
139
|
+
Or, you can only the integration tests as follows.
|
140
|
+
|
141
|
+
```
|
142
|
+
rake test:integration
|
143
|
+
```
|
144
|
+
|
142
145
|
### Formatting and Linting code
|
143
146
|
|
144
147
|
This project uses [Standard](https://github.com/standardrb/standard) for code formatting and linting. You can format and check the code by running the following commands.
|
data/lib/rexer/cli.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Rexer
|
2
|
+
module Commands
|
3
|
+
class Envs
|
4
|
+
def initialize
|
5
|
+
@definition = Definition.load_data
|
6
|
+
end
|
7
|
+
|
8
|
+
def call
|
9
|
+
defined_envs.each do
|
10
|
+
puts _1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :definition
|
17
|
+
|
18
|
+
def defined_envs
|
19
|
+
all_envs = definition.plugins.map(&:env) + definition.themes.map(&:env)
|
20
|
+
all_envs.uniq
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -28,7 +28,7 @@ module Rexer
|
|
28
28
|
|
29
29
|
install(diff.added_themes, diff.added_plugins)
|
30
30
|
uninstall(diff.deleted_themes, diff.deleted_plugins)
|
31
|
-
|
31
|
+
reload_source(diff.source_changed_themes, diff.source_changed_plugins)
|
32
32
|
|
33
33
|
create_lock_file(definition.env)
|
34
34
|
print_state
|
@@ -64,13 +64,13 @@ module Rexer
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
67
|
+
def reload_source(themes, plugins)
|
68
68
|
themes.each do
|
69
|
-
Extension::Theme::
|
69
|
+
Extension::Theme::SourceReloader.new(_1).reload
|
70
70
|
end
|
71
71
|
|
72
72
|
plugins.each do
|
73
|
-
Extension::Plugin::
|
73
|
+
Extension::Plugin::SourceReloader.new(_1).reload
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
data/lib/rexer/commands/state.rb
CHANGED
@@ -39,10 +39,8 @@ module Rexer
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def source_info(
|
43
|
-
|
44
|
-
Source.const_get(_1.type.capitalize).new(**_1.options).info
|
45
|
-
}
|
42
|
+
def source_info(definition_source)
|
43
|
+
Source.from_definition(definition_source).info
|
46
44
|
end
|
47
45
|
|
48
46
|
def no_lock_file_found
|
@@ -22,21 +22,21 @@ module Rexer
|
|
22
22
|
old_data.themes - new_data.themes
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def source_changed_plugins
|
26
26
|
old_plugins = old_data.plugins
|
27
27
|
|
28
28
|
(new_data.plugins & old_plugins).select do |new_plugin|
|
29
29
|
old_plugin = old_plugins.find { _1.name == new_plugin.name }
|
30
|
-
|
30
|
+
plugin_source_changed?(old_plugin, new_plugin)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
34
|
+
def source_changed_themes
|
35
35
|
old_themes = old_data.themes
|
36
36
|
|
37
37
|
(new_data.themes & old_themes).select do |new_theme|
|
38
38
|
old_theme = old_themes.find { _1.name == new_theme.name }
|
39
|
-
|
39
|
+
theme_source_changed?(old_theme, new_theme)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,11 +44,11 @@ module Rexer
|
|
44
44
|
|
45
45
|
attr_reader :old_data, :new_data
|
46
46
|
|
47
|
-
def
|
47
|
+
def plugin_source_changed?(old_plugin, new_plugin)
|
48
48
|
old_plugin.source != new_plugin.source
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
51
|
+
def theme_source_changed?(old_theme, new_theme)
|
52
52
|
old_theme.source != new_theme.source
|
53
53
|
end
|
54
54
|
end
|
data/lib/rexer/definition/dsl.rb
CHANGED
@@ -11,7 +11,7 @@ module Rexer
|
|
11
11
|
@plugins << Definition::Plugin.new(
|
12
12
|
name: name,
|
13
13
|
source: build_source(opts),
|
14
|
-
hooks: build_hooks(hooks, %i[installed uninstalled
|
14
|
+
hooks: build_hooks(hooks, %i[installed uninstalled]),
|
15
15
|
env: @env
|
16
16
|
)
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Rexer
|
|
20
20
|
@themes << Definition::Theme.new(
|
21
21
|
name: name,
|
22
22
|
source: build_source(opts),
|
23
|
-
hooks: build_hooks(hooks, %i[installed uninstalled
|
23
|
+
hooks: build_hooks(hooks, %i[installed uninstalled]),
|
24
24
|
env: @env
|
25
25
|
)
|
26
26
|
end
|
@@ -54,7 +54,7 @@ module Rexer
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def build_source(opts)
|
57
|
-
type = opts.keys.find { Rexer::Source
|
57
|
+
type = opts.keys.find { Rexer::Source.names.include?(_1) }
|
58
58
|
Source.new(type, opts[type]) if type
|
59
59
|
end
|
60
60
|
end
|
@@ -42,9 +42,7 @@ module Rexer
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def source
|
45
|
-
@source ||= definition.source
|
46
|
-
Source.const_get(src.type.capitalize).new(**src.options)
|
47
|
-
end
|
45
|
+
@source ||= Source.from_definition(definition.source)
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -90,7 +88,6 @@ module Rexer
|
|
90
88
|
|
91
89
|
update_source
|
92
90
|
run_db_migrate
|
93
|
-
hooks[:updated]&.call
|
94
91
|
end
|
95
92
|
|
96
93
|
private
|
@@ -99,6 +96,24 @@ module Rexer
|
|
99
96
|
source.update(plugin_dir.to_s)
|
100
97
|
end
|
101
98
|
end
|
99
|
+
|
100
|
+
class SourceReloader < Base
|
101
|
+
def reload
|
102
|
+
return unless plugin_exists?
|
103
|
+
|
104
|
+
reload_source
|
105
|
+
run_db_migrate
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def reload_source
|
111
|
+
plugin_dir.to_s.then { |dir|
|
112
|
+
FileUtils.rm_rf(dir)
|
113
|
+
source.load(dir)
|
114
|
+
}
|
115
|
+
end
|
116
|
+
end
|
102
117
|
end
|
103
118
|
end
|
104
119
|
end
|
@@ -2,7 +2,14 @@ module Rexer
|
|
2
2
|
module Extension
|
3
3
|
module Theme
|
4
4
|
def self.dir
|
5
|
-
Pathname.
|
5
|
+
public_themes = Pathname.pwd.join("public", "themes")
|
6
|
+
|
7
|
+
if public_themes.exist?
|
8
|
+
# When Redmine version is v5.1 or older, public/themes is used.
|
9
|
+
public_themes
|
10
|
+
else
|
11
|
+
Pathname.new("themes")
|
12
|
+
end
|
6
13
|
end
|
7
14
|
|
8
15
|
class Base
|
@@ -25,9 +32,7 @@ module Rexer
|
|
25
32
|
end
|
26
33
|
|
27
34
|
def source
|
28
|
-
@source ||= definition.source
|
29
|
-
Source.const_get(src.type.capitalize).new(**src.options)
|
30
|
-
end
|
35
|
+
@source ||= Source.from_definition(definition.source)
|
31
36
|
end
|
32
37
|
end
|
33
38
|
|
@@ -66,7 +71,6 @@ module Rexer
|
|
66
71
|
return unless theme_exists?
|
67
72
|
|
68
73
|
update_source
|
69
|
-
hooks[:updated]&.call
|
70
74
|
end
|
71
75
|
|
72
76
|
private
|
@@ -75,6 +79,23 @@ module Rexer
|
|
75
79
|
source.update(theme_dir.to_s)
|
76
80
|
end
|
77
81
|
end
|
82
|
+
|
83
|
+
class SourceReloader < Base
|
84
|
+
def reload
|
85
|
+
return unless theme_exists?
|
86
|
+
|
87
|
+
reload_source
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def reload_source
|
93
|
+
theme_dir.to_s.then { |dir|
|
94
|
+
FileUtils.rm_rf(dir)
|
95
|
+
source.load(dir)
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
78
99
|
end
|
79
100
|
end
|
80
101
|
end
|
data/lib/rexer/source/base.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module Rexer
|
2
2
|
module Source
|
3
3
|
class Base
|
4
|
-
def self.source_names = @source_names ||= []
|
5
|
-
|
6
4
|
def self.inherited(subclass)
|
7
|
-
|
5
|
+
Source.names << subclass.name.split("::").last.downcase.to_sym
|
8
6
|
end
|
9
7
|
|
8
|
+
# Load the source to the given path.
|
10
9
|
def load(_path)
|
11
10
|
raise "Not implemented"
|
12
11
|
end
|
13
12
|
|
13
|
+
# Update to the latest version of the source.
|
14
14
|
def update(_path)
|
15
15
|
raise "Not implemented"
|
16
16
|
end
|
data/lib/rexer/source.rb
ADDED
data/lib/rexer/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.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-08-
|
11
|
+
date: 2024-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- exe/rex
|
70
70
|
- lib/rexer.rb
|
71
71
|
- lib/rexer/cli.rb
|
72
|
+
- lib/rexer/commands/envs.rb
|
72
73
|
- lib/rexer/commands/install.rb
|
73
74
|
- lib/rexer/commands/state.rb
|
74
75
|
- lib/rexer/commands/switch.rb
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- lib/rexer/definition/lock.rb
|
82
83
|
- lib/rexer/extension/plugin.rb
|
83
84
|
- lib/rexer/extension/theme.rb
|
85
|
+
- lib/rexer/source.rb
|
84
86
|
- lib/rexer/source/base.rb
|
85
87
|
- lib/rexer/source/git.rb
|
86
88
|
- lib/rexer/source/github.rb
|