diff --git a/.gitignore b/.gitignore index 3cf992a..083c2c5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,7 @@ web/ *.log # config file -envFile -src/proxy -src/webVersion.json -src/releaseVersion.json +config/ #index file GPATH diff --git a/package.json b/package.json index d076e21..4eba0cf 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,13 @@ "filter": [ "**/*" ] + }, + { + "from": "config", + "to": "config", + "filter": [ + "**/*" + ] } ], "nsis": { diff --git a/setVersion.js b/setVersion.js index 1cd65fd..49d4e4d 100644 --- a/setVersion.js +++ b/setVersion.js @@ -8,7 +8,7 @@ const initializeEnv = async () => { if (commitInfo) { fs.writeFileSync( - path.join(__dirname, './src/webVersion.json'), + path.join(__dirname, './config/webVersion.json'), JSON.stringify(commitInfo, null, 2), encode ); @@ -18,7 +18,7 @@ const initializeEnv = async () => { if (releaseInfo) { fs.writeFileSync( - path.join(__dirname, './src/releaseVersion.json'), + path.join(__dirname, './config/releaseVersion.json'), JSON.stringify(releaseInfo, null, 2), encode ); diff --git a/src/proxyConfig.js b/src/proxyConfig.js index 76d7f8f..c230796 100644 --- a/src/proxyConfig.js +++ b/src/proxyConfig.js @@ -25,7 +25,7 @@ const initializeWindow = () => { } }); - proxyWindow.loadFile(getCorrectPath('src/proxyWebConfig.html')); + proxyWindow.loadFile(getCorrectPath('src/proxyWebConfig.html', './')); proxyWindow.on('closed', () => { proxyWindow = null; diff --git a/src/utils/autoUpdate.js b/src/utils/autoUpdate.js index 66dccbf..4be353f 100644 --- a/src/utils/autoUpdate.js +++ b/src/utils/autoUpdate.js @@ -17,7 +17,7 @@ const autoUpdateWebPage = async () => { let isUpdated = false; logger.info('autoUpdateWebPage fn'); try { - const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('src/webVersion.json'))); + const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('config/webVersion.json'))); logger.info('current web page version', currentInfo); const latestInfo = await getWebPageCommit(); logger.info('latest web page version', latestInfo); @@ -33,7 +33,7 @@ const autoUpdateWebPage = async () => { // when success, write version info to file if (isSuccess) { - await promisedWriteFile(getCorrectPath('src/webVersion.json'), JSON.stringify(latestInfo, null, 2)); + await promisedWriteFile(getCorrectPath('config/webVersion.json'), JSON.stringify(latestInfo, null, 2)); logger.info('write latest web page version info success'); } } @@ -52,7 +52,7 @@ const checkApplicationRelease = async () => { logger.info('checkApplicationRelease fn'); try { - const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('src/releaseVersion.json'))); + const currentInfo = JSON.parse(await promisedReadFile(getCorrectPath('config/releaseVersion.json'))); logger.info('current release version', currentInfo); const latestInfo = await getApplicationRelease(); logger.info('latest application release version', latestInfo); diff --git a/src/utils/env.js b/src/utils/env.js index 899d21f..ad5d0f1 100644 --- a/src/utils/env.js +++ b/src/utils/env.js @@ -7,7 +7,7 @@ const logger = log.scope('env.js'); const isDevelopment = () => !app.isPackaged; -const getCorrectPath = targetPath => { +const getCorrectPath = (targetPath, customLevelPath) => { logger.info('targetPath:', targetPath); let returnPath = ''; @@ -23,9 +23,9 @@ const getCorrectPath = targetPath => { returnPath = path.join(app.getAppPath(), targetPath); } else if (isMacOS()) { logger.info('system: macos'); - returnPath = path.join(app.getAppPath(), '../../', targetPath); + returnPath = path.join(app.getAppPath(), customLevelPath || '../../', targetPath); } else { - returnPath = path.join(app.getAppPath(), '../../', targetPath); + returnPath = path.join(app.getAppPath(), customLevelPath || '../../', targetPath); } logger.info('returnPath:', returnPath); return returnPath; diff --git a/src/utils/proxy.js b/src/utils/proxy.js index 0ede52c..5a36b9b 100644 --- a/src/utils/proxy.js +++ b/src/utils/proxy.js @@ -1,7 +1,7 @@ const { promisedReadFile, promisedWriteFile } = require('./promisedFs'); const { getCorrectPath } = require('./env'); -const proxyFilePath = getCorrectPath('src/proxy'); +const proxyFilePath = getCorrectPath('config/proxy'); const setProxy = async proxyUrl => promisedWriteFile(proxyFilePath, proxyUrl);