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

@94ai/rt-core

v1.1.5

Published

fs、oss资源互通core包

Downloads

8

Readme

前言

资源操控工具库core包,实现oss资源操作,本地资源操作,oss资源和本地资源互通。官网地址:http://oss.xccjh.top/rt-cli/

项目特点:ts+commander

阿里sdk和node的api都只支持一级

本工具扩展【递归级联】和各种路径写法兼容【如.,./,/绝对&相对】以及【文件过滤和拍平】,如oss资源和本地资源 指定操作【list/download/upload/del/create】指定目录【路径】指定资源匹配【正则/钩子/后缀】和指定资源类型【dir/file/all】)指定拍平目录【级联移动或拍平】资源互通

安装

$ yarn add @xccjh/rt-core

目前主要功能

  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 本地指定删除资源

后面考虑增加 local-copy local-cut oss-copy oss-cut oss-rename等

配置

类型

  type ResourceType = 'all' | 'file' | 'dir'
  type SourceFilter = (param: ResourceItem)=> boolean | string | RegExp
  type ResourceItem = {
    name?: string,
    path: string
  }
  type ResourceOptOptions = {   // 👈 这个就是所有配置
    opterateType: OpterateType, // 操作类型
    
    remoteResourcePath: string, // 本地操作地址
    localResourcePath: string, // 远程操作地址
    
    accessKeyId: string,
    accessKeySecret: string,
    region: string,
    endpoint: string,
    ossBucket: string,
    
    uploadFullPathFile: boolean, // 是否以全路径上传
    uploadDir: boolean, // 是否上传目录
    batchNumber: number, // 批量上传单批文件个数
    
    listType: ListType, // 远程操作过滤类型

    downloadKeepRemoteDirectory: boolean, // 是否保留远程目录下载
    
    localSourceFilter: SourceFilter, // 配置本地操作目标资源过滤器
    remoteSourceFilter: SourceFilter // 配置远程操作目标资源过滤器
  }

默认值

 /**
 * 操作类型
 * @type {'oss-list' | 'oss-upload' | 'oss-delete' | 'oss-download' | 'local-list' | 'local-create' | 'local-delete''}
 */
opterateType = 'oss-list'

/**
 * 本地操作地址
 * @type {string}
 */
remoteResourcePath = ''
/**
 * 远程操作地址
 * @type {string}
 */
localResourcePath = ''
/**
 * OSS相关
 * @type {string}
 */
accessKeyId = 'LTAI5tCzqLRdAhWtvinM7HF8'
accessKeySecret = 'Q5WJpvQtNE90O4IdgGcg0udysELuqB'
region = 'oss-cn-shanghai'
endpoint = ''
ossBucket
/**
 * 是否以全路径上传
 * @type {boolean}
 */
uploadFullPathFile = false
/**
 * 是否上传目录
 * @type {boolean}
 */
uploadDir = false
/**
 * 批量上传单批文件个数
 * @type {number}
 */
batchNumber = 200
/**
 * 过滤类型
 * @type {'all' | 'file' | 'dir'}
 */
listType = 'all'
/**
 * 是否保留远程目录下载
 * @private
 */
downloadKeepRemoteDirectory = false
/**
 * 配置本地操作目标资源过滤器
 * @param {ResourceItem} item
 * @returns {boolean}
 */
 localSourceFilter = (item: ResourceItem) => { return true }
 /**
 * 配置远程操作目标资源过滤器
 * @param {ResourceItem} item
 * @returns {boolean}
 */
 remoteSourceFilter = (item: ResourceItem) => { return true }

在项目中使用

// upload.js
const { ResourceOptManager } = require('@xccjh/rt-core') // 或者 import { ResourceOptManager } from '@xccjh/rt-core'
// 上传本地sourceMap
const options: Partial<ResourceOptOptions> = {
  opterateType: 'oss-upload',
  localResourcePath: 'test', // process.cwd()中test文件夹
  remoteResourcePath: 'test', // oss名字为xccjhback的bucket根下的test文件夹(object)
  localSourceFilter: (item) => {
    return item.path.indexOf('.js.map') !== -1 // 过滤只操作.js.map文件
  },
  region: '',
  endpoint: 'oss-cn-hongkong.aliyuncs.com',
  accessKeyId: 'LTAI5tGCjmVjvPDPooTKeU12',
  accessKeySecret: 'ddI0TfZUZel24E87YXKJVz91sn9ZFZ',
  ossBucket: 'xccjhback'
}
new ResourceOptManager(options).init()

// $ node upload.js 👈
// 上传目录:D:\resource-opt\test
// 第1波上传
// 开始上传本地文件
// 成功上传文件:D:\resource-opt\test\test.js.map 到远程地址: test/test.js.map

That's all