Skip to content

feat(configuration): add feature to overwrite homedir for storing models and server #25

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

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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
"type": "boolean",
"default": true,
"markdownDescription": "Enable experimental possibility to use opened tabs as context for manual completion mode."
},
"firecoder.homedir": {
"type": "string",
"default": "",
"description": "The directory to use for storing user data associated with this extension. Set to an empty string, `os.homedir()` will be used."
}
}
}
Expand Down Expand Up @@ -178,4 +183,4 @@
"@grafana/faro-core": "^1.3.5",
"@grafana/faro-web-sdk": "^1.3.5"
}
}
}
7 changes: 7 additions & 0 deletions src/common/download/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fsPromise from "node:fs/promises";
import fs from "node:fs";
import child_process from "node:child_process";
import { promisify } from "node:util";
import { configuration } from "../utils/configuration";
const exec = promisify(child_process.exec);

export const checkFileOrFolderExists = async (pathToCheck: string) => {
Expand All @@ -17,6 +18,12 @@ export const checkFileOrFolderExists = async (pathToCheck: string) => {
};

export const getSaveFolder = async () => {
const homedirFromConfiguration = configuration.get("homedir");

if (homedirFromConfiguration !== "") {
return homedirFromConfiguration;
}

const pathSaveFolder = path.join(os.homedir(), ".firecoder");

const folderIsExist = await checkFileOrFolderExists(pathSaveFolder);
Expand Down
6 changes: 6 additions & 0 deletions src/common/utils/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const ConfigurationProperties = {
"completion.manuallyMode": {
default: "base-small",
},
homedir: {
default: "",
},
} as const;

interface ConfigurationPropertiesType
Expand All @@ -48,6 +51,9 @@ interface ConfigurationPropertiesType
"completion.manuallyMode": {
possibleValues: TypeModelsBase;
};
homedir: {
possibleValues: string;
};
}

class Configuration {
Expand Down