Skip to content

Commit

Permalink
feat: add generate:key command
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Feb 26, 2020
1 parent 08e8abc commit 68751f0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
28 changes: 28 additions & 0 deletions commands/GenerateKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* @adonisjs/core
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import randomstring from 'randomstring'
import { BaseCommand } from '@adonisjs/ace'

/**
* A command to generate a secure app key
*/
export default class GenerateKey extends BaseCommand {
public static commandName = 'generate:key'
public static description = 'Generate a new APP_KEY secret'

public async handle () {
const secret = randomstring.generate({ length: 32 })
console.log(this.colors.green(secret))

console.log(this.colors.gray(
' > During development, you may want to set the above secret as APP_KEY inside the .env file'
))
}
}
1 change: 1 addition & 0 deletions commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
export default [
'@adonisjs/core/build/commands/DumpRc',
'@adonisjs/core/build/commands/ListRoutes',
'@adonisjs/core/build/commands/GenerateKey',
]
15 changes: 15 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"macroable": "^4.0.2",
"ms": "^2.1.2",
"on-finished": "^2.3.0",
"randomstring": "^1.1.5",
"serve-static": "^1.14.1"
},
"peerDependencies": {
Expand Down

0 comments on commit 68751f0

Please sign in to comment.