Добавлен createWebApp
This commit is contained in:
31
server/createWebApp.js
Normal file
31
server/createWebApp.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const fs = require('fs-extra');
|
||||||
|
|
||||||
|
const webApp = require('../dist/public.json');
|
||||||
|
const ZipReader = require('./core/Zip/ZipReader');
|
||||||
|
|
||||||
|
module.exports = async(config) => {
|
||||||
|
const verFile = `${config.publicDir}/version.txt`;
|
||||||
|
const zipFile = `${config.tempDir}/public.zip`;
|
||||||
|
|
||||||
|
if (await fs.pathExists(verFile)) {
|
||||||
|
const curPublicVersion = await fs.readFile(verFile, 'utf8');
|
||||||
|
if (curPublicVersion == config.version + config.rootPathStatic)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.remove(config.publicDir);
|
||||||
|
|
||||||
|
//извлекаем новый webApp
|
||||||
|
await fs.writeFile(zipFile, webApp.data, {encoding: 'base64'});
|
||||||
|
const zipReader = new ZipReader();
|
||||||
|
await zipReader.open(zipFile);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await zipReader.extractAllToDir(config.publicDir);
|
||||||
|
} finally {
|
||||||
|
await zipReader.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(verFile, config.version + config.rootPathStatic);
|
||||||
|
await fs.remove(zipFile);
|
||||||
|
};
|
||||||
@@ -55,6 +55,8 @@ async function init() {
|
|||||||
config.tempPublicDir = `${config.publicFilesDir}/tmp`;
|
config.tempPublicDir = `${config.publicFilesDir}/tmp`;
|
||||||
config.uploadPublicDir = `${config.publicFilesDir}/upload`;
|
config.uploadPublicDir = `${config.publicFilesDir}/upload`;
|
||||||
|
|
||||||
|
config.rootPathStatic = '';
|
||||||
|
|
||||||
configManager.config = config;///!!!
|
configManager.config = config;///!!!
|
||||||
|
|
||||||
await fs.ensureDir(config.dataDir);
|
await fs.ensureDir(config.dataDir);
|
||||||
@@ -85,8 +87,8 @@ async function init() {
|
|||||||
|
|
||||||
//web app
|
//web app
|
||||||
if (branch !== 'development') {
|
if (branch !== 'development') {
|
||||||
//const createWebApp = require('./createWebApp');
|
const createWebApp = require('./createWebApp');
|
||||||
//await createWebApp(config);
|
await createWebApp(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user