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

@sea_cui/upload-dist-to-server

v1.0.2

Published

上传dist文件到服务器

Downloads

2

Readme

简介

upload-dist-to-server 可以将打包后的文件快速的部署至您的服务器,支持作为vite插件或单独使用.

安装

yarn add @sea_cui/upload-dist-to-server -D

npm install @sea_cui/upload-dist-to-server -D

使用

单服务器部署

import upload from "@sea_cui/upload-dist-to-server";
//const upload = require("@sea_cui/upload-dist-to-server");

upload({
  host: "location",
  username: "root",
  password: "password",
  path: "/root"
});

多服务器多选一部署

import upload from "@sea_cui/upload-dist-to-server";
//const upload = require("@sea_cui/upload-dist-to-server");

upload([
  {
    host: "location",
    username: "root",
    password: "password",
    path: "/root",
    serverName: "测试服务器"
  },
  {
    host: "location",
    username: "root",
    password: "password",
    path: "/root",
    serverName: "正式服务器"
  }
]);

vite 作为插件使用

upload.vitejs(options);

单独使用

  • 项目根目录新建 upload.js
const upload = require("@sea_cui/upload-dist-to-server");

upload({
  host: "location",
  username: "root",
  password: "password",
  path: "/root"
});
  • 修改 package.json 中的 scripts=>build

  • 字段后面加上 && node upload.js 比如 "build": "vite build" => "build": "vite build && node upload.js"

  • 正常执行 yarn build 即可

参数

  • host: 服务器地址(必填)
  • username: 服务器登录用户名,默认为 root
  • password: 服务器登录密码(必填)
  • port: 服务器端口号,默认为 22
  • path: 服务器部署地址(必填)
  • website: 预览地址,如果有此选项地址,上传成功后,会默认使用谷歌打开此地址
  • deleteAll: 是否删除服务器目录下所有文件
  • filterList: 删除服务器文件时过滤的文件,如果文件在 filterList 内,则不会删除,deleteAll=true 时才会触发
  • folder: 上传的文件夹,默认为 dist

注意

  • 上传即删除做了比较多的校验,基本上可以不用担心误删.
    • 服务器账号密码必须正确
    • 校验项目部署路径 确保真实存在
    • 校验项目部署路径 下面必须存在 index.html
    • 校验本地 dist 文件是否存在
    • 删除文件时 会读取本地 dist 文件列表 保证不会删除多余的文件(deleteAll=true 情况下不会)
  • 尽量不推荐使用 deleteAll,deleteAll 可以和 filterList 配合减少删除多余的文件
  • 如果需要上传完执行某件事件,可以使用异步来搞定,文件上传成功后才会异步返回