wslc-wip 0.14.1 → 0.14.2

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: 103045e33c74bb6772808c9a2e3029d35c90ce190c520df0ecc6d2a803b6108b
4
- data.tar.gz: c70c47ae4c0d45a3ec0f9d695e4359d1d8915e5716b546c52d53280c1e49d09a
3
+ metadata.gz: 6f9b53bdcacc5491c788acf9af933f377cc0afe046ef133391ae866700145c83
4
+ data.tar.gz: b4ad717fba296d8082bc272238a8dd83afa206f7aaca67628e47186a0551c531
5
5
  SHA512:
6
- metadata.gz: b51cdbdfe08a7d51ef750a8a5190583c9f3de894bf5e419b5890a6cdbfda4c9da1a1ab6fb175b763669100564e2e1741ff4bfc1dbf2819e46358680515e5fafb
7
- data.tar.gz: 91b3608c4666a2e1023b3ce9e7069fe29d3fc8ecfa03cf0641e5e6da8d487b89b4fed13b3d948040e8b65b4d5e4828ac361b1be96ce8be470dbca8be58f58e5c
6
+ metadata.gz: d65e654b92b30b19a987c2b239014bb0071b92bd99d0fdb09728e23ce3948488a330ebbf61878d7c81c7b4f588888d87720e41542f91e947c7358a02e495fbe2
7
+ data.tar.gz: 3008f5c32bfaa6771ef60a75d8445a427b3ddcbc9ef19f226602275a3b4eb997a6f9b7d99fc649dcc481dcfacbeea8b32e0c03a6902934f82d6c7534a08901af
@@ -1,30 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'pathname'
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
6
8
  # mode: compose-native and mode: container, since that's the one decision
7
9
  # `wip init` can't leave to a placeholder.
8
10
  class Initializer
9
- # Shared across both templates: every sync.* key SyncSettings understands,
10
- # commented out with its default/behavior so nothing has to be looked up
11
- # in the README to customize the mirror.
12
- SYNC_TEMPLATE = <<~YAML.chomp
13
- sync: {} # optional; mirrors the source into a named volume instead of bind-mounting it live
14
- # source: . # optional; host path to mirror (default: wip.yml directory)
15
- # target: /app # optional; in-container path the mirror volume mounts at (default: workdir, else /app)
16
- # mount: /host-src # optional; read-only host mount inside the container (default: /host-src)
17
- # volume: app-src # optional; named volume that holds the mirrored tree (default: "<container>-src")
18
- # delete: true # optional; rsync --delete so removals on the host are mirrored too (default: true)
19
- # exclude: [] # optional; rsync --exclude patterns, e.g. ["node_modules", "*.log"]
20
- # command: rsync # optional; mirror binary to shell out to (default: rsync)
21
- # options: [] # optional; extra flags appended to the mirror command
22
- # interval: 2 # optional; seconds between mirrors (default: 2)
23
- # mode: exec # optional; exec (default, mirrors into the running container) | run (fresh container each mirror)
24
- # image: # optional; image the mirror container runs (required under mode: compose unless build: is set)
25
- # build: # optional; let wip build a small dedicated mirror image instead of requiring one to exist
26
- # dockerfile: # TODO required if build: is set
27
- # tag: # optional (default: wip-sync-<container>:latest)
11
+ # Appended to sync: in both templates. Every key here is either a plain constant
12
+ # default (safe to state literally) or, where commented, a value SyncSettings
13
+ # derives from another key (target from workdir, volume from the container/service
14
+ # name) — those stay unset so they keep tracking that key instead of going stale.
15
+ SYNC_EXTRAS = <<~YAML.chomp.gsub(/^/, ' ')
16
+ source: . # optional; host path to mirror (default: wip.yml directory)
17
+ # target: /app # optional; in-container mount point for the mirror (default: the container's workdir, else /app)
18
+ mount: /host-src # optional; read-only host mount inside the container
19
+ # volume: app-src # optional; named volume holding the mirrored tree (default: "<container>-src")
20
+ delete: true # optional; rsync --delete so removals on the host are mirrored too
21
+ exclude: [] # optional; rsync --exclude patterns, e.g. ["node_modules", "*.log"]
22
+ command: rsync # optional; mirror binary to shell out to
23
+ options: [] # optional; extra flags appended to the mirror command
24
+ interval: 2 # optional; seconds between mirrors
25
+ mode: exec # optional; exec (default, mirrors into the running container) | run (always a fresh container)
26
+ # image: your/image:tag # only needed if sync.mode: run (or under mode: compose); image the mirror container runs
27
+ # build: # alternative to image — let wip build a small dedicated mirror image itself
28
+ # dockerfile: |
29
+ # FROM alpine:latest
30
+ # RUN apk add --no-cache rsync
31
+ # tag: wip-sync-app:latest # optional (default: wip-sync-<container>:latest)
32
+ YAML
33
+
34
+ # Appended to both templates after dependencies/compose. commands: itself is left
35
+ # commented since an empty commands: {} is indistinguishable from omitting the key.
36
+ COMMANDS_EXAMPLE = <<~YAML.chomp
37
+ # commands: # optional; custom subcommands, e.g. `wip test` — see README
38
+ # test:
39
+ # type: exec # optional; exec (default, runs in the running container) | run (fresh container) | build
40
+ # command: bundle exec rspec # TODO
28
41
  YAML
29
42
 
30
43
  CONTAINER_TEMPLATE = <<~YAML.freeze
@@ -32,8 +45,8 @@ module Wip
32
45
  mode: container # container | compose | compose-native (see README)
33
46
  container: app # TODO: rename freely, as long as it matches a key under dependencies: below
34
47
 
35
- # wslc: {} # optional; override which wslc binary/path wip shells out to (default: auto)
36
- # command: auto
48
+ wslc:
49
+ command: auto # optional; wslc binary/path wip shells out to ("auto" resolves it for you)
37
50
 
38
51
  # network: my-network # optional; container network name (mode: container only)
39
52
 
@@ -41,18 +54,16 @@ module Wip
41
54
  app: # this is the container wip creates, execs into, and runs commands in
42
55
  image: your/image:tag # TODO: image to run
43
56
  workdir: /app # TODO: adjust to match your image, or delete this line
44
- # interactive: false # optional; keep stdin open / allocate a tty (default: false)
45
- # remove: true # optional; remove the container after each run (default: true)
46
- # env: {} # optional; environment variables passed to the container, e.g. {FOO: bar}
47
- # ports: [] # optional; published ports, e.g. ["3000:3000"]
48
- # volumes: [] # optional; extra -v specs beyond the source/sync mounts
49
-
50
- # commands:
51
- # test: # example custom command, invoked as `wip test`
52
- # type: exec # optional; exec (default, runs in the running container) | run (fresh container) | build
53
- # command: bundle exec rspec # TODO
57
+ interactive: false # optional; keep stdin open / allocate a tty
58
+ remove: true # optional; remove the container after each run
59
+ env: {} # optional; environment variables passed to the container, e.g. {FOO: bar}
60
+ ports: [] # optional; published ports, e.g. ["3000:3000"]
61
+ volumes: [] # optional; extra -v specs beyond the sync mounts below
62
+
63
+ #{COMMANDS_EXAMPLE}
54
64
 
55
- #{SYNC_TEMPLATE}
65
+ sync: # optional; mirrors the source into a named volume instead of bind-mounting it live
66
+ #{SYNC_EXTRAS}
56
67
  YAML
57
68
 
58
69
  def initialize(dir: Dir.pwd)
@@ -71,6 +82,11 @@ module Wip
71
82
  @compose_file ||= ComposeBridge::FILENAMES.find { |name| File.file?(File.join(@dir, name)) }
72
83
  end
73
84
 
85
+ # Directory name wip.yml would resolve as its default compose.project (and, from
86
+ # that, its network name) if left unset — shown as a comment so it's discoverable
87
+ # without duplicating it as a live value that would go stale if the directory moves.
88
+ def compose_project_default = Pathname(@dir).basename.to_s
89
+
74
90
  def compose_template
75
91
  <<~YAML
76
92
  version: 1
@@ -78,21 +94,22 @@ module Wip
78
94
  # compose-for-wslc binary needed. Prefer a real compose tool instead? Use
79
95
  # mode: compose (see README "Compose mode") and set compose.command.
80
96
 
81
- # wslc: {} # optional; override which wslc binary/path wip shells out to (default: auto)
82
- # command: auto
97
+ wslc:
98
+ command: auto # optional; wslc binary/path wip shells out to ("auto" resolves it for you)
83
99
 
84
100
  compose:
85
101
  service: app # TODO: which service in #{compose_file} wip run/exec/NAME target
86
- # file: #{compose_file} # optional; override which compose file to parse (default: auto-detected)
87
- # project: # optional; project/network name (default: wip.yml directory name)
88
- # command: # required under mode: compose (external compose-for-wslc binary); unused under compose-native
102
+ # file: #{compose_file} # optional; override which compose file wip parses (default: auto-detected)
103
+ # project: #{compose_project_default} # optional; project/network name (default: this directory's name)
104
+ # command: # only used under mode: compose (external compose-for-wslc binary); unused here under compose-native
105
+
106
+ # network: is derived from compose.project above (or this directory's name) — setting it
107
+ # directly conflicts with compose: (ConfigError), so it's intentionally left out here.
89
108
 
90
- # commands:
91
- # test: # example custom command, invoked as `wip test`
92
- # type: exec # optional; exec (default, runs in the running container) | run (fresh container) | build
93
- # command: bundle exec rspec # TODO
109
+ #{COMMANDS_EXAMPLE}
94
110
 
95
- #{SYNC_TEMPLATE}
111
+ sync: # optional; mirrors the source into a named volume instead of bind-mounting it live
112
+ #{SYNC_EXTRAS}
96
113
  YAML
97
114
  end
98
115
  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.14.1'
4
+ VERSION = '0.14.2'
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.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wip contributors