pm-auto 1.0.4 → 1.0.5
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 +91 -36
- package/dist/config_path.d.ts +0 -1
- package/dist/config_path.d.ts.map +1 -1
- package/dist/config_path.js +0 -5
- package/dist/config_path.js.map +1 -1
- package/dist/config_reader.d.ts +2 -0
- package/dist/config_reader.d.ts.map +1 -1
- package/dist/config_reader.js +45 -0
- package/dist/config_reader.js.map +1 -1
- package/dist/display.d.ts +0 -1
- package/dist/display.d.ts.map +1 -1
- package/dist/display.js +1 -7
- package/dist/display.js.map +1 -1
- package/dist/index.js +30 -2
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +2 -4
- package/dist/install.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +4 -5
- package/dist/orchestrator.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config_path.ts +0 -6
- package/src/config_reader.ts +56 -0
- package/src/display.ts +1 -7
- package/src/index.ts +33 -2
- package/src/install.ts +2 -4
- package/src/orchestrator.ts +5 -6
- package/src/types/index.ts +17 -16
- package/test.json +87 -94
- package/tests/config_path.test.ts +1 -23
- package/tests/display.test.ts +83 -0
- package/tests/install.test.ts +0 -5
package/README.md
CHANGED
|
@@ -58,62 +58,62 @@ yarn global add pm-auto
|
|
|
58
58
|
|
|
59
59
|
## Quick Start
|
|
60
60
|
|
|
61
|
-
**1. Create a config file** (e.g., `
|
|
61
|
+
**1. Create a config file** (e.g., `config.json`):
|
|
62
62
|
|
|
63
63
|
```json
|
|
64
64
|
{
|
|
65
|
-
"
|
|
66
|
-
"name": "
|
|
65
|
+
"InstallVite": {
|
|
66
|
+
"name": "vite",
|
|
67
|
+
"description": "Vite configuration",
|
|
67
68
|
"packageManager": "npm",
|
|
68
69
|
"packages": [
|
|
69
70
|
{
|
|
70
|
-
"command": "
|
|
71
|
-
"interactive": false
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"command": "@types/react @types/react-dom --save-dev",
|
|
75
|
-
"interactive": false
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"command": "vite @vitejs/plugin-react --save-dev",
|
|
79
|
-
"interactive": false
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"command": "create-next-app@latest my-app",
|
|
71
|
+
"command": "create-vite@latest my-app",
|
|
83
72
|
"interactive": true
|
|
84
73
|
}
|
|
85
74
|
]
|
|
86
75
|
},
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
|
|
77
|
+
"Next.js": {
|
|
78
|
+
"name": "next",
|
|
79
|
+
"description": "Next.js configuration",
|
|
89
80
|
"packageManager": "pnpm",
|
|
90
81
|
"packages": [
|
|
91
82
|
{
|
|
92
|
-
"command": "
|
|
83
|
+
"command": "three --save-dev",
|
|
84
|
+
"interactive": false
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"command": "@react-three/drei",
|
|
93
88
|
"interactive": false
|
|
94
89
|
},
|
|
95
90
|
{
|
|
96
|
-
"command": "
|
|
91
|
+
"command": "framer-motion",
|
|
97
92
|
"interactive": false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"command": "create-next-app@latest my-app",
|
|
96
|
+
"interactive": true
|
|
98
97
|
}
|
|
99
98
|
]
|
|
100
99
|
}
|
|
101
100
|
}
|
|
101
|
+
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
**2. Set your config path:**
|
|
105
105
|
|
|
106
106
|
```bash
|
|
107
|
-
pm-auto config ./
|
|
107
|
+
pm-auto config ./config.json
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
**3. Install your stack:**
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
pm-auto install
|
|
113
|
+
pm-auto install vite
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
That's it!
|
|
116
|
+
That's it! The vite package from your config is installed automatically.
|
|
117
117
|
|
|
118
118
|
## Why PM-Auto?
|
|
119
119
|
|
|
@@ -161,7 +161,7 @@ pm-auto install|i|add [options] [packages...]
|
|
|
161
161
|
pm-auto install
|
|
162
162
|
|
|
163
163
|
# Install specific packages to all presets
|
|
164
|
-
pm-auto install
|
|
164
|
+
pm-auto install vite next
|
|
165
165
|
|
|
166
166
|
# Install from existing package.json
|
|
167
167
|
pm-auto install --pkg-json
|
|
@@ -169,8 +169,8 @@ pm-auto install --pkg-json
|
|
|
169
169
|
# Preview what would be installed
|
|
170
170
|
pm-auto install --dry-run
|
|
171
171
|
|
|
172
|
-
# Add custom flags (e.g., for peer dependency issues)
|
|
173
|
-
pm-auto install --add-command "--legacy-peer-deps"
|
|
172
|
+
# Add custom flags for non interactive commands(e.g., for peer dependency issues)
|
|
173
|
+
pm-auto install vite --add-command "--legacy-peer-deps"
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
### `pm-auto uninstall`
|
|
@@ -190,13 +190,13 @@ pm-auto uninstall|u|remove [options] <packages...>
|
|
|
190
190
|
|
|
191
191
|
```bash
|
|
192
192
|
# Uninstall single package
|
|
193
|
-
pm-auto uninstall
|
|
193
|
+
pm-auto uninstall vite
|
|
194
194
|
|
|
195
195
|
# Uninstall multiple packages
|
|
196
|
-
pm-auto uninstall
|
|
196
|
+
pm-auto uninstall vite next
|
|
197
197
|
|
|
198
|
-
# Force uninstall
|
|
199
|
-
pm-auto uninstall
|
|
198
|
+
# Force uninstall for non interactive commands
|
|
199
|
+
pm-auto uninstall vite --add-command "--force"
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
### `pm-auto config`
|
|
@@ -213,12 +213,63 @@ pm-auto config <path>
|
|
|
213
213
|
# Set config with relative path
|
|
214
214
|
pm-auto config ./pm-auto-config.json
|
|
215
215
|
|
|
216
|
-
# Set config with absolute path
|
|
217
|
-
pm-auto config /home/user/configs/pm-auto-config.json
|
|
218
216
|
```
|
|
219
217
|
|
|
220
218
|
**Note:** The config path is stored persistently. If you move your config file, run `pm-auto config <new-path>` again.
|
|
221
219
|
|
|
220
|
+
### `pm-auto list`
|
|
221
|
+
List all packages from the config file
|
|
222
|
+
```bash
|
|
223
|
+
pm-auto list|ls
|
|
224
|
+
```
|
|
225
|
+
**Options:**
|
|
226
|
+
|
|
227
|
+
- `-D, --desc <command>` - Display packages description
|
|
228
|
+
- `-h, --help` - Display help
|
|
229
|
+
|
|
230
|
+
**Examples:**
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# List all presets
|
|
234
|
+
pm-auto list
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### `pm-auto describe`
|
|
239
|
+
Display description of the package
|
|
240
|
+
```bash
|
|
241
|
+
pm-auto describe <package-name>
|
|
242
|
+
```
|
|
243
|
+
**Options:**
|
|
244
|
+
|
|
245
|
+
- `-h, --help` - Display help
|
|
246
|
+
|
|
247
|
+
**Examples:**
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# List all presets
|
|
251
|
+
pm-auto describe vite
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
### `pm-auto config-path`
|
|
255
|
+
|
|
256
|
+
Display path to the config file
|
|
257
|
+
```bash
|
|
258
|
+
pm-auto config-path|cp
|
|
259
|
+
```
|
|
260
|
+
**Options:**
|
|
261
|
+
|
|
262
|
+
- `-h, --help` - Display help
|
|
263
|
+
|
|
264
|
+
**Examples:**
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# List all presets
|
|
268
|
+
pm-auto config-path
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
|
|
222
273
|
## Configuration
|
|
223
274
|
|
|
224
275
|
Create a JSON config file to define your tech stack presets.
|
|
@@ -227,8 +278,9 @@ Create a JSON config file to define your tech stack presets.
|
|
|
227
278
|
|
|
228
279
|
```json
|
|
229
280
|
{
|
|
230
|
-
"
|
|
281
|
+
"Key": {
|
|
231
282
|
"name": "preset-name",
|
|
283
|
+
"description": "Description of the preset",
|
|
232
284
|
"packageManager": "npm",
|
|
233
285
|
"packages": [
|
|
234
286
|
{
|
|
@@ -241,8 +293,9 @@ Create a JSON config file to define your tech stack presets.
|
|
|
241
293
|
```
|
|
242
294
|
|
|
243
295
|
### Config Fields
|
|
244
|
-
|
|
245
|
-
- **`name`** -
|
|
296
|
+
- **`Key`** - Identifier for the preset (it can be anything)
|
|
297
|
+
- **`name`** - The preset name (should be simple for easy remembrance)
|
|
298
|
+
- **`description`** - Description of the preset
|
|
246
299
|
- **`packageManager`** - Package manager to use: `npm`, `yarn`, or `pnpm`
|
|
247
300
|
- **`packages`** - Array of package configurations
|
|
248
301
|
- **`command`** - Package name(s) and flags (e.g., `lodash`, `typescript --save-dev`, `react react-dom`)
|
|
@@ -256,6 +309,7 @@ Create a JSON config file to define your tech stack presets.
|
|
|
256
309
|
{
|
|
257
310
|
"fullstack-ts": {
|
|
258
311
|
"name": "fullstack-ts",
|
|
312
|
+
"description": "Full-stack TypeScript setup with Express and TypeScript",
|
|
259
313
|
"packageManager": "npm",
|
|
260
314
|
"packages": [
|
|
261
315
|
{
|
|
@@ -285,6 +339,7 @@ Create a JSON config file to define your tech stack presets.
|
|
|
285
339
|
{
|
|
286
340
|
"threejs-react": {
|
|
287
341
|
"name": "threejs-react",
|
|
342
|
+
"description": "Three.js + React project setup",
|
|
288
343
|
"packageManager": "pnpm",
|
|
289
344
|
"packages": [
|
|
290
345
|
{
|
|
@@ -313,7 +368,7 @@ Set `"interactive": true` for commands that require user input during installati
|
|
|
313
368
|
|
|
314
369
|
### Config Tips
|
|
315
370
|
|
|
316
|
-
1. **Group related packages** - Combine packages that are always installed together in one command (e.g., `react react-dom`)
|
|
371
|
+
1. **Group related packages** - Combine packages that are always installed together in one command (e.g., `react react-dom gsap`)
|
|
317
372
|
2. **Use descriptive names** - Name presets by purpose: `api-starter`, `frontend-base`, `testing-setup`
|
|
318
373
|
3. **Multiple presets** - Create different presets for different project types in the same config
|
|
319
374
|
4. **Version control** - Commit your config file to share stacks across your team
|
package/dist/config_path.d.ts
CHANGED
|
@@ -1 +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
|
|
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"}
|
package/dist/config_path.js
CHANGED
|
@@ -35,9 +35,4 @@ export function getConfigPath() {
|
|
|
35
35
|
display(`Error reading config file path: ${error.message}`, "error");
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
export function clearConfigPath() {
|
|
39
|
-
if (fs.existsSync(SETTINGS_FILE)) {
|
|
40
|
-
fs.unlinkSync(SETTINGS_FILE);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
38
|
//# sourceMappingURL=config_path.js.map
|
package/dist/config_path.js.map
CHANGED
|
@@ -1 +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,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AAI,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"}
|
package/dist/config_reader.d.ts
CHANGED
|
@@ -9,5 +9,7 @@ export declare function detectPackageManager(projectPath?: string): PackageManag
|
|
|
9
9
|
* it modifies the object and returns it
|
|
10
10
|
*/
|
|
11
11
|
export declare const getConfigObject: (packages: string[], options?: any) => Promise<ConfigType[] | CommandResult[]>;
|
|
12
|
+
export declare const getConfigKeys: (options: any) => Promise<void>;
|
|
13
|
+
export declare const getPackageDescription: (packageName: string) => Promise<void>;
|
|
12
14
|
export {};
|
|
13
15
|
//# sourceMappingURL=config_reader.d.ts.map
|
|
@@ -1 +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,CAsFxC,CAAC"}
|
|
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,CAsFxC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,SAAS,GAAG,kBA2B/C,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAU,aAAa,MAAM,kBAyB9D,CAAC"}
|
package/dist/config_reader.js
CHANGED
|
@@ -100,4 +100,49 @@ export const getConfigObject = async (packages, options) => {
|
|
|
100
100
|
return result;
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
+
export const getConfigKeys = async (options) => {
|
|
104
|
+
const configPath = getConfigPath();
|
|
105
|
+
//read config file content
|
|
106
|
+
let configContent = "";
|
|
107
|
+
try {
|
|
108
|
+
configContent = await fs.readFile(configPath, "utf8");
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
display(`File not found ${error} Try updating the config file path`, "error");
|
|
112
|
+
}
|
|
113
|
+
const configObject = JSON.parse(configContent);
|
|
114
|
+
let keys = Object.keys(configObject);
|
|
115
|
+
keys.forEach((key) => {
|
|
116
|
+
if (options.desc) {
|
|
117
|
+
const description = !configObject[key].description
|
|
118
|
+
? "No description"
|
|
119
|
+
: configObject[key].description;
|
|
120
|
+
display(`${key} - ${description}`, "info");
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
display(`${key}`, "info");
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
export const getPackageDescription = async (packageName) => {
|
|
128
|
+
const configPath = getConfigPath();
|
|
129
|
+
//read config file content
|
|
130
|
+
let configContent = "";
|
|
131
|
+
try {
|
|
132
|
+
configContent = await fs.readFile(configPath, "utf8");
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
display(`File not found ${error} Try updating the config file path`, "error");
|
|
136
|
+
}
|
|
137
|
+
const configObject = JSON.parse(configContent);
|
|
138
|
+
let keys = Object.keys(configObject);
|
|
139
|
+
keys.forEach((key) => {
|
|
140
|
+
if (key === packageName) {
|
|
141
|
+
const description = !configObject[key].description
|
|
142
|
+
? "No description"
|
|
143
|
+
: configObject[key].description;
|
|
144
|
+
display(`${packageName} - ${description}`, "info");
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
};
|
|
103
148
|
//# sourceMappingURL=config_reader.js.map
|
|
@@ -1 +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,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI3D;;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,CA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success" | "warning" | "info" | "loading" | "";
|
|
2
|
-
export declare const stopSpinner: (text: string, code?: number) => void;
|
|
3
2
|
export declare const display: (text: string, type: DisplayType) => {
|
|
4
3
|
start: (msg?: string) => void;
|
|
5
4
|
stop: (msg?: string, code?: number) => void;
|
package/dist/display.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,EAAE,CAAC;AAE7E,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAGA,KAAK,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,EAAE,CAAC;AAE7E,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,MAAM,WAAW;eA2BinG,CAAC;cAAiC,CAAC,cAAc,CAAC;iBAAoC,CAAC;aAD9vG,CAAC"}
|
package/dist/display.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { log, spinner } from "@clack/prompts";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
export const stopSpinner = (text, code = 0) => {
|
|
4
|
-
const s = spinner();
|
|
5
|
-
if (!s || typeof s.stop !== "function")
|
|
6
|
-
return;
|
|
7
|
-
s.stop(code === 0 ? chalk.green(text) : chalk.red(text));
|
|
8
|
-
};
|
|
9
3
|
export const display = (text, type) => {
|
|
10
4
|
switch (type) {
|
|
11
5
|
case "error":
|
|
12
6
|
log.error(chalk.red(text));
|
|
13
|
-
process.exit(
|
|
7
|
+
process.exit(0);
|
|
14
8
|
case "success":
|
|
15
9
|
log.success(chalk.green(text)); // Use log.success instead
|
|
16
10
|
break;
|
package/dist/display.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,IAAiB,EAAE,EAAE;IACzD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAElB,KAAK,SAAS;YACZ,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,0BAA0B;YAC1D,MAAM;QAER,KAAK,SAAS;YACZ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7B,MAAM;QAER,KAAK,MAAM;YACT,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3B,MAAM;QAER,KAAK,SAAS;YACZ,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;YACpB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACd,OAAO,CAAC,CAAC,CAAC,4CAA4C;QAExD;YACE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { saveConfigPath } from "./config_path.js";
|
|
3
|
+
import { getConfigPath, saveConfigPath } from "./config_path.js";
|
|
4
4
|
import { intro } from "@clack/prompts";
|
|
5
5
|
import { orchestrator } from "./orchestrator.js";
|
|
6
6
|
import chalk from "chalk";
|
|
7
|
+
import { getConfigKeys, getPackageDescription } from "./config_reader.js";
|
|
8
|
+
import { display } from "./display.js";
|
|
7
9
|
intro(chalk.inverse(" pm-auto "));
|
|
8
10
|
const program = new Command();
|
|
9
11
|
program
|
|
10
12
|
.name("pm-auto")
|
|
11
|
-
.version("1.0.
|
|
13
|
+
.version("1.0.5")
|
|
12
14
|
.description("A CLI tool to define and install your tech stack presets with one command.");
|
|
13
15
|
program
|
|
14
16
|
.command("config <path>")
|
|
@@ -37,5 +39,31 @@ program
|
|
|
37
39
|
.action((packages, options) => {
|
|
38
40
|
orchestrator("uninstall", packages, options);
|
|
39
41
|
});
|
|
42
|
+
//Listing config packages
|
|
43
|
+
program
|
|
44
|
+
.command("list")
|
|
45
|
+
.alias("ls")
|
|
46
|
+
.description("List all packages from the config file")
|
|
47
|
+
.option("-D, --desc", "Display packages description", false)
|
|
48
|
+
.action((options) => {
|
|
49
|
+
getConfigKeys(options);
|
|
50
|
+
});
|
|
51
|
+
//Displaying config details
|
|
52
|
+
program
|
|
53
|
+
.command("describe <package>")
|
|
54
|
+
.alias("desc")
|
|
55
|
+
.description("Display description of the package")
|
|
56
|
+
.action((packages) => {
|
|
57
|
+
getPackageDescription(packages);
|
|
58
|
+
});
|
|
59
|
+
//get config path
|
|
60
|
+
program
|
|
61
|
+
.command("config-path")
|
|
62
|
+
.alias("cp")
|
|
63
|
+
.description("Display the path to the configuration file")
|
|
64
|
+
.action(() => {
|
|
65
|
+
const path = getConfigPath();
|
|
66
|
+
display(`Config Path: ${path}`, "info");
|
|
67
|
+
});
|
|
40
68
|
program.parse();
|
|
41
69
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAElC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CACV,4EAA4E,CAC7E,CAAC;AAEJ,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,wCAAwC,CAAC;KACrD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACf,cAAc,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,uBAAuB,CAAC;KAChC,KAAK,CAAC,KAAK,CAAC;KACZ,KAAK,CAAC,GAAG,CAAC;KACV,WAAW,CACV,uEAAuE,CACxE;KACA,MAAM,CAAC,gBAAgB,EAAE,oCAAoC,CAAC;KAC9D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AE;IACX,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,gBAAgB,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAwBtD;;GAEG;AACH,wBAAsB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAqBtD"}
|
package/dist/install.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
|
-
import { display
|
|
2
|
+
import { display } from "./display.js";
|
|
3
3
|
async function runCommand(command, interactive = false) {
|
|
4
4
|
try {
|
|
5
5
|
const [commandName, ...args] = command.split(" ");
|
|
6
6
|
if (interactive) {
|
|
7
|
-
// Stop spinner before interactive command
|
|
8
|
-
stopSpinner("Starting interactive command...", 0);
|
|
9
7
|
await execa(commandName, args, {
|
|
10
8
|
stdio: "inherit",
|
|
11
9
|
});
|
|
@@ -39,7 +37,7 @@ export async function install(commands) {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
// Then run non-interactive
|
|
42
|
-
if (command.nonInteractive) {
|
|
40
|
+
if (command.nonInteractive.length > 0) {
|
|
43
41
|
// For non-interactive, we show a spinner
|
|
44
42
|
display(`Running command: ${command.nonInteractive[0]}`, "loading");
|
|
45
43
|
await runCommand(command.nonInteractive[0], false);
|
package/dist/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,cAAuB,KAAK;IACrE,IAAI,CAAC;QACH,MAAM,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAElD,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,KAAK,CAAC,WAAqB,EAAE,IAAI,EAAE;gBACvC,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,CAAC,WAAqB,EAAE,IAAI,EAAE;gBACvC,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,4CAA4C;QAC5C,IAAI,KAAK,CAAC,MAAM;YAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,KAAK,CAAC,MAAM;YAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,OAAO,CAAC,WAAW,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,QAAyB;IACrD,IAAI,CAAC;QACH,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,oDAAoD;YACpD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;gBACxB,KAAK,MAAM,kBAAkB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;oBACrD,OAAO,CAAC,gCAAgC,kBAAkB,EAAE,EAAE,MAAM,CAAC,CAAC;oBACtE,MAAM,UAAU,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;gBAC7C,CAAC;YACH,CAAC;YAED,2BAA2B;YAC3B,IAAI,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtC,yCAAyC;gBACzC,OAAO,CAAC,oBAAoB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;gBACpE,MAAM,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAW,EAAE,KAAK,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,YAAY,GACvB,SAAS,MAAM,EACf,UAAU,MAAM,EAAE,EAClB,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,YAAY,GACvB,SAAS,MAAM,EACf,UAAU,MAAM,EAAE,EAClB,UAAU,GAAG,SA8Cd,CAAC"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildCommands, buildUninstallCommands } from "./build_command.js";
|
|
2
2
|
import { getConfigObject } from "./config_reader.js";
|
|
3
|
-
import { display
|
|
3
|
+
import { display } from "./display.js";
|
|
4
4
|
import { install } from "./install.js";
|
|
5
5
|
import { outro } from "@clack/prompts";
|
|
6
6
|
//Check if the value is an array of ConfigType objects
|
|
@@ -22,13 +22,12 @@ export const orchestrator = (command, packages, options) => {
|
|
|
22
22
|
if (isConfigTypeArray(config)) {
|
|
23
23
|
const commands = buildCommands(config);
|
|
24
24
|
await install(commands);
|
|
25
|
-
|
|
26
|
-
process.stdout.write("\x07");
|
|
25
|
+
display("Packages installed successfully", "success");
|
|
27
26
|
outro("Done!");
|
|
28
27
|
}
|
|
29
28
|
else {
|
|
30
29
|
await install(config);
|
|
31
|
-
|
|
30
|
+
display("Packages from package.json installed successfully", "success");
|
|
32
31
|
outro("Done!");
|
|
33
32
|
}
|
|
34
33
|
});
|
|
@@ -43,7 +42,7 @@ export const orchestrator = (command, packages, options) => {
|
|
|
43
42
|
if (isConfigTypeArray(config)) {
|
|
44
43
|
const commands = buildUninstallCommands(config);
|
|
45
44
|
await install(commands);
|
|
46
|
-
|
|
45
|
+
display("Packages uninstalled successfully", "success");
|
|
47
46
|
outro("Done!");
|
|
48
47
|
}
|
|
49
48
|
});
|
package/dist/orchestrator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE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|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACvD;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B"}
|
package/package.json
CHANGED
package/src/config_path.ts
CHANGED
|
@@ -46,9 +46,3 @@ export function getConfigPath(): string | void {
|
|
|
46
46
|
display(`Error reading config file path: ${error.message}`, "error");
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
export function clearConfigPath(): void {
|
|
51
|
-
if (fs.existsSync(SETTINGS_FILE)) {
|
|
52
|
-
fs.unlinkSync(SETTINGS_FILE);
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/config_reader.ts
CHANGED
|
@@ -127,3 +127,59 @@ export const getConfigObject = async (
|
|
|
127
127
|
return result;
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
+
|
|
131
|
+
export const getConfigKeys = async (options: any) => {
|
|
132
|
+
const configPath = getConfigPath();
|
|
133
|
+
|
|
134
|
+
//read config file content
|
|
135
|
+
let configContent = "";
|
|
136
|
+
try {
|
|
137
|
+
configContent = await fs.readFile(configPath as string, "utf8");
|
|
138
|
+
} catch (error) {
|
|
139
|
+
display(
|
|
140
|
+
`File not found ${error} Try updating the config file path`,
|
|
141
|
+
"error",
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const configObject = JSON.parse(configContent);
|
|
146
|
+
let keys = Object.keys(configObject);
|
|
147
|
+
|
|
148
|
+
keys.forEach((key) => {
|
|
149
|
+
if (options.desc) {
|
|
150
|
+
const description = !configObject[key].description
|
|
151
|
+
? "No description"
|
|
152
|
+
: configObject[key].description;
|
|
153
|
+
display(`${key} - ${description}`, "info");
|
|
154
|
+
} else {
|
|
155
|
+
display(`${key}`, "info");
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const getPackageDescription = async (packageName: string) => {
|
|
161
|
+
const configPath = getConfigPath();
|
|
162
|
+
|
|
163
|
+
//read config file content
|
|
164
|
+
let configContent = "";
|
|
165
|
+
try {
|
|
166
|
+
configContent = await fs.readFile(configPath as string, "utf8");
|
|
167
|
+
} catch (error) {
|
|
168
|
+
display(
|
|
169
|
+
`File not found ${error} Try updating the config file path`,
|
|
170
|
+
"error",
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const configObject = JSON.parse(configContent);
|
|
175
|
+
let keys = Object.keys(configObject);
|
|
176
|
+
|
|
177
|
+
keys.forEach((key) => {
|
|
178
|
+
if (key === packageName) {
|
|
179
|
+
const description = !configObject[key].description
|
|
180
|
+
? "No description"
|
|
181
|
+
: configObject[key].description;
|
|
182
|
+
display(`${packageName} - ${description}`, "info");
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
};
|
package/src/display.ts
CHANGED
|
@@ -3,17 +3,11 @@ import chalk from "chalk";
|
|
|
3
3
|
|
|
4
4
|
type DisplayType = "error" | "success" | "warning" | "info" | "loading" | "";
|
|
5
5
|
|
|
6
|
-
export const stopSpinner = (text: string, code: number = 0) => {
|
|
7
|
-
const s = spinner();
|
|
8
|
-
if (!s || typeof s.stop !== "function") return;
|
|
9
|
-
s.stop(code === 0 ? chalk.green(text) : chalk.red(text));
|
|
10
|
-
};
|
|
11
|
-
|
|
12
6
|
export const display = (text: string, type: DisplayType) => {
|
|
13
7
|
switch (type) {
|
|
14
8
|
case "error":
|
|
15
9
|
log.error(chalk.red(text));
|
|
16
|
-
process.exit(
|
|
10
|
+
process.exit(0);
|
|
17
11
|
|
|
18
12
|
case "success":
|
|
19
13
|
log.success(chalk.green(text)); // Use log.success instead
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { saveConfigPath } from "./config_path.js";
|
|
4
|
+
import { getConfigPath, saveConfigPath } from "./config_path.js";
|
|
5
5
|
import { intro } from "@clack/prompts";
|
|
6
6
|
import { orchestrator } from "./orchestrator.js";
|
|
7
7
|
import chalk from "chalk";
|
|
8
|
+
import { getConfigKeys, getPackageDescription } from "./config_reader.js";
|
|
9
|
+
import { display } from "./display.js";
|
|
8
10
|
|
|
9
11
|
intro(chalk.inverse(" pm-auto "));
|
|
10
12
|
|
|
@@ -12,7 +14,7 @@ const program = new Command();
|
|
|
12
14
|
|
|
13
15
|
program
|
|
14
16
|
.name("pm-auto")
|
|
15
|
-
.version("1.0.
|
|
17
|
+
.version("1.0.5")
|
|
16
18
|
.description(
|
|
17
19
|
"A CLI tool to define and install your tech stack presets with one command.",
|
|
18
20
|
);
|
|
@@ -57,4 +59,33 @@ program
|
|
|
57
59
|
orchestrator("uninstall", packages, options);
|
|
58
60
|
});
|
|
59
61
|
|
|
62
|
+
//Listing config packages
|
|
63
|
+
program
|
|
64
|
+
.command("list")
|
|
65
|
+
.alias("ls")
|
|
66
|
+
.description("List all packages from the config file")
|
|
67
|
+
.option("-D, --desc", "Display packages description", false)
|
|
68
|
+
.action((options) => {
|
|
69
|
+
getConfigKeys(options);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
//Displaying config details
|
|
73
|
+
program
|
|
74
|
+
.command("describe <package>")
|
|
75
|
+
.alias("desc")
|
|
76
|
+
.description("Display description of the package")
|
|
77
|
+
.action((packages) => {
|
|
78
|
+
getPackageDescription(packages);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
//get config path
|
|
82
|
+
program
|
|
83
|
+
.command("config-path")
|
|
84
|
+
.alias("cp")
|
|
85
|
+
.description("Display the path to the configuration file")
|
|
86
|
+
.action(() => {
|
|
87
|
+
const path = getConfigPath();
|
|
88
|
+
display(`Config Path: ${path}`, "info");
|
|
89
|
+
});
|
|
90
|
+
|
|
60
91
|
program.parse();
|
package/src/install.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import type { CommandResult } from "./types/index.js";
|
|
3
|
-
import { display
|
|
3
|
+
import { display } from "./display.js";
|
|
4
4
|
|
|
5
5
|
async function runCommand(command: string, interactive: boolean = false) {
|
|
6
6
|
try {
|
|
7
7
|
const [commandName, ...args] = command.split(" ");
|
|
8
8
|
|
|
9
9
|
if (interactive) {
|
|
10
|
-
// Stop spinner before interactive command
|
|
11
|
-
stopSpinner("Starting interactive command...", 0);
|
|
12
10
|
await execa(commandName as string, args, {
|
|
13
11
|
stdio: "inherit",
|
|
14
12
|
});
|
|
@@ -40,7 +38,7 @@ export async function install(commands: CommandResult[]) {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
// Then run non-interactive
|
|
43
|
-
if (command.nonInteractive) {
|
|
41
|
+
if (command.nonInteractive.length > 0) {
|
|
44
42
|
// For non-interactive, we show a spinner
|
|
45
43
|
display(`Running command: ${command.nonInteractive[0]}`, "loading");
|
|
46
44
|
await runCommand(command.nonInteractive[0] as string, false);
|
package/src/orchestrator.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildCommands, buildUninstallCommands } from "./build_command.js";
|
|
2
2
|
import { getConfigObject } from "./config_reader.js";
|
|
3
|
-
import { display
|
|
3
|
+
import { display } from "./display.js";
|
|
4
4
|
import { install } from "./install.js";
|
|
5
5
|
import type { ConfigType } from "./types/index.js";
|
|
6
6
|
import { outro } from "@clack/prompts";
|
|
@@ -38,14 +38,13 @@ export const orchestrator = (
|
|
|
38
38
|
|
|
39
39
|
if (isConfigTypeArray(config)) {
|
|
40
40
|
const commands = buildCommands(config);
|
|
41
|
+
|
|
41
42
|
await install(commands);
|
|
42
|
-
|
|
43
|
-
process.stdout.write("\x07");
|
|
43
|
+
display("Packages installed successfully", "success");
|
|
44
44
|
outro("Done!");
|
|
45
45
|
} else {
|
|
46
46
|
await install(config);
|
|
47
|
-
|
|
48
|
-
stopSpinner("Packages from package.json installed successfully");
|
|
47
|
+
display("Packages from package.json installed successfully", "success");
|
|
49
48
|
outro("Done!");
|
|
50
49
|
}
|
|
51
50
|
});
|
|
@@ -64,7 +63,7 @@ export const orchestrator = (
|
|
|
64
63
|
if (isConfigTypeArray(config)) {
|
|
65
64
|
const commands = buildUninstallCommands(config);
|
|
66
65
|
await install(commands);
|
|
67
|
-
|
|
66
|
+
display("Packages uninstalled successfully", "success");
|
|
68
67
|
outro("Done!");
|
|
69
68
|
}
|
|
70
69
|
});
|
package/src/types/index.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export interface ConfigType {
|
|
2
|
-
name: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
export interface ConfigType {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
packageManager: string;
|
|
5
|
+
packages: { command: string; interactive: boolean }[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface PackageType {
|
|
9
|
+
command: string;
|
|
10
|
+
interactive: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CommandResult {
|
|
14
|
+
name: string;
|
|
15
|
+
interactive: string[];
|
|
16
|
+
nonInteractive: string[];
|
|
17
|
+
}
|
package/test.json
CHANGED
|
@@ -1,94 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"sample": {
|
|
3
|
-
"name": "sample",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
"command": "three",
|
|
64
|
-
"interactive": false
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
"command": "@react-three/postprocessing",
|
|
90
|
-
"interactive": false
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
}
|
|
94
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"sample": {
|
|
3
|
+
"name": "sample",
|
|
4
|
+
"description": "",
|
|
5
|
+
"packageManager": "npm",
|
|
6
|
+
"packages": [
|
|
7
|
+
{
|
|
8
|
+
"command": "gsap",
|
|
9
|
+
"interactive": false
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
"vite": {
|
|
15
|
+
"name": "vite",
|
|
16
|
+
"description": "Vite configuration",
|
|
17
|
+
"packageManager": "npm",
|
|
18
|
+
"packages": [
|
|
19
|
+
{
|
|
20
|
+
"command": "create-vite@latest my-app",
|
|
21
|
+
"interactive": true
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
"next": {
|
|
27
|
+
"name": "next",
|
|
28
|
+
"description": "Next.js configuration",
|
|
29
|
+
"packageManager": "pnpm",
|
|
30
|
+
"packages": [
|
|
31
|
+
{
|
|
32
|
+
"command": "three --save-dev",
|
|
33
|
+
"interactive": false
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"command": "@react-three/drei",
|
|
37
|
+
"interactive": false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"command": "framer-motion",
|
|
41
|
+
"interactive": false
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"command": "create-next-app@latest my-app",
|
|
45
|
+
"interactive": true
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"test": {
|
|
50
|
+
"name": "test",
|
|
51
|
+
"description": "Test configuration",
|
|
52
|
+
"packageManager": "npm",
|
|
53
|
+
"packages": [
|
|
54
|
+
{
|
|
55
|
+
"command": "three",
|
|
56
|
+
"interactive": false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"command": "gsap",
|
|
60
|
+
"interactive": false
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"command": "@react-three/fiber",
|
|
64
|
+
"interactive": false
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"test2": {
|
|
69
|
+
"name": "test2",
|
|
70
|
+
"description": "Test2 configuration",
|
|
71
|
+
"packageManager": "npm",
|
|
72
|
+
"packages": [
|
|
73
|
+
{
|
|
74
|
+
"command": "@react-three/drei",
|
|
75
|
+
"interactive": false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"command": "framer-motion",
|
|
79
|
+
"interactive": false
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"command": "@react-three/postprocessing",
|
|
83
|
+
"interactive": false
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as os from "os";
|
|
4
|
-
import {
|
|
5
|
-
saveConfigPath,
|
|
6
|
-
getConfigPath,
|
|
7
|
-
clearConfigPath,
|
|
8
|
-
} from "../src/config_path.js";
|
|
4
|
+
import { saveConfigPath, getConfigPath } from "../src/config_path.js";
|
|
9
5
|
import * as display from "../src/display.js";
|
|
10
6
|
|
|
11
7
|
const mocks = vi.hoisted(() => {
|
|
@@ -121,22 +117,4 @@ describe("Config Path Management", () => {
|
|
|
121
117
|
expect(result).toBe("");
|
|
122
118
|
});
|
|
123
119
|
});
|
|
124
|
-
|
|
125
|
-
describe("clearConfigPath", () => {
|
|
126
|
-
it("deletes settings file if exists", () => {
|
|
127
|
-
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
128
|
-
|
|
129
|
-
clearConfigPath();
|
|
130
|
-
|
|
131
|
-
expect(fs.unlinkSync).toHaveBeenCalledWith(mockSettingsFile);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("does nothing if file does not exist", () => {
|
|
135
|
-
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
136
|
-
|
|
137
|
-
clearConfigPath();
|
|
138
|
-
|
|
139
|
-
expect(fs.unlinkSync).not.toHaveBeenCalled();
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
120
|
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
+
import { display } from "../src/display.js";
|
|
3
|
+
import { log, spinner } from "@clack/prompts";
|
|
4
|
+
|
|
5
|
+
// Mock the dependencies
|
|
6
|
+
vi.mock("@clack/prompts", () => ({
|
|
7
|
+
log: {
|
|
8
|
+
error: vi.fn(),
|
|
9
|
+
success: vi.fn(),
|
|
10
|
+
warn: vi.fn(),
|
|
11
|
+
info: vi.fn(),
|
|
12
|
+
message: vi.fn(),
|
|
13
|
+
},
|
|
14
|
+
spinner: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
vi.mock("chalk", () => ({
|
|
18
|
+
default: {
|
|
19
|
+
red: vi.fn((text) => `red:${text}`),
|
|
20
|
+
green: vi.fn((text) => `green:${text}`),
|
|
21
|
+
yellow: vi.fn((text) => `yellow:${text}`),
|
|
22
|
+
blue: vi.fn((text) => `blue:${text}`),
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
describe("display", () => {
|
|
27
|
+
let mockSpinner: any;
|
|
28
|
+
let exitSpy: any;
|
|
29
|
+
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
mockSpinner = {
|
|
32
|
+
stop: vi.fn(),
|
|
33
|
+
start: vi.fn(),
|
|
34
|
+
};
|
|
35
|
+
vi.mocked(spinner).mockReturnValue(mockSpinner);
|
|
36
|
+
exitSpy = vi
|
|
37
|
+
.spyOn(process, "exit")
|
|
38
|
+
.mockImplementation(() => undefined as never);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
vi.clearAllMocks();
|
|
43
|
+
exitSpy.mockRestore();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should display error message and exit process", () => {
|
|
47
|
+
display("Error text", "error");
|
|
48
|
+
expect(log.error).toHaveBeenCalledWith("red:Error text");
|
|
49
|
+
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should display success message", () => {
|
|
53
|
+
display("Success text", "success");
|
|
54
|
+
expect(log.success).toHaveBeenCalledWith("green:Success text");
|
|
55
|
+
expect(exitSpy).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should display warning message", () => {
|
|
59
|
+
display("Warning text", "warning");
|
|
60
|
+
expect(log.warn).toHaveBeenCalledWith("yellow:Warning text");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should display info message", () => {
|
|
64
|
+
display("Info text", "info");
|
|
65
|
+
expect(log.info).toHaveBeenCalledWith("blue:Info text");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should start spinner for loading type", () => {
|
|
69
|
+
const result = display("Loading text", "loading");
|
|
70
|
+
expect(mockSpinner.start).toHaveBeenCalledWith("Loading text");
|
|
71
|
+
expect(result).toBe(mockSpinner);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should display plain message for default/empty type", () => {
|
|
75
|
+
display("Plain text", "");
|
|
76
|
+
expect(log.message).toHaveBeenCalledWith("Plain text");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should display plain message when type is not recognized", () => {
|
|
80
|
+
display("Unknown text", "unknown" as any);
|
|
81
|
+
expect(log.message).toHaveBeenCalledWith("Unknown text");
|
|
82
|
+
});
|
|
83
|
+
});
|
package/tests/install.test.ts
CHANGED
|
@@ -26,10 +26,6 @@ describe("install", () => {
|
|
|
26
26
|
|
|
27
27
|
await install(commands);
|
|
28
28
|
|
|
29
|
-
expect(display.stopSpinner).toHaveBeenCalledWith(
|
|
30
|
-
"Starting interactive command...",
|
|
31
|
-
0,
|
|
32
|
-
);
|
|
33
29
|
expect(execa).toHaveBeenCalledWith("npm", ["init"], { stdio: "inherit" });
|
|
34
30
|
expect(display.display).toHaveBeenCalledWith(expect.any(String), "info");
|
|
35
31
|
});
|
|
@@ -73,7 +69,6 @@ describe("install", () => {
|
|
|
73
69
|
expect(execa).toHaveBeenNthCalledWith(2, "npm", ["install"], {
|
|
74
70
|
stdio: "inherit",
|
|
75
71
|
});
|
|
76
|
-
expect(display.stopSpinner).toHaveBeenCalled();
|
|
77
72
|
});
|
|
78
73
|
|
|
79
74
|
it("handles multiple interactive commands sequentially", async () => {
|