-
Notifications
You must be signed in to change notification settings - Fork 11
Allow seperate app versions under an Umbrella #7
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
base: master
Are you sure you want to change the base?
Changes from all commits
137dc8c
44c1fa7
76be5c8
5b13a12
0961c67
f4840d8
89584b4
d863558
47e1486
dab9a11
e9ef765
47b5498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule Eliver.Multiple do | ||
|
||
def list_sub_apps() do | ||
Mix.Project.apps_paths() | ||
|> case do | ||
nil -> {:error, :unknown_app_structure} | ||
sub_apps -> {:ok, sub_apps} | ||
end | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,36 +6,129 @@ defmodule Mix.Tasks.Eliver.Bump do | |
args |> parse_args |> bump | ||
end | ||
|
||
defp bump(_) do | ||
defp bump(args) do | ||
case check_for_git_problems() do | ||
{:error, message} -> | ||
say message, :red | ||
{:ok} -> | ||
{new_version, changelog_entries} = get_changes() | ||
if allow_changes?(new_version, changelog_entries) do | ||
make_changes(new_version, changelog_entries) | ||
do_bump(args) | ||
end | ||
end | ||
|
||
defp do_bump(args) do | ||
case Keyword.get(args, :multi) do | ||
true -> bump_multiple() | ||
nil -> bump_normal() | ||
end | ||
end | ||
|
||
defp bump_multiple() do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could make sense to try to split this one into smaller functions so that it's a bit more understandable what it does, wdyt ? |
||
Eliver.Multiple.list_sub_apps() | ||
|> case do | ||
{:ok, sub_apps} -> | ||
sub_apps = Map.put(sub_apps, :umbrella, ".") | ||
|
||
changes = Enum.map(sub_apps, fn | ||
|
||
{:umbrella, app_path} -> | ||
# Note changes re required for the umbrella app | ||
{current_version, new_version, changelog_entries} = get_changes(app_path, :normal) | ||
{:umbrella, app_path, current_version, new_version, changelog_entries} | ||
|
||
{app, app_path} -> | ||
|
||
say "\n\n==============================================" | ||
say "Bump details for #{Atom.to_string(app)}" | ||
say "==============================================" | ||
|
||
get_changes(app_path, :multi) | ||
|> case do | ||
nil -> nil | ||
{current_version, new_version, changelog_entries} -> | ||
{app, app_path, current_version, new_version, changelog_entries} | ||
end | ||
|
||
|
||
end) | ||
|> Enum.filter(fn(change) -> not is_nil(change) end) | ||
|
||
if allow_changes?(changes) do | ||
make_changes(changes) | ||
end | ||
|
||
{:error, :unknown_app_structure} -> | ||
say "Please note that only standard umbrella app directory structures are supported. Please refer to the documentation for details", :red | ||
end | ||
Comment on lines
+28
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon this could be used with a |
||
end | ||
defp bump_normal() do | ||
{current_version, new_version, changelog_entries} = get_changes() | ||
if allow_changes?(new_version, changelog_entries) do | ||
make_changes(new_version, changelog_entries) | ||
end | ||
end | ||
|
||
defp get_changes do | ||
{get_new_version(), get_changelog_entries()} | ||
defp get_changes(root_for_changes \\ ".", bump_type \\ :normal) do | ||
{current_version, new_version} = get_new_version(root_for_changes, bump_type) | ||
|
||
if current_version == new_version do | ||
nil | ||
else | ||
{current_version, new_version, get_changelog_entries()} | ||
end | ||
end | ||
|
||
defp allow_changes?(changes) when is_list(changes) do | ||
say "\n" | ||
say "==============================================" | ||
say "Summary of changes:" | ||
say "==============================================" | ||
|
||
Enum.each(changes, fn(app_changes) -> | ||
display_change(app_changes) | ||
end) | ||
|
||
say "\n" | ||
result = ask "Continue?", false | ||
case result do | ||
{:ok, value} -> value | ||
{:error, _} -> false | ||
end | ||
end | ||
defp allow_changes?(new_version, changelog_entries) do | ||
current_version = Eliver.VersionFile.version | ||
say "\n" | ||
say "Summary of changes:" | ||
say "Bumping version #{current_version} → #{new_version}", :green | ||
say ("#{Enum.map(changelog_entries, fn(x) -> "* " <> x end) |> Enum.join("\n")}"), :green | ||
say "\n" | ||
display_change(current_version, new_version, changelog_entries) | ||
result = ask "Continue?", false | ||
case result do | ||
{:ok, value} -> value | ||
{:error, _} -> false | ||
end | ||
end | ||
|
||
defp display_change({app, app_path, current_version, new_version, changelog_entries}) do | ||
say "\n#{Atom.to_string(app)} (#{app_path})" | ||
say "==============================================" | ||
display_change(current_version, new_version, changelog_entries) | ||
end | ||
defp display_change(current_version, new_version, changelog_entries) do | ||
say "Bumping version #{current_version} → #{new_version}", :green | ||
say ("#{Enum.map(changelog_entries, fn(x) -> "* " <> x end) |> Enum.join("\n")}"), :green | ||
say "\n" | ||
end | ||
|
||
defp make_changes(changes) when is_list(changes) do | ||
for {app, app_path, current_version, new_version, changelog_entries} <- changes do | ||
Eliver.VersionFile.bump(new_version, "#{app_path}/VERSION") | ||
Eliver.ChangeLogFile.bump(new_version, changelog_entries, "#{app_path}/CHANGELOG.md") | ||
end | ||
|
||
tags = Eliver.Git.commit!(changes) | ||
|
||
say "Pushing to origin..." | ||
Eliver.Git.push!(tags) | ||
end | ||
|
||
defp make_changes(new_version, changelog_entries) do | ||
Eliver.VersionFile.bump(new_version) | ||
Eliver.ChangeLogFile.bump(new_version, changelog_entries) | ||
|
@@ -68,16 +161,33 @@ defmodule Mix.Tasks.Eliver.Bump do | |
end | ||
end | ||
|
||
defp get_new_version do | ||
Eliver.VersionFile.version |> Eliver.next_version(get_bump_type()) | ||
defp get_new_version(dir, type) do | ||
{ | ||
Eliver.VersionFile.version("#{dir}/VERSION"), | ||
Eliver.VersionFile.version("#{dir}/VERSION") |> Eliver.next_version(get_bump_type(type)) | ||
} | ||
end | ||
|
||
defp get_changelog_entries do | ||
{:ok, result} = get_list "Enter the changes, enter a blank line when you're done" | ||
result | ||
end | ||
|
||
defp get_bump_type do | ||
defp get_bump_type(:multi) do | ||
result = choose "Select release type", | ||
patch: "Bug fixes, recommended for all", | ||
minor: "New features, but backwards compatible", | ||
major: "Breaking changes", | ||
none: "None", | ||
default: :none | ||
|
||
case result do | ||
{:ok, value} -> value | ||
{:error, _} -> get_bump_type(:multi) | ||
end | ||
end | ||
|
||
defp get_bump_type(:normal) do | ||
result = choose "Select release type", | ||
patch: "Bug fixes, recommended for all", | ||
minor: "New features, but backwards compatible", | ||
|
@@ -86,12 +196,12 @@ defmodule Mix.Tasks.Eliver.Bump do | |
|
||
case result do | ||
{:ok, value} -> value | ||
{:error, _} -> get_bump_type() | ||
{:error, _} -> get_bump_type(:normal) | ||
end | ||
end | ||
|
||
defp parse_args(args) do | ||
{_, args, _} = OptionParser.parse(args) | ||
{args, _, _} = OptionParser.parse(args) | ||
args | ||
end | ||
end |
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.
This could be combined in a
with