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

Changed warning when using .mirrord config folder to info. closes #29 #87

Merged
merged 16 commits into from
Jan 3, 2024
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
1 change: 1 addition & 0 deletions changelog.d/29.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed notifications when loading config file to be less confusing.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,21 @@
"default": true,
"description": "Show a notification when mirrord uses active configuration."
},
"mirrord.promptUsingEnvVarConfig": {
"type": "boolean",
"default": true,
"description": "Show a notification when mirrord uses env var configuration."
},
"mirrord.promptUsingDefaultConfig": {
"type": "boolean",
"default": true,
"description": "Show a notification when mirrord uses default configuration."
},
"mirrord.promptUsingDefaultConfigSingleFileNoFolder": {
"type": "boolean",
"default": true,
"description": "Show a notification when mirrord uses default configuration when running vscode with a single file (no folder)."
},
"mirrord.promptTargetless": {
"type": "boolean",
"default": true,
Expand Down
53 changes: 30 additions & 23 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,43 +296,50 @@ export class MirrordConfigManager {
if (this.active) {
// User has selected a config (via active config button).
new NotificationBuilder()
.withMessage("using active mirrord configuration")
.withMessage("Using active mirrord configuration.")
.withOpenFileAction(this.active)
.withDisableAction("promptUsingActiveConfig")
.info();

return this.active;
} else if (config.env?.["MIRRORD_CONFIG_FILE"]) {
// Get the config path from the env var.
return vscode.Uri.parse(`file://${config.env?.["MIRRORD_CONFIG_FILE"]}`, true);
const configFromEnv = vscode.Uri.parse(`file://${config.env?.["MIRRORD_CONFIG_FILE"]}`, true);

new NotificationBuilder()
.withMessage(`Using mirrord configuration from env var "MIRRORD_CONFIG_FILE".`)
.withOpenFileAction(configFromEnv)
.withDisableAction("promptUsingEnvVarConfig")
.info();

return configFromEnv;

} else if (folder) {
let predefinedConfig = await MirrordConfigManager.getDefaultConfig(folder);
if (predefinedConfig) {
const configFromMirrordFolder = await MirrordConfigManager.getDefaultConfig(folder);

if (configFromMirrordFolder) {
new NotificationBuilder()
.withMessage("using a default mirrord config")
.withOpenFileAction(predefinedConfig)
.withMessage(`Using mirrord configuration from ".mirrord" folder.`)
.withOpenFileAction(configFromMirrordFolder)
.withDisableAction("promptUsingDefaultConfig")
.warning();
return predefinedConfig;
.info();

return configFromMirrordFolder;
} else {
// There is no configuration file in a .mirrord directory and no configuration file was specified
// via "active configuration" extension setting or environment variable. This is a valid case.
// mirrord will run without a configuration file.
return null;
meowjesty marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
folder = vscode.workspace.workspaceFolders?.[0];
t4lz marked this conversation as resolved.
Show resolved Hide resolved
if (!folder) {
throw new Error("mirrord requires an open folder in the workspace");
}
// User probably openend vscode in a single file, no folder is loaded and they have
// not set up the `MIRRORD_CONFIG_FILE` env var.
new NotificationBuilder()
.withMessage(`No folder open in editor - so not using a configuration file even if one exists.`)
.withDisableAction("promptUsingDefaultConfigSingleFileNoFolder")
.info();

let predefinedConfig = await MirrordConfigManager.getDefaultConfig(folder);
if (predefinedConfig) {
new NotificationBuilder()
.withMessage(`using a default mirrord config from folder ${folder.name} `)
.withOpenFileAction(predefinedConfig)
.withDisableAction("promptUsingDefaultConfig")
.warning();
return predefinedConfig;
} else {
return null;
}
return null;
}
}
}
4 changes: 2 additions & 2 deletions src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ async function main(
let cliPath = await getMirrordBinary(false);

if (!cliPath) {
mirrordFailure(`Couldn't download mirrord binaries or find local one in path`);
return null;
mirrordFailure(`Couldn't download mirrord binaries or find local one in path`);
return null;
}

let mirrordApi = new MirrordAPI(cliPath);
Expand Down