diff --git a/api/babel.config.js b/api/babel.config.js new file mode 100644 index 00000000..45ab8ad8 --- /dev/null +++ b/api/babel.config.js @@ -0,0 +1,6 @@ +module.exports = { + presets: [ + ["@babel/preset-env", { targets: { node: "current" } }], + ["@babel/preset-typescript", { allowDeclareFields: true }] + ] +}; diff --git a/api/package-lock.json b/api/package-lock.json index fd9c68b4..3e8f655d 100644 Binary files a/api/package-lock.json and b/api/package-lock.json differ diff --git a/api/package.json b/api/package.json index ad959e57..c54dc0e9 100644 --- a/api/package.json +++ b/api/package.json @@ -5,16 +5,18 @@ "main": "dist/Server.js", "types": "dist/Server.d.ts", "scripts": { - "test:only": "node -r ./scripts/tsconfig-paths-bootstrap.js node_modules/.bin/jest --coverage --verbose --forceExit ./tests", + "prepare": "ts-patch install -s", + "test:only": "jest --coverage --verbose --forceExit ./tests", "test": "npm run build && npm run test:only", "test:watch": "jest --watch", - "start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start", + "start": "npm run build && node dist/start", "build": "npx tsc -b .", "build-docker": "tsc -p tsconfig-docker.json", "dev": "tsnd --respawn src/start.ts", "patch": "npx patch-package", "postinstall": "npm run patch", "generate:docs": "ts-node scripts/generate_openapi_schema.ts", + "generate:test": "ts-node scripts/generate_test_schema.ts", "generate:schema": "ts-node scripts/generate_body_schema.ts" }, "repository": { @@ -36,6 +38,9 @@ }, "homepage": "https://fosscord.com", "devDependencies": { + "@babel/core": "^7.15.5", + "@babel/preset-env": "^7.15.6", + "@babel/preset-typescript": "^7.15.0", "@types/amqplib": "^0.8.1", "@types/bcrypt": "^5.0.0", "@types/express": "^4.17.9", @@ -49,14 +54,17 @@ "@types/multer": "^1.4.5", "@types/node": "^14.17.9", "@types/node-fetch": "^2.5.7", + "@types/supertest": "^2.0.11", "@zerollup/ts-transform-paths": "^1.7.18", "0x": "^4.10.2", + "babel-jest": "^27.2.0", "caxa": "^2.1.0", "image-size": "^1.0.0", "jest": "^26.6.3", "saslprep": "^1.0.3", "ts-node": "^9.1.1", "ts-node-dev": "^1.1.6", + "ts-patch": "^1.4.4", "typescript": "^4.4.2", "typescript-json-schema": "0.50.1" }, @@ -96,7 +104,7 @@ "setupFiles": [ "/jest/setup.js" ], - "globalSetup": "/scripts/globalSetup.js", + "globalSetup": "/jest/globalSetup.js", "verbose": true } } diff --git a/api/tsconfig.json b/api/tsconfig.json index 21a8eb96..0169642d 100644 --- a/api/tsconfig.json +++ b/api/tsconfig.json @@ -66,8 +66,9 @@ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "baseUrl": ".", "paths": { - "@fosscord/api": ["src/index.ts"], + "@fosscord/api": ["src/index"], "@fosscord/api/*": ["src/*"] - } + }, + "plugins": [{ "transform": "@zerollup/ts-transform-paths" }] } } diff --git a/bundle/package-lock.json b/bundle/package-lock.json index 718cc969..08e09450 100644 Binary files a/bundle/package-lock.json and b/bundle/package-lock.json differ diff --git a/bundle/package.json b/bundle/package.json index 83f26116..7cf4ba40 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -4,6 +4,7 @@ "description": "", "main": "src/start.js", "scripts": { + "prepare": "ts-patch install -s", "preinstall": "cd ../util && npm i && cd ../api && npm i && cd ../cdn && npm i && cd ../gateway && npm i", "build": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle", "build:bundle": "npx tsc -b .", @@ -12,7 +13,7 @@ "build:cdn": "cd ../cdn/ && npm run build", "build:gateway": "cd ../gateway/ && npm run build", "start": "npm run build && npm run start:bundle", - "start:bundle": "node -r ./tsconfig-paths-bootstrap.js dist/start.js", + "start:bundle": "node dist/start.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -43,6 +44,7 @@ "@types/uuid": "^8.3.0", "@types/ws": "^7.4.0", "@zerollup/ts-transform-paths": "^1.7.18", + "ts-patch": "^1.4.4", "typescript": "^4.3.5" }, "dependencies": { diff --git a/bundle/tsconfig-paths-bootstrap.js b/bundle/tsconfig-paths-bootstrap.js deleted file mode 100644 index efe4b3bc..00000000 --- a/bundle/tsconfig-paths-bootstrap.js +++ /dev/null @@ -1,14 +0,0 @@ -const tsConfigPaths = require("tsconfig-paths"); -const path = require("path"); - -const cleanup = tsConfigPaths.register({ - baseUrl: path.join(__dirname, "node_modules", "@fosscord"), - paths: { - "@fosscord/api": ["api/dist/index.js"], - "@fosscord/api/*": ["api/dist/*"], - "@fosscord/gateway": ["gateway/dist/index.js"], - "@fosscord/gateway/*": ["gateway/dist/*"], - "@fosscord/cdn": ["cdn/dist/index.js"], - "@fosscord/cdn/*": ["cdn/dist/*"], - }, -}); diff --git a/cdn/package-lock.json b/cdn/package-lock.json index 7a4edd89..8a70844c 100644 Binary files a/cdn/package-lock.json and b/cdn/package-lock.json differ diff --git a/cdn/package.json b/cdn/package.json index 7c59381b..71211d67 100644 --- a/cdn/package.json +++ b/cdn/package.json @@ -5,9 +5,10 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { + "prepare": "ts-patch install -s", "test": "npm run build && jest --coverage ./tests", "build": "npx tsc -b .", - "start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start.js" + "start": "npm run build && node dist/start.js" }, "repository": { "type": "git", @@ -34,7 +35,8 @@ "@types/multer": "^1.4.7", "@types/node": "^14.17.0", "@types/node-fetch": "^2.5.7", - "@types/uuid": "^8.3.0" + "@types/uuid": "^8.3.0", + "ts-patch": "^1.4.4" }, "dependencies": { "@fosscord/util": "file:../util", diff --git a/cdn/scripts/tsconfig-paths-bootstrap.js b/cdn/scripts/tsconfig-paths-bootstrap.js deleted file mode 100644 index 50602b02..00000000 --- a/cdn/scripts/tsconfig-paths-bootstrap.js +++ /dev/null @@ -1,10 +0,0 @@ -const tsConfigPaths = require("tsconfig-paths"); -const path = require("path"); - -const cleanup = tsConfigPaths.register({ - baseUrl: path.join(__dirname, ".."), - paths: { - "@fosscord/cdn": ["dist/index.js"], - "@fosscord/cdn/*": ["dist/*"], - }, -}); diff --git a/cdn/tsconfig.json b/cdn/tsconfig.json index 2daac1ad..f893869f 100644 --- a/cdn/tsconfig.json +++ b/cdn/tsconfig.json @@ -70,6 +70,7 @@ "paths": { "@fosscord/cdn/": ["src/index.ts"], "@fosscord/cdn/*": ["src/*"] - } + }, + "plugins": [{ "transform": "@zerollup/ts-transform-paths" }] } } diff --git a/gateway/package-lock.json b/gateway/package-lock.json index 40db319d..df97d858 100644 Binary files a/gateway/package-lock.json and b/gateway/package-lock.json differ diff --git a/gateway/package.json b/gateway/package.json index 6b9e27d6..f5e66a9a 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -4,8 +4,9 @@ "description": "", "main": "dist/index.js", "scripts": { + "prepare": "ts-patch install -s", "test": "echo \"Error: no test specified\" && exit 1", - "start": "npm run build && node -r ./scripts/tsconfig-paths-bootstrap.js dist/start.js", + "start": "npm run build && node dist/start.js", "build": "npx tsc -b .", "dev": "tsnd --respawn src/start.ts" }, @@ -23,6 +24,7 @@ "@types/uuid": "^8.3.0", "@types/ws": "^7.4.0", "ts-node-dev": "^1.1.6", + "ts-patch": "^1.4.4", "typescript": "^4.2.3" }, "dependencies": { diff --git a/gateway/scripts/tsconfig-paths-bootstrap.js b/gateway/scripts/tsconfig-paths-bootstrap.js deleted file mode 100644 index 7308523b..00000000 --- a/gateway/scripts/tsconfig-paths-bootstrap.js +++ /dev/null @@ -1,10 +0,0 @@ -const tsConfigPaths = require("tsconfig-paths"); -const path = require("path"); - -const cleanup = tsConfigPaths.register({ - baseUrl: path.join(__dirname, ".."), - paths: { - "@fosscord/gateway": ["dist/index.js"], - "@fosscord/gateway/*": ["dist/*"], - }, -}); diff --git a/gateway/tsconfig.json b/gateway/tsconfig.json index 2530aa41..c50bd77a 100644 --- a/gateway/tsconfig.json +++ b/gateway/tsconfig.json @@ -72,6 +72,7 @@ "paths": { "@fosscord/gateway/*": ["src/*"], "@fosscord/util/*": ["../util/src/*"] - } + }, + "plugins": [{ "transform": "@zerollup/ts-transform-paths" }] } } diff --git a/util/tsconfig.json b/util/tsconfig.json index ac41cea5..7fbe3bac 100644 --- a/util/tsconfig.json +++ b/util/tsconfig.json @@ -68,12 +68,6 @@ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, "emitDecoratorMetadata": true, "experimentalDecorators": true, - "resolveJsonModule": true, - "plugins": [ - { - "transform": "ts-transform-json-schema", - "type": "program" - } - ] + "resolveJsonModule": true } }