docman 0.0.81 → 0.0.82

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: 9143ca229196d50ceb0be8f5e11d6d8e3650ac1d
4
- data.tar.gz: 04440af097c5ea1cabb15190c871df939621981a
3
+ metadata.gz: 3cdd636d62e958434d0c228cac7f4b87fed36eff
4
+ data.tar.gz: 53f29632b22a725ac462c45898fd10770270771a
5
5
  SHA512:
6
- metadata.gz: 94991a65d0c2d8eb88c04a1a6e43d66e85cf8f449c789f102bb1b64a136d10bed191a0848c1aa28a7bf453137c586147f8b5d787e4b9ce83de39d9675bbaa874
7
- data.tar.gz: b884a747f67815c57758efed8bb9e61fbdc885ab5f0aea5afc2fbad91773ee7061a63dc24daf72e546e696cc3fd83031979d89ac4d2511bb29ec083e4e984237
6
+ metadata.gz: f8de66b59de7c7cd891103c8b96783edb058ee7001accc9e1c11a074f55b3410290e4a08b424a831f89c830196b66fefddcc67c8dcd01743c8acb12c04cf7927
7
+ data.tar.gz: 762077fd3b560406c586f94d33632689d7be47dc47053c3a6dee6198ad204b00fe947ed4d5a05668258e86b0547f283249c47aa4d18d63c49213a9c0810e288f
File without changes
@@ -30,6 +30,12 @@ deploy_targets:
30
30
  # deployer handler
31
31
  handler: :common_deployer
32
32
  builders:
33
+ single:
34
+ handler: :copy_builder
35
+ hooks:
36
+ builder:
37
+ after_execute:
38
+ - <<: *execute_yaml_file
33
39
  root:
34
40
  handler: :dir_builder
35
41
  root_chain:
@@ -60,6 +66,13 @@ deploy_targets:
60
66
  # deployer handler
61
67
  handler: :common_deployer
62
68
  builders:
69
+ single:
70
+ handler: :copy_builder
71
+ hooks:
72
+ builder:
73
+ after_execute:
74
+ - <<: *remove_git_dir
75
+ - <<: *execute_yaml_file
63
76
  root:
64
77
  handler: :dir_builder
65
78
  root_chain:
@@ -92,6 +105,13 @@ deploy_targets:
92
105
  # deployer handler
93
106
  handler: :git_deployer
94
107
  builders:
108
+ single:
109
+ handler: :copy_builder
110
+ hooks:
111
+ builder:
112
+ after_execute:
113
+ - <<: *execute_yaml_file
114
+ - <<: *git_commit
95
115
  root:
96
116
  handler: :direct_builder
97
117
  provider: :git_repo_provider
@@ -16,6 +16,7 @@ require 'docman/builders/builder'
16
16
  require 'docman/builders/provider_builder'
17
17
  require 'docman/builders/git_provider_builder'
18
18
  require 'docman/builders/dir_builder'
19
+ require 'docman/builders/copy_builder'
19
20
  require 'docman/builders/direct_builder'
20
21
  require 'docman/builders/git_root_chain_builder'
21
22
  require 'docman/builders/git_strip_builder'
@@ -223,6 +224,17 @@ module Docman
223
224
  Docman::Deployers::Deployer.create(params, nil, self).perform
224
225
  end
225
226
 
227
+ def config_dirs(options)
228
+ config_dirs = []
229
+ if options[:config_dir]
230
+ config_dirs = options[:config_dir].split(',')
231
+ end
232
+ config_dirs.push('.unipipe')
233
+ config_dirs.push('.drupipe')
234
+ config_dirs.push('')
235
+ config_dirs
236
+ end
237
+
226
238
  def force?
227
239
  @force or @options[:force]
228
240
  end
@@ -0,0 +1,29 @@
1
+ require 'pathname'
2
+
3
+ module Docman
4
+ module Builders
5
+ class CopyBuilder < Builder
6
+
7
+ register_builder :copy_builder
8
+
9
+ def prepare_build_dir
10
+ if not @context['root_repo'].nil?
11
+ GitUtil.get(@context['root_repo'], @context['full_build_path'], @context.version_type(type: 'root'), @context.version(type: 'root'), true, 1)
12
+ end
13
+ end
14
+
15
+ def execute
16
+ prepare_build_dir
17
+ docroot_config_dir = Pathname(@context['docroot_config'].docroot_config_dir)
18
+ config_dir = Pathname(@context['docroot_config'].config_dir)
19
+ log("Copy project files from: #{docroot_config_dir}")
20
+ `rsync -a --exclude '.git' --exclude 'config.json' --exclude '#{config_dir.relative_path_from(docroot_config_dir)}' #{File.join(@context['docroot_config'].docroot_dir, 'config')}/. #{@context['full_build_path']}`
21
+ end
22
+
23
+ def version
24
+ @context['build_path']
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -41,6 +41,7 @@ module Docman
41
41
  desc 'build', 'Build docroot'
42
42
  method_option :force, :aliases => '-f', :desc => 'Force full rebuild'
43
43
  method_option :config, :desc => 'Configuration override JSON'
44
+ method_option :config_dir, :desc => 'Config directories divided by coma where docman will search for config.yaml'
44
45
  option :tag
45
46
  def build(deploy_target, state)
46
47
  get_to_root_dir
@@ -54,6 +55,7 @@ module Docman
54
55
  desc 'deploy', 'Deploy to target'
55
56
  method_option :force, :aliases => '-f', :desc => 'Force full deploy'
56
57
  method_option :config, :desc => 'Configuration override JSON'
58
+ method_option :config_dir, :desc => 'Config directories divided by coma where docman will search for config.yaml'
57
59
  def deploy(deploy_target, name, type, version)
58
60
  get_to_root_dir
59
61
  if version.start_with?('state_')
@@ -97,6 +99,7 @@ module Docman
97
99
 
98
100
  desc 'info', 'Get info'
99
101
  method_option :force, :aliases => '-f', :desc => 'Force full rebuild'
102
+ method_option :config_dir, :desc => 'Config directories divided by coma where docman will search for config.yaml'
100
103
  option :tag
101
104
  def info(command, file)
102
105
  say(Application.instance.info(command, file, options).to_json);
@@ -13,6 +13,7 @@ module Docman
13
13
  if File.directory? @context['full_build_path']
14
14
  if @context.need_rebuild?
15
15
  return false if @context['type'] == 'dir'
16
+ return false if @context['type'] == 'single' and @context['build_type'] == :copy_builder and not GitUtil.repo?(@context['full_build_path'])
16
17
  return false if @context['type'] == 'root' and @context['build_type'] == :dir_builder and not GitUtil.repo?(@context['full_build_path'])
17
18
  return false if @context['type'] == 'root' and @context['build_type'] == :direct_builder and GitUtil.repo?(@context['full_build_path'])
18
19
  return false if @context['type'] == 'root_chain' and @context['build_type'] == :direct_builder and GitUtil.repo?(@context['full_build_path'])
@@ -20,9 +20,9 @@ module Docman
20
20
  if self['providers'].nil? || self['providers'] == 'all' || self['providers'].include?(@context['provider'])
21
21
  commands = nil
22
22
  if self['source_type'] == 'file'
23
- yaml_file_name = self['yaml_file_name'].nil? ? '.build.yml' : self['yaml_file_name']
24
- build_file = File.join(@context['full_build_path'], yaml_file_name)
25
- if File.file? build_file
23
+ yaml_file_name = self['yaml_file_name'].nil? ? '{unipipe,.unipipe,drupipe,.drupipe,build,.build}.{yaml,yml}' : self['yaml_file_name']
24
+ build_file = Dir.glob([File.join(@context['docroot_config'].config_dir, yaml_file_name), File.join(@context['full_build_path'], yaml_file_name)]).first
25
+ if not build_file.nil?
26
26
  build_file_yaml = YAML::load_file(build_file)
27
27
  commands = build_file_yaml[self['stage']]
28
28
  source = yaml_file_name
@@ -24,14 +24,14 @@ module Docman
24
24
  @unmutable_config = Marshal::load(Marshal.dump(@config))
25
25
  end
26
26
 
27
- def merge_config_from_file(docroot_config_dir, config_file, options = nil)
27
+ def merge_config_from_file(docroot_dir, docroot_config_dir, config_file, options = nil)
28
28
  file = File.join(docroot_config_dir, config_file)
29
29
  if File.file?(file)
30
30
  config = YAML::load_file(file)
31
31
  if config['scenarios']
32
- scenarios_path = File.join(docroot_config_dir, '/../', 'scenarios')
32
+ scenarios_path = File.join(docroot_dir, '.docman/scenarios')
33
33
  `rm -fR #{scenarios_path}` if File.directory? scenarios_path
34
- `mkdir -p scenarios_path`
34
+ `mkdir -p #{scenarios_path}`
35
35
  unless config['scenarioSources']
36
36
  config['scenarioSources'] = {}
37
37
  end
@@ -1,3 +1,4 @@
1
+ require 'application'
1
2
  require 'fileutils'
2
3
  require 'docman/info'
3
4
 
@@ -5,7 +6,7 @@ module Docman
5
6
 
6
7
  class DocrootConfig
7
8
 
8
- attr_reader :structure, :deploy_target, :docroot_dir, :root, :raw_infos
9
+ attr_reader :structure, :deploy_target, :docroot_dir, :docroot_config_dir, :config_dir, :root, :raw_infos
9
10
 
10
11
  def initialize(docroot_dir, deploy_target_name = nil, options = nil)
11
12
  @override = {}
@@ -17,10 +18,18 @@ module Docman
17
18
  @docroot_config_dir = File.join(docroot_dir, 'config')
18
19
 
19
20
  Dir.chdir @docroot_config_dir
20
- update(' origin master')
21
- if File.file? File.join(@docroot_config_dir, 'config.yaml')
22
- Docman::Application.instance.config.merge_config_from_file(@docroot_config_dir, 'config.yaml', options)
23
- end
21
+ update('origin')
22
+ config_files = Docman::Application.instance.config_dirs(options).collect{|item|
23
+ File.join(@docroot_config_dir, item, 'config.{yaml,yml}')
24
+ }
25
+ config_file_path = Dir.glob(config_files).first
26
+
27
+ raise "Configuration file config.{yaml,yml} not found." if config_file_path.nil?
28
+
29
+ @config_dir = File.dirname(config_file_path)
30
+ @config_file = File.basename(config_file_path)
31
+
32
+ Docman::Application.instance.config.merge_config_from_file(docroot_dir, @config_dir, @config_file, options)
24
33
 
25
34
  if deploy_target_name
26
35
  @deploy_target = Application.instance.config['deploy_targets'][deploy_target_name]
@@ -39,8 +48,10 @@ module Docman
39
48
  end
40
49
 
41
50
  def update(options = '')
51
+ Dir.chdir @docroot_config_dir
42
52
  GitUtil.exec("reset --hard", false)
43
- GitUtil.update @docroot_config_dir, options
53
+ branch = GitUtil.branch
54
+ GitUtil.update @docroot_config_dir, "#{options} #{branch.strip}"
44
55
  end
45
56
 
46
57
  def structure_build_from_config_file(path, prefix = '', parent = nil, parent_key = 'master')
@@ -60,9 +71,9 @@ module Docman
60
71
  info['full_path'] = path
61
72
  info['docroot_config'] = self
62
73
  info['build_path'] = prefix
63
- info['full_build_path'] = File.join(@docroot_dir, prefix)
64
- info['temp_path'] = File.join(@docroot_dir, 'tmp', info['build_path'])
65
- info['states_path'] = File.join(@docroot_dir, 'states', info['build_path'])
74
+ info['full_build_path'] = File.join(@docroot_dir, '.docman', prefix)
75
+ info['temp_path'] = File.join(@docroot_dir, '.docman/tmp', info['build_path'])
76
+ info['states_path'] = File.join(@docroot_dir, '.docman/states', info['build_path'])
66
77
  info['name'] = name
67
78
  info['parent'] = parent
68
79
  info['order'] = info.has_key?('order') ? info['order'] : 10
@@ -105,9 +116,9 @@ module Docman
105
116
  info['full_path'] = path
106
117
  info['docroot_config'] = self
107
118
  info['build_path'] = prefix
108
- info['full_build_path'] = File.join(@docroot_dir, prefix)
109
- info['temp_path'] = File.join(@docroot_dir, 'tmp', info['build_path'])
110
- info['states_path'] = File.join(@docroot_dir, 'states', info['build_path'])
119
+ info['full_build_path'] = File.join(@docroot_dir, '.docman', prefix)
120
+ info['temp_path'] = File.join(@docroot_dir, '.docman/tmp', info['build_path'])
121
+ info['states_path'] = File.join(@docroot_dir, '.docman/states', info['build_path'])
111
122
  info['name'] = name
112
123
  info['parent'] = parent
113
124
  info['order'] = info.has_key?('order') ? info['order'] : 10
@@ -172,4 +183,4 @@ module Docman
172
183
  end
173
184
 
174
185
  end
175
- end
186
+ end
@@ -19,7 +19,7 @@ module Docman
19
19
  def self.squash_commits(commit_count, message = nil)
20
20
  message = "$(git log --format=%B --reverse HEAD..HEAD@{1})" unless message
21
21
  exec "reset --soft HEAD~#{commit_count}"
22
- exec "commit -m \"#{message}\""
22
+ exec "commit --no-verify -m \"#{message}\""
23
23
  end
24
24
 
25
25
  def self.reset_repo(path)
@@ -84,7 +84,7 @@ module Docman
84
84
  # pull root_path
85
85
  Dir.chdir root_path
86
86
  exec %Q(add --all #{path.slice "#{root_path}/"})
87
- exec %Q(commit -m "#{message}") if repo_changed? path
87
+ exec %Q(commit --no-verify -m "#{message}") if repo_changed? path
88
88
  self.tag(root_path, tag) if tag
89
89
  Docman::Application.instance.commit_count = Docman::Application.instance.commit_count + 1
90
90
  end
@@ -126,4 +126,4 @@ module Docman
126
126
  end
127
127
  end
128
128
 
129
- end
129
+ end
@@ -1,3 +1,3 @@
1
1
  module Docman
2
- VERSION = "0.0.81"
2
+ VERSION = "0.0.82"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.81
4
+ version: 0.0.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tolstikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -199,6 +199,7 @@ files:
199
199
  - features/support/step_definitions/dm_steps.rb
200
200
  - lib/application.rb
201
201
  - lib/docman/builders/builder.rb
202
+ - lib/docman/builders/copy_builder.rb
202
203
  - lib/docman/builders/dir_builder.rb
203
204
  - lib/docman/builders/direct_builder.rb
204
205
  - lib/docman/builders/git_provider_builder.rb