**feat(cli, scripts): introduce CLI package and automated publishing process**
- 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.
This commit is contained in:
parent
fa9b1164fd
commit
087eb51799
11 changed files with 417 additions and 22 deletions
|
|
@ -7,7 +7,8 @@
|
|||
* This allows the CLI to access the version without having to read package.json directly,
|
||||
* which can be problematic when the package is installed globally.
|
||||
*
|
||||
* It also updates the version in the README.md file to ensure it stays in sync with package.json.
|
||||
* It also updates the version in the README.md file and CLI package.json to ensure they
|
||||
* stay in sync with the main package.json.
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
|
|
@ -33,6 +34,9 @@ const outputFile = path.join(outputDir, 'version.ts')
|
|||
// Path to README.md
|
||||
const readmePath = path.join(rootDir, 'README.md')
|
||||
|
||||
// Path to CLI package.json
|
||||
const cliPackageJsonPath = path.join(rootDir, 'cli-package', 'package.json')
|
||||
|
||||
// Read package.json
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
||||
const version = packageJson.version
|
||||
|
|
@ -105,3 +109,23 @@ try {
|
|||
} catch (error) {
|
||||
console.error('Error updating README.md:', error)
|
||||
}
|
||||
|
||||
// Update CLI package.json with the same version
|
||||
try {
|
||||
// Read CLI package.json
|
||||
const cliPackageJson = JSON.parse(fs.readFileSync(cliPackageJsonPath, 'utf8'))
|
||||
|
||||
// Update version
|
||||
cliPackageJson.version = version
|
||||
|
||||
// Update dependency on main package to be exact
|
||||
if (cliPackageJson.dependencies && cliPackageJson.dependencies['@soulcraft/brainy']) {
|
||||
cliPackageJson.dependencies['@soulcraft/brainy'] = version
|
||||
}
|
||||
|
||||
// Write the updated CLI package.json back to disk
|
||||
fs.writeFileSync(cliPackageJsonPath, JSON.stringify(cliPackageJson, null, 2))
|
||||
console.log(`Updated CLI package.json with version ${version} and exact dependency on main package`)
|
||||
} catch (error) {
|
||||
console.error('Error updating CLI package.json:', error)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue