From 337f1a98a8a7ae46772262fefabb8bb008f346ca Mon Sep 17 00:00:00 2001 From: Weiko Date: Tue, 7 Oct 2025 11:46:23 +0200 Subject: [PATCH] Fix auth + cli -V not picking up package json (#14934) - Auth was failing, GQL query was not well formatted - -V was not working as expected and was reading hardcoded version instead of package.json - CommanderError due to early exit (with -V for example) were thrown and logged, now not logging those --- packages/twenty-cli/src/cli.ts | 13 +++++++++++-- packages/twenty-cli/src/services/api.service.ts | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/twenty-cli/src/cli.ts b/packages/twenty-cli/src/cli.ts index 77008dac063..0e0ee88f4bf 100644 --- a/packages/twenty-cli/src/cli.ts +++ b/packages/twenty-cli/src/cli.ts @@ -1,17 +1,23 @@ #!/usr/bin/env node import chalk from 'chalk'; -import { Command } from 'commander'; +import { Command, CommanderError } from 'commander'; +import { readFileSync } from 'fs'; +import { join } from 'path'; import { AppCommand } from './commands/app.command'; import { AuthCommand } from './commands/auth.command'; import { ConfigCommand } from './commands/config.command'; +const packageJson = JSON.parse( + readFileSync(join(__dirname, '../package.json'), 'utf-8'), +); + const program = new Command(); program .name('twenty') .description('CLI for Twenty application development') - .version('0.1.0'); + .version(packageJson.version); program.option( '--api-url ', @@ -28,6 +34,9 @@ program.exitOverride(); try { program.parse(); } catch (error) { + if (error instanceof CommanderError) { + process.exit(error.exitCode); + } if (error instanceof Error) { console.error(chalk.red('Error:'), error.message); process.exit(1); diff --git a/packages/twenty-cli/src/services/api.service.ts b/packages/twenty-cli/src/services/api.service.ts index bdebcac9501..03de86cb752 100644 --- a/packages/twenty-cli/src/services/api.service.ts +++ b/packages/twenty-cli/src/services/api.service.ts @@ -57,7 +57,8 @@ export class ApiService { const query = ` query CurrentWorkspace { currentWorkspace { - id + id + } } `;