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
Adding support for project additional files #314
Merged
kwridan
merged 9 commits into
tuist:master
from
bloomberg:feature/202-1-project-additional-files
Apr 3, 2019
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
69a1717
Adding fixture
kwridan 7f683e5
Extract `Workspace.Element` > `WorkspaceElement` within ProjectDescriβ¦
kwridan b04dca3
Updating models to reflect manifest changes of `WorkspaceElement`
kwridan 2ddccc3
Additional files are now included in the generated projects
kwridan 9867a72
Updating fixture
kwridan dc3364e
Renaming `WorkspaceElement` to `FileElement`
kwridan f27422c
Updating fixture
kwridan c5ca621
Updating documentation
kwridan b640532
Updating changelog
kwridan File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Foundation | ||
|
||
/// Workspace element | ||
/// | ||
/// - glob: a glob pattern for files to include | ||
/// - folderReference: a single path to a directory | ||
/// | ||
/// Note: For convenience, an element can be represented as a string literal | ||
/// `"some/pattern/**"` is the equivalent of `WorkspaceElement.glob(pattern: "some/pattern/**")` | ||
public enum WorkspaceElement: Codable { | ||
/// A glob pattern of files to include | ||
case glob(pattern: String) | ||
|
||
/// Relative path to a directory to include | ||
/// as a folder reference | ||
case folderReference(path: String) | ||
|
||
private enum TypeName: String, Codable { | ||
case glob | ||
case folderReference | ||
} | ||
|
||
private var typeName: TypeName { | ||
switch self { | ||
case .glob: | ||
return .glob | ||
case .folderReference: | ||
return .folderReference | ||
} | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey { | ||
case type | ||
case pattern | ||
case path | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let type = try container.decode(TypeName.self, forKey: .type) | ||
switch type { | ||
case .glob: | ||
let pattern = try container.decode(String.self, forKey: .pattern) | ||
self = .glob(pattern: pattern) | ||
case .folderReference: | ||
let path = try container.decode(String.self, forKey: .path) | ||
self = .folderReference(path: path) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(typeName, forKey: .type) | ||
switch self { | ||
case let .glob(pattern: pattern): | ||
try container.encode(pattern, forKey: .pattern) | ||
case let .folderReference(path: path): | ||
try container.encode(path, forKey: .path) | ||
} | ||
} | ||
} | ||
|
||
extension WorkspaceElement: ExpressibleByStringLiteral { | ||
public init(stringLiteral value: String) { | ||
self = .glob(pattern: value) | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still a workspace element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we'd like to reuse the same type I'd change the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed - was looking for better names:
Reference
,Element
: too broad?FileReference
,FileElement
: Folder references aren't files :/Will think some more on suitable alternatives, if you had any please do share :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd stick to the Xcode project's convention, FileElement