Skip to content

Commit 3f955d5

Browse files
authored
[vscode-extension] Fixed tab size for extension (#1701)
## Summary This is just a styling PR to fix indent size across all files in extension. ## How was it tested? N/A
1 parent a5acdca commit 3f955d5

File tree

4 files changed

+240
-247
lines changed

4 files changed

+240
-247
lines changed

vscode-extension/.eslintrc.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"ecmaVersion": 6,
6-
"sourceType": "module"
7-
},
8-
"plugins": [
9-
"@typescript-eslint"
10-
],
11-
"rules": {
12-
"@typescript-eslint/naming-convention": "warn",
13-
"@typescript-eslint/semi": "warn",
14-
"curly": "warn",
15-
"eqeqeq": "warn",
16-
"no-throw-literal": "warn",
17-
"semi": "off"
18-
},
19-
"ignorePatterns": [
20-
"out",
21-
"dist",
22-
"**/*.d.ts"
23-
]
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 6,
6+
"sourceType": "module"
7+
},
8+
"plugins": [
9+
"@typescript-eslint"
10+
],
11+
"rules": {
12+
"@typescript-eslint/naming-convention": "warn",
13+
"@typescript-eslint/semi": "warn",
14+
"curly": "warn",
15+
"eqeqeq": "warn",
16+
"no-throw-literal": "warn",
17+
"semi": "off"
18+
},
19+
"ignorePatterns": [
20+
"out",
21+
"dist",
22+
"**/*.d.ts"
23+
]
2424
}

vscode-extension/src/devbox.ts

Lines changed: 108 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -7,127 +7,124 @@ interface Message {
77
}
88

99
export async function devboxReopen() {
10-
11-
if (process.platform === 'win32') {
12-
const seeDocs = 'See Devbox docs';
13-
const result = await window.showErrorMessage(
14-
'This feature is not supported on your platform. \
15-
Please open VSCode from inside devbox shell in WSL using the CLI.', seeDocs
16-
);
17-
if (result === seeDocs) {
18-
env.openExternal(Uri.parse('https://www.jetpack.io/devbox/docs/ide_configuration/vscode/#windows-setup'));
19-
return;
20-
}
10+
if (process.platform === 'win32') {
11+
const seeDocs = 'See Devbox docs';
12+
const result = await window.showErrorMessage(
13+
'This feature is not supported on your platform. \
14+
Please open VSCode from inside devbox shell in WSL using the CLI.', seeDocs
15+
);
16+
if (result === seeDocs) {
17+
env.openExternal(Uri.parse('https://www.jetpack.io/devbox/docs/ide_configuration/vscode/#windows-setup'));
18+
return;
2119
}
22-
await window.withProgress({
23-
location: ProgressLocation.Notification,
24-
title: "Setting up your Devbox environment. Please don't close vscode.",
25-
cancellable: true
26-
},
27-
async (progress, token) => {
28-
token.onCancellationRequested(() => {
29-
console.log("User canceled the long running operation");
30-
});
31-
32-
const p = new Promise<void>(async (resolve, reject) => {
20+
}
21+
await window.withProgress({
22+
location: ProgressLocation.Notification,
23+
title: "Setting up your Devbox environment. Please don't close vscode.",
24+
cancellable: true
25+
},
26+
async (progress, token) => {
27+
token.onCancellationRequested(() => {
28+
console.log("User canceled the long running operation");
29+
});
3330

34-
if (workspace.workspaceFolders) {
35-
const workingDir = workspace.workspaceFolders[0].uri;
36-
const dotdevbox = Uri.joinPath(workingDir, '/.devbox');
37-
progress.report({ message: 'Installing devbox packages...', increment: 25 });
38-
await setupDotDevbox(workingDir, dotdevbox);
31+
const p = new Promise<void>(async (resolve, reject) => {
32+
if (workspace.workspaceFolders) {
33+
const workingDir = workspace.workspaceFolders[0].uri;
34+
const dotdevbox = Uri.joinPath(workingDir, '/.devbox');
35+
progress.report({ message: 'Installing devbox packages...', increment: 25 });
36+
await setupDotDevbox(workingDir, dotdevbox);
3937

40-
// setup required vscode settings
41-
progress.report({ message: 'Updating configurations...', increment: 50 });
42-
updateVSCodeConf();
38+
// setup required vscode settings
39+
progress.report({ message: 'Updating configurations...', increment: 50 });
40+
updateVSCodeConf();
4341

44-
// Calling CLI to compute devbox env
45-
progress.report({ message: 'Calling Devbox to setup environment...', increment: 80 });
46-
// To use a custom compiled devbox when testing, change this to an absolute path.
47-
const devbox = 'devbox';
48-
// run devbox integrate and then close this window
49-
let child = spawn(devbox, ['integrate', 'vscode'], {
50-
cwd: workingDir.path,
51-
stdio: [0, 1, 2, 'ipc']
52-
});
53-
// if CLI closes before sending "finished" message
54-
child.on('close', (code: number) => {
55-
console.log("child process closed with exit code:", code);
56-
window.showErrorMessage("Failed to setup devbox environment.");
57-
reject();
58-
});
59-
// send config path to CLI
60-
child.send({ configDir: workingDir.path });
61-
// handle CLI finishing the env and sending "finished"
62-
child.on('message', function (msg: Message, handle) {
63-
if (msg.status === "finished") {
64-
progress.report({ message: 'Finished setting up! Reloading the window...', increment: 100 });
65-
resolve();
66-
commands.executeCommand("workbench.action.closeWindow");
67-
}
68-
else {
69-
console.log(msg);
70-
window.showErrorMessage("Failed to setup devbox environment.");
71-
reject();
72-
}
73-
});
74-
}
75-
});
76-
return p;
42+
// Calling CLI to compute devbox env
43+
progress.report({ message: 'Calling Devbox to setup environment...', increment: 80 });
44+
// To use a custom compiled devbox when testing, change this to an absolute path.
45+
const devbox = 'devbox';
46+
// run devbox integrate and then close this window
47+
let child = spawn(devbox, ['integrate', 'vscode'], {
48+
cwd: workingDir.path,
49+
stdio: [0, 1, 2, 'ipc']
50+
});
51+
// if CLI closes before sending "finished" message
52+
child.on('close', (code: number) => {
53+
console.log("child process closed with exit code:", code);
54+
window.showErrorMessage("Failed to setup devbox environment.");
55+
reject();
56+
});
57+
// send config path to CLI
58+
child.send({ configDir: workingDir.path });
59+
// handle CLI finishing the env and sending "finished"
60+
child.on('message', function (msg: Message, handle) {
61+
if (msg.status === "finished") {
62+
progress.report({ message: 'Finished setting up! Reloading the window...', increment: 100 });
63+
resolve();
64+
commands.executeCommand("workbench.action.closeWindow");
65+
}
66+
else {
67+
console.log(msg);
68+
window.showErrorMessage("Failed to setup devbox environment.");
69+
reject();
70+
}
71+
});
7772
}
78-
);
79-
80-
73+
});
74+
return p;
75+
}
76+
);
8177
}
8278

8379
async function setupDotDevbox(workingDir: Uri, dotdevbox: Uri) {
84-
try {
85-
// check if .devbox exists
86-
await workspace.fs.stat(dotdevbox);
87-
} catch (error) {
88-
//.devbox doesn't exist
89-
// running devbox shellenv to create it
90-
spawnSync('devbox', ['shellenv'], {
91-
cwd: workingDir.path
92-
});
93-
}
80+
try {
81+
// check if .devbox exists
82+
await workspace.fs.stat(dotdevbox);
83+
} catch (error) {
84+
//.devbox doesn't exist
85+
// running devbox shellenv to create it
86+
spawnSync('devbox', ['shellenv'], {
87+
cwd: workingDir.path
88+
});
89+
}
9490
}
9591

9692
function updateVSCodeConf() {
97-
if (process.platform === 'darwin') {
98-
const shell = process.env["SHELL"] ?? "/bin/zsh";
99-
const shellArgsMap = (shellType: string) => {
100-
switch (shellType) {
101-
case "fish":
102-
// We special case fish here because fish's `fish_add_path` function
103-
// tends to prepend to PATH by default, hence sourcing the fish config after
104-
// vscode reopens in devbox environment, overwrites devbox packages and
105-
// might cause confusion for users as to why their system installed packages
106-
// show up when they type for example `which go` as opposed to the packages
107-
// installed by devbox.
108-
return ["--no-config"];
109-
default:
110-
return [];
111-
}
112-
};
113-
const shellTypeSlices = shell.split("/");
114-
const shellType = shellTypeSlices[shellTypeSlices.length - 1];
115-
shellArgsMap(shellType);
116-
const devboxCompatibleShell = {
117-
"devboxCompatibleShell": {
118-
"path": shell,
119-
"args": shellArgsMap(shellType)
120-
}
121-
};
93+
if (process.platform === 'darwin') {
94+
const shell = process.env["SHELL"] ?? "/bin/zsh";
95+
const shellArgsMap = (shellType: string) => {
96+
switch (shellType) {
97+
case "fish":
98+
// We special case fish here because fish's `fish_add_path` function
99+
// tends to prepend to PATH by default, hence sourcing the fish config after
100+
// vscode reopens in devbox environment, overwrites devbox packages and
101+
// might cause confusion for users as to why their system installed packages
102+
// show up when they type for example `which go` as opposed to the packages
103+
// installed by devbox.
104+
return ["--no-config"];
105+
default:
106+
return [];
107+
}
108+
};
109+
const shellTypeSlices = shell.split("/");
110+
const shellType = shellTypeSlices[shellTypeSlices.length - 1];
111+
shellArgsMap(shellType);
112+
const devboxCompatibleShell = {
113+
"devboxCompatibleShell": {
114+
"path": shell,
115+
"args": shellArgsMap(shellType)
116+
}
117+
};
122118

123-
workspace.getConfiguration().update(
124-
'terminal.integrated.profiles.osx',
125-
devboxCompatibleShell,
126-
ConfigurationTarget.Workspace
127-
);
128-
workspace.getConfiguration().update(
129-
'terminal.integrated.defaultProfile.osx',
130-
'devboxCompatibleShell',
131-
ConfigurationTarget.Workspace);
132-
}
119+
workspace.getConfiguration().update(
120+
'terminal.integrated.profiles.osx',
121+
devboxCompatibleShell,
122+
ConfigurationTarget.Workspace
123+
);
124+
workspace.getConfiguration().update(
125+
'terminal.integrated.defaultProfile.osx',
126+
'devboxCompatibleShell',
127+
ConfigurationTarget.Workspace
128+
);
129+
}
133130
}

vscode-extension/src/extension.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ async function initialCheckDevboxJSON(context: ExtensionContext) {
126126
// devbox.json exists setcontext for devbox commands to be available
127127
commands.executeCommand('setContext', 'devbox.configFileExists', true);
128128
context.workspaceState.update("configFileExists", true);
129-
130129
} catch (err) {
131130
console.log(err);
132131
// devbox.json does not exist
@@ -153,7 +152,6 @@ async function runInTerminal(cmd: string, showTerminal: boolean) {
153152
'text': `${cmd}\r\n`
154153
});
155154
}
156-
157155
}
158156

159157
async function getDevboxScripts(): Promise<string[]> {
@@ -192,7 +190,6 @@ async function readDevboxJson(workspaceUri: Uri) {
192190
const readStr = Buffer.from(readData).toString('utf8');
193191
const devboxJsonData = JSON.parse(readStr);
194192
return devboxJsonData;
195-
196193
}
197194

198195
// This method is called when your extension is deactivated

0 commit comments

Comments
 (0)