takelage 0.20.1 → 0.22.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d318a7c4c17c6319e50997f41934e44a39fb6fddd58c66f8f1da168a5e21d54
4
- data.tar.gz: f56501c87c2044f41e9b7f66473aeb3c1244a1b6ec983b4853d7e2565b65f4e4
3
+ metadata.gz: 240831f6c4308e8336a2d476a4ff3f5b728804e7e03d4e1463c9262fff7d2b56
4
+ data.tar.gz: 85d29bb364dbaf5758f51813a1f6388c9ad6babd417da65d30b6907283147c9f
5
5
  SHA512:
6
- metadata.gz: 2450ffc17a6e8efe1e8bc3195136253bce595f91e098018e890d5e182fe837beb98d6dbba3a3d22c0f3e2db3d58b4104213042d3898c4e457e53f6076860e04d
7
- data.tar.gz: 301cbb253cc736a39264476385e595f4b0c07f9dbcecec3a39325176c964a6ec51f582d2acf29cdfb90ead7fec3f586e136f2850918349db9d82e86e7b18af6f
6
+ metadata.gz: cfa4649517e1818407361da9e3a17832cb010dbcc6d79139e05e95f355838ae175f09b5959b338972b7953b1a11d8fdf04b31b21f8c7c6451026b93837cd1c55
7
+ data.tar.gz: ad5526d627c8cdb72d21936de73c8990782eb85f908ed405eab683bcc67b8e03dab564891636d919ab65c2cf4cce1d329efc4f28e8bd192d2ce2d60b64d15046
data/README.md CHANGED
@@ -42,68 +42,68 @@ You are encouraged to read the cucumber feature files
42
42
  for the *tau* commands
43
43
  to get an idea of how the commands work.
44
44
  You can list the *tau* commands by running
45
- *tau [self list](features/takelage/self/self.list.feature)*
45
+ *tau [self list](features/cucumber/features/self/self.list.feature)*
46
46
  or *tau list*:
47
47
 
48
48
  Command | Description
49
49
  ------- | -----------
50
- tau [bit check workspace](features/takelage/bit/bit.check.workspace.feature) | Check if a bit workspace exists
51
- tau [bit clipboard copy](features/takelage/bit/bit.clipboard.copy.feature) [DIR] [SCOPE] | Copy new [DIR] to [SCOPE]
52
- tau [bit clipboard paste](features/takelage/bit/bit.clipboard.paste.feature) [COMPONENT] [DIR] | Paste bit [COMPONENT] into [DIR]
53
- tau [bit clipboard pull](features/takelage/bit/bit.clipboard.pull.feature) | Pull all updates for bit components from bit remote scopes
54
- tau [bit clipboard push](features/takelage/bit/bit.clipboard.push.feature) | Push all updates of bit components to bit remote scopes
55
- tau [bit require export](features/takelage/bit/bit.require.export.feature) | Show requirements file of bit components
56
- tau [bit require import](features/takelage/bit/bit.require.import.feature) | Import bit components from requirements file
57
- tau [bit scope add](features/takelage/bit/bit.scope.add.feature) [SCOPE] | Add a bit [SCOPE]
58
- tau [bit scope inbit](features/takelage/bit/bit.scope.inbit.feature) | Log in to bit remote server
59
- tau [bit scope list](features/takelage/bit/bit.scope.list.feature) | List bit remote scopes
60
- tau [bit scope new](features/takelage/bit/bit.scope.new.feature) [SCOPE] | Init a new bit [SCOPE]
61
- tau [completion bash](features/takelage/completion/completion.bash.feature) | Print bash completion code
62
- tau [docker check running](features/takelage/docker/docker.check.running.feature) | Check if docker daemon is running
63
- tau [docker container check existing](features/takelage/docker/docker.container.check.existing.feature) [CONTAINER] | Check if docker [CONTAINER] is existing
64
- tau [docker container check network](features/takelage/docker/docker.container.check.network.feature) [NETWORK] | Check if docker [NETWORK] is existing
65
- tau [docker container check orphaned](features/takelage/docker/docker.container.check.orphaned.feature) [CONTAINER] | Check if docker [CONTAINER] is orphaned
66
- tau [docker container command](features/takelage/docker/docker.container.command.feature) [CMD] | Run [CMD] in a docker container
67
- tau [docker container daemon](features/takelage/docker/docker.container.daemon.feature) | Run docker container in daemon mode
68
- tau [docker container login](features/takelage/docker/docker.container.login.feature) | Log in to latest local docker container
69
- tau [docker container clean](features/takelage/docker/docker.container.clean.feature) | Remove all docker containers
70
- tau [docker container prune](features/takelage/docker/docker.container.prune.feature) | Remove orphaned docker containers
71
- tau [docker image check outdated](features/takelage/docker/docker.image.check.outdated.feature) | Check if a docker image is outdated
72
- tau [docker image tag check local](features/takelage/docker/docker.image.tag.check.local.feature) [TAG] | Check if local docker image [TAG] exists
73
- tau [docker image tag check remote](features/takelage/docker/docker.image.tag.check.remote.feature) [TAG] | Check if remote docker image [TAG] exists
74
- tau [docker image tag latest local](features/takelage/docker/docker.image.tag.latest.local.feature) | Print latest local docker image tag
75
- tau [docker image tag latest remote](features/takelage/docker/docker.image.tag.latest.remote.feature) | Print latest remote docker image tag
76
- tau [docker image tag list local](features/takelage/docker/docker.image.tag.list.local.feature) | Print local docker image tags
77
- tau [docker image tag list remote](features/takelage/docker/docker.image.tag.list.remote.feature) | Print remote docker image tags
78
- tau [docker image update](features/takelage/docker/docker.image.update.feature) | Get latest remote docker container
79
- tau [docker socket host](features/takelage/docker/docker.socket.host.feature) | Print docker socket host ip address
80
- tau [docker socket scheme](features/takelage/docker/docker.socket.scheme.feature) | Print docker socket scheme
81
- tau [docker socket start](features/takelage/docker/docker.socket.start.feature) | Start sockets for docker container
82
- tau [docker socket stop](features/takelage/docker/docker.socket.stop.feature) | Stop sockets for docker container
83
- tau [git check clean](features/takelage/git/git.check.clean.feature) | Check if the git workspace is clean
84
- tau [git check master](features/takelage/git/git.check.master.feature) | Check if we are on the git master branch
85
- tau [git check workspace](features/takelage/git/git.check.workspace.feature) | Check if a git workspace exists
86
- tau [info project active](features/takelage/info/info.project.active.feature) | Print active project info
87
- tau [info project main](features/takelage/info/info.project.main.feature) | Print main project info
88
- tau [info project private](features/takelage/info/info.project.private.feature) | Print private project info
89
- tau [self config active](features/takelage/self/self.config.active.feature) | Print active takelage configuration
90
- tau [self config default](features/takelage/self/self.config.default.feature) | Print takelage default configuration
91
- tau [self config home](features/takelage/self/self.config.home.feature) | Print takelage home config file configuration
92
- tau [self config project](features/takelage/self/self.config.project.feature) | Print takelage project config file configuration
93
- tau [self list](features/takelage/self/self.list.feature) | List all commands
94
- tau [self version](features/takelage/self/self.version.feature) | Print tau semantic version number
95
- tau config | Alias for tau [self config active](features/takelage/self/self.config.active.feature)
96
- tau copy [DIR] [SCOPE] | Alias for tau [bit clipboard copy](features/takelage/bit/bit.clipboard.copy.feature)
97
- tau list | Alias for tau [self list](features/takelage/self/self.list.feature)
98
- tau login | Alias for tau [docker container login](features/takelage/docker/docker.container.login.feature)
99
- tau clean | Alias for tau [docker container clean](features/takelage/docker/docker.container.clean.feature)
100
- tau paste [COMPONENT] [DIR] | Alias for tau [bit clipboard paste](features/takelage/bit/bit.clipboard.paste.feature)
101
- tau project | Alias for tau [info project active](features/takelage/info/info.project.active.feature)
102
- tau pull | Alias for tau [bit clipboard pull](features/takelage/bit/bit.clipboard.pull.feature)
103
- tau prune | Alias for tau [docker container prune](features/takelage/docker/docker.container.prune.feature)
104
- tau push | Alias for tau [bit clipboard push](features/takelage/bit/bit.clipboard.push.feature)
105
- tau update | Alias for tau [docker image update](features/takelage/docker/docker.image.update.feature)
106
- tau version | Alias for tau [self version](features/takelage/self/self.version.feature)
50
+ tau [bit check workspace](features/cucumber/features/bit/bit.check.workspace.feature) | Check if a bit workspace exists
51
+ tau [bit clipboard copy](features/cucumber/features/bit/bit.clipboard.copy.feature) [DIR] [SCOPE] | Copy new [DIR] to [SCOPE]
52
+ tau [bit clipboard paste](features/cucumber/features/bit/bit.clipboard.paste.feature) [COMPONENT] [DIR] | Paste bit [COMPONENT] into [DIR]
53
+ tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature) | Pull all updates for bit components from bit remote scopes
54
+ tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature) | Push all updates of bit components to bit remote scopes
55
+ tau [bit require export](features/cucumber/features/bit/bit.require.export.feature) | Show requirements file of bit components
56
+ tau [bit require import](features/cucumber/features/bit/bit.require.import.feature) | Import bit components from requirements file
57
+ tau [bit scope add](features/cucumber/features/bit/bit.scope.add.feature) [SCOPE] | Add a bit [SCOPE]
58
+ tau [bit scope inbit](features/cucumber/features/bit/bit.scope.inbit.feature) | Log in to bit remote server
59
+ tau [bit scope list](features/cucumber/features/bit/bit.scope.list.feature) | List bit remote scopes
60
+ tau [bit scope new](features/cucumber/features/bit/bit.scope.new.feature) [SCOPE] | Init a new bit [SCOPE]
61
+ tau [completion bash](features/cucumber/features/completion/completion.bash.feature) | Print bash completion code
62
+ tau [docker check running](features/cucumber/features/docker/docker.check.running.feature) | Check if docker daemon is running
63
+ tau [docker container check existing](features/cucumber/features/docker/docker.container.check.existing.feature) [CONTAINER] | Check if docker [CONTAINER] is existing
64
+ tau [docker container check network](features/cucumber/features/docker/docker.container.check.network.feature) [NETWORK] | Check if docker [NETWORK] is existing
65
+ tau [docker container check orphaned](features/cucumber/features/docker/docker.container.check.orphaned.feature) [CONTAINER] | Check if docker [CONTAINER] is orphaned
66
+ tau [docker container command](features/cucumber/features/docker/docker.container.command.feature) [CMD] | Run [CMD] in a docker container
67
+ tau [docker container daemon](features/cucumber/features/docker/docker.container.daemon.feature) | Run docker container in daemon mode
68
+ tau [docker container login](features/cucumber/features/docker/docker.container.login.feature) | Log in to latest local docker container
69
+ tau [docker container clean](features/cucumber/features/docker/docker.container.clean.feature) | Remove all docker containers
70
+ tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature) | Remove orphaned docker containers
71
+ tau [docker image check outdated](features/cucumber/features/docker/docker.image.check.outdated.feature) | Check if a docker image is outdated
72
+ tau [docker image tag check local](features/cucumber/features/docker/docker.image.tag.check.local.feature) [TAG] | Check if local docker image [TAG] exists
73
+ tau [docker image tag check remote](features/cucumber/features/docker/docker.image.tag.check.remote.feature) [TAG] | Check if remote docker image [TAG] exists
74
+ tau [docker image tag latest local](features/cucumber/features/docker/docker.image.tag.latest.local.feature) | Print latest local docker image tag
75
+ tau [docker image tag latest remote](features/cucumber/features/docker/docker.image.tag.latest.remote.feature) | Print latest remote docker image tag
76
+ tau [docker image tag list local](features/cucumber/features/docker/docker.image.tag.list.local.feature) | Print local docker image tags
77
+ tau [docker image tag list remote](features/cucumber/features/docker/docker.image.tag.list.remote.feature) | Print remote docker image tags
78
+ tau [docker image update](features/cucumber/features/docker/docker.image.update.feature) | Get latest remote docker container
79
+ tau [docker socket host](features/cucumber/features/docker/docker.socket.host.feature) | Print docker socket host ip address
80
+ tau [docker socket scheme](features/cucumber/features/docker/docker.socket.scheme.feature) | Print docker socket scheme
81
+ tau [docker socket start](features/cucumber/features/docker/docker.socket.start.feature) | Start sockets for docker container
82
+ tau [docker socket stop](features/cucumber/features/docker/docker.socket.stop.feature) | Stop sockets for docker container
83
+ tau [git check clean](features/cucumber/features/git/git.check.clean.feature) | Check if the git workspace is clean
84
+ tau [git check main](features/cucumber/features/git/git.check.main.feature) | Check if we are on the git main branch
85
+ tau [git check workspace](features/cucumber/features/git/git.check.workspace.feature) | Check if a git workspace exists
86
+ tau [info project active](features/cucumber/features/info/info.project.active.feature) | Print active project info
87
+ tau [info project main](features/cucumber/features/info/info.project.main.feature) | Print main project info
88
+ tau [info project private](features/cucumber/features/info/info.project.private.feature) | Print private project info
89
+ tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
90
+ tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
91
+ tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
92
+ tau [self config project](features/cucumber/features/self/self.config.project.feature) | Print takelage project config file configuration
93
+ tau [self list](features/cucumber/features/self/self.list.feature) | List all commands
94
+ tau [self version](features/cucumber/features/self/self.version.feature) | Print tau semantic version number
95
+ tau config | Alias for tau [self config active](features/cucumber/features/self/self.config.active.feature)
96
+ tau copy [DIR] [SCOPE] | Alias for tau [bit clipboard copy](features/cucumber/features/bit/bit.clipboard.copy.feature)
97
+ tau list | Alias for tau [self list](features/cucumber/features/self/self.list.feature)
98
+ tau login | Alias for tau [docker container login](features/cucumber/features/docker/docker.container.login.feature)
99
+ tau clean | Alias for tau [docker container clean](features/cucumber/features/docker/docker.container.clean.feature)
100
+ tau paste [COMPONENT] [DIR] | Alias for tau [bit clipboard paste](features/cucumber/features/bit/bit.clipboard.paste.feature)
101
+ tau project | Alias for tau [info project active](features/cucumber/features/info/info.project.active.feature)
102
+ tau pull | Alias for tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature)
103
+ tau prune | Alias for tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature)
104
+ tau push | Alias for tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature)
105
+ tau update | Alias for tau [docker image update](features/cucumber/features/docker/docker.image.update.feature)
106
+ tau version | Alias for tau [self version](features/cucumber/features/self/self.version.feature)
107
107
 
108
108
  **Warning: *tau update* will call *docker image prune* and remove all dangling images!**
109
109
 
@@ -115,7 +115,7 @@ tau version | Alias for tau [self version](features/takelage/self/self.version.f
115
115
  which have different precedences.
116
116
  They are merged to an active configuration during runtime
117
117
  which can be inspected with
118
- *tau [self config active](features/takelage/self/self.config.active.feature)*
118
+ *tau [self config active](features/cucumber/features/self/self.config.active.feature)*
119
119
  or *tau config*.
120
120
 
121
121
  | Filename | Precedence | Description |
@@ -168,7 +168,7 @@ Furthermore, every external command can be reconfigured.
168
168
  which have different precedences.
169
169
  They are merged to an active configuration during runtime
170
170
  which can be inspected with
171
- *tau [info project active](features/takelage/info/info.project.active.feature)*
171
+ *tau [info project active](features/cucumber/features/info/info.project.active.feature)*
172
172
  or *tau project*.
173
173
 
174
174
  | Default filename | Config key | Precedence | Description |
@@ -186,8 +186,11 @@ source <(tau completion bash)
186
186
 
187
187
  ### Software Tests
188
188
 
189
+ *takelage-cli* uses
190
+ [minitest](https://github.com/seattlerb/minitest) unit tests.
191
+
189
192
  *takelage-cli* ships with
190
- [cucumber](https://github.com/cucumber/cucumber) ruby tests.
193
+ [cucumber](https://github.com/cucumber/cucumber) ruby system tests.
191
194
  It uses cucumber's
192
195
  [aruba](https://github.com/cucumber/aruba) extension and especially its
193
196
  [filesystem](https://relishapp.com/cucumber/aruba/v/0-11-0/docs/filesystem)
@@ -21,7 +21,7 @@ require_relative 'takelage/lib/config'
21
21
  require_relative 'takelage/lib/project'
22
22
 
23
23
  require_relative 'takelage/git/check/clean'
24
- require_relative 'takelage/git/check/master'
24
+ require_relative 'takelage/git/check/main'
25
25
  require_relative 'takelage/git/check/workspace'
26
26
  require_relative 'takelage/git/check/cli'
27
27
  require_relative 'takelage/git/cli'
@@ -7,7 +7,7 @@ module Takelage
7
7
  include ConfigModule
8
8
  include SystemModule
9
9
  include GitCheckClean
10
- include GitCheckMaster
10
+ include GitCheckMain
11
11
  include GitCheckWorkspace
12
12
  include BitCheckWorkspace
13
13
  include BitClipboardLib
@@ -9,6 +9,8 @@ module BitClipboardCopy
9
9
 
10
10
  log.debug "Running bit copy \"#{dir}\" to \"#{scope}\""
11
11
 
12
+ return false unless configured? %w[project_root_dir]
13
+
12
14
  return false unless _bit_clipboard_lib_prepare_workspace
13
15
 
14
16
  unless File.directory? dir
@@ -69,7 +71,7 @@ module BitClipboardCopy
69
71
  bit_dev = config.active['bit_dev_user']
70
72
 
71
73
  # check if scope is a candidate for a bit.dev remote scope
72
- if scope.start_with? bit_dev + '.'
74
+ if scope.start_with? "#{bit_dev}."
73
75
  return false unless _bit_clipboard_bit_dev_scope_exists scope
74
76
  else
75
77
  return false unless _bit_clipboard_custom_scope_exists scope
@@ -4,6 +4,14 @@
4
4
  module BitClipboardLib
5
5
  private
6
6
 
7
+ # Run bit status.
8
+ def _bit_clipboard_lib_bit_status
9
+ log.debug 'Running bit status'
10
+
11
+ cmd_bit_status = config.active['cmd_bit_clipboard_lib_bit_status']
12
+ run_and_exit cmd_bit_status
13
+ end
14
+
7
15
  # Prepare workspace for bit clipboard.
8
16
  def _bit_clipboard_lib_prepare_workspace
9
17
  unless bit_check_workspace
@@ -18,8 +26,8 @@ module BitClipboardLib
18
26
 
19
27
  # Prepare git workspace for bit clipboard.
20
28
  def _bit_clipboard_lib_prepare_git_workspace
21
- unless git_check_master
22
- log.error 'Not on git master branch'
29
+ unless git_check_main
30
+ log.error 'Not on git main branch'
23
31
  return false
24
32
  end
25
33
 
@@ -51,7 +59,7 @@ module BitClipboardLib
51
59
  def _bit_clipboard_lib_sync_workspace
52
60
  log.debug 'Syncing git workspace'
53
61
 
54
- _rakefile, path = Rake.application.find_rakefile_location
62
+ path = config.active['project_root_dir']
55
63
  file = "#{path}/.bitmap"
56
64
  message = 'Update .bitmap'
57
65
 
@@ -83,12 +91,14 @@ module BitClipboardLib
83
91
  run cmd_bit_clipboard_git_commit
84
92
  end
85
93
 
86
- # git push origin master.
94
+ # git push origin main.
87
95
  def _bit_clipboard_lib_git_push
88
- log.debug 'Pushing master branch to origin'
96
+ log.debug 'Pushing main branch to origin'
89
97
 
90
- cmd_bit_clipboard_git_push =
91
- config.active['cmd_bit_clipboard_git_push']
98
+ cmd_bit_clipboard_git_push = format(
99
+ config.active['cmd_bit_clipboard_git_push'],
100
+ main: config.active['git_main_branch']
101
+ )
92
102
 
93
103
  run cmd_bit_clipboard_git_push
94
104
  end
@@ -96,8 +106,10 @@ module BitClipboardLib
96
106
  # git pull.
97
107
  def _bit_clipboard_lib_git_pull
98
108
  log.debug 'Updating git workspace'
99
- cmd_bit_clipboard_git_pull =
100
- config.active['cmd_bit_clipboard_git_pull']
109
+ cmd_bit_clipboard_git_pull = format(
110
+ config.active['cmd_bit_clipboard_git_pull'],
111
+ main: config.active['git_main_branch']
112
+ )
101
113
 
102
114
  return true if try cmd_bit_clipboard_git_pull
103
115
 
@@ -6,6 +6,8 @@ module BitClipboardPaste
6
6
  def bit_clipboard_paste(cid, dir)
7
7
  log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
8
8
 
9
+ return false unless configured? %w[project_root_dir]
10
+
9
11
  return false unless _bit_clipboard_lib_prepare_workspace
10
12
 
11
13
  return false unless _bit_clipboard_paste_cid_exists? cid
@@ -40,7 +42,7 @@ module BitClipboardPaste
40
42
 
41
43
  bit_list_scope = _bit_clipboard_paste_cid_exists_list_scope scope
42
44
 
43
- return true if bit_list_scope.include? '"id": "' + cid + '",'
45
+ return true if bit_list_scope.include? "\"id\": \"#{cid}\","
44
46
 
45
47
  log.error "No remote component \"#{cid}\""
46
48
  false
@@ -6,15 +6,15 @@ module BitClipboardPull
6
6
  def bit_clipboard_pull
7
7
  log.debug 'Running bit pull'
8
8
 
9
+ return false unless configured? %w[project_root_dir]
10
+
9
11
  return false unless _bit_clipboard_lib_prepare_workspace
10
12
 
11
13
  _bit_clipboard_pull_import_all
12
14
  _bit_clipboard_pull_checkout_all
13
15
  _bit_clipbpard_lib_remove_bit_artifacts
14
16
  _bit_clipboard_lib_sync_workspace
15
-
16
- log.info 'Pulled bit components'
17
- true
17
+ _bit_clipboard_lib_bit_status
18
18
  end
19
19
 
20
20
  private
@@ -6,15 +6,15 @@ module BitClipboardPush
6
6
  def bit_clipboard_push
7
7
  log.debug 'Running bit push'
8
8
 
9
+ return false unless configured? %w[project_root_dir]
10
+
9
11
  return false unless _bit_clipboard_lib_prepare_workspace
10
12
 
11
13
  _bit_clipboard_push_tag_all
12
14
  _bit_clipboard_push_export_all
13
15
  _bit_clipbpard_lib_remove_bit_artifacts
14
16
  _bit_clipboard_lib_sync_workspace
15
-
16
- log.info 'Pushed bit components'
17
- true
17
+ _bit_clipboard_lib_bit_status
18
18
  end
19
19
 
20
20
  private
@@ -7,7 +7,7 @@ module Takelage
7
7
  include ConfigModule
8
8
  include SystemModule
9
9
  include GitCheckClean
10
- include GitCheckMaster
10
+ include GitCheckMain
11
11
  include GitCheckWorkspace
12
12
  include BitCheckWorkspace
13
13
  include BitScopeList
@@ -6,6 +6,8 @@ module BitRequireExport
6
6
  def bit_require_export
7
7
  log.debug 'Running bit require export'
8
8
 
9
+ return false unless configured? %w[project_root_dir]
10
+
9
11
  components = _bit_require_lib_get_components
10
12
  bitrequire_yml = _bit_require_export_get_bitrequire_yml components
11
13
 
@@ -6,6 +6,8 @@ module BitRequireImport
6
6
  def bit_require_import
7
7
  log.debug 'Running bit require import'
8
8
 
9
+ return false unless configured? %w[project_root_dir]
10
+
9
11
  return false unless _bit_clipboard_lib_prepare_workspace
10
12
 
11
13
  return false unless _bit_require_import_check_require_file_exists
@@ -69,7 +71,7 @@ module BitRequireImport
69
71
 
70
72
  # Check if there are bit components
71
73
  def _bit_require_import_check_component_valid(component, scope)
72
- return true if (component.class == Hash) && component.key?('name')
74
+ return true if component.instance_of?(Hash) && component.key?('name')
73
75
 
74
76
  log.error "No component in #{scope}"
75
77
  false
@@ -84,7 +86,9 @@ module BitRequireImport
84
86
 
85
87
  # Paste bit components.
86
88
  def _bit_require_import_paste_components(components)
87
- _rakefile, path = Rake.application.find_rakefile_location
89
+ path = config.active['project_root_dir']
90
+ return false if path.empty?
91
+
88
92
  components.each do |component|
89
93
  next if _bit_require_import_check_component_exists component, path
90
94
 
@@ -28,9 +28,9 @@ module BitScopeAdd
28
28
 
29
29
  return true unless git_check_workspace
30
30
 
31
- return true if git_check_master
31
+ return true if git_check_main
32
32
 
33
- log.error 'Not on git master branch'
33
+ log.error 'Not on git main branch'
34
34
  false
35
35
  end
36
36
 
@@ -6,7 +6,7 @@ module Takelage
6
6
  include LoggingModule
7
7
  include SystemModule
8
8
  include ConfigModule
9
- include GitCheckMaster
9
+ include GitCheckMain
10
10
  include GitCheckWorkspace
11
11
  include BitCheckWorkspace
12
12
  include BitScopeAdd
@@ -6,6 +6,7 @@ bit_root: '/bit'
6
6
  bit_ssh: ''
7
7
  cmd_bit_check_workspace_bit_list: 'bit list'
8
8
  cmd_bit_check_workspace_pwd: 'pwd'
9
+ cmd_bit_clipboard_lib_bit_status: 'bit status'
9
10
  cmd_bit_clipboard_copy_bit_list_scope: 'bit list --skip-update --json %{scope}'
10
11
  cmd_bit_clipboard_copy_bit_list_remotes: 'bit remote --skip-update'
11
12
  cmd_bit_clipboard_copy_bit_add_dir: 'bit add --skip-update --id %{id} --main %{dir}/README.bit %{dir}'
@@ -13,8 +14,8 @@ cmd_bit_clipboard_copy_bit_tag_id: 'bit tag --skip-update --skip-tests %{id}'
13
14
  cmd_bit_clipboard_copy_bit_export_to_scope: 'bit export --skip-update %{scope}'
14
15
  cmd_bit_clipboard_git_add: 'git add %{file}'
15
16
  cmd_bit_clipboard_git_commit: 'git commit --message="%{message}"'
16
- cmd_bit_clipboard_git_pull: 'git pull origin master'
17
- cmd_bit_clipboard_git_push: 'git push origin master'
17
+ cmd_bit_clipboard_git_pull: 'git pull origin %{main}'
18
+ cmd_bit_clipboard_git_push: 'git push origin %{main}'
18
19
  cmd_bit_clipboard_paste_bit_list_scope: 'bit list --skip-update --json %{scope}'
19
20
  cmd_bit_clipboard_paste_bit_import_cid: 'bit import --ignore-package-json --ignore-dist --skip-update --path %{dir} %{cid}'
20
21
  cmd_bit_clipboard_pull_bit_import_all: 'bit import --ignore-package-json --ignore-dist --skip-update'
@@ -53,7 +54,7 @@ cmd_docker_socket_stop_docker_socket_kill: 'sudo kill -SIGTERM %{pid}'
53
54
  cmd_git_check_clean_git_unstaged: 'git diff --exit-code'
54
55
  cmd_git_check_clean_git_uncommitted: 'git diff --cached --exit-code'
55
56
  cmd_git_check_clean_git_status: 'git status --porcelain'
56
- cmd_git_check_master_git_branch: 'git symbolic-ref HEAD'
57
+ cmd_git_check_main_git_branch: 'git symbolic-ref HEAD'
57
58
  cmd_git_check_workspace_git_repo: 'git -C . rev-parse'
58
59
  cmd_git_check_workspace_pwd: 'pwd'
59
60
  docker_debug: 'ansible/roles/takel-takelage/files/takelscripts'
@@ -67,5 +68,6 @@ docker_socket_gpg_agent_port: 17874
67
68
  docker_socket_gpg_ssh_agent_port: 17875
68
69
  docker_tag: 'latest'
69
70
  docker_user: 'takelage'
71
+ git_main_branch: 'main'
70
72
  info_project_main: 'project.yml'
71
73
  info_project_private: 'private/project.yml'
@@ -6,6 +6,17 @@ module DockerSocketHost
6
6
  def docker_socket_host
7
7
  log.debug 'Getting docker socket host ip address'
8
8
 
9
+ socket_host = _docker_socket_host_get_socket_host
10
+
11
+ log.debug "Docker socket host ip address is \"#{socket_host}\""
12
+
13
+ socket_host
14
+ end
15
+
16
+ private
17
+
18
+ # Get the socket host, i.e. the ip of the docker host.
19
+ def _docker_socket_host_get_socket_host
9
20
  socket_host = '127.0.0.1'
10
21
 
11
22
  addr_infos = Socket.getifaddrs
@@ -13,13 +24,12 @@ module DockerSocketHost
13
24
  # if interface docker0 exists (== linux host)
14
25
  # then return the ip address
15
26
  addr_infos.each do |addr_info|
16
- if addr_info.name == 'docker0'
17
- socket_host = addr_info.addr.ip_address if addr_info.addr.ipv4?
27
+ if (addr_info.name == 'docker0') && addr_info.addr.ipv4?
28
+ socket_host = addr_info.addr.ip_address
29
+ break
18
30
  end
19
31
  end
20
32
 
21
- log.debug "Docker socket host ip address is \"#{socket_host}\""
22
-
23
33
  socket_host
24
34
  end
25
35
  end
@@ -7,7 +7,7 @@ module Takelage
7
7
  include SystemModule
8
8
  include ConfigModule
9
9
  include GitCheckClean
10
- include GitCheckMaster
10
+ include GitCheckMain
11
11
  include GitCheckWorkspace
12
12
 
13
13
  #
@@ -23,15 +23,15 @@ module Takelage
23
23
  end
24
24
 
25
25
  #
26
- # git check master
26
+ # git check main
27
27
  #
28
- desc 'master', 'Check if we are on the git master branch'
28
+ desc 'main', 'Check if we are on the git main branch'
29
29
  long_desc <<-LONGDESC.gsub("\n", "\x5")
30
- Check if we are on the git master branch
30
+ Check if we are on the git main branch
31
31
  LONGDESC
32
- # Check if we are on the git master branch.
33
- def master
34
- exit git_check_master
32
+ # Check if we are on the git main branch.
33
+ def main
34
+ exit git_check_main
35
35
  end
36
36
 
37
37
  #
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage git check main
4
+ module GitCheckMain
5
+ # Backend method for git check main.
6
+ # @return [Boolean] are we on the git main branch?
7
+ def git_check_main
8
+ log.debug 'Check if we are on the git main branch'
9
+
10
+ return false unless git_check_workspace
11
+
12
+ branch = _git_check_main_get_branch
13
+ log.debug "We are on git branch \"#{branch}\""
14
+
15
+ branch == config.active['git_main_branch']
16
+ end
17
+
18
+ private
19
+
20
+ # Get git branch.
21
+ def _git_check_main_get_branch
22
+ cmd_get_branch =
23
+ config.active['cmd_git_check_main_git_branch']
24
+ (run cmd_get_branch).strip.split('/')[-1]
25
+ end
26
+ end
@@ -21,12 +21,15 @@ module ConfigModule
21
21
  # Initialze config
22
22
  # rubocop:disable Metrics/AbcSize
23
23
  def initialize_config
24
+ project_root_dir = _get_project_root_dir
25
+
24
26
  log.debug "takelage version: #{Takelage::VERSION}"
25
27
  log.debug "Current working directory: #{Dir.pwd}"
28
+ log.debug "Project root directory: #{project_root_dir}" unless project_root_dir.empty?
26
29
 
27
- TakelageConfig.instance.default = _config_read_default
30
+ TakelageConfig.instance.default = _config_read_default project_root_dir
28
31
  TakelageConfig.instance.home = _config_read_home
29
- TakelageConfig.instance.project = _config_read_project
32
+ TakelageConfig.instance.project = _config_read_project project_root_dir
30
33
  TakelageConfig.instance.active = _config_merge_active
31
34
  end
32
35
  # rubocop:enable Metrics/AbcSize
@@ -62,19 +65,25 @@ module ConfigModule
62
65
  takel_config_key = TakelageConfig.instance.active[config_key]
63
66
  return true unless takel_config_key.nil? || takel_config_key.empty?
64
67
 
65
- log.error "Unset config key. Please configure \"#{config_key}\""
68
+ if config_key == 'project_root_dir'
69
+ log.error 'Please create a "Rakefile" in the project root directory'
70
+ else
71
+ log.error "Unset config key. Please configure \"#{config_key}\""
72
+ end
66
73
  @configured = false
67
74
  false
68
75
  end
69
76
 
70
77
  # Read default config file in lib.
71
- def _config_read_default
78
+ def _config_read_default(project_root_dir)
72
79
  default_file = File.expand_path("#{File.dirname(__FILE__)}/../default.yml")
73
80
 
74
- return {} unless File.exist? default_file
81
+ return { project_root_dir: project_root_dir } unless File.exist? default_file
75
82
 
76
83
  default_yaml = read_yaml_file(default_file) || {}
77
84
 
85
+ default_yaml['project_root_dir'] = project_root_dir
86
+
78
87
  default_yaml.sort.to_h
79
88
  end
80
89
 
@@ -84,21 +93,16 @@ module ConfigModule
84
93
 
85
94
  return {} unless File.exist? home_file
86
95
 
87
- home_yaml = read_yaml_file(home_file) || {}
88
-
89
- home_yaml.sort.to_h
96
+ (read_yaml_file(home_file) || {}).sort.to_h
90
97
  end
91
98
 
92
- # Read custom config file next to Rakefile.
93
- def _config_read_project
94
- _rakefile, path = Rake.application.find_rakefile_location
95
- project_file = "#{path}/takelage.yml"
99
+ # Read custom config file in project root.
100
+ def _config_read_project(project_root_dir)
101
+ project_file = "#{project_root_dir}/takelage.yml"
96
102
 
97
103
  return {} unless File.exist? project_file
98
104
 
99
- project_yaml = read_yaml_file(project_file) || {}
100
-
101
- project_yaml.sort.to_h
105
+ (read_yaml_file(project_file) || {}).sort.to_h
102
106
  end
103
107
 
104
108
  # Merge active config.
@@ -113,4 +117,14 @@ module ConfigModule
113
117
  project_over_home = home.merge!(project)
114
118
  default.merge!(project_over_home).sort.to_h
115
119
  end
120
+
121
+ # Get project root directory.
122
+ # @return [String] project root directory
123
+ def _get_project_root_dir
124
+ _rakefile, path = Rake.application.find_rakefile_location
125
+ return path unless path.nil?
126
+
127
+ log.debug 'No "Rakefile" found. Cannot determine project root directory.'
128
+ ''
129
+ end
116
130
  end
@@ -9,7 +9,7 @@ module LoggingModule
9
9
  attr_accessor :logger
10
10
 
11
11
  def initialize
12
- @logger = Logger.new(STDOUT)
12
+ @logger = Logger.new($stdout)
13
13
  end
14
14
  end
15
15
 
@@ -34,24 +34,24 @@ module ProjectModule
34
34
 
35
35
  # Read main YAML file.
36
36
  def _project_read_main
37
- _rakefile, @path = Rake.application.find_rakefile_location
38
- main_file = "#{@path}/" \
37
+ path = TakelageProject.instance.config.active['project_root_dir']
38
+ main_file = "#{path}/" \
39
39
  "#{TakelageProject.instance.config.active['info_project_main']}"
40
40
 
41
41
  return {} unless File.exist? main_file
42
42
 
43
- read_yaml_file(main_file).sort.to_h || {}
43
+ (read_yaml_erb_file(main_file) || {}).sort.to_h
44
44
  end
45
45
 
46
46
  # Read private YAML file.
47
47
  def _project_read_private
48
- _rakefile, @path = Rake.application.find_rakefile_location
49
- private_file = "#{@path}/" \
48
+ path = TakelageProject.instance.config.active['project_root_dir']
49
+ private_file = "#{path}/" \
50
50
  "#{TakelageProject.instance.config.active['info_project_private']}"
51
51
 
52
52
  return {} unless File.exist? private_file
53
53
 
54
- private_yaml = read_yaml_file(private_file) || {}
54
+ private_yaml = read_yaml_erb_file(private_file) || {}
55
55
 
56
56
  private_yaml.sort.to_h
57
57
  end
@@ -3,9 +3,11 @@
3
3
  # Thor with subcommands that work correctly with help
4
4
  class SubCommandBase < Thor
5
5
  # Set the subcommand banner.
6
+ # rubocop:disable Style/OptionalBooleanParameter
6
7
  def self.banner(command, _namespace = nil, _subcommand = false)
7
8
  "#{basename} #{subcommand_prefix} #{command.usage}"
8
9
  end
10
+ # rubocop:enable Style/OptionalBooleanParameter
9
11
 
10
12
  # Set the subcommand prefix.
11
13
  def self.subcommand_prefix
@@ -20,7 +20,19 @@ module SystemModule
20
20
  log.debug "Reading YAML file \"#{file}\""
21
21
  return nil unless _file_exists? file
22
22
  return nil unless _file_read file
23
- return nil unless _parse_yaml @content_yaml
23
+ return nil unless _parse_yaml file, @content_file
24
+
25
+ @content
26
+ end
27
+
28
+ # Read yaml file with erb templates.
29
+ # @return [Hash] content of yaml file
30
+ def read_yaml_erb_file(file)
31
+ log.debug "Reading YAML ERB file \"#{file}\""
32
+ return nil unless _file_exists? file
33
+ return nil unless _file_read file
34
+ return nil unless _parse_erb file, @content_file
35
+ return nil unless _parse_yaml file, @content_yaml
24
36
 
25
37
  @content
26
38
  end
@@ -82,7 +94,7 @@ module SystemModule
82
94
  # Read yaml file.
83
95
  def _file_read(file)
84
96
  begin
85
- @content_yaml = File.read file
97
+ @content_file = File.read file
86
98
  rescue SystemCallError
87
99
  log.debug "Unable to read file \"#{file}\""
88
100
  return false
@@ -90,8 +102,21 @@ module SystemModule
90
102
  true
91
103
  end
92
104
 
105
+ # Parse erb file.
106
+ def _parse_erb(file, content_erb)
107
+ begin
108
+ @content_yaml = ERB.new(content_erb).result
109
+ rescue StandardError => e
110
+ log.debug e.class
111
+ log.debug "Invalid ERB in YAML file \"#{file}\". " \
112
+ "#{e.class}: \"#{e.message}\""
113
+ return false
114
+ end
115
+ true
116
+ end
117
+
93
118
  # Parse yaml file.
94
- def _parse_yaml(content_yaml)
119
+ def _parse_yaml(file, content_yaml)
95
120
  begin
96
121
  @content = YAML.safe_load content_yaml
97
122
  rescue Psych::SyntaxError
@@ -4,6 +4,13 @@
4
4
  module SelfList
5
5
  # Backend method for config self.
6
6
  def self_list
7
+ _manipulate_output_(_get_thor_list_)
8
+ end
9
+
10
+ private
11
+
12
+ # Get output of thor list command.
13
+ def _get_thor_list_
7
14
  # use Thorfile which requires relative takelage.rb
8
15
  thorfile_dir = "#{File.dirname(__FILE__)}/../"
9
16
 
@@ -12,20 +19,17 @@ module SelfList
12
19
  "cd #{thorfile_dir} && " \
13
20
  'thor list' \
14
21
  "'"
15
- thor_list = `#{cmd_thor_list}`
16
22
 
17
- # manipulate thor list output
18
- _manipulate_output_(thor_list)
23
+ # call thor list command
24
+ `#{cmd_thor_list}`
19
25
  end
20
26
 
21
- private
22
-
23
27
  # Manipulate output of thor list command.
24
28
  def _manipulate_output_(thor_list)
25
- thor_list.gsub!("takelage\n", '')
26
- thor_list.gsub!("------\n", '')
27
- thor_list.gsub!('thor ', 'tau ')
28
- thor_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
29
- thor_list.gsub!(/.*COMMAND.*\n/, '')
29
+ tau_list = thor_list.gsub("takelage\n", '')
30
+ tau_list.gsub!("------\n", '')
31
+ tau_list.gsub!('thor ', 'tau ')
32
+ tau_list.gsub!(/(.*)takelage:c_l_i:(.*)#(.*)/, '\1\2 #\3')
33
+ tau_list.gsub!(/.*COMMAND.*\n/, '')
30
34
  end
31
35
  end
@@ -1 +1 @@
1
- 0.20.1
1
+ 0.22.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takelage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin
@@ -261,7 +261,7 @@ files:
261
261
  - lib/takelage/docker/socket/stop.rb
262
262
  - lib/takelage/git/check/clean.rb
263
263
  - lib/takelage/git/check/cli.rb
264
- - lib/takelage/git/check/master.rb
264
+ - lib/takelage/git/check/main.rb
265
265
  - lib/takelage/git/check/workspace.rb
266
266
  - lib/takelage/git/cli.rb
267
267
  - lib/takelage/info/cli.rb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takelage git check master
4
- module GitCheckMaster
5
- # Backend method for git check master.
6
- # @return [Boolean] are we on the git master branch?
7
- def git_check_master
8
- log.debug 'Check if we are on the git master branch'
9
-
10
- return false unless git_check_workspace
11
-
12
- branch = _git_check_master_get_branch
13
- log.debug "We are on git branch \"#{branch}\""
14
-
15
- branch == 'master'
16
- end
17
-
18
- private
19
-
20
- # Get git branch.
21
- def _git_check_master_get_branch
22
- cmd_get_branch =
23
- config.active['cmd_git_check_master_git_branch']
24
- (run cmd_get_branch).strip.split('/')[-1]
25
- end
26
- end