takelage 0.13.3 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takelage.rb +37 -14
- data/lib/takelage/bit/check/cli.rb +1 -1
- data/lib/takelage/bit/check/{module.rb → workspace.rb} +2 -2
- data/lib/takelage/bit/clipboard/cli.rb +9 -3
- data/lib/takelage/bit/clipboard/copy.rb +140 -0
- data/lib/takelage/bit/clipboard/lib.rb +153 -0
- data/lib/takelage/bit/clipboard/paste.rb +58 -0
- data/lib/takelage/bit/clipboard/pull.rb +38 -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 +7 -3
- 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/default.yml +4 -3
- data/lib/takelage/docker/check/cli.rb +1 -1
- data/lib/takelage/docker/check/{module.rb → running.rb} +2 -2
- data/lib/takelage/docker/container/check/cli.rb +4 -2
- 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/cli.rb +35 -34
- 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 +149 -0
- data/lib/takelage/docker/container/login.rb +46 -0
- data/lib/takelage/docker/container/nuke.rb +39 -0
- data/lib/takelage/docker/container/purge.rb +30 -0
- data/lib/takelage/docker/image/check/cli.rb +4 -4
- data/lib/takelage/docker/image/check/{module.rb → outdated.rb} +4 -5
- data/lib/takelage/docker/image/cli.rb +4 -4
- data/lib/takelage/docker/image/tag/check/cli.rb +4 -3
- data/lib/takelage/docker/image/tag/check/{module.rb → local.rb} +2 -34
- data/lib/takelage/docker/image/tag/check/remote.rb +38 -0
- data/lib/takelage/docker/image/tag/latest/cli.rb +5 -3
- data/lib/takelage/docker/image/tag/latest/local.rb +20 -0
- data/lib/takelage/docker/image/tag/latest/{module.rb → remote.rb} +2 -18
- data/lib/takelage/docker/image/tag/list/cli.rb +3 -2
- data/lib/takelage/docker/image/tag/list/local.rb +19 -0
- data/lib/takelage/docker/image/tag/list/{module.rb → remote.rb} +2 -17
- data/lib/takelage/docker/image/{module.rb → update.rb} +2 -2
- data/lib/takelage/docker/socket/cli.rb +6 -2
- 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 +46 -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 +3 -1
- data/lib/takelage/git/check/master.rb +26 -0
- data/lib/takelage/git/check/workspace.rb +33 -0
- data/lib/takelage/self/cli.rb +1 -1
- data/lib/takelage/self/{module.rb → list.rb} +2 -2
- data/lib/takelage/version +1 -1
- metadata +38 -15
- data/lib/takelage/bit/clipboard/module.rb +0 -401
- data/lib/takelage/bit/scope/module.rb +0 -122
- data/lib/takelage/docker/container/check/module.rb +0 -81
- data/lib/takelage/docker/container/module.rb +0 -295
- data/lib/takelage/docker/socket/module.rb +0 -227
- data/lib/takelage/git/check/module.rb +0 -93
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage git check clean
|
4
|
+
module GitCheckClean
|
5
|
+
# Backend method for git check clean.
|
6
|
+
# @return [Boolean] is git workspace clean?
|
7
|
+
def git_check_clean
|
8
|
+
log.debug 'Checking if git workspace is clean'
|
9
|
+
|
10
|
+
return false unless git_check_workspace
|
11
|
+
|
12
|
+
status_unstaged = _git_check_clean_get_status_unstaged
|
13
|
+
status_uncommitted = _git_check_clean_get_status_uncommitted
|
14
|
+
stdout_str_status = _git_check_clean_get_str_status
|
15
|
+
|
16
|
+
# only return true if neither unstaged nor uncommitted nor empty files
|
17
|
+
sum = status_unstaged.exitstatus +
|
18
|
+
status_uncommitted.exitstatus +
|
19
|
+
stdout_str_status.length
|
20
|
+
|
21
|
+
sum.zero?
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# Get git status of unstaged changes.
|
27
|
+
def _git_check_clean_get_status_unstaged
|
28
|
+
cmd_git_unstaged =
|
29
|
+
config.active['cmd_git_check_clean_git_unstaged']
|
30
|
+
try cmd_git_unstaged
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get git status of uncommitted changes.
|
34
|
+
def _git_check_clean_get_status_uncommitted
|
35
|
+
cmd_git_uncommitted =
|
36
|
+
config.active['cmd_git_check_clean_git_uncommitted']
|
37
|
+
try cmd_git_uncommitted
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get git status result.
|
41
|
+
def _git_check_clean_get_str_status
|
42
|
+
cmd_git_status =
|
43
|
+
config.active['cmd_git_check_clean_git_status']
|
44
|
+
run cmd_git_status
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage git check workspace
|
4
|
+
module GitCheckWorkspace
|
5
|
+
# Backend method for git check workspace.
|
6
|
+
# @return [Boolean] is this a git workspace?
|
7
|
+
def git_check_workspace
|
8
|
+
log.debug 'Check if this is a git workspace'
|
9
|
+
status_repo = _git_check_workspace_get_status_repo
|
10
|
+
dir = _git_check_workspace_get_dir
|
11
|
+
unless status_repo.exitstatus.zero?
|
12
|
+
log.debug "No git workspace found in \"#{dir}\""
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Get git repository status.
|
21
|
+
def _git_check_workspace_get_status_repo
|
22
|
+
cmd_git_repo =
|
23
|
+
config.active['cmd_git_check_workspace_git_repo']
|
24
|
+
try cmd_git_repo
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get current working directory.
|
28
|
+
def _git_check_workspace_get_dir
|
29
|
+
cmd_pwd =
|
30
|
+
config.active['cmd_git_check_workspace_pwd']
|
31
|
+
(run cmd_pwd).strip
|
32
|
+
end
|
33
|
+
end
|
data/lib/takelage/self/cli.rb
CHANGED
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.14.0
|
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.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geospin
|
@@ -206,36 +206,59 @@ files:
|
|
206
206
|
- lib/Thorfile
|
207
207
|
- lib/takelage.rb
|
208
208
|
- lib/takelage/bit/check/cli.rb
|
209
|
-
- lib/takelage/bit/check/
|
209
|
+
- lib/takelage/bit/check/workspace.rb
|
210
210
|
- lib/takelage/bit/cli.rb
|
211
211
|
- lib/takelage/bit/clipboard/cli.rb
|
212
|
-
- lib/takelage/bit/clipboard/
|
212
|
+
- lib/takelage/bit/clipboard/copy.rb
|
213
|
+
- lib/takelage/bit/clipboard/lib.rb
|
214
|
+
- lib/takelage/bit/clipboard/paste.rb
|
215
|
+
- lib/takelage/bit/clipboard/pull.rb
|
216
|
+
- lib/takelage/bit/clipboard/push.rb
|
217
|
+
- lib/takelage/bit/scope/add.rb
|
213
218
|
- lib/takelage/bit/scope/cli.rb
|
214
|
-
- lib/takelage/bit/scope/
|
219
|
+
- lib/takelage/bit/scope/inbit.rb
|
220
|
+
- lib/takelage/bit/scope/list.rb
|
221
|
+
- lib/takelage/bit/scope/new.rb
|
215
222
|
- lib/takelage/completion/cli.rb
|
216
223
|
- lib/takelage/default.yml
|
217
224
|
- lib/takelage/docker/check/cli.rb
|
218
|
-
- lib/takelage/docker/check/
|
225
|
+
- lib/takelage/docker/check/running.rb
|
219
226
|
- lib/takelage/docker/cli.rb
|
220
227
|
- lib/takelage/docker/container/check/cli.rb
|
221
|
-
- lib/takelage/docker/container/check/
|
228
|
+
- lib/takelage/docker/container/check/existing.rb
|
229
|
+
- lib/takelage/docker/container/check/network.rb
|
230
|
+
- lib/takelage/docker/container/check/orphaned.rb
|
222
231
|
- lib/takelage/docker/container/cli.rb
|
223
|
-
- lib/takelage/docker/container/
|
232
|
+
- lib/takelage/docker/container/command.rb
|
233
|
+
- lib/takelage/docker/container/daemon.rb
|
234
|
+
- lib/takelage/docker/container/lib.rb
|
235
|
+
- lib/takelage/docker/container/login.rb
|
236
|
+
- lib/takelage/docker/container/nuke.rb
|
237
|
+
- lib/takelage/docker/container/purge.rb
|
224
238
|
- lib/takelage/docker/image/check/cli.rb
|
225
|
-
- lib/takelage/docker/image/check/
|
239
|
+
- lib/takelage/docker/image/check/outdated.rb
|
226
240
|
- lib/takelage/docker/image/cli.rb
|
227
|
-
- lib/takelage/docker/image/module.rb
|
228
241
|
- lib/takelage/docker/image/tag/check/cli.rb
|
229
|
-
- lib/takelage/docker/image/tag/check/
|
242
|
+
- lib/takelage/docker/image/tag/check/local.rb
|
243
|
+
- lib/takelage/docker/image/tag/check/remote.rb
|
230
244
|
- lib/takelage/docker/image/tag/cli.rb
|
231
245
|
- lib/takelage/docker/image/tag/latest/cli.rb
|
232
|
-
- lib/takelage/docker/image/tag/latest/
|
246
|
+
- lib/takelage/docker/image/tag/latest/local.rb
|
247
|
+
- lib/takelage/docker/image/tag/latest/remote.rb
|
233
248
|
- lib/takelage/docker/image/tag/list/cli.rb
|
234
|
-
- lib/takelage/docker/image/tag/list/
|
249
|
+
- lib/takelage/docker/image/tag/list/local.rb
|
250
|
+
- lib/takelage/docker/image/tag/list/remote.rb
|
251
|
+
- lib/takelage/docker/image/update.rb
|
235
252
|
- lib/takelage/docker/socket/cli.rb
|
236
|
-
- lib/takelage/docker/socket/
|
253
|
+
- lib/takelage/docker/socket/host.rb
|
254
|
+
- lib/takelage/docker/socket/lib.rb
|
255
|
+
- lib/takelage/docker/socket/scheme.rb
|
256
|
+
- lib/takelage/docker/socket/start.rb
|
257
|
+
- lib/takelage/docker/socket/stop.rb
|
258
|
+
- lib/takelage/git/check/clean.rb
|
237
259
|
- lib/takelage/git/check/cli.rb
|
238
|
-
- lib/takelage/git/check/
|
260
|
+
- lib/takelage/git/check/master.rb
|
261
|
+
- lib/takelage/git/check/workspace.rb
|
239
262
|
- lib/takelage/git/cli.rb
|
240
263
|
- lib/takelage/info/cli.rb
|
241
264
|
- lib/takelage/info/project/cli.rb
|
@@ -246,7 +269,7 @@ files:
|
|
246
269
|
- lib/takelage/lib/system.rb
|
247
270
|
- lib/takelage/self/cli.rb
|
248
271
|
- lib/takelage/self/config/cli.rb
|
249
|
-
- lib/takelage/self/
|
272
|
+
- lib/takelage/self/list.rb
|
250
273
|
- lib/takelage/version
|
251
274
|
homepage: https://github.com/geospin-takelage/takelage-cli
|
252
275
|
licenses:
|
@@ -1,401 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# takelage bit clipboard module
|
4
|
-
module BitClipboardModule
|
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_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
|
-
# Backend method for bit paste.
|
23
|
-
def bit_clipboard_paste(cid, dir)
|
24
|
-
log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
|
25
|
-
|
26
|
-
return false unless _bit_clipboard_prepare_workspace
|
27
|
-
|
28
|
-
return false unless _bit_clipboard_cid_exists? cid
|
29
|
-
|
30
|
-
_bit_clipboard_import_cid cid, dir
|
31
|
-
_handle_bitignore
|
32
|
-
_bit_clipbpard_remove_bit_artifacts
|
33
|
-
_bit_clipboard_sync_workspace
|
34
|
-
|
35
|
-
log.info "Pasted bit component \"#{cid}\" to directory \"#{dir}\""
|
36
|
-
true
|
37
|
-
end
|
38
|
-
|
39
|
-
# Backend method for bit pull.
|
40
|
-
def bit_clipboard_pull
|
41
|
-
log.debug 'Running bit pull'
|
42
|
-
|
43
|
-
return false unless _bit_clipboard_prepare_workspace
|
44
|
-
|
45
|
-
_bit_clipboard_import_all
|
46
|
-
_bit_clipboard_checkout_all
|
47
|
-
_handle_bitignore
|
48
|
-
_bit_clipbpard_remove_bit_artifacts
|
49
|
-
_bit_clipboard_sync_workspace
|
50
|
-
|
51
|
-
log.info 'Pulled bit components'
|
52
|
-
true
|
53
|
-
end
|
54
|
-
|
55
|
-
# Backend method for bit push
|
56
|
-
def bit_clipboard_push
|
57
|
-
log.debug 'Running bit push'
|
58
|
-
|
59
|
-
return false unless _bit_clipboard_prepare_workspace
|
60
|
-
|
61
|
-
_bit_clipboard_tag_all
|
62
|
-
_bit_clipboard_export_all
|
63
|
-
_bit_clipbpard_remove_bit_artifacts
|
64
|
-
_bit_clipboard_sync_workspace
|
65
|
-
|
66
|
-
log.info 'Pushed bit components'
|
67
|
-
true
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
# rubocop:disable Metrics/MethodLength
|
73
|
-
def _bit_clipboard_copy_dir(dir, scope)
|
74
|
-
log.debug "Adding the directory \"#{dir}\" as a tagged bit component"
|
75
|
-
|
76
|
-
return false unless _bit_clipboard_copy_dir_scope_exists scope
|
77
|
-
|
78
|
-
return false if _bit_clipboard_readme_bit_exists_in_subdir dir
|
79
|
-
|
80
|
-
id = _id(dir)
|
81
|
-
|
82
|
-
_bit_clipboard_touch_readme_bit dir
|
83
|
-
_bit_clipboard_add_dir id, dir
|
84
|
-
_bit_clipboard_tag_dir id
|
85
|
-
_bit_clipboard_export_to_scope scope
|
86
|
-
_bit_clipbpard_remove_bit_artifacts
|
87
|
-
_bit_clipboard_sync_workspace
|
88
|
-
|
89
|
-
log.info "Copied directory \"#{dir}\" as bit component \"#{id}\" " \
|
90
|
-
"to bit remote scope \"#{scope}\""
|
91
|
-
end
|
92
|
-
# rubocop:enable Metrics/MethodLength
|
93
|
-
|
94
|
-
# Genereate .gitignore if bitignore is present
|
95
|
-
def _handle_bitignore
|
96
|
-
log.debug 'Handling bitgnore files'
|
97
|
-
|
98
|
-
# find all bitgnore files
|
99
|
-
Dir.glob('./**/bitignore').each do |file|
|
100
|
-
# get directory of bitignore file
|
101
|
-
dir = File.dirname file
|
102
|
-
|
103
|
-
# build gitignore filepath
|
104
|
-
gitignore_file = "#{dir}/.gitignore"
|
105
|
-
|
106
|
-
unless File.exist? gitignore_file
|
107
|
-
log.debug "Creating \".gitignore\" in \"#{dir}\""
|
108
|
-
File.open(gitignore_file, 'w') { |gitignore| gitignore.write('*') }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# touch README.bit if necessary
|
114
|
-
def _bit_clipboard_touch_readme_bit(dir)
|
115
|
-
readme_bit = "#{dir}/README.bit"
|
116
|
-
return if File.file? readme_bit
|
117
|
-
|
118
|
-
log.info "Creating \"README.bit\" in \"#{dir}\""
|
119
|
-
File.open(readme_bit, 'w') {}
|
120
|
-
end
|
121
|
-
|
122
|
-
# check if a README.bit file exists in a subdirectory
|
123
|
-
def _bit_clipboard_readme_bit_exists_in_subdir(dir)
|
124
|
-
Dir.glob("#{dir}/**/README.bit").each do |file|
|
125
|
-
unless file == "#{dir}/README.bit"
|
126
|
-
log.error 'Nested README.bit file detected'
|
127
|
-
return true
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
false
|
132
|
-
end
|
133
|
-
|
134
|
-
# Check if bit scope exists
|
135
|
-
def _bit_clipboard_copy_dir_scope_exists(scope)
|
136
|
-
bit_dev = config.active['bit_dev_user']
|
137
|
-
|
138
|
-
# check if scope is a candidate for a bit.dev remote scope
|
139
|
-
if scope.start_with? bit_dev + '.'
|
140
|
-
return false unless _bit_clipboard_bit_dev_scope_exists scope
|
141
|
-
else
|
142
|
-
return false unless _bit_clipboard_custom_scope_exists scope
|
143
|
-
end
|
144
|
-
|
145
|
-
true
|
146
|
-
end
|
147
|
-
|
148
|
-
# check if bit.dev remote scope exists
|
149
|
-
def _bit_clipboard_bit_dev_scope_exists(scope)
|
150
|
-
cmd_bit_list_scope = format(
|
151
|
-
config.active['cmd_bit_clipboard_copy_bit_list_scope'],
|
152
|
-
scope: scope
|
153
|
-
)
|
154
|
-
|
155
|
-
status = try cmd_bit_list_scope
|
156
|
-
|
157
|
-
return true if status.exitstatus.zero?
|
158
|
-
|
159
|
-
log.error "No bit.dev remote scope \"#{scope}\" found"
|
160
|
-
false
|
161
|
-
end
|
162
|
-
|
163
|
-
# check if bit remote scope is added to local workspace
|
164
|
-
def _bit_clipboard_custom_scope_exists(scope)
|
165
|
-
cmd_bit_list_remotes =
|
166
|
-
config.active['cmd_bit_clipboard_copy_bit_list_remotes']
|
167
|
-
|
168
|
-
stdout_str = run cmd_bit_list_remotes
|
169
|
-
|
170
|
-
return true if /.*\s+#{scope}\s+.*/m.match? stdout_str
|
171
|
-
|
172
|
-
log.error "No bit remote scope \"#{scope}\" " \
|
173
|
-
'found in local bit workspace'
|
174
|
-
false
|
175
|
-
end
|
176
|
-
|
177
|
-
# Generate bit component ID.
|
178
|
-
def _id(name)
|
179
|
-
id = ''
|
180
|
-
|
181
|
-
# bit restrictions:
|
182
|
-
# component names can only contain alphanumeric,
|
183
|
-
# lowercase characters, and the following ["-", "_", "$", "!", "/"]
|
184
|
-
|
185
|
-
# convert directory name to lowercase characters
|
186
|
-
dir_downcase = name.downcase
|
187
|
-
|
188
|
-
# construct array of allowed characters
|
189
|
-
allowed_chars = [*('a'..'z'), *('0'..'9'), '-', '_', '$', '!', '/']
|
190
|
-
|
191
|
-
# iterate over directory or file name
|
192
|
-
# and replace invalid characters with underscore
|
193
|
-
dir_downcase.split('').each do |char|
|
194
|
-
id += allowed_chars.include?(char) ? char : '_'
|
195
|
-
end
|
196
|
-
|
197
|
-
log.debug "Generated bit id \"#{id}\" from \"#{name}\""
|
198
|
-
id
|
199
|
-
end
|
200
|
-
|
201
|
-
# Prepare workspace for bit clipboard.
|
202
|
-
# rubocop:disable Metrics/MethodLength
|
203
|
-
def _bit_clipboard_prepare_workspace
|
204
|
-
unless bit_check_workspace
|
205
|
-
log.error 'No bit workspace'
|
206
|
-
return false
|
207
|
-
end
|
208
|
-
|
209
|
-
if git_check_workspace
|
210
|
-
unless git_check_master
|
211
|
-
log.error 'Not on git master branch'
|
212
|
-
return false
|
213
|
-
end
|
214
|
-
|
215
|
-
unless git_check_clean
|
216
|
-
log.error 'No clean git workspace'
|
217
|
-
return false
|
218
|
-
end
|
219
|
-
|
220
|
-
return _bit_clipboard_git_pull
|
221
|
-
end
|
222
|
-
|
223
|
-
true
|
224
|
-
end
|
225
|
-
# rubocop:enable Metrics/MethodLength
|
226
|
-
|
227
|
-
def _bit_clipboard_cid_exists?(cid)
|
228
|
-
scope = cid.scan(%r{([^/]*).*}).first.first
|
229
|
-
|
230
|
-
log.debug "Checking if scope \"#{scope}\" " \
|
231
|
-
"contains component id \"#{cid}\""
|
232
|
-
|
233
|
-
bit_list_scope = _bit_clipboard_cid_exists_list_scope scope
|
234
|
-
|
235
|
-
return true if bit_list_scope.include? '"id": "' + cid + '",'
|
236
|
-
|
237
|
-
log.error "No remote component \"#{cid}\""
|
238
|
-
false
|
239
|
-
end
|
240
|
-
|
241
|
-
# Remove bit artifacts.
|
242
|
-
def _bit_clipbpard_remove_bit_artifacts
|
243
|
-
log.debug 'Removing bit artifacts'
|
244
|
-
|
245
|
-
# Remove node_modules directory.
|
246
|
-
FileUtils.remove_entry_secure('node_modules', force: true)
|
247
|
-
|
248
|
-
# Remove index.bit files recursively.
|
249
|
-
Dir.glob('./**/index.bit').each do |file|
|
250
|
-
FileUtils.remove_entry_secure(file, force: true)
|
251
|
-
end
|
252
|
-
|
253
|
-
# Remove package.json file.
|
254
|
-
FileUtils.remove_entry_secure('package.json', force: true)
|
255
|
-
end
|
256
|
-
|
257
|
-
# bit tag dir
|
258
|
-
def _bit_clipboard_add_dir(id, dir)
|
259
|
-
cmd_bit_add_dir = format(
|
260
|
-
config.active['cmd_bit_clipboard_copy_bit_add_dir'],
|
261
|
-
id: id,
|
262
|
-
dir: dir
|
263
|
-
)
|
264
|
-
|
265
|
-
run cmd_bit_add_dir
|
266
|
-
end
|
267
|
-
|
268
|
-
# bit tag dir
|
269
|
-
def _bit_clipboard_tag_dir(id)
|
270
|
-
cmd_bit_tag_id = format(
|
271
|
-
config.active['cmd_bit_clipboard_copy_bit_tag_id'],
|
272
|
-
id: id
|
273
|
-
)
|
274
|
-
|
275
|
-
run cmd_bit_tag_id
|
276
|
-
end
|
277
|
-
|
278
|
-
# bit export component to bit remote scope
|
279
|
-
def _bit_clipboard_export_to_scope(scope)
|
280
|
-
cmd_bit_export_to_scope = format(
|
281
|
-
config.active['cmd_bit_clipboard_copy_bit_export_to_scope'],
|
282
|
-
scope: scope
|
283
|
-
)
|
284
|
-
|
285
|
-
run cmd_bit_export_to_scope
|
286
|
-
end
|
287
|
-
|
288
|
-
# paste bit component into directory
|
289
|
-
def _bit_clipboard_import_cid(cid, dir)
|
290
|
-
cmd_bit_import_cid = format(
|
291
|
-
config.active['cmd_bit_clipboard_paste_bit_import_cid'],
|
292
|
-
cid: cid,
|
293
|
-
dir: dir
|
294
|
-
)
|
295
|
-
|
296
|
-
run cmd_bit_import_cid
|
297
|
-
end
|
298
|
-
|
299
|
-
# bit import components into workspace
|
300
|
-
def _bit_clipboard_import_all
|
301
|
-
cmd_bit_import_all =
|
302
|
-
config.active['cmd_bit_clipboard_pull_bit_import_all']
|
303
|
-
|
304
|
-
run cmd_bit_import_all
|
305
|
-
end
|
306
|
-
|
307
|
-
# checkout components and merge them
|
308
|
-
def _bit_clipboard_checkout_all
|
309
|
-
cmd_bit_checkout_all =
|
310
|
-
config.active['cmd_bit_clipboard_pull_bit_checkout_all']
|
311
|
-
|
312
|
-
run cmd_bit_checkout_all
|
313
|
-
end
|
314
|
-
|
315
|
-
# bit tag all components
|
316
|
-
def _bit_clipboard_tag_all
|
317
|
-
cmd_bit_tag_all =
|
318
|
-
config.active['cmd_bit_clipboard_push_bit_tag_all']
|
319
|
-
|
320
|
-
run cmd_bit_tag_all
|
321
|
-
end
|
322
|
-
|
323
|
-
# bit export components
|
324
|
-
def _bit_clipboard_export_all
|
325
|
-
cmd_bit_export_all =
|
326
|
-
config.active['cmd_bit_clipboard_push_bit_export_all']
|
327
|
-
|
328
|
-
run cmd_bit_export_all
|
329
|
-
end
|
330
|
-
|
331
|
-
# Sync workspace with upstream.
|
332
|
-
def _bit_clipboard_sync_workspace
|
333
|
-
log.debug 'Syncing git workspace'
|
334
|
-
|
335
|
-
_rakefile, path = Rake.application.find_rakefile_location
|
336
|
-
bitmap = "#{path}/.bitmap"
|
337
|
-
|
338
|
-
_bit_clipboard_git_add bitmap
|
339
|
-
_bit_clipboard_git_commit bitmap
|
340
|
-
_bit_clipboard_git_push
|
341
|
-
end
|
342
|
-
|
343
|
-
# git add .bitmap
|
344
|
-
def _bit_clipboard_git_add(bitmap)
|
345
|
-
log.debug "Adding \"#{bitmap}\" to git"
|
346
|
-
|
347
|
-
cmd_bit_clipboard_git_add = format(
|
348
|
-
config.active['cmd_bit_clipboard_git_add'],
|
349
|
-
file: bitmap
|
350
|
-
)
|
351
|
-
run cmd_bit_clipboard_git_add
|
352
|
-
end
|
353
|
-
|
354
|
-
# git commit -m "Update .bitmap"
|
355
|
-
def _bit_clipboard_git_commit(bitmap)
|
356
|
-
message = 'Update .bitmap'
|
357
|
-
|
358
|
-
log.debug "Committing \"#{bitmap}\" to git"
|
359
|
-
|
360
|
-
cmd_bit_clipboard_git_commit = format(
|
361
|
-
config.active['cmd_bit_clipboard_git_commit'],
|
362
|
-
message: message
|
363
|
-
)
|
364
|
-
|
365
|
-
run cmd_bit_clipboard_git_commit
|
366
|
-
end
|
367
|
-
|
368
|
-
# git push origin master
|
369
|
-
def _bit_clipboard_git_push
|
370
|
-
log.debug 'Pushing master branch to origin'
|
371
|
-
|
372
|
-
cmd_bit_clipboard_git_push =
|
373
|
-
config.active['cmd_bit_clipboard_git_push']
|
374
|
-
|
375
|
-
run cmd_bit_clipboard_git_push
|
376
|
-
end
|
377
|
-
|
378
|
-
# git pull
|
379
|
-
def _bit_clipboard_git_pull
|
380
|
-
log.debug 'Updating git workspace'
|
381
|
-
cmd_bit_clipboard_git_pull =
|
382
|
-
config.active['cmd_bit_clipboard_git_pull']
|
383
|
-
|
384
|
-
result_git_pull = try cmd_bit_clipboard_git_pull
|
385
|
-
|
386
|
-
return true unless result_git_pull
|
387
|
-
|
388
|
-
log.error 'Unable to update git workspace'
|
389
|
-
false
|
390
|
-
end
|
391
|
-
|
392
|
-
# get components in remote scope
|
393
|
-
def _bit_clipboard_cid_exists_list_scope(scope)
|
394
|
-
cmd_bit_list_scope = format(
|
395
|
-
config.active['cmd_bit_clipboard_paste_bit_list_scope'],
|
396
|
-
scope: scope
|
397
|
-
)
|
398
|
-
|
399
|
-
run cmd_bit_list_scope
|
400
|
-
end
|
401
|
-
end
|