Skip to content

Commit 7905f88

Browse files
committed
Add Swiftly installation support
1 parent c14c506 commit 7905f88

File tree

6 files changed

+649
-46
lines changed

6 files changed

+649
-46
lines changed

package-lock.json

Lines changed: 179 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,13 @@
10831083
"order": 4,
10841084
"scope": "machine-overridable"
10851085
},
1086+
"swift.suppressSwiftlyInstallPrompt": {
1087+
"type": "boolean",
1088+
"default": false,
1089+
"markdownDescription": "Suppress the automatic Swiftly installation prompt when no Swift toolchain is found.",
1090+
"order": 98,
1091+
"scope": "application"
1092+
},
10861093
"swift.diagnostics": {
10871094
"type": "boolean",
10881095
"default": false,
@@ -2081,6 +2088,7 @@
20812088
"fast-glob": "^3.3.3",
20822089
"lcov-parse": "^1.0.0",
20832090
"plist": "^3.1.0",
2091+
"tar": "^7.5.1",
20842092
"vscode-languageclient": "^9.0.1",
20852093
"xml2js": "^0.6.2",
20862094
"zod": "^4.1.5"

src/PackageWatcher.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import * as vscode from "vscode";
1717

1818
import { FolderContext } from "./FolderContext";
1919
import { FolderOperation } from "./WorkspaceContext";
20+
import { handleMissingSwiftly } from "./commands/installSwiftly";
2021
import { SwiftLogger } from "./logging/SwiftLogger";
2122
import { BuildFlags } from "./toolchain/BuildFlags";
23+
import { handleMissingSwiftlyToolchain } from "./toolchain/swiftly";
2224
import { showReloadExtensionNotification } from "./ui/ReloadExtension";
2325
import { fileExists } from "./utilities/filesystem";
2426
import { Version } from "./utilities/version";
@@ -140,6 +142,30 @@ export class PackageWatcher {
140142
async handleSwiftVersionFileChange() {
141143
const version = await this.readSwiftVersionFile();
142144
if (version?.toString() !== this.currentVersion?.toString()) {
145+
if (version) {
146+
const swiftlyInstalled = await handleMissingSwiftly(this.logger);
147+
if (swiftlyInstalled) {
148+
const toolchainInstalled = await handleMissingSwiftlyToolchain(
149+
version.toString(),
150+
this.logger,
151+
this.folderContext.folder
152+
);
153+
if (toolchainInstalled) {
154+
// Build dynamic message based on installation results
155+
const message =
156+
"Swiftly and Swift toolchain have been installed. Please reload the extension to use the new toolchain.";
157+
await showReloadExtensionNotification(message);
158+
return;
159+
} else {
160+
// Only Swiftly was installed
161+
const message =
162+
"Swiftly has been installed. Please reload the extension to continue.";
163+
await showReloadExtensionNotification(message);
164+
return;
165+
}
166+
}
167+
}
168+
143169
await this.folderContext.fireEvent(FolderOperation.swiftVersionUpdated);
144170
await showReloadExtensionNotification(
145171
"Changing the swift toolchain version requires the extension to be reloaded"

0 commit comments

Comments
 (0)