@sp-packages/depkit v2.4.1
DepKit
š Why DepKit?
Managing dependencies across both Composer (PHP) and NPM (JavaScript) can be tedious. depkit simplifies the process by providing a single command to:
- š¦ Install dependencies for both Composer and NPM
 - š Audit and check for outdated dependencies
 - š Ensure best practices by running necessary package checks
 - š Customizable config file (
depkit.json) - ā” Works seamlessly with WordPress, PHP, and Node.js projects
 - š ļø Ideal for automation in CI/CD, Lando, and local development workflows
 
⨠Features
- š Installs production or development dependencies
 - š ļø Runs security audits to identify vulnerabilities
 - š Checks for outdated packages
 - ā” Lightweight and fast
 
š How DepKit Works
Before executing any commands, depkit checks for the existence of composer.json and package.json in your project root:
- If 
composer.jsonis found, it runs Composer commands. Otherwise, it skips Composer execution. - If 
package.jsonis found, it runs NPM commands. Otherwise, it skips NPM execution. - If neither file is found, 
depkitexits with an error, as there are no dependencies to manage. 
This ensures that depkit only executes relevant commands based on your project structure.
š¦ Installation
Global Installation (For system-wide use)
npm install -g @sp-packages/depkitThis allows you to use depkit globally in your terminal.
Local Installation (For project-specific use)
npm install @sp-packages/depkit --save-devThen, run it via:
npx depkitš Usage
Basic Usage
Run dependency installation and checks for both Composer and NPM:
depkitOptions:
$ depkit -h
Usage: depkit [options]
A lightweight CLI tool to efficiently manage Composer & NPM dependencies in a project.
Options:
-V, --version output the version number
--skip-composer Skip processing Composer dependencies
--skip-npm Skip processing NPM dependencies
--production Install only production dependencies (exclude dev dependencies)
-c, --config <config> Path to the configuration file (default: depkit.json)
-q, --quiet Disable output
-v, --verbose Enable verbose logging
-h, --help display help for commandSkipping Composer or NPM Processing
Skip Composer execution:
depkit --skip-composerSkip NPM execution:
depkit --skip-npmSkip both (not recommended):
depkit --skip-composer --skip-npm
Production Mode
To install only production dependencies (skip devDependencies):
depkit --productionThis runs:
composer install --no-devnpm install --omit=dev
āļø Configuration (depkit.json)
Running the depkit command will allow you to automatically create the depkit.json file. Alternatively, you can manually create a depkit.json or .depkit.json in your project root or a custom configuration file and pass it using the -c or --config parameter:
{
  "TOOLS": {
    "COMPOSER_VERSION": {
      "title": "Checking Composer version",
      "command": "info",
      "type": "composer",
      "behavior": "error",
      "priority": 1,
      "args": ["--version"]
    },
    "COMPOSER_AUDIT": {
      "title": "Auditing PHP Dependencies",
      "command": "audit",
      "type": "composer",
      "behavior": "error",
      "priority": 2
    },
    "NPM_VERSION": {
      "title": "Checking NPM version",
      "prefix": "npm",
      "command": "info",
      "args": ["--version"],
      "type": "npm",
      "behavior": "error",
      "priority": 3
    },
    "DEPCHECK": {
      "title": "Depcheck NPM Packages",
      "prefix": "npx",
      "command": "depcheck",
      "type": "npm",
      "behavior": "warn",
      "requires": "depcheck",
      "priority": 4
    },
    "NPM_OUTDATED": {
      "title": "Outdated NPM Packages",
      "command": "outdated",
      "type": "npm",
      "behavior": "warn",
      "priority": 5
    }
  }
}If no --config option is provided, depkit will look for depkit.json or .depkit.json in the project root by default.
š Commands Overview
By default, depkit executes predefined commands for Composer and NPM, ensuring dependencies are properly managed.
Composer Commands
| Command | Description | 
|---|---|
composer -V | Checks the installed Composer version | 
composer install | Installs Composer dependencies | 
composer install --no-dev | Installs Composer dependencies without dev dependencies (when --production is used) | 
composer audit | Checks for known security vulnerabilities in dependencies | 
composer outdated | Lists outdated Composer dependencies | 
NPM Commands
| Command | Description | 
|---|---|
npm -v | Checks the installed NPM version | 
npm install | Installs NPM dependencies | 
npm install --omit=dev | Installs only production dependencies (when --production is used) | 
npm audit --omit=dev | Runs an NPM security audit | 
npm outdated | Lists outdated NPM dependencies | 
š Gain Insights Into Your Dependencies
By running these commands, depkit provides a clear picture of your project's dependencies:
- š Composer & NPM Version Checks ā Ensure the correct versions are installed.
 - š Security Audits ā Identify vulnerabilities in your dependencies.
 - š Outdated Package Reports ā Know when dependencies need updates.
 - š Seamless Installation ā Manage dependencies across multiple environments.
 
This helps maintain a secure, up-to-date, and stable project setup! š
šÆ Example Outputs
ā [SUCCESS] No security vulnerability advisories found.ā [SUCCESS] Checking Composer version: Passed
ā [SUCCESS] Installing PHP Dependencies: Passed
ā [SUCCESS] Auditing PHP Dependencies: Passed
ā [SUCCESS] Outdated PHP Dependencies: Passed
ā [SUCCESS] Checking NPM version: Passed
ā [SUCCESS] Installing NPM Packages: Passed
ā  [WARNING] Depcheck NPM Packages: Issues found
ā [SUCCESS] Outdated NPM Packages: Passed
ā [SUCCESS] Auditing NPM Packages: Passedš” Use Cases
- WordPress & PHP Projects ā Handle Composer and NPM dependencies in one go
 - Node.js Projects ā Keep dependencies up to date with ease
 - CI/CD Automation ā Ensure dependencies are installed before builds
 - Lando & Local Dev Environments ā Automate dependency setup
 
1ļøā£ Automating Lando Post-Start Hook
If you're using Lando, you can automatically run depkit after lando start:
services:
  appserver:
    run_as_root:
      - depkit2ļøā£ CI/CD Integration
Run depkit in GitHub Actions, GitLab CI/CD, or other automation scripts:
jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
      - name: Install Dependencies
        run: npm ci
      - name: Install DepKit
        run: npm install -g @sp-packages/depkit
      - name: Run DepKit
        run: depkitš¤ Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
š License
This project is licensed under the MIT License. See the LICENSE file for details.