fix: use Typescript for files in entry-asar (#83)
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
*.app
|
entry-asar/*.js*
|
||||||
|
entry-asar/*.ts
|
||||||
|
*.app
|
||||||
|
|||||||
19
entry-asar/ambient.d.ts
vendored
Normal file
19
entry-asar/ambient.d.ts
vendored
Normal file
@@ -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 };
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
const { app } = require('electron');
|
import { app } from 'electron';
|
||||||
const path = require('path');
|
import path from 'path';
|
||||||
|
|
||||||
if (process.arch === 'arm64') {
|
if (process.arch === 'arm64') {
|
||||||
setPaths('arm64');
|
setPaths('arm64');
|
||||||
@@ -7,7 +7,7 @@ if (process.arch === 'arm64') {
|
|||||||
setPaths('x64');
|
setPaths('x64');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPaths(platform) {
|
function setPaths(platform: string) {
|
||||||
// This should return the full path, ending in something like
|
// This should return the full path, ending in something like
|
||||||
// Notion.app/Contents/Resources/app.asar
|
// Notion.app/Contents/Resources/app.asar
|
||||||
const appPath = app.getAppPath();
|
const appPath = app.getAppPath();
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
|
import { app } from 'electron';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
if (process.arch === 'arm64') {
|
if (process.arch === 'arm64') {
|
||||||
setPaths('arm64');
|
setPaths('arm64');
|
||||||
} else {
|
} else {
|
||||||
setPaths('x64');
|
setPaths('x64');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPaths(platform) {
|
function setPaths(platform: string) {
|
||||||
// This should return the full path, ending in something like
|
// This should return the full path, ending in something like
|
||||||
// Notion.app/Contents/Resources/app
|
// Notion.app/Contents/Resources/app
|
||||||
const appPath = app.getAppPath();
|
const appPath = app.getAppPath();
|
||||||
@@ -20,13 +20,14 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
"entry-asar/*",
|
"entry-asar/*",
|
||||||
|
"!entry-asar/**/*.ts",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"author": "Samuel Attard",
|
"author": "Samuel Attard",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc && tsc -p tsconfig.esm.json",
|
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && tsc -p tsconfig.entry-asar.json",
|
||||||
"lint": "prettier --check \"{src,entry-asar}/**/*.{js,ts}\"",
|
"lint": "prettier --check \"{src,entry-asar}/**/*.ts\"",
|
||||||
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.{js,ts}\"",
|
"prettier:write": "prettier --write \"{src,entry-asar}/**/*.ts\"",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
"test": "exit 0",
|
"test": "exit 0",
|
||||||
"prepare": "husky install"
|
"prepare": "husky install"
|
||||||
@@ -57,4 +58,4 @@
|
|||||||
"prettier --write"
|
"prettier --write"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
tsconfig.cjs.json
Normal file
4
tsconfig.cjs.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
10
tsconfig.entry-asar.json
Normal file
10
tsconfig.entry-asar.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "entry-asar",
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"entry-asar"
|
||||||
|
],
|
||||||
|
"exclude": []
|
||||||
|
}
|
||||||
@@ -3,5 +3,6 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"outDir": "dist/esm"
|
"outDir": "dist/esm"
|
||||||
}
|
},
|
||||||
}
|
"include": ["src"]
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"declaration": true
|
"declaration": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src"
|
"src",
|
||||||
|
"entry-asar"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user