Skip to content

Commit 94daede

Browse files
committed
feat: Universal package manager wrapper (xpm)
A smart CLI tool that unifies npm/yarn/pnpm/bun commands with automatic detection. Features: - Auto-detects package manager from lockfiles and package.json - Unifies commands across all package managers (add/remove/upgrade) - Supports workspaces and monorepos with smart command routing - Works from any subdirectory in the project - Auto-syncs dependencies when lockfile changes - Unifies dev dependency flags (-D/--save-dev/--dev) - Smart script detection for npm (auto-adds 'run' prefix) - Lightweight implementation under 400 lines of TypeScript - Zero dependencies, uses only Node.js built-ins
0 parents  commit 94daede

19 files changed

Lines changed: 672 additions & 0 deletions

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.0.1/schema.json",
3+
"access": "public",
4+
"privatePackages": { "version": false }
5+
}

.github/workflows/changeset.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Changesets
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
concurrency: ${{ github.workflow }}-${{ github.ref }}
8+
9+
permissions:
10+
id-token: write
11+
contents: write
12+
pull-requests: write
13+
14+
env:
15+
CI: true
16+
17+
jobs:
18+
version:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 1
25+
26+
- name: Install pnpm
27+
uses: pnpm/action-setup@v4
28+
29+
- name: Setup node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 22
33+
cache: "pnpm"
34+
35+
- name: Cache turbo build setup
36+
uses: actions/cache@v4
37+
with:
38+
path: .turbo
39+
key: ${{ runner.os }}-turbo-${{ github.sha }}
40+
restore-keys: |
41+
${{ runner.os }}-turbo-
42+
43+
- name: Install dependencies
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: Create and publish versions
47+
uses: changesets/action@v1
48+
with:
49+
commit: "chore: update versions"
50+
title: "chore: update versions"
51+
version: pnpm ci:version
52+
publish: pnpm ci:publish
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules/
2+
dist/
3+
*.log
4+
.DS_Store
5+
coverage/
6+
.env
7+
.vscode/
8+
.idea/
9+
*.swp
10+
*.swo
11+
*~

.npmignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
src/
2+
tsconfig.json
3+
.gitignore
4+
*.log
5+
.DS_Store
6+
coverage/
7+
.env
8+
.vscode/
9+
.idea/
10+
*.swp
11+
*.swo
12+
*~
13+
SPEC.md

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Assistant UI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# xpm - Universal Package Manager CLI
2+
3+
`xpm` is built for those who work across multiple projects with different package managers. You can use `xpm` instead of `npm`/`yarn`/`pnpm`/`bun`. `xpm` invokes the right package manager for you. Additonally, it installs package dependencies if you forgot to do it.
4+
5+
For example, when you run `xpm dev` in a project:
6+
7+
- xpm detects the package manager
8+
- auto-installs dependencies if necessary (compares lockfile hash)
9+
- runs `npm run dev` / `yarn dev` / `pnpm dev` / `bun dev`
10+
11+
## Install
12+
13+
```bash
14+
npm install -g @assistant-ui/xpm
15+
```
16+
17+
## Features
18+
19+
- 🔍 **Auto-detects** your package manager from lockfiles or package.json
20+
-**Dependency sync** - auto-installs dependencies when lockfile changes
21+
- 🎯 **Unified commands** - identical commands across all package managers
22+
- 📦 **Workspace aware** - correctly handles monorepo operations
23+
- 🏃 **Runs from anywhere** - works in project subdirectories
24+
25+
26+
## Usage
27+
28+
```bash
29+
xpm # Install dependencies
30+
xpm add react # Add a package
31+
xpm dev # Run a script
32+
```
33+
34+
35+
## License
36+
37+
MIT

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "@assistant-ui/xpm",
3+
"version": "0.0.1",
4+
"description": "Universal package manager wrapper that automatically detects and uses the right package manager",
5+
"main": "dist/index.js",
6+
"bin": {
7+
"xpm": "./dist/cli.js"
8+
},
9+
"scripts": {
10+
"build": "tsc",
11+
"dev": "tsc --watch",
12+
"prepublishOnly": "npm run build",
13+
"test": "echo \"No tests yet\"",
14+
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
15+
"ci:publish": "npm publish --access public"
16+
},
17+
"keywords": [
18+
"package-manager",
19+
"npm",
20+
"yarn",
21+
"pnpm",
22+
"bun",
23+
"cli",
24+
"wrapper",
25+
"universal"
26+
],
27+
"author": "AgentbaseAI Inc.",
28+
"license": "MIT",
29+
"devDependencies": {
30+
"@types/node": "^22.18.1",
31+
"typescript": "^5.9.2"
32+
},
33+
"files": [
34+
"dist",
35+
"README.md"
36+
],
37+
"engines": {
38+
"node": ">=14.0.0"
39+
},
40+
"repository": {
41+
"type": "git",
42+
"url": "https://github.com/assistant-ui/xpm"
43+
},
44+
"bugs": {
45+
"url": "https://github.com/assistant-ui/xpm/issues"
46+
},
47+
"homepage": "https://github.com/assistant-ui/xpm#readme",
48+
"packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
49+
}

pnpm-lock.yaml

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
3+
import { XPM } from './xpm';
4+
5+
const args = process.argv.slice(2);
6+
const xpm = new XPM(args);
7+
xpm.run();

0 commit comments

Comments
 (0)