topkit 0.1.0 → 1.0.0.pre.1
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/Gemfile +0 -1
- data/{LICENSE.txt → LICENSE.md} +1 -1
- data/README.md +10 -24
- data/Rakefile +1 -0
- data/bin/ripen +248 -0
- data/bin/topkit +111 -7
- data/lib/templates/database.yml +9 -0
- data/lib/templates/developer/database.yml +7 -0
- data/lib/templates/developer/topkit.yml +3 -0
- data/lib/templates/nginx.conf +27 -0
- data/lib/templates/topkit.yml +14 -0
- data/lib/templates/unicorn.rb +8 -0
- data/lib/templates/unicorn_init +84 -0
- data/lib/topkit/developer/base.rb +156 -0
- data/lib/topkit/developer/database.rb +17 -0
- data/lib/topkit/developer/installer.rb +46 -0
- data/lib/topkit/developer/site.rb +193 -0
- data/lib/topkit/developer/symlinks.rb +53 -0
- data/lib/topkit/developer/user.rb +53 -0
- data/lib/topkit/server/base.rb +84 -0
- data/lib/topkit/server/console.rb +11 -0
- data/lib/topkit/server/installer.rb +117 -0
- data/lib/topkit/server/symlinks.rb +53 -0
- data/lib/topkit/server/updater.rb +21 -0
- data/lib/topkit/version.rb +1 -1
- data/lib/topkit.rb +23 -2
- data/topkit.gemspec +10 -10
- metadata +50 -46
- data/lib/topkit/actions.rb +0 -41
- data/lib/topkit/app_builder.rb +0 -112
- data/lib/topkit/generators/app_generator.rb +0 -109
- data/templates/Gemfile_clean +0 -41
- data/templates/_footer.html.erb +0 -2
- data/templates/_header.html.erb +0 -2
- data/templates/_status.html.erb +0 -6
- data/templates/application_layout.html.erb +0 -35
- data/templates/database.pg.yml.erb +0 -55
- data/templates/database_cleaner_rspec.rb +0 -21
- data/templates/topkit_gitignore +0 -2
- data/test/lib/topkit/version_test.rb +0 -7
- data/test/test_helper.rb +0 -3
@@ -0,0 +1,117 @@
|
|
1
|
+
module Topkit
|
2
|
+
module Server
|
3
|
+
class Installer < Base
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
clone_repo
|
7
|
+
checkout_release_branch
|
8
|
+
install_bundle
|
9
|
+
add_database_config
|
10
|
+
add_unicorn_config
|
11
|
+
add_nginx_config
|
12
|
+
add_topkit_config
|
13
|
+
create_and_migrate_database
|
14
|
+
precompile_assets
|
15
|
+
create_default_user
|
16
|
+
transfer_ownership
|
17
|
+
start_server
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def clone_repo
|
23
|
+
system("cd #{@@home} && git clone #{@@git_url} #{@@app_name}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def checkout_release_branch
|
27
|
+
system("cd #{@@root} && git checkout -b release origin/release")
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_database_config
|
31
|
+
system("cd #{@@root} && sudo -u postgres psql -c \"DROP DATABASE IF EXISTS #{@@db_name};\"")
|
32
|
+
system("cd #{@@root} && sudo -u postgres psql -c \"DROP ROLE IF EXISTS #{@@db_user};\"")
|
33
|
+
system("cd #{@@root} && sudo -u postgres psql -c \"CREATE ROLE #{@@db_user} LOGIN CREATEDB PASSWORD '#{@@db_pass}';\"")
|
34
|
+
config = template('database.yml')
|
35
|
+
.gsub(/\[db_user\]/, @@db_user)
|
36
|
+
.gsub(/\[db_pass\]/, @@db_pass)
|
37
|
+
.gsub(/\[db_name\]/, @@db_name)
|
38
|
+
File.open(@@db_file, 'w+') { |f| f.write(config) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_unicorn_config
|
42
|
+
# Service
|
43
|
+
config = template('unicorn_init')
|
44
|
+
.gsub(/\[root\]/, @@root)
|
45
|
+
.gsub(/\[user\]/, @@user)
|
46
|
+
File.open(@@unicorn_init, 'w+') { |f| f.write(config) }
|
47
|
+
system("chmod +x #{@@unicorn_init}")
|
48
|
+
# App Config
|
49
|
+
config = template('unicorn.rb')
|
50
|
+
.gsub(/\[root\]/, @@root)
|
51
|
+
.gsub(/\[app_name\]/, @@app_name)
|
52
|
+
File.open(@@unicorn_file, 'w+') { |f| f.write(config) }
|
53
|
+
system("mkdir -p #{@@root}/tmp/pids")
|
54
|
+
# Update
|
55
|
+
system("update-rc.d -f #{@@service} defaults")
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_nginx_config
|
59
|
+
@@server_name = ask("Domain for your Topkit instance (without http)? ")
|
60
|
+
config = template('nginx.conf')
|
61
|
+
.gsub(/\[app_name\]/, @@app_name)
|
62
|
+
.gsub(/\[server_name\]/, @@server_name)
|
63
|
+
File.open(@@nginx_file, 'w+') { |f| f.write(config) }
|
64
|
+
# Remove the default config file
|
65
|
+
system("rm /etc/nginx/sites-enabled/default")
|
66
|
+
# Restart the service
|
67
|
+
system("service nginx restart")
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_topkit_config
|
71
|
+
config = template('topkit.yml').gsub!(/\[url\]/, @@server_name)
|
72
|
+
|
73
|
+
say "You're gonna wanna know what folks are doing on your site..."
|
74
|
+
@@google_analytics_id = ask("Google Analytics ID: ")
|
75
|
+
config.gsub!(/\[google_analytics_id\]/, @@google_analytics_id)
|
76
|
+
|
77
|
+
say "You'll also need a SendGrid account to make sending emails easy..."
|
78
|
+
@@mailer_user_name = ask("SendGrid Username: ")
|
79
|
+
config.gsub!(/\[mailer_user_name\]/, @@mailer_user_name)
|
80
|
+
@@mailer_password = ask("SendGrid Password: ")
|
81
|
+
config.gsub!(/\[mailer_password\]/, @@mailer_password)
|
82
|
+
@@mailer_domain = ask("SendGrid Domain: ")
|
83
|
+
config.gsub!(/\[mailer_domain\]/, @@mailer_domain)
|
84
|
+
config.gsub!(/\[mailer_address\]/, @@mailer_address)
|
85
|
+
config.gsub!(/\[mailer_port\]/, @@mailer_port)
|
86
|
+
@@mailer_default_from = ask("Default From Address: ")
|
87
|
+
config.gsub!(/\[mailer_default_from\]/, @@mailer_default_from)
|
88
|
+
|
89
|
+
say "And when you encounter an error, we fire off an email..."
|
90
|
+
@@errors_subject = ask("Email Subject: ")
|
91
|
+
config.gsub!(/\[errors_subject\]/, @@errors_subject)
|
92
|
+
@@errors_from = ask("From Address: ")
|
93
|
+
config.gsub!(/\[errors_from\]/, @@errors_from)
|
94
|
+
@@errors_to = ask("To Address: ")
|
95
|
+
config.gsub!(/\[errors_to\]/, @@errors_to)
|
96
|
+
|
97
|
+
File.open(@@topkit_file, 'w+') { |f| f.write(config) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_default_user
|
101
|
+
say "========================="
|
102
|
+
say "CREATE A USER"
|
103
|
+
say "========================="
|
104
|
+
say "\nWe are going to create your first user so you have API access."
|
105
|
+
name = ask("Name: ")
|
106
|
+
email = ask("Email: ")
|
107
|
+
password = ask("Password: ")
|
108
|
+
create_user(name, email, password, true)
|
109
|
+
end
|
110
|
+
|
111
|
+
def transfer_ownership
|
112
|
+
system("chown -R #{@@user}:#{@@user} #{@@home}")
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Topkit
|
2
|
+
module Server
|
3
|
+
class Symlinks < Base
|
4
|
+
|
5
|
+
def clean
|
6
|
+
system("find #{@@root} -type l -exec sh -c \"file -b {} | grep -q ^broken\" \\; -delete")
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate
|
10
|
+
clean
|
11
|
+
Dir.glob("#{@@projects_root}/*").each do |site_dir|
|
12
|
+
site = site_dir.split('/').last
|
13
|
+
# Assets
|
14
|
+
%w{images javascripts stylesheets fonts}.each do |asset_dir|
|
15
|
+
src = "#{site_dir}/#{asset_dir}"
|
16
|
+
if Dir.exists?(src)
|
17
|
+
dest_parent = "#{@@root}/app/assets/#{asset_dir}/viewer"
|
18
|
+
FileUtils.mkdir_p(dest_parent)
|
19
|
+
dest = "#{dest_parent}/#{site}"
|
20
|
+
system("ln -s #{src} #{dest}") unless File.exists?(dest)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# Layout
|
24
|
+
src = "#{site_dir}/layouts/layout.html.erb"
|
25
|
+
dest = "#{@@root}/app/views/layouts/viewer"
|
26
|
+
FileUtils.mkdir_p(dest)
|
27
|
+
dest = "#{dest}/#{site}.html.erb"
|
28
|
+
system("ln -s #{src} #{dest}") unless File.exists?(dest)
|
29
|
+
# View Files
|
30
|
+
%w{templates partials}.each do |dir|
|
31
|
+
src = "#{site_dir}/#{dir}/*"
|
32
|
+
dest = "#{@@root}/app/views/viewer/#{site}"
|
33
|
+
FileUtils.mkdir_p(dest)
|
34
|
+
system("ln -s #{src} #{dest}") #unless File.exists?(dest)
|
35
|
+
end
|
36
|
+
# Service Object
|
37
|
+
src = "#{site_dir}/utilities/services.rb"
|
38
|
+
dest_dir = "#{@@root}/app/viewer_services"
|
39
|
+
FileUtils.mkdir_p(dest_dir)
|
40
|
+
dest = "#{dest}/#{underscore(site)}_viewer.rb"
|
41
|
+
system("ln -s #{src} #{dest}") unless File.exists?(dest)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def underscore(site)
|
48
|
+
site.downcase.gsub(/[\ \-]+/i, '_').gsub(/[^0-9a-z\-\_]/i, '')
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Topkit
|
2
|
+
module Server
|
3
|
+
class Updater < Base
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
pull_repo
|
7
|
+
install_bundle
|
8
|
+
precompile_assets
|
9
|
+
migrate_database
|
10
|
+
restart_server
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def pull_repo
|
16
|
+
system("cd #{@@root} && git pull")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/topkit/version.rb
CHANGED
data/lib/topkit.rb
CHANGED
@@ -1,5 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'topkit/version'
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'highline/import'
|
5
|
+
require 'json'
|
6
|
+
require 'net/http'
|
7
|
+
require 'securerandom'
|
8
|
+
require 'yaml'
|
2
9
|
|
3
10
|
module Topkit
|
4
|
-
|
11
|
+
def self.root
|
12
|
+
File.expand_path '../..', __FILE__
|
13
|
+
end
|
5
14
|
end
|
15
|
+
|
16
|
+
require 'topkit/developer/base'
|
17
|
+
require 'topkit/developer/installer'
|
18
|
+
require 'topkit/developer/user'
|
19
|
+
require 'topkit/developer/site'
|
20
|
+
require 'topkit/developer/database'
|
21
|
+
require 'topkit/developer/symlinks'
|
22
|
+
|
23
|
+
require 'topkit/server/base'
|
24
|
+
require 'topkit/server/installer'
|
25
|
+
require 'topkit/server/updater'
|
26
|
+
require 'topkit/server/console'
|
data/topkit.gemspec
CHANGED
@@ -6,20 +6,20 @@ require 'topkit/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "topkit"
|
8
8
|
spec.version = Topkit::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Sean C Davis']
|
10
|
+
spec.email = ['sdavis@topicdesign.com']
|
11
|
+
spec.summary = %q{Command-line interface for working with topkit Server and topkit Developer.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = 'https://github.com/topicdesign/topkit-cli.git'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.
|
22
|
-
spec.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
|
24
|
-
spec.
|
24
|
+
spec.add_dependency 'highline'
|
25
25
|
end
|
metadata
CHANGED
@@ -1,88 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 1.0.0.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Sean C Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: highline
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
type: :
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description: ''
|
56
56
|
email:
|
57
|
-
-
|
57
|
+
- sdavis@topicdesign.com
|
58
58
|
executables:
|
59
|
+
- ripen
|
59
60
|
- topkit
|
60
61
|
extensions: []
|
61
62
|
extra_rdoc_files: []
|
62
63
|
files:
|
63
|
-
- .gitignore
|
64
|
+
- ".gitignore"
|
64
65
|
- Gemfile
|
65
|
-
- LICENSE.
|
66
|
+
- LICENSE.md
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
69
|
+
- bin/ripen
|
68
70
|
- bin/topkit
|
71
|
+
- lib/templates/database.yml
|
72
|
+
- lib/templates/developer/database.yml
|
73
|
+
- lib/templates/developer/topkit.yml
|
74
|
+
- lib/templates/nginx.conf
|
75
|
+
- lib/templates/topkit.yml
|
76
|
+
- lib/templates/unicorn.rb
|
77
|
+
- lib/templates/unicorn_init
|
69
78
|
- lib/topkit.rb
|
70
|
-
- lib/topkit/
|
71
|
-
- lib/topkit/
|
72
|
-
- lib/topkit/
|
79
|
+
- lib/topkit/developer/base.rb
|
80
|
+
- lib/topkit/developer/database.rb
|
81
|
+
- lib/topkit/developer/installer.rb
|
82
|
+
- lib/topkit/developer/site.rb
|
83
|
+
- lib/topkit/developer/symlinks.rb
|
84
|
+
- lib/topkit/developer/user.rb
|
85
|
+
- lib/topkit/server/base.rb
|
86
|
+
- lib/topkit/server/console.rb
|
87
|
+
- lib/topkit/server/installer.rb
|
88
|
+
- lib/topkit/server/symlinks.rb
|
89
|
+
- lib/topkit/server/updater.rb
|
73
90
|
- lib/topkit/version.rb
|
74
|
-
- templates/Gemfile_clean
|
75
|
-
- templates/_footer.html.erb
|
76
|
-
- templates/_header.html.erb
|
77
|
-
- templates/_status.html.erb
|
78
|
-
- templates/application_layout.html.erb
|
79
|
-
- templates/database.pg.yml.erb
|
80
|
-
- templates/database_cleaner_rspec.rb
|
81
|
-
- templates/topkit_gitignore
|
82
|
-
- test/lib/topkit/version_test.rb
|
83
|
-
- test/test_helper.rb
|
84
91
|
- topkit.gemspec
|
85
|
-
homepage: https://github.com/topicdesign/topkit-
|
92
|
+
homepage: https://github.com/topicdesign/topkit-cli.git
|
86
93
|
licenses:
|
87
94
|
- MIT
|
88
95
|
metadata: {}
|
@@ -92,21 +99,18 @@ require_paths:
|
|
92
99
|
- lib
|
93
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
101
|
requirements:
|
95
|
-
- -
|
102
|
+
- - ">="
|
96
103
|
- !ruby/object:Gem::Version
|
97
104
|
version: '0'
|
98
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
106
|
requirements:
|
100
|
-
- -
|
107
|
+
- - ">"
|
101
108
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
109
|
+
version: 1.3.1
|
103
110
|
requirements: []
|
104
111
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.6
|
106
113
|
signing_key:
|
107
114
|
specification_version: 4
|
108
|
-
summary:
|
109
|
-
|
110
|
-
test_files:
|
111
|
-
- test/lib/topkit/version_test.rb
|
112
|
-
- test/test_helper.rb
|
115
|
+
summary: Command-line interface for working with topkit Server and topkit Developer.
|
116
|
+
test_files: []
|
data/lib/topkit/actions.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
module Topkit
|
2
|
-
module Actions
|
3
|
-
def concat_file(source, destination)
|
4
|
-
contents = IO.read(find_in_source_paths(source))
|
5
|
-
append_file destination, contents
|
6
|
-
end
|
7
|
-
|
8
|
-
def replace_in_file(relative_path, find, replace)
|
9
|
-
path = File.join(destination_root, relative_path)
|
10
|
-
contents = IO.read(path)
|
11
|
-
unless contents.gsub!(find, replace)
|
12
|
-
raise "#{find.inspect} not found in #{relative_path}"
|
13
|
-
end
|
14
|
-
File.open(path, "w") { |file| file.write(contents) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def action_mailer_host(rails_env, host)
|
18
|
-
host_config = "config.action_mailer.default_url_option = { host: '#{host}' }"
|
19
|
-
configure_environment(rails_env, host_config)
|
20
|
-
end
|
21
|
-
|
22
|
-
def configure_environment(rails_env, config)
|
23
|
-
inject_into_file(
|
24
|
-
"config/environments/#{rails_env}.rb",
|
25
|
-
"\n\n #{config}",
|
26
|
-
before: "\nend"
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
def download_file(uri_string, destination)
|
31
|
-
require 'net/http'
|
32
|
-
uri = URI.parse(uri_string)
|
33
|
-
http = ::Net::HTTP.new(uri.host, uri.port)
|
34
|
-
http.use_ssl = true if uri_string =~ /^https/
|
35
|
-
request = ::Net::HTTP::Get.new(uri.path)
|
36
|
-
contents = http.request(request).body
|
37
|
-
path = File.join(destination_root, destination)
|
38
|
-
File.open(path, "w") { |file| file.write(contents) }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/topkit/app_builder.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
module Topkit
|
2
|
-
class AppBuilder < Rails::AppBuilder
|
3
|
-
include Topkit::Actions
|
4
|
-
|
5
|
-
def configure_rspec_generators
|
6
|
-
config = <<-RUBY
|
7
|
-
config.generators do |g|
|
8
|
-
g.fixture true
|
9
|
-
g.fixture_replacement "factory_girl"
|
10
|
-
g.assets false
|
11
|
-
g.test_framework :rspec
|
12
|
-
g.view_specs false
|
13
|
-
g.controller_specs false
|
14
|
-
g.helper_specs false
|
15
|
-
g.routing_specs false
|
16
|
-
g.request_specs false
|
17
|
-
g.stylesheets false
|
18
|
-
end
|
19
|
-
|
20
|
-
RUBY
|
21
|
-
|
22
|
-
inject_into_class 'config/application.rb', 'Application', config
|
23
|
-
end
|
24
|
-
|
25
|
-
def replace_gemfile
|
26
|
-
remove_file 'Gemfile'
|
27
|
-
copy_file 'Gemfile_clean', 'Gemfile'
|
28
|
-
end
|
29
|
-
|
30
|
-
def template_database_file
|
31
|
-
template 'database.pg.yml.erb', 'config/database.yml', force: true
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_database
|
35
|
-
bundle_command "exec rake db:create"
|
36
|
-
end
|
37
|
-
|
38
|
-
def remove_public_index
|
39
|
-
remove_file 'public/index.html'
|
40
|
-
end
|
41
|
-
|
42
|
-
def remove_rails_logo_image
|
43
|
-
remove_file 'app/assets/images/rails.png'
|
44
|
-
end
|
45
|
-
|
46
|
-
def remove_routes_comment_lines
|
47
|
-
replace_in_file 'config/routes.rb',
|
48
|
-
/Application\.routes\.draw do.*end/m,
|
49
|
-
"Application.routes.draw do\nend"
|
50
|
-
end
|
51
|
-
|
52
|
-
def create_partials_directory
|
53
|
-
empty_directory 'app/views/application'
|
54
|
-
end
|
55
|
-
|
56
|
-
def create_status_partials
|
57
|
-
copy_file '_status.html.erb', 'app/views/application/_status.html.erb'
|
58
|
-
copy_file '_header.html.erb', 'app/views/application/_header.html.erb'
|
59
|
-
copy_file '_footer.html.erb', 'app/views/application/_footer.html.erb'
|
60
|
-
end
|
61
|
-
|
62
|
-
def create_application_layout
|
63
|
-
remove_file "app/views/layouts/application.html.erb"
|
64
|
-
copy_file "application_layout.html.erb", "app/views/layouts/application.html.erb", force: true
|
65
|
-
end
|
66
|
-
|
67
|
-
def generate_rspec
|
68
|
-
generate 'rspec:install'
|
69
|
-
end
|
70
|
-
|
71
|
-
def generate_backbone
|
72
|
-
generate "backbone:install"
|
73
|
-
end
|
74
|
-
|
75
|
-
def generate_backtrace
|
76
|
-
download_file "https://gist.github.com/apcomplete/4113645/download", "vendor/assets/javascripts/backtrace.js"
|
77
|
-
end
|
78
|
-
|
79
|
-
def enable_database_cleaner
|
80
|
-
replace_in_file 'spec/spec_helper.rb',
|
81
|
-
'config.use_transactional_fixtures = true',
|
82
|
-
'config.use_transactional_fixtures = false'
|
83
|
-
|
84
|
-
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
85
|
-
end
|
86
|
-
|
87
|
-
def setup_stylesheets
|
88
|
-
remove_file 'app/assets/stylesheets/application.css'
|
89
|
-
create_file 'app/assets/stylesheets/application.css.scss'
|
90
|
-
end
|
91
|
-
|
92
|
-
def generate_devise
|
93
|
-
generate "devise:install"
|
94
|
-
generate "devise User"
|
95
|
-
bundle_command "exec rake db:migrate"
|
96
|
-
generate "devise:views"
|
97
|
-
end
|
98
|
-
|
99
|
-
def generate_cucumber
|
100
|
-
generate 'cucumber:install', '--rspec', '--capybara'
|
101
|
-
end
|
102
|
-
|
103
|
-
def init_git
|
104
|
-
run 'git init'
|
105
|
-
end
|
106
|
-
|
107
|
-
def add_to_git_ignore
|
108
|
-
concat_file 'topkit_gitignore', '.gitignore'
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/rails/app/app_generator'
|
3
|
-
|
4
|
-
module Topkit
|
5
|
-
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
-
class_option :client, type: :string, desc: "Specify client abbreviation"
|
7
|
-
class_option :project, type: :string, desc: "Specify project number"
|
8
|
-
|
9
|
-
def finish_template
|
10
|
-
invoke :topkit_customization
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
|
-
def topkit_customization
|
15
|
-
invoke :configure_generators
|
16
|
-
invoke :customize_gemfile
|
17
|
-
invoke :setup_database
|
18
|
-
invoke :remove_useless_files
|
19
|
-
invoke :remove_routes_comment_lines
|
20
|
-
invoke :create_views_and_layouts
|
21
|
-
invoke :copy_miscellaneous_files
|
22
|
-
invoke :configure_rspec
|
23
|
-
invoke :configure_backbone
|
24
|
-
invoke :configure_cucumber
|
25
|
-
invoke :generate_devise
|
26
|
-
invoke :setup_git
|
27
|
-
end
|
28
|
-
|
29
|
-
def configure_generators
|
30
|
-
say "Configuring rspec generators"
|
31
|
-
build :configure_rspec_generators
|
32
|
-
end
|
33
|
-
|
34
|
-
def customize_gemfile
|
35
|
-
say "Setting up gems"
|
36
|
-
build :replace_gemfile
|
37
|
-
bundle_command "install"
|
38
|
-
bundle_command "package"
|
39
|
-
end
|
40
|
-
|
41
|
-
def setup_database
|
42
|
-
say "Setting up database"
|
43
|
-
build :template_database_file
|
44
|
-
build :create_database
|
45
|
-
end
|
46
|
-
|
47
|
-
def remove_useless_files
|
48
|
-
build :remove_public_index
|
49
|
-
build :remove_rails_logo_image
|
50
|
-
end
|
51
|
-
|
52
|
-
def remove_routes_comment_lines
|
53
|
-
build :remove_routes_comment_lines
|
54
|
-
end
|
55
|
-
|
56
|
-
def create_views_and_layouts
|
57
|
-
say "Creating partials and default layout"
|
58
|
-
build :create_partials_directory
|
59
|
-
build :create_status_partials
|
60
|
-
build :create_application_layout
|
61
|
-
end
|
62
|
-
|
63
|
-
def copy_miscellaneous_files
|
64
|
-
build :setup_stylesheets
|
65
|
-
end
|
66
|
-
|
67
|
-
def configure_rspec
|
68
|
-
say "Generating rspec"
|
69
|
-
build :generate_rspec
|
70
|
-
build :enable_database_cleaner
|
71
|
-
end
|
72
|
-
|
73
|
-
def configure_backbone
|
74
|
-
say "Generating backbone"
|
75
|
-
build :generate_backbone
|
76
|
-
build :generate_backtrace
|
77
|
-
end
|
78
|
-
|
79
|
-
def generate_devise
|
80
|
-
say "Generating Devise"
|
81
|
-
build :generate_devise
|
82
|
-
end
|
83
|
-
|
84
|
-
def configure_cucumber
|
85
|
-
say "Installing cucumber"
|
86
|
-
build :generate_cucumber
|
87
|
-
end
|
88
|
-
|
89
|
-
def setup_git
|
90
|
-
say "Initializing git repo"
|
91
|
-
build :add_to_git_ignore
|
92
|
-
build :init_git
|
93
|
-
end
|
94
|
-
|
95
|
-
def outro
|
96
|
-
say 'You are good to go!'
|
97
|
-
end
|
98
|
-
|
99
|
-
def run_bundle
|
100
|
-
end
|
101
|
-
|
102
|
-
protected
|
103
|
-
|
104
|
-
def get_builder_class
|
105
|
-
Topkit::AppBuilder
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
end
|