Skip to content

Commit 60c702a

Browse files
committed
chore: adjust script outputs
1 parent 877c442 commit 60c702a

File tree

9 files changed

+84
-33
lines changed

9 files changed

+84
-33
lines changed

Makefile

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# --- Pipeline
2-
3-
info:
4-
sh scripts/package/info.sh
5-
6-
bump:
7-
sh scripts/package/bump.sh "$(PROJECT)"
1+
# --- Git
82

93
sign:
104
git add .
115
git commit -S
126

137
shelf:
8+
git add .
9+
git commit -S
1410
git push
1511

16-
push:
12+
release:
1713
sh scripts/package/bump.sh "$(PROJECT)"
1814
git push
1915

16+
# --- Package
17+
18+
info:
19+
sh scripts/package/info.sh
20+
2021
reset:
2122
sh scripts/deploy/reset.sh
2223

2324
build:
24-
${MAKE} -C frontend build
25-
${MAKE} -C http build
25+
sh scripts/package/build.sh
2626

2727
plan:
2828
cd terraform && terraform plan
@@ -31,23 +31,20 @@ apply:
3131
cd terraform && terraform apply
3232

3333
deploy:
34-
dotenvx run -f .env.production -- sh scripts/deploy/docker.sh
34+
sh scripts/deploy/docker.sh
3535

3636
vercel:
37-
${MAKE} -C frontend build
38-
node scripts/deploy/vercel-pre.mjs
39-
vercel build
40-
vercel .
41-
node scripts/deploy/vercel-post.mjs
42-
43-
# --- Environment
37+
sh scripts/deploy/vercel.sh
4438

4539
env-decrypt:
4640
sh scripts/env/decrypt.sh
4741

4842
env-encrypt:
4943
sh scripts/env/encrypt.sh
5044

45+
env-validate:
46+
sh scripts/env/validate.sh "$(ENV)"
47+
5148
# --- Frontend
5249

5350
frontend-dev:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"dependencies": {
99
"@dotenvx/dotenvx": "^1.44.1",
10+
"chalk": "^5.4.1",
1011
"husky": "^9.1.7",
1112
"semver": "^7.7.2",
1213
"vercel": "^42.1.1"

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/deploy/vercel.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cd frontend && make build
2+
cd ../
3+
node scripts/deploy/vercel-pre.mjs
4+
vercel build
5+
vercel .
6+
node scripts/deploy/vercel-post.mjs

scripts/env/validate.mjs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
/* eslint-disable */
1+
import chalk from "chalk";
2+
3+
const red = chalk.redBright;
4+
const green = chalk.greenBright;
5+
const bold = chalk.bold;
6+
7+
console.log(chalk.greenBright(bold(`\nValidating environment variables`)));
8+
29
const REQUIRED_CLIENT_ENVIRONMENT = [];
310

411
// prettier-ignore
@@ -14,9 +21,6 @@ const REQUIRED_SERVER_ENVIRONMENT = [
1421
// REQUIRED_SERVER_ENVIRONMENT.push("SENTRY_TOKEN");
1522
// }
1623

17-
const red = "\u001b[31m";
18-
const resetColor = "\u001b[0m";
19-
2024
const getInvalids = (envs) =>
2125
envs.reduce(
2226
(invalids, env) => (process.env[env] ? invalids : [...invalids, env]),
@@ -30,25 +34,31 @@ const isServerEnvValid = getInvalids(REQUIRED_SERVER_ENVIRONMENT).length === 0;
3034
const isClientEnvValid = getInvalids(REQUIRED_CLIENT_ENVIRONMENT).length === 0;
3135

3236
if (isServerEnvValid && isClientEnvValid) {
33-
console.log("Environment validation succeded!");
37+
console.log(bold(green(`\nEnvironment validation succeded!\n`)));
3438
process.exit(0);
3539
}
40+
3641
const invalids = [
3742
...getInvalids(REQUIRED_SERVER_ENVIRONMENT),
3843
...getInvalids(REQUIRED_CLIENT_ENVIRONMENT),
3944
];
4045

46+
console.log(
47+
chalk.redBright(
48+
bold(
49+
`\nFound ${invalids.length} missing ${invalids.length > 1 ? "variables" : "variable"}.\n`,
50+
),
51+
),
52+
);
53+
4154
invalids.forEach((env) => {
4255
const type = REQUIRED_SERVER_ENVIRONMENT.includes(env) ? "server" : "client";
4356
console.error(
44-
`${red}Missing ${type} variable:${resetColor} ${env}${resetColor} is ${getErrorType(env)}!`,
57+
chalk.grey(
58+
`Missing ${type} variable: ${chalk.bold(chalk.blue(env))} is ${getErrorType(env)}!)`,
59+
),
4560
);
4661
});
4762

48-
console.log(
49-
`\nFound ${invalids.length} missing ${invalids.length > 1 ? "variables" : "variable"}.\n`,
50-
);
51-
52-
console.log("Environment validation failed!");
63+
console.log(red.bold(`\nEnvironment validation failed!\n`));
5364
process.exit(13);
54-
/* eslint-enable */

scripts/env/validate.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NO_FORMAT="\033[0m"
2+
F_BOLD="\033[1m"
3+
F_DIM="\033[2m"
4+
C_INDIANRED1="\033[38;5;203m"
5+
C_SEAGREEN2="\033[38;5;83m"
6+
C_GREY46="\033[38;5;243m"
7+
C_GREY62="\033[38;5;247m"
8+
9+
if [ -z "$1" ]; then
10+
echo "${C_INDIANRED1}No environment provided!${NO_FORMAT}"
11+
exit 1
12+
else
13+
ENVIRONMENT=$1
14+
fi
15+
16+
dotenvx run -f ".env.${ENVIRONMENT}" -- node scripts/env/validate.mjs

scripts/package/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
NO_FORMAT="\033[0m"
2+
F_BOLD="\033[1m"
3+
F_DIM="\033[2m"
4+
C_INDIANRED1="\033[38;5;203m"
5+
C_SEAGREEN2="\033[38;5;83m"
6+
C_GREY46="\033[38;5;243m"
7+
C_GREY62="\033[38;5;247m"
8+
9+
echo "\n${F_BOLD}Build packages${NO_FORMAT}${C_GREY46}\n"
10+
cd frontend && make build
11+
cd ../http && make build
12+
echo "${NO_FORMAT}"

scripts/package/bump.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ C_SEAGREEN2="\033[38;5;83m"
66
C_GREY46="\033[38;5;243m"
77
C_GREY62="\033[38;5;247m"
88

9-
echo "${F_BOLD}Update package versions.${NO_FORMAT}"
9+
echo "\n${F_BOLD}Update package versions.${NO_FORMAT}\n"
1010

1111
PROJECT=""
1212

@@ -19,7 +19,7 @@ fi
1919
make info
2020

2121
if ! git diff-index --quiet HEAD -- || [ -n "$(git ls-files --others --exclude-standard)" ]; then
22-
echo "${F_BOLD}${C_INDIANRED1}Working directory is not clean. Commit or stash your changes first.${NO_FORMAT}"
22+
echo "${F_BOLD}${C_INDIANRED1}Working directory is not clean. Commit or stash your changes first.${NO_FORMAT}\n"
2323
exit 1
2424
else
2525
echo "${C_GREY46}INFO\tWorking directory is clean."

scripts/package/info.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ else
1414
PROJECT=$1
1515
fi
1616

17-
echo "${F_BOLD}Cluster info for '${PROJECT}-local'${NO_FORMAT}"
17+
echo "\n${F_BOLD}Cluster info for '${PROJECT}-local'${NO_FORMAT}"
1818
echo "${C_GREY46}"
1919
echo "Change project: make bump PROJECT=my-project${NO_FORMAT}"
2020
echo "${F_DIM}"

0 commit comments

Comments
 (0)