diff --git a/lib/manager/cocoapods/__fixtures__/Podfile.simple b/lib/manager/cocoapods/__fixtures__/Podfile.simple index 1c8ffcff3fc15f1d61eea569a4c6a27b8070acda..b1b385c8f41343d56ac62469e193e1ab2303b671 100644 --- a/lib/manager/cocoapods/__fixtures__/Podfile.simple +++ b/lib/manager/cocoapods/__fixtures__/Podfile.simple @@ -8,4 +8,9 @@ pod 'd', :path => '~/Documents/Alamofire' pod 'e', :git => 'e.git' pod 'f', :git => 'f.git', :branch => 'dev' pod 'g', :git => 'g.git', :tag => '3.2.1' -pod 'h', :git => 'https://github.com/foo/bar.git', :tag => '0.0.1' +pod 'h', :git => 'https://github.com/foo/foo.git', :tag => '0.0.1' +pod 'i', :git => 'git@github.com:foo/foo.git', :tag => '0.0.1' +pod 'j', :git => 'https://gitlab.com/bar/bar.git', :tag => '0.1.0' +pod 'k', :git => 'https://gitlab.com/bar/bar.git', :tag => '0.1.0' +pod 'l', :git => 'https://example.com/baz/baz.git', :tag => '1.0.0' +pod 'm', :git => 'git@example.com:baz/baz.git', :tag => '1.0.0' diff --git a/lib/manager/cocoapods/__snapshots__/extract.spec.ts.snap b/lib/manager/cocoapods/__snapshots__/extract.spec.ts.snap index 34de373e898a68e3693134133f48fc990825bd6e..2eb3e63cac356d9dfdbd24c4bcdfb27acf011071 100644 --- a/lib/manager/cocoapods/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/cocoapods/__snapshots__/extract.spec.ts.snap @@ -1,74 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`manager/cocoapods/extract extractPackageFile() extracts all dependencies 1`] = ` -Array [ - Object { - "depName": "a", - "groupName": "a", - "skipReason": "unknown-version", - }, - Object { - "depName": "a/sub", - "groupName": "a", - "skipReason": "unknown-version", - }, - Object { - "currentValue": "1.2.3", - "datasource": "pod", - "depName": "b", - "groupName": "b", - "managerData": Object { - "lineNumber": 4, - }, - "registryUrls": Array [ - "https://github.com/Artsy/Specs.git", - ], - }, - Object { - "currentValue": "1.2.3", - "datasource": "pod", - "depName": "c", - "groupName": "c", - "managerData": Object { - "lineNumber": 5, - }, - "registryUrls": Array [ - "https://github.com/Artsy/Specs.git", - ], - }, - Object { - "depName": "d", - "groupName": "d", - "skipReason": "path-dependency", - }, - Object { - "depName": "e", - "groupName": "e", - "skipReason": "git-dependency", - }, - Object { - "depName": "f", - "groupName": "f", - "skipReason": "git-dependency", - }, - Object { - "managerData": Object { - "lineNumber": 9, - }, - }, - Object { - "currentValue": "0.0.1", - "datasource": "github-tags", - "depName": "h", - "lookupName": "foo/bar", - "managerData": Object { - "lineNumber": 10, - }, - }, -] -`; - -exports[`manager/cocoapods/extract extractPackageFile() extracts all dependencies 2`] = ` +exports[`manager/cocoapods/extract extractPackageFile() extracts from complex file 1`] = ` Array [ Object { "currentValue": "~> 6.5.0", @@ -392,3 +324,120 @@ Array [ }, ] `; + +exports[`manager/cocoapods/extract extractPackageFile() extracts from simple file 1`] = ` +Array [ + Object { + "depName": "a", + "groupName": "a", + "skipReason": "unknown-version", + }, + Object { + "depName": "a/sub", + "groupName": "a", + "skipReason": "unknown-version", + }, + Object { + "currentValue": "1.2.3", + "datasource": "pod", + "depName": "b", + "groupName": "b", + "managerData": Object { + "lineNumber": 4, + }, + "registryUrls": Array [ + "https://github.com/Artsy/Specs.git", + ], + }, + Object { + "currentValue": "1.2.3", + "datasource": "pod", + "depName": "c", + "groupName": "c", + "managerData": Object { + "lineNumber": 5, + }, + "registryUrls": Array [ + "https://github.com/Artsy/Specs.git", + ], + }, + Object { + "depName": "d", + "groupName": "d", + "skipReason": "path-dependency", + }, + Object { + "depName": "e", + "groupName": "e", + "skipReason": "git-dependency", + }, + Object { + "depName": "f", + "groupName": "f", + "skipReason": "git-dependency", + }, + Object { + "currentValue": "3.2.1", + "datasource": "git-tags", + "depName": "g", + "lookupName": "g.git", + "managerData": Object { + "lineNumber": 9, + }, + }, + Object { + "currentValue": "0.0.1", + "datasource": "github-tags", + "depName": "h", + "lookupName": "foo/foo", + "managerData": Object { + "lineNumber": 10, + }, + }, + Object { + "currentValue": "0.0.1", + "datasource": "github-tags", + "depName": "i", + "lookupName": "foo/foo", + "managerData": Object { + "lineNumber": 11, + }, + }, + Object { + "currentValue": "0.1.0", + "datasource": "gitlab-tags", + "depName": "j", + "lookupName": "bar/bar", + "managerData": Object { + "lineNumber": 12, + }, + }, + Object { + "currentValue": "0.1.0", + "datasource": "gitlab-tags", + "depName": "k", + "lookupName": "bar/bar", + "managerData": Object { + "lineNumber": 13, + }, + }, + Object { + "currentValue": "1.0.0", + "datasource": "git-tags", + "depName": "l", + "lookupName": "https://example.com/baz/baz.git", + "managerData": Object { + "lineNumber": 14, + }, + }, + Object { + "currentValue": "1.0.0", + "datasource": "git-tags", + "depName": "m", + "lookupName": "git@example.com:baz/baz.git", + "managerData": Object { + "lineNumber": 15, + }, + }, +] +`; diff --git a/lib/manager/cocoapods/extract.spec.ts b/lib/manager/cocoapods/extract.spec.ts index aaac0157a5cee6261b21fc5086e709b7621fb256..f4c70a6792388809ecdaefac749fdc6f6ec584f0 100644 --- a/lib/manager/cocoapods/extract.spec.ts +++ b/lib/manager/cocoapods/extract.spec.ts @@ -6,25 +6,73 @@ import { extractPackageFile } from '.'; const simplePodfile = loadFixture('Podfile.simple'); const complexPodfile = loadFixture('Podfile.complex'); -const adminConfig: RepoAdminConfig = { - localDir: '', -}; +const adminConfig: RepoAdminConfig = { localDir: '' }; describe(getName(), () => { describe('extractPackageFile()', () => { - it('extracts all dependencies', async () => { + it('extracts from simple file', async () => { setAdminConfig(adminConfig); - const simpleResult = (await extractPackageFile(simplePodfile, 'Podfile')) - .deps; - // FIXME: explicit assert condition - expect(simpleResult).toMatchSnapshot(); + const { deps } = await extractPackageFile(simplePodfile, 'Podfile'); + expect(deps).toMatchSnapshot([ + { depName: 'a' }, + { depName: 'a/sub' }, + { depName: 'b', currentValue: '1.2.3' }, + { depName: 'c', currentValue: '1.2.3' }, + { depName: 'd', skipReason: 'path-dependency' }, + { depName: 'e', skipReason: 'git-dependency' }, + { depName: 'f', skipReason: 'git-dependency' }, + { depName: 'g', datasource: 'git-tags', currentValue: '3.2.1' }, + { depName: 'h', currentValue: '0.0.1', datasource: 'github-tags' }, + { depName: 'i', lookupName: 'foo/foo', datasource: 'github-tags' }, + { depName: 'j', lookupName: 'bar/bar', datasource: 'gitlab-tags' }, + { depName: 'k', lookupName: 'bar/bar', datasource: 'gitlab-tags' }, + { + depName: 'l', + lookupName: 'https://example.com/baz/baz.git', + datasource: 'git-tags', + }, + { + depName: 'm', + lookupName: 'git@example.com:baz/baz.git', + datasource: 'git-tags', + }, + ]); + }); - // TODO: split test - const complexResult = ( - await extractPackageFile(complexPodfile, 'Podfile') - ).deps; - // FIXME: explicit assert condition - expect(complexResult).toMatchSnapshot(); + it('extracts from complex file', async () => { + setAdminConfig(adminConfig); + const { deps } = await extractPackageFile(complexPodfile, 'Podfile'); + expect(deps).toMatchSnapshot([ + { depName: 'IQKeyboardManager', currentValue: '~> 6.5.0' }, + { depName: 'CYLTabBarController', currentValue: '~> 1.28.3' }, + { depName: 'PureLayout', currentValue: '~> 3.1.4' }, + { depName: 'AFNetworking/Serialization', currentValue: '~> 3.2.1' }, + { depName: 'AFNetworking/Security', currentValue: '~> 3.2.1' }, + { depName: 'AFNetworking/Reachability', currentValue: '~> 3.2.1' }, + { depName: 'AFNetworking/NSURLSession', currentValue: '~> 3.2.1' }, + { depName: 'MBProgressHUD', currentValue: '~> 1.1.0' }, + { depName: 'MJRefresh', currentValue: '~> 3.1.16' }, + { depName: 'MJExtension', currentValue: '~> 3.1.0' }, + { depName: 'TYPagerController', currentValue: '~> 2.1.2' }, + { depName: 'YYImage', currentValue: '~> 1.0.4' }, + { depName: 'SDWebImage', currentValue: '~> 5.0' }, + { depName: 'SDCycleScrollView', currentValue: '~> 1.80' }, + { depName: 'NullSafe', currentValue: '~> 2.0' }, + { depName: 'TZImagePickerController', currentValue: '~> 3.2.1' }, + { depName: 'TOCropViewController', currentValue: '~> 2.5.1' }, + { depName: 'FMDB', currentValue: '~> 2.7.5' }, + { depName: 'FDStackView', currentValue: '~> 1.0.1' }, + { depName: 'LYEmptyView', skipReason: 'unknown-version' }, + { depName: 'MMKV', currentValue: '~> 1.0.22' }, + { depName: 'fishhook', skipReason: 'unknown-version' }, + { depName: 'CocoaLumberjack', currentValue: '~> 3.5.3' }, + { depName: 'GZIP', currentValue: '~> 1.2' }, + { depName: 'LBXScan/LBXNative', currentValue: '~> 2.3' }, + { depName: 'LBXScan/LBXZXing', currentValue: '~> 2.3' }, + { depName: 'LBXScan/UI', currentValue: '~> 2.3' }, + { depName: 'MLeaksFinder', skipReason: 'unknown-version' }, + { depName: 'FBMemoryProfiler', skipReason: 'unknown-version' }, + ]); }); }); }); diff --git a/lib/manager/cocoapods/extract.ts b/lib/manager/cocoapods/extract.ts index 59bb5f7ea8634edfbc2b74e4f51b33848b9f41f2..9535e783fc4cf680aa82653d6479cd37712ebd33 100644 --- a/lib/manager/cocoapods/extract.ts +++ b/lib/manager/cocoapods/extract.ts @@ -1,4 +1,6 @@ +import * as datasourceGitTags from '../../datasource/git-tags'; import * as datasourceGithubTags from '../../datasource/github-tags'; +import * as datasourceGitlabTags from '../../datasource/gitlab-tags'; import * as datasourcePod from '../../datasource/pod'; import { logger } from '../../logger'; import { SkipReason } from '../../types'; @@ -47,13 +49,21 @@ export function parseLine(line: string): ParsedLine { export function gitDep(parsedLine: ParsedLine): PackageDependency | null { const { depName, git, tag } = parsedLine; - if (git?.startsWith('https://github.com/')) { - const githubMatch = - /https:\/\/github\.com\/(?<account>[^/]+)\/(?<repo>[^/]+)/.exec(git); - const { account, repo } = githubMatch?.groups || {}; + + const platformMatch = + /[@/](?<platform>github|gitlab)\.com[:/](?<account>[^/]+)\/(?<repo>[^/]+)/.exec( + git + ); + + if (platformMatch) { + const { account, repo, platform } = platformMatch?.groups || {}; if (account && repo) { + const datasource = + platform === 'github' + ? datasourceGithubTags.id + : datasourceGitlabTags.id; return { - datasource: datasourceGithubTags.id, + datasource, depName, lookupName: `${account}/${repo.replace(/\.git$/, '')}`, currentValue: tag, @@ -61,7 +71,12 @@ export function gitDep(parsedLine: ParsedLine): PackageDependency | null { } } - return null; + return { + datasource: datasourceGitTags.id, + depName, + lookupName: git, + currentValue: tag, + }; } export async function extractPackageFile(