这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@darinwilson
Copy link
Member

When setting up a new app using this as a base, it's a little tedious to change every instance of PhoenixBase and :phoenix_base throughout the codebase to the new app name. This PR adds a step to bin/setup that prompts the user for the app name they'd like to use, then renames files and replaces strings in the repo as needed.

This feature uses sed for the string replacement. It should work on Mac and Unix systems, but probably not Windows. Ideally, we would have a pure Elixir solution, but this will get the ball rolling.

@darinwilson
Copy link
Member Author

I just noticed that Semaphore is failing because bin/setup now requires user input. I could change the script so that it accepts an optional parameter to use as the app name, but that would require making a change in the Semaphore setup to call the script with the parameter. Does that work? Or is there a better approach?

@darinwilson
Copy link
Member Author

Now that I think about it some more, I think I'll change the script so that rather than prompting the user for the app name, it will just accept it as an optional argument to bin/setup. If the user doesn't provide anything, it will leave it as "PhoenixBase", e.g.

# setup the app as MyApp
./bin/setup MyApp

# setup the app as PhoenixBase
./bin/setup

That seems cleaner to me, and will require no changes to Semaphore. Does that work?

@danielberkompas
Copy link
Contributor

I'd like to see this be a mix task. For example:

mix project.rename OldName NewName

We could then later extract it to its own hex package, and run it in bin/setup like you are doing here.

@danielberkompas
Copy link
Contributor

I also don't think we have to run it as part of bin/setup, since it doesn't really need to be run every time your project is set up (because ultimately your project will be renamed), it only has to be run by the very first person who works on the project.

Just including it in the base project with a comment in the README should be enough. "After you fork this project, rename it using mix project.rename." Forkers don't need to change the bin/setup script at all.

@darinwilson
Copy link
Member Author

I also don't think we have to run it as part of bin/setup, since it doesn't really need to be run every time your project is set up (because ultimately your project will be renamed), it only has to be run by the very first person who works on the project.

Yeah, that makes sense - I'll move it out to a mix task. Thanks for the feedback!

@danielberkompas
Copy link
Contributor

I'm working on a PR to add this to Elixir. If it's accepted, we'll get a mix app.rename NewName task available to us everywhere.

@darinwilson
Copy link
Member Author

That would be great! 👍

On Sat, Apr 16, 2016, 2:03 PM Daniel Berkompas notifications@github.com
wrote:

I'm working on a PR to add this to Elixir. If it's accepted, we'll get a mix
app.rename NewName task available to us everywhere.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#6 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants