npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tl-publish

v1.0.2

Published

使用nodeJs将项目部署到指定服务器。

Downloads

14

Readme

简介(测试版请勿使用)

使用nodeJs将项目部署到指定服务器。

  • 将本地目录复制到服务器指定目录。
  • 将本地项目目录压缩为zip文件,在传输到服务器,在解压缩。
  • 备份服务器指定目录存储到本地为zip文件。
  • 将备份zip文件发布到服务器。

安装

npm i -D tl-publish

demo

  • 将本地目录拷贝到服务器目录
const fs = require('fs');
const {uploadDir} = require('tl-publish');
uploadDir(`./www`, `/var/www`, {
    host: '192.168.1.100',
    port: 21,
    username: 'ubuntu',
    privateKey: fs.readFileSync(`./id_rsa`)
});
  • 备份服务器指定目录存储到本地为zip文件。
const { backup } = require('tl-publish');

backup({
    tip: '测试',
    key: 'test',
    server: {
        // 服务器部署项目地址
        projectRootPath: '/var/www/Cloud_CFS/Assets/test',
        connectConfig: {
            host: '192.168.1.100',
            port: 88888,
            username: 'root',
            password: '123456'
        },
    },
    local: {
        // 本地备份路径
        backupDir: './backup'
    }
});
  • 将备份zip文件发布到服务器。
const { back } = require('tl-publish');

back({
    tip: '测试',
    key: 'test',
    server: {
        // 服务器部署项目地址
        projectRootPath: '/var/www/Cloud_CFS/Assets/test',
       connectConfig: {
            host: '192.168.1.100',
            port: 88888,
            username: 'root',
            password: '123456'
        },
    },
    local: {
        // 本地备份路径
        backupDir: './backup'
    }
});
  • 将本地项目目录压缩为zip文件,在传输到服务器,在解压缩。
const { publish } = require('tl-publish');

const config = {
    tip: '测试',
    key: 'test',
    server: {
        // 服务器部署项目地址
        projectRootPath: '/var/www/Cloud_CFS/Assets/test',
        connectConfig: {
            host: '192.168.1.100',
            port: 88888,
            username: 'root',
            password: '123456'
        },
        // 上传前服务器运行命令
        beforeUploadCmds: [
            `rm -rf /var/www/Cloud_CFS/Assets/test/*`,
        ],
        // 上传后服务器运行命令
        afterUploadCmds: [
            `unzip -o /var/www/Cloud_CFS/Assets/test/test.zip -d /var/www/Cloud_CFS/Assets/test/`,
            `sudo chmod -R 755 /var/www/Cloud_CFS/Assets/test`,
            `rm -f /var/www/Cloud_CFS/Assets/test/test.zip`,
        ]
    },
    local: {
        // 要打包上传的目录
        distPath: './www',
        // 存放压缩文件目录
        zipDir: './zip',
        backupDir: './backup'
    }
}

publish(config);