Skip to content

Commit

Permalink
installed graceful-fs and removed useless files and updated github ac…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
danielc-n committed Oct 1, 2024
1 parent a98307f commit 5ea1101
Show file tree
Hide file tree
Showing 73 changed files with 117 additions and 122 deletions.
15 changes: 0 additions & 15 deletions .expo/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions .expo/settings.json

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/.pnp
.pnp.js
bower_components
/.expo

# next-on-netlify build output
out_functions/
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion main/index.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
12 changes: 12 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
Expand Down
8 changes: 4 additions & 4 deletions renderer/src/components/EditorPage/AudioEditor/MainPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/EditorPage/Reference/OBS/ObsTn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Login/LeftLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Projects/ImportPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Projects/hooks/useEditProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/components/Resources/ImportResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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 = '';
Expand Down
2 changes: 1 addition & 1 deletion renderer/src/components/Resources/useReadLocalResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand All @@ -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
Expand Down
Loading

0 comments on commit 5ea1101

Please sign in to comment.