x-package-manager 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/bin/xpm.sh +41 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# xpm
|
|
2
|
+
|
|
3
|
+
Cross-package-manager executor - automatically detects and runs the right package manager (npm, yarn, or pnpm) based on your project's lock files.
|
|
4
|
+
|
|
5
|
+
## Why?
|
|
6
|
+
|
|
7
|
+
Tired of remembering which package manager each project uses? `xpm` detects it automatically by looking for lock files and runs the appropriate command.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### Global Installation (Recommended)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g x-package-manager
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Standalone Script
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -o xpm https://raw.githubusercontent.com/janicduplessis/xpm/main/bin/xpm.sh
|
|
21
|
+
chmod +x xpm
|
|
22
|
+
mv xpm /usr/local/bin/
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Use `xpm` exactly as you would use npm, yarn, or pnpm:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Install dependencies
|
|
31
|
+
xpm install
|
|
32
|
+
|
|
33
|
+
# Add a package
|
|
34
|
+
xpm add react
|
|
35
|
+
|
|
36
|
+
# Run scripts
|
|
37
|
+
xpm run build
|
|
38
|
+
xpm test
|
|
39
|
+
|
|
40
|
+
# Any other command
|
|
41
|
+
xpm --version
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## How It Works
|
|
45
|
+
|
|
46
|
+
`xpm` walks up the directory tree from your current location looking for lock files:
|
|
47
|
+
|
|
48
|
+
- `pnpm-lock.yaml` → uses **pnpm**
|
|
49
|
+
- `yarn.lock` → uses **yarn**
|
|
50
|
+
- `package-lock.json` → uses **npm**
|
|
51
|
+
|
|
52
|
+
If no lock file is found, it defaults to **npm**.
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Bash (included on macOS and Linux)
|
|
57
|
+
- At least one of: npm, yarn, or pnpm installed
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/bin/xpm.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
detect_package_manager() {
|
|
6
|
+
local dir="$PWD"
|
|
7
|
+
|
|
8
|
+
# Walk up the directory tree looking for lock files
|
|
9
|
+
while [[ "$dir" != "/" ]]; do
|
|
10
|
+
if [[ -f "$dir/pnpm-lock.yaml" ]]; then
|
|
11
|
+
echo "pnpm"
|
|
12
|
+
return
|
|
13
|
+
elif [[ -f "$dir/yarn.lock" ]]; then
|
|
14
|
+
echo "yarn"
|
|
15
|
+
return
|
|
16
|
+
elif [[ -f "$dir/package-lock.json" ]]; then
|
|
17
|
+
echo "npm"
|
|
18
|
+
return
|
|
19
|
+
fi
|
|
20
|
+
dir=$(dirname "$dir")
|
|
21
|
+
done
|
|
22
|
+
|
|
23
|
+
# Default to npm if no lock file found
|
|
24
|
+
echo "npm"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main() {
|
|
28
|
+
local pm
|
|
29
|
+
pm=$(detect_package_manager)
|
|
30
|
+
|
|
31
|
+
# Check if the package manager is available
|
|
32
|
+
if ! command -v "$pm" &> /dev/null; then
|
|
33
|
+
echo "Error: $pm is not installed" >&2
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Execute the package manager with all provided arguments
|
|
38
|
+
exec "$pm" "$@"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main "$@"
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "x-package-manager",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cross-package-manager executor - automatically detects and runs npm, yarn, or pnpm based on your project",
|
|
5
|
+
"bin": {
|
|
6
|
+
"xpm": "./bin/xpm.sh"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"package-manager",
|
|
13
|
+
"npm",
|
|
14
|
+
"yarn",
|
|
15
|
+
"pnpm",
|
|
16
|
+
"executor",
|
|
17
|
+
"wrapper"
|
|
18
|
+
],
|
|
19
|
+
"author": "Janic Duplessis",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/janicduplessis/xpm.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/janicduplessis/xpm/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/janicduplessis/xpm#readme"
|
|
29
|
+
}
|