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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f34ba1e90b936146999504b8db29e2b0376efd4b1bf8faa65a398e8ae7758a6c
4
- data.tar.gz: 94945faa2bb0d04ed9cc5159ab21d9ad1811bf8bdbd8e1049b22e91acf282f24
3
+ metadata.gz: a32d5a9003a7197fd47fa4b81b7ca764b495ea7955ccc523cda29330f0e4e5b2
4
+ data.tar.gz: 9d47155b5a53497dc9e5ad16cbd48f402ee0ea9d3865cfd932f577d6a1f4a746
5
5
  SHA512:
6
- metadata.gz: e3420daa82aa13024e1c8d4331170be74e76249fe044c4f051a58e412bba33ea0b3481c0bccdab813868b719dba61c0f30c8af7becb4b37a0f6bb35eb9edfab7
7
- data.tar.gz: 23b08e3581ff3ffc6967125a339c02d82197f0247070f57ff0cff6b62c7065558ad36c18524c682a870d6c093d5ff7485fb00962d350bc341c41bcd203442c13
6
+ metadata.gz: 167b4aa726f99b28e2ce78087c07e10c122382a82e61db43820f43f7a28ca3bb8cfc24ab4aabb27d2577018f586257aec4a8bd3c18ae13dfcabc70be53ce2108
7
+ data.tar.gz: c4c9c0a6766fa93fcf5b40365d22526b40ff7d9cf22615484f030d5043b4b851878e9e36cfc70e1402943296592ed69074b1b813ea372332e4a3a2002cc13bc9
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wip
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wslc-wip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wip contributors