-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-captain-api.ts
64 lines (56 loc) · 1.67 KB
/
build-captain-api.ts
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
import { copy, copyFile, exists } from "fs-extra";
import { exec } from "node:child_process";
import { join } from "node:path";
import { computeMetaHash } from "./compute-meta-hash";
(async function build() {
/**
* Compute hash
*/
const buildHash = computeMetaHash([join(__dirname, "../apps/api")]);
/**
* Dockerfile
*/
const dockerfileOrigin = join(__dirname, "../apps/api/Dockerfile");
if (await exists(dockerfileOrigin)) {
await copyFile(
dockerfileOrigin,
join(__dirname, "../dist/apps/api/Dockerfile")
);
console.log("🗸 Copied Dockerfile");
}
/**
* captain-definition
*/
const captainOrigin = join(__dirname, "../apps/api/captain-definition");
if (await exists(captainOrigin)) {
await copyFile(
captainOrigin,
join(__dirname, "../dist/apps/api/captain-definition")
);
console.log("🗸 Copied captain-definition");
}
/**
* Copy prisma
*/
const prismaOrigin = join(__dirname, `../apps/api/prisma`);
const prismaDestination = join(__dirname, `../dist/apps/api/prisma`);
await copy(prismaOrigin, prismaDestination);
/**
* Copy Scripts
*/
const scriptsOrigin = join(__dirname, `../scripts`);
const scriptsDestination = join(__dirname, `../dist/apps/api/scripts`);
await copy(scriptsOrigin, scriptsDestination);
/**
* Build tarball
*/
const distFolder = join(__dirname, `../dist/apps/api`);
const artifactName = "proghours-api.tar";
exec(`cd ${distFolder} && tar -czvf ../${artifactName} .`, (error) => {
if (error) {
console.log(`🚨 Error: ${error.message}`);
return;
}
console.log(`🎉 Successfully created: ${artifactName}`);
});
})();