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

@liuyinlin/upload-server

v1.0.12

Published

上传本地文件夹到 Linux 服务器

Downloads

5

Readme

上传本地文件到 Linux 服务器

使用场景:将打包的产物上传到部署服务器

安装

npm i @liuyinlin/upload-server -g

安装完成后,会提供 upload [command] [options] 命令

配置文件

生成配置文件

在当前目录下生成 upload-server.config.mjs 文件

upload init

支持以下配置文件的文件名

  • upload-server.config.json
  • upload-server.config.js
  • upload-server.config.ts
  • upload-server.config.mjs
  • upload-server.config.cjs

配置文件选项

export declare type Config = {
    /**
     * 服务器 ip
     */
    host: string;
    /**
     * 端口
     * @default 22
     */
    port?: number;
    /**
     * 用户名
     * @default 'root'
     */
    username?: string;
    /**
     * 密码
     */
    password: string;
    /**
     * 上传到服务器的路径
     */
    serverPath: string;
    /**
     * 本地目录
     * @default 'dist'
     */
    localDir?: string;
    /**
     * 上传成功后是否删除本地文件
     * @default true
     */
    deleteLocalFile?: boolean;
    /**
     * 在删除服务器文件前,是否需要确认文件路径,如果为 `false` 则不会提示
     * @default true
     */
    confirmServerFilePath?: boolean;
};

上传文件

在上传文件之前,会先删除服务器的文件,命令行会提示你是否要删除,选择 y 即可,若发现文件路径不正确,选择 n 即可取消删除,也会取消上传

upload [-m, --mode mode]
  • -m, --mode:指定 .env 的 mode

    例如:upload -m dev 将会读取 .env.dev.env 文件,前者会覆盖后者同名属性

配置文件使用环境变量

执行 upload 会默认读取 .env 文件(如果存在)

# .env
SERVER_USERNAME=root
SERVER_PASSWORD=123456

使用环境变量替换,语法 %ENV_NAME%

/**
 * @type {import('@liuyinlin/upload-server').Config}
 */
export default {
    host: '127.0.0.1',
    port: 22,
    username: '%SERVER_USERNAME%',
    password: '%SERVER_PASSWORD%',
    serverPath: '/usr/local/nginx/html/dist',
    localDir: 'dist',
    deleteLocalFile: true
};

如果你的配置文件是 js,也可以直接使用 process.env 来读取环境变量

/**
 * @type {import('@liuyinlin/upload-server').Config}
 */
export default {
    host: '127.0.0.1',
    port: 22,
    username: process.env.SERVER_USERNAME,
    password: process.env.SERVER_PASSWORD',
    serverPath: '/usr/local/nginx/html/dist',
    localDir: 'dist',
    deleteLocalFile: true
}