Ihr neuer Entwickler hat gerade einen Arbeitsvertrag unterschrieben und ist bereit, 15 Aufgaben pro Tag mit brennenden Augen zu erledigen. Es gibt nur ein Hindernis auf seinem Weg - einen neuen Laptop, der noch nicht richtig konfiguriert wurde. In den meisten Fällen wird der Prozess zum Einrichten der Umgebung in einem Dokument beschrieben, das an einen neuen Entwickler ausgegeben wird. Wir sind nicht sehr weit gegangen und haben auch eine solche Liste gemacht.
Xcode installieren
Einrichten eines lokalen Git-Repositorys
Umgebung einrichten
Projektaufbau
Lesen Sie die Dokumentation
Einrichten eines Task-Trackers (Jira / Youtrack)
Um keine wertvolle Entwicklerzeit mit dem manuellen Einrichten eines neuen Laptops zu verschwenden, haben wir die Schritte 3 und 4 automatisiert, weil Sie sind am arbeitsintensivsten.
Schauen wir uns also zuerst die Einrichtung der Umgebung an.
Umgebung einrichten
In unserem Fall besteht die Einrichtung der Umgebung aus mehreren Punkten:
1. Installieren von Brühabhängigkeiten
2. mint
3. ruby
4. python
, Ansible. , , , , – playbooks.
, ansible .
:
#!/usr/bin/env bash
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && sudo python get-pip.py
sudo pip install ansible
cd $(dirname $0) && ansible-playbook main.yml
:
pip
Ansible
main.yml
, main.yml
.
- hosts: localhost
roles:
- common_setup
hosts , , , roles , , .
roles , ,
(meta, tasks vars) main.yml
.
main.yml, roles .
tasks, , . , Ruby rvm.
---
- name: Check if RVM already installed
stat: path=~/.rvm
register: rvmdir
changedwhen: false
- name: Install RVM for a user
command: bash -c "\curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles"
when: rvmdir.stat.exists == False
- name: Add RVM to profile
command: bash -c "~/.rvm/bin/rvm get stable --auto-dotfiles"
when: rvmdir.stat.exists == False
- name: Add RVM to zshrc
command: bash -c "echo '\n[ -s ${HOME}/.rvm/scripts/rvm ] && source ${HOME}/.rvm/scripts/rvm' >> ~/.zshrc"
when: rvmdir.stat.exists == False
- name: Install {{ rubyversion }}
command: bash -c "~/.rvm/bin/rvm install {{ rubyversion }}"
when: rvmdir.stat.exists == False
- name: Set Ruby Default
command: bash -c "~/.rvm/bin/rvm --default use {{ rubyversion }}"
when: rvmdir.stat.exists == False
- name: Install Ruby Gems required for iOS app developement
gem: name={{ item.name }} version={{ item.version }} state={{ if item.version is defined nil else latest }}
withitems: "{{ rubygems_packages_to_install }}"
when: rvmdir.stat.exists == False
, rvm.
name
-
stat
- rvm
register
changed_when
rvm.
name
-
command
-
when
-
rvm,
rvmdir
.
rvm. .
.zshrc . MacOS Catalina , zsh .
Ruby. , vars.
main.yml
:
rubyversion: ruby-2.6.5
Ruby
, bundler. vars, :
rubygems_packages_to_install:
- name: bundler
version:2.1.4
, .
.
:
#!/usr/bin/ruby
require 'FileUtils'
require 'colorize'
RESOURCES_DIRECTORY = './Scripts/Resources'.freeze
XCODE_DIRECTORY = '~/Library/Developer/Xcode'.freeze
def setup_git_hooks
puts "Setting up git hooks".blue.bold
git_hooks_path = '.git/hooks'
FileUtils.mkdir_p(git_hooks_path)
Dir["#{RESOURCES_DIRECTORY}/Git hooks/*"].each do |file|
FileUtils.cp_r(file, "#{git_hooks_path}/#{File.basename(file)}")
end
end
def setup_file_templates
puts "\nSetting up file templates".blue.bold
file_templates_path = File.expand_path("#{XCODE_DIRECTORY}/Templates/File Templates/Tests")
FileUtils.mkdir_p(file_templates_path)
Dir["#{RESOURCES_DIRECTORY}/Templates/*.xctemplate"].each do |file|
FileUtils.cp_r(file, "#{file_templates_path}/#{File.basename(file)}")
end
end
def setup_xcode_snippets
puts "\nSetting up xcode snippets".blue.bold
need_to_reboot_xcode = false
code_snippets_path = File.expand_path("#{XCODE_DIRECTORY}/UserData/CodeSnippets")
FileUtils.mkdir_p(code_snippets_path)
Dir["#{RESOURCES_DIRECTORY}/Snippets/*.codesnippet"].each { |file|
path = "#{code_snippets_path}/#{File.basename(file)}"
next if File.file?(path)
need_to_reboot_xcode = true
FileUtils.cp_r(file, path)
}
return unless need_to_reboot_xcode
puts 'Quiting Xcode'.blue
system('killall Xcode')
end
def setup_gems
puts "\nSetting up gems".blue.bold
system('bundle install')
end
def setup_mocks
puts "\nSetting up mocks".blue.bold
system('cd $(pwd) && swiftymocky generate')
end
def setup_projects
puts "\nSetting up projects".blue.bold
system('bundle exec rake update_projects')
end
# Steps
Dir.chdir("#{File.expand_path(File.dirname(__FILE__))}/..")
setup_git_hooks
setup_file_templates
setup_xcode_snippets
setup_gems
setup_mocks
setup_projects
:
-. , .
.
.
.
.
.
, , . Carthage XcodeGen.
1 , . , , .
. , -, .