Migrate project foundations to TypeScript (#342)

This commit is contained in:
Michał Leszczyński
2024-07-14 10:45:24 -07:00
committed by GitHub
parent ce798f60f9
commit daa5bd2417
67 changed files with 1123 additions and 185 deletions

9
cli/.gitignore vendored
View File

@@ -1,3 +1,6 @@
assets/static/*.js
assets/static/*.js.*
.pkg-cache/
/node_modules/
/lib.esm/
/assets/static/*.js
/assets/static/*.js.*
/.pkg-cache/

View File

@@ -25,8 +25,6 @@
"bugs": {
"url": "https://github.com/arx-research/libhalo/issues/new/choose"
},
"main": "entry_cli.js",
"bin": "entry_cli.js",
"pkg": {
"targets": [
"node20"
@@ -40,9 +38,12 @@
},
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"reload-libhalo": "cd ../core && ./node_modules/.bin/tsc && cd ../cli && yarn add ../core"
},
"dependencies": {
"@arx-research/libhalo": "../core",
"bufferutil": "^4.0.8",
"express": "^4.19.2",
"jsonwebtoken": "^9.0.2",
"nfc-pcsc": "^0.8.1",
@@ -53,6 +54,8 @@
"devDependencies": {
"@yao-pkg/pkg": "^5.12.0",
"resedit": "^2.0.2",
"ts-loader": "^9.5.1",
"typescript": "^5.5.3",
"webpack": "^5.92.1",
"webpack-cli": "^5.1.4"
}

View File

@@ -8,7 +8,7 @@ import {Buffer} from 'buffer/index.js';
import {NFC} from 'nfc-pcsc';
import open from 'open';
import {__runTestSuite} from "../halo/tests.js";
import {__runTestSuite} from "@arx-research/libhalo/__tests";
import util from "util";
import {
wsEventCardDisconnected,
@@ -18,7 +18,7 @@ import {
wsEventCardIncompatible,
wsEventReaderDisconnected
} from "./ws_server.js";
import {execHaloCmdPCSC} from "../api/desktop.js";
import {execHaloCmdPCSC} from "@arx-research/libhalo/api/desktop";
const nfc = new NFC();
let stopPCSCTimeout = null;

View File

@@ -1,7 +1,10 @@
import { fileURLToPath } from 'node:url';
import { dirname as path_dirname } from 'node:path';
import crypto from "crypto";
import {randomBuffer} from "../halo/util.js";
function randomBuffer() {
return Buffer.from(crypto.getRandomValues(new Uint8Array(32)));
}
let dirname;

View File

@@ -1,7 +1,6 @@
import express from 'express';
import nunjucks from "nunjucks";
import {WebSocketServer} from 'ws';
import {webcrypto as crypto} from 'crypto';
import {dirname, randomBuffer} from "./util.js";
import jwt from 'jsonwebtoken';
import https from "https";
@@ -9,9 +8,9 @@ import fs from "fs";
import path from "path";
import os from "os";
import util from "util";
import {execHaloCmdPCSC} from "../api/desktop.js";
import {execHaloCmdPCSC} from "@arx-research/libhalo/api/desktop";
import {getBuildInfo} from "./version.js";
import {NFCOperationError} from "../halo/exceptions.js";
import {NFCOperationError} from "@arx-research/libhalo/api/common";
let wss = null;

36
cli/tsconfig.json Normal file
View File

@@ -0,0 +1,36 @@
{
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"lib": [
"es2020",
"es5",
"dom"
],
"moduleResolution": "node16",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"preserveSymlinks": true,
"preserveWatchOutput": true,
"pretty": false,
"rootDir": "./src.ts/",
"strict": true,
"sourceMap": true,
"target": "es2022",
"module": "node16",
"outDir": "./lib.esm",
"allowJs": true
},
"include": [
"./src.ts/**/*.tsx",
"./src.ts/**/*.js"
],
"exclude": []
}

View File

@@ -1,14 +1,14 @@
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
export default {
entry: {
entry_cli: './entry_cli.js',
entry_bridge: './entry_bridge.js',
entry_gateway: './entry_gateway.js',
entry_cli: './src.ts/entry_cli.js',
entry_bridge: './src.ts/entry_bridge.js',
entry_gateway: './src.ts/entry_gateway.js',
},
output: {
filename: '[name].bundle.js',
@@ -16,9 +16,21 @@ export default {
},
mode: 'production',
target: 'node',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
vm: false
vm: false,
chokidar: false,
"utf-8-validate": false
}
},
optimization: {

File diff suppressed because it is too large Load Diff