-
Notifications
You must be signed in to change notification settings - Fork 823
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
Spec file relative directory expansion #489
Spec file relative directory expansion #489
Conversation
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.
Great work @ellneal! Sorry for the delay in getting to this. I've left some initial comments above.
Technically this would be a breaking change. I wonder if the default should be to keep the old paths, and opt in via an option
or property on the include
Thanks @yonaskolb. I would hazard a guess that this behaviour is what most people would expect, so I do think that any |
@yonaskolb I've added a new option when including files to provide the legacy behaviour of not expanding paths. |
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.
Could you also add a changelog entry saying:
Changed
- BREAKING All the paths within
included
files are now relative to that file and not the root spec. This can be disabled with arelativePaths: false
on the include. See docs for more details
static var pathProperties: [PathProperty] { | ||
return [ | ||
.string("carthageBuildPath"), | ||
.string("carthageExecutablePath"), |
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.
Note to self that if these classes were Codable
we could use a CodingKey
for this
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 had the same thought, but not the motivation to do it. 👍
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.
Fantastic work @ellneal! I think this will make a lot of people happy
My pleasure 😄 |
FWIW I just updated to Our project configuration structure has a
When running
It is obviously expecting the source directories to be relative to where the |
Yeah it was a decision to make relative paths the default, as per the change log. Unfortunately this is a breaking change. You can opt out like this
Would be great to know stats on which default people prefer. |
While it was a pain to migrate, I prefer the new way by a long shot. |
Yeah same opinion here. It's rather a pain to migrate but I can see why it's needed. |
amazing update. thank you. |
Closes #385.
This PR started as a bug fix but ended up including quite a bit refactoring; so I welcome any feedback (I've tried to stay as true to the style of the existing code as I could).
The Problem
Included
spec files still used the root spec file's directory as their base directory.In this structure, a target declared in
Embedded/project.yml
would have to use the pathEmbedded/Sources
to reference theSources
directory adjacent to it.The Fix
The first major change is that I've introduced a
Spec
struct that references the directory containing the spec file, theJSONDictionary
content of the spec file, and any included spec files.This struct replaces the
Project.loadDictionary(path:)
function used before, and theSpec
struct itself is used in the initialization of aProject
, where previously a rawJSONDictionary
was used.The second major change is the introduction of a
PathContainer
protocol to abstract away the process of changing a path in an embedded file.This is implemented by the model types (e.g.
Target
) to convert any dictionary keys that reference paths relative to the spec file. It is then used during initialization of aProject
before collapsing the tree ofSpec
objects into a singleJSONDictionary
.