wslc-wip 0.10.0 → 0.11.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/wip/initializer.rb +41 -0
- data/lib/wip/version.rb +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: a32d5a9003a7197fd47fa4b81b7ca764b495ea7955ccc523cda29330f0e4e5b2
|
|
4
|
+
data.tar.gz: 9d47155b5a53497dc9e5ad16cbd48f402ee0ea9d3865cfd932f577d6a1f4a746
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 167b4aa726f99b28e2ce78087c07e10c122382a82e61db43820f43f7a28ca3bb8cfc24ab4aabb27d2577018f586257aec4a8bd3c18ae13dfcabc70be53ce2108
|
|
7
|
+
data.tar.gz: c4c9c0a6766fa93fcf5b40365d22526b40ff7d9cf22615484f030d5043b4b851878e9e36cfc70e1402943296592ed69074b1b813ea372332e4a3a2002cc13bc9
|
data/lib/wip/initializer.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
3
5
|
module Wip
|
|
4
6
|
# Builds a starter wip.yml. Detects an existing compose file next to the
|
|
5
7
|
# target (the same filenames ComposeBridge auto-detects) to decide between
|
|
@@ -42,7 +44,46 @@ module Wip
|
|
|
42
44
|
compose:
|
|
43
45
|
service: app # TODO: which service in #{compose_file} wip run/exec/NAME target
|
|
44
46
|
command: wslc-compose # TODO: the compose-for-wslc binary/path you have installed
|
|
47
|
+
|
|
48
|
+
#{sync_hint}
|
|
45
49
|
YAML
|
|
46
50
|
end
|
|
51
|
+
|
|
52
|
+
# sync: needs sync.image (mode: compose has no dependencies: entry to borrow one from) and a
|
|
53
|
+
# named volume the compose service mounts, matching sync.volume ("app-src" by default). Checked
|
|
54
|
+
# against the detected compose file so the hint doesn't repeat what's already set up.
|
|
55
|
+
def sync_hint
|
|
56
|
+
return sync_hint_configured if compose_volume_mounted?
|
|
57
|
+
|
|
58
|
+
sync_hint_todo
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def sync_hint_configured
|
|
62
|
+
<<~COMMENT.chomp
|
|
63
|
+
# #{compose_file} already mounts a volume matching sync.volume's default (app-src).
|
|
64
|
+
# sync: # add sync.image too (required under mode: compose) — see README
|
|
65
|
+
COMMENT
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def sync_hint_todo
|
|
69
|
+
<<~COMMENT.chomp
|
|
70
|
+
# sync: # optional; mirrors the source into a named volume instead of bind-mounting it live
|
|
71
|
+
# image: your/image:tag # required under mode: compose (no dependencies: entry to borrow one from)
|
|
72
|
+
# # the service above must also mount a volume named "app-src" (sync.volume's default) at the
|
|
73
|
+
# # path your app expects — add to #{compose_file}:
|
|
74
|
+
# # volumes:
|
|
75
|
+
# # - app-src:/app
|
|
76
|
+
# # and, alongside services:
|
|
77
|
+
# # volumes:
|
|
78
|
+
# # app-src:
|
|
79
|
+
COMMENT
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def compose_volume_mounted?
|
|
83
|
+
services = YAML.safe_load_file(File.join(@dir, compose_file), aliases: true)&.fetch('services', nil) || {}
|
|
84
|
+
services.values.any? { |service| Array(service['volumes']).any? { |v| v.to_s.start_with?('app-src:') } }
|
|
85
|
+
rescue StandardError
|
|
86
|
+
false
|
|
87
|
+
end
|
|
47
88
|
end
|
|
48
89
|
end
|
data/lib/wip/version.rb
CHANGED