mirror of
https://github.com/Lakr233/GitLab-License-Generator.git
synced 2026-01-30 11:55:35 +02:00
feat: added more parameters to cli
This commit is contained in:
committed by
GitHub
parent
ddb087081c
commit
4291bd13bc
@@ -6,6 +6,12 @@ license_json_path = nil
|
|||||||
public_key_path = nil
|
public_key_path = nil
|
||||||
private_key_path = nil
|
private_key_path = nil
|
||||||
features_json_path = nil
|
features_json_path = nil
|
||||||
|
license_name="Tim Cook"
|
||||||
|
license_company="Apple Computer, Inc."
|
||||||
|
license_email="tcook@apple.com"
|
||||||
|
license_plan='ultimate'
|
||||||
|
license_user_count=2147483647
|
||||||
|
license_expire_year=2500
|
||||||
|
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
@@ -31,6 +37,30 @@ OptionParser.new do |opts|
|
|||||||
license_json_path = File.expand_path(v)
|
license_json_path = File.expand_path(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--license-name <Name>", "Specify license name (optional) [#{license_name}]") do |v|
|
||||||
|
license_name = v
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--license-company <Company Name>", "Specify license company (optional) [#{license_company}]") do |v|
|
||||||
|
license_company = v
|
||||||
|
end
|
||||||
|
|
||||||
|
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 <Email Address>", "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
|
opts.on("-h", "--help", "Prints this help") do
|
||||||
puts opts
|
puts opts
|
||||||
exit
|
exit
|
||||||
@@ -44,6 +74,11 @@ if license_file_path.nil? || public_key_path.nil? || private_key_path.nil?
|
|||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if license_plan != 'ultimate' && license_plan != 'premium' && license_plan != 'starter' &&
|
||||||
|
puts "[!] license plan is set to #{license_plan} which is not one of [ultimate, premium, starter]"
|
||||||
|
puts "[!] use -h for help"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
# ==========
|
# ==========
|
||||||
|
|
||||||
puts "[*] loading keys..."
|
puts "[*] loading keys..."
|
||||||
@@ -74,29 +109,29 @@ license = Gitlab::License.new
|
|||||||
|
|
||||||
# don't use gitlab inc, search `gl_team_license` in lib for details
|
# don't use gitlab inc, search `gl_team_license` in lib for details
|
||||||
license.licensee = {
|
license.licensee = {
|
||||||
"Name" => "Tim Cook",
|
"Name" => license_name,
|
||||||
"Company" => "Apple Computer, Inc.",
|
"Company" => license_company,
|
||||||
"Email" => "tcook@apple.com"
|
"Email" => license_email
|
||||||
}
|
}
|
||||||
|
|
||||||
# required of course
|
# required of course
|
||||||
license.starts_at = Date.new(1976, 4, 1)
|
license.starts_at = Date.new(1976, 4, 1)
|
||||||
|
|
||||||
# required since gem gitlab-license v2.2.1
|
# required since gem gitlab-license v2.2.1
|
||||||
license.expires_at = Date.new(2500, 4, 1)
|
license.expires_at = Date.new(license_expire_year, 4, 1)
|
||||||
|
|
||||||
# prevent gitlab crash at
|
# prevent gitlab crash at
|
||||||
# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at
|
# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at
|
||||||
license.block_changes_at = Date.new(2500, 4, 1)
|
license.block_changes_at = Date.new(license_expire_year, 4, 1)
|
||||||
|
|
||||||
# required
|
# required
|
||||||
license.restrictions = {
|
license.restrictions = {
|
||||||
plan: 'ultimate',
|
plan: license_plan,
|
||||||
# STARTER_PLAN = 'starter'
|
# STARTER_PLAN = 'starter'
|
||||||
# PREMIUM_PLAN = 'premium'
|
# PREMIUM_PLAN = 'premium'
|
||||||
# ULTIMATE_PLAN = 'ultimate'
|
# ULTIMATE_PLAN = 'ultimate'
|
||||||
|
|
||||||
active_user_count: 2147483647,
|
active_user_count: license_user_count,
|
||||||
# required, just dont overflow
|
# required, just dont overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +140,7 @@ license.restrictions = {
|
|||||||
# so here by we inject all features into restrictions
|
# so here by we inject all features into restrictions
|
||||||
# see scan.rb for a list of features that we are going to inject
|
# see scan.rb for a list of features that we are going to inject
|
||||||
for feature in FEATURE_LIST
|
for feature in FEATURE_LIST
|
||||||
license.restrictions[feature] = 2147483647
|
license.restrictions[feature] = license_user_count
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "[*] validating license..."
|
puts "[*] validating license..."
|
||||||
|
|||||||
Reference in New Issue
Block a user