xnlogic 1.0.28 → 1.0.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0c76d195dd38887c45cb3607e37b76b46f9aa59
4
- data.tar.gz: 609ef7558fc53d793daf06e5d3492a37708000af
3
+ metadata.gz: a6289c5acc2d9d23ec6c3113e13c8c684e310e6e
4
+ data.tar.gz: 890996e3dacd9c0ef21ca8c9b394370741dcbb7a
5
5
  SHA512:
6
- metadata.gz: e150c0fd30e61b5d4e518b378676b10f285198b8cdf9db02dc869c7287641934f3cbbd8106803fe6f9b7dc7755800c8a5f3b950ca7a0357b6710e5a5d447486d
7
- data.tar.gz: 8c3a09415dd81ab777031ff6c0b04bffc9a9fb5fd214442f7e1217fdcc4202c3b1f1e87373f98888b1b5de83201beb039562edca79b097747e778de76abf554e
6
+ metadata.gz: d0c66d6fe416ea7ac2c4839f8d6ff47d86de921d302b2fc1268191478631939204d5e75e4ede10e33667b07fce6581982cd8315c6d32bd40bd87a5fcb44d560d
7
+ data.tar.gz: a8bef2d0b60b3a1ba0f8b9af75a733d3f2385c69026bc56f91d0664d270f095e03fd99c0fa3080775e755e68a0bf916be3683b6838448baeb7e02a344dae2f4d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # xnlogic
2
2
 
3
- Bootstrap your xnlogic.com application with this easy to use executable gem.
3
+ Bootstrap your [xnlogic.com](http://xnlogic.com) application with this easy to use executable gem.
4
4
 
5
5
  ![gem install xnlogic](https://raw.githubusercontent.com/wiki/xnlogic/xn-gem-template/gif/readme_header.gif)
6
6
 
@@ -11,32 +11,54 @@ Bootstrap your xnlogic.com application with this easy to use executable gem.
11
11
 
12
12
  ## Usage
13
13
 
14
- $ xnlogic application my_app --key xnuser:xnpassword
14
+ $ xnlogic application my_app --key xnuser:xnpassword --up
15
15
  $ cd my_app
16
- $ vagrant up
17
- $ vagrant ssh
16
+ $ xnlogic ssh
18
17
 
19
18
  From the Vagrant VM, you can then:
20
19
 
21
20
  $ xn-server
22
21
  $ xn-console
23
22
 
24
- ## Development
25
23
 
26
- To execute from your checked out development version, run it as follows:
24
+ ## Reference
25
+
26
+ The general syntax of the command-line tool is
27
+
28
+ $ xnlogic COMMAND [ARGS] [OPTIONS]
29
+
30
+ And the following commands are available:
31
+
32
+ | Command | Description |
33
+ | ------- | ----------- |
34
+ | `application` | Create/update an application. |
35
+ | `up` | Start a development VM |
36
+ | `ssh` | Log in to a running development VM |
37
+ | `vm_config` | Update the configuration and settings of an application. |
38
+ | `provision` | Apply configuration updates to a running VM |
39
+ | `server_profiles` | Generates a server profile that can be used to configure a production deployment. |
40
+ | `gem_sources` | List gem sources required by this application |
41
+ | `version` | Print the version of the command-line tool |
42
+ | `help` | Display a help page |
43
+
44
+ You can get more information on each command using
45
+
46
+ $ xnlogic help COMMAND
47
+
27
48
 
28
- ruby -I ~/dev/xnlogic/lib ~/dev/xnlogic/bin/xnlogic vm_config
29
49
 
30
50
  ## Contributing
31
51
 
32
- 1. Fork it ( https://github.com/[my-github-username]/xnlogic/fork )
33
- 2. Create your feature branch (`git checkout -b my-new-feature`)
34
- 3. Commit your changes (`git commit -am 'Add some feature'`)
35
- 4. Push to the branch (`git push origin my-new-feature`)
36
- 5. Create a new Pull Request
52
+ Pull-requests are welcome.
53
+ If you submit a pull-request, please create a feature branch for your changes.
54
+
55
+ #### Using the CLI in development
37
56
 
57
+ To execute from your checked out development version, run it as follows:
58
+
59
+ ruby -I ~/dev/xnlogic/lib ~/dev/xnlogic/bin/xnlogic vm_config
38
60
 
39
- ## Releasing a new gem to rubygems:
61
+ #### Releasing a new gem to rubygems:
40
62
 
41
63
  CI is not set up yet, so once you're happy with the release, simply:
42
64
 
@@ -59,6 +59,7 @@ module Xnlogic
59
59
  require_key
60
60
  generate_vm_config if options['vm_config']
61
61
  generate_application
62
+ options['application_version'] = Xnlogic::VERSION
62
63
  write_options
63
64
  Xnlogic.ui.info "Initializing git repo in #{app}"
64
65
  Dir.chdir(app) { system 'git init' and system 'git add .' }
@@ -88,6 +89,7 @@ module Xnlogic
88
89
 
89
90
  def vm_config
90
91
  generate_vm_config
92
+ options['vm_config_version'] = Xnlogic::VERSION
91
93
  write_options
92
94
  install_vagrant_note
93
95
 
@@ -114,6 +116,26 @@ module Xnlogic
114
116
  end
115
117
  end
116
118
 
119
+
120
+ def update_key(xn_key)
121
+ # Set the option
122
+ options['key'] = xn_key
123
+
124
+ # Check that we are in an existing project folder
125
+ in_existing_project
126
+
127
+ # Gemerate the necessary templates
128
+ templates = {
129
+ "Gemfile.tt" => "Gemfile",
130
+ "config/vagrant.provision.tt" => "config/vagrant.provision",
131
+ }
132
+ _generate_templates(templates, 'vagrant', template_options, 'Updating configuration')
133
+
134
+ # Write the options YAML file
135
+ write_options
136
+ end
137
+
138
+
117
139
  def template_options
118
140
  namespaced_path = name
119
141
  constant_name = namespaced_path.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
@@ -131,24 +153,34 @@ module Xnlogic
131
153
  }
132
154
  end
133
155
 
156
+
157
+ def _generate_templates(template_src_to_dst, template_folder, opts, ui_message=nil)
158
+ if(not ui_message.nil?)
159
+ Xnlogic.ui.info ""
160
+ Xnlogic.ui.info ui_message
161
+ Xnlogic.ui.info ""
162
+ end
163
+
164
+ template_src_to_dst.each do |src, dst|
165
+ thor.template("#{template_folder}/#{src}", app.join(dst), opts)
166
+ end
167
+ end
168
+
169
+
134
170
  def generate_vm_config
135
- opts = template_options
136
171
  base_templates = {
137
172
  "Vagrantfile.tt" => "Vagrantfile",
138
173
  "Gemfile.tt" => "Gemfile",
139
174
  "config/vagrant.provision.tt" => "config/vagrant.provision",
140
175
  "config/datomic.conf" => "config/datomic.conf",
176
+ "config/start.sh" => "config/start.sh",
141
177
  "config/transactor.properties" => "config/transactor.properties",
142
178
  }
143
179
 
144
- Xnlogic.ui.info ""
145
- Xnlogic.ui.info "Creating Vagrant configuration"
146
- Xnlogic.ui.info ""
147
- base_templates.each do |src, dst|
148
- thor.template("vagrant/#{src}", app.join(dst), opts)
149
- end
180
+ _generate_templates(base_templates, 'vagrant', template_options, 'Creating Vagrant configuration')
150
181
  end
151
182
 
183
+
152
184
  def generate_application
153
185
  opts = template_options
154
186
  namespaced_path = opts[:namespaced_path]
@@ -179,13 +211,10 @@ module Xnlogic
179
211
  "spec/gemname/gemname_spec.rb.tt" => "spec/#{namespaced_path}/#{name}_spec.rb",
180
212
  }
181
213
 
182
- Xnlogic.ui.info ""
183
- Xnlogic.ui.info "Creating application templates"
184
- Xnlogic.ui.info ""
185
- templates.each do |src, dst|
186
- thor.template("application/#{src}", app.join(dst), opts)
187
- end
214
+ _generate_templates(templates, 'application', opts, 'Creating application templates')
188
215
  end
216
+
217
+
189
218
  end
190
219
  end
191
220
 
@@ -24,6 +24,7 @@ module Xnlogic
24
24
  end
25
25
 
26
26
  def write_options
27
+ options['last_run_version'] = Xnlogic::VERSION
27
28
  Dir.mkdir(app.join('config')) unless app.join('config').exist?
28
29
  opts = options.clone
29
30
  ignore_options.each do |x|
data/lib/xnlogic/cli.rb CHANGED
@@ -125,6 +125,12 @@ EOD
125
125
  exec 'vagrant ssh'
126
126
  end
127
127
 
128
+ desc "key XN_KEY", "Set the key (i.e. xn_user:xn_password) for this application."
129
+ def key(xn_key)
130
+ app = Application.new(options, self)
131
+ app.update_key(xn_key)
132
+ end
133
+
128
134
  desc "server_profile HOSTNAME [OPTIONS]",
129
135
  "Generate a new server profile"
130
136
  method_option "ssh_user", type: :string, default: 'deploy', banner:
@@ -1,7 +1,10 @@
1
1
  # xnlogic gem does not require these dependencies itself, they are used by the
2
2
  # generated app which does require them.
3
- require 'torquebox-rake-support'
4
- require 'torquebox-remote-deployer'
3
+ begin
4
+ # optional dependencies
5
+ require 'torquebox-rake-support'
6
+ require 'torquebox-remote-deployer'
7
+ rescue LoadError; nil; end
5
8
 
6
9
  # Monkey patches deploy utils to modify the environment to allow bundler to run successfully.
7
10
  module TorqueBox
@@ -12,6 +15,10 @@ module TorqueBox
12
15
  # RUBYOPT has to be unset from the environment so bundler doesn't lose its shit
13
16
  env_vars = { 'RUBYOPT' => nil }
14
17
 
18
+
19
+
20
+
21
+
15
22
  system(env_vars, "#{cmd} 2>&1")
16
23
  end
17
24
 
@@ -43,6 +43,10 @@ Updates an existing application with the current Vagrant VM configuration, or ca
43
43
  \fBxnlogic server_profile(1)\fR
44
44
  Generates a server profile that can be used to configure a production deployment\.
45
45
  .
46
+ .TP
47
+ \fBxnlogic key(1)\fR
48
+ Updates the key (i\.e\. xn_user:xn_password) used by an existing application\.
49
+ .
46
50
  .SH "UTILITY COMMANDS"
47
51
  .
48
52
  .TP
@@ -38,16 +38,20 @@ APPLICATION UPDATES
38
38
  Generates a server profile that can be used to configure a pro-
39
39
  duction deployment.
40
40
 
41
+ xnlogic key(1)
42
+ Updates the key (i.e. xn_user:xn_password) used by an existing
43
+ application.
44
+
41
45
  UTILITY COMMANDS
42
46
  xnlogic up(1)
43
- Starts the development VM. On the first run (only) it will also
47
+ Starts the development VM. On the first run (only) it will also
44
48
  provision it.
45
49
 
46
50
  xnlogic ssh(1)
47
51
  Interactively log into the development VM.
48
52
 
49
53
  xnlogic provision(1)
50
- Update a running VM's configuration to match the con-
54
+ Update a running VM's configuration to match the con-
51
55
  fig/vagrant.provision script.
52
56
 
53
57
  xnlogic gem_sources(1)
@@ -1,54 +1,70 @@
1
- if defined?(Capistrano)
2
- # Captures Capistrano-relevant configuration from a server profile.
3
- class CapConfig
4
- class << self
5
- attr_reader :roles, :variables
6
-
7
- def configure(&config_block)
8
- @roles = {}
9
- @variables = {}
10
- instance_eval &config_block
11
- end
12
-
13
- # config_binding is the binding taken from the Capistrano configuration file
14
- def apply_config(config_binding)
15
- roles.each { |role, user| config_binding.eval("role #{role.inspect}, #{user.inspect}") }
16
- variables.each { |name, val| config_binding.eval("set #{name.inspect}, #{val.inspect}") }
17
- end
18
-
19
- # Setters
20
-
21
- def hostname(hn)
22
- @roles[:web] = hn
23
- end
24
-
25
- def api_hostname(hn)
26
- @variables[:api_hostname] = hn
27
- end
28
-
29
- def user(u)
30
- @variables[:user] = u
31
- end
32
-
33
- def method_missing(symbol, *args)
34
- # Swallow config settings we don't care about
35
- end
1
+ # Captures Capistrano-relevant configuration from a server profile.
2
+ class DeployConfig
3
+ class << self
4
+ attr_reader :roles, :variables
5
+
6
+ def configure(&config_block)
7
+ @roles = {}
8
+ @variables = {}
9
+ instance_eval &config_block
36
10
  end
37
- end
38
11
 
39
- def server_profile(&config_block)
40
- CapConfig.configure(&config_block)
12
+ # config_binding is the binding taken from the Capistrano configuration file
13
+ def apply_cap_config(config_binding)
14
+ roles.each { |role, user| config_binding.eval("role #{role.inspect}, #{user.inspect}") }
15
+ variables.each { |name, val| config_binding.eval("set #{name.inspect}, #{val.inspect}") }
16
+ end
17
+
18
+ # Setters
19
+
20
+ def hostname(hn)
21
+ @roles[:web] = hn
22
+ end
23
+
24
+ def api_hostname(hn)
25
+ @variables[:api_hostname] = hn
26
+ end
27
+
28
+ def user(u)
29
+ @variables[:user] = u
30
+ end
31
+
32
+ def ssl_cert(cert_path)
33
+ @variables[:ssl_cert] = cert
34
+ end
35
+
36
+ def nginx_conf(file_path)
37
+ @variables[:nginx_conf] = cert
38
+ end
39
+
40
+ def method_missing(symbol, *args)
41
+ # Swallow config settings we don't care about
42
+ end
41
43
  end
42
- else # torquebox remote deployer
44
+ end
45
+
46
+ if defined? TorqueBox
43
47
  # Monkey patching this to extend the configuration
44
48
  class TorqueBox::RemoteDeploy
45
49
  def api_hostname(hn)
46
50
  # Unused
47
51
  end
52
+
53
+ def ssl_cert(cert_path)
54
+ # Unused
55
+ end
56
+
57
+ def nginx_conf(file_path)
58
+ # Unused
59
+ end
48
60
  end
49
61
 
50
62
  def server_profile(&config_block)
63
+ DeployConfig.configure(&config_block)
51
64
  TorqueBox::RemoteDeploy.configure(&config_block)
52
65
  end
66
+ else
67
+ def server_profile(&config_block)
68
+ DeployConfig.configure(&config_block)
69
+ end
53
70
  end
54
-
@@ -9,4 +9,3 @@ rescue LoadError => e
9
9
  puts e
10
10
  puts e.backtrace.join("\n")
11
11
  end
12
-
@@ -2,5 +2,6 @@ require 'torquebox-messaging'
2
2
  require '<%= config[:namespaced_path] %>'
3
3
 
4
4
  # Silence Datomic's verbose console logs
5
- org.slf4j.LoggerFactory.getILoggerFactory.reset
5
+ factory = org.slf4j.LoggerFactory.getILoggerFactory
6
+ factory.reset if factory.respond_to? :reset
6
7
 
File without changes
@@ -10,4 +10,8 @@ source "https://rubygems.org/"
10
10
 
11
11
  gemspec
12
12
 
13
- eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
13
+ unless ENV['CONFIG_FILE'] # ie. deployment
14
+ # Gemfile-custom is .gitignored, but evaluated here so you can add
15
+ # whatever dev tools you like to use to your local environment.
16
+ eval File.read('Gemfile-custom') if File.exist?('Gemfile-custom')
17
+ end
@@ -0,0 +1,86 @@
1
+
2
+ #!/bin/bash
3
+
4
+ export XN_LOG_DIR=$HOME/xn.dev/tmp
5
+
6
+ silent() { if [[ $debug ]] ; then "$@"; else "$@" &>/dev/null; fi; }
7
+
8
+ # Check for jruby 1.7, don't force it.
9
+ if [[ `ruby -v` == jruby\ 1.7* ]]; then
10
+ echo "Using `ruby -v`"
11
+ else
12
+ echo "Unsupported Ruby version: (`ruby -v | cut -c 1-35`)"
13
+ echo "Please try again with jruby-1.7.x"
14
+ fi
15
+ echo '{"note":"Suppressing Torquebox logs."}' | json -i | cat
16
+
17
+
18
+ cd $HOME/xn.dev
19
+
20
+ mkdir -p $XN_LOG_DIR
21
+ cd $XN_LOG_DIR
22
+ touch xn.js.log xnlogic.json development.log ${XN_CLIENT}-assets.log
23
+ cd -
24
+
25
+ cd fe/xn.js
26
+ cake serve &> $XN_LOG_DIR/xn.js.log &
27
+ echo "xn.js started"
28
+ cd -
29
+
30
+
31
+
32
+ ASSETS_DIR=$HOME/$XN_CLIENT/assets
33
+ if [ -d $ASSETS_DIR ]; then
34
+ ASSETS_PORT=3031
35
+
36
+ cd $ASSETS_DIR
37
+
38
+ script/duster -w assets/templates assets/javascripts/templates.js &> $XN_LOG_DIR/duster.js.log &
39
+
40
+ bundle exec rackup -p $ASSETS_PORT &> $XN_LOG_DIR/${XN_CLIENT}-assets.log &
41
+
42
+ cd -
43
+ fi
44
+
45
+
46
+
47
+
48
+ START_APPS=$HOME/$XN_CLIENT/apps/apps.start.sh
49
+ if [ -x $START_APPS ]; then
50
+ cd $HOME/$XN_CLIENT/apps
51
+ $START_APPS &
52
+ cd -
53
+ fi
54
+
55
+
56
+
57
+
58
+ cd $HOME/xn.dev
59
+
60
+
61
+ tail -n 0 -f fe/fe-server/log/development.log $XN_LOG_DIR/xn.js.log $XN_LOG_DIR/${XN_CLIENT}-assets.log &
62
+ tail -n 0 -f $XN_LOG_DIR/server.log | grep -E "Deployed|Starting deployment|TOPLEVEL_BINDING" &
63
+
64
+ tail -n 0 -f $XN_LOG_DIR/xnlogic.json | while read line; do echo "$line" | json -i; done &
65
+
66
+ warn_sigint() {
67
+ echo "Please wait for shutdown to complete cleanly. (Press Ctrl-C again to force)"
68
+ }
69
+
70
+
71
+ # Terminate all processes
72
+ terminator() {
73
+ trap 'warn_sigint' SIGINT
74
+ echo "Shutting down support processes..."
75
+ jobs -p | xargs kill -s SIGTERM
76
+ echo "Shutting down jboss..."
77
+ silent $JBOSS_HOME/bin/jboss-cli.sh --connect :shutdown
78
+ }
79
+ trap 'terminator' SIGINT
80
+
81
+ export RELOAD=true
82
+ echo "starting torquebox"
83
+ lsof -i :8080 -sTCP:listen | grep . || torquebox run &> /dev/null &
84
+ echo "Hit Ctrl+C to terminate"
85
+ cat
86
+ at
@@ -58,15 +58,13 @@ cd xn.dev
58
58
  source script/setup_stack
59
59
  echo jruby-${jruby_version} > .ruby-version
60
60
  cd fe/xn.js
61
- sudo npm install --loglevel silent
61
+ npm install --loglevel silent
62
62
  cd -
63
63
  rake --quiet new_tb_version bundle_fe_server fresh_fe_config fe_server_db_init
64
64
 
65
65
  if [ -d $HOME/$XN_CLIENT/assets ]; then
66
66
  hr
67
67
  echo "Configuring Assets"
68
- silent sudo chown -R vagrant:vagrant $HOME
69
- chown -R vagrant:vagrant $HOME
70
68
  cd $HOME/$XN_CLIENT/assets
71
69
  bundle install
72
70
  npm install
@@ -80,7 +78,8 @@ sudo start datomic
80
78
  hr
81
79
  echo "Customizing .zshrc for $XN_CLIENT development"
82
80
  echo "export XN_CLIENT=$XN_CLIENT" >> ~/.zshrc
83
- echo "alias xn-server='(cd ~/xn.dev && ./script/start);'" >> ~/.zshrc
81
+ chmod +x $XN_CLIENT/config/start.sh
82
+ echo "alias xn-server=$XN_CLIENT/config/start.sh" >> ~/.zshrc
84
83
  echo 'alias xn-console="(cd ~/$XN_CLIENT && bundle exec jruby -J-Xmx1g -J-XX:MaxPermSize=200m -S irb -I lib -r dev/console)"' >> ~/.zshrc
85
84
  echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> ~/.zshrc
86
85
  echo 'JRUBY_OPTS=--dev source $HOME/xn.dev/script/setup_stack' >> ~/.zshrc
@@ -98,12 +97,20 @@ git config --global --add alias.lg "log --color --graph --pretty=format:'%Cred%h
98
97
  git config --global --add alias.lga "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
99
98
  git config --global --add alias.branches "submodule foreach 'git branch | grep \*'"
100
99
 
101
-
102
-
103
100
  hr
104
101
  echo "Configuring $XN_CLIENT"
105
102
  cd $HOME/$XN_CLIENT
106
103
  bundle
107
104
  torquebox deploy
105
+
106
+ PROVISION_APPS=$HOME/$XN_CLIENT/apps/apps.provision.sh
107
+ if [ -x $PROVISION_APPS ]; then
108
+ hr
109
+ echo "Provisioning Custom Apps"
110
+ cd $HOME/$XN_CLIENT/apps
111
+ $PROVISION_APPS
112
+ cd -
113
+ fi
114
+
108
115
  hr
109
116
  echo "Done!"
@@ -1,3 +1,3 @@
1
1
  module Xnlogic
2
- VERSION = "1.0.28"
2
+ VERSION = "1.0.29"
3
3
  end
data/man/xnlogic.ronn CHANGED
@@ -37,6 +37,9 @@ We divide `xnlogic` subcommands into the initial command, update commands, and u
37
37
  * `xnlogic server_profile(1)`:
38
38
  Generates a server profile that can be used to configure a production deployment.
39
39
 
40
+ * `xnlogic key(1)`:
41
+ Updates the key (i.e. xn_user:xn_password) used by an existing application.
42
+
40
43
  ## UTILITY COMMANDS
41
44
 
42
45
  * `xnlogic up(1)`:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xnlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.28
4
+ version: 1.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darrick Wiebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -126,10 +126,12 @@ files:
126
126
  - lib/xnlogic/templates/application/tasks/deploy.rb.tt
127
127
  - lib/xnlogic/templates/application/torquebox.yml.tt
128
128
  - lib/xnlogic/templates/application/torquebox_init.rb.tt
129
+ - lib/xnlogic/templates/deploy/nginx.conf.tt
129
130
  - lib/xnlogic/templates/deploy/server_profiles/profile.rb.tt
130
131
  - lib/xnlogic/templates/vagrant/Gemfile.tt
131
132
  - lib/xnlogic/templates/vagrant/Vagrantfile.tt
132
133
  - lib/xnlogic/templates/vagrant/config/datomic.conf
134
+ - lib/xnlogic/templates/vagrant/config/start.sh
133
135
  - lib/xnlogic/templates/vagrant/config/transactor.properties
134
136
  - lib/xnlogic/templates/vagrant/config/vagrant.provision.tt
135
137
  - lib/xnlogic/ui.rb