rugby
v0.1.2
Published
A Node.js CLI to collect npm package tarballs and assets (including those fetched by pre/postinstall scripts) for offline Artifactory use.
Maintainers
Readme
rugby
Collect npm package tarballs and install-script assets for offline installs and air‑gapped environments (e.g., publish to JFrog Artifactory or use a local cache/server).
Requirements
- Node.js >= 20
- npm
Install (from npm)
npm install -g rugbyInstall (from source)
git clone <repo>
cd arti-bundle
npm i
npm link # or run via ./bin/rugby.jsCLI
rugby --dir <projectDir> --out <outputDir> [--list-only] [--verbose] [--npm <path>] [--npm-args "..."]Options:
--dir: Project directory withpackage.jsonandpackage-lock.json(default: current dir)--out: Output folder (default:./out). Prompted to create if missing--list-only: Do not download; show dependency tree and install-script assets/packages--npm: Path to npm (auto-resolved)--npm-args: Extra args for npm when simulating scripts (e.g.,--registry)--verbose: Verbose output
What rugby does
- Reads
package-lock.json(v2 preferred) and enumerates all resolved packages (preserving multiple versions). - Installs with
--ignore-scriptsand then runs only lifecycle scripts vianpm rebuildin a sandbox, while:- Capturing Node
http/httpsrequests (NODE_OPTIONS hook) - Shimming
curl/wgetto log/capture payloads - Diffing
node_modulesbefore/after to flag packages installed by scripts
- Capturing Node
- Downloads all package tarballs to
out/packages/and copies captured assets toout/assets/. - Writes
out/NEXT_STEPS.txtwith offline install instructions (local cache or Artifactory) for macOS/Linux and Windows.
Fast start
List only:
rugby --dir /path/to/your/project --list-onlyFull export:
rugby --dir /path/to/your/project --out /path/to/out --verboseOffline install options
After a successful export, see out/NEXT_STEPS.txt. Summary below.
Option A: local npm cache (no registry)
- macOS/Linux
export CACHE=/abs/path/to/cache
export PKGS=/abs/path/to/out/packages
mkdir -p "$CACHE"
for f in "$PKGS"/*.tgz; do npm cache add --cache "$CACHE" "$f"; done
cd /abs/path/to/project
rm -rf node_modules
npm ci --cache "$CACHE" --prefer-offline --offline- Windows PowerShell
$env:CACHE = "C:\path\to\cache"
$env:PKGS = "C:\path\to\out\packages"
New-Item -ItemType Directory -Force -Path $env:CACHE | Out-Null
Get-ChildItem -Path $env:PKGS -Filter *.tgz | ForEach-Object { npm cache add --cache $env:CACHE $_.FullName }
cd C:\path\to\project
rmdir /s /q node_modules 2>$null
npm ci --cache "$env:CACHE" --prefer-offline --offlineOption B: Artifactory (npm repo for tarballs, generic repo or local hosting for assets)
- Publish tarballs to Artifactory npm repo
export REG=https://artifactory.example.com/artifactory/api/npm/your-npm-repo/
npm set registry "$REG"
for f in "/abs/path/to/out/packages"/*.tgz; do npm publish "$f" --registry "$REG" || true; done- Upload assets to Generic repo
export GEN=https://artifactory.example.com/artifactory/generic-assets/
for f in "/abs/path/to/out/assets"/*; do curl -u <user:api_key> -T "$f" "$GEN$(basename "$f")"; done- Alternative: host assets locally (no Artifactory)
ASSETS=/abs/path/to/out/assets
(cd "$ASSETS" && python3 -m http.server 9000) & SERVE_PID=$!
export npm_config_bcrypt_binary_host_mirror=http://127.0.0.1:9000/
export SHARP_DIST_BASE_URL=http://127.0.0.1:9000/
export SASS_BINARY_SITE=http://127.0.0.1:9000/
# run npm ci in your project, then:
kill $SERVE_PID- Configure project to use Artifactory npm + assets
npm config set registry https://artifactory.example.com/artifactory/api/npm/your-npm-repo/
export npm_config_bcrypt_binary_host_mirror=https://artifactory.example.com/artifactory/generic-assets/
export SHARP_DIST_BASE_URL=https://artifactory.example.com/artifactory/generic-assets/
export SASS_BINARY_SITE=https://artifactory.example.com/artifactory/generic-assets/Notes & limitations
- Capturing non-HTTP(S) custom downloaders beyond curl/wget may require extending shims.
- Script-installed packages are detected and their network downloads are captured, but their tarballs are not yet auto-added to
out/packages/if not present in the lockfile (planned enhancement). - Works best with npm lockfile v2+.
License
MIT
