This guide explains how to publish new versions of SonicJS packages to npm.
-
You must be logged into npm with publish permissions:
npm login
-
Verify you're logged in:
npm whoami
-
Ensure all tests pass:
npm test npm run e2e
npm run release:patchnpm run release:minornpm run release:majorEach release:* command automatically:
- ✅ Bumps the version in
packages/core/package.json - ✅ Updates the core version reference in
packages/create-app/src/cli.js - ✅ Bumps the version in
packages/create-app/package.json - ✅ Builds the core package
- ✅ Publishes
@sonicjs-cms/coreto npm - ✅ Publishes
create-sonicjsto npm
If you prefer more control, you can publish manually:
# For patch release (2.0.4 → 2.0.5)
npm run version:patch
# For minor release (2.0.4 → 2.1.0)
npm run version:minor
# For major release (2.0.4 → 3.0.0)
npm run version:majorThis updates versions in:
packages/core/package.jsonpackages/create-app/package.jsonpackages/create-app/src/cli.js(the core version used by create-sonicjs)
git diffgit add .
git commit -m "chore: release v2.0.5"# Publish both packages
npm run publish:all
# Or publish individually:
npm run publish:core # Publishes @sonicjs-cms/core
npm run publish:create-app # Publishes create-sonicjs# Use the version from packages/core/package.json
git tag v2.0.5git push
git push --tagsThe monorepo maintains two npm packages:
- @sonicjs-cms/core: The core framework package
- create-sonicjs: The CLI tool for scaffolding new apps
When you bump the core version, the sync-versions.js script automatically:
- Updates the create-app CLI to install the new core version
- Bumps the create-sonicjs package version
The create-sonicjs CLI hardcodes which version of @sonicjs-cms/core to install.
This is located at packages/create-app/src/cli.js line ~385:
packageJson.dependencies = {
'@sonicjs-cms/core': '^2.0.4', // This gets auto-updated
...packageJson.dependencies
}The sync-versions.js script keeps this in sync with the actual core version.
Run npm login and ensure you're authenticated with an account that has publish permissions.
You need to bump the version first. Run one of the npm run version:* commands.
Make sure you're in the repository root directory.
You can test the packages locally using npm link:
# In packages/core
cd packages/core
npm run build
npm link
# In your test app
cd /path/to/test-app
npm link @sonicjs-cms/coreTo publish a beta version:
-
Manually set the version with a beta suffix:
cd packages/core npm version 2.1.0-beta.1 --no-git-tag-version node ../../scripts/sync-versions.js -
Publish with the beta tag:
npm publish --workspace=@sonicjs-cms/core --tag beta npm publish --workspace=create-sonicjs --tag beta
-
Users can install with:
npm create sonicjs@beta # or npm install @sonicjs-cms/core@beta
-
Verify on npm: Check that packages are published:
-
Test the CLI: Try creating a new app:
npm create sonicjs@latest my-test-app cd my-test-app npm install npm run dev -
Update documentation: If there are breaking changes or new features, update:
- README.md
- CHANGELOG.md
- Documentation site (www/)
-
Create GitHub Release: Create a release on GitHub with release notes:
Title: v2.0.5 Description: Bug fixes and improvements - Fixed database tools row click redirect issue - Added authentication middleware to database routes - Improved E2E test coverage
Consider setting up GitHub Actions to automate publishing:
name: Publish to npm
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run publish:all
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}