Добавил скачивание ipfs для дистрибутива linux
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/node_modules
|
||||
/server/data
|
||||
/server/public
|
||||
/server/ipfs
|
||||
/dist
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
|
||||
const fs = require('fs');
|
||||
const download = require('download');
|
||||
const decompress = require('decompress');
|
||||
const decompressTargz = require('decompress-targz');
|
||||
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const DisableOutputWebpackPlugin = require('disable-output-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const EventHooksPlugin = require('event-hooks-webpack-plugin');
|
||||
|
||||
const distDir = path.resolve(__dirname, '../dist');
|
||||
const publicDir = `${distDir}/tmp/public`;
|
||||
const outDir = `${distDir}/linux`;
|
||||
|
||||
const tempDownloadDir = `${distDir}/tmp/download`;
|
||||
|
||||
module.exports = {
|
||||
mode: 'production',
|
||||
entry: `${distDir}/public/index.html`,
|
||||
entry: `${publicDir}/index.html`,
|
||||
output: {
|
||||
path: outDir
|
||||
},
|
||||
@@ -23,11 +32,38 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin([outDir], {root: distDir}),
|
||||
new CleanWebpackPlugin([outDir, tempDownloadDir], {root: distDir}),
|
||||
new DisableOutputWebpackPlugin(),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: `${distDir}/public`, to: `${outDir}/public` }
|
||||
{ from: publicDir, to: `${outDir}/public` }
|
||||
]
|
||||
),
|
||||
new EventHooksPlugin({
|
||||
done: () => {
|
||||
fs.mkdirSync(tempDownloadDir);
|
||||
// Скачиваем ipfs
|
||||
const ipfsRemoteUrl = 'https://dist.ipfs.io/go-ipfs/v0.4.18/go-ipfs_v0.4.18_linux-amd64.tar.gz';
|
||||
|
||||
d = download(ipfsRemoteUrl);
|
||||
d.pipe(fs.createWriteStream(`${tempDownloadDir}/ipfs.tar.gz`));
|
||||
d.on('end', () => {
|
||||
console.log(`done downloading ${ipfsRemoteUrl}`);
|
||||
|
||||
//распаковываем
|
||||
decompress(`${tempDownloadDir}/ipfs.tar.gz`, `${tempDownloadDir}`, {
|
||||
plugins: [
|
||||
decompressTargz()
|
||||
]
|
||||
}).then(() => {
|
||||
console.log('files decompressed');
|
||||
// копируем в дистрибутив
|
||||
fs.copyFileSync(`${tempDownloadDir}/go-ipfs/ipfs`, `${outDir}/ipfs`);
|
||||
console.log(`copied ${tempDownloadDir}/go-ipfs/ipfs to ${outDir}/ipfs`);
|
||||
//для development
|
||||
fs.copyFileSync(`${tempDownloadDir}/go-ipfs/ipfs`, path.resolve(__dirname, '../server/ipfs'));
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"build:win": "npm run build:client && webpack --config build/webpack.win.config.js && pkg -t latest-win-x64 -o dist/win/liberama .",
|
||||
"lint": "eslint --ext=.js,.vue client server",
|
||||
"build:client-dev": "webpack --config build/webpack.dev.config.js",
|
||||
"postinstall": "npm run build:client-dev"
|
||||
"postinstall": "npm run build:client-dev && build:linux"
|
||||
},
|
||||
"bin": "server/index.js",
|
||||
"pkg": {
|
||||
|
||||
Reference in New Issue
Block a user