-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvscodium.rb.patch
64 lines (59 loc) · 2.86 KB
/
vscodium.rb.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
diff --git a/homebrew-cask/Casks/vscodium.rb b/Casks/vscodium-with-vscode-extensions.rb
index fe11b6463..6a3abdfe1 100644
--- a/homebrew-cask/Casks/v/vscodium.rb
+++ b/Casks/vscodium-with-vscode-extensions.rb
@@ -1,1 +1,1 @@
-cask "vscodium" do
+cask "vscodium-with-vscode-extensions" do
@@ -7,6 +7,6 @@
url "https://github.com/VSCodium/vscodium/releases/download/#{version}/VSCodium.#{arch}.#{version}.dmg"
- name "VSCodium"
+ name "VSCodium (with original Visual Studio Code Extensions Gallery configuration)"
desc "Binary releases of VS Code without MS branding/telemetry/licensing"
homepage "https://github.com/VSCodium/vscodium"
@@ -33,7 +33,11 @@
auto_updates true
depends_on macos: ">= :high_sierra"
+ conflicts_with cask: [
+ "visual-studio-code",
+ "vscodium",
+ ]
app "VSCodium.app"
binary "#{appdir}/VSCodium.app/Contents/Resources/app/bin/codium"
@@ -47,4 +51,36 @@
"~/Library/Preferences/com.vscodium*.plist",
"~/Library/Saved Application State/com.vscodium.savedState",
]
+
+ postflight do
+ require 'json'
+ require 'fileutils'
+
+ # Reset extensions gallery to mainline Visual Studio Code one by overriding some settings in an external `product.json`.
+ # Support for this was added in [a recent VSCodium change](https://github.com/VSCodium/vscodium/pull/674).
+ product_file_path = "#{Dir.home}/Library/Application Support/VSCodium/product.json"
+
+ # Read exisitng product file if it exists, to not clobber any other settings the user might have.
+ begin
+ product = JSON.load(File.read(product_file_path))
+ # Just use an empty hash otherwise.
+ rescue
+ product = {}
+ end
+
+ # Change needed settings and write back to external file.
+ # Make sure we don't clobber more settings here than necessary, in case there is something else set in the `extensionsGallery` dictionary.
+ extensionsGallerySettings = product['extensionsGallery'] || {}
+ extensionsGallerySettings['serviceUrl'] = 'https://marketplace.visualstudio.com/_apis/public/gallery'
+ extensionsGallerySettings['itemUrl'] = 'https://marketplace.visualstudio.com/items'
+ product['extensionsGallery'] = extensionsGallerySettings
+
+ # Make sure VSCodium's Application Support directory is actually created before we try to write a file into it.
+ FileUtils.mkdir_p(File.dirname(product_file_path))
+ File.write(product_file_path, JSON.pretty_generate(product))
+ end
+
+ # Since we previously forced auto-updating off, we need to alert users about the new functionality.
+ # We don't want to blindly turn auto-updating back on in case the user doesn't want that for other reasons.
+ caveats 'With the latest versions of VSCodium, extensions gallery override settings and auto-updating can now coexist; if you want to turn auto-updating back on, remove the `update.mode` setting from your `settings.json` file.'
end