-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
Scaffold init #1129
Scaffold init #1129
Conversation
Rakefile
Outdated
@@ -101,7 +101,8 @@ def package | |||
system( | |||
"zip", "-q", "-r", "--symlinks", | |||
"tuist.zip", "tuist", | |||
"ProjectDescription.swiftmodule", "ProjectDescription.swiftdoc", "libProjectDescription.dylib", "ProjectDescription.swiftinterface" | |||
"ProjectDescription.swiftmodule", "ProjectDescription.swiftdoc", "libProjectDescription.dylib", "ProjectDescription.swiftinterface", | |||
File.expand_path("Templates", __dir__) |
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.
Did you double-check that the zipped directory copies its content recursively?
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.
It did, but it was nested deeply in the expanded path, I have modified the copy method to fix it.
@@ -21,16 +23,38 @@ public final class TemplatesDirectoryLocator: TemplatesDirectoryLocating { | |||
|
|||
// MARK: - TemplatesDirectoryLocating | |||
|
|||
public func locateTuistTemplates() -> AbsolutePath? { | |||
#if DEBUG |
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 think it's an ok hack because we are using the #DEBUG macro. I'd add a comment indicating what path bundlePath
points to:
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.
good point, added π
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.
@fortmarek when I use scaffold --list
I get the following as an output:
default: Default template
What about adding a couple of improvements:
- Make it grep parseable and presenting it as a table.
- Add support for returning the list as a JSON.
That's a good idea @pepibumur , I think it'd make sense to change Would you mind if I did the recommended changes in a follow-up PR? |
Short description π
This PR does not bring any new user-facing features, but it should make it super easy to add tuist built-in templates. That way you will be soon able to call
tuist scaffold --template swiftui
and it will generate a SwiftUI-compatible project instead of usingUIKit
as it does now. This is made possible byscaffold
command merged here.Solution π¦
Tuist templates are defined in
Templates
. This directory then gets copied to~/.tuist/Versions/version/Templates
. When locating available templates, tuist will scan both user and tuist templates. When runningtuist init
, it will default to template calleddefault
, if the user provides--template
option, it will try to use that.Implementation π©βπ»π¨βπ»
TemplateGenerator
inInitCommand
Questions β
To get the command running when running this tool via
swift run
or in Xcode, I had to make this ugly hack - the reason is that it is not possible to copy files to thebuild
directory that are not libraries/executables. If you can think of a better solution, I'd love to hear it.Another question is if there is a way how to test the whole flow of bundling the templates directory and then copying it?