chore: cleanup

This commit is contained in:
Cory Dransfeldt 2024-09-16 07:56:25 -07:00
parent ade57be4a5
commit de2dca0810
No known key found for this signature in database
10 changed files with 311 additions and 37 deletions

View file

@ -1,22 +1,28 @@
import fs from 'fs/promises';
import dotenv from 'dotenv-flow';
import fs from 'fs/promises'
import dotenv from 'dotenv-flow'
dotenv.config();
dotenv.config()
const workerName = process.argv[2];
const workerName = process.argv[2]
if (!workerName) {
console.error('Please specify a worker name.');
process.exit(1);
console.error('Please specify a worker name.')
process.exit(1)
}
const templatePath = `workers/${workerName}/wrangler.template.toml`;
const outputPath = `workers/${workerName}/wrangler.toml`;
const template = await fs.readFile(templatePath, 'utf8');
const output = template
.replace(/\${CF_ACCOUNT_ID}/g, process.env.CF_ACCOUNT_ID)
.replace(/\${CF_ZONE_ID}/g, process.env.CF_ZONE_ID);
const templatePath = `workers/${workerName}/wrangler.template.toml`
const outputPath = `workers/${workerName}/wrangler.toml`
await fs.writeFile(outputPath, output);
try {
const template = await fs.readFile(templatePath, 'utf8')
const output = template
.replace(/\${CF_ACCOUNT_ID}/g, process.env.CF_ACCOUNT_ID)
.replace(/\${CF_ZONE_ID}/g, process.env.CF_ZONE_ID)
console.log(`Generated wrangler.toml for ${workerName}`);
await fs.writeFile(outputPath, output)
console.log(`Generated wrangler.toml for ${workerName}`)
} catch (error) {
console.error('Error generating wrangler.toml:', error)
process.exit(1)
}