Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

Commit a195d81

Browse files
authored
Merge pull request #423 from tgodzik/add-mirror
Add mirror env variable when set by the user
2 parents 04112b5 + ce3e31d commit a195d81

5 files changed

+44
-8
lines changed

src/checkServerVersion.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { WorkspaceConfiguration } from "./interfaces/WorkspaceConfiguration";
2-
import { ConfigurationTarget } from "./interfaces/ConfigurationTarget";
31
import * as semver from "semver";
2+
import { ConfigurationTarget } from "./interfaces/ConfigurationTarget";
3+
import { UserConfiguration } from "./interfaces/UserConfiguration";
4+
import { WorkspaceConfiguration } from "./interfaces/WorkspaceConfiguration";
45

56
interface OnOutdatedParams {
67
message: string;
@@ -16,7 +17,7 @@ interface UpdateConfigParams {
1617
configurationTarget: ConfigurationTarget;
1718
}
1819

19-
const configSection = "serverVersion";
20+
const configSection = UserConfiguration.ServerVersion;
2021

2122
interface CheckServerVersionParams {
2223
config: WorkspaceConfiguration;

src/detectLaunchConfigurationChanges.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { UserConfiguration } from "./interfaces/UserConfiguration";
12
import { Workspace } from "./interfaces/Workspace";
23

34
interface PromptRestartParams {
@@ -13,10 +14,11 @@ export function detectLaunchConfigurationChanges(
1314
): void {
1415
workspace.onDidChangeConfiguration((e) => {
1516
const promptRestartKeys = [
16-
"serverVersion",
17-
"serverProperties",
18-
"javaHome",
19-
"customRepositories",
17+
UserConfiguration.ServerVersion,
18+
UserConfiguration.ServerProperties,
19+
UserConfiguration.JavaHome,
20+
UserConfiguration.CustomRepositories,
21+
UserConfiguration.CoursierMirror,
2022
...additionalRestartKeys,
2123
];
2224
const shouldPromptRestart = promptRestartKeys.some((key) =>

src/getJavaConfig.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface JavaConfig {
55
javaOptions: string[];
66
javaPath: string;
77
coursierPath: string;
8+
coursierMirrorFilePath: string | undefined;
89
extraEnv: {
910
[k: string]: string | undefined;
1011
};
@@ -14,27 +15,31 @@ interface GetJavaConfigOptions {
1415
workspaceRoot: string | undefined;
1516
javaHome: string;
1617
extensionPath: string;
18+
coursierMirrorFilePath: string | undefined;
1719
customRepositories: string[] | undefined;
1820
}
1921

2022
export function getJavaConfig({
2123
workspaceRoot,
2224
javaHome,
2325
extensionPath,
26+
coursierMirrorFilePath,
2427
customRepositories = [],
2528
}: GetJavaConfigOptions): JavaConfig {
2629
const javaOptions = getJavaOptions(workspaceRoot);
2730
const javaPath = path.join(javaHome, "bin", "java");
2831
const coursierPath = path.join(extensionPath, "./coursier");
2932
const extraEnv = {
3033
COURSIER_REPOSITORIES: customRepositories.join("|"),
34+
COURSIER_MIRRORS: coursierMirrorFilePath,
3135
JAVA_HOME: javaHome,
3236
};
3337

3438
return {
3539
javaOptions,
3640
javaPath,
3741
coursierPath,
42+
coursierMirrorFilePath,
3843
extraEnv,
3944
};
4045
}

src/interfaces/ClientCommands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* These are all of the client commands that Metals supports. Note that not support
33
* may vary based on the `InitializationSettings` the client sets.
44
*
5-
* - https://scalameta.org/metals/docs/editors/new-editor.html#metals-client-commands
5+
* - https://scalameta.org/metals/docs/integrations/new-editor#metals-client-commands
66
*/
77
export const ClientCommands = {
88
/**

src/interfaces/UserConfiguration.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* These are some of the common user configuration options used in Metals and needed for the editors.
3+
*
4+
* - https://scalameta.org/metals/docs/integrations/new-editor#metals-user-configuration
5+
*/
6+
export enum UserConfiguration {
7+
/**
8+
* Metals server version
9+
*/
10+
ServerVersion = "serverVersion",
11+
/**
12+
* Metals server Java properties
13+
*/
14+
ServerProperties = "serverProperties",
15+
/**
16+
* Directory containing the Java binary.
17+
*/
18+
JavaHome = "javaHome",
19+
/**
20+
* Additional repositories that can be used to download dependencies.
21+
* https://get-coursier.io/docs/other-repositories
22+
*/
23+
CustomRepositories = "customRepositories",
24+
/**
25+
* Repository to use instead of maven central for example `https://jcenter.bintray.com`
26+
*/
27+
CoursierMirror = "coursierMirror",
28+
}

0 commit comments

Comments
 (0)