disloku 0.4.0 → 0.5.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/bin/disloku +1 -5
- data/config/sample.config +11 -0
- data/lib/disloku/BaseCommand.rb +0 -51
- data/lib/disloku/BaseCoreCommand.rb +71 -0
- data/lib/disloku/BaseTask.rb +4 -3
- data/lib/disloku/CliAdapter.rb +22 -7
- data/lib/disloku/Constants.rb +1 -1
- data/lib/disloku/DislokuError.rb +10 -0
- data/lib/disloku/Log.rb +20 -1
- data/lib/disloku/OsCommands.rb +28 -0
- data/lib/disloku/SysCmd.rb +4 -1
- data/lib/disloku/commands/Build.rb +10 -5
- data/lib/disloku/commands/Config.rb +3 -3
- data/lib/disloku/commands/Deploy.rb +31 -15
- data/lib/disloku/commands/Generate.rb +26 -0
- data/lib/disloku/config/Mapping.rb +15 -14
- data/lib/disloku/config/Options.rb +26 -0
- data/lib/disloku/git/ChangeSetProvider.rb +3 -1
- data/lib/disloku/tasks/NetSftpTask.rb +14 -7
- data/lib/disloku.rb +33 -10
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3df4e4387e6a88f82dbb55189ac71b7774e6db
|
4
|
+
data.tar.gz: 53658b6566ee5c871f6fd8b45fe6081de894081c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b45fb10023f1843931bec38c0c52f200e6294a4756bb3083c1ef9500f9f2f7092e1f1f1007dfc34c0a035a517427530ad4bb4c722b262d86e55635ffd994447f
|
7
|
+
data.tar.gz: cdc37da67c74c182c6845d9fa41f6b48726f5648d6e1ca94753463f0dba12869b03547b8826ac50aed717594a31ca0fca0af03b02963ba4e160a84eca2627475
|
data/bin/disloku
CHANGED
data/lib/disloku/BaseCommand.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
require_relative('DislokuError')
|
2
1
|
require_relative('Log')
|
3
|
-
require_relative('config/YamlConfig')
|
4
|
-
require_relative('config/Options')
|
5
|
-
require_relative('config/MappingStore')
|
6
|
-
require_relative('config/ConnectionStore')
|
7
|
-
require_relative('config/Target')
|
8
2
|
require_relative('git/Repository')
|
9
3
|
|
10
4
|
module Disloku
|
@@ -14,32 +8,6 @@ module Disloku
|
|
14
8
|
|
15
9
|
def initialize(cliOptions)
|
16
10
|
processGlobalOptions(cliOptions)
|
17
|
-
|
18
|
-
@repository = @scmImplementation.new(cliOptions[:dir])
|
19
|
-
@config = loadConfiguration()
|
20
|
-
@options = Config::Options.new(@config["options"], cliOptions)
|
21
|
-
@mappingStore = Config::MappingStore.new(@config["mappings"])
|
22
|
-
@connectionStore = Config::ConnectionStore.new(@config["connections"])
|
23
|
-
|
24
|
-
Log.instance.addLogTarget(:logfile, File.join(repository.root, "disloku.log"), Logger::INFO)
|
25
|
-
end
|
26
|
-
|
27
|
-
def loadConfiguration()
|
28
|
-
repoConfig = File.join(repository.root, 'disloku.config')
|
29
|
-
if (!File.exists?(repoConfig))
|
30
|
-
raise DislokuError.new("There is no disloku.config file in #{repository.root}")
|
31
|
-
end
|
32
|
-
|
33
|
-
config = Config::YamlConfig.new(repoConfig)
|
34
|
-
|
35
|
-
userHome = File.expand_path("~")
|
36
|
-
userConfig = File.join(userHome, ".disloku.config")
|
37
|
-
if (File.exists?(userConfig))
|
38
|
-
base = Config::YamlConfig.new(userConfig)
|
39
|
-
config.merge(base)
|
40
|
-
end
|
41
|
-
|
42
|
-
return config
|
43
11
|
end
|
44
12
|
|
45
13
|
def processGlobalOptions(cliOptions)
|
@@ -55,25 +23,6 @@ module Disloku
|
|
55
23
|
Log.instance.level(:default, Logger::WARN)
|
56
24
|
end
|
57
25
|
end
|
58
|
-
|
59
|
-
def resolveTargets(targets)
|
60
|
-
actualTargets = []
|
61
|
-
|
62
|
-
while (targets.count > 0)
|
63
|
-
current = targets.shift()
|
64
|
-
targetConfig = @config["targets"][current]
|
65
|
-
if (targetConfig != nil)
|
66
|
-
if (targetConfig["targets"] != nil)
|
67
|
-
targetConfig["targets"].value().each() { |x| targets.push(x.value()) }
|
68
|
-
next
|
69
|
-
end
|
70
|
-
|
71
|
-
actualTargets.push(Config::Target.new(current, targetConfig, @mappingStore, @connectionStore))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
return actualTargets
|
76
|
-
end
|
77
26
|
end
|
78
27
|
|
79
28
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative('DislokuError')
|
2
|
+
require_relative('BaseCommand')
|
3
|
+
require_relative('Log')
|
4
|
+
require_relative('CliAdapter')
|
5
|
+
require_relative('config/YamlConfig')
|
6
|
+
require_relative('config/Options')
|
7
|
+
require_relative('config/MappingStore')
|
8
|
+
require_relative('config/ConnectionStore')
|
9
|
+
require_relative('config/Target')
|
10
|
+
|
11
|
+
module Disloku
|
12
|
+
|
13
|
+
class BaseCoreCommand < BaseCommand
|
14
|
+
attr_accessor :repository, :config, :options
|
15
|
+
|
16
|
+
def initialize(cliOptions)
|
17
|
+
super(cliOptions)
|
18
|
+
|
19
|
+
@repository = @scmImplementation.new(cliOptions[:dir])
|
20
|
+
@config = loadConfiguration()
|
21
|
+
@options = Config::Options.new(@config["options"], cliOptions)
|
22
|
+
@mappingStore = Config::MappingStore.new(@config["mappings"])
|
23
|
+
@connectionStore = Config::ConnectionStore.new(@config["connections"])
|
24
|
+
|
25
|
+
Log.instance.addLogTarget(:logfile, File.join(repository.root, "disloku.log"), Logger::INFO)
|
26
|
+
CliAdapter.setYesNoBehavior(@options.inputDefault)
|
27
|
+
end
|
28
|
+
|
29
|
+
def loadConfiguration()
|
30
|
+
repoConfig = File.join(repository.root, 'disloku.config')
|
31
|
+
if (!File.exists?(repoConfig))
|
32
|
+
raise DislokuError.new("There is no disloku.config file in #{repository.root}")
|
33
|
+
end
|
34
|
+
|
35
|
+
config = Config::YamlConfig.new(repoConfig)
|
36
|
+
|
37
|
+
userHome = File.expand_path("~")
|
38
|
+
userConfig = File.join(userHome, ".disloku.config")
|
39
|
+
if (File.exists?(userConfig))
|
40
|
+
base = Config::YamlConfig.new(userConfig)
|
41
|
+
config.merge(base)
|
42
|
+
end
|
43
|
+
|
44
|
+
return config
|
45
|
+
end
|
46
|
+
|
47
|
+
def resolveTargets(targets)
|
48
|
+
actualTargets = []
|
49
|
+
|
50
|
+
while (targets.count > 0)
|
51
|
+
current = targets.shift()
|
52
|
+
targetConfig = @config["targets"][current]
|
53
|
+
if (targetConfig != nil)
|
54
|
+
if (targetConfig["targets"] != nil)
|
55
|
+
targetConfig["targets"].value().each() { |x| targets.push(x.value()) }
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
actualTargets.push(Config::Target.new(current, targetConfig, @mappingStore, @connectionStore))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
return actualTargets
|
64
|
+
end
|
65
|
+
|
66
|
+
def execute(*args)
|
67
|
+
send(:executeCommand, *args)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/lib/disloku/BaseTask.rb
CHANGED
data/lib/disloku/CliAdapter.rb
CHANGED
@@ -1,23 +1,38 @@
|
|
1
1
|
require('io/console')
|
2
|
+
require('rainbow')
|
2
3
|
|
3
4
|
module Disloku
|
4
5
|
|
5
6
|
class CliAdapter
|
7
|
+
|
6
8
|
class << self
|
7
9
|
|
8
10
|
@@in = $stdin
|
9
11
|
@@out = $stdout
|
12
|
+
@@rainbow = Rainbow.new()
|
13
|
+
@@rainbow.enabled = true
|
14
|
+
@@default = :none
|
10
15
|
|
11
|
-
def
|
12
|
-
@@
|
13
|
-
|
16
|
+
def setYesNoBehavior(default)
|
17
|
+
@@default = default
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
20
|
+
def queryYesNo(question, highPrio = false)
|
21
|
+
color = highPrio ? :yellow : :green
|
22
|
+
@@out.puts()
|
23
|
+
@@out.puts(@@rainbow.wrap("#{question} (Y/N)?").color(color))
|
24
|
+
|
25
|
+
if ((@@default == :veryYes) || (@@default == :yes && !highPrio))
|
26
|
+
self.puts("Assuming 'yes'")
|
27
|
+
return true
|
28
|
+
else
|
29
|
+
char = @@in.getch()
|
30
|
+
return !char.match(/^[Yy]/).nil?
|
31
|
+
end
|
17
32
|
end
|
18
33
|
|
19
|
-
def queryYesNo!(question)
|
20
|
-
if (queryYesNo(question))
|
34
|
+
def queryYesNo!(question, highPrio = false)
|
35
|
+
if (queryYesNo(question, highPrio))
|
21
36
|
yield
|
22
37
|
end
|
23
38
|
end
|
data/lib/disloku/Constants.rb
CHANGED
data/lib/disloku/DislokuError.rb
CHANGED
data/lib/disloku/Log.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative('util/Kernel')
|
2
2
|
require('singleton')
|
3
3
|
require('logger')
|
4
|
+
require('rainbow')
|
4
5
|
|
5
6
|
module Disloku
|
6
7
|
class Log
|
@@ -10,8 +11,26 @@ module Disloku
|
|
10
11
|
def initialize()
|
11
12
|
@loggers = {}
|
12
13
|
|
14
|
+
rainbow = Rainbow.new()
|
15
|
+
rainbow.enabled = true
|
16
|
+
colors = {
|
17
|
+
"DEBUG" => [:green, :normal],
|
18
|
+
"INFO" => [:cyan, :normal],
|
19
|
+
"WARN" => [:yellow, :bright],
|
20
|
+
"ERROR" => [:red, :normal],
|
21
|
+
"FATAL" => [:red, :bright],
|
22
|
+
}
|
23
|
+
|
13
24
|
addLogTarget(:default, STDOUT, Logger::INFO) do |severity, datetime, progname, msg|
|
14
|
-
"#{msg}
|
25
|
+
line = rainbow.wrap("#{msg}")
|
26
|
+
if (colors.has_key?(severity))
|
27
|
+
c = colors[severity]
|
28
|
+
line = line.color(c[0])
|
29
|
+
if (c[1] == :bright)
|
30
|
+
line = line.bright()
|
31
|
+
end
|
32
|
+
end
|
33
|
+
line + "\n"
|
15
34
|
end
|
16
35
|
|
17
36
|
@scope = [[:default]]
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative('SysCmd')
|
2
|
+
require('rbconfig')
|
3
|
+
|
4
|
+
module Disloku
|
5
|
+
|
6
|
+
class OsCommands
|
7
|
+
class << self
|
8
|
+
|
9
|
+
@@os = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ ? :win : :unix)
|
10
|
+
|
11
|
+
@@commands = {
|
12
|
+
:openDir => {
|
13
|
+
:win => "explorer \"$1\"",
|
14
|
+
:unix => "xdg-open \"$1\"",
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
def get(cmdKey, *args)
|
19
|
+
return SysCmd.new(@@commands[cmdKey][@@os], *args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def convertPath(path)
|
23
|
+
return @@os == :win ? path.gsub(File::SEPARATOR, File::ALT_SEPARATOR) : path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/disloku/SysCmd.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
-
require_relative('../
|
1
|
+
require_relative('../BaseCoreCommand')
|
2
2
|
require_relative('../tasks/FolderTask')
|
3
|
+
require_relative('../OsCommands')
|
3
4
|
|
4
5
|
module Disloku
|
5
6
|
module Commands
|
6
7
|
|
7
|
-
class Build <
|
8
|
+
class Build < BaseCoreCommand
|
8
9
|
def initialize(cliOptions)
|
9
10
|
super(cliOptions)
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
-
changesets = @repository.getChangeSets(from
|
13
|
+
def executeCommand(from)
|
14
|
+
changesets = @repository.getChangeSets(from)
|
14
15
|
|
15
16
|
folderInput = {
|
16
17
|
:options => @options,
|
@@ -21,8 +22,12 @@ module Disloku
|
|
21
22
|
resolveTargets([@options.target]).each() do |t|
|
22
23
|
folderInput[:target] = t
|
23
24
|
|
24
|
-
|
25
|
+
Tasks::FolderTask.new(folderInput).execute()
|
25
26
|
end
|
27
|
+
|
28
|
+
convertedPath = OsCommands.convertPath(@options.packageDir)
|
29
|
+
Log.instance.info("Opening package directory #{convertedPath}")
|
30
|
+
@options.getCommand(:openDirCmd, convertedPath).execute()
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require_relative('../
|
1
|
+
require_relative('../BaseCoreCommand')
|
2
2
|
|
3
3
|
module Disloku
|
4
4
|
module Commands
|
5
5
|
|
6
|
-
class Config <
|
6
|
+
class Config < BaseCoreCommand
|
7
7
|
def initialize(cliOptions)
|
8
8
|
super(cliOptions)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def executeCommand()
|
12
12
|
puts(config.to_yaml())
|
13
13
|
end
|
14
14
|
end
|
@@ -1,17 +1,21 @@
|
|
1
|
-
require_relative('../
|
1
|
+
require_relative('../DislokuError')
|
2
|
+
require_relative('../BaseCoreCommand')
|
3
|
+
require_relative('../CliAdapter')
|
4
|
+
require_relative('../Log')
|
2
5
|
require_relative('../tasks/FolderTask')
|
3
6
|
require_relative('../tasks/NetSftpTask')
|
4
7
|
|
5
8
|
module Disloku
|
6
9
|
module Commands
|
7
10
|
|
8
|
-
class Deploy <
|
11
|
+
class Deploy < BaseCoreCommand
|
9
12
|
def initialize(cliOptions)
|
10
13
|
super(cliOptions)
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
14
|
-
changesets = @repository.getChangeSets(from
|
16
|
+
def executeCommand(from)
|
17
|
+
changesets = @repository.getChangeSets(from)
|
18
|
+
dirty = changesets.any?() { |c| c.dirty?() }
|
15
19
|
|
16
20
|
folderInput = {
|
17
21
|
:options => @options,
|
@@ -19,17 +23,29 @@ module Disloku
|
|
19
23
|
}
|
20
24
|
|
21
25
|
resolveTargets([@options.target]).each() do |t|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
begin
|
27
|
+
folderInput[:target] = t
|
28
|
+
|
29
|
+
result = Tasks::FolderTask.new(folderInput).execute()
|
30
|
+
|
31
|
+
sftpInput = result.merge({
|
32
|
+
:repository => @repository,
|
33
|
+
:options => @options,
|
34
|
+
:target => t,
|
35
|
+
:dirty => dirty,
|
36
|
+
})
|
37
|
+
|
38
|
+
result = Tasks::NetSftpTask.new(sftpInput).execute()
|
39
|
+
rescue DislokuError => e
|
40
|
+
if (e.recoverable?)
|
41
|
+
Log.instance.error(e.message)
|
42
|
+
if (!CliAdapter.queryYesNo("Continue with next target?", true))
|
43
|
+
return
|
44
|
+
end
|
45
|
+
else
|
46
|
+
raise
|
47
|
+
end
|
48
|
+
end
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative('../DislokuError')
|
2
|
+
require('fileutils')
|
3
|
+
|
4
|
+
module Disloku
|
5
|
+
module Commands
|
6
|
+
|
7
|
+
class Generate < BaseCommand
|
8
|
+
def initialize(cliOptions)
|
9
|
+
super(cliOptions)
|
10
|
+
|
11
|
+
@repository = @scmImplementation.new(cliOptions[:dir])
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute()
|
15
|
+
repoConfig = File.join(@repository.root, 'disloku.config')
|
16
|
+
if (File.exists?(repoConfig))
|
17
|
+
raise DislokuError.new("disloku.config already exists in this repository")
|
18
|
+
else
|
19
|
+
sampleConfig = File.expand_path(File.join(File.dirname(__FILE__), "../../../config/sample.config"))
|
20
|
+
FileUtils.cp(sampleConfig, repoConfig)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -9,6 +9,11 @@ module Disloku
|
|
9
9
|
def initialize(config, mappingStore = nil, allowDefault = true)
|
10
10
|
@mapping = {}
|
11
11
|
|
12
|
+
symbolize = Proc.new() do |s|
|
13
|
+
match = s.match(/^:(.*)/)
|
14
|
+
match.nil? ? s : match[1].to_sym()
|
15
|
+
end
|
16
|
+
|
12
17
|
mappingConfig = config["mapping"]
|
13
18
|
if (!mappingConfig.nil?)
|
14
19
|
mappingConfig.value().each() do |m|
|
@@ -18,25 +23,21 @@ module Disloku
|
|
18
23
|
if (src.kind_of?(Symbol))
|
19
24
|
segments = [src]
|
20
25
|
else
|
21
|
-
segments = Util::File.getSegments(src)
|
26
|
+
segments = Util::File.getSegments(src).map(&symbolize)
|
27
|
+
end
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
node = node[segment]
|
29
|
+
segments[0..-2].each() do |segment|
|
30
|
+
if (!node.has_key?(segment))
|
31
|
+
node[segment] = {}
|
28
32
|
end
|
33
|
+
node = node[segment]
|
29
34
|
end
|
30
35
|
|
31
|
-
|
32
|
-
|
36
|
+
dst = m["dst"].value()
|
37
|
+
if (dst.kind_of?(Symbol))
|
38
|
+
node[segments[-1]] = dst
|
33
39
|
else
|
34
|
-
|
35
|
-
if (dst.kind_of?(Symbol))
|
36
|
-
node[segments[-1]] = dst
|
37
|
-
else
|
38
|
-
node[segments[-1]] = Util::File.getSegments(m["dst"].value())
|
39
|
-
end
|
40
|
+
node[segments[-1]] = Util::File.getSegments(dst)
|
40
41
|
end
|
41
42
|
end
|
42
43
|
elsif (allowDefault)
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require_relative('../Log')
|
2
|
+
require_relative('../OsCommands')
|
3
|
+
require_relative('../SysCmd')
|
2
4
|
require('tmpdir')
|
3
5
|
require('fileutils')
|
4
6
|
|
@@ -14,6 +16,11 @@ module Disloku
|
|
14
16
|
:allowOverride => false,
|
15
17
|
:target => "default",
|
16
18
|
:packageDir => :temp,
|
19
|
+
:inputDefault => :none,
|
20
|
+
:assumeYes => false,
|
21
|
+
:assumeVeryYes => false,
|
22
|
+
:openPackageDir => true,
|
23
|
+
:openDirCmd => :openDir,
|
17
24
|
}
|
18
25
|
|
19
26
|
@options.each_key() do |key|
|
@@ -24,6 +31,11 @@ module Disloku
|
|
24
31
|
end
|
25
32
|
end
|
26
33
|
|
34
|
+
processPackageDir()
|
35
|
+
processInputDefaults()
|
36
|
+
end
|
37
|
+
|
38
|
+
def processPackageDir()
|
27
39
|
if (@options[:packageDir] == :temp)
|
28
40
|
@options[:packageDir] = Dir.mktmpdir("disloku")
|
29
41
|
Log.instance.debug("Creating tmp directory #{@options[:packageDir]}")
|
@@ -38,6 +50,14 @@ module Disloku
|
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
53
|
+
def processInputDefaults()
|
54
|
+
if (@options[:assumeVeryYes] == true)
|
55
|
+
@options[:inputDefault] = :veryYes
|
56
|
+
elsif (@options[:assumeYes] == true)
|
57
|
+
@options[:inputDefault] = :yes
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
41
61
|
def method_missing(name, *args, &block)
|
42
62
|
if (!@options.has_key?(name))
|
43
63
|
raise ArgumentError.new("There's no option '#{name}' here")
|
@@ -45,6 +65,12 @@ module Disloku
|
|
45
65
|
|
46
66
|
return @options[name]
|
47
67
|
end
|
68
|
+
|
69
|
+
def getCommand(cmdKey, *args)
|
70
|
+
cmd = @options[cmdKey]
|
71
|
+
return cmd.kind_of?(Symbol) ? OsCommands.get(cmd, *args) : SysCmd.new(cmd, *args)
|
72
|
+
end
|
73
|
+
|
48
74
|
end
|
49
75
|
|
50
76
|
end
|
@@ -37,7 +37,9 @@ module Disloku
|
|
37
37
|
if (to == nil)
|
38
38
|
diff = SysCmd.new("git diff --name-status --staged #{from} #{repository.root}").execute()
|
39
39
|
else
|
40
|
-
|
40
|
+
# defining a 'to' means that this particular ref has to be checked out first
|
41
|
+
raise NotImplementedError.new()
|
42
|
+
#diff = SysCmd.new("git diff --name-status #{from} #{to} #{repository.root}").execute()
|
41
43
|
end
|
42
44
|
|
43
45
|
Log.instance.scope([:default, :logfile]) do
|
@@ -34,29 +34,36 @@ module Disloku
|
|
34
34
|
@directory = getInputParam(input, :directory, String)
|
35
35
|
@files = getInputParam(input, :files, Array)
|
36
36
|
@target = getInputParam(input, :target, Config::Target)
|
37
|
+
@dirty = getInputParam(input, :dirty, Object)
|
37
38
|
end
|
38
39
|
|
39
40
|
def beforeExecute()
|
41
|
+
if (@files.count == 0)
|
42
|
+
CliAdapter.puts("Nothing to deploy for target [#{@target.name}]")
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
40
46
|
if (!@target.branchLock.nil?)
|
41
47
|
branch = @repository.getBranchName()
|
42
48
|
if (branch != @target.branchLock)
|
43
|
-
raise DislokuError.new("Target [#{@target.name}] is locked to branch #{@target.branchLock} but current branch is #{branch}")
|
49
|
+
raise DislokuError.new("Target [#{@target.name}] is locked to branch #{@target.branchLock} but current branch is #{branch}", true)
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
|
-
|
48
|
-
|
53
|
+
if (@dirty && !@target.allowDirty.nil? && !@target.allowDirty)
|
54
|
+
raise DislokuError.new("Target does not allow deployments from dirty repositories", true)
|
55
|
+
end
|
56
|
+
|
57
|
+
CliAdapter.puts()
|
58
|
+
CliAdapter.puts("Target [#{@target.name}]: #{@target.user}@#{@target.host}:#{@target.targetDir}")
|
49
59
|
@files.each() do |file|
|
50
60
|
puts(file)
|
51
61
|
end
|
52
62
|
|
53
|
-
|
63
|
+
return CliAdapter.queryYesNo("Continue with deployment?")
|
54
64
|
end
|
55
65
|
|
56
66
|
def executeTask()
|
57
|
-
if (@skip)
|
58
|
-
return
|
59
|
-
end
|
60
67
|
CliAdapter.puts("Doploying target [#{@target.name}]")
|
61
68
|
|
62
69
|
Log.instance.scope([:default, :logfile]) do
|
data/lib/disloku.rb
CHANGED
@@ -1,39 +1,62 @@
|
|
1
|
+
require_relative('disloku/Log')
|
1
2
|
require_relative('disloku/Constants')
|
2
3
|
require_relative('disloku/commands/Config')
|
3
4
|
require_relative('disloku/commands/Build')
|
4
5
|
require_relative('disloku/commands/Deploy')
|
6
|
+
require_relative('disloku/commands/Generate')
|
5
7
|
require_relative('disloku/SysCmd')
|
6
8
|
require_relative('disloku/SessionManager')
|
7
9
|
require('thor')
|
8
10
|
|
9
11
|
class DislokuCli < Thor
|
12
|
+
|
13
|
+
def self.run()
|
14
|
+
begin
|
15
|
+
DislokuCli.start()
|
16
|
+
rescue Interrupt => e
|
17
|
+
Disloku::Log.instance.warn("Disloku was killed with CTRL+C")
|
18
|
+
rescue Exception => e
|
19
|
+
Disloku::Log.instance.fatal("Unhandled exception: #{e.message}")
|
20
|
+
if (ARGV.any?() { |a| a == "-d" || a == "--debug" })
|
21
|
+
Disloku::Log.instance.fatal(e.backtrace.join("\n"))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
class_option :verbose, :aliases => "-v", :type => :boolean, :desc => "verbose output"
|
11
27
|
class_option :debug, :aliases => "-d", :type => :boolean, :desc => "debug output"
|
12
28
|
class_option :scm, :aliases => "-s", :type => :string, :desc => "source control adapter to use (git) - defaults to git"
|
29
|
+
class_option :dir, :default => ".", :aliases => "-d", :desc => "repository directory - defaults to current directory"
|
30
|
+
class_option :assumeYes, :aliases => "-y", :type => :boolean, :desc => "assume 'yes' to all basic questions"
|
31
|
+
class_option :assumeVeryYes, :aliases => "-Y", :type => :boolean, :desc => "assume 'yes' to _all_ questions"
|
13
32
|
|
14
|
-
desc "deploy [FROM]
|
15
|
-
method_option :dir, :default => ".", :aliases => "-d", :desc => "repository directory"
|
33
|
+
desc "deploy [FROM]", "deploy changes"
|
16
34
|
method_option :target, :aliases => "-t", :desc => "target"
|
17
35
|
method_option :packageDir, :aliases => "-p", :desc => "directory in which the deployment package will be created (a temp folder is created if this option is omitted)"
|
18
36
|
method_option :ignoreDeleteErrors, :aliases => "--ignore-delete-errors", :type => :boolean, :desc => "ignore remote delete errors"
|
19
|
-
def deploy(from = nil
|
37
|
+
def deploy(from = nil)
|
20
38
|
cmd = Disloku::Commands::Deploy.new(options)
|
21
|
-
cmd.execute(from
|
39
|
+
cmd.execute(from)
|
22
40
|
end
|
23
41
|
|
24
|
-
desc "build [FROM]
|
25
|
-
method_option :dir, :default => ".", :aliases => "-d", :desc => "repository directory"
|
42
|
+
desc "build [FROM]", "build change package"
|
26
43
|
method_option :target, :aliases => "-t", :desc => "target"
|
27
44
|
method_option :packageDir, :default => "~/disloku", :aliases => "-p", :desc => "directory in which the deployment package will be created (~/disloku if this option is omitted)"
|
28
|
-
method_option :allowOverride, :aliases => "-
|
45
|
+
method_option :allowOverride, :aliases => "-o", :type => :boolean, :desc => "overwrites existing deployment packages in packageDir"
|
29
46
|
method_option :createDeletesFile, :aliases => "--create-deletes-file", :type => :boolean, :desc => "creates a .deletes file containing a list of deleted files"
|
30
|
-
|
47
|
+
method_option :openPackageDir, :type => :boolean, :desc => "open package directory after successfull creation"
|
48
|
+
def build(from = nil)
|
31
49
|
cmd = Disloku::Commands::Build.new(options)
|
32
|
-
cmd.execute(from
|
50
|
+
cmd.execute(from)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "generate", "creates a new sample disloku.config file in the target directory"
|
54
|
+
def generate()
|
55
|
+
cmd = Disloku::Commands::Generate.new(options)
|
56
|
+
cmd.execute()
|
33
57
|
end
|
34
58
|
|
35
59
|
desc "config", "show configuration"
|
36
|
-
method_option :dir, :default => ".", :aliases => "-d", :desc => "repository directory"
|
37
60
|
def config()
|
38
61
|
cmd = Disloku::Commands::Config.new(options)
|
39
62
|
cmd.execute()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: disloku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Angerer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.1.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rainbow
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,7 @@ dependencies:
|
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 2.14.1
|
69
83
|
description: A deployment tool that allows copying of Git changesets via sftp (version
|
70
|
-
0.
|
84
|
+
0.5.0 [1195da82ef])
|
71
85
|
email:
|
72
86
|
- executor.dev@gmail.com
|
73
87
|
executables:
|
@@ -76,6 +90,7 @@ extensions: []
|
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
92
|
- lib/disloku/BaseCommand.rb
|
93
|
+
- lib/disloku/BaseCoreCommand.rb
|
79
94
|
- lib/disloku/BaseTask.rb
|
80
95
|
- lib/disloku/ChangeSet.rb
|
81
96
|
- lib/disloku/ChangeSetProvider.rb
|
@@ -83,6 +98,7 @@ files:
|
|
83
98
|
- lib/disloku/commands/Build.rb
|
84
99
|
- lib/disloku/commands/Config.rb
|
85
100
|
- lib/disloku/commands/Deploy.rb
|
101
|
+
- lib/disloku/commands/Generate.rb
|
86
102
|
- lib/disloku/config/Connection.rb
|
87
103
|
- lib/disloku/config/ConnectionStore.rb
|
88
104
|
- lib/disloku/config/Mapping.rb
|
@@ -97,6 +113,7 @@ files:
|
|
97
113
|
- lib/disloku/git/ChangeSetProvider.rb
|
98
114
|
- lib/disloku/git/Repository.rb
|
99
115
|
- lib/disloku/Log.rb
|
116
|
+
- lib/disloku/OsCommands.rb
|
100
117
|
- lib/disloku/Repository.rb
|
101
118
|
- lib/disloku/SessionManager.rb
|
102
119
|
- lib/disloku/svn/ChangeSetProvider.rb
|
@@ -110,6 +127,7 @@ files:
|
|
110
127
|
- lib/disloku/util/Kernel.rb
|
111
128
|
- lib/disloku.rb
|
112
129
|
- LICENSE
|
130
|
+
- config/sample.config
|
113
131
|
- bin/disloku
|
114
132
|
homepage: https://rubygems.org/gems/disloku
|
115
133
|
licenses:
|