()
| 50 | declare force: boolean |
| 51 | |
| 52 | async run() { |
| 53 | let writeToFile = process.env.NODE_ENV !== 'production' |
| 54 | if (this.force) { |
| 55 | writeToFile = true |
| 56 | } |
| 57 | |
| 58 | if (this.show) { |
| 59 | writeToFile = false |
| 60 | } |
| 61 | |
| 62 | const secureKey = string.random(32) |
| 63 | |
| 64 | if (writeToFile) { |
| 65 | const editor = await EnvEditor.create(this.app.appRoot) |
| 66 | editor.add('APP_KEY', secureKey, true) |
| 67 | await editor.save() |
| 68 | this.logger.action('add APP_KEY to .env').succeeded() |
| 69 | } else { |
| 70 | this.logger.log(`APP_KEY = ${secureKey}`) |
| 71 | } |
| 72 | } |
| 73 | } |