#!/usr/bin/env ruby $:.push File.expand_path("../../lib", __FILE__) require 'sigh' require 'commander/import' require 'credentials_manager/password_manager' require 'credentials_manager/appfile_config' HighLine.track_eof = false # Commander program :version, Sigh::VERSION program :description, 'CLI for \'sigh\' - Because you would rather spend your time building stuff than fighting provisioning' program :help, 'Author', 'Felix Krause ' program :help, 'Website', 'http://fastlane.tools' program :help, 'GitHub', 'https://github.com/krausefx/sigh' program :help_formatter, :compact global_option('--verbose') { $verbose = true } command :renew do |c| c.syntax = 'sigh renew' c.description = 'Renews the certificate (in case it expired) and outputs the path to the generated file' c.option '-a', '--identifier STRING', String, 'The bundle identifier of your app' c.option '-u', '--username STRING', String, 'Your Apple ID username' c.option '-n', '--cert_name STRING', String, 'The name of the generated certificate file.' c.option '-o', '--output STRING', String, 'The folder in which the file should be generated.' c.option '--adhoc', 'By default, sigh will create and renew App Store profiles. Setting this flag will generate Adhoc profiles instead.' c.option '--skip_install', 'By default, the certificate will be added on your local machine. Setting this flag will skip this action.' c.option '--development', 'Renew the development certificate instead of the production one' c.action do |args, options| app = app_identifier(options) username(options) type = Sigh::DeveloperCenter::APPSTORE type = Sigh::DeveloperCenter::ADHOC if options.adhoc type = Sigh::DeveloperCenter::DEVELOPMENT if options.development path = Sigh::DeveloperCenter.new.run(app, type, options.cert_name) if path file_name = File.basename(path) output_path = options.output || '.' output = File.join(output_path.gsub("~", ENV["HOME"]), file_name) FileUtils.mv(path, output) system("open '#{output}'") unless options.skip_install puts output.green end end end default_command :renew def username(options) user = options.username user ||= ENV["SIGH_USERNAME"] user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) CredentialsManager::PasswordManager.shared_manager(user) if user end def app_identifier(options) value = options.identifier value ||= ENV["SIGH_APP_IDENTIFIER"] value ||= CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) value ||= ask("App Identifier (Bundle ID, e.g. com.krausefx.app): ") return value end