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

@xccjh/rt

v1.0.0

Published

工具库,包含oss文件操作,本地文件操作

Downloads

4

Readme

前言

工具库,包含oss文件操作,本地文件操作

特性

  1. oss-upload oss上传资源
  2. oss-list oss获取资源列表
  3. oss-delete oss删除资源
  4. oss-download oss下载资源
  5. local-list 本地获取资源列表
  6. local-create 本地创建资源
  7. local-delete 本地删除资源

安装

$ yarn add @xccjh/resource-opt

配置oss & fs操作

const { ResourceOptManager } = require('@xccjh/resource-opt')

const options = {
  uploadDir: true,
  uploadFullPathFile: false,
  listType: 'all',
  region: '',
  endpoint: 'oss-cn-hongkong.aliyuncs.com',
  accessKeyId: 'LTAI5tGCjmVjvPDPooTKeU12',
  accessKeySecret: 'ddI0TfZUZel24E87YXKJVz91sn9ZFZ',
  localSourceFilter: (item) => {
    return item.path.indexOf('.js.map') !== -1
  }
}

new ResourceOptManager(options).init()

option汇总

  /**
  * 配置本地操作目标资源过滤器
  * @param item
  * @returns {boolean}
  */
  localSourceFilter = (item) => { return true }
  /**
  * 配置远程操作目标资源过滤器
  * @param item
  * @returns {boolean}
  */
  remoteSourceFilter = (item) => { return true }
  /**
   * 操作类型
   * @type {'oss-list' | 'oss-upload' | 'oss-delete' | 'oss-download' | 'local-list' | 'local-create' | 'local-delete''}
   */
  opterateType = 'oss-list'
  /**
   * 是否以全路径上传
   * @type {boolean}
   */
  uploadFullPathFile = false
  /**
   * 是否上传目录
   * @type {boolean}
   */
  uploadDir = false
  /**
   * 过滤类型
   * @type {'all' | 'file' | 'dir'}
   */
  listType = 'all'

/**
 * 本地操作地址
 * @type {string}
 */
  remoteResourcePath = ''
/**
 * 远程操作地址
 * @type {string}
 */
  localResourcePath = ''
  /**
   * 批量上传单批文件个数
   * @type {number}
   */
  batchNumber = 200
  ossBucket
  endpoint = ''
  region = 'oss-cn-shanghai'
  accessKeyId = 'LTAI5tCzqLRdAhWtvinM7HF8'
  accessKeySecret = 'Q5WJpvQtNE90O4IdgGcg0udysELuqB'

通用资源cli操作

// $ yarn add @xccjh/resource-opt -g
/**
* 通用资源操作
* @description
* resource-opt <operateType : oss-upload | oss-list | oss-delete | oss-download | local-list | local-create> [Bucket] [remotepath] [localpath] 
* @example ‘’‘md
* 用法示例(分批,深度递归,支持文件,文件夹,./,.等,没有的目录和文件自动处理):
* - 删除远程文件夹bb下所有: resource-opt oss-delete xccjhzjh bb 
* - 删除远程根目录所有下所有: resource-opt oss-delete xccjhzjh .
* - 删除远程根目录所有下所有: resource-opt oss-delete xccjhzjh ./
* - 删除远程根目录所有下所有: resource-opt oss-delete xccjhzjh /
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh bb 
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh ./bb 
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh /bb 
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh bb/ 
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh ./bb/ 
* - 查看远程文件夹bb下所有: resource-opt oss-list xccjhzjh /bb/ 
* - 上传本地cc文件夹所有到远程文件夹bb: resource-opt oss-upload xccjhzjh bb cc 
* - 上传本地cc文件夹所有到远程文件夹bb: resource-opt oss-upload xccjhzjh bb ./cc
* - 上传本地bb文件夹所有到远程根目录: resource-opt oss-upload xccjhzjh . bb
* - 上传本地bb文件夹所有到远程根目录: resource-opt oss-upload xccjhzjh ./ bb
* - 下载远程bb文件夹所有到本地文件夹cc: resource-opt oss-download xccjhzjh bb cc 
* - 下载远程aa文件夹所有到本地文件夹根目录: resource-opt oss-download xccjhzjh aa ./
* - 下载远程aa文件夹所有到本地文件夹根目录: resource-opt oss-download xccjhzjh aa .
* - 创建本地aa/aa/bb/c: resource-opt local-create aa/aa/bb/c
* - 查看本地aa/aa/bb/c文件列表: resource-opt local-list aa/aa/bb/c
* - 删除本地aa/aa/bb/c: resource-opt local-delete aa/aa/bb/c
* ’‘’
*/

That's all