xing-framework 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/default_configuration/base_app/API_DOC/README +23 -0
  3. data/default_configuration/base_app/API_DOC/admin-menus +167 -0
  4. data/default_configuration/base_app/API_DOC/admin-pages +173 -0
  5. data/default_configuration/base_app/API_DOC/content-block +10 -0
  6. data/default_configuration/base_app/API_DOC/navigation +54 -0
  7. data/default_configuration/base_app/API_DOC/page +38 -0
  8. data/default_configuration/base_app/CHANGELOG.md +122 -0
  9. data/default_configuration/base_app/Capfile +26 -0
  10. data/default_configuration/base_app/Gemfile +7 -0
  11. data/default_configuration/base_app/Gemfile.lock +155 -0
  12. data/default_configuration/base_app/README.md +24 -0
  13. data/default_configuration/base_app/Rakefile +25 -0
  14. data/default_configuration/base_app/backend/Gemfile +45 -0
  15. data/default_configuration/base_app/backend/Gemfile.lock +292 -0
  16. data/default_configuration/base_app/backend/README +12 -0
  17. data/default_configuration/base_app/backend/Rakefile +10 -0
  18. data/default_configuration/base_app/backend/app/controllers/application_controller.rb +3 -0
  19. data/default_configuration/base_app/backend/app/controllers/confirmations_controller.rb +3 -0
  20. data/default_configuration/base_app/backend/app/controllers/passwords_controller.rb +3 -0
  21. data/default_configuration/base_app/backend/app/controllers/registrations_controller.rb +15 -0
  22. data/default_configuration/base_app/backend/app/models/ability.rb +13 -0
  23. data/default_configuration/base_app/backend/app/models/role/admin.rb +8 -0
  24. data/default_configuration/base_app/backend/app/models/user.rb +43 -0
  25. data/default_configuration/base_app/backend/autotest/discover.rb +2 -0
  26. data/default_configuration/base_app/backend/bin/bundle +3 -0
  27. data/default_configuration/base_app/backend/bin/rails +4 -0
  28. data/default_configuration/base_app/backend/bin/rake +4 -0
  29. data/default_configuration/base_app/backend/config.ru +6 -0
  30. data/default_configuration/base_app/backend/config/application.rb +71 -0
  31. data/default_configuration/base_app/backend/config/boot.rb +4 -0
  32. data/default_configuration/base_app/backend/config/database.yml.ci +9 -0
  33. data/default_configuration/base_app/backend/config/database.yml.example +22 -0
  34. data/default_configuration/base_app/backend/config/environment.rb +5 -0
  35. data/default_configuration/base_app/backend/config/environments/development.rb +45 -0
  36. data/default_configuration/base_app/backend/config/environments/production.rb +78 -0
  37. data/default_configuration/base_app/backend/config/environments/staging.rb +48 -0
  38. data/default_configuration/base_app/backend/config/environments/test.rb +47 -0
  39. data/default_configuration/base_app/backend/config/initializers/assets.rb +8 -0
  40. data/default_configuration/base_app/backend/config/initializers/backtrace_silencers.rb +7 -0
  41. data/default_configuration/base_app/backend/config/initializers/constants.rb +1 -0
  42. data/default_configuration/base_app/backend/config/initializers/cookies_serializer.rb +3 -0
  43. data/default_configuration/base_app/backend/config/initializers/devise.rb +241 -0
  44. data/default_configuration/base_app/backend/config/initializers/devise_token_auth.rb +22 -0
  45. data/default_configuration/base_app/backend/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/default_configuration/base_app/backend/config/initializers/inflections.rb +16 -0
  47. data/default_configuration/base_app/backend/config/initializers/mime_types.rb +4 -0
  48. data/default_configuration/base_app/backend/config/initializers/session_store.rb +3 -0
  49. data/default_configuration/base_app/backend/config/initializers/smtp.rb +25 -0
  50. data/default_configuration/base_app/backend/config/initializers/time_formats.rb +12 -0
  51. data/default_configuration/base_app/backend/config/initializers/wrap_parameters.rb +14 -0
  52. data/default_configuration/base_app/backend/config/locales/en.yml +23 -0
  53. data/default_configuration/base_app/backend/config/locales/json.yml +29 -0
  54. data/default_configuration/base_app/backend/config/routes.rb +33 -0
  55. data/default_configuration/base_app/backend/config/secrets.yml.ci +22 -0
  56. data/default_configuration/base_app/backend/config/secrets.yml.example +57 -0
  57. data/default_configuration/base_app/backend/config/sidekiq.yml +4 -0
  58. data/default_configuration/base_app/backend/db/sample_data/users.rake +10 -0
  59. data/default_configuration/base_app/backend/db/seeds.rb +14 -0
  60. data/default_configuration/base_app/backend/lib/static-app.rb +15 -0
  61. data/default_configuration/base_app/backend/public/404.html +26 -0
  62. data/default_configuration/base_app/backend/public/422.html +26 -0
  63. data/default_configuration/base_app/backend/public/500.html +26 -0
  64. data/default_configuration/base_app/backend/public/favicon.ico +0 -0
  65. data/default_configuration/base_app/backend/public/index.html +0 -0
  66. data/default_configuration/base_app/backend/public/robots.txt +5 -0
  67. data/default_configuration/base_app/backend/script/rails +6 -0
  68. data/default_configuration/base_app/backend/spec/factories/user_sessions_factory.rb +6 -0
  69. data/default_configuration/base_app/backend/spec/factories/users_factory.rb +35 -0
  70. data/default_configuration/base_app/backend/spec/features/user_sends_reset_password_email_spec.rb +30 -0
  71. data/default_configuration/base_app/backend/spec/features/user_signs_up_spec.rb +32 -0
  72. data/default_configuration/base_app/backend/spec/models/role/admin_spec.rb +12 -0
  73. data/default_configuration/base_app/backend/spec/models/role_spec.rb +48 -0
  74. data/default_configuration/base_app/backend/spec/models/user_spec.rb +59 -0
  75. data/default_configuration/base_app/backend/spec/requests/resources_index_spec.rb +22 -0
  76. data/default_configuration/base_app/backend/spec/spec_helper.rb +65 -0
  77. data/default_configuration/base_app/backend/spec/support/devise_helper.rb +78 -0
  78. data/default_configuration/base_app/backend/spec/support/log_tests.rb +5 -0
  79. data/default_configuration/base_app/backend/spec/support/session_helpers.rb +67 -0
  80. data/default_configuration/base_app/backend/spec/tasks/sample_data_rake_spec.rb +17 -0
  81. data/default_configuration/base_app/backend/static-app.ru +3 -0
  82. data/default_configuration/base_app/codeclimate.yml +7 -0
  83. data/default_configuration/base_app/config/compass.rb +21 -0
  84. data/default_configuration/base_app/config/deploy.rb +157 -0
  85. data/default_configuration/base_app/config/deploy/bundle-config +4 -0
  86. data/default_configuration/base_app/config/deploy/production.rb +7 -0
  87. data/default_configuration/base_app/config/deploy/staging.rb +6 -0
  88. data/default_configuration/base_app/doc/01_fail_resources.txt +173 -0
  89. data/default_configuration/base_app/doc/02_fail_auth.txt +165 -0
  90. data/default_configuration/base_app/doc/03_fail_menus.txt +174 -0
  91. data/default_configuration/base_app/dummy-api/admin/menu_items/10.json +15 -0
  92. data/default_configuration/base_app/dummy-api/admin/menu_items/11.json +15 -0
  93. data/default_configuration/base_app/dummy-api/admin/menu_items/12.json +15 -0
  94. data/default_configuration/base_app/dummy-api/admin/menu_items/13.json +15 -0
  95. data/default_configuration/base_app/dummy-api/admin/menu_items/14.json +15 -0
  96. data/default_configuration/base_app/dummy-api/admin/menu_items/15.json +15 -0
  97. data/default_configuration/base_app/dummy-api/admin/menu_items/16.json +15 -0
  98. data/default_configuration/base_app/dummy-api/admin/menus.json +23 -0
  99. data/default_configuration/base_app/dummy-api/admin/menus/1.json +118 -0
  100. data/default_configuration/base_app/dummy-api/admin/menus/2.json +8 -0
  101. data/default_configuration/base_app/dummy-api/admin/pages.json +105 -0
  102. data/default_configuration/base_app/dummy-api/admin/pages/about_us.json +45 -0
  103. data/default_configuration/base_app/dummy-api/admin/pages/contact_us.json +36 -0
  104. data/default_configuration/base_app/dummy-api/admin/pages/gallery.json +36 -0
  105. data/default_configuration/base_app/dummy-api/admin/pages/home.json +36 -0
  106. data/default_configuration/base_app/dummy-api/admin/pages/homepage.json +18 -0
  107. data/default_configuration/base_app/dummy-api/admin/pages/links.json +36 -0
  108. data/default_configuration/base_app/dummy-api/admin/pages/newsletter.json +54 -0
  109. data/default_configuration/base_app/dummy-api/homepage.json +14 -0
  110. data/default_configuration/base_app/dummy-api/navigation/main.json +119 -0
  111. data/default_configuration/base_app/dummy-api/pages/about_us.json +41 -0
  112. data/default_configuration/base_app/dummy-api/pages/contact_us.json +32 -0
  113. data/default_configuration/base_app/dummy-api/pages/gallery.json +32 -0
  114. data/default_configuration/base_app/dummy-api/pages/home.json +32 -0
  115. data/default_configuration/base_app/dummy-api/pages/homepage.json +14 -0
  116. data/default_configuration/base_app/dummy-api/pages/links.json +32 -0
  117. data/default_configuration/base_app/dummy-api/pages/newsletter.json +50 -0
  118. data/default_configuration/base_app/dump.rdb +0 -0
  119. data/default_configuration/base_app/example-lrd-dev-tmux.conf +17 -0
  120. data/default_configuration/base_app/frontend/CHANGELOG.md +125 -0
  121. data/default_configuration/base_app/frontend/Gemfile +5 -0
  122. data/default_configuration/base_app/frontend/Gemfile.lock +34 -0
  123. data/default_configuration/base_app/frontend/Gruntfile.js +3 -0
  124. data/default_configuration/base_app/frontend/LICENSE +19 -0
  125. data/default_configuration/base_app/frontend/README.md +5 -0
  126. data/default_configuration/base_app/frontend/bin/index.html +0 -0
  127. data/default_configuration/base_app/frontend/build.config.js +110 -0
  128. data/default_configuration/base_app/frontend/changelog.tpl +23 -0
  129. data/default_configuration/base_app/frontend/config/compass.rb +33 -0
  130. data/default_configuration/base_app/frontend/config/environments/development.js +4 -0
  131. data/default_configuration/base_app/frontend/config/environments/integration.js +4 -0
  132. data/default_configuration/base_app/frontend/config/environments/production.js +3 -0
  133. data/default_configuration/base_app/frontend/config/environments/test.js +4 -0
  134. data/default_configuration/base_app/frontend/create +0 -0
  135. data/default_configuration/base_app/frontend/karma/karma-unit.tpl.js +80 -0
  136. data/default_configuration/base_app/frontend/module.prefix +1 -0
  137. data/default_configuration/base_app/frontend/module.suffix +1 -0
  138. data/default_configuration/base_app/frontend/npm-shrinkwrap.json +4334 -0
  139. data/default_configuration/base_app/frontend/package.json +75 -0
  140. data/default_configuration/base_app/frontend/sprockets/index.tpl.js +2 -0
  141. data/default_configuration/base_app/frontend/src/README.md +48 -0
  142. data/default_configuration/base_app/frontend/src/app/README.md +68 -0
  143. data/default_configuration/base_app/frontend/src/app/app.js +47 -0
  144. data/default_configuration/base_app/frontend/src/app/appConfig.js +19 -0
  145. data/default_configuration/base_app/frontend/src/app/auth/auth.js +66 -0
  146. data/default_configuration/base_app/frontend/src/app/auth/config.js +22 -0
  147. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations-success.tpl.html +1 -0
  148. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations.js +8 -0
  149. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmationsStates.js +12 -0
  150. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request-success.tpl.html +3 -0
  151. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request.tpl.html +16 -0
  152. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update-success.tpl.html +3 -0
  153. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update.tpl.html +21 -0
  154. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords.js +11 -0
  155. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsControllers.js +47 -0
  156. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsStates.js +38 -0
  157. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations-success.tpl.html +1 -0
  158. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.js +14 -0
  159. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.tpl.html +37 -0
  160. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsControllers.js +25 -0
  161. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsStates.js +18 -0
  162. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions-success.tpl.html +1 -0
  163. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.js +18 -0
  164. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.tpl.html +25 -0
  165. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsControllers.js +26 -0
  166. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsStates.js +20 -0
  167. data/default_configuration/base_app/frontend/src/app/homepage/homepage-show.tpl.html +2 -0
  168. data/default_configuration/base_app/frontend/src/app/homepage/homepage.js +10 -0
  169. data/default_configuration/base_app/frontend/src/app/homepage/homepage.tpl.html +13 -0
  170. data/default_configuration/base_app/frontend/src/app/homepage/homepageControllers.js +9 -0
  171. data/default_configuration/base_app/frontend/src/app/homepage/homepageStates.js +22 -0
  172. data/default_configuration/base_app/frontend/src/app/inner.tpl.html +16 -0
  173. data/default_configuration/base_app/frontend/src/app/root.tpl.html +2 -0
  174. data/default_configuration/base_app/frontend/src/app/rootController.js +8 -0
  175. data/default_configuration/base_app/frontend/src/app/rootStates.js +20 -0
  176. data/default_configuration/base_app/frontend/src/assets/README.md +4 -0
  177. data/default_configuration/base_app/frontend/src/assets/icons/alert.svg +1 -0
  178. data/default_configuration/base_app/frontend/src/common/README.md +19 -0
  179. data/default_configuration/base_app/frontend/src/common/components/OnLoginDirective/OnLoginDirective.js +17 -0
  180. data/default_configuration/base_app/frontend/src/common/components/adminOnly/admin-only.tpl.html +4 -0
  181. data/default_configuration/base_app/frontend/src/common/components/adminOnly/adminOnly.js +23 -0
  182. data/default_configuration/base_app/frontend/src/common/components/sessionLinks/session-links.tpl.html +5 -0
  183. data/default_configuration/base_app/frontend/src/common/components/sessionLinks/sessionLinks.js +25 -0
  184. data/default_configuration/base_app/frontend/src/common/components/signOut/signOut.js +19 -0
  185. data/default_configuration/base_app/frontend/src/common/config.js +27 -0
  186. data/default_configuration/base_app/frontend/src/index.html +86 -0
  187. data/default_configuration/base_app/frontend/src/styles/_constants.sass +14 -0
  188. data/default_configuration/base_app/frontend/src/styles/main.sass +52 -0
  189. data/default_configuration/base_app/frontend/src/styles/partials/_footer.sass +18 -0
  190. data/default_configuration/base_app/frontend/src/styles/partials/_forms.sass +9 -0
  191. data/default_configuration/base_app/frontend/src/styles/partials/_layout.sass +17 -0
  192. data/default_configuration/base_app/frontend/src/styles/partials/_navbar.sass +10 -0
  193. data/default_configuration/base_app/frontend/src/styles/partials/_typography.sass +18 -0
  194. data/default_configuration/base_app/frontend/src/styles/states/_errorFallback.sass +7 -0
  195. data/default_configuration/base_app/frontend/src/styles/states/_root_homepage.sass +8 -0
  196. data/default_configuration/base_app/frontend/test-help/xpath.js +9 -0
  197. data/default_configuration/base_app/frontend/test/app.js +24 -0
  198. data/default_configuration/base_app/frontend/test/auth/confirmations/confirmationsStates.js +46 -0
  199. data/default_configuration/base_app/frontend/test/auth/passwords/passwordsControllers.js +193 -0
  200. data/default_configuration/base_app/frontend/test/auth/passwords/passwordsStates.js +108 -0
  201. data/default_configuration/base_app/frontend/test/auth/registrations/registrationsControllers.js +117 -0
  202. data/default_configuration/base_app/frontend/test/auth/registrations/registrationsStates.js +64 -0
  203. data/default_configuration/base_app/frontend/test/auth/sessions/sessionsControllers.js +95 -0
  204. data/default_configuration/base_app/frontend/test/auth/sessions/sessionsStates.js +67 -0
  205. data/default_configuration/base_app/frontend/test/specHelper.js +33 -0
  206. data/default_configuration/base_app/frontend/test/support/mockDirective.js +13 -0
  207. data/default_configuration/base_app/frontend/test/support/stateResolveFn.js +3 -0
  208. data/default_configuration/base_app/frontend/test/support/testStates.js +20 -0
  209. data/default_configuration/base_app/frontend/tools.md +223 -0
  210. data/default_configuration/base_app/lib/capistrano/tasks/sidekiq.rake +218 -0
  211. data/default_configuration/base_app/static-app.ru +3 -0
  212. data/default_configuration/base_app/tmux-windows +68 -0
  213. data/default_configuration/base_app/tmux-windows.txt +53 -0
  214. data/lib/xing/cli.rb +8 -3
  215. data/lib/xing/cli/generators/new_project.rb +48 -13
  216. metadata +219 -7
@@ -0,0 +1,218 @@
1
+ # vim: set ft=ruby :
2
+ #
3
+ namespace :load do
4
+ task :defaults do
5
+ set :sidekiq_default_hooks, -> { true }
6
+
7
+ set :sidekiq_path, -> { release_path }
8
+ set :sidekiq_pid, -> { File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid') }
9
+ set :sidekiq_env, -> { fetch(:rack_env, fetch(:rails_env, fetch(:stage))) }
10
+ set :sidekiq_log, -> { File.join(shared_path, 'log', 'sidekiq.log') }
11
+ set :sidekiq_timeout, -> { 10 }
12
+ set :sidekiq_role, -> { :app }
13
+ set :sidekiq_processes, -> { 1 }
14
+ # Rbenv and RVM integration
15
+ set :rbenv_map_bins, fetch(:rbenv_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
16
+ set :rvm_map_bins, fetch(:rvm_map_bins).to_a.concat(%w(sidekiq sidekiqctl))
17
+ end
18
+ end
19
+
20
+ namespace :deploy do
21
+ before :starting, :check_sidekiq_hooks do
22
+ invoke 'sidekiq:add_default_hooks' if fetch(:sidekiq_default_hooks)
23
+ end
24
+ after :publishing, :restart_sidekiq do
25
+ invoke 'sidekiq:restart' if fetch(:sidekiq_default_hooks)
26
+ end
27
+ end
28
+
29
+ namespace :sidekiq do
30
+ def for_each_process(reverse = false, &block)
31
+ pids = processes_pids
32
+ pids.reverse! if reverse
33
+ pids.each_with_index do |pid_file, idx|
34
+ p fetch(:sidekiq_path)
35
+ within fetch(:sidekiq_path) do
36
+ yield(pid_file, idx)
37
+ end
38
+ end
39
+ end
40
+
41
+ def processes_pids
42
+ pids = []
43
+ fetch(:sidekiq_processes).times do |idx|
44
+ pids.push (idx.zero? && fetch(:sidekiq_processes) <= 1) ?
45
+ fetch(:sidekiq_pid) :
46
+ fetch(:sidekiq_pid).gsub(/\.pid$/, "-#{idx}.pid")
47
+
48
+ end
49
+ pids
50
+ end
51
+
52
+ def pid_process_exists?(pid_file)
53
+ pid_file_exists?(pid_file) and test(*("kill -0 $( cat #{pid_file} )").split(' '))
54
+ end
55
+
56
+ def pid_file_exists?(pid_file)
57
+ test(*("[ -f #{pid_file} ]").split(' '))
58
+ end
59
+
60
+ def stop_sidekiq(pid_file)
61
+ if fetch(:stop_sidekiq_in_background, fetch(:sidekiq_run_in_background))
62
+ if fetch(:sidekiq_use_signals)
63
+ background "kill -TERM `cat #{pid_file}`"
64
+ else
65
+ background :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
66
+ end
67
+ else
68
+ execute :bundle, :exec, :sidekiqctl, 'stop', "#{pid_file}", fetch(:sidekiq_timeout)
69
+ end
70
+ end
71
+
72
+ def quiet_sidekiq(pid_file)
73
+ if fetch(:sidekiq_use_signals)
74
+ background "kill -USR1 `cat #{pid_file}`"
75
+ else
76
+ begin
77
+ execute :bundle, :exec, :sidekiqctl, 'quiet', "#{pid_file}"
78
+ rescue SSHKit::Command::Failed
79
+ # If gems are not installed eq(first deploy) and sidekiq_default_hooks as active
80
+ warn 'sidekiqctl not found (ignore if this is the first deploy)'
81
+ end
82
+ end
83
+ end
84
+
85
+ def start_sidekiq(pid_file, idx = 0)
86
+ args = []
87
+ args.push "--index #{idx}"
88
+ args.push "--pidfile #{pid_file}"
89
+ args.push "--environment #{fetch(:sidekiq_env)}"
90
+ args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log)
91
+ args.push "--require #{fetch(:sidekiq_require)}" if fetch(:sidekiq_require)
92
+ args.push "--tag #{fetch(:sidekiq_tag)}" if fetch(:sidekiq_tag)
93
+ Array(fetch(:sidekiq_queue)).each do |queue|
94
+ args.push "--queue #{queue}"
95
+ end
96
+ args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config)
97
+ args.push "--concurrency #{fetch(:sidekiq_concurrency)}" if fetch(:sidekiq_concurrency)
98
+ # use sidekiq_options for special options
99
+ args.push fetch(:sidekiq_options) if fetch(:sidekiq_options)
100
+
101
+ if defined?(JRUBY_VERSION)
102
+ args.push '>/dev/null 2>&1 &'
103
+ warn 'Since JRuby doesn\'t support Process.daemon, Sidekiq will not be running as a daemon.'
104
+ else
105
+ args.push '--daemon'
106
+ end
107
+
108
+ if fetch(:start_sidekiq_in_background, fetch(:sidekiq_run_in_background))
109
+ background :bundle, :exec, :sidekiq, args.compact.join(' ')
110
+ else
111
+ execute :bundle, :exec, :sidekiq, args.compact.join(' ')
112
+ end
113
+ end
114
+
115
+ task :add_default_hooks do
116
+ after 'deploy:starting', 'sidekiq:quiet'
117
+ after 'deploy:updated', 'sidekiq:stop'
118
+ after 'deploy:reverted', 'sidekiq:stop'
119
+ after 'deploy:published', 'sidekiq:start'
120
+ end
121
+
122
+ desc 'Quiet sidekiq (stop processing new tasks)'
123
+ task :quiet do
124
+ on roles fetch(:sidekiq_role) do
125
+ if test("[ -d #{release_path} ]") # fixes #11
126
+ for_each_process(true) do |pid_file, idx|
127
+ if pid_process_exists?(pid_file)
128
+ quiet_sidekiq(pid_file)
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+ desc 'Stop sidekiq'
136
+ task :stop do
137
+ on roles fetch(:sidekiq_role) do
138
+ if test("[ -d #{release_path} ]")
139
+ for_each_process(true) do |pid_file, idx|
140
+ if pid_process_exists?(pid_file)
141
+ stop_sidekiq(pid_file)
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+
148
+ desc 'Start sidekiq'
149
+ task :start do
150
+ on roles fetch(:sidekiq_role) do
151
+ for_each_process do |pid_file, idx|
152
+ start_sidekiq(pid_file, idx) unless pid_process_exists?(pid_file)
153
+ end
154
+ end
155
+ end
156
+
157
+ desc 'Restart sidekiq'
158
+ task :restart do
159
+ invoke 'sidekiq:stop'
160
+ invoke 'sidekiq:start'
161
+ end
162
+
163
+ desc 'Rolling-restart sidekiq'
164
+ task :rolling_restart do
165
+ on roles fetch(:sidekiq_role) do
166
+ for_each_process(true) do |pid_file, idx|
167
+ if pid_process_exists?(pid_file)
168
+ stop_sidekiq(pid_file)
169
+ end
170
+ start_sidekiq(pid_file, idx)
171
+ end
172
+ end
173
+ end
174
+
175
+ # Delete any pid file not in use
176
+ task :cleanup do
177
+ on roles fetch(:sidekiq_role) do
178
+ for_each_process do |pid_file, idx|
179
+ if pid_file_exists?(pid_file)
180
+ execute "rm #{pid_file}" unless pid_process_exists?(pid_file)
181
+ end
182
+ end
183
+ end
184
+ end
185
+
186
+ # TODO : Don't start if all proccess are off, raise warning.
187
+ desc 'Respawn missing sidekiq proccesses'
188
+ task :respawn do
189
+ invoke 'sidekiq:cleanup'
190
+ on roles fetch(:sidekiq_role) do
191
+ for_each_process do |pid_file, idx|
192
+ unless pid_file_exists?(pid_file)
193
+ start_sidekiq(pid_file, idx)
194
+ end
195
+ end
196
+ end
197
+ end
198
+
199
+ def template_sidekiq(from, to, role)
200
+ [
201
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}-#{fetch(:stage)}.rb"),
202
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{role.hostname}.rb"),
203
+ File.join('lib', 'capistrano', 'templates', "#{from}-#{fetch(:stage)}.rb"),
204
+ File.join('lib', 'capistrano', 'templates', "#{from}.rb.erb"),
205
+ File.join('lib', 'capistrano', 'templates', "#{from}.rb"),
206
+ File.join('lib', 'capistrano', 'templates', "#{from}.erb"),
207
+ File.expand_path("../../templates/#{from}.rb.erb", __FILE__),
208
+ File.expand_path("../../templates/#{from}.erb", __FILE__)
209
+ ].each do |path|
210
+ if File.file?(path)
211
+ erb = File.read(path)
212
+ upload! StringIO.new(ERB.new(erb).result(binding)), to
213
+ break
214
+ end
215
+ end
216
+ end
217
+
218
+ end
@@ -0,0 +1,3 @@
1
+ $:.unshift("./backend")
2
+ require 'lib/static-app'
3
+ run LrdCms2::StaticApp.build("frontend/bin", ENV['LRD_BACKEND_PORT'])
@@ -0,0 +1,68 @@
1
+ #!/bin/bash -e
2
+
3
+ #TODO: port needs to actually do the port addition e.g. -p 1 => +1 to port numbers
4
+
5
+ existing="yes"
6
+ new_thing="pane"
7
+ port=0
8
+ extra_config=~/.lrd-dev-tmux.conf
9
+
10
+ if [ -z $TMUX ]; then
11
+ existing="no"
12
+ fi
13
+
14
+ if tmux list-windows -F '#{window_name}' | egrep 'Dev Servers|Grunt Watch|Backend Server|Sidekiq'; then
15
+ echo "It looks like there are already windows open for this tmux?"
16
+ exit 2
17
+ fi
18
+
19
+ while getopts Pw option; do
20
+ case $option in
21
+ P) new_thing="pane";;
22
+ w) new_thing="window";;
23
+
24
+ esac
25
+ done
26
+
27
+ DEPENDENCIES_INCLUDE_TMUX=true rake preflight || exit 1
28
+
29
+ frontend_dir=$(realpath frontend)
30
+ backend_dir=$(realpath backend)
31
+
32
+ case $new_thing in
33
+ pane)
34
+ if [ $existing == "yes" ]; then
35
+ tmux new-window -n "Dev Servers" -c $frontend_dir 'bundle exec node_modules/.bin/grunt --stack watch:develop' \; set-window-option remain-on-exit on
36
+ else
37
+ tmux new-session -d -n "Dev Servers" -c $frontend_dir 'bundle exec node_modules/.bin/grunt --stack watch:develop' \; set-window-option remain-on-exit on
38
+ fi
39
+
40
+ tmux split-window -c $backend_dir 'bundle exec sidekiq'
41
+ tmux split-window -c $backend_dir 'bundle exec rails server'
42
+
43
+ tmux select-layout -t "Dev Servers" tiled
44
+ ;;
45
+ window)
46
+ if [ $existing == "yes" ]; then
47
+ tmux new-window -c $frontend_dir -n "Grunt Watch" 'env; bundle exec node_modules/.bin/grunt watch:develop' \; set-window-option remain-on-exit on
48
+ else
49
+ tmux new-session -d -c $frontend_dir -n "Grunt Watch" 'env; bundle exec node_modules/.bin/grunt watch:develop' \; set-window-option remain-on-exit on
50
+ fi
51
+
52
+ tmux new-window -c $backend_dir -n "Backend Server" 'bundle exec rails server' \; set-window-option remain-on-exit on
53
+
54
+ tmux new-window -c $backend_dir -n "Sidekiq" 'bundle exec sidekiq' \; set-window-option remain-on-exit on
55
+ esac
56
+
57
+ if [ -f $extra_config ]; then
58
+ echo Loading $extra_config
59
+ tmux source-file $extra_config
60
+ else
61
+ echo No $extra_config to load
62
+ fi
63
+
64
+ if [ $existing != "yes" ]; then
65
+ tmux attach-session -d
66
+ fi
67
+
68
+ rake develop:launch_browser
@@ -0,0 +1,53 @@
1
+ A quick guide to tmux-windows:
2
+
3
+ ( "Help, I started tmux-windows and I can't get out!" Hit Ctrl-b, type
4
+ kill-session, hit return )
5
+
6
+ This is a script around the very excellent terminal multiplexer tmux. The
7
+ script launches all the services that help develop web apps in the LRD
8
+ framework.
9
+
10
+ Start by running `./tmux-windows` - you'll see some output while it checks
11
+ that things seem to be in order, and then it'll redraw the console into 3
12
+ panes.
13
+
14
+ - In one, you'll see a big Grunt task building the front end JavaScript.
15
+ - In the next, you'll see Sidekiq handling background processes.
16
+ - In the last, you'll see the Rails server handling requests.
17
+
18
+ A browser window should open connected to the development server, so you can
19
+ poke around at things as you work on it.
20
+
21
+ Quickie on the default command and interactions:
22
+
23
+ Tmux is meant to get out of the way while you do other things. As a result,
24
+ you need to let it know that keystrokes are directed at it. By default, you
25
+ prefix all your commands directed at tmux with Ctrl-b.
26
+
27
+ Ctrl-b Up/Down/Left/Right will bounce around between panes.
28
+ Ctrl-b : will open up a command line where you can enter commands for tmux
29
+ Useful examples include
30
+ kill-session (when you're done)
31
+ respawn-pane (if one of the services crashes - Tmux will add the message
32
+ "Pane is dead")
33
+ respawn-window -k (restart everything)
34
+
35
+ Ctrl-b [ enters copy mode which merits its own section
36
+
37
+ Copy Mode:
38
+ You can copy and paste stuff using just the keyboard here, but the most useful
39
+ commands are these:
40
+ You can use PageUp/PageDown and the arrow keys to browse the backlog.
41
+
42
+ ? to search - type a few characters, hit return.
43
+ n to search up for the next occurance.
44
+ N to search down for the next occrance.
45
+ (the search commands are brought in from less, if they look familiar)
46
+
47
+ q will end copy mode and go back to the bottom of the console, where the
48
+ service will still be running
49
+
50
+
51
+ Finally, there's an example-lrd-dev-tmux.conf file that you can copy to your
52
+ home directory to make thing a little easier. Review it first, if only to find
53
+ out where to put it! :)
data/lib/xing/cli.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'byebug'
2
-
3
1
  module Xing
4
2
  class CLI
5
3
  SUPPORTED_VERBS = %w{new}
@@ -38,12 +36,19 @@ Global Options:
38
36
  when 'new'
39
37
  opts = Trollop::options do
40
38
  opt :cms, "Include content management architecture. (coming soon)"
39
+ opt :ruby_version, "Set the ruby version used for the new project (e.g. 2.2)", :type => :string
41
40
  stop_on ['name']
42
41
  end
43
42
  name = ARGV.shift
44
43
  Trollop::die "Please specify a project name with 'xing new <name>'" unless name
45
44
  Trollop::die "The CMS option is not yet implemented." if opts[:cms]
46
- Xing::CLI::Generators::NewProject.new.generate(opts.merge({:name => name}))
45
+ if opts[:ruby_version].nil?
46
+ opts[:ruby_version] = RbConfig::CONFIG.values_at("MAJOR","MINOR").join(".")
47
+ end
48
+ generator = Xing::CLI::Generators::NewProject.new
49
+ generator.target_name = name
50
+ generator.ruby_version = opts[:ruby_version]
51
+ generator.generate
47
52
  else
48
53
  Trollop::die "Unknown command. Supported commands are [" + SUPPORTED_VERBS.join(" ") + "]"
49
54
  end
@@ -4,26 +4,61 @@ module Xing::CLI::Generators
4
4
  class NewProject
5
5
  include Caliph::CommandLineDSL
6
6
 
7
- BASE_PROJECT_URL = "git@github.com:XingFramework/xing-application-base.git"
7
+ attr_accessor :target_name
8
+ attr_accessor :ruby_version
8
9
 
9
- # For the moment, this is the simplest thing that can work. Zero templating is done
10
- # so the project will still have the default module names etc.
11
- def generate(options)
12
- shell = Caliph.new()
13
- command = cmd('git', 'clone', '--depth=1', '--branch=master', BASE_PROJECT_URL, options[:name])
10
+ def shell
11
+ @shell ||= Caliph.new
12
+ end
13
+ attr_writer :shell
14
+
15
+ # For the moment, this is the simplest thing that can work. Zero templating
16
+ # is done so the project will still have the default module names etc.
17
+ def generate
18
+ command = cmd('cp', '-a', File.expand_path('../../../../../default_configuration/base_app/', __FILE__), target_name)
14
19
  result = shell.run(command)
15
20
 
16
- if result.succeeded?
17
- remove_git_directory(options[:name], shell)
21
+ unless result.succeeded?
22
+ raise "Attempt to copy base application to #{target_name} failed!"
23
+ end
24
+
25
+ write_ruby_version
26
+ write_ruby_version "frontend"
27
+ write_ruby_version "backend"
28
+
29
+ with_temporary_database_yml do
30
+ Bundler.with_clean_env do
31
+ shell.run(cmd("cd", target_name) &
32
+ cmd("bundle", "install")).must_succeed!
33
+
34
+ shell.run(cmd("cd", File.join(target_name, "frontend")) &
35
+ cmd("bundle", "install") &
36
+ cmd("npm", "install")).must_succeed!
37
+
38
+ shell.run(cmd("cd", File.join(target_name, "backend")) &
39
+ cmd("bundle", "install") &
40
+ cmd("rake", "xing:install:migrations")).must_succeed!
41
+ end
42
+ end
43
+ end
44
+
45
+ def with_temporary_database_yml
46
+ dbyml_path = File.join(target_name, "backend", "config", "database.yml")
47
+ if File.exist?(dbyml_path)
48
+ yield
18
49
  else
19
- raise "Attempt to clone base git repository failed!"
50
+ begin
51
+ File.open(dbyml_path, "w"){}
52
+ yield
53
+ ensure
54
+ File.unlink(dbyml_path)
55
+ end
20
56
  end
21
57
  end
22
58
 
23
- def remove_git_directory(name, shell)
24
- git_dir = File.join("#{name}", ".git")
25
- if File.exists?(git_dir)
26
- shell.run(cmd('rm -rf', git_dir))
59
+ def write_ruby_version(*subdir)
60
+ File.open(File.join(*([target_name] + subdir + [".ruby-version"])), "w") do |rv|
61
+ rv.write(ruby_version)
27
62
  end
28
63
  end
29
64
  end