]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/installer.ts
Fix old DB enum names
[github/Chocobozzz/PeerTube.git] / server / initializers / installer.ts
index c1899824414d9c9d2dff7d4ccce1b127de27d0fa..b02be956702505add2383ba165777c202f692f13 100644 (file)
@@ -1,5 +1,8 @@
 import { ensureDir, readdir, remove } from 'fs-extra'
 import passwordGenerator from 'password-generator'
+import { join } from 'path'
+import { isTestOrDevInstance } from '@server/helpers/core-utils'
+import { getNodeABIVersion } from '@server/helpers/version'
 import { UserRole } from '@shared/models'
 import { logger } from '../helpers/logger'
 import { buildUser, createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user'
@@ -67,7 +70,7 @@ async function removeDirectoryOrContent (dir: string) {
     const files = await readdir(dir)
 
     for (const file of files) {
-      await remove(file)
+      await remove(join(dir, file))
     }
   }
 }
@@ -134,8 +137,8 @@ async function createOAuthAdminIfNotExist () {
   let validatePassword = true
   let password = ''
 
-  // Do not generate a random password for tests
-  if (process.env.NODE_ENV === 'test') {
+  // Do not generate a random password for test and dev environments
+  if (isTestOrDevInstance()) {
     password = 'test'
 
     if (process.env.NODE_APP_INSTANCE) {
@@ -173,7 +176,9 @@ async function createApplicationIfNotExist () {
   logger.info('Creating application account.')
 
   const application = await ApplicationModel.create({
-    migrationVersion: LAST_MIGRATION_VERSION
+    migrationVersion: LAST_MIGRATION_VERSION,
+    nodeVersion: process.version,
+    nodeABIVersion: getNodeABIVersion()
   })
 
   return createApplicationActor(application.id)