@@ -8,9 +8,10 @@ import {
88 resolvePluginsForContext ,
99} from "./extensions.js" ;
1010import { createExternalsBuildExtension } from "./externals.js" ;
11- import { join , relative , sep } from "node:path" ;
11+ import { join , relative , sep , basename } from "node:path" ;
1212import { generateContainerfile } from "../deploy/buildImage.js" ;
1313import { writeFile } from "node:fs/promises" ;
14+ import fsModule from "node:fs/promises" ;
1415import { buildManifestToJSON } from "../utilities/buildManifest.js" ;
1516import { readPackageJSON } from "pkg-types" ;
1617import { writeJSONFile } from "../utilities/fileSystem.js" ;
@@ -53,16 +54,16 @@ export async function buildWorker(options: BuildWorkerOptions) {
5354 const buildContext = createBuildContext ( options . target , resolvedConfig , {
5455 logger : options . plain
5556 ? {
56- debug : ( ...args ) => console . log ( ...args ) ,
57- log : ( ...args ) => console . log ( ...args ) ,
58- warn : ( ...args ) => console . log ( ...args ) ,
59- progress : ( message ) => console . log ( message ) ,
60- spinner : ( message ) => {
61- const $spinner = spinner ( { plain : true } ) ;
62- $spinner . start ( message ) ;
63- return $spinner ;
64- } ,
65- }
57+ debug : ( ...args ) => console . log ( ...args ) ,
58+ log : ( ...args ) => console . log ( ...args ) ,
59+ warn : ( ...args ) => console . log ( ...args ) ,
60+ progress : ( message ) => console . log ( message ) ,
61+ spinner : ( message ) => {
62+ const $spinner = spinner ( { plain : true } ) ;
63+ $spinner . start ( message ) ;
64+ return $spinner ;
65+ } ,
66+ }
6667 : undefined ,
6768 } ) ;
6869 buildContext . prependExtension ( externalsExtension ) ;
@@ -196,6 +197,7 @@ async function writeDeployFiles({
196197 join ( outputPath , "package.json" ) ,
197198 {
198199 ...packageJson ,
200+ version : "0.0.0" , // Strip version for better docker caching
199201 name : packageJson . name ?? "trigger-project" ,
200202 dependencies : {
201203 ...dependencies ,
@@ -208,8 +210,13 @@ async function writeDeployFiles({
208210 true
209211 ) ;
210212
213+ if ( resolvedConfig . lockfilePath ) {
214+ const lockfileName = basename ( resolvedConfig . lockfilePath ) ;
215+ await fsModule . copyFile ( resolvedConfig . lockfilePath , join ( outputPath , lockfileName ) ) ;
216+ }
217+
211218 await writeJSONFile ( join ( outputPath , "build.json" ) , buildManifestToJSON ( buildManifest ) ) ;
212- await writeContainerfile ( outputPath , buildManifest ) ;
219+ await writeContainerfile ( outputPath , buildManifest , resolvedConfig . lockfilePath ) ;
213220}
214221
215222async function readProjectPackageJson ( packageJsonPath : string ) {
@@ -218,17 +225,31 @@ async function readProjectPackageJson(packageJsonPath: string) {
218225 return packageJson ;
219226}
220227
221- async function writeContainerfile ( outputPath : string , buildManifest : BuildManifest ) {
228+ async function writeContainerfile (
229+ outputPath : string ,
230+ buildManifest : BuildManifest ,
231+ lockfilePath ?: string
232+ ) {
222233 if ( ! buildManifest . runControllerEntryPoint || ! buildManifest . indexControllerEntryPoint ) {
223234 throw new Error ( "Something went wrong with the build. Aborting deployment. [code 7789]" ) ;
224235 }
225236
237+ const packageManager = lockfilePath
238+ ? lockfilePath . endsWith ( "pnpm-lock.yaml" )
239+ ? ( "pnpm" as const )
240+ : lockfilePath . endsWith ( "yarn.lock" )
241+ ? ( "yarn" as const )
242+ : ( "npm" as const )
243+ : undefined ;
244+
226245 const containerfile = await generateContainerfile ( {
227246 runtime : buildManifest . runtime ,
228247 entrypoint : buildManifest . runControllerEntryPoint ,
229248 build : buildManifest . build ,
230249 image : buildManifest . image ,
231250 indexScript : buildManifest . indexControllerEntryPoint ,
251+ packageManager,
252+ lockfile : lockfilePath ? basename ( lockfilePath ) : undefined ,
232253 } ) ;
233254
234255 const containerfilePath = join ( outputPath , "Containerfile" ) ;
0 commit comments