Sha256: e59ccecc379dd13e552335689eb2b8d805eb82a12746a164fb27fb2170f11e4e
Contents?: true
Size: 1.21 KB
Versions: 18
Compression:
Stored size: 1.21 KB
Contents
require "hanami/utils/blank" require "securerandom" module Hanami class CLI module Commands module Generate # @since 1.1.0 # @api private class Secret < Command requires "environment" desc "Generate session secret" argument :app, desc: "The application name (eg. `web`)" example [ " # Prints secret (eg. `#{Project.app_sessions_secret}`)", "web # Prints session secret (eg. `WEB_SESSIONS_SECRET=#{Project.app_sessions_secret}`)" ] # @since 1.1.0 # @api private def call(app: nil, **options) context = Context.new(app: app, options: options) generate_secret(context) end private # @since 1.1.0 # @api private def generate_secret(context) secret = project.app_sessions_secret if Hanami::Utils::Blank.blank?(context.app) puts secret else puts "Set the following environment variable to provide the secret token:" puts %(#{context.app.upcase}_SESSIONS_SECRET="#{secret}") end end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems