wslc-wip 0.4.0 → 0.4.1

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: c1e6e4afaf5e33e69fa5dd6dc35f4fc32695e9916b0ceeac998ae58334fab3d4
4
- data.tar.gz: 56e438283cad62937ac37132bb49048a1159897de4d3058c122f14272bca9e68
3
+ metadata.gz: 5808f27cf9f20fab582caacc33a35f4727d1b74764b8e541fe9f10a82ec8ceaa
4
+ data.tar.gz: 79c031022523b9ea21dfc79d7b160bcc46ab71cebe9f98d89050758ba581d986
5
5
  SHA512:
6
- metadata.gz: 29bfbc9430132bf62ae58813e333f64df00d9228ad98386f3374e3a0de897e55605b977d7208bf7ce9622957e0a3acd1d598e25f25a594eed839fc7007deb37d
7
- data.tar.gz: 8588e1b97851a59936bb42daf6a8d09002e1c3fdba12dafba0a35bfe8a1c9e430742bee1b8f818a677b83cc793f6b96151be1d729f7465632c3c368d9b518cd8
6
+ metadata.gz: 4b64f0d01f0f54476b5acacc7094dc6c54f2ea5ed480272644b20839a9a1d3217d9c32748935eb20d75f5ee3672012d6c8799dfba8192b1fa656e16a7c65380f
7
+ data.tar.gz: 5ab533ffee65252d885c20862c32450f3d4b7c5c4a8019cf2314e5075b9c3f5ea49efd551f08cf73c170663b90cebe420533be7041e5d20c6eff1988e6b3a758
data/lib/wip/doctor.rb CHANGED
@@ -15,9 +15,8 @@ module Wip
15
15
 
16
16
  def call
17
17
  results = []
18
- results << result(@environment.wsl2? ? :ok : :fail, 'Running on WSL2', 'Not running on WSL2')
19
- results << result(@environment.windows_interop? ? :ok : :fail, 'Windows executable interoperability is enabled',
20
- 'Windows executable interoperability is disabled')
18
+ results << result(@environment.wsl2? ? :ok : :fail, *wsl2_messages)
19
+ results << interop_result unless @environment.windows?
21
20
  results << Result.new(:ok, "Architecture: #{@environment.architecture}")
22
21
  config = load_config(results)
23
22
  command = resolve(config, results) if config
@@ -29,6 +28,17 @@ module Wip
29
28
 
30
29
  private
31
30
 
31
+ def wsl2_messages
32
+ return ['WSL2 is available', 'WSL2 is not available'] if @environment.windows?
33
+
34
+ ['Running on WSL2', 'Not running on WSL2']
35
+ end
36
+
37
+ def interop_result
38
+ result(@environment.windows_interop? ? :ok : :fail, 'Windows executable interoperability is enabled',
39
+ 'Windows executable interoperability is disabled')
40
+ end
41
+
32
42
  def load_config(results)
33
43
  config = @loader.load
34
44
  invalid = %w[container image].select { |key| config.defaults[key].to_s.empty? }
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open3'
4
+
3
5
  module Wip
4
6
  # Detects WSL2, Windows interop, and architecture facts about the host.
5
7
  class Environment
@@ -8,7 +10,11 @@ module Wip
8
10
  @stdout = stdout
9
11
  end
10
12
 
13
+ def windows? = Gem.win_platform?
14
+
11
15
  def wsl2?
16
+ return wsl2_backend_available? if windows?
17
+
12
18
  File.read('/proc/version').match?(/microsoft.*WSL2/i)
13
19
  rescue Errno::ENOENT
14
20
  false
@@ -18,9 +24,20 @@ module Wip
18
24
  def interactive? = @stdin.tty? && @stdout.tty?
19
25
 
20
26
  def architecture
21
- machine = `uname -m`.strip
22
- { 'x86_64' => 'linux/amd64', 'aarch64' => 'linux/arm64', 'arm64' => 'linux/arm64' }.fetch(machine,
23
- "linux/#{machine}")
27
+ machine = RbConfig::CONFIG['host_cpu']
28
+ { 'x86_64' => 'linux/amd64', 'x64' => 'linux/amd64', 'aarch64' => 'linux/arm64', 'arm64' => 'linux/arm64' }
29
+ .fetch(machine, "linux/#{machine}")
30
+ end
31
+
32
+ private
33
+
34
+ # On native Windows there is no /proc/version to read, so ask Windows
35
+ # itself whether the WSL2 backend that WSLC depends on is installed.
36
+ def wsl2_backend_available?
37
+ _output, status = Open3.capture2e('wsl.exe', '--status')
38
+ status.success?
39
+ rescue Errno::ENOENT
40
+ false
24
41
  end
25
42
  end
26
43
  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.4.0'
4
+ VERSION = '0.4.1'
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wip contributors