jt55401-eddie-cli 0.4.3
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 +7 -0
- data/LICENSE.txt +1 -0
- data/README.md +20 -0
- data/exe/eddie +9 -0
- data/lib/eddie/cli/runner.rb +157 -0
- data/lib/eddie/cli/version.rb +7 -0
- metadata +47 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b4eac5d36b69867d0ab5859fde5a5d6317c251b1ce8f9900d4a01aa7163153be
|
|
4
|
+
data.tar.gz: 5f232d8908ced798106cb26725bc6c7b7e800263b85ed71d324e77ceb208aa8c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2c5461d49d6c90dcd233d8f452fb1f32bf964282629bdf09a97127bce83f010bbab574939de825a7fb6779afbf2de35ad12cf028b32b6fe48fe1a8c6aea2fcc8
|
|
7
|
+
data.tar.gz: a3cb084c58e69b496df9dcf01a3312a8b2da8674020fdbdfeba5851bd30a7560f2afa5aa95e312dad36427b3d8eca84c57d46b48f1348ad2119d6c7b926f889b
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GPL-3.0-only; see repository root LICENSE for full text.
|
data/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# jt55401-eddie-cli
|
|
2
|
+
|
|
3
|
+
`jt55401-eddie-cli` exposes the `eddie` command for Ruby workflows.
|
|
4
|
+
|
|
5
|
+
On first run it downloads the native Eddie binary for this gem version from:
|
|
6
|
+
|
|
7
|
+
- `https://github.com/jt55401/eddie/releases/tag/v<version>`
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
gem install jt55401-eddie-cli -v 0.2.4
|
|
13
|
+
eddie --help
|
|
14
|
+
eddie index --cms jekyll --content-dir . --output assets/eddie/index.ed
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Environment
|
|
18
|
+
|
|
19
|
+
- `EDDIE_CLI_CACHE_DIR`: override download/cache directory
|
|
20
|
+
- `EDDIE_CLI_VERSION`: override release version (defaults to gem version)
|
data/exe/eddie
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "digest"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "net/http"
|
|
6
|
+
require "uri"
|
|
7
|
+
require "tmpdir"
|
|
8
|
+
|
|
9
|
+
require_relative "version"
|
|
10
|
+
|
|
11
|
+
module Eddie
|
|
12
|
+
module CLI
|
|
13
|
+
module Runner
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
# Asset names match the eddie release matrix: eddie-<os>-<arch>[.exe].
|
|
17
|
+
# Only the platforms release.yml actually builds are listed here.
|
|
18
|
+
def resolve_asset
|
|
19
|
+
platform = RUBY_PLATFORM
|
|
20
|
+
|
|
21
|
+
return "eddie-linux-x86_64" if platform.match?(/linux/) && platform.match?(/x86_64|amd64/)
|
|
22
|
+
return "eddie-linux-aarch64" if platform.match?(/linux/) && platform.match?(/aarch64|arm64/)
|
|
23
|
+
return "eddie-macos-x86_64" if platform.match?(/darwin/) && platform.match?(/x86_64|amd64/)
|
|
24
|
+
return "eddie-macos-aarch64" if platform.match?(/darwin/) && platform.match?(/arm64/)
|
|
25
|
+
return "eddie-windows-x86_64.exe" if platform.match?(/mingw|mswin/) && platform.match?(/x64|x86_64|amd64/)
|
|
26
|
+
|
|
27
|
+
raise "Unsupported platform for Eddie CLI: #{platform}. Eddie releases eddie-linux-x86_64, " \
|
|
28
|
+
"eddie-linux-aarch64, eddie-macos-x86_64, eddie-macos-aarch64, and eddie-windows-x86_64.exe. " \
|
|
29
|
+
"Build from source for other platforms."
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def package_version
|
|
33
|
+
ENV.fetch("EDDIE_CLI_VERSION", Eddie::CLI::VERSION)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# OS cache directory convention, overridable with EDDIE_CLI_CACHE_DIR.
|
|
37
|
+
def cache_root
|
|
38
|
+
return ENV["EDDIE_CLI_CACHE_DIR"] if ENV["EDDIE_CLI_CACHE_DIR"]
|
|
39
|
+
|
|
40
|
+
case RUBY_PLATFORM
|
|
41
|
+
when /darwin/
|
|
42
|
+
File.join(Dir.home, "Library", "Caches", "eddie-cli")
|
|
43
|
+
when /mingw|mswin/
|
|
44
|
+
local_app_data = ENV["LOCALAPPDATA"] || File.join(Dir.home, "AppData", "Local")
|
|
45
|
+
File.join(local_app_data, "eddie-cli", "Cache")
|
|
46
|
+
else
|
|
47
|
+
File.join(ENV["XDG_CACHE_HOME"] || File.join(Dir.home, ".cache"), "eddie-cli")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Parses `sha256sum * > SHA256SUMS` output into { filename => hex digest }.
|
|
52
|
+
def parse_sha256sums(text)
|
|
53
|
+
sums = {}
|
|
54
|
+
text.each_line do |line|
|
|
55
|
+
line = line.strip
|
|
56
|
+
next if line.length < 66
|
|
57
|
+
|
|
58
|
+
hash = line[0, 64].downcase
|
|
59
|
+
next unless hash.match?(/\A[0-9a-f]{64}\z/)
|
|
60
|
+
|
|
61
|
+
filename = line[64..].sub(/\A[\s*]+/, "").strip
|
|
62
|
+
sums[filename] = hash unless filename.empty?
|
|
63
|
+
end
|
|
64
|
+
sums
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def ensure_binary
|
|
68
|
+
version = package_version
|
|
69
|
+
asset = resolve_asset
|
|
70
|
+
bin_name = asset.end_with?(".exe") ? "eddie.exe" : "eddie"
|
|
71
|
+
|
|
72
|
+
version_dir = File.join(cache_root, version)
|
|
73
|
+
bin_path = File.join(version_dir, bin_name)
|
|
74
|
+
|
|
75
|
+
if File.exist?(bin_path)
|
|
76
|
+
FileUtils.chmod(0o755, bin_path)
|
|
77
|
+
return bin_path
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
FileUtils.mkdir_p(version_dir)
|
|
81
|
+
release_base = "https://github.com/jt55401/eddie/releases/download/v#{version}"
|
|
82
|
+
asset_url = "#{release_base}/#{asset}"
|
|
83
|
+
sums_url = "#{release_base}/SHA256SUMS"
|
|
84
|
+
warn "Downloading Eddie CLI #{version} (#{asset})..."
|
|
85
|
+
|
|
86
|
+
Dir.mktmpdir("eddie-cli", version_dir) do |tmp_dir|
|
|
87
|
+
tmp_path = File.join(tmp_dir, bin_name)
|
|
88
|
+
download(asset_url, tmp_path)
|
|
89
|
+
|
|
90
|
+
sums_text = String.new
|
|
91
|
+
download_text(sums_url, sums_text)
|
|
92
|
+
expected = parse_sha256sums(sums_text)[asset]
|
|
93
|
+
raise "SHA256SUMS for v#{version} has no entry for #{asset}." unless expected
|
|
94
|
+
|
|
95
|
+
actual = Digest::SHA256.file(tmp_path).hexdigest
|
|
96
|
+
if actual != expected
|
|
97
|
+
raise "Checksum mismatch for #{asset}: expected #{expected}, got #{actual}. " \
|
|
98
|
+
"Refusing to install a corrupted or tampered binary."
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
FileUtils.chmod(0o755, tmp_path)
|
|
102
|
+
FileUtils.mv(tmp_path, bin_path)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
bin_path
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def download(url, destination, redirects = 0)
|
|
109
|
+
raise "Too many redirects while downloading #{url}" if redirects > 5
|
|
110
|
+
|
|
111
|
+
uri = URI(url)
|
|
112
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
113
|
+
request = Net::HTTP::Get.new(uri)
|
|
114
|
+
request["User-Agent"] = "eddie-cli-rubygems"
|
|
115
|
+
response = http.request(request)
|
|
116
|
+
|
|
117
|
+
case response
|
|
118
|
+
when Net::HTTPSuccess
|
|
119
|
+
File.open(destination, "wb") { |file| file.write(response.body) }
|
|
120
|
+
when Net::HTTPRedirection
|
|
121
|
+
location = response["location"]
|
|
122
|
+
raise "Redirect missing location header for #{url}" unless location
|
|
123
|
+
|
|
124
|
+
next_url = URI.join(url, location).to_s
|
|
125
|
+
download(next_url, destination, redirects + 1)
|
|
126
|
+
else
|
|
127
|
+
raise "Download failed (#{response.code}): #{url}"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Fetches a small text file (SHA256SUMS) and appends its body into `text`.
|
|
133
|
+
def download_text(url, text, redirects = 0)
|
|
134
|
+
raise "Too many redirects while downloading #{url}" if redirects > 5
|
|
135
|
+
|
|
136
|
+
uri = URI(url)
|
|
137
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
|
138
|
+
request = Net::HTTP::Get.new(uri)
|
|
139
|
+
request["User-Agent"] = "eddie-cli-rubygems"
|
|
140
|
+
response = http.request(request)
|
|
141
|
+
|
|
142
|
+
case response
|
|
143
|
+
when Net::HTTPSuccess
|
|
144
|
+
text << response.body
|
|
145
|
+
when Net::HTTPRedirection
|
|
146
|
+
location = response["location"]
|
|
147
|
+
raise "Redirect missing location header for #{url}" unless location
|
|
148
|
+
|
|
149
|
+
download_text(URI.join(url, location).to_s, text, redirects + 1)
|
|
150
|
+
else
|
|
151
|
+
raise "Download failed (#{response.code}): #{url}"
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jt55401-eddie-cli
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jason Grey
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Provides an eddie executable that downloads and runs tagged Eddie release
|
|
13
|
+
binaries.
|
|
14
|
+
executables:
|
|
15
|
+
- eddie
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE.txt
|
|
20
|
+
- README.md
|
|
21
|
+
- exe/eddie
|
|
22
|
+
- lib/eddie/cli/runner.rb
|
|
23
|
+
- lib/eddie/cli/version.rb
|
|
24
|
+
homepage: https://github.com/jt55401/eddie
|
|
25
|
+
licenses:
|
|
26
|
+
- GPL-3.0-only
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: https://github.com/jt55401/eddie
|
|
29
|
+
source_code_uri: https://github.com/jt55401/eddie
|
|
30
|
+
rdoc_options: []
|
|
31
|
+
require_paths:
|
|
32
|
+
- lib
|
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: 3.0.0
|
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
requirements: []
|
|
44
|
+
rubygems_version: 4.0.16
|
|
45
|
+
specification_version: 4
|
|
46
|
+
summary: Cross-platform launcher for the Eddie CLI
|
|
47
|
+
test_files: []
|