Skip to content

Commit cd4a12e

Browse files
committed
change pack scripts
Signed-off-by: Adam Setch <[email protected]>
1 parent 0d1f405 commit cd4a12e

File tree

6 files changed

+49
-24
lines changed

6 files changed

+49
-24
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
cache: 'pnpm'
1818
- run: pnpm install
1919
- run: pnpm build
20-
- run: pnpm prepare:remove-source-maps
2120
- run: pnpm package:macos --publish=never -c.mac.identity=null
2221
env:
2322
CSC_LINK: ${{ secrets.mac_certs }}
@@ -43,7 +42,6 @@ jobs:
4342
cache: 'pnpm'
4443
- run: pnpm install
4544
- run: pnpm build
46-
- run: pnpm prepare:remove-source-maps
4745
- run: pnpm package:win --publish=never
4846
- name: Clean up builds
4947
run: Remove-Item dist/win-unpacked -Recurse
@@ -66,7 +64,6 @@ jobs:
6664
cache: 'pnpm'
6765
- run: pnpm install
6866
- run: pnpm build
69-
- run: pnpm prepare:remove-source-maps
7067
- run: pnpm package:linux --publish=never
7168
- name: Clean up builds
7269
run: rm -rfv dist/linux-unpacked

.github/workflows/publish.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
env:
2525
OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }}
2626
OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }}
27-
- run: pnpm prepare:remove-source-maps
2827
- run: pnpm package:macos --publish onTagOrDraft
2928
env:
3029
APPLEID_USERNAME: ${{ secrets.appleid_username }}
@@ -56,7 +55,6 @@ jobs:
5655
env:
5756
OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }}
5857
OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }}
59-
- run: pnpm prepare:remove-source-maps
6058
- run: pnpm package:win --publish onTagOrDraft
6159
env:
6260
GH_TOKEN: ${{ secrets.github_token }}
@@ -82,7 +80,6 @@ jobs:
8280
env:
8381
OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }}
8482
OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }}
85-
- run: pnpm prepare:remove-source-maps
8683
- run: pnpm package:linux --publish onTagOrDraft
8784
env:
8885
GH_TOKEN: ${{ secrets.github_token }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"watch": "concurrently --names \"main,renderer\" --prefix-colors \"blue,green\" \"pnpm watch:main\" \"pnpm watch:renderer\"",
1212
"watch:main": "webpack --watch --config ./config/webpack.config.main.base.ts",
1313
"watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.ts",
14-
"prepare:remove-source-maps": "ts-node ./scripts/delete-source-maps.ts",
1514
"package:linux": "electron-builder --linux",
1615
"package:macos": "electron-builder --mac",
1716
"package:win": "electron-builder --win",
@@ -129,6 +128,7 @@
129128
"repo": "gitify"
130129
},
131130
"afterSign": "scripts/notarize.js",
131+
"beforeBuild": "scripts/beforeBuild.js",
132132
"afterPack": "scripts/after-pack.js"
133133
},
134134
"dependencies": {

scripts/after-pack.js renamed to scripts/afterPack.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('node:path');
22
const fs = require('node:fs');
3+
const { chmodSync, chownSync } = require('node:fs');
34
const { AfterPackContext } = require('electron-builder');
45

56
const packageJson = require('../package.json');
@@ -9,6 +10,9 @@ const electronLanguages = packageJson.build.electronLanguages;
910
* @param {AfterPackContext} context
1011
*/
1112
const afterPack = async (context) => {
13+
// biome-ignore lint/suspicious/noConsoleLog: disabled
14+
console.log('[afterPack]: Starting...');
15+
1216
const appName = context.packager.appInfo.productFilename;
1317
const appOutDir = context.appOutDir;
1418
const platform = context.electronPlatformName;
@@ -18,6 +22,9 @@ const afterPack = async (context) => {
1822
} else if (platform === 'linux') {
1923
fixChromeSandboxPermissions(appOutDir);
2024
}
25+
26+
// biome-ignore lint/suspicious/noConsoleLog: disabled
27+
console.log('[afterPack]: Completed');
2128
};
2229

2330
/**
@@ -26,6 +33,9 @@ const afterPack = async (context) => {
2633
* @param {string} appName
2734
*/
2835
const removeUnusedLocales = (appOutDir, appName) => {
36+
// biome-ignore lint/suspicious/noConsoleLog: disabled
37+
console.log('[afterPack]: removing unused locales');
38+
2939
const resourcesPath = path.join(
3040
appOutDir,
3141
`${appName}.app`,
@@ -58,15 +68,21 @@ const removeUnusedLocales = (appOutDir, appName) => {
5868
* @param {string} appOutDir
5969
*/
6070
const fixChromeSandboxPermissions = (appOutDir) => {
71+
// biome-ignore lint/suspicious/noConsoleLog: disabled
72+
console.log('[afterPack]: fix chrome sandbox permissions');
73+
6174
const chromeSandboxPath = path.join(appOutDir, 'chrome-sandbox');
6275

6376
try {
6477
chownSync(chromeSandboxPath, 0, 0); // Set root ownership
6578
chmodSync(chromeSandboxPath, 0o4755); // Set SUID bit
66-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
67-
console.log('Fixed chrome-sandbox permissions');
79+
// biome-ignore lint/suspicious/noConsoleLog: disabled
80+
console.log('[afterPack]: Fixed chrome-sandbox permissions');
6881
} catch (err) {
69-
console.error('Failed to set chrome-sandbox permissions:', err);
82+
console.error(
83+
'[afterPack]: Failed to set chrome-sandbox permissions:',
84+
err,
85+
);
7086
}
7187
};
7288

scripts/beforeBuild.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { rimrafSync } from 'rimraf';
4+
const { BeforeBuildContext } = require('electron-builder');
5+
6+
import webpackPaths from '../config/webpack.paths';
7+
8+
/**
9+
* @param {BeforeBuildContext} context
10+
*/
11+
export default async function beforeBuild(_context) {
12+
// biome-ignore lint/suspicious/noConsoleLog: disabled
13+
console.log('[beforeBuild]: Starting...');
14+
15+
deleteSourceMaps();
16+
17+
// biome-ignore lint/suspicious/noConsoleLog: disabled
18+
console.log('[beforeBuild]: Completed');
19+
}
20+
21+
function deleteSourceMaps() {
22+
if (fs.existsSync(webpackPaths.buildPath)) {
23+
rimrafSync(path.join(webpackPaths.buildPath, '*.map'), {
24+
glob: true,
25+
});
26+
// biome-ignore lint/suspicious/noConsoleLog: disabled
27+
console.log('[beforeBuild]: Deleted source maps');
28+
}
29+
}

scripts/delete-source-maps.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)