takelage 0.11.1 → 0.12.0
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 +4 -4
- data/lib/takelage/bit/clipboard/module.rb +81 -57
- data/lib/takelage/default.yml +4 -0
- data/lib/takelage/docker/container/module.rb +28 -12
- data/lib/takelage/docker/image/tag/check/module.rb +1 -1
- data/lib/takelage/docker/image/tag/latest/module.rb +1 -1
- data/lib/takelage/docker/image/tag/list/module.rb +7 -6
- data/lib/takelage/version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c97cc9d492c1532db93e5090ebf54357a46bf74ffa17f9ad55ad90d8a4595032
|
4
|
+
data.tar.gz: 59bca9e854ffe6441cfb80abf847c97b16390b86fef6c74d13aa6a6adfd5b66d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce47bc65c2f5c45685eafb643b30461562d3c24993378332f9d45a9fb590f106dab71d090ac4180ee5ac7fadb1574cd70e44ec37023cdcee275a9dd455ccd5ad
|
7
|
+
data.tar.gz: 217ac20d55861f557a4df55304f0888fa7bb58a773400f912405d0c48c9aee5db0cf300fa0da3187d19de513ea7ea13169daa57c7676ff1bc41985db817ce299
|
@@ -5,17 +5,7 @@ module BitClipboardModule
|
|
5
5
|
def bit_clipboard_copy(dir, scope)
|
6
6
|
log.debug "Running bit copy \"#{dir}\" to \"#{scope}\""
|
7
7
|
|
8
|
-
unless
|
9
|
-
log.error 'No bit workspace'
|
10
|
-
return false
|
11
|
-
end
|
12
|
-
|
13
|
-
if git_check_workspace
|
14
|
-
unless git_check_master
|
15
|
-
log.error 'Not on git master branch'
|
16
|
-
return false
|
17
|
-
end
|
18
|
-
end
|
8
|
+
return false unless _prepare_workspace
|
19
9
|
|
20
10
|
if File.directory? dir
|
21
11
|
|
@@ -105,6 +95,7 @@ module BitClipboardModule
|
|
105
95
|
run cmd_bit_export_to_scope
|
106
96
|
|
107
97
|
_remove_bit_artifacts
|
98
|
+
_sync_workspace
|
108
99
|
|
109
100
|
log.info "Copied directory \"#{dir}\" " +
|
110
101
|
"as bit component \"#{id}\" " +
|
@@ -116,17 +107,7 @@ module BitClipboardModule
|
|
116
107
|
def bit_clipboard_paste(cid, dir)
|
117
108
|
log.debug "Running bit paste \"#{cid}\" to \"#{dir}\""
|
118
109
|
|
119
|
-
unless
|
120
|
-
log.error 'No bit workspace'
|
121
|
-
return false
|
122
|
-
end
|
123
|
-
|
124
|
-
if git_check_workspace
|
125
|
-
unless git_check_master
|
126
|
-
log.error 'Not on git master branch'
|
127
|
-
return false
|
128
|
-
end
|
129
|
-
end
|
110
|
+
return false unless _prepare_workspace
|
130
111
|
|
131
112
|
scope = cid.scan(/([^\/]*).*/).first.first
|
132
113
|
|
@@ -156,6 +137,7 @@ module BitClipboardModule
|
|
156
137
|
|
157
138
|
_handle_bitignore
|
158
139
|
_remove_bit_artifacts
|
140
|
+
_sync_workspace
|
159
141
|
|
160
142
|
log.info "Pasted bit component \"#{cid}\" " +
|
161
143
|
"to directory \"#{dir}\""
|
@@ -166,17 +148,7 @@ module BitClipboardModule
|
|
166
148
|
def bit_clipboard_pull
|
167
149
|
log.debug "Running bit pull"
|
168
150
|
|
169
|
-
unless
|
170
|
-
log.error 'No bit workspace'
|
171
|
-
return false
|
172
|
-
end
|
173
|
-
|
174
|
-
if git_check_workspace
|
175
|
-
unless git_check_master
|
176
|
-
log.error 'Not on git master branch'
|
177
|
-
return false
|
178
|
-
end
|
179
|
-
end
|
151
|
+
return false unless _prepare_workspace
|
180
152
|
|
181
153
|
# import components into workspace
|
182
154
|
cmd_bit_import_all =
|
@@ -192,6 +164,7 @@ module BitClipboardModule
|
|
192
164
|
|
193
165
|
_handle_bitignore
|
194
166
|
_remove_bit_artifacts
|
167
|
+
_sync_workspace
|
195
168
|
|
196
169
|
log.info "Pulled bit components"
|
197
170
|
true
|
@@ -201,17 +174,7 @@ module BitClipboardModule
|
|
201
174
|
def bit_clipboard_push
|
202
175
|
log.debug "Running bit push"
|
203
176
|
|
204
|
-
unless
|
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
|
-
end
|
177
|
+
return false unless _prepare_workspace
|
215
178
|
|
216
179
|
# tag all components
|
217
180
|
cmd_bit_tag_all =
|
@@ -226,6 +189,7 @@ module BitClipboardModule
|
|
226
189
|
run cmd_bit_export_all
|
227
190
|
|
228
191
|
_remove_bit_artifacts
|
192
|
+
_sync_workspace
|
229
193
|
|
230
194
|
log.info "Pushed bit components"
|
231
195
|
true
|
@@ -279,29 +243,89 @@ module BitClipboardModule
|
|
279
243
|
id
|
280
244
|
end
|
281
245
|
|
246
|
+
# Prepare workspace for bit clipboard.
|
247
|
+
def _prepare_workspace
|
248
|
+
unless bit_check_workspace
|
249
|
+
log.error 'No bit workspace'
|
250
|
+
return false
|
251
|
+
end
|
252
|
+
|
253
|
+
if git_check_workspace
|
254
|
+
|
255
|
+
unless git_check_master
|
256
|
+
log.error 'Not on git master branch'
|
257
|
+
return false
|
258
|
+
end
|
259
|
+
|
260
|
+
unless git_check_clean
|
261
|
+
log.error 'No clean git workspace'
|
262
|
+
return false
|
263
|
+
end
|
264
|
+
|
265
|
+
log.debug "Updating git workspace"
|
266
|
+
cmd_bit_clipboard_git_pull =
|
267
|
+
config.active['cmd_bit_clipboard_git_pull']
|
268
|
+
|
269
|
+
result_git_pull = try cmd_bit_clipboard_git_pull
|
270
|
+
|
271
|
+
unless result_git_pull
|
272
|
+
log.error "Unable to update git workspace"
|
273
|
+
return false
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
277
|
+
|
278
|
+
true
|
279
|
+
end
|
280
|
+
|
282
281
|
# Remove bit artifacts.
|
283
282
|
def _remove_bit_artifacts
|
284
283
|
log.debug "Removing bit artifacts"
|
285
284
|
|
286
|
-
|
287
|
-
_remove_index_bit
|
288
|
-
_remove_package_json
|
289
|
-
end
|
290
|
-
|
291
|
-
# Remove node_modules directory.
|
292
|
-
def _remove_node_modules
|
285
|
+
# Remove node_modules directory.
|
293
286
|
FileUtils.remove_entry_secure('node_modules', force: true)
|
294
|
-
end
|
295
287
|
|
296
|
-
|
297
|
-
def _remove_index_bit
|
288
|
+
# Remove index.bit files recursively.
|
298
289
|
Dir.glob("./**/index.bit").each do |file|
|
299
290
|
FileUtils.remove_entry_secure(file, force: true)
|
300
291
|
end
|
301
|
-
end
|
302
292
|
|
303
|
-
|
304
|
-
def _remove_package_json
|
293
|
+
# Remove package.json file.
|
305
294
|
FileUtils.remove_entry_secure('package.json', force: true)
|
306
295
|
end
|
296
|
+
|
297
|
+
# Sync workspace with upstream.
|
298
|
+
def _sync_workspace
|
299
|
+
log.debug "Syncing git workspace"
|
300
|
+
|
301
|
+
rakefile, path = Rake.application.find_rakefile_location
|
302
|
+
bitmap = "#{path}/.bitmap"
|
303
|
+
|
304
|
+
log.debug "Adding \"#{bitmap}\" to git"
|
305
|
+
|
306
|
+
cmd_bit_clipboard_git_add =
|
307
|
+
config.active['cmd_bit_clipboard_git_add'] % {
|
308
|
+
file: bitmap
|
309
|
+
}
|
310
|
+
|
311
|
+
run cmd_bit_clipboard_git_add
|
312
|
+
|
313
|
+
message = "Update .bitmap"
|
314
|
+
|
315
|
+
log.debug "Committing \"#{bitmap}\" to git"
|
316
|
+
|
317
|
+
cmd_bit_clipboard_git_commit =
|
318
|
+
config.active['cmd_bit_clipboard_git_commit'] % {
|
319
|
+
message: message
|
320
|
+
}
|
321
|
+
|
322
|
+
run cmd_bit_clipboard_git_commit
|
323
|
+
|
324
|
+
log.debug "Pushing master branch to origin"
|
325
|
+
|
326
|
+
cmd_bit_clipboard_git_push =
|
327
|
+
config.active['cmd_bit_clipboard_git_push']
|
328
|
+
|
329
|
+
run cmd_bit_clipboard_git_push
|
330
|
+
end
|
307
331
|
end
|
data/lib/takelage/default.yml
CHANGED
@@ -10,6 +10,10 @@ cmd_bit_clipboard_copy_bit_list_remotes: 'bit remote --skip-update'
|
|
10
10
|
cmd_bit_clipboard_copy_bit_add_dir: 'bit add --skip-update --id %{id} --main %{dir}/README.bit %{dir}'
|
11
11
|
cmd_bit_clipboard_copy_bit_tag_id: 'bit tag --skip-update --skip-tests %{id}'
|
12
12
|
cmd_bit_clipboard_copy_bit_export_to_scope: 'bit export --skip-update %{scope}'
|
13
|
+
cmd_bit_clipboard_git_add: 'git add %{file}'
|
14
|
+
cmd_bit_clipboard_git_commit: 'git commit --message="%{message}"'
|
15
|
+
cmd_bit_clipboard_git_pull: 'git pull origin master'
|
16
|
+
cmd_bit_clipboard_git_push: 'git push origin master'
|
13
17
|
cmd_bit_clipboard_paste_bit_list_scope: 'bit list --skip-update --json %{scope}'
|
14
18
|
cmd_bit_clipboard_paste_bit_import_cid: 'bit import --ignore-package-json --ignore-dist --skip-update --path %{dir} %{cid}'
|
15
19
|
cmd_bit_clipboard_pull_bit_import_all: 'bit import --ignore-package-json --ignore-dist --skip-update'
|
@@ -10,7 +10,10 @@ module DockerContainerModule
|
|
10
10
|
docker_socket_start
|
11
11
|
|
12
12
|
_create_network @hostname unless docker_container_check_network @hostname
|
13
|
-
|
13
|
+
|
14
|
+
container_created = true
|
15
|
+
container_created = _create_container @hostname unless docker_container_check_existing @hostname
|
16
|
+
return false unless container_created
|
14
17
|
_run_command_in_container @hostname, command
|
15
18
|
end
|
16
19
|
|
@@ -21,7 +24,10 @@ module DockerContainerModule
|
|
21
24
|
return false unless docker_check_running
|
22
25
|
|
23
26
|
_create_network @hostname unless docker_container_check_network @hostname
|
24
|
-
|
27
|
+
|
28
|
+
container_created = true
|
29
|
+
container_created = _create_container @hostname unless docker_container_check_existing @hostname
|
30
|
+
return false unless container_created
|
25
31
|
end
|
26
32
|
|
27
33
|
# Backend method for docker container login.
|
@@ -34,15 +40,19 @@ module DockerContainerModule
|
|
34
40
|
outdated = docker_image_check_outdated @docker_tag
|
35
41
|
if outdated
|
36
42
|
tag_latest_remote = docker_image_tag_latest_remote
|
37
|
-
|
38
|
-
|
43
|
+
log.warn "#{@docker_user}/#{@docker_repo}:#{@docker_tag} is outdated"
|
44
|
+
log.warn "#{@docker_user}/#{@docker_repo}:#{tag_latest_remote} is available"
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
48
|
docker_socket_start
|
43
49
|
|
44
50
|
_create_network @hostname unless docker_container_check_network @hostname
|
45
|
-
|
51
|
+
|
52
|
+
container_created = true
|
53
|
+
container_created = _create_container @hostname unless docker_container_check_existing @hostname
|
54
|
+
return false unless container_created
|
55
|
+
|
46
56
|
_enter_container @hostname
|
47
57
|
end
|
48
58
|
|
@@ -52,6 +62,12 @@ module DockerContainerModule
|
|
52
62
|
|
53
63
|
return false unless docker_check_running
|
54
64
|
|
65
|
+
if ENV['HOSTNAME'].start_with? "#{@docker_repo}_"
|
66
|
+
log.error "Please run \"tau nuke\" outside of #{@docker_repo} containers"
|
67
|
+
log.info "Run \"tau purge\" to remove orphaned #{@docker_repo} containers"
|
68
|
+
return false
|
69
|
+
end
|
70
|
+
|
55
71
|
networks = []
|
56
72
|
|
57
73
|
_get_containers.each do |container|
|
@@ -90,17 +106,16 @@ module DockerContainerModule
|
|
90
106
|
def _create_container(container)
|
91
107
|
log.debug "Creating container \"#{container}\""
|
92
108
|
|
93
|
-
|
94
|
-
tag = @docker_tag
|
95
|
-
else
|
96
|
-
tag = docker_image_tag_latest_local
|
97
|
-
end
|
109
|
+
image = "#{@docker_user}/#{@docker_repo}:#{@docker_tag}"
|
98
110
|
|
99
|
-
|
111
|
+
unless docker_image_tag_list_local.include? @docker_tag
|
112
|
+
log.error "No local image \"#{image}\" available"
|
113
|
+
return false
|
114
|
+
end
|
100
115
|
|
101
116
|
log.debug "Using docker image \"#{image}\""
|
102
117
|
|
103
|
-
unless docker_image_tag_check_local
|
118
|
+
unless docker_image_tag_check_local @docker_tag
|
104
119
|
log.error "Image \"#{image}\" does not exist"
|
105
120
|
return false
|
106
121
|
end
|
@@ -134,6 +149,7 @@ module DockerContainerModule
|
|
134
149
|
}
|
135
150
|
|
136
151
|
run cmd_docker_create
|
152
|
+
true
|
137
153
|
end
|
138
154
|
|
139
155
|
# Create docker network.
|
@@ -26,13 +26,14 @@ module DockerImageTagListModule
|
|
26
26
|
"of \"#{@docker_user}/#{@docker_repo}\" " +
|
27
27
|
"from \"#{@docker_registry}\""
|
28
28
|
|
29
|
-
registry = DockerRegistry2.connect(@docker_registry)
|
30
|
-
|
31
|
-
log.debug ("Connected to registry \"#{@docker_registry}\"")
|
32
|
-
|
33
29
|
user = File.basename @docker_user
|
34
|
-
|
35
|
-
|
30
|
+
begin
|
31
|
+
registry = DockerRegistry2.connect(@docker_registry)
|
32
|
+
tags = registry.tags("#{user}/#{@docker_repo}")
|
33
|
+
rescue RestClient::Exceptions::OpenTimeout
|
34
|
+
log.error "Timeout while connecting to \"#{@docker_registry}\""
|
35
|
+
return false
|
36
|
+
end
|
36
37
|
|
37
38
|
VersionSorter.sort(tags['tags'])
|
38
39
|
end
|
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.12.0
|