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

vue-compress-upload-plugin

v1.2.3

Published

将文件打成压缩包,上传到服务器上

Downloads

8

Readme

vue-compress-upload-plugin

1.2.x

本次版本升级支持多种压缩格式(zip/tar),更新的参数的属性名,使用 1.2.x 的小伙伴记得修改对应参数的属性名 增加了支持同时向多台服务器发布应用的功能、支持上传本地脚本到服务器执行

下面展示的两种使用方法,视具体情况使用,一般情况下,我们只需要配置 serverList 或者是 server即可

const CompressUploadPlugin = require('vue-compress-upload-plugin');

// 第一种 有多台服务器需要发布应用
new CompressUploadPlugin({
    serverList: [
        {
            host: 'xxx.xxx.xxx.xxx',
            username: 'nginx',
            password: 'xxx',
            uploadPath: '/usr/local/nginx/webapp/dist.zip',
            localCmdScriptPath:'c:/script/bin',
            cmdScriptPath: '/usr/local/nginx/bin',
            uploadAfterCmd: 'sh deploy-after.sh',
            uploadBeforeCmd: 'sh deploy-before.sh'
        },
        {
            host: 'xxx.xxx.xxx.xxx',
            username: 'nginx',
            password: 'xxx',
            uploadPath: '/nginx/webapp/test/dist.zip',
        }
    ],
   	compress:{
        outPath: path.join(__dirname, '../static'),
        srcPath: path.join(__dirname, '../dist')
    },
    serverOptions:{
        uploadPath: '',
        localCmdScriptPath:'',
        cmdScriptPath: '',
        uploadBeforeCmd: '',
        uploadAfterCmd: '',
    }
},{
    stdout: false,
});

// 第二种 只有一台服务器需要发布应用
new CompressUploadPlugin({
  server: {
    host: 'xxx.xxx.xxx.xxx',
    username: 'xxx',
    password: 'xxx',
    uploadPath: '/usr/local/nginx/webapp/dist.zip',
    localCmdScriptPath: path.join(__dirname, '../bin'),
    cmdScriptPath: '/usr/local/nginx/bin/',
    uploadAfterCmd: 'sh deploy-after.sh',
    uploadBeforeCmd: 'sh deploy-before.sh'
  },
  compress: {
    filename: 'dist.zip',
    outPath: path.join(__dirname, '../target'),
    srcPath: path.join(__dirname, '../target/resources/home/static')
  }
}, {
  stdout: true,
  showConfigInfo: true
});

参数说明

CompressUploadPlugin({server,serverList,serverOptions,zip},options)

serverList

本质是集合,[{server},{server},{server}...]

server

| Name | Type | Default | Description | | -------------------- | -------- | ------------------------ | -------------------------------- | | host | string | | 主机名 | | `username` | `string` | `当前项目根节点下的dist` | 用户名 | | `password` | `string` | | 密码 | | port | number | 22 | sftp 端口 | | uploadPath | string | | 文件上传路径 | | `localCmdScriptPath` | `string` | | 本地脚本路径 | | cmdScriptPath | string | | 脚本执行路径 | | `uploadBeforeCmd` | `string` | | 文件上传成功前需要执行的脚本命令 | | uploadAfterCmd | string | `` | 文件上传成功后需要执行的脚本命令 |

serverOptions

| Name | Type | Default | Description | | ----------------- | -------- | ------------------------ | -------------------------------- | | uploadPath | string | | 文件上传路径 | | `localCmdScriptPath` | `string` | | 本地脚本路径 | | cmdScriptPath | string | | 脚本执行路径 | | `uploadBeforeCmd` | `string` | | 文件上传成功前需要执行的脚本命令 | | uploadAfterCmd | string | `` | 文件上传成功后需要执行的脚本命令 |

compress

| Name | Type | Default | Description | | ------------ | -------- | -------------------------- | ---------------- | | format | string | zip,tar,json | 压缩格式,不建议使用 json | | outPath | string | 当前项目根节点下的static | 压缩文件输出目录 | | srcPath | string | 当前项目根节点下的dist | 需要压缩的目录 | | filename | string | dist.zip | 压缩的文件名 |

options

| Name | Type | Default | Description | | ------ | --------- | ------- | ----------------------- | | stdout | boolean | false | 是否输出shell的输出信息 | | showConfigInfo | boolean | false | 是否输出插件的配置信息 |

这里提供一个Linux脚本案列

deploy-before.sh

cd /nginx/webapp/public
if [ ! -f "/nginx/webapp/public/dist.zip" ];then
echo "dist.zip文件不存在"
else
mv dist.zip dist_backups.zip
fi

deploy-after.sh

#!/bin/bash
cd /nginx/webapp/public
# 删除原静态资源目录
rm -rf dist
# 解压新的包
unzip dist.zip
ls -l

1578561182884

NOTE

1. 在打包的时候,请将指定的 `zipName` 排除用 `CopyWebpackPlugin` 排除在外,以避免不必要的性能开销
2. 请确保服务器和本地对应的目录存在