diff --git a/README.md b/README.md index 3e1f82c30..4876e9745 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask, Mac App Store, W [Visual Studio Code](https://code.visualstudio.com/) is optional and used for installing Visual Studio Code extensions. +[VSCodium](https://vscodium.com/) is optional and used for installing VSCodium extensions. + ## Installation `brew bundle` is automatically installed when first run. @@ -69,6 +71,9 @@ whalebrew "whalebrew/wget" # 'vscode --install-extension' vscode "GitHub.codespaces" + +# 'codium --install-extension' +vscodium "GitHub.codespaces" ``` ## Versions and lockfiles @@ -78,7 +83,7 @@ If your software needs specific pinned versions, consider [`whalebrew`](https:// ## New Installers/Checkers/Dumpers -`brew bundle` currently supports Homebrew, Homebrew Cask, Mac App Store, Whalebrew and Visual Studio Code. +`brew bundle` currently supports Homebrew, Homebrew Cask, Mac App Store, Whalebrew, Visual Studio Code, and VSCodium. We are interested in contributions for other installers/checkers/dumpers but they must: diff --git a/cmd/bundle.rb b/cmd/bundle.rb index 23355d9a3..570bdd588 100755 --- a/cmd/bundle.rb +++ b/cmd/bundle.rb @@ -95,6 +95,12 @@ class BundleCmd < AbstractCommand env: :bundle_dump_no_vscode, description: "`dump` without VSCode extensions. " \ "This is enabled by default if `HOMEBREW_BUNDLE_DUMP_NO_VSCODE` is set." + switch "--vscodium", + description: "`list` or `dump` VSCodium extensions." + switch "--no-vscodium", + env: :bundle_dump_no_vscodium, + description: "`dump` without VSCodium extensions. " \ + "This is enabled by default if `HOMEBREW_BUNDLE_DUMP_NO_VSCODIUM` is set." switch "--describe", env: :bundle_dump_describe, description: "`dump` adds a description comment above each line, unless the " \ @@ -106,7 +112,9 @@ class BundleCmd < AbstractCommand description: "`cleanup` casks using the `zap` command instead of `uninstall`." conflicts "--all", "--no-vscode" + conflicts "--all", "--no-vscodium" conflicts "--vscode", "--no-vscode" + conflicts "--vscodium", "--no-vscodium" named_args %w[install dump cleanup check exec list] end @@ -129,7 +137,7 @@ def run force = args.force? zap = args.zap? - no_type_args = !args.brews? && !args.casks? && !args.taps? && !args.mas? && !args.whalebrew? && !args.vscode? + no_type_args = !args.brews? && !args.casks? && !args.taps? && !args.mas? && !args.whalebrew? && !args.vscode? && !args.vscodium? case subcommand when nil, "install" diff --git a/lib/bundle.rb b/lib/bundle.rb index 09797d4ef..e12ba2348 100644 --- a/lib/bundle.rb +++ b/lib/bundle.rb @@ -35,3 +35,6 @@ require "bundle/vscode_extension_checker" require "bundle/vscode_extension_dumper" require "bundle/vscode_extension_installer" +require "bundle/vscodium_extension_checker" +require "bundle/vscodium_extension_dumper" +require "bundle/vscodium_extension_installer" diff --git a/lib/bundle/bundle.rb b/lib/bundle/bundle.rb index ff1af098a..b10670ef5 100644 --- a/lib/bundle/bundle.rb +++ b/lib/bundle/bundle.rb @@ -33,6 +33,10 @@ def vscode_installed? @vscode_installed ||= which("code").present? end + def vscodium_installed? + @vscodium_installed ||= which("codium").present? + end + def whalebrew_installed? @whalebrew_installed ||= which_formula("whalebrew") end diff --git a/lib/bundle/checker.rb b/lib/bundle/checker.rb index fb2be58ae..a10873b66 100644 --- a/lib/bundle/checker.rb +++ b/lib/bundle/checker.rb @@ -58,12 +58,13 @@ def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verb CheckResult = Struct.new :work_to_be_done, :errors CHECKS = { - taps_to_tap: "Taps", - casks_to_install: "Casks", - extensions_to_install: "VSCode Extensions", - apps_to_install: "Apps", - formulae_to_install: "Formulae", - formulae_to_start: "Services", + taps_to_tap: "Taps", + casks_to_install: "Casks", + extensions_to_install: "VSCode Extensions", + vscodium_extensions_to_install: "VSCodium Extensions", + apps_to_install: "Apps", + formulae_to_install: "Formulae", + formulae_to_start: "Services", }.freeze def check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false) @@ -122,6 +123,13 @@ def extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose ) end + def vscodium_extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false) + Bundle::Checker::VscodiumExtensionChecker.new.find_actionable( + @dsl.entries, + exit_on_first_error:, no_upgrade:, verbose:, + ) + end + def formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false) Bundle::Checker::BrewServiceChecker.new.find_actionable( @dsl.entries, diff --git a/lib/bundle/commands/cleanup.rb b/lib/bundle/commands/cleanup.rb index 132d3cb68..04b47b8dc 100644 --- a/lib/bundle/commands/cleanup.rb +++ b/lib/bundle/commands/cleanup.rb @@ -16,6 +16,7 @@ def reset! Bundle::BrewDumper.reset! Bundle::TapDumper.reset! Bundle::VscodeExtensionDumper.reset! + Bundle::VscodiumExtensionDumper.reset! Bundle::BrewServices.reset! end @@ -26,6 +27,7 @@ def run(global: false, file: nil, force: false, zap: false, dsl: nil) formulae = formulae_to_uninstall(global:, file:) taps = taps_to_untap(global:, file:) vscode_extensions = vscode_extensions_to_uninstall(global:, file:) + vscodium_extensions = vscodium_extensions_to_uninstall(global:, file:) if force if casks.any? args = zap ? ["--zap"] : [] @@ -44,6 +46,10 @@ def run(global: false, file: nil, force: false, zap: false, dsl: nil) vscode_extensions.each do |extension| Kernel.system "code", "--uninstall-extension", extension end + + vscodium_extensions.each do |extension| + Kernel.system "codium", "--uninstall-extension", extension + end end cleanup = system_output_no_stderr(HOMEBREW_BREW_FILE, "cleanup") @@ -75,6 +81,12 @@ def run(global: false, file: nil, force: false, zap: false, dsl: nil) would_uninstall = true end + if vscodium_extensions.any? + puts "Would uninstall VSCodium extensions:" + puts Formatter.columns vscodium_extensions + would_uninstall = true + end + cleanup = system_output_no_stderr(HOMEBREW_BREW_FILE, "cleanup", "--dry-run") unless cleanup.empty? puts "Would `brew cleanup`:" @@ -180,6 +192,19 @@ def vscode_extensions_to_uninstall(global: false, file: nil) current_extensions - kept_extensions end + def vscodium_extensions_to_uninstall(global: false, file: nil) + @dsl ||= Brewfile.read(global:, file:) + kept_extensions = @dsl.entries.select { |e| e.type == :vscodium }.map { |x| x.name.downcase } + + # To provide a graceful migration from `Brewfile`s that don't yet or + # don't want to use `vscodium`: don't remove any extensions if we don't + # find any in the `Brewfile`. + return [].freeze if kept_extensions.empty? + + current_extensions = Bundle::VscodiumExtensionDumper.extensions + current_extensions - kept_extensions + end + def system_output_no_stderr(cmd, *args) IO.popen([cmd, *args], err: :close).read end diff --git a/lib/bundle/commands/dump.rb b/lib/bundle/commands/dump.rb index 8a8747428..84d8fdbd6 100644 --- a/lib/bundle/commands/dump.rb +++ b/lib/bundle/commands/dump.rb @@ -5,9 +5,9 @@ module Commands module Dump module_function - def run(global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:) + def run(global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:, vscodium:) Bundle::Dumper.dump_brewfile( - global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:, + global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:, vscodium:, ) end end diff --git a/lib/bundle/commands/list.rb b/lib/bundle/commands/list.rb index b4568ed46..ad04508a4 100644 --- a/lib/bundle/commands/list.rb +++ b/lib/bundle/commands/list.rb @@ -5,11 +5,11 @@ module Commands module List module_function - def run(global:, file:, brews:, casks:, taps:, mas:, whalebrew:, vscode:) + def run(global:, file:, brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:) parsed_entries = Brewfile.read(global:, file:).entries Bundle::Lister.list( parsed_entries, - brews:, casks:, taps:, mas:, whalebrew:, vscode:, + brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:, ) end end diff --git a/lib/bundle/dsl.rb b/lib/bundle/dsl.rb index 7d1007a37..ae0f48e18 100644 --- a/lib/bundle/dsl.rb +++ b/lib/bundle/dsl.rb @@ -81,6 +81,12 @@ def vscode(name) @entries << Entry.new(:vscode, name) end + def vscodium(name) + raise "name(#{name.inspect}) should be a String object" unless name.is_a? String + + @entries << Entry.new(:vscodium, name) + end + def tap(name, clone_target = nil, options = {}) raise "name(#{name.inspect}) should be a String object" unless name.is_a? String if clone_target && !clone_target.is_a?(String) diff --git a/lib/bundle/dumper.rb b/lib/bundle/dumper.rb index dd3ba6694..b002e0471 100644 --- a/lib/bundle/dumper.rb +++ b/lib/bundle/dumper.rb @@ -13,7 +13,7 @@ def can_write_to_brewfile?(brewfile_path, force: false) true end - def build_brewfile(describe:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:, vscode:) + def build_brewfile(describe:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:, vscode:, vscodium:) content = [] content << TapDumper.dump if taps content << BrewDumper.dump(describe:, no_restart:) if brews @@ -21,14 +21,15 @@ def build_brewfile(describe:, no_restart:, brews:, taps:, casks:, mas:, whalebre content << MacAppStoreDumper.dump if mas content << WhalebrewDumper.dump if whalebrew content << VscodeExtensionDumper.dump if vscode + content << VscodiumExtensionDumper.dump if vscodium "#{content.reject(&:empty?).join("\n")}\n" end def dump_brewfile(global:, file:, describe:, force:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:, - vscode:) + vscode:, vscodium:) path = brewfile_path(global:, file:) can_write_to_brewfile?(path, force:) - content = build_brewfile(describe:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:) + content = build_brewfile(describe:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:, vscodium:) write_file path, content end diff --git a/lib/bundle/installer.rb b/lib/bundle/installer.rb index 31015439f..a20d69086 100644 --- a/lib/bundle/installer.rb +++ b/lib/bundle/installer.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: true +1# frozen_string_literal: true module Bundle module Installer @@ -31,6 +31,8 @@ def install(entries, global: false, file: nil, no_lock: false, no_upgrade: false Bundle::WhalebrewInstaller when :vscode Bundle::VscodeExtensionInstaller + when :vscodium + Bundle::VscodiumExtensionInstaller when :tap verb = "Tapping" options = entry.options diff --git a/lib/bundle/lister.rb b/lib/bundle/lister.rb index 4d9693ccf..599cff545 100644 --- a/lib/bundle/lister.rb +++ b/lib/bundle/lister.rb @@ -4,19 +4,20 @@ module Bundle module Lister module_function - def list(entries, brews:, casks:, taps:, mas:, whalebrew:, vscode:) + def list(entries, brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:) entries.each do |entry| - puts entry.name if show?(entry.type, brews:, casks:, taps:, mas:, whalebrew:, vscode:) + puts entry.name if show?(entry.type, brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:) end end - def self.show?(type, brews:, casks:, taps:, mas:, whalebrew:, vscode:) + def self.show?(type, brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:) return true if brews && type == :brew return true if casks && type == :cask return true if taps && type == :tap return true if mas && type == :mas return true if whalebrew && type == :whalebrew return true if vscode && type == :vscode + return true if vscodium && type == :vscodium false end diff --git a/lib/bundle/vscodium_extension_checker.rb b/lib/bundle/vscodium_extension_checker.rb new file mode 100644 index 000000000..7d44c4595 --- /dev/null +++ b/lib/bundle/vscodium_extension_checker.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Bundle + module Checker + class VscodiumExtensionChecker < Bundle::Checker::Base + PACKAGE_TYPE = :vscodium + PACKAGE_TYPE_NAME = "VSCodium Extension" + + def failure_reason(extension, no_upgrade:) + "#{PACKAGE_TYPE_NAME} #{extension} needs to be installed." + end + + def installed_and_up_to_date?(extension, no_upgrade: false) + Bundle::VscodiumExtensionInstaller.extension_installed?(extension) + end + end + end +end diff --git a/lib/bundle/vscodium_extension_dumper.rb b/lib/bundle/vscodium_extension_dumper.rb new file mode 100644 index 000000000..4fa1a2527 --- /dev/null +++ b/lib/bundle/vscodium_extension_dumper.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Bundle + module VscodiumExtensionDumper + module_function + + def reset! + @extensions = nil + end + + def extensions + @extensions ||= if Bundle.vscodium_installed? + Bundle.exchange_uid_if_needed! do + `codium --list-extensions 2>/dev/null` + end.split("\n").map(&:downcase) + else + [] + end + end + + def dump + extensions.map { |name| "vscodium \"#{name}\"" }.join("\n") + end + end +end diff --git a/lib/bundle/vscodium_extension_installer.rb b/lib/bundle/vscodium_extension_installer.rb new file mode 100644 index 000000000..720682dd5 --- /dev/null +++ b/lib/bundle/vscodium_extension_installer.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Bundle + module VscodiumExtensionInstaller + module_function + + def reset! + @installed_extensions = nil + end + + def preinstall(name, no_upgrade: false, verbose: false) + if !Bundle.vscodium_installed? && Bundle.cask_installed? + puts "Installing vscodium. It is not currently installed." if verbose + Bundle.system HOMEBREW_BREW_FILE, "install", "--cask", "vscodium", verbose: + end + + if extension_installed?(name) + puts "Skipping install of #{name} VSCodium extension. It is already installed." if verbose + return false + end + + raise "Unable to install #{name} VSCodium extension. VSCodium is not installed." unless Bundle.vscodium_installed? + + true + end + + def install(name, preinstall: true, no_upgrade: false, verbose: false, force: false) + return true unless preinstall + return true if extension_installed?(name) + + puts "Installing #{name} VSCodium extension. It is not currently installed." if verbose + + return false unless Bundle.exchange_uid_if_needed! do + Bundle.system("codium", "--install-extension", name, verbose:) + end + + installed_extensions << name + + true + end + + def extension_installed?(name) + installed_extensions.include? name.downcase + end + + def installed_extensions + @installed_extensions ||= Bundle::VscodiumExtensionDumper.extensions + end + end +end diff --git a/spec/bundle/commands/check_command_spec.rb b/spec/bundle/commands/check_command_spec.rb index 121041534..e100f9833 100644 --- a/spec/bundle/commands/check_command_spec.rb +++ b/spec/bundle/commands/check_command_spec.rb @@ -261,6 +261,14 @@ receive(:exit_early_check).once.and_call_original expect { do_check }.to raise_error(SystemExit) end + + it "stops checking after the first VSCodium extension" do + allow_any_instance_of(Pathname).to receive(:read).and_return("vscodium 'abc'\nvscodium 'def'") + + expect_any_instance_of(Bundle::Checker::VscodiumExtensionChecker).to \ + receive(:exit_early_check).once.and_call_original + expect { do_check }.to raise_error(SystemExit) + end end context "when a new checker fails to implement installed_and_up_to_date" do diff --git a/spec/bundle/commands/cleanup_command_spec.rb b/spec/bundle/commands/cleanup_command_spec.rb index 8cac2e535..1625eb7cb 100644 --- a/spec/bundle/commands/cleanup_command_spec.rb +++ b/spec/bundle/commands/cleanup_command_spec.rb @@ -22,6 +22,7 @@ brew 'hasbuilddependency2' mas 'appstoreapp1', id: 1 vscode 'VsCodeExtension1' + vscodium 'VsCodiumExtension1' EOS end @@ -87,15 +88,26 @@ allow(Bundle::VscodeExtensionDumper).to receive(:extensions).and_return(%w[z vscodeextension1]) expect(described_class.vscode_extensions_to_uninstall).to eql(%w[z]) end + + it "computes which VSCodium extensions to uninstall" do + allow(Bundle::VscodiumExtensionDumper).to receive(:extensions).and_return(%w[z]) + expect(described_class.vscodium_extensions_to_uninstall).to eql(%w[z]) + end + + it "computes which VSCodium extensions to uninstall irrespective of case of the extension name" do + allow(Bundle::VscodiumExtensionDumper).to receive(:extensions).and_return(%w[z vscodiumextension1]) + expect(described_class.vscodium_extensions_to_uninstall).to eql(%w[z]) + end end context "when there are no formulae to uninstall and no taps to untap" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: [], - formulae_to_uninstall: [], - taps_to_untap: [], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end it "does nothing" do @@ -108,10 +120,11 @@ context "when there are casks to uninstall" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], - formulae_to_uninstall: [], - taps_to_untap: [], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end it "uninstalls casks" do @@ -124,10 +137,11 @@ context "when there are casks to zap" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], - formulae_to_uninstall: [], - taps_to_untap: [], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end it "uninstalls casks" do @@ -140,10 +154,11 @@ context "when there are formulae to uninstall" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: [], - formulae_to_uninstall: %w[a b], - taps_to_untap: [], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: %w[a b], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end it "uninstalls formulae" do @@ -156,10 +171,11 @@ context "when there are taps to untap" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: [], - formulae_to_uninstall: [], - taps_to_untap: %w[a b], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: [], + taps_to_untap: %w[a b], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end it "untaps taps" do @@ -172,10 +188,11 @@ context "when there are VSCode extensions to uninstall" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: [], - formulae_to_uninstall: [], - taps_to_untap: [], - vscode_extensions_to_uninstall: %w[GitHub.codespaces]) + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: %w[GitHub.codespaces], + vscodium_extensions_to_uninstall: []) end it "uninstalls extensions" do @@ -185,33 +202,52 @@ end end + context "when there are VSCodium extensions to uninstall" do + before do + described_class.reset! + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: %w[GitHub.codespaces]) + end + + it "uninstalls extensions" do + expect(Kernel).to receive(:system).with("codium", "--uninstall-extension", "GitHub.codespaces") + expect(described_class).to receive(:system_output_no_stderr).and_return("") + described_class.run(force: true) + end + end + context "when there are casks and formulae to uninstall and taps to untap but without passing `--force`" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], - formulae_to_uninstall: %w[a b], - taps_to_untap: %w[a b], - vscode_extensions_to_uninstall: %w[a b]) + allow(described_class).to receive_messages(casks_to_uninstall: %w[a b], + formulae_to_uninstall: %w[a b], + taps_to_untap: %w[a b], + vscode_extensions_to_uninstall: %w[a b], + vscodium_extensions_to_uninstall: %w[a b]) end it "lists casks, formulae and taps" do - expect(Formatter).to receive(:columns).with(%w[a b]).exactly(4).times + expect(Formatter).to receive(:columns).with(%w[a b]).exactly(5).times expect(Kernel).not_to receive(:system) expect(described_class).to receive(:system_output_no_stderr).and_return("") expect do described_class.run end.to raise_error(SystemExit) - .and output(/Would uninstall formulae:.*Would untap:.*Would uninstall VSCode extensions:/m).to_stdout + .and output(/Would uninstall formulae:.*Would untap:.*Would uninstall VSCode extensions:.*Would uninstall VSCodium extensions:/m).to_stdout end end context "when there is brew cleanup output" do before do described_class.reset! - allow(described_class).to receive_messages(casks_to_uninstall: [], - formulae_to_uninstall: [], - taps_to_untap: [], - vscode_extensions_to_uninstall: []) + allow(described_class).to receive_messages(casks_to_uninstall: [], + formulae_to_uninstall: [], + taps_to_untap: [], + vscode_extensions_to_uninstall: [], + vscodium_extensions_to_uninstall: []) end def sane? diff --git a/spec/bundle/commands/dump_command_spec.rb b/spec/bundle/commands/dump_command_spec.rb index 90a755466..9013f6081 100644 --- a/spec/bundle/commands/dump_command_spec.rb +++ b/spec/bundle/commands/dump_command_spec.rb @@ -5,7 +5,7 @@ describe Bundle::Commands::Dump do subject(:dump) do described_class.run(global:, file: nil, describe: false, force:, no_restart: false, taps: true, brews: true, - casks: true, mas: true, whalebrew: true, vscode: true) + casks: true, mas: true, whalebrew: true, vscode: true, vscodium: true) end let(:force) { false } diff --git a/spec/bundle/commands/install_command_spec.rb b/spec/bundle/commands/install_command_spec.rb index 70970a770..43314e392 100644 --- a/spec/bundle/commands/install_command_spec.rb +++ b/spec/bundle/commands/install_command_spec.rb @@ -23,6 +23,7 @@ mas '1Password', id: 443987910 whalebrew 'whalebrew/wget' vscode 'GitHub.codespaces' + vscodium 'GitHub.codespaces' EOS end @@ -30,6 +31,7 @@ allow(Bundle::TapInstaller).to receive(:preinstall).and_return(false) allow(Bundle::WhalebrewInstaller).to receive(:preinstall).and_return(false) allow(Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false) + allow(Bundle::VscodiumExtensionInstaller).to receive(:preinstall).and_return(false) allow(Bundle::BrewInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true) @@ -41,6 +43,7 @@ allow(Bundle::TapInstaller).to receive(:preinstall).and_return(false) allow(Bundle::WhalebrewInstaller).to receive(:preinstall).and_return(false) allow(Bundle::VscodeExtensionInstaller).to receive(:preinstall).and_return(false) + allow(Bundle::VscodiumExtensionInstaller).to receive(:preinstall).and_return(false) allow(Bundle::BrewInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::CaskInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true) @@ -65,6 +68,7 @@ allow(Bundle::TapInstaller).to receive_messages(preinstall: true, install: false) allow(Bundle::WhalebrewInstaller).to receive_messages(preinstall: true, install: false) allow(Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: false) + allow(Bundle::VscodiumExtensionInstaller).to receive_messages(preinstall: true, install: false) allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents) expect { described_class.run }.to raise_error(SystemExit) @@ -77,6 +81,7 @@ allow(Bundle::MacAppStoreInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::WhalebrewInstaller).to receive_messages(preinstall: true, install: true) allow(Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: true) + allow(Bundle::VscodiumExtensionInstaller).to receive_messages(preinstall: true, install: true) allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents) expect(Bundle).not_to receive(:system) diff --git a/spec/bundle/commands/list_command_spec.rb b/spec/bundle/commands/list_command_spec.rb index 131f91d99..035e93364 100644 --- a/spec/bundle/commands/list_command_spec.rb +++ b/spec/bundle/commands/list_command_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" describe Bundle::Commands::List do - subject(:list) { described_class.run(global: false, file: nil, brews:, casks:, taps:, mas:, whalebrew:, vscode:) } + subject(:list) { described_class.run(global: false, file: nil, brews:, casks:, taps:, mas:, whalebrew:, vscode:, vscodium:) } let(:brews) { true } let(:casks) { false } @@ -11,6 +11,7 @@ let(:mas) { false } let(:whalebrew) { false } let(:vscode) { false } + let(:vscodium) { false } before do allow_any_instance_of(IO).to receive(:puts) @@ -26,6 +27,7 @@ mas '1Password', id: 443987910 whalebrew 'whalebrew/imagemagick' vscode 'shopify.ruby-lsp' + vscodium 'shopify.ruby-lsp' EOS ) end @@ -42,6 +44,7 @@ mas: "1Password", whalebrew: "whalebrew/imagemagick", vscode: "shopify.ruby-lsp", + vscodium: "shopify.ruby-lsp", } combinations = 1.upto(types_and_deps.length).flat_map do |i| @@ -61,6 +64,7 @@ let(:mas) { args_hash[:mas] } let(:whalebrew) { args_hash[:whalebrew] } let(:vscode) { args_hash[:vscode] } + let(:vscodium) { args_hash[:vscodium] } it "shows only #{words}" do expected = options_list.map { |opt| types_and_deps[opt] }.join("\n") diff --git a/spec/bundle/dsl_spec.rb b/spec/bundle/dsl_spec.rb index 34708a327..d0bca1e66 100644 --- a/spec/bundle/dsl_spec.rb +++ b/spec/bundle/dsl_spec.rb @@ -24,6 +24,7 @@ def dsl_from_string(string) mas '1Password', id: 443987910 whalebrew 'whalebrew/wget' vscode 'GitHub.codespaces' + vscodium 'GitHub.codespaces' EOS end diff --git a/spec/bundle/dumper_spec.rb b/spec/bundle/dumper_spec.rb index fa54f5c86..2733b33d0 100644 --- a/spec/bundle/dumper_spec.rb +++ b/spec/bundle/dumper_spec.rb @@ -10,13 +10,14 @@ ENV["HOMEBREW_BUNDLE_FILE"] = "" allow(Bundle).to receive_messages(cask_installed?: true, mas_installed?: false, whalebrew_installed?: false, - vscode_installed?: false) + vscode_installed?: false, vscodium_installed?: false) Bundle::BrewDumper.reset! Bundle::TapDumper.reset! Bundle::CaskDumper.reset! Bundle::MacAppStoreDumper.reset! Bundle::WhalebrewDumper.reset! Bundle::VscodeExtensionDumper.reset! + Bundle::VscodiumExtensionDumper.reset! Bundle::BrewServices.reset! chrome = instance_double(Cask::Cask, @@ -38,7 +39,7 @@ it "generates output" do expect(dumper.build_brewfile( describe: false, no_restart: false, brews: true, taps: true, casks: true, mas: true, - whalebrew: true, vscode: true + whalebrew: true, vscode: true, vscodium: true )).to eql("cask \"google-chrome\"\ncask \"java\"\ncask \"iterm2-beta\"\n") end