capistrano-nodeenv 0.0.2
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.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE +22 -0
- data/README.md +70 -0
- data/Rakefile +2 -0
- data/capistrano-nodeenv.gemspec +20 -0
- data/lib/capistrano-nodeenv.rb +191 -0
- data/lib/capistrano-nodeenv/version.rb +5 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Alexandr Lispython
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# capistrano-virtualenv
|
2
|
+
|
3
|
+
a capistrano recipe to deploy python apps with [nodeenv](http://pypi.python.org/pypi/nodeenv).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-nodeenv'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-nodeenv
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This recipe will create 2 kind of nodeenv during `deploy` task.
|
22
|
+
|
23
|
+
* shared nodeenv
|
24
|
+
* created in `shared_path` after `deploy:setup`
|
25
|
+
* common libraries are installed here.
|
26
|
+
* release nodeenv
|
27
|
+
* created in `release_path` after `deploy:finalize_update`
|
28
|
+
* per-release nodeenv that can be rolled back.
|
29
|
+
|
30
|
+
To deploy your application with `nodeenv`, add following in you `config/deploy.rb`.
|
31
|
+
|
32
|
+
# in "config/deploy.rb"
|
33
|
+
require 'capistrano-nodeenv'
|
34
|
+
|
35
|
+
Following options are available to manage your nodeenv.
|
36
|
+
|
37
|
+
* `:nodeenv_bootstrap_python` - the python executable which will be used to craete nodeenv. by default "python".
|
38
|
+
* `:nodeenv_current_path` - nodeenv path under `:current_path`.
|
39
|
+
* `:nodeenv_current_node` - node path under `:nodeenv_current_path`.
|
40
|
+
* `:nodeenv_npm_options` - options for `npm`.
|
41
|
+
* `:nodeenv_install_packages` - apt packages dependencies for python.
|
42
|
+
* `:nodeenv_npm_install_options` - options for `pip install`.
|
43
|
+
* `:nodeenv_release_path` - nodeenv path under `:release_path`.
|
44
|
+
* `:nodeenv_release_python` - python path under `:nodeenv_release_path`.
|
45
|
+
|
46
|
+
* `:nodeenv_requirements_file` - the path to the directory that include package.json with dependencies.
|
47
|
+
* `:nodeenv_script_url` - the download URL of `nodeenv.py`.
|
48
|
+
* `:nodeenv_shared_path` - nodeenv path under `:shared_path`.
|
49
|
+
* `:nodeenv_shared_node` - node path under `:nodeenv_shared_path`
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
1. Fork it
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create new Pull Request
|
58
|
+
|
59
|
+
## Author
|
60
|
+
|
61
|
+
Authors of capistrano-virtualenv:
|
62
|
+
- YAMASHITA Yuu (https://github.com/yyuu)
|
63
|
+
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
64
|
+
|
65
|
+
capistrano-nodeenv:
|
66
|
+
- Alexandr Lispython (http://github.com/Lispython)
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano-nodeenv/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alexandr Lispython"]
|
6
|
+
gem.email = ["alex@obout.ru"]
|
7
|
+
gem.description = %q{a capistrano recipe to deploy nodejs apps with nodenev.}
|
8
|
+
gem.summary = %q{a capistrano recipe to deploy nodejs apps with nodenev.}
|
9
|
+
gem.homepage = "https://github.com/Lispython/capistrano-nodeenv"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "capistrano-nodeenv"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Capistrano::Nodeenv::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency("capistrano")
|
19
|
+
gem.add_dependency("capistrano-file-transfer-ext", "~> 0.0.3")
|
20
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require "capistrano-nodeenv/version"
|
2
|
+
require "capistrano/configuration/actions/file_transfer_ext"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
|
6
|
+
module Capistrano
|
7
|
+
module Nodeenv
|
8
|
+
# Your code goes here...
|
9
|
+
def self.extended(configuration)
|
10
|
+
configuration.load {
|
11
|
+
namespace(:nodeenv) {
|
12
|
+
_cset(:nodeenv_version, nil)
|
13
|
+
_cset(:nodeenv_jobs, 4)
|
14
|
+
_cset(:nodeenv_verbose, true)
|
15
|
+
|
16
|
+
_cset(:nodeenv_script_url, 'https://raw.github.com/ekalinin/nodeenv/master/nodeenv.py')
|
17
|
+
_cset(:nodeenv_script_file) {
|
18
|
+
File.join(shared_path, 'nodeenv', File.basename(URI.parse(nodeenv_script_url).path))
|
19
|
+
}
|
20
|
+
_cset(:nodeenv_bootstrap_python, 'python') # the python executable which will be used to craete nodeenv
|
21
|
+
|
22
|
+
# Make installation command
|
23
|
+
# execute downloaded nodeenv.py
|
24
|
+
_cset(:nodeenv_cmd) {
|
25
|
+
[
|
26
|
+
nodeenv_bootstrap_python,
|
27
|
+
nodeenv_script_file,
|
28
|
+
nodeenv_options,
|
29
|
+
].flatten.join(' ')
|
30
|
+
}
|
31
|
+
|
32
|
+
_cset(:nodeenv_requirements_file) { # secondary package list
|
33
|
+
File.join(release_path)
|
34
|
+
}
|
35
|
+
_cset(:nodeenv_options) {
|
36
|
+
os = ""
|
37
|
+
os << "--jobs=#{nodeenv_jobs} "
|
38
|
+
os << "--verbose " if nodeenv_verbose
|
39
|
+
os << "--node=#{nodeenv_version} " if nodeenv_version
|
40
|
+
#os << "--requirement=#{nodeenv_requirements_file}" if nodeenv_requirements_file
|
41
|
+
os
|
42
|
+
}
|
43
|
+
_cset(:nodeenv_npm_options, "")
|
44
|
+
_cset(:nodeenv_npm_install_options, [])
|
45
|
+
_cset(:nodeenv_npm_package, 'npm')
|
46
|
+
_cset(:nodeenv_requirements, []) # primary package list
|
47
|
+
|
48
|
+
_cset(:nodeenv_build_requirements, {})
|
49
|
+
_cset(:nodeenv_install_packages, []) # apt packages
|
50
|
+
|
51
|
+
## shared nodeenv:
|
52
|
+
## - created in shared_path
|
53
|
+
## - to be used to share libs between releases
|
54
|
+
_cset(:nodeenv_shared_path) {
|
55
|
+
File.join(shared_path, 'nodeenv', 'shared')
|
56
|
+
}
|
57
|
+
_cset(:nodeenv_shared_node) {
|
58
|
+
File.join(nodeenv_shared_path, 'bin', 'node')
|
59
|
+
}
|
60
|
+
_cset(:nodeenv_shared_npm) {
|
61
|
+
File.join(nodeenv_shared_path, 'bin', 'npm')
|
62
|
+
}
|
63
|
+
|
64
|
+
_cset(:nodeenv_shared_npm_cmd) {
|
65
|
+
[
|
66
|
+
nodeenv_shared_node,
|
67
|
+
nodeenv_shared_npm,
|
68
|
+
nodeenv_npm_options,
|
69
|
+
].flatten.join(' ')
|
70
|
+
}
|
71
|
+
|
72
|
+
## release nodeenv
|
73
|
+
## - created in release_path
|
74
|
+
## - common libs are copied from shared nodeenv
|
75
|
+
## - will be used for running application
|
76
|
+
_cset(:nodeenv_release_path) { # the path where runtime nodeenv will be created
|
77
|
+
File.join(release_path, 'vendor', 'nodeenv')
|
78
|
+
}
|
79
|
+
_cset(:nodeenv_release_node) { # the python executable within nodeenv
|
80
|
+
File.join(nodeenv_release_path, 'bin', 'node')
|
81
|
+
}
|
82
|
+
_cset(:nodeenv_release_npm) {
|
83
|
+
File.join(nodeenv_release_path, 'bin', 'npm')
|
84
|
+
}
|
85
|
+
_cset(:nodeenv_release_npm_cmd) {
|
86
|
+
[
|
87
|
+
nodeenv_release_node,
|
88
|
+
nodeenv_release_npm,
|
89
|
+
nodeenv_npm_options,
|
90
|
+
].flatten.join(' ')
|
91
|
+
}
|
92
|
+
|
93
|
+
## current nodeenv
|
94
|
+
## - placed in current_path
|
95
|
+
## - nodeenv of currently running application
|
96
|
+
_cset(:nodeenv_current_path) {
|
97
|
+
File.join(current_path, 'vendor', 'nodeenv')
|
98
|
+
}
|
99
|
+
_cset(:nodeenv_current_node) {
|
100
|
+
File.join(nodeenv_current_path, 'bin', 'node')
|
101
|
+
}
|
102
|
+
|
103
|
+
_cset(:nodeenv_current_npm) {
|
104
|
+
File.join(nodeenv_current_path, 'bin', 'npm')
|
105
|
+
}
|
106
|
+
_cset(:nodeenv_current_npm_cmd) {
|
107
|
+
[
|
108
|
+
nodeenv_current_python,
|
109
|
+
nodeenv_current_npm,
|
110
|
+
nodeenv_npm_options,
|
111
|
+
].flatten.join(' ')
|
112
|
+
}
|
113
|
+
|
114
|
+
desc("Setup nodeenv.")
|
115
|
+
task(:setup, :except => { :no_release => true }) {
|
116
|
+
transaction {
|
117
|
+
install
|
118
|
+
create_shared
|
119
|
+
}
|
120
|
+
}
|
121
|
+
after 'deploy:setup', 'nodeenv:setup'
|
122
|
+
|
123
|
+
desc("Install nodeenv.")
|
124
|
+
task(:install, :except => { :no_release => true }) {
|
125
|
+
#run("#{sudo} apt-get install #{nodeenv_install_packages.join(' ')}") unless nodeenv_install_packages.empty?
|
126
|
+
# Download nodeenv.py file
|
127
|
+
dirs = [ File.dirname(nodeenv_script_file) ].uniq()
|
128
|
+
run("mkdir -p #{dirs.join(' ')} && ( test -f #{nodeenv_script_file} || wget --no-verbose -O #{nodeenv_script_file} #{nodeenv_script_url} )")
|
129
|
+
}
|
130
|
+
|
131
|
+
desc("Uninstall nodeenv.")
|
132
|
+
task(:uninstall, :except => { :no_release => true }) {
|
133
|
+
run("rm -f #{nodeenv_script_file}")
|
134
|
+
}
|
135
|
+
|
136
|
+
task(:create_shared, :except => { :no_release => true }) {
|
137
|
+
dirs = [ File.dirname(nodeenv_shared_path) ].uniq()
|
138
|
+
cmds = [ ]
|
139
|
+
cmds << "mkdir -p #{dirs.join(' ')}"
|
140
|
+
cmds << "( test -d #{nodeenv_shared_path} || #{nodeenv_cmd} #{nodeenv_shared_path} )"
|
141
|
+
cmds << "#{nodeenv_shared_node} --version && #{nodeenv_shared_npm_cmd} --version"
|
142
|
+
run(cmds.join(' && '))
|
143
|
+
}
|
144
|
+
|
145
|
+
task(:destroy_shared, :except => { :no_release => true }) {
|
146
|
+
run("rm -rf #{nodeenv_shared_path}")
|
147
|
+
}
|
148
|
+
|
149
|
+
desc("Update nodeenv for project.")
|
150
|
+
task(:update, :except => { :no_release => true }) {
|
151
|
+
transaction {
|
152
|
+
update_shared
|
153
|
+
create_release
|
154
|
+
}
|
155
|
+
}
|
156
|
+
after 'deploy:finalize_update', 'nodeenv:update'
|
157
|
+
|
158
|
+
task(:update_shared, :except => { :no_release => true }) {
|
159
|
+
unless nodeenv_requirements.empty?
|
160
|
+
top.safe_put(nodeenv_requirements.join("\n"), nodeenv_requirements_file, :place => :if_modified)
|
161
|
+
end
|
162
|
+
run("touch #{nodeenv_requirements_file} && #{nodeenv_shared_npm_cmd} install #{nodeenv_npm_install_options.join(' ')} #{nodeenv_requirements_file}")
|
163
|
+
|
164
|
+
puts("Updated requirements")
|
165
|
+
execute = nodeenv_build_requirements.map { |package, options|
|
166
|
+
build_options = ( options || [] )
|
167
|
+
"#{nodeenv_shared_npm_cmd} install #{nodeenv_npm_install_options.join(' ')} #{build_options.join(' ')} #{package.dump}"
|
168
|
+
}
|
169
|
+
run(execute.join(' && ')) unless execute.empty?
|
170
|
+
}
|
171
|
+
|
172
|
+
task(:create_release, :except => { :no_release => true }) {
|
173
|
+
dirs = [ File.dirname(nodeenv_release_path) ].uniq()
|
174
|
+
cmds = [ ]
|
175
|
+
cmds << "mkdir -p #{dirs.join(' ')}"
|
176
|
+
|
177
|
+
# Copy nodeenv from shared to release directory
|
178
|
+
cmds << "cp -rf #{nodeenv_shared_path} #{nodeenv_release_path}"
|
179
|
+
cmds << "sed -i -e 's|#{nodeenv_shared_path}|#{nodeenv_release_path}|g' #{nodeenv_release_path}/bin/activate"
|
180
|
+
run(cmds.join(' && '))
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
if Capistrano::Configuration.instance
|
190
|
+
Capistrano::Configuration.instance.extend(Capistrano::Nodeenv)
|
191
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-nodeenv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alexandr Lispython
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-03-25 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: capistrano
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: capistrano-file-transfer-ext
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 25
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
- 3
|
47
|
+
version: 0.0.3
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
description: a capistrano recipe to deploy nodejs apps with nodenev.
|
51
|
+
email:
|
52
|
+
- alex@obout.ru
|
53
|
+
executables: []
|
54
|
+
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files: []
|
58
|
+
|
59
|
+
files:
|
60
|
+
- .gitignore
|
61
|
+
- Gemfile
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- capistrano-nodeenv.gemspec
|
66
|
+
- lib/capistrano-nodeenv.rb
|
67
|
+
- lib/capistrano-nodeenv/version.rb
|
68
|
+
homepage: https://github.com/Lispython/capistrano-nodeenv
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.15
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: a capistrano recipe to deploy nodejs apps with nodenev.
|
101
|
+
test_files: []
|
102
|
+
|