Skip to content

Commit b745cad

Browse files
committed
Added a swiftly step to walkthrough
1 parent f7a44ae commit b745cad

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed
42 KB
Loading

assets/walkthrough/swiftly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Install Swiftly
2+
3+
![Install Swiftly](./images/installSwiftly.png)
4+
5+
A toolchain is the complete set of tools needed to compile and run Swift code. [Swiftly](https://www.swift.org/swiftly/documentation/swiftlydocs/) is a toolchain manager and installer that allows you to switch between different toolchains. If you're familiar with the JS ecosystem, Swiftly is roughly equivalent to [nvm](https://www.nvmnode.com).

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@
109109
"markdown": "assets/walkthrough/swiftCommands.md"
110110
}
111111
},
112+
{
113+
"id": "installing-toolchains",
114+
"title": "Install a Swift toolchain with Swiftly",
115+
"description": "[Swiftly](https://www.swift.org/swiftly/documentation/swiftlydocs/) is an open source toolchain manager that was built to install and manage multiple toolchains. \n[Install Swiftly](command:swift.installSwiftly)",
116+
"media": {
117+
"markdown": "assets/walkthrough/swiftly.md"
118+
},
119+
"completionEvents": [
120+
"onContext:swift.supportsSwiftlyInstall"
121+
]
122+
},
112123
{
113124
"id": "selecting-toolchain",
114125
"title": "Select a toolchain",
@@ -363,6 +374,11 @@
363374
"title": "Select Toolchain...",
364375
"category": "Swift"
365376
},
377+
{
378+
"command": "swift.installSwiftly",
379+
"title": "Install Swiftly",
380+
"category": "Swift"
381+
},
366382
{
367383
"command": "swift.installSwiftlyToolchain",
368384
"title": "Install Swiftly Toolchain...",

src/commands.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { useLocalDependency } from "./commands/dependencies/useLocal";
3030
import { generateLaunchConfigurations } from "./commands/generateLaunchConfigurations";
3131
import { generateSourcekitConfiguration } from "./commands/generateSourcekitConfiguration";
3232
import { insertFunctionComment } from "./commands/insertFunctionComment";
33+
import { runInstallSwiftly } from "./commands/installSwiftly";
3334
import { promptToInstallSwiftlyToolchain } from "./commands/installSwiftlyToolchain";
3435
import { newSwiftFile } from "./commands/newFile";
3536
import { openDocumentation } from "./commands/openDocumentation";
@@ -117,6 +118,7 @@ export enum Commands {
117118
OPEN_MANIFEST = "swift.openManifest",
118119
RESTART_LSP = "swift.restartLSPServer",
119120
SELECT_TOOLCHAIN = "swift.selectToolchain",
121+
INSTALL_SWIFTLY = "swift.installSwiftly",
120122
INSTALL_SWIFTLY_TOOLCHAIN = "swift.installSwiftlyToolchain",
121123
INSTALL_SWIFTLY_SNAPSHOT_TOOLCHAIN = "swift.installSwiftlySnapshotToolchain",
122124
GENERATE_SOURCEKIT_CONFIG = "swift.generateSourcekitConfiguration",
@@ -367,6 +369,10 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
367369
"@ext:swiftlang.swift-vscode "
368370
)
369371
),
372+
vscode.commands.registerCommand(
373+
Commands.INSTALL_SWIFTLY,
374+
async () => await runInstallSwiftly(ctx?.logger)
375+
),
370376
vscode.commands.registerCommand(
371377
Commands.INSTALL_SWIFTLY_TOOLCHAIN,
372378
async () => await promptToInstallSwiftlyToolchain(ctx, "stable")

src/commands/installSwiftly.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,36 @@ async function promptToRestartVSCode(): Promise<void> {
113113
}
114114
}
115115

116+
export async function runInstallSwiftly(logger?: SwiftLogger): Promise<boolean> {
117+
const confirmation = await vscode.window.showInformationMessage(
118+
"Install Swiftly - The Swift Toolchain Version Manager",
119+
{
120+
modal: true,
121+
detail: `The Swift extension is going to install the swiftly toolchain manager on your behalf.
122+
123+
This process involves updating your shell profile in order to add swiftly to your PATH. Alternatively, you can also install swiftly yourself using the instructions at swift.org to customize the installation options.`,
124+
},
125+
"Continue",
126+
"Open Swiftly Documentation"
127+
);
128+
129+
if (confirmation === "Continue") {
130+
if (!(await installSwiftlyWithProgress(logger))) {
131+
return false;
132+
}
133+
await promptToRestartVSCode();
134+
return true;
135+
}
136+
137+
if (confirmation === "Open Swiftly Documentation") {
138+
void vscode.env.openExternal(
139+
vscode.Uri.parse("https://www.swift.org/swiftly/documentation/swiftly/getting-started")
140+
);
141+
}
142+
143+
return false;
144+
}
145+
116146
/**
117147
* Main function to handle missing Swiftly detection and installation
118148
* @param swiftVersionFiles A list of swift version files that will need to be installed

0 commit comments

Comments
 (0)