Skip to content

Commit 14742f2

Browse files
bitjaruclaude
andcommitted
fix: Centralize version management from package.json
- Create src/utils/version.ts as single source of truth - Update init.ts to use VERSION from utility - Update index.ts to use VERSION from utility - Version now displays correctly (was hardcoded as v2.0) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dca494b commit 14742f2

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codesyncer",
3-
"version": "2.7.4",
3+
"version": "2.7.5",
44
"description": "AI-powered multi-repository collaboration system - Works with Claude Code, Cursor, GitHub Copilot, and more",
55
"keywords": [
66
"ai-collaboration",

src/commands/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { getMonorepoToolName } from '../utils/monorepo-helpers';
1010
import { getGitHubInfo } from '../utils/git-helpers';
1111
import { displayProgress } from '../utils/progress';
1212
import { saveSetupState, loadSetupState, clearSetupState, SetupState } from '../utils/setup-state';
13+
import { VERSION } from '../utils/version';
1314

1415
export async function initCommand(options: InitOptions) {
15-
console.log(chalk.bold.cyan('\n🤖 CodeSyncer v2.0 - AI-Powered Collaboration System\n'));
16+
console.log(chalk.bold.cyan(`\n🤖 CodeSyncer v${VERSION} - AI-Powered Collaboration System\n`));
1617
console.log(chalk.gray('Framework provider for AI coding assistants\n'));
1718

1819
const currentDir = process.cwd();

src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@ import { updateCommand } from './commands/update';
77
import { addRepoCommand } from './commands/add-repo';
88
import { watchCommand } from './commands/watch';
99
import { validateCommand } from './commands/validate';
10-
import * as path from 'path';
11-
import * as fs from 'fs';
10+
import { VERSION } from './utils/version';
1211
import * as os from 'os';
1312

14-
// Read version from package.json
15-
const packageJsonPath = path.join(__dirname, '..', 'package.json');
16-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
17-
const version = packageJson.version;
18-
1913
/**
2014
* Format version output with system info
2115
*/
@@ -24,7 +18,7 @@ function formatVersionOutput(): string {
2418
const platform = `${os.platform()} ${os.arch()}`;
2519

2620
const lines = [
27-
`${chalk.bold.cyan('CodeSyncer')} ${chalk.green(`v${version}`)}`,
21+
`${chalk.bold.cyan('CodeSyncer')} ${chalk.green(`v${VERSION}`)}`,
2822
'',
2923
chalk.gray(`Node.js: ${nodeVersion}`),
3024
chalk.gray(`Platform: ${platform}`),

src/utils/version.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as path from 'path';
2+
import * as fs from 'fs';
3+
4+
/**
5+
* Read version from package.json
6+
* Single source of truth for version number
7+
*/
8+
function getPackageJson(): { version: string; name: string; description: string } {
9+
const packageJsonPath = path.join(__dirname, '..', '..', 'package.json');
10+
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
11+
}
12+
13+
export const VERSION = getPackageJson().version;
14+
export const PACKAGE_NAME = getPackageJson().name;
15+
export const DESCRIPTION = getPackageJson().description;

0 commit comments

Comments
 (0)