salesforce-deploy-tool 0.12.1 → 1.0.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 +4 -4
- data/.gitignore +3 -0
- data/Rakefile +7 -0
- data/bin/sf +38 -50
- data/features/config.feature +18 -0
- data/features/pull.feature +28 -0
- data/features/push.feature +124 -0
- data/features/support/env.rb +25 -0
- data/features/support/hooks.rb +42 -0
- data/lib/salesforcedeploytool/app.rb +27 -27
- data/lib/salesforcedeploytool/version.rb +1 -1
- data/salesforce-deploy-tool.gemspec +3 -0
- metadata +55 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0187f9d3c8b96465eff801d720921eb54dd8bea
|
4
|
+
data.tar.gz: 5da419996326662b10deaf34fcd32aec60099fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8f7dcafe1335100865ca5dc8ecf6c28a21b7d29b3155ec220df5d4f3f22df844ed09eea1b20da2a8f7c70ff9e8b1d207249541524ebdf1100e099b1c2832a74
|
7
|
+
data.tar.gz: c17f60805fe445ef8ed7331e3fe2a5ccc732d325484efd8f6f8c1956a21c19635368577340ea7eaa07bef372baf4e89075ef5be1c4a1bec2c0f06b6431c1c144
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "aruba"
|
3
|
+
|
4
|
+
# Cucumber tasks
|
5
|
+
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
Cucumber::Rake::Task.new
|
2
9
|
|
3
10
|
# extracted from https://github.com/grosser/project_template
|
4
11
|
rule /^version:bump:.*/ do |t|
|
data/bin/sf
CHANGED
@@ -7,16 +7,15 @@ require 'fileutils'
|
|
7
7
|
STDOUT.sync = true
|
8
8
|
|
9
9
|
# Static files
|
10
|
-
CONFIG_DIR = '~/.sf'
|
11
|
-
CONFIG_FILE = '~/.sf/credentials.yaml'
|
12
|
-
GLOBAL_CONFIG_FILE = '~/.sf/salesforce.yaml'
|
13
|
-
SANDBOX_CONFIG_FILE = '~/.sf/salesforce.sbox'
|
10
|
+
CONFIG_DIR = File.expand_path '~/.sf'
|
11
|
+
CONFIG_FILE = File.expand_path '~/.sf/credentials.yaml'
|
12
|
+
GLOBAL_CONFIG_FILE = File.expand_path '~/.sf/salesforce.yaml'
|
13
|
+
SANDBOX_CONFIG_FILE = File.expand_path '~/.sf/salesforce.sbox'
|
14
14
|
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
FileUtils.mkdir File.expand_path CONFIG_DIR if not Dir.exists? File.expand_path CONFIG_DIR
|
15
|
+
# Create .sf dir if doesn't exists
|
16
|
+
FileUtils.mkdir CONFIG_DIR if not Dir.exists? CONFIG_DIR
|
19
17
|
|
18
|
+
# Load configurations
|
20
19
|
config = {}
|
21
20
|
[CONFIG_FILE,GLOBAL_CONFIG_FILE].each do |file|
|
22
21
|
file = File.expand_path file
|
@@ -29,22 +28,24 @@ config = {}
|
|
29
28
|
end
|
30
29
|
|
31
30
|
# Grab variables from env if not in the config files
|
32
|
-
config[:
|
33
|
-
config[:
|
34
|
-
config[:
|
35
|
-
config[:
|
36
|
-
config[:
|
37
|
-
config[:
|
38
|
-
config[:
|
39
|
-
config[:
|
31
|
+
config[:buildxml_dir] = ENV["SFDT_BUILDXML_DIR"] || config[:buildxml_dir]
|
32
|
+
config[:git_dir] = ENV["SFDT_GIT_DIR"] || config[:git_dir]
|
33
|
+
config[:tmp_dir] = ENV["SFDT_TMP_DIR"] || config[:tmp_dir]
|
34
|
+
config[:version_file] = ENV["SFDT_VERSION_FILE"] || config[:version_file]
|
35
|
+
config[:build_number_pattern] = ENV["SFDT_BUILD_NUMBER_PATTERN"] || config[:build_number_pattern]
|
36
|
+
config[:commit_hash_pattern] = ENV["SFDT_COMMIT_HASH_PATTERN"] || config[:commit_hash_pattern]
|
37
|
+
config[:git_repo] = ENV["SFDT_GIT_REPO"] || config[:git_repo]
|
38
|
+
config[:username] = ENV["SFDT_USERNAME"] || config[:username]
|
39
|
+
config[:password] = ENV["SFDT_PASSWORD"] || config[:password]
|
40
|
+
config[:deploy_ignore_files] = ENV["SFDT_DEPLOY_IGNORE_FILES"].nil? ? config[:deploy_ignore_files] : ENV["DEPLOY_IGNORE_FILES"].split(',')
|
41
|
+
|
42
|
+
# Minimal config validation
|
43
|
+
abort "Config error: git_dir not found in #{GLOBAL_CONFIG_FILE} or through SFDT_GIT_DIR" if config[:git_dir].nil?
|
44
|
+
abort "Config error: tmp_dir not found in #{GLOBAL_CONFIG_FILE} or through SFDT_TMP_DIR" if config[:tmp_dir].nil?
|
40
45
|
|
41
46
|
# Normalize file paths:
|
42
47
|
config[:git_dir] = File.expand_path config[:git_dir]
|
43
48
|
config[:tmp_dir] = File.expand_path config[:tmp_dir]
|
44
|
-
config[:version_file] = File.expand_path config[:version_file]
|
45
|
-
|
46
|
-
# Relative ignore files
|
47
|
-
config[:deploy_ignore_files] = ENV["DEPLOY_IGNORE_FILES"].nil? ? config[:deploy_ignore_files] : ENV["DEPLOY_IGNORE_FILES"].split(',')
|
48
49
|
|
49
50
|
# Read sandbox environment
|
50
51
|
|
@@ -59,33 +60,6 @@ require 'salesforcedeploytool'
|
|
59
60
|
program :version, SalesforceDeployTool::VERSION
|
60
61
|
program :description, 'A cli tool to help manage and deploy salesforce sandboxes with git'
|
61
62
|
|
62
|
-
command :init do |c|
|
63
|
-
c.syntax = 'sf init [options]'
|
64
|
-
c.summary = 'Initialize salesforce sandbox from git'
|
65
|
-
c.description = "Clone the #{config[:git_repo]} to #{config[:git_dir]}"
|
66
|
-
c.example 'usage', 'sf init'
|
67
|
-
c.option "--sandbox NAME", "-s NAME", "use 'prod' to deploy production or sandbox name"
|
68
|
-
c.action do |args, options|
|
69
|
-
|
70
|
-
# short flag mapping
|
71
|
-
options.sandbox = options.s if options.s
|
72
|
-
|
73
|
-
# Parameter validation:
|
74
|
-
if options.sandbox.nil? and sandbox.nil?
|
75
|
-
puts "error: please specify sandbox using --sandbox or sf sandbox"
|
76
|
-
exit 1
|
77
|
-
end
|
78
|
-
config[:sandbox] = options.sandbox || sandbox
|
79
|
-
|
80
|
-
# Initialize
|
81
|
-
sfdt = SalesforceDeployTool::App.new config
|
82
|
-
|
83
|
-
# Clone
|
84
|
-
sfdt.clone
|
85
|
-
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
63
|
command :pull do |c|
|
90
64
|
c.syntax = 'sf pull'
|
91
65
|
c.summary = 'Pull code from the sandbox'
|
@@ -152,7 +126,7 @@ command :push do |c|
|
|
152
126
|
sfdt = SalesforceDeployTool::App.new config.clone
|
153
127
|
|
154
128
|
# Remove destructive change if there is one
|
155
|
-
DESTRUCTIVE_CHANGE_FILE = File.join(config[:git_dir],'src','destructiveChanges.xml')
|
129
|
+
DESTRUCTIVE_CHANGE_FILE = File.join(config[:git_dir],config[:buildxml_dir],'src','destructiveChanges.xml')
|
156
130
|
FileUtils.rm DESTRUCTIVE_CHANGE_FILE if File.exists? DESTRUCTIVE_CHANGE_FILE
|
157
131
|
|
158
132
|
if ! options.append
|
@@ -168,8 +142,8 @@ command :push do |c|
|
|
168
142
|
# Create destructiveChanges.xml
|
169
143
|
puts "INFO: Creating destructive changes xml"
|
170
144
|
dc_gen = Dcgen::App.new
|
171
|
-
dc_gen.master = File.join(config[:git_dir],'src')
|
172
|
-
dc_gen.destination = File.join(config[:tmp_dir],'src')
|
145
|
+
dc_gen.master = File.join(config[:git_dir],config[:buildxml_dir],'src')
|
146
|
+
dc_gen.destination = File.join(config[:tmp_dir],config[:buildxml_dir],'src')
|
173
147
|
dc_gen.output = DESTRUCTIVE_CHANGE_FILE
|
174
148
|
dc_gen.exclude = options.exclude.split(',') unless options.exclude.nil?
|
175
149
|
dc_gen.verbose = false if not options.debug
|
@@ -246,14 +220,28 @@ command :config do |c|
|
|
246
220
|
q.validate = /^\S+@\S+$/
|
247
221
|
end
|
248
222
|
|
223
|
+
sandbox = ask "Please enter your sandbox so to be used as default when push and pull" do |q|
|
224
|
+
q.validate = /^[a-zA-Z]+$/
|
225
|
+
end
|
226
|
+
|
249
227
|
%x[git config --global user.email "#{git_email}"]
|
250
228
|
%x[git config --global user.name "#{git_name}"]
|
251
229
|
|
252
230
|
config[:username] = config_new[:username]
|
253
231
|
config[:password] = config_new[:password]
|
232
|
+
config[:sandbox] = sandbox
|
233
|
+
|
234
|
+
pp config
|
254
235
|
|
236
|
+
File.open(File.expand_path(SANDBOX_CONFIG_FILE),'w').write sandbox
|
255
237
|
File.open(File.expand_path(CONFIG_FILE),'w').write config_new.to_yaml
|
256
238
|
|
239
|
+
# Initialize
|
240
|
+
sfdt = SalesforceDeployTool::App.new config
|
241
|
+
|
242
|
+
# Clone
|
243
|
+
sfdt.clone
|
244
|
+
|
257
245
|
end
|
258
246
|
end
|
259
247
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@config
|
2
|
+
Feature: Configure the user credentials interactively
|
3
|
+
|
4
|
+
In order to use sf
|
5
|
+
As a user using
|
6
|
+
I want to be able to configure my credentials interactively
|
7
|
+
|
8
|
+
Scenario: Running sf config it has to interactively setup my environment
|
9
|
+
When I run `sf config` interactively
|
10
|
+
And I type my salesforce production_username
|
11
|
+
And I type my salesforce production_password
|
12
|
+
And I type my salesforce git_full_name
|
13
|
+
And I type my salesforce git_email_address
|
14
|
+
And I type my salesforce sandbox
|
15
|
+
Then the exit status should be 0
|
16
|
+
And the file "~/.sf/credentials.yaml" should contain "username"
|
17
|
+
And the file "~/.sf/credentials.yaml" should contain "password"
|
18
|
+
And the file "~/.sf/salesforce.sbox" should match /.+/
|
@@ -0,0 +1,28 @@
|
|
1
|
+
@pull
|
2
|
+
Feature: Pull code from salesforce
|
3
|
+
|
4
|
+
As a developer
|
5
|
+
I want to be able to retrieve code from a sandbox
|
6
|
+
|
7
|
+
Scenario: Retrieve code from the default sandbox
|
8
|
+
When I run `sf pull`
|
9
|
+
Then the exit status should be 0
|
10
|
+
And the output should match /INFO: Pulling changes from env_a.*OK/
|
11
|
+
|
12
|
+
Scenario: Retrieve code from a specific sandbox
|
13
|
+
When I run `sf pull -s env_b`
|
14
|
+
Then the exit status should be 0
|
15
|
+
And the output should match /INFO: Pulling changes from env_b.*OK/
|
16
|
+
|
17
|
+
Scenario: Retrieve code from the default sandbox with debug output
|
18
|
+
When I run `sf pull -d`
|
19
|
+
Then the exit status should be 0
|
20
|
+
And the output should contain "INFO: Pulling changes from env_a"
|
21
|
+
And the output should contain "BUILD SUCCESSFUL"
|
22
|
+
|
23
|
+
Scenario: Retrieve code from a specific sandbox with debug output
|
24
|
+
When I run `sf pull -s env_a -d`
|
25
|
+
Then the exit status should be 0
|
26
|
+
And the output should contain "INFO: Pulling changes from env_a"
|
27
|
+
And the output should contain "BUILD SUCCESSFUL"
|
28
|
+
|
@@ -0,0 +1,124 @@
|
|
1
|
+
@push
|
2
|
+
Feature: Push code to salesforce
|
3
|
+
|
4
|
+
As a developer
|
5
|
+
I should be able to push code to a sandbox
|
6
|
+
|
7
|
+
Scenario: Push code to a sandbox
|
8
|
+
When I run `sf push`
|
9
|
+
Then the exit status should be 0
|
10
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
11
|
+
And the output should match:
|
12
|
+
"""
|
13
|
+
^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
|
14
|
+
^INFO: Creating destructive changes xml$
|
15
|
+
^INFO: Deploying code to env_a:.*OK$
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: Push code to a different sandbox
|
19
|
+
When I run `sf push -s env_b`
|
20
|
+
Then the exit status should be 0
|
21
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
22
|
+
And the output should match:
|
23
|
+
"""
|
24
|
+
^INFO: Pulling changes from env_b to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
|
25
|
+
^INFO: Creating destructive changes xml$
|
26
|
+
^INFO: Deploying code to env_b:.*OK$
|
27
|
+
"""
|
28
|
+
|
29
|
+
Scenario: Push code to a sandbox with debug information
|
30
|
+
When I run `sf push -d`
|
31
|
+
Then the exit status should be 0
|
32
|
+
And the output should match /^.* env_a .*BUILD SUCCESSFUL.*Diff between.*Changes detected.*File generated.*BUILD SUCCESSFUL.*$/
|
33
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
34
|
+
|
35
|
+
Scenario: Push code to a sandbox with debug information to a different sandbox
|
36
|
+
When I run `sf push -d -s env_b`
|
37
|
+
Then the exit status should be 0
|
38
|
+
And the output should match /^.* env_b .*BUILD SUCCESSFUL.*Diff between.*Changes detected.*File generated.*BUILD SUCCESSFUL.*$/
|
39
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
40
|
+
|
41
|
+
Scenario: Push code to a sandbox and trigger all the tests
|
42
|
+
When I run `sf push -T`
|
43
|
+
Then the exit status should be 0
|
44
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
45
|
+
And the output should match:
|
46
|
+
"""
|
47
|
+
^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
|
48
|
+
^INFO: Creating destructive changes xml$
|
49
|
+
^INFO: Deploying and Testing code to env_a:.*OK$
|
50
|
+
"""
|
51
|
+
|
52
|
+
Scenario: Push code to a sandbox and trigger all the tests in debug mode
|
53
|
+
When I run `sf push -T -d`
|
54
|
+
Then the exit status should be 0
|
55
|
+
And a file named "dcxml_location/destructiveChanges.xml" should exist
|
56
|
+
And the output should match /^.* env_a .*BUILD SUCCESSFUL.*Diff between.*Changes detected.*File generated.*Running Test:.*DEPLOYMENT SUCCEEDED.*BUILD SUCCESSFUL.*$/
|
57
|
+
|
58
|
+
Scenario: Push code to a sandbox in append mode
|
59
|
+
When I run `sf push -a`
|
60
|
+
Then the exit status should be 0
|
61
|
+
And a file named "dcxml_location/destructiveChanges.xml" should not exist
|
62
|
+
And the output should match:
|
63
|
+
"""
|
64
|
+
^INFO: Deploying code to env_a:.*OK$
|
65
|
+
"""
|
66
|
+
|
67
|
+
Scenario: Push code to a sandbox in append mode and run all tests
|
68
|
+
When I run `sf push -a -T`
|
69
|
+
Then the exit status should be 0
|
70
|
+
And a file named "dcxml_location/destructiveChanges.xml" should not exist
|
71
|
+
And the output should match:
|
72
|
+
"""
|
73
|
+
^INFO: Deploying and Testing code to env_a:.*OK$
|
74
|
+
"""
|
75
|
+
|
76
|
+
Scenario: Push code to a sandbox in append mode and run all tests and output debug information
|
77
|
+
When I run `sf push -a -T -d`
|
78
|
+
Then the exit status should be 0
|
79
|
+
And a file named "dcxml_location/destructiveChanges.xml" should not exist
|
80
|
+
And the output should match:
|
81
|
+
"""
|
82
|
+
^INFO: Deploying and Testing code to env_a: $
|
83
|
+
^$
|
84
|
+
^Buildfile: .*$
|
85
|
+
^$
|
86
|
+
^deployAndTestCode:$
|
87
|
+
"""
|
88
|
+
And the output should match /Running Test/
|
89
|
+
And the output should match /DEPLOYMENT SUCCEEDED.*BUILD SUCCESSFUL/
|
90
|
+
|
91
|
+
Scenario: Push code to a sandbox with a build number
|
92
|
+
Given I set the environment variables to:
|
93
|
+
| variable | value |
|
94
|
+
| SFDT_VERSION_FILE | version_file |
|
95
|
+
| SFDT_BUILD_NUMBER_PATTERN | build_number_pattern |
|
96
|
+
When I watch "sfdt_git_dir/version_file" for changes and copy to "test_file"
|
97
|
+
And I run `sf push --build_number 123456789`
|
98
|
+
Then the exit status should be 0
|
99
|
+
And the file "test_file" should contain "123456789"
|
100
|
+
And the file "sfdt_git_dir/version_file" should contain "build_number_pattern"
|
101
|
+
And the output should match:
|
102
|
+
"""
|
103
|
+
^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
|
104
|
+
^INFO: Creating destructive changes xml$
|
105
|
+
^INFO: Deploying code to env_a:.*OK$
|
106
|
+
"""
|
107
|
+
|
108
|
+
Scenario: Push code to a sandbox with the commit hash stamped into a version file
|
109
|
+
Given I set the environment variables to:
|
110
|
+
| variable | value |
|
111
|
+
| SFDT_VERSION_FILE | version_file |
|
112
|
+
| SFDT_COMMIT_HASH_PATTERN | commit_hash_pattern |
|
113
|
+
When I watch "sfdt_git_dir/version_file" for changes and copy to "test_file"
|
114
|
+
And I run `sf push`
|
115
|
+
Then the exit status should be 0
|
116
|
+
And the file "test_file" should not contain "commit_hash_pattern"
|
117
|
+
And the file "sfdt_git_dir/version_file" should contain "commit_hash_pattern"
|
118
|
+
And the output should match:
|
119
|
+
"""
|
120
|
+
^INFO: Pulling changes from env_a to temporary directory .*tmp_repo.* to generate destructiveChanges.xml.*OK$
|
121
|
+
^INFO: Creating destructive changes xml$
|
122
|
+
^INFO: Deploying code to env_a:.*OK$
|
123
|
+
"""
|
124
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aruba/cucumber'
|
2
|
+
require 'filewatcher'
|
3
|
+
require 'git'
|
4
|
+
|
5
|
+
# Load configuratiohn
|
6
|
+
config = YAML::load(File.open('config.yaml'))
|
7
|
+
|
8
|
+
# Cucumber / aruba configuration parameters
|
9
|
+
Before do
|
10
|
+
@aruba_timeout_seconds = 300
|
11
|
+
end
|
12
|
+
|
13
|
+
# Set environment variables
|
14
|
+
Before do
|
15
|
+
config[:environment_variables].keys.each do |key|
|
16
|
+
ENV[key.to_s.upcase] = config[:environment_variables][key]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Before push and pull clone the repository
|
21
|
+
Before '@push,@pull' do
|
22
|
+
uri = ENV['SFDT_GIT_REPO']
|
23
|
+
name = File.join 'tmp', 'aruba', ENV['SFDT_GIT_DIR']
|
24
|
+
Git.clone(uri, name)
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
config = YAML::load(File.open('config.yaml'))
|
2
|
+
|
3
|
+
When /^I type my salesforce (.*)$/ do |input|
|
4
|
+
raise "Please create credentials.yaml" if config[input.to_sym].nil?
|
5
|
+
type(config[input.to_sym])
|
6
|
+
end
|
7
|
+
|
8
|
+
When /^I watch "(.+)" for changes and copy to "(.+)"$/ do |file,dest|
|
9
|
+
file = File.join('tmp','aruba',file)
|
10
|
+
dest = File.join('tmp','aruba',dest)
|
11
|
+
fork do
|
12
|
+
FileWatcher.new(file).watch do |filename|
|
13
|
+
FileUtils.cp file, dest
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Transform /^.+$/ do |arg|
|
20
|
+
case arg
|
21
|
+
when String
|
22
|
+
config[:replacement_patterns].keys.each do |key|
|
23
|
+
arg = arg.gsub /#{key.to_s}/, config[:replacement_patterns][key]
|
24
|
+
end
|
25
|
+
config[:environment_variables].keys.each do |key|
|
26
|
+
arg = arg.gsub /#{key.to_s}/, config[:environment_variables][key]
|
27
|
+
end
|
28
|
+
when Cucumber::Ast::Table
|
29
|
+
arg.cell_matrix.each do |c|
|
30
|
+
config[:replacement_patterns].keys.each do |key|
|
31
|
+
c[1].value = c[1].value.gsub /#{key.to_s}/, config[:replacement_patterns][key]
|
32
|
+
end
|
33
|
+
config[:environment_variables].keys.each do |key|
|
34
|
+
c[1].value = c[1].value.gsub /#{key.to_s}/, config[:environment_variables][key]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
arg
|
40
|
+
|
41
|
+
end
|
42
|
+
|
@@ -7,35 +7,35 @@ module SalesforceDeployTool
|
|
7
7
|
|
8
8
|
def initialize config
|
9
9
|
|
10
|
-
# Parameter Normalization
|
11
|
-
config[:git_dir] = File.expand_path config[:git_dir]
|
12
|
-
config[:tmp_dir] = File.expand_path config[:tmp_dir]
|
13
|
-
config[:version_file] = File.expand_path config[:version_file]
|
14
|
-
config[:deploy_ignore_files] = config[:deploy_ignore_files].map {|f| File.expand_path File.join(config[:git_dir],f)}
|
15
|
-
|
16
|
-
# Defaults
|
17
|
-
@debug = config[:debug]
|
18
|
-
@test = config[:test]
|
19
|
-
@build_number = 'N/A'
|
20
|
-
|
21
10
|
# Config file validation:
|
22
11
|
( @git_repo = config[:git_repo] ).nil? and raise "Invalid Config: git_repo not found"
|
23
12
|
( @git_dir = config[:git_dir] ).nil? and raise "Invalid Config: git_dir not found"
|
24
13
|
( @sandbox = config[:sandbox] ).nil? and raise "Invalid Config: sandbox not found"
|
25
14
|
( @password = config[:password] ).nil? and raise "Invalid Config: password not found, please run `sf config`"
|
26
|
-
( @
|
27
|
-
( @
|
28
|
-
( @commit_hash_pattern = config[:commit_hash_pattern] ).nil? and raise "Invalid Config: commit_hash_pattern not found"
|
29
|
-
( @version_file = config[:version_file] ).nil? and raise "Invalid Config: version_file not found"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
config[:username].nil? and raise "Invalid Config: username not found, please run `sf config`"
|
34
|
-
config[:password].nil? and raise "Invalid Config: password not found, please run `sf config`"
|
15
|
+
( @username = config[:username] ).nil? and raise "Invalid Config: username not found, please run `sf config`"
|
16
|
+
( @password = config[:password] ).nil? and raise "Invalid Config: password not found, please run `sf config`"
|
35
17
|
|
36
|
-
|
18
|
+
# Parameter Normalization
|
19
|
+
@git_dir = File.expand_path config[:git_dir]
|
20
|
+
@tmp_dir = File.expand_path config[:tmp_dir]
|
21
|
+
@version_file = File.join(@git_dir,config[:version_file]) if !config[:version_file].nil?
|
22
|
+
@deploy_ignore_files = config[:deploy_ignore_files].map {|f| File.expand_path File.join(config[:git_dir],f)} if ! config[:deploy_ignore_files].nil?
|
23
|
+
@build_number_pattern = config[:build_number_pattern]
|
24
|
+
@commit_hash_pattern = config[:commit_hash_pattern]
|
25
|
+
@buildxml_dir = config[:buildxml_dir]
|
26
|
+
@username = @sandbox == 'prod' ? @username : @username + '.' + @sandbox
|
37
27
|
@server_url = @sandbox == 'prod' ? 'https://login.salesforce.com' : 'https://test.salesforce.com'
|
38
28
|
|
29
|
+
# Defaults
|
30
|
+
@debug ||= config[:debug]
|
31
|
+
@test ||= config[:test]
|
32
|
+
@build_number ||= 'N/A'
|
33
|
+
@version_file ||= false
|
34
|
+
@buildxml_dir ||= ''
|
35
|
+
@build_number_pattern ||= false
|
36
|
+
@commit_hash_pattern ||= false
|
37
|
+
@deploy_ignore_files ||= []
|
38
|
+
|
39
39
|
end
|
40
40
|
|
41
41
|
def set_version
|
@@ -44,19 +44,19 @@ module SalesforceDeployTool
|
|
44
44
|
|
45
45
|
File.open(@version_file,'r+') do |file|
|
46
46
|
content = file.read
|
47
|
-
content.gsub!(/#{@build_number_pattern}/,@build_number)
|
48
|
-
content.gsub!(/#{@commit_hash_pattern}/,g.log.first.sha)
|
47
|
+
content.gsub!(/#{@build_number_pattern}/,@build_number) if @build_number_pattern
|
48
|
+
content.gsub!(/#{@commit_hash_pattern}/,g.log.first.sha) if @commit_hash_pattern
|
49
49
|
file.seek(0,IO::SEEK_SET)
|
50
50
|
file.truncate 0
|
51
51
|
file.write content
|
52
|
-
end if File.exists?
|
52
|
+
end if @version_file && File.exists?(@version_file)
|
53
53
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def clean_version
|
57
57
|
|
58
58
|
g = Git.open(@git_dir)
|
59
|
-
g.checkout @version_file if File.exists?
|
59
|
+
g.checkout @version_file if @version_file && File.exists?(@version_file)
|
60
60
|
|
61
61
|
end
|
62
62
|
|
@@ -96,7 +96,7 @@ module SalesforceDeployTool
|
|
96
96
|
|
97
97
|
full_cmd = env_vars + cmd
|
98
98
|
|
99
|
-
Dir.chdir @git_dir
|
99
|
+
Dir.chdir File.join(@git_dir,@buildxml_dir)
|
100
100
|
|
101
101
|
exec_options = {
|
102
102
|
:stderr => @debug,
|
@@ -128,7 +128,7 @@ module SalesforceDeployTool
|
|
128
128
|
def push
|
129
129
|
|
130
130
|
# Working dir
|
131
|
-
Dir.chdir @git_dir
|
131
|
+
Dir.chdir File.join(@git_dir,@buildxml_dir)
|
132
132
|
|
133
133
|
# Set env variables to run ant
|
134
134
|
env_vars = ""
|
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "aruba"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "filewatcher"
|
23
26
|
|
24
27
|
spec.add_runtime_dependency 'git', "~> 1.2"
|
25
28
|
spec.add_runtime_dependency 'colorize', "~> 0.7"
|
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.
|
4
|
+
version: 1.0.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-01-
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aruba
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: filewatcher
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
- !ruby/object:Gem::Dependency
|
42
84
|
name: git
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +150,11 @@ files:
|
|
108
150
|
- README.md
|
109
151
|
- Rakefile
|
110
152
|
- bin/sf
|
153
|
+
- features/config.feature
|
154
|
+
- features/pull.feature
|
155
|
+
- features/push.feature
|
156
|
+
- features/support/env.rb
|
157
|
+
- features/support/hooks.rb
|
111
158
|
- lib/salesforcedeploytool.rb
|
112
159
|
- lib/salesforcedeploytool/app.rb
|
113
160
|
- lib/salesforcedeploytool/functions.rb
|
@@ -137,4 +184,9 @@ rubygems_version: 2.4.3
|
|
137
184
|
signing_key:
|
138
185
|
specification_version: 4
|
139
186
|
summary: A tool to help you at deploying and pulling code and metadata from salesforce
|
140
|
-
test_files:
|
187
|
+
test_files:
|
188
|
+
- features/config.feature
|
189
|
+
- features/pull.feature
|
190
|
+
- features/push.feature
|
191
|
+
- features/support/env.rb
|
192
|
+
- features/support/hooks.rb
|