-
-
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 740d10e
Showing
46 changed files
with
780 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
64 changes: 64 additions & 0 deletions
64
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,64 @@ | ||
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] { | ||
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] = [] | ||
let decoder = JSONDecoder() | ||
for target in project.targets { | ||
for resource in target.resources.resources { | ||
guard let children = try? resource.path.path.recursiveChildren() else { continue } | ||
for child in children { | ||
guard let pathExtension = child.extension, assetFormats.contains(pathExtension) else { continue } | ||
guard let contents = try? child.children().first(where: { | ||
$0.lastComponent == "Contents.json" | ||
}) else { | ||
continue | ||
} | ||
guard let data = try? Data(contentsOf: contents.url) else { continue } | ||
guard let attributes = try? decoder.decode(ContentJson.self, from: data) else { continue } | ||
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.