Merge pull request #162 from ente-io/export-v3

Export v3
This commit is contained in:
Abhinav Kumar 2023-05-09 11:33:34 +05:30 committed by GitHub
commit f43287df24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 171 additions and 136 deletions

View file

@ -1,125 +1,125 @@
{ {
"name": "ente", "name": "ente",
"productName": "ente", "productName": "ente",
"version": "1.6.27", "version": "1.6.28-alpha.1",
"private": true, "private": true,
"description": "Desktop client for ente.io", "description": "Desktop client for ente.io",
"main": "app/main.js", "main": "app/main.js",
"build": { "build": {
"appId": "io.ente.bhari-frame", "appId": "io.ente.bhari-frame",
"artifactName": "${productName}-${version}.${ext}", "artifactName": "${productName}-${version}.${ext}",
"linux": { "linux": {
"target": [ "target": [
"AppImage", "AppImage",
"deb", "deb",
"rpm", "rpm",
"pacman", "pacman",
"tar.gz" "tar.gz"
], ],
"icon": "./build/icon.icns", "icon": "./build/icon.icns",
"category": "Photography" "category": "Photography"
},
"mac": {
"target": {
"target": "default",
"arch": [
"universal"
]
},
"category": "public.app-category.photography",
"hardenedRuntime": true
},
"afterSign": "electron-builder-notarize",
"extraFiles": [
{
"from": "build",
"to": "resources",
"filter": [
"**/*"
]
}
],
"asarUnpack": [
"node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg",
"node_modules/ffmpeg-static/index.js",
"node_modules/ffmpeg-static/package.json"
],
"files": [
"app/**/*",
{
"from": "ui",
"to": "ui",
"filter": [
"!**/*",
"out/**/*"
]
}
]
}, },
"mac": { "scripts": {
"target": { "postinstall": "electron-builder install-app-deps",
"target": "default", "prebuild": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
"arch": [ "prepare": "husky install",
"universal" "lint": "eslint -c .eslintrc --ext .ts src",
] "watch": "tsc -w",
}, "build-main": "yarn install && tsc",
"category": "public.app-category.photography", "start-main": "yarn build-main && electron app/main.js",
"hardenedRuntime": true "start-renderer": "cd ui && yarn install && yarn dev",
"start": "concurrently \"yarn start-main\" \"yarn start-renderer\"",
"build-renderer": "cd ui && yarn install && yarn build && cd ..",
"build": "yarn build-renderer && yarn build-main",
"test-release": "cross-env IS_TEST_RELEASE=true yarn build && electron-builder --config.compression=store"
}, },
"afterSign": "electron-builder-notarize", "author": "ente <code@ente.io>",
"extraFiles": [ "devDependencies": {
{ "@sentry/cli": "^1.68.0",
"from": "build", "@types/auto-launch": "^5.0.2",
"to": "resources", "@types/ffmpeg-static": "^3.0.1",
"filter": [ "@types/get-folder-size": "^2.0.0",
"**/*" "@types/node": "^16.18.3",
"@types/node-fetch": "^2.6.2",
"@types/promise-fs": "^2.1.1",
"@types/semver-compare": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"concurrently": "^7.0.0",
"cross-env": "^7.0.3",
"electron": "^21.2.2",
"electron-builder": "^23.0.3",
"electron-builder-notarize": "^1.2.0",
"electron-download": "^4.1.1",
"eslint": "^7.23.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.1",
"prettier": "2.5.1",
"typescript": "^4.2.3"
},
"dependencies": {
"@sentry/electron": "^2.5.1",
"any-shell-escape": "^0.1.1",
"auto-launch": "^5.0.5",
"chokidar": "^3.5.3",
"electron-log": "^4.3.5",
"electron-reload": "^2.0.0-alpha.1",
"electron-store": "^8.0.1",
"electron-updater": "^4.3.8",
"ffmpeg-static": "^5.1.0",
"get-folder-size": "^2.0.1",
"next-electron-server": "file:./thirdparty/next-electron-server",
"node-fetch": "^2.6.7",
"node-stream-zip": "^1.15.0",
"promise-fs": "^2.1.1",
"semver-compare": "^1.0.0"
},
"standard": {
"parser": "babel-eslint"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write --ignore-unknown"
] ]
} }
],
"asarUnpack": [
"node_modules/ffmpeg-static/bin/${os}/${arch}/ffmpeg",
"node_modules/ffmpeg-static/index.js",
"node_modules/ffmpeg-static/package.json"
],
"files": [
"app/**/*",
{
"from": "ui",
"to": "ui",
"filter": [
"!**/*",
"out/**/*"
]
}
]
},
"scripts": {
"postinstall": "electron-builder install-app-deps",
"prebuild": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
"prepare": "husky install",
"lint": "eslint -c .eslintrc --ext .ts src",
"watch": "tsc -w",
"build-main": "yarn install && tsc",
"start-main": "yarn build-main && electron app/main.js",
"start-renderer": "cd ui && yarn install && yarn dev",
"start": "concurrently \"yarn start-main\" \"yarn start-renderer\"",
"build-renderer": "cd ui && yarn install && yarn build && cd ..",
"build": "yarn build-renderer && yarn build-main",
"test-release": "cross-env IS_TEST_RELEASE=true yarn build && electron-builder --config.compression=store"
},
"author": "ente <code@ente.io>",
"devDependencies": {
"@sentry/cli": "^1.68.0",
"@types/auto-launch": "^5.0.2",
"@types/ffmpeg-static": "^3.0.1",
"@types/get-folder-size": "^2.0.0",
"@types/node": "^16.18.3",
"@types/node-fetch": "^2.6.2",
"@types/promise-fs": "^2.1.1",
"@types/semver-compare": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"concurrently": "^7.0.0",
"cross-env": "^7.0.3",
"electron": "^21.2.2",
"electron-builder": "^23.0.3",
"electron-builder-notarize": "^1.2.0",
"electron-download": "^4.1.1",
"eslint": "^7.23.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.5.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.1",
"prettier": "2.5.1",
"typescript": "^4.2.3"
},
"dependencies": {
"@sentry/electron": "^2.5.1",
"any-shell-escape": "^0.1.1",
"auto-launch": "^5.0.5",
"chokidar": "^3.5.3",
"electron-log": "^4.3.5",
"electron-reload": "^2.0.0-alpha.1",
"electron-store": "^8.0.1",
"electron-updater": "^4.3.8",
"ffmpeg-static": "^5.1.0",
"get-folder-size": "^2.0.1",
"next-electron-server": "file:./thirdparty/next-electron-server",
"node-fetch": "^2.6.7",
"node-stream-zip": "^1.15.0",
"promise-fs": "^2.1.1",
"semver-compare": "^1.0.0"
},
"standard": {
"parser": "babel-eslint"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
"eslint --fix",
"prettier --write --ignore-unknown"
]
}
} }

View file

@ -12,15 +12,6 @@ export const checkExistsAndCreateDir = async (dirPath: string) => {
} }
}; };
export const checkExistsAndRename = async (
oldDirPath: string,
newDirPath: string
) => {
if (fs.existsSync(oldDirPath)) {
await fs.rename(oldDirPath, newDirPath);
}
};
export const saveStreamToDisk = async ( export const saveStreamToDisk = async (
filePath: string, filePath: string,
fileStream: ReadableStream<Uint8Array> fileStream: ReadableStream<Uint8Array>

View file

@ -5,4 +5,4 @@ export async function getDirFiles(dirPath: string) {
const electronFiles = await Promise.all(files.map(getElectronFile)); const electronFiles = await Promise.all(files.map(getElectronFile));
return electronFiles; return electronFiles;
} }
export { isFolder } from '../services/fs'; export { isFolder, moveFile, deleteFolder, rename } from '../services/fs';

View file

@ -29,7 +29,6 @@ import { clearElectronStore } from './api/electronStore';
import { openDiskCache, deleteDiskCache } from './api/cache'; import { openDiskCache, deleteDiskCache } from './api/cache';
import { import {
checkExistsAndCreateDir, checkExistsAndCreateDir,
checkExistsAndRename,
saveStreamToDisk, saveStreamToDisk,
saveFileToDisk, saveFileToDisk,
getExportRecord, getExportRecord,
@ -45,7 +44,13 @@ import {
openDirectory, openDirectory,
} from './api/common'; } from './api/common';
import { fixHotReloadNext12 } from './utils/preload'; import { fixHotReloadNext12 } from './utils/preload';
import { isFolder, getDirFiles } from './api/fs'; import {
isFolder,
getDirFiles,
moveFile,
deleteFolder,
rename,
} from './api/fs';
import { convertHEIC, generateImageThumbnail } from './api/imageProcessor'; import { convertHEIC, generateImageThumbnail } from './api/imageProcessor';
import { setupLogging } from './utils/logging'; import { setupLogging } from './utils/logging';
import { import {
@ -63,7 +68,6 @@ const windowObject: any = window;
windowObject['ElectronAPIs'] = { windowObject['ElectronAPIs'] = {
exists, exists,
checkExistsAndCreateDir, checkExistsAndCreateDir,
checkExistsAndRename,
saveStreamToDisk, saveStreamToDisk,
saveFileToDisk, saveFileToDisk,
selectRootDirectory, selectRootDirectory,
@ -105,4 +109,7 @@ windowObject['ElectronAPIs'] = {
logRendererProcessMemoryUsage, logRendererProcessMemoryUsage,
registerForegroundEventListener, registerForegroundEventListener,
openDirectory, openDirectory,
moveFile,
deleteFolder,
rename,
}; };

View file

@ -241,3 +241,40 @@ export async function readTextFile(filePath: string) {
} }
return await fs.readFile(filePath, 'utf-8'); return await fs.readFile(filePath, 'utf-8');
} }
export async function moveFile(
sourcePath: string,
destinationPath: string
): Promise<void> {
if (!existsSync(sourcePath)) {
throw new Error('File does not exist');
}
if (existsSync(destinationPath)) {
throw new Error('Destination file already exists');
}
// check if destination folder exists
const destinationFolder = path.dirname(destinationPath);
if (!existsSync(destinationFolder)) {
await fs.mkdir(destinationFolder, { recursive: true });
}
await fs.rename(sourcePath, destinationPath);
}
export async function deleteFolder(folderPath: string): Promise<void> {
if (!existsSync(folderPath)) {
return;
}
// check if folder is empty
const files = await fs.readdir(folderPath);
if (files.length > 0) {
throw new Error('Folder is not empty');
}
await fs.rmdir(folderPath);
}
export async function rename(oldPath: string, newPath: string) {
if (!existsSync(oldPath)) {
throw new Error('Path does not exist');
}
await fs.rename(oldPath, newPath);
}

View file

@ -114,7 +114,7 @@ export default function setupIpcComs(
}); });
ipcMain.handle('open-dir', (_, dirPath) => { ipcMain.handle('open-dir', (_, dirPath) => {
shell.openPath(dirPath); shell.openPath(path.normalize(dirPath));
}); });
ipcMain.on('update-and-restart', () => { ipcMain.on('update-and-restart', () => {

2
ui

@ -1 +1 @@
Subproject commit 627cad22e2481258bec9dd6996ea55fe38512672 Subproject commit d0cd90f2715fe3b9c2cd0ce3f422505deb4f5d5d