Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
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

Deployment package for projects

latest
npmnpm
Version
1.0.8
Version published
Maintainers
1
Created
Source

Deploy Finlean

一个简单易用的项目部署工具,支持将前端项目打包并部署到远程服务器。

功能特性

  • 自动生成部署配置文件
  • 本地项目打包
  • 压缩打包结果为 zip 文件
  • 通过 SSH 连接远程服务器
  • 自动清空服务器目标目录
  • 上传并解压文件
  • 清理临时文件

安装

全局安装

npm install -g deploy-finlean

项目本地安装

npm install --save-dev deploy-finlean

使用方法

1. 初始化部署配置

在项目根目录执行以下命令:

# 全局安装方式
deploy-init

# 本地安装方式
npx deploy-init

自定义服务器 Web 目录

# 指定完整路径
deploy-init --webDir /path/to/web/directory

# 或使用简写
npx deploy-init -w directory-name

# 自动拼接为 /home/webapps/directory-name

2. 配置服务器信息

初始化后会生成 deploy.config.js 文件,需要修改为你的服务器信息:

/*
 * Deployment configuration file
 * Generated by deploy-finlean
 */
export default {
  // 服务器配置
  server: {
    host: 'your-server-host',     // 服务器 IP 或域名
    port: 22,                     // SSH 端口
    username: 'your-username',     // 服务器用户名
    password: 'your-password'      // 服务器密码
  },
  // 本地配置
  local: {
    buildDir: 'dist',              // 构建输出目录
    zipPath: 'dist.zip',           // 压缩文件路径
    buildCommand: 'npm run build:prod' // 打包命令
  },
  // 服务器配置
  remote: {
    webDir: '/home/webapps/'       // 服务器 web 目录
  }
}

3. 执行部署

在项目根目录执行:

npm run deploy

部署流程

  • 读取 deploy.config.js 配置文件
  • 执行 npm run build:prod 命令进行本地打包
  • 将打包结果压缩为 zip 文件
  • 通过 SSH 连接远程服务器
  • 清空服务器目标目录
  • 上传 zip 文件到服务器
  • 在服务器上解压 zip 文件
  • 删除服务器上的 zip 文件
  • 删除本地 zip 文件
  • 关闭 SSH 连接

依赖项

  • archiver - 用于压缩文件
  • node-ssh - 用于 SSH 连接和文件传输
  • fs - Node.js 内置文件系统模块
  • child_process - Node.js 内置子进程模块
  • path - Node.js 内置路径模块

注意事项

  • 确保服务器上已安装 unzip 命令
  • 确保服务器用户名和密码正确,且具有目标目录的写入权限
  • 确保本地项目具有 npm run build:prod 脚本
  • 首次部署时,确保服务器目标目录已存在

错误处理

如果部署过程中出现错误,工具会输出错误信息并退出。常见错误包括:

  • deploy.config.js 文件不存在
  • 服务器连接失败
  • 构建命令执行失败
  • 文件上传失败
  • 解压命令执行失败

示例

完整部署流程

  • 初始化配置:

    npx deploy-init -w my-project
    
  • 修改 deploy.config.js

    export default {
      server: {
        host: '192.168.1.100',
        port: 22,
        username: 'deploy',
        password: 'your-password'
      },
      local: {
       buildDir: 'dist',
       zipPath: 'dist.zip',
       buildCommand: 'npm run build:prod'
     },
      remote: {
        webDir: '/home/webapps/my-project'
      }
    }
    
  • 执行部署:

    npm run deploy
    

许可证

ISC

Keywords

deploy

FAQs

Package last updated on 25 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts