mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-14 18:59:56 +01:00
Working
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
{
|
||||
"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",
|
||||
|
||||
40
commands/UserCreate.ts
Normal file
40
commands/UserCreate.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
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 !')
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@linkyjs/core",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "URL Shortener for Developers 💻",
|
||||
"main": "start/kernel.ts",
|
||||
"repository": {
|
||||
@@ -18,7 +18,8 @@
|
||||
"start": "node server.js",
|
||||
"seed": "node ace db:seed",
|
||||
"mig": "node ace migration:run",
|
||||
"generate": "node ace generate:key"
|
||||
"generate": "node ace generate:key",
|
||||
"user": "node ace user:create"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@adonisjs/assembler": "^5.3.2",
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { ApplicationContract } from '@ioc:Adonis/Core/Application'
|
||||
import User from "../app/Models/User";
|
||||
import Env from "@ioc:Adonis/Core/Env";
|
||||
|
||||
export default class AppProvider {
|
||||
public static needsApplication = true
|
||||
@@ -15,12 +13,6 @@ export default class AppProvider {
|
||||
}
|
||||
|
||||
public async ready () {
|
||||
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')
|
||||
})
|
||||
}
|
||||
|
||||
public async shutdown () {
|
||||
|
||||
Reference in New Issue
Block a user