weapon 0.1.8 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/support/build_activeadmin_pages/build_activeadmin_pages_generator.rb +15 -0
- data/lib/support/grape_entity/grape_entity_generator.rb +16 -0
- data/lib/support/mina_unicorn/staging-unicorn-nginx.conf +7 -7
- data/lib/support/mina_unicorn/unicorn-nginx.conf +1 -1
- data/lib/support/mina_unicorn/unicorn_production.rb +1 -1
- data/lib/support/mina_unicorn/unicorn_staging.rb +1 -1
- data/lib/support/model_from_sql/model_from_sql_generator.rb +8 -2
- data/lib/weapon.rb +33 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7b98eef2fed257f65d7a388c123f7265d3a0111
|
4
|
+
data.tar.gz: 545bc73a573868385e9c900cf2b0c8617a50a493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb7909bf9c3cabeb2cf381490ddcc570d20f8f3908453e2c7d5d67b334f8ace4c1a48489a9c42949f7d4b698b83b1db6480a309d12b58faafed0ec1b690d1fd
|
7
|
+
data.tar.gz: 8bf36672904e2e173cd9ec95f444915b197aa1c2911c8e563ee46a3279b6882c24a6b34491939f4d01f226c9b9da1b3a0d1ab8b05b56233383681104d0e4f82b
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class BuildActiveadminPagesGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path("../templates", __FILE__)
|
3
|
+
|
4
|
+
def build_pages
|
5
|
+
Rails.application.eager_load!
|
6
|
+
|
7
|
+
all_models = ActiveRecord::Base.descendants
|
8
|
+
|
9
|
+
all_models.each do |model_ins|
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class WeaponGenerator < Rails::Generators::NamedBase
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def generate_grape_entity
|
5
|
+
names = args[0].split('/')
|
6
|
+
column_names = names[-1].camelize.constantize.column_names
|
7
|
+
infos = column_names.map {|column| "expose :#{column}"}
|
8
|
+
a = Magicfile.new
|
9
|
+
a.append_modules(names[0..-2])
|
10
|
+
a.append_class(names[-1].camelize, 'Grape::Entity')
|
11
|
+
a.append_string_lines(infos)
|
12
|
+
a.to_file("app/#{args[0]}.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
upstream
|
1
|
+
upstream staging_app_name_for_replace {
|
2
2
|
# Path to Unicorn SOCK file, as defined previously
|
3
|
-
server unix
|
3
|
+
server unix:deploy_directory_for_replace_staging/current/tmp/unicorn.sock;
|
4
4
|
}
|
5
5
|
|
6
6
|
server {
|
@@ -12,15 +12,15 @@ server {
|
|
12
12
|
# Application root, as defined previously
|
13
13
|
root deploy_directory_for_replace_staging/current/public;
|
14
14
|
|
15
|
-
try_files $uri @
|
16
|
-
access_log /var/log/nginx/
|
17
|
-
error_log /var/log/nginx/
|
15
|
+
try_files $uri @staging_app_name_for_replace;
|
16
|
+
access_log /var/log/nginx/staging_app_name_for_replace_access.log;
|
17
|
+
error_log /var/log/nginx/staging_app_name_for_replace_error.log;
|
18
18
|
|
19
|
-
location @
|
19
|
+
location @staging_app_name_for_replace{
|
20
20
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
21
21
|
proxy_set_header Host $http_host;
|
22
22
|
proxy_redirect off;
|
23
|
-
proxy_pass http://
|
23
|
+
proxy_pass http://staging_app_name_for_replace;
|
24
24
|
}
|
25
25
|
|
26
26
|
error_page 500 502 503 504 /500.html;
|
@@ -3,7 +3,7 @@ app_path = File.expand_path( File.join(File.dirname(__FILE__), '..', '..'))
|
|
3
3
|
worker_processes 4
|
4
4
|
preload_app true
|
5
5
|
timeout 180
|
6
|
-
listen
|
6
|
+
listen "#{app_path}/tmp/unicorn.sock"
|
7
7
|
pid "#{app_path}/tmp/pids/unicorn.pid"
|
8
8
|
user 'username_for_replace', 'username_for_replace'
|
9
9
|
stderr_path "log/unicorn_err.log"
|
@@ -3,7 +3,7 @@ app_path = File.expand_path( File.join(File.dirname(__FILE__), '..', '..'))
|
|
3
3
|
worker_processes 1
|
4
4
|
preload_app true
|
5
5
|
timeout 180
|
6
|
-
listen
|
6
|
+
listen "#{app_path}/tmp/unicorn.sock"
|
7
7
|
pid "#{app_path}/tmp/pids/unicorn-staging.pid"
|
8
8
|
user 'username_for_replace', 'username_for_replace'
|
9
9
|
stderr_path "log/unicorn-stagingerr.log"
|
@@ -3,11 +3,17 @@ class ModelFromSqlGenerator < Rails::Generators::Base
|
|
3
3
|
|
4
4
|
def build_models
|
5
5
|
tables = ActiveRecord::Base.connection.tables
|
6
|
-
|
6
|
+
|
7
|
+
Rails.application.eager_load!
|
8
|
+
in_models = ActiveRecord::Base.descendants.map(&:table_name)
|
9
|
+
ap in_models
|
10
|
+
new_tables = tables - in_models - ['schema_migrations', 'ar_internal_metadata']
|
11
|
+
|
12
|
+
new_tables.each do |table_name|
|
7
13
|
generate "model #{table_name} --skip-migration" # or whatever you want here
|
8
14
|
model_file = "app/models/#{table_name.singularize}.rb"
|
9
15
|
inject_into_file model_file, before: "end\n" do <<-'RUBY'
|
10
|
-
self.table_name = table_name_replace
|
16
|
+
self.table_name = "table_name_replace"
|
11
17
|
RUBY
|
12
18
|
end
|
13
19
|
gsub_file model_file, 'table_name_replace', table_name
|
data/lib/weapon.rb
CHANGED
@@ -35,7 +35,7 @@ class Weapon < Thor
|
|
35
35
|
|
36
36
|
|
37
37
|
desc "setup_mina_unicorn", "setup mina deploy and unicorn server"
|
38
|
-
def setup_mina_unicorn
|
38
|
+
def setup_mina_unicorn(user_host)
|
39
39
|
makesure_in_git
|
40
40
|
repo_path = `git config --get remote.origin.url`.strip()
|
41
41
|
return puts "at least one remote url should be set before we start!!!".colorize(:red) unless repo_path.present?
|
@@ -59,7 +59,7 @@ class Weapon < Thor
|
|
59
59
|
puts "setup mina deploy"
|
60
60
|
|
61
61
|
app_name = `pwd`.split('/')[-1].strip()
|
62
|
-
username, domain =
|
62
|
+
username, domain = user_host.split('@')
|
63
63
|
deploy_directory = "/home/#{username}/#{app_name}"
|
64
64
|
|
65
65
|
|
@@ -98,15 +98,28 @@ class Weapon < Thor
|
|
98
98
|
|
99
99
|
run 'scp config/database.yml ' + username + '@' + domain + ':' + deploy_directory + '/shared/config/'
|
100
100
|
run 'scp config/application.yml ' + username + '@' + domain + ':' + deploy_directory + '/shared/config/'
|
101
|
-
|
101
|
+
|
102
|
+
run 'cp config/secrets.yml config/production_secrets.yml'
|
103
|
+
gsub_file "config/production_secrets.yml", "production", "staging"
|
104
|
+
gsub_file "config/production_secrets.yml", "test", "production"
|
105
|
+
run 'scp config/production_secrets.yml ' + username + '@' + domain + ':' + deploy_directory + '/shared/config/secrets.yml'
|
106
|
+
run "rm config/production_secrets.yml"
|
107
|
+
|
108
|
+
## for staging
|
102
109
|
|
103
110
|
run 'cp config/database.yml config/staging_database.yml'
|
104
111
|
gsub_file "config/staging_database.yml", "production", "staging"
|
105
112
|
run 'scp config/staging_database.yml ' + username + '@' + domain + ':' + deploy_directory + '_staging/shared/config/database.yml'
|
106
113
|
run "rm config/staging_database.yml"
|
114
|
+
|
115
|
+
run 'cp config/secrets.yml config/staging_secrets.yml'
|
116
|
+
gsub_file "config/staging_secrets.yml", "development", "staging"
|
117
|
+
run 'scp config/staging_secrets.yml ' + username + '@' + domain + ':' + deploy_directory + '_staging/shared/config/secrets.yml'
|
118
|
+
run "rm config/staging_secrets.yml"
|
119
|
+
|
107
120
|
run 'scp config/application.yml ' + username + '@' + domain + ':' + deploy_directory + '_staging/shared/config/'
|
108
|
-
run 'scp config/secrets.yml ' + username + '@' + domain + ':' + deploy_directory + '_staging/shared/config/'
|
109
121
|
|
122
|
+
## run mina setup && deploy
|
110
123
|
run 'mina deploy' if staging.present?
|
111
124
|
run 'mina production deploy'
|
112
125
|
run 'git add config/ .gitignore staging-unicorn-nginx.conf unicorn-nginx.conf'
|
@@ -124,10 +137,24 @@ class Weapon < Thor
|
|
124
137
|
copy_file 'support/model_from_sql/model_from_sql_generator.rb', 'lib/generators/model_from_sql/model_from_sql_generator.rb'
|
125
138
|
run 'git add lib/'
|
126
139
|
run 'rails g model_from_sql'
|
127
|
-
run 'git add app/
|
140
|
+
run 'git add app/'
|
141
|
+
run 'git add spec/'
|
142
|
+
run 'git add test/'
|
143
|
+
run 'git add lib/'
|
128
144
|
run 'git commit -a -m "add model_from_sql generator and build models from sql"'
|
129
145
|
end
|
130
146
|
|
147
|
+
desc "build all activeadmin page ", "build all activeadmin page"
|
148
|
+
def build_activeadmin_pages
|
149
|
+
makesure_in_git
|
150
|
+
FileUtils.mkdir_p "lib/generators/build_activeadmin_pages"
|
151
|
+
copy_file 'support/build_activeadmin_pages/build_activeadmin_pages_generator.rb', 'lib/generators/build_activeadmin_pages/build_activeadmin_pages_generator.rb'
|
152
|
+
run 'git add lib/'
|
153
|
+
run 'rails g build_activeadmin_pages'
|
154
|
+
run 'git add app/ test/ lib/'
|
155
|
+
run 'git commit -a -m "add build_activeadmin_pages generator and build pages from model"'
|
156
|
+
end
|
157
|
+
|
131
158
|
desc "setup_settings_ui", "setup settings ui"
|
132
159
|
def setup_settings_ui
|
133
160
|
makesure_in_git
|
@@ -196,6 +223,7 @@ class Weapon < Thor
|
|
196
223
|
makesure_in_git
|
197
224
|
|
198
225
|
gem 'enumerize'
|
226
|
+
gem 'aasm'
|
199
227
|
gem 'slim-rails'
|
200
228
|
gem 'sass-rails', '~> 5.0'
|
201
229
|
gem 'bootstrap-sass'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weapon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seaify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,6 +89,7 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- bin/weapon
|
92
|
+
- lib/support/build_activeadmin_pages/build_activeadmin_pages_generator.rb
|
92
93
|
- lib/support/create_gem/basic.bin
|
93
94
|
- lib/support/create_gem/basic.gemspec
|
94
95
|
- lib/support/create_gem/basic.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/support/custom_i18n/show.html.slim
|
102
103
|
- lib/support/custom_i18n/zh-CN.yml
|
103
104
|
- lib/support/exception_slack_notify/exception_notification.rb
|
105
|
+
- lib/support/grape_entity/grape_entity_generator.rb
|
104
106
|
- lib/support/mina_unicorn/deploy.rb
|
105
107
|
- lib/support/mina_unicorn/deploy_production.rb
|
106
108
|
- lib/support/mina_unicorn/deploy_staging.rb
|