-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-env.js
More file actions
executable file
·50 lines (38 loc) · 1.29 KB
/
Copy pathsetup-env.js
File metadata and controls
executable file
·50 lines (38 loc) · 1.29 KB
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
#!/usr/bin/env node
import fs from "node:fs";
import { fileURLToPath } from "node:url";
const ENV_EXAMPLE = "env.example";
const ENV_FILE = ".env";
function setupEnvironment() {
console.log("Setting up environment configuration...\n");
// Check if .env already exists
if (fs.existsSync(ENV_FILE)) {
console.log(".env file already exists");
console.log("If you want to reset it, delete .env and run this script again\n");
return;
}
// Check if env.example exists
if (!fs.existsSync(ENV_EXAMPLE)) {
console.error("env.example file not found");
process.exit(1);
}
try {
// Copy env.example to .env
fs.copyFileSync(ENV_EXAMPLE, ENV_FILE);
console.log("Created .env file from env.example");
console.log("Environment file created");
console.log("\nEnvironment setup complete!");
console.log("\nNext steps:");
console.log("1. Edit .env file with your OAuth provider settings");
console.log("2. Run: pnpm run dev");
console.log("3. Or run: pnpm run build && pnpm start");
} catch (error) {
console.error("Error setting up environment:", error.message);
process.exit(1);
}
}
// Run setup if this file is executed directly
if (process.argv[1] === fileURLToPath(import.meta.url)) {
setupEnvironment();
}
export { setupEnvironment };