Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

generate-constants.js 841 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  1. const fs = require('fs');
  2. const path = require('path');
  3. // Get the PostHog key from environment
  4. const posthogKey = process.env.PROMPTFOO_POSTHOG_KEY || '';
  5. const constantsTemplate = `// This file is auto-generated during build. Do not edit manually.
  6. // Generated at: ${new Date().toISOString()}
  7. export const POSTHOG_KEY = '${posthogKey}';
  8. `;
  9. const generatedDir = path.join(__dirname, '../src/generated');
  10. const outputPath = path.join(generatedDir, 'constants.ts');
  11. try {
  12. // Ensure the directory exists
  13. if (!fs.existsSync(generatedDir)) {
  14. fs.mkdirSync(generatedDir, { recursive: true });
  15. }
  16. fs.writeFileSync(outputPath, constantsTemplate, 'utf8');
  17. console.log('Generated constants file at src/generated/constants.ts');
  18. } catch (error) {
  19. console.error('✗ Failed to generate constants file:', error);
  20. process.exit(1);
  21. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...