@kevlns/u-cli-mod 0.2.1 → 0.2.3
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/AGENTS.md +4 -4
- package/README.md +9 -5
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.js +14 -14
- package/dist/commands/exec.d.ts +13 -3
- package/dist/commands/exec.js +32 -12
- package/dist/consolePatch.js +4 -4
- package/dist/installer.js +1 -2
- package/dist/integrity.d.ts +7 -2
- package/dist/integrity.js +32 -5
- package/dist/transform.js +4 -4
- package/package.json +2 -2
- package/routes/expected-tree/2022.3.59f1c1.json +3 -3
- package/routes/expected-tree/2022.3.62f3c1.json +3 -3
- package/v-cli.plugin.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
6. `exec` 每次调用前都会重新校验 CLI 哈希(防篡改),属正常行为;校验失败按提示跑 `u-cli-mod cli install --force` 修复即可。
|
|
29
29
|
7. **读取 Editor 当前 Console 首选 `command read_console`**,`get_console_logs` 是兼容别名;`command console` 读取回调捕获流,适合 `since`/cursor 跟随,但不能代替原生 Console 快照。工具必须经 `command <名>` 调用。若实际 schema 中缺少 `read_console`,先检查 `doctor` 的 `patchVersion`/`installedPatchVersion` 和 `state`,不要将其误认成 `console` 的别名。
|
|
30
30
|
|
|
31
|
-
8.
|
|
31
|
+
8. **全量测试必须走 `--async_tests`**:Unity CLI 对同步命令有 30 秒硬性等待上限(`--timeout` 无法延长),同步 `run_tests` 全量必然超时且不入 `test_status` 跟踪。全量:`run_tests --mode EditMode --async_tests`(立即返回)→ 轮询 `test_status` 至 `completed` 拿完整 Summary;小范围用 `--filter` 缩到单命名空间/类,可直接同步等待拿 Summary。
|
|
32
32
|
## 典型流程
|
|
33
33
|
|
|
34
34
|
```bash
|
|
@@ -36,11 +36,11 @@ u-cli-mod doctor <project> # 1. 体检(只读)
|
|
|
36
36
|
u-cli-mod setup <project> # 2. 就绪(CLI + 适配包)
|
|
37
37
|
u-cli-mod exec <project> -- command editor_status # 3. 执行
|
|
38
38
|
u-cli-mod exec <project> -- command run_tests --mode EditMode --filter <命名空间或类名> # 小范围:同步返回 Summary
|
|
39
|
-
u-cli-mod exec <project> -- command run_tests --mode EditMode
|
|
39
|
+
u-cli-mod exec <project> -- command run_tests --mode EditMode --async_tests # 全量:立即返回,轮询 test_status
|
|
40
40
|
u-cli-mod exec <project> -- command read_console --types error,warning --count 100
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
`doctor.pipeline` 的 `patchVersion` 为当前路由要求的补丁版本,`installedPatchVersion` 为 receipt 记录的版本(旧 receipt 也兼容,未知为 null);`state` 为 `missing | outdated | invalid | current
|
|
43
|
+
`doctor.pipeline` 的 `patchVersion` 为当前路由要求的补丁版本,`installedPatchVersion` 为 receipt 记录的版本(旧 receipt 也兼容,未知为 null);`state` 为 `missing | outdated | invalid | current`。完整 expected-tree 校验通过即返回 `installed=true` / `current`,不因 receipt 缺失或陈旧要求重装。`verification` 列出内容不匹配、校验错误及仅行尾差异的文件。已安装 UTF-8 文本允许 LF/CRLF 等价,其他内容及二进制仍严格校验;生成源与 staging 保持字节级校验,新生成文本统一 LF。`sourceReady=false` 仅表示生成缓存需重建,不代表已安装包失效。
|
|
44
44
|
|
|
45
45
|
## Pipeline 工具清单
|
|
46
46
|
|
|
@@ -234,4 +234,4 @@ u-cli-mod exec <project> -- command read_console --types error,warning --count 1
|
|
|
234
234
|
|
|
235
235
|
### Authoring 根路径
|
|
236
236
|
- `get_authoring_root` — Get the base folder (under Assets/) that bare authoring paths resolve against.
|
|
237
|
-
- `set_authoring_root` — Set the base folder (under Assets/) that bare authoring paths resolve against and are confined to. Use 'Assets' for full project access.
|
|
237
|
+
- `set_authoring_root` — Set the base folder (under Assets/) that bare authoring paths resolve against and are confined to. Use 'Assets' for full project access.
|
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ u-cli-mod routes # 列出支持的 Editor 路由
|
|
|
52
52
|
|
|
53
53
|
升级 npm 包不会自动替换已有工程的 `Packages/com.unity.pipeline`。检查 `doctor` 的 `pipeline.state`:只有 `current` 且 `installed=true` 才表示当前补丁完整;`outdated`/`invalid` 时关闭目标 Unity Editor 后执行 `u-cli-mod pipeline install <project> --force`(自动备份)。`patchVersion` 是路由要求,`installedPatchVersion` 来自安装 receipt;仅看到上游版本 `0.5.0-exp.1` 或诊断退出码 0 不代表适配包已更新。
|
|
54
54
|
|
|
55
|
+
就绪状态以当前路由的完整文件树为准,旧 receipt、缺失 receipt 或生成缓存未就绪均不会推翻已通过校验的安装。`pipeline.verification` 提供 `mismatches`、`lineEndingDifferences` 和 `error`,可直接定位失效原因。新生成的文本统一 LF;已安装 UTF-8 文本只接受 LF/CRLF 的等价差异,不忽略 BOM、空白、实际内容、缺失或额外文件,二进制保持 SHA-256 严格校验。生成缓存与安装 staging 仍要求精确字节。
|
|
56
|
+
|
|
55
57
|
## Usage
|
|
56
58
|
|
|
57
59
|
> 示例中的 `<project>` 指代你的 Unity 工程目录,请替换为实际路径。
|
|
@@ -119,11 +121,13 @@ u-cli-mod cache clean
|
|
|
119
121
|
|
|
120
122
|
```bash
|
|
121
123
|
npm run check # build + lint + vitest 测试 + pack guard
|
|
124
|
+
|
|
125
|
+
> 发版除 `npm version` 外,还需同步 tests/scripts 中的版本断言(`cli.test.ts`、`vcli-manifest.test.ts`、`pack-guard.mjs`、`test-package-install.mjs`):grep 旧版本号应为零,再打 tag。
|
|
122
126
|
```
|
|
123
127
|
|
|
124
128
|
`pack:guard` 会执行真实 `npm pack`(含文件清单校验),断言发布包:
|
|
125
129
|
|
|
126
|
-
- 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.2.
|
|
130
|
+
- 包名为 `@kevlns/u-cli-mod`,tgz 文件名精确为 `kevlns-u-cli-mod-0.2.3.tgz`(与 package.json 版本一致);
|
|
127
131
|
- `files` 必须包含 `v-cli.plugin.json`,且清单身份字段(schemaVersion/package/command/bin/platforms)与包一致;
|
|
128
132
|
- 不出现:
|
|
129
133
|
|
|
@@ -191,9 +195,9 @@ kevlns 工具家族共享同一套发布约定(tag 驱动、CI 护栏、MIT)
|
|
|
191
195
|
|
|
192
196
|
| Package | Purpose | Status |
|
|
193
197
|
| --- | --- | --- |
|
|
194
|
-
| [`v-cli`](https://github.com/kevlns/v-cli) | 个人工具箱 CLI | v0.2.
|
|
195
|
-
| [`xlmerge`](https://github.com/kevlns/xlmerge) | Git 中 .xlsx/.xlsm 冲突可视化解决工具 |
|
|
196
|
-
| [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.2.
|
|
198
|
+
| [`v-cli`](https://github.com/kevlns/v-cli) | 个人工具箱 CLI | v0.2.13 |
|
|
199
|
+
| [`xlmerge`](https://github.com/kevlns/xlmerge) | Git 中 .xlsx/.xlsm 冲突可视化解决工具 | v2.0.0 |
|
|
200
|
+
| [`u-cli-mod`](https://github.com/kevlns/u-cli-mod) | Unity 精确版本路由 + CLI + pipeline 包(Windows-first,本仓库) | v0.2.3 |
|
|
197
201
|
|
|
198
202
|
## Compatibility
|
|
199
203
|
|
|
@@ -219,4 +223,4 @@ For bugs and feature requests, use [GitHub Issues](https://github.com/kevlns/u-c
|
|
|
219
223
|
|
|
220
224
|
Part of the **kevlns** tool family.
|
|
221
225
|
|
|
222
|
-
</div>
|
|
226
|
+
</div>
|
|
@@ -20,6 +20,18 @@ export declare function runDoctor(projectPath: string, options?: DoctorOptions):
|
|
|
20
20
|
installed: boolean;
|
|
21
21
|
state: string;
|
|
22
22
|
installedPatchVersion: number | null;
|
|
23
|
+
verification: {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
mismatches: never[];
|
|
26
|
+
lineEndingDifferences: never[];
|
|
27
|
+
error: string;
|
|
28
|
+
} | {
|
|
29
|
+
error: null;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
mismatches: import("../integrity.js").TreeMismatch[];
|
|
32
|
+
fileCount: number;
|
|
33
|
+
lineEndingDifferences: string[];
|
|
34
|
+
};
|
|
23
35
|
};
|
|
24
36
|
unityProcesses: string[];
|
|
25
37
|
supportedVersions: string[];
|
package/dist/commands/doctor.js
CHANGED
|
@@ -25,14 +25,14 @@ async function readInstalledPatchVersion(receiptPath) {
|
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
|
-
async function
|
|
28
|
+
async function inspectPackageTree(root, expected, options = {}) {
|
|
29
29
|
if (!existsSync(root))
|
|
30
|
-
return false;
|
|
30
|
+
return { ok: false, mismatches: [], lineEndingDifferences: [], error: 'Package directory is missing' };
|
|
31
31
|
try {
|
|
32
|
-
return
|
|
32
|
+
return { ...await compareTree(root, expected, options), error: null };
|
|
33
33
|
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
34
|
+
catch (err) {
|
|
35
|
+
return { ok: false, mismatches: [], lineEndingDifferences: [], error: err instanceof Error ? err.message : String(err) };
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export async function runDoctor(projectPath, options = {}) {
|
|
@@ -53,18 +53,17 @@ export async function runDoctor(projectPath, options = {}) {
|
|
|
53
53
|
const pipelineOutdated = pipelinePresent &&
|
|
54
54
|
installedPatchVersion !== null &&
|
|
55
55
|
installedPatchVersion < route.pipeline.patchVersion;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const pipelineInstalled = pipelinePresent && pipelineTreeMatches && !pipelineOutdated;
|
|
56
|
+
const verification = await inspectPackageTree(pipelineRoot, expectedTree.files, { allowTextLineEndings: true });
|
|
57
|
+
// Receipts live in Library and may be stale after a checkout. The pinned tree is authoritative.
|
|
58
|
+
const pipelineInstalled = pipelinePresent && verification.ok;
|
|
60
59
|
const pipelineState = !pipelinePresent
|
|
61
60
|
? 'missing'
|
|
62
|
-
:
|
|
63
|
-
? '
|
|
64
|
-
:
|
|
65
|
-
? '
|
|
61
|
+
: verification.ok
|
|
62
|
+
? 'current'
|
|
63
|
+
: pipelineOutdated
|
|
64
|
+
? 'outdated'
|
|
66
65
|
: 'invalid';
|
|
67
|
-
const pipelineSourceReady = await
|
|
66
|
+
const pipelineSourceReady = (await inspectPackageTree(generated, expectedTree.files)).ok;
|
|
68
67
|
let editors = [];
|
|
69
68
|
if (!options.allowRunningEditor) {
|
|
70
69
|
try {
|
|
@@ -90,6 +89,7 @@ export async function runDoctor(projectPath, options = {}) {
|
|
|
90
89
|
installed: pipelineInstalled,
|
|
91
90
|
state: pipelineState,
|
|
92
91
|
installedPatchVersion,
|
|
92
|
+
verification,
|
|
93
93
|
},
|
|
94
94
|
unityProcesses: editors,
|
|
95
95
|
supportedVersions: listEditorVersions(),
|
package/dist/commands/exec.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ export declare function findProjectPathOverride(args: string[]): string | null;
|
|
|
8
8
|
export declare function buildExecArgs(cliArgs: string[], projectPath: string): string[];
|
|
9
9
|
/**
|
|
10
10
|
* Pipeline commands that block until the Editor-side work finishes.
|
|
11
|
-
* The routed Unity CLI caps that wait at 30s
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* The routed Unity CLI caps that wait at 30s (`--timeout` is not wired in the
|
|
12
|
+
* shipped build), so the wait budget belongs to this wrapper; full-suite run_tests
|
|
13
|
+
* must instead use the pipeline-side `--async_tests` flag (immediate return +
|
|
14
|
+
* `test_status` polling).
|
|
14
15
|
*/
|
|
15
16
|
export declare const LONG_RUNNING_PIPELINE_COMMANDS: ReadonlySet<string>;
|
|
16
17
|
/**
|
|
@@ -39,6 +40,15 @@ export declare function extractWaitOption(args: string[]): {
|
|
|
39
40
|
};
|
|
40
41
|
/** Exec output log of a handed-back run: project-scoped, beside the install receipts. */
|
|
41
42
|
export declare function execLogPath(projectPath: string, commandName: string | null, now?: Date): string;
|
|
43
|
+
/**
|
|
44
|
+
* Command line for a handed-back exec, written into a temp .cmd batch: the batch
|
|
45
|
+
* owns the output redirection and is spawned as a single clean path argument, so
|
|
46
|
+
* the CLI outlives the wrapper process (numeric-fd stdio kills the detached child
|
|
47
|
+
* on Windows, and Node's quoting of an inline quoted command string breaks cmd).
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildDetachedExecCommand(cliPath: string, args: string[], logPath: string): string;
|
|
50
|
+
/** Temp batch path for a handed-back exec: wrapper plumbing, never project state. */
|
|
51
|
+
export declare function detachedExecBatchPath(logPath: string, tmpDir?: string): string;
|
|
42
52
|
export interface ExecOptions {
|
|
43
53
|
downloadIfMissing?: boolean;
|
|
44
54
|
waitSeconds?: number;
|
package/dist/commands/exec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { basename, dirname, join } from 'node:path';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
4
5
|
import { readProjectInfo } from '../projectVersion.js';
|
|
5
6
|
import { resolveRouteForProject } from '../routes.js';
|
|
6
7
|
import { verifyCliBinary, ensureCliBinary } from '../ensure.js';
|
|
@@ -25,9 +26,10 @@ export function buildExecArgs(cliArgs, projectPath) {
|
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Pipeline commands that block until the Editor-side work finishes.
|
|
28
|
-
* The routed Unity CLI caps that wait at 30s
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* The routed Unity CLI caps that wait at 30s (`--timeout` is not wired in the
|
|
30
|
+
* shipped build), so the wait budget belongs to this wrapper; full-suite run_tests
|
|
31
|
+
* must instead use the pipeline-side `--async_tests` flag (immediate return +
|
|
32
|
+
* `test_status` polling).
|
|
31
33
|
*/
|
|
32
34
|
export const LONG_RUNNING_PIPELINE_COMMANDS = new Set(['run_tests']);
|
|
33
35
|
/**
|
|
@@ -104,6 +106,25 @@ export function execLogPath(projectPath, commandName, now = new Date()) {
|
|
|
104
106
|
const suffix = commandName === null ? '' : `-${commandName}`;
|
|
105
107
|
return join(projectPath, 'Library', 'editor-pipeline-cli', 'exec-logs', `${stamp}${suffix}.log`);
|
|
106
108
|
}
|
|
109
|
+
/** Quotes one token for a cmd.exe command line; embedded quotes double up. */
|
|
110
|
+
function quoteForCmd(value) {
|
|
111
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Command line for a handed-back exec, written into a temp .cmd batch: the batch
|
|
115
|
+
* owns the output redirection and is spawned as a single clean path argument, so
|
|
116
|
+
* the CLI outlives the wrapper process (numeric-fd stdio kills the detached child
|
|
117
|
+
* on Windows, and Node's quoting of an inline quoted command string breaks cmd).
|
|
118
|
+
*/
|
|
119
|
+
export function buildDetachedExecCommand(cliPath, args, logPath) {
|
|
120
|
+
const cli = `${quoteForCmd(cliPath)} ${args.map(quoteForCmd).join(' ')}`;
|
|
121
|
+
return `${cli} > ${quoteForCmd(logPath)} 2>&1`;
|
|
122
|
+
}
|
|
123
|
+
/** Temp batch path for a handed-back exec: wrapper plumbing, never project state. */
|
|
124
|
+
export function detachedExecBatchPath(logPath, tmpDir = tmpdir()) {
|
|
125
|
+
const base = basename(logPath).replace(/\.log$/, '.cmd');
|
|
126
|
+
return join(tmpDir, `u-cli-mod-exec-${base}`);
|
|
127
|
+
}
|
|
107
128
|
export async function runExec(projectPath, cliArgs, options = {}) {
|
|
108
129
|
const project = readProjectInfo(projectPath);
|
|
109
130
|
const route = resolveRouteForProject(project);
|
|
@@ -112,7 +133,6 @@ export async function runExec(projectPath, cliArgs, options = {}) {
|
|
|
112
133
|
throw new CliError(`exec 统一管理 --project-path,禁止在参数中覆盖目标工程:${override}`);
|
|
113
134
|
}
|
|
114
135
|
let cliPath = cliBinaryPath(route.cli);
|
|
115
|
-
const { existsSync } = await import('node:fs');
|
|
116
136
|
if (!existsSync(cliPath)) {
|
|
117
137
|
if (!options.downloadIfMissing) {
|
|
118
138
|
throw new CliError(`该路由的 CLI 尚未下载:${cliPath}。请先运行 "u-cli-mod cli install",或使用 --download-if-missing。`);
|
|
@@ -135,25 +155,25 @@ export async function runExec(projectPath, cliArgs, options = {}) {
|
|
|
135
155
|
}
|
|
136
156
|
/**
|
|
137
157
|
* Runs the CLI under a wait budget. When the budget expires the child keeps running
|
|
138
|
-
* (the
|
|
139
|
-
* with the output log path, so callers can poll the matching status command.
|
|
158
|
+
* (cmd owns the redirection, so the CLI survives the wrapper) and the wrapper hands
|
|
159
|
+
* control back with the output log path, so callers can poll the matching status command.
|
|
140
160
|
*/
|
|
141
161
|
async function runWithWaitBudget(cliPath, args, projectPath, waitMs, commandName) {
|
|
142
162
|
const logPath = execLogPath(projectPath, commandName);
|
|
143
163
|
mkdirSync(dirname(logPath), { recursive: true });
|
|
144
|
-
const
|
|
145
|
-
|
|
164
|
+
const batchPath = detachedExecBatchPath(logPath);
|
|
165
|
+
writeFileSync(batchPath, `@${buildDetachedExecCommand(cliPath, args, logPath)}\r\n`);
|
|
166
|
+
const child = spawn('cmd.exe', ['/d', '/c', batchPath], { stdio: 'ignore', windowsHide: true });
|
|
146
167
|
const spawnState = { error: null };
|
|
147
168
|
child.once('error', (error) => {
|
|
148
169
|
spawnState.error = error;
|
|
149
170
|
});
|
|
150
171
|
const finished = await waitForExit(child, waitMs);
|
|
151
|
-
closeSync(logFd);
|
|
152
172
|
if (finished) {
|
|
153
173
|
if (spawnState.error !== null) {
|
|
154
174
|
throw new CliError(`CLI 执行失败:${spawnState.error.message}`);
|
|
155
175
|
}
|
|
156
|
-
process.stdout.write(readFileSync(logPath, 'utf8'));
|
|
176
|
+
process.stdout.write(existsSync(logPath) ? readFileSync(logPath, 'utf8') : '');
|
|
157
177
|
return { exitCode: child.exitCode ?? 1 };
|
|
158
178
|
}
|
|
159
179
|
child.unref();
|
package/dist/consolePatch.js
CHANGED
|
@@ -349,14 +349,14 @@ const CONSOLE_COMMANDS_BODY_LF = ` [CliCommand("read_console", "Read or c
|
|
|
349
349
|
: exception.Message;
|
|
350
350
|
}
|
|
351
351
|
`;
|
|
352
|
-
function
|
|
353
|
-
return Buffer.from(bytes.toString('utf8').replace(/\r
|
|
352
|
+
function normalizeLf(bytes) {
|
|
353
|
+
return Buffer.from(bytes.toString('utf8').replace(/\r\n/g, '\n'), 'utf8');
|
|
354
354
|
}
|
|
355
355
|
/** Replace the callback-buffer console commands with an Editor LogEntries snapshot reader. */
|
|
356
356
|
export function patchConsoleCommands(bytes) {
|
|
357
357
|
const source = bytes.toString('utf8');
|
|
358
358
|
if (source.includes('[CliCommand("read_console"')) {
|
|
359
|
-
return
|
|
359
|
+
return normalizeLf(Buffer.from(source, 'utf8'));
|
|
360
360
|
}
|
|
361
361
|
const startMarker = ' [CliCommand("get_console_logs"';
|
|
362
362
|
const normalized = source.replace(/\r\n/g, '\n');
|
|
@@ -366,5 +366,5 @@ export function patchConsoleCommands(bytes) {
|
|
|
366
366
|
throw new CliError('ConsoleCommands.cs 缺少 get_console_logs/class 闭合锚点');
|
|
367
367
|
}
|
|
368
368
|
const patched = normalized.slice(0, start) + CONSOLE_COMMANDS_BODY_LF + normalized.slice(classClose);
|
|
369
|
-
return
|
|
369
|
+
return normalizeLf(Buffer.from(patched, 'utf8'));
|
|
370
370
|
}
|
package/dist/installer.js
CHANGED
|
@@ -48,8 +48,7 @@ export async function installPipeline(project, route, sourceDir, expectedTree, o
|
|
|
48
48
|
let existingIsValid = false;
|
|
49
49
|
if (existsSync(destination)) {
|
|
50
50
|
try {
|
|
51
|
-
await
|
|
52
|
-
existingIsValid = true;
|
|
51
|
+
existingIsValid = (await compareTree(destination, expectedTree, { allowTextLineEndings: true })).ok;
|
|
53
52
|
}
|
|
54
53
|
catch {
|
|
55
54
|
existingIsValid = false;
|
package/dist/integrity.d.ts
CHANGED
|
@@ -26,11 +26,16 @@ export interface TreeMismatch {
|
|
|
26
26
|
expected?: string;
|
|
27
27
|
actual?: string;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
export interface TreeComparisonOptions {
|
|
30
|
+
/** Installed text may have passed through Git; generated sources remain byte-exact. */
|
|
31
|
+
allowTextLineEndings?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Two-way comparison; optional installed-text EOL equivalence never relaxes binary hashes. */
|
|
34
|
+
export declare function compareTree(root: string, expected: Record<string, string>, options?: TreeComparisonOptions): Promise<{
|
|
31
35
|
ok: boolean;
|
|
32
36
|
mismatches: TreeMismatch[];
|
|
33
37
|
fileCount: number;
|
|
38
|
+
lineEndingDifferences: string[];
|
|
34
39
|
}>;
|
|
35
40
|
export declare function assertTreeMatches(root: string, expected: Record<string, string>, what: string): Promise<number>;
|
|
36
41
|
export declare function fileSize(file: string): number;
|
package/dist/integrity.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { createReadStream } from 'node:fs';
|
|
3
3
|
import { readdirSync, statSync } from 'node:fs';
|
|
4
|
-
import {
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { basename, extname, join, relative } from 'node:path';
|
|
5
6
|
import { CliError } from './errors.js';
|
|
6
7
|
export function sha256Buffer(data) {
|
|
7
8
|
return createHash('sha256').update(data).digest('hex');
|
|
@@ -48,17 +49,43 @@ export async function sha256Tree(root, readdirImpl = readdirSync) {
|
|
|
48
49
|
}
|
|
49
50
|
return result;
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
const TEXT_EXTENSIONS = new Set(['.cs', '.json', '.asmdef', '.meta', '.md', '.txt', '.unity']);
|
|
53
|
+
const TEXT_FILENAMES = new Set(['CHECKSUMS', 'LICENSE']);
|
|
54
|
+
async function matchesTextLineEndings(file, expected) {
|
|
55
|
+
if (!TEXT_EXTENSIONS.has(extname(file).toLowerCase()) && !TEXT_FILENAMES.has(basename(file)))
|
|
56
|
+
return false;
|
|
57
|
+
const bytes = await readFile(file);
|
|
58
|
+
if (bytes.includes(0))
|
|
59
|
+
return false;
|
|
60
|
+
let text;
|
|
61
|
+
try {
|
|
62
|
+
// Preserve BOM bytes and reject invalid UTF-8 instead of silently replacing them.
|
|
63
|
+
text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const lf = text.replace(/\r\n/g, '\n');
|
|
69
|
+
return sha256Buffer(Buffer.from(lf)) === expected ||
|
|
70
|
+
sha256Buffer(Buffer.from(lf.replace(/\n/g, '\r\n'))) === expected;
|
|
71
|
+
}
|
|
72
|
+
/** Two-way comparison; optional installed-text EOL equivalence never relaxes binary hashes. */
|
|
73
|
+
export async function compareTree(root, expected, options = {}) {
|
|
53
74
|
const actual = await sha256Tree(root);
|
|
54
75
|
const mismatches = [];
|
|
76
|
+
const lineEndingDifferences = [];
|
|
55
77
|
for (const [path, hash] of Object.entries(expected)) {
|
|
56
78
|
const real = actual.get(path);
|
|
57
79
|
if (real === undefined) {
|
|
58
80
|
mismatches.push({ kind: 'missing', path });
|
|
59
81
|
}
|
|
60
82
|
else if (real !== hash) {
|
|
61
|
-
|
|
83
|
+
if (options.allowTextLineEndings && await matchesTextLineEndings(join(root, path), hash)) {
|
|
84
|
+
lineEndingDifferences.push(path);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
mismatches.push({ kind: 'hash', path, expected: hash, actual: real });
|
|
88
|
+
}
|
|
62
89
|
}
|
|
63
90
|
}
|
|
64
91
|
for (const path of actual.keys()) {
|
|
@@ -66,7 +93,7 @@ export async function compareTree(root, expected) {
|
|
|
66
93
|
mismatches.push({ kind: 'extra', path });
|
|
67
94
|
}
|
|
68
95
|
}
|
|
69
|
-
return { ok: mismatches.length === 0, mismatches, fileCount: Object.keys(expected).length };
|
|
96
|
+
return { ok: mismatches.length === 0, mismatches, fileCount: Object.keys(expected).length, lineEndingDifferences };
|
|
70
97
|
}
|
|
71
98
|
export async function assertTreeMatches(root, expected, what) {
|
|
72
99
|
const { ok, mismatches, fileCount } = await compareTree(root, expected);
|
package/dist/transform.js
CHANGED
|
@@ -43,8 +43,8 @@ export function shouldRemove(relPath) {
|
|
|
43
43
|
return true;
|
|
44
44
|
return REMOVE_PREFIX.some((p) => relPath.startsWith(p));
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
return Buffer.from(buf.toString('utf8').replace(/\r
|
|
46
|
+
function normalizeLf(buf) {
|
|
47
|
+
return Buffer.from(buf.toString('utf8').replace(/\r\n/g, '\n'), 'utf8');
|
|
48
48
|
}
|
|
49
49
|
/** JSON rewrite matching the verified reference: compact separators, non-ASCII escaped, key order kept. */
|
|
50
50
|
export function rewritePackageJson(bytes, targetUnity) {
|
|
@@ -81,7 +81,7 @@ function patchAssetCommands(bytes) {
|
|
|
81
81
|
const extra = ALIAS_EXTRA_LF.split('\n').join(eol);
|
|
82
82
|
s = s.replace(marker, marker + extra);
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return normalizeLf(Buffer.from(s, 'utf8'));
|
|
85
85
|
}
|
|
86
86
|
function patchMaterialCommands(bytes) {
|
|
87
87
|
let s = bytes.toString('utf8');
|
|
@@ -97,7 +97,7 @@ function patchMaterialCommands(bytes) {
|
|
|
97
97
|
if (s.includes('RenderQueue = mat.rawRenderQueue,')) {
|
|
98
98
|
s = s.replace('RenderQueue = mat.rawRenderQueue,', 'RenderQueue = GetRawRenderQueue(mat),');
|
|
99
99
|
}
|
|
100
|
-
return
|
|
100
|
+
return normalizeLf(Buffer.from(s, 'utf8'));
|
|
101
101
|
}
|
|
102
102
|
function metaBody(bytes) {
|
|
103
103
|
const text = bytes.toString('utf8');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevlns/u-cli-mod",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "u-cli-mod: pin exact Unity Editor version routes and install the adapted com.unity.pipeline package for Unity 2022 (Windows-first). Downloads Unity assets at runtime into the user cache; the package itself contains no Unity binaries or package source. Not an official Unity project.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -68,4 +68,4 @@
|
|
|
68
68
|
"vitest": "^3.2.7"
|
|
69
69
|
},
|
|
70
70
|
"license": "MIT"
|
|
71
|
-
}
|
|
71
|
+
}
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"Editor/Commands/Animation/TimelineGuard.cs": "56996b9a540a57aa0ca6a44dbc1534d2b4094716983dc808683b2000f7667e8a",
|
|
58
58
|
"Editor/Commands/Animation/TimelineGuard.cs.meta": "379f2eda0f2e46f7e80b4ba41d489e12cbca16b01e693b2d24103989860b392e",
|
|
59
59
|
"Editor/Commands/Assets.meta": "50d4c1b23e0f31417d8c6810b20f50ae59e12d815a93c177f78fb2714d6713dc",
|
|
60
|
-
"Editor/Commands/Assets/AssetCommands.cs": "
|
|
60
|
+
"Editor/Commands/Assets/AssetCommands.cs": "ee9ef1c0f5d684c52f0b673e97362ebc54ec14b5936050bf9c8b14da4ae5dece",
|
|
61
61
|
"Editor/Commands/Assets/AssetCommands.cs.meta": "55316a0aaa1ef4b6546dfe6c6836b9c3693f3e82d85339eb336ac920541ad722",
|
|
62
62
|
"Editor/Commands/Assets/AssetImportCommands.cs": "4ab1172a1fe4570b83fc186feffe43e55622d922cbe4897b7cefa3f76d3ceb0a",
|
|
63
63
|
"Editor/Commands/Assets/AssetImportCommands.cs.meta": "89d86143ec620e33ba315683b2e44a27528fa676a8f0b81bbcd1728fcc36e919",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"Editor/Commands/GameObjects/TypeResolver.cs": "510e80c81e30ef6684398481fc94cb6cec5f4d416fcd3c6d31f986dd14825882",
|
|
116
116
|
"Editor/Commands/GameObjects/TypeResolver.cs.meta": "c044ba48eb76deeed438928fae73234ef401a5bbacd9c35f41041082c5963f90",
|
|
117
117
|
"Editor/Commands/Materials.meta": "ecbe40a5a0ccab03e659df0a46e57bfb693f5495482653b2b9e969841c99c9f6",
|
|
118
|
-
"Editor/Commands/Materials/MaterialCommands.cs": "
|
|
118
|
+
"Editor/Commands/Materials/MaterialCommands.cs": "46aace61bf4d50b84052285ef182a36aeaced574443899e6b3104c353029baf1",
|
|
119
119
|
"Editor/Commands/Materials/MaterialCommands.cs.meta": "2cecb3f36a2dbea3f648340a4c85c1560b28d659be520d946db6aa03bd54162b",
|
|
120
120
|
"Editor/Commands/Materials/MaterialResults.cs": "ee362f70720544d29fbc726f25f18170957a9b8b889331ccb01fe877aa6265db",
|
|
121
121
|
"Editor/Commands/Materials/MaterialResults.cs.meta": "71101ecf14c75c41224836720e1fa0a8a8517be79e9f7f346ab66c8f81fb23f1",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"Editor/Commands/Navigation/NavigationCommands.cs": "2d2bfafb2f8563380c8708ecb97300250ee9bdc8a0f6a0512903247cf19a4ae5",
|
|
130
130
|
"Editor/Commands/Navigation/NavigationCommands.cs.meta": "f1002bd852046ce3bd7b3dbd6cc35e707429455ded5ad2c79e1fbac965bf23a9",
|
|
131
131
|
"Editor/Commands/Observability.meta": "0cef75eb0161beeff22e8ba22dac994895bd3d1bef3d86c41fe7f7e192206c73",
|
|
132
|
-
"Editor/Commands/Observability/ConsoleCommands.cs": "
|
|
132
|
+
"Editor/Commands/Observability/ConsoleCommands.cs": "1d2cb5aa44ca70e77395c6e52e63123eb81fa7082aa13f89ba7bfe01dcffc7dd",
|
|
133
133
|
"Editor/Commands/Observability/ConsoleCommands.cs.meta": "0b36196d922c3f6b34b49c42606a170b298694b06f6df393f3be4c75dda4c04c",
|
|
134
134
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs": "abba3537972218a75536bbf503c9732bc967ae6a18872d6126080111b7a3011e",
|
|
135
135
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs.meta": "2f4e7cbc14f9a3bd5fc2314ebde2ad6ee9b97a292b624f174242659889f24b72",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"Editor/Commands/Animation/TimelineGuard.cs": "56996b9a540a57aa0ca6a44dbc1534d2b4094716983dc808683b2000f7667e8a",
|
|
58
58
|
"Editor/Commands/Animation/TimelineGuard.cs.meta": "379f2eda0f2e46f7e80b4ba41d489e12cbca16b01e693b2d24103989860b392e",
|
|
59
59
|
"Editor/Commands/Assets.meta": "50d4c1b23e0f31417d8c6810b20f50ae59e12d815a93c177f78fb2714d6713dc",
|
|
60
|
-
"Editor/Commands/Assets/AssetCommands.cs": "
|
|
60
|
+
"Editor/Commands/Assets/AssetCommands.cs": "ee9ef1c0f5d684c52f0b673e97362ebc54ec14b5936050bf9c8b14da4ae5dece",
|
|
61
61
|
"Editor/Commands/Assets/AssetCommands.cs.meta": "55316a0aaa1ef4b6546dfe6c6836b9c3693f3e82d85339eb336ac920541ad722",
|
|
62
62
|
"Editor/Commands/Assets/AssetImportCommands.cs": "4ab1172a1fe4570b83fc186feffe43e55622d922cbe4897b7cefa3f76d3ceb0a",
|
|
63
63
|
"Editor/Commands/Assets/AssetImportCommands.cs.meta": "89d86143ec620e33ba315683b2e44a27528fa676a8f0b81bbcd1728fcc36e919",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"Editor/Commands/GameObjects/TypeResolver.cs": "510e80c81e30ef6684398481fc94cb6cec5f4d416fcd3c6d31f986dd14825882",
|
|
116
116
|
"Editor/Commands/GameObjects/TypeResolver.cs.meta": "c044ba48eb76deeed438928fae73234ef401a5bbacd9c35f41041082c5963f90",
|
|
117
117
|
"Editor/Commands/Materials.meta": "ecbe40a5a0ccab03e659df0a46e57bfb693f5495482653b2b9e969841c99c9f6",
|
|
118
|
-
"Editor/Commands/Materials/MaterialCommands.cs": "
|
|
118
|
+
"Editor/Commands/Materials/MaterialCommands.cs": "46aace61bf4d50b84052285ef182a36aeaced574443899e6b3104c353029baf1",
|
|
119
119
|
"Editor/Commands/Materials/MaterialCommands.cs.meta": "2cecb3f36a2dbea3f648340a4c85c1560b28d659be520d946db6aa03bd54162b",
|
|
120
120
|
"Editor/Commands/Materials/MaterialResults.cs": "ee362f70720544d29fbc726f25f18170957a9b8b889331ccb01fe877aa6265db",
|
|
121
121
|
"Editor/Commands/Materials/MaterialResults.cs.meta": "71101ecf14c75c41224836720e1fa0a8a8517be79e9f7f346ab66c8f81fb23f1",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"Editor/Commands/Navigation/NavigationCommands.cs": "2d2bfafb2f8563380c8708ecb97300250ee9bdc8a0f6a0512903247cf19a4ae5",
|
|
130
130
|
"Editor/Commands/Navigation/NavigationCommands.cs.meta": "f1002bd852046ce3bd7b3dbd6cc35e707429455ded5ad2c79e1fbac965bf23a9",
|
|
131
131
|
"Editor/Commands/Observability.meta": "0cef75eb0161beeff22e8ba22dac994895bd3d1bef3d86c41fe7f7e192206c73",
|
|
132
|
-
"Editor/Commands/Observability/ConsoleCommands.cs": "
|
|
132
|
+
"Editor/Commands/Observability/ConsoleCommands.cs": "1d2cb5aa44ca70e77395c6e52e63123eb81fa7082aa13f89ba7bfe01dcffc7dd",
|
|
133
133
|
"Editor/Commands/Observability/ConsoleCommands.cs.meta": "0b36196d922c3f6b34b49c42606a170b298694b06f6df393f3be4c75dda4c04c",
|
|
134
134
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs": "abba3537972218a75536bbf503c9732bc967ae6a18872d6126080111b7a3011e",
|
|
135
135
|
"Editor/Commands/Observability/ConsoleLogBuffer.cs.meta": "2f4e7cbc14f9a3bd5fc2314ebde2ad6ee9b97a292b624f174242659889f24b72",
|
package/v-cli.plugin.json
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"output": {
|
|
53
53
|
"format": "json",
|
|
54
|
-
"description": "Diagnostics object: projectPath, editorVersion, editorRevision, routeSupported, routeRevision, cli {version, path, state}, pipeline {version, patchVersion, installedPatchVersion, sourceReady, present, installed, state: missing|outdated|invalid|current}, unityProcesses, supportedVersions. installed/sourceReady require expected-tree integrity. Exit 0 means diagnostics completed, not readiness. Close the target Editor and use pipeline install --force for outdated/invalid. npm upgrades do not update project packages."
|
|
54
|
+
"description": "Diagnostics object: projectPath, editorVersion, editorRevision, routeSupported, routeRevision, cli {version, path, state}, pipeline {version, patchVersion, installedPatchVersion, sourceReady, present, installed, state: missing|outdated|invalid|current}, unityProcesses, supportedVersions. installed/sourceReady require expected-tree integrity. Exit 0 means diagnostics completed, not readiness. Close the target Editor and use pipeline install --force for outdated/invalid. npm upgrades do not update project packages. pipeline.verification reports mismatches, lineEndingDifferences and error. Verified installed content is authoritative over stale/missing receipts; installed UTF-8 text tolerates LF/CRLF only, generated sources and binaries remain byte-exact. New generated text uses LF."
|
|
55
55
|
},
|
|
56
56
|
"exitCodes": {
|
|
57
57
|
"0": "success",
|