salesforce-dcgen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/dcgen +53 -0
- data/lib/dcgen/app.rb +59 -0
- data/lib/dcgen/plugins/apexclass.rb +12 -0
- data/lib/dcgen/plugins/apexpage.rb +12 -0
- data/lib/dcgen/plugins/approvalprocess.rb +12 -0
- data/lib/dcgen/plugins/customfield.rb +37 -0
- data/lib/dcgen/plugins/group.rb +12 -0
- data/lib/dcgen/plugins/permissionset.rb +12 -0
- data/lib/dcgen/plugins/workflow.rb +12 -0
- data/lib/dcgen/version.rb +3 -0
- data/lib/dcgen.rb +4 -0
- data/salesforce-dcgen.gemspec +23 -0
- data/tpl/destructiveChanges.xml.erb +59 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8309ecc64daeb2c5bd7e1f1422343c5ca16b3c30
|
4
|
+
data.tar.gz: c1d47909fc91c7130cb7935c2a7a388bf04d7277
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: feb564d64b0d81be96f38092fa24649af87a3e42039ebbb03b51fd9f5372b7445eb173a6bb7cc0380eb5408d3f5a20279a94350c4e150a923bf4272abb87f742
|
7
|
+
data.tar.gz: a618eeb91548c8c3d28cf00d373be10939dd1a0379ab145b0a63710aec8fe2f81682767eb9fe514e1a4d0020b7c3bf8f25dc5ed61494d76ac95d87e4a5c80cbb
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
src
|
24
|
+
destructiveChanges.xml
|
25
|
+
*.swp
|
26
|
+
test.rb
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Juan Breinlinger
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Dcgen
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dcgen'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dcgen
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/dcgen/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/dcgen
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'dcgen'
|
4
|
+
require 'optparse'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
parser = OptionParser.new do |opts|
|
10
|
+
|
11
|
+
opts.banner = 'Usage: dcgen [options]'
|
12
|
+
|
13
|
+
opts.on('-m', '--master dir', 'Source dir') do |name|
|
14
|
+
options[:master] = name;
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on('-d', '--destination dir', 'Destination dir') do |age|
|
18
|
+
options[:destination] = age;
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on('-h', '--help', 'Displays Help') do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
if ARGV.empty?
|
27
|
+
puts opts
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
parser.parse!
|
34
|
+
|
35
|
+
|
36
|
+
if options[:master].nil?
|
37
|
+
puts "error: you must specify master dir"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
if options[:destination].nil?
|
42
|
+
puts "error: you must specify destination dir"
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
|
46
|
+
dcgen = Dcgen::App.new
|
47
|
+
|
48
|
+
dcgen.master = options[:master]
|
49
|
+
dcgen.destination = options[:destination]
|
50
|
+
|
51
|
+
dcgen.generate_destructive_changes
|
52
|
+
|
53
|
+
|
data/lib/dcgen/app.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module Dcgen
|
2
|
+
class App
|
3
|
+
|
4
|
+
attr_accessor :master, :destination
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
|
8
|
+
@metadata = {}
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate_directories
|
13
|
+
|
14
|
+
@master = File.join(Dir.pwd,@master)
|
15
|
+
@destination = File.join(Dir.pwd,@destination)
|
16
|
+
raise ArgumentError, "#{@master} dir not found" if not Dir.exists? @master
|
17
|
+
raise ArgumentError, "#{@destination} dir not found" if not Dir.exists? @destination
|
18
|
+
raise ArgumentError, "#{@master} package.xml not found" if not File.exists? File.join(@master,'package.xml')
|
19
|
+
raise ArgumentError, "#{@destination} package.xml not found" if not File.exists? File.join(@destination,'package.xml')
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_xml
|
24
|
+
|
25
|
+
# Generate destructive change
|
26
|
+
dc_erb_tpl = File.open(File.join(File.dirname(__FILE__),'..','..','tpl','destructiveChanges.xml.erb')).read
|
27
|
+
renderer = ERB.new(dc_erb_tpl,0,'>')
|
28
|
+
|
29
|
+
puts "info: destructiveChanges.xml successfully generated"
|
30
|
+
|
31
|
+
File.open('destructiveChanges.xml','w') do |file|
|
32
|
+
file.write renderer.result(binding)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_destructive_changes
|
38
|
+
|
39
|
+
# Validate directories
|
40
|
+
validate_directories
|
41
|
+
|
42
|
+
# Load plugins and build metadata variables
|
43
|
+
plugins = Dir.glob(File.dirname(__FILE__) + "/plugins/*" )
|
44
|
+
|
45
|
+
plugins.each do |plugin|
|
46
|
+
require_relative plugin
|
47
|
+
|
48
|
+
plugin_name = plugin.match(/^.*\/(.*).rb$/)[1]
|
49
|
+
@metadata[plugin_name.to_sym] = eval "Dcgen::#{plugin_name} @master, @destination"
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
# Generate the template and write to file
|
54
|
+
generate_xml
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.apexclass master , destination
|
4
|
+
|
5
|
+
master_classes = Dir.glob(master + '/classes/*cls').map {|c| c.match(/^.*\/(.*).cls$/)[1] }
|
6
|
+
destination_classes = Dir.glob(destination + '/classes/*cls').map {|c| c.match(/^.*\/(.*).cls$/)[1] }
|
7
|
+
|
8
|
+
destination_classes - master_classes
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.apexpage master , destination
|
4
|
+
|
5
|
+
master_pages = Dir.glob(master + '/pages/*page').map {|c| c.match(/^.*\/(.*).page$/)[1] }
|
6
|
+
destination_pages = Dir.glob(destination + '/pages/*page').map {|c| c.match(/^.*\/(.*).page$/)[1] }
|
7
|
+
|
8
|
+
destination_pages - master_pages
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.approvalprocess master , destination
|
4
|
+
|
5
|
+
master_approvalprocess = Dir.glob(master + '/approvalProcesses/*approvalProcess').map {|c| c.match(/^.*\/(.*).approvalProcess$/)[1] }
|
6
|
+
destination_approvalprocess = Dir.glob(destination + '/approvalProcesses/*approvalProcess').map {|c| c.match(/^.*\/(.*).approvalProcess$/)[1] }
|
7
|
+
|
8
|
+
destination_approvalprocess - master_approvalprocess
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Dcgen
|
4
|
+
|
5
|
+
def self.customfield master , destination
|
6
|
+
|
7
|
+
remove_fields = []
|
8
|
+
|
9
|
+
master_objects = Dir.glob(master + '/objects/*object').map {|c| c.match(/^.*\/(.*).object$/)[1] }
|
10
|
+
|
11
|
+
master_objects.each do |obj|
|
12
|
+
|
13
|
+
master_obj_file = File.join(master,'objects',obj + '.object')
|
14
|
+
destination_obj_file = File.join(destination,'objects',obj + '.object')
|
15
|
+
|
16
|
+
if File.exists? destination_obj_file
|
17
|
+
|
18
|
+
master_obj_xml = File.open(master_obj_file).read
|
19
|
+
destination_obj_xml = File.open(destination_obj_file).read
|
20
|
+
|
21
|
+
master_doc = Nokogiri::XML(master_obj_xml).remove_namespaces!
|
22
|
+
destination_doc = Nokogiri::XML(destination_obj_xml).remove_namespaces!
|
23
|
+
|
24
|
+
# Find all the customfields that are in destination, if they are not present in
|
25
|
+
# master, then they have to be in the remove list
|
26
|
+
destination_doc.xpath('//fields/fullName').each do |field|
|
27
|
+
remove_fields << "#{obj}.#{field.text}" if master_doc.xpath("//fields[fullName=\"#{field.text}\"]").empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
remove_fields
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.group master , destination
|
4
|
+
|
5
|
+
master_groups = Dir.glob(master + '/groups/*group').map {|c| c.match(/^.*\/(.*).group$/)[1] }
|
6
|
+
destination_groups = Dir.glob(destination + '/groups/*group').map {|c| c.match(/^.*\/(.*).group$/)[1] }
|
7
|
+
|
8
|
+
destination_groups - master_groups
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.permissionset master , destination
|
4
|
+
|
5
|
+
master_permissionset = Dir.glob(master + '/permissionsets/*permissionset').map {|c| c.match(/^.*\/(.*).permissionset$/)[1] }
|
6
|
+
destination_permissionset = Dir.glob(destination + '/permissionsets/*permissionset').map {|c| c.match(/^.*\/(.*).permissionset$/)[1] }
|
7
|
+
|
8
|
+
destination_permissionset - master_permissionset
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Dcgen
|
2
|
+
|
3
|
+
def self.workflow master , destination
|
4
|
+
|
5
|
+
master_workflow = Dir.glob(master + '/workflows/*workflow').map {|c| c.match(/^.*\/(.*).workflow$/)[1] }
|
6
|
+
destination_workflow = Dir.glob(destination + '/workflows/*workflow').map {|c| c.match(/^.*\/(.*).workflow$/)[1] }
|
7
|
+
|
8
|
+
destination_workflow - master_workflow
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
data/lib/dcgen.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dcgen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "salesforce-dcgen"
|
8
|
+
spec.version = Dcgen::VERSION
|
9
|
+
spec.authors = ["Juan Breinlinger"]
|
10
|
+
spec.email = ["<juan.brein@breins.net>"]
|
11
|
+
spec.summary = %q{dcgen will generate a destructiveChanges.xml by comparing two source directories}
|
12
|
+
spec.description = %q{todo later}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
|
3
|
+
<% if not @metadata[:apexclass].empty? %>
|
4
|
+
<types>
|
5
|
+
<% for @apexclass in @metadata[:apexclass] %>
|
6
|
+
<members><%= @apexclass %></members>
|
7
|
+
<% end %>
|
8
|
+
<name>ApexClass</name>
|
9
|
+
</types>
|
10
|
+
<% end %>
|
11
|
+
<% if not @metadata[:apexpage].empty? %>
|
12
|
+
<types>
|
13
|
+
<% for @apexpage in @metadata[:apexpage] %>
|
14
|
+
<members><%= @apexpage %></members>
|
15
|
+
<% end %>
|
16
|
+
<name>ApexPage</name>
|
17
|
+
</types>
|
18
|
+
<% end %>
|
19
|
+
<% if not @metadata[:group].empty? %>
|
20
|
+
<types>
|
21
|
+
<% for @group in @metadata[:group] %>
|
22
|
+
<members><%= @group %></members>
|
23
|
+
<% end %>
|
24
|
+
<name>Group</name>
|
25
|
+
</types>
|
26
|
+
<% end %>
|
27
|
+
<% if not @metadata[:customfield].empty? %>
|
28
|
+
<types>
|
29
|
+
<% for @customfield in @metadata[:customfield] %>
|
30
|
+
<members><%= @customfield %></members>
|
31
|
+
<% end %>
|
32
|
+
<name>CustomField</name>
|
33
|
+
</types>
|
34
|
+
<% end %>
|
35
|
+
<% if not @metadata[:approvalprocess].empty? %>
|
36
|
+
<types>
|
37
|
+
<% for @approvalprocess in @metadata[:approvalprocess] %>
|
38
|
+
<members><%= @approvalprocess %></members>
|
39
|
+
<% end %>
|
40
|
+
<name>ApprovalProcess</name>
|
41
|
+
</types>
|
42
|
+
<% end %>
|
43
|
+
<% if not @metadata[:permissionset].empty? %>
|
44
|
+
<types>
|
45
|
+
<% for @permissionset in @metadata[:permissionset] %>
|
46
|
+
<members><%= @permissionset %></members>
|
47
|
+
<% end %>
|
48
|
+
<name>PermissionSet</name>
|
49
|
+
</types>
|
50
|
+
<% end %>
|
51
|
+
<% if not @metadata[:workflow].empty? %>
|
52
|
+
<types>
|
53
|
+
<% for @workflow in @metadata[:workflow] %>
|
54
|
+
<members><%= @workflow %></members>
|
55
|
+
<% end %>
|
56
|
+
<name>Workflow</name>
|
57
|
+
</types>
|
58
|
+
<% end %>
|
59
|
+
</Package>
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: salesforce-dcgen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juan Breinlinger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: todo later
|
42
|
+
email:
|
43
|
+
- "<juan.brein@breins.net>"
|
44
|
+
executables:
|
45
|
+
- dcgen
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/dcgen
|
55
|
+
- lib/dcgen.rb
|
56
|
+
- lib/dcgen/app.rb
|
57
|
+
- lib/dcgen/plugins/apexclass.rb
|
58
|
+
- lib/dcgen/plugins/apexpage.rb
|
59
|
+
- lib/dcgen/plugins/approvalprocess.rb
|
60
|
+
- lib/dcgen/plugins/customfield.rb
|
61
|
+
- lib/dcgen/plugins/group.rb
|
62
|
+
- lib/dcgen/plugins/permissionset.rb
|
63
|
+
- lib/dcgen/plugins/workflow.rb
|
64
|
+
- lib/dcgen/version.rb
|
65
|
+
- salesforce-dcgen.gemspec
|
66
|
+
- tpl/destructiveChanges.xml.erb
|
67
|
+
homepage: ''
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.2.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: dcgen will generate a destructiveChanges.xml by comparing two source directories
|
91
|
+
test_files: []
|