From 169aa099e8a5a8a2514860d1335c458185b9a81a Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 5 Jan 2019 20:21:19 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?ipfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/webpack.win.config.js | 45 ++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/build/webpack.win.config.js b/build/webpack.win.config.js index dfed1e86..be8c0971 100644 --- a/build/webpack.win.config.js +++ b/build/webpack.win.config.js @@ -1,6 +1,3 @@ -const sqliteRemoteUrl = 'https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.4'; -const sqliteFile = 'node-v64-win32-x64'; - const path = require("path"); const webpack = require("webpack"); @@ -18,10 +15,7 @@ const distDir = path.resolve(__dirname, '../dist'); const publicDir = `${distDir}/tmp/public`; const outDir = `${distDir}/win`; -const sqliteFilename = `${sqliteFile}.tar.gz`; -const tempDir = `${distDir}/tmp/sqlite`; -const sqliteDecompressedFilename = `${tempDir}/${sqliteFile}/node_sqlite3.node`; -const sqliteDistFilename = `${outDir}/node_sqlite3.node`; +const tempDownloadDir = `${distDir}/tmp/download`; module.exports = { mode: 'production', @@ -38,7 +32,7 @@ module.exports = { ] }, plugins: [ - new CleanWebpackPlugin([outDir, tempDir], {root: distDir}), + new CleanWebpackPlugin([outDir, tempDownloadDir], {root: distDir}), new DisableOutputWebpackPlugin(), new CopyWebpackPlugin([ { from: publicDir, to: `${outDir}/public` } @@ -46,16 +40,24 @@ module.exports = { ), new EventHooksPlugin({ done: () => { + fs.mkdirSync(tempDownloadDir); + + const sqliteRemoteUrl = 'https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.4'; + const sqliteFile = 'node-v64-win32-x64'; + + const sqliteFilename = `${sqliteFile}.tar.gz`; + const sqliteDecompressedFilename = `${tempDownloadDir}/${sqliteFile}/node_sqlite3.node`; + const sqliteDistFilename = `${outDir}/node_sqlite3.node`; + // Скачиваем node_sqlite3.node для винды, т.к. pkg не включает его в сборку const url = `${sqliteRemoteUrl}/${sqliteFilename}`; - fs.mkdirSync(tempDir); - const d = download(url); - d.pipe(fs.createWriteStream(`${tempDir}/${sqliteFilename}`)); + let d = download(url); + d.pipe(fs.createWriteStream(`${tempDownloadDir}/${sqliteFilename}`)); d.on('end', () => { - console.log(`downloading ${url} done`); + console.log(`done downloading ${url}`); //распаковываем - decompress(`${tempDir}/${sqliteFilename}`, `${tempDir}`, { + decompress(`${tempDownloadDir}/${sqliteFilename}`, `${tempDownloadDir}`, { plugins: [ decompressTargz() ] @@ -66,6 +68,23 @@ module.exports = { console.log(`copied ${sqliteDecompressedFilename} to ${sqliteDistFilename}`); }); }); + + // Скачиваем ipfs + const ipfsRemoteUrl = 'https://dist.ipfs.io/go-ipfs/v0.4.18/go-ipfs_v0.4.18_windows-amd64.zip'; + + d = download(ipfsRemoteUrl); + d.pipe(fs.createWriteStream(`${tempDownloadDir}/ipfs.zip`)); + d.on('end', () => { + console.log(`done downloading ${ipfsRemoteUrl}`); + + //распаковываем + decompress(`${tempDownloadDir}/ipfs.zip`, `${tempDownloadDir}`).then(() => { + console.log('files decompressed'); + // копируем в дистрибутив + fs.copyFileSync(`${tempDownloadDir}/go-ipfs/ipfs.exe`, `${outDir}/ipfs.exe`); + console.log(`copied ${tempDownloadDir}/go-ipfs/ipfs.exe to ${outDir}/ipfs.exe`); + }); + }); } }) ]