capistrano-honeybadger-sourcemaps 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 656442a86fb21c35d904086fc523f6571ba6746b
4
+ data.tar.gz: 5a930eb0fcf6b85c799b870f3a65b19e309e7bf4
5
+ SHA512:
6
+ metadata.gz: c74809468c2836d173b694ced62a0ecb9353514b19fabec9ac2885fbbb6678f14c6ae05cae643b153309cf477898725d34504c971212035f47e32d519ecf8759
7
+ data.tar.gz: 595ff3ada6830f96d50d89af79ceeebdca4277ef18345247a964645e1c904beaaf73d1fbfbb5d7fa4af67ce8dfbb61f152061e55dce50e0d8cc7f7c9eb6b39df
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.15.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in capistrano-honeybadger-sourcemaps.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Vitaly Perminov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Capistrano Honeybadger Sourcemaps
2
+
3
+ Uploads sourcemaps for your application as a part of the Capistrano deploy
4
+ process. See the [Honeybadger docs](https://docs.honeybadger.io/guides/source-maps.html) for more
5
+ information on source map support in Honeybadger.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'capistrano-honeybadger-sourcemaps'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ ## Usage
20
+
21
+ In your `Capfile`:
22
+
23
+ ```ruby
24
+ require 'capistrano/honeybadger/sourcemaps'
25
+ ```
26
+
27
+ The task will run after `deploy:set_current_revision` by default
28
+
29
+ ## Configurable options
30
+
31
+ ### Required
32
+
33
+ ```ruby
34
+ # For generating the minified_url that is passed to honeybadger on upload
35
+ set :honeybadger_sourcemaps_minified_url_base, 'http://www.example.com'
36
+
37
+ # Directory that will be searched for source maps to upload
38
+ set :honeybadger_sourcemaps_target_dir, './cache/my_app'
39
+ ```
40
+
41
+ ### Optional
42
+ ```ruby
43
+ # honeybadger api key. Defaults to the honeybadger_api_key used by the honeybadger gem
44
+ set :honeybadger_sourcemaps_api_key, -> { fetch :honeybadger_api_key }
45
+
46
+ # Version of the sourcemaps for honeybadger. Uses the current_revision by default
47
+ set :honeybadger_sourcemaps_version, -> { fetch :current_revision }
48
+
49
+ # Glob pattern used to search for sourcemaps in the target_dir
50
+ set :honeybadger_sourcemaps_glob_pattern, File.join('**', '*.js.map')
51
+
52
+ # Gsub pattern used to convert a sourcemap file to the associated JS file
53
+ set :honeybadger_sourcemaps_gsub_pattern, /\.map\Z/
54
+
55
+ # Role under which sourcemaps should be uploaded
56
+ set :honeybadger_sourcemaps_role, :sourcemaps
57
+ ```
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/honeybadger/sourcemaps"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "capistrano/honeybadger/sourcemaps/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-honeybadger-sourcemaps"
8
+ spec.version = Capistrano::Honeybadger::Sourcemaps::VERSION
9
+ spec.authors = ["Vitaly Perminov"]
10
+ spec.email = ["perminovx@gmail.com"]
11
+
12
+ spec.summary = %q{Capistrano task to upload source maps to Honeybadger on deploy}
13
+ spec.description = %q{Capistrano task that uploads source maps to Honeybadger on deploy}
14
+ spec.homepage = 'https://github.com/rentmania/capistrano-honeybadger-sourcemaps'
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "capistrano", "~> 3.1"
25
+ spec.add_dependency "multipart-post", "~> 2.0"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.15"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ end
@@ -0,0 +1,19 @@
1
+ require "capistrano/honeybadger/sourcemaps/version"
2
+
3
+ module Capistrano
4
+ module Honeybadger
5
+ module Sourcemaps
6
+ load File.expand_path('../../tasks/sourcemaps.rake', __FILE__)
7
+
8
+ namespace :deploy do
9
+ after :set_current_revision, 'honeybadger:sourcemaps:upload'
10
+ end
11
+
12
+ namespace :load do
13
+ task :defaults do
14
+ load "capistrano/honeybadger/sourcemaps/defaults.rb"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ # For generating the minified_url that is passed to honeybadger on upload
2
+ set :honeybadger_sourcemaps_minified_url_base, -> { abort 'Please specify the minified URL for your minified javascript' }
3
+
4
+ # Directory that will be searched for source maps to upload
5
+ set :honeybadger_sourcemaps_target_dir, -> { abort 'Please specify the directory from which your javascript sourcemaps will be uploaded'}
6
+
7
+ # Role under which sourcemaps should be uploaded
8
+ set :honeybadger_sourcemaps_role, -> { :sourcemaps }
9
+
10
+ # honeybadger token. Defaults to the honeybadger_api_key used by the honeybadger gem
11
+ set :honeybadger_sourcemaps_api_key, -> { fetch :honeybadger_api_key }
12
+
13
+ # Version of the sourcemaps for honeybadger. Uses the current_revision by default
14
+ set :honeybadger_sourcemaps_version, -> { fetch :current_revision }
15
+
16
+ # Glob pattern used to search for sourcemaps in the target_dir
17
+ set :honeybadger_sourcemaps_glob_pattern, File.join('**', '*.js.map')
18
+
19
+ # Gsub pattern used to convert a sourcemap file to the associated JS file
20
+ set :honeybadger_sourcemaps_gsub_pattern, /\.map\Z/
@@ -0,0 +1,7 @@
1
+ module Capistrano
2
+ module Honeybadger
3
+ module Sourcemaps
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,54 @@
1
+ require 'net/http/post/multipart'
2
+
3
+ namespace :honeybadger do
4
+ namespace :sourcemaps do
5
+ def upload_sourcemap(s_map)
6
+ debug "Uploading sourcemap #{s_map}"
7
+
8
+ uri = URI.parse('https://api.honeybadger.io/v1/source_maps')
9
+ req = Net::HTTP::Post::Multipart.new uri.path,
10
+ 'api_key' => fetch(:honeybadger_sourcemaps_api_key),
11
+ 'minified_url' => minified_url_for(js_filename(s_map)),
12
+ 'minified_file' => UploadIO.new(File.new(js_filename(s_map)), "application/octet-stream")
13
+ 'source_map' => UploadIO.new(File.new(s_map), "application/octet-stream")
14
+ 'revision' => fetch(:rollbar_sourcemaps_version),
15
+
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ http.use_ssl = true
18
+
19
+ res = http.request(req)
20
+
21
+ begin
22
+ res.value
23
+ rescue
24
+ info "Failed to upload sourcemap for #{s_map}. Error was #{res.code}: #{res.msg}"
25
+ end
26
+ end
27
+
28
+ def js_filename(s_map)
29
+ gsub_pattern = fetch(:rollbar_sourcemaps_gsub_pattern)
30
+ s_map.gsub(gsub_pattern, ''))
31
+ end
32
+
33
+ def minified_url_for(s_map)
34
+ url_base = fetch(:rollbar_sourcemaps_minified_url_base).dup
35
+ url_base = url_base.prepend('http://') unless url_base.index(/https?:\/\//)
36
+
37
+ url = File.join(url_base, js_filename(s_map))
38
+ debug "Minified url for #{s_map}: #{url}"
39
+ url
40
+ end
41
+
42
+ desc 'Upload sourcemaps to Rollbar'
43
+ task :upload do
44
+ on roles fetch(:rollbar_sourcemaps_role) do
45
+ debug "Uploading source maps from #{fetch(:rollbar_sourcemaps_target_dir)}"
46
+ Dir.chdir fetch(:rollbar_sourcemaps_target_dir) do
47
+ Dir.glob(fetch(:rollbar_sourcemaps_glob_pattern)).each do |s_map|
48
+ upload_sourcemap(s_map)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-honeybadger-sourcemaps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vitaly Perminov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-25 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
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multipart-post
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: Capistrano task that uploads source maps to Honeybadger on deploy
84
+ email:
85
+ - perminovx@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - capistrano-honeybadger-sourcemaps.gemspec
100
+ - lib/capistrano-honeybadger-sourcemaps.rb
101
+ - lib/capistrano/honeybadger/sourcemaps.rb
102
+ - lib/capistrano/honeybadger/sourcemaps/defaults.rb
103
+ - lib/capistrano/honeybadger/sourcemaps/version.rb
104
+ - lib/capistrano/tasks/sourcemaps.rake
105
+ homepage: https://github.com/rentmania/capistrano-honeybadger-sourcemaps
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Capistrano task to upload source maps to Honeybadger on deploy
129
+ test_files: []