Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use Typescript for files in entry-asar #83

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
dist
*.app
entry-asar/*.js*
entry-asar/*.ts
*.app
19 changes: 19 additions & 0 deletions entry-asar/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare namespace NodeJS {
interface Process extends EventEmitter {
// This is an undocumented private API. It exists.
_archPath: string;
}
}

declare module 'electron' {
const app: Electron.App;

namespace Electron {
interface App {
getAppPath: () => string;
setAppPath: (p: string) => void;
}
}

export { app };
}
6 changes: 3 additions & 3 deletions entry-asar/has-asar.js → entry-asar/has-asar.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { app } = require('electron');
const path = require('path');
import { app } from 'electron';
import path from 'path';

if (process.arch === 'arm64') {
setPaths('arm64');
} else {
setPaths('x64');
}

function setPaths(platform) {
function setPaths(platform: string) {
// This should return the full path, ending in something like
// Notion.app/Contents/Resources/app.asar
const appPath = app.getAppPath();
Expand Down
5 changes: 4 additions & 1 deletion entry-asar/no-asar.js → entry-asar/no-asar.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { app } from 'electron';
import path from 'path';

if (process.arch === 'arm64') {
setPaths('arm64');
} else {
setPaths('x64');
}

function setPaths(platform) {
function setPaths(platform: string) {
// This should return the full path, ending in something like
// Notion.app/Contents/Resources/app
const appPath = app.getAppPath();
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
"files": [
"dist/*",
"entry-asar/*",
"!entry-asar/**/*.ts",
"README.md"
],
"author": "Samuel Attard",
"scripts": {
"build": "tsc && tsc -p tsconfig.esm.json",
"lint": "prettier --check \"{src,entry-asar}/**/*.{js,ts}\"",
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.{js,ts}\"",
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && tsc -p tsconfig.entry-asar.json",
"lint": "prettier --check \"{src,entry-asar}/**/*.ts\"",
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.ts\"",
"prepublishOnly": "npm run build",
"test": "exit 0",
"prepare": "husky install"
Expand Down Expand Up @@ -57,4 +58,4 @@
"prettier --write"
]
}
}
}
4 changes: 4 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"include": ["src"]
}
10 changes: 10 additions & 0 deletions tsconfig.entry-asar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "entry-asar",
},
"include": [
"entry-asar"
],
"exclude": []
}
5 changes: 3 additions & 2 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"compilerOptions": {
"module": "esnext",
"outDir": "dist/esm"
}
}
},
"include": ["src"]
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"declaration": true
},
"include": [
"src"
"src",
"entry-asar"
]
}