Class: Produce::Group

Inherits:
Object
  • Object
show all
Defined in:
produce/lib/produce/group.rb

Instance Method Summary collapse

Instance Method Details

#app_exists?Boolean

Returns:

  • (Boolean)


86
87
88
# File 'produce/lib/produce/group.rb', line 86

def app_exists?
  Spaceship.app.find(app_identifier) != nil
end

#app_group_exists?(identifier) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'produce/lib/produce/group.rb', line 82

def app_group_exists?(identifier)
  Spaceship.app_group.find(identifier) != nil
end

#app_identifierObject



78
79
80
# File 'produce/lib/produce/group.rb', line 78

def app_identifier
  Produce.config[:app_identifier].to_s
end

#associate(_options, args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'produce/lib/produce/group.rb', line 42

def associate(_options, args)
  

  if !app_exists?
    UI.message("[DevCenter] App '#{Produce.config[:app_identifier]}' does not exist, nothing to associate with the groups")
  else
    app = Spaceship.app.find(app_identifier)
    UI.user_error!("Something went wrong when fetching the app - it's not listed in the apps list") if app.nil?

    new_groups = []

    UI.message("Validating groups before association")

    args.each do |group_identifier|
      if !app_group_exists?(group_identifier)
        UI.message("[DevCenter] App group '#{group_identifier}' does not exist, please create it first, skipping for now")
      else
        new_groups.push(Spaceship.app_group.find(group_identifier))
      end
    end

    UI.message("Finalising association with #{new_groups.count} groups")
    app.associate_groups(new_groups)
    UI.success("Done!")
  end

  return true
end

#create(options, _args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'produce/lib/produce/group.rb', line 6

def create(options, _args)
  

  ENV["CREATED_NEW_GROUP_ID"] = Time.now.to_i.to_s

  group_identifier = options.group_identifier || UI.input("Group identifier: ")

  if app_group_exists?(group_identifier)
    UI.success("[DevCenter] Group '#{options.group_name} (#{options.group_identifier})' already exists, nothing to do on the Dev Center")
    ENV["CREATED_NEW_GROUP_ID"] = nil
    # Nothing to do here
  else
    group_name = options.group_name || group_identifier.split(".").map(&:capitalize).reverse.join(' ')

    UI.success("Creating new app group '#{group_name}' with identifier '#{group_identifier}' on the Apple Dev Center")

    group = Spaceship.app_group.create!(group_id: group_identifier,
                                        name: group_name)

    if group.name != group_name
      UI.important("Your group name includes non-ASCII characters, which are not supported by the Apple Developer Portal.")
      UI.important("To fix this a unique (internal) name '#{group.name}' has been created for you.")
    end

    UI.message("Created group #{group.app_group_id}")

    UI.user_error!("Something went wrong when creating the new app group - it's not listed in the app groups list") unless app_group_exists?(group_identifier)

    ENV["CREATED_NEW_GROUP_ID"] = Time.now.to_i.to_s

    UI.success("Finished creating new app group '#{group_name}' on the Dev Center")
  end

  return true
end

#loginObject



71
72
73
74
75
76
# File 'produce/lib/produce/group.rb', line 71

def 
  UI.message("Starting login with user '#{Produce.config[:username]}'")
  Spaceship.(Produce.config[:username], nil)
  Spaceship.select_team
  UI.message("Successfully logged in")
end