Visual Studio Code extension development requires node
and npm
. This extension is authored in TypeScript, which is included in the devDependencies
section of package.json
.
Install project dependencies:
npm install
Cedar libraries in Rust, compiled to WASM, for use in this Visual Studio Code extension. Uses open source cedar-policy/cedar.
Read these for background:
Install Rust and wasm-pack
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
Install llvm
brew install llvm
export PATH="/usr/local/opt/llvm/bin/:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export AR=/usr/local/opt/llvm/bin/llvm-ar
npm run wasm-build
The package.json
directly refers to the vscode-cedar-wasm/pkg
folder.
"dependencies": {
"vscode-cedar-wasm": "file:vscode-cedar-wasm/pkg"
},
To run NodeJS TypeScript test code from src/test/suite/*.test.ts
(using Cedar and Cedar schema files containing errors from testdata
).
npm run test
The npm install
included a devDependency for vsce
(short for "Visual Studio Code Extensions"), a command-line tool for packaging, publishing and managing Visual Studio Code extensions. Verify the installation of @vscode/vsce by running:
npx vsce --version
Then run the package
command to create the .vsix file.
npm run package
To build and run tests in a clean environment, first build the container, then open a bash shell in the container. The CLI commands below use docker
, but are compatible with the Finch
open source client for container development.
docker build . -t cedar-policy/vscode-cedar
docker run --rm -it --entrypoint bash cedar-policy/vscode-cedar
Then build and test the extension inside the container. This will take several minutes.
./build.sh
This extension can locally be installed to ~/.vscode/extensions
using the command palette and selecting Extensions: Install from VSIX... or running the following Visual Studio Code command-line interface command (see link if code
is not in your PATH) replacing the .vsix
filename:
code --install-extension vscode-cedar-{major}.{minor}.{patch}.vsix
Note: Preview install may see a [DEP0005] DeprecationWarning
tracked in GitHub issue install-extension command throws Buffer deprecated warning #82524
The project currently uses GitHub flow where feature branches are merged into the main
branch where releases are tagged. .github\workflows\build_and_test.yml
runs on push
and pull_request
to the main
branch.