pm-auto 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/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/build_command.d.ts +7 -0
- package/dist/build_command.d.ts.map +1 -0
- package/dist/build_command.js +97 -0
- package/dist/build_command.js.map +1 -0
- package/dist/config_path.d.ts +4 -0
- package/dist/config_path.d.ts.map +1 -0
- package/dist/config_path.js +43 -0
- package/dist/config_path.js.map +1 -0
- package/dist/config_reader.d.ts +13 -0
- package/dist/config_reader.d.ts.map +1 -0
- package/dist/config_reader.js +96 -0
- package/dist/config_reader.js.map +1 -0
- package/dist/display.d.ts +8 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +29 -0
- package/dist/display.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +6 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +38 -0
- package/dist/install.js.map +1 -0
- package/dist/orchestrator.d.ts +2 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +48 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/nodemon.json +6 -0
- package/package.json +38 -0
- package/src/build_command.ts +119 -0
- package/src/config_path.ts +54 -0
- package/src/config_reader.ts +119 -0
- package/src/display.ts +33 -0
- package/src/index.ts +45 -0
- package/src/install.ts +40 -0
- package/src/orchestrator.ts +71 -0
- package/src/types/index.ts +16 -0
- package/test.json +83 -0
- package/tsconfig.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Elliot Otoijagha
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# PM-Auto
|
|
2
|
+
|
|
3
|
+
A CLI tool for automated npm, yarn, and pnpm package installation across multiple package managers.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Quick Start](#quick-start)
|
|
9
|
+
- [Commands](#commands)
|
|
10
|
+
- [install](#install)
|
|
11
|
+
- [uninstall](#uninstall)
|
|
12
|
+
- [config](#config)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [Configuration File Structure](#configuration-file-structure)
|
|
15
|
+
- [Configuration Properties](#configuration-properties)
|
|
16
|
+
- [Setting Up Your Config](#setting-up-your-config)
|
|
17
|
+
- [Global Options](#global-options)
|
|
18
|
+
- [Use Cases](#use-cases)
|
|
19
|
+
- [Contributing](#contributing)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g pm-auto
|
|
25
|
+
# or
|
|
26
|
+
pnpm add -g pm-auto
|
|
27
|
+
# or
|
|
28
|
+
yarn global add pm-auto
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
1. **Create a configuration file** in any directory (e.g., `config.json` or `test.json`)
|
|
34
|
+
|
|
35
|
+
2. **Set the config file path** using a relative path from your current working directory:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Example: If you're in C:\Users\admin\Documents and your config is test.json
|
|
39
|
+
C:\Users\admin\Documents> pm-auto config ./test.json
|
|
40
|
+
|
|
41
|
+
# Example: If your config is in a subdirectory
|
|
42
|
+
pm-auto config ./my-configs/config.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. **Start installing packages**:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Install packages from your config
|
|
49
|
+
pm-auto install
|
|
50
|
+
|
|
51
|
+
# Install specific packages
|
|
52
|
+
pm-auto install express lodash
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> **⚠️ Important:** If you move your config file to a different location, you must set the path again using `pm-auto config <new-path>`
|
|
56
|
+
|
|
57
|
+
## Commands
|
|
58
|
+
|
|
59
|
+
### `install`
|
|
60
|
+
|
|
61
|
+
Install packages across configured package managers.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pm-auto install [options] [packages...]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Options:**
|
|
68
|
+
|
|
69
|
+
- `-p, --pkg-json` - Install all packages from package.json
|
|
70
|
+
- `-A, --add-command <command>` - Add a custom command to all installation commands from config file
|
|
71
|
+
- `-D, --dry-run` - Display commands before execution without running them
|
|
72
|
+
- `-h, --help` - Display help
|
|
73
|
+
|
|
74
|
+
**Examples:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Install single package
|
|
78
|
+
pm-auto install express
|
|
79
|
+
|
|
80
|
+
# Install multiple packages
|
|
81
|
+
pm-auto install express lodash axios
|
|
82
|
+
|
|
83
|
+
# Install from package.json
|
|
84
|
+
pm-auto install --pkg-json
|
|
85
|
+
|
|
86
|
+
# Dry run to see what would be executed
|
|
87
|
+
pm-auto install express --dry-run
|
|
88
|
+
|
|
89
|
+
# Add custom flag to all installations
|
|
90
|
+
pm-auto install express --add-command "--legacy-peer-deps"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### `uninstall`
|
|
94
|
+
|
|
95
|
+
Uninstall packages from configured package managers.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pm-auto uninstall [options] <packages...>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Options:**
|
|
102
|
+
|
|
103
|
+
- `-A, --add-command <command>` - Add a custom command to all uninstallation commands from config file
|
|
104
|
+
- `-h, --help` - Display help
|
|
105
|
+
|
|
106
|
+
**Examples:**
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Uninstall single package
|
|
110
|
+
pm-auto uninstall lodash
|
|
111
|
+
|
|
112
|
+
# Uninstall multiple packages
|
|
113
|
+
pm-auto uninstall lodash express axios
|
|
114
|
+
|
|
115
|
+
# Add custom flag to uninstallation
|
|
116
|
+
pm-auto uninstall lodash --add-command "--force"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `config`
|
|
120
|
+
|
|
121
|
+
Set the path to your configuration file.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pm-auto config <path>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Options:**
|
|
128
|
+
|
|
129
|
+
- `-h, --help` - Display help
|
|
130
|
+
|
|
131
|
+
**Examples:**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Set config file path
|
|
135
|
+
pm-auto config ./pm-auto.config.json
|
|
136
|
+
|
|
137
|
+
# Use absolute path
|
|
138
|
+
pm-auto config /home/user/project/pm-auto.config.json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Configuration
|
|
142
|
+
|
|
143
|
+
pm-auto uses a configuration file to define project presets with specific package managers and packages.
|
|
144
|
+
|
|
145
|
+
### Configuration File Structure
|
|
146
|
+
|
|
147
|
+
Create a JSON file (e.g., `config.json`) with the following format:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"vite": {
|
|
152
|
+
"name": "vite",
|
|
153
|
+
"packageManager": "npm",
|
|
154
|
+
"packages": [
|
|
155
|
+
{
|
|
156
|
+
"command": "@types/three --save-dev",
|
|
157
|
+
"interactive": false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"command": "@react-three/fiber",
|
|
161
|
+
"interactive": false
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"command": "gsap",
|
|
165
|
+
"interactive": false
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"command": "create-vite@latest my-app",
|
|
169
|
+
"interactive": true
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
"express-api": {
|
|
174
|
+
"name": "express-api",
|
|
175
|
+
"packageManager": "pnpm",
|
|
176
|
+
"packages": [
|
|
177
|
+
{
|
|
178
|
+
"command": "express",
|
|
179
|
+
"interactive": false
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"command": "dotenv",
|
|
183
|
+
"interactive": false
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Configuration Properties
|
|
191
|
+
|
|
192
|
+
- **`name`** - Identifier for the project preset
|
|
193
|
+
- **`packageManager`** - Package manager to use (`npm`, `yarn`, or `pnpm`)
|
|
194
|
+
- **`packages`** - Array of package installation configurations
|
|
195
|
+
- **`command`** - The package name and any additional flags (e.g., `lodash`, `typescript --save-dev`)
|
|
196
|
+
- **`interactive`** - Set to `true` for commands that require user interaction (e.g., `create-vite@latest`)
|
|
197
|
+
|
|
198
|
+
### Setting Up Your Config
|
|
199
|
+
|
|
200
|
+
1. Create your config file in any directory
|
|
201
|
+
2. Set the path using relative paths from your current working directory:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# From C:\Users\admin\Documents
|
|
205
|
+
C:\Users\admin\Documents> pm-auto config ./test.json
|
|
206
|
+
|
|
207
|
+
# From a project directory
|
|
208
|
+
/home/user/projects/my-app> pm-auto config ../configs/pm-auto-config.json
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
3. Verify the configuration is set correctly by running a dry run:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pm-auto install --dry-run
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> **📝 Note:** The config path is stored persistently. If you move the config file, remember to update the path using `pm-auto config <new-path>` again.
|
|
218
|
+
|
|
219
|
+
## Global Options
|
|
220
|
+
|
|
221
|
+
- `-V, --version` - Output the version number
|
|
222
|
+
- `-h, --help` - Display help for command
|
|
223
|
+
|
|
224
|
+
## Use Cases
|
|
225
|
+
|
|
226
|
+
### Multi-Project Development
|
|
227
|
+
|
|
228
|
+
When working on projects that use different package managers, pm-auto ensures packages are installed consistently across all of them.
|
|
229
|
+
|
|
230
|
+
### Package Testing
|
|
231
|
+
|
|
232
|
+
Test your package installation across multiple package managers to ensure compatibility.
|
|
233
|
+
|
|
234
|
+
## Contributing
|
|
235
|
+
|
|
236
|
+
We welcome contributions! Here's how you can help:
|
|
237
|
+
|
|
238
|
+
### Getting Started
|
|
239
|
+
|
|
240
|
+
1. **Fork the repository**
|
|
241
|
+
2. **Clone your fork:**
|
|
242
|
+
```bash
|
|
243
|
+
git clone https://github.com/your-username/pm-auto.git
|
|
244
|
+
cd pm-auto
|
|
245
|
+
```
|
|
246
|
+
3. **Install dependencies:**
|
|
247
|
+
```bash
|
|
248
|
+
npm install
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Development Workflow
|
|
252
|
+
|
|
253
|
+
1. **Create a new branch:**
|
|
254
|
+
```bash
|
|
255
|
+
git checkout -b feature/your-feature-name
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
2. **Make your changes**
|
|
259
|
+
- Write clean, readable code
|
|
260
|
+
- Follow existing code style and conventions
|
|
261
|
+
- Add tests if applicable
|
|
262
|
+
|
|
263
|
+
3. **Test your changes:**
|
|
264
|
+
```bash
|
|
265
|
+
npm test
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
4. **Commit your changes:**
|
|
269
|
+
```bash
|
|
270
|
+
git add .
|
|
271
|
+
git commit -m "feat: add your feature description"
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Commit message format:**
|
|
275
|
+
- `feat:` for new features
|
|
276
|
+
- `fix:` for bug fixes
|
|
277
|
+
- `docs:` for documentation changes
|
|
278
|
+
- `refactor:` for code refactoring
|
|
279
|
+
- `test:` for adding tests
|
|
280
|
+
- `chore:` for maintenance tasks
|
|
281
|
+
|
|
282
|
+
5. **Push to your fork:**
|
|
283
|
+
```bash
|
|
284
|
+
git push origin feature/your-feature-name
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
6. **Open a Pull Request** from your fork to the main repository
|
|
288
|
+
|
|
289
|
+
### Pull Request Guidelines
|
|
290
|
+
|
|
291
|
+
- Provide a clear description of the changes
|
|
292
|
+
- Reference any related issues
|
|
293
|
+
- Ensure all tests pass
|
|
294
|
+
- Update documentation if needed
|
|
295
|
+
- Keep PRs focused on a single feature or fix
|
|
296
|
+
|
|
297
|
+
### Reporting Issues
|
|
298
|
+
|
|
299
|
+
Found a bug or have a feature request?
|
|
300
|
+
|
|
301
|
+
1. Check if the issue already exists
|
|
302
|
+
2. If not, create a new issue with:
|
|
303
|
+
- Clear title and description
|
|
304
|
+
- Steps to reproduce (for bugs)
|
|
305
|
+
- Expected vs actual behavior
|
|
306
|
+
- Environment details (OS, Node version, etc.)
|
|
307
|
+
|
|
308
|
+
### Code of Conduct
|
|
309
|
+
|
|
310
|
+
- Be respectful and inclusive
|
|
311
|
+
- Provide constructive feedback
|
|
312
|
+
- Focus on the code, not the person
|
|
313
|
+
|
|
314
|
+
Thank you for contributing to pm-auto! 🎉
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConfigType, CommandResult } from "./types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build commands from project configurations.
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildCommands(projects: ConfigType[]): CommandResult[];
|
|
6
|
+
export declare function buildUninstallCommands(projects: ConfigType[]): CommandResult[];
|
|
7
|
+
//# sourceMappingURL=build_command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_command.d.ts","sourceRoot":"","sources":["../src/build_command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE/E;;GAEG;AAEH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,mBA6DnD;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,UAAU,EAAE,mBAiD5D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build commands from project configurations.
|
|
3
|
+
*/
|
|
4
|
+
export function buildCommands(projects) {
|
|
5
|
+
// Initialize arrays properly
|
|
6
|
+
const commandArray = [];
|
|
7
|
+
for (const project of projects) {
|
|
8
|
+
const { packageManager, packages } = project;
|
|
9
|
+
const commandPrefixes = {
|
|
10
|
+
npm: {
|
|
11
|
+
install: "npm install",
|
|
12
|
+
run: "npx",
|
|
13
|
+
},
|
|
14
|
+
pnpm: {
|
|
15
|
+
install: "pnpm add",
|
|
16
|
+
run: "pnpm dlx",
|
|
17
|
+
},
|
|
18
|
+
yarn: {
|
|
19
|
+
install: "yarn add",
|
|
20
|
+
run: "yarn dlx",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
const manager = commandPrefixes[packageManager] ||
|
|
24
|
+
commandPrefixes.npm;
|
|
25
|
+
const result = {
|
|
26
|
+
name: project.name,
|
|
27
|
+
interactive: [],
|
|
28
|
+
nonInteractive: [],
|
|
29
|
+
};
|
|
30
|
+
// Separate interactive from non-interactive packages
|
|
31
|
+
const nonInteractive = [];
|
|
32
|
+
const interactive = [];
|
|
33
|
+
if (packages) {
|
|
34
|
+
packages.forEach((pkg) => {
|
|
35
|
+
if (pkg.interactive) {
|
|
36
|
+
interactive.push(pkg);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
nonInteractive.push(pkg);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// Add interactive packages as separate commands (sequential)
|
|
44
|
+
interactive.forEach((pkg) => {
|
|
45
|
+
result.interactive.push(`${manager.run} ${pkg.command}`);
|
|
46
|
+
});
|
|
47
|
+
// Batch all non-interactive packages into ONE command
|
|
48
|
+
if (nonInteractive.length > 0) {
|
|
49
|
+
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
50
|
+
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
51
|
+
}
|
|
52
|
+
commandArray.push(result);
|
|
53
|
+
}
|
|
54
|
+
return commandArray;
|
|
55
|
+
}
|
|
56
|
+
export function buildUninstallCommands(projects) {
|
|
57
|
+
const commandArray = [];
|
|
58
|
+
for (const project of projects) {
|
|
59
|
+
const { packageManager, packages } = project;
|
|
60
|
+
const commandPrefixes = {
|
|
61
|
+
npm: {
|
|
62
|
+
install: "npm uninstall",
|
|
63
|
+
},
|
|
64
|
+
pnpm: {
|
|
65
|
+
install: "pnpm uninstall",
|
|
66
|
+
},
|
|
67
|
+
yarn: {
|
|
68
|
+
install: "yarn remove",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
const manager = commandPrefixes[packageManager] ||
|
|
72
|
+
commandPrefixes.npm;
|
|
73
|
+
const result = {
|
|
74
|
+
name: project.name,
|
|
75
|
+
interactive: [],
|
|
76
|
+
nonInteractive: [],
|
|
77
|
+
};
|
|
78
|
+
// Separate interactive from non-interactive packages
|
|
79
|
+
const nonInteractive = [];
|
|
80
|
+
const interactive = [];
|
|
81
|
+
if (packages) {
|
|
82
|
+
packages.forEach((pkg) => {
|
|
83
|
+
if (!pkg.interactive) {
|
|
84
|
+
nonInteractive.push(pkg);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Batch all non-interactive packages into ONE command
|
|
89
|
+
if (nonInteractive.length > 0) {
|
|
90
|
+
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
91
|
+
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
92
|
+
}
|
|
93
|
+
commandArray.push(result);
|
|
94
|
+
}
|
|
95
|
+
return commandArray;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=build_command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_command.js","sourceRoot":"","sources":["../src/build_command.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,MAAM,UAAU,aAAa,CAAC,QAAsB;IAClD,6BAA6B;IAE7B,MAAM,YAAY,GAAoB,EAAE,CAAC;IACzC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAE7C,MAAM,eAAe,GAAG;YACtB,GAAG,EAAE;gBACH,OAAO,EAAE,aAAa;gBACtB,GAAG,EAAE,KAAK;aACX;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,UAAU;gBACnB,GAAG,EAAE,UAAU;aAChB;YACD,IAAI,EAAE;gBACJ,OAAO,EAAE,UAAU;gBACnB,GAAG,EAAE,UAAU;aAChB;SACF,CAAC;QAE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IAC5B,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_path.d.ts","sourceRoot":"","sources":["../src/config_path.ts"],"names":[],"mappings":"AAYA,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAgBvD;AAED,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAiB7C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAItC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import { display } from "./display.js";
|
|
5
|
+
const SETTINGS_DIR = path.join(os.homedir(), ".pm-auto");
|
|
6
|
+
const SETTINGS_FILE = path.join(SETTINGS_DIR, "settings.json");
|
|
7
|
+
export function saveConfigPath(configPath) {
|
|
8
|
+
// Create directory if it doesn't exist
|
|
9
|
+
if (!fs.existsSync(SETTINGS_DIR)) {
|
|
10
|
+
fs.mkdirSync(SETTINGS_DIR, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
//check if file exists
|
|
13
|
+
try {
|
|
14
|
+
const real = fs.realpathSync(configPath);
|
|
15
|
+
const settings = { configPath: real };
|
|
16
|
+
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
17
|
+
display(`Config file path saved: ${configPath}`, "success");
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
display(`Error saving config file: ${err.message}`, "error");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function getConfigPath() {
|
|
24
|
+
//check if settings exists
|
|
25
|
+
if (!fs.existsSync(SETTINGS_FILE)) {
|
|
26
|
+
display("Run `pm-auto config <path>`, where <path> is the path to your config file", "info");
|
|
27
|
+
display("Config file path not set", "error");
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const data = fs.readFileSync(SETTINGS_FILE, "utf8");
|
|
31
|
+
const settings = JSON.parse(data);
|
|
32
|
+
return settings.configPath || "";
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
display(`Error reading config file path: ${error.message}`, "error");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function clearConfigPath() {
|
|
39
|
+
if (fs.existsSync(SETTINGS_FILE)) {
|
|
40
|
+
fs.unlinkSync(SETTINGS_FILE);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=config_path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_path.js","sourceRoot":"","sources":["../src/config_path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AACzD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AAM/D,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,uCAAuC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,sBAAsB;IACtB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAa,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAChD,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEnE,OAAO,CAAC,2BAA2B,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC;IAC9D,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,6BAA6B,GAAG,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,0BAA0B;IAC1B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,OAAO,CACL,2EAA2E,EAC3E,MAAM,CACP,CAAC;QACF,OAAO,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAa,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,mCAAmC,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CommandResult, ConfigType } from "./types/index.js";
|
|
2
|
+
type PackageManager = "npm" | "yarn" | "pnpm";
|
|
3
|
+
/**
|
|
4
|
+
* Detect the package manager used in the project.
|
|
5
|
+
*/
|
|
6
|
+
export declare function detectPackageManager(projectPath?: string): PackageManager | void;
|
|
7
|
+
/**
|
|
8
|
+
* Get the installation commands from the config file, transforms into a js object and with the options given
|
|
9
|
+
* it modifies the object and returns it
|
|
10
|
+
*/
|
|
11
|
+
export declare const getConfigObject: (packages: string[], options?: any) => Promise<ConfigType[] | CommandResult[]>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=config_reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_reader.d.ts","sourceRoot":"","sources":["../src/config_reader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAIlE,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C;;GAEG;AAEH,wBAAgB,oBAAoB,CAClC,WAAW,GAAE,MAAsB,GAClC,cAAc,GAAG,IAAI,CAgBvB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAAE,EAClB,UAAU,GAAG,KACZ,OAAO,CAAC,UAAU,EAAE,GAAG,aAAa,EAAE,CA4ExC,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import { getConfigPath } from "./config_path.js";
|
|
3
|
+
import * as fsd from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { display } from "./display.js";
|
|
6
|
+
import { confirm } from "@inquirer/prompts";
|
|
7
|
+
/**
|
|
8
|
+
* Detect the package manager used in the project.
|
|
9
|
+
*/
|
|
10
|
+
export function detectPackageManager(projectPath = process.cwd()) {
|
|
11
|
+
// Check for lock files in order of specificity
|
|
12
|
+
if (fsd.existsSync(path.join(projectPath, "pnpm-lock.yaml"))) {
|
|
13
|
+
return "pnpm";
|
|
14
|
+
}
|
|
15
|
+
if (fsd.existsSync(path.join(projectPath, "yarn.lock"))) {
|
|
16
|
+
return "yarn";
|
|
17
|
+
}
|
|
18
|
+
if (fsd.existsSync(path.join(projectPath, "package-lock.json"))) {
|
|
19
|
+
return "npm";
|
|
20
|
+
}
|
|
21
|
+
// Default to npm if no lock file found
|
|
22
|
+
display("No Lock File Found", "error");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get the installation commands from the config file, transforms into a js object and with the options given
|
|
26
|
+
* it modifies the object and returns it
|
|
27
|
+
*/
|
|
28
|
+
export const getConfigObject = async (packages, options) => {
|
|
29
|
+
if (!options.pkgJson) {
|
|
30
|
+
const configPath = getConfigPath();
|
|
31
|
+
//read config file content
|
|
32
|
+
let configContent = "";
|
|
33
|
+
try {
|
|
34
|
+
configContent = await fs.readFile(configPath, "utf8");
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
display(`File not found ${error}`, "error");
|
|
38
|
+
}
|
|
39
|
+
const configObject = JSON.parse(configContent);
|
|
40
|
+
let result = Object.values(configObject);
|
|
41
|
+
//filter the packages the user wants to install
|
|
42
|
+
if (packages.length > 0) {
|
|
43
|
+
result = packages.map((pkg) => {
|
|
44
|
+
if (!configObject[pkg]) {
|
|
45
|
+
display(`Package ${pkg} not found in the configuration file`, "warning");
|
|
46
|
+
}
|
|
47
|
+
return configObject[pkg];
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/*
|
|
51
|
+
* Config object modification with the options given
|
|
52
|
+
*/
|
|
53
|
+
//Add command to previous configured commands (-A/-add-command)
|
|
54
|
+
if (options.addCommand) {
|
|
55
|
+
result.forEach((config) => {
|
|
56
|
+
config.packages.forEach((pkg) => {
|
|
57
|
+
pkg.command = pkg.interactive
|
|
58
|
+
? pkg.command
|
|
59
|
+
: pkg.command + " " + options.addCommand;
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//Dry run - Display commands before execution
|
|
64
|
+
if (options.dryRun) {
|
|
65
|
+
display("Dry Run:", "info");
|
|
66
|
+
result.forEach((config) => {
|
|
67
|
+
display(`Package name -> ${config.name}`, "info");
|
|
68
|
+
config.packages.forEach((pkg) => {
|
|
69
|
+
display(`add ${pkg.command}`, "info");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
const continueWithInstall = await confirm({
|
|
73
|
+
message: "Continue with installation?",
|
|
74
|
+
default: true,
|
|
75
|
+
});
|
|
76
|
+
if (!continueWithInstall) {
|
|
77
|
+
display("Installation cancelled ", "success");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
//generate command for package.json
|
|
84
|
+
const pm = detectPackageManager();
|
|
85
|
+
const command = pm + " install";
|
|
86
|
+
const result = [
|
|
87
|
+
{
|
|
88
|
+
name: "package.json",
|
|
89
|
+
interactive: [],
|
|
90
|
+
nonInteractive: [command],
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=config_reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_reader.js","sourceRoot":"","sources":["../src/config_reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,GAAG,MAAM,IAAI,CAAC;AAC1B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C;;GAEG;AAEH,MAAM,UAAU,oBAAoB,CAClC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAEnC,+CAA+C;IAC/C,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE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B;YAC9B;gBACE,IAAI,EAAE,cAAc;gBACpB,WAAW,EAAE,EAAE;gBACf,cAAc,EAAE,CAAC,OAAO,CAAC;aAC1B;SACF,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display a message with a specified type.
|
|
3
|
+
*
|
|
4
|
+
* @param text - The message to display.
|
|
5
|
+
* @param type - The type of message to display to determine the color.
|
|
6
|
+
*/
|
|
7
|
+
export declare const display: (text: string, type: "error" | "success" | "warning" | "info" | "loading" | "") => void;
|
|
8
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,OAAO,GAClB,MAAM,MAAM,EACZ,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,EAAE,SAqBhE,CAAC"}
|
package/dist/display.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display a message with a specified type.
|
|
3
|
+
*
|
|
4
|
+
* @param text - The message to display.
|
|
5
|
+
* @param type - The type of message to display to determine the color.
|
|
6
|
+
*/
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
export const display = (text, type) => {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case "error":
|
|
11
|
+
console.error(chalk.red(text));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
case "success":
|
|
14
|
+
console.log(chalk.green(text));
|
|
15
|
+
process.exit(0);
|
|
16
|
+
case "warning":
|
|
17
|
+
console.warn(chalk.yellow(text));
|
|
18
|
+
break;
|
|
19
|
+
case "info":
|
|
20
|
+
console.info(chalk.blue(text));
|
|
21
|
+
break;
|
|
22
|
+
case "loading":
|
|
23
|
+
console.log(`Loading... ${text}`);
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
console.log(text);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,IAAY,EACZ,IAA+D,EAC/D,EAAE;IACF,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/B,MAAM;QACR,KAAK,SAAS;YACZ,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;YAClC,MAAM;QACR;YACE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC"}
|