salesforce-deploy-tool 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba29983f91588b0c40f5822c403c81b303d68b06
4
- data.tar.gz: 83dcecf2534b368e47fecd87ecd2621963fe044e
3
+ metadata.gz: cbe3021d67e55804a0f2815e685d08c2ba4cc6e4
4
+ data.tar.gz: 9d80f486d15a382c4956992ec4c86cce4085133f
5
5
  SHA512:
6
- metadata.gz: 7a7af88b26b18ff95d8ef3e426aefd8a5945364bc00a33d8f378ba906a15ddd20060b8e9bd409e7d16332d1c1e9ab831ffa0f5d3887cbb44c799d96f214b6272
7
- data.tar.gz: 75045aad5e03022740490c82c2317cb31715072fd7eb7ed216e98c28013080cc7e86683fe50aba9eae53f87e6c65b4816b88a55490c8d04cd8e2190814a1e018
6
+ metadata.gz: 608e4a229fcdb828cc15c8b16320a85b3c0f1fc4202f3c2961863cb09a8a9859311b77c90f5a90d181d270957dfbe06c3a2cdc4fe89e259a7beed93f26565777
7
+ data.tar.gz: 81ac889d4979f9e81eddb4216770b65d0921e40a6225f41def605bd28e264b79ce74278521fb3f4c89849efd81dd2dd5c4d7471a0a80184e1e6b9b3f27036830
data/bin/sf CHANGED
@@ -27,6 +27,13 @@ config = {}
27
27
  end
28
28
  end
29
29
 
30
+ # Read sandbox environment
31
+ begin
32
+ sandbox = File.open(File.expand_path(SANDBOX_CONFIG_FILE)).read
33
+ rescue
34
+ sandbox = nil
35
+ end
36
+
30
37
  # Grab variables from env if not in the config files
31
38
  config[:git_dir] = ENV["SFDT_GIT_DIR"] || config[:git_dir]
32
39
  config[:tmp_dir] = ENV["SFDT_TMP_DIR"] || config[:tmp_dir]
@@ -36,11 +43,9 @@ config[:commit_hash_pattern] = ENV["SFDT_COMMIT_HASH_PATTERN"] || config[:
36
43
  config[:git_repo] = ENV["SFDT_GIT_REPO"] || config[:git_repo]
37
44
  config[:username] = ENV["SFDT_USERNAME"] || config[:username]
38
45
  config[:password] = ENV["SFDT_PASSWORD"] || config[:password]
46
+ config[:salesforce_url] = ENV["SFDT_SALESFORCE_URL"] || config[:salesforce_url]
39
47
  config[:deploy_ignore_files] = ENV["SFDT_DEPLOY_IGNORE_FILES"].nil? ? config[:deploy_ignore_files] : ENV["SFDT_DEPLOY_IGNORE_FILES"].split(',')
40
48
 
41
- # The salesforce URL, first from environment varialbes, second from config file , thierd defaults:
42
- config[:salesforce_url] = ENV["SFDT_SALESFORCE_URL"] || config[:salesforce_url] ||( @sandbox == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com' )
43
-
44
49
  # Default values
45
50
  config[:buildxml_dir] = ENV["SFDT_BUILDXML_DIR"] || config[:buildxml_dir] || ''
46
51
 
@@ -51,7 +56,7 @@ abort "Config error: username not found in #{GLOBAL_CONFIG_FILE} or through SFDT
51
56
  abort "Config error: password not found in #{GLOBAL_CONFIG_FILE} or through SFDT_PASSWORD" if config[:password].nil? && ARGV[0] != 'config'
52
57
 
53
58
  # If the repository is not cloned then fail:
54
- if !File.exists?(config[:git_dir]) && ARGV[0] != 'config'
59
+ if !File.exists?(config[:git_dir]) && ['pull','push'].include?(ARGV[0])
55
60
  abort "ERROR: The environment is not properly configured, please run sf config to clone the repo and setup the credentials"
56
61
  end
57
62
 
@@ -59,13 +64,6 @@ end
59
64
  config[:git_dir] = File.expand_path config[:git_dir]
60
65
  config[:tmp_dir] = File.expand_path config[:tmp_dir]
61
66
 
62
- # Read sandbox environment
63
- begin
64
- sandbox = File.open(File.expand_path(SANDBOX_CONFIG_FILE)).read
65
- rescue
66
- sandbox = nil
67
- end
68
-
69
67
  require 'salesforcedeploytool'
70
68
 
71
69
  program :version, SalesforceDeployTool::VERSION
@@ -92,6 +90,12 @@ command :pull do |c|
92
90
  config[:sandbox] = options.sandbox || sandbox
93
91
  config[:debug] = options.debug.nil? ? false : true
94
92
 
93
+ # The salesforce URL
94
+ config[:salesforce_url] =
95
+ ENV["SFDT_SALESFORCE_URL"] || # First from environment variables
96
+ config[:salesforce_url] || # Second from the configuration files
97
+ ( config[:sandbox] == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com' ) # If not defined anywhere, use defaults
98
+
95
99
  # Initialize
96
100
  sfdt = SalesforceDeployTool::App.new config
97
101
 
@@ -99,7 +103,9 @@ command :pull do |c|
99
103
  sfdt.clean_git_dir unless options.append
100
104
 
101
105
  # Pull the changes
102
- sfdt.pull "INFO: Pulling changes from #{config[:sandbox]} "
106
+ print "INFO: Pulling changes from #{config[:sandbox]} using url #{config[:salesforce_url]} "
107
+ print "\n\n" if options.debug
108
+ sfdt.pull
103
109
  sfdt.clean_version
104
110
 
105
111
  end
@@ -133,6 +139,12 @@ command :push do |c|
133
139
  config[:test] = options.test.nil? ? false : true
134
140
  config[:debug] = options.debug.nil? ? false : true
135
141
 
142
+ # The salesforce URL
143
+ config[:salesforce_url] =
144
+ ENV["SFDT_SALESFORCE_URL"] || # First from environment variables
145
+ config[:salesforce_url] || # Second from the configuration files
146
+ ( config[:sandbox] == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com' ) # If not defined anywhere, use defaults
147
+
136
148
  # Initialize
137
149
  sfdt = SalesforceDeployTool::App.new config.clone
138
150
 
@@ -147,7 +159,8 @@ command :push do |c|
147
159
  FileUtils.rm_rf config_tmp[:git_dir] if File.exists? config_tmp[:git_dir]
148
160
  FileUtils.cp_r config[:git_dir],config_tmp[:git_dir]
149
161
  sfdt_tmp = SalesforceDeployTool::App.new config_tmp
150
- sfdt_tmp.pull "INFO: Pulling changes from #{config[:sandbox]} to temporary directory #{config[:tmp_dir]} to generate destructiveChanges.xml "
162
+ print "INFO: Pulling changes from #{config[:sandbox]} using url #{config[:salesforce_url]} to temporary directory #{config[:tmp_dir]} to generate destructiveChanges.xml "
163
+ sfdt_tmp.pull
151
164
 
152
165
  # Create destructiveChanges.xml
153
166
  puts "INFO: Creating destructive changes xml"
@@ -171,6 +184,7 @@ command :push do |c|
171
184
  sfdt.test = options.test.nil? ? false : true
172
185
 
173
186
  # Push
187
+ print(options.test.nil? ? "INFO: Deploying code to #{config[:sandbox]}: ": "INFO: Deploying and Testing code to #{config[:sandbox]}: \n\n")
174
188
  sfdt.push
175
189
  ensure
176
190
  sfdt.clean_version
@@ -0,0 +1,11 @@
1
+ @misc
2
+ Feature: Misc features related to sf
3
+
4
+ In order to use sf
5
+ As a user using
6
+ I want to be able to run sf misc functionality
7
+
8
+ Scenario: I should be able to see the version of sf
9
+ When I run `sf -v` interactively
10
+ Then the exit status should be 0
11
+ And the output should match /sf \d+\.\d+.\d+/
@@ -3,26 +3,57 @@ Feature: Pull code from salesforce
3
3
 
4
4
  As a developer
5
5
  I want to be able to retrieve code from a sandbox
6
-
6
+
7
7
  Scenario: Retrieve code from the default sandbox
8
8
  When I run `sf pull`
9
9
  Then the exit status should be 0
10
- And the output should match /INFO: Pulling changes from env_a.*OK/
10
+ And the output should match:
11
+ """
12
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com.*OK
13
+ """
11
14
 
12
15
  Scenario: Retrieve code from a specific sandbox
13
16
  When I run `sf pull -s env_b`
14
17
  Then the exit status should be 0
15
- And the output should match /INFO: Pulling changes from env_b.*OK/
18
+ And the output should match:
19
+ """
20
+ ^INFO: Pulling changes from env_b using url https://test.salesforce.com.*OK
21
+ """
22
+
23
+ Scenario: Retrieve code from a sandbox using a specific URL
24
+ Given I set the environment variables to:
25
+ | variable | value |
26
+ | SFDT_SALESFORCE_URL | https://invalid_url.salesforce.com |
27
+ When I run `sf pull`
28
+ Then the exit status should be 1
29
+ And the output should match:
30
+ """
31
+ ^INFO: Pulling changes from env_a using url https://invalid_url.*
32
+ """
33
+
34
+ Scenario: Retrieve code from a production
35
+ When I run `sf pull -s prod`
36
+ Then the exit status should be 0
37
+ And the output should match:
38
+ """
39
+ ^INFO: Pulling changes from prod using url https://login.salesforce.com.*OK$
40
+ """
16
41
 
17
42
  Scenario: Retrieve code from the default sandbox with debug output
18
43
  When I run `sf pull -d`
19
44
  Then the exit status should be 0
20
- And the output should contain "INFO: Pulling changes from env_a"
21
45
  And the output should contain "BUILD SUCCESSFUL"
46
+ And the output should match:
47
+ """
48
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com.*
49
+ """
22
50
 
23
51
  Scenario: Retrieve code from a specific sandbox with debug output
24
52
  When I run `sf pull -s env_a -d`
25
53
  Then the exit status should be 0
26
- And the output should contain "INFO: Pulling changes from env_a"
27
54
  And the output should contain "BUILD SUCCESSFUL"
55
+ And the output should match:
56
+ """
57
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com.*$
58
+ """
28
59
 
@@ -10,7 +10,7 @@ Feature: Push code to salesforce
10
10
  And a file named "dcxml_location/destructiveChanges.xml" should exist
11
11
  And the output should match:
12
12
  """
13
- ^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
13
+ ^INFO: Pulling changes from env_a using url https:\/\/test.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
14
14
  ^INFO: Creating destructive changes xml$
15
15
  ^INFO: Deploying code to env_a:.*OK$
16
16
  """
@@ -21,11 +21,23 @@ Feature: Push code to salesforce
21
21
  And a file named "dcxml_location/destructiveChanges.xml" should exist
22
22
  And the output should match:
23
23
  """
24
- ^INFO: Pulling changes from env_b to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
24
+ ^INFO: Pulling changes from env_b using url https://test.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
25
25
  ^INFO: Creating destructive changes xml$
26
26
  ^INFO: Deploying code to env_b:.*OK$
27
27
  """
28
28
 
29
+ Scenario: Push code to production should use the url login.salesorce.com
30
+ Given I set the environment variables to:
31
+ | variable | value |
32
+ | SFDT_USERNAME | invalid_user |
33
+ | SFDT_PASSWORD | invalid_pass |
34
+ When I run `sf push -s prod`
35
+ Then the exit status should be 1
36
+ And the output should match:
37
+ """
38
+ ^INFO: Pulling changes from prod using url https://login.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*$
39
+ """
40
+
29
41
  Scenario: Push code to a sandbox with debug information
30
42
  When I run `sf push -d`
31
43
  Then the exit status should be 0
@@ -44,7 +56,7 @@ Feature: Push code to salesforce
44
56
  And a file named "dcxml_location/destructiveChanges.xml" should exist
45
57
  And the output should match:
46
58
  """
47
- ^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
59
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
48
60
  ^INFO: Creating destructive changes xml$
49
61
  ^INFO: Deploying and Testing code to env_a:.*OK$
50
62
  """
@@ -73,6 +85,7 @@ Feature: Push code to salesforce
73
85
  ^INFO: Deploying and Testing code to env_a:.*OK$
74
86
  """
75
87
 
88
+ @test
76
89
  Scenario: Push code to a sandbox in append mode and run all tests and output debug information
77
90
  When I run `sf push -a -T -d`
78
91
  Then the exit status should be 0
@@ -100,7 +113,7 @@ Feature: Push code to salesforce
100
113
  And the file "sfdt_git_dir/version_file" should contain "build_number_pattern"
101
114
  And the output should match:
102
115
  """
103
- ^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
116
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
104
117
  ^INFO: Creating destructive changes xml$
105
118
  ^INFO: Deploying code to env_a:.*OK$
106
119
  """
@@ -117,7 +130,7 @@ Feature: Push code to salesforce
117
130
  And the file "sfdt_git_dir/version_file" should contain "commit_hash_pattern"
118
131
  And the output should match:
119
132
  """
120
- ^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
133
+ ^INFO: Pulling changes from env_a using url https://test.salesforce.com to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
121
134
  ^INFO: Creating destructive changes xml$
122
135
  ^INFO: Deploying code to env_a:.*OK$
123
136
  """
@@ -131,7 +144,6 @@ Feature: Push code to salesforce
131
144
  ^ERROR: The environment is not properly configured, please run sf config to clone the repo and setup the credentials$
132
145
  """
133
146
 
134
- @new
135
147
  Scenario: Push code to a sandbox specifying a different URL
136
148
  Given I set the environment variables to:
137
149
  | variable | value |
@@ -143,16 +155,4 @@ Feature: Push code to salesforce
143
155
  .*Failed to login: Failed to send request to https://invalid_url.salesforce.com.*
144
156
  """
145
157
 
146
- # Scenario: Push code to a sandbox excluding files
147
- # Given I set the environment variables to:
148
- # | variable | value |
149
- # | SFDT_DEPLOY_IGNORE_FILES | src/layouts/test.layout,src/layouts/another_test.layout |
150
- # When I run `sf push`
151
- # #TODO: Then the files listed in SFDT_DEPLOY_IGNORE_FILES should be ignored by sf when deploying
152
- # Then the exit status should be 0
153
- # And the output should match:
154
- # """
155
- # ^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
156
- # ^INFO: Creating destructive changes xml$
157
- # ^INFO: Deploying code to env_a:.*OK$
158
- # """
158
+ # TODO: Scenario: Push code to a sandbox excluding files
@@ -76,17 +76,15 @@ module SalesforceDeployTool
76
76
 
77
77
  end
78
78
 
79
- def clean_git_dir message = nil
79
+ def clean_git_dir
80
80
 
81
- print message
82
81
  Dir[File.join(@git_dir,'src','*')].each do |dir|
83
82
  FileUtils.rm_rf dir unless dir =~ /.*package.xml$/
84
83
  end
85
- puts "OK" unless message.nil?
86
84
 
87
85
  end
88
86
 
89
- def pull message = nil
87
+ def pull
90
88
 
91
89
  env_vars = ""
92
90
  env_vars += " SF_USERNAME=" + @username
@@ -102,13 +100,11 @@ module SalesforceDeployTool
102
100
  :stderr => @debug,
103
101
  :stdout => @debug,
104
102
  :spinner => ! @debug,
105
- :message => message,
106
103
  :okmsg => "OK",
107
104
  :failmsg => "FAILED",
108
105
  }
109
106
 
110
107
  if @debug
111
- exec_options[:message] += "\n\n"
112
108
  exec_options[:okmsg] = nil
113
109
  exec_options[:failmsg] = nil
114
110
  end
@@ -150,10 +146,6 @@ module SalesforceDeployTool
150
146
  exec_options[:failmsg] = nil
151
147
  end
152
148
 
153
- # Deploy code
154
- exec_options[:message] = @test ? "INFO: Deploying and Testing code to #{@sandbox}: " : "INFO: Deploying code to #{@sandbox}: "
155
- exec_options[:message] += "\n\n" if @debug
156
-
157
149
  cmd = @test ? " ant deployAndTestCode" : " ant deployCode"
158
150
  full_cmd = env_vars + cmd
159
151
 
@@ -1,3 +1,3 @@
1
1
  module SalesforceDeployTool
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.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: 1.2.0
4
+ version: 1.3.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: 2015-03-02 00:00:00.000000000 Z
11
+ date: 2015-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,6 +151,7 @@ files:
151
151
  - Rakefile
152
152
  - bin/sf
153
153
  - features/config.feature
154
+ - features/misc.feature
154
155
  - features/pull.feature
155
156
  - features/push.feature
156
157
  - features/support/env.rb
@@ -186,6 +187,7 @@ specification_version: 4
186
187
  summary: A tool to help you at deploying and pulling code and metadata from salesforce
187
188
  test_files:
188
189
  - features/config.feature
190
+ - features/misc.feature
189
191
  - features/pull.feature
190
192
  - features/push.feature
191
193
  - features/support/env.rb