This commit is contained in:
mbecker20
2022-03-30 01:24:01 -07:00
parent 7141530c86
commit 3f1e7e6e62
12 changed files with 75 additions and 42 deletions
+7 -1
View File
@@ -39,9 +39,14 @@ async function build(
app.broadcast(BUILD, { complete: false, buildID });
const { cliBuild, dockerBuildArgs } = build;
try {
const pull = await execute(
`cd ${BUILD_REPO_PATH + build.pullName} && git pull origin ${
build.branch || "main"
}`
);
const cli = cliBuild
? await execute(
`cd ${BUILD_REPO_PATH}${
`cd ${BUILD_REPO_PATH + build.pullName}${
cliBuild.path ? (cliBuild.path[0] === "/" ? "" : "/") : ""
}${cliBuild.path} && ${cliBuild.command}`
)
@@ -55,6 +60,7 @@ async function build(
)
: undefined;
const { command, log, isError } = mergeCommandLogError(
{ name: "log", cle: pull },
{ name: "cli", cle: cli },
{ name: "docker", cle: docker }
);
@@ -35,6 +35,11 @@ export const ConfigProvider: Component<{ build: Build }> = (p) => {
getBuild(p.build._id!).then((build) => {
set({
...build,
repo: build.repo,
branch: build.branch,
onClone: build.onClone,
dockerBuildArgs: build.dockerBuildArgs,
cliBuild: build.cliBuild,
loaded: true,
updated: false,
saving: false
@@ -16,7 +16,7 @@ const CliBuild: Component<{}> = (p) => {
<div>build path</div>
<Input
placeholder="from root of repo"
value={build.cliBuild?.path}
value={build.cliBuild?.path || ""}
onEdit={(path) => setBuild("cliBuild", { path })}
/>
</Flex>
@@ -24,7 +24,7 @@ const CliBuild: Component<{}> = (p) => {
<div>command</div>
<Input
placeholder="ie. yarn build"
value={build.cliBuild?.command}
value={build.cliBuild?.command || ""}
onEdit={(command) => setBuild("cliBuild", { command })}
/>
</Flex>
@@ -15,16 +15,16 @@ const Docker: Component<{}> = (p) => {
<div>build path</div>
<Input
placeholder="from root of repo"
value={build.dockerBuildArgs?.buildPath}
onEdit={(value) => setBuild("dockerBuildArgs", "buildPath", value)}
value={build.dockerBuildArgs?.buildPath || ""}
onEdit={(buildPath) => setBuild("dockerBuildArgs", { buildPath })}
/>
</Flex>
<Flex justifyContent="space-between" alignItems="center">
<div>dockerfile path</div>
<Input
placeholder="from root of repo"
value={build.dockerBuildArgs?.buildPath}
onEdit={(value) => setBuild("dockerBuildArgs", "buildPath", value)}
placeholder="from root of build path"
value={build.dockerBuildArgs?.dockerfilePath || ""}
onEdit={(dockerfilePath) => setBuild("dockerBuildArgs", { dockerfilePath })}
/>
</Flex>
</Grid>
@@ -15,7 +15,7 @@ const Git: Component<{}> = (p) => {
<div>repo</div>
<Input
placeholder="ie. solidjs/solid"
value={build.repo}
value={build.repo || ""}
onEdit={(value) => setBuild("repo", value)}
/>
</Flex>
@@ -23,7 +23,7 @@ const Git: Component<{}> = (p) => {
<div>branch</div>
<Input
placeholder="defaults to main"
value={build.branch}
value={build.branch || ""}
onEdit={(value) => setBuild("branch", value)}
/>
</Flex>
@@ -31,7 +31,7 @@ const Git: Component<{}> = (p) => {
<div>access token</div>
<Input
placeholder="paste token"
value={build.accessToken}
value={build.accessToken || ""}
onEdit={(value) => setBuild("accessToken", value)}
/>
</Flex>
@@ -21,7 +21,7 @@ const GitConfig: Component<{}> = (p) => {
</Grid>
<Show when={build.updated}>
<Show when={!build.saving} fallback={<button class="green">
<Loading type="spinner" />
updating <Loading type="spinner" />
</button>}>
<Flex style={{ "place-self": "center", padding: "1rem" }}>
<button onClick={reset}>
@@ -12,15 +12,31 @@ const OnClone: Component = () => {
<h1>on clone</h1>
<Input
placeholder="path"
value={build.onClone?.path}
value={build.onClone?.path || ""}
onEdit={(path) => {
if (
path.length === 0 &&
(!build.onClone ||
!build.onClone.command ||
build.onClone.command.length === 0)
) {
setBuild("onClone", undefined);
}
setBuild("onClone", { path });
}}
/>
<Input
placeholder="command"
value={build.onClone?.command}
value={build.onClone?.command || ""}
onEdit={(command) => {
if (
command.length === 0 &&
(!build.onClone ||
!build.onClone.path ||
build.onClone.path.length === 0)
) {
setBuild("onClone", undefined);
}
setBuild("onClone", { command });
}}
/>
+25 -17
View File
@@ -76,20 +76,28 @@ const Actions: Component<{}> = (p) => {
<Flex class={combineClasses(s.Action, "shadow")}>
deploy{" "}
<Flex>
<ConfirmButton
color="green"
onConfirm={() => {
ws.send(DEPLOY, { deploymentID: deployment()._id });
pushNotification("ok", `deploying ${deployment().name}...`);
}}
<Show
when={!actions.deploying}
fallback={
<button class="green">
<Loading type="spinner" />
</button>
}
>
<Show
when={!actions.deploying}
fallback={<Loading type="spinner" scale={0.25} />}
<ConfirmButton
color="green"
onConfirm={() => {
ws.send(DEPLOY, { deploymentID: deployment()._id });
pushNotification(
"ok",
`deploying ${deployment().name}...`
);
}}
>
<Icon type="reset" />
</Show>
</ConfirmButton>
</ConfirmButton>
</Show>
<ConfirmButton
color="red"
onConfirm={() => {
@@ -101,7 +109,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.deleting}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="trash" />
</Show>
@@ -119,7 +127,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.stopping}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="pause" />
</Show>
@@ -145,7 +153,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.deploying}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="reset" />
</Show>
@@ -161,7 +169,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.deleting}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="trash" />
</Show>
@@ -179,7 +187,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.starting}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="play" />
</Show>
@@ -199,7 +207,7 @@ const Actions: Component<{}> = (p) => {
>
<Show
when={!actions.deploying}
fallback={<Loading type="spinner" scale={0.25} />}
fallback={<Loading type="spinner" />}
>
<Icon type="play" />
</Show>
+3 -3
View File
@@ -1,6 +1,6 @@
/* CSS from https://loading.io/css/ */
export function spinnerCss(scale = 0.5) {
export function spinnerCss(scale = 0.25) {
return `
.Spinner {
display: inline-block;
@@ -40,7 +40,7 @@ export function spinnerCss(scale = 0.5) {
`;
}
export function sonarCss(scale = 0.5) {
export function sonarCss(scale = 0.25) {
return `
.Sonar {
display: inline-block;
@@ -77,7 +77,7 @@ export function sonarCss(scale = 0.5) {
`;
}
export function threeDotsCss(scale = 0.5) {
export function threeDotsCss(scale = 0.25) {
return `
.ThreeDot {
display: inline-block;
+1 -1
View File
@@ -53,7 +53,7 @@ export type Server = {
export type DockerBuildArgs = {
buildPath: string; // build folder relative to repo root
dockerfilePath: string; // relative to buildPath
dockerfilePath?: string; // relative to buildPath
};
// these are potentially dangerous but also useful
+4 -6
View File
@@ -36,9 +36,7 @@ export async function createNetwork(
}
export async function deleteNetwork(name: string): Promise<CommandLogError> {
return await execute(
`docker network rm ${name}`
);
return await execute(`docker network rm ${name}`);
}
export async function pruneNetworks(): Promise<CommandLogError> {
@@ -112,9 +110,9 @@ export async function dockerBuild(
buildPath && (buildPath[0] === "/" ? buildPath : "/" + buildPath)
}`;
const build = `docker build -t ${
registryUrl + imageName
} -f ${dockerfilePath} .`;
const build = `docker build -t ${registryUrl + imageName}${
dockerfilePath ? ` -f ${dockerfilePath}` : ""
} .`;
const push = `docker push ${registryUrl + imageName}`;
+1 -1
View File
@@ -54,7 +54,7 @@ export async function clone(
}
}
export async function pull(folder: string, branch = "master") {
export async function pull(folder: string, branch = "main") {
const command = `cd ${folder} && git pull origin ${branch}`;
return await execute(command);
}