dtk-client 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDc3MDgwYjMwMzU0MTM5Y2UzZGY5YTk4MGM3NDIxMTNkMjBlZjI0Ng==
5
- data.tar.gz: !binary |-
6
- N2QyN2FhN2JiMTNlZGU0YTM1YzAzYTE2ZGZiNTdlYjEyZGNmN2ZjMQ==
2
+ SHA1:
3
+ metadata.gz: 255d3202f2e1ed5a8549778e48dbb1e98d83e287
4
+ data.tar.gz: c7c2879f1783ea5dfae4bba570e0587e7853c469
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDVmZGE3ODE2NjFhZWNmMGUxNDQ0YWI3ODM0NGU2NjRlZGFkNzlhZGQ0YzA5
10
- NGNhOTUwYzgxMmUxZDgwODU1ZDhiZDljYWNjNWEwM2I3MWM3OTQ5MjFkOTIz
11
- MmYxNjBjZTQwZjI5ZWRlMTA0NDkxYmE0MTc5YzM3MTY1NzllNzg=
12
- data.tar.gz: !binary |-
13
- MGU0MjZmMDViY2FiNGY3ZGMyMzVjMWJmNGE0NjFhZTljNjA1ZTExZjVlNjY5
14
- MjEzN2JjOWE3MTEzMmI4NmUyOGM1ZWZjNzE4OTI4YzgxZDQyOGU0YmU5ZDEw
15
- NGU4MGRhMGUwZmYzYzE0NjkzZDZmYmY5ZTU4ZGVkYjQ0NGVkZTM=
6
+ metadata.gz: edc060619dbdfee5195dd346a87a0c81edbe18c69a67704b0510c048560d60e125270f7dc27b40877f718453d2a288c992a8e56b0f11f308d46901a2cd8fb1d9
7
+ data.tar.gz: 436463ab2e98c92e9e5677ef12e54453eb9c2825249e2d1dd2b50592c65f87185d127b0c4a011dd113fb72f1e8bb44b0c8b7e8f98094e728db25b44778d90a5b
data/dtk-client.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.add_dependency 'hirb','~> 0.7.0'
30
30
  gem.add_dependency 'thor','~> 0.15.4'
31
31
  gem.add_dependency 'erubis','~> 2.7.0'
32
- gem.add_dependency 'dtk-common-core','~> 0.5.10'
32
+ gem.add_dependency 'dtk-common-core','~> 0.6.0'
33
33
  gem.add_dependency 'git','~> 1.2.6'
34
34
  gem.add_dependency 'colorize','~> 0.5.8'
35
35
  gem.add_dependency 'highline', '1.6.16'
@@ -12,18 +12,28 @@ module DTK; module Client; class CommandHelper
12
12
  GitAdapter.new(repo_dir,branch)
13
13
  end
14
14
 
15
+ def create_clone_from_optional_branch(type, module_name, repo_url, opts={})
16
+ branch = opts[:branch]
17
+ version = opts[:version]
18
+ namespace = opts[:namespace]
19
+ create_clone_with_branch(type,module_name,repo_url,branch,version,namespace,{:track_remote_branch => true}.merge(opts))
20
+ end
21
+ # TODO: should we deprecate below for above, subsituting the body of below for above ?
15
22
  def create_clone_with_branch(type, module_name, repo_url, branch=nil, version=nil, module_namespace=nil, opts={})
16
23
  Response.wrap_helper_actions do
17
24
  full_name = module_namespace ? ModuleUtil.resolve_name(module_name, module_namespace) : module_name
18
25
 
19
26
  modules_dir = modules_dir(type,full_name,version,opts)
20
27
  FileUtils.mkdir_p(modules_dir) unless File.directory?(modules_dir)
28
+
21
29
  target_repo_dir = local_repo_dir(type,full_name,version,opts)
30
+ if File.exists?(target_repo_dir)
31
+ raise ErrorUsage.new("Directory '#{target_repo_dir}' is not empty; it must be deleted or removed before retrying the command")
32
+ end
22
33
 
23
- opts = {}
24
- opts = { :branch => branch } if branch
25
34
  begin
26
- GitAdapter.clone(repo_url, target_repo_dir, opts[:branch])
35
+ opts_clone = (opts[:track_remote_branch] ? {:track_remote_branch => true} : {})
36
+ GitAdapter.clone(repo_url, target_repo_dir, branch,opts_clone)
27
37
  rescue => e
28
38
  # Handling Git error messages with more user friendly messages
29
39
  e = GitErrorHandler.handle(e)
@@ -174,6 +184,7 @@ module DTK; module Client; class CommandHelper
174
184
  # creates directory if missing
175
185
  parent_path = new_dir.gsub(/(\/\w+)$/,'')
176
186
  FileUtils::mkdir_p(parent_path) unless File.directory?(parent_path)
187
+ # raise ErrorUsage.new("Destination folder already exists '#{new_dir}', aborting initialization.") if File.directory?(new_dir)
177
188
  FileUtils.mv(old_dir, new_dir)
178
189
  else
179
190
  new_dir = local_repo_dir
@@ -191,7 +202,7 @@ module DTK; module Client; class CommandHelper
191
202
  response = unlink_local_clone?(type,module_name,version)
192
203
  unless response.ok?
193
204
  # in case delete went wrong, we raise usage error
194
- raise ErrorUsage.new("Directory (#{local_repo_dir} is set as a git repo; to continue it must be a non git repo; this can be handled by shell command 'rm -rf #{local_repo_dir}/.git'")
205
+ raise DtkError.new("Directory (#{local_repo_dir} is set as a git repo; to continue it must be a non git repo; this can be handled by shell command 'rm -rf #{local_repo_dir}/.git'")
195
206
  end
196
207
  # we return to normal flow, since .git dir is removed
197
208
  end
@@ -14,6 +14,7 @@ module DTK::Client
14
14
  full_module_name = ModuleUtil.resolve_name(module_name, module_namespace)
15
15
 
16
16
  return not_ok_response if not_ok_response
17
+ # TODO: should we use instead Helper(:git_repo).create_clone_from_optional_branch
17
18
  response = Helper(:git_repo).create_clone_with_branch(module_type,module_name,repo_url,branch,version,module_namespace,opts)
18
19
 
19
20
  if response.ok?
@@ -187,7 +187,11 @@ module DTK::Client
187
187
  namespace, local_module_name = get_namespace_and_name(module_name, ModuleUtil::NAMESPACE_SEPERATOR)
188
188
 
189
189
  # Create component module from user's input git repo
190
- response = Helper(:git_repo).create_clone_with_branch(module_type.to_sym, local_module_name, git_repo_url, nil, nil, namespace)
190
+ opts = {
191
+ :namespace => namespace,
192
+ :branch => options['branch']
193
+ }
194
+ response = Helper(:git_repo).create_clone_from_optional_branch(module_type.to_sym, local_module_name, git_repo_url, opts)
191
195
 
192
196
  # Raise error if git repository is invalid
193
197
  # raise DtkError,"Git repository URL '#{git_repo_url}' is invalid." unless response.ok?
@@ -208,6 +212,7 @@ module DTK::Client
208
212
  OsUtil.print("There are some missing dependencies: #{possibly_missing}", :yellow) unless possibly_missing.empty?
209
213
  end
210
214
  else
215
+ local_module_name = create_response.data[:full_module_name] if create_response.data[:full_module_name]
211
216
  delete_module_sub_aux(context_params, local_module_name, :force_delete => true, :no_error_msg => true, :purge => true)
212
217
  return create_response
213
218
  end
@@ -340,6 +345,7 @@ module DTK::Client
340
345
  end
341
346
 
342
347
  unless skip_cloning
348
+ # TODO: should we use instead Helper(:git_repo).create_clone_from_optional_branch
343
349
  response = Helper(:git_repo).create_clone_with_branch(module_type.to_sym, module_name, repo_url, branch, version, remote_namespace)
344
350
  end
345
351
 
@@ -68,7 +68,7 @@ module DTK::Client
68
68
  content = dsl_created_info["content"]
69
69
  if path and content
70
70
  msg = "A #{path} file has been created for you, located at #{repo_obj.repo_dir}"
71
- response = Helper(:git_repo).add_file(path,content,msg)
71
+ response = Helper(:git_repo).add_file(repo_obj,path,content,msg)
72
72
  return response unless response.ok?
73
73
  end
74
74
  end
@@ -264,7 +264,9 @@ module DTK::Client
264
264
  @@invalidate_map << :assembly
265
265
 
266
266
  assembly_template_name = get_assembly_name(assembly_template_id)
267
- assembly_template_name.gsub!('::','-') if assembly_template_name
267
+ if assembly_template_name
268
+ assembly_template_name.gsub!(/(::)|(\/)/,'-')
269
+ end
268
270
 
269
271
  # we check current options and forwarded options (from deploy method)
270
272
  in_target = options["in-target"] || context_params.get_forwarded_thor_option("in-target")
@@ -184,7 +184,8 @@ TODO: might deprecate
184
184
  #
185
185
  # Creates component module from input git repo, removing .git dir to rid of pointing to user github, and creates component module
186
186
  #
187
- desc "import-git GIT-SSH-REPO-URL [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
187
+ method_option :branch, :aliases => '-b'
188
+ desc "import-git GIT-SSH-REPO-URL [-b BRANCH/TAG] [NAMESPACE:]COMPONENT-MODULE-NAME", "Create new local component module by importing from provided git repo URL"
188
189
  def import_git(context_params)
189
190
  import_git_module_aux(context_params)
190
191
  end
@@ -85,6 +85,11 @@ module DTK::Client
85
85
  :endpoint => "assembly",
86
86
  :url => "assembly/info_about",
87
87
  :opts => {:subtype=>"instance", :about=>"modules"}
88
+ },
89
+ :delete_node => {
90
+ :endpoint => "assembly",
91
+ :url => "assembly/info_about",
92
+ :opts => {:subtype=>"instance", :about=>"nodes"}
88
93
  }
89
94
  }
90
95
  }
@@ -574,7 +579,13 @@ TODO: will put in dot release and will rename to 'extend'
574
579
  response = create_node_aux(context_params)
575
580
  return response unless response.ok?
576
581
 
582
+ @@invalidate_map << :assembly
583
+ @@invalidate_map << :assembly_node
584
+ @@invalidate_map << :service
577
585
  @@invalidate_map << :service_node
586
+ @@invalidate_map << :workspace
587
+ @@invalidate_map << :workspace_node
588
+
578
589
  message = "Created node '#{response.data["display_name"]}'."
579
590
  DTK::Client::OsUtil.print(message, :yellow)
580
591
  end
@@ -601,7 +612,13 @@ TODO: will put in dot release and will rename to 'extend'
601
612
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
602
613
  def delete_node(context_params)
603
614
  response = delete_node_aux(context_params)
615
+
616
+ @@invalidate_map << :assembly
617
+ @@invalidate_map << :assembly_node
618
+ @@invalidate_map << :service
604
619
  @@invalidate_map << :service_node
620
+ @@invalidate_map << :workspace
621
+ @@invalidate_map << :workspace_node
605
622
 
606
623
  return response
607
624
  end
@@ -61,6 +61,11 @@ module DTK::Client
61
61
  :endpoint => "assembly",
62
62
  :url => "assembly/info_about",
63
63
  :opts => {:subtype=>"instance", :about=>"modules"}
64
+ },
65
+ :delete_node => {
66
+ :endpoint => "assembly",
67
+ :url => "assembly/info_about",
68
+ :opts => {:subtype=>"instance", :about=>"nodes"}
64
69
  }
65
70
  }
66
71
  }
@@ -245,7 +250,13 @@ module DTK::Client
245
250
  response = create_node_aux(context_params)
246
251
  return response unless response.ok?
247
252
 
253
+ @@invalidate_map << :assembly
254
+ @@invalidate_map << :assembly_node
255
+ @@invalidate_map << :service
248
256
  @@invalidate_map << :service_node
257
+ @@invalidate_map << :workspace
258
+ @@invalidate_map << :workspace_node
259
+
249
260
  message = "Created node '#{response.data["display_name"]}'."
250
261
  DTK::Client::OsUtil.print(message, :yellow)
251
262
  end
@@ -291,7 +302,13 @@ module DTK::Client
291
302
  method_option :force, :aliases => '-y', :type => :boolean, :default => false
292
303
  def delete_node(context_params)
293
304
  response = delete_node_aux(context_params)
305
+
306
+ @@invalidate_map << :assembly
307
+ @@invalidate_map << :assembly_node
308
+ @@invalidate_map << :service
294
309
  @@invalidate_map << :service_node
310
+ @@invalidate_map << :workspace
311
+ @@invalidate_map << :workspace_node
295
312
 
296
313
  return response
297
314
  end
@@ -189,10 +189,24 @@ module DTK
189
189
  @git_repo.merge(remote_branch_ref)
190
190
  end
191
191
 
192
- def self.clone(repo_url, target_path, branch)
192
+ def self.clone(repo_url, target_path, branch, opts={})
193
193
  git_base = Git.clone(repo_url, target_path)
194
- git_base.branch(branch).checkout unless branch.nil?
195
- git_base
194
+ unless branch.nil?
195
+ if opts[:track_remote_branch]
196
+ # This just tracks remote branch
197
+ begin
198
+ git_base.checkout(branch)
199
+ rescue => e
200
+ # TODO: see if any other kind of error
201
+ raise DtkError.new("The branch or tag '#{branch}' does not exist on repo '#{repo_url}'")
202
+ end
203
+ else
204
+ # This wil first create a remote branch;
205
+ # TODO: this might be wrong and should be deprecated
206
+ git_base.branch(branch).checkout
207
+ end
208
+ end
209
+ git_base
196
210
  end
197
211
 
198
212
  def repo_dir
@@ -1,3 +1,3 @@
1
1
  module DtkClient
2
- VERSION="0.6.1"
2
+ VERSION="0.6.2"
3
3
  end
data/lib/shell/context.rb CHANGED
@@ -229,7 +229,8 @@ module DTK
229
229
  clazz_from_args = DTK::Shell::Context.get_command_class(command_from_args) if command_from_args
230
230
  end
231
231
 
232
- if (command.eql?('cd') || command.eql?('cc') || command.eql?('popc') || command.eql?('pushc'))
232
+ # this delete-node is a hack because we need autocomplete when there is node with name 'node'
233
+ if (command.eql?('cd') || command.eql?('cc') || command.eql?('popc') || command.eql?('pushc') || command.eql?('delete-node'))
233
234
  if is_root
234
235
  if entries.size >= 3
235
236
  node = entries[2]
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.2.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.2.4
27
27
  - !ruby/object:Gem::Dependency
@@ -56,98 +56,98 @@ dependencies:
56
56
  name: mime-types
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.25'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.25'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hirb
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.7.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.7.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.15.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.15.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: erubis
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 2.7.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.7.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: dtk-common-core
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.5.10
117
+ version: 0.6.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.5.10
124
+ version: 0.6.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: git
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.2.6
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.2.6
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: colorize
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: 0.5.8
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.5.8
153
153
  - !ruby/object:Gem::Dependency
@@ -328,17 +328,17 @@ require_paths:
328
328
  - lib
329
329
  required_ruby_version: !ruby/object:Gem::Requirement
330
330
  requirements:
331
- - - ! '>='
331
+ - - ">="
332
332
  - !ruby/object:Gem::Version
333
333
  version: '0'
334
334
  required_rubygems_version: !ruby/object:Gem::Requirement
335
335
  requirements:
336
- - - ! '>='
336
+ - - ">="
337
337
  - !ruby/object:Gem::Version
338
338
  version: '0'
339
339
  requirements: []
340
340
  rubyforge_project:
341
- rubygems_version: 2.2.2
341
+ rubygems_version: 2.4.1
342
342
  signing_key:
343
343
  specification_version: 4
344
344
  summary: DTK CLI client for DTK server interaction.