@univer-cli/unit-layout-lint-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 +29 -0
- package/README.zh-CN.md +31 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +1 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @univer-cli/unit-layout-lint-command
|
|
2
|
+
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Provide a native Commander `lint` preset for `@univer-cli/unit-layout-lint`. The command currently accepts Slide only.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add commander @univer-cli/unit-layout-lint @univer-cli/unit-layout-lint-command
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Add to application
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createUnitLayoutLint } from "@univer-cli/unit-layout-lint";
|
|
17
|
+
import { createUnitLayoutLintCommand } from "@univer-cli/unit-layout-lint-command";
|
|
18
|
+
|
|
19
|
+
program.addCommand(
|
|
20
|
+
createUnitLayoutLintCommand({
|
|
21
|
+
lint: createUnitLayoutLint({ runtime: slideLayoutRuntime }),
|
|
22
|
+
loadUnit: async ({ unitId }) => await loadSlideUnitData(unitId),
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The command parses a Unit ID, page selectors, rule filters, and `--json`. Default text lists findings; JSON output contains the complete report. No findings is a successful result. Commander exits non-zero when input, loading, rendering, or linting fails.
|
|
28
|
+
|
|
29
|
+
The application owns target resolution and UnitData loading. The package does not access Workspace, files, or servers. The factory returns a native `Command`.
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @univer-cli/unit-layout-lint-command
|
|
2
|
+
|
|
3
|
+
[English](./README.md) | 简体中文
|
|
4
|
+
|
|
5
|
+
为 `@univer-cli/unit-layout-lint` 提供原生 Commander `lint` preset。当前 command 明确只接收 Slide。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add commander @univer-cli/unit-layout-lint @univer-cli/unit-layout-lint-command
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 添加到应用
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createUnitLayoutLint } from "@univer-cli/unit-layout-lint";
|
|
17
|
+
import { createUnitLayoutLintCommand } from "@univer-cli/unit-layout-lint-command";
|
|
18
|
+
|
|
19
|
+
program.addCommand(
|
|
20
|
+
createUnitLayoutLintCommand({
|
|
21
|
+
lint: createUnitLayoutLint({ runtime: slideLayoutRuntime }),
|
|
22
|
+
loadUnit: async ({ unitId }) => await loadSlideUnitData(unitId),
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Command 解析 Unit ID、page selector、rule filter 和 `--json`。默认文本列出 findings;JSON 输出完整 report。
|
|
28
|
+
没有 finding 时成功退出,输入、加载、渲染或 lint 失败时由 Commander 失败退出。
|
|
29
|
+
|
|
30
|
+
Application 拥有 target 解析与 UnitData 加载;package 不访问 Workspace、文件或 server。Factory 返回原生
|
|
31
|
+
`Command`。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';module['exports']=require('./index.mjs');
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SlideLayoutLintPageSelector, UnitLayoutLint, UnitLayoutLintReport, UnitLayoutLintSource } from "@univer-cli/unit-layout-lint";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface UnitLayoutLintCommandDependencies {
|
|
5
|
+
readonly lint: UnitLayoutLint;
|
|
6
|
+
readonly loadUnit: (input: {
|
|
7
|
+
readonly unitId: string;
|
|
8
|
+
}) => Promise<UnitLayoutLintSource>;
|
|
9
|
+
}
|
|
10
|
+
declare class UnitLayoutLintCommandInputError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
declare function createUnitLayoutLintCommand(dependencies: UnitLayoutLintCommandDependencies): Command;
|
|
14
|
+
declare function renderUnitLayoutLint(report: UnitLayoutLintReport): string;
|
|
15
|
+
declare function parseUnitLayoutLintPages(value: string): readonly SlideLayoutLintPageSelector[] | undefined;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { UnitLayoutLintCommandDependencies, UnitLayoutLintCommandInputError, createUnitLayoutLintCommand, parseUnitLayoutLintPages, renderUnitLayoutLint };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(_0x532909,_0x1a12ff){const _0x55119f=_0x503d,_0x146fb7=_0x532909();while(!![]){try{const _0x1d4f70=parseInt(_0x55119f(0x1ed))/0x1*(-parseInt(_0x55119f(0x209))/0x2)+parseInt(_0x55119f(0x1f7))/0x3+-parseInt(_0x55119f(0x1f8))/0x4+-parseInt(_0x55119f(0x206))/0x5*(-parseInt(_0x55119f(0x213))/0x6)+parseInt(_0x55119f(0x1f4))/0x7+-parseInt(_0x55119f(0x20b))/0x8*(-parseInt(_0x55119f(0x210))/0x9)+-parseInt(_0x55119f(0x1ea))/0xa;if(_0x1d4f70===_0x1a12ff)break;else _0x146fb7['push'](_0x146fb7['shift']());}catch(_0x435587){_0x146fb7['push'](_0x146fb7['shift']());}}}(_0x190a,0xd2499));import{isUnitLayoutLintError as _0x244f11}from'@univer-cli/unit-layout-lint';import{Command as _0x4430d9}from'commander';var n=0x2710,r=class extends Error{constructor(_0x238338){const _0x7d0c23=_0x503d;super(_0x238338),this[_0x7d0c23(0x20d)]=_0x7d0c23(0x211);}};function i(_0x449be3){const _0x27a346=_0x503d;let _0x5bdba6=new _0x4430d9(_0x27a346(0x214))[_0x27a346(0x1f9)]('Lint\x20browser-rendered\x20Unit\x20layout\x20(currently\x20Slide\x20only)')[_0x27a346(0x1f1)](_0x27a346(0x1ef),_0x27a346(0x1f6))['option'](_0x27a346(0x1f3),_0x27a346(0x201))['option'](_0x27a346(0x1fb),_0x27a346(0x1ee))[_0x27a346(0x20a)](async _0x478289=>{const _0x2e0560=_0x27a346;let _0x2bb764;try{let _0x3d247f=_0x478289[_0x2e0560(0x1fc)]===void 0x0?void 0x0:s(_0x478289['pages']),_0x39df45=await _0x449be3[_0x2e0560(0x208)]({'unitId':_0x478289[_0x2e0560(0x1f0)]});_0x2bb764=await _0x449be3['lint'][_0x2e0560(0x214)]({..._0x39df45,..._0x3d247f===void 0x0?{}:{'pages':_0x3d247f}});}catch(_0x43d09e){throw(_0x43d09e instanceof r||_0x244f11(_0x43d09e)||c(_0x43d09e))&&_0x5bdba6[_0x2e0560(0x215)](''+('code'in _0x43d09e?String(_0x43d09e[_0x2e0560(0x1ec)])+':\x20':'')+_0x43d09e[_0x2e0560(0x204)],{'code':'unit-layout-lint.failed','exitCode':0x1}),_0x43d09e;}_0x5bdba6['configureOutput']()[_0x2e0560(0x212)]?.((_0x478289[_0x2e0560(0x202)]===!0x0?JSON[_0x2e0560(0x1fa)](_0x2bb764,null,0x2):a(_0x2bb764))+'\x0a');});return _0x5bdba6;}function a(_0x16ceb0){const _0x376a86=_0x503d;if(_0x16ceb0['findings'][_0x376a86(0x20c)]===0x0)return _0x376a86(0x1ff)+String(_0x16ceb0['coverage'][_0x376a86(0x1fc)]['length'])+'\x20pages\x20checked)';let _0x5ea560=[_0x376a86(0x1f5)+String(_0x16ceb0[_0x376a86(0x20f)][_0x376a86(0x20c)])+_0x376a86(0x205)+String(_0x16ceb0[_0x376a86(0x203)][_0x376a86(0x1fc)][_0x376a86(0x20c)])+'\x20pages\x20checked)'];for(let _0x3f7177 of _0x16ceb0['findings'])_0x5ea560[_0x376a86(0x207)]('page\x20'+String(_0x3f7177[_0x376a86(0x1fd)])+'\x20\x20'+_0x3f7177['rule']+'\x20\x20'+_0x3f7177['id']),_0x5ea560[_0x376a86(0x207)]('\x20\x20'+_0x3f7177['detail']);return _0x5ea560['join']('\x0a');}function o(_0x4cb98b){return s(_0x4cb98b);}function _0x503d(_0x31f360,_0x129986){_0x31f360=_0x31f360-0x1ea;const _0x190aab=_0x190a();let _0x503d3f=_0x190aab[_0x31f360];return _0x503d3f;}function s(_0x3968fc){const _0x133ca5=_0x503d;if(_0x3968fc[_0x133ca5(0x200)]()===_0x133ca5(0x20e))return;if(_0x3968fc['trim']()==='')throw new r('--pages\x20cannot\x20be\x20empty');let _0x4e4139=[];for(let _0x55617b of _0x3968fc['split'](',')){let _0x55824c=_0x55617b[_0x133ca5(0x200)]();if(_0x55824c==='')throw new r(_0x133ca5(0x1fe));let _0x353f8e=/^(\d+)(?:-(\d+))?$/['exec'](_0x55824c);if(_0x353f8e===null){_0x4e4139[_0x133ca5(0x207)](_0x55824c);continue;}let _0x5ec07c=Number(_0x353f8e[0x1]),_0x278315=Number(_0x353f8e[0x2]??_0x353f8e[0x1]);if(_0x5ec07c<0x1||_0x278315<_0x5ec07c)throw new r('Invalid\x20page\x20selector:\x20'+_0x55824c);if(_0x4e4139[_0x133ca5(0x20c)]+_0x278315-_0x5ec07c+0x1>n)throw new r(_0x133ca5(0x1eb));for(let _0x195b72=_0x5ec07c;_0x195b72<=_0x278315;_0x195b72+=0x1)_0x4e4139['push'](_0x195b72);}return _0x4e4139;}function c(_0x5b0d00){const _0x33e95b=_0x503d;return _0x5b0d00 instanceof Error&&typeof _0x5b0d00[_0x33e95b(0x1ec)]==_0x33e95b(0x1f2);}export{r as UnitLayoutLintCommandInputError,i as createUnitLayoutLintCommand,o as parseUnitLayoutLintPages,a as renderUnitLayoutLint};function _0x190a(){const _0x578746=['push','loadUnit','335024xSwXRY','action','104872mNArMX','length','name','all','findings','531jZufba','UnitLayoutLintCommandInputError','writeOut','226962ySXZyn','lint','error','11136720SldmrP','--pages\x20expands\x20to\x20too\x20many\x20pages','code','8QOuKFf','write\x20the\x20complete\x20lint\x20report\x20as\x20JSON','--unit\x20<unit-id>','unit','requiredOption','string','--pages\x20<pages>','10319610KJFMnW','Slide\x20layout\x20lint:\x20','Unit\x20to\x20lint;\x20currently\x20requires\x20a\x20Slide\x20Unit','4892967pUgdqg','4069876dnmvBK','description','stringify','--json','pages','page','--pages\x20contains\x20an\x20empty\x20selector','Slide\x20layout\x20lint:\x20no\x20findings\x20(','trim','Slide\x20pages\x20or\x20page\x20IDs,\x20for\x20example\x201,3-5,cover','json','coverage','message','\x20findings\x20(','60ktvZob'];_0x190a=function(){return _0x578746;};return _0x190a();}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@univer-cli/unit-layout-lint-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/unit-layout-lint": "1.0.0-beta.2"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"commander": "^15.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|