takeltau 0.34.12 → 0.35.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/takeltau/completion/cli.rb +1 -1
  3. data/lib/takeltau/default.yml +10 -35
  4. data/lib/takeltau/docker/check/cli.rb +1 -1
  5. data/lib/takeltau/docker/check/daemon.rb +1 -1
  6. data/lib/takeltau/docker/cli.rb +1 -1
  7. data/lib/takeltau/docker/container/check/cli.rb +1 -1
  8. data/lib/takeltau/docker/container/check/existing.rb +1 -1
  9. data/lib/takeltau/docker/container/check/network.rb +1 -1
  10. data/lib/takeltau/docker/container/check/orphaned.rb +1 -1
  11. data/lib/takeltau/docker/container/clean.rb +1 -1
  12. data/lib/takeltau/docker/container/cli.rb +1 -1
  13. data/lib/takeltau/docker/container/command.rb +1 -1
  14. data/lib/takeltau/docker/container/daemon.rb +1 -1
  15. data/lib/takeltau/docker/container/lib.rb +1 -1
  16. data/lib/takeltau/docker/container/login.rb +1 -1
  17. data/lib/takeltau/docker/container/prune.rb +1 -1
  18. data/lib/takeltau/docker/image/cli.rb +1 -1
  19. data/lib/takeltau/docker/image/tag/check.rb +1 -1
  20. data/lib/takeltau/docker/image/tag/cli.rb +1 -1
  21. data/lib/takeltau/docker/image/tag/latest.rb +1 -1
  22. data/lib/takeltau/docker/image/tag/list.rb +1 -1
  23. data/lib/takeltau/docker/image/update.rb +1 -1
  24. data/lib/takeltau/git/check/clean.rb +1 -1
  25. data/lib/takeltau/git/check/cli.rb +14 -14
  26. data/lib/takeltau/git/check/hg.rb +26 -0
  27. data/lib/takeltau/git/check/workspace.rb +1 -1
  28. data/lib/takeltau/git/cli.rb +1 -1
  29. data/lib/takeltau/git/lib.rb +80 -0
  30. data/lib/takeltau/hg/cli.rb +56 -0
  31. data/lib/takeltau/hg/export.rb +18 -0
  32. data/lib/takeltau/hg/pull.rb +45 -0
  33. data/lib/takeltau/hg/push.rb +42 -0
  34. data/lib/takeltau/info/cli.rb +1 -1
  35. data/lib/takeltau/info/project/cli.rb +1 -1
  36. data/lib/takeltau/info/status/bar.rb +1 -1
  37. data/lib/takeltau/info/status/cli.rb +1 -1
  38. data/lib/takeltau/info/status/git.rb +1 -1
  39. data/lib/takeltau/info/status/gopass.rb +1 -1
  40. data/lib/takeltau/info/status/gpg.rb +1 -1
  41. data/lib/takeltau/info/status/lib.rb +1 -1
  42. data/lib/takeltau/info/status/ssh.rb +1 -1
  43. data/lib/takeltau/init/lib.rb +9 -28
  44. data/lib/takeltau/init/packer/cli.rb +4 -14
  45. data/lib/takeltau/init/packer/docker.rb +2 -5
  46. data/lib/takeltau/init/packer/templates/hgclone.tt +8 -0
  47. data/lib/takeltau/init/packer/templates/projectyml.tt +2 -6
  48. data/lib/takeltau/init/takelage/cli.rb +4 -14
  49. data/lib/takeltau/init/takelage/rake.rb +2 -5
  50. data/lib/takeltau/init/takelage/templates/hgclone.tt +2 -0
  51. data/lib/takeltau/lib/config.rb +2 -2
  52. data/lib/takeltau/lib/logging.rb +2 -2
  53. data/lib/takeltau/lib/project.rb +2 -2
  54. data/lib/takeltau/mutagen/check/cli.rb +1 -1
  55. data/lib/takeltau/mutagen/check/daemon.rb +1 -1
  56. data/lib/takeltau/mutagen/cli.rb +1 -1
  57. data/lib/takeltau/mutagen/socket/check.rb +1 -1
  58. data/lib/takeltau/mutagen/socket/cli.rb +1 -1
  59. data/lib/takeltau/mutagen/socket/create.rb +1 -1
  60. data/lib/takeltau/mutagen/socket/list.rb +1 -1
  61. data/lib/takeltau/mutagen/socket/terminate.rb +1 -1
  62. data/lib/takeltau/mutagen/socket/tidy.rb +1 -1
  63. data/lib/takeltau/self/cli.rb +1 -1
  64. data/lib/takeltau/self/config/cli.rb +1 -1
  65. data/lib/takeltau/self/list.rb +1 -1
  66. data/lib/takeltau/version +1 -1
  67. data/lib/takeltau.rb +37 -62
  68. metadata +9 -22
  69. data/lib/takeltau/bit/check/cli.rb +0 -23
  70. data/lib/takeltau/bit/check/workspace.rb +0 -37
  71. data/lib/takeltau/bit/cli.rb +0 -18
  72. data/lib/takeltau/bit/clipboard/cli.rb +0 -73
  73. data/lib/takeltau/bit/clipboard/copy.rb +0 -142
  74. data/lib/takeltau/bit/clipboard/lib.rb +0 -143
  75. data/lib/takeltau/bit/clipboard/paste.rb +0 -60
  76. data/lib/takeltau/bit/clipboard/pull.rb +0 -37
  77. data/lib/takeltau/bit/clipboard/push.rb +0 -37
  78. data/lib/takeltau/bit/require/cli.rb +0 -57
  79. data/lib/takeltau/bit/require/export.rb +0 -34
  80. data/lib/takeltau/bit/require/import.rb +0 -133
  81. data/lib/takeltau/bit/require/lib.rb +0 -19
  82. data/lib/takeltau/bit/scope/add.rb +0 -55
  83. data/lib/takeltau/bit/scope/cli.rb +0 -74
  84. data/lib/takeltau/bit/scope/list.rb +0 -41
  85. data/lib/takeltau/bit/scope/new.rb +0 -44
  86. data/lib/takeltau/bit/scope/ssh.rb +0 -13
  87. data/lib/takeltau/git/check/bit.rb +0 -26
  88. data/lib/takeltau/init/packer/templates/bitrequireyml.tt +0 -13
  89. data/lib/takeltau/init/takelage/templates/bitrequireyml.tt +0 -5
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit require export
4
- module BitRequireExport
5
- # Backend method for bit require export.
6
- def bit_require_export
7
- log.debug 'Running bit require export'
8
-
9
- return false unless configured? %w[project_root_dir]
10
-
11
- components = _bit_require_lib_get_components
12
- bitrequire_yml = _bit_require_export_get_bitrequire_yml components
13
-
14
- log.debug "bitrequire.yml of this project:\n#{bitrequire_yml}"
15
- bitrequire_yml
16
- end
17
-
18
- private
19
-
20
- # Create contents of bitrequire yaml file.
21
- # rubocop:disable Metrics/AbcSize
22
- def _bit_require_export_get_bitrequire_yml(components)
23
- bitrequire = {}
24
- components.each do |component|
25
- scope = component['id'].clone.gsub!(%r{/.*}, '')
26
- name = component['id'].clone.gsub!(%r{#{scope}/}, '')
27
- bitrequire['scopes'] = { scope => [] } if bitrequire['scopes'].nil?
28
- bitrequire['scopes'][scope] = [] unless bitrequire['scopes'].key? scope
29
- bitrequire['scopes'][scope] << { 'name' => name }
30
- end
31
- hash_to_yaml bitrequire
32
- end
33
- # rubocop:enable Metrics/AbcSize
34
- end
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit require import
4
- module BitRequireImport
5
- # Backend method for bit require import.
6
- def bit_require_import
7
- log.debug 'Running bit require import'
8
-
9
- return false unless configured? %w[project_root_dir]
10
-
11
- return false unless _bit_clipboard_lib_prepare_workspace
12
-
13
- return false unless _bit_require_import_check_require_file_exists
14
-
15
- scopes = _bit_require_import_get_scopes_and_components
16
- return false unless scopes
17
-
18
- components = _bit_require_import_get_components scopes
19
- return false unless components
20
-
21
- return false unless _bit_require_import_add_scopes scopes
22
-
23
- _bit_require_import_paste_components components
24
- end
25
-
26
- private
27
-
28
- # Check if a bit requirements file exists.
29
- def _bit_require_import_check_require_file_exists
30
- return true if File.exist? @bit_require_file
31
-
32
- log.error "No #{@bit_require_file} file found"
33
- false
34
- end
35
-
36
- # Get scopes and components from requirements file.
37
- def _bit_require_import_get_scopes_and_components
38
- bit_require = read_yaml_file(@bit_require_file)
39
- return bit_require['scopes'] if bit_require.key?('scopes')
40
-
41
- log.error "No scopes in #{@bit_require_file} file"
42
- false
43
- end
44
-
45
- # Get flat components array.
46
- def _bit_require_import_get_components(scopes)
47
- components_all = []
48
- scopes.each do |scope, components|
49
- scope_components = _bit_require_import_get_scope_components scope, components
50
- return false unless scope_components
51
-
52
- components_all |= scope_components
53
- end
54
- components_all
55
- end
56
-
57
- # Get bit components of a scope.
58
- def _bit_require_import_get_scope_components(scope, components)
59
- scope_components = []
60
- components.each do |component|
61
- return false unless _bit_require_import_check_component_valid component, scope
62
-
63
- name = component['name']
64
- path = name
65
- path = component['path'] if component.key?('path')
66
- scope_components << { name: name, path: path, scope: scope }
67
- log.debug "Identified bit component \"#{name}\" with path \"#{path}\" in scope \"#{scope}\""
68
- end
69
- scope_components
70
- end
71
-
72
- # Check if there are bit components
73
- def _bit_require_import_check_component_valid(component, scope)
74
- return true if component.instance_of?(Hash) && component.key?('name')
75
-
76
- log.error "No component in #{scope}"
77
- false
78
- end
79
-
80
- # Add bit scopes to workspace.
81
- def _bit_require_import_add_scopes(scopes)
82
- scopes.each do |scope, _components|
83
- bit_scope_add scope unless _bit_clipboard_bit_dev_scope_exists scope
84
- end
85
- end
86
-
87
- # Paste bit components.
88
- def _bit_require_import_paste_components(components)
89
- path = config.active['project_root_dir']
90
- return false if path.empty?
91
-
92
- components.each do |component|
93
- next if _bit_require_import_check_component_exists component, path
94
-
95
- return false unless _bit_require_import_paste_component component
96
-
97
- _bit_require_import_commit_component component, path
98
- end
99
- true
100
- end
101
-
102
- # Check if there are bit components
103
- def _bit_require_import_check_component_exists(component, path)
104
- scope = component[:scope]
105
- cid = component[:name]
106
- dir = component[:path]
107
- dest = "#{path}/#{dir}"
108
- cids = _bit_require_lib_get_components_ids
109
- return false unless cids.include? "#{scope}/#{cid}"
110
-
111
- log.warn "Skipping existing bit component \"#{scope}/#{cid}\" with path \"#{dest}\""
112
- true
113
- end
114
-
115
- # Paste a bit component
116
- def _bit_require_import_paste_component(component)
117
- scope = component[:scope]
118
- cid = component[:name]
119
- dir = component[:path]
120
- bit_clipboard_paste "#{scope}/#{cid}", dir
121
- end
122
-
123
- # Commit a bit component
124
- def _bit_require_import_commit_component(component, path)
125
- scope = component[:scope]
126
- cid = component[:name]
127
- dir = component[:path]
128
- dest = "#{path}/#{dir}"
129
- message = "Add bit component \"#{scope}/#{cid}\" to path \"#{dest}\""
130
- _bit_clipboard_lib_git_add dest
131
- _bit_clipboard_lib_git_commit message
132
- end
133
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit require lib
4
- module BitRequireLib
5
- private
6
-
7
- # Get bit components.
8
- def _bit_require_lib_get_components
9
- cmd_bit_list = config.active['cmd_bit_require_lib_bit_list']
10
- bit_list = run cmd_bit_list
11
- JSON.parse bit_list
12
- end
13
-
14
- # Get bit components ids.
15
- def _bit_require_lib_get_components_ids
16
- cmd_bit_list_ids = config.active['cmd_bit_require_lib_bit_list_ids']
17
- run cmd_bit_list_ids
18
- end
19
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit scope add
4
- module BitScopeAdd
5
- # Backend method for bit scope add.
6
- def bit_scope_add(scope)
7
- log.debug "Adding bit remote scope \"#{scope}\" to local workspace"
8
-
9
- return false unless configured? %w[bit_ssh bit_remote]
10
-
11
- return false unless _bit_scope_add_workspace_ready?
12
-
13
- return false unless _bit_scope_add_scope_exists? scope
14
-
15
- run _bit_scope_add_cmd scope
16
-
17
- log.info "Added bit remote scope \"#{scope}\" to local bit workspace"
18
- end
19
-
20
- private
21
-
22
- # Check if workspace ready for bit scope add.
23
- def _bit_scope_add_workspace_ready?
24
- unless bit_check_workspace
25
- log.error 'No bit workspace'
26
- return false
27
- end
28
-
29
- return true unless git_check_workspace
30
-
31
- return true if git_check_bit
32
-
33
- log.error 'Not on git main branch'
34
- false
35
- end
36
-
37
- # Check if bit remote scope exists.
38
- def _bit_scope_add_scope_exists?(scope)
39
- return true if bit_scope_list.include? scope
40
-
41
- log.error "The bit remote bit scope \"#{scope}\" doesn't exist"
42
- false
43
- end
44
-
45
- # Prepare bit add scope command.
46
- def _bit_scope_add_cmd(scope)
47
- remote = config.active['bit_remote']
48
-
49
- format(
50
- config.active['cmd_bit_scope_add_scope'],
51
- remote: remote,
52
- scope: scope
53
- )
54
- end
55
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Takeltau
4
- # takeltau bit scope
5
- class BitScope < SubCommandBase
6
- include LoggingModule
7
- include SystemModule
8
- include ConfigModule
9
- include GitCheckBit
10
- include GitCheckWorkspace
11
- include BitCheckWorkspace
12
- include BitScopeAdd
13
- include BitScopeSSH
14
- include BitScopeList
15
- include BitScopeNew
16
-
17
- #
18
- # bit scope add
19
- #
20
- desc 'add [SCOPE]', 'Add a bit [SCOPE]'
21
- long_desc <<-LONGDESC.gsub("\n", "\x5")
22
- Add bit remote scope
23
- This command will add a bit remote scope to a local bit workspace.
24
- The scope must exist on the bit remote server.
25
- LONGDESC
26
- # Add bit remote scope.
27
- def add(scope)
28
- exit bit_scope_add scope
29
- end
30
-
31
- #
32
- # bit scope new
33
- #
34
- desc 'new [SCOPE]', 'Init a new bit [SCOPE]'
35
- long_desc <<-LONGDESC.gsub("\n", "\x5")
36
- Create new bit remote scope
37
- This command will create a new directory on the remote bit server.
38
- Then it will run "bit init --bare" in the newly created directory.
39
- See the bit documentation: http://docs.bit.dev/docs/bit-server
40
- LONGDESC
41
- # Create new bit remote scope.
42
- def new(scope)
43
- exit bit_scope_new scope
44
- end
45
-
46
- #
47
- # bit scope list
48
- #
49
- desc 'list', 'List bit remote scopes'
50
- long_desc <<-LONGDESC.gsub("\n", "\x5")
51
- List bit remote scopes
52
- This command will list bit remote scopes.
53
- LONGDESC
54
- # List bit remote scopes.
55
- def list
56
- scopes = bit_scope_list
57
- exit false if scopes == false
58
- say scopes unless scopes.to_s.chomp.empty?
59
- true
60
- end
61
-
62
- #
63
- # bit scope ssh
64
- #
65
- desc 'ssh', 'Log in to bit remote server'
66
- long_desc <<-LONGDESC.gsub("\n", "\x5")
67
- Log in to bit remote server
68
- LONGDESC
69
- # Log in to bit remote server.
70
- def ssh
71
- exit bit_scope_ssh
72
- end
73
- end
74
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit scope list
4
- module BitScopeList
5
- # Backend method for bit scope list.
6
- # @return [String] list of bit scopes
7
- def bit_scope_list
8
- log.debug 'Listing bit remote scopes'
9
-
10
- return false unless configured? %w[bit_ssh bit_remote]
11
-
12
- # get ssh command from active config.
13
- cmd_bit_ssh =
14
- config.active['bit_ssh']
15
-
16
- root = config.active['bit_root']
17
-
18
- cmd_bit_scope_list = _bit_scope_list_cmd root
19
-
20
- # run ssh command with scope list command.
21
- scope_list = run "#{cmd_bit_ssh} '#{cmd_bit_scope_list}'"
22
-
23
- # remove bit remote root directory from results
24
- scope_list.gsub!(%r{#{root}/*}, '')
25
-
26
- # remove /scope.json from results
27
- scope_list.gsub!(%r{/scope.json}, '')
28
-
29
- scope_list
30
- end
31
-
32
- private
33
-
34
- # Prepare bit scope list command.
35
- def _bit_scope_list_cmd(root)
36
- format(
37
- config.active['cmd_bit_scope_list_find_scopes'],
38
- root: root
39
- )
40
- end
41
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit scope new
4
- module BitScopeNew
5
- # Backend method for bit scope new.
6
- # @return [Int] status of new command
7
- def bit_scope_new(scope)
8
- log.debug "Creating new bit remote scope \"#{scope}\""
9
-
10
- return false unless configured? %w[bit_ssh bit_remote]
11
-
12
- return false if _bit_scope_new_scope_exists? scope
13
-
14
- cmd_bit_ssh = config.active['bit_ssh']
15
-
16
- cmd_bit_scope_new = _bit_scope_new_cmd scope
17
-
18
- run "#{cmd_bit_ssh} '#{cmd_bit_scope_new}'"
19
-
20
- log.info "Created new bit remote scope \"#{scope}\""
21
- end
22
-
23
- private
24
-
25
- # Check if bit scope already exists.
26
- def _bit_scope_new_scope_exists?(scope)
27
- scope_list = bit_scope_list
28
- return false unless scope_list.include? scope
29
-
30
- log.error "The remote bit scope \"#{scope}\" already exists"
31
- false
32
- end
33
-
34
- # Prepare bit scope new command.
35
- def _bit_scope_new_cmd(scope)
36
- root = config.active['bit_root']
37
-
38
- format(
39
- config.active['cmd_bit_scope_new_bit_init'],
40
- scope: scope,
41
- root: root
42
- )
43
- end
44
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit scope ssh
4
- module BitScopeSSH
5
- # Backend method for bit scope ssh.
6
- def bit_scope_ssh
7
- log.debug 'Logging in to bit remote server'
8
-
9
- return false unless configured? %w[bit_ssh]
10
-
11
- run_and_exit config.active['bit_ssh']
12
- end
13
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau git check bit
4
- module GitCheckBit
5
- # Backend method for git check bit.
6
- # @return [Boolean] are we on the git bit branch?
7
- def git_check_bit
8
- log.debug 'Check if we are on the git bit branch'
9
-
10
- return false unless git_check_workspace
11
-
12
- branch = _git_check_bit_get_branch
13
- log.debug "We are on git branch \"#{branch}\""
14
-
15
- branch == config.active['git_bit_branch']
16
- end
17
-
18
- private
19
-
20
- # Get git branch.
21
- def _git_check_bit_get_branch
22
- cmd_get_branch =
23
- config.active['cmd_git_check_bit_get_git_branch']
24
- (run cmd_get_branch).chomp.split('/')[-1]
25
- end
26
- end
@@ -1,13 +0,0 @@
1
- ---
2
- scopes:
3
- takelage.ansible:
4
- - name: ansible/molecule/default
5
- - name: ansible/molecule/image
6
- - name: ansible/roles/takel-cleanup
7
- takelage.packer:
8
- - name: packer/templates/takelage/docker
9
- takelage.rake:
10
- - name: rake/ansible
11
- - name: rake/images
12
- - name: rake/meta
13
- - name: rake/rubylint
@@ -1,5 +0,0 @@
1
- ---
2
- scopes:
3
- takelage.rake:
4
- - name: rake/meta
5
- - name: rake/rubylint