## Context Previous token was tied to a non-existing token and codegen was failing locally due to the server throwing. This is due to a regression introduced here https://github.com/twentyhq/twenty/pull/18590/changes#diff-848fff5d5b6f9858c8e2391212dfa9da5151cd3b1325d410df8a82250a229558L26 where a token is hardcoded instead of using the one from the ENV
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { readFile } from 'node:fs/promises';
|
|
import path from 'path';
|
|
|
|
import { CLIENTS_GENERATED_DIR } from '@/cli/constants/clients-dir';
|
|
import { ClientService } from '@/cli/utilities/client/client-service';
|
|
|
|
const TEMPLATE_PATH = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'src',
|
|
'cli',
|
|
'utilities',
|
|
'client',
|
|
'twenty-client-template.ts',
|
|
);
|
|
|
|
const main = async () => {
|
|
const outputPath = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
CLIENTS_GENERATED_DIR,
|
|
'metadata',
|
|
);
|
|
|
|
const serverUrl = process.env.TWENTY_API_URL ?? 'http://localhost:3000';
|
|
const token = process.env.TWENTY_API_KEY;
|
|
const clientWrapperTemplateSource = await readFile(TEMPLATE_PATH, 'utf-8');
|
|
|
|
const clientService = new ClientService({
|
|
clientWrapperTemplateSource,
|
|
serverUrl,
|
|
token,
|
|
});
|
|
|
|
await clientService.generateMetadataClient({ outputPath });
|
|
|
|
console.log(`Metadata client generated at ${outputPath}`);
|
|
};
|
|
|
|
main().catch((error) => {
|
|
console.error('Failed to generate metadata client:', error);
|
|
process.exit(1);
|
|
});
|