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

@cjs-front-end/quickupdate

v0.0.21

Published

## 简介

Downloads

5

Readme

轻量级更新脚本

简介

通过简单的配置,就可以一行命令将当前项目打包到服务端完成前端项目的更新,适用于个人项目

避免本地打包,再 🔗ssh 等后面一系列的繁琐操作,大幅提高更新效率

使用教程

  1. 全局安装依赖
npm i quickupdate -g
  1. 通过“qupConfig”在本机上,根据提示配置上传信息
/**
 * 更新配置
 */
{
"name":"测试后台3", // 当前所有更新项目的名称
"buildPath":"/dist", // 你的项目打包路径例如 /dist
"buildRunPath": '', // 你运行打包命令的地址
"buildCmd":"npm run build", //  打包命令
"host":"0.0.0.0", // 填写服务器地址
"port":"22", // 端口号
"username":"root", // 服务器用户名
"password": "123456", // 服务器密码
"uploadDir":"/www/wwwroot/http",  // 在服务器的文件存放路径,例如填写的
"fileName":"admin",// 更新项目到服务器的文件名称
"backupName":"back_admin"// 更新项目到服务器的备份文件名称
}
  1. 开始第一次命令更新

假设你的项目在服务器中的路径为 /usr/share/nginx/admin,配置文件 uploadDir 填写为/usr/share/nginx,则更新命令为

qup

之后将会出现询问

您正在将代码更新到服务器,回车将会继续执行

按回车即可,之后变回执行打包 发送到服务器的脚本,结束后将会看到

总共 x.xx MB,完成源代码压缩
程序zip上传成功,判断线上是否需要备份
当前无需备份,直接解压上传压缩包
项目包完成解压,admin项目部署成功了!
项目更新时长12.663s
本地缓存zip清除完毕
线上项目.DS_Store删除完成

如果看到这个就恭喜您更新成功了,完成了一行命令将本地代码打包到服务器

注意!

  • 不要忘记将写入敏感信息的文件update.config.js加入.gitignore,否则你的敏感信息将会被上传到代码库中!!

  • 如果发现上传到服务端的 zip 文件没有没解压,请前往服务器中测试 unzip 命令是否存在(输入 unzip 然后回车),如果提示unzip: command not found,就执行命令进行安装yum install -y unzip zip

高阶操作

限制更新名称

命令中最后附带的更新名称将会被传回你的配置函数,所以可以在函数中可以进行逻辑校验

let whiteList = ['dist']
/**
 * 更新配置
 * @param {String} objName 当前更新名称
 * @returns
 */
module.exports = (objName) => {
  if (!whiteList.includes(objName)) {
    console.log('当前项目不存在您输入的更新命令,请检查更新名称')
    process.exit(0)
  }
  return {
    // ....
  }
}

多环境部署

假设您的前端项目存在多个环境 你希望可以通过命令备份正式环境代码,其他环境忽略,这可以启用参数 backObject

let whiteList = ['dist', 'dist-pre']
/**
 * 更新配置
 * @param {String} objName 当前更新名称
 * @returns
 */
module.exports = (objName) => {
  if (!whiteList.includes(objName)) {
    console.log('当前项目不存在您输入的更新命令,请检查更新名称')
    process.exit(0)
  }
  return {
    // ....
    backObject: 'dist',
  }
}

祝你开发愉快!