takeltau 0.34.15 → 0.35.15

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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -27
  3. data/lib/takeltau/completion/cli.rb +1 -1
  4. data/lib/takeltau/default.yml +10 -35
  5. data/lib/takeltau/docker/check/cli.rb +1 -1
  6. data/lib/takeltau/docker/check/daemon.rb +1 -1
  7. data/lib/takeltau/docker/cli.rb +1 -1
  8. data/lib/takeltau/docker/container/check/cli.rb +1 -1
  9. data/lib/takeltau/docker/container/check/existing.rb +1 -1
  10. data/lib/takeltau/docker/container/check/network.rb +1 -1
  11. data/lib/takeltau/docker/container/check/orphaned.rb +1 -1
  12. data/lib/takeltau/docker/container/clean.rb +1 -1
  13. data/lib/takeltau/docker/container/cli.rb +1 -1
  14. data/lib/takeltau/docker/container/command.rb +1 -1
  15. data/lib/takeltau/docker/container/daemon.rb +1 -1
  16. data/lib/takeltau/docker/container/lib.rb +1 -1
  17. data/lib/takeltau/docker/container/login.rb +1 -1
  18. data/lib/takeltau/docker/container/prune.rb +1 -1
  19. data/lib/takeltau/docker/image/cli.rb +1 -1
  20. data/lib/takeltau/docker/image/tag/check.rb +1 -1
  21. data/lib/takeltau/docker/image/tag/cli.rb +1 -1
  22. data/lib/takeltau/docker/image/tag/latest.rb +1 -1
  23. data/lib/takeltau/docker/image/tag/list.rb +1 -1
  24. data/lib/takeltau/docker/image/update.rb +1 -1
  25. data/lib/takeltau/git/check/clean.rb +1 -1
  26. data/lib/takeltau/git/check/cli.rb +14 -14
  27. data/lib/takeltau/git/check/hg.rb +26 -0
  28. data/lib/takeltau/git/check/workspace.rb +1 -1
  29. data/lib/takeltau/git/cli.rb +1 -1
  30. data/lib/takeltau/git/lib.rb +80 -0
  31. data/lib/takeltau/hg/cli.rb +56 -0
  32. data/lib/takeltau/hg/export.rb +18 -0
  33. data/lib/takeltau/hg/pull.rb +43 -0
  34. data/lib/takeltau/hg/push.rb +42 -0
  35. data/lib/takeltau/info/cli.rb +1 -1
  36. data/lib/takeltau/info/project/cli.rb +1 -1
  37. data/lib/takeltau/info/status/bar.rb +1 -1
  38. data/lib/takeltau/info/status/cli.rb +1 -1
  39. data/lib/takeltau/info/status/git.rb +1 -1
  40. data/lib/takeltau/info/status/gopass.rb +1 -1
  41. data/lib/takeltau/info/status/gpg.rb +1 -1
  42. data/lib/takeltau/info/status/lib.rb +1 -1
  43. data/lib/takeltau/info/status/ssh.rb +1 -1
  44. data/lib/takeltau/init/lib.rb +9 -28
  45. data/lib/takeltau/init/packer/cli.rb +4 -14
  46. data/lib/takeltau/init/packer/docker.rb +2 -5
  47. data/lib/takeltau/init/packer/templates/hgclone.tt +8 -0
  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
data/lib/takeltau.rb CHANGED
@@ -20,30 +20,17 @@ require_relative 'takeltau/lib/system'
20
20
  require_relative 'takeltau/lib/config'
21
21
  require_relative 'takeltau/lib/project'
22
22
 
23
+ require_relative 'takeltau/completion/cli'
23
24
  require_relative 'takeltau/git/check/clean'
24
- require_relative 'takeltau/git/check/bit'
25
+ require_relative 'takeltau/git/check/hg'
25
26
  require_relative 'takeltau/git/check/workspace'
26
27
  require_relative 'takeltau/git/check/cli'
28
+ require_relative 'takeltau/git/lib'
27
29
  require_relative 'takeltau/git/cli'
28
- require_relative 'takeltau/bit/check/workspace'
29
- require_relative 'takeltau/bit/check/cli'
30
- require_relative 'takeltau/bit/scope/add'
31
- require_relative 'takeltau/bit/scope/ssh'
32
- require_relative 'takeltau/bit/scope/list'
33
- require_relative 'takeltau/bit/scope/new'
34
- require_relative 'takeltau/bit/scope/cli'
35
- require_relative 'takeltau/bit/clipboard/lib'
36
- require_relative 'takeltau/bit/clipboard/copy'
37
- require_relative 'takeltau/bit/clipboard/paste'
38
- require_relative 'takeltau/bit/clipboard/pull'
39
- require_relative 'takeltau/bit/clipboard/push'
40
- require_relative 'takeltau/bit/clipboard/cli'
41
- require_relative 'takeltau/bit/require/lib'
42
- require_relative 'takeltau/bit/require/export'
43
- require_relative 'takeltau/bit/require/import'
44
- require_relative 'takeltau/bit/require/cli'
45
- require_relative 'takeltau/bit/cli'
46
- require_relative 'takeltau/completion/cli'
30
+ require_relative 'takeltau/hg/export'
31
+ require_relative 'takeltau/hg/pull'
32
+ require_relative 'takeltau/hg/push'
33
+ require_relative 'takeltau/hg/cli'
47
34
  require_relative 'takeltau/init/lib'
48
35
  require_relative 'takeltau/init/packer/docker'
49
36
  require_relative 'takeltau/init/packer/cli'
@@ -138,9 +125,6 @@ module Takeltau
138
125
  # Subcommands
139
126
  #
140
127
 
141
- desc 'bit [COMMAND] ', 'Manage bit'
142
- subcommand 'bit', Bit
143
-
144
128
  desc 'completion [COMMAND] ', 'Print shell completion code'
145
129
  subcommand 'completion', Completion
146
130
 
@@ -150,10 +134,13 @@ module Takeltau
150
134
  desc 'git [COMMAND] ', 'Manage git'
151
135
  subcommand 'git', Git
152
136
 
137
+ desc 'hg [COMMAND] ', 'Manage hg'
138
+ subcommand 'hg', Hg
139
+
153
140
  desc 'info [COMMAND] ', 'Get information'
154
141
  subcommand 'info', Info
155
142
 
156
- desc 'init [COMMAND] ', 'Init projects'
143
+ desc 'init [COMMAND] ', 'Init project'
157
144
  subcommand 'init', Init
158
145
 
159
146
  desc 'mutagen [COMMAND] ', 'Manage mutagen'
@@ -166,80 +153,68 @@ module Takeltau
166
153
  # Top-level commands
167
154
  #
168
155
 
156
+ desc 'clean', 'Alias for tau docker container clean'
157
+ # tau clean: {Takeltau::DockerContainer#clean}
158
+ def clean
159
+ Takeltau::DockerContainer.new.clean
160
+ end
161
+
169
162
  desc 'config', 'Alias for tau self config active'
170
- # takeltau config: {takelage::SelfConfig#active}
163
+ # tau config: {Takeltau::SelfConfig#active}
171
164
  def config
172
165
  Takeltau::SelfConfig.new.active
173
166
  end
174
167
 
175
- desc 'copy [DIR] [SCOPE]', 'Alias for tau bit clipboard copy'
176
- # takeltau copy: {takelage::BitClipboard#copy}
177
- def copy(dir_or_file, scope)
178
- Takeltau::BitClipboard.new.copy dir_or_file, scope
179
- end
180
-
181
- desc 'project', 'Alias for tau info project active'
182
- # takeltau project: {takelage::InfoProject#active}
183
- def project
184
- Takeltau::InfoProject.new.active
185
- end
186
-
187
168
  desc 'login', 'Alias for tau docker container login'
188
- # takeltau login: {takelage::DockerContainer#login}
169
+ # tau login: {Takeltau::DockerContainer#login}
189
170
  def login
190
171
  Takeltau::DockerContainer.new.login
191
172
  end
192
173
 
193
174
  desc 'list', 'Alias for tau self list'
194
- # takeltau version: {takelage::Self#list}
175
+ # tau version: {Takeltau::Self#list}
195
176
  def list
196
177
  Takeltau::Self.new.list
197
178
  end
198
179
 
199
- desc 'clean', 'Alias for tau docker container clean'
200
- # takeltau clean: {takelage::DockerContainer#clean}
201
- def clean
202
- Takeltau::DockerContainer.new.clean
203
- end
204
-
205
- desc 'paste [COMPONENT] [DIR]', 'Alias for tau bit clipboard paste'
206
- # takeltau paste: {takelage::BitClipboard#paste}
207
- def paste(cid, dir)
208
- Takeltau::BitClipboard.new.paste cid, dir
209
- end
210
-
211
- desc 'pull', 'Alias for tau bit clipboard pull'
212
- # takeltau pull: {takelage::BitClipboard#pull}
213
- def pull
214
- Takeltau::BitClipboard.new.pull
180
+ desc 'project', 'Alias for tau info project active'
181
+ # tau project: {Takeltau::InfoProject#active}
182
+ def project
183
+ Takeltau::InfoProject.new.active
215
184
  end
216
185
 
217
186
  desc 'prune', 'Alias for tau docker container prune'
218
- # takeltau prune: {takelage::DockerContainer#prune}
187
+ # tau prune: {Takeltau::DockerContainer#prune}
219
188
  def prune
220
189
  Takeltau::DockerContainer.new.prune
221
190
  end
222
191
 
223
- desc 'push', 'Alias for tau bit clipboard push'
224
- # takeltau push: {takelage::BitClipboard#push}
192
+ desc 'pull', 'Alias for tau hg pull'
193
+ # tau pull: {Takeltau::Hg#pull}
194
+ def pull
195
+ Takeltau::Hg.new.pull
196
+ end
197
+
198
+ desc 'push', 'Alias for tau hg push'
199
+ # tau push: {Takeltau::Hg#push}
225
200
  def push
226
- Takeltau::BitClipboard.new.push
201
+ Takeltau::Hg.new.push
227
202
  end
228
203
 
229
204
  desc 'status', 'Alias for tau info status bar'
230
- # takeltau status: {takelage::InfoStatus#bar}
205
+ # tau status: {Takeltau::InfoStatus#bar}
231
206
  def status
232
207
  Takeltau::InfoStatus.new.bar
233
208
  end
234
209
 
235
210
  desc 'update', 'Alias for tau docker image update'
236
- # takeltau update: {takelage::DockerImage#update}
211
+ # tau update: {Takeltau::DockerImage#update}
237
212
  def update
238
213
  Takeltau::DockerImage.new.update
239
214
  end
240
215
 
241
216
  desc 'version', 'Alias for tau self version'
242
- # takeltau version: {takelage::Self#version}
217
+ # tau version: {Takeltau::Self#version}
243
218
  def version
244
219
  Takeltau::Self.new.version
245
220
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: takeltau
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.15
4
+ version: 0.35.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takelwerk
@@ -205,24 +205,6 @@ files:
205
205
  - bin/tau
206
206
  - lib/Thorfile
207
207
  - lib/takeltau.rb
208
- - lib/takeltau/bit/check/cli.rb
209
- - lib/takeltau/bit/check/workspace.rb
210
- - lib/takeltau/bit/cli.rb
211
- - lib/takeltau/bit/clipboard/cli.rb
212
- - lib/takeltau/bit/clipboard/copy.rb
213
- - lib/takeltau/bit/clipboard/lib.rb
214
- - lib/takeltau/bit/clipboard/paste.rb
215
- - lib/takeltau/bit/clipboard/pull.rb
216
- - lib/takeltau/bit/clipboard/push.rb
217
- - lib/takeltau/bit/require/cli.rb
218
- - lib/takeltau/bit/require/export.rb
219
- - lib/takeltau/bit/require/import.rb
220
- - lib/takeltau/bit/require/lib.rb
221
- - lib/takeltau/bit/scope/add.rb
222
- - lib/takeltau/bit/scope/cli.rb
223
- - lib/takeltau/bit/scope/list.rb
224
- - lib/takeltau/bit/scope/new.rb
225
- - lib/takeltau/bit/scope/ssh.rb
226
208
  - lib/takeltau/completion/cli.rb
227
209
  - lib/takeltau/default.yml
228
210
  - lib/takeltau/docker/check/cli.rb
@@ -245,11 +227,16 @@ files:
245
227
  - lib/takeltau/docker/image/tag/latest.rb
246
228
  - lib/takeltau/docker/image/tag/list.rb
247
229
  - lib/takeltau/docker/image/update.rb
248
- - lib/takeltau/git/check/bit.rb
249
230
  - lib/takeltau/git/check/clean.rb
250
231
  - lib/takeltau/git/check/cli.rb
232
+ - lib/takeltau/git/check/hg.rb
251
233
  - lib/takeltau/git/check/workspace.rb
252
234
  - lib/takeltau/git/cli.rb
235
+ - lib/takeltau/git/lib.rb
236
+ - lib/takeltau/hg/cli.rb
237
+ - lib/takeltau/hg/export.rb
238
+ - lib/takeltau/hg/pull.rb
239
+ - lib/takeltau/hg/push.rb
253
240
  - lib/takeltau/info/cli.rb
254
241
  - lib/takeltau/info/project/cli.rb
255
242
  - lib/takeltau/info/status/bar.rb
@@ -264,13 +251,13 @@ files:
264
251
  - lib/takeltau/init/packer/cli.rb
265
252
  - lib/takeltau/init/packer/docker.rb
266
253
  - lib/takeltau/init/packer/templates/ansiblelint.tt
267
- - lib/takeltau/init/packer/templates/bitrequireyml.tt
268
254
  - lib/takeltau/init/packer/templates/groupvarsprojectyml.tt
255
+ - lib/takeltau/init/packer/templates/hgclone.tt
269
256
  - lib/takeltau/init/packer/templates/playbooksiteyml.tt
270
257
  - lib/takeltau/init/packer/templates/projectyml.tt
271
258
  - lib/takeltau/init/takelage/cli.rb
272
259
  - lib/takeltau/init/takelage/rake.rb
273
- - lib/takeltau/init/takelage/templates/bitrequireyml.tt
260
+ - lib/takeltau/init/takelage/templates/hgclone.tt
274
261
  - lib/takeltau/init/takelage/templates/projectyml.tt
275
262
  - lib/takeltau/init/templates/Rakefile.tt
276
263
  - lib/takeltau/init/templates/gitignore.tt
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Takeltau
4
- # takeltau bit check
5
- class BitCheck < SubCommandBase
6
- include LoggingModule
7
- include SystemModule
8
- include ConfigModule
9
- include BitCheckWorkspace
10
-
11
- #
12
- # bit check workspace
13
- #
14
- desc 'workspace', 'Check if a bit workspace exists'
15
- long_desc <<-LONGDESC.gsub("\n", "\x5")
16
- Check if a bit workspace exists
17
- LONGDESC
18
- # Check if a bit workspace exists.
19
- def workspace
20
- exit bit_check_workspace
21
- end
22
- end
23
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit check workspace
4
- module BitCheckWorkspace
5
- # Backend method for bit check workspace.
6
- # @return [Boolean] is this a bit workspace?
7
- def bit_check_workspace
8
- log.debug 'Check if this is a bit workspace'
9
-
10
- status_repo = _bit_check_workspace_bit_repo
11
- return true if status_repo.exitstatus.zero?
12
-
13
- dir = _bit_check_workspace_dir
14
- log.debug "No bit workspace found in \"#{dir}\""
15
- false
16
- end
17
-
18
- private
19
-
20
- # Check bit repo.
21
- def _bit_check_workspace_bit_repo
22
- cmd_bit_repo =
23
- config.active['cmd_bit_check_workspace_bit_list']
24
-
25
- try cmd_bit_repo
26
- end
27
-
28
- # Get current working directory.
29
- def _bit_check_workspace_dir
30
- cmd_pwd =
31
- config.active['cmd_bit_check_workspace_pwd']
32
-
33
- stdout_str_dir = run cmd_pwd
34
-
35
- stdout_str_dir.chomp
36
- end
37
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Takeltau
4
- # takeltau bit
5
- class Bit < SubCommandBase
6
- desc 'check [COMMAND]', 'Check bit state'
7
- subcommand 'check', BitCheck
8
-
9
- desc 'clipboard [COMMAND]', 'Manage bit clipboard'
10
- subcommand 'clipboard', BitClipboard
11
-
12
- desc 'require [COMMAND]', 'Manage bit requirements'
13
- subcommand 'require', BitRequire
14
-
15
- desc 'scope [COMMAND]', 'Manage bit scopes'
16
- subcommand 'scope', BitScope
17
- end
18
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Takeltau
4
- # takeltau bit clipboard
5
- class BitClipboard < SubCommandBase
6
- include LoggingModule
7
- include ConfigModule
8
- include SystemModule
9
- include GitCheckClean
10
- include GitCheckBit
11
- include GitCheckWorkspace
12
- include BitCheckWorkspace
13
- include BitClipboardLib
14
- include BitClipboardCopy
15
- include BitClipboardPaste
16
- include BitClipboardPull
17
- include BitClipboardPush
18
-
19
- #
20
- # bit copy
21
- #
22
- desc 'copy [DIR] [SCOPE]', 'Copy new [DIR] to [SCOPE]'
23
- long_desc <<-LONGDESC.gsub("\n", "\x5")
24
- Copy a directory as a bit component to a bit remote scope
25
- This command will add a directory as a bit component and tag it.
26
- The id of the component will be created from the directory name.
27
- The directory needs to contain a README.bit file
28
- or else a new README.bit file will be created.
29
- The README.bit will be the main file of the component which must not be deleted.
30
- The tagged bit component will be exported to a bit remote scope.
31
- LONGDESC
32
- # Copy a file or directory as a bit component to a bit remote scope.
33
- def copy(dir_or_file, scope)
34
- exit bit_clipboard_copy dir_or_file, scope
35
- end
36
-
37
- #
38
- # bit paste
39
- #
40
- desc 'paste [COMPONENT] [DIR]', 'Paste bit [COMPONENT] into [DIR]'
41
- long_desc <<-LONGDESC.gsub("\n", "\x5")
42
- Paste a bit component into a directory
43
- LONGDESC
44
- # Paste a bit component into a directory.
45
- def paste(cid, dir)
46
- exit bit_clipboard_paste cid, dir
47
- end
48
-
49
- #
50
- # bit pull
51
- #
52
- desc 'pull', 'Pull all updates for bit components from bit remote scopes'
53
- long_desc <<-LONGDESC.gsub("\n", "\x5")
54
- Pull all updates for bit components from bit remote scopes
55
- LONGDESC
56
- # Pull all updates for bit components from bit remote scopes.
57
- def pull
58
- exit bit_clipboard_pull
59
- end
60
-
61
- #
62
- # bit push
63
- #
64
- desc 'push', 'Push all updates of bit components to bit remote scopes'
65
- long_desc <<-LONGDESC.gsub("\n", "\x5")
66
- Push all updates of bit components to bit remote scopes
67
- LONGDESC
68
- # Push all updates of bit components to bit remote scopes.
69
- def push
70
- exit bit_clipboard_push
71
- end
72
- end
73
- end
@@ -1,142 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit clipboard copy
4
- module BitClipboardCopy
5
- # Backend method for bit copy.
6
- def bit_clipboard_copy(dir, scope)
7
- # remove trailing slash
8
- dir = dir.chomp('/')
9
-
10
- log.info "Running bit copy \"#{dir}\" to \"#{scope}\""
11
-
12
- return false unless configured? %w[project_root_dir]
13
-
14
- return false unless _bit_clipboard_lib_prepare_workspace
15
-
16
- unless File.directory? dir
17
- log.error "The directory \"#{dir}\" does not exist"
18
- return false
19
- end
20
-
21
- _bit_clipboard_copy_dir dir, scope
22
- end
23
-
24
- private
25
-
26
- # rubocop:disable Metrics/MethodLength
27
- def _bit_clipboard_copy_dir(dir, scope)
28
- log.debug "Adding the directory \"#{dir}\" as a tagged bit component"
29
-
30
- return false unless _bit_clipboard_copy_dir_scope_exists? scope
31
-
32
- return false if _bit_clipboard_copy_readme_bit_exists_in_subdir? dir
33
-
34
- id = _bit_clipboard_lib_id(dir)
35
-
36
- _bit_clipboard_copy_touch_readme_bit dir
37
- _bit_clipboard_copy_add_dir id, dir
38
- _bit_clipboard_copy_tag_dir id
39
- _bit_clipboard_copy_export_to_scope scope
40
- _bit_clipbpard_lib_remove_bit_artifacts
41
- _bit_clipboard_lib_sync_workspace
42
-
43
- log.info "Copied directory \"#{dir}\" as bit component \"#{id}\" " \
44
- "to bit remote scope \"#{scope}\""
45
- end
46
- # rubocop:enable Metrics/MethodLength
47
-
48
- # Touch README.bit if necessary.
49
- def _bit_clipboard_copy_touch_readme_bit(dir)
50
- readme_bit = "#{dir}/README.bit"
51
- return if File.file? readme_bit
52
-
53
- log.info "Creating \"README.bit\" in \"#{dir}\""
54
- File.open(readme_bit, 'w') {}
55
- end
56
-
57
- # Check if a README.bit file exists in a subdirectory.
58
- def _bit_clipboard_copy_readme_bit_exists_in_subdir?(dir)
59
- Dir.glob("#{dir}/**/README.bit").each do |file|
60
- unless file == "#{dir}/README.bit"
61
- log.error 'Nested README.bit file detected'
62
- return true
63
- end
64
- end
65
-
66
- false
67
- end
68
-
69
- # Check if bit scope exists.
70
- def _bit_clipboard_copy_dir_scope_exists?(scope)
71
- bit_dev = config.active['bit_dev_user']
72
-
73
- # check if scope is a candidate for a bit.dev remote scope
74
- if scope.start_with? "#{bit_dev}."
75
- return false unless _bit_clipboard_bit_dev_scope_exists scope
76
- else
77
- return false unless _bit_clipboard_custom_scope_exists scope
78
- end
79
-
80
- true
81
- end
82
-
83
- # Check if bit.dev remote scope exists.
84
- def _bit_clipboard_bit_dev_scope_exists(scope)
85
- cmd_bit_list_scope = format(
86
- config.active['cmd_bit_clipboard_copy_bit_list_scope'],
87
- scope: scope
88
- )
89
-
90
- status = try cmd_bit_list_scope
91
-
92
- return true if status.exitstatus.zero?
93
-
94
- log.error "No bit.dev remote scope \"#{scope}\" found"
95
- false
96
- end
97
-
98
- # Check if bit remote scope is added to local workspace.
99
- def _bit_clipboard_custom_scope_exists(scope)
100
- cmd_bit_list_remotes =
101
- config.active['cmd_bit_clipboard_copy_bit_list_remotes']
102
-
103
- stdout_str = run cmd_bit_list_remotes
104
-
105
- return true if /.*\s+#{scope}\s+.*/m.match? stdout_str
106
-
107
- log.error "No bit remote scope \"#{scope}\" " \
108
- 'found in local bit workspace'
109
- false
110
- end
111
-
112
- # bit tag dir.
113
- def _bit_clipboard_copy_add_dir(id, dir)
114
- cmd_bit_add_dir = format(
115
- config.active['cmd_bit_clipboard_copy_bit_add_dir'],
116
- id: id,
117
- dir: dir
118
- )
119
-
120
- run cmd_bit_add_dir
121
- end
122
-
123
- # bit tag dir.
124
- def _bit_clipboard_copy_tag_dir(id)
125
- cmd_bit_tag_id = format(
126
- config.active['cmd_bit_clipboard_copy_bit_tag_id'],
127
- id: id
128
- )
129
-
130
- run cmd_bit_tag_id
131
- end
132
-
133
- # bit export component to bit remote scope.
134
- def _bit_clipboard_copy_export_to_scope(scope)
135
- cmd_bit_export_to_scope = format(
136
- config.active['cmd_bit_clipboard_copy_bit_export_to_scope'],
137
- scope: scope
138
- )
139
-
140
- run cmd_bit_export_to_scope
141
- end
142
- end
@@ -1,143 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takeltau bit clipboard lib
4
- module BitClipboardLib
5
- private
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
-
15
- # Prepare workspace for bit clipboard.
16
- def _bit_clipboard_lib_prepare_workspace
17
- unless bit_check_workspace
18
- log.error 'No bit workspace'
19
- return false
20
- end
21
-
22
- return true unless git_check_workspace
23
-
24
- _bit_clipboard_lib_prepare_git_workspace
25
- end
26
-
27
- # Prepare git workspace for bit clipboard.
28
- def _bit_clipboard_lib_prepare_git_workspace
29
- unless git_check_bit
30
- log.error 'Not on git main branch'
31
- return false
32
- end
33
-
34
- unless git_check_clean
35
- log.error 'No clean git workspace'
36
- return false
37
- end
38
-
39
- _bit_clipboard_lib_git_pull
40
- end
41
-
42
- # Remove bit artifacts.
43
- def _bit_clipbpard_lib_remove_bit_artifacts
44
- log.debug 'Removing bit artifacts'
45
-
46
- # Remove node_modules directory.
47
- FileUtils.remove_entry_secure('node_modules', force: true)
48
-
49
- # Remove index.bit files recursively.
50
- Dir.glob('./**/index.bit').each do |file|
51
- FileUtils.remove_entry_secure(file, force: true)
52
- end
53
-
54
- # Remove package.json file.
55
- FileUtils.remove_entry_secure('package.json', force: true)
56
- end
57
-
58
- # Sync workspace with upstream.
59
- def _bit_clipboard_lib_sync_workspace
60
- log.info 'Syncing git workspace'
61
-
62
- path = config.active['project_root_dir']
63
- file = "#{path}/.bitmap"
64
- message = 'Update .bitmap'
65
-
66
- _bit_clipboard_lib_git_add file
67
- _bit_clipboard_lib_git_commit message
68
- _bit_clipboard_lib_git_push
69
- end
70
-
71
- # git add .bitmap.
72
- def _bit_clipboard_lib_git_add(file)
73
- log.debug "Adding \"#{file}\" to git"
74
-
75
- cmd_bit_clipboard_git_add = format(
76
- config.active['cmd_bit_clipboard_git_add'],
77
- file: file
78
- )
79
- run cmd_bit_clipboard_git_add
80
- end
81
-
82
- # git commit -m "Update .bitmap".
83
- def _bit_clipboard_lib_git_commit(message)
84
- log.debug "Committing to git with message \"#{message}\""
85
-
86
- cmd_bit_clipboard_git_commit = format(
87
- config.active['cmd_bit_clipboard_git_commit'],
88
- message: message
89
- )
90
-
91
- run cmd_bit_clipboard_git_commit
92
- end
93
-
94
- # git push origin main.
95
- def _bit_clipboard_lib_git_push
96
- log.debug 'Pushing main branch to origin'
97
-
98
- cmd_bit_clipboard_git_push = format(
99
- config.active['cmd_bit_clipboard_git_push'],
100
- main: config.active['git_bit_branch']
101
- )
102
-
103
- run cmd_bit_clipboard_git_push
104
- end
105
-
106
- # git pull.
107
- def _bit_clipboard_lib_git_pull
108
- log.info 'Updating git workspace'
109
- cmd_bit_clipboard_git_pull = format(
110
- config.active['cmd_bit_clipboard_git_pull'],
111
- main: config.active['git_bit_branch']
112
- )
113
-
114
- return true if try cmd_bit_clipboard_git_pull
115
-
116
- log.error 'Unable to update git workspace'
117
- false
118
- end
119
-
120
- # Generate bit component ID.
121
- def _bit_clipboard_lib_id(name)
122
- id = ''
123
-
124
- # bit restrictions:
125
- # component names can only contain alphanumeric,
126
- # lowercase characters, and the following ["-", "_", "$", "!", "/"]
127
-
128
- # convert directory name to lowercase characters
129
- dir_downcase = name.downcase
130
-
131
- # construct array of allowed characters
132
- allowed_chars = [*('a'..'z'), *('0'..'9'), '-', '_', '$', '!', '/']
133
-
134
- # iterate over directory or file name
135
- # and replace invalid characters with underscore
136
- dir_downcase.split('').each do |char|
137
- id += allowed_chars.include?(char) ? char : '_'
138
- end
139
-
140
- log.debug "Generated bit id \"#{id}\" from \"#{name}\""
141
- id
142
- end
143
- end