Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
Use vcpkg to install the tools as discussed in the README. The test-workspace contains a vcpkg-configuration.json file to do this.
-
To download the tools, you must have a
GITHUB_TOKENenvironment variable containing a personal access token. -
In order to install dependencies, Edit your global .npmrc file, and add the following to it:
@open-cmsis-pack:registry=https://npm.pkg.github.com //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}This assumes a
GITHUB_TOKENenvironment variable is exported in your environment. This needs to be a GitHub personal access token with theread:packagesscope set on it. -
Install NPM dependencies
npm install
-
Build the extension.
npm run build
-
In Visual Studio Code, press the F5 key to run the Desktop Extension run configuration, starting the extension in debug mode. A new VS Code window will open with the extension loaded so it can be used.
Unit test files are kept inline with the source files, and are named *.test.ts. Run with:
npm testThe vscode module is mocked in the mocks folder for testing files
that interact with the VS Code extension API.
Do not reset the global mocks or the mock implementations will be deleted.
Use the vscode-uri module to access the URI class.
Factories for test data that is used in multiple tests are stored in <name>.factories.ts files,
where <name> is the source file where their return type is defined.
A limited number of end-to-end (E2E) tests are maintained for key extension features, using the Playwright framework. E2E test files are stored under src/e2e-tests.
Running from the terminal:
npm run build
npm run e2eE2E tests can be debugged in VS Code using the Debug Playwright E2E Tests and Debug Playwright E2E Tests (Current File) launch configurations.
After the tests complete, Playwright will generate reports in two formats:
- HTML
- JUnit XML
Both formats can be found under the e2e-reports/ directory at the project root. For example:
📦e2e-report
┣ 📜index.html
┗ 📜results.xmlLog messages useful for end users should be exposed through an output channel. Log messages only useful for extension developers can be logged with console.log, and appear in the debug console when running in development mode.
Before running a release, check the following:
-
Tools and schemas integrated into the extension packages according to
package.json-
schema version referenced in
csolutionsection"schemaVersion": "<version>"<version>must match a project manager schemas tag
-
-
User guide is up-to-date at MDK-Packs/vscode-cmsis-solution-docs@main.
-
Update and review CHANGELOG.md
Add all changes relevant for the upcoming release into the
[Unreleased]section. This section is automatically replaced by the release version during the release workflow.
This repository follows the VS Code Marketplace pre-release recommendation:
- Odd minor versions (
x.1.z,x.3.z, ...) are pre-releases. - Even minor versions (
x.0.z,x.2.z, ...) are full releases.
To enforce this consistently, both packaging and publishing use scripts/package.ts, which:
- checks the current
package.jsonversion minor value. - automatically adds
--pre-releasetovsce packagefor odd minor versions.
Use the following commands:
> npm run package [--target <target>]- Ensure the version in
package.jsonis up to date. - Update the
CHANGELOGwith the latest changes. - Open a pull request with these updates and merge it into
main. - Create a new release at: https://github.com/Open-CMSIS-Pack/vscode-cmsis-solution/releases
- This will trigger the
CI.ymlworkflow. - Once the workflow completes successfully, the release artifacts will be generated automatically.
- This will trigger the
The extension communicates with the csolution binary using JSON-RPC 2.0. The protocol is defined in the csolution-rpc repository.
The generated TypeScript client interface (src/json-rpc/interface/rpc-interface.ts) and API version file (src/json-rpc/interface/version.txt) are fetched/generated by the tooling during setup (for example via npm install / the download:rpc-interface workflow) and are not committed to this repository. Do not edit those generated files manually.
When a new RPC method or data type is needed:
-
Update the OpenAPI schema in the csolution-rpc repository (
api/csolution-openapi.yml). Use the Swagger Editor to verify the schema. Follow the naming and schema conventions defined in that repository. -
Regenerate the interfaces using json-rpc-codegen:
node dist/cli.js --client rpc-interface.ts --server RpcInterface.h <schema>
This produces two generated files:
rpc-interface.ts— TypeScript client interface (consumed by this extension)RpcInterface.h— C++ server header (consumed bycsolution)
-
Implement the server side in
ProjMgrRpcServer.cppin thedevtoolsrepository. -
Implement the client side in this extension:
- Copy the regenerated
rpc-interface.tsintosrc/json-rpc/interface/and updatesrc/json-rpc/interface/version.txtto the new API version. - Expose the new method via
CsolutionServicein src/json-rpc/csolution-rpc-client.ts. - Use the method from the relevant data source or manager in src/data-manager/.
- Copy the regenerated
All outgoing JSON-RPC requests are printed via console.log in the transceive() function in src/json-rpc/csolution-rpc-client.ts. They appear in the Debug Console when running the extension with F5.
For more verbose output from the csolution process, set the CSOLUTION_ARGS environment variable to a comma-separated list of arguments before launching the extension:
export CSOLUTION_ARGS="--debug,-v"With these flags, csolution produces detailed diagnostic output and writes a csolution-rpc-log.txt file in the target workspace folder, logging all JSON-RPC requests and responses exchanged during the session.
To test a specific RPC method manually, launch the csolution binary in RPC mode and send JSON-RPC requests over stdin:
csolution rpcExample request:
{"jsonrpc":"2.0","id":1,"method":"loadPacks","params":{}}To debug the csolution server (C++ code) running on the backend:
-
Check out and build
devtoolswith debug symbols:git clone https://github.com/Open-CMSIS-Pack/devtools.git cd devtools cmake --preset default cmake --build --preset default --config RelWithDebugInfoThe debug executable will be in the build output directory.
-
Make the debug executable available to the extension:
Either copy the debug
csolutionexecutable to thecmsis-toolbox/bindirectory:cp <devtools-build>/csolution <cmsis-toolbox/bin>/csolution
Or create a symbolic link:
ln -s <devtools-build>/csolution <cmsis-toolbox/bin>/csolution
Alternatively, set the
CMSIS_SOLUTION_TOOLBOXenvironment variable to point to a directory containing the toolbox structure (withbinandetcsubdirectories):export CMSIS_SOLUTION_TOOLBOX=<toolbox-root>
The debug
csolutionexecutable must be located at<toolbox-root>/bin/csolution. -
Launch the extension in debug mode:
Press F5 in VS Code to start the extension with its debugger attached.
-
Load a csolution project in the extension to trigger
csolutionstartup. -
Attach the native debugger (Visual Studio Debugger or gdb/lldb) to the running
csolutionprocess by PID. The process will be active while the extension is communicating with it.
For security considerations see SECURITY.md
The .devcontainer folder provides a set of pre-configured environments that can be used for testing and development.
Find more details about the Visual Studio Code Dev Containers.
One can reopen the current workspace in a container by hitting the Remote Windows button >< in the lower left
In order to use Dev Containers one needs to have Docker running. Easiest way to get Docker is installing Docker Desktop. For commercial use one needs to request a subscription.
For each container there is a subfolder in .devcontainers which at least contains two files:
devcontainer.json- Code meta data about the containerDockerfile- Recipe to create the Docker image
To create another container just duplicate an existing folder with a new name.
The devcontainer.json file basically does two things:
- List environment variables dynamically set in a container. E.g., it forwards
the local
GITHUB_TOKENvariable into the container environment. - Specify Code customizations such as preferences to be set and extensions to be installed by default.
The Dockerfile specifies the recipe on how to create the Linux image, including:
- Linux distribution to use (via
FROMinstruction) - System packages to be installed (e.g.,
apt-get install) - Additional tweaks, e.g.,
- Setting default shell to
zsh - Install Oh-My-Zsh and Powerlevel10k theme
- Install Node Version Manager (nvm) and Node.JS
- Install and initialize vcpkg
- Setting default shell to
