

























@@ -75,6 +75,27 @@ export function isLegacyPluginDependencyInstallStagePath(relativePath: string):
7575);
7676}
777778+function collectExcludedPackagedExtensionDirs(rootPackageJson: unknown): Set<string> {
79+if (!rootPackageJson || typeof rootPackageJson !== "object") {
80+return new Set();
81+}
82+const files = (rootPackageJson as { files?: unknown }).files;
83+if (!Array.isArray(files)) {
84+return new Set();
85+}
86+const excluded = new Set<string>();
87+for (const entry of files) {
88+if (typeof entry !== "string") {
89+continue;
90+}
91+const match = /^!dist\/extensions\/([^/]+)\/\*\*$/u.exec(entry);
92+if (match?.[1]) {
93+excluded.add(match[1]);
94+}
95+}
96+return excluded;
97+}
98+7899function isExternalizedBundledExtensionDistPath(
79100relativePath: string,
80101externalizedExtensionIds: ExternalizedBundledExtensionIds,
@@ -92,65 +113,19 @@ function isExternalizedBundledExtensionDistPath(
92113);
93114}
9411595-function isPublishableExternalizedBundledManifest(value: unknown): boolean {
96-if (!value || typeof value !== "object") {
97-return false;
98-}
99-const openclaw = (value as { openclaw?: unknown }).openclaw;
100-if (!openclaw || typeof openclaw !== "object") {
101-return false;
102-}
103-const release = (openclaw as { release?: unknown }).release;
104-if (!release || typeof release !== "object") {
105-return false;
106-}
107-const bundle = (openclaw as { bundle?: unknown }).bundle;
108-if (
109-bundle &&
110-typeof bundle === "object" &&
111-(bundle as { includeInCore?: unknown }).includeInCore === true
112-) {
113-return false;
114-}
115-const typedRelease = release as { publishToClawHub?: unknown; publishToNpm?: unknown };
116-return typedRelease.publishToNpm === true || typedRelease.publishToClawHub === true;
117-}
118-119116async function collectExternalizedBundledExtensionIds(
120117packageRoot: string,
121118): Promise<ExternalizedBundledExtensionIds> {
122-const extensionsDir = path.join(packageRoot, "extensions");
123-let entries: import("node:fs").Dirent[];
119+const packageJsonPath = path.join(packageRoot, "package.json");
124120try {
125-entries = await fs.readdir(extensionsDir, { withFileTypes: true });
121+const parsed = JSON.parse(await fs.readFile(packageJsonPath, "utf8")) as unknown;
122+return collectExcludedPackagedExtensionDirs(parsed);
126123} catch (error) {
127124if ((error as NodeJS.ErrnoException).code === "ENOENT") {
128125return new Set();
129126}
130127throw error;
131128}
132-133-const ids = new Set<string>();
134-await Promise.all(
135-entries.map(async (entry) => {
136-if (!entry.isDirectory()) {
137-return;
138-}
139-const packageJsonPath = path.join(extensionsDir, entry.name, "package.json");
140-try {
141-const parsed = JSON.parse(await fs.readFile(packageJsonPath, "utf8")) as unknown;
142-if (isPublishableExternalizedBundledManifest(parsed)) {
143-ids.add(entry.name);
144-}
145-} catch (error) {
146-if ((error as NodeJS.ErrnoException).code === "ENOENT") {
147-return;
148-}
149-throw error;
150-}
151-}),
152-);
153-return ids;
154129}
155130156131function isPackagedDistPath(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。