Corella NPM and PHP Composer Package Backup

A command line tool to create offline backups of packages from your projects. Currently supports NPM and PHP Composer package files.

NPM
Scans all dependencies and devDependencies
For each found dependency, moves it’s dependencies into bundleDependencies
Installs the package with bundled dependencies, skipping scripts
Packs the package so that it can then be installed from archive using npm install archived.tar.gz
Composer
Copies only the requires, requires-dev and config attributes of the supplied composer.json file to a new file
Runs composer install
Leaves you with an uncompressed vendor folder with the required packages
Usage
–phpBinPath must be a valid path to your PHP installation if you’re backing up composer.json
Multiple package files can be supplied, each with their own backup destination by repeating –type, –filePath, –backupFolderPath options, at least one set of these is required
–doNotRemoveTemp will leave behind the corella_temp directory in each backupFolderPath
Example
corella.exe backup –phpBinPath=”/path/to/bin/php” –type=”npm” –filePath=”/path/to/package.json” –backupFolderPath=”/path/to/npmBackup” –type=”composer” –filePath=”/path/to/composer.json” –backupFolderPath=”/path/to/composerBackup”
Notes
composer install is RAM hungry. If it runs out of memory, the tool tends to just crash
Add it to a batch/bash script with paths to all of your projects, and run it whenever you like, or add it to your task scheduler
PHP must have openssl module enabled , and if on windows the MS Visual C++ 2015 redistributable must be installed
backupFolderPath will be written to and deleted from by the backup process so don’t point it anywhere important
It’s not the greatest tool, but it’s handy if you want to keep your own copies of the packages you use in case they get unpublished. For more complex projects or for finer control over which versions of dependencies are used, or for maintainng your own copies of a packages full history, a caching package proxy like Verdaccio (NPM) or Satis (composer) might be better
If this program gives your errors, let me know. Pretty much everything it does is based on hacky workarounds (npm and composer were not meant to be bundled and used this way!), but I’ll take a look at them and see what I can do.
Download (64 bit only)
1.0.0 Windows
1.0.0 Mac
1.0.0 Linux
Provided ‘as-is’ with no warranty expressed or implied. I assume no liability or responsibility for any damage this software causes. Use at your own risk. Find this useful? Drop me an email and let me know 🙂

Leave a Reply