Open onurgenes opened 5 years ago
Thanks @onurgenes! It's on my todo list for this week :) I found this https://nshipster.com/homebrew/ — which looks promising! Were you able to install it without Homebrew?
Currently, I'm trying to figure out, how users can add their custom generators. I have a rough idea, but haven't tried it yet.
As soon as it works, I'll add support for Homebrew and I'll let you know if I need help :D
Yeah, I just read that today. I open for helping in any topic :) Eagerly waiting.
Sorry @onurgenes — no Homebrew yet. I'm still struggling with the custom generators #12 :/ If you have any ideas, feel free to share them :)
Sorry for the late response. I have been busy last week. I will try to add this to homebrew by myself. I will share the details with you soon :)
Just another place to look for an example of how this is accomplished in a real world project. (I was curious about how hard this is, so did some digging in the XcodeGen
project to see how they do it.) Here's the PR for it over there: https://github.com/yonaskolb/XcodeGen/pull/16
Sounds like a make file is required. I might throw one together quick.
Gah, harder than I'd hoped. Looks like we probably have to copy the entire contents of Source somewhere. (Although it would maybe make sense to move all the templates out of there and just copy those.)
Here's what I came up with:
export EXECUTABLE_NAME = hackman
PREFIX = /usr/local
INSTALL_PATH = $(PREFIX)/bin/$(EXECUTABLE_NAME)
build:
swift build -c release --disable-sandbox
install: build
mkdir -p $(PREFIX)/bin
cp -f .build/release/$(EXECUTABLE_NAME) $(INSTALL_PATH)
uninstall:
rm -f $(INSTALL_PATH)
clean:
rm -rf .build
.PHONY: build install uninstall clean
But after make install
(which seems to work just fine), I get this error when trying to generate a new project:
Fatal error: 'try!' expression unexpectedly raised an error: Template named `project.yml` does not exist in loader FileSystemLoader([/usr/Sources/HackManLib/Generators/NewProject]): file /Users/grid/Documents/dev/externals/HackMan/HackMan/Sources/HackManLib/Generators/NewProject/NewProject.swift, line 25
Illegal instruction: 4
This is looking like it can't find the file at path. If you add clear instructions I can check.
Yeah, the copy itself is easy to add... but I am not 100% sure exactly how the paths are constructed in hackman itself. (And I think that is what will have to change.) I believe it has to do with how Stencil loads its paths (which is not explicitly being specified in hackman, I don't think). I started looking into it and got lost pretty quickly. IMO, some re-architecture is probably in order.
As far as instructions, you can add a new file (with the text I posted above) in the root directory named Makefile
, and then run make install
.
But as I mentioned, it won't work without copying the Source
directory somewhere, and referencing that new location from the hackman code. (Looks like at the very least Generator.swift
would need its basePath
function changed, but Writer.swift
also contains path stuff, and... IMO, there should really be a central location, maybe a configuration file, that specifies a list of places to look, not just one.)
I am thinking about adding this package to HomeBrew but I didn't do that before. Maybe we can work together on this.