diff --git a/.expo/README.md b/.expo/README.md deleted file mode 100755 index fd146b4d3..000000000 --- a/.expo/README.md +++ /dev/null @@ -1,15 +0,0 @@ -> Why do I have a folder named ".expo" in my project? - -The ".expo" folder is created when an Expo project is started using "expo start" command. - -> What do the files contain? - -- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds. -- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator. -- "settings.json": contains the server configuration that is used to serve the application manifest. - -> Should I commit the ".expo" folder? - -No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine. - -Upon project creation, the ".expo" folder is already added to your ".gitignore" file. diff --git a/.expo/settings.json b/.expo/settings.json deleted file mode 100755 index 92bc513bf..000000000 --- a/.expo/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "hostType": "lan", - "lanType": "ip", - "dev": true, - "minify": false, - "urlRandomness": null, - "https": false -} diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index dc6a5b1a5..b41922b9f 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -76,6 +76,9 @@ 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/.gitignore b/.gitignore index 8cbe4b69a..a0f608045 100755 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /.pnp .pnp.js bower_components +/.expo # next-on-netlify build output out_functions/ diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 9d122cea9..a97a7fad1 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('fs'); +const fs = require('graceful-fs'); const path = require('path'); const { _electron: electron } = require('@playwright/test'); diff --git a/main/index.js b/main/index.js index 985fba8a5..adda0474d 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('fs').promises; +const fs = require('graceful-fs').promises; const { format } = require('url'); const { install } = require('@puppeteer/browsers'); const config = require("dotenv"); diff --git a/next.config.js b/next.config.js index c3dcde20e..874faae7f 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,7 @@ // const nodeExternals = require('webpack-node-externals'); const path = require('path'); const colors = require('tailwindcss/colors'); +const TerserPlugin = require("terser-webpack-plugin"); const nextConfig = { webpack: (config, { isServer }) => { @@ -9,6 +10,17 @@ const nextConfig = { config.resolve.fallback.fs = false; 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 c6a16423d..13bb51639 100644 --- a/package.json +++ b/package.json @@ -180,6 +180,7 @@ "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", @@ -224,6 +225,7 @@ "react-scripts": "5.0.1", "styled-components": "^5.3.6", "tc-ui-toolkit": "5.3.3", + "terser-webpack-plugin": "^5.3.10", "tls": "^0.0.1", "translation-helps-rcl": "3.5.12", "typescript": "^4.9.5", diff --git a/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js b/renderer/src/components/EditorPage/AudioEditor/AudioEditor.js index cc61639f8..2a1031a8a 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('fs'); + const fs = window.require('graceful-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 88e5f115c..0afe86d77 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 59f5dd9a9..42d5a69bb 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('fs'); + const fs = window.require('graceful-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 4c91173df..04f68278d 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('fs'); + const fs = window.require('graceful-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 203fe7c3d..c588a7f3f 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('fs'); + const fs = window.require('graceful-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 92eeaa31a..e79b63cb6 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 465ea3888..ca7c37603 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('fs'); + const fs = window.require('graceful-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 580f27ba7..376da6ddb 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('fs'); + const fs = window.require('graceful-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 6468d8980..44e86130c 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('fs'); + const fs = window.require('graceful-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 d95c021d6..8d704fd89 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('fs'); - const fs = window.require('fs'); + const { readdirSync } = window.require('graceful-fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 a33799799..4e45bcef6 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('fs'); + const fs = window.require('graceful-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 d11e5821c..d9c8b41da 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('fs'); + const fs = window.require('graceful-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 c2bd4631e..3f5d71c6d 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('fs'); + const fs = window.require('graceful-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 be75e50f9..3c48094ed 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('fs'); + const fs = window.require('graceful-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 743752ff6..bcfb7b85b 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('fs'); + const fs = window.require('graceful-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 7a327ad3e..d51ce8cc1 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 46cb20cb9..45fe24e77 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('fs'); + const fs = window.require('graceful-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 8a3609d60..68447f0ff 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('fs'); + const fs = window.require('graceful-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 e04670632..6db604f39 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-fs'); let resourceBurritoFile = {}; let currentResourceMeta = ''; let currentResourceProject = ''; diff --git a/renderer/src/components/Resources/useReadLocalResources.js b/renderer/src/components/Resources/useReadLocalResources.js index 675603a79..04039cca4 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('fs'); + const fs = window.require('graceful-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 0e32b184e..fe6ed03f4 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('fs'); + const fs = window.require('graceful-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 0865e0928..fc2512eb3 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 20841bfe6..0d32b27fa 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('fs'); + const fs = window.require('graceful-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 3acc70bdb..83cd919e8 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('fs'); + const fs = window.require('graceful-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 b7f659138..ba525d42e 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 83d0d8ff5..7540657e8 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 4eda99dd7..d200d388a 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('fs'); + const fs = window.require('graceful-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 4e0071c60..445ad3adc 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('fs'); + const fs = window.require('graceful-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 54de61b32..b8578069d 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('fs'); + const fs = window.require('graceful-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 6334a356a..f30a10306 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 b66e8efc4..91f44df43 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('fs'); + const fs = window.require('graceful-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 20ba76085..db5e4ca81 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('fs'); + const fs = window.require('graceful-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 2ada6d2d3..20aa06a55 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('fs'); + const fs = window.require('graceful-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 a4a8066ba..4f60e0367 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('fs'); + const fs = window.require('graceful-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 b2689d187..c0ad4931f 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 49daa4b40..e9a33d68d 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('fs'); + const fs = window.require('graceful-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 a8ad5618a..df743b291 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('fs'); + const fs = window.require('graceful-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 054c280f4..9472c92e6 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 6978cc045..dd62f621d 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('fs'); + const fs = window.require('graceful-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 25423060b..fdc244b81 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('fs'); + const fs = window.require('graceful-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 bd3083779..ad55534bf 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('fs'); + const fs = window.require('graceful-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 60f4d597f..d18b06971 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('fs'); + const fs = window.require('graceful-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 c994ba9ac..01b12e833 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 b5a0a6f56..1a2a47158 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('fs'); + const fs = window.require('graceful-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 d0a1801ad..d6826e842 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('fs'); + const fs = window.require('graceful-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 73f56fe1b..1f853c2a4 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('fs'); + const fs = window.require('graceful-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 2c7322666..e87a38340 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('fs'); + const fs = window.require('graceful-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 36d44fd37..e8a28ed3d 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('fs'); + const fs = window.require('graceful-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 994a2a46f..d56a54fb4 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('fs'); + const fs = window.require('graceful-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 711008e10..ad07bed67 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('fs'); + const fs = window.require('graceful-fs'); const fixedPath = fixPath(folder); let projects; @@ -502,7 +502,7 @@ export default function InnerFramePopup() { }, [nameFile]); useEffect(() => { - const fs = window.require('fs'); + const fs = window.require('graceful-fs'); const os = window.require('os'); const path = window.require('path'); diff --git a/renderer/src/layouts/editor/SectionContainer.js b/renderer/src/layouts/editor/SectionContainer.js index 4e4415eb2..4acaaae92 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('fs'); + const fs = window.require('graceful-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 eb39a744e..44adfcf2b 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('fs'); + const fs = window.require('graceful-fs'); setStories1(core(fs, _obsNavigation1, referenceColumnOneData1.refName, user.username)); } if (_obsNavigation2 && referenceColumnOneData2.refName && referenceColumnOneData2.selectedResource === 'obs') { - const fs = window.require('fs'); + const fs = window.require('graceful-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 cde0d258f..70297a368 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('fs'); + const fs = window.require('graceful-fs'); setStories1(core(fs, _obsNavigation1, referenceColumnTwoData1.refName, user.username)); } if (_obsNavigation2 && referenceColumnTwoData2.refName && referenceColumnTwoData2.selectedResource === 'obs') { - const fs = window.require('fs'); + const fs = window.require('graceful-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 31c29817e..d5ac98b2b 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('fs'); + const fs = window.require('graceful-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 2a0097cda..09d754f54 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('fs'); +// const fs = window.require('graceful-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 c253b12b6..3f114bb38 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('fs'); + const fs = window.require('graceful-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 fa557270e..8d20d95ff 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('fs'); + const fs = window.require('graceful-fs'); modelClose(); setConflictPopup({ open: false, diff --git a/renderer/src/layouts/projects/Import/mergeObsUtils.js b/renderer/src/layouts/projects/Import/mergeObsUtils.js index a14add8b8..0775f1c99 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 bbd3d5d3c..938ceba46 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('fs'); + const fs = window.require('graceful-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 8d3b90805..71fc3d370 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 19979144a..485ffa06a 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('fs'); + const fs = window.require('graceful-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 aec228e76..98efa4af5 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('fs'); + const fs = window.require('graceful-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 41f19fae1..dc02abc53 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('fs'); + const fs = window.require('graceful-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 bd581f5ab..de8fa232b 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-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 555247491..89d8cfeb7 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('fs'); + const fs = window.require('graceful-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('fs'); + const fs = window.require('graceful-fs'); if (!fs.existsSync(folder)) { fs.mkdirSync(folder, { recursive: true }); } @@ -121,7 +121,7 @@ export const createVersificationUSFM = ( } } }); - const fs = window.require('fs'); + const fs = window.require('graceful-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'));