wslc-wip 0.8.0 → 0.9.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: afc914ac16e4359e48e682f5dab523827ad782251365abee7abd60b6eee89044
4
- data.tar.gz: dcc97ec1bace3262bc1c419162085de6a3f5e24f0dde8babb2532ef9bdd6446c
3
+ metadata.gz: d16349112264f413d1492541731ec704d56616ccb4b05cef1f505d667a5d823d
4
+ data.tar.gz: 05f7f5819345079aa82e062ee368a3255f93bdeaa62cf55fda2621c2bd36c4ed
5
5
  SHA512:
6
- metadata.gz: 526f9730c15eb6beabda31c3df3ee95cac2f8058c6da2dddf27100aadb48276bb68d66a3ede2b7383f49ecb6cd6fd45604b39ec1130058718cfbf439e7629f5a
7
- data.tar.gz: 87a5f6c40e948fabdc79eeaf3e81cb73fac3cdb0fdd306189a72a437f459de22deeb57fbd92167411c157485d66dd82f40734f72316f46cb65fe6aa74b111511
6
+ metadata.gz: cdbeea98b7472f9ec6e1ccec8883bf136dfcb76164c2ba2d2ddbd63fe52f22c20f72a994a2a85527b1d9e7a7511016fe1b54ab64e678aca009530616887435f1
7
+ data.tar.gz: a6f524f41b20fe20af6262e3e22e2dafa924d37e31279ff21ed94268824587017ad94670084ae81aeb79513369a923d37011fd95bd9471a1e357551b90701769
data/README.md CHANGED
@@ -31,6 +31,7 @@ From source: `bundle install && bundle exec exe/wip version`.
31
31
  ```bash
32
32
  gem install wslc-wip
33
33
  cd my-project
34
+ wip init # writes a starter wip.yml; edit the TODOs, then:
34
35
  wip doctor
35
36
  wip build
36
37
  wip up -d
@@ -238,6 +239,7 @@ found, its version, and which compose file `wip` resolved.
238
239
 
239
240
  | Command | Description |
240
241
  |---|---|
242
+ | `wip init [--force]` | Write a starter `wip.yml`: `mode: compose` if a `compose.yml`/`docker-compose.yml` is found next to it, `mode: container` otherwise. Refuses to overwrite an existing `wip.yml` unless `--force` |
241
243
  | `wip version` | wip's version, plus WSLC's if it can be detected |
242
244
  | `wip doctor` | Diagnose WSL2, interop, WSLC, config, architecture, and Git |
243
245
  | `wip config` | Print the effective configuration (secrets masked) |
data/lib/wip/cli.rb CHANGED
@@ -39,6 +39,17 @@ module Wip
39
39
  nil
40
40
  end
41
41
 
42
+ desc 'init', 'Create a starter wip.yml (detects an existing compose.yml/docker-compose.yml)'
43
+ option :force, type: :boolean, default: false, desc: 'Overwrite an existing wip.yml'
44
+ def init
45
+ path = Pathname(options[:config] || ConfigLoader::FILENAME).expand_path
46
+ raise Error, "#{path} already exists (use --force to overwrite)" if path.file? && !options[:force]
47
+
48
+ initializer = Initializer.new(dir: path.dirname)
49
+ path.write(initializer.call)
50
+ warn "wip: wrote #{path} (mode: #{initializer.compose? ? 'compose' : 'container'})"
51
+ end
52
+
42
53
  desc 'doctor', 'Diagnose the development environment'
43
54
  def doctor
44
55
  results = Doctor.new(loader: loader).call
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wip
4
+ # Builds a starter wip.yml. Detects an existing compose file next to the
5
+ # target (the same filenames ComposeBridge auto-detects) to decide between
6
+ # mode: compose and mode: container, since that's the one decision `wip
7
+ # init` can't leave to a placeholder.
8
+ class Initializer
9
+ CONTAINER_TEMPLATE = <<~YAML
10
+ version: 1
11
+ mode: container
12
+
13
+ defaults:
14
+ container: app # TODO: name of the container wip creates
15
+ image: your/image:tag # TODO: image to run
16
+ workdir: /app
17
+
18
+ sync: {} # optional; mirrors the source into a named volume instead of bind-mounting it live
19
+ YAML
20
+
21
+ def initialize(dir: Dir.pwd)
22
+ @dir = dir
23
+ end
24
+
25
+ def compose? = !!compose_file
26
+
27
+ def call
28
+ compose? ? compose_template : CONTAINER_TEMPLATE
29
+ end
30
+
31
+ private
32
+
33
+ def compose_file
34
+ @compose_file ||= ComposeBridge::FILENAMES.find { |name| File.file?(File.join(@dir, name)) }
35
+ end
36
+
37
+ def compose_template
38
+ <<~YAML
39
+ version: 1
40
+ mode: compose
41
+
42
+ compose:
43
+ service: app # TODO: which service in #{compose_file} wip run/exec/NAME target
44
+ command: wslc-compose # TODO: the compose-for-wslc binary/path you have installed
45
+ YAML
46
+ end
47
+ end
48
+ 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.8.0'
4
+ VERSION = '0.9.0'
5
5
  end
data/lib/wip.rb CHANGED
@@ -13,6 +13,7 @@ require_relative 'wip/command_resolver'
13
13
  require_relative 'wip/error_interpreter'
14
14
  require_relative 'wip/command_builder'
15
15
  require_relative 'wip/compose_bridge'
16
+ require_relative 'wip/initializer'
16
17
  require_relative 'wip/command_display'
17
18
  require_relative 'wip/command_runner'
18
19
  require_relative 'wip/resource_monitor'
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wip contributors
@@ -49,6 +49,7 @@ files:
49
49
  - lib/wip/environment.rb
50
50
  - lib/wip/error_interpreter.rb
51
51
  - lib/wip/errors.rb
52
+ - lib/wip/initializer.rb
52
53
  - lib/wip/resource_monitor.rb
53
54
  - lib/wip/sync_settings.rb
54
55
  - lib/wip/version.rb