- Added a new `@soulcraft/brainy-cli` package to provide a dedicated CLI interface for the Brainy database. - Implemented a CLI wrapper script (`cli-wrapper.js`) to manage global package execution and version handling. - Introduced `scripts/publish-cli.js` to automate synchronized publishing of the main package and CLI, ensuring version consistency. - Created documentation for CLI usage and publishing workflow (`publishing-cli.md`). - Updated `package.json` to include CLI-related build and deploy scripts. - Adjusted `README.md` to document the CLI package, usage instructions, and build separation. This feature introduces a standalone CLI package, improves deployment automation, and enhances documentation to align with the updated architecture.
2.7 KiB
2.7 KiB
Publishing @soulcraft/brainy and @soulcraft/brainy-cli to npm
This document explains how to publish both the @soulcraft/brainy and @soulcraft/brainy-cli packages to npm.
Prerequisites
Before publishing, ensure you have:
- Node.js >= 24.0.0 installed
- An npm account with access to the @soulcraft organization
- Logged in to npm using
npm login
Publishing Process
The repository is set up to publish both packages together with synchronized versions. To publish the packages, follow these steps:
1. Ensure you're in the root directory of the project
cd /path/to/brainy
2. Make sure you have the latest version of the code
git pull
3. Build and publish both packages
npm run deploy:both
This command will:
- Ensure versions are in sync between both packages
- Build the main package
- Build the CLI
- Verify the CLI was built successfully
- Publish the main package to npm
- Publish the CLI package to npm
4. Verify the packages were published successfully
After publishing, you can verify that the packages were published successfully by checking the npm registry:
npm view @soulcraft/brainy
npm view @soulcraft/brainy-cli
How It Works
The publishing process uses the scripts/publish-cli.js script, which:
- Ensures versions are in sync by running
scripts/generate-version.js - Builds the main package with
npm run build - Builds the CLI with
npm run build:cli - Verifies the CLI was built successfully
- Publishes the main package with
npm publishfrom the root directory - Publishes the CLI package with
npm publishfrom the cli-package directory
The version synchronization ensures that:
- Both packages always have the same version number
- The CLI package's dependency on the main package is exact (not using the ^ prefix)
- The README.md file is updated with the current version
The CLI package is configured in cli-package/package.json with:
- The correct package name:
@soulcraft/brainy-cli "private": falseto allow publishing"publishConfig": { "access": "public" }to ensure the scoped package is public- The necessary files in the
"files"array - The correct bin configuration to make the CLI available as
brainy
Troubleshooting
If you encounter any issues during the publishing process:
- Make sure you're logged in to npm with an account that has access to the @soulcraft organization
- Ensure that the
dist/cli.jsfile exists and has been built correctly - If you get an error about the package already existing, you may need to update the version in both package.json files:
npm version patch # This will update both package.json files via the version script