MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / askInstallDependenciesPrompt

Function askInstallDependenciesPrompt

src/utils/vscode.ts:218–254  ·  view source on GitHub ↗
(
  rootDir: vscode.Uri,
  depsToInstall: string[],
  devDepsToInstall?: string[]
)

Source from the content-addressed store, hash-verified

216}
217
218export const askInstallDependenciesPrompt = async (
219 rootDir: vscode.Uri,
220 depsToInstall: string[],
221 devDepsToInstall?: string[]
222) => {
223 const deps = await getDependenciesArray(rootDir);
224 const devDeps = await getDevDependenciesArray(rootDir);
225 // No package.json found
226 if (!deps) {
227 return;
228 }
229 const filteredDepsToInstall = depsToInstall.filter((dep) => !deps.includes(dep));
230 const filteredDevDepsToInstall = devDepsToInstall?.filter((dep) => !devDeps?.includes(dep)) ?? [];
231 // No dependencies to install
232 if (filteredDepsToInstall.length === 0 && filteredDevDepsToInstall.length === 0) {
233 return;
234 }
235 const message =
236 "Remix Forge has generated code that uses dependencies you do not have in the project. Would you like to install these dependencies?";
237 const options = ["Yes", "No"];
238
239 vscode.window.showInformationMessage(message, ...options).then(async (selectedOption) => {
240 if (selectedOption === "Yes") {
241 if (filteredDepsToInstall.length > 0) {
242 // Install dependencies logic
243 await installDependencies(rootDir, filteredDepsToInstall);
244 }
245 if (filteredDevDepsToInstall.length > 0) {
246 await installDevDependencies(rootDir, filteredDevDepsToInstall);
247 }
248 // Execute the logic to install dependencies here
249 } else if (selectedOption === "No") {
250 // User chose not to install dependencies
251 // vscode.window.showInformationMessage("Skipping dependency installation.");
252 }
253 });
254};
255
256export const showError = (error: string) => vscode.window.showErrorMessage(`${error}`);
257

Callers 5

lintingFunction · 0.90
generatePrismaFunction · 0.90
generateRemixFormRouteFunction · 0.90
generateAuthFunction · 0.90
generateTestsFunction · 0.90

Calls 4

getDependenciesArrayFunction · 0.85
getDevDependenciesArrayFunction · 0.85
installDependenciesFunction · 0.85
installDevDependenciesFunction · 0.85

Tested by

no test coverage detected