Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit 63bb38f

Browse files
authored
Minor fixes and allow port as argument (#79)
1 parent 52d9b1a commit 63bb38f

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

src/commands/deployment/dashboard.ts

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import commander from "commander";
22
import open = require("open");
3+
import { env } from "shelljs";
34
import { exec } from "../../lib/shell";
45
import { logger } from "../../logger";
56
import { validatePrereqs } from "../infra/vaildate";
@@ -14,7 +15,8 @@ export const dashboardCommandDecorator = (command: commander.Command): void => {
1415
.command("dashboard")
1516
.alias("d")
1617
.description("Launch the service introspection dashboard")
17-
.action(async () => {
18+
.option("-p, --port <port>", "Port to launch the dashboard on", 4040)
19+
.action(async opts => {
1820
if (
1921
!config.introspection ||
2022
!config.azure_devops ||
@@ -31,9 +33,8 @@ export const dashboardCommandDecorator = (command: commander.Command): void => {
3133
);
3234
return;
3335
}
34-
const port = 1010;
35-
if (await launchDashboard(port)) {
36-
await open("http://localhost:" + port);
36+
if (await launchDashboard(opts.port)) {
37+
await open("http://localhost:" + opts.port);
3738
}
3839
});
3940
};
@@ -51,21 +52,7 @@ export const launchDashboard = async (port: number): Promise<string> => {
5152
"run",
5253
"-d",
5354
"--rm",
54-
"-e",
55-
"REACT_APP_PIPELINE_ORG=" + config.azure_devops!.org!,
56-
"-e",
57-
"REACT_APP_PIPELINE_PROJECT=" + config.azure_devops!.project!,
58-
"-e",
59-
"REACT_APP_STORAGE_ACCOUNT_NAME=" +
60-
config.introspection!.azure!.account_name!,
61-
"-e",
62-
"REACT_APP_STORAGE_PARTITION_KEY=" +
63-
config.introspection!.azure!.partition_key!,
64-
"-e",
65-
"REACT_APP_STORAGE_TABLE_NAME=" +
66-
config.introspection!.azure!.table_name!,
67-
"-e",
68-
"REACT_APP_STORAGE_ACCESS_KEY=" + config.introspection!.azure!.key!,
55+
...getEnvVars(),
6956
"-p",
7057
port + ":80",
7158
dockerRepository
@@ -76,3 +63,37 @@ export const launchDashboard = async (port: number): Promise<string> => {
7663
return "";
7764
}
7865
};
66+
67+
const getEnvVars = (): string[] => {
68+
const envVars = [];
69+
envVars.push("-e");
70+
envVars.push("REACT_APP_PIPELINE_ORG=" + config.azure_devops!.org!);
71+
envVars.push("-e");
72+
envVars.push("REACT_APP_PIPELINE_PROJECT=" + config.azure_devops!.project!);
73+
envVars.push("-e");
74+
envVars.push(
75+
"REACT_APP_STORAGE_ACCOUNT_NAME=" +
76+
config.introspection!.azure!.account_name!
77+
);
78+
envVars.push("-e");
79+
envVars.push(
80+
"REACT_APP_STORAGE_PARTITION_KEY=" +
81+
config.introspection!.azure!.partition_key!
82+
);
83+
envVars.push("-e");
84+
envVars.push(
85+
"REACT_APP_STORAGE_TABLE_NAME=" + config.introspection!.azure!.table_name!
86+
);
87+
envVars.push("-e");
88+
envVars.push(
89+
"REACT_APP_STORAGE_ACCESS_KEY=" + config.introspection!.azure!.key!
90+
);
91+
if (config.azure_devops!.access_token) {
92+
envVars.push("-e");
93+
envVars.push(
94+
"REACT_APP_PIPELINE_ACCESS_TOKEN=" + config.azure_devops!.access_token
95+
);
96+
}
97+
98+
return envVars;
99+
};

0 commit comments

Comments
 (0)