Skip to content

Commit b6b19d0

Browse files
Merge branch 'main' into typescript-setup
2 parents 773754e + 3718943 commit b6b19d0

92 files changed

Lines changed: 2710 additions & 1266 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"parser": "@babel/eslint-parser",
2+
"parser": "@typescript-eslint/parser",
33
"env": {
44
"node": true,
55
"browser": true,
@@ -9,13 +9,23 @@
99
},
1010
"extends": [
1111
"eslint:recommended",
12+
"plugin:@typescript-eslint/recommended",
1213
"plugin:react/recommended",
1314
"google",
1415
"prettier",
1516
"plugin:json/recommended"
1617
],
17-
"overrides": [],
18+
"overrides": [
19+
{
20+
"files": ["test/**/*.js", "**/*.json"],
21+
"parser": "espree",
22+
"rules": {
23+
"@typescript-eslint/no-unused-expressions": "off"
24+
}
25+
}
26+
],
1827
"parserOptions": {
28+
"project": "./tsconfig.json",
1929
"requireConfigFile": false,
2030
"ecmaVersion": 12,
2131
"sourceType": "module",
@@ -27,11 +37,15 @@
2737
"presets": ["@babel/preset-react"]
2838
}
2939
},
30-
"plugins": ["react", "prettier"],
40+
"plugins": ["@typescript-eslint", "react", "prettier"],
3141
"rules": {
3242
"react/prop-types": "off",
3343
"require-jsdoc": "off",
34-
"no-async-promise-executor": "off"
44+
"no-async-promise-executor": "off",
45+
"@typescript-eslint/no-explicit-any": "warn", // temporary until TS refactor is complete
46+
"@typescript-eslint/no-unused-vars": "off", // temporary until TS refactor is complete
47+
"@typescript-eslint/no-require-imports": "off", // prevents error on old "require" imports
48+
"@typescript-eslint/no-unused-expressions": "off" // prevents error on test "expect" expressions
3549
},
3650
"settings": {
3751
"react": {

.github/workflows/unused-dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
node-version: '18.x'
2222
- name: 'Run depcheck'
2323
run: |
24-
npx depcheck --skip-missing --ignores="tsx,@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,concurrently,nyc,prettier,typescript,vite-tsconfig-paths"
24+
npx depcheck --skip-missing --ignores="tsx,@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,ts-mocha,ts-node,concurrently,nyc,prettier,typescript,tsconfig-paths,vite-tsconfig-paths"
2525
echo $?
2626
if [[ $? == 1 ]]; then
2727
echo "Unused dependencies or devDependencies found"

config.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@
7878
"type": "object"
7979
}
8080
}
81+
},
82+
"tls": {
83+
"description": "TLS configuration for secure connections",
84+
"type": "object",
85+
"properties": {
86+
"enabled": { "type": "boolean" },
87+
"key": { "type": "string" },
88+
"cert": { "type": "string" }
89+
},
90+
"required": ["enabled", "key", "cert"]
8191
}
8292
},
8393
"definitions": {

cypress/e2e/autoApproved.cy.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import moment from 'moment';
2+
3+
describe('Auto-Approved Push Test', () => {
4+
beforeEach(() => {
5+
cy.intercept('GET', '/api/v1/push/123', {
6+
statusCode: 200,
7+
body: {
8+
steps: [
9+
{
10+
stepName: 'diff',
11+
content: '',
12+
},
13+
],
14+
error: false,
15+
allowPush: true,
16+
authorised: true,
17+
canceled: false,
18+
rejected: false,
19+
autoApproved: true,
20+
autoRejected: false,
21+
commitFrom: 'commitFrom',
22+
commitTo: 'commitTo',
23+
branch: 'refs/heads/main',
24+
user: 'testUser',
25+
id: 'commitFrom__commitTo',
26+
type: 'push',
27+
method: 'POST',
28+
timestamp: 1696161600000,
29+
project: 'testUser',
30+
repoName: 'test.git',
31+
url: 'https://github.com/testUser/test.git',
32+
repo: 'testUser/test.git',
33+
commitData: [
34+
{
35+
tree: '1234',
36+
parent: '12345',
37+
},
38+
],
39+
attestation: {
40+
timestamp: '2023-10-01T12:00:00Z',
41+
autoApproved: true,
42+
},
43+
},
44+
}).as('getPush');
45+
});
46+
47+
it('should display auto-approved message and verify tooltip contains the expected timestamp', () => {
48+
cy.visit('/admin/push/123');
49+
50+
cy.wait('@getPush');
51+
52+
cy.contains('Auto-approved by system').should('be.visible');
53+
54+
cy.get('svg.MuiSvgIcon-root')
55+
.filter((_, el) => getComputedStyle(el).fill === 'rgb(0, 128, 0)')
56+
.invoke('attr', 'style')
57+
.should('include', 'cursor: default')
58+
.and('include', 'opacity: 0.5');
59+
60+
const expectedTooltipTimestamp = moment('2023-10-01T12:00:00Z')
61+
.local()
62+
.format('dddd, MMMM Do YYYY, h:mm:ss a');
63+
64+
cy.get('kbd')
65+
.trigger('mouseover')
66+
.then(() => {
67+
cy.get('.MuiTooltip-tooltip').should('contain', expectedTooltipTimestamp);
68+
});
69+
70+
cy.contains('approved this contribution').should('not.exist');
71+
});
72+
});

index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import yargs from 'yargs';
44
import { hideBin } from 'yargs/helpers';
55
import * as fs from 'fs';
6-
import config from './src/config/file';
6+
import { configFile, setConfigFile, validate } from './src/config/file';
77
import proxy from './src/proxy';
88
import service from './src/service';
99

@@ -28,22 +28,22 @@ const argv = yargs(hideBin(process.argv))
2828
.strict()
2929
.parseSync();
3030

31-
config.configFile = argv.c ? argv.c : undefined;
31+
setConfigFile(argv.c as string || "");
3232

3333
if (argv.v) {
34-
if (!fs.existsSync(config.configFile as string)) {
34+
if (!fs.existsSync(configFile)) {
3535
console.error(
36-
`Config file ${config.configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
36+
`Config file ${configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
3737
);
3838
process.exit(1);
3939
}
4040

41-
config.validate();
42-
console.log(`${config.configFile} is valid`);
41+
validate();
42+
console.log(`${configFile} is valid`);
4343
process.exit(0);
4444
}
4545

46-
config.validate();
46+
validate();
4747

4848
proxy.start();
4949
service.start();

0 commit comments

Comments
 (0)