Skip to content

Commit

Permalink
Convert relative imports to .js (except home.ts), fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
lizthegrey committed May 2, 2022
1 parent caccdaa commit 25f2163
Show file tree
Hide file tree
Showing 203 changed files with 1,155 additions and 1,063 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build-client": "webpack --config out/server/infra/build-client/webpack.prod.js",
"build-client:dev": "webpack --config out/server/infra/build-client/webpack.dev.js",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue --max-warnings=0",
"build-server": "ttsc",
"build-server": "tsc",
"clean": "rm -rf out/ && rm -rf static/dist/",
"pretty-check": "prettier --check .",
"start": "yarn node out/server/bin/witness/witness.js",
Expand Down Expand Up @@ -62,6 +62,7 @@
"@babel/types": "^7.17.10",
"@sentry/browser": "^6.19.7",
"@sentry/tracing": "^6.19.7",
"@types/axios": "^0.14.0",
"@types/bluebird": "^3.5.36",
"@types/body-parser": "^1.19.2",
"@types/cookie-parser": "^1.4.3",
Expand All @@ -70,6 +71,7 @@
"@types/csurf": "^1.11.2",
"@types/events": "^3",
"@types/express": "^4.17.13",
"@types/express-rate-limit": "^6.0.0",
"@types/heapdump": "^0.3.1",
"@types/imagemin": "^8",
"@types/jest": "^27.4.1",
Expand All @@ -93,7 +95,6 @@
"@typescript-eslint/parser": "^5.21.0",
"@vue/compiler-sfc": "^3.2.33",
"@vue/runtime-dom": "^3.2.33",
"@zoltu/typescript-transformer-append-js-extension": "^1.0.1",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"cleanup-mini-css-extract-plugin": "^1.1.1",
Expand Down Expand Up @@ -123,10 +124,9 @@
"request": "^2.88.2",
"stream-browserify": "^3.0.0",
"swagger-ui": "^4.10.3",
"terser-webpack-plugin": "^5.3.1",
"ts-jest": "^27.1.4",
"ts-jest-resolver": "^2.0.0",
"ts-loader": "^9.2.9",
"ttypescript": "^1.5.13",
"typescript": "4.7.0-beta",
"url": "^0.11.0",
"vue": "^3.2.33",
Expand All @@ -143,6 +143,7 @@
"resolutions": {
"ansi-html": "^0.0.9",
"find-versions": "^5",
"jose": "patch:jose@^4.8.0#./patches/jose+4.8.0.patch",
"json-schema": "^0.4.0",
"lpad-align": "^3.0.0",
"minimist": "^1.2.6",
Expand All @@ -160,6 +161,7 @@
"json",
"node"
],
"resolver": "ts-jest-resolver",
"roots": [
"test/"
],
Expand Down
12 changes: 12 additions & 0 deletions patches/jose+4.8.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/package.json b/package.json
index a378992d2bcb1cbf4f2f8ada1895994c015cdae4..a79238da092341ebb50581e665f793eb95f404df 100644
--- a/package.json
+++ b/package.json
@@ -55,6 +55,7 @@
"sideEffects": false,
"exports": {
".": {
+ "types": "./dist/types/index.d.ts",
"browser": "./dist/browser/index.js",
"worker": "./dist/browser/index.js",
"import": "./dist/node/esm/index.js",
6 changes: 3 additions & 3 deletions src/bin/updatedb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

import { fileURLToPath } from "url";
import { getPostgresKnex } from "../db/getPostgresKnex";
import { getPostgresKnex } from "../db/getPostgresKnex.js";

// Directory is relative to project root
const MIGRATE_CONFIG = {
Expand All @@ -45,7 +45,7 @@ const knex = getPostgresKnex();
export function updateDb(revert: boolean): Promise<void> {
if (revert) {
console.log("Reverting schema changes...");
return knex.migrate.rollback(MIGRATE_CONFIG).then((reverts) => {
return knex!.migrate.rollback(MIGRATE_CONFIG).then((reverts) => {
const batch = reverts[0];
const scripts = reverts[1];
if (scripts.length > 0) {
Expand All @@ -60,7 +60,7 @@ export function updateDb(revert: boolean): Promise<void> {
} else {
// Proceed with an update to latest schema
console.log("Updating...");
return knex.migrate.latest(MIGRATE_CONFIG).then((updates) => {
return knex!.migrate.latest(MIGRATE_CONFIG).then((updates) => {
const batch = updates[0];
const scripts = updates[1];
if (scripts.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/witness/ProcessControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as child_process from "child_process";
import { ChildProcess } from "child_process";
import * as logger from "./logger";
import * as logger from "./logger.js";

/**
* Manages the lifecycle of the child and parent processes.
Expand Down
10 changes: 5 additions & 5 deletions src/bin/witness/RotatingFileLogWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import * as path from "path";
import moment from "moment";
import { Writable } from "stream";
import { WriteStream } from "fs";
import { BasicCallback } from "../../util/stream/core";
import { BasicCallback } from "../../util/stream/core.js";
import { Moment } from "moment";
import { asyncEach } from "./asyncEach";
import { pruneOldLogs } from "./pruneOldLogs";
import * as logger from "./logger";
import { asyncEach } from "./asyncEach.js";
import { pruneOldLogs } from "./pruneOldLogs.js";
import * as logger from "./logger.js";
import {
formatLogFilename,
getLogFormatSpecifier,
formatOutputLine,
parseInputLine,
} from "./protocol";
} from "./protocol.js";

/**
* Writes log output to a text file.
Expand Down
2 changes: 1 addition & 1 deletion src/bin/witness/asyncEach.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BasicCallback } from "../../util/stream/core";
import { BasicCallback } from "../../util/stream/core.js";

/**
* Array iteration for callback-based async execution.
Expand Down
8 changes: 4 additions & 4 deletions src/bin/witness/pruneOldLogs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as fs from "fs";
import * as path from "path";
import moment from "moment";
import { asyncEach } from "./asyncEach";
import { BasicCallback } from "../../util/stream/core";
import { parseLogFilename } from "./protocol";
import * as logger from "./logger";
import { asyncEach } from "./asyncEach.js";
import { BasicCallback } from "../../util/stream/core.js";
import { parseLogFilename } from "./protocol.js";
import * as logger from "./logger.js";

/**
* Deletes any log files older than MAX_LOG_LIFETIME.
Expand Down
8 changes: 4 additions & 4 deletions src/bin/witness/witness.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import moment from "moment";
import { ProcessControl } from "./ProcessControl";
import { RotatingFileLogWriter } from "./RotatingFileLogWriter";
import { getRootPath } from "./getRootPath";
import * as logger from "./logger";
import { ProcessControl } from "./ProcessControl.js";
import { RotatingFileLogWriter } from "./RotatingFileLogWriter.js";
import { getRootPath } from "./getRootPath.js";
import * as logger from "./logger.js";

import path from "path";
import { fileURLToPath } from "url";
Expand Down
2 changes: 1 addition & 1 deletion src/client/character/skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ for (let i = 0; i < GROUP_DISPLAY_ORDER.length; i++) {
};
}

import * as api from "../../route/api/character/skills";
import * as api from "../../route/api/character/skills.js";

export interface Skill extends api.Skill {
queuedLevel?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/client/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import AllBorrowedShips from "./ships/AllBorrowedShips.vue";

import { configureCsrfInterceptor } from "./shared/ajaxer";

import { SimpleMap } from "../util/simpleTypes";
import { SimpleMap } from "../util/simpleTypes.js";

// Anything added here should also be in server.js:FRONTEND_ROUTES
// TODO(aiiane): make server.js just read it directly from here
Expand Down
2 changes: 1 addition & 1 deletion src/client/roster/rosterColumns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Character, Account } from "./types";
import { Character, Account } from "./types.js";

interface RenderColumn {
label: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/roster/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as serverTypes from "../../route/api/roster";
import * as serverTypes from "../../route/api/roster.js";

export interface Character extends serverTypes.CharacterJson {
totalSp?: number;
Expand Down
26 changes: 16 additions & 10 deletions src/client/shared/ajaxer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import axios, { AxiosResponse } from "axios";
import { Output as syncStatus_Output } from "../../route/api/admin/roster/syncStatus_GET";
import { Output as dashboard_Output } from "../../route/api/dashboard";
import { Output as character_Output } from "../../route/api/character";
import { Triage, Battles, Losses, Transaction, Payments } from "../srp/types";
import { Task, Job, Log, Citadel } from "../admin/types";
import { Account } from "../roster/types";
import { CharacterDescription } from "../../route/api/account/characters_GET";
import { Payload as skills_Payload } from "../../route/api/character/skills";
import { Ship } from "../ships/ships";
import { default as axios, AxiosResponse } from "axios";
import { Output as syncStatus_Output } from "../../route/api/admin/roster/syncStatus_GET.js";
import { Output as dashboard_Output } from "../../route/api/dashboard.js";
import { Output as character_Output } from "../../route/api/character.js";
import {
Triage,
Battles,
Losses,
Transaction,
Payments,
} from "../srp/types.js";
import { Task, Job, Log, Citadel } from "../admin/types.js";
import { Account } from "../roster/types.js";
import { CharacterDescription } from "../../route/api/account/characters_GET.js";
import { Payload as skills_Payload } from "../../route/api/character/skills.js";
import { Ship } from "../ships/ships.js";

export function configureCsrfInterceptor(token: string) {
axios.interceptors.request.use(
Expand Down
2 changes: 1 addition & 1 deletion src/client/shared/nameCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const nameCache = new Map<number, string>();
* map, it should call addNames(). This allows any child components to
* access the map without it being passed to them explicitly.
*/
import { SimpleNumMap } from "../../util/simpleTypes";
import { SimpleNumMap } from "../../util/simpleTypes.js";
export const NameCacheMixin = {
methods: {
addNames(names: SimpleNumMap<string>) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/srp/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SimpleNumMap } from "../../util/simpleTypes";
import { SimpleNumMap } from "../../util/simpleTypes.js";

export interface Loss {
payout: number;
Expand Down
10 changes: 5 additions & 5 deletions src/data-source/accessToken/TokenRefresher.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as querystring from "querystring";
import axios from "axios";
import { default as axios } from "axios";

import { AccessToken } from "../../db/tables";
import { AccessTokenErrorType } from "../../error/AccessTokenError";
import { AccessToken } from "../../db/tables.js";
import { AccessTokenErrorType } from "../../error/AccessTokenError.js";
import { fileURLToPath } from "url";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger.js";

import { fetchAuthInfo } from "./jwt";
import { fetchAuthInfo } from "./jwt.js";

const logger = buildLoggerFromFilename(fileURLToPath(import.meta.url));

Expand Down
10 changes: 5 additions & 5 deletions src/data-source/accessToken/accessToken.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { dao } from "../../db/dao";
import { Tnex } from "../../db/tnex/index";
import { AccessToken } from "../../db/tables";
import { dao } from "../../db/dao.js";
import { Tnex } from "../../db/tnex/index.js";
import { AccessToken } from "../../db/tables.js";
import {
AccessTokenError,
AccessTokenErrorType,
} from "../../error/AccessTokenError";
} from "../../error/AccessTokenError.js";
import {
RefreshResult,
TokenRefresher,
AccessTokenUpdate,
} from "./TokenRefresher";
} from "./TokenRefresher.js";

const TOKEN_EXPIRATION_FUDGE_MS = 1000; // 1 second
const tokenRefresher = new TokenRefresher();
Expand Down
8 changes: 4 additions & 4 deletions src/data-source/esi/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EsiAsset } from "./EsiAsset";
import { FetchMethod, Private, Public } from "./EsiEndpoint";
import { EsiKillmail } from "./EsiKillmail";
import { EsiNotification } from "./EsiNotification";
import { EsiAsset } from "./EsiAsset.js";
import { FetchMethod, Private, Public } from "./EsiEndpoint.js";
import { EsiKillmail } from "./EsiKillmail.js";
import { EsiNotification } from "./EsiNotification.js";

/**
* Supported endpoints in the ESI API
Expand Down
2 changes: 1 addition & 1 deletion src/data-source/esi/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EsiError, EsiErrorKind } from "./EsiError";
import { EsiError, EsiErrorKind } from "./EsiError.js";
import VError from "verror";
import { inspect } from "util";

Expand Down
2 changes: 1 addition & 1 deletion src/data-source/esi/fetch/EsiEndpointParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EsiEndpoint, Private } from "../EsiEndpoint";
import { EsiEndpoint, Private } from "../EsiEndpoint.js";

/**
* Given an ESI endpoint, assembles a unified "params" type object for use in
Expand Down
6 changes: 3 additions & 3 deletions src/data-source/esi/fetch/buildEsiFetchConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EsiEndpoint } from "../EsiEndpoint";
import { EsiEndpoint } from "../EsiEndpoint.js";
import { AxiosRequestConfig } from "axios";
import { MixedObject } from "../../../util/simpleTypes";
import { MixedObject } from "../../../util/simpleTypes.js";
import { inspect } from "util";
import { EsiEndpointParams } from "./EsiEndpointParams";
import { EsiEndpointParams } from "./EsiEndpointParams.js";

export function buildEsiFetchConfig<T extends EsiEndpoint>(
baseUrl: string,
Expand Down
6 changes: 3 additions & 3 deletions src/data-source/esi/fetch/checkEsiResponseForWarnings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import moment from "moment";
import { EsiEndpoint } from "../EsiEndpoint";
import { EsiEndpoint } from "../EsiEndpoint.js";
import { AxiosResponse } from "axios";
import { SimpleMap } from "../../../util/simpleTypes";
import { buildLogger } from "../../../infra/logging/buildLogger";
import { SimpleMap } from "../../../util/simpleTypes.js";
import { buildLogger } from "../../../infra/logging/buildLogger.js";

const logger = buildLogger("esi");

Expand Down
12 changes: 6 additions & 6 deletions src/data-source/esi/fetch/fetchEsi.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosResponse } from "axios";
import { EsiEndpoint } from "../EsiEndpoint";
import { EsiError, EsiErrorKind } from "../EsiError";
import { buildEsiFetchConfig } from "./buildEsiFetchConfig";
import { checkEsiResponseForWarnings } from "./checkEsiResponseForWarnings";
import { EsiEndpointParams } from "./EsiEndpointParams";
import { default as axios, AxiosResponse } from "axios";
import { EsiEndpoint } from "../EsiEndpoint.js";
import { EsiError, EsiErrorKind } from "../EsiError.js";
import { buildEsiFetchConfig } from "./buildEsiFetchConfig.js";
import { checkEsiResponseForWarnings } from "./checkEsiResponseForWarnings.js";
import { EsiEndpointParams } from "./EsiEndpointParams.js";

/**
* Loads a particular ESI endpoint.
Expand Down
2 changes: 1 addition & 1 deletion src/data-source/esi/fetch/fetchSwagger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosRequestConfig } from "axios";
import { default as axios, AxiosRequestConfig } from "axios";

export const CHARACTER_HEADER = "X-Proxy-Character";

Expand Down
12 changes: 6 additions & 6 deletions src/data-source/esi/names.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SimpleNumMap, nil } from "../../util/simpleTypes";
import { isAnyEsiError, printError } from "./error";
import { UNKNOWN_CORPORATION_ID } from "../../db/constants";
import { SimpleNumMap, nil } from "../../util/simpleTypes.js";
import { isAnyEsiError, printError } from "./error.js";
import { UNKNOWN_CORPORATION_ID } from "../../db/constants.js";
import { fileURLToPath } from "url";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger";
import { ESI_UNIVERSE_NAMES } from "./endpoints";
import { fetchEsi } from "./fetch/fetchEsi";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger.js";
import { ESI_UNIVERSE_NAMES } from "./endpoints.js";
import { fetchEsi } from "./fetch/fetchEsi.js";

const logger = buildLoggerFromFilename(fileURLToPath(import.meta.url));

Expand Down
12 changes: 6 additions & 6 deletions src/data-source/evemarketer/fetchJitaSellPrices.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import axios from "axios";
import { default as axios } from "axios";
import moment from "moment";
import { inspect } from "util";

import { ExpirationCache } from "../../util/ExpirationCache";
import { fetchMarketStats } from "./fetchMarketStats";
import { SYSTEM_JITA } from "../../eve/constants/mapSolarSystems";
import { MarketStat } from "./MarketStat";
import { ExpirationCache } from "../../util/ExpirationCache.js";
import { fetchMarketStats } from "./fetchMarketStats.js";
import { SYSTEM_JITA } from "../../eve/constants/mapSolarSystems.js";
import { MarketStat } from "./MarketStat.js";
import { fileURLToPath } from "url";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger";
import { buildLoggerFromFilename } from "../../infra/logging/buildLogger.js";

const logger = buildLoggerFromFilename(fileURLToPath(import.meta.url));

Expand Down
4 changes: 2 additions & 2 deletions src/data-source/evemarketer/fetchMarketStats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { MarketStat } from "./MarketStat";
import { default as axios } from "axios";
import { MarketStat } from "./MarketStat.js";

const BASE_URL = `https://api.evemarketer.com/ec`;

Expand Down
Loading

0 comments on commit 25f2163

Please sign in to comment.