mirror of
https://github.com/Lakr233/GitLab-License-Generator.git
synced 2026-01-30 11:55:35 +02:00
fix: added year and user count validations
This commit is contained in:
committed by
GitHub
parent
66e00738a2
commit
9a70dabcfb
@@ -48,19 +48,19 @@ OptionParser.new do |opts|
|
||||
opts.on("--license-email EMAIL-ADDRESS", "Specify license email address (optional) [#{license_email}]") do |v|
|
||||
license_email = v
|
||||
end
|
||||
|
||||
|
||||
opts.on("--license-plan PLAN", "Specify license plan (optional) [#{license_plan} (default), premium, starter]") do |v|
|
||||
license_plan = v
|
||||
end
|
||||
|
||||
|
||||
opts.on("--license-user-count COUNT", "Specify license user count (optional) [#{license_user_count} (default)]") do |v|
|
||||
license_user_count = v.to_i
|
||||
end
|
||||
|
||||
|
||||
opts.on("--license-expire-year YEAR", "Specify license expire year (optional) [#{license_expire_year} (default)]") do |v|
|
||||
license_expire_year = v.to_i
|
||||
end
|
||||
|
||||
|
||||
opts.on("-h", "--help", "Prints this help") do
|
||||
puts opts
|
||||
exit
|
||||
@@ -79,6 +79,19 @@ if license_plan != 'ultimate' && license_plan != 'premium' && license_plan !=
|
||||
puts "[!] use -h for help"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if Time.now.year > license_expire_year
|
||||
puts "[!] license expiry year is set to #{license_expire_year} which is less than current year, this value must be greater than current year"
|
||||
puts "[!] use -h for help"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if license_user_count < 1
|
||||
puts "[!] license user count is set to #{license_user_count} which is less minumum user count possible"
|
||||
puts "[!] use -h for help"
|
||||
exit 1
|
||||
end
|
||||
|
||||
# ==========
|
||||
|
||||
puts "[*] loading keys..."
|
||||
@@ -94,7 +107,7 @@ if !features_json_path.nil?
|
||||
puts "[*] loading features from #{features_json_path}"
|
||||
require 'json'
|
||||
FEATURE_LIST = JSON.parse(File.read(features_json_path))
|
||||
else
|
||||
else
|
||||
FEATURE_LIST = []
|
||||
end
|
||||
puts "[*] total features to inject: #{FEATURE_LIST.size}"
|
||||
@@ -116,7 +129,7 @@ license.licensee = {
|
||||
|
||||
# required of course
|
||||
license.starts_at = Date.new(1976, 4, 1)
|
||||
|
||||
puts Date.new()
|
||||
# required since gem gitlab-license v2.2.1
|
||||
license.expires_at = Date.new(license_expire_year, 4, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user