pm-auto 1.0.0 → 1.0.1
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 +257 -141
- package/dist/config_reader.d.ts.map +1 -1
- package/dist/config_reader.js +7 -3
- package/dist/config_reader.js.map +1 -1
- package/dist/display.d.ts +4 -7
- package/dist/display.d.ts.map +1 -1
- package/dist/display.js +18 -6
- package/dist/display.js.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +26 -8
- package/dist/install.js.map +1 -1
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +8 -4
- package/dist/orchestrator.js.map +1 -1
- package/nodemon.json +6 -6
- package/package.json +8 -7
- package/src/build_command.ts +119 -119
- package/src/config_path.ts +54 -54
- package/src/config_reader.ts +11 -3
- package/src/display.ts +23 -19
- package/src/index.ts +20 -5
- package/src/install.ts +20 -8
- package/src/orchestrator.ts +8 -7
- package/src/types/index.ts +16 -16
- package/test.json +94 -83
package/dist/display.js
CHANGED
|
@@ -4,26 +4,38 @@
|
|
|
4
4
|
* @param text - The message to display.
|
|
5
5
|
* @param type - The type of message to display to determine the color.
|
|
6
6
|
*/
|
|
7
|
+
import { log, spinner } from "@clack/prompts";
|
|
7
8
|
import chalk from "chalk";
|
|
9
|
+
const s = spinner();
|
|
8
10
|
export const display = (text, type) => {
|
|
9
11
|
switch (type) {
|
|
10
12
|
case "error":
|
|
11
|
-
|
|
13
|
+
log.error(chalk.red(text));
|
|
12
14
|
process.exit(1);
|
|
13
15
|
case "success":
|
|
14
|
-
|
|
16
|
+
if (s) {
|
|
17
|
+
s.stop(chalk.green(text));
|
|
18
|
+
}
|
|
15
19
|
process.exit(0);
|
|
16
20
|
case "warning":
|
|
17
|
-
|
|
21
|
+
log.warn(chalk.yellow(text));
|
|
18
22
|
break;
|
|
19
23
|
case "info":
|
|
20
|
-
|
|
24
|
+
log.info(chalk.blue(text));
|
|
21
25
|
break;
|
|
22
26
|
case "loading":
|
|
23
|
-
|
|
27
|
+
s.start(text);
|
|
24
28
|
break;
|
|
25
29
|
default:
|
|
26
|
-
|
|
30
|
+
log.message(text);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const stopSpinner = (text, code = 0) => {
|
|
34
|
+
if (code === 0) {
|
|
35
|
+
s.stop(chalk.green(text));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
s.stop(chalk.red(text));
|
|
27
39
|
}
|
|
28
40
|
};
|
|
29
41
|
//# sourceMappingURL=display.js.map
|
package/dist/display.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../src/display.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;AAEpB,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;QAClB,KAAK,SAAS;YACZ,IAAI,CAAC,EAAE,CAAC;gBACN,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YAC5B,CAAC;YAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,KAAK,SAAS;YACZ,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7B,MAAM;QACR,KAAK,MAAM;YACT,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3B,MAAM;QACR,KAAK,SAAS;YACZ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACd,MAAM;QACR;YACE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAAe,CAAC,EAAE,EAAE;IAC5D,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;QACf,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { saveConfigPath } from "./config_path.js";
|
|
4
|
+
import { intro } from "@clack/prompts";
|
|
4
5
|
import { orchestrator } from "./orchestrator.js";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
intro(chalk.inverse(" pm-auto "));
|
|
5
8
|
const program = new Command();
|
|
6
9
|
program
|
|
7
10
|
.name("pm-auto")
|
|
8
|
-
.version("1.0.
|
|
9
|
-
.description("CLI
|
|
11
|
+
.version("1.0.1")
|
|
12
|
+
.description("A CLI tool to define and install your tech stack presets with one command.");
|
|
10
13
|
program
|
|
11
14
|
.command("config <path>")
|
|
12
|
-
.description("Set the
|
|
15
|
+
.description("Set the path to the configuration file")
|
|
13
16
|
.action((path) => {
|
|
14
17
|
saveConfigPath(path);
|
|
15
18
|
});
|
|
16
19
|
program
|
|
17
20
|
.command("install [packages...]")
|
|
18
|
-
.
|
|
21
|
+
.alias("add")
|
|
22
|
+
.alias("i")
|
|
23
|
+
.description("Install packages using the detected package manager (Aliases: add, i)")
|
|
19
24
|
.option("-p, --pkg-json", "Install packages from package.json")
|
|
20
25
|
.option("-A, --add-command <command>", "Add a custom command to all installation commands from config file")
|
|
21
26
|
.option("-D, --dry-run", "Dry run - Display commands before execution")
|
|
@@ -24,7 +29,10 @@ program
|
|
|
24
29
|
});
|
|
25
30
|
program
|
|
26
31
|
.command("uninstall <packages...>")
|
|
27
|
-
.
|
|
32
|
+
.alias("remove")
|
|
33
|
+
.alias("u")
|
|
34
|
+
.alias("un")
|
|
35
|
+
.description("Remove packages using the detected package manager (Aliases: remove, u, un)")
|
|
28
36
|
.option("-A, --add-command <command>", "Add a custom command to all installation commands from config file")
|
|
29
37
|
.action((packages, options) => {
|
|
30
38
|
orchestrator("uninstall", packages, options);
|
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;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,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,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAElC,MAAM,OA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"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;AA0BtD;;GAEG;AACH,wBAAsB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,iBAwBtD"}
|
package/dist/install.js
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
|
-
import { display } from "./display.js";
|
|
3
|
-
async function runCommand(command) {
|
|
2
|
+
import { display, stopSpinner } from "./display.js";
|
|
3
|
+
async function runCommand(command, interactive = false) {
|
|
4
4
|
try {
|
|
5
5
|
const [commandName, ...args] = command.split(" ");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
if (interactive) {
|
|
7
|
+
// Stop spinner before interactive command
|
|
8
|
+
stopSpinner("Starting interactive command...", 0);
|
|
9
|
+
await execa(commandName, args, {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
await execa(commandName, args, {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
});
|
|
17
|
+
}
|
|
9
18
|
}
|
|
10
19
|
catch (error) {
|
|
20
|
+
// If pipe failed, we should show the output
|
|
21
|
+
if (error.stdout)
|
|
22
|
+
display(error.stdout, "");
|
|
23
|
+
if (error.stderr)
|
|
24
|
+
display(error.stderr, "error");
|
|
11
25
|
display(`Error:, ${error.message}`, "error");
|
|
12
26
|
}
|
|
13
27
|
}
|
|
@@ -20,14 +34,18 @@ export async function install(commands) {
|
|
|
20
34
|
// Wait for all interactive commands to finish first
|
|
21
35
|
if (command.interactive) {
|
|
22
36
|
for (const interactiveCommand of command.interactive) {
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
// Interactive commands need full terminal access
|
|
38
|
+
// We don't start a spinner here, or we stop it immediately in runCommand
|
|
39
|
+
// But better to just log info
|
|
40
|
+
display(`Running interactive command: ${interactiveCommand}`, "info");
|
|
41
|
+
await runCommand(interactiveCommand, true);
|
|
25
42
|
}
|
|
26
43
|
}
|
|
27
44
|
// Then run non-interactive
|
|
28
45
|
if (command.nonInteractive) {
|
|
46
|
+
// For non-interactive, we show a spinner
|
|
29
47
|
display(`Running command: ${command.nonInteractive[0]}`, "loading");
|
|
30
|
-
await runCommand(command.nonInteractive[0]);
|
|
48
|
+
await runCommand(command.nonInteractive[0], false);
|
|
31
49
|
}
|
|
32
50
|
}
|
|
33
51
|
}
|
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,MAAM,cAAc,CAAC;
|
|
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,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpD,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,0CAA0C;YAC1C,WAAW,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;YAClD,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,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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"
|
|
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,SA+Cd,CAAC"}
|
package/dist/orchestrator.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { buildCommands, buildUninstallCommands } from "./build_command.js";
|
|
2
2
|
import { getConfigObject } from "./config_reader.js";
|
|
3
|
-
import { display } from "./display.js";
|
|
3
|
+
import { display, stopSpinner } from "./display.js";
|
|
4
4
|
import { install } from "./install.js";
|
|
5
|
+
import { outro } from "@clack/prompts";
|
|
5
6
|
//Check if the value is an array of ConfigType objects
|
|
6
7
|
function isConfigTypeArray(value) {
|
|
7
8
|
return (Array.isArray(value) &&
|
|
@@ -21,12 +22,14 @@ export const orchestrator = (command, packages, options) => {
|
|
|
21
22
|
if (isConfigTypeArray(config)) {
|
|
22
23
|
const commands = buildCommands(config);
|
|
23
24
|
await install(commands);
|
|
24
|
-
|
|
25
|
+
stopSpinner("Packages installed successfully");
|
|
25
26
|
process.stdout.write("\x07");
|
|
27
|
+
outro("Done!");
|
|
26
28
|
}
|
|
27
29
|
else {
|
|
28
30
|
await install(config);
|
|
29
|
-
|
|
31
|
+
stopSpinner("Packages from package.json installed successfully");
|
|
32
|
+
outro("Done!");
|
|
30
33
|
}
|
|
31
34
|
});
|
|
32
35
|
}
|
|
@@ -40,7 +43,8 @@ export const orchestrator = (command, packages, options) => {
|
|
|
40
43
|
if (isConfigTypeArray(config)) {
|
|
41
44
|
const commands = buildUninstallCommands(config);
|
|
42
45
|
await install(commands);
|
|
43
|
-
|
|
46
|
+
stopSpinner("Packages uninstalled successfully");
|
|
47
|
+
outro("Done!");
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
50
|
}
|
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,MAAM,cAAc,CAAC;
|
|
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,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,sDAAsD;AACtD,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,KAAK,CAAC,KAAK,CACT,CAAC,IAAI,EAAE,EAAE,CACP,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,UAAU,IAAI,IAAI;YAClB,KAAK,CAAC,OAAO,CAAE,IAAY,CAAC,QAAQ,CAAC,CACxC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,OAAe,EACf,QAAkB,EAClB,OAAa,EACb,EAAE;IACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CACL,0BAA0B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAE,QAAqB,CAAC,IAAI,CAAC,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B,WAAW,CAAC,mCAAmC,CAAC,CAAC;gBACjD,KAAK,CAAC,OAAO,CAAC,CAAC;YACjB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
package/nodemon.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"watch": ["src"],
|
|
3
|
-
"ext": "ts,json",
|
|
4
|
-
"ignore": ["src/**/*.test.ts", "node_modules", "dist"],
|
|
5
|
-
"exec": "tsx src/index.ts"
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"watch": ["src"],
|
|
3
|
+
"ext": "ts,json",
|
|
4
|
+
"ignore": ["src/**/*.test.ts", "node_modules", "dist"],
|
|
5
|
+
"exec": "tsx src/index.ts"
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pm-auto",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "CLI
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A CLI tool to define and install your tech stack presets with one command.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pm-auto",
|
|
7
7
|
"yarn-auto",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"auto"
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"author": "Elliot Otoijagha",
|
|
12
|
+
"author": "Elliot Otoijagha, Triumph Aidenojie",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"bin": {
|
|
@@ -19,18 +19,19 @@
|
|
|
19
19
|
"build": "tsc",
|
|
20
20
|
"dev": "nodemon --exec tsx src/index.ts",
|
|
21
21
|
"start": "node dist/index.js",
|
|
22
|
-
"test": "
|
|
22
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@clack/prompts": "^0.11.0",
|
|
26
26
|
"chalk": "^5.6.2",
|
|
27
27
|
"commander": "^14.0.2",
|
|
28
|
-
"execa": "^9.6.0"
|
|
29
|
-
"ora": "^9.0.0"
|
|
28
|
+
"execa": "^9.6.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
31
|
+
"@types/jest": "^30.0.0",
|
|
32
32
|
"@types/node": "^24.10.1",
|
|
33
33
|
"nodemon": "^3.1.11",
|
|
34
|
+
"ts-jest": "^29.4.5",
|
|
34
35
|
"ts-node": "^10.9.2",
|
|
35
36
|
"tsx": "^4.20.6",
|
|
36
37
|
"typescript": "^5.9.3"
|
package/src/build_command.ts
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
import type { ConfigType, PackageType, CommandResult } from "./types/index.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Build commands from project configurations.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export function buildCommands(projects: ConfigType[]) {
|
|
8
|
-
// Initialize arrays properly
|
|
9
|
-
|
|
10
|
-
const commandArray: CommandResult[] = [];
|
|
11
|
-
for (const project of projects) {
|
|
12
|
-
const { packageManager, packages } = project;
|
|
13
|
-
|
|
14
|
-
const commandPrefixes = {
|
|
15
|
-
npm: {
|
|
16
|
-
install: "npm install",
|
|
17
|
-
run: "npx",
|
|
18
|
-
},
|
|
19
|
-
pnpm: {
|
|
20
|
-
install: "pnpm add",
|
|
21
|
-
run: "pnpm dlx",
|
|
22
|
-
},
|
|
23
|
-
yarn: {
|
|
24
|
-
install: "yarn add",
|
|
25
|
-
run: "yarn dlx",
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const manager =
|
|
30
|
-
commandPrefixes[packageManager as keyof typeof commandPrefixes] ||
|
|
31
|
-
commandPrefixes.npm;
|
|
32
|
-
|
|
33
|
-
const result: CommandResult = {
|
|
34
|
-
name: project.name,
|
|
35
|
-
interactive: [],
|
|
36
|
-
nonInteractive: [],
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Separate interactive from non-interactive packages
|
|
40
|
-
const nonInteractive: PackageType[] = [];
|
|
41
|
-
const interactive: PackageType[] = [];
|
|
42
|
-
|
|
43
|
-
if (packages) {
|
|
44
|
-
packages.forEach((pkg) => {
|
|
45
|
-
if (pkg.interactive) {
|
|
46
|
-
interactive.push(pkg);
|
|
47
|
-
} else {
|
|
48
|
-
nonInteractive.push(pkg);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Add interactive packages as separate commands (sequential)
|
|
54
|
-
interactive.forEach((pkg) => {
|
|
55
|
-
result.interactive.push(`${manager.run} ${pkg.command}`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Batch all non-interactive packages into ONE command
|
|
59
|
-
if (nonInteractive.length > 0) {
|
|
60
|
-
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
61
|
-
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
commandArray.push(result);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return commandArray;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function buildUninstallCommands(projects: ConfigType[]) {
|
|
71
|
-
const commandArray: CommandResult[] = [];
|
|
72
|
-
for (const project of projects) {
|
|
73
|
-
const { packageManager, packages } = project;
|
|
74
|
-
|
|
75
|
-
const commandPrefixes = {
|
|
76
|
-
npm: {
|
|
77
|
-
install: "npm uninstall",
|
|
78
|
-
},
|
|
79
|
-
pnpm: {
|
|
80
|
-
install: "pnpm uninstall",
|
|
81
|
-
},
|
|
82
|
-
yarn: {
|
|
83
|
-
install: "yarn remove",
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const manager =
|
|
88
|
-
commandPrefixes[packageManager as keyof typeof commandPrefixes] ||
|
|
89
|
-
commandPrefixes.npm;
|
|
90
|
-
|
|
91
|
-
const result: CommandResult = {
|
|
92
|
-
name: project.name,
|
|
93
|
-
interactive: [],
|
|
94
|
-
nonInteractive: [],
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// Separate interactive from non-interactive packages
|
|
98
|
-
const nonInteractive: PackageType[] = [];
|
|
99
|
-
const interactive: PackageType[] = [];
|
|
100
|
-
|
|
101
|
-
if (packages) {
|
|
102
|
-
packages.forEach((pkg) => {
|
|
103
|
-
if (!pkg.interactive) {
|
|
104
|
-
nonInteractive.push(pkg);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Batch all non-interactive packages into ONE command
|
|
110
|
-
if (nonInteractive.length > 0) {
|
|
111
|
-
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
112
|
-
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
commandArray.push(result);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return commandArray;
|
|
119
|
-
}
|
|
1
|
+
import type { ConfigType, PackageType, CommandResult } from "./types/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build commands from project configurations.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function buildCommands(projects: ConfigType[]) {
|
|
8
|
+
// Initialize arrays properly
|
|
9
|
+
|
|
10
|
+
const commandArray: CommandResult[] = [];
|
|
11
|
+
for (const project of projects) {
|
|
12
|
+
const { packageManager, packages } = project;
|
|
13
|
+
|
|
14
|
+
const commandPrefixes = {
|
|
15
|
+
npm: {
|
|
16
|
+
install: "npm install",
|
|
17
|
+
run: "npx",
|
|
18
|
+
},
|
|
19
|
+
pnpm: {
|
|
20
|
+
install: "pnpm add",
|
|
21
|
+
run: "pnpm dlx",
|
|
22
|
+
},
|
|
23
|
+
yarn: {
|
|
24
|
+
install: "yarn add",
|
|
25
|
+
run: "yarn dlx",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const manager =
|
|
30
|
+
commandPrefixes[packageManager as keyof typeof commandPrefixes] ||
|
|
31
|
+
commandPrefixes.npm;
|
|
32
|
+
|
|
33
|
+
const result: CommandResult = {
|
|
34
|
+
name: project.name,
|
|
35
|
+
interactive: [],
|
|
36
|
+
nonInteractive: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Separate interactive from non-interactive packages
|
|
40
|
+
const nonInteractive: PackageType[] = [];
|
|
41
|
+
const interactive: PackageType[] = [];
|
|
42
|
+
|
|
43
|
+
if (packages) {
|
|
44
|
+
packages.forEach((pkg) => {
|
|
45
|
+
if (pkg.interactive) {
|
|
46
|
+
interactive.push(pkg);
|
|
47
|
+
} else {
|
|
48
|
+
nonInteractive.push(pkg);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Add interactive packages as separate commands (sequential)
|
|
54
|
+
interactive.forEach((pkg) => {
|
|
55
|
+
result.interactive.push(`${manager.run} ${pkg.command}`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Batch all non-interactive packages into ONE command
|
|
59
|
+
if (nonInteractive.length > 0) {
|
|
60
|
+
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
61
|
+
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
commandArray.push(result);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return commandArray;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function buildUninstallCommands(projects: ConfigType[]) {
|
|
71
|
+
const commandArray: CommandResult[] = [];
|
|
72
|
+
for (const project of projects) {
|
|
73
|
+
const { packageManager, packages } = project;
|
|
74
|
+
|
|
75
|
+
const commandPrefixes = {
|
|
76
|
+
npm: {
|
|
77
|
+
install: "npm uninstall",
|
|
78
|
+
},
|
|
79
|
+
pnpm: {
|
|
80
|
+
install: "pnpm uninstall",
|
|
81
|
+
},
|
|
82
|
+
yarn: {
|
|
83
|
+
install: "yarn remove",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const manager =
|
|
88
|
+
commandPrefixes[packageManager as keyof typeof commandPrefixes] ||
|
|
89
|
+
commandPrefixes.npm;
|
|
90
|
+
|
|
91
|
+
const result: CommandResult = {
|
|
92
|
+
name: project.name,
|
|
93
|
+
interactive: [],
|
|
94
|
+
nonInteractive: [],
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Separate interactive from non-interactive packages
|
|
98
|
+
const nonInteractive: PackageType[] = [];
|
|
99
|
+
const interactive: PackageType[] = [];
|
|
100
|
+
|
|
101
|
+
if (packages) {
|
|
102
|
+
packages.forEach((pkg) => {
|
|
103
|
+
if (!pkg.interactive) {
|
|
104
|
+
nonInteractive.push(pkg);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Batch all non-interactive packages into ONE command
|
|
110
|
+
if (nonInteractive.length > 0) {
|
|
111
|
+
const packageNames = nonInteractive.map((pkg) => pkg.command).join(" ");
|
|
112
|
+
result.nonInteractive.push(`${manager.install} ${packageNames}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
commandArray.push(result);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return commandArray;
|
|
119
|
+
}
|
package/src/config_path.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
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
|
-
|
|
6
|
-
const SETTINGS_DIR = path.join(os.homedir(), ".pm-auto");
|
|
7
|
-
const SETTINGS_FILE = path.join(SETTINGS_DIR, "settings.json");
|
|
8
|
-
|
|
9
|
-
interface Settings {
|
|
10
|
-
configPath?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function saveConfigPath(configPath: string): void {
|
|
14
|
-
// Create directory if it doesn't exist
|
|
15
|
-
if (!fs.existsSync(SETTINGS_DIR)) {
|
|
16
|
-
fs.mkdirSync(SETTINGS_DIR, { recursive: true });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//check if file exists
|
|
20
|
-
try {
|
|
21
|
-
const real = fs.realpathSync(configPath);
|
|
22
|
-
const settings: Settings = { configPath: real };
|
|
23
|
-
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
24
|
-
|
|
25
|
-
display(`Config file path saved: ${configPath}`, "success");
|
|
26
|
-
} catch (err: any) {
|
|
27
|
-
display(`Error saving config file: ${err.message}`, "error");
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function getConfigPath(): string | void {
|
|
32
|
-
//check if settings exists
|
|
33
|
-
if (!fs.existsSync(SETTINGS_FILE)) {
|
|
34
|
-
display(
|
|
35
|
-
"Run `pm-auto config <path>`, where <path> is the path to your config file",
|
|
36
|
-
"info",
|
|
37
|
-
);
|
|
38
|
-
display("Config file path not set", "error");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const data = fs.readFileSync(SETTINGS_FILE, "utf8");
|
|
43
|
-
const settings: Settings = JSON.parse(data);
|
|
44
|
-
return settings.configPath || "";
|
|
45
|
-
} catch (error: any) {
|
|
46
|
-
display(`Error reading config file path: ${error.message}`, "error");
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function clearConfigPath(): void {
|
|
51
|
-
if (fs.existsSync(SETTINGS_FILE)) {
|
|
52
|
-
fs.unlinkSync(SETTINGS_FILE);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
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
|
+
|
|
6
|
+
const SETTINGS_DIR = path.join(os.homedir(), ".pm-auto");
|
|
7
|
+
const SETTINGS_FILE = path.join(SETTINGS_DIR, "settings.json");
|
|
8
|
+
|
|
9
|
+
interface Settings {
|
|
10
|
+
configPath?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function saveConfigPath(configPath: string): void {
|
|
14
|
+
// Create directory if it doesn't exist
|
|
15
|
+
if (!fs.existsSync(SETTINGS_DIR)) {
|
|
16
|
+
fs.mkdirSync(SETTINGS_DIR, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//check if file exists
|
|
20
|
+
try {
|
|
21
|
+
const real = fs.realpathSync(configPath);
|
|
22
|
+
const settings: Settings = { configPath: real };
|
|
23
|
+
fs.writeFileSync(SETTINGS_FILE, JSON.stringify(settings, null, 2));
|
|
24
|
+
|
|
25
|
+
display(`Config file path saved: ${configPath}`, "success");
|
|
26
|
+
} catch (err: any) {
|
|
27
|
+
display(`Error saving config file: ${err.message}`, "error");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getConfigPath(): string | void {
|
|
32
|
+
//check if settings exists
|
|
33
|
+
if (!fs.existsSync(SETTINGS_FILE)) {
|
|
34
|
+
display(
|
|
35
|
+
"Run `pm-auto config <path>`, where <path> is the path to your config file",
|
|
36
|
+
"info",
|
|
37
|
+
);
|
|
38
|
+
display("Config file path not set", "error");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const data = fs.readFileSync(SETTINGS_FILE, "utf8");
|
|
43
|
+
const settings: Settings = JSON.parse(data);
|
|
44
|
+
return settings.configPath || "";
|
|
45
|
+
} catch (error: any) {
|
|
46
|
+
display(`Error reading config file path: ${error.message}`, "error");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function clearConfigPath(): void {
|
|
51
|
+
if (fs.existsSync(SETTINGS_FILE)) {
|
|
52
|
+
fs.unlinkSync(SETTINGS_FILE);
|
|
53
|
+
}
|
|
54
|
+
}
|