🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

deploy-finlean

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deploy-finlean - npm Package Compare versions

Comparing version
1.0.5
to
1.0.6
+150
-59
bin/deploy-init.js

@@ -1,54 +0,64 @@

/*
* @Author: zhaoxiaoqiang1 287285524@qq.com
* @Date: 2026-03-19 15:03:13
* @LastEditors: zhaoxiaoqiang1 287285524@qq.com
* @LastEditTime: 2026-03-20 16:42:56
* @FilePath: \deploy-package\bin\deploy-init.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
#!/usr/bin/env node
/**
* deploy-init.js - 初始化部署配置文件
*
* 修复说明:
* 1. 支持双模块系统:同时兼容CommonJS和ES模块
* 2. 自动检测环境:根据运行环境自动选择合适的模块系统
* 3. 解决初始 化 失败问题:确保在不同项目环境中都能正确执行
*
* 原因:不同项目可能使用不同的模块系统,
* 有些项目使用CommonJS (require/module.exports),
* 有些项目使用ES模块 (import/export)。
*/
import fs from 'fs';
import path from 'path';
// 解析命令行参数
const argv = process.argv.slice(2);
let webDir = '/home/webapps/'; // 默认值
for (let i = 0; i < argv.length; i++) {
if (argv[i] === '--webDir' || argv[i] === '-w') {
if (argv[i + 1]) {
const dirName = argv[i + 1];
// 如果用户只传入了文件夹名,自动拼接路径
if (!dirName.startsWith('/')) {
webDir = `/home/webapps/${dirName}`;
} else {
webDir = dirName;
// 检查是否支持ES模块(通过检测require是否存在)
if (typeof require !== 'undefined') {
// 使用CommonJS模块
const fs = require('fs');
const path = require('path');
// 解析命令行参数
const argv = process.argv.slice(2);
let webDir = '/home/webapps/'; // 默认值
for (let i = 0; i < argv.length; i++) {
if (argv[i] === '--webDir' || argv[i] === '-w') {
if (argv[i + 1]) {
const dirName = argv[i + 1];
// 如果用户只传入了文件夹名,自动拼接路径
if (!dirName.startsWith('/')) {
webDir = `/home/webapps/${dirName}`;
} else {
webDir = dirName;
}
i++;
}
i++;
}
}
}
// 检查当前目录是否存在 package.json 文件
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (!fs.existsSync(packageJsonPath)) {
console.error('Error: package.json not found in current directory');
process.exit(1);
}
// 读取 package.json 文件
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// 添加部署脚本
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.deploy = 'node ./node_modules/deploy-finlean/index.js';
// 写入更新后的 package.json 文件
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log('Added deploy script to package.json');
// 生成 deploy.config.js 文件
const deployConfigContent = `/*
// 检查当前目录是否存在 package.json 文件
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (!fs.existsSync(packageJsonPath)) {
console.error('Error: package.json not found in current directory');
process.exit(1);
}
// 读取 package.json 文件
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// 添加部署脚本
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.deploy = 'node ./node_modules/deploy-finlean/index.js';
// 写入更新后的 package.json 文件
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log('Added deploy script to package.json');
// 生成 deploy.config.js 文件
const deployConfigContent = `/*
* Deployment configuration file

@@ -76,12 +86,93 @@ * Generated by deploy-finlean

}`;
const deployConfigPath = path.join(process.cwd(), 'deploy.config.js');
fs.writeFileSync(deployConfigPath, deployConfigContent);
console.log('Generated deploy.config.js file');
console.log('\nPlease update deploy.config.js with your server information');
console.log('You can also specify the web directory during initialization:');
console.log(' npx deploy-init --webDir /path/to/web/directory (完整路径)');
console.log(' or');
console.log(' npx deploy-init -w directory-name (自动拼接 /home/webapps/directory-name)');
console.log('\nThen run "npm run deploy" to deploy your project');
const deployConfigPath = path.join(process.cwd(), 'deploy.config.js');
fs.writeFileSync(deployConfigPath, deployConfigContent);
console.log('Generated deploy.config.js file');
console.log('\nPlease update deploy.config.js with your server information');
console.log('You can also specify the web directory during initialization:');
console.log(' npx deploy-init --webDir /path/to/web/directory (完整路径)');
console.log(' or');
console.log(' npx deploy-init -w directory-name (自动拼接 /home/webapps/directory-name)');
console.log('\nThen run "npm run deploy" to deploy your project');
} else {
// 使用ES模块
import fs from 'fs';
import path from 'path';
// 解析命令行参数
const argv = process.argv.slice(2);
let webDir = '/home/webapps/'; // 默认值
for (let i = 0; i < argv.length; i++) {
if (argv[i] === '--webDir' || argv[i] === '-w') {
if (argv[i + 1]) {
const dirName = argv[i + 1];
// 如果用户只传入了文件夹名,自动拼接路径
if (!dirName.startsWith('/')) {
webDir = `/home/webapps/${dirName}`;
} else {
webDir = dirName;
}
i++;
}
}
}
// 检查当前目录是否存在 package.json 文件
const packageJsonPath = path.join(process.cwd(), 'package.json');
if (!fs.existsSync(packageJsonPath)) {
console.error('Error: package.json not found in current directory');
process.exit(1);
}
// 读取 package.json 文件
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
// 添加部署脚本
if (!packageJson.scripts) {
packageJson.scripts = {};
}
packageJson.scripts.deploy = 'node ./node_modules/deploy-finlean/index.js';
// 写入更新后的 package.json 文件
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
console.log('Added deploy script to package.json');
// 生成 deploy.config.js 文件
const deployConfigContent = `/*
* Deployment configuration file
* Generated by deploy-finlean
*/
export default {
// 服务器配置
server: {
host: '39.106.58.84',
port: 22,
username: 'root',
password: '' // 或者使用私钥
},
// 本地配置
local: {
buildDir: 'dist', // 构建输出目录
zipPath: 'dist.zip', // 压缩文件路径
buildCommand: 'npm run build:prod' // 打包命令
},
// 服务器配置
remote: {
webDir: '${webDir}' // 服务器 web 目录
}
}`;
const deployConfigPath = path.join(process.cwd(), 'deploy.config.js');
fs.writeFileSync(deployConfigPath, deployConfigContent);
console.log('Generated deploy.config.js file');
console.log('\nPlease update deploy.config.js with your server information');
console.log('You can also specify the web directory during initialization:');
console.log(' npx deploy-init --webDir /path/to/web/directory (完整路径)');
console.log(' or');
console.log(' npx deploy-init -w directory-name (自动拼接 /home/webapps/directory-name)');
console.log('\nThen run "npm run deploy" to deploy your project');
}

@@ -5,5 +5,13 @@ /*

* @LastEditors: zhaoxiaoqiang1 287285524@qq.com
* @LastEditTime: 2026-03-20 16:12:19
* @LastEditTime: 2026-03-23 10:15:30
* @FilePath: \deploy-package\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 部署工具主文件
*
* 修复说明:
* 1. 配置文件加载:使用fs.readFileSync和eval替代ES模块import
* 2. 解决Windows路径问题:避免ES模块加载器对Windows路径的限制
* 3. 增强错误处理:添加配置文件解析错误的捕获和提示
*
* 原因:ES模块的import语法在Windows系统上对路径格式有严格要求,
* 直接使用绝对路径会导致ERR_UNSUPPORTED_ESM_URL_SCHEME错误。
*/

@@ -10,0 +18,0 @@ import fs from 'fs';

{
"name": "deploy-finlean",
"version": "1.0.5",
"version": "1.0.6",
"description": "Deployment package for projects",

@@ -5,0 +5,0 @@ "main": "index.js",