Skip to content

Commit

Permalink
chore: Update packages, switch to tsx, and cleanup types a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Apr 3, 2024
1 parent b319ca7 commit 515985e
Show file tree
Hide file tree
Showing 17 changed files with 1,923 additions and 1,363 deletions.
5 changes: 3 additions & 2 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"require": ["./register.js", "source-map-support/register"],
"reporter": "dot"
"reporter": "dot",
"extension": "ts",
"import": "tsx"
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.16.0
v18.19.1
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FROM base as build
COPY --chown=abc:abc package.json yarn.lock tsconfig.json ./
COPY --chown=abc:abc patches ./patches

RUN yarn add global patch-package && yarn install
RUN yarn install

COPY --chown=abc:abc . /app

Expand All @@ -43,10 +43,12 @@ FROM base as app
COPY --from=build --chown=abc:abc /app /app
COPY --chown=abc:abc patches /app/patches

ENV NODE_ENV="production"
ENV NODE_ENV=production
ENV COLORED_STD=true

RUN yarn add global patch-package && yarn install --omit=dev \
RUN yarn install --omit=dev \
&& npm cache clean --force \
&& chown abc:abc node_modules \
&& rm -rf node_modules/ts-node \
&& rm -rf node_modules/typescript
&& rm -rf node_modules/tsx \
&& rm -rf node_modules/typescript \
&& rm -rf node_modules/patch-package
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
},
"scripts": {
"test": "nyc ./node_modules/.bin/_mocha 'tests/**/*.test.ts'",
"test": "mocha 'tests/**/*.test.ts'",
"build": "tsc",
"start": "node src/index.js",
"schema": "yarn run -s schema-operator",
Expand All @@ -39,17 +39,20 @@
"croner": "^6.0.7",
"dayjs": "^1.11.8",
"deepmerge": "^4.3.1",
"discord.js": "14.11.0",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"es6-error": "^4.1.1",
"express": "^4.17.1",
"formidable": "^2.1",
"got": "^11.8.2",
"ip": "^1.1.8",
"ip": "^2.0.1",
"patch-package": "^8.0.0",
"pony-cause": "^1.1.1",
"postinstall-postinstall": "^2.1.0",
"sequelize": "^6.32.1",
"sqlite3": "^5.1.6",
"toad-scheduler": "^3.0.0",
"tsx": "^4.7.1",
"umzug": "^3.2.1",
"yaml": "^2.3.1"
},
Expand All @@ -66,15 +69,12 @@
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"lorem-ipsum": "^2.0.8",
"mocha": "^9.2.1",
"mocha": "^10.3.0",
"nyc": "^15.1.0",
"patch-package": "^8.0.0",
"sequelize-cli": "^6.6.1",
"source-map-support": "^0.5.21",
"ts-essentials": "^9.1.2",
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.13.0",
"typescript": "^4.9.5",
"typescript-json-schema": "~0.55"
"typescript": "^5.3.3",
"typescript-json-schema": "^0.63"
}
}
26 changes: 26 additions & 0 deletions patches/typescript-json-schema+0.63.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/node_modules/typescript-json-schema/dist/typescript-json-schema.js b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
index 7bc282b..2e84ed0 100644
--- a/node_modules/typescript-json-schema/dist/typescript-json-schema.js
+++ b/node_modules/typescript-json-schema/dist/typescript-json-schema.js
@@ -55,7 +55,7 @@ var crypto_1 = require("crypto");
var ts = require("typescript");
var path_equal_1 = require("path-equal");
var vm = require("vm");
-var REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"\)|".*?")\.| /g;
+var REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"(, \{ assert: \{ "resolution-mode": "(import|require)" \} \})?\)|".*?")\.| /g;
var REGEX_TSCONFIG_NAME = /^.*\.json$/;
var REGEX_TJS_JSDOC = /^-([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
var REGEX_GROUP_JSDOC = /^[.]?([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
diff --git a/node_modules/typescript-json-schema/typescript-json-schema.ts b/node_modules/typescript-json-schema/typescript-json-schema.ts
index 7d03763..61a4b5f 100644
--- a/node_modules/typescript-json-schema/typescript-json-schema.ts
+++ b/node_modules/typescript-json-schema/typescript-json-schema.ts
@@ -9,7 +9,7 @@ export { Program, CompilerOptions, Symbol } from "typescript";

const vm = require("vm");

-const REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"\)|".*?")\.| /g;
+const REGEX_FILE_NAME_OR_SPACE = /(\bimport\(".*?"(, \{ assert: \{ "resolution-mode": "(import|require)" \} \})?\)|".*?")\.| /g;// /(\bimport\(".*?"\)|".*?")\.| /g;
const REGEX_TSCONFIG_NAME = /^.*\.json$/;
const REGEX_TJS_JSDOC = /^-([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
const REGEX_GROUP_JSDOC = /^[.]?([\w]+)\s+(\S|\S[\s\S]*\S)\s*$/g;
12 changes: 0 additions & 12 deletions patches/winston-daily-rotate-file+4.7.1.patch

This file was deleted.

10 changes: 0 additions & 10 deletions patches/winston-null+2.0.0.patch

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/db/models/TautulliRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
HasManyCreateAssociationMixin,
Model, Association,
} from "sequelize";
import { TautulliRequestData } from "../../infrastructure/Tautulli.js";
import {TautulliRequestFile} from "./TautulliRequestFile.js";
import {BaseMessageOptions} from "discord.js";
import {TautulliRequestData} from "../../infrastructure/Atomic.js";

export class TautulliRequest extends Model<InferAttributes<TautulliRequest>, InferCreationAttributes<TautulliRequest>> implements TautulliRequestData {

Expand Down
2 changes: 1 addition & 1 deletion src/common/db/models/TautulliRequestFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
CreationOptional,
Model, ForeignKey,
} from "sequelize";
import { TautulliRequestFileData } from "../../infrastructure/Tautulli.js";
import {TautulliRequest} from "./TautulliRequest.js";
import {TautulliRequestFileData} from "../../infrastructure/Atomic.js";

export class TautulliRequestFile extends Model<InferAttributes<TautulliRequestFile>, InferCreationAttributes<TautulliRequestFile>> implements TautulliRequestFileData {

Expand Down
18 changes: 0 additions & 18 deletions src/common/infrastructure/Atomic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import {BaseMessageOptions} from "discord.js";

export type DiscordLogLevel = "error" | "warn" | "safety" | "info" | "verbose" | "debug";

export type ConfigFormat = 'yaml';

export interface NamedGroup {
Expand Down Expand Up @@ -54,22 +50,8 @@ export interface IncomingFileData {
size: number
}

export interface TautulliRequestData {
id: number,
content: BaseMessageOptions
}

export interface TautulliRequestFileData extends FileData {
tautulliRequestId: number
content: Buffer
filename: string
}

export interface FileData {
content: Buffer
filename: string
}

export interface EventAwareBaseMessageOptions extends BaseMessageOptions {
includedEvents: number
}
3 changes: 2 additions & 1 deletion src/common/infrastructure/Logging.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LogOptions } from "@foxxmd/logging";
import { DiscordLogLevel } from "./Atomic.js";

export type DiscordLogLevel = "error" | "warn" | "safety" | "info" | "verbose" | "debug";

export interface LoggingOptions extends LogOptions {
db?: boolean
Expand Down
17 changes: 17 additions & 0 deletions src/common/infrastructure/Tautulli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BaseMessageOptions } from "discord.js";
import { FileData } from "./Atomic.js";

export interface TautulliRequestData {
id: number,
content: BaseMessageOptions
}

export interface TautulliRequestFileData extends FileData {
tautulliRequestId: number
content: Buffer
filename: string
}

export interface EventAwareBaseMessageOptions extends BaseMessageOptions {
includedEvents: number
}
Loading

0 comments on commit 515985e

Please sign in to comment.