BPM is a command-line package manager that allows you to install and manage Bash scripts easily, similar to how you would manage packages in Node.js or Java projects.
Every project created with BPM must adhere to the following structure, which is inspired by Node.js and Java workflows:
package.sh
: This file defines the project metadata, including the name, main script, version, and dependencies.src/
directory: This directory contains all the package scripts, which can be imported by any other BPM package.
With BPM, you can run any package that contains a main script using the command:
bpm run
This command works similarly to npx
in Node.js.
When you run a package, the BPM CLI first calls the runner script, which will check for the package dependencies defined in package.sh
, and then invoke its main function.
The main function must be defined in the main script and named as pkg-name/main
. If the main function or the main script cannot be found, execution will be halted.
BPM provides an import
command that manages script dependencies in the global scope, similar to Java’s import mechanism. This allows you to import scripts based on their namespace, as specified by their path in the src
directory.
Example:
import com.package.name.MainScript # Imports from src/com/package/name/MainScript
Note: You can import scripts from any package defined as a dependency.
While not mandatory, it is encouraged that all BPM packages follow these conventions:
- Functional Paradigm: BPM encourages you to encapsulate all your scripts within functions, using the global scope only for defining constants and variables.
- Modular Scopes: It is recommended to name all functions using the
module/name
format, which helps prevent name collisions.