Skip to content

Commit 1dc258d

Browse files
fixed more issues with uploaded and fixed windows electron build
1 parent 0e5aeb4 commit 1dc258d

File tree

9 files changed

+123
-72
lines changed

9 files changed

+123
-72
lines changed

.gitignore

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# OS X
2-
.DS_Store
1+
# OS X
2+
.DS_Store
3+
4+
# npm
5+
node_modules
6+
package-lock.json
7+
8+
# WebStorm
9+
.idea
10+
11+
# build
12+
dist/
13+
14+
# config
15+
.env
316

4-
# npm
5-
node_modules
6-
package-lock.json
7-
8-
# WebStorm
9-
.idea
10-
11-
# build
12-
dist/
13-
14-
# config
15-
.env
17+
out/

__tests__/main-process/utils.js

+44-43
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
1-
require('dotenv').config();
2-
const pLimit = require('p-limit');
3-
const {ipcMain} = require('electron');
4-
const {
5-
MAIN_API,
6-
} = require('../../src/shared/constants/ipc');
7-
const {
8-
api,
9-
} = require('../../src/main-process/preload/utils');
10-
11-
const AWS_CONFIG = {
12-
accessKeyId: process.env.S3_ACCESS_KEY_ID,
13-
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
14-
region: 'us-west-2',
15-
bucket: 'integration-testing-or',
16-
};
17-
18-
exports.AWS_CONFIG = AWS_CONFIG;
19-
20-
exports.mockIpcMainApi = () => {
21-
const {
22-
generateIpcMainApiHandler,
23-
} = require('../../src/main-process/ipc-handlers/main-api');
24-
25-
ipcMain.handle(MAIN_API, generateIpcMainApiHandler());
26-
};
27-
28-
exports.setS3Settings = async () => api.updateS3Settings({
29-
accessKeyId: AWS_CONFIG.accessKeyId,
30-
secretAccessKey: AWS_CONFIG.secretAccessKey,
31-
region: AWS_CONFIG.region,
32-
bucket: AWS_CONFIG.bucket,
33-
});
34-
35-
exports.cleanDatabase = async () => {
36-
const models = require('../../src/main-process/models/data');
37-
const limit = pLimit(1);
38-
39-
return Promise.all(
40-
Object.values(models.sequelize.models)
41-
.map(model => limit(() => model.destroy({where: {}}))),
42-
);
43-
};
1+
require('dotenv').config();
2+
const pLimit = require('p-limit');
3+
const {ipcMain} = require('electron');
4+
const {
5+
MAIN_API,
6+
} = require('../../src/shared/constants/ipc');
7+
const {
8+
api,
9+
} = require('../../src/main-process/preload/utils');
10+
11+
const AWS_CONFIG = {
12+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
13+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
14+
region: 'us-west-2',
15+
bucket: 'integration-testing-or',
16+
};
17+
18+
exports.AWS_CONFIG = AWS_CONFIG;
19+
20+
exports.mockIpcMainApi = () => {
21+
const {
22+
generateIpcMainApiHandler,
23+
} = require('../../src/main-process/ipc-handlers/main-api');
24+
25+
ipcMain.handle(MAIN_API, generateIpcMainApiHandler());
26+
};
27+
28+
exports.setS3Settings = async () => api.updateS3Settings({
29+
accessKeyId: AWS_CONFIG.accessKeyId,
30+
secretAccessKey: AWS_CONFIG.secretAccessKey,
31+
region: AWS_CONFIG.region,
32+
bucket: AWS_CONFIG.bucket,
33+
endpoint: AWS_CONFIG.endpoint,
34+
});
35+
36+
exports.cleanDatabase = async () => {
37+
const models = require('../../src/main-process/models/data');
38+
const limit = pLimit(1);
39+
40+
return Promise.all(
41+
Object.values(models.sequelize.models)
42+
.map(model => limit(() => model.destroy({where: {}}))),
43+
);
44+
};

forge.config.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
packagerConfig: {
3+
asar: true,
4+
},
5+
rebuildConfig: {},
6+
makers: [
7+
{
8+
name: '@electron-forge/maker-squirrel',
9+
config: {},
10+
},
11+
{
12+
name: '@electron-forge/maker-zip',
13+
platforms: ['darwin'],
14+
},
15+
{
16+
name: '@electron-forge/maker-deb',
17+
config: {},
18+
},
19+
{
20+
name: '@electron-forge/maker-rpm',
21+
config: {},
22+
},
23+
],
24+
plugins: [
25+
{
26+
name: '@electron-forge/plugin-auto-unpack-natives',
27+
config: {},
28+
},
29+
],
30+
};

package.json

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
{
22
"name": "electron-s3-file-manager",
3-
"productName": "Electron S3 File Manager",
3+
"productName": "Araxia Client Patch Manager",
44
"bundleID": "io.github.kelp404.electron-s3-file-manager",
5-
"version": "0.3.0",
5+
"version": "1.0.0",
66
"description": "A GUI AWS S3 file manager. It supports keyword search, download, upload and preview video.",
77
"main": "dist/main-process/index.js",
88
"scripts": {
9-
"build": "npm run clear:build && npm run build:renderer && npm run build:main && node tools.js build",
10-
"build:main": "cp -r src/main-process src/shared dist/.",
11-
"build:renderer": "NODE_ENV=production webpack",
9+
"build": "npm run clear:build && npm run build:renderer && npm run build:main",
10+
"build:mkdir": "mkdirp ./dist/main-process && mkdirp ./dist/shared",
11+
"build:main": "npm run build:mkdir && ncp ./src/main-process ./dist/main-process && ncp ./src/shared ./dist/shared",
12+
"make": "npx electron-forge make",
13+
"build:renderer": "npx webpack",
1214
"changelog": "node_modules/conventional-changelog-cli/cli.js -n node_modules/@kelp404/changelog.config",
13-
"clear:build": "rm -rf dist",
15+
"clear:build": "rimraf dist/",
1416
"dev": "concurrently --kill-others \"webpack serve\" \"wait-on tcp:3000 && electron src/main-process/index.js\"",
1517
"eslint": "eslint ./ --ignore-path .gitignore --ignore-pattern src/main-process/migrations/",
1618
"ncu": "npm-check-updates",
17-
"start": "npm run dev",
19+
"start": "electron-forge start",
1820
"test": "npm run test:main && npm run test:render",
1921
"test:main": "jest --config __tests__/main-process/jest.config.js",
2022
"test:render": "jest --config __tests__/render-process/jest.config.js",
2123
"makemigration": "makemigration --name $npm_package_version --migrations-path src/main-process/migrations --models-path src/main-process/models/data && eslint src/main-process/migrations --fix || true",
22-
"runmigration": "runmigration --migrations-path src/main-process/migrations --models-path src/main-process/models/data"
24+
"runmigration": "runmigration --migrations-path src/main-process/migrations --models-path src/main-process/models/data",
25+
"package": "electron-forge package"
2326
},
2427
"repository": {
2528
"type": "git",
2629
"url": "git+https://github.com/kelp404/electron-s3-file-manager.git"
2730
},
2831
"author": "Kelp <[email protected]>",
29-
"contributors": ["Ben Carter @ben-of-codecraft"],
32+
"contributors": [
33+
"Ben Carter @ben-of-codecraft"
34+
],
3035
"license": "MIT",
3136
"bugs": {
3237
"url": "https://github.com/kelp404/electron-s3-file-manager/issues"
@@ -40,9 +45,11 @@
4045
"@aws-sdk/s3-request-presigner": "3.215.0",
4146
"@kelp404/sequelize-auto-migrations": "1.3.1",
4247
"electron-is-dev": "2.0.0",
48+
"electron-squirrel-startup": "^1.0.0",
4349
"lodash": "4.17.21",
4450
"mime-types": "2.1.35",
4551
"p-limit": "3.1.0",
52+
"rimraf": "^5.0.1",
4653
"sequelize": "6.31.0",
4754
"sqlite3": "5.1.4"
4855
},
@@ -52,6 +59,12 @@
5259
"@babel/eslint-parser": "7.22.11",
5360
"@babel/preset-env": "7.21.4",
5461
"@babel/preset-react": "7.18.6",
62+
"@electron-forge/cli": "^6.4.2",
63+
"@electron-forge/maker-deb": "^6.4.2",
64+
"@electron-forge/maker-rpm": "^6.4.2",
65+
"@electron-forge/maker-squirrel": "^6.4.2",
66+
"@electron-forge/maker-zip": "^6.4.2",
67+
"@electron-forge/plugin-auto-unpack-natives": "^6.4.2",
5568
"@fortawesome/fontawesome-free": "6.1.2",
5669
"@kelp404/changelog.config": "0.1.0",
5770
"@kelp404/react-infinite-scroller": "1.2.6",
@@ -68,7 +81,6 @@
6881
"dayjs": "1.11.5",
6982
"dotenv": "16.0.3",
7083
"electron": "20.3.8",
71-
"electron-builder": "23.6.0",
7284
"electron-mock-ipc": "0.3.12",
7385
"electron-reload": "2.0.0-alpha.1",
7486
"eslint": "8.39.0",
@@ -85,6 +97,8 @@
8597
"jest-environment-jsdom": "29.5.0",
8698
"jest-environment-node": "29.4.1",
8799
"mini-css-extract-plugin": "2.6.1",
100+
"mkdirp": "^3.0.1",
101+
"ncp": "^2.0.0",
88102
"npm-check-updates": "16.10.9",
89103
"prop-types": "15.8.1",
90104
"pubsub-js": "1.9.4",
@@ -98,7 +112,7 @@
98112
"sweetalert2": "11.6.15",
99113
"wait-on": "6.0.1",
100114
"webpack": "5.81.0",
101-
"webpack-cli": "4.10.0",
115+
"webpack-cli": "^4.10.0",
102116
"webpack-dev-server": "4.9.2"
103117
}
104118
}

src/main-process/common/database.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exports.connectDatabase = ({isLogSQL = false} = {}) => {
1919
exports._sequelize = exports._sequelize || new Sequelize({
2020
dialect: 'sqlite',
2121
storage: exports.DATABASE_PATH,
22-
logging: isLogSQL ? console.log : false,
22+
logging: false //isLogSQL && ? console.log : false,
2323
});
2424

2525
return {

src/main-process/common/s3.js

+2
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ exports.putObject = (path, options = {}) => {
182182
secretAccessKey: settings.secretAccessKey,
183183
},
184184
});
185+
185186
const putObjectCommand = new PutObjectCommand({
186187
...options,
187188
Bucket: settings.bucket,
@@ -208,6 +209,7 @@ exports.upload = ({path, content, options, onProgress}) => {
208209
secretAccessKey: settings.secretAccessKey,
209210
},
210211
});
212+
211213
const upload = new Upload({
212214
client,
213215
params: {

src/main-process/ipc-handlers/main-api/object-handler.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ exports.createFile = async ({$event, localPath, dirname, onProgressChannel} = {}
206206
throw error;
207207
}
208208

209-
try {
209+
try {
210+
console.log(mimeTypes.lookup(basename));
210211
await s3.upload({
211212
path: object.path,
212213
content: fs.createReadStream(localPath),
@@ -221,6 +222,7 @@ exports.createFile = async ({$event, localPath, dirname, onProgressChannel} = {}
221222
object.lastModified = objectHeaders.LastModified;
222223
await object.save();
223224
} catch (error) {
225+
console.log(error.message);
224226
await object.destroy();
225227
throw error;
226228
}

tools.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function build() {
5656
x64: true,
5757
projectDir: path.resolve(__dirname),
5858
win: ['portable'],
59-
mac: ['dmg'],
59+
// mac: ['dmg'],
6060
config: {
6161
copyright: 'Copyright © 2022 kelp404',
6262
directories: {

webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = () => {
88

99
return {
1010
target: 'web',
11-
mode: IS_DEVELOPMENT ? 'development' : 'production',
11+
mode: 'development', //'production',
1212
entry: {
1313
renderer: path.join(__dirname, 'src', 'renderer-process', 'index.js'),
1414
'dark-theme': path.join(__dirname, 'src', 'renderer-process', 'stylesheets', 'dark-theme.scss'),

0 commit comments

Comments
 (0)