@carbonellai/snpm
v1.0.0
Published
Smart NPM - pnpm wrapper with dynamic script execution
Maintainers
Readme
@carbonellai/snpm
Smart NPM - pnpm wrapper with dynamic script execution from scripts/ workspace.
The Magic
Drop any script in scripts/ → instantly available. No package.json updates needed.
scripts/
├── deploy.js # Flat file → snpm deploy
├── quick-check.ts # TypeScript → snpm quick-check
├── analyze.mjs # ESM → snpm analyze
└── complex-tool/ # Package → snpm complex-tool
├── package.json
├── cli.js
└── lib/Add more scripts → automatically available.
Usage
Execute any script in scripts/:
snpm deploy --env production
snpm quick-check --target api
snpm analyze --depth deep
snpm complex-tool --watchAll other commands pass through to pnpm:
snpm install
snpm add express
snpm testHow It Works
snpm <command> [args]
↓
Scans scripts/ for:
• Flat files: *.js, *.mjs, *.cjs, *.ts
• Packages: */package.json with bin field
↓
Match found?
↓
YES: Execute with node/tsx [args]
↓
NO: Pass to pnpm → pnpm <command> [args]Discovery
Flat files: deploy.js → command deploy
Packages: Directory name or package name → command
Supported formats:
.js,.mjs,.cjs→ executed withnode.ts→ executed withtsx- Package with
binfield → executed perbinconfig
Examples
Flat File Script
scripts/deploy.js:
#!/usr/bin/env node
const env = process.argv.find(arg => arg.startsWith('--env='));
console.log(`Deploying to ${env || 'staging'}...`);Use immediately:
snpm deploy --env=production
snpm deploy --env=stagingTypeScript Script
scripts/analyze.ts:
#!/usr/bin/env tsx
const depth = process.argv.find(arg => arg.startsWith('--depth='))?.split('=')[1];
console.log(`Analyzing with depth: ${depth}...`);Use immediately:
snpm analyze --depth=deepComplex Packaged Script
scripts/complex-tool/package.json:
{
"name": "complex-tool",
"version": "1.0.0",
"bin": {
"complex-tool": "./cli.js"
}
}scripts/complex-tool/cli.js:
#!/usr/bin/env node
import { someLib } from './lib/utils.js';
// ... complex logic with dependenciesUse immediately:
snpm complex-tool --watchInstall
pnpm install -g @carbonellai/snpmOr use from workspace:
pnpm --filter @carbonellai/snpm link --globalBenefits
✓ No hardcoding - Scripts auto-discovered on every invocation
✓ Zero config - Drop scripts in, they just work
✓ TypeScript support - .ts files executed via tsx
✓ Flexible - Flat files or full packages
✓ Full pnpm compatibility - All non-script commands pass through
✓ Extensible - Add new scripts, instantly available
