From e79080a00486e5f69044dbe58eaf9d1cd4616416 Mon Sep 17 00:00:00 2001 From: Arthur Danjou Date: Fri, 18 Jun 2021 21:42:13 +0200 Subject: [PATCH] Working --- ace-manifest.json | 12 ------------ commands/UserCreate.ts | 40 ---------------------------------------- package.json | 6 ++---- providers/AppProvider.ts | 12 ++++++++++++ 4 files changed, 14 insertions(+), 56 deletions(-) delete mode 100644 commands/UserCreate.ts diff --git a/ace-manifest.json b/ace-manifest.json index a77a38e..48f6f56 100644 --- a/ace-manifest.json +++ b/ace-manifest.json @@ -1,17 +1,5 @@ { "commands": { - "user:create": { - "settings": { - "loadApp": true, - "stayAlive": false - }, - "commandPath": "./commands/UserCreate", - "commandName": "user:create", - "description": "Create the default user", - "args": [], - "aliases": [], - "flags": [] - }, "dump:rcfile": { "settings": {}, "commandPath": "@adonisjs/core/build/commands/DumpRc", diff --git a/commands/UserCreate.ts b/commands/UserCreate.ts deleted file mode 100644 index a2096a7..0000000 --- a/commands/UserCreate.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { BaseCommand } from '@adonisjs/core/build/standalone' - -export default class UserCreate extends BaseCommand { - - /** - * Command name is used to run the command - */ - public static commandName = 'user:create' - - /** - * Command description is displayed in the "help" output - */ - public static description = 'Create the default user' - - public static settings = { - /** - * Set the following value to true, if you want to load the application - * before running the command - */ - loadApp: true, - - /** - * Set the following value to true, if you want this command to keep running until - * you manually decide to exit the process - */ - stayAlive: false, - } - - public async run () { - const { default: User } = await import('App/Models/User') - const { default: Env } = await import('@ioc:Adonis/Core/Env') - await User.firstOrCreate({ - email: Env.get('ADMIN_USER', 'admin@linkyjs.dev') - }, { - email: Env.get('ADMIN_USER', 'admin@linkyjs.dev'), - password: Env.get('ADMIN_PASSWORD', 'password') - }) - this.logger.info('User successfully created !') - } -} diff --git a/package.json b/package.json index 7cc1cf3..7af96a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@linkyjs/core", - "version": "1.0.9", + "version": "1.0.10", "description": "URL Shortener for Developers 💻", "main": "start/kernel.ts", "repository": { @@ -16,10 +16,8 @@ "scripts": { "build": "node ace build --production", "start": "node server.js", - "seed": "node ace db:seed", "mig": "node ace migration:run", - "generate": "node ace generate:key", - "user": "node ace user:create" + "generate": "node ace generate:key" }, "devDependencies": { "@adonisjs/assembler": "^5.3.2", diff --git a/providers/AppProvider.ts b/providers/AppProvider.ts index 1c8ec8e..80a35fd 100644 --- a/providers/AppProvider.ts +++ b/providers/AppProvider.ts @@ -13,6 +13,18 @@ export default class AppProvider { } public async ready () { + const { default: User } = await import('App/Models/User') + const { default: Env } = await import('@ioc:Adonis/Core/Env') + const { default: Logger } = await import('@ioc:Adonis/Core/Logger') + const user = await User.firstOrCreate({ + email: Env.get('ADMIN_USER', 'admin@linkyjs.dev') + }, { + email: Env.get('ADMIN_USER', 'admin@linkyjs.dev'), + password: Env.get('ADMIN_PASSWORD', 'password') + }) + if (user) { + Logger.info('User successfully created') + } } public async shutdown () {