@@ -13,6 +13,7 @@ import {
1313 parseArgs ,
1414 prepareBundledAiRuntimePackage ,
1515 runCommandForTest ,
16+ writePackageInventoryForDocker ,
1617} from "../../../../scripts/package-openclaw-for-docker.mjs" ;
1718import { useAutoCleanupTempDirTracker } from "../../../helpers/temp-dir.js" ;
1819
@@ -175,6 +176,32 @@ describe("package-openclaw-for-docker", () => {
175176 }
176177 } ) ;
177178
179+ it ( "writes inventory for a frozen source checkout without the trusted helper" , async ( ) => {
180+ const sourceDir = tempDirs . make ( "openclaw-package-frozen-source-" ) ;
181+ fs . mkdirSync ( path . join ( sourceDir , "dist" ) , { recursive : true } ) ;
182+ fs . mkdirSync ( path . join ( sourceDir , "scripts" ) , { recursive : true } ) ;
183+ fs . writeFileSync ( path . join ( sourceDir , "package.json" ) , '{"name":"openclaw"}\n' ) ;
184+ fs . writeFileSync ( path . join ( sourceDir , "dist" , "entry.js" ) , "export {};\n" ) ;
185+ fs . writeFileSync (
186+ path . join ( sourceDir , "scripts" , "write-package-dist-inventory.ts" ) ,
187+ [
188+ 'import fs from "node:fs";' ,
189+ 'fs.writeFileSync("dist/postinstall-inventory.json", JSON.stringify(["dist/entry.js"]));' ,
190+ ] . join ( "\n" ) ,
191+ ) ;
192+
193+ await writePackageInventoryForDocker ( sourceDir ) ;
194+
195+ expect (
196+ JSON . parse (
197+ fs . readFileSync ( path . join ( sourceDir , "dist" , "postinstall-inventory.json" ) , "utf8" ) ,
198+ ) ,
199+ ) . toEqual ( [ "dist/entry.js" ] ) ;
200+ expect ( fs . existsSync ( path . join ( sourceDir , "scripts" , "lib" , "package-dist-inventory.ts" ) ) ) . toBe (
201+ false ,
202+ ) ;
203+ } ) ;
204+
178205 it ( "rejects pnpm pack with npm metadata output" , ( ) => {
179206 expect ( parseArgs ( [ "--pnpm-pack" ] ) . pnpmPack ) . toBe ( true ) ;
180207 expect ( ( ) => parseArgs ( [ "--pnpm-pack" , "--pack-json" , "pack.json" ] ) ) . toThrow (
0 commit comments