salesforce-deploy-tool 0.7.3 → 0.8.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9312bcf7bdcde9cf1de413cf832eea3b994bb528
4
- data.tar.gz: 37aa56ed035fb246e3746805b0155c2fecea5401
3
+ metadata.gz: d679e29b245a57fd3d2b37e4457df5a6336122aa
4
+ data.tar.gz: 6eb175a4de7cf17a15e5bb4cdb45a47d77f158de
5
5
  SHA512:
6
- metadata.gz: 9a967b03aa7e93240372f8251212b264336d3082015df4aa1ecd0c14dd6fb5760ce6072ee0dc696dafbb84d6cd1011e64ce73182d7671039bc4f432a654ea9bf
7
- data.tar.gz: 4129b5575a9ddbc19863712777b98c5c69f34069a4c5329a83cc5bee5359ac208d7af38b8b67ce4738c5a4dfe393d9d34701c361c02f8cd9ea0b043eb7850b7f
6
+ metadata.gz: 00b450d8069c69f3cf53d9c962dc062cafe64006fb0780f4e81aa0299fcd63c6d247c63a9b36a19d34541fc543ab5ffd086ff2d5df91ec2d41e34040f7159759
7
+ data.tar.gz: c53191a04faad0833c4adb2b45595d9b170f3e4db7fa45beb6fea83f4586c95b83d0c415b4cb5bc3b51bac77cb9ef11099d44ede8ff1ca42ba1c3c98bc0743e7
data/bin/sf CHANGED
@@ -40,8 +40,10 @@ command :init do |c|
40
40
  c.option "--sandbox NAME", "-s NAME", "use 'prod' to deploy production or sandbox name"
41
41
  c.action do |args, options|
42
42
 
43
- # Parameter validation:
43
+ # short flag mapping
44
44
  options.sandbox = options.s if options.s
45
+
46
+ # Parameter validation:
45
47
  if options.sandbox.nil? and sandbox.nil?
46
48
  puts "error: please specify sandbox using --sandbox or sf sandbox"
47
49
  exit 1
@@ -67,9 +69,12 @@ command :pull do |c|
67
69
  c.option "--sandbox NAME", "-s NAME", "use 'prod' to deploy production or sandbox name"
68
70
  c.action do |args, options|
69
71
 
72
+ # short flag mapping
73
+ options.sandbox = options.s if options.s
74
+
70
75
  # Parameter validation:
71
76
  if options.sandbox.nil? and sandbox.nil?
72
- puts "error: please specify the sandbox to pull from using --sandbox"
77
+ puts "error: please specify sandbox using --sandbox or sf sandbox"
73
78
  exit 1
74
79
  end
75
80
  config[:sandbox] = options.sandbox || sandbox
@@ -98,9 +103,10 @@ command :push do |c|
98
103
  c.option "--test", "-T", "Deploy and test"
99
104
  c.option "--exclude LIST", "-x LIST", "a CSV list of metadata to exclude when creating destructiveChange.xml"
100
105
  c.option "--append", "Disable destructive change and do an append deploy"
106
+ c.option "--build_number NUMBER","Record build number on version file"
101
107
  c.action do |args, options|
102
108
 
103
- # short flag for test, so that not conflicts with trace
109
+ # short flag mapping
104
110
  options.test = true if options.T
105
111
  options.exclude = options.x if options.x
106
112
  options.sandbox = options.s if options.s
@@ -144,6 +150,7 @@ command :push do |c|
144
150
  end
145
151
 
146
152
  # Finally push:
153
+ sfdt.build_number = options.build_number if not options.build_number.nil?
147
154
  sfdt.push
148
155
 
149
156
  end
@@ -2,23 +2,55 @@ module SalesforceDeployTool
2
2
 
3
3
  class App
4
4
 
5
- def initialize config
5
+ attr_accessor :build_number
6
6
 
7
- @git_repo = config[:git_repo]
8
- @git_dir = config[:git_dir]
9
- @sandbox = config[:sandbox]
10
- @username = @sandbox == 'prod' ? config[:username] : config[:username] + '.' + @sandbox
11
- @password = config[:password]
7
+ def initialize config
8
+
12
9
  @debug = config[:debug]
13
10
  @test = config[:test]
14
- @deploy_ignore_files = config[:deploy_ignore_files]
15
11
 
12
+ @build_number = 'N/A'
13
+ ( @git_repo = config[:git_repo] ).nil? and raise "Invalid Config: git_repo not found"
14
+ ( @git_dir = config[:git_dir] ).nil? and raise "Invalid Config: git_dir not found"
15
+ ( @sandbox = config[:sandbox] ).nil? and raise "Invalid Config: sandbox not found"
16
+ ( @password = config[:password] ).nil? and raise "Invalid Config: password not found, please run `sf config`"
17
+ ( @deploy_ignore_files = config[:deploy_ignore_files] ).nil? and raise "Invalid Config: deploy_ignore_files not found"
18
+ ( @build_number_pattern = config[:build_number_pattern] ).nil? and raise "Invalid Config: build_number_pattern not found"
19
+ ( @commit_hash_pattern = config[:commit_hash_pattern] ).nil? and raise "Invalid Config: commit_hash_pattern not found"
20
+
21
+ config[:version_file].nil? and raise "Invalid Config: version_file not found"
22
+ config[:username].nil? and raise "Invalid Config: username not found, please run `sf config`"
23
+
24
+ @version_file = File.join(@git_dir,config[:version_file])
25
+ @username = @sandbox == 'prod' ? config[:username] : config[:username] + '.' + @sandbox
16
26
  @server_url = @sandbox == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com'
17
27
 
18
28
  self.clone if ! Dir.exists? File.join(@git_dir,'.git')
19
29
 
20
30
  end
21
31
 
32
+ def commit_hash
33
+
34
+ g = Git.open(@git_dir)
35
+
36
+ File.open(@version_file,'r+') do |file|
37
+ content = file.read
38
+ content.gsub!(/#{@build_number_pattern}/,@build_number)
39
+ content.gsub!(/#{@commit_hash_pattern}/,g.log.last.sha)
40
+ file.seek(0,IO::SEEK_SET)
41
+ file.truncate 0
42
+ file.write content
43
+ end if File.exists? @version_file
44
+
45
+ end
46
+
47
+ def clean_version
48
+
49
+ g = Git.open(@git_dir)
50
+ g.checkout @version_file
51
+
52
+ end
53
+
22
54
  def clone
23
55
 
24
56
  if Dir.exists? File.join(@git_dir,'.git')
@@ -74,12 +106,20 @@ module SalesforceDeployTool
74
106
 
75
107
  exit_code = myexec full_cmd, exec_options
76
108
 
109
+ clean_version
110
+
77
111
  exit exit_code if exit_code != 0
78
112
 
79
113
  end
80
114
 
81
115
  def push
82
116
 
117
+ # Working dir
118
+ Dir.chdir @git_dir
119
+
120
+ # Add the commit hash to the version file
121
+ commit_hash
122
+
83
123
  # Set env variables to run ant
84
124
  env_vars = ""
85
125
  env_vars += " SF_USERNAME=" + @username
@@ -107,15 +147,18 @@ module SalesforceDeployTool
107
147
  cmd = @test ? " ant deployAndTestCode" : " ant deployCode"
108
148
  full_cmd = env_vars + cmd
109
149
 
110
- Dir.chdir @git_dir
111
-
112
150
  # Delete files to be ignored:
113
151
  @deploy_ignore_files.each do |file|
114
152
  FileUtils.rm file if File.exists? file
115
153
  end
116
154
 
155
+ # Push the code
117
156
  exit_code = myexec full_cmd, exec_options
118
157
 
158
+ # Clean changes on version file
159
+ clean_version
160
+
161
+ # exit with exit_code
119
162
  exit exit_code if exit_code != 0
120
163
 
121
164
  end
@@ -1,3 +1,3 @@
1
1
  module SalesforceDeployTool
2
- VERSION = "0.7.3"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforce-deploy-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Breinlinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler