|
| 1 | +# Visual Studio Setup |
| 2 | + |
| 3 | +Make use of the following code workspace config to get the ideal setup for working on the driver. |
| 4 | +Save the contents below to a file called `node-driver.code-workspace`, somewhere outside the driver folder and modify PATH_TO_DRIVER to point to your local clone. |
| 5 | + |
| 6 | +Launch VSCode and navigate to `File > Open Workspace From File...`. |
| 7 | +VScode will automatically recommend a bunch of extensions defined at the bottom of this .code-workspace file. |
| 8 | + |
| 9 | +Here's a quick description of each: |
| 10 | + |
| 11 | +- `streetsidesoftware.code-spell-checker` - Spell check! who doesn't need that 😁. |
| 12 | +- `dbaeumer.vscode-eslint` - Runs ESLint automatically after file save, saves you the need to run the linter manually most of the time. |
| 13 | +- `hbenl.vscode-test-explorer` - Lets you navigate our tests and run them through button presses. |
| 14 | +- `hbenl.vscode-mocha-test-adapter` - The mocha specific module to the common extension mentioned above. |
| 15 | +- `github.vscode-pull-request-github` - With this you can manage and make pull requests right from VSCode, even reviews can be done via the editor. |
| 16 | +- `eamodio.gitlens` - Gives spectacular insight into git history, has many helpful git navigation UI features. |
| 17 | +- `mongodb.mongodb-vscode` - Our VScode extension can be connected to your locally running MongoDB instance (to help debug tests, etc.) |
| 18 | + |
| 19 | +```jsonc |
| 20 | +{ |
| 21 | + "folders": [ |
| 22 | + { |
| 23 | + "name": "node-driver", |
| 24 | + "path": "PATH_TO_DRIVER" |
| 25 | + } |
| 26 | + ], |
| 27 | + "settings": { |
| 28 | + // Automatic Formatting settings |
| 29 | + "editor.codeActionsOnSave": { |
| 30 | + "source.fixAll.eslint": true |
| 31 | + }, |
| 32 | + "[json]": { |
| 33 | + "editor.formatOnSave": true |
| 34 | + }, |
| 35 | + "[jsonc]": { |
| 36 | + "editor.formatOnSave": true |
| 37 | + }, |
| 38 | + "[javascript]": { |
| 39 | + "editor.defaultFormatter": "dbaeumer.vscode-eslint" |
| 40 | + }, |
| 41 | + "[typescript]": { |
| 42 | + "editor.defaultFormatter": "dbaeumer.vscode-eslint", |
| 43 | + "editor.codeActionsOnSave": { |
| 44 | + "source.organizeImports": false |
| 45 | + } |
| 46 | + }, |
| 47 | + "files.autoSave": "onFocusChange", |
| 48 | + "files.trimTrailingWhitespace": true, |
| 49 | + "files.trimFinalNewlines": true, |
| 50 | + "files.insertFinalNewline": true, |
| 51 | + // Testing settings |
| 52 | + "mochaExplorer.files": "test/unit/**/*.test.js", |
| 53 | + "mochaExplorer.ui": "test/tools/runner/metadata_ui.js", |
| 54 | + "mochaExplorer.envPath": null, // Useful for more advanced tests |
| 55 | + // Typescript settings |
| 56 | + "typescript.disableAutomaticTypeAcquisition": true, |
| 57 | + "typescript.tsdk": "./node_modules/typescript/lib", |
| 58 | + // Editor nice to haves |
| 59 | + "editor.rulers": [ |
| 60 | + 100 |
| 61 | + ], |
| 62 | + "editor.renderWhitespace": "selection" |
| 63 | + }, |
| 64 | + "extensions": { |
| 65 | + "recommendations": [ |
| 66 | + "streetsidesoftware.code-spell-checker", |
| 67 | + "dbaeumer.vscode-eslint", |
| 68 | + "hbenl.vscode-test-explorer", |
| 69 | + "hbenl.vscode-mocha-test-adapter", |
| 70 | + "github.vscode-pull-request-github", |
| 71 | + "mongodb.mongodb-vscode", |
| 72 | + "eamodio.gitlens" |
| 73 | + ], |
| 74 | + "unwantedRecommendations": [ |
| 75 | + "esbenp.prettier-vscode" |
| 76 | + ] |
| 77 | + } |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Native Extensions |
| 82 | + |
| 83 | +The two non-default things in the configuration are marked with `CHANGE THIS` comments. |
| 84 | + |
| 85 | +- You need to add `node_modules/node-addon-api` to the include path to find `napi.h`. |
| 86 | + - For libmongocrypt the path might be: `bindings/node/node_modules/node-addon-api` depending on your workspace root |
| 87 | +- Bump up the cpp standard to whatever the relevant standard is |
| 88 | + |
| 89 | +In VSCode install `ms-vscode.cpptools` and in a `.vscode/c_cpp_properties.json` file add: |
| 90 | + |
| 91 | +```jsonc |
| 92 | +{ |
| 93 | + "configurations": [ |
| 94 | + { |
| 95 | + "name": "Mac", |
| 96 | + "includePath": [ |
| 97 | + "${default}", |
| 98 | + "node_modules/node-addon-api" // CHANGE THIS |
| 99 | + ], |
| 100 | + "defines": [], |
| 101 | + "macFrameworkPath": [ |
| 102 | + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" |
| 103 | + ], |
| 104 | + "compilerPath": "/usr/bin/clang", |
| 105 | + "cStandard": "c17", |
| 106 | + "cppStandard": "c++14", // CHANGE THIS |
| 107 | + "intelliSenseMode": "macos-clang-x64" |
| 108 | + } |
| 109 | + ], |
| 110 | + "version": 4 |
| 111 | +} |
| 112 | +``` |
0 commit comments