diff --git a/helpers/scanner/parsers/seven-zip.js b/helpers/scanner/parsers/seven-zip.js new file mode 100644 index 0000000..2cb49bd --- /dev/null +++ b/helpers/scanner/parsers/seven-zip.js @@ -0,0 +1,31 @@ +import SevenZip from '7z-wasm' +// import { Buffer } from 'buffer' + +// function async function compressBuffer () { + +// } + +// Archive directory 7z a archive1.zip subdir\ +export async function compress ( input, archivePath ) { + const sevenZip = await SevenZip() + + // const isBuffer = Buffer.isBuffer( input ) + + console.log( 'process.cwd()', input ) + console.log( 'archivePath', archivePath ) + + + + const mountRoot = 'virtual'//input.split( '\\' ).slice( 0, -1 ).join( '\\' ) + sevenZip.FS.mkdir( mountRoot ) + sevenZip.FS.mount( sevenZip.NODEFS, { root: process.cwd() }, mountRoot ) + sevenZip.FS.chdir( mountRoot ) + + console.log( 'cwd', sevenZip.FS.cwd() ) + console.log( 'readdir ', sevenZip.FS.readdir( sevenZip.FS.cwd() ) ) + + // test/_artifacts/temp/BlueJeans(No Resources).app.zip + await sevenZip.callMain([ 'a', archivePath, input ]) + + return +} diff --git a/test/scanner/client.test.js b/test/scanner/client.test.js index 17b4ad5..9fe1af5 100644 --- a/test/scanner/client.test.js +++ b/test/scanner/client.test.js @@ -13,6 +13,7 @@ import { LocalFileData } from 'get-file-object-from-local-path' import { Zip } from 'zip-lib' import { AppScan } from '~/helpers/scanner/client' +// import { compress } from '~/helpers/scanner/parsers/seven-zip' const appGlobOptions = { @@ -50,6 +51,8 @@ async function makeZipFromBundlePath ( bundlePath ) { // console.log( 'archivePath', archivePath ) + // await compress( bundlePath, archivePath ) + const zipLib = new Zip() // Adds a folder from the file system, putting its contents at the root of archive