takelage 0.18.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 +7 -0
- data/LICENSE +674 -0
- data/README.md +213 -0
- data/bin/tau +6 -0
- data/lib/Thorfile +3 -0
- data/lib/takelage.rb +230 -0
- data/lib/takelage/bit/check/cli.rb +23 -0
- data/lib/takelage/bit/check/workspace.rb +37 -0
- data/lib/takelage/bit/cli.rb +15 -0
- data/lib/takelage/bit/clipboard/cli.rb +73 -0
- data/lib/takelage/bit/clipboard/copy.rb +140 -0
- data/lib/takelage/bit/clipboard/lib.rb +132 -0
- data/lib/takelage/bit/clipboard/paste.rb +57 -0
- data/lib/takelage/bit/clipboard/pull.rb +37 -0
- data/lib/takelage/bit/clipboard/push.rb +37 -0
- data/lib/takelage/bit/scope/add.rb +55 -0
- data/lib/takelage/bit/scope/cli.rb +74 -0
- data/lib/takelage/bit/scope/inbit.rb +13 -0
- data/lib/takelage/bit/scope/list.rb +41 -0
- data/lib/takelage/bit/scope/new.rb +44 -0
- data/lib/takelage/completion/cli.rb +24 -0
- data/lib/takelage/default.yml +68 -0
- data/lib/takelage/docker/check/cli.rb +23 -0
- data/lib/takelage/docker/check/running.rb +23 -0
- data/lib/takelage/docker/cli.rb +18 -0
- data/lib/takelage/docker/container/check/cli.rb +57 -0
- data/lib/takelage/docker/container/check/existing.rb +31 -0
- data/lib/takelage/docker/container/check/network.rb +31 -0
- data/lib/takelage/docker/container/check/orphaned.rb +31 -0
- data/lib/takelage/docker/container/clean.rb +39 -0
- data/lib/takelage/docker/container/cli.rb +114 -0
- data/lib/takelage/docker/container/command.rb +33 -0
- data/lib/takelage/docker/container/daemon.rb +13 -0
- data/lib/takelage/docker/container/lib.rb +160 -0
- data/lib/takelage/docker/container/login.rb +46 -0
- data/lib/takelage/docker/container/prune.rb +30 -0
- data/lib/takelage/docker/image/check/cli.rb +39 -0
- data/lib/takelage/docker/image/check/outdated.rb +40 -0
- data/lib/takelage/docker/image/cli.rb +44 -0
- data/lib/takelage/docker/image/tag/check/cli.rb +48 -0
- data/lib/takelage/docker/image/tag/check/local.rb +42 -0
- data/lib/takelage/docker/image/tag/check/remote.rb +38 -0
- data/lib/takelage/docker/image/tag/cli.rb +15 -0
- data/lib/takelage/docker/image/tag/latest/cli.rb +57 -0
- data/lib/takelage/docker/image/tag/latest/local.rb +20 -0
- data/lib/takelage/docker/image/tag/latest/remote.rb +25 -0
- data/lib/takelage/docker/image/tag/list/cli.rb +53 -0
- data/lib/takelage/docker/image/tag/list/local.rb +19 -0
- data/lib/takelage/docker/image/tag/list/remote.rb +28 -0
- data/lib/takelage/docker/image/update.rb +33 -0
- data/lib/takelage/docker/socket/cli.rb +75 -0
- data/lib/takelage/docker/socket/host.rb +25 -0
- data/lib/takelage/docker/socket/lib.rb +88 -0
- data/lib/takelage/docker/socket/scheme.rb +63 -0
- data/lib/takelage/docker/socket/start.rb +34 -0
- data/lib/takelage/docker/socket/stop.rb +55 -0
- data/lib/takelage/git/check/clean.rb +46 -0
- data/lib/takelage/git/check/cli.rb +49 -0
- data/lib/takelage/git/check/master.rb +26 -0
- data/lib/takelage/git/check/workspace.rb +33 -0
- data/lib/takelage/git/cli.rb +9 -0
- data/lib/takelage/info/cli.rb +9 -0
- data/lib/takelage/info/project/cli.rb +56 -0
- data/lib/takelage/lib/config.rb +114 -0
- data/lib/takelage/lib/logging.rb +47 -0
- data/lib/takelage/lib/project.rb +69 -0
- data/lib/takelage/lib/subcmd.rb +16 -0
- data/lib/takelage/lib/system.rb +104 -0
- data/lib/takelage/self/cli.rb +43 -0
- data/lib/takelage/self/config/cli.rb +82 -0
- data/lib/takelage/self/list.rb +30 -0
- data/lib/takelage/version +1 -0
- metadata +298 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage 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
|
+
# takelage 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.strip
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage 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 'scope [COMMAND]', 'Manage bit scopes'
|
13
|
+
subcommand 'scope', BitScope
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage bit
|
5
|
+
class BitClipboard < SubCommandBase
|
6
|
+
include LoggingModule
|
7
|
+
include ConfigModule
|
8
|
+
include SystemModule
|
9
|
+
include GitCheckClean
|
10
|
+
include GitCheckMaster
|
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,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage 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 _bit_clipboard_lib_prepare_workspace
|
13
|
+
|
14
|
+
unless File.directory? dir
|
15
|
+
log.error "The directory \"#{dir}\" does not exist"
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
_bit_clipboard_copy_dir dir, scope
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# rubocop:disable Metrics/MethodLength
|
25
|
+
def _bit_clipboard_copy_dir(dir, scope)
|
26
|
+
log.debug "Adding the directory \"#{dir}\" as a tagged bit component"
|
27
|
+
|
28
|
+
return false unless _bit_clipboard_copy_dir_scope_exists? scope
|
29
|
+
|
30
|
+
return false if _bit_clipboard_copy_readme_bit_exists_in_subdir? dir
|
31
|
+
|
32
|
+
id = _bit_clipboard_lib_id(dir)
|
33
|
+
|
34
|
+
_bit_clipboard_copy_touch_readme_bit dir
|
35
|
+
_bit_clipboard_copy_add_dir id, dir
|
36
|
+
_bit_clipboard_copy_tag_dir id
|
37
|
+
_bit_clipboard_copy_export_to_scope scope
|
38
|
+
_bit_clipbpard_lib_remove_bit_artifacts
|
39
|
+
_bit_clipboard_lib_sync_workspace
|
40
|
+
|
41
|
+
log.info "Copied directory \"#{dir}\" as bit component \"#{id}\" " \
|
42
|
+
"to bit remote scope \"#{scope}\""
|
43
|
+
end
|
44
|
+
# rubocop:enable Metrics/MethodLength
|
45
|
+
|
46
|
+
# touch README.bit if necessary
|
47
|
+
def _bit_clipboard_copy_touch_readme_bit(dir)
|
48
|
+
readme_bit = "#{dir}/README.bit"
|
49
|
+
return if File.file? readme_bit
|
50
|
+
|
51
|
+
log.info "Creating \"README.bit\" in \"#{dir}\""
|
52
|
+
File.open(readme_bit, 'w') {}
|
53
|
+
end
|
54
|
+
|
55
|
+
# check if a README.bit file exists in a subdirectory
|
56
|
+
def _bit_clipboard_copy_readme_bit_exists_in_subdir?(dir)
|
57
|
+
Dir.glob("#{dir}/**/README.bit").each do |file|
|
58
|
+
unless file == "#{dir}/README.bit"
|
59
|
+
log.error 'Nested README.bit file detected'
|
60
|
+
return true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
false
|
65
|
+
end
|
66
|
+
|
67
|
+
# Check if bit scope exists
|
68
|
+
def _bit_clipboard_copy_dir_scope_exists?(scope)
|
69
|
+
bit_dev = config.active['bit_dev_user']
|
70
|
+
|
71
|
+
# check if scope is a candidate for a bit.dev remote scope
|
72
|
+
if scope.start_with? bit_dev + '.'
|
73
|
+
return false unless _bit_clipboard_bit_dev_scope_exists scope
|
74
|
+
else
|
75
|
+
return false unless _bit_clipboard_custom_scope_exists scope
|
76
|
+
end
|
77
|
+
|
78
|
+
true
|
79
|
+
end
|
80
|
+
|
81
|
+
# check if bit.dev remote scope exists
|
82
|
+
def _bit_clipboard_bit_dev_scope_exists(scope)
|
83
|
+
cmd_bit_list_scope = format(
|
84
|
+
config.active['cmd_bit_clipboard_copy_bit_list_scope'],
|
85
|
+
scope: scope
|
86
|
+
)
|
87
|
+
|
88
|
+
status = try cmd_bit_list_scope
|
89
|
+
|
90
|
+
return true if status.exitstatus.zero?
|
91
|
+
|
92
|
+
log.error "No bit.dev remote scope \"#{scope}\" found"
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
# check if bit remote scope is added to local workspace
|
97
|
+
def _bit_clipboard_custom_scope_exists(scope)
|
98
|
+
cmd_bit_list_remotes =
|
99
|
+
config.active['cmd_bit_clipboard_copy_bit_list_remotes']
|
100
|
+
|
101
|
+
stdout_str = run cmd_bit_list_remotes
|
102
|
+
|
103
|
+
return true if /.*\s+#{scope}\s+.*/m.match? stdout_str
|
104
|
+
|
105
|
+
log.error "No bit remote scope \"#{scope}\" " \
|
106
|
+
'found in local bit workspace'
|
107
|
+
false
|
108
|
+
end
|
109
|
+
|
110
|
+
# bit tag dir
|
111
|
+
def _bit_clipboard_copy_add_dir(id, dir)
|
112
|
+
cmd_bit_add_dir = format(
|
113
|
+
config.active['cmd_bit_clipboard_copy_bit_add_dir'],
|
114
|
+
id: id,
|
115
|
+
dir: dir
|
116
|
+
)
|
117
|
+
|
118
|
+
run cmd_bit_add_dir
|
119
|
+
end
|
120
|
+
|
121
|
+
# bit tag dir
|
122
|
+
def _bit_clipboard_copy_tag_dir(id)
|
123
|
+
cmd_bit_tag_id = format(
|
124
|
+
config.active['cmd_bit_clipboard_copy_bit_tag_id'],
|
125
|
+
id: id
|
126
|
+
)
|
127
|
+
|
128
|
+
run cmd_bit_tag_id
|
129
|
+
end
|
130
|
+
|
131
|
+
# bit export component to bit remote scope
|
132
|
+
def _bit_clipboard_copy_export_to_scope(scope)
|
133
|
+
cmd_bit_export_to_scope = format(
|
134
|
+
config.active['cmd_bit_clipboard_copy_bit_export_to_scope'],
|
135
|
+
scope: scope
|
136
|
+
)
|
137
|
+
|
138
|
+
run cmd_bit_export_to_scope
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage bit clipboard lib
|
4
|
+
module BitClipboardLib
|
5
|
+
private
|
6
|
+
|
7
|
+
# Prepare workspace for bit clipboard.
|
8
|
+
def _bit_clipboard_lib_prepare_workspace
|
9
|
+
unless bit_check_workspace
|
10
|
+
log.error 'No bit workspace'
|
11
|
+
return false
|
12
|
+
end
|
13
|
+
|
14
|
+
return true unless git_check_workspace
|
15
|
+
|
16
|
+
_bit_clipboard_lib_prepare_git_workspace
|
17
|
+
end
|
18
|
+
|
19
|
+
# Prepare git workspace for bit clipboard.
|
20
|
+
def _bit_clipboard_lib_prepare_git_workspace
|
21
|
+
unless git_check_master
|
22
|
+
log.error 'Not on git master branch'
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
|
26
|
+
unless git_check_clean
|
27
|
+
log.error 'No clean git workspace'
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
|
31
|
+
_bit_clipboard_lib_git_pull
|
32
|
+
end
|
33
|
+
|
34
|
+
# Remove bit artifacts.
|
35
|
+
def _bit_clipbpard_lib_remove_bit_artifacts
|
36
|
+
log.debug 'Removing bit artifacts'
|
37
|
+
|
38
|
+
# Remove node_modules directory.
|
39
|
+
FileUtils.remove_entry_secure('node_modules', force: true)
|
40
|
+
|
41
|
+
# Remove index.bit files recursively.
|
42
|
+
Dir.glob('./**/index.bit').each do |file|
|
43
|
+
FileUtils.remove_entry_secure(file, force: true)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Remove package.json file.
|
47
|
+
FileUtils.remove_entry_secure('package.json', force: true)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Sync workspace with upstream.
|
51
|
+
def _bit_clipboard_lib_sync_workspace
|
52
|
+
log.debug 'Syncing git workspace'
|
53
|
+
|
54
|
+
_rakefile, path = Rake.application.find_rakefile_location
|
55
|
+
bitmap = "#{path}/.bitmap"
|
56
|
+
|
57
|
+
_bit_clipboard_lib_git_add bitmap
|
58
|
+
_bit_clipboard_lib_git_commit bitmap
|
59
|
+
_bit_clipboard_lib_git_push
|
60
|
+
end
|
61
|
+
|
62
|
+
# git add .bitmap
|
63
|
+
def _bit_clipboard_lib_git_add(bitmap)
|
64
|
+
log.debug "Adding \"#{bitmap}\" to git"
|
65
|
+
|
66
|
+
cmd_bit_clipboard_git_add = format(
|
67
|
+
config.active['cmd_bit_clipboard_git_add'],
|
68
|
+
file: bitmap
|
69
|
+
)
|
70
|
+
run cmd_bit_clipboard_git_add
|
71
|
+
end
|
72
|
+
|
73
|
+
# git commit -m "Update .bitmap"
|
74
|
+
def _bit_clipboard_lib_git_commit(bitmap)
|
75
|
+
message = 'Update .bitmap'
|
76
|
+
|
77
|
+
log.debug "Committing \"#{bitmap}\" to git"
|
78
|
+
|
79
|
+
cmd_bit_clipboard_git_commit = format(
|
80
|
+
config.active['cmd_bit_clipboard_git_commit'],
|
81
|
+
message: message
|
82
|
+
)
|
83
|
+
|
84
|
+
run cmd_bit_clipboard_git_commit
|
85
|
+
end
|
86
|
+
|
87
|
+
# git push origin master
|
88
|
+
def _bit_clipboard_lib_git_push
|
89
|
+
log.debug 'Pushing master branch to origin'
|
90
|
+
|
91
|
+
cmd_bit_clipboard_git_push =
|
92
|
+
config.active['cmd_bit_clipboard_git_push']
|
93
|
+
|
94
|
+
run cmd_bit_clipboard_git_push
|
95
|
+
end
|
96
|
+
|
97
|
+
# git pull
|
98
|
+
def _bit_clipboard_lib_git_pull
|
99
|
+
log.debug 'Updating git workspace'
|
100
|
+
cmd_bit_clipboard_git_pull =
|
101
|
+
config.active['cmd_bit_clipboard_git_pull']
|
102
|
+
|
103
|
+
return true if try cmd_bit_clipboard_git_pull
|
104
|
+
|
105
|
+
log.error 'Unable to update git workspace'
|
106
|
+
false
|
107
|
+
end
|
108
|
+
|
109
|
+
# Generate bit component ID.
|
110
|
+
def _bit_clipboard_lib_id(name)
|
111
|
+
id = ''
|
112
|
+
|
113
|
+
# bit restrictions:
|
114
|
+
# component names can only contain alphanumeric,
|
115
|
+
# lowercase characters, and the following ["-", "_", "$", "!", "/"]
|
116
|
+
|
117
|
+
# convert directory name to lowercase characters
|
118
|
+
dir_downcase = name.downcase
|
119
|
+
|
120
|
+
# construct array of allowed characters
|
121
|
+
allowed_chars = [*('a'..'z'), *('0'..'9'), '-', '_', '$', '!', '/']
|
122
|
+
|
123
|
+
# iterate over directory or file name
|
124
|
+
# and replace invalid characters with underscore
|
125
|
+
dir_downcase.split('').each do |char|
|
126
|
+
id += allowed_chars.include?(char) ? char : '_'
|
127
|
+
end
|
128
|
+
|
129
|
+
log.debug "Generated bit id \"#{id}\" from \"#{name}\""
|
130
|
+
id
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage 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 _bit_clipboard_lib_prepare_workspace
|
10
|
+
|
11
|
+
return false unless _bit_clipboard_paste_cid_exists? cid
|
12
|
+
|
13
|
+
_bit_clipboard_paste_import_cid cid, dir
|
14
|
+
_bit_clipbpard_lib_remove_bit_artifacts
|
15
|
+
_bit_clipboard_lib_sync_workspace
|
16
|
+
|
17
|
+
log.info "Pasted bit component \"#{cid}\" to directory \"#{dir}\""
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# paste bit component into directory
|
24
|
+
def _bit_clipboard_paste_import_cid(cid, dir)
|
25
|
+
cmd_bit_import_cid = format(
|
26
|
+
config.active['cmd_bit_clipboard_paste_bit_import_cid'],
|
27
|
+
cid: cid,
|
28
|
+
dir: dir
|
29
|
+
)
|
30
|
+
|
31
|
+
run cmd_bit_import_cid
|
32
|
+
end
|
33
|
+
|
34
|
+
def _bit_clipboard_paste_cid_exists?(cid)
|
35
|
+
scope = cid.scan(%r{([^/]*).*}).first.first
|
36
|
+
|
37
|
+
log.debug "Checking if scope \"#{scope}\" " \
|
38
|
+
"contains component id \"#{cid}\""
|
39
|
+
|
40
|
+
bit_list_scope = _bit_clipboard_paste_cid_exists_list_scope scope
|
41
|
+
|
42
|
+
return true if bit_list_scope.include? '"id": "' + cid + '",'
|
43
|
+
|
44
|
+
log.error "No remote component \"#{cid}\""
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
# get components in remote scope
|
49
|
+
def _bit_clipboard_paste_cid_exists_list_scope(scope)
|
50
|
+
cmd_bit_list_scope = format(
|
51
|
+
config.active['cmd_bit_clipboard_paste_bit_list_scope'],
|
52
|
+
scope: scope
|
53
|
+
)
|
54
|
+
|
55
|
+
run cmd_bit_list_scope
|
56
|
+
end
|
57
|
+
end
|