ghpages_deploy 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile +0 -6
- data/Rakefile +1 -10
- data/ghpages_deploy.gemspec +2 -0
- data/lib/ghpages_deploy/deployer.rb +6 -23
- data/lib/ghpages_deploy/git_manager.rb +15 -10
- data/lib/ghpages_deploy/rake/json.rb +33 -49
- data/lib/ghpages_deploy/rake/task.rb +6 -11
- data/lib/ghpages_deploy/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74af19bd981f4e4bd25b8892fac9aa98b8dd6615
|
4
|
+
data.tar.gz: 5780df2c62671a09c6b2038a6199a3f3e6bc53dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1f2b3445e81f42aa5cc050544a5178bec9213c98fe96a4e6d30efb0e48ef19c636c88cbefa1f8987a0ce3efb636b355d5bd91c8e2d038c219c5a9a536f9719
|
7
|
+
data.tar.gz: e6b1c0a838548c8c9215d4545d4523c5c067d5b9993f42e2610ddb285778f645a54e6119a3329716ec0bd5b3d26adbb967bb3b0bf06db1d898f3bc5fae0fa29f
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
# Copyright (c) 2016 Nathan Currier
|
3
3
|
|
4
|
-
require 'rubygems'
|
5
4
|
require 'bundler'
|
6
5
|
|
7
6
|
Bundler.setup(:default, :development)
|
8
7
|
|
9
|
-
require '
|
10
|
-
|
11
|
-
require 'rubocop/rake_task'
|
12
|
-
RuboCop::RakeTask.new(:rubocop) do |t|
|
13
|
-
t.fail_on_error = false
|
14
|
-
end
|
15
|
-
task('rubocop:auto_correct').clear
|
16
|
-
|
17
|
-
task default: %i(rubocop)
|
8
|
+
require 'rideliner/tasks'
|
data/ghpages_deploy.gemspec
CHANGED
@@ -6,22 +6,24 @@ require 'ghpages_deploy/git_manager'
|
|
6
6
|
|
7
7
|
module GithubPages
|
8
8
|
class Deployer
|
9
|
-
def initialize(git, source,
|
9
|
+
def initialize(git, source, destination, message, handler)
|
10
10
|
@git = git
|
11
11
|
@source = source
|
12
|
-
@
|
12
|
+
@destination = destination
|
13
13
|
@handler = handler
|
14
|
+
@message = message || "Deployed to '#{@destination}'."
|
14
15
|
end
|
15
16
|
|
16
17
|
def deploy
|
17
|
-
|
18
|
+
deploy_site_to(@destination)
|
18
19
|
|
19
20
|
@git.stage @handler.on_deploy.flatten.uniq if @handler
|
20
21
|
|
21
22
|
if @git.staged_modifications('.').empty?
|
22
23
|
$stderr.puts 'No changes detected, not commiting.'
|
23
24
|
else
|
24
|
-
@git.commit_and_push message
|
25
|
+
@git.commit_and_push @message
|
26
|
+
$stdout.puts "Commit made with message: #{@message}"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -54,9 +56,6 @@ module GithubPages
|
|
54
56
|
FileUtils.cp_r("#{@source}/.", dest)
|
55
57
|
|
56
58
|
stage_destination_files(dest)
|
57
|
-
|
58
|
-
# check if any changes were made to the destination
|
59
|
-
!@git.staged_modifications(dest).empty?
|
60
59
|
end
|
61
60
|
|
62
61
|
def stage_destination_files(dest)
|
@@ -70,21 +69,5 @@ module GithubPages
|
|
70
69
|
|
71
70
|
@git.stage files
|
72
71
|
end
|
73
|
-
|
74
|
-
def message
|
75
|
-
return 'Handler updates' if @destinations.empty?
|
76
|
-
|
77
|
-
# English join
|
78
|
-
msg =
|
79
|
-
if @destinations.length == 1
|
80
|
-
@destinations.first
|
81
|
-
elsif @destinations.length == 2
|
82
|
-
@destinations.join ' and '
|
83
|
-
else
|
84
|
-
@destinations[0..-2].join(', ') + ", and #{@destinations.last}"
|
85
|
-
end
|
86
|
-
|
87
|
-
"Deployed to #{msg}."
|
88
|
-
end
|
89
72
|
end
|
90
73
|
end
|
@@ -6,22 +6,25 @@ require 'logger'
|
|
6
6
|
|
7
7
|
module GithubPages
|
8
8
|
class GitManager
|
9
|
-
def initialize(remote, preserved_dir)
|
9
|
+
def initialize(remote, preserved_dir, repo = nil, branch = nil)
|
10
10
|
@preserved = preserved_dir
|
11
11
|
@remote = remote
|
12
|
-
@repo = `git config remote.#{remote}.url`.gsub(/^git:/, 'https:')
|
13
|
-
@branch =
|
14
|
-
if @repo =~ /\.github\.(?:com|io)\.git$/
|
15
|
-
'master'
|
16
|
-
else
|
17
|
-
'gh-pages'
|
18
|
-
end
|
12
|
+
@repo = repo || `git config remote.#{remote}.url`.gsub(/^git:/, 'https:')
|
13
|
+
@branch = branch || default_branch
|
19
14
|
|
20
15
|
@git = Git.open(Dir.pwd)
|
21
16
|
|
22
17
|
setup
|
23
18
|
end
|
24
19
|
|
20
|
+
def default_branch
|
21
|
+
if @repo =~ /\.github\.(?:com|io)\.git$/
|
22
|
+
'master'
|
23
|
+
else
|
24
|
+
'gh-pages'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
25
28
|
def self.open(*args, &block)
|
26
29
|
git = new(*args, &block)
|
27
30
|
yield git
|
@@ -76,8 +79,10 @@ module GithubPages
|
|
76
79
|
|
77
80
|
def setup_repo
|
78
81
|
@git.add_remote(remote, repo) unless @git.remote(remote)
|
79
|
-
@git.config(
|
80
|
-
|
82
|
+
@git.config(
|
83
|
+
"remote.#{remote}.fetch",
|
84
|
+
"+refs/heads/*:refs/remotes/#{remote}/*"
|
85
|
+
)
|
81
86
|
@git.remote(remote).fetch
|
82
87
|
end
|
83
88
|
|
@@ -2,69 +2,53 @@
|
|
2
2
|
# Copyright (c) 2016 Nathan Currier
|
3
3
|
|
4
4
|
require 'json'
|
5
|
+
require 'set'
|
5
6
|
|
6
7
|
require 'ghpages_deploy/rake/task'
|
7
8
|
|
8
9
|
module GithubPages
|
9
10
|
module JsonRakeExt
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# v1.0.0/
|
15
|
-
# _index.html
|
16
|
-
# ...
|
17
|
-
# v1.1.0/
|
18
|
-
# index.html
|
19
|
-
# _index.html
|
20
|
-
# ...
|
21
|
-
# ...
|
22
|
-
# branch/
|
23
|
-
# master/
|
24
|
-
# index.html
|
25
|
-
# ...
|
26
|
-
# ...
|
27
|
-
#
|
28
|
-
|
29
|
-
# if update_sitemap is being called, excluded directories should be relative to './'
|
11
|
+
class << self
|
12
|
+
def directory_sitemap(files)
|
13
|
+
directory_mash.tap { |root| files.each { |path| map_file(root, path) } }
|
14
|
+
end
|
30
15
|
|
31
|
-
|
32
|
-
|
16
|
+
def map_file(marker, path)
|
17
|
+
*dirs, file = path.split('/')
|
18
|
+
dirs.each { |dir| marker = marker[:dirs][dir] }
|
19
|
+
marker[:files] << file
|
20
|
+
end
|
33
21
|
|
34
|
-
|
35
|
-
|
22
|
+
def sanitize_list(list)
|
23
|
+
list.each_with_object(Set.new) { |glob, set| set.merge(Dir[glob]) }
|
36
24
|
end
|
37
|
-
end
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
next [] unless Dir.exist?(file_dir)
|
26
|
+
def expand_lists(directory, whitelist, blacklist)
|
27
|
+
Dir.chdir(directory) do
|
28
|
+
lists = [whitelist, blacklist].map { |list| sanitize_list(list) }
|
29
|
+
lists.reduce(&:-).select { |f| File.file?(f) }
|
30
|
+
end
|
31
|
+
end
|
46
32
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
33
|
+
def directory_mash
|
34
|
+
Hash[dirs: mash, files: []]
|
35
|
+
end
|
51
36
|
|
52
|
-
|
37
|
+
def mash
|
38
|
+
Hash.new { |h, k| h[k] = directory_mash }
|
39
|
+
end
|
40
|
+
end
|
53
41
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
42
|
+
def generate_json_map(
|
43
|
+
directory: '.', output: 'sitemap.json',
|
44
|
+
whitelist: ['**/*'], blacklist: []
|
45
|
+
)
|
46
|
+
files = self.class.expand_lists(directory, whitelist, blacklist)
|
47
|
+
map = self.class.directory_sitemap(files)
|
58
48
|
|
59
|
-
|
60
|
-
[File.basename(dir), Hash[*mapping]]
|
61
|
-
end
|
49
|
+
File.open(output, 'w+') { |f| f.puts map.to_json }
|
62
50
|
|
63
|
-
|
64
|
-
handler.handle_deploy do
|
65
|
-
JsonRakeExt.update_sitemap(excluded)
|
66
|
-
['sitemap.json']
|
67
|
-
end
|
51
|
+
[output]
|
68
52
|
end
|
69
53
|
end
|
70
54
|
|
@@ -12,35 +12,30 @@ module GithubPages
|
|
12
12
|
class DeployTask < ::Rake::TaskLib
|
13
13
|
def initialize(*args)
|
14
14
|
@args = args
|
15
|
-
@destinations = []
|
16
15
|
@handler = GithubPages::Handler.new
|
17
16
|
|
18
17
|
yield self if block_given?
|
19
18
|
|
20
19
|
@source &&= @source.gsub(%r{^#{Dir.pwd}[\/]?}, '')
|
21
20
|
|
21
|
+
@destination ||= '.'
|
22
22
|
@source ||= '.'
|
23
23
|
@remote ||= 'origin'
|
24
24
|
|
25
|
-
@destinations << '.' if @destinations.empty?
|
26
|
-
|
27
25
|
define
|
28
26
|
end
|
29
27
|
|
30
|
-
attr_accessor :remote, :source
|
28
|
+
attr_accessor :remote, :source, :destination
|
29
|
+
attr_accessor :repo, :branch
|
30
|
+
attr_accessor :message
|
31
31
|
attr_reader :handler
|
32
32
|
|
33
|
-
def register(destination)
|
34
|
-
@destinations << destination
|
35
|
-
end
|
36
|
-
|
37
33
|
private
|
38
34
|
|
39
35
|
def define
|
40
36
|
task(*@args) do
|
41
|
-
GitManager.open(@remote, @source) do |git|
|
42
|
-
|
43
|
-
deployer.deploy
|
37
|
+
GitManager.open(@remote, @source, @repo, @branch) do |git|
|
38
|
+
Deployer.new(git, @source, @destination, @message, @handler).deploy
|
44
39
|
end
|
45
40
|
end
|
46
41
|
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghpages_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Currier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
prerelease: false
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
14
21
|
name: git
|
15
22
|
requirement: !ruby/object:Gem::Requirement
|
16
23
|
requirements:
|
17
24
|
- - ">="
|
18
25
|
- !ruby/object:Gem::Version
|
19
26
|
version: '0'
|
20
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
21
28
|
prerelease: false
|
22
29
|
version_requirements: !ruby/object:Gem::Requirement
|
23
30
|
requirements:
|
24
31
|
- - ">="
|
25
32
|
- !ruby/object:Gem::Version
|
26
33
|
version: '0'
|
34
|
+
type: :development
|
35
|
+
name: rideliner
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Deploy to Github Pages
|
28
42
|
email:
|
29
43
|
- nathan.currier@gmail.com
|
@@ -67,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
81
|
version: '0'
|
68
82
|
requirements: []
|
69
83
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.6.2
|
71
85
|
signing_key:
|
72
86
|
specification_version: 4
|
73
87
|
summary: Deploy your site to Github Pages
|