Class: Zwischen::Setup
- Inherits:
-
Object
- Object
- Zwischen::Setup
- Defined in:
- lib/zwischen/setup.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Setup
constructor
A new instance of Setup.
- #run ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize ⇒ Setup
Returns a new instance of Setup.
19 20 21 |
# File 'lib/zwischen/setup.rb', line 19 def initialize @shell = Thor::Shell::Color.new end |
Class Method Details
.run ⇒ Object
11 12 13 |
# File 'lib/zwischen/setup.rb', line 11 def self.run new.run end |
.uninstall ⇒ Object
15 16 17 |
# File 'lib/zwischen/setup.rb', line 15 def self.uninstall new.uninstall end |
Instance Method Details
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zwischen/setup.rb', line 23 def run @shell.say("\nš”ļø Installing Zwischen security layer...\n", :bold) check_tools configure_credentials install_hook create_config @shell.say(" ā Done!", :green) @shell.say("\nZwischen will now scan automatically before pushes.") @shell.say("Run 'zwischen scan' to test it now.\n") end |
#uninstall ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/zwischen/setup.rb', line 36 def uninstall @shell.say("\nšļø Zwischen Uninstall\n", :bold) project_root = Dir.pwd hook_path = Hooks.hook_path(project_root) # Remove hook if Hooks.installed?(project_root) if @shell.yes?("Remove git hook?", default: true) if Hooks.uninstall(project_root) @shell.say(" ā Removed .git/hooks/pre-push", :green) else @shell.say(" ā Failed to remove hook", :red) end end else @shell.say(" ā³ No Zwischen hook found", :yellow) end # Remove config config_path = File.join(project_root, Config::CONFIG_FILE) if File.exist?(config_path) if @shell.yes?("Remove project config (.zwischen.yml)?", default: false) File.delete(config_path) @shell.say(" ā Removed .zwischen.yml", :green) else @shell.say(" ā³ Kept .zwischen.yml", :yellow) end end # Remove credentials if File.exist?(Credentials.credentials_path) if @shell.yes?("Remove global credentials (~/.zwischen/credentials)?", default: false) File.delete(Credentials.credentials_path) @shell.say(" ā Removed credentials", :green) else @shell.say(" ā³ Kept credentials", :yellow) end end @shell.say("\nā Zwischen uninstalled from this project.\n", :green) end |