rexer 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c8c8383d931ce1824f0b3dff3b835d16b242803e3991f1ab9ff3b60df396ecc
4
- data.tar.gz: 03270c384dfe36f34ee418a48847d671e470bb49f1699c69944a3f38326bdf37
3
+ metadata.gz: 8718806ffc0a827890d574a6396e88904059b58b5087b6ac09740da7bd39be42
4
+ data.tar.gz: b651388f82e418b597bbdf59016bf5a392b86593a462db1248eee5e6c101239f
5
5
  SHA512:
6
- metadata.gz: f06dd899a19bb55eab11bd5891b40ab1135cf5b2f4ee001b744bd2e2421a543470b960d6a7ea369efc9c96c98c1784eb1ff37a35445d1270ee5699c9a012ebb1
7
- data.tar.gz: cb0652c4d01e86e99f2c727c29ebc276d988e5f174ec0be980df977ad8fdf0118234decec87143ba5da57b9b575466d1edf77bc6eec7cc0eef723bf1fdb2c408
6
+ metadata.gz: ba24fbdc765bc378b6fd024c9e9215db5476c40cb77890da0468343374d79049d2bbb18d2a216377c71d4cc42d77a221c75493f3783f553521b29b27c8a1641d
7
+ data.tar.gz: fde4958f98ae92922e07a16b8b0564897a7449ab8f16b5102c9ca77389614290a7e5c59128af436843e028783094ba017af9ef59b4fd99250ca494f00845dff5
data/README.md CHANGED
@@ -1,11 +1,26 @@
1
- # Rexer: Redmine Extension manager
2
-
3
- Rexer is a tool for managing Redmine Extension, which means Redmine [Plugin](https://www.redmine.org/projects/redmine/wiki/Plugins) and [Theme](https://www.redmine.org/projects/redmine/wiki/Themes) in this tool.
1
+ <div align="center">
2
+ <h1>Rexer</h1>
3
+ <p>Redmine Extension (Plugin and Theme) manager</p>
4
+ </div>
5
+
6
+ <p align="center">
7
+ <a href="https://github.com/hidakatsuya/rexer/actions/workflows/build.yml">
8
+ <img src="https://github.com/hidakatsuya/rexer/actions/workflows/build.yml/badge.svg" alt="Build">
9
+ </a>
10
+ <a href="https://badge.fury.io/rb/rexer">
11
+ <img src="https://badge.fury.io/rb/rexer.svg" alt="Gem Version">
12
+ </a>
13
+ </p>
14
+
15
+ Rexer is a command-line tool for managing Redmine Extension (Plugin and Theme).
4
16
 
5
17
  It is mainly aimed at helping with the development of Redmine and its plugins, allowing you to define extensions in a Ruby DSL and install, uninstall, update, and switch between different sets of the extensions.
6
18
 
7
- [![Build](https://github.com/hidakatsuya/rexer/actions/workflows/build.yml/badge.svg)](https://github.com/hidakatsuya/rexer/actions/workflows/build.yml)
8
- [![Gem Version](https://badge.fury.io/rb/rexer.svg)](https://badge.fury.io/rb/rexer)
19
+ [![demo](docs/demo-v0.8.0.gif)](https://asciinema.org/a/672754)
20
+
21
+ ## What is Redmine Extension?
22
+
23
+ Redmine [Plugin](https://www.redmine.org/projects/redmine/wiki/Plugins) and [Theme](https://www.redmine.org/projects/redmine/wiki/Themes) are called Redmine Extension in this tool.
9
24
 
10
25
  ## Installation
11
26
 
@@ -19,14 +34,17 @@ Rexer is tested with Redmine v5.1 and trunk.
19
34
 
20
35
  ## Usage
21
36
 
22
- ### Quick Start
37
+ Run the following command in the root directory of the Redmine application.
23
38
 
24
- First, create a `.extensions.rb` file in the root directory of the Redmine application.
39
+ ```
40
+ rex init
41
+ ```
42
+
43
+ This command generates a `.extensions.rb`, so define the extensions you want to install in the file like below.
25
44
 
26
45
  ```ruby
27
46
  theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "support-propshaft" }
28
47
 
29
- plugin :view_customize, github: { repo: "onozaty/redmine-view-customize", tag: "v3.5.2" }
30
48
  plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.2" }
31
49
  ```
32
50
 
@@ -36,10 +54,18 @@ Then, run the following command in the root directory of the Redmine application
36
54
  rex install
37
55
  ```
38
56
 
39
- This command installs plugins and themes defined in the `.extensions.rb` file and generates the `.extensions.lock` file.
57
+ This command performs the following steps for each extension defined in the `.extensions.rb` to install it and generates a `.extensions.lock`.
58
+
59
+ For plugins:
60
+ * Load the plugin from the specified `git` or `github` repository.
61
+ * Run the `bundle install` command if the plugin has a `Gemfile`.
62
+ * Run the `bundle exec rake redmine:plugins:migrate NAME=<plugin_name>` command if the plugin has any database migration.
63
+
64
+ For themes:
65
+ * Load the theme from the specified `git` or `github` repository.
40
66
 
41
67
  > [!NOTE]
42
- > The `.extensions.lock` file is a file that locks the state of the installed extensions, but it's NOT a file that locks the version of the extensions.
68
+ > The `.extensions.lock` is a file for preserving the state of installed extensions, but not the version of an extension.
43
69
 
44
70
  If you want to uninstall the extensions, run the following command.
45
71
 
@@ -47,24 +73,29 @@ If you want to uninstall the extensions, run the following command.
47
73
  rex uninstall
48
74
  ```
49
75
 
50
- This command uninstalls the extensions and deletes the `.extensions.lock` file.
76
+ This command uninstalls the extensions and deletes the `.extensions.lock`.
51
77
 
52
- ### Commands
78
+ ## Commands
53
79
 
54
80
  ```
55
81
  $ rex
56
82
  Commands:
57
- rex help [COMMAND] # Describe available commands or one specific command
58
83
  rex envs # Show the list of defined environments in .extensions.rb
59
- rex install [ENV] # Install extensions for the specified environment
84
+ rex help [COMMAND] # Describe available commands or one specific command
85
+ rex init # Create a new .extensions.rb file
86
+ rex install [ENV] # Install the definitions in .extensions.rb for the specified environment
60
87
  rex state # Show the current state of the installed extensions
61
- rex switch [ENV] # Uninstall extensions for the currently installed environment and install extensions for the specified environment
62
- rex uninstall # Uninstall extensions for the currently installed environment
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...
63
90
  rex update # Update extensions for the currently installed environment to the latest version
64
91
  rex version # Show Rexer version
92
+
93
+ Options:
94
+ -v, [--verbose], [--no-verbose], [--skip-verbose] # Detailed output
95
+ -q, [--quiet], [--no-quiet], [--skip-quiet] # Minimal output
65
96
  ```
66
97
 
67
- #### rex install [ENV]
98
+ ### rex install [ENV]
68
99
 
69
100
  Installs extensions in the specified ENV environment and makes them available for use. Specifically, it does the following:
70
101
 
@@ -73,30 +104,34 @@ If the specified ENV is NOT currently installed, it adds all extensions in the E
73
104
  If the specified ENV is currently installed, it compares the current `.extensions.lock` with `.extensions.rb` and does the following:
74
105
  * Installs additional extensions (the `installed` hook is executed).
75
106
  * Uninstalls deleted extensions (the `uninstalled` hook is executed).
76
- * Re-fetches extensions whose source settings has changed (for example, the `branch` or `tag` has changed) and runs the database migration if necessary.
107
+ * Reload extensions whose source settings has changed (for example, the `branch` or `tag` has changed) and runs the database migration if necessary.
77
108
 
78
- #### rex update
109
+ ### rex update
79
110
 
80
111
  Loads `.extensions.lock` and updates the currently installed extensions to the latest version. `.extensions.rb` is NOT referenced in this command.
81
112
 
113
+ ## Advanced Usage
114
+
82
115
  ### Defining for each environment and extension
83
116
 
84
117
  You can define an environment and extensions for each environment using the `env ... do - end` block.
85
118
 
86
119
  ```ruby
87
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair" }
88
120
  plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel" }
89
121
 
90
122
  env :stable do
91
- theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "support-propshaft" }
92
123
  plugin :redmine_issues_panel, git: { url: "https://github.com/redmica/redmine_issues_panel", tag: "v1.0.2" }
93
124
  end
125
+
126
+ env :default, :stable do
127
+ theme :bleuclair, github: { repo: "farend/redmine_theme_farend_bleuclair", branch: "support-propshaft" }
128
+ end
94
129
  ```
95
130
 
96
131
  Definitions other than `env ... do - end` are implicitly defined as `env :default do - end`. Therefore, the above is resolved as follows:
97
132
 
98
133
  * default env
99
- * bleuclair (master)
134
+ * bleuclair (support-propshaft)
100
135
  * redmine_issues_panel (master)
101
136
  * stable env
102
137
  * bleuclair (support-propshaft)
data/lib/rexer/cli.rb CHANGED
@@ -9,6 +9,11 @@ module Rexer
9
9
  class_option :verbose, type: :boolean, aliases: "-v", desc: "Detailed output"
10
10
  class_option :quiet, type: :boolean, aliases: "-q", desc: "Minimal output"
11
11
 
12
+ desc "init", "Create a new .extensions.rb file"
13
+ def init
14
+ Commands::Init.new.call
15
+ end
16
+
12
17
  desc "install [ENV]", "Install the definitions in .extensions.rb for the specified environment"
13
18
  def install(env = "default")
14
19
  Commands::Install.new.call(env&.to_sym)
@@ -6,9 +6,7 @@ module Rexer
6
6
  end
7
7
 
8
8
  def call
9
- defined_envs.each do
10
- puts _1
11
- end
9
+ puts(*defined_envs)
12
10
  end
13
11
 
14
12
  private
@@ -17,7 +15,7 @@ module Rexer
17
15
 
18
16
  def defined_envs
19
17
  all_envs = definition.plugins.map(&:env) + definition.themes.map(&:env)
20
- all_envs.uniq
18
+ all_envs.uniq.sort
21
19
  end
22
20
  end
23
21
  end
@@ -0,0 +1,39 @@
1
+ module Rexer
2
+ module Commands
3
+ class Init
4
+ def call
5
+ definition_file = Definition.file
6
+
7
+ if definition_file.exist?
8
+ puts Paint["#{definition_file.basename} already exists", :red]
9
+ exit 1
10
+ end
11
+
12
+ definition_file.write(template)
13
+
14
+ puts Paint["#{definition_file.expand_path} created", :green]
15
+ end
16
+
17
+ private
18
+
19
+ def template
20
+ <<~TEMPLATE
21
+ # Define themes and plugins you want to use in your Redmine here.
22
+ #
23
+ # Syntax for defining themes and plugins is as follows.
24
+ # For theme_id and plugin_id, specify the name of the installation directory.
25
+ #
26
+ # theme :theme_a_id, github: { repo: "repo/theme_a" }
27
+ # theme :theme_b_id, github: { repo: "repo/theme_b", ref: "abcdefghi" }
28
+ # plugin :plugin_a_id, github: { repo: "repo/plugin_a", tag: "v1.0.0" }
29
+ # plugin :plugin_b_id, git: { url: "https://github.com/repo/plugin_b.git", branch: "stable" }
30
+ #
31
+ # Then, run `rex install` to install these themes and plugins.
32
+ #
33
+ # For more usage, see https://github.com/hidakatsuya/rexer.
34
+
35
+ TEMPLATE
36
+ end
37
+ end
38
+ end
39
+ end
@@ -36,6 +36,10 @@ module Rexer
36
36
  Rexer.verbosity.on(:info) { puts Paint["done", :green] }
37
37
  end
38
38
 
39
+ def skipped(reason)
40
+ Rexer.verbosity.on(:info) { puts Paint["skipped (#{reason})", :yellow] }
41
+ end
42
+
39
43
  def processing(process_title)
40
44
  Rexer.verbosity.on(:debug) { puts Paint[process_title, :gray] }
41
45
  end
@@ -25,11 +25,13 @@ module Rexer
25
25
  )
26
26
  end
27
27
 
28
- def env(env_name, &dsl)
29
- data = self.class.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
28
+ def env(*env_names, &dsl)
29
+ env_names.each do |env_name|
30
+ data = self.class.new(env_name).tap { _1.instance_eval(&dsl) }.to_data
30
31
 
31
- @plugins += data.plugins
32
- @themes += data.themes
32
+ @plugins += data.plugins
33
+ @themes += data.themes
34
+ end
33
35
  end
34
36
 
35
37
  def to_data
@@ -62,10 +62,13 @@ module Rexer
62
62
 
63
63
  class Install < Base
64
64
  def call
65
- return if plugin_exists?
66
-
67
65
  broadcast(:started, "Install #{name}")
68
66
 
67
+ if plugin_exists?
68
+ broadcast(:skipped, "Already exists")
69
+ return
70
+ end
71
+
69
72
  load_from_source
70
73
  run_bundle_install
71
74
  run_db_migrate
@@ -93,10 +96,13 @@ module Rexer
93
96
 
94
97
  class Uninstall < Base
95
98
  def call
96
- return unless plugin_exists?
97
-
98
99
  broadcast(:started, "Uninstall #{name}")
99
100
 
101
+ unless plugin_exists?
102
+ broadcast(:skipped, "Not exists")
103
+ return
104
+ end
105
+
100
106
  reset_db_migration
101
107
  remove_plugin
102
108
  hooks[:uninstalled]&.call
@@ -121,6 +127,11 @@ module Rexer
121
127
 
122
128
  broadcast(:started, "Update #{name}")
123
129
 
130
+ unless source.updatable?
131
+ broadcast(:skipped, "Not updatable")
132
+ return
133
+ end
134
+
124
135
  update_source
125
136
  run_db_migrate
126
137
 
@@ -42,10 +42,13 @@ module Rexer
42
42
 
43
43
  class Install < Base
44
44
  def call
45
- return if theme_exists?
46
-
47
45
  broadcast(:started, "Install #{name}")
48
46
 
47
+ if theme_exists?
48
+ broadcast(:skipped, "Already exists")
49
+ return
50
+ end
51
+
49
52
  load_from_source
50
53
  hooks[:installed]&.call
51
54
 
@@ -61,10 +64,13 @@ module Rexer
61
64
 
62
65
  class Uninstall < Base
63
66
  def call
64
- return unless theme_exists?
65
-
66
67
  broadcast(:started, "Uninstall #{name}")
67
68
 
69
+ unless theme_exists?
70
+ broadcast(:skipped, "Not exists")
71
+ return
72
+ end
73
+
68
74
  remove_theme
69
75
  hooks[:uninstalled]&.call
70
76
 
@@ -15,6 +15,12 @@ module Rexer
15
15
  raise "Not implemented"
16
16
  end
17
17
 
18
+ # Check if the source can be updated to a newer version.
19
+ def updatable?
20
+ raise "Not implemented"
21
+ end
22
+
23
+ # Return the status of the source.
18
24
  def info = ""
19
25
  end
20
26
  end
@@ -19,6 +19,10 @@ module Rexer
19
19
  load(path)
20
20
  end
21
21
 
22
+ def updatable?
23
+ !branch.nil?
24
+ end
25
+
22
26
  def info
23
27
  branch || tag || ref || "master"
24
28
  end
data/lib/rexer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rexer
2
- VERSION = "0.7.0"
2
+ VERSION = "0.9.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.7.0
4
+ version: 0.9.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-20 00:00:00.000000000 Z
11
+ date: 2024-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -94,9 +94,9 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.1'
97
- description: Rexer is a tool for managing Redmine Extension (Plugin and Themes). It
98
- allows you to define extensions in a Ruby DSL and install, uninstall, update, and
99
- switch between different sets of the extensions.
97
+ description: Rexer is a command-line tool for managing Redmine Extension (Plugin and
98
+ Themes). It allows you to define extensions in a Ruby DSL and install, uninstall,
99
+ update, and switch between different sets of the extensions.
100
100
  email:
101
101
  - hidakatsuya@gmail.com
102
102
  executables:
@@ -113,6 +113,7 @@ files:
113
113
  - lib/rexer/cli.rb
114
114
  - lib/rexer/commands.rb
115
115
  - lib/rexer/commands/envs.rb
116
+ - lib/rexer/commands/init.rb
116
117
  - lib/rexer/commands/install.rb
117
118
  - lib/rexer/commands/state.rb
118
119
  - lib/rexer/commands/switch.rb
@@ -153,5 +154,5 @@ requirements: []
153
154
  rubygems_version: 3.5.11
154
155
  signing_key:
155
156
  specification_version: 4
156
- summary: A tool for managing Redmine Plugins and Themes
157
+ summary: A command-line tool for managing Redmine Plugins and Themes
157
158
  test_files: []