Skip to content

Commit 757a2a1

Browse files
fix: fix copy bug
1 parent 1515890 commit 757a2a1

File tree

7 files changed

+27
-40
lines changed

7 files changed

+27
-40
lines changed

src/backend/db.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import getGithubUser from "./utils/github-user.ts";
2-
import { Context, exec, Sentry } from "./dependencies.ts";
3-
import dockerize from "./utils/container.ts";
4-
import { checkJWT } from "./utils/jwt.ts";
52
import DfContentMap from "./types/maps_interface.ts";
63

74
const DATA_API_KEY = Deno.env.get("MONGO_API_KEY")!;

src/backend/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function addSubdomain(ctx: Context) {
2525
} catch (e) {
2626
document = body;
2727
}
28-
const copy = document;
28+
const copy = { ...document };
2929
const token = document.token;
3030
delete document.token;
3131
delete document.port;

src/backend/scripts.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,32 @@ async function addScript(
1010
port: string,
1111
build_cmds: string,
1212
) {
13-
if (document.resource_type === "URL") {
14-
await exec(
15-
`bash -c "echo 'bash ../../src/backend/utils/automate.sh -u ${document.resource} ${document.subdomain}' > /hostpipe/pipe"`,
16-
);
17-
} else if (document.resource_type === "PORT") {
18-
await exec(
19-
`bash -c "echo 'bash ../../src/backend/utils/automate.sh -p ${document.resource} ${document.subdomain}' > /hostpipe/pipe"`,
20-
);
21-
} else if (document.resource_type === "GITHUB" && static_content == "Yes") {
22-
Deno.writeTextFile(`/hostpipe/.env`,env_content)
23-
await exec(
24-
`bash -c "echo 'bash ../../src/backend/utils/container.sh -s ${document.subdomain} ${document.resource}' > /hostpipe/pipe"`,
25-
);
26-
} else if (document.resource_type === "GITHUB" && static_content == "No") {
27-
let dockerfile = dockerize(stack, port, build_cmds);
28-
Deno.writeTextFile(`/hostpipe/Dockerfile`,dockerfile)
29-
Deno.writeTextFile(`/hostpipe/.env`,env_content)
30-
await exec(
31-
`bash -c "echo 'bash ../../src/backend/utils/container.sh -g ${document.subdomain} ${document.resource} ${port}' > /hostpipe/pipe"`);
32-
}
13+
if (document.resource_type === "URL") {
14+
await exec(
15+
`bash -c "echo 'bash ../../src/backend/shell_scripts/automate.sh -u ${document.resource} ${document.subdomain}' > /hostpipe/pipe"`,
16+
);
17+
} else if (document.resource_type === "PORT") {
18+
await exec(
19+
`bash -c "echo 'bash ../../src/backend/shell_scripts/automate.sh -p ${document.resource} ${document.subdomain}' > /hostpipe/pipe"`,
20+
);
21+
} else if (document.resource_type === "GITHUB" && static_content == "Yes") {
22+
Deno.writeTextFile(`/hostpipe/.env`, env_content);
23+
await exec(
24+
`bash -c "echo 'bash ../../src/backend/shell_scripts/container.sh -s ${document.subdomain} ${document.resource}' > /hostpipe/pipe"`,
25+
);
26+
} else if (document.resource_type === "GITHUB" && static_content == "No") {
27+
const dockerfile = dockerize(stack, port, build_cmds);
28+
Deno.writeTextFile(`/hostpipe/Dockerfile`, dockerfile);
29+
Deno.writeTextFile(`/hostpipe/.env`, env_content);
30+
await exec(
31+
`bash -c "echo 'bash ../../src/backend/shell_scripts/container.sh -g ${document.subdomain} ${document.resource} ${port}' > /hostpipe/pipe"`,
32+
);
33+
}
3334
}
3435

3536
async function deleteScript(document: DfContentMap) {
3637
await exec(
37-
`bash -c "echo 'bash ../../src/backend/utils/delete.sh ${document.subdomain}' > /hostpipe/pipe"`,
38+
`bash -c "echo 'bash ../../src/backend/shell_scripts/delete.sh ${document.subdomain}' > /hostpipe/pipe"`,
3839
);
3940
}
4041

File renamed without changes.

src/backend/utils/container.sh renamed to src/backend/shell_scripts/container.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ done
1616
echo "Available ports: ${available_ports[56]}"
1717
AVAILABLE=0
1818
if [ $flag = "-g" ]; then
19-
echo "idhar";
20-
echo 'hello'
2119
git clone $resource $name
2220
sudo cp Dockerfile $name/
2321
sudo cp .env $name/
File renamed without changes.

src/backend/utils/container.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export default function dockerize(
44
build_cmds: string,
55
) {
66
let dockerfile = "";
7-
let run_cmd = build_cmds.split("\n");
8-
let execute_cmd = "CMD " + JSON.stringify(run_cmd.pop().split(" "));
9-
let build_cmds_mapped = run_cmd.map((elem) => {
7+
const run_cmd = build_cmds.split("\n");
8+
const execute_cmd = "CMD " + JSON.stringify(run_cmd.pop()?.split(" "));
9+
const build_cmds_mapped = run_cmd.map((elem) => {
1010
return "RUN " + elem;
1111
}).join("\n");
1212
if (stack == "Python") {
@@ -17,16 +17,7 @@ export default function dockerize(
1717
dockerfile =
1818
"FROM node:latest \n WORKDIR /app \n COPY ./package*.json . \n RUN npm install \n COPY . ." +
1919
build_cmds_mapped + `\n EXPOSE ${port} \n` + execute_cmd;
20-
console.log(port)
20+
console.log(port);
2121
}
22-
// dockerfile = btoa(dockerfile);
2322
return dockerfile.toString();
2423
}
25-
26-
// bash ./container.sh -g hack "https://github.com/angelmittal03/mdg-text.git" 'FROM node:latest
27-
// WORKDIR /app
28-
// COPY ./client/package*.json .
29-
// RUN npm install
30-
// COPY . .
31-
// EXPOSE 3000
32-
// CMD ["npm","start"]' 3000

0 commit comments

Comments
 (0)