discharger 0.2.10 → 0.2.12

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +75 -26
  3. data/Rakefile +3 -1
  4. data/lib/discharger/setup_runner/command_factory.rb +56 -0
  5. data/lib/discharger/setup_runner/command_registry.rb +62 -0
  6. data/lib/discharger/setup_runner/commands/asdf_command.rb +61 -0
  7. data/lib/discharger/setup_runner/commands/base_command.rb +185 -0
  8. data/lib/discharger/setup_runner/commands/brew_command.rb +26 -0
  9. data/lib/discharger/setup_runner/commands/bundler_command.rb +25 -0
  10. data/lib/discharger/setup_runner/commands/config_command.rb +51 -0
  11. data/lib/discharger/setup_runner/commands/custom_command.rb +41 -0
  12. data/lib/discharger/setup_runner/commands/database_command.rb +111 -0
  13. data/lib/discharger/setup_runner/commands/docker_command.rb +100 -0
  14. data/lib/discharger/setup_runner/commands/env_command.rb +42 -0
  15. data/lib/discharger/setup_runner/commands/git_command.rb +45 -0
  16. data/lib/discharger/setup_runner/commands/yarn_command.rb +45 -0
  17. data/lib/discharger/setup_runner/condition_evaluator.rb +130 -0
  18. data/lib/discharger/setup_runner/configuration.rb +71 -0
  19. data/lib/discharger/setup_runner/runner.rb +111 -0
  20. data/lib/discharger/setup_runner/version.rb +7 -0
  21. data/lib/discharger/setup_runner.rb +55 -0
  22. data/lib/discharger/task.rb +2 -0
  23. data/lib/discharger/version.rb +1 -1
  24. data/lib/discharger.rb +1 -0
  25. data/lib/generators/discharger/install/install_generator.rb +14 -0
  26. data/lib/generators/discharger/install/templates/setup +36 -0
  27. data/lib/generators/discharger/install/templates/setup.yml +60 -0
  28. metadata +47 -1
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "setup_runner/version"
4
+ require_relative "setup_runner/configuration"
5
+ require_relative "setup_runner/command_registry"
6
+ require_relative "setup_runner/command_factory"
7
+ require_relative "setup_runner/runner"
8
+
9
+ module Discharger
10
+ module SetupRunner
11
+ class << self
12
+ def configure
13
+ yield configuration if block_given?
14
+ end
15
+
16
+ def configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def run(config_path = nil, logger = nil)
21
+ config = config_path ? Configuration.from_file(config_path) : configuration
22
+ runner = Runner.new(config, Dir.pwd, logger)
23
+ yield runner if block_given?
24
+ runner.run
25
+ end
26
+
27
+ # Extension points for adding custom commands
28
+ def register_command(name, command_class)
29
+ CommandRegistry.register(name, command_class)
30
+ end
31
+
32
+ def unregister_command(name)
33
+ # Re-register all commands except the one to remove
34
+ all_commands = {}
35
+ CommandRegistry.names.each do |cmd_name|
36
+ unless cmd_name == name.to_s
37
+ all_commands[cmd_name] = CommandRegistry.get(cmd_name)
38
+ end
39
+ end
40
+ CommandRegistry.clear
41
+ all_commands.each do |cmd_name, cmd_class|
42
+ CommandRegistry.register(cmd_name, cmd_class)
43
+ end
44
+ end
45
+
46
+ def list_commands
47
+ CommandRegistry.names
48
+ end
49
+
50
+ def get_command(name)
51
+ CommandRegistry.get(name)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -16,6 +16,7 @@ module Discharger
16
16
  reissue.updated_paths = task.updated_paths
17
17
  reissue.commit = task.commit
18
18
  reissue.commit_finalize = task.commit_finalize
19
+ reissue.fragment_directory = task.fragment_directory
19
20
  end
20
21
  task.define
21
22
  task
@@ -36,6 +37,7 @@ module Discharger
36
37
  attr_accessor :app_name
37
38
  attr_accessor :commit_identifier
38
39
  attr_accessor :pull_request_url
40
+ attr_accessor :fragment_directory
39
41
 
40
42
  attr_reader :last_message_ts
41
43
 
@@ -1,3 +1,3 @@
1
1
  module Discharger
2
- VERSION = "0.2.10"
2
+ VERSION = "0.2.12"
3
3
  end
data/lib/discharger.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "discharger/version"
2
2
  require "discharger/railtie"
3
+ require "discharger/setup_runner"
3
4
 
4
5
  module Discharger
5
6
  class << self
@@ -3,9 +3,23 @@ module Discharger
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path("templates", __dir__)
5
5
 
6
+ class_option :setup_path,
7
+ type: :string,
8
+ default: "bin/setup",
9
+ desc: "Path where the setup script should be created"
10
+
6
11
  def copy_initializer
7
12
  template "discharger_initializer.rb", "config/initializers/discharger.rb"
8
13
  end
14
+
15
+ def create_setup_script
16
+ template "setup", options[:setup_path]
17
+ chmod options[:setup_path], 0o755
18
+ end
19
+
20
+ def create_sample_setup_yml
21
+ template "setup.yml", "config/setup.yml"
22
+ end
9
23
  end
10
24
  end
11
25
  end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+ require "pathname"
4
+ require "bundler/setup"
5
+
6
+ # Path to the application root.
7
+ APP_ROOT = File.expand_path("..", __dir__)
8
+
9
+ FileUtils.chdir APP_ROOT do
10
+ # This script uses Discharger to set up your development environment automatically.
11
+ # All setup steps are configured in config/setup.yml
12
+ # This script is idempotent, so you can run it at any time and get an expectable outcome.
13
+
14
+ unless File.exist?("Gemfile")
15
+ puts "No Gemfile found. Please run this script from the root of your Rails application."
16
+ exit 1
17
+ end
18
+
19
+ unless File.exist?("config/setup.yml")
20
+ puts "No config/setup.yml found. Please run 'rails generate discharger:install' first."
21
+ exit 1
22
+ end
23
+
24
+ puts "== Running Discharger setup =="
25
+ puts "Configuration loaded from: config/setup.yml"
26
+
27
+ # Load Rails environment first, then discharger
28
+ require_relative "../config/application"
29
+ Rails.application.initialize!
30
+
31
+ # Load the discharger gem and run the setup
32
+ require "discharger"
33
+ Discharger::SetupRunner.run("config/setup.yml")
34
+
35
+ puts "\n== Setup completed successfully! =="
36
+ end
@@ -0,0 +1,60 @@
1
+ # Discharger Setup Configuration
2
+ # This file defines the setup process for your application
3
+ # Customize the configuration based on your project needs
4
+
5
+ # Application name
6
+ app_name: "YourAppName"
7
+
8
+ # Database configuration
9
+ database:
10
+ port: 5432
11
+ name: "db-your-app"
12
+ version: "14"
13
+ password: "postgres"
14
+
15
+ # Redis configuration (if using Redis)
16
+ redis:
17
+ port: 6379
18
+ name: "redis-your-app"
19
+ version: "latest"
20
+
21
+ # Built-in commands to run (empty array runs all available commands)
22
+ # Available commands: brew, asdf, git, bundler, yarn, config, docker, env, database
23
+ steps:
24
+ - brew
25
+ - asdf
26
+ - git
27
+ - bundler
28
+ - yarn
29
+ - config
30
+ - docker
31
+ - env
32
+ - database
33
+
34
+ # Custom commands for application-specific setup
35
+ custom_steps:
36
+ - description: "Seed application data"
37
+ command: "bin/rails db:seed"
38
+
39
+ - description: "Setup application-specific configurations"
40
+ command: "bin/rails runner 'YourAppSetup.new.configure'"
41
+ condition: "defined?(YourAppSetup)"
42
+
43
+ - description: "Import application data"
44
+ command: "bin/rails db:seed:import"
45
+ condition: "File.exist?('db/seeds/import.rb')"
46
+
47
+ # Example: Conditional setup based on environment variable
48
+ # - description: "Seed legacy data"
49
+ # command: "LEGACY_DATA=true bin/rails db:seed"
50
+ # condition: "ENV['LEGACY_DATA'] == 'true'"
51
+
52
+ # Example: Setup external services
53
+ # - description: "Setup Elasticsearch"
54
+ # command: "bin/rails search:setup"
55
+ # condition: "defined?(Elasticsearch)"
56
+
57
+ # Example: Setup background job processing
58
+ # - description: "Setup Sidekiq"
59
+ # command: "bundle exec sidekiq -d"
60
+ # condition: "defined?(Sidekiq)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discharger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: prism
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.19.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.19.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rails
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -92,16 +106,47 @@ files:
92
106
  - Rakefile
93
107
  - lib/discharger.rb
94
108
  - lib/discharger/railtie.rb
109
+ - lib/discharger/setup_runner.rb
110
+ - lib/discharger/setup_runner/command_factory.rb
111
+ - lib/discharger/setup_runner/command_registry.rb
112
+ - lib/discharger/setup_runner/commands/asdf_command.rb
113
+ - lib/discharger/setup_runner/commands/base_command.rb
114
+ - lib/discharger/setup_runner/commands/brew_command.rb
115
+ - lib/discharger/setup_runner/commands/bundler_command.rb
116
+ - lib/discharger/setup_runner/commands/config_command.rb
117
+ - lib/discharger/setup_runner/commands/custom_command.rb
118
+ - lib/discharger/setup_runner/commands/database_command.rb
119
+ - lib/discharger/setup_runner/commands/docker_command.rb
120
+ - lib/discharger/setup_runner/commands/env_command.rb
121
+ - lib/discharger/setup_runner/commands/git_command.rb
122
+ - lib/discharger/setup_runner/commands/yarn_command.rb
123
+ - lib/discharger/setup_runner/condition_evaluator.rb
124
+ - lib/discharger/setup_runner/configuration.rb
125
+ - lib/discharger/setup_runner/runner.rb
126
+ - lib/discharger/setup_runner/version.rb
95
127
  - lib/discharger/task.rb
96
128
  - lib/discharger/version.rb
97
129
  - lib/generators/discharger/install/install_generator.rb
98
130
  - lib/generators/discharger/install/templates/discharger_initializer.rb
131
+ - lib/generators/discharger/install/templates/setup
132
+ - lib/generators/discharger/install/templates/setup.yml
99
133
  homepage: https://github.com/SOFware/discharger
100
134
  licenses: []
101
135
  metadata:
102
136
  homepage_uri: https://github.com/SOFware/discharger
103
137
  source_code_uri: https://github.com/SOFware/discharger.git
104
138
  changelog_uri: https://github.com/SOFware/discharger/blob/main/CHANGELOG.md
139
+ post_install_message: |2+
140
+
141
+ Thanks for installing Discharger!
142
+
143
+ To get started, run the generator in your Rails application:
144
+
145
+ rails generate discharger:install
146
+
147
+ This will create a bin/setup script and config/setup.yml file
148
+ to help automate your development environment setup.
149
+
105
150
  rdoc_options: []
106
151
  require_paths:
107
152
  - lib
@@ -120,3 +165,4 @@ rubygems_version: 3.6.7
120
165
  specification_version: 4
121
166
  summary: Tasks for discharging an application for deployment.
122
167
  test_files: []
168
+ ...