homebrew-core/Formula/code-server.rb

75 lines
2.5 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.9.0.tgz"
sha256 "f4e69487fb2524ac4d3e4c9914e88647d73cab502c67d932400df67a223ccb86"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "fc691d8a7ee8bb0196b88b07e7632f72f5672c6fc282bf43ceac105477bd76c6"
sha256 cellar: :any_skip_relocation, big_sur: "d2a74e6e8ddf3d237bfc88db314f6f08359aa20f1d281fc362c98e434abae926"
sha256 cellar: :any_skip_relocation, catalina: "01367ad466c969e70d3dec46a3cd4dcd73ca1757ce7716240968a71b05ac1422"
sha256 cellar: :any_skip_relocation, mojave: "ae5c19804b128fc9efa1f580ecc5fb5b97118410c82a7058cefdaf0dfd268a8e"
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