#!/usr/bin/env node /** * 初始化部署配置:把 scripts/deploy.config.example.json 复制为 scripts/deploy.config.json。 * deploy.config.json 含服务器/密钥信息,已被 .gitignore 排除,不要提交。 * * 用法:npm run deploy:init */ import { copyFileSync, existsSync } from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const EXAMPLE_PATH = path.join(__dirname, 'deploy.config.example.json'); const CONFIG_PATH = path.join(__dirname, 'deploy.config.json'); if (existsSync(CONFIG_PATH)) { console.log('ℹ️ scripts/deploy.config.json 已存在,未覆盖。'); console.log(` 如需重新生成,请先删除该文件:${CONFIG_PATH}`); process.exit(0); } copyFileSync(EXAMPLE_PATH, CONFIG_PATH); console.log('✅ 已生成 scripts/deploy.config.json'); console.log(' 请按实际服务器信息修改其中的 user / ip / basePath / siteHost / sshKey,然后再执行 npm run deploy。');