MCPcopy Create free account
hub / github.com/jetify-com/devbox / devboxReopen

Function devboxReopen

vscode-extension/src/devbox.ts:17–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15};
16
17export async function devboxReopen() {
18 if (process.platform === 'win32') {
19 const seeDocs = 'See Devbox docs';
20 const result = await window.showErrorMessage(
21 'This feature is not supported on your platform. \
22 Please open VSCode from inside devbox shell in WSL using the CLI.', seeDocs
23 );
24 if (result === seeDocs) {
25 env.openExternal(Uri.parse('https://www.jetify.com/devbox/docs/ide_configuration/vscode/#windows-setup'));
26 return;
27 }
28 }
29 await window.withProgress({
30 location: ProgressLocation.Notification,
31 title: "Setting up your Devbox environment. Please don't close vscode.",
32 cancellable: true
33 },
34 async (progress, token) => {
35 token.onCancellationRequested(() => {
36 console.log("User canceled the long running operation");
37 });
38
39 const p = new Promise<void>(async (resolve, reject) => {
40 if (workspace.workspaceFolders) {
41 const workingDir = workspace.workspaceFolders[0].uri;
42 const dotdevbox = Uri.joinPath(workingDir, '/.devbox');
43 await logToFile(dotdevbox, 'Installing devbox packages');
44 progress.report({ message: 'Installing devbox packages...', increment: 25 });
45 await setupDotDevbox(workingDir, dotdevbox);
46
47 // setup required vscode settings
48 await logToFile(dotdevbox, 'Updating editor configurations');
49 progress.report({ message: 'Updating configurations...', increment: 50 });
50 updateVSCodeConf();
51
52 // Calling CLI to compute devbox env
53 await logToFile(dotdevbox, 'Calling "devbox integrate" to setup environment');
54 progress.report({ message: 'Calling Devbox to setup environment...', increment: 80 });
55 // To use a custom compiled devbox when testing, change this to an absolute path.
56 const devbox = 'devbox';
57 // run devbox integrate and then close this window
58 const debugModeFlag = workspace.getConfiguration("devbox").get("enableDebugMode");
59 // name of the currently open editor
60 const ideName = appNameBinaryMap[env.appName.toLocaleLowerCase()] || 'code';
61 let child = spawn(devbox, ['integrate', 'vscode', '--debugmode='+debugModeFlag, '--ide='+ideName], {
62 cwd: workingDir.path,
63 stdio: [0, 1, 2, 'ipc']
64 });
65 // if CLI closes before sending "finished" message
66 child.on('close', (code: number) => {
67 console.log("child process closed with exit code:", code);
68 logToFile(dotdevbox, 'child process closed with exit code: ' + code);
69 window.showErrorMessage("Failed to setup devbox environment.");
70 reject();
71 });
72 // send config path to CLI
73 child.send({ configDir: workingDir.path });
74 // handle CLI finishing the env and sending "finished"

Callers 1

activateFunction · 0.90

Calls 4

logToFileFunction · 0.85
setupDotDevboxFunction · 0.85
updateVSCodeConfFunction · 0.85
resolveFunction · 0.85

Tested by

no test coverage detected