This module is intended to unify usage of code across multiple Oracle Labs Extensions to avoid duplicate code and problems like bug fixes applied on code only in some Extensions.
This module has to built first to be used see Building. After building this module all packages can be accessed by importing them directly from lib folder of the module.
import * as <package> from '<vscode-extensions>/common/lib/<package>';
or
import { <imported> } from '<vscode-extensions>/common/lib/<package>';
Where <vscode_extensions> means navigating to the top/parent folder.
To build this module use one of these commands:
.../vscode-extensions $> npm run build:common
.../vscode-extensions/common $> npm run build
This module is also build in prebuild step of base package so it is prepared before building rest of the Extensions.
Whenever you encounter a need to use code from another extension, find duplicate or unifiable code in Extensions make use of this module to reference the code from single source.
- The code that can be moved to this module has to be not coupled to Extensions functionality or the functionality has to be also movable to this module.
- Make sure to move the code to proper package or create suitable package for the code.
- Build the module with new code, this will allow you to access new code from the Extensions.
- Redirect all imports and usages to the modules package.
- Dependencies can be added to this module in package.json but some (Node) modules need to have fallback resolved in webpack.config.js of extension using the code:
resolve: {
fallback: {
"fs": false,
"os": false,
"path": false,
"child_process": false
}
}
- Be aware that
tsc
command will pick index.d.ts files from common package if included (this makes a raid condition on type resolution), to avoid this behavior you have to specify where it should pick the types from in tsconfig.json file of extension using the type:
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"<type>": ["node_modules/@types/<type>"]
}
}
- Please include description of shared functionality here in this README for easy lookup.
- logUtils.ts
code used for logging
Contains basic logging code, to use it properly the logging has to be registered during Extension activation by registerExtensionForLogging method. - dialogs.ts
code used for communication with user
Contains most of code to create dialogs mainly MultistepInput for QuickPick. - utils.ts
misc. code
Contains mostly miscelaneous code, mainly findExecutable and getJavaVersion.