capistrano-react-assets 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a9a2e6363473ad19d77010477badd3ce73c0946
4
+ data.tar.gz: 7feeb42b8d78b6cfa6c7ea3c1ef61844312ee844
5
+ SHA512:
6
+ metadata.gz: d68f89add8fefaf142c0c4924ad7b8900151c123609a4a43594f46d50d46043bdbe0a6e702ec6bd96ee03533530791235a53ad8347779ed2376014e41fd70b88
7
+ data.tar.gz: 307c7e9f336f02d6e6d14bc4616f0fa727af3fd9fe1f9b4244847198fd334adc88dcc3120dfc21a397b44c42da038426ce2817205cbdec8f961d25a72e36d96a
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ .ruby-gemset
4
+ pkg/
5
+ vendor/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016, Goldstar Events, Inc.
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,31 @@
1
+ # Capistrano React Assets
2
+
3
+ Package react assets locally (once) and upload to each host. This saves you time since the npm modules are only installed (and compiled) once, and the assets are only packaged once. The assets are then compressed, shipped, and unpacked.
4
+
5
+ # Setup
6
+
7
+ Add the library to your `Gemfile`:
8
+
9
+ ```
10
+ gem 'capistrano-react-assets'
11
+ ```
12
+
13
+ Add the library to your `Capfile`:
14
+
15
+ ```
16
+ require 'capistrano/react-assets'
17
+ ```
18
+
19
+ Provide some setup and invoke the commands in your `config/deploy.rb` or `config/deploy/ENVIRONMENT.rb`:
20
+
21
+ ```
22
+ set :assets_tar, "assets.tar.bz2"
23
+ set :assets_package_path, "public/webpack"
24
+ set :remote_assets_tar, File.join(fetch(:deploy_to), "current", fetch(:assets_tar))
25
+ set :remote_assets_path, File.join(fetch(:deploy_to), "current", fetch(:assets_package_path))
26
+
27
+ before "unicorn_restart", "react_assets:prepare_environment"
28
+ after "react_assets:prepare_environment", "react_assets:package_and_upload"
29
+ after "react_assets:package_and_upload", "react_assets:cleanup"
30
+ ```
31
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "capistrano-react-assets"
6
+ gem.version = "0.0.0"
7
+ gem.authors = ["Patrick O'Brien"]
8
+ gem.email = ["pobrien@goldstar.com"]
9
+ gem.description = "Package and push react assets locally"
10
+ gem.summary = "Package and push react assets locally"
11
+ gem.homepage = "https://github.com/goldstar/capistrano-react-assets"
12
+ gem.license = "MIT"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_runtime_dependency 'capistrano', '~> 3.1', '>= 3.1.0'
19
+ end
@@ -0,0 +1 @@
1
+ load File.expand_path("../tasks/react-assets.rake", __FILE__)
@@ -0,0 +1,40 @@
1
+ namespace :react_assets do
2
+
3
+ # this is what compiles and packages the assets locally. It compiles the
4
+ # javascripts and tars up the generated files.
5
+ task :package_and_upload do
6
+ run_locally do
7
+ execute "rm -f #{fetch(:assets_tar)}"
8
+ execute "npm install --production ."
9
+ execute "rm -rf #{fetch(:assets_package_path)}"
10
+ execute "NODE_ENV=production npm run-script build"
11
+ execute "tar cjf #{fetch(:assets_tar)} #{fetch(:assets_package_path)}"
12
+ end
13
+
14
+ # this will create the public/javascripts directory if it needs to and
15
+ # will then upload the assets.tar.bz2 file there. after that it will
16
+ # unpack the tar.
17
+ on roles(:app) do
18
+ execute "if [[ ! -d #{fetch(:remote_assets_path)} ]]; then mkdir -p #{fetch(:remote_assets_path)}; fi"
19
+ upload! fetch(:assets_tar), File.join(fetch(:deploy_to), "current")
20
+ execute "tar xjf #{fetch(:remote_assets_tar)} -C #{File.join(fetch(:deploy_to), "current")}"
21
+ end
22
+
23
+ end
24
+
25
+ # clean up the remote assets tar
26
+ task :cleanup do
27
+ on roles(:app) do
28
+ execute "rm -f #{fetch(:remote_assets_tar)}"
29
+ end
30
+ end
31
+
32
+ task :prepare_environment do
33
+ run_locally do
34
+ execute "npm config set proxy 'http://proxy:3128'"
35
+ execute "npm config set registry https://registry.npmjs.org/"
36
+ end
37
+ end
38
+
39
+ end
40
+
File without changes
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-react-assets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Patrick O'Brien
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0
33
+ description: Package and push react assets locally
34
+ email:
35
+ - pobrien@goldstar.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - Gemfile
42
+ - LICENSE
43
+ - README.md
44
+ - Rakefile
45
+ - capistrano-react-assets.gemspec
46
+ - lib/capistrano/react-assets.rb
47
+ - lib/capistrano/tasks/react-assets.rake
48
+ - lib/react-assets.rb
49
+ homepage: https://github.com/goldstar/capistrano-react-assets
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.5.1
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Package and push react assets locally
73
+ test_files: []