zents-cli
Version:
ZenTS is a Node.js & TypeScript MVC-Framework for building rich web applications, released as free and open-source software under the MIT License. It is designed for building web applications with modern tools and design patterns.
33 lines (32 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const AbstractCommand_1 = require("../../classes/AbstractCommand");
const crypto_1 = tslib_1.__importDefault(require("crypto"));
const command_1 = require("@oclif/command");
class SecretKey extends AbstractCommand_1.AbstractCommand {
async run() {
const { flags } = this.parse(SecretKey);
this.welcome('Your secret key is:');
this.log(crypto_1.default.randomBytes(flags.len).toString('hex'));
}
}
exports.default = SecretKey;
SecretKey.description = 'generate a secret key for security configurations';
SecretKey.examples = ['$ zen security:secret-key', '$ zen security:secret-key --len=60'];
SecretKey.flags = {
len: command_1.flags.integer({
char: 'l',
description: 'length of the generated key (min: 32)',
parse: (input) => {
const min = 32;
let value = parseInt(input, 10);
if (value < min) {
value = min;
}
return value;
},
default: 42,
required: false,
}),
};