| Crates.io | wdm |
| lib.rs | wdm |
| version | 0.1.0 |
| created_at | 2024-10-12 22:33:04.011398+00 |
| updated_at | 2024-10-12 22:33:04.011398+00 |
| description | Decentralized WordPress Plugin Dependency Manager |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1406934 |
| size | 82,112 |
DISCLAIMER: This project is currently in progress and under active development. Features, documentation, and functionality may change or be incomplete.
wdm-cli is a command-line tool for managing WordPress plugin dependencies. It provides a decentralized alternative that empowers authors with control over where they store their plugins and gives users more granular control over their dependencies. With wdm-cli, you can specify exact versions, repositories (including private ones), and manage your WordPress projects' dependencies with greater flexibility.
You can install wdm-cli using Cargo, the Rust package manager:
cargo install wdm-cli
Alternatively, you can clone the repository and build it manually:
git clone https://github.com/vcanales/wdm-cli.git
cd wdm-cli
cargo build --release
This will create an executable in target/release/wdm, which you can move to a directory in your PATH.
Navigate to your WordPress project directory and initialize wdm:
wdm init
This command creates a wdm.yml file in your current directory, which will hold your dependencies and configuration.
By default, wdm expects your WordPress installation to be in the current directory. If your WordPress installation is located elsewhere, you can set the wordpress_path in the wdm.yml file:
config:
wordpress_path: "/path/to/your/wordpress"
dependencies: []
To add a plugin to your project, use the add command:
wdm add <dependency-name> --version <version> --repo <repository> [--token-env <token-env-variable>]
<dependency-name>: The name you want to give to the dependency.--version: The version of the dependency. You can specify an exact version (e.g., 1.8.0), latest, or a version requirement like ^1.0.--repo: The repository where the dependency is stored in the format owner/repo.--token-env (optional): The name of the environment variable that contains the GitHub token for accessing private repositories.Examples:
Adding a Public Dependency:
wdm add create-block-theme --version latest --repo WordPress/create-block-theme
This command adds the create-block-theme plugin from the WordPress/create-block-theme repository at the latest version.
Adding a Private Dependency:
wdm add private-plugin --version latest --repo yourusername/private-plugin --token-env WDM_TOKEN_PRIVATE_PLUGIN
This command adds the private-plugin from your private repository, using the token stored in the WDM_TOKEN_PRIVATE_PLUGIN environment variable.
To install all dependencies listed in your wdm.yml, run:
wdm install
This command resolves the versions, downloads the dependencies, and installs them into your WordPress installation.
wdm-cli supports installing dependencies from private GitHub repositories. To access private repositories, you need to provide a GitHub Personal Access Token (PAT). Tokens should be defined as environment variables.
If you have multiple private dependencies that require different tokens, you can specify different environment variables for each dependency.
Create a GitHub Personal Access Token
repo for private repositories).Define Environment Variables
Example:
export WDM_TOKEN_CUSTOM_PLUGIN="your-token-for-custom-plugin"
export WDM_TOKEN_ANOTHER_PLUGIN="your-token-for-another-plugin"
When adding a private dependency, specify the environment variable that contains the token using the --token-env option.
wdm add <dependency-name> --version <version> --repo <repository> --token-env <token-env-variable>
--token-env: The name of the environment variable that contains the token for this dependency.Example:
wdm add private-plugin --version latest --repo yourusername/private-plugin --token-env WDM_TOKEN_CUSTOM_PLUGIN
When you run wdm install, wdm-cli will use the specified environment variables to access the private repositories.
Important:
wdm install.If you want to update a dependency to a newer version, you can change the version in wdm.yml and run wdm install again.
Example:
Edit wdm.yml:
dependencies:
- name: private-plugin
version: "1.0.0"
repo: yourusername/private-plugin
token_env: WDM_TOKEN_CUSTOM_PLUGIN
Change the version to "1.1.0" or "latest":
dependencies:
- name: private-plugin
version: "latest"
repo: yourusername/private-plugin
token_env: WDM_TOKEN_CUSTOM_PLUGIN
Run the install command:
wdm install
To remove a dependency from your project, use the remove command:
wdm remove <dependency-name>
Example:
wdm remove private-plugin
This command removes private-plugin from your wdm.yml and uninstalls it from your WordPress installation.
Below is a table detailing all the supported fields in the wdm.yml configuration file for wdm-cli, including their default values.
| Field | Type | Description | Required | Default Value |
|---|---|---|---|---|
config |
Object | Contains configuration settings for wdm-cli. | Yes | N/A |
config.wordpress_path |
String | Specifies the file system path to your WordPress installation. Defaults to the current directory if not set. | Yes | Current working directory (.) |
dependencies |
Array | Lists all the dependencies (plugins/themes) managed by wdm-cli. | Yes | Empty array [] |
dependencies[].name |
String | The unique name you assign to the dependency. | Yes | N/A |
dependencies[].version |
String | The version of the dependency. Can be an exact version (e.g., 1.8.0), latest, or a version requirement like ^1.0. |
Yes | N/A |
dependencies[].repo |
String | The GitHub repository of the dependency in the format owner/repo. |
Yes | N/A |
dependencies[].token_env |
String | (Optional) The name of the environment variable that contains the GitHub token for accessing private repositories. | No | N/A |
config Objectwordpress_path
.)Example:
config:
wordpress_path: "/var/www/html/wordpress"
dependencies ArrayEach item in the dependencies array represents a plugin that you want to manage with wdm-cli.
name
Example:
dependencies:
- name: custom-plugin
version
1.8.0)latest to fetch the most recent version^1.0)Example:
- version: "^1.8.0"
repo
owner/repo.Example:
- repo: yourusername/custom-plugin
token_env
Example:
- token_env: WDM_TOKEN_CUSTOM_PLUGIN
# Set up the environment variable with your token
export WDM_TOKEN_CUSTOM_PLUGIN="your-token-for-custom-plugin"
# Initialize wdm
wdm init
# Add a private plugin from your own repository
wdm add private-plugin --version ^1.0 --repo yourusername/private-plugin --token-env WDM_TOKEN_CUSTOM_PLUGIN
# Install all dependencies
wdm install
# Set up environment variables for each token
export WDM_TOKEN_CUSTOM_PLUGIN="your-token-for-custom-plugin"
export WDM_TOKEN_ANOTHER_PLUGIN="your-token-for-another-plugin"
# Add the first private plugin
wdm add private-plugin --version ^1.0 --repo yourusername/private-plugin --token-env WDM_TOKEN_CUSTOM_PLUGIN
# Add the second private plugin
wdm add another-plugin --version ^2.0 --repo anotheruser/private-plugin --token-env WDM_TOKEN_ANOTHER_PLUGIN
# Install all dependencies
wdm install
# Update the version in wdm.yml
# Change the version of private-plugin to "1.2.0"
# Install the updated dependencies
wdm install
# Remove the private plugin
wdm remove private-plugin
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
Disclaimer:
When handling tokens and private repositories, always ensure you follow best security practices: