79 lines
2.4 KiB
Ruby
79 lines
2.4 KiB
Ruby
class CodeServer < Formula
|
|
desc "Access VS Code through the browser"
|
|
homepage "https://github.com/cdr/code-server"
|
|
url "https://registry.npmjs.org/code-server/-/code-server-3.7.4.tgz"
|
|
sha256 "6ac859268c5d3f7bebe5624c60fb8ecf2acabfd32b14cc4bd604c11f60a2e2c7"
|
|
license "MIT"
|
|
|
|
livecheck do
|
|
url :stable
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "52371fd8a9a4781362a3312bd8cd74a9c94e539d2891d9df8b483db19744c335" => :big_sur
|
|
sha256 "bfb6e272fb8cb24550ebbb053e09e087dfecde627855595883a089b024f5cd75" => :catalina
|
|
sha256 "deb034592f8582e2281b35b4854dfe0baaec82319e65e996cdcafce0d27eb0fa" => :mojave
|
|
end
|
|
|
|
depends_on "python@3.9" => :build
|
|
depends_on "yarn" => :build
|
|
depends_on "node"
|
|
|
|
on_linux do
|
|
depends_on "pkg-config" => :build
|
|
depends_on "libsecret"
|
|
depends_on "libx11"
|
|
depends_on "libxkbfile"
|
|
end
|
|
|
|
def install
|
|
system "yarn", "--production", "--frozen-lockfile"
|
|
libexec.install Dir["*"]
|
|
env = { PATH: "#{HOMEBREW_PREFIX}/opt/node/bin:$PATH" }
|
|
(bin/"code-server").write_env_script "#{libexec}/out/node/entry.js", env
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
The launchd service runs on http://127.0.0.1:8080. Logs are located at #{var}/log/code-server.log.
|
|
EOS
|
|
end
|
|
|
|
plist_options manual: "code-server"
|
|
|
|
def plist
|
|
<<~EOS
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>KeepAlive</key>
|
|
<true/>
|
|
<key>Label</key>
|
|
<string>#{plist_name}</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>#{HOMEBREW_PREFIX}/bin/code-server</string>
|
|
</array>
|
|
<key>RunAtLoad</key>
|
|
<true/>
|
|
<key>WorkingDirectory</key>
|
|
<string>#{ENV["HOME"]}</string>
|
|
<key>StandardOutPath</key>
|
|
<string>#{var}/log/code-server.log</string>
|
|
<key>StandardErrorPath</key>
|
|
<string>#{var}/log/code-server.log</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
# See https://github.com/cdr/code-server/blob/master/ci/build/test-standalone-release.sh
|
|
system bin/"code-server", "--extensions-dir=.", "--install-extension", "ms-python.python"
|
|
assert_match "ms-python.python",
|
|
shell_output("#{bin/"code-server"} --extensions-dir=. --list-extensions")
|
|
end
|
|
end
|