-
Notifications
You must be signed in to change notification settings - Fork 1
/
init-env.js
50 lines (45 loc) · 1.33 KB
/
init-env.js
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
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
// Function to copy file from source to destination
function copyFile(source, destination) {
if (fs.existsSync(destination)) {
console.log(
chalk.yellow(
`⚠️ ${path.basename(destination)} already exists. Skipping copy.`,
),
)
} else {
fs.copyFile(source, destination, (err) => {
if (err) {
console.error(
chalk.red(`❌ Error copying ${path.basename(destination)}:`),
err,
)
} else {
console.log(
chalk.green(
`✅ ${path.basename(destination)} was successfully copied.`,
),
)
}
})
}
}
// Define source and destination paths
const filesToCopy = [
{
source: path.join(__dirname, 'apps', 'backend', '.env.example'),
destination: path.join(__dirname, 'apps', 'backend', '.env'),
},
{
source: path.join(__dirname, 'apps', 'frontend', '.env.local.example'),
destination: path.join(__dirname, 'apps', 'frontend', '.env.local'),
},
]
// Header
console.log(chalk.blue.bold('\n📂 Initializing Environment Files...\n'))
// Iterate over the files and copy them
filesToCopy.forEach((file) => copyFile(file.source, file.destination))
// Footer
console.log(chalk.blue.bold('\n✨ Environment setup complete!\n'))