From f62e774e0d618d7d8a5f9a706b0ce112f81c6b5e Mon Sep 17 00:00:00 2001 From: danielc-n Date: Tue, 1 Oct 2024 14:55:01 +0200 Subject: [PATCH] getting rid of 'graceful-fs' and everything is working here --- .github/workflows/node.js.yml | 3 -- e2e-tests/base.test.ts | 2 +- main/index.js | 46 ++++++++++++++----- next.config.js | 10 ---- package.json | 1 - .../EditorPage/AudioEditor/AudioEditor.js | 2 +- .../EditorPage/AudioEditor/MainPlayer.js | 8 ++-- .../Reference/Audio/ReferenceAudio.js | 2 +- .../EditorPage/Reference/OBS/ObsTn.js | 2 +- .../EditorPage/Reference/TA/TaNavigation.js | 2 +- .../EditorPage/Reference/TW/TwNavigation.js | 4 +- .../Reference/TranslationHelpsCard.js | 2 +- .../EditorPage/UsfmEditor/UsfmEditor.js | 2 +- renderer/src/components/Login/LeftLogin.js | 2 +- .../utils/readProjectScope.js | 6 +-- .../utils/updateBurritoScope.js | 2 +- .../src/components/Projects/ImportPopUp.js | 2 +- .../Projects/hooks/useEditProject.js | 2 +- .../CreateProject/AdvancedSettingsDropdown.js | 2 +- .../checkandDownloadObsImages.js | 2 +- .../components/Resources/ImportResource.js | 4 +- .../ResourceUtils/DownloadCreateSBforHelps.js | 2 +- .../Resources/ResourceUtils/RemoveResource.js | 2 +- .../createDownloadedResourceSB.js | 6 +-- .../Resources/useReadLocalResources.js | 2 +- .../Sync/Gitea/EditorSync/EditorSyncUtils.js | 2 +- .../Gitea/ProjectMerge/ProjectMergeUtils.js | 6 +-- .../Sync/Gitea/SyncFromGiteaUtils.js | 2 +- .../src/components/Sync/Scribe/SyncToGitea.js | 2 +- .../Sync/Scribe/SyncToGiteaUtils.js | 4 +- .../src/components/context/ProjectContext.js | 4 +- renderer/src/core/Login/handleJson.js | 2 +- renderer/src/core/Login/handleLogin.js | 2 +- renderer/src/core/Login/removeUser.js | 2 +- renderer/src/core/burrito/importBurrito.js | 6 +-- renderer/src/core/burrito/updateObsSB.js | 2 +- .../src/core/burrito/updateTranslationSB.js | 2 +- renderer/src/core/editor/readFile.js | 2 +- renderer/src/core/editor/writeToFile.js | 2 +- renderer/src/core/export/exportHTML.js | 4 +- .../core/projects/existProjectInBackEnd.js | 2 +- .../src/core/projects/fetchProjectsMeta.js | 2 +- renderer/src/core/projects/handleProfile.js | 4 +- renderer/src/core/projects/metaFileReplace.js | 2 +- .../src/core/projects/saveProjectFiles.js | 2 +- .../src/core/projects/saveProjetcsMeta.js | 2 +- .../src/core/projects/updateAgSettings.js | 2 +- renderer/src/core/projects/userSettings.js | 8 ++-- .../src/core/reference/readCustomResources.js | 2 +- .../src/core/reference/readIngredients.js | 2 +- renderer/src/core/reference/readRefBurrito.js | 2 +- renderer/src/core/reference/readRefMeta.js | 2 +- renderer/src/core/reference/readmanifest.js | 2 +- .../core/reference/writeCustomResources.js | 2 +- .../src/layouts/editor/InnerFramePopup.js | 20 ++------ .../src/layouts/editor/SectionContainer.js | 2 +- .../src/layouts/editor/SectionPlaceholder1.js | 4 +- .../src/layouts/editor/SectionPlaceholder2.js | 4 +- renderer/src/layouts/editor/SubMenuBar.js | 2 +- .../editor/pdfGenInterface/PdfPreview.js | 2 +- .../projects/Export/ExportProjectPopUp.js | 2 +- .../projects/Import/ConflictResolverUI.jsx | 2 +- .../layouts/projects/Import/mergeObsUtils.js | 8 ++-- .../layouts/projects/Import/mergeProject.js | 2 +- .../layouts/projects/ImportProjectPopUp.js | 4 +- .../modules/projects/hooks/useEditProject.js | 2 +- renderer/src/util/createAudioVersification.js | 2 +- renderer/src/util/createJuxtaContent.js | 2 +- renderer/src/util/createObsContent.js | 8 ++-- renderer/src/util/createVersificationUSFM.js | 6 +-- 70 files changed, 135 insertions(+), 137 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 313aa28e5..3ed5e6557 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -76,9 +76,6 @@ jobs: - name: install dependencies run: yarn install - - name: increase max file opened - run: ulimit -n 1048576 - - name: install wine run: | sudo dpkg --add-architecture i386 diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index a97a7fad1..9d122cea9 100755 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -14,7 +14,7 @@ import { createUser, projectPageExpect } from './common'; -const fs = require('graceful-fs'); +const fs = require('fs'); const path = require('path'); const { _electron: electron } = require('@playwright/test'); diff --git a/main/index.js b/main/index.js index adda0474d..786ffce4c 100755 --- a/main/index.js +++ b/main/index.js @@ -1,7 +1,7 @@ // Native require('@electron/remote/main').initialize(); const path = require('path'); -const fs = require('graceful-fs').promises; +const fs = require('fs'); const { format } = require('url'); const { install } = require('@puppeteer/browsers'); const config = require("dotenv"); @@ -21,14 +21,14 @@ function isDev() { async function setPermissions(chromePath) { try { - await fs.chmod(chromePath, '755'); // Set the permissions to be executable + fs.chmodSync(chromePath, '755'); // Set the permissions to be executable console.log(`Permissions set for: ${chromePath}`); } catch (err) { console.error(`Failed to set permissions for ${chromePath}: `, err); } } -async function getChromeCacheDir() { +function getChromeCacheDir() { // Use Electron's app.getPath to get the userData directory (persistent) const dataDir = app.getPath('appData'); @@ -37,28 +37,45 @@ async function getChromeCacheDir() { // Create the folder if it doesn't exist try { - await fs.access(chromeDataDir); + fs.accessSync(chromeDataDir); } catch (err) { // If the directory doesn't exist, create it - await fs.mkdir(chromeDataDir, { recursive: true }); + fs.mkdirSync(chromeDataDir, { recursive: true }); console.log(`Created persistent Chrome data directory at: ${chromeDataDir}`); } return chromeDataDir; } +function getChromeExecutablePath(platform, chromeDir, platformDir) { + let executableName = ''; + if (platform === 'linux') { + executableName = 'chrome-linux64/chrome'; + } else if (platform === 'darwin') { + executableName = 'chrome-mac/Chromium.app/Contents/MacOS/Chromium'; + } else if (platform === 'win64') { + executableName = 'chrome-win64/chrome.exe'; + } + + return path.join(chromeDir, platformDir, executableName); +} + async function verifyAndInstallChrome(version) { const platform = process.platform === 'win32' ? 'win64' : process.platform; // Get the persistent directory - const cacheDir = await getChromeCacheDir(); - const bPath = path.join(cacheDir, `chrome/${platform}-${version}`); + const cacheDir = getChromeCacheDir(); + const chromeDir = path.join(cacheDir, 'chrome'); + const platformDir = `${platform}-${version}`; + + const chromeExecutablePath = getChromeExecutablePath(platform, chromeDir, platformDir); + // Check if the browser is already installed try { - await fs.access(bPath); + fs.accessSync(chromeExecutablePath); console.log(`Chrome version ${version} is already installed.`); - browserPath = bPath; + browserPath = chromeExecutablePath; } catch (err) { console.log(`Chrome version ${version} is not installed. Installing now...`); await install({ @@ -67,10 +84,17 @@ async function verifyAndInstallChrome(version) { buildId: version, platform, }).then((res) => { - browserPath = res.path; + const installedChromePath = getChromeExecutablePath(platform, chromeDir, platformDir); + if (fs.existsSync(installedChromePath)) { + browserPath = installedChromePath; + console.log(`Chrome version ${version} has been installed to ${browserPath}.`); + } + let bet = res.path; + console.log("## browserPath ==",bet); setPermissions(browserPath); + }).catch((err) => { + throw new Error(`Failed to install Chrome version ${version}`); }); - console.log(`Chrome version ${version} has been installed.`); } } diff --git a/next.config.js b/next.config.js index 874faae7f..b77ffcaac 100644 --- a/next.config.js +++ b/next.config.js @@ -11,16 +11,6 @@ const nextConfig = { config.resolve.alias.canvas = false; } - config.optimization = { - ...config.optimization, - minimize: true, - minimizer: [ - new TerserPlugin({ - parallel: 1, - }), - ], - }; - config.module.rules.push({ test: /\.md$/, use: 'raw-loader', diff --git a/package.json b/package.json index 13bb51639..e53d41af2 100644 --- a/package.json +++ b/package.json @@ -180,7 +180,6 @@ "fs-extra": "^10.1.0", "get-system-fonts": "^2.0.2", "gitea-react-toolkit": "2.1.2", - "graceful-fs": "^4.2.11", "history": "^5.3.0", "i18next": "^21.8.9", "ionicons": "^7.1.2", diff --git a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js index 2a1031a8a..cc61639f8 100644 --- a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js +++ b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js @@ -69,7 +69,7 @@ const AudioEditor = ({ editor }) => { // Checking whether the selected book and chapter is in the scope or not if (key === bookId.toUpperCase() && _data.type.flavorType.currentScope[key].includes(chapter)) { _books.push(bookId.toUpperCase()); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); let bookContent = []; const exists = fs.existsSync(path.join(projectsDir, 'text-1', 'ingredients', `${bookId.toUpperCase()}.usfm`)); diff --git a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js index 0afe86d77..88e5f115c 100644 --- a/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js +++ b/renderer/src/components/EditorPage/AudioEditor/MainPlayer.js @@ -57,7 +57,7 @@ const MainPlayer = () => { const loadChapter = async () => { if (audioCurrentChapter) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); // Fetching the Audios const chapters = await fs.readdirSync(path.join(audioCurrentChapter.filePath, audioCurrentChapter.chapterNum)); @@ -101,7 +101,7 @@ const MainPlayer = () => { // Setting up the default audio from the takes const changeDefault = (value) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); let i = 1; // Checking whether the take has any audio @@ -126,7 +126,7 @@ const MainPlayer = () => { .then(({ projectsDir, path, }) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const result = take.replace(/take/g, ''); // Fetching the mp3 files const folderName = fs.readdirSync(path.join(projectsDir, 'audio', 'ingredients', bookId.toUpperCase(), chapter)); @@ -178,7 +178,7 @@ const MainPlayer = () => { const handleFunction = () => { // We have used trigger to identify whether the call is from DeleteAudio or Re-record if (trigger === 'delete') { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const result = take.replace(/take/g, ''); let versePosition; diff --git a/renderer/src/components/EditorPage/Reference/Audio/ReferenceAudio.js b/renderer/src/components/EditorPage/Reference/Audio/ReferenceAudio.js index 42d5a69bb..59f5dd9a9 100644 --- a/renderer/src/components/EditorPage/Reference/Audio/ReferenceAudio.js +++ b/renderer/src/components/EditorPage/Reference/Audio/ReferenceAudio.js @@ -69,7 +69,7 @@ const ReferenceAudio = ({ setIsLoading(true); setDisplayScreen(false); setBookData(); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); // Fetching the reference list diff --git a/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js b/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js index 04f68278d..4c91173df 100644 --- a/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js +++ b/renderer/src/components/EditorPage/Reference/OBS/ObsTn.js @@ -78,7 +78,7 @@ function ObsTnCard({ try { localForage.getItem('userProfile').then(async (user) => { logger.debug('OfflineResourceFetch.js', 'reading offline obs-tn ', offlineResource.data?.projectDir); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const currentUser = user?.username; diff --git a/renderer/src/components/EditorPage/Reference/TA/TaNavigation.js b/renderer/src/components/EditorPage/Reference/TA/TaNavigation.js index c588a7f3f..203fe7c3d 100644 --- a/renderer/src/components/EditorPage/Reference/TA/TaNavigation.js +++ b/renderer/src/components/EditorPage/Reference/TA/TaNavigation.js @@ -64,7 +64,7 @@ export default function TaNavigation({ languageId, referenceResources }) { // console.log('offline data : ', { taList, offlineResource }); localForage.getItem('userProfile').then(async (user) => { logger.debug('TaNavigation.js', 'reading offline helps ', offlineResource.data?.projectDir); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const currentUser = user?.username; diff --git a/renderer/src/components/EditorPage/Reference/TW/TwNavigation.js b/renderer/src/components/EditorPage/Reference/TW/TwNavigation.js index e79b63cb6..92eeaa31a 100644 --- a/renderer/src/components/EditorPage/Reference/TW/TwNavigation.js +++ b/renderer/src/components/EditorPage/Reference/TW/TwNavigation.js @@ -25,7 +25,7 @@ export default function TwNavigation({ languageId, referenceResources, setRefere if (referenceResources && referenceResources?.offlineResource?.offline) { const { offlineResource } = referenceResources; localForage.getItem('userProfile').then(async (user) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const currentUser = user?.username; @@ -97,7 +97,7 @@ export default function TwNavigation({ languageId, referenceResources, setRefere const taArrayOffline = []; const { offlineResource } = referenceResources; localForage.getItem('userProfile').then(async (user) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const currentUser = user?.username; diff --git a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js index ca7c37603..465ea3888 100644 --- a/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js +++ b/renderer/src/components/EditorPage/Reference/TranslationHelpsCard.js @@ -75,7 +75,7 @@ export default function TranslationHelpsCard({ setOfflineItems(''); localForage.getItem('userProfile').then(async (user) => { logger.debug('TranslationHelpsCard.js', `reading offline helps ${offlineResource.data?.projectDir}`); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const currentUser = user?.username; diff --git a/renderer/src/components/EditorPage/UsfmEditor/UsfmEditor.js b/renderer/src/components/EditorPage/UsfmEditor/UsfmEditor.js index 376da6ddb..580f27ba7 100644 --- a/renderer/src/components/EditorPage/UsfmEditor/UsfmEditor.js +++ b/renderer/src/components/EditorPage/UsfmEditor/UsfmEditor.js @@ -347,7 +347,7 @@ const UsfmEditor = () => { const username = value?.username; localforage.getItem('currentProject').then((projectName) => { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const projectsDir = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectName); const metaPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectName, 'metadata.json'); diff --git a/renderer/src/components/Login/LeftLogin.js b/renderer/src/components/Login/LeftLogin.js index 44e86130c..6468d8980 100644 --- a/renderer/src/components/Login/LeftLogin.js +++ b/renderer/src/components/Login/LeftLogin.js @@ -97,7 +97,7 @@ const LeftLogin = () => { // router.push('/main'); // The below code is commented for UI dev purpose. if (handleValidation(values)) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); logger.debug( 'LeftLogin.js', 'Triggers handleLogin to check whether the user is existing or not', diff --git a/renderer/src/components/ProjectManagement/utils/readProjectScope.js b/renderer/src/components/ProjectManagement/utils/readProjectScope.js index 8d704fd89..d95c021d6 100644 --- a/renderer/src/components/ProjectManagement/utils/readProjectScope.js +++ b/renderer/src/components/ProjectManagement/utils/readProjectScope.js @@ -14,8 +14,8 @@ const getDirectories = (readdirSync, source) => readdirSync(source, { withFileTy export const getScope = async (project) => { const path = require('path'); const scope = {}; - const { readdirSync } = window.require('graceful-fs'); - const fs = window.require('graceful-fs'); + const { readdirSync } = window.require('fs'); + const fs = window.require('fs'); const list = getDirectories(readdirSync, project); list.forEach(async (book) => { @@ -43,7 +43,7 @@ export const readProjectScope = async (projectName) => { logger.debug('readProjectScope.js', `In read metadata - ${projectName}`); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, 'projects'); diff --git a/renderer/src/components/ProjectManagement/utils/updateBurritoScope.js b/renderer/src/components/ProjectManagement/utils/updateBurritoScope.js index 4e45bcef6..a33799799 100644 --- a/renderer/src/components/ProjectManagement/utils/updateBurritoScope.js +++ b/renderer/src/components/ProjectManagement/utils/updateBurritoScope.js @@ -7,7 +7,7 @@ export const updateBurritoScope = async (projectName, metadata) => { logger.debug('updateBurritoScope.js', `In update metadata - ${projectName}`); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, 'projects'); // Finally updating the scope in the metadata diff --git a/renderer/src/components/Projects/ImportPopUp.js b/renderer/src/components/Projects/ImportPopUp.js index d9c8b41da..d11e5821c 100644 --- a/renderer/src/components/Projects/ImportPopUp.js +++ b/renderer/src/components/Projects/ImportPopUp.js @@ -111,7 +111,7 @@ export default function ImportPopUp(props) { const importFiles = (folderPath) => { logger.debug('ImportPopUp.js', 'Inside importFiles'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const files = []; const bookCodeList = []; folderPath.forEach((filePath) => { diff --git a/renderer/src/components/Projects/hooks/useEditProject.js b/renderer/src/components/Projects/hooks/useEditProject.js index 3f5d71c6d..c2bd4631e 100644 --- a/renderer/src/components/Projects/hooks/useEditProject.js +++ b/renderer/src/components/Projects/hooks/useEditProject.js @@ -26,7 +26,7 @@ const useEditProject = () => { const userProfile = await localforage.getItem('userProfile'); if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); folder = path.join(newpath, packageInfo.name, 'users', userProfile.username, 'projects', `${project.name}_${project.id[0]}`); data = fs.readFileSync(path.join(folder, 'metadata.json'), 'utf-8'); diff --git a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js index 3c48094ed..be75e50f9 100644 --- a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js +++ b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js @@ -92,7 +92,7 @@ export default function AdvancedSettingsDropdown({ call, project, projectType }) if (isElectron()) { let title = licenceTitle; let myLicence = {}; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if ((title === 'Custom' || !title) && !selectNew) { myLicence.title = 'Custom'; myLicence.locked = false; diff --git a/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js b/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js index bcfb7b85b..743752ff6 100644 --- a/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js +++ b/renderer/src/components/Resources/DownloadObsImages/checkandDownloadObsImages.js @@ -48,7 +48,7 @@ export const checkandDownloadObsImages = async () => { // check for the folder and images // const imageCdnBaseUrl = 'https://cdn.door43.org/obs/jpg/360px/'; if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const obsImagePath = path.join(newpath, packageInfo.name, 'common', environment.OBS_IMAGE_DIR); diff --git a/renderer/src/components/Resources/ImportResource.js b/renderer/src/components/Resources/ImportResource.js index d51ce8cc1..7a327ad3e 100644 --- a/renderer/src/components/Resources/ImportResource.js +++ b/renderer/src/components/Resources/ImportResource.js @@ -53,7 +53,7 @@ export default function ImportResource({ }; const importReference = async (projectsDir, name, burritoType) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const fse = window.require('fs-extra'); const path = require('path'); let dirPath; @@ -84,7 +84,7 @@ export default function ImportResource({ setFolderPath(''); }; const uploadRefBible = async () => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); try { const user = await localforage.getItem('userProfile'); diff --git a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js index 45fe24e77..46cb20cb9 100644 --- a/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js +++ b/renderer/src/components/Resources/ResourceUtils/DownloadCreateSBforHelps.js @@ -18,7 +18,7 @@ const DownloadCreateSBforHelps = async (projectResource, setLoading, update = fa setLoading(true); await localForage.getItem('userProfile').then(async (user) => { logger.debug('DownloadCreateSBforHelps.js', 'In helps-resource download user fetch - ', user?.username); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources'); diff --git a/renderer/src/components/Resources/ResourceUtils/RemoveResource.js b/renderer/src/components/Resources/ResourceUtils/RemoveResource.js index 68447f0ff..8a3609d60 100644 --- a/renderer/src/components/Resources/ResourceUtils/RemoveResource.js +++ b/renderer/src/components/Resources/ResourceUtils/RemoveResource.js @@ -118,7 +118,7 @@ function RemoveResource({ logger.warn('removeResource.js', 'inside removing resource call'); localForage.getItem('userProfile').then(async (user) => { logger.debug('DownloadResourcePopUp.js', 'In resource download user fetch - ', user?.username); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources'); let resourceName = null; diff --git a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js index 6db604f39..e04670632 100644 --- a/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js +++ b/renderer/src/components/Resources/ResourceUtils/createDownloadedResourceSB.js @@ -161,7 +161,7 @@ export const generateResourceIngredientsTextTransaltion = async (currentResource // generating ingredients content in metadata currentResourceMeta?.projects.forEach(async (project) => { logger.debug('createDownloadedResourceSB.js', 'In adding ingredients to burrito for TextTransaltion'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (fs.existsSync(path.join(folder, currentResourceProject.name, project.path))) { const filecontent = await fs.readFileSync(path.join(folder, currentResourceProject.name, project.path), 'utf8'); // find checksum & size by reading the file @@ -184,7 +184,7 @@ export const generateResourceIngredientsTextTransaltion = async (currentResource export const generateResourceIngredientsOBS = async (currentResourceMeta, path, folder, currentResourceProject, resourceBurritoFile, files) => { logger.debug('createDownloadedResourceSB.js', 'In adding ingredients to burrito of OBS'); files.forEach(async (file) => { // en_obs/content/01.md, en_obs/content/front/title.md - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const endPart = file.split('/').pop(); const regX = /^\d{2}.md$/; if (regX.test(endPart) || ['intro.md', 'title.md'].indexOf(endPart) > -1) { @@ -272,7 +272,7 @@ export const handleDownloadResources = async (resourceData, selectResource, acti localForage.getItem('userProfile').then(async (user) => { logger.debug('createDownloadedResourceSB.js', 'In create downloaded resource SB user fetch - ', user?.username); const folder = path.join(newpath, packageInfo.name, 'users', `${user?.username}`, 'resources'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); let resourceBurritoFile = {}; let currentResourceMeta = ''; let currentResourceProject = ''; diff --git a/renderer/src/components/Resources/useReadLocalResources.js b/renderer/src/components/Resources/useReadLocalResources.js index 04039cca4..675603a79 100644 --- a/renderer/src/components/Resources/useReadLocalResources.js +++ b/renderer/src/components/Resources/useReadLocalResources.js @@ -11,7 +11,7 @@ import { createDirectory, newPath } from '../../../../supabase'; export default async function readLocalResources(username, setSubMenuItems) { if (isElectron()) { const parseData = []; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const projectsDir = path.join(newpath, packageInfo.name, 'users', username, 'resources');// Read user resources diff --git a/renderer/src/components/Sync/Gitea/EditorSync/EditorSyncUtils.js b/renderer/src/components/Sync/Gitea/EditorSync/EditorSyncUtils.js index fe6ed03f4..0e32b184e 100644 --- a/renderer/src/components/Sync/Gitea/EditorSync/EditorSyncUtils.js +++ b/renderer/src/components/Sync/Gitea/EditorSync/EditorSyncUtils.js @@ -7,7 +7,7 @@ import { uploadToGitea } from '../../Scribe/SyncToGitea'; export async function getGiteaUsersList() { let usersList = []; const userData = await localForage.getItem('userProfile'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const file = path.join(newpath, packageInfo.name, 'users', userData?.username, environment.USER_SETTING_FILE); diff --git a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js index fc2512eb3..0865e0928 100644 --- a/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js +++ b/renderer/src/components/Sync/Gitea/ProjectMerge/ProjectMergeUtils.js @@ -10,7 +10,7 @@ export const uploadProjectToBranchRepoExist = async (selectedGiteaProject, ignor repo, branch, metaDataSB, localUsername, auth, } = selectedGiteaProject; const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const projectId = Object.keys(metaDataSB.identification.primary.scribe)[0]; const projectName = metaDataSB.identification.name.en; @@ -73,7 +73,7 @@ export const backupLocalProject = async (selectedGiteaProject, actions) => { logger.debug('ProjectMErgeUtils.js', 'Stated Backing up the project', projectName); const newpath = localStorage.getItem('userPath'); const fse = window.require('fs-extra'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const projectsMetaPath = path.join(newpath, packageInfo.name, 'users', selectedGiteaProject?.localUsername, 'projects', `${projectName}_${projectId}`); const projectBackupPath = path.join(newpath, packageInfo.name, 'users', selectedGiteaProject?.localUsername, 'projects-backups'); @@ -92,7 +92,7 @@ export const backupLocalProject = async (selectedGiteaProject, actions) => { export const undoMergeOrDeleteOldBackup = async (selectedGiteaProject, backupName, SYNC_BACKUP_COUNT, undo = false) => { logger.debug('ProjectMErgeUtils.js', 'in undo merge or delete old backup'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const projectBackupPath = path.join(newpath, packageInfo.name, 'users', selectedGiteaProject?.localUsername, 'projects-backups'); // Sorted files in directory on creation date diff --git a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js index 0d32b27fa..20841bfe6 100644 --- a/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js +++ b/renderer/src/components/Sync/Gitea/SyncFromGiteaUtils.js @@ -188,7 +188,7 @@ export const cloneAndSetProject = async (fs, gitprojectDir, repo, userBranch, au export const importServerProject = async (updateBurrito, repo, sbData, auth, userBranch, action, currentUser, duplicate, setPullPopup, setPullData, t = undefined) => { try { logger.debug('SyncFromGiteaUtils.js', 'Inside Import Project core'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const sbDataObject = { ...sbData }; const projectDir = path.join(newpath, packageInfo.name, 'users', currentUser, 'projects'); diff --git a/renderer/src/components/Sync/Scribe/SyncToGitea.js b/renderer/src/components/Sync/Scribe/SyncToGitea.js index 83cd919e8..3acc70bdb 100644 --- a/renderer/src/components/Sync/Scribe/SyncToGitea.js +++ b/renderer/src/components/Sync/Scribe/SyncToGitea.js @@ -18,7 +18,7 @@ export async function uploadToGitea(projectDataAg, auth, setSyncProgress, notify const localBranch = `${auth?.user?.username}/${packageInfo.name}`; await localForage.getItem('userProfile').then(async (user) => { const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const projectsMetaPath = path.join(newpath, packageInfo.name, 'users', user?.username, 'projects', `${projectName}_${projectId}`); // Create A REPO for the project diff --git a/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js b/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js index ba525d42e..b7f659138 100644 --- a/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js +++ b/renderer/src/components/Sync/Scribe/SyncToGiteaUtils.js @@ -92,7 +92,7 @@ export const updateFiletoServer = async (fileContent, filePath, branch, repoName // sync profile updation export const createSyncProfile = async (auth) => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); await localForage.getItem('userProfile').then(async (user) => { const currentUser = user?.username; @@ -165,7 +165,7 @@ export const getOrPutLastSyncInAgSettings = async (method, projectMeta, syncUser if (method === 'get' || method === 'put') { let currentUser = await localForage.getItem('userProfile'); currentUser = currentUser?.username; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const id = Object.keys(projectMeta?.identification?.primary?.scribe); diff --git a/renderer/src/components/context/ProjectContext.js b/renderer/src/components/context/ProjectContext.js index 7540657e8..83d0d8ff5 100644 --- a/renderer/src/components/context/ProjectContext.js +++ b/renderer/src/components/context/ProjectContext.js @@ -181,7 +181,7 @@ const ProjectContextProvider = ({ children }) => { logger.error('ProjectContext.js', 'Unable to find current user'); return; } - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const file = path.join(newpath, packageInfo.name, 'users', currentUser, environment.USER_SETTING_FILE); if (fs.existsSync(file)) { const agUserSettings = await fs.readFileSync(file); @@ -279,7 +279,7 @@ const ProjectContextProvider = ({ children }) => { currentUser = value.username; setUsername(value.username); }); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const file = path.join(newpath, packageInfo.name, 'users', currentUser, environment.USER_SETTING_FILE); if (fs.existsSync(file)) { const agUserSettings = await fs.readFileSync(file); diff --git a/renderer/src/core/Login/handleJson.js b/renderer/src/core/Login/handleJson.js index d200d388a..4eda99dd7 100644 --- a/renderer/src/core/Login/handleJson.js +++ b/renderer/src/core/Login/handleJson.js @@ -16,7 +16,7 @@ const uniqueUser = (users, username) => users.some((user) => user.username === u */ export const loadUsers = async () => { const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', 'users.json'); if (fs.existsSync(file)) { diff --git a/renderer/src/core/Login/handleLogin.js b/renderer/src/core/Login/handleLogin.js index 445ad3adc..4e0071c60 100644 --- a/renderer/src/core/Login/handleLogin.js +++ b/renderer/src/core/Login/handleLogin.js @@ -42,7 +42,7 @@ export const createWebUser = async (values) => { */ export const writeToFile = (users) => { const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', 'users.json'); fs.writeFileSync(file, JSON.stringify(users), (err) => { diff --git a/renderer/src/core/Login/removeUser.js b/renderer/src/core/Login/removeUser.js index b8578069d..54de61b32 100644 --- a/renderer/src/core/Login/removeUser.js +++ b/renderer/src/core/Login/removeUser.js @@ -3,7 +3,7 @@ import packageInfo from '../../../../package.json'; export const removeUser = async (userName) => { const newpath = await localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const folder = path.join(newpath, packageInfo.name, 'users', userName.toLowerCase()); const file = path.join(newpath, packageInfo.name, 'users', 'users.json'); diff --git a/renderer/src/core/burrito/importBurrito.js b/renderer/src/core/burrito/importBurrito.js index f30a10306..6334a356a 100644 --- a/renderer/src/core/burrito/importBurrito.js +++ b/renderer/src/core/burrito/importBurrito.js @@ -32,7 +32,7 @@ export const checkImportDuplicate = async (folderList, projectName, metadata, pr export const checkDuplicate = async (metadata, currentUser, resource) => { logger.debug('importBurrito.js', 'In checkDuplicate'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const projectName = metadata.identification?.name?.en; let existingProject; let id; @@ -82,7 +82,7 @@ export const checkDuplicate = async (metadata, currentUser, resource) => { }; export const viewBurrito = async (filePath, currentUser, resource) => { logger.debug('importBurrito.js', 'Inside viewBurrito'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const result = {}; if (fs.existsSync(path.join(filePath, 'metadata.json'))) { logger.debug('importBurrito.js', 'Project has Burrito file metadata.json.'); @@ -186,7 +186,7 @@ const checkTheProjectIsAudioChapterLevel = async (metadata) => { // Core Function Handle Burrito Import for all type of Projects const importBurrito = async (filePath, currentUser, updateBurritoVersion, concatedLangs = []) => { logger.debug('importBurrito.js', 'Inside importBurrito'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const fse = window.require('fs-extra'); const status = []; const newpath = localStorage.getItem('userPath'); diff --git a/renderer/src/core/burrito/updateObsSB.js b/renderer/src/core/burrito/updateObsSB.js index 91f44df43..b66e8efc4 100644 --- a/renderer/src/core/burrito/updateObsSB.js +++ b/renderer/src/core/burrito/updateObsSB.js @@ -32,7 +32,7 @@ const updateObsSB = async (username, project, updateBurrito) => new Promise((res logger.debug('updateObsSB.js', 'In updateObsSB for updating the burrito.'); const newpath = localStorage.getItem('userPath'); const folder = path.join(newpath, packageInfo.name, 'users', username, 'projects', `${project.name}_${project.id[0]}`); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const sb = fs.readFileSync(path.join(folder, 'metadata.json')); let metadata = JSON.parse(sb); // eslint-disable-next-line no-unused-vars diff --git a/renderer/src/core/burrito/updateTranslationSB.js b/renderer/src/core/burrito/updateTranslationSB.js index db5e4ca81..20ba76085 100644 --- a/renderer/src/core/burrito/updateTranslationSB.js +++ b/renderer/src/core/burrito/updateTranslationSB.js @@ -35,7 +35,7 @@ const updateTranslationSB = async (username, project, updateBurrito) => new Prom logger.debug('updateTranslationSB.js', 'In updateTranslationSB for updating the burrito.'); const newpath = localStorage.getItem('userPath'); const folder = path.join(newpath, packageInfo.name, 'users', username, 'projects', `${project.name}_${project.id[0]}`); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const sb = fs.readFileSync(path.join(folder, 'metadata.json')); let metadata = JSON.parse(sb); // eslint-disable-next-line no-unused-vars diff --git a/renderer/src/core/editor/readFile.js b/renderer/src/core/editor/readFile.js index 20aa06a55..2ada6d2d3 100644 --- a/renderer/src/core/editor/readFile.js +++ b/renderer/src/core/editor/readFile.js @@ -13,7 +13,7 @@ export const readFile = async ({ filename, }) => { if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const projectsPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectname, filename); diff --git a/renderer/src/core/editor/writeToFile.js b/renderer/src/core/editor/writeToFile.js index 4f60e0367..a4a8066ba 100644 --- a/renderer/src/core/editor/writeToFile.js +++ b/renderer/src/core/editor/writeToFile.js @@ -12,7 +12,7 @@ const writeToFile = async ({ data, }) => { if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const newpath = localStorage.getItem('userPath'); const projectsPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectname, filename); diff --git a/renderer/src/core/export/exportHTML.js b/renderer/src/core/export/exportHTML.js index c0ad4931f..b2689d187 100644 --- a/renderer/src/core/export/exportHTML.js +++ b/renderer/src/core/export/exportHTML.js @@ -103,7 +103,7 @@ export const exportHTML = () => { new Date(), )}.html`, ); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); fs.writeFile(filepath, inlineData, (err) => { if (err) { logger.info('dynamic-msg-went-wrong', err); @@ -165,7 +165,7 @@ export const exportHTML = () => { new Date(), )}.html`, ); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); fs.writeFile(filepath, inlineData, (err) => { if (err) { logger.info('dynamic-msg-went-wrong', err); diff --git a/renderer/src/core/projects/existProjectInBackEnd.js b/renderer/src/core/projects/existProjectInBackEnd.js index e9a33d68d..49daa4b40 100644 --- a/renderer/src/core/projects/existProjectInBackEnd.js +++ b/renderer/src/core/projects/existProjectInBackEnd.js @@ -16,7 +16,7 @@ function isBackendProjectExist(ProjectDir) { localforage.getItem('userProfile').then(async (value) => { if (isElectron()) { const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (value?.username) { const resourcePath = path.join(newpath, packageInfo.name, 'users', value.username, 'resources', ProjectDir); // check for path exist or not and resolve true or false will work for pane 1 now add for other panes diff --git a/renderer/src/core/projects/fetchProjectsMeta.js b/renderer/src/core/projects/fetchProjectsMeta.js index df743b291..a8ad5618a 100644 --- a/renderer/src/core/projects/fetchProjectsMeta.js +++ b/renderer/src/core/projects/fetchProjectsMeta.js @@ -15,7 +15,7 @@ const fetchProjectsMeta = async ({ currentUser }) => { if (isElectron()) { logger.debug('fetchProjectsMeta.js', 'In fetchProjectsMeta'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const projectsMetaPath = path.join(newpath, packageInfo.name, 'users', currentUser, 'projects'); fs.mkdirSync(projectsMetaPath, { recursive: true }); diff --git a/renderer/src/core/projects/handleProfile.js b/renderer/src/core/projects/handleProfile.js index 9472c92e6..054c280f4 100644 --- a/renderer/src/core/projects/handleProfile.js +++ b/renderer/src/core/projects/handleProfile.js @@ -16,7 +16,7 @@ export const getorPutAppLangage = async (method, currentUser, appLang) => { if (isElectron()) { logger.error('handleProfile.js', 'In updateAppLang, for updating the App language Selection'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); let file; if (currentUser) { @@ -68,7 +68,7 @@ export const getorPutAppLangage = async (method, currentUser, appLang) => { const updateJson = async (userdata) => { logger.error('handleProfile.js', 'In UpdateJson, for updating the current user details'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', 'users.json'); const status = []; diff --git a/renderer/src/core/projects/metaFileReplace.js b/renderer/src/core/projects/metaFileReplace.js index dd62f621d..6978cc045 100644 --- a/renderer/src/core/projects/metaFileReplace.js +++ b/renderer/src/core/projects/metaFileReplace.js @@ -3,7 +3,7 @@ import packageInfo from '../../../../package.json'; const metaFileReplace = ({ userData }) => { const newpath = localStorage.getItem('userPath'); const status = []; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const json = JSON.stringify(userData); const projectsMetaPath = path.join(newpath, packageInfo.name, 'users', 'username', 'projects', 'projects.json'); diff --git a/renderer/src/core/projects/saveProjectFiles.js b/renderer/src/core/projects/saveProjectFiles.js index fdc244b81..25423060b 100644 --- a/renderer/src/core/projects/saveProjectFiles.js +++ b/renderer/src/core/projects/saveProjectFiles.js @@ -6,7 +6,7 @@ const saveProjectsFiles = ({ filenames, }) => { const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); fs.mkdirSync(path.join(newpath, packageInfo.name, 'users', username, 'projects', projectname), { recursive: true, diff --git a/renderer/src/core/projects/saveProjetcsMeta.js b/renderer/src/core/projects/saveProjetcsMeta.js index ad55534bf..bd3083779 100644 --- a/renderer/src/core/projects/saveProjetcsMeta.js +++ b/renderer/src/core/projects/saveProjetcsMeta.js @@ -54,7 +54,7 @@ export const saveProjectsMeta = async (projectMetaObj) => { logger.debug('saveProjectsMeta.js', 'In saveProjectsMeta'); const newpath = localStorage.getItem('userPath'); const status = []; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); let currentUser; await localforage.getItem('userProfile').then((value) => { diff --git a/renderer/src/core/projects/updateAgSettings.js b/renderer/src/core/projects/updateAgSettings.js index d18b06971..60f4d597f 100644 --- a/renderer/src/core/projects/updateAgSettings.js +++ b/renderer/src/core/projects/updateAgSettings.js @@ -15,7 +15,7 @@ import { export const updateAgSettings = async (username, projectName, data, font, fontSize = 1) => { logger.debug('updateAgSettings.js', 'In updateAgSettings'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const result = Object.keys(data.ingredients).filter((key) => key.includes(environment.PROJECT_SETTING_FILE)); const folder = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectName, result[0]); diff --git a/renderer/src/core/projects/userSettings.js b/renderer/src/core/projects/userSettings.js index 01b12e833..c994ba9ac 100644 --- a/renderer/src/core/projects/userSettings.js +++ b/renderer/src/core/projects/userSettings.js @@ -8,7 +8,7 @@ export const readUserSettings = async () => { logger.debug('userSettings.js', 'In readUserSettings'); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, environment.USER_SETTING_FILE); @@ -32,7 +32,7 @@ export const readJsonFiles = async (fileType, dirName = 'ingredients') => { logger.debug('userSettings.js', 'In readSettings'); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, 'projects'); let filePath; @@ -72,7 +72,7 @@ export const saveJsonFiles = async (data, fileType, dirName = 'ingredients') => logger.debug('userSettings.js', 'In saveUserSettings'); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, 'projects'); let filePath; @@ -101,7 +101,7 @@ export const saveUserSettings = async (userSettingsJson) => { logger.debug('userSettings.js', 'In saveUserSettings'); const currentUser = await localForage.getItem('userProfile'); const newpath = localStorage.getItem('userPath'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); const file = path.join(newpath, packageInfo.name, 'users', currentUser.username, environment.USER_SETTING_FILE); await fs.writeFileSync(file, JSON.stringify(userSettingsJson)); diff --git a/renderer/src/core/reference/readCustomResources.js b/renderer/src/core/reference/readCustomResources.js index 1a2a47158..b5a0a6f56 100644 --- a/renderer/src/core/reference/readCustomResources.js +++ b/renderer/src/core/reference/readCustomResources.js @@ -14,7 +14,7 @@ export async function readCustomResources({ resourceId, translationData }) { // {id: 'tw', resourceType: "translationWords"}, // { id: 'obs-tq', resourceType: 'obsTranslationQuestions' }, ]; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const userProfile = await localforage.getItem('userProfile'); const currentUser = userProfile.username; diff --git a/renderer/src/core/reference/readIngredients.js b/renderer/src/core/reference/readIngredients.js index d6826e842..d0a1801ad 100644 --- a/renderer/src/core/reference/readIngredients.js +++ b/renderer/src/core/reference/readIngredients.js @@ -4,7 +4,7 @@ export const readIngredients = async ({ filePath, }) => { logger.debug('readIngreadients.js', 'In readIngredients'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); return new Promise((resolve) => { if (fs.existsSync(filePath)) { diff --git a/renderer/src/core/reference/readRefBurrito.js b/renderer/src/core/reference/readRefBurrito.js index 1f853c2a4..73f56fe1b 100644 --- a/renderer/src/core/reference/readRefBurrito.js +++ b/renderer/src/core/reference/readRefBurrito.js @@ -8,7 +8,7 @@ export const readRefBurrito = async ({ }) => { if (isElectron()) { logger.debug('readRefBurrito.js', 'In readRefBurrito'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); return new Promise((resolve) => { if (fs.existsSync(metaPath)) { diff --git a/renderer/src/core/reference/readRefMeta.js b/renderer/src/core/reference/readRefMeta.js index e87a38340..2c7322666 100644 --- a/renderer/src/core/reference/readRefMeta.js +++ b/renderer/src/core/reference/readRefMeta.js @@ -8,7 +8,7 @@ export const readRefMeta = async ({ projectsDir, }) => { if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const path = require('path'); return new Promise((resolve) => { if (fs.existsSync(projectsDir)) { diff --git a/renderer/src/core/reference/readmanifest.js b/renderer/src/core/reference/readmanifest.js index e8a28ed3d..36d44fd37 100644 --- a/renderer/src/core/reference/readmanifest.js +++ b/renderer/src/core/reference/readmanifest.js @@ -5,7 +5,7 @@ import { environment } from '../../../environment'; const path = require('path'); export async function readCustomResources({ resourceId }) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); let currentUser; await localforage.getItem('userProfile').then((value) => { diff --git a/renderer/src/core/reference/writeCustomResources.js b/renderer/src/core/reference/writeCustomResources.js index d56a54fb4..994a2a46f 100644 --- a/renderer/src/core/reference/writeCustomResources.js +++ b/renderer/src/core/reference/writeCustomResources.js @@ -5,7 +5,7 @@ import { environment } from '../../../environment'; const path = require('path'); export async function writeCustomResources({ resourceUrl }) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); let currentUser; await localforage.getItem('userProfile').then((value) => { diff --git a/renderer/src/layouts/editor/InnerFramePopup.js b/renderer/src/layouts/editor/InnerFramePopup.js index ad07bed67..ace7c4a01 100644 --- a/renderer/src/layouts/editor/InnerFramePopup.js +++ b/renderer/src/layouts/editor/InnerFramePopup.js @@ -97,7 +97,7 @@ function messageToPeople(json) { function createSection(folder, pickerJson) { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const fixedPath = fixPath(folder); let projects; @@ -502,7 +502,7 @@ export default function InnerFramePopup() { }, [nameFile]); useEffect(() => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const os = window.require('os'); const path = window.require('path'); @@ -819,7 +819,7 @@ export default function InnerFramePopup() { } } onClick={async () => { - const executablePath = await global.ipcRenderer.invoke('get-browser-path'); + let executablePath = await global.ipcRenderer.invoke('get-browser-path'); let browser; if (jsonValidation.length === 0) { try { @@ -827,14 +827,11 @@ export default function InnerFramePopup() { headless: 'new', args: [ '--disable-web-security', - '--no-sandbox', - '--disable-setuid-sandbox', ], - ignoreDefaultArgs: ['--disable-extensions'], executablePath, }); } catch (err) { - console.log('Puppeteer falling back to no-sandbox'); + logger.error('InnerFramePopup.js', 'Puppeteer falling back to no-sandbox'); browser = await global.puppeteer.launch({ headless: 'new', args: [ @@ -842,21 +839,12 @@ export default function InnerFramePopup() { '--no-sandbox', '--disable-setuid-sandbox', ], - ignoreDefaultArgs: ['--disable-extensions'], executablePath, }); } setMessagePrint(''); setMessagePrint('Generating Pdf ...'); try { - // setMessagePrint((prev) => `${prev }\nInstanciating browser ... `); - // let browser = await global.puppeteer.connect({ - // // browserURL: 'http://localhost:8000', - // browserWSEndpoint: wsEndpoint, - // // defaultViewport: null - // }); - console.log('browser ok! : browser.version()', await browser.version()); - // const browser = await ipcRenderer.invoke('instanciate-browserpie'); setMessagePrint((prev) => `${prev}\nInstanciating pdfGen`); const pdfGen = new global.PdfGenStatic( { ...JSON.parse(kitchenFaucet), browser }, diff --git a/renderer/src/layouts/editor/SectionContainer.js b/renderer/src/layouts/editor/SectionContainer.js index 4acaaae92..4e4415eb2 100644 --- a/renderer/src/layouts/editor/SectionContainer.js +++ b/renderer/src/layouts/editor/SectionContainer.js @@ -22,7 +22,7 @@ const SectionContainer = () => { const username = value?.username; localforage.getItem('currentProject').then((projectName) => { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const metaPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectName, 'metadata.json'); const data = fs.readFileSync(metaPath, 'utf-8'); diff --git a/renderer/src/layouts/editor/SectionPlaceholder1.js b/renderer/src/layouts/editor/SectionPlaceholder1.js index 44adfcf2b..eb39a744e 100644 --- a/renderer/src/layouts/editor/SectionPlaceholder1.js +++ b/renderer/src/layouts/editor/SectionPlaceholder1.js @@ -288,11 +288,11 @@ const SectionPlaceholder1 = ({ editor }) => { // if (isElectron()) { localforage.getItem('userProfile').then(async (user) => { if (_obsNavigation1 && referenceColumnOneData1.refName && referenceColumnOneData1.selectedResource === 'obs') { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); setStories1(core(fs, _obsNavigation1, referenceColumnOneData1.refName, user.username)); } if (_obsNavigation2 && referenceColumnOneData2.refName && referenceColumnOneData2.selectedResource === 'obs') { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); setStories2(core(fs, _obsNavigation2, referenceColumnOneData2.refName, user.username)); } }); diff --git a/renderer/src/layouts/editor/SectionPlaceholder2.js b/renderer/src/layouts/editor/SectionPlaceholder2.js index 70297a368..cde0d258f 100644 --- a/renderer/src/layouts/editor/SectionPlaceholder2.js +++ b/renderer/src/layouts/editor/SectionPlaceholder2.js @@ -290,11 +290,11 @@ const SectionPlaceholder2 = ({ editor }) => { useEffect(() => { localforage.getItem('userProfile').then((user) => { if (_obsNavigation1 && referenceColumnTwoData1.refName && referenceColumnTwoData1.selectedResource === 'obs') { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); setStories1(core(fs, _obsNavigation1, referenceColumnTwoData1.refName, user.username)); } if (_obsNavigation2 && referenceColumnTwoData2.refName && referenceColumnTwoData2.selectedResource === 'obs') { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); setStories2(core(fs, _obsNavigation2, referenceColumnTwoData2.refName, user.username)); } }); diff --git a/renderer/src/layouts/editor/SubMenuBar.js b/renderer/src/layouts/editor/SubMenuBar.js index d5ac98b2b..31c29817e 100644 --- a/renderer/src/layouts/editor/SubMenuBar.js +++ b/renderer/src/layouts/editor/SubMenuBar.js @@ -131,7 +131,7 @@ export default function SubMenuBar() { const username = value?.username; localforage.getItem('currentProject').then((projectName) => { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); const metaPath = path.join(newpath, packageInfo.name, 'users', username, 'projects', projectName, 'metadata.json'); const data = fs.readFileSync(metaPath, 'utf-8'); diff --git a/renderer/src/layouts/editor/pdfGenInterface/PdfPreview.js b/renderer/src/layouts/editor/pdfGenInterface/PdfPreview.js index 09d754f54..2a0097cda 100644 --- a/renderer/src/layouts/editor/pdfGenInterface/PdfPreview.js +++ b/renderer/src/layouts/editor/pdfGenInterface/PdfPreview.js @@ -12,7 +12,7 @@ // //This component is te pdf preview view, it is mostly a place holder for now // export function PdfPreview() { // const path = require('path'); -// const fs = window.require('graceful-fs'); +// const fs = window.require('fs'); // const [zoom, setZoom] = useState(1); // const [numPages, setNumPages] = useState(); // const [pageNumber, setPageNumber] = useState(1); diff --git a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js index 3f114bb38..c253b12b6 100644 --- a/renderer/src/layouts/projects/Export/ExportProjectPopUp.js +++ b/renderer/src/layouts/projects/Export/ExportProjectPopUp.js @@ -162,7 +162,7 @@ export default function ExportProjectPopUp(props) { }; const exportBible = async () => { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (folderPath && fs.existsSync(folderPath)) { setValid(false); logger.debug('ExportProjectPopUp.js', 'Inside exportBible'); diff --git a/renderer/src/layouts/projects/Import/ConflictResolverUI.jsx b/renderer/src/layouts/projects/Import/ConflictResolverUI.jsx index 8d20d95ff..fa557270e 100644 --- a/renderer/src/layouts/projects/Import/ConflictResolverUI.jsx +++ b/renderer/src/layouts/projects/Import/ConflictResolverUI.jsx @@ -53,7 +53,7 @@ function ConflictResolverUI({ conflictData, setConflictPopup }) { const abortConflictResolution = async (conflictData) => { logger.debug('conflictResolverUI.jsx', 'in abort conflict'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); modelClose(); setConflictPopup({ open: false, diff --git a/renderer/src/layouts/projects/Import/mergeObsUtils.js b/renderer/src/layouts/projects/Import/mergeObsUtils.js index 0775f1c99..a14add8b8 100644 --- a/renderer/src/layouts/projects/Import/mergeObsUtils.js +++ b/renderer/src/layouts/projects/Import/mergeObsUtils.js @@ -10,7 +10,7 @@ import OBSBack from '../../../lib/OBSback.md'; const path = require('path'); export async function parseObs(conflictData, selectedFileName) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const filePath = path.join(conflictData.data.mergeDirPath, selectedFileName); @@ -160,7 +160,7 @@ export async function updateAndSaveStory(story, currentUser, projectName, mergeD let title; let body = ''; let end; const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); story.forEach((s) => { if (Object.prototype.hasOwnProperty.call(s, 'title')) { @@ -185,7 +185,7 @@ export async function createAllMdInDir(dirPath) { try { // function to create 50 md story in a dir logger.debug('mergeObsUtils.js', 'Inside createAllMd - create empty md in a dir'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); await OBSData.forEach(async (storyJson) => { const currentFileName = `${storyJson.storyId.toString().padStart(2, 0)}.md`; const file = await JsonToMd(storyJson, ''); @@ -210,7 +210,7 @@ export async function createAllMdInDir(dirPath) { export async function copyFilesTempToOrginal(conflictData) { try { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const fse = window.require('fs-extra'); // copy all md from merge main to project main diff --git a/renderer/src/layouts/projects/Import/mergeProject.js b/renderer/src/layouts/projects/Import/mergeProject.js index 938ceba46..bbd3d5d3c 100644 --- a/renderer/src/layouts/projects/Import/mergeProject.js +++ b/renderer/src/layouts/projects/Import/mergeProject.js @@ -49,7 +49,7 @@ export const mergeProject = async (incomingPath, currentUser, setConflictPopup, const tempMergeIncoming = 'merge-incoming'; const mainBranch = `${packageInfo.name}-main`; let currentActiveBranch = mainBranch; - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const fse = window.require('fs-extra'); // read incoming meta let incomingMeta = await readIngredients({ diff --git a/renderer/src/layouts/projects/ImportProjectPopUp.js b/renderer/src/layouts/projects/ImportProjectPopUp.js index 71fc3d370..8d3b90805 100644 --- a/renderer/src/layouts/projects/ImportProjectPopUp.js +++ b/renderer/src/layouts/projects/ImportProjectPopUp.js @@ -109,7 +109,7 @@ export default function ImportProjectPopUp(props) { const removeExtractedZipDir = async() => { const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); // delete the extracted zip file after successfull / failed import if(importingIsZip && folderPath) { setImportingIsZip(false) @@ -138,7 +138,7 @@ export default function ImportProjectPopUp(props) { setImportProgress((prev)=>({...prev, importStarted:true, completedSteps: prev.completedSteps + 1 })) logger.debug('ImportProjectPopUp.js', 'Inside callImport'); const path = require('path'); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); await localforage.getItem('userProfile').then(async (value) => { const status = await importBurrito(folderPath, value.username, updateBurriot, languages); // delete the extracted zip file after successfull / failed import diff --git a/renderer/src/modules/projects/hooks/useEditProject.js b/renderer/src/modules/projects/hooks/useEditProject.js index 485ffa06a..19979144a 100644 --- a/renderer/src/modules/projects/hooks/useEditProject.js +++ b/renderer/src/modules/projects/hooks/useEditProject.js @@ -26,7 +26,7 @@ const useEditProject = () => { const userProfile = await localforage.getItem('userProfile'); if (isElectron()) { - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); const newpath = localStorage.getItem('userPath'); folder = path.join(newpath, packageInfo.name, 'users', userProfile.username, 'projects', `${project.name}_${project.id[0]}`); data = fs.readFileSync(path.join(folder, 'metadata.json'), 'utf-8'); diff --git a/renderer/src/util/createAudioVersification.js b/renderer/src/util/createAudioVersification.js index 98efa4af5..aec228e76 100644 --- a/renderer/src/util/createAudioVersification.js +++ b/renderer/src/util/createAudioVersification.js @@ -33,7 +33,7 @@ export const createAudioVersification = ( logger.debug('createAudioVersification.js', 'Creating the files with selected scheme'); // eslint-disable-next-line import/no-dynamic-require const file = require(`../lib/versification/${scheme.file}`); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } diff --git a/renderer/src/util/createJuxtaContent.js b/renderer/src/util/createJuxtaContent.js index dc02abc53..41f19fae1 100644 --- a/renderer/src/util/createJuxtaContent.js +++ b/renderer/src/util/createJuxtaContent.js @@ -38,7 +38,7 @@ export const createJuxtaContent = ( logger.debug('createJuxtaContent.js', `call == ${call}`); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } diff --git a/renderer/src/util/createObsContent.js b/renderer/src/util/createObsContent.js index de8fa232b..bd581f5ab 100644 --- a/renderer/src/util/createObsContent.js +++ b/renderer/src/util/createObsContent.js @@ -36,7 +36,7 @@ export const createObsContent = ( ingredientsDirName = ingredientsDirName[0].split(/[(\\)?(/)?]/gm).slice(0)[0]; } const folder = path.join(newpath, packageInfo.name, 'users', username, 'projects', `${project.projectName}_${id}`, ingredientsDirName); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); logger.debug('createObsContent.js', 'Creating the story md files'); // eslint-disable-next-line import/no-dynamic-require @@ -46,7 +46,7 @@ export const createObsContent = ( if (bookAvailable(importedFiles, currentFileName)) { logger.debug('createObsContent.js', `${currentFileName} has been Imported`); const file = importedFiles.filter((obj) => (obj.id === currentFileName)); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } @@ -64,7 +64,7 @@ export const createObsContent = ( } else { logger.debug('createObsContent.js', 'Creating the md file using RCL function JsonToMd'); const file = JsonToMd(storyJson, ''); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } @@ -148,7 +148,7 @@ export const createObsContent = ( logger.debug('createObsContent.js', `${file.id} has been Imported`); const currentStory = OBSData.filter((obj) => ( (obj.storyId).toString().padStart(2, 0) === (file.id).split('.')[0])); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); // if (!fs.existsSync(folder)) { // fs.mkdirSync(folder, { recursive: true }); // } diff --git a/renderer/src/util/createVersificationUSFM.js b/renderer/src/util/createVersificationUSFM.js index 89d8cfeb7..555247491 100644 --- a/renderer/src/util/createVersificationUSFM.js +++ b/renderer/src/util/createVersificationUSFM.js @@ -55,7 +55,7 @@ export const createVersificationUSFM = ( if (bookAvailable(importedFiles, book)) { logger.debug('createVersificationUSFM.js', `${book} is been Imported`); const file = importedFiles.filter((obj) => (obj.id === book)); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } @@ -101,7 +101,7 @@ export const createVersificationUSFM = ( const isJsonValid = myJsonParser.validate(); if (isJsonValid) { const reCreatedUsfm = myJsonParser.toUSFM(); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } @@ -121,7 +121,7 @@ export const createVersificationUSFM = ( } } }); - const fs = window.require('graceful-fs'); + const fs = window.require('fs'); logger.debug('createVersificationUSFM.js', 'Creating versification.json file in ingredients'); await fs.writeFileSync(path.join(folder, 'versification.json'), JSON.stringify(file)); const stats = fs.statSync(path.join(folder, 'versification.json'));