-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5271cb3
commit e284daa
Showing
46 changed files
with
781 additions
and
12 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
65 changes: 65 additions & 0 deletions
65
Sources/TuistGenerator/Generator/KnownAssetTagsGenerator.swift
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,65 @@ | ||
import Foundation | ||
import TuistGraph | ||
|
||
private let assetFormats: Set = [ | ||
"arresourcegroup", | ||
"cubetextureset", | ||
"dataset", | ||
"imageset", | ||
"imagestack", | ||
"spriteatlas", | ||
"textureset", | ||
] | ||
|
||
private struct ContentJson: Decodable { | ||
struct ContentProperties: Decodable { | ||
enum CodingKeys: String, CodingKey { | ||
case onDemandResourceTags = "on-demand-resource-tags" | ||
} | ||
|
||
let onDemandResourceTags: [String] | ||
} | ||
|
||
let properties: ContentProperties | ||
} | ||
|
||
protocol KnownAssetTagsGenerating: AnyObject { | ||
func generate(project: Project) throws -> [String] | ||
} | ||
|
||
final class KnownAssetTagsGenerator: KnownAssetTagsGenerating { | ||
func generate(project: Project) throws -> [String] { | ||
// On Demand Resources tags | ||
var tags = project.targets.map { $0.resources.resources.map(\.tags).flatMap { $0 } }.flatMap { $0 } | ||
|
||
let initialInstallTags = project.targets.map { $0.odrInitialInstallTags.map { $0 } }.flatMap { $0 } | ||
let prefetchOrderTags = project.targets.map { $0.odrPrefetchOrder.map { $0 } }.flatMap { $0 } | ||
tags.append(contentsOf: initialInstallTags) | ||
tags.append(contentsOf: prefetchOrderTags) | ||
|
||
var assetsTags: [String] = [] | ||
for target in project.targets { | ||
target.resources.resources.forEach { | ||
guard let children = try? $0.path.path.recursiveChildren() else { return } | ||
children.forEach { | ||
guard let pathExtension = $0.extension, assetFormats.contains(pathExtension) else { return } | ||
guard let contents = try? $0.children() else { return } | ||
contents.forEach { | ||
guard $0.lastComponent == "Contents.json" else { return } | ||
if let data = try? Data(contentsOf: $0.url), | ||
let attributes = try? JSONDecoder().decode(ContentJson.self, from: data) | ||
{ | ||
assetsTags.append(contentsOf: attributes.properties.onDemandResourceTags) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
tags.append(contentsOf: assetsTags) | ||
|
||
let uniqueTags = Set(tags).sorted() | ||
|
||
return uniqueTags | ||
} | ||
} |
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
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
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,70 @@ | ||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two | ||
Icon | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### Xcode ### | ||
# Xcode | ||
# | ||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore | ||
|
||
## User settings | ||
xcuserdata/ | ||
|
||
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) | ||
*.xcscmblueprint | ||
*.xccheckout | ||
|
||
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) | ||
build/ | ||
DerivedData/ | ||
*.moved-aside | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
|
||
### Xcode Patch ### | ||
*.xcodeproj/* | ||
!*.xcodeproj/project.pbxproj | ||
!*.xcodeproj/xcshareddata/ | ||
!*.xcworkspace/contents.xcworkspacedata | ||
/*.gcno | ||
|
||
### Projects ### | ||
*.xcodeproj | ||
*.xcworkspace | ||
|
||
### Tuist derived files ### | ||
graph.dot | ||
Derived/ | ||
|
||
### Tuist managed dependencies ### | ||
Tuist/.build |
Empty file.
Oops, something went wrong.