Skip to content

Commit

Permalink
fix package native addon path error
Browse files Browse the repository at this point in the history
  • Loading branch information
niuniuland committed Nov 21, 2023
1 parent f9edd95 commit c4acfd8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
14 changes: 6 additions & 8 deletions .electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@
*/
module.exports = async function () {
const {getVersion} = await import('./version/getVersion.mjs');

console.log(process.env.MODE);
return {
productName: 'chrome-power-beta',
directories: {
output: 'dist',
buildResources: 'buildResources',
},
files: ['packages/**/dist/**', 'packages/**/assets/**', 'migrations'],
extraResources: {
"from": "packages/main/src/native-addon/build/Release/",
"to": "app/packages/main/native-addon/build/Release/",
"filter": [
"*.node"
]
extraResources: {
from: 'packages/main/src/native-addon/build/Release/',
to: 'app.asar.unpacked/node_modules/window-addon/',
filter: ['*.node'],
},
extraMetadata: {
version: getVersion(),
},

asarUnpack: ['**/*.node'],
nsis: {
oneClick: false,
allowElevation: true,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
retry_wait_seconds: 15
retry_on: error
shell: 'bash'
command: npx --no-install electron-builder --config .electron-builder.config.js --publish ${{ inputs.dry-run && 'never' || 'always' }}
command: ./node_modules/.bin/electron-builder --config .electron-builder.config.js --publish ${{ inputs.dry-run && 'never' || 'always' }}
env:
# Code Signing params
# See https://www.electron.build/code-signing
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Follow the steps below to start using this software:

## Todo

- [ ] Mutiple Languages Support
- [ ] Synchronization
- [ ] Cookies Import
- [ ] Extensions Management
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
"build:main": "cd ./packages/main && vite build",
"build:preload": "cd ./packages/preload && vite build",
"build:renderer": "cd ./packages/renderer && vite build",
"rebuild": "electron-rebuild -f -w ./node_modules/.bin/electron-rebuild.cmd",
"compile": "cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js --dir --config.asar=false",
"publish": "cross-env MODE=production npm run build && electron-builder build --config .electron-builder.config.js --config.asar=false",
"publish": "cross-env MODE=production npm run build && node_modules\\.bin\\electron-builder --config .electron-builder.config.js --publish never",
"test": "npm run test:main && npm run test:preload && npm run test:renderer && npm run test:e2e",
"test:e2e": "npm run build && vitest run",
"test:main": "vitest run -r packages/main --passWithNoTests",
Expand All @@ -29,11 +28,10 @@
"typecheck:preload": "tsc --noEmit -p packages/preload/tsconfig.json",
"typecheck:renderer": "tsc --noEmit -p packages/renderer/tsconfig.json",
"typecheck": "npm run typecheck:main && npm run typecheck:preload && npm run typecheck:renderer",
"postinstall": "electron-builder install-app-deps && cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs",
"postinstall": "node_modules\\.bin\\electron-builder install-app-deps && cross-env ELECTRON_RUN_AS_NODE=1 electron scripts/update-electron-vendors.mjs",
"format": "npx prettier --write \"**/*.{js,mjs,cjs,ts,mts,cts,vue,json}\""
},
"devDependencies": {
"@electron/rebuild": "^3.3.0",
"@iconify/react": "^4.1.1",
"@types/lodash": "^4.14.199",
"@types/node": "18.17.19",
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ app
* if you compile production app without publishing it to distribution server.
* Like `npm run compile` does. It's ok 😅
*/
console.log(import.meta.env);
logger.info(`env, ${import.meta.env.PROD ? 'true' : 'false'}`);
if (import.meta.env.PROD) {
app
Expand Down
19 changes: 13 additions & 6 deletions packages/main/src/sync/tile.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import type {SafeAny} from '../../../shared/types/db';

let windowAddon: unknown;

console.log(process.env.NODE_ENV);
if (process.env.NODE_ENV === 'production') {
windowAddon = require('../native-addon/build/Release/window-addon.node');
} else {
const path = require('path');
import * as path from 'path';
import {createLogger} from '../../../shared/utils/logger';
const logger = createLogger('Tile');
logger.warn(`process.env.MODE${process.env.MODE}`);
if (process.env.MODE === 'development') {
windowAddon = require(path.join(
__dirname,
'../src/native-addon/build/Release/window-addon.node',
));
} else {
windowAddon = require(path.join(
process.resourcesPath,
'app.asar.unpacked',
'node_modules',
'window-addon',
'window-addon.node',
));
}
export const tileWindows = async () => {
(windowAddon as unknown as SafeAny)!.tileChromeWindows();
Expand Down
1 change: 1 addition & 0 deletions scripts/watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import electronPath from 'electron';
import {spawn} from 'child_process';

/** @type 'production' | 'development'' */
console.log(process.env.MODE);
const mode = (process.env.MODE = process.env.MODE || 'development');

/** @type {import('vite').LogLevel} */
Expand Down

0 comments on commit c4acfd8

Please sign in to comment.