Package not found. Please check the package name and try again.
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.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.md +235 -0
- data/bin/tau +6 -0
- data/lib/Thorfile +3 -0
- data/lib/takeltau.rb +257 -0
- data/lib/takeltau/bit/check/cli.rb +23 -0
- data/lib/takeltau/bit/check/workspace.rb +37 -0
- data/lib/takeltau/bit/cli.rb +18 -0
- data/lib/takeltau/bit/clipboard/cli.rb +73 -0
- data/lib/takeltau/bit/clipboard/copy.rb +142 -0
- data/lib/takeltau/bit/clipboard/lib.rb +143 -0
- data/lib/takeltau/bit/clipboard/paste.rb +60 -0
- data/lib/takeltau/bit/clipboard/pull.rb +37 -0
- data/lib/takeltau/bit/clipboard/push.rb +37 -0
- data/lib/takeltau/bit/require/cli.rb +57 -0
- data/lib/takeltau/bit/require/export.rb +34 -0
- data/lib/takeltau/bit/require/import.rb +133 -0
- data/lib/takeltau/bit/require/lib.rb +19 -0
- data/lib/takeltau/bit/scope/add.rb +55 -0
- data/lib/takeltau/bit/scope/cli.rb +74 -0
- data/lib/takeltau/bit/scope/list.rb +41 -0
- data/lib/takeltau/bit/scope/new.rb +44 -0
- data/lib/takeltau/bit/scope/ssh.rb +13 -0
- data/lib/takeltau/completion/cli.rb +24 -0
- data/lib/takeltau/default.yml +95 -0
- data/lib/takeltau/docker/check/cli.rb +23 -0
- data/lib/takeltau/docker/check/daemon.rb +27 -0
- data/lib/takeltau/docker/cli.rb +15 -0
- data/lib/takeltau/docker/container/check/cli.rb +57 -0
- data/lib/takeltau/docker/container/check/existing.rb +32 -0
- data/lib/takeltau/docker/container/check/network.rb +32 -0
- data/lib/takeltau/docker/container/check/orphaned.rb +32 -0
- data/lib/takeltau/docker/container/clean.rb +40 -0
- data/lib/takeltau/docker/container/cli.rb +118 -0
- data/lib/takeltau/docker/container/command.rb +38 -0
- data/lib/takeltau/docker/container/daemon.rb +17 -0
- data/lib/takeltau/docker/container/lib.rb +181 -0
- data/lib/takeltau/docker/container/login.rb +58 -0
- data/lib/takeltau/docker/container/prune.rb +31 -0
- data/lib/takeltau/docker/image/cli.rb +39 -0
- data/lib/takeltau/docker/image/tag/check.rb +42 -0
- data/lib/takeltau/docker/image/tag/cli.rb +68 -0
- data/lib/takeltau/docker/image/tag/latest.rb +24 -0
- data/lib/takeltau/docker/image/tag/list.rb +19 -0
- data/lib/takeltau/docker/image/update.rb +27 -0
- data/lib/takeltau/git/check/bit.rb +26 -0
- data/lib/takeltau/git/check/clean.rb +46 -0
- data/lib/takeltau/git/check/cli.rb +49 -0
- data/lib/takeltau/git/check/workspace.rb +34 -0
- data/lib/takeltau/git/cli.rb +9 -0
- data/lib/takeltau/info/cli.rb +12 -0
- data/lib/takeltau/info/project/cli.rb +69 -0
- data/lib/takeltau/info/status/bar.rb +112 -0
- data/lib/takeltau/info/status/cli.rb +107 -0
- data/lib/takeltau/info/status/git.rb +47 -0
- data/lib/takeltau/info/status/gopass.rb +37 -0
- data/lib/takeltau/info/status/gpg.rb +39 -0
- data/lib/takeltau/info/status/lib.rb +46 -0
- data/lib/takeltau/info/status/ssh.rb +46 -0
- data/lib/takeltau/init/cli.rb +12 -0
- data/lib/takeltau/init/lib.rb +86 -0
- data/lib/takeltau/init/packer/cli.rb +82 -0
- data/lib/takeltau/init/packer/docker.rb +64 -0
- data/lib/takeltau/init/packer/templates/ansiblelint.tt +3 -0
- data/lib/takeltau/init/packer/templates/bitrequireyml.tt +13 -0
- data/lib/takeltau/init/packer/templates/groupvarsprojectyml.tt +2 -0
- data/lib/takeltau/init/packer/templates/playbooksiteyml.tt +6 -0
- data/lib/takeltau/init/packer/templates/projectyml.tt +19 -0
- data/lib/takeltau/init/takelage/cli.rb +70 -0
- data/lib/takeltau/init/takelage/rake.rb +61 -0
- data/lib/takeltau/init/takelage/templates/bitrequireyml.tt +5 -0
- data/lib/takeltau/init/takelage/templates/projectyml.tt +3 -0
- data/lib/takeltau/init/templates/Rakefile.tt +3 -0
- data/lib/takeltau/init/templates/gitignore.tt +16 -0
- data/lib/takeltau/lib/config.rb +130 -0
- data/lib/takeltau/lib/logging.rb +49 -0
- data/lib/takeltau/lib/project.rb +72 -0
- data/lib/takeltau/lib/subcmd.rb +18 -0
- data/lib/takeltau/lib/system.rb +194 -0
- data/lib/takeltau/mutagen/check/cli.rb +40 -0
- data/lib/takeltau/mutagen/check/daemon.rb +76 -0
- data/lib/takeltau/mutagen/cli.rb +12 -0
- data/lib/takeltau/mutagen/socket/check.rb +33 -0
- data/lib/takeltau/mutagen/socket/cli.rb +103 -0
- data/lib/takeltau/mutagen/socket/create.rb +47 -0
- data/lib/takeltau/mutagen/socket/list.rb +33 -0
- data/lib/takeltau/mutagen/socket/terminate.rb +32 -0
- data/lib/takeltau/mutagen/socket/tidy.rb +21 -0
- data/lib/takeltau/self/cli.rb +43 -0
- data/lib/takeltau/self/config/cli.rb +82 -0
- data/lib/takeltau/self/list.rb +35 -0
- data/lib/takeltau/version +1 -0
- metadata +319 -0
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
|
@@ -0,0 +1,142 @@
|
|
|
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.debug "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
|
|
@@ -0,0 +1,143 @@
|
|
|
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.debug '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.debug '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
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# takeltau bit clipboard paste
|
|
4
|
+
module BitClipboardPaste
|
|
5
|
+
# Backend method for bit paste.
|
|
6
|
+
def bit_clipboard_paste(cid, dir)
|
|
7
|
+
log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
|
|
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_clipboard_paste_cid_exists? cid
|
|
14
|
+
|
|
15
|
+
_bit_clipboard_paste_import_cid cid, dir
|
|
16
|
+
_bit_clipbpard_lib_remove_bit_artifacts
|
|
17
|
+
_bit_clipboard_lib_sync_workspace
|
|
18
|
+
|
|
19
|
+
log.info "Pasted bit component \"#{cid}\" to directory \"#{dir}\""
|
|
20
|
+
true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# paste bit component into directory.
|
|
26
|
+
def _bit_clipboard_paste_import_cid(cid, dir)
|
|
27
|
+
cmd_bit_import_cid = format(
|
|
28
|
+
config.active['cmd_bit_clipboard_paste_bit_import_cid'],
|
|
29
|
+
cid: cid,
|
|
30
|
+
dir: dir
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
run cmd_bit_import_cid
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Check if remote component exists.
|
|
37
|
+
def _bit_clipboard_paste_cid_exists?(cid)
|
|
38
|
+
scope = cid.scan(%r{([^/]*).*}).first.first
|
|
39
|
+
|
|
40
|
+
log.debug "Checking if scope \"#{scope}\" " \
|
|
41
|
+
"contains component id \"#{cid}\""
|
|
42
|
+
|
|
43
|
+
bit_list_scope = _bit_clipboard_paste_cid_exists_list_scope scope
|
|
44
|
+
|
|
45
|
+
return true if bit_list_scope.include? "\"id\": \"#{cid}\","
|
|
46
|
+
|
|
47
|
+
log.error "No remote component \"#{cid}\""
|
|
48
|
+
false
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Get components in remote scope.
|
|
52
|
+
def _bit_clipboard_paste_cid_exists_list_scope(scope)
|
|
53
|
+
cmd_bit_list_scope = format(
|
|
54
|
+
config.active['cmd_bit_clipboard_paste_bit_list_scope'],
|
|
55
|
+
scope: scope
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
run cmd_bit_list_scope
|
|
59
|
+
end
|
|
60
|
+
end
|