-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.mjs
98 lines (90 loc) · 2.69 KB
/
dev.mjs
1
2
3
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
64
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
90
91
92
93
94
95
96
97
98
import concurrently from "concurrently";
import inquirer from "inquirer";
import chalk from "chalk";
const services = [
{ name: "COMMENT", profile: "Comment.Presentation", prefixColor: "green" },
{ name: "FILE", profile: "File.Presentation", prefixColor: "yellow" },
{ name: "GROUP", profile: "Group.Presentation", prefixColor: "magenta" },
{ name: "IDENTITY", profile: "Identity.Presentation", prefixColor: "cyan" },
{ name: "MAIL", profile: "Mail.Presentation", prefixColor: "red" },
{
name: "NOTIFICATION",
profile: "Notification.Presentation",
prefixColor: "blueBright",
},
{
name: "OCELOT",
profile: "Ocelot.Presentaition",
prefixColor: "greenBright",
},
{ name: "POST", profile: "Post.Presentation", prefixColor: "blue" },
{
name: "PROFILE",
profile: "Profile.Presentation",
prefixColor: "magentaBright",
},
{
name: "REACTION",
profile: "Reaction.Presentation",
prefixColor: "cyanBright",
},
{
name: "RELATIONSHIP",
profile: "Relationship.Presentation",
prefixColor: "redBright",
},
];
async function runMenu() {
const { servicesToRun } = await inquirer.prompt([
{
type: "checkbox",
name: "servicesToRun",
message: "Select the services to run:",
choices: services.map((service) => ({
name: service.name,
value: service.profile,
})),
},
]);
if (servicesToRun.length === 0) {
console.log(chalk.red("No services selected. Exiting..."));
return;
}
const { watchModeServices } = await inquirer.prompt([
{
type: "checkbox",
name: "watchModeServices",
message: "Select the services to run in watch mode:",
choices: servicesToRun.map((profile) => {
const service = services.find((s) => s.profile === profile);
return { name: service.name, value: profile };
}),
},
]);
const commands = servicesToRun.map((profile) => {
const service = services.find((s) => s.profile === profile);
return {
command: watchModeServices.includes(profile)
? `dotnet watch run --launch-profile https --project ${profile}`
: `dotnet run --launch-profile https --project ${profile}`,
name: service.name,
prefixColor: watchModeServices.includes(profile)
? service.prefixColor
: "gray",
};
});
const processManager = concurrently(commands, {
prefix: "name",
restartTries: 3,
killOthers: ["failure", "success"],
output: "always",
});
processManager.result
.then(() => {
console.log(chalk.green("All selected services started successfully."));
})
.catch((error) => {
console.error(chalk.red("Some service failed:"), error);
});
}
runMenu();