Добавил скачивание ipfs

This commit is contained in:
Book Pauk
2019-01-05 20:21:19 +07:00
parent 29b9fa5ed2
commit 169aa099e8

View File

@@ -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`);
});
});
}
})
]