diff --git a/kit/local.json b/kit/local.json new file mode 100644 index 0000000..765b114 --- /dev/null +++ b/kit/local.json @@ -0,0 +1,5 @@ +{ + "linux" : "./dist/linux/kit", + "windows" : "./dist/windows/kit.exe", + "dir" : "C:\\Users\\occul\\SynologyDrive\\bin" +} \ No newline at end of file diff --git a/kit/push.js b/kit/push.js new file mode 100644 index 0000000..86e0a1a --- /dev/null +++ b/kit/push.js @@ -0,0 +1,58 @@ +// push.js +const fs = require('fs'); +const path = require('path'); + +// 读取命令行参数 +const args = process.argv.slice(2); +const platform = args[0]; // 'windows' 或 'linux' +const target = args[1]; // 目标配置键,如 'dir' + +if (!platform || !target) { + console.error('用法: node push.js <平台> <目标配置键>'); + console.error('示例: node push.js windows dir'); + process.exit(1); +} + +try { + // 读取配置文件 + const configPath = path.join(__dirname, 'local.json'); + const configData = JSON.parse(fs.readFileSync(configPath, 'utf8')); + + // 验证参数 + if (!configData[platform]) { + console.error(`错误: 配置文件中找不到平台 "${platform}"`); + process.exit(1); + } + + if (!configData[target]) { + console.error(`错误: 配置文件中找不到目标 "${target}"`); + process.exit(1); + } + + // 获取源文件和目标目录 + const sourceFile = path.resolve(__dirname, configData[platform]); + const targetDir = configData[target]; + + // 获取源文件名 + const sourceFileName = path.basename(sourceFile); + + // 创建目标路径 + const targetPath = path.join(targetDir, sourceFileName); + + // 确保目标目录存在 + if (!fs.existsSync(targetDir)) { + console.log(`创建目录: ${targetDir}`); + fs.mkdirSync(targetDir, { recursive: true }); + } + + // 复制文件 + fs.copyFileSync(sourceFile, targetPath); + + console.log(`成功复制文件:`); + console.log(` 从: ${sourceFile}`); + console.log(` 到: ${targetPath}`); + +} catch (error) { + console.error(`错误: ${error.message}`); + process.exit(1); +} \ No newline at end of file