tambahannya
This commit is contained in:
56
bin/init.ts
Executable file
56
bin/init.ts
Executable file
@@ -0,0 +1,56 @@
|
||||
import fs from 'fs/promises';
|
||||
import { execSync } from 'child_process'
|
||||
|
||||
async function init() {
|
||||
console.log("[INIT] Initializing...")
|
||||
|
||||
try {
|
||||
await fs.access(".env")
|
||||
} catch (error) {
|
||||
let envText = ""
|
||||
envText += "NAMESPACE=\n"
|
||||
envText += "OPENAPI_URL=\n"
|
||||
// generate .env
|
||||
await fs.writeFile(".env", envText)
|
||||
console.log('[GEN] Generated .env');
|
||||
}
|
||||
|
||||
const NAMESPACE = process.env.NAMESPACE
|
||||
const OPENAPI_URL = process.env.OPENAPI_URL
|
||||
|
||||
if (!NAMESPACE || !OPENAPI_URL) {
|
||||
throw new Error('NAMESPACE and OPENAPI_URL are required')
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.access(".git")
|
||||
} catch (error) {
|
||||
execSync("git init")
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("[INIT] Gitignored...")
|
||||
await fs.access(".gitignore")
|
||||
} catch (e) {
|
||||
|
||||
execSync("npx -y gitignore node")
|
||||
console.log('[INIT] gitignored');
|
||||
}
|
||||
|
||||
try {
|
||||
console.log("[INIT] Npmignored...")
|
||||
await fs.access(".npmignore")
|
||||
} catch (e) {
|
||||
|
||||
execSync("npx -y npmignore node")
|
||||
console.log('[INIT] npmignored');
|
||||
}
|
||||
|
||||
console.log('[INIT] Installing dependencies...');
|
||||
execSync("bun install", { stdio: 'inherit' })
|
||||
|
||||
console.log('[INIT] Done');
|
||||
|
||||
}
|
||||
|
||||
init()
|
||||
Reference in New Issue
Block a user