diff options
-rw-r--r-- | priv/shell-completion/fish/rebar3.fish | 161 | ||||
-rw-r--r-- | src/rebar_plugins.erl | 3 | ||||
-rw-r--r-- | src/rebar_prv_clean.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_packages.erl | 6 | ||||
-rw-r--r-- | src/rebar_utils.erl | 6 | ||||
-rw-r--r-- | test/rebar_compile_SUITE.erl | 38 |
6 files changed, 208 insertions, 8 deletions
diff --git a/priv/shell-completion/fish/rebar3.fish b/priv/shell-completion/fish/rebar3.fish new file mode 100644 index 0000000..ad3dad9 --- /dev/null +++ b/priv/shell-completion/fish/rebar3.fish @@ -0,0 +1,161 @@ +## copy this to ~/.config/fish/completions + +function __fish_rebar3_needs_command + set cmd (commandline -opc) + if [ (count $cmd) -eq 1 -a $cmd[1] = 'rebar3' -o $cmd[1] = './rebar3' ] + return 0 + end + return 1 +end + +function __fish_rebar3_using_command + set cmd (commandline -opc) + if [ (count $cmd) -gt 1 ] + if [ $argv[1] = $cmd[2] ] + return 0 + end + end + return 1 +end + +## ➜ ~ rebar3 --help +## Rebar3 is a tool for working with Erlang projects. +## +## +## Usage: rebar [-h] [-v] [<task>] +## +## -h, --help Print this help. +## -v, --version Show version information. +## <task> Task to run. +## +## +## Several tasks are available: +## +## as Higher order provider for running multiple tasks in a sequence as a certain profiles. +## clean Remove compiled beam files from apps. +## compile Compile apps .app.src and .erl files. +## cover Perform coverage analysis. +## ct Run Common Tests. +## deps List dependencies +## dialyzer Run the Dialyzer analyzer on the project. +## do Higher order provider for running multiple tasks in a sequence. +## edoc Generate documentation using edoc. +## escriptize Generate escript archive. +## eunit Run EUnit Tests. +## help Display a list of tasks or help for a given task or subtask. +## new Create new project from templates. +## pkgs List available packages. +## release Build release of project. +## relup Create relup of releases. +## report Provide a crash report to be sent to the rebar3 issues page. +## shell Run shell with project apps and deps in path. +## tar Tar archive of release built of project. +## unlock Unlock dependencies. +## update Update package index. +## upgrade Upgrade dependencies. +## version Print version for rebar and current Erlang. +## xref Run cross reference analysis. +## +## plugins <task>: +## list List local and global plugins for this project +## upgrade Uprade plugins +## +## Run 'rebar3 help <TASK>' for details. +# general options +complete -f -c 'rebar3' -n 'not __fish_rebar3_needs_command' -l help -d 'Display the manual of a rebar3 command' + + +complete -f -c 'rebar3' -s h -l help -d "Show the program options" +complete -f -c 'rebar3' -s v -l version -d "Show version information" + +## included tasks + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a as -d "Higher order task which takes a profile name and list of tasks to run under that profile." +## TODO: 'as' needs to inspect the rebar.config's profiles element + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a clean -d "Removes compiled beam files from apps." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command clean' -s a -l all -d "Clean all apps, including the dependencies" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a compile -d "Compile apps .app.src and .erl files." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a cover -d "Perform coverage analysis." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command cover' -s r -l reset -d "Resets all cover data" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command cover' -s v -l verbose -d "Prints coverage analysis in the terminal." + +## ct +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a ct -d "Run Common Tests." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -l dir -d "Compile and run all test suites in the specified directories." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -l suites -d "Compile and run all test suites specified. Must be specified by full path, either absolute or relative to the current directory." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -l group -d "Test groups to run." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -l config -d "Config files to use when running tests." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -l logdir -d "The directory in which test logs will be written. Default: _build/test/logs" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -s v -l verbose -d "Enable verbose output. Default: false" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command ct' -s c -l cover -d "Generate cover data" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a deps -d "List dependencies" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a dialyzer -d "Run the Dialyzer analyzer on the project." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command dialyzer' -s u -l update-plt -d "Enable updating the PLT. Default: true" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command dialyzer' -s s -l succ-typings -d "Enable success typing analysis. Default: true" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a do -d "Higher order provider for running multiple tasks in a sequence." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command do' -a 'compile, clean, ct, cover, deps, dialyzer, edoc, eunit, help, new, pkgs, release, relup, report, shell, tar, unlock, update, upgrade, version, xref,' +## TODO: do should understand plugins, but now it does not. + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a edoc -d "Generate documentation using edoc." +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a escriptize -d "Generate escript archive." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a eunit -d "Run EUnit Tests." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command eunit' -s c -l cover -d "Generate cover data" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command eunit' -s v -l verbose -d "Verbose output" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command eunit' -l app -d "List of applications to run tests for" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command eunit' -l suite -d "Lists of test suites to run" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a help -d "Display a list of tasks or help for a given task or subtask." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a new -d "Create new project from templates." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command new' -s f -l force -d "Overwrite existing files" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command new' -a help -d "Display all variables and arguments for each template" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a pkgs -d "List available packages." +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a release -d "Build release of project." +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a relup -d "Create relup of releases." +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a report -d "Provide a crash report to be sent to the rebar3 issues page." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a shell -d "Run shell with project apps and deps in path." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command shell' -l config -d "Allows to load a config file, if any. Defaults to the sys_config entry defined for relx if present." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command shell' -l name -d "equivalent to erlang's -name" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command shell' -l sname -d "equivalent to erlang's -sname" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a tar -d "Tar archive of release built of project." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s n -l relname -d "Specify the name for the release that will be generated" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s v -l relvsn -d "Specify the version for the release" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s g -l goal -d "Specify a target constraint on the system. These are usually the OTP" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s u -l upfrom -d "Only valid with relup target, specify the release to upgrade from" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s o -l output-dir -d "The output directory for the release. This is `./` by default." +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s h -l help -d "Print usage" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s l -l lib-dir -d "Additional dir that should be searched for OTP Apps" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s p -l path -d "Additional dir to add to the code path" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l default-libs -d "Whether to use the default system added lib dirs (means you must add them all manually). Default is true" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s V -l verbose -d "Verbosity level, maybe between 0 and 3 [default: 2]" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s d -l dev-mode -d "Symlink the applications and configuration into the release instead of copying" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s i -l include-erts -d "If true include a copy of erts used to build with, if a path include erts at that path. If false, do not include erts" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s a -l override -d "Provide an app name and a directory to override in the form <appname>:<app directory>" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s c -l config -d "The path to a config file [default: ]" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l overlay_vars -d "Path to a file of overlay variables" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l vm_args -d "Path to a file to use for vm.args" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l sys_config -d "Path to a file to use for sys.config" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l system_libs -d "Path to dir of Erlang system libs" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -l version -d "Print relx version" +complete -f -c 'rebar3' -n '__fish_rebar3_using_command tar' -s r -l root -d "The project root directory" + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a unlock -d "Unlock dependencies." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a update -d "Update package index." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a upgrade -d "Upgrade dependencies." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a version -d "Print version for rebar and current Erlang." + +complete -f -c 'rebar3' -n '__fish_rebar3_needs_command' -a xref -d "Run cross reference analysis." + diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index 3e855de..bda3fb7 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -94,7 +94,8 @@ build_plugin(AppInfo, Apps, State) -> Providers = rebar_state:providers(State), Providers1 = rebar_state:providers(rebar_app_info:state(AppInfo)), S = rebar_state:all_deps(rebar_app_info:state_or_new(State, AppInfo), Apps), - rebar_prv_compile:compile(S, Providers++Providers1, AppInfo). + S1 = rebar_state:set(S, deps_dir, ?DEFAULT_PLUGINS_DIR), + rebar_prv_compile:compile(S1, Providers++Providers1, AppInfo). plugin_providers({Plugin, _, _, _}) when is_atom(Plugin) -> validate_plugin(Plugin); diff --git a/src/rebar_prv_clean.erl b/src/rebar_prv_clean.erl index e3cb84e..f10d12b 100644 --- a/src/rebar_prv_clean.erl +++ b/src/rebar_prv_clean.erl @@ -39,7 +39,7 @@ do(State) -> case All of true -> DepsDir = rebar_dir:deps_dir(State), - DepApps = rebar_app_discover:find_apps([DepsDir], all); + DepApps = rebar_app_discover:find_apps([filename:join(DepsDir, "*")], all); false -> DepApps = [] end, diff --git a/src/rebar_prv_packages.erl b/src/rebar_prv_packages.erl index 8ba66de..9a40734 100644 --- a/src/rebar_prv_packages.erl +++ b/src/rebar_prv_packages.erl @@ -46,7 +46,11 @@ print_packages(Dict) -> end, orddict:new(), Pkgs), orddict:map(fun(Name, Vsns) -> - VsnStr = join(Vsns, <<", ">>), + SortedVsns = lists:sort(fun(A, B) -> + ec_semver:lte(ec_semver:parse(A) + ,ec_semver:parse(B)) + end, Vsns), + VsnStr = join(SortedVsns, <<", ">>), io:format("~s:~n Versions: ~s~n~n", [Name, VsnStr]) end, SortedPkgs). diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index c729b58..7ae3d9c 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -757,12 +757,12 @@ set_httpc_options(Scheme, Proxy) -> escape_chars(Str) when is_atom(Str) -> escape_chars(atom_to_list(Str)); escape_chars(Str) -> - re:replace(Str, "([ ()?`!$])", "\\\\&", [global, {return, list}]). + re:replace(Str, "([ ()?`!$&;])", "\\\\&", [global, {return, list}]). %% "escape inside these" escape_double_quotes(Str) -> - re:replace(Str, "([\"\\\\`!$*])", "\\\\&", [global, {return, list}]). + re:replace(Str, "([\"\\\\`!$&*;])", "\\\\&", [global, {return, list}]). %% "escape inside these" but allow * escape_double_quotes_weak(Str) -> - re:replace(Str, "([\"\\\\`!$])", "\\\\&", [global, {return, list}]). + re:replace(Str, "([\"\\\\`!$&;])", "\\\\&", [global, {return, list}]). diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 6884a22..0aaa899 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -22,7 +22,8 @@ parse_transform_test/1, erl_first_files_test/1, mib_test/1, - only_default_transitive_deps/1]). + only_default_transitive_deps/1, + clean_all/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -50,7 +51,8 @@ all() -> recompile_when_opts_change, dont_recompile_when_opts_dont_change, dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted, deps_in_path, checkout_priority, highest_version_of_pkg_dep, - parse_transform_test, erl_first_files_test, mib_test, only_default_transitive_deps]. + parse_transform_test, erl_first_files_test, mib_test, only_default_transitive_deps, + clean_all]. build_basic_app(Config) -> AppDir = ?config(apps, Config), @@ -556,3 +558,35 @@ only_default_transitive_deps(Config) -> Config, RConf, ["as", "test", "compile"], {ok, [{app, Name}, {dep, "a", <<"1.0.0">>}, {dep_not_exist, PkgName}]} ). + +clean_all(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + DepName = rebar_test_utils:create_random_name("dep1_"), + PkgName = rebar_test_utils:create_random_name("pkg1_"), + mock_git_resource:mock([]), + mock_pkg_resource:mock([ + {pkgdeps, [{{iolist_to_binary(PkgName), iolist_to_binary(Vsn)}, []}]} + ]), + + RConfFile = rebar_test_utils:create_config(AppDir, [{deps, [ + {list_to_atom(DepName), {git, "http://site.com/user/"++DepName++".git", {tag, Vsn}}}, + {list_to_atom(PkgName), Vsn} + ]}]), + {ok, RConf} = file:consult(RConfFile), + + %% Build things + rebar_test_utils:run_and_check( + Config, RConf, ["compile"], + {ok, [{app, Name}, {app, DepName}, {app, PkgName}]} + ), + + %% Clean all + rebar_test_utils:run_and_check( + Config, RConf, ["clean", "--all"], + {ok, [{app, Name, invalid}, {app, DepName, invalid}, {app, PkgName, invalid}]} + ). |