{"_id":"@94ai/rt-core","_rev":"2-a970714f5c1b51caa3a4ee0a55f4057e","name":"@94ai/rt-core","dist-tags":{"latest":"1.1.5"},"versions":{"1.1.5":{"name":"@94ai/rt-core","version":"1.1.5","description":"fs、oss资源互通core包","main":"lib/rt.esm-bundler.min.mjs","module":"lib/rt.esm-bundler.min.mjs","types":"lib/index.d.ts","scripts":{"core":"cross-env TARGET=CORE rollup -c --watch","test":"echo \"Error: no test specified\" && exit 1"},"keywords":["fs、oss"],"dependencies":{"@types/ali-oss":"^6.16.7","ali-oss":"^6.17.1"},"repository":{"type":"git","url":"https://gitee.com/xccjh/resource-opt"},"publishConfig":{"access":"public"},"homepage":"http://oss.xccjh.top/rt-cli/","peerDependencies":{"@types/ali-oss":"^6.16.7","ali-oss":"6.15.2"},"author":{"name":"xccjh"},"license":"ISC","babel":{"presets":[["@babel/env",{"modules":false}]],"plugins":[["@babel/plugin-transform-runtime",{"corejs":{"version":3,"proposals":true},"useESModules":true}]]},"gitHead":"456cece42e45536ce90b628cf803484fb0babd34","_id":"@94ai/rt-core@1.1.5","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-ugTVbe99CaH7Y/r2Zd0SeyXqrA6nfZBMK0EQdEWpXwhK9CkMG8bhJ7fiQNF1V3eiUpHk/ZybsL9brdkn9tGJVQ==","shasum":"c0a570d7f63490dcd0610e2edb62e50842301593","tarball":"https://registry.npmjs.org/@94ai/rt-core/-/rt-core-1.1.5.tgz","fileCount":15,"unpackedSize":213161,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbXran4s5XSbYfQurW27hSmKl4nZz5N4qsY6q53AqQVQIhAIAZajmHYp0+a2KsOOGM01G3CKN1OfpTW8GInw+frsop"}]},"_npmUser":{"name":"94ai","email":"zjh15018707394@gmail.com"},"directories":{},"maintainers":[{"name":"94ai","email":"zjh15018707394@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rt-core_1.1.5_1690179259218_0.9161861350681408"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-24T06:14:19.094Z","1.1.5":"2023-07-24T06:14:19.393Z","modified":"2024-05-24T09:11:31.471Z"},"maintainers":[{"email":"liuxiangxiang1992@gmail.com","name":"louislxx"},{"email":"zjh15018707394@gmail.com","name":"nfai"}],"description":"fs、oss资源互通core包","homepage":"http://oss.xccjh.top/rt-cli/","keywords":["fs、oss"],"repository":{"type":"git","url":"https://gitee.com/xccjh/resource-opt"},"author":{"name":"xccjh"},"license":"ISC","readme":"## 前言\r\n\r\n资源操控工具库core包，实现oss资源操作，本地资源操作，oss资源和本地资源互通。官网地址：http://oss.xccjh.top/rt-cli/\r\n\r\n项目特点：ts+commander\r\n\r\n> 阿里sdk和node的api都只支持一级\r\n>\r\n> 本工具扩展【递归级联】和各种路径写法兼容【如.,./,/绝对&相对】以及【文件过滤和拍平】，如oss资源和本地资源 指定操作【list/download/upload/del/create】指定目录【路径】指定资源匹配【正则/钩子/后缀】和指定资源类型【dir/file/all】)指定拍平目录【级联移动或拍平】资源互通\r\n\r\n## 安装\r\n```shell\r\n$ yarn add @xccjh/rt-core\r\n```\r\n\r\n## 目前主要功能\r\n1. oss-upload   指定本地资源上传oss\r\n2. oss-list     oss指定获取资源列表\r\n3. oss-delete   oss删除指定资源\r\n4. oss-download oss下载指定资源\r\n5. local-list   本地获取指定资源列表\r\n6. local-create 本地创建指定资源\r\n7. local-delete 本地指定删除资源\r\n\r\n后面考虑增加 local-copy local-cut oss-copy oss-cut oss-rename等\r\n\r\n## 配置\r\n### 类型\r\n```ts\r\n  type ResourceType = 'all' | 'file' | 'dir'\r\n  type SourceFilter = (param: ResourceItem)=> boolean | string | RegExp\r\n  type ResourceItem = {\r\n    name?: string,\r\n    path: string\r\n  }\r\n  type ResourceOptOptions = {   // 👈 这个就是所有配置\r\n    opterateType: OpterateType, // 操作类型\r\n    \r\n    remoteResourcePath: string, // 本地操作地址\r\n    localResourcePath: string, // 远程操作地址\r\n    \r\n    accessKeyId: string,\r\n    accessKeySecret: string,\r\n    region: string,\r\n    endpoint: string,\r\n    ossBucket: string,\r\n    \r\n    uploadFullPathFile: boolean, // 是否以全路径上传\r\n    uploadDir: boolean, // 是否上传目录\r\n    batchNumber: number, // 批量上传单批文件个数\r\n    \r\n    listType: ListType, // 远程操作过滤类型\r\n\r\n    downloadKeepRemoteDirectory: boolean, // 是否保留远程目录下载\r\n    \r\n    localSourceFilter: SourceFilter, // 配置本地操作目标资源过滤器\r\n    remoteSourceFilter: SourceFilter // 配置远程操作目标资源过滤器\r\n  }\r\n```\r\n### 默认值\r\n```js\r\n /**\r\n * 操作类型\r\n * @type {'oss-list' | 'oss-upload' | 'oss-delete' | 'oss-download' | 'local-list' | 'local-create' | 'local-delete''}\r\n */\r\nopterateType = 'oss-list'\r\n\r\n/**\r\n * 本地操作地址\r\n * @type {string}\r\n */\r\nremoteResourcePath = ''\r\n/**\r\n * 远程操作地址\r\n * @type {string}\r\n */\r\nlocalResourcePath = ''\r\n/**\r\n * OSS相关\r\n * @type {string}\r\n */\r\naccessKeyId = 'LTAI5tCzqLRdAhWtvinM7HF8'\r\naccessKeySecret = 'Q5WJpvQtNE90O4IdgGcg0udysELuqB'\r\nregion = 'oss-cn-shanghai'\r\nendpoint = ''\r\nossBucket\r\n/**\r\n * 是否以全路径上传\r\n * @type {boolean}\r\n */\r\nuploadFullPathFile = false\r\n/**\r\n * 是否上传目录\r\n * @type {boolean}\r\n */\r\nuploadDir = false\r\n/**\r\n * 批量上传单批文件个数\r\n * @type {number}\r\n */\r\nbatchNumber = 200\r\n/**\r\n * 过滤类型\r\n * @type {'all' | 'file' | 'dir'}\r\n */\r\nlistType = 'all'\r\n/**\r\n * 是否保留远程目录下载\r\n * @private\r\n */\r\ndownloadKeepRemoteDirectory = false\r\n/**\r\n * 配置本地操作目标资源过滤器\r\n * @param {ResourceItem} item\r\n * @returns {boolean}\r\n */\r\n localSourceFilter = (item: ResourceItem) => { return true }\r\n /**\r\n * 配置远程操作目标资源过滤器\r\n * @param {ResourceItem} item\r\n * @returns {boolean}\r\n */\r\n remoteSourceFilter = (item: ResourceItem) => { return true }\r\n```\r\n\r\n## 在项目中使用\r\n```ts\r\n// upload.js\r\nconst { ResourceOptManager } = require('@xccjh/rt-core') // 或者 import { ResourceOptManager } from '@xccjh/rt-core'\r\n// 上传本地sourceMap\r\nconst options: Partial<ResourceOptOptions> = {\r\n  opterateType: 'oss-upload',\r\n  localResourcePath: 'test', // process.cwd()中test文件夹\r\n  remoteResourcePath: 'test', // oss名字为xccjhback的bucket根下的test文件夹（object）\r\n  localSourceFilter: (item) => {\r\n    return item.path.indexOf('.js.map') !== -1 // 过滤只操作.js.map文件\r\n  },\r\n  region: '',\r\n  endpoint: 'oss-cn-hongkong.aliyuncs.com',\r\n  accessKeyId: 'LTAI5tGCjmVjvPDPooTKeU12',\r\n  accessKeySecret: 'ddI0TfZUZel24E87YXKJVz91sn9ZFZ',\r\n  ossBucket: 'xccjhback'\r\n}\r\nnew ResourceOptManager(options).init()\r\n\r\n// $ node upload.js 👈\r\n// 上传目录：D:\\resource-opt\\test\r\n// 第1波上传\r\n// 开始上传本地文件\r\n// 成功上传文件：D:\\resource-opt\\test\\test.js.map 到远程地址： test/test.js.map\r\n```\r\n\r\nThat's all\r\n","readmeFilename":"README.md"}