|
1 | 1 | # Auto-PM |
2 | 2 |
|
3 | | -Auto-PM is a CLI tool to detect the package manager in a project and run commands accordingly. |
| 3 | +Auto-PM is a CLI tool that automatically detects the package manager (npm, yarn, pnpm, bun, deno) in your project and runs commands accordingly. This allows you to use a consistent command (`auto`) across different projects without worrying about which package manager is in use. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Automatically detects npm, yarn, pnpm, bun, and deno. |
| 8 | +- Seamlessly runs package manager commands. |
| 9 | +- Supports executing packages with `auto x <package>` (equivalent to `npx`, `yarn dlx`, `pnpm dlx`, `bun x`, `deno run -A`). |
4 | 10 |
|
5 | 11 | ## Installation |
6 | 12 |
|
| 13 | +### Global Installation (Recommended) |
| 14 | + |
| 15 | +Install `auto-pm` globally to use the `auto` command in any project: |
| 16 | + |
7 | 17 | ```bash |
8 | 18 | npm install -g auto-pm |
9 | 19 | ``` |
10 | 20 |
|
11 | | -## Usage |
| 21 | +### Local Installation |
| 22 | + |
| 23 | +You can also install `auto-pm` as a dev dependency in a specific project: |
12 | 24 |
|
13 | 25 | ```bash |
14 | | -auto <command> [args...] |
| 26 | +npm install --save-dev auto-pm |
15 | 27 | ``` |
16 | 28 |
|
17 | | -- `x`: Runs a command using the appropriate package manager (e.g., `npx`, `yarn dlx`, etc.). |
18 | | -- Other commands are passed directly to the detected package manager. |
| 29 | +Then you can run it via `npx auto ...` or by adding it to your `package.json` scripts. |
19 | 30 |
|
20 | | -## Development |
| 31 | +## Usage |
21 | 32 |
|
22 | | -### Build |
| 33 | +Once installed globally, you can use the `auto` command in any project directory that uses a supported package manager. |
23 | 34 |
|
24 | | -```bash |
25 | | -npm run build |
26 | | -``` |
| 35 | +### Basic Commands |
27 | 36 |
|
28 | | -### Test |
| 37 | +- `auto install`: Installs project dependencies (e.g., runs `npm install`, `yarn install`, etc.). |
| 38 | +- `auto add <package>`: Adds a new package (e.g., runs `npm install <package>`, `yarn add <package>`, etc.). |
| 39 | +- `auto remove <package>`: Removes a package (e.g., runs `npm uninstall <package>`, `yarn remove <package>`, etc.). |
| 40 | +- `auto run <script>`: Runs a script defined in your `package.json` (e.g., runs `npm run <script>`, `yarn <script>`, etc.). |
29 | 41 |
|
30 | | -```bash |
31 | | -npm test |
32 | | -``` |
| 42 | +### Executing Packages (like npx) |
33 | 43 |
|
34 | | -### Lint |
| 44 | +The `auto x` command allows you to execute packages without installing them globally, similar to `npx`, `yarn dlx`, `pnpm dlx`, `bun x`, or `deno run -A`. |
35 | 45 |
|
36 | 46 | ```bash |
37 | | -npm run lint |
| 47 | +auto x create-react-app my-app |
| 48 | +auto x cowsay "Hello World" |
38 | 49 | ``` |
39 | 50 |
|
40 | | -### Format |
| 51 | +### Passing Arguments |
| 52 | + |
| 53 | +Arguments are passed through to the underlying package manager command: |
41 | 54 |
|
42 | 55 | ```bash |
43 | | -npm run format |
| 56 | +auto add typescript --dev |
| 57 | +auto run build --watch |
44 | 58 | ``` |
45 | 59 |
|
| 60 | +## How it Works |
| 61 | + |
| 62 | +`auto-pm` detects the package manager by looking for specific lock files or configuration files in the current directory and its parent directories: |
| 63 | + |
| 64 | +- `yarn.lock` for Yarn |
| 65 | +- `package-lock.json` for npm |
| 66 | +- `pnpm-lock.yaml` for pnpm |
| 67 | +- `bun.lockb` or `bun.lock` for Bun |
| 68 | +- `deno.json` or `deno.jsonc` for Deno |
| 69 | + |
| 70 | +If no lock file is found, it will throw an error. |
| 71 | + |
| 72 | +## Supported Package Managers |
| 73 | + |
| 74 | +- npm |
| 75 | +- Yarn |
| 76 | +- pnpm |
| 77 | +- Bun |
| 78 | +- Deno |
| 79 | + |
| 80 | +## Contributing |
| 81 | + |
| 82 | +Contributions are welcome! Please feel free to submit a pull request or open an issue if you have suggestions or find a bug. |
| 83 | + |
| 84 | +1. Fork the repository. |
| 85 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`). |
| 86 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`). |
| 87 | +4. Push to the branch (`git push origin feature/AmazingFeature`). |
| 88 | +5. Open a Pull Request. |
| 89 | + |
46 | 90 | ## License |
47 | 91 |
|
48 | | -This project is licensed under the MIT License. |
| 92 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments