This package can be used from command line or from any bash script that needs to source some dependencies.
Assuming that the previous steps in How to Install
have been followed successfully, we can try some examples.
Invoking install
will read all required packages from file required-packages.pkg
if it exists in the root of your project or package.
This is done recursively, by looking in each package it installs, for the file required-packages.pkg
and installing also that packages, until no more required packages are found to install.
The file required-packages.pkg
must require a package per line in the format repository-service-url,vendor-name,package-name,package-version,sym-link:package/path/to/bash-script.sh
. The
symbolic link declaration is optional.
The file required-packages.pkg
must be located in the root of your package.
without symbolic links as per seen in Bash Package Manager itself...
github.com,exadra37-bash,file-system,0.3.0
github.com,exadra37-bash,pretty-print,0.1.0
with symbolic links as per seen in VLC Media Player...
gitlab.com,exadra37-playground/docker,android-studio-3,master,android-studio:bin/studio.sh
gitlab.com,exadra37-docker/cli-tool,fuzzy-finder,latest,fuzzy-finder:bin/fuzzy-finder
gitlab.com,exadra37-docker/api-tool,postman,master,postman:src/bin/postman
gitlab.com,exadra37-docker/productivity-tool,go-for-it,latest,go-for-it:src/dockerize-gui-app-demo.sh
gitlab.com,exadra37-docker/media,vlc,master,vlc:bin/vlc.sh
NOTE: DO NOT LEAVE BLANK SPACES BETWEEN COMMAS
To auto install recursively the above packages, just type from the root of your project:
$ bpm install
When invoking require
, we need to specify the following arguments:
vendor-name
package-name
package-version
repository-service-url
(optional)
To install from the default repository provider, Github, the package exadra37-bash/file-system
in version 0.2.0
, we just need to type in command line:
$ bpm require exadra37-bash file-system 0.2.0
To install the same package, from Example 1, but from other repository service provider, like Gitlab, we will need to add into the end the domain name gitlab.com
:
$ bpm require exadra37-bash file-system 0.2.0 gitlab.com
Now that we have the required packages to develop our project or package, we just need to source them as usually we do with any other file we want to include in our Bash Script.
# this example is assuming that the script from where we source,
# is located 1 level inside our project or package, like in `src` folder
source ../vendor/vendor-name/package-name/src/sourcing/file-to-source.sh
Considering that the instructions in How to Install have been followed, the following example will show how to integrate Bash Package Manager functionality to Auto Source Dependencies into any Bash Script.
# we need to determine the absolut path for this bash script
script_path=$( cd "$( dirname "$0" )" && pwd )
# we need to manually source our Bash Package Manager
source "${script_path}/../vendor/exadra37-bash/package-manager/src/sourcing/package-manager-trait.source.sh"
# Now we can automaticcly source any dependency we need to run our bash script
Auto_Source_Dependency "exadra37-bash" "pretty-print" "0.1.0" "src/sourcing/pretty-print-trait.source.sh" "${script_path}/../"
$ mkdir -p src && touch src/demo-auto-sourcing.sh && chmod +x src/demo-auto-sourcing.sh && vim src/demo-auto-sourcing.sh
#!/bin/bash
# @author Exadra37(Paulo Silva) <exadra37ingmailpointcom>
# @since 2016/06/04
# @link https://exadra37.com
set -e
#################################################################################################################################################################
# Declare Variables
#################################################################################################################################################################
script_path=$( cd "$( dirname "$0" )" && pwd )
#################################################################################################################################################################
# Sourcing Dependencies
#################################################################################################################################################################
source "${script_path}/../vendor/exadra37-bash/package-manager/src/sourcing/package-manager-trait.source.sh"
Auto_Source_Dependency "exadra37-bash" "pretty-print" "0.1.0" "src/sourcing/pretty-print-trait.source.sh" "${script_path}/../"
#################################################################################################################################################################
# Execution
#################################################################################################################################################################
# Lets see if we can use some of the nice Pretty Print functions
Print_Success "Auto Sourced Dependency Successfully :)."
Print_Info "The first time the script runs all dependencies are cloned from remote repositories, if they do not exist in the vendor folder."
Print_Info "Next time we run this script, Auto Sourcing the Dependency will not need to clone it, therefore will run faster."
Print_Alert "Pretty Print can do a lot more funny stuff... go to https://github.com/exadra37-bash/package-manager for more examples."
$ ./src/demo-auto-sourcing.sh
SUCCESS: Auto Sourced Dependency Successfully :).
INFO: The first time the script runs all dependencies are cloned from remote repositories, if they do not exist in the vendor folder.
INFO: Next time we run this script, Auto Sourcing the Dependency will not need to clone it, therefore will run faster.
ALERT: Pretty Print can do a lot more funny stuff... go to https://github.com/exadra37-bash/pretty-print for more examples.
If the above output can't be seen, please perform all the steps again and ensure that you do not skip any of them or that you are not making some typos.