@univer-cli/resource-library-command 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @univer-cli/resource-library-command
2
+
3
+ English | [简体中文](./README.zh-CN.md)
4
+
5
+ Provide a native Commander `resources` preset for `@univer-cli/resource-library`, including registry listing, search, reading, and batch export.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add commander @univer-cli/resource-library @univer-cli/resource-library-command
11
+ ```
12
+
13
+ Commander `^15.0.0` is a peer dependency. Requires Node.js 22.12 or higher.
14
+
15
+ ## Add to application
16
+
17
+ ```ts
18
+ import { createResourcesCommand } from "@univer-cli/resource-library-command";
19
+ import type { ResourceLibrary } from "@univer-cli/resource-library";
20
+ import { Command } from "commander";
21
+
22
+ export async function runCli(openLibrary: () => ResourceLibrary): Promise<void> {
23
+ const program = new Command("my-cli");
24
+ program.addCommand(createResourcesCommand({ openLibrary }));
25
+ await program.parseAsync();
26
+ }
27
+ ```
28
+
29
+ ## Command list
30
+
31
+ ```text
32
+ resources registries [--json]
33
+ resources find <queries...> [--registry <id>] [--limit <number>] [--json]
34
+ resources export <handle> [--json]
35
+ resources export <handles...> --out <directory> [--json]
36
+ resources cache path [--json]
37
+ resources cache clear [--json]
38
+ ```
39
+
40
+ Default text is human-readable; `--json` prints structured results. Binary content is not mixed into the JSON summary. Commander exits non-zero for invalid input, unknown handles, and download or export failures.
41
+
42
+ `openLibrary` lets the application lazily create a library with credentials or filesystem adapters. The command package does not own catalog, cache, download, or export rules; those behaviors belong to the capability. The factory returns a native `Command`.
@@ -0,0 +1,44 @@
1
+ # @univer-cli/resource-library-command
2
+
3
+ [English](./README.md) | 简体中文
4
+
5
+ 为 `@univer-cli/resource-library` 提供原生 Commander `resources` preset,包括目录查看、搜索、读取和批量导出。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pnpm add commander @univer-cli/resource-library @univer-cli/resource-library-command
11
+ ```
12
+
13
+ Commander `^15.0.0` 是 peer dependency。要求 Node.js 22.12 或更高版本。
14
+
15
+ ## 添加到应用
16
+
17
+ ```ts
18
+ import { createResourcesCommand } from "@univer-cli/resource-library-command";
19
+ import type { ResourceLibrary } from "@univer-cli/resource-library";
20
+ import { Command } from "commander";
21
+
22
+ export async function runCli(openLibrary: () => ResourceLibrary): Promise<void> {
23
+ const program = new Command("my-cli");
24
+ program.addCommand(createResourcesCommand({ openLibrary }));
25
+ await program.parseAsync();
26
+ }
27
+ ```
28
+
29
+ ## 命令一览
30
+
31
+ ```text
32
+ resources registries [--json]
33
+ resources find <queries...> [--registry <id>] [--limit <number>] [--json]
34
+ resources export <handle> [--json]
35
+ resources export <handles...> --out <directory> [--json]
36
+ resources cache path [--json]
37
+ resources cache clear [--json]
38
+ ```
39
+
40
+ 默认文本面向人阅读;`--json` 输出结构化结果。二进制内容不会混入 JSON summary。输入非法、handle 不存在、
41
+ 下载或输出失败由 Commander 以失败退出处理。
42
+
43
+ `openLibrary` 允许 application 延迟创建含凭证或 filesystem adapter 的 library。Command package 不拥有
44
+ catalog、cache、下载和导出规则;这些行为全部由 capability 定义。Factory 返回原生 `Command`。
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';module['exports']=require('./index.mjs');
@@ -0,0 +1,9 @@
1
+ import { ResourceLibrary } from "@univer-cli/resource-library";
2
+ import { Command } from "commander";
3
+ //#region src/index.d.ts
4
+ interface ResourceLibraryCommandDependencies {
5
+ readonly openLibrary: () => ResourceLibrary;
6
+ }
7
+ declare function createResourcesCommand(dependencies: ResourceLibraryCommandDependencies): Command;
8
+ //#endregion
9
+ export { ResourceLibraryCommandDependencies, createResourcesCommand };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ (function(_0x518ec0,_0x3e54e9){const _0xd4454=_0x2822,_0x16663d=_0x518ec0();while(!![]){try{const _0x44a72e=parseInt(_0xd4454(0x1b8))/0x1+-parseInt(_0xd4454(0x1e1))/0x2+-parseInt(_0xd4454(0x1bd))/0x3+-parseInt(_0xd4454(0x1b6))/0x4*(-parseInt(_0xd4454(0x1e9))/0x5)+-parseInt(_0xd4454(0x1ea))/0x6*(parseInt(_0xd4454(0x1e5))/0x7)+parseInt(_0xd4454(0x196))/0x8*(parseInt(_0xd4454(0x1ee))/0x9)+parseInt(_0xd4454(0x1eb))/0xa*(parseInt(_0xd4454(0x1d9))/0xb);if(_0x44a72e===_0x3e54e9)break;else _0x16663d['push'](_0x16663d['shift']());}catch(_0x4e9a1f){_0x16663d['push'](_0x16663d['shift']());}}}(_0x2402,0xb0619));import{isResourceLibraryError as _0xe68a0e}from'@univer-cli/resource-library';import{Command as _0xf5684f,InvalidArgumentError as _0x32cf57,Option as _0x980daa}from'commander';var i=0x1e;function a(_0x4e025d){const _0x15e840=_0x2822;let _0x31dc53=new _0xf5684f(_0x15e840(0x1b4))['description'](_0x15e840(0x1cc))[_0x15e840(0x1e6)](()=>_0x31dc53['outputHelp']());_0x31dc53['command'](_0x15e840(0x1cd))[_0x15e840(0x1e2)](_0x15e840(0x1b1))[_0x15e840(0x198)](_0x15e840(0x1f1),'write\x20structured\x20JSON')[_0x15e840(0x1e6)](async _0x175c37=>{const _0x58c4bb=_0x15e840;let _0x22228d=await c(_0x31dc53,async()=>_0x4e025d[_0x58c4bb(0x1bc)]()['listRegistries']());l(_0x31dc53,_0x175c37,{'registries':_0x22228d},d(_0x22228d));}),_0x31dc53[_0x15e840(0x19c)](_0x15e840(0x197))['description'](_0x15e840(0x1e0))[_0x15e840(0x1ac)]('<queries...>',_0x15e840(0x1a9))[_0x15e840(0x1ec)](new _0x980daa('--registry\x20<id>',_0x15e840(0x1ce))[_0x15e840(0x1a2)](o)['default']([]))['addOption'](new _0x980daa(_0x15e840(0x19f),_0x15e840(0x1c7))[_0x15e840(0x1a2)](s)[_0x15e840(0x1b9)](i))[_0x15e840(0x198)](_0x15e840(0x1f1),'write\x20structured\x20JSON')[_0x15e840(0x1e6)](async(_0x43ff70,_0x2fc4b9)=>{const _0x2bce07=_0x15e840;let _0x328c3f=await c(_0x31dc53,async()=>_0x4e025d[_0x2bce07(0x1bc)]()[_0x2bce07(0x197)]({'queries':_0x43ff70,'registries':_0x2fc4b9[_0x2bce07(0x1ad)],'limit':_0x2fc4b9['limit']}));l(_0x31dc53,_0x2fc4b9,{'query':{'queries':_0x43ff70,'registries':_0x2fc4b9[_0x2bce07(0x1ad)]},'resources':_0x328c3f['resources'],'total':_0x328c3f[_0x2bce07(0x1d6)],'limit':_0x2fc4b9['limit']},f(_0x328c3f[_0x2bce07(0x1b4)],_0x328c3f['total']));}),_0x31dc53['command'](_0x15e840(0x1be))['description'](_0x15e840(0x199))['argument']('<handles...>',_0x15e840(0x1aa))[_0x15e840(0x198)]('--out\x20<directory>','write\x20flat\x20<registry>--<resource>.svg\x20files')[_0x15e840(0x198)]('--json',_0x15e840(0x1a4))[_0x15e840(0x1e6)](async(_0x32ae37,_0x40457f)=>{const _0x5405b7=_0x15e840;if(_0x40457f[_0x5405b7(0x1db)]===void 0x0){_0x32ae37[_0x5405b7(0x1b7)]!==0x1&&_0x31dc53[_0x5405b7(0x1d7)](_0x5405b7(0x1a0),{'code':_0x5405b7(0x1e3),'exitCode':0x1});let _0x568841=await c(_0x31dc53,async()=>_0x4e025d[_0x5405b7(0x1bc)]()[_0x5405b7(0x1c9)]({'handle':_0x32ae37[0x0]}));_0x40457f[_0x5405b7(0x1de)]===!0x0?u(_0x31dc53,_0x568841):_0x31dc53[_0x5405b7(0x1ed)]()[_0x5405b7(0x1af)]?.(_0x568841[_0x5405b7(0x1f0)]);return;}let _0x15d32a=await c(_0x31dc53,async()=>_0x4e025d[_0x5405b7(0x1bc)]()['export']({'handles':_0x32ae37,'destination':_0x40457f[_0x5405b7(0x1db)]}));if(_0x40457f[_0x5405b7(0x1de)]===!0x0)u(_0x31dc53,_0x15d32a);else{let _0x13b6c7=_0x31dc53[_0x5405b7(0x1ed)]();for(let _0x2616cb of _0x15d32a[_0x5405b7(0x1d2)])_0x13b6c7[_0x5405b7(0x1af)]?.(_0x2616cb[_0x5405b7(0x1ef)]+'\x0a');for(let _0x12fc8a of _0x15d32a[_0x5405b7(0x1c3)])_0x13b6c7[_0x5405b7(0x1d4)]?.(_0x12fc8a[_0x5405b7(0x1d0)]+':\x20'+_0x12fc8a[_0x5405b7(0x19e)]+':\x20'+_0x12fc8a['message']+'\x0a');}_0x15d32a[_0x5405b7(0x1c3)][_0x5405b7(0x1b7)]>0x0&&_0x31dc53['error'](_0x15d32a[_0x5405b7(0x1c3)]['length']+_0x5405b7(0x1bf)+(_0x15d32a[_0x5405b7(0x1c3)][_0x5405b7(0x1b7)]===0x1?'':'s')+_0x5405b7(0x1a6),{'code':_0x5405b7(0x1b5),'exitCode':0x1});});let _0x118f66=_0x31dc53[_0x15e840(0x19c)]('cache')[_0x15e840(0x1e2)](_0x15e840(0x1ab));return _0x118f66['action'](()=>_0x118f66[_0x15e840(0x1b3)]()),_0x118f66[_0x15e840(0x19c)](_0x15e840(0x1ef))[_0x15e840(0x1e2)]('Show\x20the\x20resource\x20cache\x20path')[_0x15e840(0x198)](_0x15e840(0x1f1),_0x15e840(0x1a4))['action'](_0x2a317c=>{const _0x28f138=_0x15e840;let _0x4fe61f=_0x4e025d['openLibrary']()[_0x28f138(0x1e7)];l(_0x31dc53,_0x2a317c,{'path':_0x4fe61f},_0x4fe61f);}),_0x118f66[_0x15e840(0x19c)](_0x15e840(0x1dc))['description'](_0x15e840(0x1e8))[_0x15e840(0x198)](_0x15e840(0x1f1),_0x15e840(0x1a4))[_0x15e840(0x1e6)](async _0x1b0143=>{const _0x5edfd9=_0x15e840;let _0x56bb86=await c(_0x31dc53,async()=>_0x4e025d[_0x5edfd9(0x1bc)]()[_0x5edfd9(0x19d)]());l(_0x31dc53,_0x1b0143,{'cleared':_0x56bb86},_0x5edfd9(0x1d1)+_0x56bb86[_0x5edfd9(0x1a1)]+_0x5edfd9(0x19b)+p(_0x56bb86['byteCount'])+')\x20from\x20'+_0x56bb86['path']+'.');}),_0x31dc53;}function o(_0x50d791,_0x527083){return[..._0x527083,_0x50d791];}function s(_0x3527a4){const _0x1410d0=_0x2822;let _0x32bb0e=Number(_0x3527a4);if(!Number['isInteger'](_0x32bb0e)||_0x32bb0e<0x1)throw new _0x32cf57(_0x1410d0(0x1e4)+_0x3527a4+'\x22.');return _0x32bb0e;}async function c(_0x929ae7,_0x4a3bc2){const _0x34f0f7=_0x2822;try{return await _0x4a3bc2();}catch(_0x1d6a73){throw _0xe68a0e(_0x1d6a73)&&_0x929ae7[_0x34f0f7(0x1d7)](_0x1d6a73[_0x34f0f7(0x19e)]+':\x20'+_0x1d6a73[_0x34f0f7(0x1c8)],{'code':_0x34f0f7(0x1dd),'exitCode':0x1}),_0x1d6a73;}}function l(_0xf2d6d9,_0x589fce,_0x246282,_0x5e35ea){const _0x348693=_0x2822;_0x589fce[_0x348693(0x1de)]===!0x0?u(_0xf2d6d9,_0x246282):_0xf2d6d9['configureOutput']()[_0x348693(0x1af)]?.(_0x5e35ea+'\x0a');}function u(_0x2cefc9,_0x345577){const _0x3be617=_0x2822;_0x2cefc9['configureOutput']()[_0x3be617(0x1af)]?.(JSON['stringify'](_0x345577,null,0x2)+'\x0a');}function _0x2822(_0x309209,_0x1059e5){_0x309209=_0x309209-0x196;const _0x2402ce=_0x2402();let _0x2822b2=_0x2402ce[_0x309209];return _0x2822b2;}function _0x2402(){const _0x31bd1e=['message','read','push','groupCount','Find\x20and\x20export\x20SVG\x20resources\x20from\x20a\x20multi-registry\x20catalog','registries','restrict\x20results\x20to\x20a\x20registry;\x20repeatable','toFixed','handle','Cleared\x20','exported','intrinsicSize','writeErr','join','total','error','\x20MB','21827509vEWuTH','width','out','clear','resources.failed','json','padEnd','Find\x20resources\x20by\x20name,\x20description,\x20group,\x20tag,\x20or\x20keyword','2413472NxQyDV','description','resources.invalid-input','Expected\x20a\x20positive\x20integer;\x20received\x20\x22','28VUkDsb','action','cacheLocation','Clear\x20all\x20cached\x20resources','1229945pZrUGy','1779432iVVrTz','10rxEurA','addOption','configureOutput','2619eFwCCm','path','svg','--json','23384EBuMeF','find','option','Read\x20one\x20SVG\x20or\x20export\x20resources\x20to\x20a\x20directory','\x20more;\x20raise\x20--limit\x20or\x20narrow\x20the\x20query.','\x20resources\x20(','command','clearCache','code','--limit\x20<number>','Exporting\x20more\x20than\x20one\x20resource\x20requires\x20--out\x20<directory>.','resourceCount','argParser','editable','write\x20structured\x20JSON','name','\x20could\x20not\x20be\x20exported.','RESOURCES','height','one\x20or\x20more\x20queries,\x20searched\x20independently','canonical\x20<registryId>/<resourceId>\x20handles','Inspect\x20or\x20clear\x20the\x20resource\x20cache','argument','registry','tagCount','writeOut','\x20\x20SIZE','List\x20available\x20resource\x20registries','HANDLE','outputHelp','resources','resources.export.failed','4RBnNXb','length','218729BqeFEY','default','map','padStart','openLibrary','552447LZUstN','export','\x20resource','colorEditableCount','NAME','REGISTRY','failed','GROUP','No\x20resources\x20matched;\x20try\x20a\x20shorter\x20substring,\x20a\x20synonym,\x20or\x20another\x20registry.','COLOR','maximum\x20number\x20of\x20results'];_0x2402=function(){return _0x31bd1e;};return _0x2402();}function d(_0x116645){const _0x55e4f2=_0x2822;return[_0x55e4f2(0x1c2)[_0x55e4f2(0x1df)](0x22)+'\x20\x20'+_0x55e4f2(0x1a7)['padStart'](0x9)+'\x20\x20'+'GROUPS'[_0x55e4f2(0x1bb)](0x7)+'\x20\x20'+'TAGS'[_0x55e4f2(0x1bb)](0x6)+'\x20\x20'+'EDITABLE'['padStart'](0xa),..._0x116645['map'](_0x317ead=>[_0x317ead['id'][_0x55e4f2(0x1df)](0x22),String(_0x317ead[_0x55e4f2(0x1a1)])[_0x55e4f2(0x1bb)](0x9),String(_0x317ead[_0x55e4f2(0x1cb)])[_0x55e4f2(0x1bb)](0x7),String(_0x317ead[_0x55e4f2(0x1ae)])[_0x55e4f2(0x1bb)](0x6),(_0x317ead[_0x55e4f2(0x1c0)]+'/'+_0x317ead[_0x55e4f2(0x1a1)])[_0x55e4f2(0x1bb)](0xa)]['join']('\x20\x20'))]['join']('\x0a');}function f(_0x35c2cd,_0x5bc00d){const _0x422383=_0x2822;if(_0x35c2cd[_0x422383(0x1b7)]===0x0)return _0x422383(0x1c5);let _0x2a99ad=[_0x422383(0x1b2)[_0x422383(0x1df)](0x32)+'\x20\x20'+_0x422383(0x1c1)['padEnd'](0x1c)+'\x20\x20'+_0x422383(0x1c4)[_0x422383(0x1df)](0x12)+'\x20\x20'+_0x422383(0x1c6)[_0x422383(0x1df)](0x8)+_0x422383(0x1b0),..._0x35c2cd[_0x422383(0x1ba)](_0x1427a4=>{const _0x5d9270=_0x422383;let _0x2d75f3=_0x1427a4['group']?.['label']??'-',_0x4c6da7=_0x1427a4['colorEditable']?_0x5d9270(0x1a3):'fixed',_0x381dd5=_0x1427a4[_0x5d9270(0x1d3)][_0x5d9270(0x1da)]+'×'+_0x1427a4['intrinsicSize'][_0x5d9270(0x1a8)];return _0x1427a4['handle'][_0x5d9270(0x1df)](0x32)+'\x20\x20'+_0x1427a4[_0x5d9270(0x1a5)][_0x5d9270(0x1df)](0x1c)+'\x20\x20'+_0x2d75f3[_0x5d9270(0x1df)](0x12)+'\x20\x20'+_0x4c6da7[_0x5d9270(0x1df)](0x8)+'\x20\x20'+_0x381dd5;})];return _0x5bc00d>_0x35c2cd['length']&&_0x2a99ad[_0x422383(0x1ca)]('…\x20'+(_0x5bc00d-_0x35c2cd['length'])+_0x422383(0x19a)),_0x2a99ad[_0x422383(0x1d5)]('\x0a');}function p(_0x192af3){const _0x21f1cb=_0x2822;return _0x192af3<0x400?_0x192af3+'\x20B':_0x192af3<0x100000?(_0x192af3/0x400)[_0x21f1cb(0x1cf)](0x1)+'\x20KB':(_0x192af3/0x100000)[_0x21f1cb(0x1cf)](0x1)+_0x21f1cb(0x1d8);}export{a as createResourcesCommand};
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@univer-cli/resource-library-command",
3
+ "type": "module",
4
+ "version": "1.0.0-beta.2",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "README.zh-CN.md"
19
+ ],
20
+ "dependencies": {
21
+ "@univer-cli/resource-library": "1.0.0-beta.2"
22
+ },
23
+ "peerDependencies": {
24
+ "commander": "^15.0.0"
25
+ }
26
+ }