Skip to content

Commit 1948f1c

Browse files
authoredNov 2, 2023
fix: use Typescript for files in entry-asar (#83)
1 parent 52fa9a2 commit 1948f1c

9 files changed

+53
-12
lines changed
 

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
dist
3-
*.app
3+
entry-asar/*.js*
4+
entry-asar/*.ts
5+
*.app

‎entry-asar/ambient.d.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare namespace NodeJS {
2+
interface Process extends EventEmitter {
3+
// This is an undocumented private API. It exists.
4+
_archPath: string;
5+
}
6+
}
7+
8+
declare module 'electron' {
9+
const app: Electron.App;
10+
11+
namespace Electron {
12+
interface App {
13+
getAppPath: () => string;
14+
setAppPath: (p: string) => void;
15+
}
16+
}
17+
18+
export { app };
19+
}

‎entry-asar/has-asar.js ‎entry-asar/has-asar.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const { app } = require('electron');
2-
const path = require('path');
1+
import { app } from 'electron';
2+
import path from 'path';
33

44
if (process.arch === 'arm64') {
55
setPaths('arm64');
66
} else {
77
setPaths('x64');
88
}
99

10-
function setPaths(platform) {
10+
function setPaths(platform: string) {
1111
// This should return the full path, ending in something like
1212
// Notion.app/Contents/Resources/app.asar
1313
const appPath = app.getAppPath();

‎entry-asar/no-asar.js ‎entry-asar/no-asar.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { app } from 'electron';
2+
import path from 'path';
3+
14
if (process.arch === 'arm64') {
25
setPaths('arm64');
36
} else {
47
setPaths('x64');
58
}
69

7-
function setPaths(platform) {
10+
function setPaths(platform: string) {
811
// This should return the full path, ending in something like
912
// Notion.app/Contents/Resources/app
1013
const appPath = app.getAppPath();

‎package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
"files": [
2121
"dist/*",
2222
"entry-asar/*",
23+
"!entry-asar/**/*.ts",
2324
"README.md"
2425
],
2526
"author": "Samuel Attard",
2627
"scripts": {
27-
"build": "tsc && tsc -p tsconfig.esm.json",
28-
"lint": "prettier --check \"{src,entry-asar}/**/*.{js,ts}\"",
29-
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.{js,ts}\"",
28+
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && tsc -p tsconfig.entry-asar.json",
29+
"lint": "prettier --check \"{src,entry-asar}/**/*.ts\"",
30+
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.ts\"",
3031
"prepublishOnly": "npm run build",
3132
"test": "exit 0",
3233
"prepare": "husky install"
@@ -57,4 +58,4 @@
5758
"prettier --write"
5859
]
5960
}
60-
}
61+
}

‎tsconfig.cjs.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src"]
4+
}

‎tsconfig.entry-asar.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "entry-asar",
5+
},
6+
"include": [
7+
"entry-asar"
8+
],
9+
"exclude": []
10+
}

‎tsconfig.esm.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"compilerOptions": {
44
"module": "esnext",
55
"outDir": "dist/esm"
6-
}
7-
}
6+
},
7+
"include": ["src"]
8+
}

‎tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"declaration": true
1717
},
1818
"include": [
19-
"src"
19+
"src",
20+
"entry-asar"
2021
]
2122
}

0 commit comments

Comments
 (0)
Please sign in to comment.