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

@yolanda-qn/qiniu-upload-cli

v1.1.2

Published

上传项目文件到七牛云

Downloads

14

Readme

@yolanda-qn/qiniu-upload-cli

上传项目文件到七牛云

Usage

yarn add @yolanda-qn/qiniu-upload-cli -D

命令

Usage: @yolanda-qn/qiniu-upload-cli <command> [options]

命令:
  index.js init    在当前目录初始化一个qiniuupload.config.js
  index.js upload  上传文件 输入 upload --help 查看帮助信息

选项:
  --version  显示版本号                                                   [布尔]
  --help     显示帮助信息                                                 [布尔]
# 在package.json中添加如下命令
{
  "scripts": {
    "upload": "qiniu-upload-cli upload",
    "upload:init": "qiniu-upload-cli init"
  }
}

init

在当前目录下初始化一个 qiniuupload.config.js

yarn upload:init

upload

上传文件到七牛云

$ node dist/lib/index.js upload --help
index.js upload

上传文件 输入 upload --help 查看帮助信息

选项:
      --version                 显示版本号                                [布尔]
      --help                    显示帮助信息                              [布尔]
  -A, --accessKey               七牛云的ACCESS_KEY                      [字符串]
  -S, --secretKey               七牛云的SECRET_KEY                      [字符串]
  -B, --bucket                  要上传的存储空间                        [字符串]
  -Z, --zone                    区域服务器。可选:华东 | 华北 | 华南 | 北美
                                                                        [字符串]
  -K, --key                     文件名。可使用 $(key)指代原文件名。例如:docs/$(
                                key)。不能使用反斜杠 \ 等字符。         [字符串]
  -D, --domain                  服务器域名                              [字符串]
      --files                   目标文件。支持glob路径。使用,隔开多个路径
                                                                        [字符串]
      --baseUrl                 基路径                                  [字符串]
      --isRefreshCDN            是否需要刷新 CDN           [布尔] [默认值: true]
      --refreshCDNFilesPattern  对指定文件刷新CDN。默认 html 文件。使用 glob
                                路径匹配          [字符串] [默认值: "**/*.html"]
  -V, --verbose                 显示详细信息                              [布尔]
      --coverFileIfExist        是否覆盖已存在的文件                      [布尔]
      --interactive             是否与命令行进行确认交互                  [布尔]
      --autoRetry               是否自动重发失败的文件     [布尔] [默认值: true]
      --retryTimes              重新尝试次数                  [数字] [默认值: 3]
  -C, --config                  配置文件。默认为当前目录下的
                                qiniuupload.config.js                   [字符串]
      --prompt                  上传提示。提醒开发人员上传时注意环境配置。例如:
                                当前环境为正式服务器地址,确认执行此操作[字符串]
      --validatePkgVersion      会提示输入当前项目package.json中的version字段,
                                并校验                    [布尔] [默认值: false]
                                                                        
yarn upload

在代码中使用

import { QiniuUploader } from '@yolanda-qn/qiniu-upload-cli/lib/QiniuUploader';

const uploader = new QiniuUploader(/* ProjectUploadConfig */{
  accessKey: 'XXX',
  secretKey: 'XXX',
  bucket: 'XXX',
  zone: '华南',
  key: 'docs/$(key)',
  domain: 'https://xxxx.com',
  files: 'dist/**',
  baseUrl: 'dist',
  isRefreshCDN: true,
  coverFileIfExist: true,
});

uploader.uploadFiles().finally(() => {
  console.log('成功的文件', uploader.succeedFilesPool);
  console.log('失败的文件', uploader.failedFilesPool);
});

UploadConfig

export interface ProjectUploadConfig {
  /**
   * ACCESS_KEY
   */
  accessKey: string;
  /**
   * SECRET_KEY
   */
  secretKey: string;
  /**
   * 要上传的空间
   */
  bucket: string;
  /**
   * 区域
   */
  zone: '华东' | '华北' | '华南' | '北美';
  /**
   * 文件名。可使用 $(key)指代原文件名
   *
   * 我们可以这样添加前缀 `docs/$(key)`
   */
  key: string | ((key: string) => string);
  /**
   * 服务器域名
   */
  domain: string;
  /**
   * 目标文件。支持glob路径。可用,隔开多个路径
   */
  files: string[] | string;
  /**
   * 基路径
   *
   * 例如 files: ['dist/**'],dist目录下有index.html,如果没有配置baseUrl,那么文件的key默认为dist/index.html
   *
   * 如果baseUrl设置为 dist,那么dist/index.html的key默认为相对地址 index.html
   */
  baseUrl: string;
  /**
   * 是否需要刷新 cdn,新添加的文件就不需要开启,以免浪费资源
   */
  isRefreshCDN: boolean;
  /**
   * 对指定文件刷新CDN。默认 html 文件。使用 glob 路径匹配。
   */
  refreshCDNFilesPattern: string;
  /**
   * 额外的七牛云配置
   */
  qiniuConfig?: Qiniu.conf.ConfigOptions;
  /**
   * 是否显示详细信息
   */
  verbose?: boolean;
  /**
   * 是否覆盖已存在的文件
   */
  coverFileIfExist?: boolean;
  /**
   * 是否与命令行进行确认交互
   */
  interactive?: boolean;
  /**
   * 是否自动重发失败的文件
   */
  autoRetry?: boolean;
  /**
   * 重新尝试次数
   */
  retryTimes?: number;
  /**
   * 上传提示。提醒开发人员上传时注意环境配置
   * @since 1.1.1
   */
  prompt?: string;
  /**
   * 会提示输入当前项目package.json中的version字段,并校验
   * @since 1.1.2
   */
  validatePkgVersion?: boolean;
}