






















@@ -6,8 +6,10 @@ import { spawnSync } from "node:child_process";
66import fs from "node:fs";
77import os from "node:os";
88import path from "node:path";
9+import { performance } from "node:perf_hooks";
910import { LOCAL_BUILD_METADATA_DIST_PATHS } from "./lib/local-build-metadata-paths.mjs";
1011import {
12+collectPackageDistImports,
1113collectPackageDistImportErrors,
1214expandPackageDistImportClosure,
1315} from "./lib/package-dist-imports.mjs";
@@ -29,20 +31,37 @@ if (!fs.existsSync(tarball)) {
2931fail(`OpenClaw package tarball does not exist: ${tarball}`);
3032}
313332-const list = spawnSync("tar", ["-tf", tarball], {
33-encoding: "utf8",
34-stdio: ["ignore", "pipe", "pipe"],
35-});
34+const phaseTimingsEnabled = process.env.OPENCLAW_PACKAGE_TARBALL_CHECK_TIMINGS !== "0";
35+function runPhase(label, action) {
36+const startedAt = performance.now();
37+try {
38+return action();
39+} finally {
40+if (phaseTimingsEnabled) {
41+const durationMs = Math.round(performance.now() - startedAt);
42+console.error(`check-openclaw-package-tarball: ${label} completed in ${durationMs}ms`);
43+}
44+}
45+}
46+47+const list = runPhase("tar list", () =>
48+spawnSync("tar", ["-tf", tarball], {
49+encoding: "utf8",
50+stdio: ["ignore", "pipe", "pipe"],
51+}),
52+);
3653if (list.status !== 0) {
3754fail(`tar -tf failed for ${tarball}: ${list.stderr || list.status}`);
3855}
39564057const extractDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-package-tarball-"));
4158try {
42-const extract = spawnSync("tar", ["-xf", tarball, "-C", extractDir], {
43-encoding: "utf8",
44-stdio: ["ignore", "pipe", "pipe"],
45-});
59+const extract = runPhase("tar extract", () =>
60+spawnSync("tar", ["-xf", tarball, "-C", extractDir], {
61+encoding: "utf8",
62+stdio: ["ignore", "pipe", "pipe"],
63+}),
64+);
4665if (extract.status !== 0) {
4766fail(`tar -xf failed for ${tarball}: ${extract.stderr || extract.status}`);
4867}
@@ -181,6 +200,7 @@ for (const forbiddenEntry of FORBIDDEN_LOCAL_BUILD_METADATA_FILES) {
181200if (!entrySet.has("dist/postinstall-inventory.json")) {
182201errors.push("missing dist/postinstall-inventory.json");
183202}
203+let packageDistImports = null;
184204if (entrySet.has("dist/postinstall-inventory.json")) {
185205try {
186206const allowLegacyPrivateQaInventoryOmissions =
@@ -191,6 +211,12 @@ if (entrySet.has("dist/postinstall-inventory.json")) {
191211} else {
192212const normalizedInventory = inventory.map((entry) => entry.replace(/\\/gu, "/"));
193213const normalizedInventorySet = new Set(normalizedInventory);
214+packageDistImports = runPhase("dist import graph", () =>
215+collectPackageDistImports({
216+files: normalized,
217+readText: readTarEntry,
218+}),
219+);
194220for (const inventoryEntry of inventory) {
195221const normalizedEntry = inventoryEntry.replace(/\\/gu, "/");
196222if (!entrySet.has(normalizedEntry)) {
@@ -210,6 +236,7 @@ if (entrySet.has("dist/postinstall-inventory.json")) {
210236files: normalized,
211237seedFiles: normalizedInventory,
212238readText: readTarEntry,
239+imports: packageDistImports,
213240});
214241for (const importedEntry of expandedInventory) {
215242if (!normalizedInventorySet.has(importedEntry)) {
@@ -230,6 +257,7 @@ errors.push(
230257 ...collectPackageDistImportErrors({
231258files: normalized,
232259readText: readTarEntry,
260+imports: packageDistImports ?? undefined,
233261}),
234262);
235263此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。