opskit 0.3.0 → 0.4.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
  SHA1:
3
- metadata.gz: 9209f0b04c7c210ce8cc00d6522293c42ac18988
4
- data.tar.gz: e884c18f2456ffc6701be54b85ebf16b8ffe168c
3
+ metadata.gz: d89b64c75f4eddaf021b4e895360a1734d59a49c
4
+ data.tar.gz: e5c635f6b09595fde80f58555803feaf3a6b96a9
5
5
  SHA512:
6
- metadata.gz: 834dc05dfd7bfe5365b2ac5de1113575a3d7a2320bbfe89948b5f3603e4c76610656412995b2ab35a50e2957c52d4c8c183f76651f355bcae256faba05cbe058
7
- data.tar.gz: d6d61b96af46e6bd4030536950445136a558eafc5255fcd22c8c6231fb0e1aa8fb8b1e1dc20b3ca16413c60d2f8fbf8aa9175caabd21b00cc11c52ba86ac2312
6
+ metadata.gz: 36ad979ad1dd415917edcdf427c30bbc465c5bd1bf246cfed1dc28831cb439c0fda2dc6f94bedcade1f9968d137ee6fadb0c6da5453b7fa80a6764f6c3ec3f29
7
+ data.tar.gz: b8905f380e197cff419dd7c43213c01217c7354b2402af24c745a28a11867ba0173c919e4d5c42625d6f175ffbce209332ff626c1f0bddc895249533a109ea6f
@@ -4,5 +4,17 @@ require "opskit/version"
4
4
  require "opskit/cli"
5
5
  require "opskit/vhost"
6
6
  require "opskit/host"
7
+ require "opskit/configuration"
8
+ require 'thor/actions'
7
9
 
8
- module OpsKit;end
10
+ module OpsKit
11
+
12
+ class << self
13
+ attr_accessor :configuration
14
+ end
15
+
16
+ def self.configure name
17
+ self.configuration ||= Configuration.new(name)
18
+ #yield(configuration) #Not sure if we need somthing like initializers
19
+ end
20
+ end
@@ -1,27 +1,101 @@
1
1
  require 'thor'
2
2
  require 'thor/actions'
3
3
  require 'yaml'
4
+ require 'fileutils'
4
5
 
5
6
  module OpsKit
6
7
  class OdinSon < Thor
7
8
  include Thor::Actions
8
9
 
9
- desc "export", "Generates vhost and host file config"
10
- def export
11
- conf = {}
12
- conf[:url] = ask "What is the dev url?"
13
- conf[:docroot] = ask "What is the docroot?"
10
+ desc "setup", "Setup a project based on a git repo"
11
+ def setup (repo, name=nil)
12
+ if !name
13
+ name = repo.split('/').last.split(".git").first
14
+ end
15
+
16
+ OpsKit.configure name
17
+
18
+ if Dir.exist? OpsKit.configuration.project_root
19
+ return if no? "This project already exists do you want to overwrite it?"
20
+ clean name
21
+ end
22
+
23
+ say "Cloning repo into #{OpsKit.configuration.project_root}", :cyan
24
+ run "git clone #{repo} #{name}"
25
+
26
+ if yes? "create vhost?"
27
+ ask_for_url
28
+ ask_for_docroot
29
+
30
+ vhost = OpsKit::VHost.new( {template: OpsKit.configuration.template, url: OpsKit.configuration.url, docroot: OpsKit.configuration.docroot } )
31
+ say "Create vhost for #{vhost.conf[:url]} at #{vhost.vhost_location}", :cyan
32
+ run "echo '#{vhost.render}' | sudo tee #{vhost.vhost_location}"
33
+ run "sudo a2ensite #{vhost.conf[:url]}"
14
34
 
15
- if yes?("Is it a custom template? y/n")
16
- conf[:template_path] = ask "What is the template path?"
35
+ say "Creating hosts entry", :cyan
36
+ run "grep -q -F '127.0.0.1 #{vhost.conf[:url]}' /etc/hosts || echo '127.0.0.1 #{vhost.conf[:url]}' | sudo tee -a /etc/hosts"
37
+
38
+ say "Reload the apache2 server", :cyan
39
+ run "sudo service apache2 reload"
40
+ end
41
+
42
+ end
43
+
44
+ desc "clean", "Cleans a project from your system"
45
+ def clean (name)
46
+ OpsKit.configure name
47
+
48
+ if Dir.exist? OpsKit.configuration.project_root
49
+ return if no? "This will remove #{OpsKit.configuration.project_root} are you sure?"
50
+ FileUtils.rm_rf(OpsKit.configuration.project_root)
17
51
  else
18
- conf[:template] = ask "What is the template?"
52
+ return if no? "Can´t find the project continue cleaning?"
53
+ end
54
+
55
+ if yes? "clean vhost?"
56
+
57
+ ask_for_url
58
+ vhost = OpsKit::VHost.new( {template: OpsKit.configuration.template, url: OpsKit.configuration.url, docroot: OpsKit.configuration.docroot } )
59
+
60
+ say "Removing the hosts entry for #{vhost.conf[:url]}", :cyan
61
+ run "sed '/127.0.0.1 #{vhost.conf[:url]}/d' /etc/hosts | sudo tee /etc/hosts"
62
+
63
+ say "Disabling #{vhost.conf[:url]}", :cyan
64
+ run "sudo a2dissite #{vhost.conf[:url]}"
65
+
66
+ say "Remove #{vhost.vhost_location}", :cyan
67
+ if File.exist? vhost.vhost_location
68
+ run "sudo rm #{vhost.vhost_location}"
69
+ else
70
+ say "Couldn't find #{vhost.vhost_location}", :red
71
+ end
72
+
73
+ say "Reload the apache2 server", :cyan
74
+ run "sudo service apache2 reload"
75
+ end
76
+ end
77
+
78
+ no_commands do
79
+ def ask_for_url
80
+ url = ask "What is the dev url? [#{OpsKit.configuration.url}]"
81
+
82
+ return if url == ""
83
+
84
+ OpsKit.configuration.url = url
19
85
  end
20
86
 
21
- vhost = OpsKit::VHost.new( conf )
87
+ def ask_for_docroot
88
+ path = ask "What is the docroot? [#{OpsKit.configuration.docroot}]"
22
89
 
23
- system "echo '#{vhost.render}' | sudo tee #{ vhost.vhost_location }"
24
- system "echo '127.0.0.1\t#{ conf[:url]}' | sudo tee -a /etc/hosts"
90
+ return if path == "" || path == "/"
91
+
92
+ if path.start_with? "/"
93
+ OpsKit.configuration.docroot = path
94
+ else
95
+ OpsKit.configuration.docroot = "#{OpsKit.configuration.docroot}/#{path}"
96
+ end
97
+ end
25
98
  end
99
+
26
100
  end
27
101
  end
@@ -0,0 +1,18 @@
1
+ module OpsKit
2
+ class Configuration
3
+ attr_accessor :name
4
+ attr_accessor :project_root
5
+ attr_accessor :url
6
+ attr_accessor :template
7
+ attr_accessor :docroot
8
+
9
+ def initialize name
10
+ @name = name
11
+ @project_root = "#{Dir.pwd}/#{name}" # get default location for project folders from ~/.opskit/config.yml or something
12
+ @url = "dev.#{name}.nl"
13
+ @template = "apache"
14
+ @docroot = "#{@project_root}"
15
+ end
16
+
17
+ end
18
+ end
@@ -1,8 +1,8 @@
1
1
  <VirtualHost *:80>
2
2
  ServerName <%= url %>
3
- DocumentRoot <%= Dir.pwd %>/<%= docroot %>
3
+ DocumentRoot <%= docroot %>
4
4
 
5
- <Directory "<%= Dir.pwd %>/<%= docroot %>/"
5
+ <Directory "<%= docroot %>">
6
6
  Options Indexes FollowSymLinks Includes ExecCGI
7
7
  AllowOverride All
8
8
  Require all granted
@@ -1,3 +1,3 @@
1
1
  module OpsKit
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opskit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "ClikeX\n\n"
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - bin/opskit
79
79
  - lib/opskit.rb
80
80
  - lib/opskit/cli.rb
81
+ - lib/opskit/configuration.rb
81
82
  - lib/opskit/host.rb
82
83
  - lib/opskit/templates/apache.erb.conf
83
84
  - lib/opskit/version.rb
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  version: '0'
103
104
  requirements: []
104
105
  rubyforge_project:
105
- rubygems_version: 2.6.3
106
+ rubygems_version: 2.5.1
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: Command line tool to simplify setting up dev environments