Merge twenty-cli into twenty-sdk (#16150)
- Moves twenty-cli content into twenty-sdk - add a new twenty-sdk:0.1.0 version - this new twenty-sdk exports a cli command called 'twenty' (like twenty-cli before) - deprecates twenty-cli - simplify app init command base-project - use `twenty-sdk:0.1.0` in base project - move the "twenty-sdk/application" barrel to "twenty-sdk" - add `create-twenty-app` package <img width="1512" height="919" alt="image" src="https://github.com/user-attachments/assets/007bef45-4e71-419a-9213-cebed376adbf" /> <img width="1506" height="929" alt="image" src="https://github.com/user-attachments/assets/3de2fec6-1624-4923-ae13-f4e1cf165eb5" />
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
import chalk from 'chalk';
|
||||
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 { ConfigService } from './services/config.service';
|
||||
|
||||
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(packageJson.version);
|
||||
|
||||
program.option(
|
||||
'--workspace <name>',
|
||||
'Use a specific workspace configuration',
|
||||
'default',
|
||||
);
|
||||
|
||||
program.hook('preAction', (thisCommand) => {
|
||||
const opts = (thisCommand as any).optsWithGlobals
|
||||
? (thisCommand as any).optsWithGlobals()
|
||||
: thisCommand.opts();
|
||||
const workspace = opts.workspace;
|
||||
ConfigService.setActiveWorkspace(workspace);
|
||||
console.log(
|
||||
chalk.gray(`👩💻 Workspace - ${ConfigService.getActiveWorkspace()}`),
|
||||
);
|
||||
});
|
||||
|
||||
program.addCommand(new AuthCommand().getCommand());
|
||||
program.addCommand(new AppCommand().getCommand());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user