onboard 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTYzNmVlZDFjMDRmZWViZGVmYzllMTM3MjAzMGZkNjU4NjYwNjc5OA==
4
+ MjlmMTg5NmViZWI0N2VmNGNhYTRkNDg5ZDM2YWFjYWU5Y2EwZWI5NA==
5
5
  data.tar.gz: !binary |-
6
- YTQwZTBhYmRlZDc2MzRlYmVlZjliY2JiMzI0ZDY3NDY5MTM1M2RmOA==
6
+ MmU4ZjRiMjllNWFhYjlhODY1ODFjNjM2YTFkNDIxNjEzM2I1NWE1ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTlhMDY5YTc4YTc2MjJmMTJlYzAzMTkwOGVmZTFlOWM0NTEwM2JiN2ViM2E5
10
- NzhkMzMwYjcyZWYwOGU4ZjRjM2IyZGFjZjFmMDkwYmZmMGVhNTc5MzJkNjg4
11
- ODllNTVlNjI5ODkyMzk2MDcxNjFiZGU3ZDdkODY1MzQ3ZGQzYzQ=
9
+ MmVlZjM4MmExZGJlMjE1YmQ4OWNmOGE3NDI5ZjM1NGE1ODA1YzQ1ZTE4MTk3
10
+ ZjIzNTFhMzMzOGFhZTMwMzgwYzU2ZWJmMGYxYzc5ZjUwYTFlMTM2MDYyOTU2
11
+ YWY5NjFiMDFhNWQ2MmM1YTZhYzY0NmViZDk2OTJkM2VkMGVmYjY=
12
12
  data.tar.gz: !binary |-
13
- YTllNDkwOTE1ZjJkZmExYzc0NGQyYWIxYWQ0MjM4MThlYTFjMGQ2MTFhZjBj
14
- Y2MwMzYwY2EwM2I5MzAyNzNlZmU0ZGZlOTRjMjc2ZWMwM2Q2NjIzM2VmNzM2
15
- NjUyNjI4MjVmZmJjMDUzZTE2NDViMmQ4YWNiM2Y5NTUwODYwOWI=
13
+ NjI0MGMwNjlkYjNjODg0MmZjNjg0ZTk5MzdjZTQ4MDk5MThkZjkwZjhmNTE3
14
+ ODIzMTQ1YmNhYzhmN2E1YzI3OWQyODM2ZmI5NGNlYWNmZGIxOTNlNjIzNWQ1
15
+ ZGFlNDgwMzg0ZDk3M2E5YTllYjgzODUwOTFjM2FmMzIzM2QzODY=
data/lib/onboard/cli.rb CHANGED
@@ -28,7 +28,7 @@ module Onboard
28
28
  option :force, :aliases => "-f", :desc => "Force add modules (even if already present)"
29
29
  option :no, :aliases => "-n", :desc => "Assume 'no' for all prompts"
30
30
  option :modules, :aliases => "-m", :type => :array, :desc => "Pass a list of modules"
31
- # option :delete, :aliases => "-d", :desc => "Delete existing projects"
31
+ option :delete, :aliases => "-d", :desc => "Delete existing projects"
32
32
  # option :source, :aliases => "-s", :desc => "Specify a project source other than drupal.org"
33
33
  option :themes, :aliases => "-t", :type => :array, :desc => "Pass a list of themes"
34
34
  option :vc, :type => :boolean, :default => true, :desc => "Enable/Disable version control handling"
@@ -50,6 +50,14 @@ module Onboard
50
50
  projects[File.basename(x)] = y[0]
51
51
  end
52
52
  puts ""
53
+ if options[:delete] == 'delete'
54
+ say("Ready to delete existing projects:", :yellow)
55
+ Confirm.new("Proceed?", true).yes?
56
+ found.each do |x, y|
57
+ Project.new.clean(x)
58
+ projects[File.basename(x)] = ''
59
+ end
60
+ end
53
61
  end
54
62
  if options[:force] != 'force'
55
63
  if found.empty? == false
@@ -4,11 +4,12 @@ require 'thor'
4
4
 
5
5
  module Onboard
6
6
  class Confirm < Thor
7
- attr_reader :message
7
+ attr_reader :message, :full_stop
8
8
 
9
9
  no_tasks do
10
- def initialize(message)
10
+ def initialize(message, full_stop = false)
11
11
  @message = message
12
+ @full_stop = full_stop
12
13
  end
13
14
 
14
15
  def yes?
@@ -18,8 +19,15 @@ module Onboard
18
19
  puts ""
19
20
  end
20
21
  if answer =~ /^[N]$/i
21
- say("Script was exited.")
22
- exit
22
+ if full_stop
23
+ say("Script was exited.")
24
+ exit
25
+ else
26
+ say("Action was aborted.")
27
+ return false
28
+ end
29
+ elsif answer =~ /^[Y]$/i
30
+ return true
23
31
  end
24
32
  end
25
33
  end
@@ -1,10 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'fileutils'
3
4
  require 'net/http'
4
5
 
5
6
  module Onboard
6
7
  class Download
7
- def initialize(cache_dir='/tmp')
8
+ attr_reader :cache_dir
9
+
10
+ def initialize(cache_dir='/tmp/onboard/cache')
8
11
  @cache_dir = cache_dir
9
12
  end
10
13
 
@@ -13,6 +16,9 @@ module Onboard
13
16
  end
14
17
 
15
18
  def fetch(url, max_age=1800)
19
+ unless File.directory?(cache_dir)
20
+ FileUtils.mkdir_p(cache_dir)
21
+ end
16
22
  file_path = self.path(url)
17
23
  if File.exists? file_path
18
24
  return File.new(file_path).read if Time.now-File.mtime(file_path)<max_age
@@ -38,32 +38,60 @@ module Onboard
38
38
 
39
39
  def hacked?(project, existing)
40
40
  self.clean("#{path}/#{project}")
41
- link = DRUPAL_DL_LINK + project + "-" + existing + ".tar.gz"
41
+ link = self.build_link(project, existing)
42
42
  Download.new.fetch(link)
43
43
  self.extract(Download.new.path(link)) if self.verify(project, link, existing)
44
- st = {}
45
- st['codebase'] = codebase
46
- changes = Repo.new(st).st
44
+ repo = self.build_vc(project)
45
+ changes = Repo.new(repo).st(true)
47
46
  if changes.empty? == false
48
- Confirm.new("Proceed?").yes?
47
+ return !Confirm.new("Proceed?").yes?
48
+ else
49
+ return false
50
+ end
51
+ end
52
+
53
+ def latest?(latest, existing, project)
54
+ if Gem::Dependency.new('', "~> #{latest}").match?('', "#{existing}")
55
+ say("#{project} is already at the latest version (#{latest}).", :yellow)
56
+ return true
57
+ else
58
+ return false
49
59
  end
50
60
  end
51
61
 
62
+ def build_link(project, version)
63
+ DRUPAL_DL_LINK + "#{project}-#{version}.tar.gz"
64
+ end
65
+
52
66
  def dl
53
67
  changes = []
54
68
  projects.each do |x, y|
55
- self.hacked?(x, y) if y.empty? == false
56
- self.clean("#{path}/#{x}")
57
- # TODO: check existing version against release version - abort if same.
58
- md5, link = self.release(x)
59
- Download.new.fetch(link)
60
- # TODO: retry download after failed download verification
61
- self.extract(Download.new.path(link)) if self.verify(x, link)
62
- if vc == true
63
- repo = self.build_vc(x)
64
- changes += self.vc_up(repo)
69
+ md5, version = self.release(x)
70
+ if y.empty? == false
71
+ if !self.hacked?(x, y) && !self.latest?(version, y, x)
72
+ proceed = true
73
+ else
74
+ proceed = false
75
+ end
76
+ else
77
+ proceed = true
78
+ end
79
+ if proceed
80
+ self.clean("#{path}/#{x}")
81
+ link = self.build_link(x, version)
82
+ Download.new.fetch(link)
83
+ # TODO: retry download after failed download verification
84
+ self.extract(Download.new.path(link)) if self.verify(x, link)
85
+ if vc == true
86
+ repo = self.build_vc(x)
87
+ changes += self.vc_up(repo)
88
+ else
89
+ say("#{x} added to codebase but changes are not yet under version control.", :yellow)
90
+ end
65
91
  else
66
- say("#{x} added to codebase but changes are not yet under version control.", :yellow)
92
+ self.clean("#{path}/#{x}")
93
+ repo = self.build_vc(x)
94
+ Repo.new(repo).co
67
95
  end
68
96
  end
69
97
  if changes.empty? == false
@@ -81,6 +109,10 @@ module Onboard
81
109
  return repo
82
110
  end
83
111
 
112
+ def vc_co(args)
113
+ Repo.new(args).co
114
+ end
115
+
84
116
  def vc_up(args)
85
117
  g = Repo.new(args)
86
118
  info = g.info
@@ -106,11 +138,11 @@ module Onboard
106
138
  end
107
139
 
108
140
  def verify(x, file, version='')
109
- md5, link = self.release(x, version)
141
+ md5, version = self.release(x, version)
110
142
  if md5 == Digest::MD5.file(Download.new.path(file)).hexdigest
111
143
  return true
112
144
  else
113
- say("Verification failed for #{project} download!", :red)
145
+ say("Verification failed for #{x} download!", :red)
114
146
  exit
115
147
  end
116
148
  end
@@ -124,19 +156,19 @@ module Onboard
124
156
  if version.empty? == false
125
157
  doc.xpath('//releases//release').each do |item|
126
158
  if item.at_xpath('version').content == version
127
- releases[item.at_xpath('mdhash').content] = item.at_xpath('download_link').content
159
+ releases[item.at_xpath('mdhash').content] = item.at_xpath('version').content
128
160
  end
129
161
  end
130
162
  else
131
163
  doc.xpath('//releases//release').each do |item|
132
164
  if !item.at_xpath('version_extra')
133
- releases[item.at_xpath('mdhash').content] = item.at_xpath('download_link').content
165
+ releases[item.at_xpath('mdhash').content] = item.at_xpath('version').content
134
166
  end
135
167
  end
136
168
  end
137
169
  if releases.nil?
138
170
  doc.xpath('//releases//release').each do |item|
139
- releases[item.at_xpath('mdhash').content] = item.at_xpath('download_link').content
171
+ releases[item.at_xpath('mdhash').content] = item.at_xpath('version').content
140
172
  end
141
173
  end
142
174
  return releases.first
data/lib/onboard/repo.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'fileutils'
3
4
  require 'git'
4
5
  require 'pathname'
5
6
  require 'thor'
6
7
 
7
8
  module Onboard
8
9
  class Repo < Thor
9
- attr_reader :g, :path, :branch, :codebase, :projects
10
+ attr_reader :g, :path, :branch, :codebase, :project
10
11
 
11
12
  no_tasks do
12
13
  def initialize(repo)
@@ -14,14 +15,22 @@ module Onboard
14
15
  @g = self.prepare(repo)
15
16
  @path = repo['path']
16
17
  @branch = repo['branch']
17
- @projects = repo['projects']
18
+ @project = repo['project']
18
19
  end
19
20
 
20
- def st
21
+ def st(patch = false)
21
22
  changed = []
22
23
  deleted = []
23
24
  untracked = []
24
25
 
26
+ if patch
27
+ patches_dir = "/tmp/onboard/patches"
28
+ unless File.directory?(patches_dir)
29
+ FileUtils.mkdir_p(patches_dir)
30
+ end
31
+ patch_file = File.open( "#{patches_dir}/#{Time.now.to_i}_#{project}.patch","w" )
32
+ end
33
+
25
34
  # TODO: figure out why g.status.changed.keys.each is returning
26
35
  # unchanged files
27
36
  g.status.changed.keys.each { |file| changed.push(file.to_s) if !g.diff('HEAD', file).patch.empty? }
@@ -31,25 +40,53 @@ module Onboard
31
40
 
32
41
  if changed.empty? == false
33
42
  say('CHANGED FILES:', :yellow)
34
- changed.each { |z| puts g.diff('HEAD', z).patch }
43
+ changed.each do |x|
44
+ puts g.diff('HEAD', x).patch
45
+ if patch
46
+ patch_file << g.diff('HEAD', x).patch
47
+ end
48
+ end
35
49
  puts ''
36
50
  end
37
51
 
38
52
  if deleted.empty? == false
39
53
  say('DELETED FILES:', :yellow)
40
- deleted.each { |x| say(x, :red) }
54
+ deleted.each do |x|
55
+ say(x, :red)
56
+ if patch
57
+ patch_file << g.diff('--', x).patch
58
+ end
59
+ end
41
60
  puts ''
42
61
  end
43
62
 
44
63
  if untracked.empty? == false
45
64
  say('UNTRACKED FILES:', :yellow)
46
- untracked.each { |y| say(y, :red) }
65
+ untracked.each do |x|
66
+ say(x, :red)
67
+ if patch
68
+ g.add(x)
69
+ patch_file << g.diff('HEAD', x).patch
70
+ end
71
+ end
47
72
  puts ''
48
73
  end
49
74
 
75
+ if patch
76
+ patch_file.close
77
+ Dir.foreach(patches_dir) do |item|
78
+ file = "#{patches_dir}/#{item}"
79
+ FileUtils.rm_r file if File.zero?(file)
80
+ end
81
+ end
82
+
50
83
  return all
51
84
  end
52
85
 
86
+ def co
87
+ g.checkout_file('HEAD', path)
88
+ end
89
+
53
90
  def info
54
91
  repo = {}
55
92
  repo['current_branch'] = g.current_branch
@@ -70,7 +107,7 @@ module Onboard
70
107
  g.status.untracked.keys.each { |x| changes.push x }
71
108
 
72
109
  if changes.empty? == false
73
- g.add(path, :all=>true)
110
+ g.add(codebase, :all=>true)
74
111
  g.commit("Add #{project}")
75
112
  end
76
113
 
@@ -1,3 +1,3 @@
1
1
  module Onboard
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathaniel Hoag
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri