-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from maxim-lobanov/support-preview-versions
Add support for prerelease versions
- Loading branch information
Showing
11 changed files
with
177 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
PODS: | ||
- Bond (6.2.10): | ||
- Diff (~> 0.4) | ||
- ReactiveKit (~> 3.6.0) | ||
- Diff (0.5.3) | ||
- ReactiveKit (3.6.0) | ||
- Alamofire (4.8.2) | ||
|
||
DEPENDENCIES: | ||
- Bond | ||
- Alamofire | ||
|
||
SPEC REPOS: | ||
https://github.com/cocoapods/specs.git: | ||
- Alamofire | ||
|
||
SPEC CHECKSUMS: | ||
Bond: 8bafdefda68c4f525c9a751b60ef827b0548ef3c | ||
Diff: befa1d19c32726b2b36ce915d98793e2fbde8dcc | ||
ReactiveKit: b3037cb797aa79b58964d309cd724611bea033e6 | ||
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3 | ||
|
||
PODFILE CHECKSUM: f0549efd571fb0d6e3b9828ef306c31ce0bfa0d0 | ||
PODFILE CHECKSUM: 6e25dc1d1d6302e538a09a3e0120a572a5fbd5d1 | ||
|
||
COCOAPODS: 1.3.1 | ||
COCOAPODS: 1.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PODS: | ||
- Alamofire (4.8.2) | ||
|
||
DEPENDENCIES: | ||
- Alamofire | ||
|
||
SPEC REPOS: | ||
https://github.com/cocoapods/specs.git: | ||
- Alamofire | ||
|
||
SPEC CHECKSUMS: | ||
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3 | ||
|
||
PODFILE CHECKSUM: 6e25dc1d1d6302e538a09a3e0120a572a5fbd5d1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as path from "path"; | ||
import { getVersionFromPodfile, getVersionFromPodfileLine } from "../src/podfile-parser"; | ||
|
||
describe("getVersionFromPodfile", () => { | ||
it.each([ | ||
["Podfile.lock", "1.5.3"], | ||
["Podfile2.lock", "1.9.3"], | ||
["Podfile3.lock", "1.10.0.rc.1"], | ||
["Podfile4.lock", "1.9.0.beta.2"], | ||
["Podfile5.lock", null] | ||
])("test case %#", (input: string, expected: string | null) => { | ||
const testCasePath = path.resolve(path.join(__dirname, "podfile-example", input)); | ||
if (expected) { | ||
expect(getVersionFromPodfile(testCasePath)).toBe(expected); | ||
} else { | ||
expect(() => getVersionFromPodfile(testCasePath)).toThrow(); | ||
} | ||
}); | ||
}); | ||
|
||
describe("getVersionFromPodfileLine", () => { | ||
it.each([ | ||
["COCOAPODS: 1.5.3", "1.5.3"], | ||
["COCOAPODS: 1.9.1", "1.9.1"], | ||
["COCOAPODS: 1.10.0.rc.1", "1.10.0.rc.1"], | ||
["COCOAPODS: 1.8.0.beta.2", "1.8.0.beta.2"], | ||
["COCOAPODS: 1.7.0.beta.1", "1.7.0.beta.1"], | ||
])("%s -> %s", (input: string, expected: string) => { | ||
const matchedVersion = getVersionFromPodfileLine(input); | ||
expect(matchedVersion).toBe(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { EOL } from "os"; | ||
|
||
const podVersionRegex = /^COCOAPODS: ([\d.]+(beta|rc)?\.?\d*)$/i; | ||
|
||
export const getVersionFromPodfileLine = (line: string): string | null => { | ||
const match = line.match(podVersionRegex); | ||
if (match && match.length >= 2) { | ||
return match[1].trim(); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const getVersionFromPodfile = (podfilePath: string): string => { | ||
const absolutePath = path.resolve(podfilePath); | ||
|
||
if (!fs.existsSync(absolutePath)) { | ||
throw new Error(`Podfile is not found on path '${absolutePath}'`); | ||
} | ||
|
||
const fileContent = fs.readFileSync(absolutePath); | ||
const podLines = fileContent.toString().split(EOL); | ||
|
||
for (const podLine of podLines) { | ||
const matchedVersion = getVersionFromPodfileLine(podLine); | ||
if (matchedVersion) { | ||
return matchedVersion; | ||
} | ||
} | ||
|
||
throw new Error(`Podfile '${absolutePath}' doesn't contain COCOAPODS version.`); | ||
}; | ||
|
Oops, something went wrong.