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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pigjs/deploy

v2.1.3

Published

A front-end lightweight deployment tool

Downloads

9

Readme

@pigjs/deploy

@pigjs/deploy 是一个非常轻量级前端部署工具

  • 支持前端项目快速部署
  • 支持多台服务器部署
  • 支持版本管理
  • 采用软链接的形式,可以实现无感发布和秒级回滚

安装

npm i @pigjs/deploy -g
// 也可以安装到项目中
npm i @pigjs/deploy -save

使用

// 服务器配置
interface ServerConfig {
    /** 服务器地址 */
    host: string;
    /** 端口 */
    port: number;
    /** 服务器用户名 */
    username: string;
    /** 服务器密钥 */
    password?: string;
    /** 服务器密钥地址 */
    privateKey?: string;
    /** 密钥密码 */
    passphrase?: string;
    /** 服务器上部署的地址 */
    webDir: string;
    /** 项目版本管理 */
    webVersion?: {
        /** 版本存放地址 */
        sourceDir: string;
        /** 最大存放几个版本 默认 5个 */
        maxLimit?: number;
    };
}

// .deployrc.js 配置文件
interface DeployConfig {
    /** 服务器配置 */
    serverConfig: ServerConfig[];
    /** 打包命令 */
    script: string;
    /** 本地打包文件目录 */
    distPath: string;
    /** 运行目录 */
    cwd?: string;
    /** 用户自定义配置文件地址 */
    customPath?: string;
    /** 部署完成之后,是否删除打包文件 */
    delDistFile?: boolean;
    plugins?: {
        /** 上传过程中 过滤某些文件 */
        uploadValidate?: (itemPath: string) => boolean;
        /** 上传完成后允许用户自定义一些操作 */
        useUploadDone?: (command) => Promise<void> | void;
    };
}

const commands = ['revert', 'deploy'] as const;

// 自定义命令调用
interface Commands extends DeployConfig {
    /** 命令 */
    command: typeof commands[number];
    /** 是否需要读取配置文件 */
    readConfigFile?: boolean;
}
// package.json
{
    "script": {
        "deploy": "pig-deploy deploy --config ./config/deploy",
        "deploy:revert": "pig-deploy revert --config ./config/deploy"
    }
}

你也可以在项目根目录下创建 .deployrc.js 文件 或者在 package.json 中 --config 指定配置文件

自定义调用

如果你不是在终端中直接调用 deploy 的,想集成到插件中的,你可以使用自定义调用

import deploy,{Commands} from '@pigjs/deploy'

const commands:Commands {
    // 配置信息
}

deploy(commands)

版本回滚

pig-deploy revert --config=配置文件地址

部署

pig-deploy deploy --config=配置文件地址