cocoapods-azure-universal-packages2 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f7c6958396e8971a36dbc07e01099a518c0863f2908739f25af891c3528d54fa
4
+ data.tar.gz: 1df3179c1182a84bdc768bbddb6ca0b1a98f57c6e093d73204b9cb8194fa5fff
5
+ SHA512:
6
+ metadata.gz: 2237ee62ebc27637f86c04824af0f38bfd9ee9294fa273067134413034be4e4f5546185f0c47208e3524356eff078690e8120f9d776735fda41666a986b67697
7
+ data.tar.gz: eba3a32ccb50ed18f59dd6c7defea71d934bd05630a076d8b308d225b05ffb6622c507a43a02f5c840f91ed2fcc5c20effb443e9536badde225511628e4717cb
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # CocoaPods Azure Universal Packages plugin
2
+
3
+ This project is a [CocoaPods](https://github.com/CocoaPods/CocoaPods) plugin that allows to dowload pods published as [Universal Packages](https://docs.microsoft.com/en-us/azure/devops/artifacts/quickstarts/universal-packages) in [Azure Artifacts](https://azure.microsoft.com/en-gb/services/devops/artifacts/) feeds.
4
+
5
+ ## Getting started
6
+
7
+ Install the plugin by adding to your `Gemfile`
8
+ ```Ruby
9
+ gem "cocoapods-azure-universal-packages"
10
+ ```
11
+
12
+ Under the hood the plugin uses the [Azure CLI](https://aka.ms/azcli) to download the Universal Packages, you can install it running
13
+ ```shell
14
+ brew update && brew install azure-cli
15
+ ```
16
+
17
+ Finally, ensure that you are logged in using
18
+ ```shell
19
+ az login
20
+ ```
21
+
22
+ ## How it works
23
+
24
+ The plugin replaces the default CocoaPods HTTP downloader when a pod source URL points to a universal package and it uses the Azure CLI to perform the download.
25
+
26
+ _Note:_ The plugin will install the Azure CLI [DevOps extension](https://github.com/Azure/azure-devops-cli-extension) automatically when running `pod install` or `pod update` for the first time.
27
+
28
+ ## Usage
29
+
30
+ Add to your Podfile
31
+ ```Ruby
32
+ plugin 'cocoapods-azure-universal-packages', {
33
+ :organization => '{{ORGANIZATION_URL}}'
34
+ }
35
+ ```
36
+ replacing `{{ORGANIZATION_URL}}` with the base URL of your Azure Artifacts feed (for example: `https://pkgs.dev.azure.com/myorg`).
37
+
38
+ Then, in your podspec set the pod's source to
39
+ ```Ruby
40
+ # For project scoped feeds:
41
+ spec.source = { :http => '{{ORGANIZATION_URL}}/{{PROJECT}}/_apis/packaging/feeds/{{FEED}}/upack/packages/{{PACKAGE}}/versions/{{VERSION}}' }
42
+
43
+ # For organization scoped feeds:
44
+ spec.source = { :http => '{{ORGANIZATION_URL}}/_apis/packaging/feeds/{{FEED}}/upack/packages/{{PACKAGE}}/versions/{{VERSION}}' }
45
+ ```
46
+ where:
47
+ - `{{ORGANIZATION_URL}}` is the URL of your feed's organization
48
+ - `{{PROJECT}}` is the name of your feed's project (you must specify this only if your feed is a project scoped feed)
49
+ - `{{PACKAGE}}` is the name of your universal package
50
+ - `{{VERSION}}` is the version of your universal package
51
+
52
+ ### Plugin parameters
53
+
54
+ | Parameter | Description |
55
+ | --------- | ----------- |
56
+ | `organization` | The URL of the Azure Artifacts feed's orgnization. Required unless `organizations` is specified. |
57
+ | `organizations` | An array of URLs of possible Azure Artifacts feeds' organizations. Required unless `organization` is specified. |
58
+ | `update_cli_extension` | Whether to update the Azure CLI DevOps extensions automatically. Default to `false`. |
59
+
60
+ ## Run tests for this plugin
61
+
62
+ To run the tests, use
63
+ ```shell
64
+ rake tests
65
+ ```
66
+
67
+ ## Contributing
68
+
69
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
70
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
71
+ the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
72
+
73
+ When you submit a pull request, a CLA bot will automatically determine whether you need to provide
74
+ a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
75
+ provided by the bot. You will only need to do this once across all repos using our CLA.
76
+
77
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
78
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
79
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
@@ -0,0 +1,93 @@
1
+ require 'addressable'
2
+ require 'cocoapods'
3
+ require 'cocoapods-downloader'
4
+
5
+ module Pod
6
+ module Downloader
7
+
8
+ @azure_organizations = []
9
+
10
+ class << self
11
+ attr_accessor :azure_organizations
12
+ end
13
+
14
+ class Http
15
+
16
+ private
17
+
18
+ alias_method :aliased_download!, :download!
19
+
20
+ executable :az
21
+
22
+ def download!
23
+ # Check if the url matches any known Azure organization
24
+ organization = Downloader.azure_organizations.find { |org| url.to_s.start_with?(org) }
25
+
26
+ if organization.nil?
27
+ aliased_download!
28
+ else
29
+ # Parse the url
30
+ organization.delete_suffix!('/')
31
+ aup_uri_template = Addressable::Template.new(
32
+ "#{organization}{/project}/_apis/packaging/feeds/{feed}/upack/packages/{package}/versions/{version}"
33
+ )
34
+ uri = Addressable::URI.parse(url)
35
+ aup_uri_components = aup_uri_template.extract(uri)
36
+
37
+ if !aup_uri_components.nil?
38
+ download_azure_universal_package!(aup_uri_components.merge({ 'organization' => organization }))
39
+
40
+ # Extract the file if it's the only one in the package
41
+ package_files = target_path.glob('*')
42
+ if package_files.count == 1 && package_files.first.file?
43
+ file = package_files.first
44
+ file_type = begin
45
+ case file.to_s
46
+ when /\.zip$/
47
+ :zip
48
+ when /\.(tgz|tar\.gz)$/
49
+ :tgz
50
+ when /\.tar$/
51
+ :tar
52
+ when /\.(tbz|tar\.bz2)$/
53
+ :tbz
54
+ when /\.(txz|tar\.xz)$/
55
+ :txz
56
+ when /\.dmg$/
57
+ :dmg
58
+ end
59
+ end
60
+ extract_with_type(file, file_type) unless file_type.nil?
61
+ end
62
+ else
63
+ Pod::UserInterface.warn("#{url} looks like a Azure artifact feed but it's malformed")
64
+ aliased_download!
65
+ end
66
+ end
67
+ end
68
+
69
+ def download_azure_universal_package!(params)
70
+ ui_sub_action("Downloading #{params['package']} (#{params['version']}) from Azure feed #{params['feed']} (#{[params['organization'], params['project']].compact.join('/')})") do
71
+ parameters = [
72
+ 'artifacts',
73
+ 'universal',
74
+ 'download',
75
+ '--organization', params['organization'],
76
+ '--feed', params['feed'],
77
+ '--name', params['package'],
78
+ '--version', params['version'],
79
+ '--path', target_path.to_s
80
+ ]
81
+
82
+ # If it's a project scoped feed, we need to pass a few more arguments
83
+ parameters.push('--project', params['project'], '--scope', 'project') unless params['project'].nil?
84
+
85
+ # Fetch the Universal Package
86
+ az! parameters
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsAzureUniversalPackages
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,29 @@
1
+ module CocoapodsAzureUniversalPackages
2
+ class << self
3
+
4
+ Pod::HooksManager.register('cocoapods-azure-universal-packages', :pre_install) do |context, options|
5
+ CocoapodsAzureUniversalPackages.pre_install(options)
6
+ end
7
+
8
+ def pre_install(options)
9
+ # Check if the Azure CLI is installed
10
+ raise Pod::Informative, 'Unable to locate the Azure CLI. To learn more refer to https://aka.ms/azcli' unless Pod::Executable.which('az')
11
+
12
+ # Install the azure-devops extension if necessary
13
+ Pod::Executable.execute_command('az', ['extension', 'add', '--yes', '--name', 'azure-devops'], false)
14
+
15
+ # Optionally, update the azure-devops extension
16
+ if options.fetch(:update_cli_extension, false)
17
+ Pod::Executable.execute_command('az', ['extension', 'update', '--name', 'azure-devops'], false)
18
+ end
19
+
20
+ # Now we can configure the downloader to use the Azure CLI for downloading pods from the given hosts
21
+ azure_organizations = options[:organization] || options[:organizations]
22
+ raise Pod::Informative, 'You must configure at least one Azure organization' unless azure_organizations
23
+
24
+ Pod::Downloader.azure_organizations = ([] << azure_organizations).flatten.map { |url| url.delete_suffix('/') }
25
+ raise Pod::Informative, 'You must configure at least one Azure organization' if Pod::Downloader.azure_organizations.empty?
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ require 'cocoapods-azure-universal-packages/azure_universal_package_downloader'
2
+ require 'cocoapods-azure-universal-packages/gem_version'
3
+ require 'cocoapods-azure-universal-packages/pre_install'
@@ -0,0 +1 @@
1
+ require 'cocoapods-azure-universal-packages'
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-azure-universal-packages2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Microsoft Corporation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-03-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocoapods
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cocoapods-downloader
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: addressable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
97
+ description:
98
+ email:
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/cocoapods-azure-universal-packages.rb
106
+ - lib/cocoapods-azure-universal-packages/azure_universal_package_downloader.rb
107
+ - lib/cocoapods-azure-universal-packages/gem_version.rb
108
+ - lib/cocoapods-azure-universal-packages/pre_install.rb
109
+ - lib/cocoapods_plugin.rb
110
+ homepage: https://github.com/microsoft/cocoapods-azure-universal-packages
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.3.26
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: A CocoaPods plugin for downloading Universal Packages from Azure Artifacts
133
+ feeds.
134
+ test_files: []