forked from kriasoft/graphql-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
51 lines (43 loc) · 1.33 KB
/
postinstall.js
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
/* SPDX-FileCopyrightText: 2016-present Kriasoft */
/* SPDX-License-Identifier: MIT */
import { execa } from "execa";
import { EOL } from "node:os";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { fs } from "zx";
if (process.env.CI === "true") process.exit();
export const rootDir = dirname(dirname(fileURLToPath(import.meta.url)));
process.cwd(rootDir);
const environments = [
{ name: "local", description: "development" },
{ name: "test", description: "staging/QA" },
{ name: "prod", description: "production" },
];
// Enable Git hooks
// https://typicode.github.io/husky/
await execa("yarn", ["husky", "install"], { stdio: "inherit" });
// Create environment variable override files
// such as `env/.prod.override.env`.
for (const env of environments) {
const filename = `./env/.${env.name}.override.env`;
if (!fs.existsSync(filename)) {
await fs.writeFile(
filename,
[
`# Overrides for the "${env.name}" (${env.description}) environment`,
`#`,
`# GOOGLE_CLOUD_CREDENTIALS=xxxxx`,
"# CLOUDFLARE_API_TOKEN=xxxxx",
`# SENDGRID_API_KEY=SG.xxxxx`,
`# PGPASSWORD=xxxxx`,
``,
].join(EOL),
"utf-8",
);
}
}
try {
await execa("yarn", ["tsc", "--build"], { stdin: "inherit" });
} catch (err) {
console.error(err);
}