Files
chromebrew/packages/copilot.rb
2026-03-28 03:29:57 +00:00

43 lines
1.3 KiB
Ruby

require 'package'
class Copilot < Package
description 'AI coding assistant that helps you write code faster and with less effort.'
homepage 'https://github.com/github/copilot-cli'
version '1.0.12'
license 'GitHub Copilot CLI License'
compatibility 'x86_64'
min_glibc '2.28'
source_url "https://github.com/github/copilot-cli/releases/download/v#{version}/copilot-linux-x64.tar.gz"
source_sha256 '42a1593bd04d5b3fbc7b8042f4ab7160ef4cdf2e637b2e6cc7b8cca71dfb59f6'
depends_on 'nodebrew' # R
no_compile_needed
def self.preinstall
# Get the major node version.
node_version = `node -v 2> /dev/null`
if node_version.empty?
abort <<~EOM.lightred
Node.js is not installed. Use nodebrew to install a compatible version.
Example: source ~/.bashrc && nodebrew install 22 && nodebrew use 22
EOM
end
node_major_version = node_version.gsub(/[^\d^.]/, '').split('.')[0].chomp
unless node_major_version >= '22'
abort <<~EOM.lightred
Node.js version must be >= 22. Use nodebrew to install a compatible version.
Example: source ~/.bashrc && nodebrew install 22 && nodebrew use 22
EOM
end
end
def self.install
FileUtils.install 'copilot', "#{CREW_DEST_PREFIX}/bin/copilot", mode: 0o755
end
def self.postremove
Package.agree_to_remove("#{HOME}/.copilot")
end
end