@@ -93,10 +93,19 @@ if (watcherVersion) {
9393
9494// Map platform/arch to target names
9595const platformMap = {
96- 'linux-x64' : { target : 'bun-linux-x64' , os : 'linux' , arch : 'x64' , ext : '' } ,
97- 'darwin-arm64' : { target : 'bun-darwin-arm64' , os : 'darwin' , arch : 'arm64' , ext : '' } ,
98- 'darwin-x64' : { target : 'bun-darwin-x64' , os : 'darwin' , arch : 'x64' , ext : '' } ,
99- 'win32-x64' : { target : 'bun-windows-x64' , os : 'windows' , arch : 'x64' , ext : '.exe' } ,
96+ 'linux-x64' : { target : 'bun-linux-x64' , pkgOs : 'linux' , npmOs : 'linux' , arch : 'x64' , ext : '' } ,
97+ 'darwin-arm64' : { target : 'bun-darwin-arm64' , pkgOs : 'darwin' , npmOs : 'darwin' , arch : 'arm64' , ext : '' } ,
98+ 'darwin-x64' : { target : 'bun-darwin-x64' , pkgOs : 'darwin' , npmOs : 'darwin' , arch : 'x64' , ext : '' } ,
99+ // NOTE: npm expects `win32` in the package.json `os` field; using `windows` causes the
100+ // optional dependency to be skipped entirely on Windows. Keep the package name as
101+ // `codemachine-windows-x64`, but set the npm metadata to `win32` so it installs.
102+ 'win32-x64' : {
103+ target : 'bun-windows-x64' ,
104+ pkgOs : 'windows' ,
105+ npmOs : 'win32' ,
106+ arch : 'x64' ,
107+ ext : '.exe' ,
108+ } ,
100109} ;
101110
102111// Determine which targets to build
@@ -133,8 +142,15 @@ const outputRoot = process.env.OUTPUT_DIR || process.env.OUTPUT_ROOT || './binar
133142
134143try {
135144 for ( const targetConfig of targets ) {
136- const { target, os, arch : archName , ext = '' , key } = targetConfig ;
137- const outdir = join ( outputRoot , `codemachine-${ os } -${ archName } ` ) ;
145+ const {
146+ target,
147+ pkgOs = targetConfig . os ,
148+ npmOs = targetConfig . pkgOs ?? targetConfig . os ,
149+ arch : archName ,
150+ ext = '' ,
151+ key,
152+ } = targetConfig ;
153+ const outdir = join ( outputRoot , `codemachine-${ pkgOs } -${ archName } ` ) ;
138154
139155 console . log ( `${ cyan } →${ reset } Building executables for ${ dim } ${ target } ${ reset } ...` ) ;
140156 mkdirSync ( outdir , { recursive : true } ) ;
@@ -200,7 +216,7 @@ try {
200216 console . log ( ` ${ green } ✓${ reset } ${ dim } Workflow runner built${ reset } ` ) ;
201217
202218 // Create package.json for the platform-specific package
203- const pkgName = `codemachine-${ os } -${ archName } ` ;
219+ const pkgName = `codemachine-${ pkgOs } -${ archName } ` ;
204220 const binEntries = {
205221 codemachine : `codemachine${ ext } ` ,
206222 'codemachine-workflow' : `codemachine-workflow${ ext } ` ,
@@ -210,8 +226,8 @@ try {
210226 const pkg = {
211227 name : pkgName ,
212228 version : mainVersion ,
213- description : `${ mainPackage . description } (prebuilt ${ os } -${ archName } binaries)` ,
214- os : [ os ] ,
229+ description : `${ mainPackage . description } (prebuilt ${ pkgOs } -${ archName } binaries)` ,
230+ os : [ npmOs ] ,
215231 cpu : [ archName ] ,
216232 files : [ 'codemachine' + ext , 'codemachine-workflow' + ext ] ,
217233 bin : binEntries ,
0 commit comments