mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 02:06:43 +00:00
fix(release): resolve package tools from source checkout
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
// helpers, and GitHub Actions all prepare the exact same npm tarball.
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs/promises";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { DOCKER_SELECTED_PLUGIN_BUILD_IDS_ENV } from "./lib/bundled-plugin-build-entries.mjs";
|
||||
import { preparePackageChangelog, restorePackageChangelog } from "./package-changelog.mjs";
|
||||
|
||||
@@ -726,7 +727,9 @@ export async function packOpenClawPackageForDocker(sourceDir, outputDir, options
|
||||
|
||||
export async function writePackageInventoryForDocker(sourceDir, runImpl = run) {
|
||||
// Frozen release refs own their inventory shape; run their writer instead of importing current-main helpers.
|
||||
const tsxModuleUrl = import.meta.resolve("tsx");
|
||||
// Resolve the loader from that checkout too: the workflow harness may install production deps only.
|
||||
const sourceRequire = createRequire(path.join(sourceDir, "package.json"));
|
||||
const tsxModuleUrl = pathToFileURL(sourceRequire.resolve("tsx")).href;
|
||||
await runImpl(
|
||||
"node",
|
||||
["--import", tsxModuleUrl, path.join(sourceDir, "scripts/write-package-dist-inventory.ts")],
|
||||
|
||||
@@ -180,7 +180,13 @@ describe("package-openclaw-for-docker", () => {
|
||||
const sourceDir = tempDirs.make("openclaw-package-frozen-source-");
|
||||
fs.mkdirSync(path.join(sourceDir, "dist"), { recursive: true });
|
||||
fs.mkdirSync(path.join(sourceDir, "scripts"), { recursive: true });
|
||||
fs.mkdirSync(path.join(sourceDir, "node_modules", "tsx"), { recursive: true });
|
||||
fs.writeFileSync(path.join(sourceDir, "package.json"), '{"name":"openclaw"}\n');
|
||||
fs.writeFileSync(
|
||||
path.join(sourceDir, "node_modules", "tsx", "package.json"),
|
||||
'{"name":"tsx","exports":"./loader.mjs","type":"module"}\n',
|
||||
);
|
||||
fs.writeFileSync(path.join(sourceDir, "node_modules", "tsx", "loader.mjs"), "export {};\n");
|
||||
fs.writeFileSync(path.join(sourceDir, "dist", "entry.js"), "export {};\n");
|
||||
fs.writeFileSync(
|
||||
path.join(sourceDir, "scripts", "write-package-dist-inventory.ts"),
|
||||
@@ -190,7 +196,21 @@ describe("package-openclaw-for-docker", () => {
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
await writePackageInventoryForDocker(sourceDir);
|
||||
await writePackageInventoryForDocker(
|
||||
sourceDir,
|
||||
async (command: string, args: string[], cwd: string) => {
|
||||
expect({ command, cwd }).toEqual({ command: "node", cwd: sourceDir });
|
||||
expect(args).toEqual([
|
||||
"--import",
|
||||
pathToFileURL(path.join(sourceDir, "node_modules", "tsx", "loader.mjs")).href,
|
||||
path.join(sourceDir, "scripts", "write-package-dist-inventory.ts"),
|
||||
]);
|
||||
fs.writeFileSync(
|
||||
path.join(sourceDir, "dist", "postinstall-inventory.json"),
|
||||
JSON.stringify(["dist/entry.js"]),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
expect(
|
||||
JSON.parse(
|
||||
@@ -297,7 +317,7 @@ describe("package-openclaw-for-docker", () => {
|
||||
expect(calls).toEqual([
|
||||
{
|
||||
command: "node",
|
||||
args: ["scripts/build-all.mjs", "ciArtifacts"],
|
||||
args: ["scripts/build-all.mjs", "full"],
|
||||
cwd: "/repo",
|
||||
dockerBuildExtensions: undefined,
|
||||
internalDockerBuildPluginIds: undefined,
|
||||
|
||||
Reference in New Issue
Block a user