Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | import fs from 'fs';
import { dotenvLoader, fileWriter } from './functions';
const main = () => {
//* Change directory to the project root where the .env file is located *//
process.chdir('../');
//* Check current directory is project root *//
if (!fs.existsSync('pay-crew')) {
throw new Error('This script must be run from the root directory of the project');
}
//* Load environment variables from .env file *//
const envConfig = dotenvLoader();
//* Create secret configuration files *//
{
// frontend
const frontendDotenvData = `VITE_API_URL=${envConfig.frontendConfig.viteApiUrl}
VITE_SENTRY_DSN=${envConfig.frontendConfig.viteSentryDsn}
SENTRY_AUTH_TOKEN=${envConfig.frontendConfig.sentryAuthToken}
SENTRY_ORG=${envConfig.frontendConfig.sentryOrg}
SENTRY_PROJECT=${envConfig.frontendConfig.sentryProject}
`;
fileWriter('./products/frontend/.env', frontendDotenvData);
}
{
// backend
const wranglerData = `{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "pay-crew-backend",
"main": "src/index.ts",
"compatibility_date": "2025-09-21",
"compatibility_flags": [
"nodejs_compat"
],
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "dummy",
"localConnectionString": "postgresql://${envConfig.backendConfig.postgresUser}:${envConfig.backendConfig.postgresPassword}@localhost:${envConfig.backendConfig.postgresPort}/${envConfig.backendConfig.postgresDb}"
}
]
}
`;
fileWriter('./products/backend/wrangler.local.jsonc', wranglerData);
const backendDotenvData = `POSTGRES_URL=postgresql://${envConfig.backendConfig.postgresUser}:${envConfig.backendConfig.postgresPassword}@localhost:${envConfig.backendConfig.postgresPort}/${envConfig.backendConfig.postgresDb}
`;
fileWriter('./products/backend/.env', backendDotenvData);
}
{
// notify
const wranglerData = `{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "pay-crew-notify",
"main": "src/index.ts",
"compatibility_date": "2025-11-19",
"observability": {
"enabled": true,
},
"vars": {
"API_URL": "${envConfig.notifyConfig.apiUrl}",
},
}
`;
fileWriter('./products/notify/wrangler.local.jsonc', wranglerData);
}
};
main();
|