wslc-wip 0.14.0 → 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 +4 -4
- data/lib/wip/initializer.rb +68 -4
- 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: 6f9b53bdcacc5491c788acf9af933f377cc0afe046ef133391ae866700145c83
|
|
4
|
+
data.tar.gz: b4ad717fba296d8082bc272238a8dd83afa206f7aaca67628e47186a0551c531
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d65e654b92b30b19a987c2b239014bb0071b92bd99d0fdb09728e23ce3948488a330ebbf61878d7c81c7b4f588888d87720e41542f91e947c7358a02e495fbe2
|
|
7
|
+
data.tar.gz: 3008f5c32bfaa6771ef60a75d8445a427b3ddcbc9ef19f226602275a3b4eb997a6f9b7d99fc649dcc481dcfacbeea8b32e0c03a6902934f82d6c7534a08901af
|
data/lib/wip/initializer.rb
CHANGED
|
@@ -1,22 +1,69 @@
|
|
|
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
|
-
|
|
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
|
|
41
|
+
YAML
|
|
42
|
+
|
|
43
|
+
CONTAINER_TEMPLATE = <<~YAML.freeze
|
|
10
44
|
version: 1
|
|
11
|
-
mode: container
|
|
45
|
+
mode: container # container | compose | compose-native (see README)
|
|
12
46
|
container: app # TODO: rename freely, as long as it matches a key under dependencies: below
|
|
13
47
|
|
|
48
|
+
wslc:
|
|
49
|
+
command: auto # optional; wslc binary/path wip shells out to ("auto" resolves it for you)
|
|
50
|
+
|
|
51
|
+
# network: my-network # optional; container network name (mode: container only)
|
|
52
|
+
|
|
14
53
|
dependencies:
|
|
15
54
|
app: # this is the container wip creates, execs into, and runs commands in
|
|
16
55
|
image: your/image:tag # TODO: image to run
|
|
17
56
|
workdir: /app # TODO: adjust to match your image, or delete this line
|
|
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}
|
|
18
64
|
|
|
19
|
-
sync:
|
|
65
|
+
sync: # optional; mirrors the source into a named volume instead of bind-mounting it live
|
|
66
|
+
#{SYNC_EXTRAS}
|
|
20
67
|
YAML
|
|
21
68
|
|
|
22
69
|
def initialize(dir: Dir.pwd)
|
|
@@ -35,6 +82,11 @@ module Wip
|
|
|
35
82
|
@compose_file ||= ComposeBridge::FILENAMES.find { |name| File.file?(File.join(@dir, name)) }
|
|
36
83
|
end
|
|
37
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
|
+
|
|
38
90
|
def compose_template
|
|
39
91
|
<<~YAML
|
|
40
92
|
version: 1
|
|
@@ -42,10 +94,22 @@ module Wip
|
|
|
42
94
|
# compose-for-wslc binary needed. Prefer a real compose tool instead? Use
|
|
43
95
|
# mode: compose (see README "Compose mode") and set compose.command.
|
|
44
96
|
|
|
97
|
+
wslc:
|
|
98
|
+
command: auto # optional; wslc binary/path wip shells out to ("auto" resolves it for you)
|
|
99
|
+
|
|
45
100
|
compose:
|
|
46
101
|
service: app # TODO: which service in #{compose_file} wip run/exec/NAME target
|
|
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.
|
|
108
|
+
|
|
109
|
+
#{COMMANDS_EXAMPLE}
|
|
47
110
|
|
|
48
|
-
sync:
|
|
111
|
+
sync: # optional; mirrors the source into a named volume instead of bind-mounting it live
|
|
112
|
+
#{SYNC_EXTRAS}
|
|
49
113
|
YAML
|
|
50
114
|
end
|
|
51
115
|
end
|
data/lib/wip/version.rb
CHANGED