Generating single binary file from fw.zip

Hello,

I would like to build a binary file from fw.zip to flash it using single esptool command (esptool write_flash --erase-all 0 ./firmware.bin). I have written following script to build such firmware.bin:

#!/usr/bin/env node

const StreamZip = require('node-stream-zip');
const fs = require('fs');

const zip = new StreamZip({
  file: 'fw.zip',
  storeEntries: true,
});

zip.on('error', err => {
  console.log(err);
});

const prefix = 'project-1.0.0/';

zip.on('ready', () => {
  const out = fs.openSync('firmware.bin', 'w');

  const manifest = JSON.parse(zip.entryDataSync(`${prefix}manifest.json`));

  for (const { addr, src, fill, size } of Object.values(manifest.parts)) {
    if (src) {
      fs.writeSync(out, zip.entryDataSync(`${prefix}${src}`), 0, size, addr);
    } else {
      fs.writeSync(out, Buffer.alloc(size, fill), 0, size, addr);
    }
  }

  zip.close();

  fs.closeSync(out);
});

Unfortunately it doesn’t work. After flashing I see in mos console bootloader logs and then just a garbage. What I am doing wrong?

Thanks in advance