extensionator 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/bin/extensionator +3 -29
- data/lib/extensionator.rb +2 -71
- data/lib/extensionator/cli.rb +33 -0
- data/lib/extensionator/extensionator.rb +71 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06b7a339386fc46ebe5b5e45787bbcef57c3c6fb
|
4
|
+
data.tar.gz: f816f69988245cf245a975825861570ecc1b1d9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44041e56d42bd22c208ccec61d3ac064051f3b4d9a7f18936ae3c2f014dc034d0db56562c3d63d083df03dab2811f87f405f20c50f813cb73c0184e3e5c1b344
|
7
|
+
data.tar.gz: 1576bc72c0fca068ed179ed386286c685b9d2719ab18bd9af4a0301062b54b9c9d1d43f67834b79a306ad45bc3fc706a6dcdb22b3ce95514eeaf0dd1ec8224cc
|
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
Package Chrome extensions with Ruby. Inspired by (Loosely based on? Stolen from?) [crxmake]
|
1
|
+
Package Chrome extensions with Ruby. Inspired by (Loosely based on? Stolen from?) [crxmake][crxmake-url]. Use the CLI or the Ruby API.
|
2
|
+
|
3
|
+
[![Gem Version][gem-img]][gem-url]
|
4
|
+
[![Gem Downloads][gem-dl-img]][gem-url]
|
5
|
+
[![Code Climate][code-climate-img]][code-climate-url]
|
6
|
+
[![License][license-img]][license-url]
|
2
7
|
|
3
8
|
# Install
|
4
9
|
|
@@ -79,3 +84,15 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
79
84
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
80
85
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
81
86
|
THE SOFTWARE.
|
87
|
+
|
88
|
+
[license-img]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
|
89
|
+
[license-url]: http://opensource.org/licenses/MIT
|
90
|
+
|
91
|
+
[code-climate-img]: https://img.shields.io/codeclimate/github/Zensight/extensionator.svg?style=flat-square
|
92
|
+
[code-climate-url]: https://codeclimate.com/github/Zensight/extensionator
|
93
|
+
|
94
|
+
[gem-img]: https://img.shields.io/gem/v/extensionator.svg?style=flat-square
|
95
|
+
[gem-dl-img]: https://img.shields.io/gem/dt/extensionator.svg?style=flat-square
|
96
|
+
[gem-url]: https://rubygems.org/gems/extensionator
|
97
|
+
|
98
|
+
[crxmake-url]: https://github.com/Constellation/crxmake
|
data/bin/extensionator
CHANGED
@@ -1,35 +1,9 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
require "slop"
|
4
|
-
|
5
3
|
begin
|
6
|
-
require "extensionator"
|
7
|
-
rescue LoadError
|
8
4
|
require_relative "../lib/extensionator"
|
5
|
+
rescue LoadError
|
6
|
+
require "extensionator"
|
9
7
|
end
|
10
8
|
|
11
|
-
|
12
|
-
o.string "-d", "--directory", "Directory containing the extension. (Default: .)", default: "."
|
13
|
-
o.string "-i", "--identity", "Location of the pem file to sign with. (Required)"
|
14
|
-
o.string "-o", "--output", "Location of the output file. (Default: 'extension.crx')", default: "extension.crx"
|
15
|
-
o.string "-e", "--exclude", "Regular expression for filenames to exclude. (Default: \.crx$)", default: nil
|
16
|
-
o.on "-v", "--version", "Extensionator version info." do
|
17
|
-
puts Extensionator::VERSION
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
o.on "-h", "--help", "Print this message." do
|
21
|
-
puts o
|
22
|
-
exit
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
unless opts[:identity]
|
27
|
-
puts("No identity file specified.")
|
28
|
-
puts(opts)
|
29
|
-
exit(-1)
|
30
|
-
else
|
31
|
-
Extensionator.create(opts[:directory],
|
32
|
-
opts[:identity],
|
33
|
-
opts[:output],
|
34
|
-
exclude: opts[:exclude] ? Regexp.new(opts[:exclude]) : nil)
|
35
|
-
end
|
9
|
+
Extensionator::CLI.start
|
data/lib/extensionator.rb
CHANGED
@@ -1,71 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "openssl"
|
4
|
-
require "pathname"
|
5
|
-
require "zip"
|
6
|
-
|
7
|
-
module Extensionator
|
8
|
-
VERSION = "0.0.8"
|
9
|
-
|
10
|
-
module Impl
|
11
|
-
def self.create(dir, key_file, dest_filename, opts)
|
12
|
-
priv_key = read_key(key_file)
|
13
|
-
zip_str = zip(dir, opts)
|
14
|
-
sig_bytes = sign(zip_str, priv_key)
|
15
|
-
write(zip_str, sig_bytes, priv_key, dest_filename)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.read_key(key_file)
|
19
|
-
OpenSSL::PKey::RSA.new(File.read(key_file))
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.zip(dir, opts = {})
|
23
|
-
Zip::File.add_buffer do |zip|
|
24
|
-
Find.find(dir) do |path|
|
25
|
-
case
|
26
|
-
when path == dir
|
27
|
-
next
|
28
|
-
when (opts[:exclude] && path =~ opts[:exclude])
|
29
|
-
Find.prune
|
30
|
-
when File.directory?(path)
|
31
|
-
zip.mkdir(relative_path(dir, path))
|
32
|
-
else
|
33
|
-
zip.add(relative_path(dir, path), path)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end.string
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.sign(zip_str, priv_key)
|
40
|
-
priv_key.sign(OpenSSL::Digest::SHA1.new, zip_str)
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.write(zip_str, sig_bytes, priv_key, dest_filename)
|
44
|
-
pub_key_bytes = priv_key.public_key.to_der
|
45
|
-
|
46
|
-
#See https://developer.chrome.com/extensions/crx for the format description
|
47
|
-
File.open(dest_filename, "wb") do |file|
|
48
|
-
file << "Cr24"
|
49
|
-
file << format_size(2)
|
50
|
-
file << format_size(pub_key_bytes.size)
|
51
|
-
file << format_size(sig_bytes.size)
|
52
|
-
file << pub_key_bytes
|
53
|
-
file << sig_bytes
|
54
|
-
file << zip_str
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.relative_path(base, target)
|
59
|
-
from, to = [base, target].map(&Pathname.method(:new))
|
60
|
-
to.relative_path_from(from).to_s
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.format_size(num)
|
64
|
-
[num].pack("V")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def self.create(dir, key_file, dest_filename, opts = {exclude: /\.crx$/})
|
69
|
-
Impl.create(dir, key_file, dest_filename, opts)
|
70
|
-
end
|
71
|
-
end
|
1
|
+
require_relative "extensionator/extensionator"
|
2
|
+
require_relative "extensionator/cli"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "slop"
|
2
|
+
|
3
|
+
module Extensionator
|
4
|
+
module CLI
|
5
|
+
def self.start
|
6
|
+
opts = Slop.parse do |o|
|
7
|
+
o.string "-d", "--directory", "Directory containing the extension. (Default: .)", default: "."
|
8
|
+
o.string "-i", "--identity", "Location of the pem file to sign with. (Required)"
|
9
|
+
o.string "-o", "--output", "Location of the output file. (Default: 'extension.crx')", default: "extension.crx"
|
10
|
+
o.string "-e", "--exclude", "Regular expression for filenames to exclude. (Default: \.crx$)", default: nil
|
11
|
+
o.on "-v", "--version", "Extensionator version info." do
|
12
|
+
puts Extensionator::VERSION
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
o.on "-h", "--help", "Print this message." do
|
16
|
+
puts o
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
unless opts[:identity]
|
22
|
+
puts("No identity file specified.")
|
23
|
+
puts(opts)
|
24
|
+
exit(-1)
|
25
|
+
else
|
26
|
+
Extensionator.create(opts[:directory],
|
27
|
+
opts[:identity],
|
28
|
+
opts[:output],
|
29
|
+
exclude: opts[:exclude] ? Regexp.new(opts[:exclude]) : nil)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
require "find"
|
3
|
+
require "openssl"
|
4
|
+
require "pathname"
|
5
|
+
require "zip"
|
6
|
+
|
7
|
+
module Extensionator
|
8
|
+
VERSION = "0.0.9"
|
9
|
+
|
10
|
+
module Impl
|
11
|
+
def self.create(dir, key_file, dest_filename, opts)
|
12
|
+
priv_key = read_key(key_file)
|
13
|
+
zip_str = zip(dir, opts)
|
14
|
+
sig_bytes = sign(zip_str, priv_key)
|
15
|
+
write(zip_str, sig_bytes, priv_key, dest_filename)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.read_key(key_file)
|
19
|
+
OpenSSL::PKey::RSA.new(File.read(key_file))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.zip(dir, opts = {})
|
23
|
+
Zip::File.add_buffer do |zip|
|
24
|
+
Find.find(dir) do |path|
|
25
|
+
case
|
26
|
+
when path == dir
|
27
|
+
next
|
28
|
+
when (opts[:exclude] && path =~ opts[:exclude])
|
29
|
+
Find.prune
|
30
|
+
when File.directory?(path)
|
31
|
+
zip.mkdir(relative_path(dir, path))
|
32
|
+
else
|
33
|
+
zip.add(relative_path(dir, path), path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end.string
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.sign(zip_str, priv_key)
|
40
|
+
priv_key.sign(OpenSSL::Digest::SHA1.new, zip_str)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.write(zip_str, sig_bytes, priv_key, dest_filename)
|
44
|
+
pub_key_bytes = priv_key.public_key.to_der
|
45
|
+
|
46
|
+
#See https://developer.chrome.com/extensions/crx for the format description
|
47
|
+
File.open(dest_filename, "wb") do |file|
|
48
|
+
file << "Cr24"
|
49
|
+
file << format_size(2)
|
50
|
+
file << format_size(pub_key_bytes.size)
|
51
|
+
file << format_size(sig_bytes.size)
|
52
|
+
file << pub_key_bytes
|
53
|
+
file << sig_bytes
|
54
|
+
file << zip_str
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.relative_path(base, target)
|
59
|
+
from, to = [base, target].map(&Pathname.method(:new))
|
60
|
+
to.relative_path_from(from).to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.format_size(num)
|
64
|
+
[num].pack("V")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.create(dir, key_file, dest_filename, opts = {exclude: /\.crx$/})
|
69
|
+
Impl.create(dir, key_file, dest_filename, opts)
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extensionator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Cambron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -64,6 +64,8 @@ files:
|
|
64
64
|
- bin/extensionator
|
65
65
|
- extensionator.gemspec
|
66
66
|
- lib/extensionator.rb
|
67
|
+
- lib/extensionator/cli.rb
|
68
|
+
- lib/extensionator/extensionator.rb
|
67
69
|
homepage: http://github.com/zensight/extensionator/
|
68
70
|
licenses:
|
69
71
|
- MIT
|