Skip to content

Commit a2b4095

Browse files
authored
docs: vscode workspace config files #3052
1 parent abc52fd commit a2b4095

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ You can find the coverage report at `./coverage/index.html` after running the te
163163
- Exercise the code (`Extension Tests`, `Integration Tests`, etc.)
164164
- Generate a report with `npm run report`
165165
166+
### CodeCatalyst Blueprints
167+
168+
You can find documentation to create VSCode IDE settings for CodeCatalyst blueprints at [docs/vscode-config.md](./docs/vscode-config.md).
169+
166170
## Pull Requests
167171
168172
Before sending a pull request:

docs/vscode-config.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# VSCode Settings Configuration
2+
3+
## Overview
4+
5+
There are four main files when dealing with VSCode settings: `settings.json`, `extensions.json`, `tasks.json`, and `launch.json`.
6+
7+
### File overview
8+
9+
[settings.json](https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings) is responsible for handling any settings you want to be in VSCode when they start the editor for the first time. This can range from default forwarded ports to pointing to where executables exist on the filesystem.
10+
11+
[extensions.json](https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions) is responsible for handling which extensions should be installed in the workspace (or ignored). When VSCode is first started, the user will get prompted to install any extensions that are recommended in this file.
12+
13+
[tasks.json](https://code.visualstudio.com/docs/editor/tasks) is responsible for handling background tasks that are specific to the project. These can be common tasks like `npm run compile` or `mvn test`.
14+
15+
[launch.json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) is responsible for handling the visual running and debugging of applications. This would be something like running `mvn test` and then attaching a debugger instance to it.
16+
17+
### Folder structure
18+
19+
VSCode requires the following project structure when adding in VSCode settings:
20+
21+
```
22+
project_root/
23+
.vscode/
24+
settings.json
25+
extensions.json
26+
tasks.json
27+
launch.json
28+
```
29+
30+
If your project has multiple roots:
31+
32+
```
33+
my_frontend_application/
34+
main.js
35+
my_backend_application/
36+
main.py
37+
```
38+
39+
then the .vscode folder is expected to be at the root:
40+
41+
```
42+
.vscode/
43+
settings.json
44+
extensions.json
45+
launch.json
46+
tasks.json
47+
my_frontend_application/
48+
main.js
49+
my_backend_application/
50+
main.py
51+
```
52+
53+
## Settings.json
54+
55+
The `settings.json` file is for handling any settings you want to be in VSCode when they start the editor for the first time. On VSCode start, this file will provide default settings that might be necessary when starting/running your project.
56+
57+
For example, the following settings.json is used to expose local ports of a Vue application and setup the default python interpreter path:
58+
59+
```json
60+
{
61+
"remote.portsAttributes": {
62+
"5173": {
63+
"label": "Vue Application"
64+
}
65+
},
66+
"remote.SSH.defaultForwardedPorts": [
67+
{
68+
"localPort": 5173,
69+
"name": "Vue Application Port",
70+
"remotePort": 5173
71+
}
72+
],
73+
"python.defaultInterpreterPath": "python"
74+
}
75+
```
76+
77+
This is going to be project specific, but any configuration for VSCode settings should live here.
78+
79+
You can learn more about VSCode settings and the settings editor [here](https://code.visualstudio.com/docs/getstarted/settings#_settings-editor).
80+
81+
## Extensions.json
82+
83+
The `extensions.json` file is used to specify the recommended extensions that should be installed in the given workspace. When a user opens a new workspace, if any of the recommended extensions are not currently installed, the user will be prompted to install them.
84+
85+
In all extensions.json, we want to at minimum recommend the aws-toolkit-vscode extension.
86+
87+
```json
88+
{
89+
"recommendations": ["amazonwebservices.aws-toolkit-vscode"]
90+
}
91+
```
92+
93+
Additional extensions should also be added depending on the front-end/back-end of the application.
94+
95+
## Tasks.json
96+
97+
The `tasks.json` is responsible for handling background tasks that run from the command line. These can be things common tasks like `npm run compile` or `mvn test`.
98+
99+
**Example:** [`npm run lint`](../.vscode/tasks.json#L40)
100+
101+
### Additional tips
102+
103+
- Occasionally tasks can be long running and VSCode will throw an error if the task doesn’t seem to be making any progress. VSCode has a built-in way to handle this through isBackground and problemMatcher. This allows VSCode to wait for a pattern to appear in the terminal and stops VSCode from throwing an error if a task is running for too long. You can see this in the [`serve` task](../.vscode/tasks.json#L19)
104+
105+
## Launch.json
106+
107+
The `launch.json` is responsible for handling the visual running and debugging of applications. This would be like running a `mvn test` command and then attaching a debugger instance to it or compiling a VSCode extension and launching it in debug mode.
108+
109+
In order for us to debug and launch the application, we first need to create a pre-launch task which is responsible for building the application. Pre-launch tasks are just regular tasks defined in `.vscode/tasks.json.` See [this](https://code.visualstudio.com/docs/editor/tasks) and [this](#additional-tips) for more details on tasks.
110+
111+
**Example:** pre launch task [`npm: compile`](../.vscode/tasks.json#L50) that builds the project
112+
113+
Once you have a pre-launch task, you can delegate the responsibility of building the application to the task, and then the launch configuration will take care of attaching the debugger to the already running application instance.
114+
115+
**Example:** [Extension launch configuration](../.vscode/launch.json#L9) that waits for the your application to finish compiling and then attaches the debugger to the extension host.

0 commit comments

Comments
 (0)