Deploy Staging Extension
A Visual Studio Code extension that adds a configurable checkbox in the status bar to automatically append custom messages (like [deploy staging]) to Git commit messages. Includes configurable message length validation to maintain commit message best practices.
Features
- Status Bar Checkbox: Clickable item in the bottom left that toggles between checked (✓) and unchecked (○) states
- Automatic Message Appending: When checked, automatically appends a custom message to the first line of commit messages
- Length Validation: Warns when commit message first line exceeds the configured maximum length
- Smart Toggle Prevention: Prevents enabling the checkbox if it would exceed the maximum commit message length
- Fully Configurable: Customize the message, checkbox name, and maximum line length via VS Code settings
Requirements
- Visual Studio Code 1.70.0 or higher
- Git extension enabled (built into VS Code)
- Node.js 20.18.1 or higher (for building from source)
Installation
Install from VSIX
Build the extension (or get the .vsix file from a colleague):
cd vscode-deploy-staging-extension
npm install
npm run compile
npx @vscode/vsce package
This creates a file like deploy-staging-extension-1.0.1.vsix
Install in VS Code:
- Open VS Code
- Press
Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
- Type "Extensions: Install from VSIX..."
- Select the
.vsix file
- Reload VS Code when prompted
For Developers
Clone the repository:
git clone https://klarna.ghe.com/klarna/kafka_dis-tooling-misc-scripts.git
cd kafka_dis-tooling-misc-scripts/vscode-deploy-staging-extension
Install Node.js 20+ (if not already installed):
nvm install 20
nvm use 20
Or with Homebrew:
brew install node@20
export PATH="/opt/homebrew/opt/node@20/bin:$PATH"
Install dependencies:
npm install
Compile TypeScript:
npm run compile
Open in VS Code and test:
code .
Press F5 to launch the Extension Development Host
Usage
- Open a Git repository in VS Code
- Find the checkbox in the status bar (bottom left) - default name is "○ Deploy Staging"
- Click to toggle - changes to "✓ Deploy Staging" when enabled
- Write your commit message in Source Control (
Cmd+Shift+G)
- Custom message is appended automatically to the first line when checkbox is enabled
- Length validation warns if the first line exceeds the configured maximum (default: 50 characters)
- Click again to disable and remove the custom message
Length Validation
- Warning appears when typing if the first line exceeds the maximum length
- Checkbox cannot be enabled if adding the custom message would exceed the limit
- Helps maintain Git commit message best practices (50 character first line)
Configuration
Customize the extension in VS Code settings:
Settings
| Setting |
Default |
Description |
deployStagingExtension.customMessage |
[deploy staging] |
Message to append to commit messages |
deployStagingExtension.checkboxName |
Deploy Staging |
Name displayed on the status bar checkbox |
deployStagingExtension.maxCommitMessageLength |
50 |
Maximum length for the first line of commit messages |
Via Settings UI:
- Open Settings (
Cmd+,)
- Search for "Deploy Staging Extension"
- Modify the desired settings
Via settings.json:
{
"deployStagingExtension.customMessage": "[your custom message]",
"deployStagingExtension.checkboxName": "Custom Name",
"deployStagingExtension.maxCommitMessageLength": 72
}
Development
Building from Source
Compile TypeScript:
npm run compile
Watch for changes (auto-recompile):
npm run watch
Testing
- Make your code changes
- Ensure
npm run watch is running (or run npm run compile)
- Press
F5 in VS Code to launch Extension Development Host
- Test the extension in the new window
- Check the Debug Console for errors
- Reload the debug window to see new changes
Version Management
Update version in package.json using semantic versioning:
{
"version": "1.0.1"
}
Semantic Versioning:
- MAJOR (1.0.0 → 2.0.0): Breaking changes
- MINOR (1.0.0 → 1.1.0): New features, backwards compatible
- PATCH (1.0.0 → 1.0.1): Bug fixes, backwards compatible
Packaging for Distribution
Prerequisites:
- Node.js 20.18.1 or higher
- Install vsce globally:
npm install -g @vscode/vsce
Create VSIX file:
# Update version in package.json first
npm run compile
vsce package
This creates a .vsix file named deploy-staging-extension-<version>.vsix
Quick version bump and package:
# Automatically increment version and package
vsce package --patch # 1.0.0 → 1.0.1
vsce package --minor # 1.0.0 → 1.1.0
vsce package --major # 1.0.0 → 2.0.0
Note: The .vsix files are not committed to Git. Users must build the extension from source.
Publishing (Optional)
If you want to publish to the VS Code Marketplace:
Create a publisher account at https://marketplace.visualstudio.com/manage
Get a Personal Access Token from https://dev.azure.com
Publish:
vsce publish
Troubleshooting
Extension not activating
- Ensure Git extension is enabled
- Check Output panel (View → Output) and select "Log (Extension Host)"
- Look for errors related to the extension
Warnings not appearing
- Verify you have a Git repository open
- Open Source Control view (
Cmd+Shift+G) to initialize Git integration
- Check the maximum length setting matches your expectations
Build errors
Ensure Node.js version is 20.18.1 or higher: node --version
Delete node_modules and out folders, then run:
npm install
npm run compile
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE.txt file for details.
Author
Fredrik Lysén
Email: fredrik.lysen@klarna.com