Skip to content

Commit 9ecbb44

Browse files
authored
feat: Add sentry
1 parent 972fb7f commit 9ecbb44

20 files changed

+1540
-276
lines changed

.env.production

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NEXT_PUBLIC_WIDGET_INTEGRATOR_BLOG=jumper.exchange.blog
1010
NEXT_PUBLIC_ARCX_API_KEY=77e1a62a0a564549bba4f546ee70b352f962f11a281d75ba35d194215499893a
1111
NEXT_PUBLIC_ADDRESSABLE_TID=0d48165d8b544e029b816f54c3371ae8
1212
NEXT_PUBLIC_CUSTOM_RPCS={ "1151111081099710": ["https://chaotic-restless-putty.solana-mainnet.quiknode.pro/"] }
13-
SENTRY_DSN=https://bc1312161bf948db9b9c82618035ec22@o1302189.ingest.sentry.io/6539228
13+
NEXT_PUBLIC_SENTRY_DSN=https://68d5c1e572fc61a9a6840dc57ae1fa1c@o4507344626647040.ingest.de.sentry.io/4507344891347024
1414
NEXT_PUBLIC_ONRAMPER_API_KEY=pk_prod_01GWH1ZXS9JS04JJQ5W4KWQBFF
1515
NEXT_PUBLIC_ONRAMPER_ENABLED=true
1616
NEXT_PUBLIC_STRAPI_URL=https://strapi.li.finance/api

.github/scripts/delete-feature.mjs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// @ts-check
22

3-
import { deleteFeatureTemplates, getEnvs, updateFeatureBranchList } from './utils.mjs'
3+
import {
4+
deleteFeatureTemplates,
5+
getEnvs,
6+
updateFeatureBranchList,
7+
} from './utils.mjs';
48

59
const init = async () => {
610
try {
7-
const [appName] = getEnvs('APP_NAME')
11+
const [appName] = getEnvs('APP_NAME');
812
// enter the deployment repo folder
9-
process.chdir('lifi-deployment')
10-
deleteFeatureTemplates(appName)
11-
updateFeatureBranchList(appName, true)
13+
process.chdir('lifi-deployment');
14+
deleteFeatureTemplates(appName);
15+
updateFeatureBranchList(appName, true);
1216
} catch (e) {
13-
console.error(e)
14-
process.exitCode = 1
17+
console.error(e);
18+
process.exitCode = 1;
1519
}
16-
}
20+
};
1721

18-
export default init
22+
export default init;

.github/scripts/dotenv-to-json.mjs

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
11
// @ts-check
22

3-
import { open } from 'node:fs/promises'
3+
import { open } from 'node:fs/promises';
44

5-
const envType = process.argv[2]
5+
const envType = process.argv[2];
66

7-
if (envType !=='local' && envType !== 'test') {
8-
console.error(`Wrong env type param: ${envType}`)
9-
process.exit(1)
7+
if (envType !== 'local' && envType !== 'test') {
8+
console.error(`Wrong env type param: ${envType}`);
9+
process.exit(1);
1010
}
1111

12-
const cfgPath = process.argv[3] ?? './config'
12+
const cfgPath = process.argv[3] ?? './config';
1313

14-
const startsAndEndsBy = c => s => s.startsWith(c) && s.endsWith(c)
14+
const startsAndEndsBy = (c) => (s) => s.startsWith(c) && s.endsWith(c);
1515

1616
const removeQuotes = (value) => {
17-
const enclosedInSingleQuotes = startsAndEndsBy(`'`)
18-
const enclosedInDoubleQuotes = startsAndEndsBy(`"`)
19-
const quoteEnclosed = enclosedInSingleQuotes(value) || enclosedInDoubleQuotes(value)
20-
return quoteEnclosed ? value.slice(1, -1) : value
21-
}
17+
const enclosedInSingleQuotes = startsAndEndsBy(`'`);
18+
const enclosedInDoubleQuotes = startsAndEndsBy(`"`);
19+
const quoteEnclosed =
20+
enclosedInSingleQuotes(value) || enclosedInDoubleQuotes(value);
21+
return quoteEnclosed ? value.slice(1, -1) : value;
22+
};
2223

2324
async function getJsonString() {
24-
const file = await open(`${cfgPath}/.env.${envType}`)
25-
const obj = {}
25+
const file = await open(`${cfgPath}/.env.${envType}`);
26+
const obj = {};
2627
for await (const line of file.readLines()) {
2728
if (line.length && !line.startsWith('#')) {
28-
const i = line.indexOf('=')
29+
const i = line.indexOf('=');
2930
if (i) {
30-
const key = line.substring(0, i)
31-
const value = line.substring(i + 1)
31+
const key = line.substring(0, i);
32+
const value = line.substring(i + 1);
3233
// remove quotes at the end/start if needed
33-
obj[key] = removeQuotes(value.trim())
34+
obj[key] = removeQuotes(value.trim());
3435
}
3536
}
3637
}
37-
return JSON.stringify(obj)
38+
return JSON.stringify(obj);
3839
}
3940

4041
// print to stdout
41-
getJsonString().then(str => console.log(str))
42+
getJsonString().then((str) => console.log(str));

.github/scripts/update-feature-img-version.mjs

+19-19
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import {
55
getDeploymentTemplates,
66
updateFeatureBranchList,
77
updateDeploymentTemplate,
8-
getValueFilesPath
9-
} from './utils.mjs'
8+
getValueFilesPath,
9+
} from './utils.mjs';
1010

1111
const init = async () => {
1212
try {
1313
// get the required envs
14-
const [appName, dockerTag] = getEnvs('APP_NAME', 'DOCKER_TAG')
14+
const [appName, dockerTag] = getEnvs('APP_NAME', 'DOCKER_TAG');
1515
// enter the deployment repo folder
16-
process.chdir('lifi-deployment')
16+
process.chdir('lifi-deployment');
1717
// update/create the value file
18-
let endpoints = ""
18+
let endpoints = '';
1919
try {
2020
// update the app template
21-
const list = getDeploymentTemplates(appName)
21+
const list = getDeploymentTemplates(appName);
2222
for (const { valueFile, template } of list) {
23-
template.image.tag = dockerTag
24-
updateDeploymentTemplate({ valueFile, template })
23+
template.image.tag = dockerTag;
24+
updateDeploymentTemplate({ valueFile, template });
2525
}
2626
} catch {
2727
// value file does not exist yet, we need to create it
@@ -33,23 +33,23 @@ const init = async () => {
3333
hosts: [
3434
{
3535
host: endpoint,
36-
paths: [{ path: '/', pathType: 'Prefix' }]
36+
paths: [{ path: '/', pathType: 'Prefix' }],
3737
},
3838
],
3939
},
40-
}
41-
const valueFiles = getValueFilesPath(appName)
40+
};
41+
const valueFiles = getValueFilesPath(appName);
4242
for (const valueFile of valueFiles) {
43-
updateDeploymentTemplate({ valueFile, template: newTemplate })
43+
updateDeploymentTemplate({ valueFile, template: newTemplate });
4444
}
45-
endpoints = `https://${endpoint}`
45+
endpoints = `https://${endpoint}`;
4646
}
47-
updateFeatureBranchList(appName)
48-
return endpoints
47+
updateFeatureBranchList(appName);
48+
return endpoints;
4949
} catch (e) {
50-
console.error(`::error::${e}`)
51-
process.exitCode = 1
50+
console.error(`::error::${e}`);
51+
process.exitCode = 1;
5252
}
53-
}
53+
};
5454

55-
export default init
55+
export default init;

.github/scripts/utils.mjs

+71-62
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,150 @@
11
// @ts-check
22

3-
import { execSync } from 'child_process'
4-
import { existsSync, rmSync, openSync, writeSync, closeSync, readFileSync, writeFileSync, readdirSync } from 'fs'
3+
import { execSync } from 'child_process';
4+
import {
5+
existsSync,
6+
rmSync,
7+
openSync,
8+
writeSync,
9+
closeSync,
10+
readFileSync,
11+
writeFileSync,
12+
readdirSync,
13+
} from 'fs';
514
// @ts-ignore
6-
import YAML from 'yaml'
15+
import YAML from 'yaml';
716

817
// get the list of env variable values
918
export const getEnvs = (...envs) => {
1019
if (envs?.length) {
11-
return envs.map(name => {
12-
const value = process.env[name]
20+
return envs.map((name) => {
21+
const value = process.env[name];
1322
if (!value) {
14-
throw new Error(`Env variable ${name} is required.`)
23+
throw new Error(`Env variable ${name} is required.`);
1524
}
16-
return value
17-
})
25+
return value;
26+
});
1827
} else {
19-
throw new Error(`Missing env variable list.`)
28+
throw new Error(`Missing env variable list.`);
2029
}
21-
}
30+
};
2231

23-
const isFeatureBranch = (name) => name.startsWith('feat-')
32+
const isFeatureBranch = (name) => name.startsWith('feat-');
2433

2534
// get feature branch template (value file) path
2635
export const getValueFilesPath = (name) => {
2736
if (!name) {
28-
throw new Error(`Missing app name.`)
37+
throw new Error(`Missing app name.`);
2938
}
30-
const basePath = 'charts/jumper-exchange'
31-
const files = readdirSync(basePath)
32-
const valueFiles = files.filter(f => f.startsWith(`values-${name}`))
39+
const basePath = 'charts/jumper-exchange';
40+
const files = readdirSync(basePath);
41+
const valueFiles = files.filter((f) => f.startsWith(`values-${name}`));
3342
if (!valueFiles.length) {
3443
// we do not throw an error since if a feature branch value file
3544
// does not exists, we want to create it instead (first deploy)
3645
if (isFeatureBranch(name)) {
37-
return [`${basePath}/values-${name}.yaml`]
46+
return [`${basePath}/values-${name}.yaml`];
3847
}
39-
throw new Error(`Cannot find value file for ${name}.`)
48+
throw new Error(`Cannot find value file for ${name}.`);
4049
}
41-
return valueFiles.map(v => `${basePath}/${v}`)
42-
}
50+
return valueFiles.map((v) => `${basePath}/${v}`);
51+
};
4352

4453
// get a deployment template (value file)
4554
export const getDeploymentTemplates = (appName) => {
46-
const valueFiles = getValueFilesPath(appName)
47-
const templates = []
55+
const valueFiles = getValueFilesPath(appName);
56+
const templates = [];
4857
for (const valueFile of valueFiles) {
4958
if (existsSync(valueFile)) {
50-
const file = readFileSync(valueFile, 'utf8')
51-
templates.push({ valueFile, template: YAML.parse(file) })
59+
const file = readFileSync(valueFile, 'utf8');
60+
templates.push({ valueFile, template: YAML.parse(file) });
5261
} else {
53-
throw new Error(`Missing ${valueFile} file.`)
62+
throw new Error(`Missing ${valueFile} file.`);
5463
}
5564
}
56-
return templates
57-
}
65+
return templates;
66+
};
5867

5968
// update a deployment template (value file)
6069
export const updateDeploymentTemplate = ({ valueFile, template }) => {
6170
if (template) {
6271
if (template?.feature?.version) {
63-
template.feature.version += 1
72+
template.feature.version += 1;
6473
}
65-
const file = openSync(valueFile, 'w') // w: write and create if does not exist
66-
const yamlData = YAML.stringify(template)
74+
const file = openSync(valueFile, 'w'); // w: write and create if does not exist
75+
const yamlData = YAML.stringify(template);
6776
if (yamlData.length) {
68-
writeSync(file, yamlData)
69-
closeSync(file)
77+
writeSync(file, yamlData);
78+
closeSync(file);
7079
} else {
71-
closeSync(file)
72-
throw new Error(`Yaml data shouldn't be empty.`)
80+
closeSync(file);
81+
throw new Error(`Yaml data shouldn't be empty.`);
7382
}
74-
execSync(`git add ${valueFile}`, { shell: '/bin/bash' })
83+
execSync(`git add ${valueFile}`, { shell: '/bin/bash' });
7584
} else {
76-
throw new Error(`The template shouldn't be empty.`)
85+
throw new Error(`The template shouldn't be empty.`);
7786
}
78-
}
87+
};
7988

8089
// delete the feature branch template (value file)
8190
// do not throw an error if missing (already deleted)
8291
export const deleteFeatureTemplates = (appName) => {
83-
const valueFiles = getValueFilesPath(appName)
92+
const valueFiles = getValueFilesPath(appName);
8493
for (const valueFile of valueFiles) {
8594
if (existsSync(valueFile)) {
86-
rmSync(valueFile, { force: true })
87-
execSync(`git add ${valueFile}`, { shell: '/bin/bash' })
95+
rmSync(valueFile, { force: true });
96+
execSync(`git add ${valueFile}`, { shell: '/bin/bash' });
8897
}
8998
}
90-
}
99+
};
91100

92101
// get the app list in the apps/value.yaml file of the deployment repo
93102
export const getFeatureBranchList = () => {
94-
const file = readFileSync('apps/values.yaml', 'utf8')
95-
const valueFile = YAML.parse(file)
103+
const file = readFileSync('apps/values.yaml', 'utf8');
104+
const valueFile = YAML.parse(file);
96105
if (valueFile?.featureBranchesJumper) {
97-
return valueFile.featureBranchesJumper
106+
return valueFile.featureBranchesJumper;
98107
} else {
99-
throw new Error('Missing feature branch list in apps/values.yaml')
108+
throw new Error('Missing feature branch list in apps/values.yaml');
100109
}
101-
}
110+
};
102111

103112
// replace the app list in the apps/value.yaml file of the deployment repo
104113
const saveFeatureBranchList = (newList) => {
105114
if (!newList) {
106-
throw new Error(`App list must be an array.`)
115+
throw new Error(`App list must be an array.`);
107116
}
108-
const valueFile = YAML.parse(readFileSync('apps/values.yaml', 'utf8'))
117+
const valueFile = YAML.parse(readFileSync('apps/values.yaml', 'utf8'));
109118
if (valueFile?.featureBranchesJumper) {
110-
valueFile.featureBranchesJumper = newList
111-
writeFileSync('apps/values.yaml', YAML.stringify(valueFile))
119+
valueFile.featureBranchesJumper = newList;
120+
writeFileSync('apps/values.yaml', YAML.stringify(valueFile));
112121
} else {
113-
throw new Error(`Yaml data shouldn't be empty.`)
122+
throw new Error(`Yaml data shouldn't be empty.`);
114123
}
115-
execSync(`git add apps/values.yaml`, { shell: '/bin/bash' })
116-
}
124+
execSync(`git add apps/values.yaml`, { shell: '/bin/bash' });
125+
};
117126

118127
// update the app list in the apps/value.yaml file of the deployment repo
119128
export const updateFeatureBranchList = (appName, remove = false) => {
120129
if (!appName) {
121-
throw new Error(`Missing feature branch name.`)
130+
throw new Error(`Missing feature branch name.`);
122131
}
123132
// get the list and add or remove the new app
124-
const list = getFeatureBranchList()
125-
const index = list.findIndex(a => a === appName)
133+
const list = getFeatureBranchList();
134+
const index = list.findIndex((a) => a === appName);
126135
if (remove) {
127136
if (index > -1) {
128-
list.splice(index, 1)
129-
saveFeatureBranchList(list)
137+
list.splice(index, 1);
138+
saveFeatureBranchList(list);
130139
} else {
131-
console.warn(`${appName} does not exist in app list.`)
140+
console.warn(`${appName} does not exist in app list.`);
132141
}
133142
} else {
134143
if (list.indexOf(appName) === -1) {
135-
list.push(appName)
136-
saveFeatureBranchList(list)
144+
list.push(appName);
145+
saveFeatureBranchList(list);
137146
} else {
138-
console.warn(`${appName} is already in app list.`)
147+
console.warn(`${appName} is already in app list.`);
139148
}
140149
}
141-
}
150+
};

0 commit comments

Comments
 (0)