Skip to content

Commit

Permalink
fix(#19): paths causing crash when building
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu authored Aug 17, 2022
1 parent 152fc2c commit 394cdc7
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .swcrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"@core/*": ["src/core/*"],
"@utils/*": ["src/utils/*"],
"@api/*": ["src/api/*"]
},
"transform": {
"decoratorMetadata": true
}
},
"module": {
Expand Down
87 changes: 87 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
"version": "1.0.0",
"description": "A fully-featured discord bots template written in Typescript, intended to provide a framework that's easy to use, extend and modify",
"license": "MIT",
"main": "build/src/main.js",
"main": "build/main.js",
"scripts": {
"prebuild": "rimraf build/",
"build": "npm run prebuild && tsc --project tsconfig.json && npm run postbuild",
"postbuild": "tsc-alias -p tsconfig.json && npm run copy:static",
"build": "npm run build:clean && swc src -d build && npm run type:check",
"build:changelog": "npx @discordx/changelog --root=src",
"build:serve": "npm run build && npm run serve",
"copy:static": "ncp ./assets ./build/assets",
"serve": "cross-env NODE_ENV=production node build/src/main.js",
"build:clean": "rimraf build",
"serve": "cross-env NODE_ENV=production node build/main.js",
"start": "cross-env NODE_ENV=production node --loader ts-node/esm/transpile-only src/main.ts",

"dev": "npm-run-all --parallel dev:*",
"dev:watch": "cross-env NODE_ENV=development nodemon --watch \"build/**/*\" -e js ./build/src/main.js",
"dev:compile": "swc src mikro-orm.config.ts -w --out-dir build/src && swc mikro-orm.config.ts -w --out-file build/mikro-orm.config.js",
"dev": "npm-run-all --parallel dev:i18n dev:compile dev:watch",
"dev:watch": "cross-env NODE_ENV=development nodemon --watch \"build/**/*\" -e js ./build/main.js",
"dev:compile": "swc src -w -d build",
"dev:i18n": "typesafe-i18n",

"test": "nodemon --exec node --loader ts-node/esm/transpile-only tests/main.ts",
"type:check": "tsc --pretty --skipLibCheck --noEmit",
"migration:create": "npx mikro-orm migration:create",
"migration:up": "npx mikro-orm migration:up",
"migration:down": "npx mikro-orm migration:down",
Expand Down Expand Up @@ -57,6 +53,7 @@
"http-status-codes": "^2.2.0",
"image-hash": "^5.3.1",
"imgur": "^2.2.0",
"joi": "^17.6.0",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-context-validator": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/services/Database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { delay, inject, singleton } from 'tsyringe'
import { EntityName, MikroORM } from '@mikro-orm/core'
import { EntityName, MikroORM, Options } from '@mikro-orm/core'
import { EntityManager, SqliteDriver } from '@mikro-orm/sqlite'
import { backup, restore } from 'saveqlite'
import fs from 'fs'
Expand All @@ -22,7 +22,7 @@ export class Database {
async initialize() {

// initialize the ORM using the configuration exported in `mikro-orm.config.ts`
this._orm = await MikroORM.init()
this._orm = await MikroORM.init(mikroORMConfig[process.env.NODE_ENV || 'development'] as Options<SqliteDriver>)

const migrator = this._orm.getMigrator()

Expand Down
2 changes: 1 addition & 1 deletion src/services/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Logger {
// console.debug = (...args) => this.log("debug", args.join(", "))
}

private readonly logPath: string = `${__dirname.includes('build') ? `${__dirname}/..` : __dirname}/../../logs`
private readonly logPath: string = `${__dirname}/../../logs`
private readonly levels = ['debug', 'info', 'warn', 'error'] as const
private spinner = ora()
private defaultConsole: typeof console
Expand Down

0 comments on commit 394cdc7

Please sign in to comment.