Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add brew bundle dump selections #1217

Merged
merged 1 commit into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea
.vscode

Brewfile
Brewfile.lock.json
Gemfile.lock
Expand Down
7 changes: 7 additions & 0 deletions cmd/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ def bundle
describe: args.describe?,
force: args.force?,
no_restart: args.no_restart?,
all: args.all?,
taps: args.taps?,
brews: args.brews?,
casks: args.casks?,
mas: args.mas?,
whalebrew: args.whalebrew?,
vscode: args.vscode?,
)
when "cleanup"
Bundle::Commands::Cleanup.run(
Expand Down
6 changes: 5 additions & 1 deletion lib/bundle/commands/dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ module Commands
module Dump
module_function

def run(global: false, file: nil, describe: false, force: false, no_restart: false)
def run(global: false, file: nil, describe: false, force: false, no_restart: false,
all: false, taps: false, brews: false, casks: false,
mas: false, whalebrew: false, vscode: false)
Bundle::Dumper.dump_brewfile(
global: global, file: file, describe: describe, force: force, no_restart: no_restart,
all: all, taps: taps, brews: brews, casks: casks,
mas: mas, whalebrew: whalebrew, vscode: vscode
)
end
end
Expand Down
25 changes: 16 additions & 9 deletions lib/bundle/dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,28 @@ def can_write_to_brewfile?(brewfile_path, force: false)
true
end

def build_brewfile(describe: false, no_restart: false)
def build_brewfile(describe: false, no_restart: false,
all: false, taps: false, brews: false, casks: false,
mas: false, whalebrew: false, vscode: false)
all ||= !(taps || brews || casks || mas || whalebrew || vscode)
content = []
content << TapDumper.dump
content << BrewDumper.dump(describe: describe, no_restart: no_restart)
content << CaskDumper.dump(describe: describe)
content << MacAppStoreDumper.dump
content << WhalebrewDumper.dump
content << VscodeExtensionDumper.dump
content << TapDumper.dump if taps || all
content << BrewDumper.dump(describe: describe, no_restart: no_restart) if brews || all
content << CaskDumper.dump(describe: describe) if casks || all
content << MacAppStoreDumper.dump if mas || all
content << WhalebrewDumper.dump if whalebrew || all
content << VscodeExtensionDumper.dump if vscode || all
"#{content.reject(&:empty?).join("\n")}\n"
end

def dump_brewfile(global: false, file: nil, describe: false, force: false, no_restart: false)
def dump_brewfile(global: false, file: nil, describe: false, force: false, no_restart: false,
all: false, taps: false, brews: false, casks: false,
mas: false, whalebrew: false, vscode: false)
path = brewfile_path(global: global, file: file)
can_write_to_brewfile?(path, force: force)
content = build_brewfile(describe: describe, no_restart: no_restart)
content = build_brewfile(describe: describe, no_restart: no_restart,
all: all, taps: taps, brews: brews, casks: casks,
mas: mas, whalebrew: whalebrew, vscode: vscode)
write_file path, content
end

Expand Down