Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating subtree to apollo-ios main #60

Merged
merged 72 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
d757f12
ci: Update tooling versions (#3052)
calvincestari May 30, 2023
4771541
Fix RootEntityType and FulfilledFragment name generation (#3045)
AnthonyMDev May 31, 2023
c5195d6
2023-06-01 Roadmap Update (#3055)
bignimbus Jun 1, 2023
759a665
Release: 1.2.1 (#3059)
AnthonyMDev Jun 2, 2023
6510505
docs: Updates cache policy documentation (#3062)
calvincestari Jun 5, 2023
e31ee4a
fix: Adding type name suffixing for reserved keywords (#3058)
BobaFetters Jun 7, 2023
de57ae4
docs: Updates `1.2.0` migration guide for access modifiers default (#…
calvincestari Jun 9, 2023
f64927c
Fix: Added missing fulfilledFragments to generated initializers (#3067)
AnthonyMDev Jun 12, 2023
1ec00c8
fix: Remove `managedSelf` from `InterceptorRequestChain` (#3070)
calvincestari Jun 14, 2023
9f48589
Merge branch 'main' into release/1.3
calvincestari Jun 14, 2023
2ba71de
Updated 1.3 migration guide to include Reserved Keyword change (#3072)
BobaFetters Jun 14, 2023
ff49bec
Fix merged source name generation when shared root is operation root …
AnthonyMDev Jun 14, 2023
077430a
Fix parsing of input objects as default values for input params (#3074)
AnthonyMDev Jun 15, 2023
f80aadb
feat: Enable SOCKS proxy support (#3076)
tahirmt Jun 15, 2023
a3a1eae
Release 1.2.2 (#3077)
AnthonyMDev Jun 15, 2023
2c2daab
fix: Exclude script from target source (#3083)
calvincestari Jun 16, 2023
79fec42
ci: Enable manual clone from forked PRs (#3080)
calvincestari Jun 16, 2023
917a48d
Merge branch 'release/1.3'
calvincestari Jun 20, 2023
84d797e
release: `1.3.0` (#3085)
calvincestari Jun 20, 2023
d2bbeb0
Update CHANGELOG.md
calvincestari Jun 20, 2023
3111cb8
Adds documentation to ApolloInterceptor
calvincestari Jun 21, 2023
4cc0751
Fixes ApolloInterceptor API documentation
calvincestari Jun 21, 2023
0531744
docs: Update subscriptions for multipart over HTTP (#2926)
calvincestari Jun 21, 2023
03baa31
fix: Updating test mock set method definitions (#3089)
BobaFetters Jun 23, 2023
ec05b00
Persisted Queries [1/x] Define new persisted queries config (#3095)
AnthonyMDev Jun 30, 2023
93b6578
release: 1.3.1 (#3117)
AnthonyMDev Jul 12, 2023
df4648b
Fix documentation bug
AnthonyMDev Jul 12, 2023
efdae87
Update CODEOWNERS.md (#3127)
Meschreiber Jul 18, 2023
9961d2b
fix: fixes two issues in the generation of mocks. (#3120)
TizianoCoroneo Jul 19, 2023
c338ee9
Throw error when an invalid key is present in a `JSON` Apollo configu…
Iron-Ham Jul 19, 2023
7515d46
Operation Manifest Generation Updates (#3128)
BobaFetters Jul 19, 2023
b2a3054
chore: Delete unused imports and declarations (#3100)
Iron-Ham Jul 20, 2023
5ddf770
Issue 2426 improve response code error api (#3123)
dfperry5 Jul 20, 2023
874c7ff
Deprecating queryStringLiteralFormat (#3129)
BobaFetters Jul 20, 2023
d840428
fix: Update graphql-js error handling (#3132)
BobaFetters Jul 20, 2023
97ad4f5
Release: 1.3.2 (#3133)
BobaFetters Jul 20, 2023
c1d9a22
Update pull-request-template-release.md
calvincestari Jul 20, 2023
1d0badc
fix: Fragment definitions support escaped characters (#3135)
BobaFetters Jul 25, 2023
e95cec8
fix: Updated mock function descriptor handling (#3150)
BobaFetters Jul 25, 2023
a47a8af
feature: Adding CLI command for Operation Manifest (#3152)
BobaFetters Jul 26, 2023
fa28628
Also look for Package.resolved in .xcworkspace when performing versio…
alexdeem Jul 26, 2023
aaeed59
Roadmap update 2023-07-27
bignimbus Jul 27, 2023
5065f51
Fix merged selection set name ambiguity at definition root (#3168)
AnthonyMDev Aug 1, 2023
2289679
fix: Removing newline characters from operation id hashes (#3163)
BobaFetters Aug 1, 2023
c3f6951
Release/1 3 3 (#3169)
AnthonyMDev Aug 1, 2023
1e0f8dd
docs: Clarify `other` schema module type (#3170)
calvincestari Aug 1, 2023
4147f78
refactor: Fragment types in IR (#3174)
calvincestari Aug 3, 2023
e21116a
Updating Persisted Query Configuration (#3175)
BobaFetters Aug 9, 2023
c608c5e
feature: Add support for field casing strategy to code gen (#3171)
BobaFetters Aug 10, 2023
f94d367
Release: 1.4.0 (#3184)
BobaFetters Aug 10, 2023
d9e83f2
Roadmap update 2023-08-10
bignimbus Aug 10, 2023
8c7f1cc
Update persisted queries docs (#3160)
Meschreiber Aug 10, 2023
7b02cb0
docs: Fix field conversion strategy docs (#3192)
BobaFetters Aug 15, 2023
6d253e2
docs: Adding full codegen config example (#3193)
BobaFetters Aug 18, 2023
e10dc84
Updating docs for `itemsToGenerate` (#3200)
BobaFetters Aug 21, 2023
888461d
Adds RequestContext to the RequestChain/Interceptor pipeline (#3198)
danieltiger Sep 5, 2023
18108c3
Remove stripping of null values from Selection Set models (apollograp…
AnthonyMDev Sep 5, 2023
0773964
Release/1.5 (#3211)
AnthonyMDev Sep 5, 2023
5f93599
feature: final class definitions for graphql codegen (#3189)
Mordil Sep 5, 2023
7607b8b
fix: Updated the target codegen configuration (#3212)
calvincestari Sep 5, 2023
76a7619
2023-09-07 Roadmap update (#3214)
bignimbus Sep 7, 2023
e76c9e7
fix: Fixed reading of the `itemsToGenerate` property for the operatio…
TizianoCoroneo Sep 8, 2023
6e3bc47
chore: Changed to use isEmpty instead of count == 0 (#3217)
tokizuoh Sep 12, 2023
f79e659
docs: Updates sample code for Advanced Network Configuration document…
calvincestari Sep 15, 2023
453738a
only output operation manifest once (#3225)
jimisaacs Sep 18, 2023
72dbf4c
Update ROADMAP.md
calvincestari Sep 21, 2023
d1b3da6
update false positive secret detection allowlist (#3239)
peakematt Sep 28, 2023
c1ff0fc
Release 1.5.1 (#3244)
BobaFetters Sep 29, 2023
56e94ba
Adding codegen deprecation message (#3243)
BobaFetters Sep 29, 2023
42802f5
Release 1.5.2 (#3245)
BobaFetters Sep 29, 2023
6dacd0b
docs: remove preview status from persisted queries (#3241)
Meschreiber Oct 4, 2023
0211771
Pulling in last updates from apollo-ios main
BobaFetters Oct 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Also look for Package.resolved in .xcworkspace when performing versio…
…n check (#3048)

Co-authored-by: Zach FettersMoore <4425109+BobaFetters@users.noreply.github.com>
  • Loading branch information
alexdeem and BobaFetters authored Jul 26, 2023
commit fa28628cb99993fc39794b05b7cab23ade1c4bf0
70 changes: 48 additions & 22 deletions Sources/CodegenCLI/Extensions/VersionChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,68 @@ enum VersionChecker {
return fileManager.base.contents(atPath: path)
}

// When using SPM via Xcode, the `Package.resolved` file is nested inside the `.xcproject`
// package. Since we don't know the name of your Xcode project, we just look for the first
// `.xcproject` file in project's root directory that depends on Apollo. This may not be
// 100% fool-proof, but it should be accurate in almost all cases.
func findInXcodeProject(named projectFileName: String) -> Data? {
let projectPackagePath =
"\(projectFileName)/project.xcworkspace/xcshareddata/swiftpm/\(Package_resolved)"

// When using SPM via Xcode, the `Package.resolved` file is nested inside either the
// `.xcworkspace` or the `.xcproject` package. Since we don't know the name of your project,
// we just look for the first workspace or project that depends on Apollo, prioritising
// workspaces. This may not be 100% fool-proof, but it should be accurate in almost all cases.
func findInXcode(
fileSuffix: String,
packagePath: String,
excludeFilePathComponents: [String] = []
) -> PackageResolvedModel? {
let projectEnumerator = fileManager.base.enumerator(atPath: projectRootURL?.path ?? ".")
enumeratorLoop: while let file = projectEnumerator?.nextObject() as? String {
if file.hasSuffix(fileSuffix) {
//check if this file should be ignored
for component in excludeFilePathComponents {
if file.contains(component) {
continue enumeratorLoop
}
}

let projectPackagePath = "\(file)\(packagePath)"
if let package = apolloDependantPackage(atPath: projectPackagePath) {
return package
}
}
}
return nil
}

func apolloDependantPackage(atPath projectPackagePath: String) -> PackageResolvedModel? {
let path: String
if let projectRootURL {
path = projectRootURL.appendingPathComponent(projectPackagePath, isDirectory: false).path
} else {
path = projectPackagePath
}

return fileManager.base.contents(atPath: path)
if let packageResolvedData = fileManager.base.contents(atPath: path),
var packageModel = try? PackageResolvedModel(data: packageResolvedData),
packageModel.apolloVersion != nil {
return packageModel
}
return nil
}


if let packageResolvedData = findInProjectRoot() {
return try PackageResolvedModel(data: packageResolvedData)
}

} else {
// Find in Xcode Projects
let projectEnumerator = fileManager.base.enumerator(atPath: projectRootURL?.path ?? ".")

while let file = projectEnumerator?.nextObject() as? String {
if file.hasSuffix(".xcodeproj") {
if let packageResolvedData = findInXcodeProject(named: file),
var packageModel = try PackageResolvedModel(data: packageResolvedData),
packageModel.apolloVersion != nil {
if let packageModel = findInXcode(
fileSuffix: ".xcworkspace",
packagePath: "/xcshareddata/swiftpm/\(Package_resolved)",
excludeFilePathComponents: [".xcodeproj/project.xcworkspace"]
) {
return packageModel
}

return packageModel
}
}
}
if let packageModel = findInXcode(
fileSuffix: ".xcodeproj",
packagePath: "/project.xcworkspace/xcshareddata/swiftpm/\(Package_resolved)"
) {
return packageModel
}

return nil
Expand Down
59 changes: 59 additions & 0 deletions Tests/CodegenCLITests/VersionCheckerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,41 @@ class VersionCheckerTests: XCTestCase {
expect(result).to(equal(.versionMismatch(cliVersion: Constants.CLIVersion, apolloVersion: apolloVersion)))
}

func test__matchCLIVersionToApolloVersion__givenPackageResolvedFileInXcodeWorkspace_withVersion2FileFormat_hasMatchingVersion_returns_versionMatch() throws {
// given
try fileManager.createFile(
body: version2PackageResolvedFileBody(apolloVersion: Constants.CLIVersion),
named: "Package.resolved",
inDirectory: "MyProject.xcworkspace/xcshareddata/swiftpm"
)

// when
let result = try VersionChecker.matchCLIVersionToApolloVersion(
projectRootURL: fileManager.directoryURL
)

// then
expect(result).to(equal(.versionMatch))
}

func test__matchCLIVersionToApolloVersion__givenPackageResolvedFileInXcodeWorkspace_withVersion2FileFormat_hasNonMatchingVersion_returns_versionMismatch() throws {
// given
let apolloVersion = "1.0.0.test-1"
try fileManager.createFile(
body: version2PackageResolvedFileBody(apolloVersion: apolloVersion),
named: "Package.resolved",
inDirectory: "MyProject.xcworkspace/xcshareddata/swiftpm"
)

// when
let result = try VersionChecker.matchCLIVersionToApolloVersion(
projectRootURL: fileManager.directoryURL
)

// then
expect(result).to(equal(.versionMismatch(cliVersion: Constants.CLIVersion, apolloVersion: apolloVersion)))
}

func test__matchCLIVersionToApolloVersion__givenPackageResolvedFileInXcodeProject_withVersion2FileFormat_hasMatchingVersion_returns_versionMatch() throws {
// given
try fileManager.createFile(
Expand Down Expand Up @@ -220,6 +255,30 @@ class VersionCheckerTests: XCTestCase {
// then
expect(result).to(equal(.versionMismatch(cliVersion: Constants.CLIVersion, apolloVersion: apolloVersion)))
}

func test__matchCLIVersionToApolloVersion__givenPackageResolvedFileInXcodeWorkspaceAndProject_withVersion2FileFormat_hasMatchingVersion_returns_versionMatch_fromWorkspace() throws {
// given
try fileManager.createFile(
body: version2PackageResolvedFileBody(apolloVersion: Constants.CLIVersion),
named: "Package.resolved",
inDirectory: "MyProject.xcworkspace/xcshareddata/swiftpm"
)

let apolloProjectVersion = "1.0.0.test-1"
try fileManager.createFile(
body: version2PackageResolvedFileBody(apolloVersion: apolloProjectVersion),
named: "Package.resolved",
inDirectory: "MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm"
)

// when
let result = try VersionChecker.matchCLIVersionToApolloVersion(
projectRootURL: fileManager.directoryURL
)

// then
expect(result).to(equal(.versionMatch))
}

}

Expand Down