Skip to content

Commit

Permalink
v1.0.0-beta.2 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion authored Jan 27, 2024
1 parent 67b7415 commit 72e2805
Show file tree
Hide file tree
Showing 18 changed files with 529 additions and 53 deletions.
22 changes: 7 additions & 15 deletions .github/workflows/IPSWDownloads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
runs-on: [ubuntu-20.04, ubuntu-22.04]
swift-version: [5.9]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache swift package modules
id: cache-spm-linux
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: SPM
with:
Expand All @@ -37,7 +37,7 @@ jobs:
run: echo "RELEASE_NAME=$(lsb_release -sc)" >> $GITHUB_ENV
- name: Cache swift
id: cache-swift-linux
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: swift
with:
Expand Down Expand Up @@ -83,17 +83,17 @@ jobs:
watchOSVersion: "10.2"
watchName: "Apple Watch Series 9 (45mm)"
iPhoneName: "iPhone 15 Pro"
- runs-on: macos-13-xlarge
- runs-on: macos-13
xcode: "/Applications/Xcode_15.2.app"
iOSVersion: "17.2"
watchOSVersion: "10.2"
watchName: "Apple Watch Ultra 2 (49mm)"
iPhoneName: "iPhone 15 Pro Max"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache swift package modules
id: cache-spm-macos
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-spm
with:
Expand All @@ -106,7 +106,7 @@ jobs:
- name: Cache mint
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.2.app' }}
id: cache-mint
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-mint
with:
Expand All @@ -125,16 +125,8 @@ jobs:
run: |
brew update
brew install mint
# - name: Initialize CodeQL
# if: startsWith(matrix.xcode,'/Applications/Xcode_15.1')
# uses: github/codeql-action/init@v3
# with:
# languages: ${{ matrix.language }}
- name: Build
run: swift build
# - name: Perform CodeQL Analysis
# if: startsWith(matrix.xcode,'/Applications/Xcode_15.1')
# uses: github/codeql-action/analyze@v3
- name: Run Swift Package tests
run: swift test -v --enable-code-coverage
- uses: sersoft-gmbh/swift-coverage-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--indent 2
--header strip
--header "\n .*?\.swift\n IPSWDownloads\n\n Created by {file}\n Copyright © {year} BrightDigit.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the “Software”), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or\n sell copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n \n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n"
--commas inline
--disable wrapMultilineStatementBraces, redundantInternal
--extensionacl on-declarations
Expand Down
1 change: 0 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ opt_in_rules:
- explicit_top_level_acl
- fallthrough
- fatal_error_message
- file_header
- file_name
- file_name_no_space
- file_types_order
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-openapi-runtime",
"state" : {
"revision" : "fd101c320185313bbf9c5a45b827b17eda9ff18a",
"version" : "1.1.0"
"revision" : "76951d77a0609599d2dc233e7e40808a74767c6a",
"version" : "1.3.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Provides a Swift-friendly API into the API for [IPSW Downloads](http://ipsw.me).

[![Codecov](https://img.shields.io/codecov/c/github/brightdigit/IPSWDownloads)](https://codecov.io/gh/brightdigit/IPSWDownloads)
[![CodeFactor](https://www.codefactor.io/repository/github/brightdigit/IPSWDownloads/badge)](https://www.codefactor.io/repository/github/brightdigit/IPSWDownloads)
[![codebeat badge](https://codebeat.co/badges/a891b07c-4cdb-42cf-a97c-bfae45b378d6)](https://codebeat.co/projects/github-com-brightdigit-IPSWDownloads-main)
[![codebeat badge](https://codebeat.co/badges/a891b07c-4cdb-42cf-a97c-bfae45b378d6)](https://codebeat.co/projects/github-com-brightdigit-ipswdownloads-main)
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/brightdigit/IPSWDownloads)](https://codeclimate.com/github/brightdigit/IPSWDownloads)
[![Code Climate technical debt](https://img.shields.io/codeclimate/tech-debt/brightdigit/IPSWDownloads?label=debt)](https://codeclimate.com/github/brightdigit/IPSWDownloads)
[![Code Climate issues](https://img.shields.io/codeclimate/issues/brightdigit/IPSWDownloads)](https://codeclimate.com/github/brightdigit/IPSWDownloads)
Expand Down
60 changes: 48 additions & 12 deletions Sources/IPSWDownloads/Board.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,62 @@
//
// File.swift
// Board.swift
// IPSWDownloads
//
// Created by Board.swift
// Copyright © 2024 BrightDigit.
//
// Created by Leo Dion on 1/11/24.
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// A struct representing a board with configuration details.
public struct Board {
/// The configuration of the board.
public let boardconfig: String

/// The platform information of the board.
public let platform: String

/// The CHIP tag is a 16-bit unsigned integer
/// that denotes the type of chip the firmware is to be installed to.
/// It is one of the few tags that is not read from the fuses,
/// but is instead hardcoded in the bootchain.
/// It is used to prevent incompatible firmwares from being installed;
/// different processors may have their MMIO registers in different locations.
/// The CHIP tag is a 16-bit unsigned integer that denotes the type of chip
/// the firmware is to be installed to. It is one of the few tags that is not
/// read from the fuses but is instead hardcoded in the bootchain. It is used
/// to prevent incompatible firmwares from being installed; different processors
/// may have their MMIO registers in different locations.
public let cpid: Int

/// The Board ID of a device
/// (also known as BORD, BDID, or ApBoardId) is a value
/// (usually represented as `uint8\_t`)
/// hat represents multiple characteristics of the logic board
/// The Board ID of a device (also known as BORD, BDID, or ApBoardId) is a value
/// (usually represented as `uint8_t`) that represents multiple characteristics
/// of the logic board.
public let bdid: Int

/// Initializes a new Board instance with the provided parameters.
///
/// - Parameters:
/// - boardconfig: The configuration of the board.
/// - platform: The platform information of the board.
/// - cpid: The CHIP tag representing the type of chip for firmware installation.
/// - bdid: The Board ID of the device
/// representing characteristics of the logic board.
public init(boardconfig: String, platform: String, cpid: Int, bdid: Int) {
self.boardconfig = boardconfig
self.platform = platform
Expand All @@ -33,6 +66,9 @@ public struct Board {
}

extension Board {
/// Initializes a new Board instance from a given `Components.Schemas.Board` component.
///
/// - Parameter component: The component containing board details.
internal init(component: Components.Schemas.Board) {
self.init(
boardconfig: component.boardconfig,
Expand Down
56 changes: 56 additions & 0 deletions Sources/IPSWDownloads/Data.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// Data.swift
// IPSWDownloads
//
// Created by Data.swift
// Copyright © 2024 BrightDigit.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
extension Data {
internal init(hexString: String) throws {
var data = Data(capacity: hexString.count / 2)

var index = hexString.startIndex
while index < hexString.endIndex {
let byteString = hexString[index ..< hexString.index(index, offsetBy: 2)]
if let byte = UInt8(byteString, radix: 16) {
data.append(byte)
} else {
throw RuntimeError.invalidDataHexString(hexString)
}
index = hexString.index(index, offsetBy: 2)
}

self = data
}

internal init?(hexString: String, emptyIsNil: Bool) throws {
if emptyIsNil, hexString.isEmpty {
return nil
}

try self.init(hexString: hexString)
}
}
47 changes: 45 additions & 2 deletions Sources/IPSWDownloads/Device.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,55 @@
//
// File.swift
// Device.swift
// IPSWDownloads
//
// Created by Device.swift
// Copyright © 2024 BrightDigit.
//
// Created by Leo Dion on 1/11/24.
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation

/// A struct representing an Apple device along with its firmware and supported boards.
public struct Device {
/// The name of the Apple device.
public let name: String

/// The unique identifier of the Apple device.
public let identifier: String

/// The list of firmware versions supported by the device.
public let firmwares: [Firmware]

/// The list of boards supported by the device.
public let boards: [Board]

/// Initializes a new Device instance with the provided parameters.
///
/// - Parameters:
/// - name: The name of the Apple device.
/// - identifier: The unique identifier of the Apple device.
/// - firmwares: The list of firmware versions supported by the device.
/// - boards: The list of boards supported by the device.
public init(name: String, identifier: String, firmwares: [Firmware], boards: [Board]) {
self.name = name
self.identifier = identifier
Expand All @@ -21,6 +59,11 @@ public struct Device {
}

extension Device {
/// Initializes a new Device instance
/// from a given `Components.Schemas.Device` component.
///
/// - Parameter component: The component containing device details.
/// - Throws: An error if there is an issue initializing the device.
internal init(component: Components.Schemas.Device) throws {
try self.init(
name: component.name,
Expand Down
Loading

0 comments on commit 72e2805

Please sign in to comment.