cocoapods-hooks 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 34a8f75a4c149e23f7e8a89da4e4ef52542255f18ee9468072b3f89936cf4d88
4
+ data.tar.gz: 5e826359b216b88c93a862f90961b7ed79489911165d4c6964ac0a72b8fcdc3b
5
+ SHA512:
6
+ metadata.gz: d0dcb09899bce00b905c21ead92b245f4d55827302ca75c5b1187027af6aa94684f58afef47d17dde2af2ebd7c7c5d0f2fe124f0bb62d36487bbc5f35dc9ade0
7
+ data.tar.gz: 8ef78f056a942eb258cbe9e7b89b702e5cfa915a4faf80bf46c713730c7390fbd251426624c6ea9524e304f79ca086a84af7a2c4191b71ca8949cf160fc327f8
@@ -0,0 +1,39 @@
1
+ require 'cocoapods/command'
2
+
3
+ module Pod
4
+ class Command
5
+ class ChangeColor < Command
6
+ self.summary = '根据配置文件里的 themecolor 修改资源图片'
7
+
8
+ def initialize(argv)
9
+ super
10
+ end
11
+
12
+ def self.options
13
+ [
14
+
15
+ ].concat(super)
16
+ end
17
+
18
+ def validate!
19
+ super
20
+ end
21
+
22
+ def run
23
+ UI.puts "change project theme color for theme and mutable theme #{@tenantid}"
24
+ # 执行你的业务逻辑
25
+ self.class.changeThemeColor()
26
+ end
27
+
28
+ private
29
+
30
+ def self.changeThemeColor()
31
+ # 改变 theme 文件夹的图片颜色
32
+ system("python3 ChangeColor.py")
33
+ # 改变 mutableTheme 文件夹的图片颜色
34
+ system("python3 svg2png.py")
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ require 'cocoapods/command'
2
+
3
+ module Pod
4
+ class Command
5
+ class FastlaneSign < Command
6
+ self.summary = '根据 配置文件 修改 xcode 工程,进行签名'
7
+
8
+ def initialize(argv)
9
+ super
10
+ end
11
+
12
+ def self.options
13
+ [
14
+
15
+ ].concat(super)
16
+ end
17
+
18
+ def validate!
19
+ super
20
+ end
21
+
22
+ def run
23
+ # 执行你的业务逻辑
24
+ system("fastlane ios configAllProject")
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,86 @@
1
+ require 'cocoapods/command'
2
+
3
+ module Pod
4
+ class Command
5
+ class GitClone < Command
6
+ self.summary = '根据 tenantid 下载 OEM 相关配置'
7
+
8
+ def self.options
9
+ [
10
+ ['--tenantid=TENANTID', 'Specify the tenant ID'],
11
+ ['--branch=Branch', 'Specify the branch for git clone']
12
+ ].concat(super)
13
+ end
14
+
15
+ def initialize(argv)
16
+ @tenantid = argv.option('tenantid')
17
+ @branch = argv.option('branch')
18
+ super
19
+ end
20
+
21
+ def validate!
22
+ super
23
+ help! 'A tenant ID is required.' unless @tenantid
24
+ end
25
+
26
+ def run
27
+ UI.puts "Downloading OEM configuration for tenant #{@tenantid}"
28
+ # 执行你的业务逻辑
29
+ if @branch == nil
30
+ UI.puts "没有传入指定分支,默认使用 main_develop"
31
+ @branch = 'main_develop'
32
+ end
33
+ self.class.git_clone_project_config(@tenantid, @branch)
34
+ end
35
+
36
+ private
37
+ def self.git_clone_project_config(tenant_id, branch)
38
+ puts "start download ios project config with tenantid: #{tenant_id}"
39
+ # 先尝试删除源目录
40
+ if Dir.exist?('ios_project_config')
41
+ puts "ios_project_config exist, try remove now!"
42
+ FileUtils.rm_r('ios_project_config')
43
+ end
44
+ ios_project_config_git_url = 'ssh://git@192.168.31.7:7999/ios_module/ios_project_config.git'
45
+ success = system("git clone -b #{branch} #{ios_project_config_git_url}")
46
+ puts "当前命令的路径为:#{Dir.pwd}"
47
+ if success
48
+ puts "repository cloned to #{Dir.pwd}"
49
+ project_config_plist_path = Dir.pwd + "/ios_project_config/#{tenant_id}/ProjectConfig.plist"
50
+ # 将配置文件拷贝到工程目录下
51
+ FileUtils.cp(project_config_plist_path, CocoapodsHooks::PLIST_PATH)
52
+ puts "AppIcon.appiconset path is: #{Dir.pwd + "/ios_project_config/#{tenant_id}/resource/AppIcon.appiconset"}"
53
+ puts "dest AppIcon.appiconset path is: #{Dir.pwd + '/AddxAi/Assets.xcassets/AppIcon.appiconset'}"
54
+ # 将资源文件拷贝到资源目录下
55
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/AppIcon.appiconset", Dir.pwd + '/AddxAi/Assets.xcassets', remove_destination: true)
56
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/LaunchImage.launchimage", Dir.pwd + '/AddxAi/Assets.xcassets', remove_destination: true)
57
+ # # 替换其他的资源图片
58
+ device_setting_dir = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/DeviceSetting/."
59
+ if File.exist?(device_setting_dir)
60
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/DeviceSetting/.", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/Assets.xcassets/DeviceSetting')
61
+ end
62
+ home_user_dir = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/HomeUser/."
63
+ if File.exist?(home_user_dir)
64
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/HomeUser/.", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/Assets.xcassets/HomePage')
65
+ end
66
+ account_logo_dir = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/account_logo.imageset"
67
+ if File.exist?(account_logo_dir)
68
+ FileUtils.cp_r(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/account_logo.imageset", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/Assets.xcassets/Account')
69
+ end
70
+ user_login_bg = Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/user_login_bg.png"
71
+ if File.exist?(user_login_bg)
72
+ FileUtils.cp(Dir.pwd + "/ios_project_config/#{tenant_id}/resource/Account/user_login_bg.png", Dir.pwd + '/AddxAi/Classes/A4xBaseSDK/Resources/other/Resource/user_login_bg.png')
73
+ end
74
+ # 拷贝完成后,删除本地的配置文件夹
75
+ FileUtils.rm_r('ios_project_config')
76
+ else
77
+ puts "Failed to clone repository"
78
+ exit 1
79
+ end
80
+ end
81
+
82
+
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,43 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class Hooks < Command
21
+ self.summary = 'Short description of cocoapods-hooks.'
22
+
23
+ self.description = <<-DESC
24
+ Longer description of cocoapods-hooks.
25
+ DESC
26
+
27
+ def initialize(argv)
28
+ @name = argv.shift_argument
29
+ puts "name: #{@name}"
30
+ super
31
+ end
32
+
33
+ def validate!
34
+ super
35
+ help! 'A Pod name is required.' unless @name
36
+ end
37
+
38
+ def run
39
+ UI.puts "Add your implementation for the cocoapods-hooks plugin in #{__FILE__}"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ require 'cocoapods/command'
2
+
3
+ module Pod
4
+ class Command
5
+ class OemConfig < Command
6
+ self.summary = '根据 tenantid 配置所有的 OEM 配置,包含三步:1. 根据 tenant_id 下载相关的配置文件 2. 修改图片的主题色 3. 修改工程配置, 进行签名'
7
+
8
+ def self.options
9
+ [
10
+ ['--tenantid=TENANTID', 'Specify the tenant ID'],
11
+ ['--branch=Branch', 'Specify the branch for git clone']
12
+ ].concat(super)
13
+ end
14
+
15
+ def initialize(argv)
16
+ @tenantid = argv.option('tenantid')
17
+ @branch = argv.option('branch')
18
+ super
19
+ end
20
+
21
+ def validate!
22
+ super
23
+ help! 'A tenant ID is required.' unless @tenantid
24
+ end
25
+
26
+ def run
27
+ UI.puts "Downloading OEM configuration for tenant #{@tenantid}"
28
+ # 执行你的业务逻辑
29
+ if @branch == nil
30
+ UI.puts "没有传入指定分支,默认使用 main_develop"
31
+ @branch = 'main_develop'
32
+ end
33
+ # 1. 根据 tenant_id 下载相关的配置文件
34
+ system("pod git-clone --tenantid=#{@tenantid} --branch=#{@branch}")
35
+ # 2. 修改图片的主题色
36
+ system("pod change-color")
37
+ # 3. 修改工程配置, 进行签名
38
+ system("pod fastlane-sign")
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,5 @@
1
+ require 'cocoapods-hooks/command/hooks'
2
+ require 'cocoapods-hooks/command/git_clone.rb'
3
+ require 'cocoapods-hooks/command/change_color.rb'
4
+ require 'cocoapods-hooks/command/fastlane_sign.rb'
5
+ require 'cocoapods-hooks/command/oem_config.rb'
@@ -0,0 +1,3 @@
1
+ module CocoapodsHooks
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-hooks/gem_version'
@@ -0,0 +1,33 @@
1
+ require 'cocoapods-hooks/command'
2
+ require 'install'
3
+ require 'dsl'
4
+ require 'cocoapods'
5
+ require 'fileutils'
6
+ require 'plist'
7
+
8
+ module CocoapodsHooks
9
+
10
+ PLIST_PATH = Dir.pwd + '/AddxAi/AppConfig/ProjectConfig.plist'
11
+ # 注册 pod install 钩子
12
+ Pod::HooksManager.register('cocoapods-hooks', :pre_install) do |installer|
13
+ p "cocoapods-plugin-hooks, hooks pre_install"
14
+ end
15
+
16
+
17
+ Pod::HooksManager.register('cocoapods-hooks', :post_install) do |installer|
18
+ p "cocoapods-plugin-hooks, hooks post_install"
19
+ end
20
+
21
+ Pod::HooksManager.register('cocoapods-hooks', :source_provider) do |context|
22
+ p "cocoapods-plugin-hooks, hooks source_provider"
23
+ end
24
+
25
+ Pod::HooksManager.register('cocoapods-hooks', :pre_integrate) do |context|
26
+ p "cocoapods-plugin-hooks, hooks pre_integrate"
27
+ end
28
+
29
+ Pod::HooksManager.register('cocoapods-hooks', :post_integrate) do |context|
30
+ p "cocoapods-plugin-hooks, hooks post_integrate"
31
+ end
32
+
33
+ end
data/lib/dsl.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Pod
2
+ class Podfile
3
+ module DSL
4
+ class << self
5
+ user_defined_options = []
6
+ attr_accessor :user_defined_options
7
+ end
8
+
9
+ def user_defined_options
10
+ DSL.user_defined_options
11
+ end
12
+ end
13
+ end
14
+ end
data/lib/install.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Pod
2
+ class Command
3
+ class Install
4
+
5
+ alias_method :original_initialize, :initialize
6
+
7
+ def initialize(argv)
8
+ options = remove_from_argv(argv, 'user-defined-')
9
+ update_podfile(options)
10
+ original_initialize(argv)
11
+ end
12
+
13
+ private
14
+
15
+ def remove_from_argv(argv, key)
16
+ options = filter_by_key(argv.options, key)
17
+ options.keys.each { |k| argv.option("#{key}#{k}") }
18
+ options
19
+ end
20
+
21
+ def filter_by_key(options, key)
22
+ filtered_options = {}
23
+ options.each do |(k, v)|
24
+ if v == 'true' then v = true
25
+ elsif v == 'false' then v = false
26
+ end
27
+ filtered_options[k.gsub(key, '').to_sym] = v if k.include?(key)
28
+ end
29
+ filtered_options
30
+ end
31
+
32
+ def update_podfile(options)
33
+ Pod::Podfile::DSL.user_defined_options = options
34
+ end
35
+
36
+ class << self
37
+ alias_method :original_options, :options
38
+
39
+ def options
40
+ new_option = [['--user-defined-{key}=value', 'Adds user defined flags that can be accessed inside the Podfile']]
41
+ original_options.concat(new_option)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-hooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - huafeng
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: plist
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A short description of cocoapods-hooks.
56
+ email:
57
+ - hm@a4x.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/cocoapods-hooks.rb
63
+ - lib/cocoapods-hooks/command.rb
64
+ - lib/cocoapods-hooks/command/change_color.rb
65
+ - lib/cocoapods-hooks/command/fastlane_sign.rb
66
+ - lib/cocoapods-hooks/command/git_clone.rb
67
+ - lib/cocoapods-hooks/command/hooks.rb
68
+ - lib/cocoapods-hooks/command/oem_config.rb
69
+ - lib/cocoapods-hooks/gem_version.rb
70
+ - lib/cocoapods_plugin.rb
71
+ - lib/dsl.rb
72
+ - lib/install.rb
73
+ homepage: https://github.com/EXAMPLE/cocoapods-hooks
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.4.12
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: A longer description of cocoapods-hooks.
96
+ test_files: []