takeltau 0.34.9

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.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/README.md +235 -0
  4. data/bin/tau +6 -0
  5. data/lib/Thorfile +3 -0
  6. data/lib/takeltau.rb +257 -0
  7. data/lib/takeltau/bit/check/cli.rb +23 -0
  8. data/lib/takeltau/bit/check/workspace.rb +37 -0
  9. data/lib/takeltau/bit/cli.rb +18 -0
  10. data/lib/takeltau/bit/clipboard/cli.rb +73 -0
  11. data/lib/takeltau/bit/clipboard/copy.rb +142 -0
  12. data/lib/takeltau/bit/clipboard/lib.rb +143 -0
  13. data/lib/takeltau/bit/clipboard/paste.rb +60 -0
  14. data/lib/takeltau/bit/clipboard/pull.rb +37 -0
  15. data/lib/takeltau/bit/clipboard/push.rb +37 -0
  16. data/lib/takeltau/bit/require/cli.rb +57 -0
  17. data/lib/takeltau/bit/require/export.rb +34 -0
  18. data/lib/takeltau/bit/require/import.rb +133 -0
  19. data/lib/takeltau/bit/require/lib.rb +19 -0
  20. data/lib/takeltau/bit/scope/add.rb +55 -0
  21. data/lib/takeltau/bit/scope/cli.rb +74 -0
  22. data/lib/takeltau/bit/scope/list.rb +41 -0
  23. data/lib/takeltau/bit/scope/new.rb +44 -0
  24. data/lib/takeltau/bit/scope/ssh.rb +13 -0
  25. data/lib/takeltau/completion/cli.rb +24 -0
  26. data/lib/takeltau/default.yml +95 -0
  27. data/lib/takeltau/docker/check/cli.rb +23 -0
  28. data/lib/takeltau/docker/check/daemon.rb +27 -0
  29. data/lib/takeltau/docker/cli.rb +15 -0
  30. data/lib/takeltau/docker/container/check/cli.rb +57 -0
  31. data/lib/takeltau/docker/container/check/existing.rb +32 -0
  32. data/lib/takeltau/docker/container/check/network.rb +32 -0
  33. data/lib/takeltau/docker/container/check/orphaned.rb +32 -0
  34. data/lib/takeltau/docker/container/clean.rb +40 -0
  35. data/lib/takeltau/docker/container/cli.rb +118 -0
  36. data/lib/takeltau/docker/container/command.rb +38 -0
  37. data/lib/takeltau/docker/container/daemon.rb +17 -0
  38. data/lib/takeltau/docker/container/lib.rb +181 -0
  39. data/lib/takeltau/docker/container/login.rb +58 -0
  40. data/lib/takeltau/docker/container/prune.rb +31 -0
  41. data/lib/takeltau/docker/image/cli.rb +39 -0
  42. data/lib/takeltau/docker/image/tag/check.rb +42 -0
  43. data/lib/takeltau/docker/image/tag/cli.rb +68 -0
  44. data/lib/takeltau/docker/image/tag/latest.rb +24 -0
  45. data/lib/takeltau/docker/image/tag/list.rb +19 -0
  46. data/lib/takeltau/docker/image/update.rb +27 -0
  47. data/lib/takeltau/git/check/bit.rb +26 -0
  48. data/lib/takeltau/git/check/clean.rb +46 -0
  49. data/lib/takeltau/git/check/cli.rb +49 -0
  50. data/lib/takeltau/git/check/workspace.rb +34 -0
  51. data/lib/takeltau/git/cli.rb +9 -0
  52. data/lib/takeltau/info/cli.rb +12 -0
  53. data/lib/takeltau/info/project/cli.rb +69 -0
  54. data/lib/takeltau/info/status/bar.rb +112 -0
  55. data/lib/takeltau/info/status/cli.rb +107 -0
  56. data/lib/takeltau/info/status/git.rb +47 -0
  57. data/lib/takeltau/info/status/gopass.rb +37 -0
  58. data/lib/takeltau/info/status/gpg.rb +39 -0
  59. data/lib/takeltau/info/status/lib.rb +46 -0
  60. data/lib/takeltau/info/status/ssh.rb +46 -0
  61. data/lib/takeltau/init/cli.rb +12 -0
  62. data/lib/takeltau/init/lib.rb +86 -0
  63. data/lib/takeltau/init/packer/cli.rb +82 -0
  64. data/lib/takeltau/init/packer/docker.rb +64 -0
  65. data/lib/takeltau/init/packer/templates/ansiblelint.tt +3 -0
  66. data/lib/takeltau/init/packer/templates/bitrequireyml.tt +13 -0
  67. data/lib/takeltau/init/packer/templates/groupvarsprojectyml.tt +2 -0
  68. data/lib/takeltau/init/packer/templates/playbooksiteyml.tt +6 -0
  69. data/lib/takeltau/init/packer/templates/projectyml.tt +19 -0
  70. data/lib/takeltau/init/takelage/cli.rb +70 -0
  71. data/lib/takeltau/init/takelage/rake.rb +61 -0
  72. data/lib/takeltau/init/takelage/templates/bitrequireyml.tt +5 -0
  73. data/lib/takeltau/init/takelage/templates/projectyml.tt +3 -0
  74. data/lib/takeltau/init/templates/Rakefile.tt +3 -0
  75. data/lib/takeltau/init/templates/gitignore.tt +16 -0
  76. data/lib/takeltau/lib/config.rb +130 -0
  77. data/lib/takeltau/lib/logging.rb +49 -0
  78. data/lib/takeltau/lib/project.rb +72 -0
  79. data/lib/takeltau/lib/subcmd.rb +18 -0
  80. data/lib/takeltau/lib/system.rb +194 -0
  81. data/lib/takeltau/mutagen/check/cli.rb +40 -0
  82. data/lib/takeltau/mutagen/check/daemon.rb +76 -0
  83. data/lib/takeltau/mutagen/cli.rb +12 -0
  84. data/lib/takeltau/mutagen/socket/check.rb +33 -0
  85. data/lib/takeltau/mutagen/socket/cli.rb +103 -0
  86. data/lib/takeltau/mutagen/socket/create.rb +47 -0
  87. data/lib/takeltau/mutagen/socket/list.rb +33 -0
  88. data/lib/takeltau/mutagen/socket/terminate.rb +32 -0
  89. data/lib/takeltau/mutagen/socket/tidy.rb +21 -0
  90. data/lib/takeltau/self/cli.rb +43 -0
  91. data/lib/takeltau/self/config/cli.rb +82 -0
  92. data/lib/takeltau/self/list.rb +35 -0
  93. data/lib/takeltau/version +1 -0
  94. metadata +319 -0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau bit clipboard pull
4
+ module BitClipboardPull
5
+ # Backend method for bit pull.
6
+ def bit_clipboard_pull
7
+ log.debug 'Running bit pull'
8
+
9
+ return false unless configured? %w[project_root_dir]
10
+
11
+ return false unless _bit_clipboard_lib_prepare_workspace
12
+
13
+ _bit_clipboard_pull_import_all
14
+ _bit_clipboard_pull_checkout_all
15
+ _bit_clipbpard_lib_remove_bit_artifacts
16
+ _bit_clipboard_lib_sync_workspace
17
+ _bit_clipboard_lib_bit_status
18
+ end
19
+
20
+ private
21
+
22
+ # bit import components into workspace.
23
+ def _bit_clipboard_pull_import_all
24
+ cmd_bit_import_all =
25
+ config.active['cmd_bit_clipboard_pull_bit_import_all']
26
+
27
+ run cmd_bit_import_all
28
+ end
29
+
30
+ # Checkout components and merge them.
31
+ def _bit_clipboard_pull_checkout_all
32
+ cmd_bit_checkout_all =
33
+ config.active['cmd_bit_clipboard_pull_bit_checkout_all']
34
+
35
+ run cmd_bit_checkout_all
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau bit clipboard push
4
+ module BitClipboardPush
5
+ # Backend method for bit push.
6
+ def bit_clipboard_push
7
+ log.debug 'Running bit push'
8
+
9
+ return false unless configured? %w[project_root_dir]
10
+
11
+ return false unless _bit_clipboard_lib_prepare_workspace
12
+
13
+ _bit_clipboard_push_tag_all
14
+ _bit_clipboard_push_export_all
15
+ _bit_clipbpard_lib_remove_bit_artifacts
16
+ _bit_clipboard_lib_sync_workspace
17
+ _bit_clipboard_lib_bit_status
18
+ end
19
+
20
+ private
21
+
22
+ # bit tag all components.
23
+ def _bit_clipboard_push_tag_all
24
+ cmd_bit_tag_all =
25
+ config.active['cmd_bit_clipboard_push_bit_tag_all']
26
+
27
+ run cmd_bit_tag_all
28
+ end
29
+
30
+ # bit export components.
31
+ def _bit_clipboard_push_export_all
32
+ cmd_bit_export_all =
33
+ config.active['cmd_bit_clipboard_push_bit_export_all']
34
+
35
+ run cmd_bit_export_all
36
+ end
37
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takeltau
4
+ # takeltau bit requiere
5
+ class BitRequire < SubCommandBase
6
+ include LoggingModule
7
+ include ConfigModule
8
+ include SystemModule
9
+ include GitCheckClean
10
+ include GitCheckBit
11
+ include GitCheckWorkspace
12
+ include BitCheckWorkspace
13
+ include BitScopeList
14
+ include BitScopeAdd
15
+ include BitClipboardLib
16
+ include BitClipboardCopy
17
+ include BitClipboardPaste
18
+ include BitRequireLib
19
+ include BitRequireExport
20
+ include BitRequireImport
21
+
22
+ # Initialize bit require
23
+ def initialize(args = [], local_options = {}, configuration = {})
24
+ # initialize thor parent class
25
+ super args, local_options, configuration
26
+
27
+ @bit_require_file = config.active['bit_require_file']
28
+ end
29
+
30
+ #
31
+ # bit require export
32
+ #
33
+ desc 'export', 'Create requirements file with bit components.'
34
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
35
+ Create requirements file with bit components
36
+ LONGDESC
37
+ # Create requirements file with bit components.
38
+ def export
39
+ bit_require_yml = bit_require_export
40
+ exit false if bit_require_yml == false
41
+ say bit_require_yml
42
+ true
43
+ end
44
+
45
+ #
46
+ # bit require import
47
+ #
48
+ desc 'import', 'Import bit components from requirements file.'
49
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
50
+ Import bit components from requirements file
51
+ LONGDESC
52
+ # Import bit components from requirements file.
53
+ def import
54
+ exit bit_require_import
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,133 @@
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
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,55 @@
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
@@ -0,0 +1,74 @@
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