Добавил скачивание ipfs
This commit is contained in:
@@ -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 path = require("path");
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
|
|
||||||
@@ -18,10 +15,7 @@ const distDir = path.resolve(__dirname, '../dist');
|
|||||||
const publicDir = `${distDir}/tmp/public`;
|
const publicDir = `${distDir}/tmp/public`;
|
||||||
const outDir = `${distDir}/win`;
|
const outDir = `${distDir}/win`;
|
||||||
|
|
||||||
const sqliteFilename = `${sqliteFile}.tar.gz`;
|
const tempDownloadDir = `${distDir}/tmp/download`;
|
||||||
const tempDir = `${distDir}/tmp/sqlite`;
|
|
||||||
const sqliteDecompressedFilename = `${tempDir}/${sqliteFile}/node_sqlite3.node`;
|
|
||||||
const sqliteDistFilename = `${outDir}/node_sqlite3.node`;
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
@@ -38,7 +32,7 @@ module.exports = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin([outDir, tempDir], {root: distDir}),
|
new CleanWebpackPlugin([outDir, tempDownloadDir], {root: distDir}),
|
||||||
new DisableOutputWebpackPlugin(),
|
new DisableOutputWebpackPlugin(),
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{ from: publicDir, to: `${outDir}/public` }
|
{ from: publicDir, to: `${outDir}/public` }
|
||||||
@@ -46,16 +40,24 @@ module.exports = {
|
|||||||
),
|
),
|
||||||
new EventHooksPlugin({
|
new EventHooksPlugin({
|
||||||
done: () => {
|
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 не включает его в сборку
|
// Скачиваем node_sqlite3.node для винды, т.к. pkg не включает его в сборку
|
||||||
const url = `${sqliteRemoteUrl}/${sqliteFilename}`;
|
const url = `${sqliteRemoteUrl}/${sqliteFilename}`;
|
||||||
fs.mkdirSync(tempDir);
|
let d = download(url);
|
||||||
const d = download(url);
|
d.pipe(fs.createWriteStream(`${tempDownloadDir}/${sqliteFilename}`));
|
||||||
d.pipe(fs.createWriteStream(`${tempDir}/${sqliteFilename}`));
|
|
||||||
d.on('end', () => {
|
d.on('end', () => {
|
||||||
console.log(`downloading ${url} done`);
|
console.log(`done downloading ${url}`);
|
||||||
|
|
||||||
//распаковываем
|
//распаковываем
|
||||||
decompress(`${tempDir}/${sqliteFilename}`, `${tempDir}`, {
|
decompress(`${tempDownloadDir}/${sqliteFilename}`, `${tempDownloadDir}`, {
|
||||||
plugins: [
|
plugins: [
|
||||||
decompressTargz()
|
decompressTargz()
|
||||||
]
|
]
|
||||||
@@ -66,6 +68,23 @@ module.exports = {
|
|||||||
console.log(`copied ${sqliteDecompressedFilename} to ${sqliteDistFilename}`);
|
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`);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user