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

dnk-deploy-cli

v1.0.10

Published

自动化部署脚手架

Downloads

98

Readme

dnk-deploy-cli

一键自动化部署脚手架服务,支持开发、测试、生产多环境配置。配置好后一键即可自动完成部署。

npm

https://www.npmjs.com/package/dnk-deploy-cli

1 安装

全局安装 dnk-deploy-cli

npm install dnk-deploy-cli -g

本地安装 dnk-deploy-cli

npm install dnk-deploy-cli --save-dev

查看版本,表示安装成功

dnk-deploy-cli - v;

注:本地安装的需要在调用前加 npx

npx dnk-deploy-cli -v

初始化

dnk-deploy-cli init

2 使用(以下代码都以全局安装为例)

2.1 查看帮助

dnk-deploy-cli -h

2.2 初始化配置文件(在项目目录下)

dnk-deploy-cli init # 或者使用简写 dnk-deploy-cli i

根据提示填写内容,会在项目根目录下生成 deploy.config.js 文件,初始化配置只会生成 dev (开发环境)、test (测试环境)、prod (生产环境) 三个配置,再有其他配置可参考模板自行配置。

2.3 手动创建或修改配置文件

在项目根目录下手动创建 deploy.config.js 文件,复制以下代码按情况修改即可。

module.exports = {
  projectName: "vue_samples", // 项目名称
  privateKey: "/Users/fuchengwei/.ssh/id_rsa",
  passphrase: "",
  readyTimeout: 20000, // 超时时间(毫秒)
  cluster: [], // 集群部署配置,要同时部署多台配置此属性如: ['dev', 'test', 'prod']
  dev: {
    // 环境对象
    name: "开发环境", // 环境名称
    script: "npm run build", // 打包命令
    host: "192.168.0.1", // 服务器地址
    port: 22, // 服务器端口号
    username: "root", // 服务器登录用户名
    password: "123456", // 服务器登录密码
    distPath: "dist", // 本地打包生成目录
    webDir: "/usr/local/nginx/html", // 服务器部署路径(不可为空或'/')
    bakDir: "/usr/local/nginx/backup", // 备份路径
    isRemoveRemoteFile: true, // 是否删除远程文件(默认true)
    isRemoveLocalFile: true, // 是否删除本地文件(默认true)
  },
  test: {
    // 环境对象
    name: "测试环境", // 环境名称
    script: "npm run build:test", // 打包命令
    host: "192.168.0.1", // 服务器地址
    port: 22, // 服务器端口号
    username: "root", // 服务器登录用户名
    password: "123456", // 服务器登录密码
    distPath: "dist", // 本地打包生成目录
    webDir: "/usr/local/nginx/html", // 服务器部署路径(不可为空或'/')
    bakDir: "/usr/local/nginx/backup", // 备份路径
    isRemoveRemoteFile: true, // 是否删除远程文件(默认true)
    isRemoveLocalFile: true, // 是否删除本地文件(默认true)
  },
  prod: {
    // 环境对象
    name: "生产环境", // 环境名称
    script: "npm run build:prod", // 打包命令
    host: "192.168.0.1", // 服务器地址
    port: 22, // 服务器端口号
    username: "root", // 服务器登录用户名
    password: "123456", // 服务器登录密码
    distPath: "dist", // 本地打包生成目录
    webDir: "/usr/local/nginx/html", // 服务器部署路径(不可为空或'/')
    bakDir: "/usr/local/nginx/backup", // 备份路径
    isRemoveRemoteFile: true, // 是否删除远程文件(默认true)
    isRemoveLocalFile: true, // 是否删除本地文件(默认true)
  },
};

2.4 部署 (在项目目录下)

注意:命令后面需要加 --mode 环境对象 (如:--mode dev

dnk-deploy-cli deploy --mode dev # 或者使用 dnk-deploy-cli d --mode dev

输入 Y 确认后即可开始自动部署

2.5 集群部署 (在项目目录下)

注意:集群配置需要在 dnk-deploy-cli 中 配置 cluster 字段 (如:cluster: ['dev', 'test', 'prod']

dnk-deploy-cli deploy # 或者使用 dnk-deploy-cli d

输入 Y 确认后即可开始自动部署

2.6 更新优化

如果不想把服务器密码保存在配置文件中,也可以在配置文件中删除 password 字段。在部署的时候会弹出输入密码界面。

如果不想在部署前执行打包命令,在配置文件中删除 script 字段即可。

如果需要部署前备份,在配置文件中配置 bakDir 字段,为空不会备份。ps: 服务器需要安装 zip 模块,可使用 yum install zip 命令。

2.7 本地安装扩展

如果使用本地安装命令的话,可以在项目根目录下的 package.json 文件中 scripts 脚本中添加如下代码

"scripts": {
  "deploy": "dnk-deploy-cli deploy",
  "deploy:dev": "dnk-deploy-cli deploy --mode dev",
  "deploy:test": "dnk-deploy-cli deploy --mode test",
  "deploy:prod": "dnk-deploy-cli deploy --mode prod"
}

然后使用下面代码也可以完成部署操作

npm run deploy:dev