Skip to content

Commit 38791bd

Browse files
authored
Merge pull request #960 from jescalada/refactor-proxy-module-ts-and-esm
refactor(ts): refactor `proxy` to TS
2 parents 9046dd4 + 5f3de0a commit 38791bd

Some content is hidden

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

79 files changed

+2838
-1301
lines changed

.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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: 'Unused Dependencies'
22
on: [pull_request]
33

4-
permissions:
5-
contents: read
4+
permissions:
5+
contents: read
66

77
jobs:
88
unused-dependecies:
@@ -20,11 +20,10 @@ jobs:
2020
with:
2121
node-version: '18.x'
2222
- name: 'Run depcheck'
23-
run: |
24-
npx depcheck --skip-missing --ignores="@babel/*,@commitlint/*,eslint,eslint-*,husky,mocha,concurrently,nyc,prettier"
23+
run: |
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"
2828
exit 1
2929
fi
30-

index.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env tsx
2+
/* eslint-disable max-len */
3+
import yargs from 'yargs';
4+
import { hideBin } from 'yargs/helpers';
5+
import * as fs from 'fs';
6+
import { configFile, setConfigFile, validate } from './src/config/file';
7+
import proxy from './src/proxy';
8+
import service from './src/service';
9+
10+
const argv = yargs(hideBin(process.argv))
11+
.usage('Usage: $0 [options]')
12+
.options({
13+
validate: {
14+
description:
15+
'Check the proxy.config.json file in the current working directory for validation errors.',
16+
required: false,
17+
alias: 'v',
18+
type: 'boolean',
19+
},
20+
config: {
21+
description: 'Path to custom git-proxy configuration file.',
22+
default: 'proxy.config.json',
23+
required: false,
24+
alias: 'c',
25+
type: 'string',
26+
},
27+
})
28+
.strict()
29+
.parseSync();
30+
31+
setConfigFile(argv.c as string || "");
32+
33+
if (argv.v) {
34+
if (!fs.existsSync(configFile)) {
35+
console.error(
36+
`Config file ${configFile} doesn't exist, nothing to validate! Did you forget -c/--config?`,
37+
);
38+
process.exit(1);
39+
}
40+
41+
validate();
42+
console.log(`${configFile} is valid`);
43+
process.exit(0);
44+
}
45+
46+
validate();
47+
48+
proxy.start();
49+
service.start();
50+
51+
export { proxy, service };

0 commit comments

Comments
 (0)