diff --git a/public/constants/paths.js b/public/constants/paths.js index f41af752..8f2f9f41 100644 --- a/public/constants/paths.js +++ b/public/constants/paths.js @@ -15,6 +15,9 @@ const ICON_PATH = isDev : `file://${path.resolve(__dirname, '..', 'icon.png')}`; const CHROME_ERROR_PATH = 'chrome-error://chromewebdata/'; const DESKTOP_PATH = path.join(os.homedir(), 'Desktop'); +const LOG_FOLDER = isDev + ? path.resolve(__dirname, '..', '..', 'logs') + : path.resolve(process.resourcesPath, '..', 'logs'); module.exports = { REACT_PATH, @@ -23,4 +26,5 @@ module.exports = { ICON_PATH, CHROME_ERROR_PATH, DESKTOP_PATH, + LOG_FOLDER, }; diff --git a/public/libs/log/index.js b/public/libs/log/index.js index b4ed69ff..917e051b 100644 --- a/public/libs/log/index.js +++ b/public/libs/log/index.js @@ -1,13 +1,8 @@ -const isDev = require('electron-is-dev'); -const path = require('path'); - const winston = require('winston'); require('winston-daily-rotate-file'); -const RendererTransport = require('./renderer-transport'); -const dirname = isDev - ? path.resolve(__dirname, '..', '..', '..', 'logs') - : path.resolve(process.resourcesPath, '..', 'logs'); +const { LOG_FOLDER } = require('../../constants/paths'); +const RendererTransport = require('./renderer-transport'); const logger = winston.createLogger({ levels: winston.config.syslog.levels, @@ -18,7 +13,7 @@ const logger = winston.createLogger({ zippedArchive: false, maxSize: '20mb', maxFiles: '14d', - dirname, + dirname: LOG_FOLDER, }), new RendererTransport(), ], @@ -29,7 +24,7 @@ const logger = winston.createLogger({ zippedArchive: false, maxSize: '20mb', maxFiles: '14d', - dirname, + dirname: LOG_FOLDER, }), ], }); diff --git a/public/libs/wiki/wiki-worker.js b/public/libs/wiki/wiki-worker.js index 10ce4e52..6cee1bed 100644 --- a/public/libs/wiki/wiki-worker.js +++ b/public/libs/wiki/wiki-worker.js @@ -4,7 +4,7 @@ const path = require('path'); const $tw = require('tiddlywiki').TiddlyWiki(); async function startNodeJSWiki() { - const { homePath, userName, tiddlyWikiPort = 5112 } = workerData; + const { homePath, tiddlyWikiPort = 5112 } = workerData; const bobServerConfigFolderPath = path.join(homePath, 'settings'); const bobServerConfigPath = path.join(bobServerConfigFolderPath, 'settings.json'); try { @@ -15,7 +15,7 @@ async function startNodeJSWiki() { .catch(() => false) ) { await fs.promises.unlink(bobServerConfigPath); - await fs.promises.unlink(bobServerConfigFolderPath); + await fs.promises.rmdir(bobServerConfigFolderPath); } await fs.promises.mkdir(bobServerConfigFolderPath); } catch (error) { diff --git a/public/listeners/index.js b/public/listeners/index.js index 83f42678..8e3bbc5d 100755 --- a/public/listeners/index.js +++ b/public/listeners/index.js @@ -8,7 +8,7 @@ const { stopWatchWiki } = require('../libs/wiki/watch-wiki'); const { stopWiki } = require('../libs/wiki/wiki-worker-mamager'); const { logger } = require('../libs/log'); const { createWiki, createSubWiki, removeWiki, ensureWikiExist } = require('../libs/create-wiki'); -const { ICON_PATH, REACT_PATH, DESKTOP_PATH } = require('../constants/paths'); +const { ICON_PATH, REACT_PATH, DESKTOP_PATH, LOG_FOLDER } = require('../constants/paths'); const { getPreference, getPreferences, resetPreferences, setPreference } = require('../libs/preferences'); @@ -88,6 +88,7 @@ const loadListeners = () => { ICON_PATH, REACT_PATH, DESKTOP_PATH, + LOG_FOLDER, }[name]; }); ipcMain.handle('request-init-wiki-git', async (event, wikiFolderPath, githubRepoUrl, userInfo, isMainWiki) => { @@ -100,8 +101,12 @@ const loadListeners = () => { } }); - ipcMain.on('request-open', (e, uri) => { - shell.openExternal(uri); + ipcMain.on('request-open', (_, uri, isDirectory) => { + if (isDirectory) { + shell.showItemInFolder(uri); + } else { + shell.openExternal(uri); + } }); // Find In Page diff --git a/src/components/main/index.js b/src/components/main/index.js index 48e2f045..b5f80c40 100644 --- a/src/components/main/index.js +++ b/src/components/main/index.js @@ -28,6 +28,8 @@ import DraggableRegion from './draggable-region'; import arrowWhite from '../../images/arrow-white.png'; import arrowBlack from '../../images/arrow-black.png'; +import { requestOpen, getLogFolderPath } from '../../senders'; + import { requestHibernateWorkspace, requestRemoveWorkspace, @@ -41,6 +43,8 @@ import { requestReload, } from '../../senders'; +console.log(getLogFolderPath()) + // https://github.com/sindresorhus/array-move/blob/master/index.js const arrayMove = (array, from, to) => { const newArray = array.slice(); @@ -233,13 +237,6 @@ const Main = ({ }) => { const workspacesList = getWorkspacesAsList(workspaces); const showTitleBar = window.process.platform === 'darwin' && titleBar && !isFullScreen; - console.log('renderer', Date.now()); - console.warn(`didFailLoad`, JSON.stringify(didFailLoad, null, ' ')); - console.warn(`isLoading`, JSON.stringify(isLoading, null, ' ')); - console.warn( - `Object.keys(workspaces).length > 0 && didFailLoad && !isLoading`, - JSON.stringify(Object.keys(workspaces).length > 0 && didFailLoad && !isLoading, null, ' '), - ); return (