sim-setup 1.0.31-preview.176.1 → 1.0.31-preview.177.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/dist/index.js +53 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12016,6 +12016,45 @@ function dockerText(args, cwd = ROOT) {
|
|
|
12016
12016
|
const result = spawnSync8("docker", args, { cwd, encoding: "utf8" });
|
|
12017
12017
|
return result.status === 0 ? result.stdout.trim() : null;
|
|
12018
12018
|
}
|
|
12019
|
+
function composeServiceState(stateOutput) {
|
|
12020
|
+
if (stateOutput === null)
|
|
12021
|
+
return "unknown";
|
|
12022
|
+
const states = stateOutput.split(`
|
|
12023
|
+
`).map((state) => state.trim()).filter(Boolean);
|
|
12024
|
+
if (states.length === 0)
|
|
12025
|
+
return null;
|
|
12026
|
+
return { state: states.includes("running") ? "running" : "stopped" };
|
|
12027
|
+
}
|
|
12028
|
+
function composeServiceQuery(project, service) {
|
|
12029
|
+
return [
|
|
12030
|
+
"ps",
|
|
12031
|
+
"-a",
|
|
12032
|
+
"--filter",
|
|
12033
|
+
`label=com.docker.compose.project=${project}`,
|
|
12034
|
+
"--filter",
|
|
12035
|
+
`label=com.docker.compose.service=${service}`,
|
|
12036
|
+
"--format",
|
|
12037
|
+
"{{.State}}"
|
|
12038
|
+
];
|
|
12039
|
+
}
|
|
12040
|
+
function serviceStatusRows(installs, standalone, query = (args) => dockerText(args)) {
|
|
12041
|
+
const rows = [];
|
|
12042
|
+
const stacks = installs.filter((install) => install.kind === "compose");
|
|
12043
|
+
if (stacks.length === 0 || installs.some((install) => install.kind === "dev")) {
|
|
12044
|
+
rows.push({ label: `postgres (${DB_CONTAINER})`, state: standalone.db }, { label: `redis (${REDIS_CONTAINER})`, state: standalone.redis });
|
|
12045
|
+
}
|
|
12046
|
+
for (const stack of stacks) {
|
|
12047
|
+
const scope = stacks.length > 1 ? `${stack.project} ` : "";
|
|
12048
|
+
rows.push({
|
|
12049
|
+
label: `${scope}postgres (compose db)`,
|
|
12050
|
+
state: composeServiceState(query(composeServiceQuery(stack.project, "db")))
|
|
12051
|
+
}, {
|
|
12052
|
+
label: `${scope}redis (compose redis)`,
|
|
12053
|
+
state: composeServiceState(query(composeServiceQuery(stack.project, "redis")))
|
|
12054
|
+
});
|
|
12055
|
+
}
|
|
12056
|
+
return rows;
|
|
12057
|
+
}
|
|
12019
12058
|
function dockerInherit(args, cwd = ROOT) {
|
|
12020
12059
|
return spawnSync8("docker", args, { cwd, stdio: "inherit" }).status ?? 1;
|
|
12021
12060
|
}
|
|
@@ -12394,10 +12433,21 @@ ${theme.heading("◆ Sim status")}
|
|
|
12394
12433
|
}
|
|
12395
12434
|
for (const install of installs)
|
|
12396
12435
|
console.log(` ${glyph.pass} ${describeInstall(install)}`);
|
|
12397
|
-
const containerState = (state) =>
|
|
12436
|
+
const containerState = (state) => {
|
|
12437
|
+
if (!docker)
|
|
12438
|
+
return "unknown (docker down)";
|
|
12439
|
+
if (state === "unknown")
|
|
12440
|
+
return "unknown (docker query failed)";
|
|
12441
|
+
return state ? state.state : "absent";
|
|
12442
|
+
};
|
|
12398
12443
|
console.log();
|
|
12399
|
-
|
|
12400
|
-
|
|
12444
|
+
const rows = serviceStatusRows(installs, {
|
|
12445
|
+
db: detection.dbContainer,
|
|
12446
|
+
redis: detection.redisContainer
|
|
12447
|
+
});
|
|
12448
|
+
const width = Math.max(...rows.map((row) => row.label.length)) + 3;
|
|
12449
|
+
for (const row of rows)
|
|
12450
|
+
console.log(` ${`${row.label}:`.padEnd(width)}${containerState(row.state)}`);
|
|
12401
12451
|
const [app, realtime] = await Promise.all([
|
|
12402
12452
|
httpHealth(`${APP_URL}/api/health`),
|
|
12403
12453
|
httpHealth(REALTIME_HEALTH)
|